// JavaScript Document
/*
   -----------------------------------------------------------
   The below validate function checks only the input fields
   that are passed to the function, thereby I can re-use the
   validation scripts in the validation.js file.
   -----------------------------------------------------------
*/
function ValidateForm(field1, field2, field3) {
 var form = document.getElementById("contactForm");
 var sFlag = 1;
 
	if(field1=="name") {
		var fn = document.getElementById(field1); //using the id tag of the element
		chkBlank(fn);  //passing the object element to the called function
		isString(fn," "); //allow spaces
	}
	if(field2=="email") {
		var eml = document.getElementById(field2);
		chkBlank(eml);
		chkEmail(eml);
	}
	if(field3=="message") {
		var msg = document.getElementById(field3);
		//if this field is not blank then change the flag value to proceed
			if(chkBlank(msg)==false) {  
				sFlag = 0; //ok to proceed
			}
	}
	//if all fields have passed validation then confirm and proceed
	if(sFlag==0) {
		var answer = confirm("Are you sure you want to submit this form?")
			if (answer){
				form.submit();
			}
			 else {
				 	//sFlag=1;
					return false;
				 }
		}
}