$(document).ready(function(){
	jQuery.extend(jQuery.easing,
	{
	  easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d) + b;
	  }
	});
	var i=1;
    function loop_slide(){
		var showId = $("#keyvisual").find(".show").attr("id");			
		if(!showId){
			var showId = "block1";
		}else{
			var showId = $("#keyvisual").find(".show").attr("id");			
		}
		if(i >=4){
			i = 1;			
		}else{
			i++;
		}
		var animateIndex = i;

		index = $("#keyvisual").find("#block"+animateIndex+".show").size();
		if(index>0)return;
		
		getVisible(animateIndex);
		getUnvisible(showId);		
	}

	var time=5000;
	$(document).everyTime(time,'timer_loop',loop_slide);	
	 
//	$(".animate").click(function(){
//		var animateIndex = $(this).index()+1;
//		var showId = $("#keyvisual").find(".show").attr("id");	
//		index = $("#keyvisual").find("#block"+animateIndex+".show").size();
//		
//		//Timerを停止する
//		$(document).stopTime('timer_loop');	
//		
//		if(index>0)return;
//		
//		//該当画像の表示
//		getVisible(animateIndex);
//		//対象画像の非表示
//		getUnvisible(showId);
//
//		//表示スライド開始の調整
//		i = animateIndex;
//		$(document).everyTime(time,'timer_loop',loop_slide);
//
//	});
	
	function getVisible(animateIndex){
		block = "#block"+animateIndex+".hidden";
		$(block).animate(
		{width:"toggle",opacity: "toggle"},
		time/6, "easeInQuart"
	  ).removeClass("hidden").addClass("show");
	};
	
	function getUnvisible(showId){
		block = "#"+showId+".show";
		$(block).animate(
		{opacity: "toggle"},
		time/6, "easeInQuart"
	  ).removeClass("show").addClass("hidden");
	};
	
});
