   requestSubmitted = false;

   function validate_profile () {
      var email_entry      = document.theform.email.value;
      var firstname_entry  = document.theform.fname.value;
      var lastname_entry   = document.theform.lname.value;
      var zipcode_entry    = document.theform.zipcode.value;
      var homephone_entry  = document.theform.homephone.value;
      var bizphone_entry   = document.theform.bizphone.value;
      var eligible         = document.theform.eligible.checked;

      if ( ! document.theform.employed.selectedIndex ) {
         error_message ( document.theform.employed,
                         "Please select whether you are currently employed.", 1 );
         return false;
      }

      if ( ! document.theform.unemployed.selectedIndex ) {
         if ( document.theform.employed.options[document.theform.employed.selectedIndex].value == 'No' ) {
            error_message ( document.theform.unemployed,
                            "Please select how long you have been unemployed.", 1 );
            return false;
         }
      }

      if ( ! document.theform.income.selectedIndex ) {
         error_message ( document.theform.income,
                         "Please select your current/last annual income.", 1 );
         return false;
      }

      if ( ! document.theform.work_experience.selectedIndex ) {
         error_message ( document.theform.work_experience,
                         "Please select your years of work experience.", 1 );
         return false;
      }

      if ( ! document.theform.last_jobtitle.selectedIndex ) {
         error_message ( document.theform.last_jobtitle,
                         "Please select the title of your current/last position.", 1 );
         return false;
      }

      if ( ! document.theform.current_position.selectedIndex ) {
         error_message ( document.theform.current_position,
                         "Please select the type of business of your current/last position.", 1 );
         return false;
      }

      if ( ! document.theform.education.selectedIndex ) {
         error_message ( document.theform.education,
                         "Please select your years of education.", 1 );
         return false;
      }

      if ( ! check_for_text ( firstname_entry ) ) {
         error_message ( document.theform.fname,
                         "Please enter your first name.", 0 );
         return false;
      }

      if ( ! check_for_text ( lastname_entry ) ) {
         error_message ( document.theform.lname,
                         "Please enter your last name.", 0 );
         return false;
      }

      if ( ! check_for_text ( zipcode_entry ) ) {
         error_message ( document.theform.zipcode,
                         "Please enter your Zip Code.", 0 );
         return false;
      }

      if ( ! validate_zip ( zipcode_entry ) ) {
         error_message ( document.theform.zipcode,
                         "Zip Code is invalid.", 0 );
         return false;
      }

      if ( check_for_text ( homephone_entry ) ) {
         if ( ! check_phone ( homephone_entry ) ) {
            error_message ( document.theform.homephone,
                            "Only numbers, spaces, and hyphens are " +
                            "allowed in the Home Phone.", 0 );
            return false;
         }
      }

      if ( check_for_text ( bizphone_entry ) ) {
         if ( ! check_phone ( bizphone_entry ) ) {
            error_message ( document.theform.bizphone,
                            "Only numbers, spaces, and hyphens are " +
                            "allowed in the Business / Mobile Phone.", 0 );
            return false;
         }
      }

      for ( i = 0; i < document.theform.bestcontact.length; i++ ) {
         if ( document.theform.bestcontact[i].checked ) {
            contact_type = i;
            break;
         } 
      }
      
      var contacttype_entry  =
         document.theform.bestcontact[contact_type].value.toLowerCase ();

      if ( contacttype_entry != "workphone" ) { 
         if ( ! check_for_text ( homephone_entry ) ) {
            error_message ( document.theform.homephone,
                            "You have indicated that the best place " +
                            "to contact you is Home Phone, but " +
                            "you have not entered a Home Phone.", 0 );
            return false;   
         }
      }

      if ( contacttype_entry != "homephone" ) { 
         if ( ! check_for_text ( bizphone_entry ) ) {
            error_message ( document.theform.bizphone,
                            "You have indicated that the best place " +
                            "to contact you is Business Phone, but " +
                            "you have not entered a Business Phone.", 0 );
            return false;   
         }
      }

      if ( ! validate_email ( email_entry, document.theform.email ) ) {
         return false;
      }

      var citizen_radio = 3;

      for ( i = 0; i < document.theform.citizenship.length; i++ ) {
         if ( document.theform.citizenship[i].checked ) {
            citizen_radio = i;
            break;
         } 
      }

      citizen_entry = '';
      if ( ( citizen_radio == 0 ) || ( citizen_radio == 1 ) ) {
         var citizen_entry  =
            document.theform.citizenship[citizen_radio].value.toLowerCase ();
      }

      if ( ( citizen_entry != "us" ) &&
           ( citizen_entry != "non-us" ) ) {
         window.alert ( 'Please indicate whether you are a U.S. citizen.' );
         return false;
      }

      if ( ! eligible ) {
         error_message ( document.theform.eligible, "You must indicate that the information you provided is accurate and that you are eligible to work in the United States.", 0 );
         return false;
      }

      if ( requestSubmitted == true ) {
         alert ( "You have already submitted the request." );
         return false;
      }

      requestSubmitted = true;

      return true;
   }

   function validate_zip ( zipcode ) {
      zip_chars = 0;

      for ( i = 0; i < zipcode.length; i++ ) {
         if ( zipcode.charAt (i) != "0" ) {
            if ( zipcode.charAt (i) != " " ) {
               if ( zipcode.charAt (i) != "-" ) {
                  if ( ! parseFloat ( zipcode.charAt (i) ) ) {
                     error_message ( document.theform.zipcode,
                                     "Zip code must be numeric." );
                                      return false;
                  } else {
                     zip_chars++;
                  }
               } else {
                  if ( i != 5 ) {
                     error_message ( document.theform.zipcode,
                                     "Zip code is invalid." );
                                      return false;
                  }
               }
            }
         } else {
            zip_chars++;
         }
      }

      if ( ( zip_chars != 5 ) && ( zip_chars != 9 ) ) {
         error_message ( document.theform.zipcode,
                         "Zip code is invalid." );
                         return false;
      }
      return true;
   }

   function check_phone ( elem_value ) {
      for ( i = 0; i < elem_value.length; i++ ) {
         if ( elem_value.charAt (i) != "0" ) {
            if ( elem_value.charAt (i) != "-" ) {
               if ( elem_value.charAt (i) != " " ) {
                  if ( ! parseFloat ( elem_value.charAt (i) ) ) {
                     return false;
                  }
               }
            }
         }
      }
      return true;
   }

   function validate_email ( email_val, email_element ) {
      if ( ! check_for_text ( email_val ) ) {
         error_message ( email_element,
                         "Please enter your email address." );
         return false;
      }

      if ( ! check_email ( email_val ) ) {
         error_message ( email_element,
                         "Invalid email address." );
         return false;
      }

      return true;
   }

   function check_email ( email_value ) {
      var email_ats    = 0;
      var email_dots   = 0;
      var at_position  = 0;
      var dot_position = 0;
      var email_spaces = 0;
      var i;
 
      if ( email_value.length < 6 ) {
         return false;
      }

      for ( i = 0; i < email_value.length; i++ ) {
         if ( email_value.charAt (i) == "@" ) {
            email_ats++;
            at_position = i;
         }
         if ( email_value.charAt (i) == "." ) {
            email_dots++;
            dot_position = i;  // Will be set to last occurrence
         }
         if ( email_value.charAt (i) == " " ) {
            email_spaces++;
         }
      }

      if ( ( email_ats == 0 ) || ( email_ats > 1 ) ) {
         return false;
      }

      if ( email_dots == 0 ) {
         return false;
      }

      // Email must have characters after the @ sign:
      if ( ( email_value.charAt ( at_position + 1 ) == "" ) ||
           ( email_value.charAt ( at_position + 1 ) == " " ) ) {
         return false;
      }

      // Email must have characters after the dot:
      if ( ( email_value.charAt ( dot_position + 1 ) == "" ) ||
           ( email_value.charAt ( dot_position + 1 ) == " " ) ) {
         return false;
      }

      // Email must have characters before the @ sign:
      if ( ( email_value.charAt ( at_position - 1 ) == "" ) ||
           ( email_value.charAt ( at_position - 1 ) == " " ) ) {
         return false;
      }

      // Email must have characters before the dot:
      if ( ( email_value.charAt ( dot_position - 1 ) == "" ) ||
           ( email_value.charAt ( dot_position - 1 ) == " " ) ) {
         return false;
      }

      // Email must have dot after @ sign:
      if ( dot_position < at_position ) {
         return false;
      }

      if ( email_spaces > 0 ) {
         return false;
      }
 
      return true;
   }

   function check_for_text ( elem_value ) {
      var text_entry = 0;
      var i;

      for ( i = 0; i < elem_value.length; i++ ) {
         if ( elem_value.charAt (i) != " " ) {
            text_entry = 1;
         }
      }

      if ( text_entry == 0 ) {
         return false;
      }
      return true;
   }

   function error_message ( elem, text, isDropdown ) {
      window.alert ( text );
      if ( ! isDropdown ) {
         elem.select ();
      }
      elem.focus ();
   }

   function error_message_popup ( elem, text ) {
      window.alert ( text );
      elem.focus ();
   }

