﻿function TabClick(region, tab, tabs) {
    for (var i = 1; i <= tabs; i++) {
        $("#" + region + "Title" + i).removeAttr("class");
        $("#" + region + "Title" + i).attr("class", "");

        $("#" + region + i).hide();
    }
    $("#" + region + "Title" + tab).attr("class", "tab_current");
    $("#" + region + tab).show();
}

function Clear(obj) {
    if (obj.value == "请输入查询内容") {
        obj.value = "";
    }
}
//搜索类型：1:新闻 2:技术文章 3:企业 4:供应 5:求购 6:招商 7:代理 8:价格 9:批发市场
function search() {
    var q = $('#q').val();
    var arr = new Array()
    arr[0] = "sell";
    arr[1] = "buy";
    arr[2] = "Invest";
    arr[3] = "company";
    arr[4] = "news";
    arr[5] = "tech";
    if (q == "") {
        alert("请输入要查询的关键字！");
    }
    else {
        for (var i = 0; i < arr.length; i++) {
            var classes = $("#" + arr[i]).attr("class");
            if (classes == "tab_current") {
                location.href = "/" + arr[i] + "/List?q=" + encodeURI(q);
            }
        }
    }
    return false;
}   

function Go() {
    var q = $('#q').val();
    var type = $("input[name=RadioGroup]:checked:").attr("value");
    if (q == "") {
        alert("请输入要查询的关键字！");
    }
    else {
        if (type + "" == "undefined") {
            alert("请选择查询类别！");
        }
        else {
            switch (type + "") {
                case "4":
                    location.href = "/Sell/List?q=" + encodeURI(q);
                    break;
                case "5":
                    location.href = "/Buy/List?q=" + encodeURI(q);
                    break;
                case "6":
                    location.href = "/Invest/List?q=" + encodeURI(q);
                    break;
                case "3":
                    location.href = "/Company/List?q=" + encodeURI(q);
                    break;
                case "1":
                    location.href = "/News/List?q=" + encodeURI(q);
                    break;
                case "2":
                    location.href = "/Tech/List?q=" + encodeURI(q);
                    break;
            }
        }
    }
    return false;
}

function ListGo() {
    var q = $('#listq').val();
    var type = $("input[name=listRadioGroup]:checked:").attr("value");
    if (q == "" || q == "请输入查询内容") {
        alert("请输入要查询的关键字！");
    }
    else {
        switch (type + "") {
            case "0":
                location.href = "/Sell/List?q=" + encodeURI(q);
                break;
            case "1":
                location.href = "/Buy/List?q=" + encodeURI(q);
                break;
            case "2":
                location.href = "/Invest/List?q=" + encodeURI(q);
                break;
            case "3":
                location.href = "/Company/List?q=" + encodeURI(q);
                break;
            case "4":
                location.href = "/News/List?q=" + encodeURI(q);
                break;
            case "5":
                location.href = "/Tech/List?q=" + encodeURI(q);
                break;
        }
    }
    return false;
}
//Tab切换时改变样式
function tabChange(obj) {
    $("[name=RadioGroup][class=tab_current]").attr("class", "");
    searchType = obj.value;
    if (typeof $("#" + obj.id).attr("tag") != "undefined")
        searchCateID = $("#" + obj.id).attr("tag");
    $(obj).attr("class", "tab_current");
    AutoComplete();
} 
//根据省获取市
function GetCityArea(areaID) {
    for (i = 0; i < areas.length; i++) {
        if (areas[i][2] == areaID) {
            if (areas[i][1].substring(2, 3) > 0)
                $("#selectCityArea").append("<option value='" + areas[i][1] + "'>" + areas[i][0] + "</option>");
            else if (areas[i][1].substring(3, 4) > 0)
                $("#selectCityArea").append("<option value='" + areas[i][1] + "'>" + areas[i][0] + "</option>");
        }
    }
}



