
//Contact Form Validation
//Developed by Chris B. Nancers

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;
		}
	}
}
function validate_form(thisform){
	with (thisform){
		if (validate_required(name,"Please fill in your name.")==false){
			name.focus();
			return false;
		}
		if (validate_required(company,"Please fill in the name of your company.")==false){
			company.focus();
			return false;
		}
		if (validate_email(email,"Please enter a valid e-mail address.")==false){
			email.focus();
			return false;
		}
		if (validate_required(message,"Please enter a question or comment.")==false){
			message.focus();
			return false;
		}
	}
}