function visualizzaForm(){
		$j("#commentilist").fadeOut(500, function(){
			$j("#commentform").fadeIn(500);
		});
	}
	
	function visualizzaCommenti(){
		$j("#commentform").fadeOut(500, function(){
			$j("#commentilist").fadeIn(500);
		});
	}
	
	function visualizzaConfermaInserimento(){
	
	
	$j("#commentform").fadeOut(500, function(){
			
			$j('#confermainserimento').fadeIn(500);
		});
	}
	
	function nascondiConfermaInserimento(){
		$j('#confermainserimento').fadeOut(250);
	}
	
	
	function insertAjaxComment(){
		
		
		
		var theForm = document.commentformform;
		
		
		var author = encodeURIComponent(theForm.author.value);
		var email = encodeURIComponent(theForm.email.value);
		var url = encodeURIComponent(theForm.url.value);
		var comment = encodeURIComponent(theForm.comment.value);
		var privacy_comment = theForm.privacy_comment;
		var comment_post_ID = encodeURIComponent(theForm.comment_post_ID.value);
		
		
		
		if(!author || author == undefined || !email || email == undefined || !comment || comment==undefined){
		
			alert("Compila correttamente nome, e-mail e commento");
			return;
		}
		
		if(privacy_comment.checked==false){
		
			alert("Devi accettare le condizioni sulla privacy");
			return;
		}
		
		
		$j.post("wp-comments-ajax.php?author="+author+'&email='+email+'&url='+url+'&comment='+comment+'&comment_post_ID='+comment_post_ID+'&ajaxComment=insert', null, function(data) {
			if(data){
				$j("#debug").html(data);
				visualizzaConfermaInserimento();
			}
		});
	}
	
	var Cto = false;
	
	function getAjaxComment(){
	
	
		$j.post("wp-comments-ajax.php", {ajaxComment: 'select'}, function(data) {
		
			if(data){
				
				refreshCommenti(data);
			
			}
		
		});
	}
	
	function refreshCommenti(data){
		$j("#commentiul").html(data);
		Cto = window.setTimeout("getAjaxComment()",3000);
	}
	
	var wrapperStatus = 'closed';
	
	function mostraWrapperCommenti(){
	
	
		if(wrapperStatus == 'closed'){
			$j.post("wp-comments-ajax.php", {ajaxComment: 'select', all: 'true'}, function(data) {
			
				if(data){
					wrapperStatus = 'open';
					$j("#commentsWrapper").html(data);
					$j("#commentsWrapper").animate({height:"toggle"},"slow");
				}
			
			});
		}else if(wrapperStatus == 'open'){
		
			$j("#commentsWrapper").animate({height:"toggle"},"slow");
			wrapperStatus = 'closed';
		}
	}
	
	
	
	function sendForm(task){
	
	
	
		theForm = document.forms[task];
		
		
		var error = '';
		
		
		if(task == 'iscriviti_convegno'){
		
			
		
			var nome = theForm.nome_iscriviti.value;
			
			
			if(!nome || nome == undefined){
				error = "Devi Specificare il nome";
			}
			
			
			
			var cognome = theForm.cognome_iscriviti.value;
			
			if(!cognome || cognome == undefined){
				error += "\nDevi Specificare il cognome";
			}
			
			
			var email = theForm.email_iscriviti.value;
			if(!email || email == undefined){
				error += "\nDevi Specificare la mail";
			}
			
			if(theForm.privacy_iscriviti.checked==false){
			
				error += "\nDevi accettare i termini sulla privacy";
			
			}
			
			var telefono = theForm.telefono_iscriviti.value;
		}else if(task == 'segnala_amico'){
		var error = '';
			var nome_amico = theForm.nome_segnala.value;
			
			
			if(!nome_amico || nome_amico == undefined){
				error += "\nDevi Specificare il tuo nome";
			}
			
			
			
			
			var nome_segnalato = theForm.amico_segnala.value;
			
			
			if(!nome_segnalato || nome_segnalato == undefined){
				error += "\nDevi Specificare il nome del tuo amico;"
			}
			
			
			var email_amico = theForm.email_amico_segnala.value;
			
			if(!email_amico || email_amico == undefined){
				error += "\nDevi Specificare la mail del tuo amico;"
			}
			
			if(theForm.privacy_segnala.checked==false){
			
				error += "\nDevi accettare i termini sulla privacy";
			
			}
			
		}else if(task == 'richiedi_atti'){
		var error = '';
			var nome_atti = theForm.nome_atti.value;
			
			
			if(!nome_atti || nome_atti == undefined){
			
				error += "\nSpecifica il tuo nome";
			}
			
			
			var cognome_atti = theForm.cognome_atti.value;
			
			
			if(!cognome_atti || cognome_atti == undefined){
			
				error += "\nSpecifica il tuo cognome";
			}
			
			
			var email_atti = theForm.email_atti.value;
			
			
			if(!email_atti || email_atti == undefined){
			
				error += "\nSpecifica la tua e-mail";
			}
			
			if(theForm.privacy_atti.checked==false){
			
				error += "\nDevi accettare i termini sulla privacy";
			
			}
			
			var telefono_atti = theForm.telefono_atti.value;
		}else if(task == 'newsletter_form'){
			
			var error = '';
			var nome_newsletter = theForm.nome_newsletter.value;
			
			if(!nome_newsletter || nome_newsletter == undefined){
			
				error += "\nSpecifica il tuo nome";
			}
			
			var email_newsletter = theForm.email_newsletter.value;
			
			if(!email_newsletter || email_newsletter == undefined){
			
				error += "\nSpecifica la tua e-mail";
			}
			
			if(theForm.privacy_newsletter.checked==false){
			
				error += "\nDevi accettare i termini sulla privacy";
			
			}
			
		}
	
		if(error) {
			alert(error);
			return;
		}
	
	
		$j.post("wp-ajax-mail.php", {action: task, _nome: nome, _cognome: cognome, _email: email, _telefono: telefono, _nome_amico: nome_amico, _nome_segnalato: nome_segnalato, _email_amico: email_amico, _nome_atti: nome_atti, _cognome_atti: cognome_atti, _email_atti: email_atti, _telefono_atti: telefono_atti, _nome_newsletter: nome_newsletter, _email_newsletter: email_newsletter}, function(data) {
			$j('#'+task+'_container').fadeOut(500,function(){
				$j('#'+task+'_ok').fadeIn(300);
				
				
			});
		});
	
	}
	
	function refreshForm(el){
		$j('#'+el+'_ok').fadeOut(300, function(){
			$j('#'+el+'_container').fadeIn(400);
		});
	}
	
	
	
	getAjaxComment();