// JavaScript Document
  function trimAll(sString){
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

	function validateOnKeyUp(){
		var f = document.getElementById("ContactForm");
		fname = f.fname.value;
		fname = trimAll(fname);
		lname = f.lname.value;
		lname = trimAll(lname);
		email = f.email.value;
		email = trimAll(email);
		details = document.getElementById("details").value;
		var msg = document.getElementById("errmsg");
		if(fname!="" && lname!="" && email!="" && details!=""){
		  msg.childNodes[0].nodeValue="";
		}else{
		  msg.childNodes[0].nodeValue="Fileds marked with an asterisk are required!";
        }
	}
	
    function validateOnSubmit(){
		var f = document.getElementById("ContactForm");
		fname = f.fname.value;
		fname = trimAll(fname);
		lname = f.lname.value;
		lname = trimAll(lname);
		email = f.email.value;
		email = trimAll(email);
		details = f.details.value;
 		if(fname!="" && lname!="" && email!="" && details!=""){
		  return true;
		}else{
		  alert("Please fill in all required fields!");
		  return false;
        }               
    }
