/*
 * 函数说明：选择搜索类型
 * 参数：	actionUrl:搜索目标页面　　tracelog:跟踪参数
 * 返回值：	无
 * 时间：2005-5-12
 */
var searchActivedItem=1;
var tracelogStr="";
var otherParamStr="";
function searchInit(num,tracelog,otherParam){
	tracelogStr = tracelog;
	otherParamStr = otherParam;
	//doclick(document.getElementById("node"+num),num);

}
function doclick(srcObj,searchID){
	var tabList = srcObj.parentNode.getElementsByTagName("li");
	if(srcObj.className=="activedTab")return;
	for(var i=0;i<tabList.length;i++){
		if(tabList[i].className=="activedTab")tabList[i].className="nTab";
	}
	searchActivedItem = searchID;
	srcObj.className = "activedTab";//TAB切换
	
	if(document.getElementById("linkKwords"))document.getElementById("linkKwords").innerHTML = linkKeywords[searchID-1].surl//热门关键字付值
	
	var v = searchform.keywords.value;
	if(trim(v) == "" || v.substring(0,3) =="请输入")searchform.keywords.value = data[searchID-1].title;
}
function checkform(){
	var v = trim(searchform.keywords.value);
	if(v.length > 100){
		alert("您输入的关键字过长！");
		return false;
	}
	if(v == ""  || v.substring(0,3) =="请输入") {
		alert("请输入关键字！");
		return false;
	}
	var s ="&";
	if((data[searchActivedItem-1].surl).indexOf("?")==-1)s="?";
	searchform.action = data[searchActivedItem-1].surl+s+"keywords=" + searchform.keywords.value +"&tracelog="+tracelogStr+data[searchActivedItem-1].tracelog+otherParamStr;//给form的action付值
}
/*
 * 函数说明：去除头尾空格
 * 参数：	字符串
 * 返回值：	无
 * 时间：2005-5-12
 */
function trim(inputString) {
	return inputString.replace(/^ +/,"").replace(/ +$/,"");
}
/*
 * 函数说明：取cookie值
 * 参数：	cookie字段名
 * 返回值：	cookie值
 * 时间：2005-5-12
 */
function getCookie(sName) {
	  var aCookie = document.cookie.split("; ");
	  for (var i=0; i < aCookie.length; i++)
	  {
	    var aCrumb = aCookie[i].split("=");
	    if (sName == aCrumb[0]) 
	      return unescape(aCrumb[1]);
	  }
	  return null;		
}
/*搜索配置*/
var data = [
	{id:1,name:"供应",surl:"/search/searchsale.jsp" , title:"请输入您感兴趣的物流服务！" , tracelog:"searchbuyer"},
	{id:2,name:"求购",surl:"/search/searchbuy.jsp" , title:"请输入您感兴趣的货盘信息！", tracelog:"searchsale"},
	{id:3,name:"公司",surl:"/search/searchcor.jsp" , title:"请输入产品名或公司名关键词！" , tracelog:"searchcom"},
	{id:4,name:"资讯",surl:"/search/searchinfo.jsp",title:"请输入您感兴趣的关键词，如“第三方”“诚信”" , tracelog:"searchinfor"},
	{id:5,name:"论坛",surl:"/search/searchsale.jsp" , title:"请输入您感兴趣的关键词查找帖子" , tracelog:"searchclub"},
	{id:6,name:"博客",surl:"/search/searchsale.jsp" , title:"请输入您感兴趣的关键词查找帖子",tracelog:"searchblog"},
	{id:7,name:"产品",surl:"/search/searchproduct.jsp" , title:"请输入产品关键词！" , tracelog:"searchbaojia"},
	{id:8,name:"代理",surl:"/search/searchsale.jsp" , title:"请输入产品关键词查找相关代理信息！" , tracelog:"searchdaili"},
	{id:9,name:"加工",surl:"/search/searchsale.jsp" , title:"请输入产品关键词查找相关加工信息！" , tracelog:"searchjiagong"}
	]

/*热门关键字*/
var linkKeywords = [
	{id:1,name:"供应",surl:"热门关键字：<a href=\"/tradeinfo/trade/1-1.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>汽运</a> <a href=\"/tradeinfo/trade/1-4.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>空运</a> <a href=\"/tradeinfo/trade/1-8.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>水运 </a> <a href=\"/tradeinfo/trade/1-9.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>铁运</a> <a href=\"/tradeinfo/trade/1-10.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>海运</a> <a href=\"/tradeinfo/trade/3-107.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>联运</a> <a href=\"/tradeinfo/index.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>更多</a>"},


	{id:2,name:"求购",surl:"热门关键字：<a href=\"/seller/offerlist/19-674-2177.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\" class=textwhite>常规货</a> <a href=\"/search/searchbuy.jsp?keywords=轻泡货\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\" class=textwhite>大件</a> <a href=\"/search/searchbuy.jsp?keywords=印刷品\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\" class=textwhite>印刷品</a> <a href=\"/search/searchbuy.jsp?keywords=危险品\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\" class=textwhite>危险品</a> </a><a href=\"/search/searchbuy.jsp?keywords=重泡货\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\" class=textwhite>重泡货</a> <a href=\"/search/searchbuy.jsp?keywords=手表\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\" class=textwhite>手表</a> <a href=\"/search/searchbuy.jsp?keywords=MP4\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\" class=textwhite>MP4</a> <a href=\"/search/searchbuy.jsp?keywords=保健品\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\" class=textwhite>保健品</a> <a href=\"/seller/index.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\" class=textwhite>更多</a>"},



	{id:3,name:"公司",surl:'热门关键字：<a href="corporation/index.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchcompanykey\');"  class=textwhite>所有行业分类</a> <a href="search/searchcor.jsp?keywords=进出口公司" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchcompanykey\');" class=textwhite>进出口公司</a> <a href="/search/searchcor.jsp?keywords=服装" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchcompanykey\');" class=textwhite>服装</a> <a href="search/searchcor.jsp?keywords=MP3" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchcompanykey\');" class=textwhite>MP3</a> <a href="search/searchcor.jsp?keywords=机械设备" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchcompanykey\');" class=textwhite>机械设备</a> <a href="search/searchcor.jsp?keywords=电子" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchcompanykey\');" class=textwhite>电子</a> <a href="search/searchcor.jsp?keywords=礼品" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchcompanykey\');" class=textwhite>礼品</a>'},


	{id:4,name:"资讯",surl:'热门关键字： <a href="/info/community/3.html" target=_blank onMouseDown="return aliclick(this,\'?ui_homepage_searchnewskey\');" class=textwhite>贸易</a> <a href="/info/community/4.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchnewskey\');" class=textwhite>创业</a> <a href="/info/community/7.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchnewskey\');" class=textwhite>人才</a> <a href="/info/community/5.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchnewskey\');" class=textwhite>诚信</a> <a href="/info/community/11.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchnewskey\');" class=textwhite>物流</a> <a href="/info/community/10.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchnewskey\');" class=textwhite>投资</a> <a href="/info/community/12.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchnewskey\');" class=textwhite>法律</a> <a href="/info/community/14.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchnewskey\');" class=textwhite>财经</a> <a href="/info/index.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchnewskey\');" class=textwhite>更多</a>'},


	{id:5,name:"论坛",surl:'热门关键字： <a href="/club/post/search?keyword=创业" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchclubkey\');" class=textwhite>创业</a> <a href="/club/post/search?keyword=财富" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchclubkey\');" class=textwhite>财富</a> <a href="/club/post/search?keyword=贸易" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchclubkey\');" class=textwhite>贸易</a> <a href="/club/post/search?keyword=物流" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchclubkey\');" class=textwhite>物流</a> <a href="/club/post/search?keyword=翻译" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchclubkey\');" class=textwhite>翻译</a></a> <a href="/club/post/search?keyword=营销" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchclubkey\');" class=textwhite>营销</a> <a href="/club/post/search?keyword=赚钱" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchclubkey\');" class=textwhite>赚钱</a> <a href="/club/post/search?keyword=成功" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchclubkey\');" class=textwhite>成功</a>  <a href="/html/bbs-paihang.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchclubkey\');" class=textwhite>更多</a>'},


	{id:6,name:"博客",surl:'热门关键字： '},


	{id:7,name:"产品",surl:'热门关键字：<a href="/search/searchproduct.jsp?keywords=礼品" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchbaojiakey\');" class=textwhite>礼品</a> <a href="/search/searchproduct.jsp?keywords=工艺品" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchbaojiakey\');" class=textwhite>工艺品</a> <a href="/search/searchproduct.jsp?keywords=T恤" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchbaojiakey\');" class=textwhite>T恤</a> <a href="/search/searchproduct.jsp?keywords=电脑" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchbaojiakey\');" class=textwhite>电脑</a> <a href="search/searchproduct.jsp?keywords=运动" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchbaojiakey\');" class=textwhite>运动</a> <a href="search/searchproduct.jsp?keywords=外贸" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchbaojiakey\');" class=textwhite>外贸</a> <a href="search/searchproduct.jsp?keywords=MP3" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchbaojiakey\');" class=textwhite>MP3</a> <a href="search/searchproduct.jsp?keywords=玩具" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchbaojiakey\');" class=textwhite>玩具</a> <a href="productshow/index.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchbaojiakey\');" class=textwhite>更多</a>'},
	{id:8,name:"代理",surl:'热门关键字：<a href="/search/offer_search.htm?keywords=%BC%D2%BE%D3&direction=sale&categoryId=51" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchdailikey\');" class=textwhite>家居</a>  <a href="/search/offer_search.htm?keywords=%B1%A3%BD%A1%C6%B7&direction=sale&categoryId=51" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchdailikey\');" class=textwhite>保健品</a> <a href="/search/offer_search.htm?keywords=%C6%FB%C4%A6&direction=sale&categoryId=51" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchdailikey\');" class=textwhite>汽摩</a> <a href="/search/offer_search.htm?keywords=%BD%F8%B3%F6%BF%DA&direction=sale&categoryId=51" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchdailikey\');" class=textwhite>进出口</a> <a href="/search/offer_search.htm?keywords=%BD%A8%B2%C4&direction=sale&categoryId=51" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchdailikey\');" class=textwhite>建材</a>  <a href="/search/offer_search.htm?keywords=%B0%B2%B7%C0&direction=sale&categoryId=51" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchdailikey\');" class=textwhite>安防</a> <a href="/search/offer_search.htm?keywords=%BC%D2%B5%E7&direction=sale&categoryId=51" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchdailikey\');" class=textwhite>家电</a> <a href="/buy/trade/51.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchdailikey\');" class=textwhite>更多</a>'},
	{id:9,name:"加工",surl:'热门关键字：<a href="/search/offer_search.htm?keywords=%B0%FC%D7%B0%D3%A1%CB%A2&direction=sale&categoryId=2805" target="_blank" onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchjiagongkey\');" class=textwhite>包装印刷</a> <a href="/search/offer_search.htm?keywords=%CE%E5%BD%F0%BC%D3%B9%A4&direction=sale&categoryId=2805" target="_blank" onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchjiagongkey\');" class=textwhite>五金加工</a> <a href="/search/offer_search.htm?keywords=%D0%E5%BB%A8%BC%D3%B9%A4&direction=sale&categoryId=2805" target="_blank" onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchjiagongkey\');" class=textwhite>绣花加工</a> <a href="/search/offer_search.htm?keywords=%B7%FE%D7%B0%BC%D3%B9%A4&direction=sale&categoryId=2805" target="_blank" onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchjiagongkey\');" class=textwhite>服装加工</a> <a href="/search/offer_search.htm?keywords=%BB%FA%D0%B5%C1%E3%BC%FE%BC%D3%B9%A4&direction=sale&categoryId=2805" target="_blank" onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchjiagongkey\');" class=textwhite>机械零件加工</a> <a href="/search/offer_search.htm?keywords=%BC%A4%B9%E2%BC%D3%B9%A4&direction=sale&categoryId=2805" target="_blank" onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchjiagongkey\');" class=textwhite>激光加工</a><a href="/buy/trade/2805.html" target=_blank onMouseDown="return aliclick(this,\'?tracelog=ui_homepage_searchjiagongkey\');" class="textwhite">更多</a>'}

]



var keys_str = getCookie('h_keys');
	if(keys_str != null  )
	{
		var keys_array = keys_str.split("#");
		if(keys_array.length >= 5){
			var strlen =0;
			var str="最近搜索记录：";
				for(var i=0;i<keys_array.length && i<7;i++){
					var type = keys_array[i].substring(keys_array[i].length-3,keys_array[i].length);
					var key = keys_array[i].substring(0,keys_array[i].length-3);
					strlen = strlen + key.length;
					if(strlen < 35){
					if(type =='[供]')
					str+=" <a target=_blank href=/selloffer/"+encodeURI(key)+".html?tracelog=jy_homepage_historyky class=textwhite onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuy');\">"+ key +"</a> ";
					else
					str+=" <a target=_blank href=/buyoffer/"+encodeURI(key)+".html?tracelog=jy_homepage_historyky class=textwhite onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchsellerkey');\">"+ key +"</a> ";
				}
			}
			linkKeywords[0].surl=str;
			linkKeywords[1].surl=str;
		}


}
	   function DoLogin() {

	      var UsernameGet = trim(document.loginForm.UsernameGet.value);
		  var PasswordGet = trim(document.loginForm.PasswordGet.value);
		  //var Verifycode = trim(document.loginForm.Verifycode.value);

          if(UsernameGet == "") {
		    alert("请输入会员登录名！");
			document.loginForm.UsernameGet.focus();
		    return false;
		  } 
		  if(PasswordGet == "") {
		    alert("请输入密码！");
			document.loginForm.PasswordGet.focus();
		    return false;
		  } 
		 // if(Verifycode == "") {
		 //   alert("请输入验证码！");
		 //	document.loginForm.Verifycode.focus();
		 //    return false;
		 //  }  
		  
		  
		 }

           function trim(inputString) {
	   
              if (typeof inputString != "string") { return inputString; }
              var retValue = inputString;
              var ch = retValue.substring(0, 1);
              while (ch == " ") { 
	          //检查字符串开始部分的空格
                  retValue = retValue.substring(1, retValue.length);
                  ch = retValue.substring(0, 1);
              }
              ch = retValue.substring(retValue.length-1, retValue.length);
              while (ch == " ") {
                 //检查字符串结束部分的空格
                 retValue = retValue.substring(0, retValue.length-1);
                 ch = retValue.substring(retValue.length-1, retValue.length);
              }
              while (retValue.indexOf("  ") != -1) { 
	         //将文字中间多个相连的空格变为一个空格
                 retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
              }
              return retValue;
           } 
