function Exists() {
    var username = DianCMS_$("txtUserName").value;
    if (username.length == 0) {
        $.dialog.alert('用户名不能够为空', function() {
            DianCMS_$("txtUserName").focus();
        });
        return false;
    }
    else {
        var patt = /^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$/
        if (!patt.test(username)) {
            $.dialog.alert('输入用户名有错误', function() {
                DianCMS_$("txtUserName").focus();
            });
            return false;
        }
        else {
            if (Len(username) < 4 || Len(username) > 20) {
                $.dialog.alert('输入用户名长度有误', function() {
                    DianCMS_$("txtUserName").focus();
                });
                return false;
            }
            else {
                admin_user_Reg.ExistsUserName(username, CallBack);
            }
        }
    }
}

function Len(str) {
    var i, sum;
    sum = 0;
    for (i = 0; i < str.length; i++) {
        if ((str.charCodeAt(i) >= 0) && (str.charCodeAt(i) <= 255))
            sum = sum + 1;
        else
            sum = sum + 2;
    }
    return sum;
}

function CallBack(res) {
    Alert(res.value);
    return false;
}

function IsOk() {
    if (DianCMS_$("txtUserName").value.length == 0) {
        $.dialog.alert('用户名不能够为空', function() {
            DianCMS_$("txtUserName").focus();
        });
        return false;
    }
    if (Len(DianCMS_$("txtUserName").value) < 4) {
        $.dialog.alert('用户名长度不能小于4位', function() {
            DianCMS_$("txtUserName").focus();
        });
        return false;
    }
    if (Len(DianCMS_$("txtUserName").value) > 20) {
        $.dialog.alert('用户名长度不能大于20位', function() {
            DianCMS_$("txtUserName").focus();
        });
        return false;
    }
    if (DianCMS_$("txtPassWord").value.length == 0) {
        $.dialog.alert('密码不能够为空', function() {
            DianCMS_$("txtPassWord").focus();
        });
        return false;
    }
    if (DianCMS_$("txtPassWord2").value.length == 0) {
        $.dialog.alert('确认密码不能够为空', function() {
            DianCMS_$("txtPassWord2").focus();
        });
        return false;
    }
    if (DianCMS_$("txtPassWord2").value != DianCMS_$("txtPassWord").value) {
        $.dialog.alert('两次密码不一样', function() {
            DianCMS_$("txtPassWord2").focus();
        });
        return false;
    }
    if (Len(DianCMS_$("txtPassWord").value) < 6) {
        $.dialog.alert('密码长度不能小于6位', function() {
            DianCMS_$("txtPassWord").focus();
        });
        return false;
    }
    if (Len(DianCMS_$("txtPassWord").value) > 30) {
        $.dialog.alert('密码长度不能大于30位', function() {
            DianCMS_$("txtPassWord").focus();
        });
        return false;
    }
    if (DianCMS_$("txtQuestion").value.length == 0) {
        $.dialog.alert('密码提示问题不能为空', function() {
            DianCMS_$("txtQuestion").focus();
        });
        return false;
    }
    if (DianCMS_$("txtAnswer").value.length == 0) {
        $.dialog.alert('密码提示答案不能为空', function() {
            DianCMS_$("txtAnswer").focus();
        });
        return false;
    }
    if (DianCMS_$("txtNickName").value.length == 0) {
        $.dialog.alert('用户昵称不能为空', function() {
            DianCMS_$("txtNickName").focus();
        });
        return false;
    }
    if (DianCMS_$("txtEmail").value.length == 0) {
        $.dialog.alert('电子邮件不能为空', function() {
            DianCMS_$("txtEmail").focus();
        });
        return false;
    }
}

//前台用户注册
function RegExists(type, value, value1) {
    switch (type) {
        case "password1":
            D.BLL.B_Common.ExistsUserReg("password", value, DianCMS_$("txtPassWord").value, RegCallBack);
            break;
        default:
            D.BLL.B_Common.ExistsUserReg(type, value, value1, RegCallBack);
            break;
    }
}

function RegCallBack(res) {
    var _str = res.value;
    DianCMS_$("ExistsSpan_" + _str.split("$")[0] + "").style.display = "";
    DianCMS_$("ExistsSpan_" + _str.split("$")[0] + "").innerHTML = _str.split("$")[1];
}

function SelQuestion(val) {
    if (val == "-1") {
        DianCMS_$("txtmyQuestion").style.display = "";
    }
    else {
        DianCMS_$("txtmyQuestion").style.display = "none";
    }
}