(function() {  
	jQuery.fn.rotation= function(config){
		config = jQuery.extend({
			id: null
			},config);
		var currentIndex = null;
		var ad;
	   	rotationInit();
		function adsInit(id) {
			// 最初のバナー以外を隠す
			ad = $(id + " > div");
			//$(id).css({position:"relative"});
			ad.css({position: "absolute" ,top:"0px",left:"0px"});
			var ad_length = ad.length;
			for (i=1; i<ad_length; i++) ad.eq(i).hide();
			currentIndex = 0;
			//$("img.photo_mini").eq(currentIndex).animate({opacity:"0.6"}, "slow");
			$("div.image_explain").eq(currentIndex).animate({top: "160"}, "slow");
			}
		adsInit(config.id);
		function rotationInit() {
			setInterval(rotation, 8000);
			}
		function rotation() {
			// 表示中の広告を隠す
			ad.eq(currentIndex).fadeOut('slow');
			$("div.image_explain").eq(currentIndex).animate({top:"320"}, "slow");
			currentIndex++;
			if (currentIndex >= ad.length) currentIndex = 0;
			// 次の広告を表示
			ad.eq(currentIndex).fadeIn('slow',
				function(){$("div.image_explain").eq(currentIndex).animate({top: "160"}, "slow");}
			);
			$("img.photo_mini").eq(currentIndex).animate({opacity:"1.0"}, "slow");
			}
		};
	})(jQuery);
