if (document.getElementsByTagName) {
	window.onload = addvalidation;
}

function addvalidation() {
	var form = document.getElementById("message-form");
	form.onsubmit = function() { return validate(form); }
}

function validate(form) {
	var errors = "";

	// Check that the name field is not bank
	var field = document.getElementById("Name");
	if (field.value.match(/^\s*$/)) {
		errors += "Your name is required.\n";
	}
	
	// Check that the email field is in the correct format
	field = document.getElementById("Email");
	if (field.value.match(/^\s*$/)) {
		errors += "Email is required.\n";
	} else if (!field.value.match(/^[\w\-\.]+@[\w\-\.]+\.[\w\-]*$/)) {
		errors += "Email is not formatted correctly.\n";
	}
	
	// Check that the message field is not blank
	field = document.getElementById("Message");
	if (field.value.match(/^\s*$/)) {
		errors += "A message is required.\n";
	}
	
	
	
	
	if (errors != "") {
		alert("Please correct the following:\n\n" + errors);
		return false;
	} else { return true; }
}
