

function showCommentiGiornale(id, np){

	document.getElementById('loadingGiornale').style.display="block";

	r=Math.random();

	_url="commentigiornale_ajax.php?cosa=lista&id="+id+"&numpag="+np+"&ran="+r;


	httpRequest("GET", _url, true, handleResponseComGior);

}


function closeCommentiGiornale(id){


	document.getElementById('loadingGiornale').style.display="block";

	r=Math.random();

	_url="commentigiornale_ajax.php?cosa=chiudi&id="+id+"&ran="+r;


	httpRequest("GET", _url, true, handleResponseCloseGior);


}


function showFormGiornale(id){


	document.getElementById('loadingGiornale').style.display="block";

	_url="commentigiornale_ajax.php?cosa=form&id="+id;


	httpRequest("GET", _url, true, handleResponseComGior);

}



function showFormInviaArticolo(id){


	document.getElementById('loadingGiornale').style.display="block";

	_url="invia_articolo.php?articolo="+id;


	httpRequest("GET", _url, true, handleResponseComGior);

}



function showFanclub(id){


	document.getElementById('loadingGiornale').style.display="block";

	_url="commentigiornale_ajax.php?cosa=fc&id="+id;



	httpRequest("GET", _url, true, handleResponseComGior);

}





function sendFormGiornale(id, messaggio){

	document.getElementById('loadingGiornale').style.display="block";

	messaggio=messaggio.replace(/\r\n/g,"<br>");
	messaggio=messaggio.replace(/\r/g,"<br>");
	messaggio=messaggio.replace(/\n/g,"<br>");

	messaggio=encodeURIComponent(messaggio);


	_url="commentigiornale_ajax.php";
	_data="cosa=invia&id="+id+"&messaggio="+messaggio;


	httpRequest("POST", _url, true, handleResponseComGior, _data);
}





function sendFormInviaArticolo(id, tuonome, tuaemail, suonome, suaemail, messaggio){


		if (document.inviaArticolo.tuonome.value==''){alert('Inserisci il tuo nome');}
		else if (document.inviaArticolo.tuaemail.value==''){alert('Inserisci la tua email, servirà come indirizzo di reply');}
		else if (document.inviaArticolo.suaemail.value==''){alert('Inserisci email del destinatario');}
		else if (document.inviaArticolo.suonome.value==''){alert('Inserisci il nome del destinatario');}
		else {

			document.getElementById('loadingGiornale').style.display="block";



		messaggio=encodeURIComponent(messaggio);


		_url="invia_articolo.php";
		_data="articolo="+id+"&tuonome="+tuonome+"&suonome="+suonome+"&tuaemail="+tuaemail+"&suaemail="+suaemail+"&messaggio="+messaggio;


		httpRequest("POST", _url, true, handleResponseComGior, _data);

	}
}



function inviaFc(id){

	document.getElementById('loadingGiornale').style.display="block";

	club=document.getElementById('formFc').fanclub.value;

	_url="commentigiornale_ajax.php?cosa=inviaFc&id="+id+"&club="+club;

	httpRequest("GET", _url, true, handleResponseComGior);
}









function handleResponseComGior(){

	if (request.readyState==4){
		if (request.status==200){
			var mex=request.responseText;

	document.getElementById('loadingGiornale').style.display="none";
	document.getElementById('commentiOff').style.display="none";
	document.getElementById('commentiOn').innerHTML=mex;
	document.getElementById('commentiOn').style.display="block";
		} else {
			alert ("Problema di connessione");
		}
	} 
}


function handleResponseCloseGior(){

	if (request.readyState==4){
		if (request.status==200){
			var mex=request.responseText;

	document.getElementById('loadingGiornale').style.display="none";
	document.getElementById('commentiOn').style.display="none";
	document.getElementById('commentiOff').innerHTML=mex;
	document.getElementById('commentiOff').style.display="block";
		} else {
			alert ("Problema di connessione");
		}
	} 
}


