
function Nascondi(valore){


document.getElementById(valore).style.display = "none";
}




function show_commenti(id,id_agenzia){

		pulsante = document.getElementById("btt_commenti_" + id)
		oggetto = document.getElementById("commenti_contenitore_" + id)
		textarea = document.getElementById("testo_commento_" + id)
		pulsante2 = document.getElementById("btt_commenta_" + id)



		stato = oggetto.style.display;

		if(stato=="inline"){
		pulsante.innerText = "Vedi commenti";
		oggetto.style.display = "none";
		textarea.style.display = "none";
		pulsante2.style.display = "none";
		textarea.value = "Inserisci un commento";

		}
		else
		{
		//commenti_refresh(id,id_agenzia)
		oggetto.style.display = "inline";
		textarea.style.display = "inline";
		pulsante.innerText = "Nascondi commenti";

		}
		}







function show_button(id){



				testo = document.getElementById("testo_commento_" + id).value;
				nome = document.getElementById("testo_commento_" + id).name;
				document.getElementById("testo_commento_" + id).style.height="25px";


				if(testo==nome||testo==""||testo==null||testo==" " ||testo=="  "){
				document.getElementById("btt_commenta_" + id).style.display="none";
				}
				else
				{
				document.getElementById("btt_commenta_" + id).style.display="inline";
				}
}




function inserisci_commento(id,id_agenzia,azione,id_commento,tipo_utente,inserito_da){

				//***************  GESTISCO LOADING SU PULSANTE INSERIMENTO
				if(azione=="add"){
				document.getElementById("btt_commenta_load_" + id).style.display ="inline";
				document.getElementById("btt_commenta_" + id).style.display ="none";
				}


				testo = document.getElementById("testo_commento_" + id).value;


				if (window.XMLHttpRequest) {
				ricercaxx = new XMLHttpRequest();
				ricercaxx.onreadystatechange = 	function (){
				if (ricercaxx.readyState == 4 && ricercaxx.status == 200) { 

				strRes=ricercaxx.responseText;


				if(strRes=="1"){
				AlertOpen("Attenzione! Effettuare il <br><a href='accesso_area_riservata.php'>LOG-IN</a> <br>per inserire o eiliminare commenti."  ,2,'');
				document.getElementById("btt_commenta_load_" + id).style.display ="none";
				document.getElementById("btt_commenta_" + id).style.display ="inline";
				return;
				}
				if(strRes=="2"){
				AlertOpen("Attenzione! Il commento puņ essere eliminato solo da chi l'ha inserito.."  ,2,'');
				document.getElementById("btt_commenta_load_" + id).style.display ="none";
				document.getElementById("btt_commenta_" + id).style.display ="inline";
				return;
				}
				if(strRes=="3"){
				AlertOpen("Attenzione! Ogni inserzionista puņ commentare solo le proprie inserzioni."  ,2,'');
				document.getElementById("btt_commenta_load_" + id).style.display ="none";
				document.getElementById("btt_commenta_" + id).style.display ="inline";
				return;
				}
				if(strRes=="add"){

				document.getElementById("btt_commenta_load_" + id).style.display ="none";
				document.getElementById("btt_commenta_" + id).style.display ="inline";

				document.getElementById("contatore_commenti_" + id).innerText = parseInt(document.getElementById("contatore_commenti_" + id).innerText) + 1;
				commenti_refresh(id,id_agenzia);
				return;
				}
				if(strRes=="del"){
				document.getElementById("contatore_commenti_" + id).innerText = parseInt(document.getElementById("contatore_commenti_" + id).innerText) - 1;
				commenti_refresh(id,id_agenzia);
				return;
				}


				}
				}
				ricercaxx.open("GET", "ax_gestione_commenti.php?inserito_da=" + inserito_da + "&tipologia_utente=" + tipo_utente + "&id_commento=" + id_commento + "&azione=" + azione + "&testo=" + testo + "&id_agenzia=" + id_agenzia + "&id=" + id + "&rand=" + Math.random() ,true);
				ricercaxx.send(null);
				} else if (window.ActiveXObject) {
				ricercaxx = new ActiveXObject("Microsoft.XMLHTTP");
				if (ricercaxx) {
				ricercaxx.onreadystatechange = 	function (){
				if (ricercaxx.readyState == 4 && ricercaxx.status == 200) { 
				strRes=ricercaxx.responseText;


				if(strRes=="1"){
				AlertOpen("Attenzione! Effettuare il <br><a href='accesso_area_riservata.php'>LOG-IN</a> <br>per inserire o eiliminare commenti."  ,2,'');
				document.getElementById("btt_commenta_load_" + id).style.display ="none";
				document.getElementById("btt_commenta_" + id).style.display ="inline";
				return;
				}
				if(strRes=="2"){
				AlertOpen("Attenzione! Il commento puņ essere eliminato solo da chi l'ha inserito.."  ,2,'');
				document.getElementById("btt_commenta_load_" + id).style.display ="none";
				document.getElementById("btt_commenta_" + id).style.display ="inline";
				return;
				}
				if(strRes=="3"){
				AlertOpen("Attenzione! Ogni inserzionista puņ commentare solo le proprie inserzioni."  ,2,'');
				document.getElementById("btt_commenta_load_" + id).style.display ="none";
				document.getElementById("btt_commenta_" + id).style.display ="inline";
				return;
				}
				if(strRes=="add"){

				document.getElementById("btt_commenta_load_" + id).style.display ="none";
				document.getElementById("btt_commenta_" + id).style.display ="inline";

				document.getElementById("contatore_commenti_" + id).innerText = parseInt(document.getElementById("contatore_commenti_" + id).innerText) + 1;
				commenti_refresh(id,id_agenzia);
				return;
				}
				if(strRes=="del"){
				document.getElementById("contatore_commenti_" + id).innerText = parseInt(document.getElementById("contatore_commenti_" + id).innerText) - 1;
				document.getElementById("commento_" + id_commento).style.display = "none";
				return;
				}

				}
				ricercaxx.open("GET", "ax_gestione_commenti.php?inserito_da=" + inserito_da + "&tipologia_utente=" + tipo_utente + "&id_commento=" + id_commento + "&azione=" + azione + "&testo=" + testo + "&id_agenzia=" + id_agenzia + "&id=" + id + "&rand=" + Math.random() ,true);
				ricercaxx.send(null);}}


			}
			} 



function commenti_refresh(id,id_agenzia){




				if (window.XMLHttpRequest) {
				ricercaxx = new XMLHttpRequest();
				ricercaxx.onreadystatechange = 	function (){
				if (ricercaxx.readyState == 4 && ricercaxx.status == 200) { 
				strRes=ricercaxx.responseText;
				document.getElementById("commenti_contenitore_" + id).innerHTML = strRes;
				document.getElementById("testo_commento_" + id).value="Inserisci un commento";
				document.getElementById("btt_commenta_" + id).style.display="none";
				}
				}
				ricercaxx.open("GET", "ax_gestione_commenti_refresh.php?id_agenzia=" + id_agenzia + "&id=" + id + "&rand=" + Math.random() ,true);
				ricercaxx.send(null);
				} else if (window.ActiveXObject) {
				ricercaxx = new ActiveXObject("Microsoft.XMLHTTP");
				if (ricercaxx) {
				ricercaxx.onreadystatechange = 	function (){
				if (ricercaxx.readyState == 4 && ricercaxx.status == 200) { 
				strRes=ricercaxx.responseText;
				document.getElementById("commenti_contenitore_" + id).innerHTML = strRes;
				document.getElementById("testo_commento_" + id).value="Inserisci un commento";
				document.getElementById("btt_commenta_" + id).style.display="none";
				}
				ricercaxx.open("GET", "ax_gestione_commenti_refresh.php?id_agenzia=" + id_agenzia + "&id=" + id + "&rand=" + Math.random() ,true);
				ricercaxx.send(null);}}


			}





}


