function checkReqdFields(theForm)
{
  var i, j, k, re, strFieldName, txtString, txtStringParsed;

  var atLeastOneTextFieldHasValue = false;
  var textFieldFocus              = -1;    // assume no input text fields
    
  with (theForm) {
    for (i = 0; i < elements.length; i++) {

      // CHECKBOX control check - assume not required
      //
      if (elements[i].type == "checkbox") continue; 

      // RADIO button check - assume one pre-selected 
      //
      if (elements[i].type == "radio") continue; 
  
      // Ensure at least one input text field contains data other than "Client:"
      //
      if ((elements[i].type == "text") && (elements[i].name != "txtClient")) {

        if (textFieldFocus == -1) textFieldFocus = i;

        // Remove blanks
        //
        re              = / /g;
        txtString       = elements[i].value;
        txtStringParsed = txtString.replace(re,"");

        if (txtStringParsed != "") atLeastOneTextFieldHasValue = true;
      }

      strFieldName = elements[i].name;
      j            = txtReqdNames.value.indexOf("|" + strFieldName + "|");

      if (j != -1) { // required field

        // SELECT control check
        //
        if (elements[i].type == "select-one") {
          if (elements[i].options[elements[i].selectedIndex].value != "") {
            continue; 
          } else {
            alert("Please select an item from the list.");
            theForm.elements[i].focus();
            return false;
          }
        }

        // Text input control check
        // 
        if (elements[i].type == "text") { 
          if (txtStringParsed != "") {
            continue;
          } else {
            // Determine display name of empty required input field 
            //
            var strReqdNames = txtReqdNames.value;
            var arrReqdNames = strReqdNames.split("|");

            for (k = 0; k < arrReqdNames.length; k++) {
              if (arrReqdNames[k] == strFieldName) break;
            }

            var strCaptions = txtReqdCaptions.value;
            var arrCaptions = strCaptions.split("|");

            alert("'" + arrCaptions[k] + "' is a required field.");

            elements[i].value = "";       // remove blanks, if any
            theForm.elements[i].focus();

            return false; 
          }
        } 

      } // if (j != -1) => required input field check
    } // for (i = 0; i < elements.length; i++)
  } // with (theForm) 
  
  // textFieldFocus will equal "-1" if there are no input text fields
  //
  if ((textFieldFocus != -1) && (!atLeastOneTextFieldHasValue)) { 
    alert("Please enter one or more search terms.");
    theForm.elements[textFieldFocus].value = "";   // remove blanks, if any
    theForm.elements[textFieldFocus].focus();
    return false;
  }
 
  return true;
}


