﻿// JavaScript
function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    } 
  } 
}
return req;
}

var http = getXMLHTTPRequest();


function getContenuto(pagina,elemento){
//alert('elto: '+elemento);
invisibile('operazioni');

  var myurl = pagina;
  myRand = parseInt(Math.random()*999999999999999);

  var modurl = myurl;
  /* var modurl = myurl+"&rand="+myRand;
  alert('->'+modurl); */
document.getElementById(elemento).style.visibility = 'visible';
document.getElementById(elemento).style.display = 'block';
	/*for (var i=1; i<=2; i++){
//alert(document.getElementById('colonna'+i));
		var a = document.getElementById('contenuto'+i);
		if('colonna'+i == elemento){
			a.style.visibility = 'visible';
        	a.style.display = 'block';
		}else{
			a.style.display = 'none';
		}
		
	}
    */
  http.open("GET", modurl, true);
  http.onreadystatechange = function (){
     if (http.readyState == 4) {
//alert("76] ELEMENTO = "+elemento+"\nPAGINA = "+pagina); 
    if(http.status == 200) { 
      var mytext = http.responseText;
	  document.getElementById('scrollbar').innerHTML = '';
      document.getElementById(elemento).innerHTML = mytext;
	  
    }
  } else {
  	document.getElementById('scrollbar').innerHTML = '<img src="immagini/progressbar_green.gif">';
  }
  };
  
  //getContenuto('autoICal.php?rand='+parseInt(Math.random()*999999999999999),'itime');
  
  http.send(null);
}

function invisibile(elemento) {
	var a = document.getElementById(elemento);
	a.style.display = 'none';
}

function visibile(elemento) {
	var e = document.getElementById(elemento);
        e.style.visibility = 'visible';
        e.style.display = 'block';
}


function vediamoloNo(elemento){
	var e = document.getElementById(elemento);
	document.getElementById(elemento).innerHTML = '';
	if(e.style.display == 'none'){
		e.style.visibility = 'visible';
        e.style.display = 'block';
	}else{
		e.style.display = 'none'
	}

}

/**/
var timerID = null;
var timerRunning = false;
function stopclock (){

        if(timerRunning)

                clearTimeout(timerID);

        timerRunning = false;

}

function showtime () {

        var now = new Date();

        var hours = now.getHours();

        var minutes = now.getMinutes();

        var seconds = now.getSeconds()

        var timeValue = " " + ((hours >12) ? hours -12 :hours)

        timeValue += ((minutes < 10) ? ":0" : ":") + minutes

        timeValue += ((seconds < 10) ? ":0" : ":") + seconds

        timeValue += (hours >= 12) ? " p.m." : " a.m."

        document.clock.face.value = timeValue;

        
        timerID = setTimeout("showtime()",1000);

        timerRunning = true;

}
function startclock () {
stopclock();
showtime();
}

/***/


	
	var myfont_face = "Tahoma";

	
	var myfont_size = "10";

	
	var myfont_color = "#000000";
	
	
	var myback_color = "#FFFFFF";

	
	var mypre_text = "Sono le ";

	
	var mywidth = 300;

	
	
	var my12_hour = 0;

	
	var myupdate = 1;

	
	
	var DisplayDate = 1;

        var ie4=document.all
        var ns4=document.layers
        var ns6=document.getElementById&&!document.all



	var dn = "";
	var mn = "";
	var old = "";


	var DaysOfWeek = new Array(7);
		DaysOfWeek[0] = "Domenica";
		DaysOfWeek[1] = "Lunedì";
		DaysOfWeek[2] = "Martedì";
		DaysOfWeek[3] = "Mercoledì";
		DaysOfWeek[4] = "Giovedì";
		DaysOfWeek[5] = "Venerdì";
		DaysOfWeek[6] = "Sabato";

	var MonthsOfYear = new Array(12);
		MonthsOfYear[0] = "Gennaio";
		MonthsOfYear[1] = "Febbraio";
		MonthsOfYear[2] = "Marzo";
		MonthsOfYear[3] = "Aprile";
		MonthsOfYear[4] = "Maggio";
		MonthsOfYear[5] = "Giugno";
		MonthsOfYear[6] = "Luglio";
		MonthsOfYear[7] = "Agosto";
		MonthsOfYear[8] = "Settembre";
		MonthsOfYear[9] = "Ottobre";
		MonthsOfYear[10] = "Novembre";
		MonthsOfYear[11] = "Dicembre";


	var ClockUpdate = new Array(3);
		ClockUpdate[0] = 0;
		ClockUpdate[1] = 1000;
		ClockUpdate[2] = 60000;


	if (ie4||ns6) { document.write('<span id="LiveClockIE" style="width:'+mywidth+'px; background-color:'+myback_color+'"></span>'); }
	else if (document.layers) { document.write('<ilayer bgColor="'+myback_color+'" id="ClockPosNS" visibility="hide"><layer width="'+mywidth+'" id="LiveClockNS"></layer></ilayer>'); }
	else { old = "true"; show_clock(); }


	function show_clock() {
		if (old == "die") { return; }
	
	
		if (ns4)
                document.ClockPosNS.visibility="show"
	
		var Digital = new Date();
		var day = Digital.getDay();
		var mday = Digital.getDate();
		var month = Digital.getMonth();
		var hours = Digital.getHours();
	

		var minutes = Digital.getMinutes();
		var seconds = Digital.getSeconds();

	
		if (mday == 1) { mn = "st"; }
		else if (mday == 2) { mn = "nd"; }
		else if (mday == 3) { mn = "rd"; }
		else if (mday == 21) { mn = "st"; }
		else if (mday == 22) { mn = "nd"; }
		else if (mday == 23) { mn = "rd"; }
		else if (mday == 31) { mn = "st"; }

	
		if (my12_hour) {
			dn = "AM";
			if (hours > 12) { dn = "PM"; hours = hours - 12; }
			if (hours == 0) { hours = 12; }
		} else {
			dn = "";
		}
		if (minutes <= 9) { minutes = "0"+minutes; }
		if (seconds <= 9) { seconds = "0"+seconds; }

	
		myclock = '';
		myclock += '<font style="color:'+myfont_color+'; font-family:'+myfont_face+'; font-size:'+myfont_size+'pt;">';
		myclock += mypre_text;
		myclock += hours+':'+minutes;
		if ((myupdate < 2) || (myupdate == 0)) { myclock += ':'+seconds; }
		myclock += ' '+dn;
		if (DisplayDate) { myclock += ' di '+DaysOfWeek[day]+', '+mday+mn+' '+MonthsOfYear[month]+' '; }
		myclock += '</font>';

		if (old == "true") {
			document.write(myclock);
			old = "die";
			return;
		}

	// Write the clock to the layer:
		if (ns4) {
			clockpos = document.ClockPosNS;
			liveclock = clockpos.document.LiveClockNS;
			liveclock.document.write(myclock);
			liveclock.document.close();
		} else if (ie4) {
			LiveClockIE.innerHTML = myclock;
		} else if (ns6){
			document.getElementById("LiveClockIE").innerHTML = myclock;
        }            

	if (myupdate != 0) { setTimeout("show_clock()",ClockUpdate[myupdate]); }
}

function autoSMS(){
	getContenuto('invioSMS.php?rand='+parseInt(Math.random()*999999999999999),'avvisi');
	setTimeout("autoSMS()",60000);
}

/**		GET CONTENUTO FRAME		*/
function getContenutoFrame(pagina,elemento) {
//ApriOscura(); 
	//alert("283] ELEMENTO = "+elemento+"\nPAGINA = "+pagina); 
  var myurl = pagina;
  myRand = parseInt(Math.random()*999999999999999);
  var modurl = myurl+"&rand="+myRand;
  //var modurl = myurl;
	/*for (var i=1; i<=2; i++){
//alert(document.getElementById('colonna'+i));
		var a = document.getElementById('contenuto'+i);
		if('colonna'+i == elemento){
			a.style.visibility = 'visible';
        	a.style.display = 'block';
		}else{
			a.style.display = 'none';
		}
		
	}
    */
  http.open("GET", modurl, true);
  http.onreadystatechange = function (){
     if (http.readyState == 4) {
//alert("76] ELEMENTO = "+elemento+"\nPAGINA = "+pagina); 
    if(http.status == 200) { 
      var mytext = http.responseText;
	  document.getElementById('scrollbar').innerHTML = '';
      //document.getElementById(elemento).innerHTML = mytext;
		document.getElementById(elemento).style.visibility = 'visible';
		document.getElementById(elemento).style.display = 'block';
		document.getElementById(elemento).innerHTML = '<iframe STYLE="background-color:trasparent;  allowtransparency="true" BORDER="0" WIDTH="100%" HEIGHT="95%" src="'+pagina+'"></iframe><div style="background-color:white;"><b onClick="invisibile(\''+elemento+'\');ChiudiOscura();"><img src=immagini/del.png border=0></b></div>';
	  
    }
  } else {
  	document.getElementById('scrollbar').innerHTML = '<img src="immagini/progressbar_green.gif">';
  }
  };
  http.send(null);
}
/**		FINE GET CONTENUTO FRAME		*/

function ApriOscura(){
    if (navigator.appVersion.indexOf("MSIE")!=-1){ 
         document.getElementById("oscura").style.width = screen.width;
         document.getElementById("oscura").style.height = screen.height;
    }
    document.getElementById("oscura").style.display = "block";
}

function ChiudiOscura() {
	document.getElementById("oscura").style.display = "none";
}

function autoEmail(){
	//getContenuto('test_pop_mail.php?rand='+parseInt(Math.random()*999999999999999),'email');
	getContenuto('pop_mail_ad.php?rand='+parseInt(Math.random()*999999999999999),'email');
	//getContenutoFrame('pop_mail_ad.php?rand='+parseInt(Math.random()*999999999999999),'email');
	//setTimeout("autoEmail()",300000);
	setTimeout("autoEmail()",10000);
}

function printDIV(elemento,css){ 
    var a = window.open('','','width='+screen.width+',height='+screen.height+''); 
    a.document.open("text/html"); 
    a.document.write('<html><head><link href="../CSS/'+css+'" rel="stylesheet" type="text/css"></head><body>'); 
    a.document.write(document.getElementById(elemento).innerHTML); 
    a.document.write('</body></html>'); 
    a.document.close(); 
    a.print(); 
}

function iTime(){
	alert('iT:me');
	getContenuto('autoICal.php?rand='+parseInt(Math.random()*999999999999999),'itime');
	setTimeout("iTime()",20000);
}
