﻿$(function () {
    $(".nowSearch").toggle(
            function () {
                $(".selOption").slideDown("fast");
            },
             function () {
                 $(".selOption").slideUp("fast");
             }
            );

    $(".selOption li").click(function () {
        $(".selOption").slideUp("fast");
        $(".nowSearch").html($(this).html());
        $("#cateID").val($(this).attr("value"));
    })

    $(".btnSel").toggle(
            function () {
                $(".selOption").slideDown("fast");
            },
             function () {
                 $(".selOption").slideUp("fast");
             }
            );

    $(".selOption li").click(function () {
        $(".selOption").slideUp("fast");
        $(".nowSearch").html($(this).html());
        $("#cateID").val($(this).attr("value"));
    })

    /*点击任何地方关闭层*/
    $(document).click(function (event) {
        if ($(event.target).attr("class") != "nowSearch") {
            $(".selOption").slideUp("fast");
        }
    });


})

function Clear(obj) {
    if (obj.value == "请输入关键字") {
        obj.value = "";
    }
}

function Go() {
    var q = $('#q').val();
    if (q == "请输入关键字"||q=="") {
        alert("请输入要查询的关键字");
        return false;
    }
    var txts = $('#cateID').val();
    if (txts == 0) {
        alert("请输入要查询的栏目");
        return false;
    }
    if (txts == "1")
        location.href = "/News/list?q=" + encodeURI(q);
    if (txts == "2")
        location.href = "/Company/list?q=" + encodeURI(q);
    if (txts == "3")
        location.href = "/Invest/list?q=" + $("#q").val();
    if (txts == "4")
        location.href = "/Sell/list?q=" + $("#q").val();
    if (txts == "5")
        location.href = "/Buy/list?q=" + $("#q").val();
    if (txts == "6")
        location.href = "/Invite?q=" + $("#q").val();
}

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;
}
