//JS版的Server.UrlEncode编码函数
function urlEncode(str) 
{ 
    str = str.replace(/./g,function(sHex) 
    { 
        window.EnCodeStr = ""; 
        window.sHex = sHex; 
        window.execScript('window.EnCodeStr=Hex(Asc(window.sHex))',"vbscript"); 
        return window.EnCodeStr.replace(/../g,"%$&"); 
    }); 
    return str; 
} 

function trim(s){return  s.replace(/(^\s*)|(\s*$)/g,  "");} 

function checksearch(theform)
{
//alert(theform.searchtype.value)
	var webdir = "/";
	var stype;
	if (trim(theform.key.value)=='')
	{alert('关键字不能为空');
	theform.key.focus();
	theform.key.value='';
	return false
	}
	if (theform.key.value=='请输入关键字')
	{alert('关键字不能为空');
	theform.key.focus();
	theform.key.value='';
	return false
	}

	switch(theform.searchtype.value)
	{
	case "1":
		stype="s";
		break;
	case "2":
		stype="a";
		break;
	case "3":
		stype="i";
		break;
	}

	if(navigator.userAgent.indexOf("MSIE")>0)
	{
		window.location.href=webdir+stype+"/?/"+urlEncode(trim(theform.key.value))+"/";
	}
	else
	{
		window.location.href=webdir+stype+"/?/"+trim(theform.key.value)+"/";
	}
	return false
}


function setTab(name, cursel, n) {
  for (i = 1; i <= n; i++) {
     var menu = document.getElementById(name + i);
     var con = document.getElementById("con_" + name + "_" + i);
     menu.className = i == cursel ? "hover" : "";
     con.style.display = i == cursel ? "block" : "none";
  }
}
