//bannerĒŠ»»
$(document).ready(function() {
	 var index = 0;
	 var button=-1;
	 var len  = $(".num > li").length;
	 $('#p0').animate({"top": "0px"}, 400, "swing");
$(function(){
	 var adTimer;
	 $(".num li").click(function(){
	 		if(button > -1){button=index};
			index = $(".num li").index(this);
			if (index > button) {animatetop(index,button)};
			if (index < button) {animatebottom(index,button)};
			button=index;
	 }).eq(0).mouseover();	
	 $('.ad').hover(
	 	function(){clearInterval(adTimer);}, 
		function(){			
		adTimer = setInterval(function(){
				button=index;
				index++;
				if(index==len){index=0;}
				if (index > button) {animatetop(index,button)};
				if (index < button) {animatebottom(index,button)};
			  } , 4000);
	 						}
	 	).trigger("mouseleave");
})
$("#next").click(function() {
		button = index;
		index++
	if (index == len ) {index = 0}
	//alert("current")
	//alert(button)
animatetop(index,button)
});
$("#prev").click(function() {
		button = index;
		index--
	if (index ==-1 ) {index = (len-1)}
//	alert(current)
	//alert(button)	
animatebottom(index,button)
});
function animatetop(index,button) {
	$('#p'+index).animate({"top": "0px"}, 400, "swing");
	$('#p'+button).animate({"top":"+680px"}, 400, "swing");
	$(".num li").removeClass("on")
	.eq(index).addClass("on");
	
}
function animatebottom(index,button) {
	$('#p'+index).animate({"top": "0px"}, 400, "swing");
	$('#p'+button).animate({"top": "-680px"}, 400, "swing");
	$(".num li").removeClass("on")
	.eq(index).addClass("on");
}	
					
});
