	/*
 * 函数说明：选择搜索类型
 * 参数：	actionUrl:搜索目标页面　　tracelog:跟踪参数
 * 返回值：	无
 * 时间：2005-5-12
 */
var searchActivedItem=2;
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(document.getElementById("searchform").keywords.value);
	if(v.length > 100){
		alert("您输入的关键字过长！");
		return false;
	}
	if(v == ""  || v.substring(0,3) =="请输入") {
		alert("请输入关键字！");
		return false;
	}
	

	var action_url = data[searchActivedItem-1].surl;
	//商友专用
	if(searchActivedItem==11){
	  var searchType = document.getElementsByName("searchType");
	  for(var i =0;i<searchType.length;i++){
	    if(searchType[i].checked==true){
				if(document.getElementById("searchform").searchType){
				}else{
					searchTypeInput = document.createElement("input");
					searchTypeInput.setAttribute("name","searchType");
					searchTypeInput.setAttribute("type","hidden");
					document.getElementById("searchform").appendChild(searchTypeInput);

					searchActionInput = document.createElement("input");
					searchActionInput.setAttribute("name","action");
					searchActionInput.setAttribute("type","hidden");
					searchActionInput.setAttribute("value","BusinessFriendSearchBar");
					document.getElementById("searchform").appendChild(searchActionInput);

					searchBarInput = document.createElement("input");
					searchBarInput.setAttribute("name","event_submit_do_searchFriendBar");
					searchBarInput.setAttribute("type","hidden");
					searchBarInput.setAttribute("value","true");
					document.getElementById("searchform").appendChild(searchBarInput);
				}
		    searchTypeInput.value = searchType[i].value;
		  }
	  } 
	}
	//document.getElementById("searchform").action = action_url; //给form的action付值
	var s ="&";
	if((data[searchActivedItem-1].surl).indexOf("?")==-1)s="?";
	document.getElementById("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:"http://www.rajxw.com/search/searchsale.asp" , title:"" , sortid:"all"},
	{id:2,name:"求购",surl:"http://www.rajxw.com/search/searchbuy.asp" , title:"", tracelog:"searchbuy"},
	{id:3,name:"公司",surl:"http://www.rajxw.com/search/searchcor.asp" , title:"" , tracelog:"searchcompany"},
	{id:4,name:"资讯",surl:"",title:"" , tracelog:"searchinfor"},
	{id:5,name:"论坛",surl:"" , title:"" , tracelog:"searchclub"},
	{id:6,name:"博客",surl:"" , title:"",tracelog:"searchblog"},
	{id:7,name:"报价",surl:"http://" , title:"" , tracelog:"searchbaojia"},
	{id:8,name:"代理",surl:"http://" , title:"" , tracelog:"searchdaili"},
	{id:9,name:"加工",surl:"http://" , title:"" , tracelog:"searchjiagong"},
	{id:10,name:"黄页",surl:"http://"},
	{id:11,name:"产品",surl:"http://www.rajxw.com/search/searchproduct.asp" , title:"" , tracelog:"searchfriend"},
	{id:12,name:"机械展会",surl:"http://www.rajxw.com/search/searchexpo.asp" , title:"" , tracelog:"searchhelp"}
	]

/*热门关键字*/
var linkKeywords = [
	{id:1,name:"供应",surl:"热门关键字：<a href=\"http://selloffer/%E5%9D%AF%E5%B8%83.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>坯布</a> <a href=\"http://selloffer/%E5%B7%A5%E8%89%BA%E5%93%81.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>工艺品</a> <a href=\"http://selloffer/%E6%9A%96%E6%B0%94%E7%89%87.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>暖气片</a> <a href=\"http://selloffer/%E5%8E%8B%E5%85%8B%E5%8A%9B.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>压克力</a> <a href=\"/selloffer/%E8%9E%BA%E6%97%8B%E8%97%BB.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>螺旋藻</a> <a href=\"/selloffer/%E9%92%A3%E9%87%91.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>钣金</a> <a href=\"/selloffer/%E5%B0%BC%E9%BE%99%E7%AE%A1.html\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" class=textwhite>尼龙管</a> <a href=\"http://info.china.alibaba.com/biznews/pages/jingjia/jingjia_hot.html?Bidding=hothomemore\" target=_blank onMouseDown=\"return aliclick(this,'?tracelog=ui_homepage_searchbuykey');\" 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 < 30){
					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;
		}


}
