	
												
ie5 = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
opac = 0;

var bOmino=new JSBalloon({	width:170, 
													autoAway:false, 
													autoHide:true,
													showCloseBox:false,
													name:'divAAA'});
													

function load() {
  
	   stPaginaCaricataJS = "S";
	   Scrolla();
  	 //caricaListaPreferiti("",""); 
		 setTimeout("controllaNovita();",1000 * 3);
}  


function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function Scrolla(){
	
	
	divOminoL = document.getElementById("divOmino");
	divOminoL.style.top=-300;
	divOminoL.style.width=10;
	divOminoL.style.height=10;
	
	var dsocx=(window.pageXOffset)? pageXOffset: ietruebody().scrollLeft;
	var dsocy=(window.pageYOffset)? pageYOffset : ietruebody().scrollTop;

	var winHeight=document.all&&!window.opera? ietruebody().clientHeight : window.innerHeight;
	var winWidth=document.all&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
	
	var floatHeight=divOminoL.offsetHeight>0? divOminoL.offsetHeight : divOminoL.style.width;
	var floatWidth=divOminoL.offsetWidth>0? divOminoL.offsetWidth : divOminoL.style.width;
	
	
	divOminoL.style.position = 'absolute';
	divOminoL.style.left = '30px';
	divOminoL.style.top=dsocy+winHeight-floatHeight-5+"px"
	
	bOmino.balloon.style.top=dsocy+winHeight-200;
}
	

function Naviga (dove) {
	document.Form_Navigazione.regola_navigazione.value=dove; 
	document.Form_Navigazione.submit();
}


function clickButton(e, buttonid){ 

      var evt = e ? e : window.event;

      var bt = document.getElementById(buttonid);

      if (bt){ 

          if (evt.keyCode == 13){ 

                bt.click(); 

                return false; 

          } 
      } 
}



var newWindow = null
function apriChat() {
    // check if window already exists
    if (!newWindow || newWindow.closed) {
    	  newWindow = window.open('chat.jsp?rnd='+escape(Math.random()), 'Chat','width=635,height=550,toolbar=no, location=yes,directories=no,status=yes,menubar=no,scrollbars=no,copyhistory=no, resizable=no');
    } else {
        // window already exists, so bring it forward
    }
    newWindow.focus();
}



var myRequest = null;
var myRequest2 = null;
var myRequestNovita = null;
var myRequestForum = null;


function CercaTag(st,tag) {

		var TagDa = "<"+tag+">";
		var TagA = "</"+tag+">";
		var x = st.indexOf(TagDa)+ TagDa.length;
		var y = st.indexOf(TagA);
		
		if (x >= 0 && y>=0 && y>=x) {
			return  st.substring(x,y);
			
		}

		return "";
}

function CreateXmlHttpReq(handler) {
  var xmlhttp = null;
  try {
    xmlhttp = new XMLHttpRequest();
  } catch(e) {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  xmlhttp.onreadystatechange = handler;
  return xmlhttp;
}


function myHandlerListaPreferiti() {
    if (myRequest.readyState == 4 && myRequest.status == 200) {
        var divPr = document.getElementById("divListaPreferiti");
            divPr.innerHTML = myRequest.responseText;
    }
    
    if(myRequest.readyState == 4 ) {
    	myRequest=null;
    }
}

function myHandlerNovita() {

    
    
    if (myRequestNovita.readyState == 4 && myRequestNovita.status == 200) {
    	   	
    	var stx =myRequestNovita.responseText;    	
    	
    	var msgBall = CercaTag(stx,'JSBalloon');
    	var lunghezza = CercaTag(stx,'JSBLEN');
    	if (msgBall.length>1){
    		    bOmino.Show({title:'Hi '+stNickLoggatoJS+"!",message:msgBall,anchor:divOmino, icon:'Info',width:lunghezza});
    		    document.getElementById("RichiestaForzata").value = "0";
      }
      
      
      var UtOnline = CercaTag(stx,'UtentiOnline');
      document.getElementById("divUtentiOnline").innerHTML = UtOnline;

      

      var UtChat = CercaTag(stx,'UtentiChat');
      document.getElementById("divUtentiChat").innerHTML = UtChat;
      
     
      if (stNickLoggatoJS=="giasso") { 
        var TuttiOn = CercaTag(stx,'TuttiOnline');
        document.getElementById("TuttiOnline").innerHTML = TuttiOn;
      }
      
    }
    
    if (myRequestNovita.readyState == 4) {
    	var saa = setTimeout('controllaNovita();',1000 * 15);
    	
    }
    
}

//-------------------------------------------------------------
function caricaListaPreferiti(idPatch,verso) {
    myRequest = CreateXmlHttpReq(myHandlerListaPreferiti);
    
    var pag = "listaPreferite2.jsp?idPatch="+idPatch+"&par="+verso+"&rnd="+escape(Math.random());

    myRequest.open("GET",pag);
    myRequest.send(null);
}

function controllaNovita() {
	
	  var richForz = document.getElementById("RichiestaForzata").value;
	  myRequestNovita = CreateXmlHttpReq(myHandlerNovita);    
    var pag = "chat_Novita.jsp?Nick="+stNickLoggatoJS+"&RichiestaForzata="+richForz+"&rnd="+escape(Math.random());
    myRequestNovita.open("GET",pag);
    myRequestNovita.setRequestHeader("connection", "close"); 
    myRequestNovita.send(null);
}

//-----------------------------------------------------------------------------------------------------

var bPatch=new JSBalloon();
function VisualizzaBalloon(obj,titolo,testo, qualBand)
{
	bPatch.Show({title:titolo,message:testo,anchor:obj, icon:'Bandiera', qualeBandiera:qualBand});
}

function VisualizzaDescrPatch(obj,titolo,testo)
{
	bPatch.Show({title:titolo,message:testo,anchor:obj, icon:'Info'});
}

function VisualizzaInfo(obj,testo)
{
	bPatch.Show({title:testo,anchor:obj, icon:'Info'});
}


var c1='red'
var c2='#<%=stColore%>'
function colore1(){
codice='<font color=' + c1+ '><b>Notes For You</b></font>'
if(document.all)
{
document.all('testo').innerHTML=codice;
}
else if(document.getElementById){
document.getElementById("testo").innerHTML = codice
}
attesa = window.setTimeout("colore2()",500);
}
function colore2(){
codice='<font color=' + c2 + '><b>Notes For You</b></font>'
if(document.all)
{
document.all('testo').innerHTML=codice;
}
else if(document.getElementById){
document.getElementById("testo").innerHTML =codice
}
attesa = window.setTimeout("colore1()",500)
}
function lampeggia()
{
attesa = window.setTimeout("colore1()",500);
}