// JavaScript Document
(function(){
	$.fn.slide=function(options){
		var opt={currentimg:null,movetime:0,currentList:null,currentAList:null};
		$(this).each(function(){
			$(this).find("li").css("opacity","0").eq(0).css("opacity","1");
			opt.currentimg=$(this).find("li").eq(0);
			opt.currentList=$(this).find("li");
			opt.currentAList=$(this).children(".num").find("a");
			opt.currentAList.removeClass("active").eq(0).addClass("active");
			opt.movetime=setInterval(autoRun,4000);
			opt.currentAList.click(function(){
				if(opt.movetime)
					clearInterval(opt.movetime);
				$(this).addClass("active").siblings("active");
				opt.currentimg=opt.currentList.eq(opt.currentAList.index(this));
				showimg();
				opt.movetime=setInterval(autoRun,4000);
			});
		});
		function autoRun(){
			if(opt.currentimg.hasClass("last")){
				opt.currentimg=opt.currentList.eq(0);
			}
			else{
				opt.currentimg=opt.currentimg.next();
			}
			showimg();
		};
		function showimg(){
			opt.currentimg.animate({"opacity":1},2000).css("z-index",10).siblings().animate({"opacity":0},1500).css("z-index",1);
			opt.currentAList.eq(opt.currentList.index(opt.currentimg)).addClass("active").siblings().removeClass("active");
	}
	}
})(jQuery)
