/************************************************************************************
Check a required field on a form
************************************************************************************/
function checkRequired(theField, fieldName) {
  if (theField.value == "") {
    alert("Please specify your " + fieldName);
    theField.focus();
    return(false);
  }
  return(true);
}
/************************************************************************************
Check a numeric field on a form
************************************************************************************/
function checkNum(theField, fieldName, required) {
  var filter;

  if (required) {
    filter = /^[0123456789 -.,]+$/;
  } else {
    filter = /^[0123456789 -.,]*$/;
  }
  if (!filter.test(theField.value)) {
    alert("Please enter a valid number in the \"" + fieldName + "\" field.");
    theField.focus();
    return(false);
  }
  return(true);
}
/************************************************************************************
Check an email field on a form
************************************************************************************/
function checkEmail(theField, fieldName, required) {
  var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

  if (theField.value == "" && !required) {
    return(true);
  }
  if (!filter.test(theField.value)) {
    alert("Please enter a valid email address in the \"" + fieldName + "\" field.");
    theField.focus();
    return(false);
  }
  return(true);
}
/************************************************************************************
Open a new window or move it to the front with new contents
************************************************************************************/
function popUp(URL,wName,wWidth,wHeight) {
  handle = window.open(URL, wName, 'menubar=0,location=0,toolbar=0,personalbar=0,' +
                       'status=0,scrollbars=1,width=' + wWidth + ',height=' + wHeight);
  handle.focus();
}

