﻿jQuery.fn.loadthumb = function(options) {
	options = $.extend({
		 src : ""
	},options);
	var _self = this;
	_self.hide();
	var img = new Image();
	$(img).load(function(){
		_self.attr("src", options.src);
		_self.fadeIn(1000);
	}).attr("src", options.src);  //.atte("src",options.src)
	return _self;
}

$(document).ready(function(){
	 var len  = $(".num > li").length;
	 var index = 0;
	 var adTimer;
	 $(".num li").mouseover(function(){
		index  =   $(".num li").index(this);
		showImg(index);
	 }).eq(0).mouseover();	
	 //增加鼠标样式
	 $('.ad').hover(function(){
			 clearInterval(adTimer);
		 },function(){
			 adTimer = setInterval(function(){
			    index++;
				if(index==len){index=0;}
				showImg(index);				
			  } , 5000);
	 }).trigger("mouseleave");
});

function showImg(index){
		//设置图片个数与链接地址
		//var src = ["/newLinkedWeb/global/images/og1.jpg","/newLinkedWeb/global/images/og2.jpg","/newLinkedWeb/global/images/og3.jpg"];
		var src = ["/newLinkedWeb/global/images/og1.jpg","/newLinkedWeb/global/images/og3.jpg"];
		//依次加载图片
		$(".ad img").loadthumb({src:  src[index] });
		$(".num li").removeClass("on")
			.eq(index).addClass("on");
}
	

