function checkForm () {
	if (!isEmpty ("firstname", "First name")) {
		if (!isEmpty ("lastname", "Last name")) {
			if (!isEmpty ("email", "Email")) {
				if (!isEmpty ("comment", "Comment")) {
					if (!isEmpty ("recaptcha_response_field", "CAPTCHA response")) {
						if (isValidEmail ("email")) {
							if (isValidCaptchaResponse ()) {	
								document.getElementById ('formError').innerHTML = "";
								return true;
							}
						}
					}
				}
			}
		}
	}
	return false;
}

function isEmpty (id, name) {
	var value = document.getElementById (id).value;
	if (value == "" || value == null || value.charAt (0) == '') {
		document.getElementById ('formError').innerHTML = name + " is a mandatory field. Please amend and retry.";
		return true;
	}
	return false;
}

function isValidEmail (id) {
	var validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	var value = document.getElementById (id).value;
	if (value.search (validRegExp) == -1) {
		document.getElementById ('formError').innerHTML = "A valid e-mail address is required. Please amend and retry.";
		return false;
	}
	return true;
}

function isValidCaptchaResponse () {
	/*
	if (Recaptcha.get_challenge () != Recaptcha.get_response ())
	{
		document.getElementById ('formError').innerHTML = "Invalid CAPTCHA response. Please amend and retry.";
		Recaptcha.reload ();
		return false;
	}
	*/
	return true;
}
