﻿function searchLine()
{
  var keyword=document.getElementById("txtkeyword");
  var drptype=document.getElementById("drptype");
  if(keyword.value=="输入您感兴趣的产品或其它关键词")
  {
     alert("输入您感兴趣的产品或其它关键词！");
     keyword.focus();
     return false;
  }
//  alert(drptype.value);
//  return false;
  switch(drptype.value)
  {
    case "1":
        window.location.href="/product/?para="+EnCodes(keyword.value);
        break;
    case "2":
        window.location.href="/Company/defaultview.aspx?para="+EnCodes(keyword.value);
        break;
    case "3":
        window.location.href="/supply/infor.aspx?key="+EnCodes(keyword.value);
        break;
    case "4":
        window.location.href = "/build/list.aspx?key=" + EnCodes(keyword.value);
        break;
  }
}

function EnCodes(words)
{
   var Keyword=base64encode(utf16to8(words));
   //Keyword = Keyword.replace(/\u002B/g, "\%2B"); 
   Keyword = Keyword.replace(/\+/g, "\%2B"); 
   return Keyword;

}
//品牌搜索
function BrandSearch() 
{
    var txtbrandkey = document.getElementById("txtbrandkey");
    var drptype = document.getElementById("drtype");
    if (RTrim(LTrim(txtbrandkey.value)) == "" && drptype.value == "")
    {
        alert("品牌分类或品牌关键字请至少选择一项查询！");
        txtbrandkey.focus();
        return false;
    }
    window.location.href = "/interact/brand.aspx?type=" + drptype.value + "&key=" + EnCodes(txtbrandkey.value);
}

//供求搜索
function SupSearch(suptype) {
    var txtsupkey = document.getElementById("txtsupkey");
    if (RTrim(LTrim(txtsupkey.value)) == "") {
        alert("请输入查询关键字！");
        txtsupkey.focus();
        return false;
    }
    window.location.href = "/supply/infor.aspx?type=" + suptype + "&key=" + EnCodes(txtsupkey.value);
}

//快速发布供求
function FastGq() {
    var txtsupkey = document.getElementById("fastword");
    if (RTrim(LTrim(txtsupkey.value)) == "") {
        alert("请输入发布主题！");
        txtsupkey.focus();
        return false;
    }
    window.location.href = "/supply/upsp.aspx?key=" + EnCodes(txtsupkey.value);
}


function LTrim(str) {
    var i;
    for (i = 0; i < str.length; i++) {
        if (str.charAt(i) != " " && str.charAt(i) != " ") break;
    }
    str = str.substring(i, str.length);
    return str;
}

function RTrim(str) {
    var i;
    for (i = str.length - 1; i >= 0; i--) {
        if (str.charAt(i) != " " && str.charAt(i) != " ") break;
    }
    str = str.substring(0, i + 1);
    return str;
} 


