(function($){
	$.fn.pic_Auto=function(options){
		var defaults={
				imgArray:[
						  	{src:"images/01.jpg",url:"http://www.baidu.com",alt:"澳大利亚：体验蓝山风光，感受澳洲风情"}
							
						  ],
				playHeight:260,
				playWidth:500
					};//默认参数结束
		var options=$.extend(defaults,options);
		$(this).append("<div id='showx'></div><!--showx -->");
		$(this).append("<div id='textx'></div><!--showx -->");
		$(this).append("<div id='numx'></div><!--showx -->");
		$(this).append("<div id='bgx'></div><!--showx -->");
		
		if (options.playWidth!= 500||options.playHeight!= 260) {                
					  	$(this).css({"width": options.playWidth,"height": options.playHeight});
						$("#showx").css({"width" :options.playWidth , "height" : options.playHeight-"1" })
						$("#bgx").css({"width" :options.playWidth , "height" : 30 })
						//$(this).hide();
						}       
		
		var mypicArray=options.imgArray;
		var imgnum=mypicArray.length;
		//alert(mypicArray[0].src);
		for(i=1;i<=imgnum;i++)//for循环用来所有图片和导航数字
			{
				$("#showx").append("<a href='"+mypicArray[i-1].url+"' target='_blank'><img src='"+mypicArray[i-1].src+"' alt='"+mypicArray[i-1].alt+"'></a>");
				$('#numx').append("<a>"+i+"</a>");
			}
		var showx_in_imgnum=$("#showx a").length;//取得导航数字的个数
		//alert(showx_in_imgnum);
		$("#showx a:not(:first-child)").hide();//隐藏出去第一张的所有图片
		$("#textx").html($("#showx a:first-child").find("img").attr('alt'))//打印描述文字
		$("#numx a:first").addClass("on").siblings().addClass("nor");//给当前导航数字加样式
		$("#textx").click(function(){window.open($("#showx a:first-child").attr('href'), "_blank")});//单击描述文字可以打开链接
		$("#numx a").click(function () {//给导航数字加上单击事件，点击对应数字打开对应的图片
		   var i = parseInt($(this).text(),10) - 1;
		   n = i;
		   //if (i >= showx_in_imgnum) return;
		   $("#textx").html($("#showx a").eq(i).find("img").attr('alt'));
		   $("#textx").unbind().click(function(){window.open($("#showx a").eq(i).attr('href'), "_blank")})
		   $("#showx a").filter(":visible").hide().parent().children().eq(i).fadeIn(500);
		   $(this).attr("class","on").siblings().attr("class","nor");
		   
		});
		
		//$('#play').hover(function(){ clearInterval(qq)}, function(){qq=setInterval(autoshow, 4000);})//鼠标悬停在图片上时停止切换
		//$('#numx').hover(function(){ clearInterval(tt)}, function(){tt=setInterval(autoshow, 4000);})//鼠标悬停在图片上时停止切换
		
		function autoshow(){//自动切换函数
			if(parseInt($("#numx a.on").text(),10) == showx_in_imgnum ){
				$("#numx a").eq(0).trigger('click');
			} else {
				$("#numx a.on").next().trigger('click');
			}
		}
		
			
			$('.banner img.eq(0)').bind("load",function(){
				$("#play").show(100);
				var qq=setInterval(autoshow, 4000);
			$("#numx").hover(function(){ clearInterval(qq)}, function(){qq=setInterval(autoshow, 4000);})//鼠标悬停在图片上时停止切换
			$('#showx').hover(function(){ clearInterval(qq)}, function(){qq=setInterval(autoshow, 4000);})//鼠标悬停在图片上时停止切换
			});
			
		
		
		var tt=setInterval(autoshow, 4000);//几秒后循环执行函数，注意函数名称不能加引号，像这样setInterval(“autoshow（）”, 3000)
			
	}//自定义方法pic_Auto()结束
 })(jQuery);
