// JavaScript Document
// funzione per assegnare l'oggetto XMLHttpRequest
// compatibile con i browsers pių recenti e diffusi
function assegnaXMLHttpRequest() {

// lista delle variabili locali
var XHR = null;
 // variabile di ritorno, nulla di default
 
 
 // informazioni sul nome del browser
 browserUtente = navigator.userAgent.toUpperCase();


	 // browser standard con supporto nativo
	 // non importa il tipo di browser
	 if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
	  XHR = new XMLHttpRequest();
	
	 // browser Internet Explorer
	 // č necessario filtrare la versione 4
	 else if(window.ActiveXObject && browserUtente.indexOf("MSIE 4") < 0) 
	 {
		  // la versione 6 di IE ha un nome differente
		  // per il tipo di oggetto ActiveX
		  if(browserUtente.indexOf("MSIE 5") < 0)
			XHR = new ActiveXObject("Msxml2.XMLHTTP");
		  // le versioni 5 e 5.5 invece sfruttano lo stesso nome
		  else
			XHR = new ActiveXObject("Microsoft.XMLHTTP");
	 }

 return XHR;
}


function attivita_ajax(id){
	var valore = id.value-1;
	var x=document.getElementsByName("attivita");
	txt=""
	for (i=0;i<x.length;++ i)
	{
		if (x[i].checked)
		{
			txt=txt + x[i].value + "-"
		}
	}
	//alert(txt);
	
	var ajax = assegnaXMLHttpRequest();
	ajax.onreadystatechange = function() {
		e = document.getElementById("ajax_content");
		  if(ajax.readyState === 4) {
				if(ajax.status == 200){
					e.innerHTML = ajax.responseText;
				}else{
					alert("Operazione fallita, errore numero " + ajax.status);
				}
			}
			else if(ajax.readyState === 3) {
					e.innerHTML = "<div align='center'>Carico i dati <br><img src='./immagini/icons/loading.gif' /></div>";	
			}
	}
	ajax.open("GET","scripts/orari_s.php?att="+txt,true); //open( metodo, URL, async )
	ajax.setRequestHeader("connection", "close");
	ajax.send(null);		
}

