<!-- Hide script from older browsers
// This script validates fields, returns error messages, submits form and redirects page

// Ensure that ESSENTIAL FIELDS have been filled in.
function CheckFields(pform) {
// The fields are checked for blanks
// Remove characters that might cause security problems from a string 
function isAlphabeticPlus(str, plus)
// returns true if str is alphabetic with addition of characters in plus
// that is only A-Z a-z or space or any of the characters in the string plus
// returns false otherwise
// returns false if empty
{
  var len= str.length;
  var ok= true;
  if (len<=1)
    return false;
  var p=0;
  var ch= "";
  while (ok && p<len)
  {
    ch= str.charAt(p);
    if (  ('A'<=ch && ch<='Z')
        ||('a'<=ch && ch<='z')
        ||(ch==" ")
        ||(plus.indexOf(ch,0)>-1)
       )
      p++;
    else
      ok= false;
  }
  return ok;
}


 if ( isAlphabeticPlus(pform.firstname.value, " ,-,'") == false) {

     alert( "Your full first name is required \nPlease ensure that all fields are filled in correctly." );
	 pform.firstname.focus();
     return false;
  }
 else if ( isAlphabeticPlus(pform.lastname.value, " ,-,'") == false) {

     alert( "Your full last name is required \nPlease ensure that all fields are filled in correctly." );
	 pform.lastname.focus();
     return false;
  }
else if (( isAlphabeticPlus(pform.phone.value, "(,),1,2,3,4,5,6,7,8,9,0,-,.") == false)||((pform.phone.value.length  < 10)||(pform.phone.value.length  > 13))) {

     alert( "Your telephone number required \nPlease ensure that all fields are filled in correctly." );
	 pform.phone.focus();
     return false;
  }
 else if ( pform.email.value.indexOf (' ', 0) != -1 ||
	pform.email.value.indexOf (';', 0) != -1 || 
	pform.email.value.indexOf (':', 0) != -1 || 
	pform.email.value.indexOf ('"', 0) != -1 || 
	pform.email.value.indexOf ('=', 0) != -1 ||
	pform.email.value.indexOf ('?', 0) != -1 ||
	pform.email.value.indexOf ('<', 0) != -1 || 
	pform.email.value.indexOf ('>', 0) != -1 || 
	pform.email.value.indexOf ('[', 0) != -1 || 
	pform.email.value.indexOf (']', 0) != -1 || 
	pform.email.value.indexOf ('{', 0) != -1 || 
	pform.email.value.indexOf ('}', 0) != -1 || 
	pform.email.value.indexOf ('|', 0) != -1 || 
	pform.email.value.indexOf (',', 0) != -1 || 
	pform.email.value.indexOf ('\'', 0) != -1 || 
	pform.email.value.indexOf ('(', 0) != -1 || 
	pform.email.value.indexOf (')', 0) != -1 || 
	pform.email.value.indexOf ('*', 0) != -1 ) {

     alert( "Invalid email address format\nPlease provide a valid email address\nand ensure that all fields are filled in correctly." );
	 pform.email.focus();
     return false;
  }
  else if ( pform.message.value.length  <= 2  ||
            pform.message.value  == "" || pform.message.value  > 160 ) {
     alert( "Message length invalid\nYou may type upto 160 characters for your message." );
	 pform.message.focus();
     return false;
  }
 else if ( isAlphabeticPlus(pform.randomnumber.value,"1,2,3,4,5,6,7,8,9,0") == false) {

     alert( "You must enter the Security Code before proceeding." );
	 pform.randomnumber.focus();
     return false;
  }


else {

// check for valid email address
 if ( pform.email.value.length <= 6 ||
      pform.email.value.indexOf ('@', 0) == -1 ||
      pform.email.value.indexOf ('.', 0) == -1){

      alert("'' " + pform.email.value + " '', is not a valid Email Address.");
	 pform.email.focus();
      return false;
 }

	else {

     // If reached this far then thank user and submit form

//	 alert ("'Thank you for your submission.'" +pform.firstname.value + "' \nPlease wait a moment while we deliver the email message")
     return true;
  }
}
}
//End Hiding -->

