/*============================= 首页广告 begin ===========================*/
$(document).ready(function(){
	//最顶全屏
	//TxAD_ShowBaiduAD("Baidu_WWW_TopAD1","http://x.itiexue.net/proxy.htm","42616","970","90");
	//顶通上
	TxAD_ShowBaiduAD("Baidu_WWW_TopAD2","http://x.itiexue.net/proxy.htm","41306","710","60");
	//顶通下
	TxAD_ShowBaiduAD("Baidu_WWW_TopAD3","http://x.itiexue.net/proxy.htm","41308","710","60");
	//焦点图下通栏
	TxAD_ShowBaiduAD("Baidu_WWW_TopAD4","http://x.itiexue.net/proxy.htm","41309","710","90");
	//二通
	TxAD_ShowBaiduAD("Baidu_WWW_TopAD5","http://x.itiexue.net/proxy.htm","41310","970","90");
    //三通
	TxAD_ShowBaiduAD("Baidu_WWW_TopAD6","http://x.itiexue.net/proxy.htm","41315","970","90");
    //四通
	TxAD_ShowBaiduAD("Baidu_WWW_TopAD7","http://x.itiexue.net/proxy.htm","75360","970","90");
    //五通
	TxAD_ShowBaiduAD("Baidu_WWW_TopAD8","http://x.itiexue.net/proxy.htm","41311","970","90");
    //底通
	TxAD_ShowBaiduAD("Baidu_WWW_TopAD9","http://x.itiexue.net/proxy.htm","42075","970","90");
    //军品实体店推广链接
	TxAD_ShowBaiduAD("Baidu_WWW_TopAD10","http://x.itiexue.net/proxy.htm","193443","350","20");
	//PopWindow("http://zz.game.tiexue.net/ad/jd0602/jdflash.htm");
});

//www首页弹窗广告
function PopWindow(popURL){
	var paypopupURL ="";
	var frequencyCap = '24'; //hours 
	var pcookieName = 'TieXuePopWindowAds';
	var pcookieValue = 'yes';
	function setPayPopUpCookie(){if (frequencyCap > 0){var today = new Date();var expire = new Date();expire.setTime(today.getTime() + 3600000 * frequencyCap);document.cookie = pcookieName+"="+escape(pcookieValue) + ";expires="+expire.toGMTString() + "; path=/"; } else if (frequencyCap == 0) { document.cookie = pcookieName+"="+escape(pcookieValue) + "; path=/"; } }
	function ReadPayPopUpCookie(){var theCookie=""+document.cookie;var ind=theCookie.indexOf(pcookieName);if (ind==-1 || pcookieName=="") return "";var ind1=theCookie.indexOf(';',ind); if (ind1==-1) ind1=theCookie.length; return unescape(theCookie.substring(ind+pcookieName.length+1,ind1));}

	function ShowPopWindowAD(URL,Path){
		if (ReadPayPopUpCookie() == pcookieValue){return;}
		setPayPopUpCookie()
		var strurl = URL;
		var Then = new Date();
		Then.setTime(Then.getTime() + 12*60*60*1000);
		var cookieString = new String(document.cookie);
		var cookieHeader = "Cookie1=";
		var beginPosition = cookieString.indexOf(cookieHeader);
		if (beginPosition != -1){ }
		else{
			focusid = setTimeout("focus();window.open('" + strurl + "','','width=1024,height=768,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes,location=yes,status=yes')",5000)
			window.focus();
	}
	}
	var openmyurl = window.location.href;
	if(openmyurl.indexOf("www.tiexue.net")>0){
		ShowPopWindowAD(popURL,"");
	}
}

//切换的方法
function public_playtab(mod,cursor,n){
	for(i=1;i<=n;i++){
			var nav=document.getElementById(mod+i);
			var cont=document.getElementById(mod+"_"+"cont"+i);
			nav.className=(i==cursor)?"moren":"";
			cont.style.display=(i==cursor)?"block":"none";
		}
}

//切换的方法
function public_playtab1(mod,cursor,n){
	for(i=1;i<=n;i++){
			var nav=document.getElementById(mod+i);
			var cont=document.getElementById(mod+"_"+"cont"+i);
			
			if(i == 3){
			nav.className=(i==cursor)?"moren2":"";
			}
			else{
				nav.className=(i==cursor)?"moren":"";
			}
			cont.style.display=(i==cursor)?"block":"none";
		}
}
	
function show_pic1(id){
	for(i=1;i<=7;i++){	
		if(document.getElementById('pn'+i) != undefined && document.getElementById('pnt'+i) != undefined){
		   document.getElementById('pn'+i).style.display= (id == i) ? "none" : 'block';
		   document.getElementById('pnt'+i).style.display= (id == i) ? "block" : 'none';
		}
	}
}

function show_pic2(id){
	for(i=1;i<=7;i++){
		if(document.getElementById('pns'+i) != undefined && document.getElementById('pnst'+i) != undefined){
		   document.getElementById('pns'+i).style.display= (id == i) ? "none" : 'block';
		   document.getElementById('pnst'+i).style.display= (id == i) ? "block" : 'none';
		}
	}
}

//滚动图
function PlayTran(){ 
	if(document.all){
		var obj=document.getElementById("ScrollImg");
		if(obj!=null){try{obj.filters.revealTrans.Transition=10;obj.filters.revealTrans.apply();obj.filters.revealTrans.play();}catch(e){}}
	}
}
function ScrollPicShow(index,isContinue){
	if(isPause && isContinue){
		window.setTimeout("ScrollPicShow("+index+",true)",10000);
		return;
	}
	ScrollButton(index);
	var simg=document.getElementById("ScrollImg");
	var stxt=document.getElementById("ScrollTxt");
	var surl=document.getElementById("ScrollUrl");
	var stxturl=document.getElementById("ScrollTxtUrl");
	PlayTran();
	try{
	simg.src=scrollImg[index][2];
	stxturl.title=scrollImg[index][1];
	simg.title=scrollImg[index][1];
	surl.title=scrollImg[index][1];
	stxt.innerHTML=scrollImg[index][1];
	stxturl.href=surl.href=scrollImg[index][0];
	var indexs=index+1;
	stxturl.onclick=surl.onclick=function(){_gaq.push(['_trackEvent', '第一屏-滚动图', 'clicked', 'pic'+indexs]);};
	}catch(e){}

	//按钮显示
	//定时滚动下一张
	if(index >= scrollImg.length-1 || index>=5)index=0;else index++;

	if(isContinue)window.setTimeout("ScrollPicShow("+index+",true)",5000);
}
function ScrollButton(index){
	var buttonName="ScrollDiv";
	for(var i=0;i<6;i++){
		var sbut=document.getElementById(buttonName+i);
		if(i==index)sbut.className="ScrollButton1";else sbut.className="ScrollButton0";
	}
}

function PauseScroll(index){
	isPause=true;
	ScrollPicShow(index,false);
	window.setTimeout("isPause=false",5000);
}
