

function apri(section) 
{
	location.href="#top"
	if (controllo(section)) 
	{
		chiuditabella(section);
	}	
	else
	{
		apritabella(section);	
	}
}

function apritabella(section)
{
	var tbody = document.getElementById(section);
	if (tbody == null) return;
	tbody.style.display = "";

}

function chiuditabella(section)
{
	var tbody = document.getElementById(section);
	if (tbody == null) return;
	tbody.style.display = "none";
}

function controllo(section)
{
	var tbody = document.getElementById(section);
	if (tbody == null) return 0;
	return (tbody.style.display == "");
}



function cerca() {

var browser_str = window.navigator.userAgent.toUpperCase();
var browser = (browser_str.indexOf("MSIE")!=-1)


	if (browser==true) {
		comune=document.ricerca.comune.value;
	}
	else{
		comune=document.forms[1].comune.value
	}
	categoria=document.ricerca.categoria.value;
	provincia=document.ricerca.provincia.value;
	
	if ((categoria!="") && (provincia=="")){
		alert("Selezionare una Provincia!")
	}
	
	if ((categoria!="") && (provincia!="") && (comune=="")){
		location.href="bk-ric-"+categoria+"-provincia-"+provincia+".html"
	}	
	if ((categoria!="") && (provincia!="") && (comune!="")){
		location.href="bk-ric-"+categoria+"-"+comune+".html"
	}
	if ((categoria=="") && (provincia!="") && (comune=="")){
		location.href="bk-ric-provincia-"+provincia+".html"
	}	
	if ((categoria=="") && (provincia!="") && (comune!="")){
		location.href="bk-ric-"+comune+".html"
	}
	
}

/* parte dedicata al codice AJAX PER UN CARICAMENTO NORMALE*/

function Richiesta(pagina,responsediv){

 
	 url  = pagina +"&rand="+escape(Math.random())
	 var xmlHttpReq = false;
    var self = this;
    // Xhr per Mozilla/Safari/Ie7
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // per tutte le altre versioni di IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
			// Quando pronta, visualizzo la risposta del form
            updatepage1(self.xmlHttpReq.responseText,responsediv);
        }
		else{
			// In attesa della risposta del form visualizzo il msg di attesa
			updatepage1('<img src="../images/preload4.gif">',responsediv);

		}
    }
     self.xmlHttpReq.open('GET', url, true);
    self.xmlHttpReq.send(null);
}

function Richiesta1(pagina,responsediv){


 
		 url  = pagina +"&rand="+escape(Math.random())
		 var xmlHttpReq1 = false;
	    var self = this;
	    // Xhr per Mozilla/Safari/Ie7
	    if (window.XMLHttpRequest) {
	        self.xmlHttpReq1 = new XMLHttpRequest();
	    }
	    // per tutte le altre versioni di IE
	    else if (window.ActiveXObject) {
	        self.xmlHttpReq1 = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    self.xmlHttpReq1.onreadystatechange = function() {
	        if (self.xmlHttpReq1.readyState == 4) {
				// Quando pronta, visualizzo la risposta del form
	            updatepage1(self.xmlHttpReq1.responseText,responsediv);
	        }
			else{
				// In attesa della risposta del form visualizzo il msg di attesa
				updatepage1('<img src="../images/preload4.gif">',responsediv);
	
			}
	    }
	     self.xmlHttpReq1.open('GET', url, true);
	    self.xmlHttpReq1.send(null);
	    

}

function Richiesta2(pagina,responsediv){


 
		 url  = pagina +"&rand="+escape(Math.random())
		 var xmlHttpReq2 = false;
	    var self = this;
	    // Xhr per Mozilla/Safari/Ie7
	    if (window.XMLHttpRequest) {
	        self.xmlHttpReq2 = new XMLHttpRequest();
	    }
	    // per tutte le altre versioni di IE
	    else if (window.ActiveXObject) {
	        self.xmlHttpReq2 = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    self.xmlHttpReq2.onreadystatechange = function() {
	        if (self.xmlHttpReq2.readyState == 4) {
				// Quando pronta, visualizzo la risposta del form
	            updatepage1(self.xmlHttpReq2.responseText,responsediv);
	        }
			else{
				// In attesa della risposta del form visualizzo il msg di attesa
				updatepage1('<img src="../images/preload4.gif">',responsediv);
	
			}
	    }
	     self.xmlHttpReq2.open('GET', url, true);
	    self.xmlHttpReq2.send(null);
	    

}

function Richiesta3(pagina,responsediv){

 
	 url  = pagina +"&rand="+escape(Math.random())
	 var xmlHttpReq3 = false;
    var self = this;
    // Xhr per Mozilla/Safari/Ie7
    if (window.XMLHttpRequest) {
        self.xmlHttpReq3 = new XMLHttpRequest();
    }
    // per tutte le altre versioni di IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq3 = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq3.onreadystatechange = function() {
        if (self.xmlHttpReq3.readyState == 4) {
			// Quando pronta, visualizzo la risposta del form
            updatepage1(self.xmlHttpReq3.responseText,responsediv);
        }
		else{
			// In attesa della risposta del form visualizzo il msg di attesa
			updatepage1('<img src="../images/preload4.gif">',responsediv);

		}
    }
     self.xmlHttpReq3.open('GET', url, true);
    self.xmlHttpReq3.send(null);
}



function updatepage1(str,responsediv){
    document.getElementById(responsediv).innerHTML = str;
}
/* FINE parte dedicata al codice AJAX PER UN CARICAMENTO NORMALE*/
