(function($){
	$.fn.switcher = function(settings) {
		var defaults = { // defaults
			'fadeOut' : 1000,
			'time' : 4000,
			'firstClass' : 'start'
		};
	
		return this.each(function() {        
			if(settings){ // if custom settings passed
				$.extend(defaults, settings); // extend defaults with passed ones
			}
			
			var $i = $(this),
				current,
				childs = $i.children().length;
			$i.delegate('.' + defaults.firstClass, 'dblclick', function(e){
				e.preventDefault();
				current = $i.children().index(this);
				var _delay = $(this).attr('name') > 0 ? (parseInt($(this).attr('name')) * 1000) : defaults.time;
				$(this).delay(_delay).fadeOut(defaults.fadeOut, function(){
					if((current + 1) < childs){
						$(this).removeClass(defaults.firstClass).next().addClass(defaults.firstClass).fadeIn('slow').trigger('dblclick');
					}else{
						$(this).removeClass(defaults.firstClass);
						$i.children(':first').addClass(defaults.firstClass).fadeIn('slow').trigger('dblclick');
					}
				});
			});
			$i.children(':not(.' + defaults.firstClass + ')').hide();
			$i.children('.' + defaults.firstClass).trigger('dblclick');
		});		
	};
})(jQuery);
