﻿// JavaScript Document
$(document).ready(function(){
	 var nowindex=0;//当前
	 var nowindex1=1;
	 var flashfile=new Array();
	 flashfile[0]='<center style="display:none"><embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="swf/hswfyq.swf" width="969" height="438" align="middle" type="application/x-shockwave-flash" wmode="transparent" quality="high"></embed></center>';
	 flashfile[1]='<center style="display:none"><embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="swf/hswf1.swf" width="969" height="438" align="middle" type="application/x-shockwave-flash" wmode="transparent" quality="high"></embed></center>';
	 flashfile[2]='<center style="display:none"><embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="swf/hswf2.swf" width="969" height="438" align="middle" type="application/x-shockwave-flash" wmode="transparent" quality="high"></embed></center>';
	 flashfile[3]='<center style="display:none"><embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="swf/hswf3.swf" width="969" height="438" align="middle" type="application/x-shockwave-flash" wmode="transparent" quality="high"></embed></center>';
	 flashfile[4]='<center style="display:none"><embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="swf/dianyan.swf" width="969" height="438" align="middle" type="application/x-shockwave-flash" wmode="transparent" quality="high"></embed></center>';
	 
	 var autoTopTimer=6000;//定时间隔
	 
	 $("#topimgbox li").eq(0).animate({opacity:"1"},0);//初始化显示
	 $("#topimgbox li").eq(0).siblings().animate({opacity:"0.5"},0);//初始化显示  

		  $("#flashstop").mouseover(function(){try{clearInterval(ameth);}catch(err){}});
　　　　　　$("#flashstop").mouseout(function(){ameth=setInterval(setAutoTogImg,autoTopTimer)});
     var setAutoTogImg=function(){//定时器主体方法，用于自动选取篇幅/切换
	 var maxindex=$("#topimgbox li").size();
	 nowindex=nowindex1!=null&&nowindex!=0?nowindex1:nowindex;
	 nowindex1=null;
	 
	 nowindex++;
	  if(nowindex>=maxindex)
	 nowindex=0;
	 
	 $("#topimgbox li").eq(nowindex).animate({opacity:"1"},0);
	 $("#topimgbox li").eq(nowindex).siblings().animate({opacity:"0.5"},0);
	
	 $("#headermain").find("div.headswf").html(flashfile[nowindex]);
	 $("#headermain").find("div.headswf center").fadeIn(100);     

	
	}
	
	var ameth=setInterval(setAutoTogImg,autoTopTimer);//初始化定时器
	$("#topimgbox li").mouseout(function(){try{ameth=setInterval(setAutoTogImg,autoTopTimer)}catch(err){}});
    $("#topimgbox li").mouseover(function(){//手动选取篇幅主题方法
					 clearInterval(ameth);					 
					 $(this).siblings().animate({opacity:"0.5"},0);	
					 $(this).animate({opacity:"1"},0);
					 if(nowindex==$("#topimgbox li").index(this)){return;}
                     nowindex= $("#topimgbox li").index(this);	
					 $("#headermain").find("div.headswf").html(flashfile[nowindex]);
					  $("#headermain").find("div.headswf center").fadeIn(100);
					 });
	 
	 
	 
	 /*上一幅*/
	$("li.hpre").click(
         function(){
			  var maxindex=$("#topimgbox li").size();
			  nowindex--;			 
			 nowindex=nowindex<0?maxindex-1:nowindex;
			 $("#topimgbox li").eq(nowindex).animate({opacity:"1"},0);
			 $("#topimgbox li").eq(nowindex).siblings().animate({opacity:"0.5"},0);	
			$("#headermain").find("div.headswf").html(flashfile[nowindex]);
			 $("#headermain").find("div.headswf center").fadeIn(100);
   		  
			
      });
	
	/*下一幅*/
	$("li.hnext").click(
			function(){
			 var maxindex=$("#topimgbox li").size();		
			  nowindex++;
			 nowindex=nowindex>=maxindex?0:nowindex;
			 $("#topimgbox li").eq(nowindex).animate({opacity:"1"},0);
			 $("#topimgbox li").eq(nowindex).siblings().animate({opacity:"0.5"},0);
			
$("#headermain").find("div.headswf").html(flashfile[nowindex]);
	 $("#headermain").find("div.headswf center").fadeIn(100);   
		});
	
	/*手动上一幅，下一幅的时候清空定时器*/
	$("li.hpre").mouseover(function(){ clearInterval(ameth);});
	$("li.hpre").mouseout(function(){ameth=setInterval(setAutoTogImg,autoTopTimer);});
	$("li.hnext").mouseover(function(){ clearInterval(ameth);});
	$("li.hnext").mouseout(function(){ameth=setInterval(setAutoTogImg,autoTopTimer);});
	
/*#####
#######
#######首页焦点图
######*/	
	var trnowindex=0;
	$("#trmeau li").eq(0).animate({opacity:"1"});//初始化显示
      $("#trmeau li").eq(0).siblings().animate({opacity:"0.4"}); 
	$("#trmeau li").mouseover(
		 function(){//手动方法
		  $(this).animate({opacity:"1"});
		  $(this).siblings().animate({opacity:"0.4"});
		  trnowindex= $("#trmeau li").index(this);
		   $("#trimg ul li").eq(trnowindex).siblings().animate({width:"0px"},"500");
		  $("#trimg ul li").eq(trnowindex).animate({width:$("#trimg ul li").find("img").width()},"500");
		 
		})
	 $("#trmeau li").mouseout(function(){try{aslidemeth=setInterval(aslidemeth,3000)}catch(err){}});
	 
	 
	//自动切换
	var setSlideauto=function(){
		var maxslideindex=$("#trimg li").size();
		 $("#trmeau li").eq(trnowindex).animate({opacity:"1"});
		 $("#trmeau li").eq(trnowindex).siblings().animate({opacity:"0.4"});
		 $("#trimg ul li").eq(trnowindex).siblings().animate({width:"0px"},"500");
		 $("#trimg ul li").eq(trnowindex).animate({width:$("#trimg ul li").find("img").width()},"500");
		 trnowindex++;
		 trnowindex=trnowindex>=maxslideindex?0:trnowindex;
		}
	var aslidemeth=setInterval(setSlideauto,5000);//初始化定时器
});

