﻿function DateAdd(interval, number, date) {
    //date 可以是时间对象也可以是字符串，如果是后者，形式必须为: yyyy-mm-dd hh:mm:ss 其中分隔符不定。"2006年12月29日 16点01分23秒" 也是合法的  
    number = parseInt(number);
    if (typeof (date) == "string") {
        date = date.split(/\D/);
        --date[1];
        eval("var date = new Date(" + date.join(",") + ")");
    }
    if (typeof (date) == "object") {
        var date = date
    }
    switch (interval) {
        case "y": date.setFullYear(date.getFullYear() + number); break;
        case "m": date.setMonth(date.getMonth() + number); break;
        case "d": date.setDate(date.getDate() + number); break;
        case "w": date.setDate(date.getDate() + 7 * number); break;
        case "h": date.setHours(date.getHour() + number); break;
        case "n": date.setMinutes(date.getMinutes() + number); break;
        case "s": date.setSeconds(date.getSeconds() + number); break;
        case "l": date.setMilliseconds(date.getMilliseconds() + number); break;
    }
    return date;
}

function keyword_Clicked(oTxtBox) {
    //oTxtBox.select();
    if (oTxtBox.value == "在此输入搜索关键字")
        oTxtBox.value = "";
}

function keyword_Blur(oTxtBox) {
    if (oTxtBox.value == "")
        oTxtBox.value = "在此输入搜索关键字";
}

function Search_Clicked(oTxtBox) {
    //oTxtBox.select();
    if (oTxtBox.value == "在此输入产品名")
        oTxtBox.value = "";
}

function Search_Blur(oTxtBox) {
    if (oTxtBox.value == "")
        oTxtBox.value = "在此输入产品名";
}

function secBoard_2(n) {
    for (i = 1; i <= 4; i++) {
        document.getElementById("sectd" + i).className = "sec11";
    }
    document.getElementById("sectd" + n).className = "sec22";
    var maxTab = 4;
    var querTabID = "";
    for (var i = 1; i <= 4; i++) {
        queryTabID = "QueryTab" + i;
        if (n != i) {
            document.getElementById(queryTabID).style.display = "none";
        } else {
            document.getElementById(queryTabID).style.display = "block";
        }
    }
}

function navShow(n) {
    var querTabID = "";
    for (var i = 1; i <= 7; i++) {
        queryTabID = "li" + i;
        if (document.getElementById(queryTabID) != null) {
            if (n == i) {
                document.getElementById(queryTabID).className = "active";
            }
        }
    }
}

function seltTitle(strId1, strId2) {
    if (strId1 != null) {
        document.getElementById(strId1).className = "selt1";
    }
    if (strId2 != null) {
        document.getElementById(strId2).className = "selt2";
    }
    if (document.getElementById(strId1 + "Con") != null) {
        document.getElementById(strId1 + "Con").style.display = "block";
    }

    if (document.getElementById(strId2 + "Con") != null) {
        document.getElementById(strId2 + "Con").style.display = "none";
    }
}

function search(module) {
    var stQuery = "";
    var seprator = '&';
    var keyword = "";
    var url = "";
    keyword = Trim(document.getElementById("keyword").value);
    if (module == "supply") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }
        if ($("#selAreaIdByBox").length > 0) {
            if (document.getElementById("selAreaIdByBox").value != "0" && document.getElementById("selAreaIdByBox").value != "")
                stQuery += "region=" + document.getElementById("selAreaIdByBox").value + seprator;
        }
        if ($("#selSearchDate").length > 0) {
            if (document.getElementById('selSearchDate').value != "" && document.getElementById('selSearchDate').value != "0")
                stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }
        if ($("#DDListType").length > 0) {
            if (document.getElementById("DDListType").value != "")
                stQuery += "searchType=" + document.getElementById("DDListType").value;
        }
        if (stQuery.length > 0) {
            location.href = "/CN/Product/Supply/SupplyList.aspx?" + stQuery;
        } else {
            location.href = "/CN/Product/Supply/";
        }
    } else if (module == "ent") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }
        if ($("#selAreaIdByBox").length > 0) {
            if (document.getElementById("selAreaIdByBox").value != "0" && document.getElementById("selAreaIdByBox").value != "" && document.getElementById("selAreaIdByBox").value != "-1") {
                stQuery += "region=" + document.getElementById("selAreaIdByBox").value + seprator;
            }
        }
        if ($("#selSearchDate").length > 0) {
            if (document.getElementById('selSearchDate').value != "" && document.getElementById('selSearchDate').value != "0") {
                stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
            }
        }
        if (stQuery.length > 0) {
            location.href = "/CN/Ent/Supply/SupplierList.aspx?" + stQuery;
        } else {
            location.href = "/CN/Ent/Supply/";
        }
    } else if (module == "story") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }

        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }

        if (stQuery.length > 0) {
            location.href = "/CN/Biz/BizInformation.aspx?id=202&" + stQuery;
        } else {
            location.href = "/CN/Biz/BizInformation.aspx?id=202&";
        }
    }
    else if (module == "supplyC") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }
        if (document.getElementById("selAreaIdByBox").value != "0" && document.getElementById("selAreaIdByBox").value != "") {
            stQuery += "region=" + document.getElementById("selAreaIdByBox").value + seprator;
        }
        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }
        if (document.getElementById("DDListType").value != "") {
            stQuery += "searchType=" + document.getElementById("DDListType").value;
        }
        if (document.getElementById("HFNodeText").value != "") {
            stQuery += "NodeText=" + document.getElementById("HFNodeText").value;
        }
        if (document.getElementById("HidCurCategoryId").value != null && document.getElementById("HidCurCategoryId").value != "0") {
            stQuery += seprator + "id=" + document.getElementById("HidCurCategoryId").value;
        }

        if (stQuery.length > 0) {
            location.href = "/CN/Product/Supply/SupplyList.aspx?" + stQuery;
        } else {
            location.href = "/CN/Product/Supply/SupplyList.aspx";
        }
    } else if (module == "gift") {
        //商品名称
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + escape(keyword) + seprator;
        }
        //价格区间
        if (document.getElementById("selSearchDate").value != "选择价格" && document.getElementById("selSearchDate").value != "") {

            var price = document.getElementById("selSearchDate").value;
            if (price.indexOf("-") > -1) {
                stQuery += "minPrice=" + price.split('-')[0] + seprator;
                stQuery += "maxPrice=" + price.split('-')[1] + seprator;
            } else {
                stQuery += "minPrice=" + 2000 + seprator;
            }
        }
        //地区
        if (document.getElementById("selAreaIdByBox").value != "" && document.getElementById("selAreaIdByBox").value != "") {
            stQuery += "region=" + document.getElementById("selAreaIdByBox").value + seprator;
        }
        if (stQuery.length > 0) {
            location.href = "/CN/Gift/GiftList.aspx?" + stQuery;
        } else {
            location.href = "/CN/Gift/default.aspx";
        }
    } else if (module == "agent") {
        //判断搜索产品或是公告
        //        var type = document.getElementById("SelType").value;
        //关键字 
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + escape(keyword) + seprator;
        }
        //类别
        if (document.getElementById("CategoryId").value != "" && document.getElementById("HidCategory").value != "" && document.getElementById("HidCategory").value != "选择类别") {
            stQuery += "categoryId=" + document.getElementById("CategoryId").value + seprator + "HidCategory=" + escape(document.getElementById("HidCategory").value) + seprator;
        }
        //日期
        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value;
        }
        if (stQuery.length > 0) {
            location.href = "/CN/Agent/AgentPostList.aspx?" + stQuery;
        } else {
            location.href = "/CN/Agent/default.aspx";
        }
    }

    else if (module == "gov") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }

        if (document.getElementById("selAreaIdByBox").value != "0" && document.getElementById("selAreaIdByBox").value != "") {
            stQuery += "region=" + document.getElementById("selAreaIdByBox").value + seprator;
        }

        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value;
        }
        if (stQuery.length > 0) {
            location.href = "/CN/Product/Buy/BuyList.aspx?" + stQuery;
        } else {
            location.href = "/CN/Product/Buy/BuyList.aspx";
        }
    }

    else if (module == "TeamBuy") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }
        if (document.getElementById("SeleType").value != "0" && document.getElementById("SeleType").value != "") {
            stQuery += "SeleType=" + document.getElementById("SeleType").value + seprator;
        }
        if (stQuery.length > 0) {
            location.href = "/CN/TeamBuy/TeamBuyBiz.aspx?" + stQuery;
        } else {
            location.href = "/CN/TeamBuy/TeamBuyBiz.aspx";
        }
    }
    else if (module == "review") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }


        if (stQuery.length > 0) {
            location.href = "/CN/teambuy/review.aspx?" + stQuery;
        } else {
            location.href = "/CN/teambuy/review.aspx";
        }
    } else if (module == "news") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }

        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }

        if (stQuery.length > 0) {
            location.href = "/CN/Biz/BizInformation.aspx?" + stQuery;
        } else {
            location.href = "/CN/Biz/BizInformation.aspx";
        }
    }
    else if (module == "newsBS") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }

        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }

        if (stQuery.length > 0) {
            location.href = "/CN/Biz/BusinessSense.aspx?" + stQuery;
        } else {
            location.href = "/CN/Biz/BusinessSense.aspx";
        }
    }
    else if (module == "newsIE") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }

        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }

        if (stQuery.length > 0) {
            location.href = "/CN/Biz/IndustrialEconomy.aspx?" + stQuery;
        } else {
            location.href = "/CN/Biz/IndustrialEconomy.aspx";
        }
    } else if (module == "newsTF") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }

        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }

        if (stQuery.length > 0) {
            location.href = "/CN/Biz/TodayFocus.aspx?" + stQuery;
        } else {
            location.href = "/CN/Biz/TodayFocus.aspx";
        }
    }
    else if (module == "newsSC") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }

        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }

        if (stQuery.length > 0) {
            location.href = "/CN/SuccessStories/Businesslist.aspx?" + stQuery;
        } else {
            location.href = "/CN/SuccessStories/Businesslist.aspx";
        }
    }
    else if (module == "newsSL") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }

        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }

        if (stQuery.length > 0) {
            location.href = "/CN/SuccessStories/StoryList.aspx?" + stQuery;
        } else {
            location.href = "/CN/SuccessStories/StoryList.aspx";
        }
    }
    else if (module == "newsSCL") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }

        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }

        if (stQuery.length > 0) {
            location.href = "/CN/SuccessStories/Successlist.aspx?" + stQuery;
        } else {
            location.href = "/CN/SuccessStories/Successlist.aspx";
        }
    }
    else if (module == "JobEmploy") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }
        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;

        }
        if (stQuery.length > 0) {
            location.href = "/CN/Job/EmployerList.aspx?" + stQuery;
        }
        else {
            location.href = "/CN/Job/EmployerList.aspx";
        }


    } else if (module == "baDaHangYe") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }

        if (document.getElementById("selAreaIdByBox").value != "0" && document.getElementById("selAreaIdByBox").value != "") {
            stQuery += "region=" + document.getElementById("selAreaIdByBox").value + seprator;
        }

        if (document.getElementById('selSearchDate').value != "") {
            stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }

        type = document.getElementById("SelType").value;


        if (type == "supply") {
            if (stQuery.length > 0) {
                location.href = "/CN/Product/Supply/SupplyList.aspx?" + stQuery;
            } else {
                location.href = "/CN/Product/Supply/SupplyList.aspx";
            }
        } else if (type == "buy") {
            if (stQuery.length > 0) {
                location.href = "/CN/Product/Buy/BuyList.aspx?" + stQuery;
            } else {
                location.href = "/CN/Product/Buy/BuyList.aspx";
            }
        } else if (type == "enterprise") {


            if (stQuery.length > 0) {
                location.href = " /CN/Ent/Supply/SupplierList.aspx?" + stQuery;
            } else {
                location.href = "/CN/Ent/Supply/SupplierList.aspx";
            }
        } else if (type == "exposition") {
            if (stQuery.length > 0) {
                location.href = "/CN/Exp/Exposition/ExhInfo.aspx?" + stQuery;
            } else {
                location.href = "/CN/Exp/Exposition/ExhInfo.aspx";
            }
        } else if (type == "news") {
            if (stQuery.length > 0) {
                location.href = "/cn/Biz/BizInformation.aspx?" + stQuery;
            } else {
                location.href = "/cn/Biz/BizInformation.aspx";
            }
        }

    } else if (module == "buy") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword) + seprator;
        }
        if ($("#selAreaIdByBox").length > 0) {
            if (document.getElementById("selAreaIdByBox").value != "0" && document.getElementById("selAreaIdByBox").value != "")
                stQuery += "region=" + document.getElementById("selAreaIdByBox").value + seprator;
        }
        if ($("#selSearchDate").length > 0) {
            if (document.getElementById('selSearchDate').value != "" && document.getElementById('selSearchDate').value != "0")
                stQuery += "date=" + document.getElementById('selSearchDate').value + seprator;
        }

        if ($("#selregion").length > 0) {
            if (document.getElementById('selregion').value != "" && stQuery != "") {

                stQuery += "type=" + document.getElementById("selregion").value;
                if (document.getElementById("selregion").value == "0") {
                    if (stQuery.length > 0)
                        location.href = "/CN/Product/Buy/BuyList.aspx?" + stQuery;
                    else
                        location.href = "/CN/Product/Buy/";
                }
                else if (document.getElementById("selregion").value == "1") {
                    if (stQuery.length > 0)
                        location.href = "/CN/Product/Buy/GovProDemand.aspx?" + stQuery;
                    else
                        location.href = "/CN/Product/Buy/";
                }
                else {
                    if (stQuery.length > 0)
                        location.href = "/CN/Product/Buy/NewOrder.aspx?" + stQuery;
                    else
                        location.href = "/CN/Product/Buy/";
                }
            } else {
                if (stQuery.length > 0)
                    location.href = "/CN/Product/Buy/BuyList.aspx?" + stQuery;
                else
                    location.href = "/CN/Product/Buy/";
            }
        } else {
            if (stQuery.length > 0)
                location.href = "/CN/Product/Buy/BuyList.aspx?" + stQuery;
            else
                location.href = "/CN/Product/Buy/";
        }
    } else if (module == "mall") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword);
        }
        if ($("#selSearchDate").length > 0) {
            if (document.getElementById('selSearchDate').value != "" && document.getElementById('selSearchDate').value != "0")
                stQuery += seprator + "date=" + document.getElementById('selSearchDate').value;
        }
        if ($("#selAreaIdByBox").length > 0) {
            if (document.getElementById("selAreaIdByBox").value != "0" && document.getElementById("selAreaIdByBox").value != "")
                stQuery += seprator + "region=" + document.getElementById("selAreaIdByBox").value;
        }
        if (stQuery.length > 0) {
            location.href = "/CN/Mall/AssociationList.aspx?" + stQuery;
        } else {
            location.href = "/CN/Mall/Default.aspx";
        }
    }
    else if (module == "exp") {
        if (keyword != "" && keyword != "在此输入搜索关键字") {
            keyword = SqlFilter(keyword);
            stQuery += "keyword=" + encodeURIComponent(keyword);
        }
        if ($("#selSearchDate").length > 0) {
            if (document.getElementById('selSearchDate').value != "" && document.getElementById('selSearchDate').value != "0")
                stQuery += seprator + "date=" + document.getElementById('selSearchDate').value;
        }

        if ($("#SelExpType").length > 0) {
            type = document.getElementById("SelExpType").value;
            if (type != "") {
                if (type == "exhalbum") {
                    if (stQuery.length > 0)
                        location.href = "/CN/Exp/Album/ExhAlbum.aspx?" + stQuery;
                    else
                        location.href = "/CN/Exp/Album/ExhAlbum.aspx";
                } else if (type == "exhreported") {
                    if (stQuery.length > 0)
                        location.href = "/CN/Exp/Reported/ExhReported.aspx?" + stQuery;
                    else
                        location.href = "/CN/Exp/Reported/ExhReported.aspx";
                } else if (type == "exhwikipedia") {
                    if (stQuery.length > 0)
                        location.href = "/CN/Exp/Wikipedia/ExhWikipedia.aspx?" + stQuery;
                    else
                        location.href = "/CN/Exp/Wikipedia/ExhWikipedia.aspx";
                } else if (type == "default") {
                    if (stQuery.length > 0)
                        location.href = "/CN/Exp/Exposition/ExhInfo.aspx?" + stQuery;
                    else
                        location.href = "/CN/Exp/Exposition/ExhInfo.aspx";
                }
            } else {
                if (stQuery.length > 0)
                    location.href = "/CN/Exp/Exposition/ExhInfo.aspx?" + stQuery;
                else
                    location.href = "/CN/Exp/Exposition/ExhInfo.aspx";
            }
        }
    }
}

function SqlFilter(inputStr) {
    if (typeof (inputStr) != "string") {
        //判断是否是字符串类型
        return inputStr;
    }
    if (inputStr != '') {
        var tmpValue = inputStr;
        //以下搜索字符串中的特殊字符，如果存在，则替换成""
        while (tmpValue.indexOf(';') > -1) { tmpValue = tmpValue.replace(';', ''); }
        while (tmpValue.indexOf('<') > -1) { tmpValue = tmpValue.replace('<', ''); }
        while (tmpValue.indexOf('>') > -1) { tmpValue = tmpValue.replace('>', ''); }
        while (tmpValue.indexOf('--') > -1) { tmpValue = tmpValue.replace('--', ''); }
        while (tmpValue.indexOf(",") > -1) { tmpValue = tmpValue.replace(",", ""); }
        while (tmpValue.indexOf("'") > -1) { tmpValue = tmpValue.replace("'", ""); }
        while (tmpValue.indexOf("?") > -1) { tmpValue = tmpValue.replace("?", ""); }
        while (tmpValue.indexOf("!") > -1) { tmpValue = tmpValue.replace("!", ""); }
        while (tmpValue.indexOf("(") > -1) { tmpValue = tmpValue.replace("(", ""); }
        while (tmpValue.indexOf(")") > -1) { tmpValue = tmpValue.replace(")", ""); }
        while (tmpValue.indexOf("~") > -1) { tmpValue = tmpValue.replace("~", ""); }
        while (tmpValue.indexOf("#") > -1) { tmpValue = tmpValue.replace("#", ""); }
        while (tmpValue.indexOf("$") > -1) { tmpValue = tmpValue.replace("$", ""); }
        while (tmpValue.indexOf("%") > -1) { tmpValue = tmpValue.replace("%", ""); }
        while (tmpValue.indexOf("^") > -1) { tmpValue = tmpValue.replace("^", ""); }
        while (tmpValue.indexOf("&") > -1) { tmpValue = tmpValue.replace("&", ""); }
        while (tmpValue.indexOf("*") > -1) { tmpValue = tmpValue.replace("*", ""); }
        while (tmpValue.indexOf("|") > -1) { tmpValue = tmpValue.replace("|", ""); }
        while (tmpValue.indexOf(".") > -1) { tmpValue = tmpValue.replace(".", ""); }
        while (tmpValue.indexOf("-") > -1) { tmpValue = tmpValue.replace("-", ""); }
        while (tmpValue.indexOf("=") > -1) { tmpValue = tmpValue.replace("=", ""); }
        while (tmpValue.indexOf("+") > -1) { tmpValue = tmpValue.replace("+", ""); }
        return tmpValue; //重新显示更改后的变量
    }
    else {
        return inputStr;
    }
}

function quickSearch(module, keyword) {
    var stQuery = "";
    if (module == "supply" && keyword != "") {

        location.href = "/CN/Product/Supply/SupplyList.aspx?keyword=" + encodeURIComponent(keyword);

    } else if (module == "buy" && keyword != "") {
        location.href = "/CN/Product/Buy/BuyList.aspx?keyword=" + encodeURIComponent(keyword);

    } else if (module == "ent" && keyword != "") {

        location.href = "CN/Cache/SupplierListStatic.aspx?keyword=" + encodeURIComponent(keyword);

    } else if (module == "news" && keyword != "") {

        location.href = "/CN/Biz/BizInformation.aspx?keyword=" + encodeURIComponent(keyword);

    }
}

function searchEntByAddr(address) {
    if (Trim(address) != "")
        location.href = "CN/Cache/SupplierListStatic.aspx?address=" + encodeURIComponent(address);
}


// 去掉字符串的头空格（左空格）
function LTrim(str) {
    var i;
    for (i = 0; i < str.length; i++) {
        if (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) != " ") break;
    }
    str = str.substring(0, i + 1);
    return str;
}

// 去掉字符串的头尾空格（左右空格）
function Trim(str) {
    return LTrim(RTrim(str));
}


function OpenRegionBox() {
    var dialogArg = new Object();
    dialogArg.selectedAreaName = "";
    dialogArg.selectedAreaId = "";
    dialogArg.selectedLayer = "";
    var dialogFeature = "dialogWidth=410px;dialogHeight=450px;status:off;scroll=no";

    var isSubmit = window.showModalDialog("/Common/AreaSelect.htm", dialogArg, dialogFeature);

    if (isSubmit) {
        document.getElementById("selAreaNameByBox").value = dialogArg.selectedAreaName;
        document.getElementById("hidSelAreaNameByBox").value = dialogArg.selectedAreaName;
        document.getElementById("selAreaIdByBox").value = dialogArg.selectedAreaId;
        document.getElementById("selAreaLayer").value = dialogArg.selectedLayer;
    }
}

function OpenRegionBox1(AreaNameCId, AreaCId, HidAreaNameCId, HidAreaCodeCId, HidZipCodeCId) {

    var dialogArg = new Object();
    dialogArg.selectedAreaName = "";
    dialogArg.selectedAreaId = "";
    dialogArg.selectedLayer = "";
    dialogArg.selectedAreaCode = "";
    dialogArg.selectedZipCode = "";

    var dialogFeature = "dialogWidth=410px;dialogHeight=450px;status:off;scroll=no";

    var isSubmit = window.showModalDialog("/Common/AreaSelect.htm", dialogArg, dialogFeature);

    if (isSubmit) {
        if (document.getElementById(AreaNameCId) != null) {
            document.getElementById(AreaNameCId).value = dialogArg.selectedAreaName;
        }
        if (document.getElementById(AreaCId) != null) {
            document.getElementById(AreaCId).value = dialogArg.selectedAreaId;
        }
        if (HidAreaNameCId != null && document.getElementById(HidAreaNameCId) != null) {
            document.getElementById(HidAreaNameCId).value = dialogArg.selectedAreaId;
        }
        if (HidAreaCodeCId != null && document.getElementById(HidAreaCodeCId) != null) {
            document.getElementById(HidAreaCodeCId).value = dialogArg.selectedAreaCode;
        }
        if (HidZipCodeCId != null && document.getElementById(HidZipCodeCId) != null) {
            document.getElementById(HidZipCodeCId).value = dialogArg.selectedZipCode;
        }
    }
}

//产品类别选择窗口
function OpenProCatetoryBox() {

    var dialogArg = new Object();
    dialogArg.selectedCategoryName = "";
    dialogArg.selectedCategoryId = "";
    var dialogFeature = "dialogWidth=550px;dialogHeight=580px;status:off;scroll=no";

    var isSubmit = window.showModalDialog("/Common/ProductCategorySelect.htm", dialogArg, dialogFeature);
    //    alert(isSubmit);
    if (isSubmit) {
        if (document.getElementById("ctl00_ContentPlaceHolder1_Category") != null)
            document.getElementById("ctl00_ContentPlaceHolder1_Category").value = dialogArg.selectedCategoryName;
        if (document.getElementById("ctl00_ContentPlaceHolder1_HidCategory") != null)
            document.getElementById("ctl00_ContentPlaceHolder1_HidCategory").value = dialogArg.selectedCategoryName;
        if (document.getElementById("ctl00_ContentPlaceHolder1_CategoryId") != null)
            document.getElementById("ctl00_ContentPlaceHolder1_CategoryId").value = dialogArg.selectedCategoryId;

        if (document.getElementById("ctl00_ContentPlaceHolder1_txtCategoryName") != null)
            document.getElementById("ctl00_ContentPlaceHolder1_txtCategoryName").value = dialogArg.selectedCategoryName;
        if (document.getElementById("ctl00_ContentPlaceHolder1_hidCategoryId") != null)
            document.getElementById("ctl00_ContentPlaceHolder1_hidCategoryId").value = dialogArg.selectedCategoryId;
    }
}
// 产品传参类别窗口
function OpenProCatetoryBox1(hfCategoryId, hfCategoryName, txtCategoryName) {

    var dialogArg = new Object();
    dialogArg.selectedCategoryName = "";
    dialogArg.selectedCategoryId = "";
    var dialogFeature = "dialogWidth=550px;dialogHeight=580px;status:off;scroll=no";

    var isSubmit = window.showModalDialog("/Common/ProductCategorySelect.htm", dialogArg, dialogFeature);
    //    alert(isSubmit);
    if (isSubmit) {
        if (document.getElementById(hfCategoryName) != null)
            document.getElementById(hfCategoryName).value = dialogArg.selectedCategoryName;
        if (document.getElementById(hfCategoryName) != null)
            document.getElementById(hfCategoryName).value = dialogArg.selectedCategoryName;
        if (document.getElementById(hfCategoryId) != null)
            document.getElementById(hfCategoryId).value = dialogArg.selectedCategoryId;

        if (document.getElementById(txtCategoryName) != null)
            document.getElementById(txtCategoryName).value = dialogArg.selectedCategoryName;
        if (document.getElementById(hfCategoryId) != null)
            document.getElementById(hfCategoryId).value = dialogArg.selectedCategoryId;
    }
}

//放到前台的类别选择窗口
function OpenProCatetoryBoxWai() {

    var dialogArg = new Object();
    dialogArg.selectedCategoryName = "";
    dialogArg.selectedCategoryId = "";
    var dialogFeature = "dialogWidth=550px;dialogHeight=580px;status:off;scroll=no";

    var isSubmit = window.showModalDialog("/Common/ProductCategorySelect.htm", dialogArg, dialogFeature);
    //    alert(isSubmit);
    if (isSubmit) {
        if (document.getElementById("Category") != null)
            document.getElementById("Category").value = dialogArg.selectedCategoryName;
        if (document.getElementById("HidCategory") != null)
            document.getElementById("HidCategory").value = dialogArg.selectedCategoryName;
        if (document.getElementById("CategoryId") != null)
            document.getElementById("CategoryId").value = dialogArg.selectedCategoryId;

        if (document.getElementById("txtCategoryName") != null)
            document.getElementById("txtCategoryName").value = dialogArg.selectedCategoryName;
        if (document.getElementById("hidCategoryId") != null)
            document.getElementById("hidCategoryId").value = dialogArg.selectedCategoryId;
    }
}


//企业自定义产品类别选择窗口
function OpenEntProCategoryBox(EntId, CurCategoryId, CategoryIDId, CategoryNameId, HidCategoryNameId) {

    var dialogArg = new Object();
    dialogArg.selectedCategoryName = "";
    dialogArg.selectedCategoryId = "";
    dialogArg.CurCategoryId = CurCategoryId;
    dialogArg.EntId = EntId;

    var dialogFeature = "dialogWidth=550px;dialogHeight=650px;status:off;scroll=no";

    var isSubmit = window.showModalDialog("/Common/EntProductCategoryTree.htm", dialogArg, dialogFeature);
    if (isSubmit) {
        if (document.getElementById(CategoryIDId) != null)
            document.getElementById(CategoryIDId).value = dialogArg.selectedCategoryId;
        if (document.getElementById(CategoryNameId) != null)
            document.getElementById(CategoryNameId).value = dialogArg.selectedCategoryName;
        if (document.getElementById(HidCategoryNameId) != null)
            document.getElementById(HidCategoryNameId).value = dialogArg.selectedCategoryName;
    }
}

function OpenCntProCategoryBox(EntId, CurCategoryId, CategoryIDId, CategoryNameId, HidCategoryNameId) {

    var dialogArg = new Object();
    dialogArg.selectedCategoryName = "";
    dialogArg.selectedCategoryId = "";
    dialogArg.CurCategoryId = CurCategoryId;
    dialogArg.EntId = EntId;

    var dialogFeature = "dialogWidth=550px;dialogHeight=650px;status:off;scroll=no";

    var isSubmit = window.showModalDialog("/Common/CntProductCategoryTree.htm", dialogArg, dialogFeature);
    if (isSubmit) {
        if (document.getElementById(CategoryIDId) != null)
            document.getElementById(CategoryIDId).value = dialogArg.selectedCategoryId;
        if (document.getElementById(CategoryNameId) != null)
            document.getElementById(CategoryNameId).value = dialogArg.selectedCategoryName;
        if (document.getElementById(HidCategoryNameId) != null)
            document.getElementById(HidCategoryNameId).value = dialogArg.selectedCategoryName;
    }
}

//行业类别选择窗口
function OpenEntCategoryBox(selCategoryID, hidCategoryID) {
    var selCategory = document.getElementById(selCategoryID);
    var dialogArg = new Object();
    dialogArg.selectedCategoryName = "";
    dialogArg.selectedCategoryID = "";
    dialogArg.curCategoryID = "";

    //取原来类别
    if (selCategory != null && selCategory.options.length > 0) {
        for (var i = 0; i < selCategory.options.length; i++) {
            dialogArg.curCategoryID += selCategory.options[i].value + ",";
        }
    }

    var dialogFeature = "dialogWidth=420px;dialogHeight=610px;status:off;scroll=no";
    var isSubmit = window.showModalDialog("/Common/EntCategoryCheck.htm", dialogArg, dialogFeature);
    if (isSubmit) {

        if (document.getElementById(hidCategoryID) != null)
            document.getElementById(hidCategoryID).value = dialogArg.selectedCategoryID;

        if (selCategory != null) {

            selCategory.options.length = 0;
            var ids = dialogArg.selectedCategoryID.split(',');
            var names = dialogArg.selectedCategoryName.split(',');
            if (ids.length > 0 && names.length > 0) {
                for (var i = 0; i < ids.length; i++) {
                    if (ids[i] != "" && names[i] != "")
                        selCategory.options.add(new Option(names[i], ids[i]));
                }
            }

        }
    }
}


//行业类别选择窗口
function EnOpenEntCategoryBox(selCategoryID, hidCategoryID) {
    var selCategory = document.getElementById(selCategoryID);
    var dialogArg = new Object();
    dialogArg.selectedCategoryName = "";
    dialogArg.selectedCategoryID = "";
    dialogArg.curCategoryID = "";

    //取原来类别
    if (selCategory != null && selCategory.options.length > 0) {
        for (var i = 0; i < selCategory.options.length; i++) {
            dialogArg.curCategoryID += selCategory.options[i].value + ",";
        }
    }

    var dialogFeature = "dialogWidth=420px;dialogHeight=610px;status:off;scroll=no";
    var isSubmit = window.showModalDialog("/Common/EnEntCategoryCheck.htm", dialogArg, dialogFeature);
    if (isSubmit) {

        if (document.getElementById(hidCategoryID) != null)
            document.getElementById(hidCategoryID).value = dialogArg.selectedCategoryID;

        if (selCategory != null) {

            selCategory.options.length = 0;
            var ids = dialogArg.selectedCategoryID.split(',');
            var names = dialogArg.selectedCategoryName.split(',');
            if (ids.length > 0 && names.length > 0) {
                for (var i = 0; i < ids.length; i++) {
                    if (ids[i] != "" && names[i] != "")
                        selCategory.options.add(new Option(names[i], ids[i]));
                }
            }

        }
    }
}

//*************************  前台例表  **********************************//
//单个选中存到翻页数组
function adminEnter_tempCheckOne(ob) {
    if (ob.checked) {
        var value = ob.value;
        adminEnter_enterpriceArr[adminEnter_enterpriceArr.length] = value;
    } else {
        for (var i = 0; i < adminEnter_enterpriceArr.length; i++) {
            if (ob.value == adminEnter_enterpriceArr[i]) {
                adminEnter_enterpriceArr.splice(i, 1);
            }
        }
        for (var i = 0; i < adminEnter_ckArr.length; i++) {
            if (ob.value == adminEnter_ckArr[i]) {
                adminEnter_ckArr.splice(i, 1);
            }
        }
    }
}

//全选存到翻页数组
function adminEnter_tempCheckAll() {
    var isCheck = document.getElementsByTagName("input");
    for (var i = 0; i < isCheck.length; i++) {
        for (var j = 0; j < adminEnter_enterpriceArr.length; j++) {
            if (isCheck[i].value == adminEnter_enterpriceArr[j]) {
                adminEnter_enterpriceArr.splice(j, 1);
            }
        }
        if (isCheck[i].type == "checkbox" && isCheck[i].checked == true && isCheck[i] !=
document.getElementById("selid")) {
            adminEnter_enterpriceArr[adminEnter_enterpriceArr.length] =
isCheck[i].value;
        } else if (isCheck[i].type == "checkbox" && isCheck[i].checked == false) {
            for (var j = 0; j < adminEnter_enterpriceArr.length; j++) {
                if (isCheck[i].value == adminEnter_enterpriceArr[j]) {
                    adminEnter_enterpriceArr.splice(j, 1);
                }
            }
            for (var j = 0; j < adminEnter_ckArr.length; j++) {
                if (isCheck[i].value == adminEnter_ckArr[j]) {
                    adminEnter_ckArr.splice(j, 1);
                }
            }
        }
    }
}
//翻页后选中状态
function adminEnter_returnCheck() {
    var isCheck = document.getElementsByTagName("input");
    if (adminEnter_enterpriceArr.length > 0) {
        for (var i = 0; i < adminEnter_enterpriceArr.length; i++) {
            for (var j = 0; j < isCheck.length; j++) {
                if (isCheck[j].type == "checkbox" && adminEnter_enterpriceArr[i] ==
isCheck[j].value) {
                    isCheck[j].checked = true;
                }
            }
        }
    }
}

function adminEnter_returnCk() {
    if (adminEnter_ckArr != "") {
        var isCheck = document.getElementsByTagName("input");
        if (adminEnter_ckArr.length > 0) {
            for (var i = 0; i < adminEnter_ckArr.length; i++) {
                adminEnter_arr[i] = adminEnter_ckArr[i];
                for (var j = 0; j < isCheck.length; j++) {
                    if (isCheck[j].type == "checkbox" && adminEnter_ckArr[i] ==
isCheck[j].value) {
                        isCheck[j].checked = true;
                    }
                }
            }
        }
    }
}

//例表钩选checkbox
function adminEnter_selectall(c) {
    var ck = document.getElementsByTagName("input");
    for (var i = 0; i < ck.length; i++) {
        if (ck[i].type == "checkbox") {
            ck[i].checked = c.checked;
        }
    }
}


//***************************************************//
