<!--
/**************************************************************************************************\
* The following scripts have been written by Benjamin Dolar of NIGHTLIGHT Consulting.              *
*                      Copyright 2004/2005, all rights reserved.                                   *
*                                                                                                  *
* Reproduction of this script may not be used in any way, private or public, without               *
* the written consent of the above author under penalty of law.                                    *
*                                                                                                  *
\**************************************************************************************************/

function Verify(valid) {
var msg="The required fields are missing information:";
var errors=0;
  if (document.ContactForm.name.value=="") {
    msg=msg+"\n- Your Name";
    errors++;
    }
  if (document.ContactForm.email.value=="" && document.ContactForm.phone.value=="") {
    msg=msg+"\n- Your Email OR Your Phone";
    errors++;
    }
  if (document.ContactForm.subject.value=="") {
    msg=msg+"\n- The Subject of Your Message";
    errors++;
    }
  if (document.ContactForm.memo.value=="") {
    msg=msg+"\n- Your Message";
    errors++;
    }
  if (errors != 0) {
    alert(msg);
    return false;
    }
  if (document.ContactForm.email.value!="") {
    if (!ValidEmail(document.ContactForm.email.value)) {
      return false;
      }
    }
  if (document.ContactForm.phone.value!="") {
    if (!ValidPhone(document.ContactForm.phone.value)) {
      return false;
      }
    }
  return true;
}

function ValidEmail(EmailAddress) {
var symbol ="@";
var ecount;
var esymcount=0;
for (ecount=0;ecount<=EmailAddress.length-1;ecount++) {
  if (symbol.indexOf(EmailAddress.charAt(ecount))!=-1) {
    esymcount++;
    }
  }
  if (esymcount !=1) {
    alert("The email address you provided is invalid.");
    return false;
    }
  return true;
}

function ValidPhone(Number) {
var chars="0123456789-()";
var pcount;
var psymcount=0;
if (Number.length < 9 || Number.length > 12) {
  alert("The phone number you supplied is invalid.");  
  return false;
  }
for (pcount=0;pcount<=Number.length-1;pcount++) {
  if (chars.indexOf(Number.charAt(pcount))==-1) {
    psymcount++;
    }
  }
  if (psymcount >0) {
    alert("The phone number you supplied is invalid.");    
    return false;
    }
  return true;
}
//-->