/* Code that validates the fields */

function validate_required(field,alerttxt){
	with (field){
	  if (value==null||value==""){
		  alert(alerttxt);
		  return false;
	  }
	  else{
		  return true;
	  }
	}
}

function validate_email(field,alerttxt){
	with (field){
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) {
			alert(alerttxt);return false;
		}
		else {
			return true;
		}

	}
}

/* End Code that validates fields */


/* Begin writing the code to validate the forms themselves */
function validate_contact(thisform){
	with (thisform){
		if (validate_required(name,"You must provide a name")==false){
			name.focus();
			return false;
		}
		if (validate_email(email,"You must provide a valid e-mail address")==false){
			email.focus();
			return false;
		}
		if (validate_required(phone,"You must provide a phone number")==false){
			phone.focus();
			return false;
		}
		if (validate_required(comment,"You must provide a message")==false){
			comment.focus();
			return false;
		}
	}
}


/* End code for validating the forms */