(function($){  
     $.fn.extend({  
         my_tabs: function(options) {       
            $.fn.my_tabs.defaults = {
					tabheader_selector:	'ul.tabs > li > a',
					details_selector:	'.tabcontents > .tab'
			};
			
			// build main options before element iteration
			var opts = $.extend({}, $.fn.my_tabs.defaults, options);
			
			return this.each(function() {
				
				var $base_container = $(this);
				
				$base_container.find('hr.hide').hide();
				
				$.each($(this).find(opts.tabheader_selector), 
					function(i, val){
						if (i == 0) {
							var pos = $(this).attr('href');
							pos = pos.substr(1);
							showItemByPos(pos);
						}
						$(this).click(function(e){
							var pos = $(this).attr('href');
							pos = pos.substr(1);
							showItemByPos(pos);
							return false;
						});
				});
				
				function showItemByPos(pos){
					$base_container.find(opts.tabheader_selector).parent().removeClass('active');	
					$base_container.find(opts.tabheader_selector+"[href='#"+pos+"']").parent().addClass('active');	
					
					$base_container.find(opts.details_selector).hide();	
					$base_container.find(opts.details_selector+"#"+pos).show();	
				}
				

            });
        } 
    }); 
 })(jQuery); 


