
  function validate()
  {
    var sweepsForm = document.getElementById( 'sweepsForm' );
    var errors = "",
        validated = "";

    if( sweepsForm.firstName.value == "" ) errors += "firstNameLabel;"; else validated += "firstNameLabel;";
    if( sweepsForm.lastName.value == "" ) errors += "lastNameLabel;"; else validated += "lastNameLabel;";
    if( sweepsForm.month.value == "-1" || sweepsForm.day.value == "-1" || sweepsForm.year.value == "-1" ) errors += "birthDateLabel;"; else validated += "birthDateLabel;";
    if( sweepsForm.email.value == "" || sweepsForm.email.value.indexOf( "@" ) == -1 || sweepsForm.email.value.indexOf( "." ) == -1 ) errors += "emailLabel;"; else validated += "emailLabel;";
    if( sweepsForm.email.value != sweepsForm.confirmEmail.value ) errors += "emailConfirmLabel;"; else validated += "emailConfirmLabel;";
    if( !sweepsForm.acceptRules.checked ) errors += "acceptRulesLabel;"; else validated += "acceptRulesLabel;";

    // unhighlight all validated fields (in the case of a 2nd validation)
    validatedList = validated.split( ";" );
    for( i = 0; i < validatedList.length; i++ )
    {
      if( validatedList[ i ] != "" ) { document.getElementById( validatedList[ i ] ).style.color = "#a38359"; }
    }


    // show all errors
    if( errors != "" )
    {
      alert( "There were errors with your submission. \nPlease check the highlighted values." );

      errorList = errors.split( ";" );
      for( i = 0; i < errorList.length; i++ )
      {
        if( errorList[ i ] != "" ) { document.getElementById( errorList[ i ] ).style.color = "#ff0000"; }
      }

      return false;
    }
    else return true;
  }
