﻿$(function() {

    $.ajaxSetup({ cache: false }); //取消cache，這樣User每次進首頁才不會都"load"到Cache的東西
    //數位教學-沒資料則隱藏
    $("#Top5Digital").load("Schedule/Digital.html", "", function(responseText, textStatus, XMLHttpRequest) { if (responseText.Trim().length == 0 || textStatus != "success") $("#digital-teaching").hide(); });
    //公告訊息-沒資料則隱藏
    $("#mqAnnounce").load("Schedule/Announce.html", "", function(responseText, textStatus, XMLHttpRequest) { if (responseText.Trim().length == 0 || textStatus != "success") $("#law-Message").hide(); });
    //活動宣導BANNER
    $("#law-relatedwebsites-bg ol").load("Schedule/Banner.html");
    //最新訊息
    $(".RulesContent").load("Schedule/all.html");
    $(".Law_Rules_menu01").click(function() { $(".RulesContent").load("Schedule/all.html"); SetMenuSelected(".Law_Rules_menu01 span"); });
    $(".Law_Rules_menu02").click(function() { $(".RulesContent").load("Schedule/cll.html"); SetMenuSelected(".Law_Rules_menu02 span");});
    $(".Law_Rules_menu03").click(function() { $(".RulesContent").load("Schedule/clm.html"); SetMenuSelected(".Law_Rules_menu03 span"); });
    $(".Law_Rules_menu04").click(function() { $(".RulesContent").load("Schedule/oqdr.html"); SetMenuSelected(".Law_Rules_menu04 span"); });
    $(".Law_Rules_menu05").click(function() { $(".RulesContent").load("Schedule/olm.html"); SetMenuSelected(".Law_Rules_menu05 span"); });
    $(".Law_Rules_menu06").click(function() { $(".RulesContent").load("Schedule/s.html"); SetMenuSelected(".Law_Rules_menu06 span"); });
    $(".Law_Rules_menu07").click(function() { $(".RulesContent").load("Schedule/cc.html"); SetMenuSelected(".Law_Rules_menu07 span"); });

    function SetMenuSelected(ctrl) {
        $("#Rules-menu ul li span").each(function(i) { this.id = ""; });
        $(ctrl).attr("id", "current");
    }
    //熱門法規
    $("#HotRules-Content").load("Schedule/HotLawTop6.html #M1");
    $("#rdoMonth1").click(function() { $("#HotRules-Content").load("Schedule/HotLawTop6.html #M1"); });
    $("#rdoMonth3").click(function() { $("#HotRules-Content").load("Schedule/HotLawTop6.html #M3"); });
    $("#rdoMonth6").click(function() { $("#HotRules-Content").load("Schedule/HotLawTop6.html #M6"); });
    //網站相關使用說明
    $("#law-lawsay-bg").load("Service/Description.htm");
    //青少年法制教育
    $(".BSContent").load("Media/Media.htm");
    $(".BS_Rules_menu01").click(function() { $(".BSContent").load("Media/Media.htm"); SetMenuSelectedForY(".BS_Rules_menu01 span"); });
    $(".BS_Rules_menu02").click(function() { $(".BSContent").load("Service/News.htm"); SetMenuSelectedForY(".BS_Rules_menu02 span"); });
    $(".BS_Rules_menu03").click(function() { $(".BSContent").load("Service/Life.htm"); SetMenuSelectedForY(".BS_Rules_menu03 span"); });
    function SetMenuSelectedForY(ctrl) {
        $("#BS-menu ul li span").each(function(i) { this.id = ""; });
        $(ctrl).attr("id", "current");
    }
});
function ResetValue(crl, msg) {
    if ($(crl).val() == "")
        $(crl).val(msg);
}
function chk_SubmitLaw() {
    if ($("#txtLawKW").val() == "" || $("#txtLawKW").val() == "請輸入字詞")
        alert("請輸入字詞");
    else
        window.location.href = "Law/LawSearchResult.aspx?p=A&t=A1A2E1F1&k1=" + encodeURI($.trim($("#txtLawKW").val()));
}
function chk_SubmitLife() {
    if ($("#txtLifeKW").val() == "" || $("#txtLifeKW").val() == "請輸入生活用語")
        alert("請輸入生活用語");
    else
        window.location.href = "Law/HelpSearch.aspx?f=i&k1=" + encodeURI($.trim($("#txtLifeKW").val()));
}
function chk_SubmitNews() {
    if ($("#txtKW").val() == "" || $("#txtKW").val() == "請輸入關鍵字")
        alert("請輸入關鍵字");
    else
        window.location.href = "News/news_result.aspx?k1=" + encodeURI($.trim($("#txtKW").val()));
}
function OpenLifeQueryDesc() {
    var srcFile = "Service/LifeQueryHelp.htm";
    //指定子視窗位置
    var winFeatures = "dialogWidth:500px; dialogHeight:500px; center:yes;";

    //將物件傳遞到新視窗中
    window.showModalDialog(srcFile, null, winFeatures);
}
function OpentoolsDesc() {
    var srcFile = "Service/tools.htm";
    //指定子視窗位置
    var winFeatures = "dialogWidth:400px; dialogHeight:300px; center:yes;";

    //將物件傳遞到新視窗中
    window.showModalDialog(srcFile, null, winFeatures);
}
function OpenNewsDesc() {
    var srcFile = "Service/NewsDataSource.htm";
    //指定子視窗位置
    var winFeatures = "dialogWidth:550px; dialogHeight:540px; center:yes;";

    //將物件傳遞到新視窗中
    window.showModalDialog(srcFile, null, winFeatures);
}
