
function validateForm()
{	
	var frm = document.forms['contactUsForm'];
	var errorDiv = document.getElementById("errorMessageDiv");
	var errorMessage = "";
	var isValidForm = false;
	if (errorDiv)
	{
		var fullName = document.getElementById('txtFullName');
		var email = document.getElementById('txtEmail')
		var phone = document.getElementById('txtTelephone')
		var question = document.getElementById('txtQuestion')
		var state = document.getElementById('txtState');
		var captchaCode = document.getElementById('captchaCode');
		
		
		if (!wos.string.hasValue(fullName.value)) 
		{
			errorMessage += "<li>Your name is missing</li>";	
			wos.dom.replaceClass(fullName, "ok", "error");
		}
		else
			wos.dom.replaceClass(fullName, "error", "ok");
		if (!wos.string.hasValue(email.value)) 
		{
			errorMessage += "<li>Your email address is missing</li>";	
			wos.dom.replaceClass(email, "ok", "error");
		}
		else if (!wos.string.isValidEmail(email.value))
		{
			errorMessage += "<li>The email address is not valid. Please supply a valid email address.</li>";	
			wos.dom.replaceClass(email, "ok", "error");
		}
		else
			wos.dom.replaceClass(email, "error", "ok");
		if (!wos.string.hasValue(phone.value)) 
		{
			errorMessage += "<li>Your phone number is missing</li>";	
			wos.dom.replaceClass(phone, "ok", "error");
		}
		else
			wos.dom.replaceClass(phone, "error", "ok");
		if (!wos.string.hasValue(state.value)) 
		{
			errorMessage += "<li>Your state is missing</li>";	
			wos.dom.replaceClass(state, "ok", "error");
		}
		else
			wos.dom.replaceClass(state, "error", "ok");
		if (!wos.string.hasValue(question.value)) 
		{
			errorMessage += "<li>Your question / comments is missing</li>";	
			wos.dom.replaceClass(question, "ok", "error");
		}
		else
			wos.dom.replaceClass(question, "error", "ok");
		if (!wos.string.hasValue(captchaCode.value)) 
		{
			errorMessage += "<li>The verification code is missing</li>";	
			wos.dom.replaceClass(captchaCode, "ok", "error");
		}
		else
			wos.dom.replaceClass(captchaCode, "error", "ok");
			
			
		if (errorMessage == "")
		{
			isValidForm = true;	
		}
		else
		{
			errorDiv.innerHTML = "Please correct the following:<ul>" + errorMessage + "</ul>";
			wos.dom.replaceClass(errorDiv, "noDisplay", "display");
		}
	}
	if (isValidForm)
		frm.submit();
}

// Register the loginForm as the "default" form on this page, and ensure the validateForm() function is called whenever form submission occurs.
wos.event.addEvent(window, 'load', function() { 
	var frm = document.forms['contactUsForm'];
	wos.form.setDefaultForm(frm); 
	frm.validatorMethod = function() { 
		validateForm(); 
	};
} );
