/***
Validation Routines
**/
function isNotEmpty(pString){
	var sCrit = /.+/;
	if(!pString.match(sCrit)){
		return false;	
	}else{
		return true;
	}
}
function isNumeric(pString){
	var iPrice = parseFloat(pString);
	if(isNaN(iPrice)){
		return false;
	}else{
		return true;
	}
}
function isEmail(pString){
	var sCrit = /^.+@.+\..{2,3}$/;
	if(!pString.match(sCrit)){
		return false;	
	}else{
		return true;
	}
}
function CreateMessage(pString){
	var sMsg="The form cannot be submited because the following fields are either mandatory or invalid\n\n";
	sMsg+=pString;
	sMsg+="\n\nPlease correct the above fields and re-submitted the form";
	return sMsg;
}




function ValidateForm(){
	var sError="";
// Get Elements
	var Name = document.getElementById("Name");	
	var Phone = document.getElementById("Phone");	
	var Email = document.getElementById("Email");
// Do Validation
	if(!isNotEmpty(Name.value)){
		sError += "- Name\n\n"
	}
	if(!isNotEmpty(Phone.value)){
		sError += "- Phone Number\n\n"
	}	
	if(!isNotEmpty(Email.value)){
		sError += "- Email Address\n\n"
	}else if(!isEmail(Email.value)){
		sError += "- Email Address is invalid\n\n"
	}	
// Display Error
	if(sError){
		alert(CreateMessage(sError));
		return false;
	}else{
		return true;	
	}	
}