﻿//注册
function Register() {
    var data = "";
    data += "&txtCustomerID=" + escape($("#txtCustomerID").val());
    data += "&txtPwd=" + $("#txtPwd").val();
    data += "&txtConfirmPwd=" + $("#txtConfirmPwd").val();
    data += "&txtVer=" + $("#txtVer").val();
    var url = "/Services/Customer.aspx";
    var pars = "opt=register" + data;
    var loadingCode = "objLoading('#CustomerRegister')";
    var completeCode = "objLoadingClose('#CustomerRegister')";
    AjaxXML(url, pars, loadingCode, completeCode, function(xml) {
        $(xml).find("ROOT").each(function(i) {
            var _result = $(this).children("RESULT").text();
            if (_result != 0) {
                $(this).find("ERROR").each(function(i) {
                    var _error = $(this).children("ERRORLIST").text();
                    AlertDiv('#RegisterNotice', false, _error, 0);
                });
                InitVer('RegisterivrLoginVerifier', 'txtVer');
            }
            else {
                if (url_pars != "")
                    ToRtnUrl(url_pars);
                else
                    location.href = "/customer/my1382.aspx";
            }
        });
    });
}

function CheckCustomerID() {
    var data = "";
    data += "&txtCustomerID=" + encodeURIComponent($("#txtCustomerID").val());

    var url = "/Services/Customer.aspx";
    var pars = "opt=checkCustomerID" + data;
    var loadingCode = "objLoading('#divCustomerID')";
    var completeCode = "objLoadingClose('#divCustomerID')";
    AjaxXML(url, pars, loadingCode, completeCode, function(xml) {
        $(xml).find("ROOT").each(function(i) {
            var _result = $(this).children("RESULT").text();
            if (_result != 0) {
                $(this).find("ERROR").each(function(i) {
                    var _error = $(this).children("ERRORLIST").text();
                    AlertDiv('#chkCustomerMsg', false, _error, 0);
                });
                InitVer('RegisterivrLoginVerifier', 'txtVer');
            }
            else { $("#chkCustomerMsg").hide(); }
        });
    });
}

//登录
function Login() {
    var data = $("#CustomerLogin").dataForAjax({
        showMessage: 'LoginNotice',
        message: {
            'txtLoginCustomerID': "对不起，用户名不能为空",
            'txtLoginPwd': "对不起，密码不能为空"
        }
    });
    if (data) {
        var url = "/Services/Customer.aspx";
        var pars = "opt=login" + data;
        var loadingCode = "objLoading('#CustomerLogin')";
        var completeCode = "objLoadingClose('#CustomerLogin')";
        AjaxXML(url, pars, loadingCode, completeCode, function(xml) {
            $(xml).find("ROOT").each(function(i) {
                var _result = $(this).children("RESULT").text();

                if (_result != 0) {
                    $(this).find("ERRORLIST").each(function(i) {
                        var _error = $(this).text();
                        AlertDiv('#LoginNotice', false, _error, 0);
                    });
                }
                else {
                    ToRtnUrl(url_pars);
                }
            });
        });
    }
}