// **********************************************************************
// *
// * Description:
// *   JavaScript variables & functions needed to perform validation
// *   of user entries on EmailAFriend entry webpage.
// *
// * Change History:
// *
// * Date       Who         Description of change
// * ---------- ----------  --------------------------------
// * 06/05/2003 DJ Kahl     "Initial" version, but was moved
// *                                   from ValidationFrom.js
// * 06/15/2004 DJ Kahl	UI/HTML changes request by Greg H.
// *				.1			CHG FLG = @06152004.1
// **********************************************************************

// **********************************************************************
// *
// * Function:
// *   finalCheck()
// *
// * Input(s):
// *   N/A
// *
// * Return:
// *   bOK == true:  all required values are present, values are valid
// *       == false: 1 or more required values are missing, 1 or more
// *                 values are invalid.
// *
// * Description:
// *   Determines if all entered data is valid and if all required values
// *   exist.
// *
// **********************************************************************
function finalCheck( frm ) {
  var bOK = true;
  var errMsgs = "";
  var missing = "";
  var invalid = "";
  var mustBeTheSame = "";
  var uiName = "";
  var bullet = "   * ";
  
  with ( frm ) {
    /* ------------------------------------------------------------- */
    /* Required-fields validations                                   */
    /* ------------------------------------------------------------- */
	
   // *** VALIDATE: email fields, required
   // uiName = "Recipients' e-mail addresses"; @06152004.1-d
   uiName = "Recipient E-Mail Address(es)"; // @06152004.1-c
    if ( NoB( txtRecipientsEmail.value ) == g_emptyStr ) { // If no Last name, then
      missing += bullet + uiName + "\r";         //  add to missing data list
    }

   // uiName = "Your e-mail address"; @06152004.1-d
   uiName = "Your E-Mail Address"; // @06152004.1-c
    if ( NoB( txtEmail.value ) == g_emptyStr ) { // If no Last name, then
      missing += bullet + uiName + "\r";         //  add to missing data list
    }
	
   // *** VALIDATE: name field, required
   // uiName = "Your full name"; @06152004.1-d
   uiName = "Your Name";  	  // @06152004.1-c
    if ( NoB( txtFullName.value ) == g_emptyStr ) { // If no Full name, then
      missing += bullet + uiName + "\r";          //  add to missing data list
    }

/* Make optional @06152004.1-d
   // *** VALIDATE: message field, required
   uiName = "Your message";
    if ( NoB( taMessage.value ) == g_emptyStr ) { // If no Last name, then
      missing += bullet + uiName + "\r";         //  add to missing data list
    }
*/
	
    // Any missing or invalid data?
    if ( missing != g_emptyStr || invalid != g_emptyStr || mustBeTheSame != g_emptyStr) {
      bOK = false;
      if ( missing != g_emptyStr ) {
        errMsgs = "The following required fields are missing a value:\r" + missing + "\r\r";
      }
      if ( invalid != g_emptyStr ) {
        errMsgs += "The following fields contain an invalid value:\r" + invalid + "\r\r";
      }
      if ( mustBeTheSame != g_emptyStr ) {
        errMsgs += "The following fields values do not match one another:\r" + mustBeTheSame + "\r\r";
      }
      alert( errMsgs );
    }
    else {
      bOK = true;
    }

  } // end of with
  return bOK;
}

