﻿$(document).ready(function() {
     //面试回复事件
    $("#InterViewButton").click(function() {

        var iid, city, contact, name, sex, phone, email, special, level, ielts, tofel, gmat, gre, other;
        iid = $("#iid").val();
        city = $("#city").val();
        if ($("#contact").attr("checked")) {
            contact = true;
        }
        else {
            contact = false;
        }

        name = $.trim($("#name").val());

        var o = document.getElementsByName("sex");
        for (var i = 0; i < o.length; i++) {
            if (o[i].checked == true) {
                sex = o[i].value;
            }
        }

        phone = $.trim($("#phone").val());
        email = $.trim($("#email").val());
        special = $.trim($("#special").val());
        level = $.trim($("#level").val());
        ielts = $.trim($("#ielts").val());
        tofel = $.trim($("#tofel").val());
        gmat = $.trim($("#gmat").val());
        gre = $.trim($("#gre").val());
        other = $.trim($("#other").val());

        if (iid == "") {
            return;
        }
        if (city == "") {
            alert("请输入城市信息");
            return;
        }
        if (name == "") {
            alert("请输入姓名信息");
            return;
        }
        if (phone == "") {
            alert("请输入联系电话信息");
            return;
        }
        if (email == "") {
            alert("请输入Email信息");
            return;
        }

        //存数据
        $.ajax({
            type: "get",
            dataType: "jsonp",
            url: "http://www.eduglobal.com/OrderInterView.axd",
            data: encodeURI("iid=" + iid + "&city=" + city + "&contact=" + contact + "&name=" + name + "&sex=" + sex +
"&phone=" + phone + "&email=" + email + "&special=" + special + "&level=" + level + "&ielts=" + ielts + "&tofel=" +
tofel + "&gmat=" + gmat + "&gre=" + gre + "&other=" + other + "&num=" + Math.round(Math.random() * 9999999)+ "&jsoncallback=?"),
            error: function() { alert("预约信息提交失败！"); },
            success: function(data) {
                if (data.result.toString() == "1") {
                    alert("预约信息提交成功！");
                    $("#ivfill").toggle();
                    $("#city").val("");
                    $("#contact").attr("checked", "");
                    $("#name").val("");
                    $("#phone").val("");
                    $("#email").val("");
                    $("#special").val("");
                    $("#level").val("");
                    $("#ielts").val("");
                    $("#tofel").val("");
                    $("#gmat").val("");
                    $("#gre").val("");
                    $("#other").val("");
                }
                if (data.result.toString() == "2") {
                    alert("预约信息已经存在！");
                }
                if (data.result.toString() == "0") {
                    alert("预约信息提交失败！");
                }
            }
        });

    });
    $("#orderNow").click(function() {

        $("#ivfill").toggle();
    });
});