function CheckDirName() {
   strInputValue = document.LoginPage.username.value;
   patternName = /\w+\s\w+/;

   if (strInputValue != "") {
      if (!(strInputValue.match(patternName))) {
         alert("Your Directory Name is your name as it appears in the Directory, most likely your\n"+
               "first name (or initial) and last name, separated by a space.");
         document.LoginPage.username.focus();
         document.LoginPage.username.select();
      }
   }
}

function CheckEmail() {
   strEmailValue = document.LoginPage.emailaddress.value;
   patternEmail = /^[\w\.\-\'\_]+\@\w+\mail.maricopa\.edu$/;

   if (strEmailValue != "") {
      if (!(strEmailValue.match(patternEmail))) {
         alert("Your email address must be in the form <username>@<site>mail.maricopa.edu,\n"+
               "where <username> is most likely your first and last names separated by a period.");
         document.LoginPage.emailaddress.focus();
         document.LoginPage.emailaddress.select();
      }
   }
}

function CheckEmpty() {
   strSiteValue = document.LoginPage.domain.selectedIndex;
   strInputValue = document.LoginPage.username.value;
   strPasswordValue = document.LoginPage.passwd.value;
   strEmailValue = document.LoginPage.emailaddress.value;
   strEmailPswdValue = document.LoginPage.emailpasswd.value;
   patternName = /^\w+\.\w+$/;
   patternEmail = /^[\w\.\-\'\_]+\@\w+\mail.maricopa\.edu$/;

   if (strSiteValue == 0) {
      alert("A site must be selected.");
      return false;
   }
   else if (((strInputValue == "") && (strEmailValue == "")) || ((strInputValue != "") && (strEmailValue != ""))) {
      alert("Enter your Directory Name OR Email Address, but not both.");
      return false;
   }
   else if (strInputValue != "") {
      if (strInputValue.match(patternName)) {
         alert("Your Directory Name is your name as it appears in the Directory, most likely your\n"+
               "first name (or initial) and last name, separated by a space.");
         return false;
      }
      else if (strPasswordValue == "") {
         alert("A password must be entered.");
         return false;
      }
      else if (strPasswordValue.indexOf(" ") >= 0) {
         alert("Spaces are not allowed in password.");
         return false;
      }
   }
   else if (strEmailValue != "") {
      if (!strEmailValue.match(patternEmail)) {
         alert("Your email address must be in the form <username>@<site>mail.maricopa.edu,\n"+
               "where <username> is most likely your first and last names separated by a period.");
         return false;
      }
      else if (strEmailPswdValue == "") {
         alert("A password must be entered.");
         return false;
      }
      else if (strEmailPswdValue.indexOf(" ") >= 0) {
         alert("Spaces are not allowed in password.");
         return false;
      }
   }

   return true;
}
