// JavaScript Document
//by lazzaro calvano
//////////////////////////////////////////////////////////////////////////////////////////////
var user;
var pass;
var isAway;
var curSelected='';
var vTimer;
var showOfflineBuddies=0;
//var usereg;
var passwd;
var getBuddyList = 1;
var xmlhttp=false;
/*function entermy() { 
//if (animale)
xmlhttp=false;
nome = "pabloj";
	var ricerca = nome + "=";
	var fine;
	// quello che devo cercare nella stringa

	if (document.cookie.length > 0) {
	   //se esistono i cookies
	   inizio = document.cookie.indexOf(ricerca);
	   if (inizio != -1) {
	   	  inizio += ricerca.length;
		  // mi metto all'inizio del valore
		  fine = document.cookie.indexOf(";", inizio);
		  // trovo la fine del valore
		  fine = (fine==-1) ? document.cookie.length : fine;
		  //.. che potrebbe essere anche la fine della stringa
		  
		  fine = unescape(document.cookie.substring(inizio, fine));
		  // missione compiuta!
		  }
		}

//alert('CHI?! in? '+ document.cookie+' && ');
if (fine){ 
if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   alert ('fa tutto cat');
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   alert ('fa ms cat');
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
	   alert ('entermy');
/*   xmlhttp.open('POST',"../myzoo/pabloajax.php",false);
   xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

   xmlhttp.send("call=entermy&from="+fine);
	alert ('la xrisp è' + xmlhttp.responseText);

   if(xmlhttp.responseText=='invalid') {
    //  document.getElementById('password').value = '';
    //  Effect.Shake('login');
			alert ('Impossibile accedere a myZOO.\nAssicurati di aver effettutato correttamente la procedura di  login.');
	} else if(xmlhttp.responseText=='0') { 
   					var mywin;
					mywin = window.open('../myzoo/',"myzoo");
					mywin.focus();
	}else if(xmlhttp.responseText=='1') { 
					alert('Il tuo myZOO dovrebbe essere già aperto in una nuova finestra.\nSe proprio non lo trovi, clicca su logout e ripeti la procedura di login.');
					mywin = window.open('../myzoo/',"myzoo");
					mywin.focus();
	} else {
			alert ('Impossibile accedere a myZOO.\nContattare lo Staff.');
	}
  } else {//!fine
  		alert ('Impossibile accedere a myZOO.\nRipetere la procedura di login.');		
  }
 xmlhttp=false;

}*/

function soundGo() {
soundManager.play('aDrumSound');
}

function on_zoo() {
//alert('fa');
//alert('on zoo '+document.cookie);   
nome = "pabloj";
var fine;
	var ricerca = nome + "=";
	// quello che devo cercare nella stringa

	if (document.cookie.length > 0) {
	   //se esistono i cookies
	   
	   inizio = document.cookie.indexOf(ricerca);
	   if (inizio != -1) {
	   	  inizio += ricerca.length;
		  // mi metto all'inizio del valore
		  fine = document.cookie.indexOf(";", inizio);
		  // trovo la fine del valore
		  fine = (fine==-1) ? document.cookie.length : fine;
		  //.. che potrebbe essere anche la fine della stringa
		  
		  fine = unescape(document.cookie.substring(inizio, fine));
		  // missione compiuta!
		  }
		}

		//fine = '';
		// se proprio non c'erano cookies
   if (fine) {
  //alert('fine: '+fine+'\n');   
if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   //alert ('fa tutto cat');
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   //alert ('fa ms cat');
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
   xmlhttp.open('POST',"../pabloajax.php",false);
   xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send("call=who&from="+fine);
   risp = xmlhttp.responseText;
   user = fine;

if ( risp != 'invalid'){ 
if (document.getElementById('logzone')){ 
//alert ('è '+risp);
    var xmlResponse = xmlhttp.responseXML.documentElement; 

        var uss = xmlResponse.getElementsByTagName('user')[0];
		ussOn = uss.getAttribute('onl');
		isAway = ussOn - 1;
//   alert('la risp iaj '+ ussOn +' isAw= '+isAway);   
		

document.getElementById('logzone').innerHTML = '<div class="box-bottom"><font size="2"><b><a class="sottotitolo" href="../myzoo" target="myzoo" onclick="">ENTRA</a>&nbsp; | &nbsp;<a class="sottotitolo" onclick="logout(0);" href="#">LOGOUT</a></div>';
document.getElementById('usname').style.display = 'inline';
document.getElementById('usname').innerHTML = 'Ciao '+ risp +'!';
document.getElementById('vparla_def').style.display = 'none';
document.getElementById('vparla').style.display = 'block';
if (ussOn == 0){

document.getElementById('sel_status').options[ 3 ].selected = true;
 
} else {
document.getElementById('sel_status').options[ isAway ].selected = true;
} 


vTimer = setTimeout("v_parla()",3000);

//document.getElementById('vparla').style.visibility = 'visible';
//document.getElementById('vparla').className = 'round';
   }
   }
   }
xmlhttp=false;

}


function on_zoo_home() {
//alert('fa home');
//alert('on zoo '+document.cookie);   
nome = "pabloj";
var fine;
	var ricerca = nome + "=";
	// quello che devo cercare nella stringa

	if (document.cookie.length > 0) {
	   //se esistono i cookies
	   
	   inizio = document.cookie.indexOf(ricerca);
	   if (inizio != -1) {
	   	  inizio += ricerca.length;
		  // mi metto all'inizio del valore
		  fine = document.cookie.indexOf(";", inizio);
		  // trovo la fine del valore
		  fine = (fine==-1) ? document.cookie.length : fine;
		  //.. che potrebbe essere anche la fine della stringa
		  
		  fine = unescape(document.cookie.substring(inizio, fine));
		  // missione compiuta!
		  }
		}

		//fine = '';
		// se proprio non c'erano cookies
   if (fine) {
  //alert('fine: '+fine+'\n');   
if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   //alert ('fa tutto cat');
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   //alert ('fa ms cat');
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
   xmlhttp.open('POST',"pabloajax.php",false);
   xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send("call=who&from="+fine);
   risp = xmlhttp.responseText;
   user = fine;
//alert ('è '+risp);

if ( risp != 'invalid'){ 
if (document.getElementById('logzone')){ 
    var xmlResponse = xmlhttp.responseXML.documentElement; 

        var uss = xmlResponse.getElementsByTagName('user')[0];
		ussOn = uss.getAttribute('onl');
		isAway = ussOn - 1;
  // alert('la risp iaj '+ ussOn +' isAw= '+isAway);   
		

document.getElementById('logzone').innerHTML = '<div class="box-bottom"><font size="2"><b><a class="sottotitolo" href="myzoo" target="myzoo" onclick="">ENTRA</a>&nbsp; | &nbsp;<a class="sottotitolo" onclick="logout(0);" href="#">LOGOUT</a></div>';
document.getElementById('usname').style.display = 'inline';
document.getElementById('usname').innerHTML = 'Ciao '+ risp +'!';
document.getElementById('vparla_def').style.display = 'none';
document.getElementById('vparla').style.display = 'block';
if (ussOn == 0){

document.getElementById('sel_status').options[ 3 ].selected = true;
 
} else {
document.getElementById('sel_status').options[ isAway ].selected = true;
} 


vTimer = setTimeout("v_parla_home()",1000);

//document.getElementById('vparla').style.visibility = 'visible';
//document.getElementById('vparla').className = 'round';
   }
   }
   }
xmlhttp=false;

}

//}
// dal submit della finestra di login parte la funz LOGON
function logon() {
//if (animale)

//alert('mhe logon');

  var username = document.getElementById('usernamee').value;
   var password = document.getElementById('passworde').value;

//alert('è '+ username +' ono');   
 if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
  // alert ('fa tutto cat');
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  // alert ('fa ms cat');
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

   xmlhttp.open('POST',"../pabloajax.php",false);
   xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send("call=logon&from="+username+"&pwd="+password);
//alert('è risp '+ xmlhttp.responseText +' ono');   

   if(xmlhttp.responseText=='invalidpwd') {
      document.getElementById('passworde').value = '';
      //Effect.Shake('login');
	  alert('Hai inserito una password errata.');
      //Effect.Shake('login');
   } else if(xmlhttp.responseText=='invalidlog') {
      document.getElementById('passworde').value = '';
	  alert('Zooname inesistente.');
      //Effect.Shake('login');
   } else {
      //user = username; pass = hex_md5(password);
      document.getElementById('usernamee').value = '';
      document.getElementById('passworde').value = '';
      //winList['login'].close();
	  nome= 'pabloj';
	  valore = xmlhttp.responseText;
	  ////////////////////////////////////////////////////////7
//functio setCookie(name, value, days) {


//document.cookie = name + "=" + escape(value)

//+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))

//}
////////////////////////////////////////////////////7

	  //scadenza = new Date();
   //scadenza.setMonth(scadenza.getHours()+12); // fra 12 ore
	//scadenza = new Date() + 14400;
var scadenza = new Date();

scadenza.setFullYear(scadenza.getFullYear() +1); 
	  //function impostaUnCookieGenerico(nome, valore, scadenza) {
	strCookie = nome + "=" + escape(valore);
	//if (scadenza)
	
	   strCookie += "; expires=" + scadenza.toGMTString();
	   strCookie += "; path=/";
	  // strCookie += "; domain=pablozoo.com;";
	document.cookie = strCookie;
	//alert( "Ho impostato il cookie <strong>" + strCookie +"</strong>");
   	//}
	//  alert('Login effettuato con successo.');
	//entermy();
	window.location.reload();
	

	   /*if (todooo == true)
		  {
			//window.location = '../myzoo/';
			} else {
			
			} /**/
 	}
xmlhttp=false;

}

// dal submit della finestra di login parte la funz LOGON
function logon_home() {
//if (animale)

//alert('mhe logon');

  var username = document.getElementById('usernamee').value;
   var password = document.getElementById('passworde').value;

//alert('è '+ username +' ono');   
 if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
  // alert ('fa tutto cat');
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  // alert ('fa ms cat');
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

   xmlhttp.open('POST',"pabloajax.php",false);
   xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send("call=logon&from="+username+"&pwd="+password);
//alert('è risphome '+ xmlhttp.responseText +' ono');   

   if(xmlhttp.responseText=='invalidpwd') {
      document.getElementById('passworde').value = '';
	  alert('Hai inserito una password errata.');
      //Effect.Shake('login');
   } else if(xmlhttp.responseText=='invalidlog') {
      document.getElementById('passworde').value = '';
	  alert('Zooname inesistente.');
      //Effect.Shake('login');
   } else {
      //user = username; pass = hex_md5(password);
      document.getElementById('usernamee').value = '';
      document.getElementById('passworde').value = '';
      //winList['login'].close();
	  nome= 'pabloj';
	  valore = xmlhttp.responseText;
	  ////////////////////////////////////////////////////////7
//functio setCookie(name, value, days) {


//document.cookie = name + "=" + escape(value)

//+ ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))

//}
////////////////////////////////////////////////////7

	  //scadenza = new Date();
   //scadenza.setMonth(scadenza.getHours()+12); // fra 12 ore
	//scadenza = new Date() + 14400;
var scadenza = new Date();

scadenza.setFullYear(scadenza.getFullYear() +1); 
	  //function impostaUnCookieGenerico(nome, valore, scadenza???????????) {
	strCookie = nome + "=" + escape(valore);
	//if (scadenza)
	
	   strCookie += "; expires=" + scadenza.toGMTString();
	   strCookie += "; path=/";
	  // strCookie += "; domain=pablozoo.com;";
	document.cookie = strCookie;
	//alert( "Ho impostato il cookie <strong>" + strCookie +"</strong>");
   	//}
	  alert('Login effettuato con successo.');
	//entermy();
	window.location.reload();
	

	   /*if (todooo == true)
		  {
			//window.location = '../myzoo/';
			} else {
			
			} /**/
 	}
xmlhttp=false;

}


function logout( exit ) { 
//alert ('coo di logout prima è '+ document.cookie)
  
   var da = 0;
   	  nome= 'pabloj';
	  //valore = xmlhttp.responseText;
	  valore = '';
	  scadenza = new Date();
   scadenza.setMonth(scadenza.getMonth()-1); // un mese fa
//	scadenza = new Date() + 14400;
	  //function impostaUnCookieGenerico(nome, valore, scadenza) {
	strCookie = nome + "=" + escape(valore);
	//if (scadenza)
	   strCookie += "; expires=" + scadenza.toGMTString();
	   strCookie += "; path=/";
	  // strCookie += "; domain=pablozoo.com;";
//alert ('coo di logout dopo è '+ strCookie)
	document.cookie = strCookie; 
  // if (document.getElementById('remember').checked) da = 1;

if ( exit == 1) { 
//   xmlhttp.open('POST',"../myzoo/pabloajax.php",false);
 //  xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

//   xmlhttp.send("call=not_online");
//alert(xmlhttp.responseText+' ');
//window.location='../';
}
if ( exit == 0) window.location.reload();

/*   document.getElementById('showLogin').style.display = 'inline';
   document.getElementById('logout').style.display = 'none';
   document.getElementById('openNewIM').style.display = 'none';
   document.getElementById('changePwd').style.display = 'none';
   document.getElementById('awayMsgWin').style.display = 'none';
   
   document.getElementById('showOfflineBuddies').value='Show Offline Buddies';*/
   // showOfflineBuddies nn se se serve, per ora lo lascio
   user = '';  
}


function out_zoo() {
//alert(document.cookie+'  out');   
nome = "pabloj";
var fine;
	var ricerca = nome + "=";
	// quello che devo cercare nella stringa

	if (document.cookie.length > 0) {
	   //se esistono i cookies
	   
	   inizio = document.cookie.indexOf(ricerca);
	   if (inizio != -1) {
	   	  inizio += ricerca.length;
		  // mi metto all'inizio del valore
		  fine = document.cookie.indexOf(";", inizio);
		  // trovo la fine del valore
		  fine = (fine==-1) ? document.cookie.length : fine;
		  //.. che potrebbe essere anche la fine della stringa
		  
		  fine = unescape(document.cookie.substring(inizio, fine));
		  // missione compiuta!
		  }
		}
//		alert('fineogzone: '+fine+'\n'+document.getElementById('logzone').innerHTML);   

		//fine = '';
		// se proprio non c'erano cookies
   if(fine) {
if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   //alert ('fa tutto cat');
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   //alert ('fa ms cat');
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
   xmlhttp.open('POST',"../pabloajax.php",false);
   xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send("call=who_out&from="+fine);
   
//alert('è out  '+ xmlhttp.responseText +' ono');   

//if (xmlhttp.responseText != "invalid"){ 
//document.getElementById('logzone').innerHTML = '<font size="2"><b><a class="sottotitolo" href="../">home</a>&nbsp; | &nbsp;<a class="sottotitolo" href="#" id="showLogin" onclick="if (winList['login']) winList['login'].open();">login</a>&nbsp; | &nbsp;<a class="sottotitolo" href="../community/register.php">register</a>';
   
  // }
   }
xmlhttp=false;

}


function out_zoo_home() {
//alert(document.cookie+'  out');   
nome = "pabloj";
var fine;
	var ricerca = nome + "=";
	// quello che devo cercare nella stringa

	if (document.cookie.length > 0) {
	   //se esistono i cookies
	   
	   inizio = document.cookie.indexOf(ricerca);
	   if (inizio != -1) {
	   	  inizio += ricerca.length;
		  // mi metto all'inizio del valore
		  fine = document.cookie.indexOf(";", inizio);
		  // trovo la fine del valore
		  fine = (fine==-1) ? document.cookie.length : fine;
		  //.. che potrebbe essere anche la fine della stringa
		  
		  fine = unescape(document.cookie.substring(inizio, fine));
		  // missione compiuta!
		  }
		}
//		alert('fineogzone: '+fine+'\n'+document.getElementById('logzone').innerHTML);   

		//fine = '';
		// se proprio non c'erano cookies
   if(fine) {
if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   //alert ('fa tutto cat');
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   //alert ('fa ms cat');
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
   xmlhttp.open('POST',"pabloajax.php",false);
   xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send("call=who_out&from="+fine);
   
//alert('è out  '+ xmlhttp.responseText +' ono');   

//if (xmlhttp.responseText != "invalid"){ 
//document.getElementById('logzone').innerHTML = '<font size="2"><b><a class="sottotitolo" href="../">home</a>&nbsp; | &nbsp;<a class="sottotitolo" href="#" id="showLogin" onclick="if (winList['login']) winList['login'].open();">login</a>&nbsp; | &nbsp;<a class="sottotitolo" href="../community/register.php">register</a>';
   
  // }
   }
xmlhttp=false;

}


function soundCheck() {
//alert('fa home');
//alert('on zoo '+document.cookie);   
nomesnd = "sound";
var finesnd;
	var ricercasnd = nomesnd + "=";
	// quello che devo cercare nella stringa

	if (document.cookie.length > 0) {
	   //se esistono i cookies
	   
	   iniziosnd = document.cookie.indexOf(ricercasnd);
	   if (iniziosnd != -1) {
	   	  iniziosnd += ricercasnd.length;
		  // mi metto all'inizio del valore
		  finesnd = document.cookie.indexOf(";", iniziosnd);
		  // trovo la fine del valore
		  finesnd = (finesnd==-1) ? document.cookie.length : finesnd;
		  //.. che potrebbe essere anche la fine della stringa
		  
		  finesnd = unescape(document.cookie.substring(iniziosnd, finesnd));
		  // missione compiuta!
		  }
		}

		//fine = '';
		// se proprio non c'erano cookies
   if (finesnd == '0' || finesnd == '1') {
  //alert('fine: '+finesnd+'\n');   
  return finesnd;
  } else {
 // alert ('no fine') ;
  nada = '0';
  return nada;
	 }
	  
} 

function v_parla( ){
////////////////////////////////////////////////////////////
//if (!livewin.closed && livewin.location)
chek = soundCheck();
//alert ('coo is '+ chek);
if (chek == '0') {
if ( document.getElementById("sound_img").src = '../images/clips/sound-off.gif') 	document.getElementById('soundRule' ).innerHTML = '<a class=\"sottotitolo\" href=\"#\" onclick=\"soundOff();\"><img id=\"sound_img\"  border=\"0\" src=\"../images/clips/sound-on.gif\" align=\"absmiddle\"></a>';
} 
if (chek == '1') {
if ( document.getElementById("sound_img").src = '../images/clips/sound-on.gif') 	document.getElementById('soundRule' ).innerHTML = '<a class=\"sottotitolo\" href=\"#\" onclick=\"soundOn();\"><img id=\"sound_img\"  border=\"0\" src=\"../images/clips/sound-off.gif\" align=\"absmiddle\"></a>';
} 

//if (document.getElementById('allin').checked == true ) showOfflineBuddies = 1;
//if (document.getElementById('allin').checked == false ) showOfflineBuddies = 0;

if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   //alert ('fa tutto cat');
  // pl = 'ff';
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   //alert ('fa ms cat');
   //pl = 'ie';
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
//
//browser = navigator.appName;
//alert ('away='+isAway);
//stt = document.getElementById('sel_status').selectedIndex ;
xmlhttp.open('POST',"../pabloajax.php",false);
xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//xmlhttp.send("call=liveping&from="+ ufrom +'&for='+ ufra  +'&away='+ stt );
xmlhttp.send("call=ping&from="+user+"&away="+isAway+"&show="+showOfflineBuddies);


//xmlhttp.send("call=ping&from="+user+"&away="+isAway);
//alert ('ora is '+ xmlhttp.responseText );

    var xmlResponse = xmlhttp.responseXML.documentElement; 
 //    var ora = xmlResponse.getElementsByTagName('now')[0].firstChild.data;
     var oraSound = xmlResponse.getElementsByTagName('isOpen')[0].firstChild.data;
	OldNumMsgs = document.getElementById("msg_now").innerHTML;
//alert ("fromsgg="+ oraSound );
 
	  
   if(xmlResponse.getElementsByTagName('numMessages')[0].firstChild.data) {
      var numMsgs = xmlResponse.getElementsByTagName('numMessages')[0].firstChild.data;
//alert ("fromsgg="+ document.getElementById("msg_now").innerHTML );
//if ( numMsgs == OldNumMsgs ) soundGo();
//if ( numMsgs > OldNumMsgs ) //soundGo();
//alert ( "di piu "+ numMsgs + " e "+ OldNumMsgs);
if ( numMsgs > OldNumMsgs ) {
if (chek == '0') {
//alert ('coo is '+ chek);
if (oraSound == '0') {
soundManager.play('lionRoar');
soundManager.setVolume('lionRoar',100);
}
//soundManager.play('lionRoar');

}
} 
//if ( numMsgs < OldNumMsgs ) soundGo();

		document.getElementById("msg_now").innerHTML = numMsgs;
		
	}
       var numBuddies = xmlResponse.getElementsByTagName('numBuddies')[0].firstChild.data;

   if(getBuddyList == 1) {
  		 var buddyList = document.getElementById('buddylist');
		 buddyList.innerHTML = '';
		 if (numBuddies > 0) {
		 if (numBuddies > 50) {
		 buddyList.innerHTML = 'Ci sono pi&ugrave; di 50 Animali online al momento.';
		 } else { // -- di 20 online
	  

       for(i=0; i<numBuddies; i++) {
         var buddy = xmlResponse.getElementsByTagName('user')[i];
		 buddyId = buddy.getAttribute('uid');
//if ()
 //alert('buddylist is '+ numBuddies + 'bud '+ buddy.firstChild.data );
         //////// prendere questa funzione addBuddyToList
//		 buddyList.innerHTML = buddyList.innerHTML + '<li id="'+buddy.firstChild.data+'_blItem" class="view" onselectstart="return false;" onclick="'+"if(curSelected.length>0){var old=document.getElementById(curSelected+'_blItem');old.style.background='#fff';old.style.color='#333';};this.style.background='#47649a';this.style.color='#fff';curSelected='"+buddy.firstChild.data+"';"+'" ondblclick="if(curSelected.length>0){if(!document.getElementById(curSelected+\'_im\')){createIMWindow(curSelected, curSelected);winList[curSelected].open();document.getElementById(curSelected+\'_sendBox\').focus();};};return false;"><img src="pabloajax/images/online.png" width="5" height="5" alt="" id="'+buddy.firstChild.data+'_blImg">&nbsp;'+buddy.firstChild.data+'</li>';
		 if(buddy.firstChild.data) addBuddyToList( buddyId , buddy.firstChild.data );

         if(buddy.getAttribute('status') == 'busy') {
            //document.getElementById(buddy.firstChild.data+"_blItem").style.display='none';
            document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/occup.gif"  
         } else if(buddy.getAttribute('status') == 'away') {
            document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/allont.gif" 
         } else if(buddy.getAttribute('status') == 'online') {
            document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/onz.gif" 
         } else if(buddy.getAttribute('status') == 'offline') {
            document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/not_on.gif" 
         }   
      }
	  
	  
	  }

		} else if (numBuddies == 0){
	 buddyList.innerHTML = 'Nessun Animale online al momento.';

		} else { //-1
	 buddyList.innerHTML = 'Nessun Animale online al momento.';

		}  // if >0
//getBuddyList = 0;
	  } else {
		 // var numBuddies = xmlResponse.getElementsByTagName('numBuddies')[0].firstChild.data;
		  for(i=0; i<numBuddies; i++) {
			 var buddy = xmlResponse.getElementsByTagName('user')[i];
			 if(buddy.getAttribute('status') == 'offline') {
			   // if(showOfflineBuddies==0) {
				 //  document.getElementById(buddy.firstChild.data+"_blItem").style.display='none';
				//} else {
				   document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				//}
				document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/not_on.gif";
			 } else if(buddy.getAttribute('status') == 'away') {
				document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/allont.gif";            
			 } else {
				if (document.getElementById(buddy.firstChild.data+"_blItem")) document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				if (document.getElementById(buddy.firstChild.data+"_blImg")) document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/onz.gif";
			 }
		  }
	   }
	   
//if (document.getElementById('titim').innerHTML) {
//livewin.focus();
//}
//return false;
liveTimer = setTimeout("v_parla()",5000);

}
/*
} else {
				   document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				//}
				document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/not_on.gif";
			 } else if(buddy.getAttribute('status') == 'away') {
				document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/allont.gif";            
			 } else {
				if (document.getElementById(buddy.firstChild.data+"_blItem")) document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				if (document.getElementById(buddy.firstChild.data+"_blImg")) document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/onz.gif";
			 }
		  }
	   }
	   
//if (document.getElementById('titim').innerHTML) {
//livewin.focus();
//}
//return false;
liveTimer = setTimeout("v_parla()",5000);

}
*/
function v_parla_home( ){
////////////////////////////////////////////////////////////
//if (!livewin.closed && livewin.location)
chek = soundCheck();
//alert ('coo is '+ chek);
if (chek == '0') {
if ( document.getElementById("sound_img").src = 'images/clips/sound-off.gif') 	document.getElementById('soundRule' ).innerHTML = '<a class=\"sottotitolo\" href=\"#\" onclick=\"soundOff();\"><img id=\"sound_img\"  border=\"0\" src=\"../images/clips/sound-on.gif\" align=\"absmiddle\"></a>';
} 
if (chek == '1') {
if ( document.getElementById("sound_img").src = 'images/clips/sound-on.gif') 	document.getElementById('soundRule' ).innerHTML = '<a class=\"sottotitolo\" href=\"#\" onclick=\"soundOn();\"><img id=\"sound_img\"  border=\"0\" src=\"../images/clips/sound-off.gif\" align=\"absmiddle\"></a>';
} 

//if (document.getElementById('allin').checked == true ) showOfflineBuddies = 1;
//if (document.getElementById('allin').checked == false ) showOfflineBuddies = 0;

if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   //alert ('fa tutto cat');
  // pl = 'ff';
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   //alert ('fa ms cat');
   //pl = 'ie';
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
//
//browser = navigator.appName;
//alert ('away='+isAway);
//stt = document.getElementById('sel_status').selectedIndex ;
xmlhttp.open('POST',"pabloajax.php",false);
xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//xmlhttp.send("call=liveping&from="+ ufrom +'&for='+ ufra  +'&away='+ stt );
xmlhttp.send("call=ping&from="+user+"&away="+isAway+"&show="+showOfflineBuddies);


//xmlhttp.send("call=ping&from="+user+"&away="+isAway);
//alert ('ora is '+ xmlhttp.responseText );

    var xmlResponse = xmlhttp.responseXML.documentElement; 
 //    var ora = xmlResponse.getElementsByTagName('now')[0].firstChild.data;
     var oraSound = xmlResponse.getElementsByTagName('isOpen')[0].firstChild.data;
	OldNumMsgs = document.getElementById("msg_now").innerHTML;
//alert ("fromsgg="+ oraSound );
 
	  
   if(xmlResponse.getElementsByTagName('numMessages')[0].firstChild.data) {
      var numMsgs = xmlResponse.getElementsByTagName('numMessages')[0].firstChild.data;
//alert ("fromsgg="+ document.getElementById("msg_now").innerHTML );
//if ( numMsgs == OldNumMsgs ) soundGo();
//if ( numMsgs > OldNumMsgs ) //soundGo();
//alert ( "di piu "+ numMsgs + " e "+ OldNumMsgs);
if ( numMsgs > OldNumMsgs ) {
if (chek == '0') {
//alert ('coo is '+ chek);
if (oraSound == '0') {
soundManager.play('lionRoar');
soundManager.setVolume('lionRoar',100);
}
//soundManager.play('lionRoar');

}
} 
//if ( numMsgs < OldNumMsgs ) soundGo();

		document.getElementById("msg_now").innerHTML = numMsgs;
		
	}
       var numBuddies = xmlResponse.getElementsByTagName('numBuddies')[0].firstChild.data;

   if(getBuddyList == 1) {
  		 var buddyList = document.getElementById('buddylist');
		 buddyList.innerHTML = '';
		 if (numBuddies > 0) {
		 if (numBuddies > 50) {
		 buddyList.innerHTML = 'Ci sono pi&ugrave; di 50 Animali online al momento.';
		 } else { // -- di 20 online
	  

       for(i=0; i<numBuddies; i++) {
         var buddy = xmlResponse.getElementsByTagName('user')[i];
		 buddyId = buddy.getAttribute('uid');
//if ()
 //alert('buddylist is '+ numBuddies + 'bud '+ buddy.firstChild.data );
         //////// prendere questa funzione addBuddyToList
//		 buddyList.innerHTML = buddyList.innerHTML + '<li id="'+buddy.firstChild.data+'_blItem" class="view" onselectstart="return false;" onclick="'+"if(curSelected.length>0){var old=document.getElementById(curSelected+'_blItem');old.style.background='#fff';old.style.color='#333';};this.style.background='#47649a';this.style.color='#fff';curSelected='"+buddy.firstChild.data+"';"+'" ondblclick="if(curSelected.length>0){if(!document.getElementById(curSelected+\'_im\')){createIMWindow(curSelected, curSelected);winList[curSelected].open();document.getElementById(curSelected+\'_sendBox\').focus();};};return false;"><img src="pabloajax/images/online.png" width="5" height="5" alt="" id="'+buddy.firstChild.data+'_blImg">&nbsp;'+buddy.firstChild.data+'</li>';
		 if(buddy.firstChild.data) addBuddyToList( buddyId , buddy.firstChild.data );

         if(buddy.getAttribute('status') == 'busy') {
            //document.getElementById(buddy.firstChild.data+"_blItem").style.display='none';
            document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/occup.gif"  
         } else if(buddy.getAttribute('status') == 'away') {
            document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/allont.gif" 
         } else if(buddy.getAttribute('status') == 'online') {
            document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/onz.gif" 
         } else if(buddy.getAttribute('status') == 'offline') {
            document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/not_on.gif" 
         }   
      }
	  
	  
	  }

		} else if (numBuddies == 0){
	 buddyList.innerHTML = 'Nessun Animale online al momento.';

		} else { //-1
	 buddyList.innerHTML = 'Nessun Animale online al momento.';

		}  // if >0
//getBuddyList = 0;
	  } else {
		 // var numBuddies = xmlResponse.getElementsByTagName('numBuddies')[0].firstChild.data;
		  for(i=0; i<numBuddies; i++) {
			 var buddy = xmlResponse.getElementsByTagName('user')[i];
			 if(buddy.getAttribute('status') == 'offline') {
			   // if(showOfflineBuddies==0) {
				 //  document.getElementById(buddy.firstChild.data+"_blItem").style.display='none';
				//} else {
				   document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				//}
				document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/not_on.gif";
			 } else if(buddy.getAttribute('status') == 'away') {
				document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/allont.gif";            
			 } else {
				if (document.getElementById(buddy.firstChild.data+"_blItem")) document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				if (document.getElementById(buddy.firstChild.data+"_blImg")) document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/onz.gif";
			 }
		  }
	   }
	   
//if (document.getElementById('titim').innerHTML) {
//livewin.focus();
//}
//return false;
liveTimer = setTimeout("v_parla_home()",5000);

}


function v_parla_homeold( ){
////////////////////////////////////////////////////////////
//if (!livewin.closed && livewin.location)
chek = soundCheck();
//alert ('coo is '+ chek);
if (chek == '0') {
if ( document.getElementById("sound_img").src = 'images/clips/sound-off.gif') 	document.getElementById('soundRule' ).innerHTML = '<a class=\"sottotitolo\" href=\"#\" onclick=\"soundOff();\"><img id=\"sound_img\"  border=\"0\" src=\"images/clips/sound-on.gif\" align=\"absmiddle\"></a>';
} 
if (chek == '1') {
if ( document.getElementById("sound_img").src = 'images/clips/sound-on.gif') 	document.getElementById('soundRule' ).innerHTML = '<a class=\"sottotitolo\" href=\"#\" onclick=\"soundOn();\"><img id=\"sound_img\"  border=\"0\" src=\"images/clips/sound-off.gif\" align=\"absmiddle\"></a>';
} 

if (document.getElementById('allin').checked == true ) showOfflineBuddies = 1;
if (document.getElementById('allin').checked == false ) showOfflineBuddies = 0;

if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   //alert ('fa tutto cat');
  // pl = 'ff';
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   //alert ('fa ms cat');
   //pl = 'ie';
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
//
//browser = navigator.appName;
//alert ('away='+isAway);
//stt = document.getElementById('sel_status').selectedIndex ;
xmlhttp.open('POST',"pabloajax.php",false);
xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//xmlhttp.send("call=liveping&from="+ ufrom +'&for='+ ufra  +'&away='+ stt );
xmlhttp.send("call=ping&from="+user+"&away="+isAway);


//xmlhttp.send("call=ping&from="+user+"&away="+isAway);
//alert ('ora is '+ xmlhttp.responseText );

    var xmlResponse = xmlhttp.responseXML.documentElement; 
     var oraSound = xmlResponse.getElementsByTagName('isOpen')[0].firstChild.data;
	OldNumMsgs = document.getElementById("msg_now").innerHTML;

	  
   if(xmlResponse.getElementsByTagName('numMessages')[0].firstChild.data) {
      var numMsgs = xmlResponse.getElementsByTagName('numMessages')[0].firstChild.data;
//alert ("fromsgg="+ document.getElementById("msg_now").innerHTML );

if ( numMsgs > OldNumMsgs ) {
if (chek == '0') {
//alert ('coo is '+ chek);
if (oraSound == '0') {
soundManager.play('lionRoar');
soundManager.setVolume('lionRoar',100);
}
//soundManager.play('lionRoar');

}
} 

		document.getElementById("msg_now").innerHTML = numMsgs;
	}
       var numBuddies = xmlResponse.getElementsByTagName('numBuddies')[0].firstChild.data;

   if(getBuddyList == 1) {
  		 var buddyList = document.getElementById('buddylist');
		 buddyList.innerHTML = '';
		 if (numBuddies > 0) {
		 if (numBuddies > 50) {
		 buddyList.innerHTML = 'Ci sono pi&ugrave; di 50 Amici in Rubrica, entra in myZOO per visualizzarli tutti.';
		 } else { // -- di 20 online
	  

       for(i=0; i<numBuddies; i++) {
         var buddy = xmlResponse.getElementsByTagName('user')[i];
		 buddyId = buddy.getAttribute('uid');
//if ()
 //alert('buddylist is '+ numBuddies + 'bud '+ buddy.firstChild.data );
         //////// prendere questa funzione addBuddyToList
//		 buddyList.innerHTML = buddyList.innerHTML + '<li id="'+buddy.firstChild.data+'_blItem" class="view" onselectstart="return false;" onclick="'+"if(curSelected.length>0){var old=document.getElementById(curSelected+'_blItem');old.style.background='#fff';old.style.color='#333';};this.style.background='#47649a';this.style.color='#fff';curSelected='"+buddy.firstChild.data+"';"+'" ondblclick="if(curSelected.length>0){if(!document.getElementById(curSelected+\'_im\')){createIMWindow(curSelected, curSelected);winList[curSelected].open();document.getElementById(curSelected+\'_sendBox\').focus();};};return false;"><img src="pabloajax/images/online.png" width="5" height="5" alt="" id="'+buddy.firstChild.data+'_blImg">&nbsp;'+buddy.firstChild.data+'</li>';
		 if(buddy.firstChild.data) addBuddyToList_home( buddyId , buddy.firstChild.data );

         if(buddy.getAttribute('status') == 'busy') {
            //document.getElementById(buddy.firstChild.data+"_blItem").style.display='none';
            document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/occup.gif"  
         } else if(buddy.getAttribute('status') == 'away') {
            document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/allont.gif" 
         } else if(buddy.getAttribute('status') == 'online') {
            document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/onz.gif" 
         }   
      }
	  
	  
	  }

		} else if (numBuddies == 0){
	 buddyList.innerHTML = 'Non ci sono Amici online.';

		} else { //-1
	 buddyList.innerHTML = 'Non ci sono Amici aggiunti in Rubrica.';

		}  // if 
//getBuddyList = 0;
	  } else {
		 // var numBuddies = xmlResponse.getElementsByTagName('numBuddies')[0].firstChild.data;
		  for(i=0; i<numBuddies; i++) {
			 var buddy = xmlResponse.getElementsByTagName('user')[i];
			 if(buddy.getAttribute('status') == 'offline') {
			   // if(showOfflineBuddies==0) {
				 //  document.getElementById(buddy.firstChild.data+"_blItem").style.display='none';
				//} else {
				   document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				//}
				document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/not_on.gif";
			 } else if(buddy.getAttribute('status') == 'away') {
				document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/allont.gif";            
			 } else {
				if (document.getElementById(buddy.firstChild.data+"_blItem")) document.getElementById(buddy.firstChild.data+"_blItem").style.display='block';
				if (document.getElementById(buddy.firstChild.data+"_blImg")) document.getElementById(buddy.firstChild.data+"_blImg").src = "images/clips/onz.gif";
			 }
		  }
	   }
	   
//if (document.getElementById('titim').innerHTML) {
//livewin.focus();
//}
//return false;
liveTimer = setTimeout("v_parla_home()",5000);

}


function changeList() {
  		 var buddyList = document.getElementById('buddylist');
		 buddyList.innerHTML = 'Aggiornamento lista in corso... ';
   } // else { // back

function setStatus() {
newstatus= document.getElementById('sel_status').selectedIndex ;

  if(newstatus == 3) { // away
      isAway = -1;
 //     document.getElementById('awayMsg').innerHTML = document.getElementById('setAwayMsgText').value;
  //    document.getElementById('setAwayMsgText').value='';
   }  else { // back
      isAway = newstatus;
      //winList['awayWindow'].close();
   //   document.getElementById('imaway').style.display = 'inline';
  //    document.getElementById('imback').style.display = 'none';
   }
 
   
}



function addBuddyToList( userId , username ) {
   var buddyList = document.getElementById('buddylist');

//   buddyList.innerHTML = buddyList.innerHTML + '<li id="'+username+'_blItem" class="view" onselectstart="return false;" onclick="'+"if(curSelected.length>0){var old=document.getElementById(curSelected+'_blItem');old.style.background='#fff';old.style.color='#333';};this.style.background='#66ccff';this.style.color='#fff';curSelected='"+username+"';"+'" ondblclick="if(curSelected.length>0){if(!document.getElementById(curSelected+\'_im\')){createIMWindow(curSelected, curSelected);winList[curSelected].open();document.getElementById(curSelected+\'_sendBox\').focus();};};return false;" ><img src="images/online.png" width="5" height="5" alt="" id="'+username+'_blImg">&nbsp;'+username+'</li>';
   buddyList.innerHTML = buddyList.innerHTML + '<li id="'+username+'_blItem" class="view" onselectstart="return false;" onclick=""  ondblclick="" ><a class="sottotitolo" href="#" onclick="live_add(\''+ userId +'\');"><img src="images/clips/onz.gif" width="10" height="10" alt="" id="'+username+'_blImg" border="0">&nbsp;'+username+'&nbsp;</a></li>';

  refreshDrag();
}

function addBuddyToList_home( userId , username ) {
   var buddyList = document.getElementById('buddylist');

//   buddyList.innerHTML = buddyList.innerHTML + '<li id="'+username+'_blItem" class="view" onselectstart="return false;" onclick="'+"if(curSelected.length>0){var old=document.getElementById(curSelected+'_blItem');old.style.background='#fff';old.style.color='#333';};this.style.background='#66ccff';this.style.color='#fff';curSelected='"+username+"';"+'" ondblclick="if(curSelected.length>0){if(!document.getElementById(curSelected+\'_im\')){createIMWindow(curSelected, curSelected);winList[curSelected].open();document.getElementById(curSelected+\'_sendBox\').focus();};};return false;" ><img src="images/online.png" width="5" height="5" alt="" id="'+username+'_blImg">&nbsp;'+username+'</li>';
   buddyList.innerHTML = buddyList.innerHTML + '<li id="'+username+'_blItem" class="view" onselectstart="return false;" onclick=""  ondblclick="" ><a class="sottotitolo" href="#" onclick="live_add_home(\''+ userId +'\');"><img src="images/clips/onz.gif" width="10" height="10" alt="" id="'+username+'_blImg" border="0">&nbsp;'+username+'&nbsp;</a></li>';

  refreshDrag();
}


function no_vu( ){
////////////////////////////////////////////////////////////
//if (!livewin.closed && livewin.location)
if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   //alert ('fa tutto cat');
  // pl = 'ff';
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   //alert ('fa ms cat');
   //pl = 'ie';
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
//
//browser = navigator.appName;
//alert ('away='+isAway);
//stt = document.getElementById('sel_status').selectedIndex ;
xmlhttp.open('POST',"../pabloajax.php",false);
xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//xmlhttp.send("call=liveping&from="+ ufrom +'&for='+ ufra  +'&away='+ stt );
xmlhttp.send("call=no_vu&from="+user);
alert ('ora is no '+ xmlhttp.responseText );
   if(xmlhttp.responseText=='ok') {
clearTimeout(vTimer);
      document.getElementById('vparla_img').src = '../images/clips/action_forward.gif';
     document.getElementById('vparla_img').onclick = "yes_vu();";

//	  alert('risp ok');
      document.getElementById('vparla').style.display = 'none';
      //Effect.Shake('login');
   } else if(xmlhttp.responseText=='invalid') {
      //document.getElementById('passworde').value = '';
	  alert('Impossibile modificare VuParl&agrave;');
      //Effect.Shake('login');
   } else {
	  alert('Impossibile modificare VuParl&agrave;');
      //Effect.Shake('login');
   }

}


function yes_vu( ){
////////////////////////////////////////////////////////////
//if (!livewin.closed && livewin.location)
if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   //alert ('fa tutto cat');
  // pl = 'ff';
} else if (window.ActiveXObject) { // IE
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   //alert ('fa ms cat');
   //pl = 'ie';
} else {
   alert('Impossibile continuare: il tuo browser non supporta XMLHttpRequest.');
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
//
//browser = navigator.appName;
//alert ('away='+isAway);
//stt = document.getElementById('sel_status').selectedIndex ;
xmlhttp.open('POST',"../pabloajax.php",false);
xmlhttp.setRequestHeader('Cache-Control','no-cache');
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
//xmlhttp.send("call=liveping&from="+ ufrom +'&for='+ ufra  +'&away='+ stt );
xmlhttp.send("call=yes_vu&from="+user);
alert ('ora is yes '+ xmlhttp.responseText );
//if (document.getElementById(buddy.firstChild.data+"_blImg")) document.getElementById(buddy.firstChild.data+"_blImg").src = "../images/clips/onz.gif";
   if(xmlhttp.responseText=='ok') {
      document.getElementById('vparla').style.display = 'inline';
      document.getElementById('vparla_img').src = '../images/clips/cross.png';
      document.getElementById('vparla_img').onclick = "no_vu()";
	  alert('risp ok');
vTimer = setTimeout("v_parla()",1000);
   } else if(xmlhttp.responseText=='invalid') {
	  alert('Impossibile modificare VuParl&agrave;');
      //Effect.Shake('login');
   } else {
	  alert('Impossibile modificare VuParl&agrave;');
      //Effect.Shake('login');
   }

}
<!--
function refreshDrag() {
   var offsets = new Array();
   var root= document.getElementById("buddylist");
   var elems = root.getElementsByTagName("li");
   for (var i = 0; i < elems.length; i++) {
       Drag.init(elems[i], null, 0, 0, null, null);
       elems[i].onDrag = function(x,y,myElem) {
           // We're only really interested in the y value
           y = myElem.offsetTop;
           recalcOffsets();
           var pos = whereAmI(myElem);
           var elems = root.getElementsByTagName("li");
           var IEoffset = document.all ? 2 : 1;
           if (pos != elems.length-IEoffset && y > offsets[pos + 1]) { 
               root.removeChild(myElem);
               root.insertBefore(myElem, elems[pos+1]);
               myElem.style["top"] = "0px";
           }
           if (pos != 0 && y < offsets[pos - 1]) { 
               root.removeChild(myElem);
               root.insertBefore(myElem, elems[pos-1]);
               myElem.style["top"] = "0px";
           }
       };
       elems[i].onDragEnd = function(x,y,myElem) {
           myElem.style["top"] = "0px";
       }
   }

   function whereAmI(elem) { 
       var elems = root.getElementsByTagName("li");
       for (var i = 0; i < elems.length; i++) {
           if (elems[i] == elem) { return i }
       }
   }
   function recalcOffsets () {
       var elems = root.getElementsByTagName("li");
       for (var i = 0; i < elems.length; i++) {
           offsets[i] = elems[i].offsetTop;
       }
   }

   recalcOffsets();
}

//-->

