﻿document.getElementById("s1").className = "";
document.getElementById("s2").className = "";
document.getElementById("s3").className = "";
document.getElementById("s4").className = "";

var intNum = 1;

var url = window.location.href;
var kword;
kword = getParameter("keyword", url);
if (kword != "")
    document.getElementById("searchKeyword").value = kword.split("=")[1];

var flag = getParameter("f", url);
if (flag != "") {
    intNum = flag.split("=")[1];
    if (intNum == "")
        document.getElementById('s1').className = "sousuoA_shiyan";
    else
        document.getElementById('s' + intNum).className = "sousuoA_shiyan";
    
}
else
    document.getElementById('s1').className = "sousuoA_shiyan";


   
 function CheckSearch(){

    var initurl = new Array(4);
    initurl[0] = "http://www.51zszy.com/Mart/TradeSearch.aspx?PostType=1&f=1&keyword=" + document.getElementById("searchKeyword").value;
    initurl[1] = "http://www.51zszy.com/Mart/TradeSearch.aspx?PostType=2&f=2&keyword=" + document.getElementById("searchKeyword").value;
    initurl[2] = "http://www.51zszy.com/News/search_list.aspx?PostType=2&f=3&keyword=" + document.getElementById("searchKeyword").value;
    initurl[3] = "http://www.51zszy.com/News/search_list.aspx?PostType=1&f=4&keyword=" + document.getElementById("searchKeyword").value;

    var keyword;

    keyword = document.getElementById("searchKeyword").value; 

    if(keyword == "" || keyword.substring(0,3) =="请输入"){
        alert("请填写搜索关键词！");
        document.getElementById("searchKeyword").focus();
        event.returnValue = false;
        return;
    }

    if(keyword.length < 1 ) {
        alert("搜索关键词最少要 1 个字符！");
        document.getElementById("searchKeyword").focus();
        event.returnValue = false;
        return;
    }

    window.location.href = initurl[intNum - 1];
}
function doClick(flag) {

    document.getElementById("s1").className = "";
    document.getElementById("s2").className = "";
    document.getElementById("s3").className = "";
    document.getElementById("s4").className = "";
    intNum = flag;

    switch (flag) {
        case 1:
            document.getElementById("searchKeyword").value = "请输入 供应 关键词 !";
            document.getElementById("s1").className = "sousuoA_shiyan";
            break;
        case 2:
            document.getElementById("searchKeyword").value = "请输入 求购 关键词 !";
            document.getElementById("s2").className = "sousuoA_shiyan";
            break;
        case 3:
            document.getElementById("searchKeyword").value = "请输入 技术 关键词 !";
            document.getElementById("s3").className = "sousuoA_shiyan";
            break;
        case 4:
            document.getElementById("searchKeyword").value = "请输入 新闻 关键词 !";
            document.getElementById("s4").className = "sousuoA_shiyan";
            break;
        default:
            document.getElementById("searchKeyword").value = "请输入 供应 关键词 !";
            document.getElementById("s1").className = "sousuoA_shiyan";
            break;
    }
}

function DelDefaultText() {
    var keyword;

    keyword = document.getElementById("searchKeyword").value;

    if (keyword == "" || keyword.substring(0, 3) == "请输入") {
        document.getElementById("searchKeyword").value = "";
    }
}

function getParameter(paraStr, url) {
    var result = "";
    //获取URL中全部参数列表数据
    var str = "&" + url.split("?")[1];
    var paraName = paraStr + "=";
    //判断要获取的参数是否存在
    if (str.indexOf("&" + paraName) != -1) {
        //如果要获取的参数到结尾是否还包含“&”
        if (str.substring(str.indexOf(paraName), str.length).indexOf("&") != -1) {
            //得到要获取的参数到结尾的字符串
            var TmpStr = str.substring(str.indexOf(paraName), str.length);
            //截取从参数开始到最近的“&”出现位置间的字符
            result = TmpStr.substr(TmpStr.indexOf(paraName), TmpStr.indexOf("&") - TmpStr.indexOf(paraName));
        }
        else {
            result = str.substring(str.indexOf(paraName), str.length);
        }
    }
    else {
        result = "";
    }
    return (result.replace("&", ""));
}