function contactValidateInit() {
	$("name").focus();
//	$("loginform").setAttribute("onsubmit", "return checkform()"); // why isn't this working in IE?
}

function contactform() {
	allowSubmit = 0;
	var fo ='';
	result = jcap($F("word"));
	var phone=$F("ph1")+$F("ph2")+$F("ph3");
	
	if ($F("name")=="") {
			$("nameError").innerHTML = 'Required Name';
			allowSubmit++;
			if(fo=='')
			{
				fo='name';
			}
	} else {
			$("nameError").innerHTML = "";
	}
	if (phone!="" && IsNumeric(phone) && phone.length==10) {
		$("phoneError").innerHTML = "";
	} else {
			$("phoneError").innerHTML = 'Required valid phone number';
			allowSubmit++;
			if(fo=='')
			{
				fo='ph1';
			}
	}
	if (checkMail($F("email"))) {
		$("emailError").innerHTML = "";
	} else {
		$("emailError").innerHTML = 'Required email';
			allowSubmit++;
			if(fo=='')
			{
				fo='email';
			}
	}
	if ($F("message")=="") {
			$("messageError").innerHTML = 'Required Message';
			allowSubmit++;
			if(fo=='')
			{
				fo='message';
			}
	} else {
			$("messageError").innerHTML = "";
	}
	
	if (result == false) {
			$("wordError").innerHTML = 'Enter code as shown';
			allowSubmit++;
			if(fo=='')
			{
				fo='word';
			}
	} else {
			$("wordError").innerHTML = "";
	}
	if (allowSubmit>0) {
		$(fo).focus();
		return false;
	} else {
		return true;
	}
	return false;
}
addEvent(window,'load', contactValidateInit);

