﻿$(document).ready(function() {

    if ($("#loginInner").outerHeight() > $("#importantChangesInner").outerHeight()) {
        $('#importantChangesInner').css('height', $("#loginInner").outerHeight());
    } else {
        $('#loginInner').css('height', $("#importantChangesInner").outerHeight());
    }

    /* Login */
    $("#btnLogin").bind("click", function() {

        /* add validation class to login textboxes */
        if (!$("#txtMemberNumber").hasClass("ValidateTextBox")) {
            $("#txtMemberNumber").addClass("ValidateTextBox");
        }
        if (!$("#txtPassword").hasClass("ValidateTextBox")) {
            $("#txtPassword").addClass("ValidateTextBox");
        }

        /* remove validation class from forgot password textboxes */
        $("#txtForgotPasswordMemberNumber").removeClass("ValidateTextBox");
        $("#txtForgotPasswordEmailAddress").removeClass("ValidateTextBox");

        var isValid = validateForm();
        return isValid;
    });

    /* Forgot password */

    /* Initially hide the container */
    $("#forgotPassword-Container").hide();

    $("#forgotPassword").bind("click", function() {
        $("#forgotPassword-Container").toggle(0);
        return false;
    });

    $("#btnForgotPassword").bind("click", function() {

        /* add class to forgot password textboxes */
        if (!$("#txtForgotPasswordMemberNumber").hasClass("ValidateTextBox")) {
            $("#txtForgotPasswordMemberNumber").addClass("ValidateTextBox");
        }
        if (!$("#txtForgotPasswordEmailAddress").hasClass("ValidateTextBox")) {
            $("#txtForgotPasswordEmailAddress").addClass("ValidateTextBox");
        }

        /* remove validation class from login textboxes */
        $("#txtMemberNumber").removeClass("ValidateTextBox");
        $("#txtPassword").removeClass("ValidateTextBox");

        /* validate the form */
        var isValid = validateForm();
        return isValid;
    });

    /* Forgot member number */
    $("#acForgotMemberNumber").bind("click", function() {
        $("#forgotMemberNumber-Container").toggle();
    });

    /* Important Message */
    var currDate = new Date();
    var endDate = new Date(2010, 10, 13, 0, 0, 0); //Javascript months start with Jan=0!
    if (currDate < endDate) {
        $("#ImportantMessage").show();
    }
    
});
