 
function addLoadEvent (func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
addLoadEvent(prepareForm);

function prepareForm () {
	for (var i=0; i < document.forms.length; i++) {
		var thisform = document.forms[i];
		if (!thisform.getAttribute("id") == "contact_form") continue;
		thisform.onsubmit = function() {
			return validateForm(this);
		}
	}
}

function validateForm (whichform) {
	for (var i=0; i < whichform.elements.length; i++) {
		var element = whichform.elements[i];
		if (element.className.indexOf("required") != -1) {
			if (element.value.length < 1) {
				alert("Please fill in the "+element.id+" field.");
				return false;
			}
		}
		/*if (element.className.indexOf("email") != -1) {
			if (!isEmail(element)) {
				alert("The "+element.name+" field must be a valid email address.");
				return false;
			}
		}*/
	}
	return true;
}