/** * @author cristiano */function Commento(){	this.script_page = "/ajax/commento.php";	this.checkFormCommenti = function()	{		try		{			nome = document.getElementById("nome");			if (nome.value.length <= 2)			{				alert("Nickname malformed, at least 3 characters.");				nome.style.borderColor = "red";				nome.focus();				return false;			}						nome.style.borderColor = "";		}		catch (e) {}				titolo = document.getElementById("titolo");		if (titolo.value.length <= 2)		{			alert("Title malformed, at least 3 characters.");			titolo.style.borderColor = "red";			titolo.focus();			return false;		}				commento = document.getElementById("commento");		if (commento.value.length <= 2)		{			alert("Comment malformed, at least 3 characters.");			commento.style.borderColor = "red";			commento.focus();			return false;		}				commento.style.borderColor = "";				return true;	}		this.sendComment = function()	{		if (this.checkFormCommenti())		{			this.setLoadingSrc("/immagini/vote_loader.gif");			this.setLoadingTarget(document.getElementById("php_response"));			this.setTarget(this.gestisciRisposta);			this.params["operazione"] = "commenta";			this.params["idc"] = document.getElementById("idc").value;			this.params["tp"] = document.getElementById("tp").value;						try { this.params["nome"] = document.getElementById("nome").value; }			catch (e) {}						this.params["titolo"] = document.getElementById("titolo").value;			this.params["commento"] = document.getElementById("commento").value;			this.makeRequest(this.script_page);		}	}		this.listaCommenti = function(idc, tp, pag)	{		this.setLoadingSrc("/immagini/vote_loader.gif");		this.setLoadingTarget(document.getElementById("php_response"));		this.setTarget(document.getElementById("php_response"));		this.params["operazione"] = "lista_commenti";		this.params["idc"] = parseInt(idc);		this.params["tp"] = parseInt(tp);		this.params["pag"] = (pag == null || pag == undefined) ? 1 : parseInt(pag);		this.makeRequest(this.script_page);	}		this.gestisciRisposta = function(response)	{		response = new String(response);		response = response.split(":");				if (response[0] == 'OK')		{			alert("Thanks for comment!\nYour comment must be approved before being published.");			document.getElementById('form_commento').reset();		}		else if (response[0] == 'FLOOD')			alert('You have to wait 1 minute to add a new comment.');		else			alert('Error adding a comment!');				eval("comm.listaCommenti(" + response[1] + ", " + response[2] + ", 1);");	}}Commento.prototype = new AjaxModule();Commento.prototype.constructor = Commento;
