

var theCaptcha;
var captchaOK = false;
var captchaValue = null;

var checkCaptcha = function(value, options){
	
	if( captchaOK ==true
	   	&& captchaValue == value)
		return true;
	
	captchaValue = value;
	
	new Request(
	{
		url:contextPath+'captcha/check/'+value,
		method: 'get',
		encoding:'ISO-8859-1',
		data:"",
		onFailure:manageCaptchaErrors,
		onSuccess:processCaptcha
	}).send();

	return false;
}

function processCaptcha(e,xml)
{
	var debug = false;
	if (debug) {console.info("[CaptchaTools.js] [processCaptcha] Starting... ");}
	
	if( xml.documentElement == null)
		return;
		
	var answer = xml.documentElement.getAttribute("value");
	if( answer == 'true')
		captchaOK = true;
	else
		captchaOK = false;
		
	theCaptcha.validate();
	
	if (debug) {console.info("[CaptchaTools.js] [processCaptcha] End ");}
	
}

function manageCaptchaErrors()
{

}