/************************************************************************************
Show or hide an element by its ID
************************************************************************************/
/*function showHide(eId,disp) {
	var e;
	
	e = getElementById(eId);
	if (!e) {
		return(false);
	}
	if (disp == "visible" || (!disp && e.style.visibility != "visible")) {
		e.style.visibility = "visible";
	} else {
		e.style.visibility = "hidden";
	}
}*/
/************************************************************************************
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 if two fields have the same value
************************************************************************************/
function checkDuplicate(theField1, theField2, fieldName1, fieldName2) {
  if (theField1.value == theField2.value) {
    alert(fieldName1 + " and " + fieldName2 + " are the same - are you a real person?");
    theField1.focus();
    return(true);
  }
  return(false);
}
/************************************************************************************
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();
}


