function applyOnSubmitToForms()
{
	var contactform = document.getElementById("commentform"); 
	
	if (contactform !=null && typeof contactform !="undefined") {
		
		contactform.onsubmit = function () {
			var author = document.getElementById('author');
			var email = document.getElementById('email');
			var comment = document.getElementById('comment');
			var spamq = document.getElementById('spamq');
			var blnvalidate = true;
			var oElement = document.getElementById("author");
			if ( oElement.value == "" ) {
				author.focus();
				author.className = 'ierror';
				alert("What is your name?");
				return false;     				
			} else {
				author.className = 'iok';
			}
			var oElement2 = document.getElementById("email");
			var emailFilter=/^.+@.+\..{2,3}$/;
			if (!emailFilter.test(oElement2.value)) {
				email.focus();
				email.className = 'ierror';
				alert("Enter a valid email.");
				return false;
			} else {
				email.className = 'iok';
			}
			var oElement3 = document.getElementById("spamq");
			if ( oElement3.value == "" ) {
				spamq.focus();
				spamq.className = 'ierror';
				alert("What color is the sky?");
				return false;
			} else {
				spamq.className = 'iok';
			}
			var oElement4 = document.getElementById("comment");
			var formcontent = oElement4.value;
			if ( formcontent.length < 1 ) {
				comment.focus();
				comment.className = 'ierror';
				alert("What do you have to say?");
				return false;
			} else {
				comment.className = 'iok';
			}
			return true;
		}
	}
}	
function addLoadEvent(func) 
{
 	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	} 
	else 
	{
		window.onload = function() 
		{
	      		oldonload();
	      		func();
	    	}
	}
}
addLoadEvent(applyOnSubmitToForms);