/************************************************
* 说明：首页JaveScript函数
************************************************/

//图片交换
var timSwitch,HtmSwitch,ArrSwitch=new Array();
function setSwitch(){
	if(ArrSwitch.length>=1){
		var h,i=document.getElementById("switch1");
		if(i){
			for(var s=0;s<ArrSwitch.length;s++){
				if(s==0)h="<div id='switch3'>";
				h+="<a href='javascript:plySwitch("+s+")' class='switch";
				if(s==0)h+="3";
				h+="'>"+(s+1)+"</a>";
				if(s==ArrSwitch.length-1)h+="</div>";
			}
			i.innerHTML="<a href='"+ArrSwitch[0][0]+"' id='switch4'><img src='"+ArrSwitch[0][1].src+"' id='switch5'></a>"+h;
			document.getElementById("switch2").innerHTML=HtmSwitch;
		}
	}
}
function plySwitch(g){
	if(timSwitch)clearTimeout(timSwitch);
	if(g==-1){
		timSwitch=setTimeout("plySwitch(-2)",4000);
	}else{
		var a=document.getElementById("switch4"),s=document.getElementById("switch5");
		var m=document.getElementById("switch3").getElementsByTagName("A");
		if(g==-2){
			for(var i=0,d=0;i<m.length;i++){
				if(m[i].className=="switch3"){
					if(i<m.length-1)d=i+1;
					a.href=ArrSwitch[d][0];
					m[i].className="switch";
					m[d].className="switch3";
					s.filters[0].Apply();
					s.filters.revealTrans.transition=3000; //变化样式
					s.filters.revealTrans.duration=1; //变化速度
					s.src=ArrSwitch[d][1].src;
					s.filters[0].Play();
					break;
				}
			}
			timSwitch=setTimeout("plySwitch(-2)",4000);
		}else{
			for(var i=0;i<m.length;i++){
				if(g==i){
					a.href=ArrSwitch[i][0];
					m[i].className="switch3";
					s.filters[0].Apply();
					s.filters.revealTrans.transition=3000; //变化样式
					s.filters.revealTrans.duration=1; //变化速度
					s.src=ArrSwitch[i][1].src;
					s.filters[0].Play();
				}else{
					m[i].className="switch";
				}
			}
			timSwitch=setTimeout("plySwitch(-2)",6000);
		}
	}
}

//专题
var timTopic;
function plyTopic(g){
	if(timTopic)clearTimeout(timTopic);
	if(g==-1){
		timTopic=setTimeout("plyTopic(-2)",3000);
	}else{
		var a=document.getElementById("topic"),s=document.getElementById("topic2");
		var t=document.getElementById("topic3");
		var n=t.getElementsByTagName("A"),m=t.getElementsByTagName("IMG");
		if(m.length>1&&m.length==n.length){
			if(g==-2){
				for(var i=0,d=0;i<m.length;i++){
					if(m[i].src==s.src){
						if(i<m.length-1)d=i+1;
						a.href=n[d].href;
						s.src=m[d].src;
						m[i].style.border="2px solid #FFF";
						m[i].style.filter="alpha(opacity=30)";
						m[d].style.border="2px solid #E5E5E5";
						m[d].style.filter="alpha(opacity=100)";
						break;
					}
				}
				timTopic=setTimeout("plyTopic(-2)",3000);
			}else{
				for(var i=0;i<m.length;i++){
					if(g==i){
						a.href=n[i].href;
						s.src=m[i].src;
						m[i].style.border="2px solid #E5E5E5";
						m[i].style.filter="alpha(opacity=100)";
					}else{
						m[i].style.border="2px solid #FFF";
						m[i].style.filter="alpha(opacity=30)";
					}
				}
			}
		}
	}
}