var bCancel = false;

function validateAccountForm(form)
{
    if (bCancel)
    {
        return true;
    }
    else
    {
        var formValidationResult;
        formValidationResult = validateRequired(form) & validateEmail(form) & validateMinLength(form) & validateInteger(form) & validateMaxLength(form) & validatePasswords(form)
        return (formValidationResult == 1);
    }
}

function AccountForm_required()
{
    this.a0 = new Array("accountForm.email", "•  Email", new Function("varName", " return this[varName];"));
    this.a1 = new Array("accountForm.password", "•  Password", new Function("varName", "this.minlength='6';  return this[varName];"));
    this.a2 = new Array("accountForm.passwordReType", "•  Retype Password", new Function("varName", "this.test='(*this* == password)';  return this[varName];"));
    this.a3 = new Array("accountForm.gender", "•  Gender", new Function("varName", " return this[varName];"));
    this.a4 = new Array("accountForm.firstName", "•  First Name", new Function("varName", " return this[varName];"));
    this.a5 = new Array("accountForm.lastName", "•  Last Name", new Function("varName", " return this[varName];"));
    this.a6 = new Array("accountForm.dobMonth", "•  Month", new Function("varName", " return this[varName];"));
    this.a7 = new Array("accountForm.dobDay", "•  Day", new Function("varName", "this.maxlength='2'; this.minlength='1';  return this[varName];"));
    this.a8 = new Array("accountForm.dobYear", "•  Year", new Function("varName", " return this[varName];"));
    this.a9 = new Array("accountForm.citizenship", "•  Citizenship", new Function("varName", " return this[varName];"));
    this.a10 = new Array("accountForm.countryOfResidence", "•  Country of Residence", new Function("varName", " return this[varName];"));
    this.a11 = new Array("accountForm.streetAddress1", "•  Street Address 1", new Function("varName", " return this[varName];"));
    this.a12 = new Array("accountForm.city", "•  City", new Function("varName", " return this[varName];"));
    //this.a13 = new Array("accountForm.state", "•  State/Province", new Function("varName", " return this[varName];"));
    //this.a14 = new Array("accountForm.postalCode", "•  Postal Code", new Function("varName", " return this[varName];"));
    //this.a15 = new Array("accountForm.contactPersonPhone", "•  Contact Person Phone", new Function("varName", " return this[varName];"));
    this.a16 = new Array("accountForm.homePhone", "•  Home Phone", new Function("varName", " return this[varName];"));
}

function AccountForm_email()
{
    this.a0 = new Array("accountForm.email", "Invalid Email. Please provide valid Email address.", new Function("varName", " return this[varName];"));
}

function AccountForm_minlength()
{
    this.a0 = new Array("accountForm.password", "Password can not be less than 6 characters.", new Function("varName", "this.minlength='6';  return this[varName];"));
    this.a1 = new Array("accountForm.dobDay", "Day can not be less than Day characters.", new Function("varName", "this.maxlength='2'; this.minlength='1';  return this[varName];"));
}

function AccountForm_IntegerValidations()
{
    this.a0 = new Array("accountForm.dobDay", "Invalid Day. Please provide valid number.", new Function("varName", "this.maxlength='2'; this.minlength='1';  return this[varName];"));
}

function AccountForm_maxlength()
{
    this.a0 = new Array("accountForm.dobDay", "Day can not be greater than Day characters.", new Function("varName", "this.maxlength='2'; this.minlength='1';  return this[varName];"));
}
function AccountForm_password()
{
    this.a0 = new Array("accountForm.password", "Password and Retype Password are not matching. Please try again!", new Function("varName", " return this[varName];"));
}

function AccountForm_passwordReType()
{
    this.a0 = new Array("accountForm.passwordReType", "Password and Retype Password are not matching. Please try again!", new Function("varName", " return this[varName];"));
}

function countryChanged()
{
    var countryOfResidence = document.getElementsByName("accountForm.countryOfResidence")[0];
    var country = countryOfResidence.options[countryOfResidence.selectedIndex];
    var provinceTBody = document.getElementById("accountForm.provinceRow");
    var stateTBody = document.getElementById("stateRow");

    if (country.value == "CA")
    {
        stateTBody.style.display = "none";
        provinceTBody.style.display = "block";
    }
    else
    {
        stateTBody.style.display = "block";
        provinceTBody.style.display = "none";
    }
}