/* contact us validation */
function validatecontact() {
	if (!document.getElementById) return false;
	if (!document.getElementById("contactform")) return false;
	theform = document.getElementById("contactform");
	theform.onsubmit = function () {
		var x = theform.elements;
			for (var i=0;i<x.length;i++) {
				if (!x['contact_name'].value) {
					alert('Name is required');
					x['contact_name'].focus();
					return false;
				}
				if (!x['contact_comments'].value) {
					alert('Comments are required');
					x['contact_comments'].focus();
					return false;
				}
			}
		return true;
	}
}

function addLoadListener(fn) {
	if (typeof window.addEventListener != 'undefined') {
		window.addEventListener('load', fn, false);
	} else if (typeof document.addEventListener != 'undefined') {
		document.addEventListener('load', fn, false);
	} else if (typeof window.attachEvent != 'undefined') {
		window.attachEvent('onload', fn);
	} else {
		return false;
	} 
	return true;
};

addLoadListener(validatecontact);


