/*  This script provides basic form validation  */

      <!--  //  Hide script from old browsers

         //  Form validation
         var validations = new Array();

         //  Define fields to validate and validation to perform
         validations[0] = ["document.contactform.name", "notblank"];
         validations[1] = ["document.contactform.email", "notblank"];
         validations[2] = ["document.contactform.message", "notblank"];
         validations[3] = ["document.contactform.email", "validemail"];
         validations[4] = ["document.contactform.phone1", "isnumber"];
         validations[5] = ["document.contactform.phone2", "isnumber"];
         validations[6] = ["document.contactform.phone3", "isnumber"];

         function isEmpty(s)
         //  Determine if field is empty
         {

            if (s == null || s.length == 0)
            {

               return true;

            } 
            else
            {

               return false;

            }  //  End if

         }  //  End isEmpty


         function isEmail(field)
         //  Determines if field contains an e-mail address
         {
 
            var s = field.value;

            //  Determine if e-mail is empty
            if (isEmpty(s))
            {

               alert("Email cannot be empty.");
               field.focus();
               return false;

            }  //  End if

            if (/[^@]+@\w+/.test(s))
            {

               return true;

            }  //  End if;

            alert("E-mail address is not in a valid form");
            field.focus();
            return false;

         }  //  End isEmail


         function isInteger(field)
         //  Determines if field contains integers
         {

            var s = field.value;

            if (isEmpty(s) && field.name != 'phone2' && field.name != 'phone3')
            {
               
               return true;

            }  //  End if

            if(!(/^-?\d+$/.test(s)))
            {

               alert("Field must only contain digits.");
               field.focus();
               return false;

            }  //  End if 

            return true;

         }  //  End isInteger


         function validate()
         //  Calls functions to validate the form when submitted
         {

            var i;		//  Loop counter
            var checkToMake;	//  Type of validation
            var field; 		//  Form field to be validated

	    //  Loop through validations array and calls appropriate validation functions
	    for (i = 0;i < validations.length;i++)
            {

               field = eval(validations[i][0]);
               checkToMake = validations[i][1];

               switch(checkToMake)
               {
                  case 'notblank':  if(isEmpty(field.value))
                                    {

                                       alert("Name, e-mail, and message are required and cannot be empty. Phone is optional.");
                                       field.focus();
                                       return false;

                                    }  //  End if
                                    break;


                  case 'validemail':  if(!isEmail(field))
                                      {

                                         return false;

                                      }  //  End if
                                      break;


                  case 'isnumber':  if(!isInteger(field))
                                    {
                                       return false;

                                    }  //  End if
                                    break;

               }  //  End switch

            }  //  End for

            return true;

         }  //  End validate

      //  End script hiding -->