//前台用户注册页脚本
$(function () {
    $.fn.password({
        passwordInput: 'password',
        checkInput: 'checkpassword',
        strengthInfoText: 'infoText',
        strengthInfoBar: 'infoBar',
        checkInfoText: "checkInfoText"
    });
    $("#password,#checkpassword").keyup(function () {
        $.checkPassword();
    });

    $("#regform tr").mouseover(function () {
        if (!$(this).find("td").is($(".ntit"))) {
            $(this).css("background-color", "#EEEFEF");
        }
    });
    $("#regform tr").mouseout(function () {
        if (!$(this).find("td").is($(".ntit"))) {
            $(this).css("background-color", "white");
        }
    });
    var password = $("#password"),
            checkpassword = $("#checkpassword"),
            sName = $("#Name"),
            Tel = $("#Tel"),
            Mobile = $("#Mobile"),
            QQ = $("#QQ"),
            ZIP = $("#ZIP"),
			allFields = $([])
            .add(password)
            .add(checkpassword)
            .add(sName)
            .add(Tel)
            .add(Mobile)
            .add(QQ)
            .add(ZIP)
    ;
    function ValidTemp() {
        var bValid = true;

        allFields.removeClass("ui-state-error");
        if (password.val().length > 0) {
            bValid = bValid && checkLength(password, "密码", 6, 16);
            bValid = bValid && checkEquals("密码", password, checkpassword);
        }
        bValid = bValid && checkLength(sName, "持有者", 2, 50);

        if (Tel.val().length > 0) {
            bValid = bValid && checkRegexp(Tel, Regex_Tel, "电话号码格式不正确");
        }
        if (Mobile.val().length > 0) {
            bValid = bValid && checkRegexp(Mobile, Regex_Mobile, "手机号码格式不正确");
        }
        if (Tel.val().length <= 0 && Mobile.val().length <= 0) {
            bValid = bValid && false;
            Tel.addClass("ui-state-error");
            updateTips("电话和手机有一项为必填", Tel.attr("id"));
        } else {
            $("." + Tel.attr("id")).html("<img src=\"/Common/Images/true.png\" />");
        }

        if (QQ.val().length > 0) {
            bValid = bValid && checkRegexp(QQ, Regex_QQ, "QQ格式不正确");
        }
        if (ZIP.val().length > 0) {
            bValid = bValid && checkRegexp(Zip, Regex_Zip, "邮政编码格式不正确");
        }

        return bValid;
    };
    $("#subbtn").click(function () {
        return ValidTemp();
    });

});