/*
 * gearTabset - jQuery Plugin
 * 
 * Examples and documentation at: http://www.aeden.it
 * 
 * Copyright (c) 2011 Aeden.it - Daniele Cerioni
 * 
 * Version: 1.0.0(14/04/2011)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function($){  
 $.fn.geartabset = function(options) {
	 var defaults = {  
			   transition:'fade',
			   inspeed:300,
			   outspeed:100,
			   selector:'<span class="selector"></span>',
			   initialtab:0
			  };
	 var options = $.extend(defaults, options);
	 return this.each(function() {  
    	var target=this;
    	$(target).find('.tab:eq('+options.initialtab+')').addClass('selected');
    	$(target).find('.tab-content').hide();
    	$(target).find('.tab-content:eq('+options.initialtab+')').show();
    	$(target).find('.tab a').click(function(){
    		if($(this).parent().hasClass('selected')){}else
    		{
    			$(target).find('.tab').removeClass('selected');
    			$(this).parent().addClass('selected');
    			switch(options.transition)
    	    	{
    	    		case 'fade':
    	    			$(target).find('.tab-content').fadeOut(options.outspeed);
    	    			$('#'+$(this).attr('tab')).delay(options.outspeed).fadeIn(options.inspeed);
    	    		break;   
    	    		case 'slide':
    	    			$(target).find('.tab-content').slideUp(options.outspeed);
    	    			$('#'+$(this).attr('tab')).delay(options.outspeed).slideDown(options.inspeed);
    	    		break;
    	    	}
    		}
    	});
    });  
 };  
})(jQuery);
