//幻灯图片索引和数量
var index = 0;
var len = $("#slider li").length;
var sliderTime = 4000;

//切换图片的方法
function showImg(i) {
	$("#slider li").eq(i).fadeIn("normal").siblings().css("display", "none");
	$("#num li").eq(i).css("background-color", "#839B1B").css("color",
			"#FFFFFF").siblings().css("background-color", "#FFFFFF").css(
			"color", "#839B1B");

}

//显示第一个图片
showImg(index);
index++;

//开始自动播放
var myTime = setInterval(function() {
	showImg(index);
	index++;
	if (index == len) {
		index = 0;
	}
}, sliderTime);

//鼠标移上数字框 
$("#num li").mouseover(function() {
	index = $("#num li").index(this);
	showImg(index);
});

//鼠标移上幻灯片停止播放
$('#ad').hover(function() {
	if (myTime) {
		clearInterval(myTime);
	}
}, function() {
	myTime = setInterval(function() {
		showImg(index);
		index++;
		if (index == len) {
			index = 0;
		}
	}, sliderTime);
});
