var CaptchaOverlay = function (id) {
	this.overlay = new Overlay(id, {	width: '420px',
										draggable: true,
										visible: false,
										zindex: 1000,
										fixedcenter: true,
										constraintoviewport: true
	});
	
	this.overlay.scriptUrl = "http://" + conf.baseUrl + "/gui_manager/captcha";
	
	this.show = function (anchorShow, text, anchorHide) {
		this.overlay.show(null, this.overlay.generateOverlay(text), null);
	};
	
	
	
	this.stepOne = function (formname) {
		// definisce cosa fare nello step 2, in realtà chiama step 2
		this.overlay.getResultByAjax('', this, this.setBodyByResult, formname);
	};

	this.setBodyByResult = function (obj, result) {
		var parsed_result = null;
		var responseText = '';

		
		try {
			parsed_result = result;
			responseText = parsed_result.header + parsed_result.body;
			
			if(parsed_result.result=='OK'){
				obj.show(null, 'Grazie della segnalazione', null);
				setTimeout(function(){location.href="http://" + conf.baseUrl;},1500);
			}else{
				
				obj.show(null, parsed_result.body, null);
			}
			//UserActions.modified[parsed_result.params.t_profile_id] = obj.overlay.isSuccessResponse(parsed_result.result);			
		} catch (e) {
			obj.overlay.color = 'rosso';
			responseText = 'Si è verificato un errore, riprova più tardi!';
			obj.show(null, responseText, null);
		}
		
		
	};
};