(function($) {
	// スライドショー
	$.fn.slideshow = function(){
		var $this = this,
			$mains = $this.find(".main li"),
			i = 0,
			duration = 1200,
			timerId,
			slideChange;
		
		slideChange = function(i){
			$mains.filter(function(index){ return index != i; }).fadeOut(duration).end()
				.eq(i).fadeIn(duration, function(){
					i = i === $mains.length - 1 ? 0 : i + 1;
					clearTimeout(timerId);
					timerId = setTimeout(function(){ slideChange(i) }, duration * 2);
				});
		};
		
		slideChange(0);
	};
})(jQuery);
