
<!--
// Author Bren Nixon 08 March 2002
// Copyrighted
// Checking text boxes and text areas are filled in

var msg = "";
var missing = "";
var invNum = "";
var validmail = "";
var add = "";

function isblankform(form) {

for(i=0; i<document.form.elements.length; i++)
	  {
	   var el = document.form.elements[i];

	      if(el.required)        // if element has required property
	     {                          // test to see if field is empty
	     if(isEmpty(el))
	      {
	       missing += "\n   - " + el.name + " is a required field. Please advise your " + el.name + " Details";
	      }
      	     }
      	  }


      	

      	 var el	= form.Telephone
      	       	 if(el.numeric)
	       	   	{
	       	   	if(notNumeric(el)){
	       	   	invNum += "\n  - " + el.name + " details must be a number without '-' or '.' characters";
	       	   	  form.Telephone.focus();
      			  form.Telephone.select();
	       	   	  }
      	   	        }




      	 var el= form.Email

      	  if (form.Email.value != ""){
    var validemail = isEmail(form.Email.value)
    if (validemail != 0) {
      if(form.Email == -1) {form.Email = 10}
      validmail += "\n  - " + el.name + " Please check your E-mail details";
      form.Email.focus();
      form.Email.select();
    }
    }





      	  // output message
      	  if(missing.length !=0 || invNum.length != 0 || validmail != 0 || add != 0)
	        {
	        if(missing.length !=0)
	        {
	        msg += "\n\nThe following required fields are missing:";
      		msg += missing;
      		}

      	  if(invNum.length !=0)
      		{
		msg += "\n\nYou have entered incorrect numeric data in these fields:";
		msg += invNum;
      		}

      	  if(validmail.length !=0)
	        {
	  	msg += "\n\nYou have entered incorrect data in this field:";
	  	msg += validmail;
      		}   

      	  if(add.length !=0)
      		{
	         msg += "\n\nYou have entered incorrect data in this field:";
		 msg += add;
      		}


      		errMsg(msg);
      		msg = ""; missing = ""; invNum = ""; add = "";
      		return false;
      		}
      	   else
      	   	{
      	   	 return true;
      	   	 }




   function notNumeric(field)
   	{
   	var errCount = 0;
   	var numdecs = 0;
   	for (j=0; j<field.value.length; j++)
   	   {
   	   c = field.value.charAt(j);
   	if ((c >= 0 && c <= 9) || c == "." || (j == 0 && c == "-"))
   		{
   		if (c== ".")
   		  {
   		  numdecs++;
   		  }
   		 }
   		else
   		 {
   		 errCount++;
   		 break;
   		 }
   		}
   	 if ((errCount > 0 ) || (numdecs > 0))
   	 	{
   	 	return true;
   	 	}
   	    return false;
   	    }
      	   //}




     function isEmail(s)
     /******************/
     {
         var i = 1;
         var sLength = s.length
         while ((i < sLength) && (s.charAt(i) != "@")) {i++}

         if ((i >= sLength) || (s.charAt(i) != "@")) {return 1}

         else {i += 2};

         while ((i < sLength) && (s.charAt(i) != "."))   {i++}

         if ((i >= sLength - 1) || (s.charAt(i) != ".")) {return 2}
         else {return 0}

}  


  function isEmpty(field)
    {
    str = field.value;
    if(str == "")
    // make sure not to put a space between those quotes
      {
      return true;
      }
    else
      {
      for(j=0; j<str.length; j++)
        {
        if(str.charAt(j) != " ")
        // make sure to put a space between those quotes!
          {
          return false;
          }
        }
      }
     return true;
     }





     function errMsg(msg)
       {
       var theMsg = "You entered some incorrect values into the form. ";
       theMsg += "Please correct your entries then re-submit the form.\n";
       theMsg += "____________________________________________________________________";
       theMsg += msg;
       theMsg += "\n____________________________________________________________________\n";
       alert(theMsg);
       }


   
}


   
//-->
