//替换header
document.getElementById("TopRobj").innerHTML = '<div class="topButton"><a href="http://china.herostart.com/trade/queryBasket" rel="nofollow">查询篮</a></div><div class="topButton"><a href="http://www.herostart.com" rel="nofollow">English</a></div><div class="topButton" id="ebook"><a href="http://china.herostart.com/shtml/ebook/ebook.html" target="_blank" rel="nofollow">电子目录</a></div><div class="topButton"><a href="http://china.herostart.com/trade/mycenter/imain" rel="nofollow">商务中心</a></div><div class="topButton"><a href="http://china.herostart.com/trade/register" rel="nofollow">免费注册</a></div><div class="topButton2" id="isLoging"><a href="http://china.herostart.com/trade/mycenter/login?nextUrl=http://china.herostart.com/trade/mycenter/imain" rel="nofollow">登 录</a></div><span id="loginUserName"></span>';
//document.getElementById("TopLobj").innerHTML = '<a href="http://china.herostart.com/">环球贸易网首页</a> <img src="http://china.herostart.com/images/product/product2_07.gif" /> &nbsp;&nbsp;&nbsp;<img src="http://china.herostart.com/images/product/product2_04.gif" /> <font style="color:#1b57cb">咨询热线：(86 591)8334 8235</font>';
document.getElementById("TopRobj").style.width = "510px";

//判断是否已登录
//获取本地最后登录用户
var lastLoginId = getCookie("loginUser");
var userName = getCookie("memberId");
var loginInfo = "";
if (lastLoginId != null && lastLoginId != "" && lastLoginId != '""'){
	loginInfo='<span style="color:green;font-weight:bold">'+lastLoginId+'</span>';
	//是否有效
	loginInfo = "您好," + loginInfo
	if (userName != null && userName != "" && userName != '""'){
		loginInfo = loginInfo + " <a title='退出' href='http://china.herostart.com/trade/mycenter/logout' style='color:#000'>[注 销]</a> ";
	}else{
		if (lastLoginId != null && lastLoginId != "" && lastLoginId != '""'){loginInfo = loginInfo + " 请重新<a href='http://china.herostart.com/trade/mycenter/login?nextUrl=http://china.herostart.com/trade/mycenter/imain' target='_blank' style='font-weight:bold;color:#000'>登录</a>！ ";}
	}
	$("loginUserName").innerHTML = loginInfo;
	document.getElementById("isLoging").style.display="none";
	document.getElementById("ebook").style.display="none";
}

/*
var userName = getCookie("loginUser");
if (userName != null && userName != "" && userName != '""'){
	document.getElementById("loginUserName").innerHTML='[ 欢迎登录！'+userName+']';
	document.getElementById("ebook").style.display="none";
	document.getElementById("isLoging").innerHTML='<a href="http://china.herostart.com/trade/mycenter/logout">注 销</a>';
}
*/

//替换LOGO左
var LogoLobj = document.getElementById("LogoLobj");
LogoLobj.innerHTML = LogoLobj.getElementsByTagName("div")[0].innerHTML;


//公司、产品、商情搜索
//var offerUrl=location.href.substring(0,location.href.indexOf("?"));
//alert(offerUrl);
var comSearchKey;
var linkList=[{surl:"http://search.china.herostart.com/sell/default.html?searchWord=",button:"找产品",title:"请输入您要找的产品信息！"},
			  {surl:"http://search.china.herostart.com/buy/default.html?searchWord=",button:"找求购",title:"请输入您要找的求购信息！"},
			  {surl:"http://search.china.herostart.com/company/default.html?searchWord=",button:"找公司",title:"请输入您要找的公司！"},
    		  {surl:"http://www.herostart.com/trade/search/sell_leads?searchWords=",button:"国际供求",title:"请输入您要找的国际供求信息！"},    		  
    		  {surl:"http://search.china.herostart.com/expo/default.html?searchWord=",button:"找展会",title:"请输入您要找的展会！"}];

//搜索条按键单击事件
function SearchTab(){
	var textObj = document.getElementById("textObj").value;
	if(textObj.substring(0,3) =="请输入" || textObj ==""){
		alert("请输入查询内容！");
		document.getElementById("textObj").focus();
		return false;
	}else{
		/*
		//商情搜索
		if(mrsearSumObj==2){
			//offerRadios 在搜索条插入到网页中是获取
			var URLValue="";
			for(var i=0;i<offerRadios.length;i++){
				if(offerRadios[i].checked){
					URLValue=offerRadios[i].value;
				}
			}
			if('sellingLead'==URLValue){
				window.location.href="http://search.china.herostart.com/sell/default.html?searchWord="+encodeURIComponent(textObj);
			}else{
				window.location.href=linkList[mrsearSumObj].surl+URLValue+"/search?searchWord="+encodeURIComponent(textObj);
			}
			return ;
		}
		*/
		
		
		var src=linkList[mrsearSumObj].surl + encodeURIComponent(textObj);
		//公司搜索
		//if(mrsearSumObj==1){
			var seaVar=getCookie("comSearchKey");
			if(seaVar != null && seaVar != "" && seaVar != '""'){
				if(seaVar.indexOf(src,0)==-1){ //关键字是否已在cookie中
					var s="</a></li>";
					if(countInstances(seaVar,s)==10){
						seaVar=seaVar.substr(seaVar.indexOf(s)+s.length);
					}
					setCookie("comSearchKey",seaVar+"<li><a href='"+src+"' title='"+textObj+"'>"+textObj.substr(0,12)+"</a></li>",30);
				}
			}else{
				setCookie("comSearchKey","<li><a href='"+src+"' title='"+textObj+"'>"+textObj.substr(0,12)+"</a></li>",30);
			}
		//}
		//decodeURIComponent
		//要对中文进行uri编码
		window.location.href = src;
	}	
}

//替换LOGO右
var topSearchFont = '<div class="productSearch">'+
'<ul id="SearchObjUp">'+
'	<li onclick=\'CommonTab(0,"SearchObjUp","li",null,0);SearchText(0,"#999");\'><div class="L">产 品</div><div class="R"></div></li>'+
'	<li onclick=\'CommonTab(1,"SearchObjUp","li",null,0);SearchText(1,"#999");\'><div class="L">求 购</div><div class="R"></div></li>'+
'	<li onclick=\'CommonTab(2,"SearchObjUp","li",null,0);SearchText(2,"#999");\'><div class="L">公 司</div><div class="R"></div></li>'+
'	<li onclick=\'CommonTab(3,"SearchObjUp","li",null,0);SearchText(3,"#999");\'><div class="L">国际供求</div><div class="R"></div></li>'+
'	<li onclick=\'CommonTab(4,"SearchObjUp","li",null,0);SearchText(4,"#999");\'><div class="L">展 会</div><div class="R"></div></li>'+
//'	<li onclick=\'window.location.href="http://search.china.herostart.com/"\'><div style="margin-top:5px;width:80px;text-align:right">更多搜索>></div></li>'+
'	<li><a href="http://china.herostart.com/shtml/searchAlexa.html" style="left: 10px;position: relative;text-align: right;top: 4px;">搜索排行榜！</a></li>'+
'</ul>'+
'<div>'+
'	<ul class="SearchDn">'+
'		<li class="P_Text"><input type="text" style="width:350px;" name="searchWord" id="textObj" onclick=\'SearchText("this","#000")\' onKeyDown=\'if(event.keyCode==13) SearchTab();\' onblur=\'SearchText("this","#999")\' /></li><li class="P_Button"><input type="button" onclick=\'javascript:SearchTab();\' id="butObj"/></li>'+
'	</ul>'+
'</div><div id="Clear"></div></div>';
document.getElementById("LogoRobj").innerHTML = topSearchFont;

new CommonTab(0,"SearchObjUp","li",null,0);
new SearchText(0,"#999");
//var offerRadios=document.getElementsByName("offer");

//设置传递过来的搜索关键字
var para = location.href;
if(para!=""){	
	try{	
		npara = decodeURIComponent(para).substring(para.indexOf("?")+1,para.length);
		for(var i=0 ;i<npara.split("&").length;i++){
			var temp=npara.split("&")[i];
			if(temp.split("=")[0]=="searchWord"){
				$("textObj").value=temp.split("=")[1];
				break;
			}
		}
		
	}catch(err){}
}
