// Create the namespace for lost password functionality
var cmo = cmo ? cmo : {};
cmo.initNamespace = function () {
    cmo.profile = cmo.profile ? cmo.profile : {};
    cmo.profile.reset = cmo.profile.reset ? cmo.profile.reset : {};
    cmo.profile.lost = cmo.profile.lost ? cmo.profile.lost : {};
    cmo.profile.lost.reset = cmo.profile.lost.reset ? cmo.profile.lost.reset : {};

    cmo.profile.my = cmo.profile.my ? cmo.profile.my : {};
    cmo.profile.my.login = cmo.profile.my.login ? cmo.profile.my.login : {};
    cmo.profile.my.account = cmo.profile.my.account ? cmo.profile.my.account : {};
    cmo.profile.my.account.password = cmo.profile.my.account.password ? cmo.profile.my.account.password : {};
};
cmo.initNamespace();


// /profile/lost
cmo.profile.lost.initPage = function () {
    // console.log("cmo.profile.lost.initPage");
    // Presentation not available through CSS
    $("fieldset p:even").css("background","#e9e9e9");
    $("#lostForm").validate();
};

// /profile/lost/reset
cmo.profile.lost.reset.initPage = function () {
    // console.log("cmo.profile.lost.reset.initPage");
    //    $("#lostResetForm").validate(cmo.profile.reset.validatorRules);
    $("#lostResetForm").validate();
};

// /profile/my/account/password
cmo.profile.my.account.password.initPage = function () {
    // console.log("cmo.profile.my.account.password.initPage");
    $("#passwordResetForm").validate(cmo.profile.reset.validatorRules);
};

// /profile/my/login
cmo.profile.my.login.initPage = function () {
    // console.log("cmo.profile.my.login.initPage");
    $("#accountLoginForm").validate();
};

// Generic rules for jQuery validator for any page that confirms a password change
cmo.profile.reset.purpose = "Password reset";
cmo.profile.reset.validatorRules =  {
    debug: true,
    rules: {
        password: {
            required: true,
            minlength: 6,
            maxlength: 20
        },
        confirmPassword: {
            required: true,
            equalTo: "#password"
        }
    },
    messages: {
        password: {
            required: "Please enter a new password.",
            minlength: "Please enter 6 - 20 characters.",
            maxlength: "Please enter 6 - 20 characters."
        },
        confirmPassword: {
            required: "Please retype your password in the 'Confirm Password' field.",
            equalTo: "Passwords do not match."
        }
    }
};
