function testForm(theForm) {
  retVal = testRequiredFields(theForm);
  if (retVal)
    retVal = testEmail(theForm);
  return retVal;
}
function testRequiredFields(theForm) {
  isOK=true;
  if(theForm.required.value.indexOf("|")!=-1){
    requiredFields = theForm.required.value.split("|")
    for(i=0;i<requiredFields.length;i++){
	  eval("formTag=theForm."+requiredFields[i]+";");
	  
      if (isOK && formTag.value == "") {
       alert("Please enter a value for the selected region.");
       formTag.focus();
       isOK = false;
      }
    }
  }
  return isOK;
}
function testEmail(theForm) {
  emailReg = new RegExp ("^[\\w.\\-_]+@[\\w.\\-_]+\\.[\\w]{2,3}$");
  if (!emailReg.test(theForm.email.value)) {
    alert ("Your email address is invalid");
    theForm.email.focus();
    return false;
  }

  if (theForm.repeatemail && (theForm.email.value != theForm.repeatemail.value)) {
    alert ("Your email addresses do not match");
    theForm.email.focus();
    return false;
  }
}
