function checkFieldsCommon() {
    if ( ! checkFieldsEmail(document.conferenceForm.DBFieldEmail, '') ) {
        return false;
    } else if ( trimit( document.conferenceForm.DBFieldFirstName.value )  == "" ) {
        alert("Please enter your first name.");
        document.conferenceForm.DBFieldFirstName.focus();
        return false;
    } else if ( trimit( document.conferenceForm.DBFieldLastName.value )  == "" ) {
        alert("Please enter your last name.");
        document.conferenceForm.DBFieldLastName.focus();
        return false;
    } else if ( trimit( document.conferenceForm.DBFieldAffiliationOrCompany.value )  == "" ) {
        alert("Please enter your affililiation.");
        document.conferenceForm.DBFieldAffiliationOrCompany.focus();
        return false;
    } else if ( trimit( document.conferenceForm.DBFieldCity.value )  == "" ) {
        alert("Please enter your city.");
        document.conferenceForm.DBFieldCity.focus();
        return false;
    } else if ( trimit( document.conferenceForm.DBFieldCountry.value )  == "" ) {
        alert("Please enter your country.");
        document.conferenceForm.DBFieldCountry.focus();
        return false;
    } else {
        return true;
    }
}
function checkFieldsEmail(theEmailField, extra) {
    if ( trimit( theEmailField.value ) == "") {
        alert("Please enter the email address." + extra);
        theEmailField.focus();
        return false;
    } else if ( trimit( theEmailField.value ).indexOf( '@' ) == -1 ) {
        alert("Please enter a valid email address. (missing \"@\".)" + extra);
        theEmailField.focus();
        return false;
    } else if ( trimit( theEmailField.value ).indexOf( '.' ) == -1 ) {
        alert("Please enter a valid email address. (missing \".\".)" + extra);
        theEmailField.focus();
        return false;
	//
    } else if ( trimit( theEmailField.value ).indexOf( ' ' ) != -1 ) {
        alert("Please enter a valid email address. (spaces not allowed)" + extra);
        theEmailField.focus();
        return false;
	//
    } else if ( trimit( theEmailField.value ).indexOf( ',' ) != -1 ) {
        alert("Please enter a valid email address. (\",\" not allowed)" + extra);
        theEmailField.focus();
        return false;

    } else {
        return true;
    }
}
function trimit(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while ( (ch == " ") || (ch == "\r") || (ch == "\n") ) { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function
function checkFieldsInviteList() {
  if ( ! checkFieldsEmail(document.formInviteAfriend.emailList, ' ( Email list) ') ) {
    return false;
  }
}
function checkFieldsInviteDetails() {
  
        atLeastOne = false;
        foundError = false;
        if ( trimit( document.formInviteAfriend.inviteeEmail1.value ) != '' ) {
          thisOne = true;
          if ( ! checkFieldsEmail(document.formInviteAfriend.inviteeEmail1, ' (First email) ') ) {
            thisOne = false;
            foundError = true;
          }
          if ( thisOne ) { atLeastOne = true; }
        }    
    if ( ! foundError) {
        if ( trimit( document.formInviteAfriend.inviteeEmail2.value ) != '' ) {
          thisOne = true;
          if ( ! checkFieldsEmail(document.formInviteAfriend.inviteeEmail2, ' (Second email) ') ) {
            thisOne = false;
            foundError = true;
          }
          if ( thisOne ) { atLeastOne = true; }
        }  
    }  
    if ( ! foundError) {
        if ( trimit( document.formInviteAfriend.inviteeEmail3.value ) != '' ) {
          thisOne = true;
          if ( ! checkFieldsEmail(document.formInviteAfriend.inviteeEmail3, ' (Third email) ') ) {
            thisOne = false;
            foundError = true;
          }
          if ( thisOne ) { atLeastOne = true; }
        }    
    }
    if ( ! foundError) {
        if ( trimit( document.formInviteAfriend.inviteeEmail4.value ) != '' ) {
          thisOne = true;
          if ( ! checkFieldsEmail(document.formInviteAfriend.inviteeEmail4, ' (Fourth email) ') ) {
            thisOne = false;
            foundError = true;
          }
          if ( thisOne ) { atLeastOne = true; }
        }    
    }
    if ( ! foundError) {
        if ( trimit( document.formInviteAfriend.inviteeEmail5.value ) != '' ) {
          thisOne = true;
          if ( ! checkFieldsEmail(document.formInviteAfriend.inviteeEmail5, ' (Fifth email) ') ) {
            thisOne = false;
            foundError = true;
          }
          if ( thisOne ) { atLeastOne = true; }
        }
    }
    if ( ( ! atLeastOne ) && ( ! foundError) ) {
        alert("Please enter at least one email address.");
        document.formInviteAfriend.inviteeEmail1.focus();
    }
    return ( atLeastOne && ( ! foundError) );
}
