var lotterytype = $("#code").val();
$(function () {
    $("#termInput").click(function (e) {
        $(".query-select").show();
        e.stopPropagation();
    })
    $(".query-select li").click(function (e) {
        $(".query-select").hide();
        e.stopPropagation();
    })
    $(window).click(function (event) {
        var e = event || window.event;
        if ($(".query-select").css("display") != "none") {
            $(".query-select").hide();
        }
    })
})
function updateTable(obj, tr, type) {
    if (!$(obj).hasClass("active")) {
        $("#table").html("");
        $("#rows").html(tr);
        var index = $(obj).parents(".qishu-box:eq(0)").children(".lot-btn").index(obj);
        $(".qishu-box").each(function (i, e) {
            $(e).find(".lot-btn").removeClass("active").eq(index).addClass("active");
        })
        queryKSJH(type, "Year", tr)
    }
}
function queryKSJH(type, type2, tr) {

    if (type2 == 'Term') {
        var Term = $("#termInput").val();
        if (Term != '') {
            window.open("/" + type + "/" + lotterytype + "-q" + Term + ".html");
        }
    }
    if (type2 == 'Year') {
        if (!tr) {
            var Year = $("#yearInput").val();
            if (Year != '') {
                window.open("/" + type + "/" + lotterytype + "-y" + Year + ".html");
            }
        } else {
            var qs = $("#qs1").text();
            if (qs != '') {
                window.open("/" + type + "/" + lotterytype + "-" + qs + "-" + tr + ".html");
            }
        }
    }
    if (type2 == 'range') {
        var minTerm = $("#startInput").val();
        var maxTerm = $("#endInput").val();
        if (minTerm != '' && maxTerm != '') {
            window.open("/" + type + "/" + lotterytype + "-" + minTerm + "-" + maxTerm + ".html");
        }
    }
}