﻿function getDownloadUrl(productName) {
			var random = parseInt(Math.random()*100);
			var temp = 0;
	
			for(var i = 0; i < productName.length && random > temp; i++) {
				temp += parseInt(productName[i].percent);
			}
			i = (random == 0 ? 0 : i - 1);

			return "<a href=\"" + productName[i].url + "\">" + productName[i].name + "</a>";
}
function switchTab(identify,index,count) {
	for(i=0;i<count;i++) {
		var CurTabObj = document.getElementById("Tab_"+identify+"_"+i) ;
		var CurListObj = document.getElementById("List_"+identify+"_"+i) ;
		if (i != index) {
			fRemoveClass(CurTabObj , "upH3") ;
			fRemoveClass(CurListObj , "upBox") ;
		}
	}
	fAddClass(document.getElementById("Tab_"+identify+"_"+index),"upH3") ;
	fAddClass(document.getElementById("List_"+identify+"_"+index),"upBox") ;
}

function switchSideTab(identify,index,count) {
	for(i=0;i<count;i++) {
		var CurTabObj = document.getElementById("Tab_"+identify+"_"+i) ;
		var CurListObj = document.getElementById("List_"+identify+"_"+i) ;
		if (i != index) {
			fRemoveClass(CurTabObj , "upH3") ;
			fRemoveClass(CurListObj , "upUL") ;
		}
	}
	fAddClass(document.getElementById("Tab_"+identify+"_"+index),"upH3") ;
	fAddClass(document.getElementById("List_"+identify+"_"+index),"upUL") ;
}

function fAddClass(XEle, XClass)
{/* shawl.qiu code, void return */
  if(!XClass) throw new Error("XClass 涓嶈兘涓虹┖!");
  if(XEle.className!="") 
  {
    var Re = new RegExp("\\b"+XClass+"\\b\\s*", "");
    XEle.className = XEle.className.replace(Re, "");
	var OldClassName = XEle.className.replace(/^\s+|\s+$/g,"") ;
	if (OldClassName == "" ) {
		 XEle.className = XClass;
	}
	else {
		XEle.className = OldClassName + " " + XClass;
	}
   
  }
  else XEle.className = XClass;
}/* end function fAddClass(XEle, XClass) */

function fRemoveClass(XEle, XClass)
{/* shawl.qiu code, void return */
  if(!XClass) throw new Error("XClass 涓嶈兘涓虹┖!");
  var OldClassName = XEle.className.replace(/^\s+|\s+$/g,"") ;
  if(OldClassName!="") 
  {
	
    var Re = new RegExp("\\b"+XClass+"\\b\\s*", "");
    XEle.className = OldClassName.replace(Re, "");
  }
}/* function fRemoveClass(XEle, XClass) */
function switchPic(screen) {
	if (screen > MaxScreen) {
		screen = 1 ;
	}
	
	for (i=1;i<=MaxScreen;i++) {
		document.getElementById("Switch_"+i).style.display = "none" ;
	}
	document.getElementById("Switch_"+screen).style.display = "block" ;
	showSwitchNav(screen);
	showSwitchTitle(screen);
	//Effect.Appear("Switch_"+screen);
			
	//switchLittlePic(screen);
	//showSwitchTitles(screen);
	CurScreen = screen  ;
}
function showSwitchNav(screen) {
	var NavStr = "" ;
	for (i=1;i<=MaxScreen;i++) {
		if (i == screen) {
			NavStr += '<li onmouseover="pauseSwitch();" onmouseout="goonSwitch();"><a href="javascript://" target="_self" class="sel">'+i+'</a></li>' ;
		}
		else {
			NavStr += '<li onmouseover="pauseSwitch();" onmouseout="goonSwitch();" onclick="goManSwitch('+i+');"><a href="javascript://" target="_self">'+i+'</a></li>' ;
		}
		
	}
	document.getElementById("SwitchNav").innerHTML = NavStr ;
}
function showSwitchTitle(screen) {
	var titlestr = "" ;
	titlestr = '<h3><a href="'+Switcher[screen]['link']+'" target="_blank">'+Switcher[screen]['title']+'</a></h3><p><a href="'+Switcher[screen]['link']+'" target="_blank">'+Switcher[screen]['stitle']+'</a></p>' ;
	document.getElementById("SwitchTitle").innerHTML = titlestr ;
}
function reSwitchPic() {
	refreshSwitchTimer = null;
	switchPic(CurScreen+1);
	refreshSwitchTimer = setTimeout('reSwitchPic();', 3000);
}
function pauseSwitch() {
	clearTimeout(refreshSwitchTimer);
}
function goonSwitch() {
	clearTimeout(refreshSwitchTimer);
	refreshSwitchTimer = setTimeout('reSwitchPic();', 3000);
}
function goManSwitch(index) {
	clearTimeout(refreshSwitchTimer);
	
	CurScreen = index - 1 ;
	reSwitchPic();
}
function floatAdMove() {
	try{BigAd = document.getElementById("BigAd")}catch(e){}
	if (BigAd.style.display != "none") {
		if (document.ns) {
			BigAd.style.top=bdy.scrollTop+bdy.clientHeight-imgheight_close -360;
			BigAd.style.left=bdy.offsetWidth/2-bdy.scrollLeft-300;
		}
		else {
			BigAd_style_left=bdy.offsetWidth/2-bdy.scrollLeft-300;
			BigAd_style_top = 200 ;
			BigAd.style.top=BigAd_style_top + "px";
			BigAd.style.left=BigAd_style_left + "px";
		}
	}
	setTimeout("floatAdMove();",50) ;
 }

function FloatCtrlMove() {
	try{FloatCtrl = document.getElementById("FloatCtrl")}catch(e){}
	if (FloatCtrl.style.display != "none") {
		if (document.ns) {
			FloatCtrl.style.top=bdy.scrollTop+bdy.clientHeight-imgheight_close;
			FloatCtrl.style.left=bdy.scrollLeft+bdy.offsetWidth-150;
		}
		else {
			FloatCtrl_style_left=bdy.scrollLeft+bdy.offsetWidth-150;
			FloatCtrl_style_top = 500 ;
			FloatCtrl.style.top=FloatCtrl_style_top + "px";
			FloatCtrl.style.left=FloatCtrl_style_left + "px";
		}
	}
	setTimeout("FloatCtrlMove();",50) ;
}

function showFloatAd() {
	cleanTimer();
	try{floatbig = document.getElementById("floatbig")}catch(e){}
	if (floatbig.innerHTML != "") {
		BigAdStartTimer = setTimeout("Effect.Appear('BigAd');",500);
		BigAdEndTimer = setTimeout("hiddenFloatAd();",6000);
		hiddenFloatCtrl();
	}
}

 function hiddenFloatAd() {
	cleanTimer();
	Effect.Fade('BigAd');
	showFloatCtrl();
 }

 function showFloatCtrl() {
	try {FloatCtrl = getElementById("FloatCtrl")} catch(e){}
	FloatCtrl.style.display = "block" ;
 }
 function hiddenFloatCtrl() {
	try {FloatCtrl = getElementById("FloatCtrl")} catch(e){}
	FloatCtrl.style.display = "none" ;
 }
 function cleanTimer() {
	clearTimeout(BigAdStartTimer) ;
	clearTimeout(BigAdEndTimer);
 }
 function InitAjax()
{
 var ajax=false; 
 try {  
  ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
 } catch (e) { 
  try { 
   ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
  } catch (E) { 
   ajax = false; 
  } 
 }
 if (!ajax && typeof XMLHttpRequest!='undefined') { 
  ajax = new XMLHttpRequest(); 
 } 
 return ajax;
}
function glogin()
{
 var span_user=document.getElementById("table_user");
 var span2=document.getElementById("Header1_a_login");
 var ver = "cn";
 var url = "/indexcallback.aspx";
 var postStr  = "ver="+ ver+"&kind=6";
 var ajax = InitAjax();
 ajax.open("POST", url, true); 
 ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
 ajax.send(postStr);
 ajax.onreadystatechange = function() { 
  if (ajax.readyState == 4 && ajax.status == 200) { 
   var json = eval("("+ajax.responseText+")");
   if(json.login[0].lbool=='true')
   {
    span2.outerHTML=json.login[0].name+"&nbsp;&nbsp;<a href='#' onclick='checkout()'>退出</a>";
    span_user.outerHTML="<table id='table_user' width='250' height='129' border='0' align='center' cellpadding='0' cellspacing='0' class='huise'>"+
                    "<tr>"+
                    "<td height='60'><img height='60' src='../images/index/cn-index_20.gif' width=250 alt='登录banner' /></td></tr>"+
                    "<tr>"+
                    "<td width='250' height='69'>"+
                    "<table height='69' cellSpacing='0' cellPadding='0' width='250' border='0'>"+
                    "<tr>"+
                    "<td width=1 bgColor=#458fda><img height=1 src='../images/Cn/tiao-1-1.gif' width=1 /></td>"+
                    "<td width=250>"+
                    "<div align=left><font class=style1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;欢迎<font color=#c40002>"+json.login[0].name+"</font> "+json.login[0].sex+"再次光临中欧在线!<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您有最新询价<font color=#c40002>"+json.login[0].askprice+"</font>条,新留言<font color=#c40002>"+json.login[0].mes+"</font>条,&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您的信息被浏览次数为<font color=#c40002>"+json.login[0].hits+"</font>次。<br /><a style='COLOR: #c40002' href='mana_center/index.asp?ver=cn'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='/myaccount/frameset.html' target='_blank'>点击此处查看详细信息</a> &nbsp;&nbsp;&nbsp;&nbsp;<a style='COLOR: #c40002' href='#' onclick='checkout()'>退出系统</a></font> </div></td>"+
                    "<td width=1 bgColor=#458fda><img height=1 src='../images/Cn/tiao-1-1.gif' width=1></td></tr></table></td></tr>"+
                    "<tr>"+
                    "<td bgColor=#458fda height=1><img height=1 src='../images/Cn/tiao-1-1.gif' width=1></td></tr></table>";
   }
  } 
 }
}
function checkout()
{
 var ver = "cn";
 var url = "./indexcallback.aspx";
 var postStr  = "ver="+ ver+"&kind=7";
 var ajax = InitAjax();
 ajax.open("POST", url, true); 
 ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
 ajax.send(postStr);
 ajax.onreadystatechange = function() { 
  if (ajax.readyState == 4 && ajax.status == 200) { 
   if(ajax.responseText=="true")
   {
    alert("成功登出!");
    location.href="./index.aspx";
   }
   else
   {
    alert("登出失败!");
    location.href="./index.aspx";
   }
  } 
 }
}