// JavaScript Document
	function inviaCommento(idScelto, nomeS, commentoS, emailS, codeS) {
	new Ajax.Updater('boxFormCommento_form', 'ajax/insertCommento.php', {method: 'post', postBody:'nome='+ nomeS +'&id='+ idScelto +'&email='+ emailS +'&code='+ codeS +'&commento='+ commentoS +'&type=video'});
	  		setTimeout("new Ajax.Updater('boxFormCommento_form', 'ajax/insertCommentoBack.php', {method: 'post', postBody:'id="+ idScelto +"'});",3000);
			setTimeout("new Ajax.Updater('listaCommenti', 'ajax/refreshComments.php', {method: 'post', postBody:'id="+ idScelto +"&type=video'});",4000);
			setTimeout("new Ajax.Updater('numCommenti', 'ajax/countCommenti.php', {method: 'post', postBody:'id="+ idScelto +"&type=video'});",4000);
	}
	
function ContaCaratteri()
{
    document.moduloCommento.conta.value = document.moduloCommento.commento.value.length;
    var massimo = 2500;
    if (document.moduloCommento.commento.value.length > massimo)
    {
        document.moduloCommento.commento.value = document.moduloCommento.commento.value.substr(0, massimo);
        document.moduloCommento.conta.value = massimo;
        alert("Massimo " + massimo + " caratteri!");
    }
}

function Modulo(idItem) {
     // Variabili associate ai campi del modulo
     var nome = document.moduloCommento.nome.value;
	 var commento = document.moduloCommento.commento.value;
	 var email = document.moduloCommento.email.value;
	 var code = document.moduloCommento.code.value;
	 var controllo = false;
	 var bottone = document.moduloCommento.accetto; 
        //Effettua il controllo sul campo NOME
        if ((commento == "") || (commento == "undefined")) {
           alert("Attenzione!\nInserire un commento prima di inviare il modulo.");
           document.moduloCommento.commento.focus();
           return false;
        }
				 else if ((nome == "") || (nome == "undefined")) {
           alert("Attenzione: inserire il campo nome.");
           document.moduloCommento.nome.focus();
           return false;
}
		for(var i=0; i<bottone.length; i++) {
 			if(bottone[i].checked) {
 				controllo = true;
 			}
	
 			else if(!controllo) {
 			alert("Attenzione: Accettazione Privacy/Termini e Condizioni richiesta!");
 			return false;
			} 

        //INVIA IL modulo
        else {
			inviaCommento(idItem,nome,commento,email,code);
        }}
  }
