document.write(unescape("%3Cscript src='script/zheng_inquiry-consult.js' type='text/javascript'%3E%3C/script%3E"));
$(document).ready(function () {
    $("#appointment").datepicker({
        dateFormat: "yy-mm-dd",
        dayNamesMin: ["日", "一", "二", "三", "四", "五", "六"],
        monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
        prevText: "上一月",
        nextText: "下一月"
    });
    $("#send").click(function () {
        var c = "";
        var b = false;
        var focusOfElt = '';        
        if ($("#name").val().length == 0) {
            if(c.length==0) if($("#name").length > 0) { focusOfElt = $("#name")[0]; }              
            c += "請輸入姓名\n"
        }
        if ($("#email").val().length) {
            var a = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            if (!$("#email").val().match(a)) {
                if(c.length==0) if($("#email").length > 0) { focusOfElt = $("#email")[0]; }                
                c += "電子信箱格式錯誤\n"
            }
        } else {
            if(c.length==0) if($("#email").length > 0) { focusOfElt = $("#email")[0]; }            
            c += "請輸入電子信箱\n"
        }
        if ($("#appointment").val().length == 0) {
            if(c.length==0) if($("#appointment").length > 0) { focusOfElt = $("#appointment")[0]; }            
            c += "請輸入預約日期\n"
        }
        $(".taipeiCourse").each(function () {
            if ($(this).attr("checked")) {
                b = true
            }
        });
        $(".tokyoCourse").each(function () {
            if ($(this).attr("checked")) {
                b = true
            }
        });
        if (!b) {
            if(c.length==0) if($(".taipeiCourse").length > 0) { focusOfElt = $(".taipeiCourse")[0]; }            
            c += "請選取至少一項台北講座或東京留學課程\n"
        }
        b = false;
        $(".jpLevel").each(function () {
            if ($(this).attr("checked")) {
                b = true
            }
        });
        if (!b) {
            if(c.length==0) if($(".jpLevel").length > 0) { focusOfElt = $(".jpLevel")[0]; }            
            c += "請選取至少一項日文程度\n"
        }
        b = false;
        
/*        
        if (c.length) {
            alert(c);
            return false
        }
*/
        alertMsgOfCheck(c,focusOfElt);        
        return false;
    })
});
