
var searchActivedItem=1;
var tracelogStr="";
var otherParamStr="";
var searchFormObj = null;
var tracelogInput = null;

function SB_OnBlur_x(ctrlObj,ctrlMenuID, event){
	if(searchActivedItem == 1){
		return SB_OnBlur(ctrlObj,ctrlMenuID, event)
	}else{
		return true;
	}
}
function SB_OnKeyDown_x(ctrlObj,ctrlMenuID, event){
	if(searchActivedItem == 1){
		return SB_OnKeyDown(ctrlObj,ctrlMenuID, event)
	}else{
		return true;
	}
}
function SB_OnKeyUp_x(ctrlObj,ctrlMenuID, event){
	if(searchActivedItem == 1){
		return SB_OnKeyUp(ctrlObj,ctrlMenuID, event)
	}else{
		return true;
	}
}
function searchInit(num,tracelog,otherParam){
	tracelogStr = tracelog;
	otherParamStr = otherParam;
	document.searchform.method=="get";
	if(document.getElementById("searchform")!=null){
		searchFormObj = document.getElementById("searchform");
	}else{
		if(document.getElementsByName("searchform").length!=0){
			searchFormObj = document.getElementsByName("searchform")[0];
		}
	}
	if(document.searchform.tracelog){
	}else{
		    tracelogInput = document.createElement("input");
			tracelogInput.setAttribute("name","tracelog");
			tracelogInput.setAttribute("type","hidden");
			document.searchform.appendChild(tracelogInput);
	}
	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 = searchFormObj.terms.value;
	if(trim(v) == "" || v.substring(0,3) =="请输入")searchFormObj.terms.value = data[searchID-1].title;
  

    var search_href="http://so.toocle.com/web/trade.htm";
    if(searchID=="1")
       search_href="http://so.toocle.com/web/trade.htm";
    else if(searchID=="2")
    	 search_href="http://china.toocle.com/Q/index.cgi";
    else if(searchID=="3")
    	 search_href="http://so.toocle.com/web/comp.htm";
    else if(searchID=="4")
    	 search_href="http://so.toocle.com/web/forum.htm";
    else if(searchID=="5")
    	 search_href="http://so.toocle.com/web/news.htm";
    else if(searchID=="6")
    	 search_href="http://so.toocle.com/web/trade.htm";
    else if(searchID=="7")
    	 search_href="http://search.toocle.com/search.jsp";
    document.getElementById('searchform').action=search_href;
   // alert(document.getElementById('searchform').action);
 }
function checkform(){
	var v = trim(searchFormObj.terms.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="?";
//if(searchActivedItem == 11){
//var action_url = data[searchActivedItem-1].surl + searchFormObj.keywords.value + ".html?tracelog="+tracelogStr+data[searchActivedItem-1].tracelog+otherParamStr;}
//else{
//var action_url = data[searchActivedItem-1].surl + s + "keywords=" + searchFormObj.keywords.value + "&tracelog="+tracelogStr+data[searchActivedItem-1].tracelog+otherParamStr;}
//searchFormObj.action = action_url; //给form的action付值
//	if(tracelogInput!=null)tracelogInput.value=tracelogStr+data[searchActivedItem-1].tracelog;//给form的tracelog付值
}
/*
 * 函数说明：去除头尾空格
 * 参数：	字符串
 * 返回值：	无
 * 时间：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://so.toocle.com/web/trade.htm" , title:"" , tracelog:"terms"},
	{id:2,name:"生意圈",surl:"http://so.toocle.com/web/comp.htm" , title:"", tracelog:"search2"},
	{id:3,name:"公司",surl:"http://search.china.alibaba.com/search/company_search.htm" , title:"" , tracelog:"searchcom"},
	{id:4,name:"供应商",surl:"http://so.toocle.com/web/comp.htm",title:"" , tracelog:"search3"},
	{id:5,name:"生意经",surl:"http://china.toocle.com/forum/search/" , title:"" , tracelog:"search4"},
	{id:6,name:"资讯",surl:"http://so.toocle.com/web/news.htm" , title:"",tracelog:"search5"},
	{id:7,name:"商机",surl:"http://so.toocle.com/web/comp.htm" , title:"" , tracelog:"search6"},
	{id:8,name:"行业联盟",surl:"http://so.toocle.com/web/comp.htm" , title:"" , tracelog:"search7"},
	{id:9,name:"商机2",surl:"http://so.toocle.com/web/comp.htm" , title:"" , tracelog:"search8"},
	{id:10,name:"商机3",surl:"http://so.toocle.com/web/comp.htm" , title:"" , tracelog:"search9"},
	{id:11,name:"商机4",surl:"http://so.toocle.com/web/comp.htm" , title:"" , tracelog:"search10"}
	]

/*热门关键字*/
var linkKeywords = [
	{id:1,name:"供应",surl:"热门关键字："},

	{id:2,name:"求购",surl:"热门关键字："},


	{id:3,name:"公司",surl:'热门关键字：'},

	{id:4,name:"行情",surl:'热门关键字： '},

	{id:5,name:"经验",surl:'热门关键字： '},

	{id:6,name:"博客",surl:'热门关键字： '},

	{id:7,name:"报价",surl:'热门关键字：'},
	{id:8,name:"代理",surl:'热门关键字：'},
	{id:9,name:"加工",surl:'热门关键字：'},
	{id:10,name:"产品",surl:'热门关键字： '},
  {id:11,name:"商友",surl:'热门关键字： '}
]



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=http://search.china.alibaba.com/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=http://search.china.alibaba.com/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;
		}


}


