window.history.forward(1);
var jq = jQuery.noConflict();

jq(document).ready(function () {
    jq("#text_mail").focus(function () {
        jq("#mail_error").hide();
        jq("#text_mail").css("border", "1px solid #00B7EF");
    });
    jq("#text_mail").blur(function () {
        jq("#text_mail").css("border", "1px solid #DBDFE6");
        check_email();
    });
    jq("#text_psw").focus(function () {
        jq("#psw_error").hide();
        jq("#text_psw").css("border", "1px solid #00B7EF");
    });
    jq("#text_psw").blur(function () {
        jq("#text_psw").css("border", "1px solid #DBDFE6");
        check_psw();
    });

    jq("#submit").click(function () {
        if (check_email() == true && check_psw() == true) {
            jq.post(
                        '/ashx/Dd_do_login.ashx',
                        {
                            email: jq("#text_mail").val(),
                            password: jq("#text_psw").val()
                        },
                        function (data) {
                            var arryuser = data.split(',');
                            if (arryuser[0] == '11') {
                                jq.ajax({
                                    type: "post",
                                    url: '/ashx/Dd_userExit.ashx',
                                    data: { type: "login", user_ID: arryuser[1], user_Name: arryuser[2], user_Email: jq("#text_mail").val(), user_check: jq("#check_state").attr("checked") },
                                    success: function (data) {
                                        window.location.href = "/Default.aspx";
                                    }
                                });
                            }
                            else if (arryuser[0] == "01") {
                                alert("不好意思，你的账号还没有激活，请登录邮箱进行账号激活！");
                            }
                            else {
                                jq("#error_div").show();
                                jq("#error_mess").text("邮箱或密码不正确！");
                                return false;
                            }
                        }

                    );
        }
        else {
            return false;
        }

    });
});

function check_email() {
    if (jq("#text_mail").val() == "") {
        jq("#mail_error").show();
        return false;
    }
    else {
        var reg = /^[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/
        if (!reg.test(jq("#text_mail").val())) {
            jq("#error_div").show();
            jq("#error_mess").text("邮箱格式不正确！");
            return false;
        }
        else {
            jq("#error_div").hide();
            return true;
        }
    }
}
function check_psw() {
    if (jq("#text_psw").val() == "") {
        jq("#psw_error").show();
        return false;
    }
    else {
        return true;
    }
}  