﻿function SS_ValidateForm()
{
  __FormErrorCount=0;
  
  // Validate the e-mail addresses.  
  if(__ValidateNotEmpty(SS_ID+"EmailAddressTextBox"))
  {
    __ValidateEmailAddress(SS_ID+"EmailAddressTextBox");
  }
  
  // Validate the password.
  if(__ValidateNotEmpty(SS_ID+"PasswordTextBox"))
  {
    if(document.getElementById(SS_ID+"PasswordTextBox").value.replace(/^\s+|\s+$/g, '')!="")
    {
      if(__ValidateMinLen(SS_ID+"PasswordTextBox",6))
      {
        __ValidateMaxLen(SS_ID+"PasswordTextBox",20);
      }
    }
  }
  
  // Validate advisor option.
  if (document.getElementById(SS_ID + "AdvisorConfirmationRadioButton"))
  {
      if (document.getElementById(SS_ID + "AdvisorConfirmationRadioButton").checked || document.getElementById(SS_ID + "CompanyConfirmationRadioButton").checked)
    {
      document.getElementById(SS_ID+"AdvisorLabel").className="";
    }
    else
    {
      document.getElementById(SS_ID+"AdvisorLabel").className="NormalRed";
      __FormErrorCount++;
    } 
  }
  
  // T&Cs
  if(document.getElementById(SS_ID+"TermsAndConditionsCheckBox").checked)
  {
    document.getElementById(SS_ID+"TermsAndConditionsLabel").className="";
  }
  else
  {
    document.getElementById(SS_ID+"TermsAndConditionsLabel").className="NormalRed";
    __FormErrorCount++;
  }
  
  // Error prompt.
  document.getElementById("ErrorMessageRow").style.display=(__FormErrorCount==0?"none":"block");
  
  if(__FormErrorCount==0)
  {
    document.getElementById(SS_ID+"MessageDiv").innerHTML="<div class='SubHead'>Please wait...</div>";
    document.getElementById(SS_ID+"MessageDiv").style.display="block";
    document.getElementById(SS_ID+"RegistrationForm").style.display="none";
  }
  
  return(__FormErrorCount==0);
}
