$(function(){
	
	var counter = -1;
	var photoLeng = $(".slide li").length;
	
	//最初以外は全部けしてみよう
	$(".slide li:not(:last)").css({"display":"none"});
	
	//タイマーセット
	var time = setInterval(timerHandler,5000);
	
	function timerHandler()
	{
		counter++;
		//写真の切り替え
		var num = counter % photoLeng;
		var nextPhoto = $(".slide li:eq(" + num + ")");
		nextPhoto.fadeIn(1000,resetDisplay);
		var indexNum = Number(nextPhoto.css("z-index")) + (counter + 1);
		nextPhoto.css({"z-index":indexNum});
		
	};
	
	//フェイドイン終了後表示されているもの以外
	function resetDisplay(e)
	{
		var num = counter % photoLeng;
		var nowPhoto = $(".slide li:eq(" + num + ")");
		
		$(".slide li").each(function(e)
		{
			if(e != num)
			{
				$(this).css("display","none");
			}
		});
	};
})


