var salvadestinatario;
var salvariga;
var arrayimmagini=new Array();
var numeromaximmagini;
var idriga;

//****************INIZIO: FUNZIONE OSCURAMENTO/DISOSCURAMENTO******************
function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) 
	{	
	  el.style.display = 'block';   
	}
	else 
	{
	   el.style.display = 'none';
	 }
}
//****************FINE: FUNZIONE OSCURAMENTO/DISOSCURAMENTO********************


//****************************************************************************************
//****************************************************************************************
//********                                                                          ******
//********                     INIZIO: POPUP UTILITA'                               ******      
//********                                                                          ******
//****************************************************************************************
//****************************************************************************************

 function popuperrore(msg)
 {


	var popUp = document.getElementById('PopupErrore');

	popUp.style.width=350 + 'px';
	popUp.style.height=200+ 'px';
	
	popUp_height=(document.body.parentNode.clientHeight/2)-((200)/2);
	popUp_width=(document.body.parentNode.clientWidth/2)-((350)/2);

	popUp.style.left= popUp_width + 'px';
	popUp.style.top = popUp_height + 'px';
	
	
	var oscurapagina = document.getElementById('oscurapagina');
	oscurapagina.style.width= $(document).width();
	oscurapagina.style.height= $(document).height();

	toggle('oscurapagina');



	document.getElementById('PopupErrore').innerHTML = "<div id='errorheader'>&nbsp;Error<a href='#' onclick='popupclose()'><div id='dialog-close'></div></a></div><br><br><br><br><center>"+msg+"</center>";

	toggle('PopupErrore');

	oscurapagina.onclick=popupclose;

}

function popupInfo(msg)
 {

	var popUp = document.getElementById('PopupInfo');

	popUp.style.width=350 + 'px';
	popUp.style.height=200+ 'px';
	
	popUp_height=(document.body.parentNode.clientHeight/2)-((200)/2);
	popUp_width=(document.body.parentNode.clientWidth/2)-((350)/2);

	popUp.style.left= popUp_width + 'px';
	popUp.style.top = popUp_height + 'px';
	
	
	var oscurapagina = document.getElementById('oscurapagina');
	oscurapagina.style.width= $(document).width();
	oscurapagina.style.height= $(document).height();


	toggle('oscurapagina');


	document.getElementById('PopupInfo').innerHTML = "<div id='promptheader'>&nbsp;Info<a href='#' onclick='infopopupclose()'><div id='dialog-close'></div></a></div><br><br><br><br><center>"+msg+"<br><br><br><br></center>";

	toggle('PopupInfo');

	oscurapagina.onclick=infopopupclose;

}

function popupSuccess(msg)
 {
	
	var popUp = document.getElementById('PopupSuccess');

	popUp.style.width=350 + 'px';
	popUp.style.height=200+ 'px';
	
	popUp_height=(document.body.parentNode.clientHeight/2)-((200)/2);
	popUp_width=(document.body.parentNode.clientWidth/2)-((350)/2);

	popUp.style.left= popUp_width + 'px';
	popUp.style.top = popUp_height + 'px';
	




	document.getElementById('PopupSuccess').innerHTML = "<div id='successheader'>&nbsp;Success<a href='#' onclick='successpopupclose()'><div id='dialog-close'></div></a></div><br><br><br><br><center>"+msg+"<br><br><br><br></center>";

	toggle('PopupSuccess');


}

function popupSuccessDarckBg(msg)
 {

	var popUp = document.getElementById('PopupSuccess');

	popUp.style.width=350 + 'px';
	popUp.style.height=200+ 'px';
	
	popUp_height=(document.body.parentNode.clientHeight/2)-((200)/2);
	popUp_width=(document.body.parentNode.clientWidth/2)-((350)/2);

	popUp.style.left= popUp_width + 'px';
	popUp.style.top = popUp_height + 'px';
	
	
	var oscurapagina = document.getElementById('oscurapagina');
	oscurapagina.style.width= $(document).width();
	oscurapagina.style.height= $(document).height();


	toggle('oscurapagina');

	document.getElementById('PopupSuccess').innerHTML = "<div id='successheader'>&nbsp;Success<a href='#' onclick='successpopupcloseDarckBg()'><div id='dialog-close'></div></a></div><br><br><br><br><center>"+msg+"<br><br><br><br></center>";

	toggle('PopupSuccess');




}

function alertPopup(msg)
 {

	var popUp = document.getElementById('PopupWarning');

	popUp.style.width=350 + 'px';
	popUp.style.height=200+ 'px';

	popUp_height=(document.body.clientHeight/2)-(250/2);
	popUp_width=(document.body.clientWidth/2)-(350/2);

	popUp.style.left= (popUp_width + document.body.scrollLeft) + 'px';
	popUp.style.top = (popUp_height + document.body.scrollTop) + 'px';

	var oscurapagina = document.getElementById('oscurapagina');
	oscurapagina.style.width=$(document).width()-23;
	oscurapagina.style.height=$(document).height();

	toggle('oscurapagina');

	document.getElementById('PopupWarning').innerHTML = "<div id='warningheader'>&nbsp;Warning<a href='#' onclick='warinpopupclose()'><div id='dialog-close'></div></a></div><br><br><br><br><center>"+msg+"<br><br><br><br></center>";

	toggle('PopupWarning');

	oscurapagina.onclick=warinpopupclose;

}

function popupConfirmDelete(id,msg)
 {

	id = id.replace("del","");
	var popUp = document.getElementById('PopupWarning');

	popUp.style.width=350 + 'px';
	popUp.style.height=200+ 'px';

	popUp_height=(document.body.clientHeight/2)-(250/2);
	popUp_width=(document.body.clientWidth/2)-(350/2);

	popUp.style.left= (popUp_width + document.body.scrollLeft) + 'px';
	popUp.style.top = (popUp_height + document.body.scrollTop) + 'px';

	var oscurapagina = document.getElementById('oscurapagina');
	oscurapagina.style.width=document.body.scrollWidth;
	oscurapagina.style.height=document.body.scrollHeight;

	toggle('oscurapagina');




	document.getElementById('PopupWarning').innerHTML = "<div id='warningheader'>&nbsp;Warning<a href='#' onclick='warinpopupclose()'><div id='dialog-close'></div></a></div><br><br><br><br><center>"+ msg +"<br><br><br><br><input id='yesButton' type='button' value='si' style='width: 70px' onclick='remove(" + id + "); warinpopupclose()'/>&nbsp;<input id='noButton' type='button' value='no' style='width: 70px' onclick='warinpopupclose()'/></center>";


	toggle('PopupWarning');

}

function popupclose() {
	toggle('oscurapagina');
	toggle('PopupMessaggio');
}

function warinpopupclose() {
	toggle('PopupWarning');
}

function infopopupclose() {
	toggle('oscurapagina');
	toggle('PopupInfo');
}

function successpopupclose() {
	toggle('PopupSuccess');
}


function successpopupcloseDarckBg() {
	toggle('oscurapagina');
	toggle('PopupSuccess');
}

//****************************************************************************************
//********                                                                          ******
//********                           FINE POPUP UTILITA'                            ******
//********                                                                          ******
//****************************************************************************************

//****************INIZIO: DIMENSIONE SFONDO OSCURATO & POPUP***************************
function oscurapagina_size(popUpDivVar) {
    var popUpDiv_h;
	var popUpDiv_w;
	var oscurapagina = document.getElementById('oscurapagina');
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_w=600; //CSS popup width
	popUpDiv_h=300; // CSS popup height
    popUpDiv.style.width=popUpDiv_w + 'px';  // settaggio larghezza popup
	popUpDiv.style.height=popUpDiv_h + 'px';  // settaggio altezza popup
	popUpDiv_width=(document.body.parentNode.clientWidth/2)-(popUpDiv_w/2);
	popUpDiv_height=(document.body.parentNode.clientHeight/2)-(popUpDiv_h/2); 
	popUpDiv.style.top = popUpDiv_height + 'px';	//margine superiore popup
	popUpDiv.style.left = popUpDiv_width + 'px';    //margine sinistro popup
	oscurapagina.style.width=$(document).width();    //largheza fonodo oscurato
	oscurapagina.style.height=$(document).height();   //altezza fonodo oscurato
}

function oscurapagina_sizeCustom(popUpDivVar,widthsize,heisghtsize) {
    var popUpDiv_h;
	var popUpDiv_w;
	var oscurapagina = document.getElementById('oscurapagina');
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_w=widthsize; //CSS popup width
	popUpDiv_h=heisghtsize; // CSS popup height
    popUpDiv.style.width=popUpDiv_w + 'px';  // settaggio larghezza popup
	popUpDiv.style.height=popUpDiv_h + 'px';  // settaggio altezza popup
	popUpDiv_width=(document.body.parentNode.clientWidth/2)-(popUpDiv_w/2);
	popUpDiv_height=(document.body.parentNode.clientHeight/2)-(popUpDiv_h/2); 
	popUpDiv.style.top = popUpDiv_height + 'px';	//margine superiore popup
	popUpDiv.style.left = popUpDiv_width + 'px';    //margine sinistro popup
	oscurapagina.style.width=$(document).width();    //largheza fonodo oscurato
	oscurapagina.style.height=$(document).height();   //altezza fonodo oscurato
}
//****************FINE: DIMENSIONE SFONDO OSCURATO & POPUP******************************

//****************INIZIO: POPUP PER PAGINA MESSAGGIRICEVUTI*********************
function popupricevutiPannelloAdmin(riga,id) {
    salvariga=riga;
	idriga=id;
	oscurapagina_size('PopupMessaggio');
	toggle('oscurapagina');
	document.getElementById('PopupMessaggio').innerHTML = document.getElementById('PopupMessaggio'+riga).innerHTML
	toggle('PopupMessaggio');	
}
//****************FINE: POPUP PER PAGINA MESSAGGIRICEVUTI*************************



//****************INIZIO: POPUP PER PAGINA MESSAGGIRICEVUTI*********************
function popupricevuti(riga,id) {
    salvariga=riga;
	idriga=id;
	oscurapagina_size('PopupMessaggio');
	toggle('oscurapagina');
	document.getElementById('PopupMessaggio').innerHTML = document.getElementById('PopupMessaggio'+riga).innerHTML
	var url;
	url  = "messaggioletto.asp?id=" + id;
	XMLHTTP = RicavaBrowser(messaggioletto);
	XMLHTTP.open("POST", url, false);
	XMLHTTP.send(null);
	toggle('PopupMessaggio');	
}


//****************FINE: POPUP PER PAGINA MESSAGGIRICEVUTI*************************

//****************INIZIO: DELETE MESSAGGIRICEVUTI*********************
  
function deletemsgMittente()
{
var id="";
var subid="";
chk=document.msgtable.check_list;

for (i = 0; i < document.msgtable.check_list.length; i++)
{
	if(chk[i].checked==true)
	{
	id=id+chk[i].value+",";
	}
	
	
}

lenghtid=id.length-1;
subid=id.substr(0,lenghtid)

var url;
	url  = "deletemsgMitt.asp?id=" + subid;
	XMLHTTP = RicavaBrowser(deletemsgResponse);
	XMLHTTP.open("POST", url, false);
	XMLHTTP.send(null);


}
//****************FINE: DELETE MESSAGGIRICEVUTI*************************

//****************INIZIO: DELETE MESSAGGIINVIATI*********************
  
function deletemsgMittente()
{
var id="";
var subid="";
chk=document.msgtable.check_list;

for (i = 0; i < document.msgtable.check_list.length; i++)
{
	if(chk[i].checked==true)
	{
	id=id+chk[i].value+",";
	}
	
	
}

lenghtid=id.length-1;
subid=id.substr(0,lenghtid)

var url;
	url  = "deletemsgDest.asp?id=" + subid;
	XMLHTTP = RicavaBrowser(deletemsgDestResponse);
	XMLHTTP.open("POST", url, false);
	XMLHTTP.send(null);


}
//****************FINE: DELETE MESSAGGIINVIATI*************************


//****************INIZIO: SEGNALA COME LETTI MESSAGGIRICEVUTI*********************
  
function readmsg()
{
var id="";
var subid="";
chk=document.msgtable.check_list;

for (i = 0; i < document.msgtable.check_list.length; i++)
{
	if(chk[i].checked==true)
	{
	id=id+chk[i].value+",";
	}
	
	
}

lenghtid=id.length-1;
subid=id.substr(0,lenghtid)

var url;
	url  = "readmsg.asp?id=" + subid;
	XMLHTTP = RicavaBrowser(readmsgResponse);
	XMLHTTP.open("POST", url, false);
	XMLHTTP.send(null);


}
//****************FINE: SEGNALA COME LETTI  MESSAGGIRICEVUTI*************************



//****************INIZIO: SEGNALA COME ANCORA NON LETTI MESSAGGIRICEVUTI*********************
  
function noreadmsg()
{
var id="";
var subid="";
chk=document.msgtable.check_list;

for (i = 0; i < document.msgtable.check_list.length; i++)
{
	if(chk[i].checked==true)
	{
	id=id+chk[i].value+",";
	}
	
	
}

lenghtid=id.length-1;
subid=id.substr(0,lenghtid)

var url;
	url  = "noreadmsg.asp?id=" + subid;
	XMLHTTP = RicavaBrowser(noreadmsgResponse);
	XMLHTTP.open("POST", url, false);
	XMLHTTP.send(null);


}
//****************FINE: SEGNALA COME ANCORA NON LETTI  MESSAGGIRICEVUTI*************************

//****************INIZIO: POPUP PER PAGINA MESSAGGIINVIATI************************
function popupinviati(riga,id) {
    salvariga=riga;
	oscurapagina_size('PopupMessaggio');

	toggle('oscurapagina');
	document.getElementById('PopupMessaggio').innerHTML = document.getElementById('PopupMessaggio'+riga).innerHTML
	toggle('PopupMessaggio');	
}
//****************FINR: POPUP PER PAGINA MESSAGGIINVIATI**************************

//****************INIZIO: POPUP PER INVIO MESSAGGI************************
function sendMessage(destinatario) {

	oscurapagina_size('PopupMessaggio');

	toggle('oscurapagina');
	salvadestinatario=destinatario
	document.getElementById('PopupMessaggio').innerHTML = "<div id='titolopopup'>"+replyMsg+"</div><a href='javascript:void(0);' onclick='popupclose()'><div id='closepopup'></div></a> <a href='javascript:void(0);' onclick='invia()'><div id='replybutton'><div id='leftbutton'></div><div id='centerbutton'>"+inviaMsg+"</div><div id='rightbutton'></div></div></a><div id='messaggioform'><p><label>"+lableMessaggio+"</label><span id='erroremessaggio'>"+errormsg+"</span><center><form name='messaggioform'><textarea name='areamessaggio'  ></textarea></form></center></p></div>";	   
	toggle('PopupMessaggio');	
}
//****************FINR: POPUP PER INVIO MESSAGGI**************************



//****************INIZIO: FUNZIONI CHIUSURA POPUP**********************************
function popupclose() {
	toggle('oscurapagina');
	toggle('PopupMessaggio');	
}

//****************FINE: FUNZIONI CHIUSURA POPUP*************************************



//****************INIZIO: FUNZIONE POPUP  RISPOSTA**********************************
function rispondi(destinatario) {
		   salvadestinatario=destinatario
		   document.getElementById('PopupMessaggio').innerHTML = "<div id='titolopopup'>"+replyMsg+"</div><a href='javascript:void(0);' onclick='popupclose()'><div id='closepopup'></div></a> <a href='javascript:void(0);' onclick='invia()'><div id='replybutton'><div id='leftbutton'></div><div id='centerbutton'>"+inviaMsg+"</div><div id='rightbutton'></div></div></a><div id='messaggioform'><p><label>"+lableMessaggio+"</label><span id='erroremessaggio'>"+errormsg+"</span><center><form name='messaggioform'><textarea name='areamessaggio'  ></textarea></form></center></p></div>";	   
		   }
//****************FINE: FUNZIONE POPUP  RISPOSTA************************************


//****************INIZIO: FUNZIONE POPUP  INVIO*************************************		   
function invia() {
	if(document.messaggioform.areamessaggio.value!="")
		{
			var url;
			url  = "inviamessaggio.asp?destinatario=" + salvadestinatario +"&messaggio="+document.messaggioform.areamessaggio.value;
			XMLHTTP = RicavaBrowser(inviamessaggio);
			XMLHTTP.open("POST", url, false);
			XMLHTTP.send(null);			   
		}
		else
		{
			document.getElementById('erroremessaggio').style.visibility = "visible";
		}
}
//****************FINE: FUNZIONE POPUP  INVIO****************************************	
 

 
 
 
 
//****************INIZIO: CREAZIONE ARRAY PER  GALLERIA IMMAGINI *************************************	 
 function addimmagine(aggiungiimmagine)
 {
	if(numeromaximmagini==null)
		{
		numeromaximmagini=1;
		}
		else
		{
		numeromaximmagini=numeromaximmagini+1;
		}
		
	arrayimmagini[numeromaximmagini]=aggiungiimmagine;
 }
 //****************FINE: CREAZIONE ARRAY PER  GALLERIA IMMAGINI*************************************	
 
 
 
//****************INIZIO: FUNZIONE POPUP  IMMAGINI GALLERIA*************************************	
 function popupimmaginigallery(numeroimmagine,flagoscuramento)
 {
   

	immagine=arrayimmagini[numeroimmagine];
    //inizio: preload immagine per conoscerne la dimensione e ridimenisonamento automatico la popup//
    imm = new Image();
	
	
	
	imm.onload=function(){   //funzione onload immagine

	h = imm.height;
	w = imm.width;
	maxh=document.body.parentNode.clientHeight;
	maxw=document.body.parentNode.clientWidth;
	
	
	while(w>maxw || h>maxh)
	{
	h=h/2;
	w=w/2;
	}

	var popUp = document.getElementById('PopupMessaggio');
	popUp.style.width=w+20 + 'px';
	popUp.style.height=h+20 + 'px';
	
	popUp_height=(document.body.parentNode.clientHeight/2)-((h+20)/2);
	popUp_width=(document.body.parentNode.clientWidth/2)-((w+20)/2);

	popUp.style.left= popUp_width + 'px';
	popUp.style.top = popUp_height + 'px';
	
	
	var oscurapagina = document.getElementById('oscurapagina');
	oscurapagina.style.width=$(document).width();
	oscurapagina.style.height=$(document).height();

	//flag oscuramento , impostato negli spostamenti avanti e indietro nella gallery per evitare disoscuramento sfondo e popup
	if(flagoscuramento!=1)
	{
	toggle('oscurapagina');
	}
	
	document.getElementById('PopupMessaggio').innerHTML = "<img src='"+imm.src+"' width='"+w+"' height='"+h+"' border='0' /><a href='javascript:void(0);' onclick='popupclose()'><div id='closepopup'></div></a>";

	
	
	//bottone per spostamento in avanti
	
	if(numeroimmagine<numeromaximmagini)
	{
	document.getElementById('PopupMessaggio').innerHTML = document.getElementById('PopupMessaggio').innerHTML+"<a href='javascript:void(0);' onclick='popupimmaginigallery("+(numeroimmagine+1)+",1)'><div id='right_ico'></div></a>"; 
	}
	
	
	//bottone per spostamento indietro
	if(numeroimmagine>1)
	{
	document.getElementById('PopupMessaggio').innerHTML = document.getElementById('PopupMessaggio').innerHTML+"<a href='javascript:void(0);' onclick='popupimmaginigallery("+(numeroimmagine-1)+",1)'><div id='left_ico'></div></a>"; 
	}
	
	
	//flag oscuramento , impostato negli spostamenti avanti e indietro nella gallery per evitare disoscuramento sfondo e popup
	if(flagoscuramento!=1)
	{
	toggle('PopupMessaggio');
	}
	
	return false;
	}

	imm.src = immagine;
	//fine: preload immagine per conoscerne la dimensione e ridimenisonamento automatico la popup//
	


		
 }
 //****************FINE: FUNZIONE POPUP  IMMAGINI GALLERIA**************************************	
 

 

 //****************INIZIO: FUNZIONE POPUP  PROFILO UTENTE ANCORA NON UTILIZZATO!!!!!!!!!!!!!!!!!!*************************************		   
function visualizzaprofilo(nick) {
			var url;
			url  = "/user/profilo.asp?user=" + nick;
			XMLHTTP = RicavaBrowser(ajaxprofiloutente);
			XMLHTTP.open("POST", url, false);
			XMLHTTP.send(null);
			
}
//****************FINE: FUNZIONE POPUP  PROFILO UTENTE  ANCORA NON UTILIZZATO!!!!!!!!!!!!!!!!!!****************************************	
 

 
//****************INIZIO: FUNZIONE POPUP  IMMAGINI*************************************	
 function popupimmagini(immagine)
 {

    //inizio: preload immagine per conoscerne la dimensione e ridimenisonamento automatico la popup//
    imm = new Image();
	
	
	
	imm.onload=function(){   //funzione onload immagine

	h = imm.height;
	w = imm.width;
	maxh=document.body.parentNode.clientHeight;
	maxw=document.body.parentNode.clientWidth;
	
	
	while(w>maxw || h>maxh)
	{
	h=h/2;
	w=w/2;
	}

	var popUp = document.getElementById('PopupMessaggio');
	popUp.style.width=w+20 + 'px';
	popUp.style.height=h+20 + 'px';
	
	popUp_height=(document.body.parentNode.clientHeight/2)-((h+20)/2);
	popUp_width=(document.body.parentNode.clientWidth/2)-((w+20)/2);

	popUp.style.left= popUp_width + 'px';
	popUp.style.top = popUp_height + 'px';
	
	
	var oscurapagina = document.getElementById('oscurapagina');
	oscurapagina.style.width=$(document).width();
	oscurapagina.style.height=$(document).height();

	toggle('oscurapagina');
	
	document.getElementById('PopupMessaggio').innerHTML = "<img src='"+imm.src+"' width='"+w+"' height='"+h+"' border='0' /><a href='javascript:void(0);' onclick='popupclose()'><div id='closepopup'></div></a>";
    
	toggle('PopupMessaggio');
	
	
	return false;
	}

	imm.src = immagine;
	//fine: preload immagine per conoscerne la dimensione e ridimenisonamento automatico la popup//
	


		
 }
 //****************FINE: FUNZIONE POPUP  IMMAGINI**************************************	
 
 
 
//****************INIZIO:  CHIAMATA AJAX ***************************************************

//profilo utente ANCORA NON UTILIZZATO!!!!!!!!!!!!!!!!!!
function ajaxprofiloutente()
{
        
		
    if (XMLHTTP.readyState == 4)
    {
	  var rispostaajax;
		rispostaajax=XMLHTTP.responseText;
	  document.getElementById('PopupMessaggio').innerHTML = rispostaajax+"<a href='javascript:void(0);' onclick='popupclose()'><div id='closepopup'></div></a>"; 
	  oscurapagina_size('PopupMessaggio');		   
	  toggle('oscurapagina');    
      toggle('PopupMessaggio');
	}
}

//flag messaggio letto
function messaggioletto()
{
    if (XMLHTTP.readyState == 4)
    {
		savecolor="white";
	 document.getElementById('tr'+idriga).style.backgroundColor="white";
	}
}

//inserimenot messaggio in db
function inviamessaggio()
{
    if (XMLHTTP.readyState == 4)
    {
		var rispostaajax;
		rispostaajax=XMLHTTP.responseText;
		if(rispostaajax==1)
		{
		document.getElementById('PopupMessaggio').innerHTML = "<div id='titolopopup'>"+successMsg+"</div><a href='javascript:void(0);' onclick='popupclose()'><div id='closepopup'></div></a>";       
		}
	}
}

//delete messsaggi RIVCEVUTI
function deletemsgResponse()
{
    if (XMLHTTP.readyState == 4)
    {
	  var rispostaajax;
		rispostaajax=XMLHTTP.responseText;
		var array=rispostaajax.split(",");
		for(i = 0; i < array.length; i++){
		document.getElementById('tr'+trim(array[i])).style.display="none";
		}
	}
}

//delete messsaggi INVIATI
function deletemsgDestResponse()
{
    if (XMLHTTP.readyState == 4)
    {
	  var rispostaajax;
		rispostaajax=XMLHTTP.responseText;
		var array=rispostaajax.split(",");
		for(i = 0; i < array.length; i++){
		document.getElementById('tr'+trim(array[i])).style.display="none";
		}
	}
}



//segna messsaggi come gią letti
function readmsgResponse()
{
    if (XMLHTTP.readyState == 4)
    {
	  var rispostaajax;
		rispostaajax=XMLHTTP.responseText;
		var array=rispostaajax.split(",");
		for(i = 0; i < array.length; i++){
		document.getElementById('tr'+trim(array[i])).style.backgroundColor="white";
		}
	}
}
//segna messsaggi come ancora da leggere 
function noreadmsgResponse()
{
    if (XMLHTTP.readyState == 4)
    {
	  var rispostaajax;
		rispostaajax=XMLHTTP.responseText;
		var array=rispostaajax.split(",");
		for(i = 0; i < array.length; i++){
		document.getElementById('tr'+trim(array[i])).style.backgroundColor="#BBBBBB";
		}

	
	}
}

function RicavaBrowser(QualeBrowser)
{
    if (navigator.userAgent.indexOf("MSIE") != (-1))
    {
        var Classe = "Msxml2.XMLHTTP";
        if (navigator.appVersion.indexOf("MSIE 5.5") != (-1));
        {
            Classe = "Microsoft.XMLHTTP";
        } 
        try
        {
            OggettoXMLHTTP = new ActiveXObject(Classe);
            OggettoXMLHTTP.onreadystatechange = QualeBrowser;
            return OggettoXMLHTTP;
        }
        catch(e)
        {
            alert("Errore: l'ActiveX non verrą eseguito!");
        }
    }
    else if (navigator.userAgent.indexOf("Mozilla") != (-1))
    {
        OggettoXMLHTTP = new XMLHttpRequest();
        OggettoXMLHTTP.onload = QualeBrowser;
        OggettoXMLHTTP.onerror = QualeBrowser;
        return OggettoXMLHTTP;
    }
    else
    {
        alert("non funziona con altri browser!");
    }
}

//**************** FINE: CHIAMATA AJAX **********************************************************

    //**************** INIZIO: TRIM  STRINGA  ******************	
	function trim(str){
        return str.replace(/^\s+|\s+$/g,"");
    } 
	
  //**************** FINE: TRIM  STRINGA    ******************	
	
    //**************** INIZIO: REPLACE ALL   ******************	
function replaceAllStr(text,item,sost)
{
    while ( text.indexOf(item) != -1)
    {
        text = text.replace(item,sost);
    }
    return text;
}

    //**************** FINE: REPLACE ALL   ******************