<!--

// Forcus on the invalid entry
function focusEnt(frmname, entname) {
  var elm = document.forms[frmname].elements[entname];
  elm.focus();
  elm.select();
}

// Check if the entry is made
function isNotEmpty(ent) {
  var str = ent.value;
  if (str = null || str.length == 0) {
    alert ("Please fill in the required field " + ent.name);
    setTimeout("focusEnt('" + ent.form.name + "', '" + ent.name +"')",10);
    return false;
  } else {
    return true;
  }
}

// Check if the entry is only letters and numbers except -, period and space
function isAlphanum(ent) {
  var str = ent.value;
  astripped = str.replace(/[\-\ \.]/g, '');
  badchars = /[\W_]/;
  if (badchars.test(astripped)) {
    alert ("Please use alphabet, numbers and/or hyphens.");
    setTimeout("focusEnt('" + ent.form.name + "', '" + ent.name +"')",10);
    return false;
  } else {
    return true;
  }
}

// Check if one of the radio buttons is checked
function isRadio(ent) {
  var valid = false;
  for (i=0, n=ent.length; i<n; i++) {
    if (ent[i].checked) {
	return true;
    }
  }
  alert ("Please choose one for your title");
  return false;
}

// Check if the email address is valid
function isEmailAddr(ent) {
  var str = ent.value;
  var emailFilter=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
  if (!(str.match(emailFilter))) {
    alert ("Please enter a valid email address.");
    setTimeout("focusEnt('" + ent.form.name + "', '" + ent.name +"')",10);
    return false;
  } else {
    return true;
  }
}

// Batch process on submit
function checkAll(theForm) {
  if (isNotEmpty(theForm.First_name)) {
    if (isAlphanum(theForm.First_name)) {
      if (isNotEmpty(theForm.Last_name)) {
        if (isAlphanum(theForm.Last_name)) {
          if (isRadio(theForm.Your_title)) {
            if (isNotEmpty(theForm.Subject)) {
              if (isNotEmpty(theForm.Email)) {
                if (isEmailAddr(theForm.Email)) {
                  if (isNotEmpty(theForm.Inquiry)) {
                    return true;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  return false;
}

// -->

