
function validateForm(oForm, strAddress) {
  var bValid = true ;
  
  // Validate the form
  
  if (checkRequired(oForm)) {
    if (AddressBad(strAddress)) {
    }
    else {
      window.alert('Sorry.  We can\'t make use of that e-mail address.  Please try a different address.') ;
      bValid = false ;
    }
  }
  else {
    window.alert('Please complete all the fields marked with an asterisk \'*\'.') ;
    bValid = false ;
  }
  
  return bValid ;
}


// ----------------------------------------------------------------------------

function checkRequired(oForm) {
  var idx ;
  var bValid = true ;
  var oControl ;
  
  // Test whether all the text fields in the form have some entry

  for (idx=0 ; idx < oForm.length ; idx++) {
    oControl = oForm.elements[idx];

    if (oControl.type == "text" || oControl.type == "textarea")
      if (oControl.value == '') {
        bValid = false ;
        break ;
      }
  }
  
  return bValid ;
}

// ----------------------------------------------------------------------------

function AddressBad(strAddress) {
  var bValid = true ;
  var astrBadAddress = new Array("@hotmail.co.uk", "@hotmail.com", "@yahoo.co.uk", "@yahoo.com") ;
  var idx, intAddresses ;
  
  // Test whether given e-mail address is in disallowed list
  
  bValid = true ;
  intAddresses = astrBadAddress.length ;
  
  for (idx = 0 ; idx < intAddresses ; idx++) {
    if (strAddress.indexOf(astrBadAddress[idx]) >= 0) {
      bValid = false ;
      break ;
    }
  }

  return bValid ;
}

