function apri_fin(nomefile,nomefin,largh,altez) {

   largh = largh + 20 
   altez = altez + 20

   config='toolbar=no,location=no,directories=no,status=no,menubar=no,width=' + largh  + ',height=' + altez 
   config += ',scrollbars=no,resizable=no'

   pop = window.open (nomefile,nomefin,config)
   pop.moveTo((screen.Width/2) - (largh/2), (screen.Height/2)- (altez/2));
   pop.focus()

}



function IO(U, V) {//LA MOD String Version. A tiny ajax library.  by, DanDavis
    var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
    X.open(V ? 'PUT' : 'GET', U, false );
    X.setRequestHeader('Content-Type', 'text/plain; Charset=ISO-8859-1')
    X.send(V ? V : '');
return X.responseText;}


	
function aggiorna_pl(){
	var nomefile = 'playlist.txt?r=' + new Date().getTime();
	//alert (nomefile) ;
	var playlist=IO(nomefile).split("||");

	var tabella = "<Table border=1 cellspacing=0 width=320 style='font-family: verdana; font-size: 10pt;'><tr bgcolor=#f59334><th>Ora</th><th>Titolo</th></tr>"

		var riga = playlist[0].split("|")
		tabella = (tabella + "<tr bgcolor=#00ff00><td align=center>" + riga[0] + "</td><td>" + riga[1] + "</td></tr>");	

	for(i = 1; i < playlist.length - 1 ; i++){
		
		if (playlist[i].length > 3){
		var riga = playlist[i].split("|")
		
		
		tabella = (tabella + "<tr><td align=center>" + riga[0] + "</td><td>" + riga[1] + "</td></tr>");	
		
		}
	}

	tabella = tabella + "</table>"


	document.getElementById("playlist").innerHTML = tabella 

}


function aggiorna_sms(){

	nomefile = 'Messages.txt?r=' + new Date().getTime();
	var sms=IO(nomefile).split("\n");
	var tabella = "<Table border=1 cellspacing=0 width=200 style='font-family: verdana; font-size: 9pt;'><tr style='font-family: verdana; font-size: 8pt; color:#FFFFFF; background-color:#f59334'><th>Ultimi Messaggi</th></tr>"


	for(i = 0; i < sms.length - 1 ; i++){
		
		if (sms[i].indexOf('sender')<0){
		
		var riga = sms[i].split(" -  - ")

		if(riga[1].indexOf('http')<0){

		tabella = (tabella + "<tr><td><p align=justify>" + riga[1] + "</td></tr>");	

		}
		}
	}

	tabella = tabella + "</table>"


	document.getElementById("sms").innerHTML = tabella 

}


function blendimage(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //imposta come sfondo l'immagine corrente
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //rende trasparente l'immagine
    changeOpac(0, imageid); 
     
    //carica la nuova immagine
    document.getElementById(imageid).src = imagefile; 

    //dissolvenza
    for(i = 0; i <= 100; i++) { 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 
} 


function blendimage_oa(divid, imageid, imagefile, millisec) { 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //imposta come sfondo l'immagine corrente
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
     
    //carica la nuova immagine
    document.getElementById(imageid).src = imagefile; 

} 



function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 




        var x = 0
        var aggcam
        var camera
        
        
		function aggiorna_cam(camera){
		x++
		var nomefoto = camera + '.jpg?r=' + new Date().getTime();
		
			if (camera != "onair") {
				blendimage('blenddiv','blendimage', nomefoto ,1000);
			}
			else
			{
				blendimage_oa('blenddiv','blendimage', nomefoto ,1000);
			}
		
		}
		

		function avvio_cam(camera){
			clearInterval(aggcam)
			aggiorna_cam(camera)
			aggcam = setInterval ("aggiorna_cam('" + camera + "')", 7000 );
		}
		


	
	setInterval ("aggiorna_sms()", 5000 );
	setInterval ("aggiorna_pl()", 5000 );


