/*
* 函数说明：取cookie值
* 参数：	cookie字段名
* 返回值：	cookie值
* 时间：2005-5-12
*/
document.write("<script language=\"javascript\" type=\"text/javascript\" src=\"http://style.china.alibaba.com/js/common/aliclick.js\"></script>");
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;
}
function $(divName){
return document.getElementById(divName);
}
function trim(inputString) {
return inputString.replace(/^ +/,"").replace(/ +$/,"");
}
/*
* 函数说明：去除头尾空格
* 参数：	字符串
* 返回值：	无
* 时间：2005-5-12
*/
function show_menu(obj_s,obj){
var  s_id = document.getElementById(obj_s);
var  sc_id = document.getElementById(obj);
s_id.style.display = "";
sc_id.className = "off";
}
function hide_menu(obj_h,obj){
var  h_id = document.getElementById(obj_h);
var  hc_id = document.getElementById(obj);
h_id.style.display = "none";
hc_id.className = "on";
}
/*
* 函数说明：取历史记录
* 参数：	sKwId:显示的容器id,nNum:显示搜索记录的个数
* 时间：2007-11-20
*/
function getHistoryWords(sKwId,nNum){
var keys_str = getCookie('h_keys');
if (keys_str != null) {
var keys_array = keys_str.split("#");
if (keys_array.length >= 3) {
var strlen = 0;
var str = "最近搜索记录：";
for (var i = 0; i < keys_array.length && i < nNum; i++) {
var key = keys_array[i];
if(key.indexOf("[") != -1 && key.indexOf("]") != -1) {
// 兼容老的cookie格式
key = key.substring(0, key.length - 3);
}
strlen = strlen + key.length;
if (strlen < nNum*12) {
str += " <a target=_blank href=http://search.china.alibaba.com/selloffer/" + encodeURI(key) + ".html?tracelog=toplist_historyky class=textwhite onMouseDown=\"return aliclick(this,'?tracelog=toplist_historyky');\">" + key + "</a> ";
}
}
document.getElementById(sKwId).innerHTML=str;
}
}
}
/*
*函数说明：搜索表单提交处理
*判空和指定长度
*2008-04-03
*/
function searchProcess(divName,keys,url){
if(trim($(keys).value)==''||$(keys).value.substring(0,3)=="请输入"){
alert("请输入关键字");
return false;
}
else if($(keys).value.length>100){
alert("您输入的关键字过长");
return false;
}
else if(url==' '){
return true;
}
else{
window.open(url+'?keywords='+trim($('keys').value));
}
}
