var tmp = false;
function ajaxFunction(url)
{
	var mykeke = false;
	new Ajax.Request(url,{
			asynchronous: false,
			method: 'get',
			onComplete: function(html) {
				mykeke = (html.responseText=="A");
			}
	});
	return mykeke;
}

function validate_form(captcha){
	return update_pagina(true);
}

function checkFields(name)
{
	if (document.getElementById(name).value == "undefined" || document.getElementById(name).value == '')
		return true;
	return false;
}

function update_pagina(captcha){
	var errors='';
	if (checkFields('contact_name'))
		errors +='Please provide a contact name'+"\n";
	if (checkFields('contact_email'))
		errors +='Please provide a contact email'+"\n";
	if (checkFields('contact_phone'))
		errors +='Please provide a contact phone'+"\n";
	
	if (checkFields('contact_inquiry'))
		errors +='Please provide an inquiry'+"\n";
	if (!ajaxFunction("ajax.php?captcha="+captcha))
		errors +='Please provide request code'+"\n";
	
	if (errors!="")
	{
		alert(errors);
		return false;
	}
	document.getElementById('contact_f').submit();
	return true;
}
