function errPrompt(aField, aMsg) {
  aField.focus();
  //aField.select();
  alert(aMsg);
  return false;
}
function errPromptSel(aField, aMsg) {
  aField.focus();
  alert(aMsg);
  return false;
}

function isEmpty(aValue) {
  var emptyStr = /^\s*$/;
  if (emptyStr.test(aValue)) {
    return true;
  }
  return false;
}

function isSelect(aOption) {
  if (aOption.value == "") {
    return false;
  } 
  return true;
}

function chkEmail(aField, aReq) {
  var emailStr = aField.value;
  var msg="Please enter a valid email address.";
  var emptyStr = /^\s*$/;
  if (isEmpty(emailStr)) {
    if (aReq == true) {
      return errPrompt(aField, msg);
    } else {
      return true;
    }
  }
  var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(emailStr))) {
    return errPrompt(aField, msg);
  }
  var illegalChars=/[\(\)\<\>\,\;\:\\\"\[\]]/;
  if (emailStr.match(illegalChars)) {
    return errPrompt(aField, msg);
  }
  return true;
}

function chkPhone(aField, aReq) {
  var msg = "Please enter a valid phone number (including area code)";
  var phoneStr = aField.value.replace(/[\(\)\.\-\ ]/g, ''); 
  if (isEmpty(phoneStr)) {
    if (aReq == true) {
      return errPrompt(aField, msg);
    } else {
      return true;
    }
  }
  if (isNaN(parseInt(phoneStr))) {
    return errPrompt(aField, msg);
  }
  if (!(phoneStr.length == 10)) {
    return errPrompt(aField, msg);
  }
  return true;
}

function chkZip(aField, aReq) {
  var msg = "Please enter a valid zip code";
  var zipStr = aField.value.replace(/\-\ ]/g, ''); 
  if (isEmpty(zipStr)) {
    if (aReq == true) {
      return errPrompt(aField, msg);
    } else {
      return true;
    }
  }
  if (isNaN(parseInt(zipStr))) {
    return errPrompt(aField, msg);
  }
  return true;
}


