/************************************************************************************
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);
}
/************************************************************************************
Check if a field contains a URL
************************************************************************************/
function checkNoURL(s) {
  var filter = /http(s)?:\/\//i;
  
  if (filter.test(s)) {
    alert("Sorry, URLs are not allowed.");
    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();
}

// Based on code distributed by http://www.hypergurl.com
function flashit()
{
  if (!document.all) {
    return;
  }
  if (subscribe_table.style.backgroundColor=="yellow") {
    subscribe_table.style.backgroundColor="#FFFFEF"; 
  } else {
    subscribe_table.style.backgroundColor="yellow";
  }
}

function subscribeFocus()
{
  url = window.location.href.split('#');
  window.location = url[0] + '#subscribe';
  subscribe_table.style.backgroundColor="yellow";
  setInterval("flashit()", 1000);
  document.subscribe.name.focus();
}

function onloadSubscribe()
{
  url = window.location.href.split('#');
  if (url[1]=="subscribe") {
	subscribeFocus();
  }
}

function hide(element)
{
  obj = document.getElementById(element);
  obj.style.display = 'none';
  return(true);
}

function show(element,disp)
{
  obj = document.getElementById(element);
  obj.style.display = disp;
  return(true);
}