<!-- validate.js  -->
<!-- ScriptAuthor:  Jeff Harding (jbh@site-ations.com) -->
<!-- AuthorWebSite:  http://www.site-ations.com -->
<!-- ScriptModifiedBy:  Ronnie T. Moore, Editor -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- ScriptModifiedBy: Tanya Rotenberg for use in information gathering forms -->
<!-- Begin
// Preload images
var empty = new Image(); empty.src = "fieldempty.gif";
var email = new Image(); email.src = "emailerror.gif";
var phone = new Image(); phone.src = "phoneerror.gif";
var extra = new Image(); extra.src = "contact.gif";

var haveerrors = 0;
function showImage(imagename, imageurl, errors) {
document[imagename].src = imageurl;
if (!haveerrors && errors) haveerrors = errors;
}

function validateForm(f) {
   haveerrors = 0;
   if (f.name.value.length < 1) { // validate name length
      if (!haveerrors) { f.name.focus(); }
      showImage("nameerror", "fieldempty.gif", true);
   }
   else { showImage("nameerror", "blankimage.gif", false); }
   // true = errors, false = no errors ??

   phonenumlength = f.phone.value.length; 
   i = 0; 
   var removed = "";
   var newphone = "";
   var digit = "";
   if (phonenumlength < 1) {
      if (!haveerrors) { f.phone.focus(); }
   }
   else { 
      while (i <= phonenumlength) {
         digit = f.phone.value.substring(i++,i);
         if (digit == "(" || digit == ")" || digit == " " 
                          || digit == "-") { removed += digit; }
         else { newphone += digit; }
      }
      phonenumlength = newphone.length;
      if (phonenumlength != 10) {
				 if (phonenumlength = 0) { f.phone.focus(); } 
				 else {
         			if (!haveerrors) { f.phone.focus(); }
         			showImage("phoneerror", "phoneerror.gif", true)
				 }
      }
      else {
         var buildphone;
         f.phone.value = newphone;
         buildphone = "(" + f.phone.value.substring(0,3);
         buildphone += ") " + f.phone.value.substring(3,6);
         buildphone += "-" + f.phone.value.substring(6,10);
         showImage("phoneerror", "blankimage.gif", false);
         f.phone.value = buildphone;
      }
   }   
   if (f.email.value.length != 0) {
	    if (f.email.value.search("@") == -1 
           || f.email.value.search("[.*]") == -1) { // validate email
         if (!haveerrors) { f.email.focus(); }
         showImage("emailerror", "emailerror.gif", true); 
      }
      else {
         if (f.email.value.length < 3) {
            if (!haveerrors) { f.email.focus(); }
            showImage("emailerror", "emailerror.gif", true); 
         }
         else { showImage("emailerror", "blankimage.gif", false); }
      }
	 } 
	 else { f.email.focus(); }

   if ((phonenumlength == 10) || (f.email.value.length > 0)) {
	 }
	 else {
	    if (!haveerrors) {
			   showImage("emailerror", "contact.gif", true);
				 showImage("phoneerror", "contact.gif", true);
			}
	 } 

   return (!haveerrors);
}
//  End -->