var url = 'naltis_captcheck.php?code=';
var captchaOK = 2;  // 2 - not yet checked, 1 - correct, 0 - failed

function getHTTPObject()
{
	try
	{
		req = new XMLHttpRequest();
	}
	catch (err1)
	{
		try
		{
			req = new ActiveXObject("Msxml12.XMLHTTP");
		}
		catch (err2)
		{
			try
			{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (err3)
			{
				req = false;
			}
		}
	}

	return req;
}

var http = getHTTPObject(); // We create the HTTP Object        
var http0 = getHTTPObject(); // We create the HTTP Object        

function handleHttpResponse()
{
	if (http0.readyState == 4)
	{
		captchaOK = http0.responseText;
		if (captchaOK != 1)
		{
			alert('The entered code was not correct. Please try again');
			document.getElementById("naltis_captcha").value='';
			document.getElementById("naltis_captcha").focus();
		}
		else
		{
			//alert('ok');
			go_valider_PDF();
		}
	}
}

function handleHttpResponse_fromcontact()
{
	if (http.readyState == 4)
	{
		captchaOK = http.responseText;
		if (captchaOK != 1)
		{
			alert('The entered code was not correct. Please try again');
			document.getElementById("naltis_captcha").value='';
			document.getElementById("naltis_captcha").focus();
			return false;
		}
//		alert('ok')
		check_fields_en();

	}
}

function checkcode(thecode)
{
//	alert(thecode)
	http0.open("GET", url + escape(thecode), true);
	http0.onreadystatechange = handleHttpResponse;
	http0.send(null);
}

function checkcode_fromcontact(thecode)
{
//	alert(thecode)
	http.open("GET", url + escape(thecode), true);
	http.onreadystatechange = handleHttpResponse_fromcontact;
	http.send(null);
}

