$(function(){
	var timer;
	var i = -1;
	var speed = 5000;//停留秒數
	var myItembox = $("#kv-bottom ul li a");

	$("#showinfo").html($("#ItemBox ul li a").attr("rel"));
	
	myItembox.hover(function(){		
		var imgfile=$(this).attr("data");
		var imginfo=$(this).attr("rel");
		$("#showimg").attr("src",imgfile);
		$("#showinfo").html(imginfo);
		i = myItembox.index($(this));
		
		$("#kv-bottom ul li").removeClass("on");//remove		
		$(this).parent().addClass("on");//add		
		
		return false;	
	}).hover(function(){//滑入時停止輪播
		clearTimeout(timer);
	}, function(){
		timer = setTimeout(autoShow, speed);
	});

	//滑入時停止輪播
	$("#kv-bottom").hover(function(){
		clearTimeout(timer);
	}, function(){
		timer = setTimeout(autoShow, speed);
	});
	
	//自動輪播函數
	function autoShow(){

		if(i+1<myItembox.length){
			i++;
		}else{
			i=0;
		}
		myItembox.eq(i).click();
		myItembox.removeClass("on");
		myItembox.eq(i).parent().addClass("on");
		timer = setTimeout(autoShow, speed);
	}
	//啟動自動輪播
	autoShow();
});

