String.prototype.trim = function() {
	var x=this;
	x=x.replace(/^\s*(.*)/, "$1");
	x=x.replace(/(.*?)\s*$/, "$1");
	return x;
}

function isEmail(string) {
	return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
}

function validateComments(oForm) {
	if (oForm.author.value.trim() == "") {
		alert("Please provide a name.");
		oForm.author.focus();
		return false;
	} else if (oForm.email.value.trim() == "" || !isEmail(oForm.email.value)) {
		alert("Please provide a proper email address.");
		oForm.email.focus();
		return false;
	} else if (oForm.text.value.trim() == "") {
		alert("If you wish to comment, do so in the box provided.");
		oForm.text.focus();
		return false;
	}
	return true;
}
