<!-- Begin
/* Form Validation Functions
Compiled and programed by Tim Kelly @ Cipher.net.au
Copyright CipherNet 2004-2005 All rights reserved
Th following functions were adapted from and still remain the legal property of 
http://javascript.internet.com 
'clearWhitespace' & 'checkEmail' 
*/
var isValid = true;
var submitForm = true;
var erMsg = "Form Submission Error. \n------------------------------------------- ";
function returnErrors() {
	if (submitForm==false) {
		alert(erMsg);
		isValid=true;
		submitForm=true;
		erMsg="Form Submission Error. \n------------------------------------------- ";
		return false;
		}
	return true;
}
function isInput(Str, Label) {
	if (Str == "") { //is empty
   		erMsg = erMsg + " \n" + Label + " is required."; 
   	return false; 
   }
	return true;
}
function isSecure(Str, Label) {
	if (Str.length < 7) { //is empty
   		erMsg = erMsg + " \n" + Label + " must be at least 7 Characters long."; 
   	return false; 
   }
	return true;
}
function clearWhitespace(item)
{
  var tmp = "";
  var item_length = item.value.length;
  var item_length_minus_1 = item.value.length - 1;
  for (index = 0; index < item_length; index++)
  {
    if (item.value.charAt(index) != ' ')
    {
      tmp += item.value.charAt(index);
    }
    else
    {
      if (tmp.length > 0)
      {
        if (item.value.charAt(index+1) != ' ' && index != item_length_minus_1)
        {
          tmp += item.value.charAt(index);
        }
      }
    }
  }
  item.value = tmp;
}

function checkEmail (emailStr) {
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null) {
		erMsg = erMsg + " \nE-mail address cannot be validated";
	return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
		erMsg = erMsg + " \nInvalid characters used in E-mail username.";
	return false;
	   }
	}
	for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
		erMsg = erMsg + " \nInvalid characters used in E-mail domain.";
	return false;
	   }
	}
	if (user.match(userPat)==null) {
		erMsg = erMsg + " \nE-mail username invalid.";
	return false;
	}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
	for (var i=1;i<=4;i++) {
	if (IPArray[i]>255) {
		erMsg = erMsg + " \nDestination IP address is invalid!";
	return false;
	   }
	}
	return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
		erMsg = erMsg + " \nDomain name invalid.";
	return false;
	   }
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && 
	domArr[domArr.length-1].search(knownDomsPat)==-1) {
		erMsg = erMsg + " \nE-mail address must end in a well-known domain or two letter country.";
	return false;
	}
	if (len<2) {
		erMsg = erMsg + " \nE-mail address is missing a hostname!";
	return false;
	}
	return true;
	}

/*Form Validation Routine */
function checkForm(form) {
isValid = isInput(form.name.value,'Your contact name');
	if (isValid==false) {
		submitForm=false;
		}   
isValid = checkEmail(form.email.value);
	if (isValid==false) {
		submitForm=false;
		}
isValid = isInput(form.phone.value,'Your contact phone number');
	if (isValid==false) {
		submitForm=false;
		}   
isValid = isInput(form.inquiry.value,'Your Message/Inquiry');
	if (isValid==false) {
		submitForm=false;
		}
/*Finally check for total errors and return results to user (if any)*/				
isValid = returnErrors();
	if (isValid==false) {
		return false;
		}	
	AuthenticateForm();
	return true;
}
/*End Form Validation Routine */
//  End -->