/**
 * @author cristiano
 */

function Recupera()
{
	this.script_page = "/ajax/recupera_dati.php";
	
	this.readForm = function()
	{
		var mailbox = document.getElementById("email");
		var span_error = document.getElementById("email_error");
		var check = new String(mailbox.value);
		
		if (!check.match(/^([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})){1}$/))
		{
			mailbox.style.borderColor = "#B1EB00";
			mailbox.focus();
			span_error.style.backgroundColor = "white";
			span_error.style.color = "#999999";
			span_error.innerHTML = "&Egrave; necessario inserire una e-mail valida.";
			return false;
		}
		else
		{
			mailbox.style.borderColor = "";
			span_error.style.backgroundColor = "";
			span_error.style.color = "";
			span_error.innerHTML = "";
			return true;
		}
	}
	
	this.sendReq = function()
	{
		if (this.readForm())
		{
			this.setLoadingSrc("/immagini/vote_loader.gif");
			this.setTarget(document.getElementById("rec_response"));
			this.setLoadingTarget(document.getElementById("submitting"));
			this.params["email"] = new String(document.getElementById("email").value);
			this.makeRequest(this.script_page);
		}
	}
}

Recupera.prototype = new AjaxModule();
Recupera.prototype.constructor = Recupera;
