function SelComuni(valore){


AlertOpen("Attendere prego....",4);

	if(document.getElementById('zona_filtro')){
	document.getElementById('zona_filtro').value = "";
	}
if(document.getElementById('form_zone_cont')){
	layer = document.getElementById("form_zone_cont")
	layer.innerHTML = "";
}

	if (window.XMLHttpRequest) {
		ricercaxx = new XMLHttpRequest();
		ricercaxx.onreadystatechange = SelComuni1;
		ricercaxx.open("GET", "ax_comune.php?valore=" + valore  + "&rand=" + Math.random() ,true);
		ricercaxx.send(null);
	} else if (window.ActiveXObject) {
		ricercaxx = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricercaxx) {
		ricercaxx.onreadystatechange = SelComuni1;
		ricercaxx.open("GET", "ax_comune.php.php?valore=" + valore  + "&rand=" + Math.random() ,true);
		ricercaxx.send(null);
	}
	}
}

function SelComuni1(){
	var strRes; 
		if (ricercaxx.readyState == 4 && ricercaxx.status == 200) { 
		strRes=ricercaxx.responseText;
		strRes = strRes.replace(/1/g,"à");
		strRes = strRes.replace(/2/g,"è");
		strRes = strRes.replace(/3/g,"ì");
		strRes = strRes.replace(/4/g,"ò");
		strRes = strRes.replace(/5/g,"ù");

		tendina1 = document.getElementById("zona")
		if(tendina1){
		var i
		for(i=tendina1.length-1;i>=0;i--){
		tendina1.remove(i);	
		}

		var optn = document.createElement("OPTION");
		optn.text = "Scegli il quartiere"
 	  	optn.value = "%"
 		tendina1.options.add(optn);
		}




		tendina = document.getElementById("Comune")
		var i
		for(i=tendina.length-1;i>=0;i--){
		tendina.remove(i);	
		}


		var optn = document.createElement("OPTION");
		optn.text = "Scegli il comune"
 	  	optn.value = "%"
 		tendina.options.add(optn);

		var comuni=strRes.split(",");
		var inizio=0;
		while (inizio < comuni.length)
 		{
 var optn = document.createElement("OPTION");
 optn.text = comuni[inizio]
 optn.value = comuni[inizio]
 tendina.options.add(optn);
 
 
 
  inizio+=1;
  }
 $("#Comune").sb("refresh");
if(tendina1){
 $("#zona").sb("refresh");
}
	AlertClose();
}

}


function SelCategoria(valore){

AlertOpen("Attendere prego....",4);

	if (window.XMLHttpRequest) {
		ricercaxx = new XMLHttpRequest();
		ricercaxx.onreadystatechange = SelCategoria1;
		ricercaxx.open("GET", "ax_categoria.php?valore=" + valore  + "&rand=" + Math.random() ,true);
		ricercaxx.send(null);
	} else if (window.ActiveXObject) {
		ricercaxx = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricercaxx) {
		ricercaxx.onreadystatechange = SelCategoria1;
		ricercaxx.open("GET", "ax_categoria.php.php?valore=" + valore  + "&rand=" + Math.random() ,true);
		ricercaxx.send(null);
	}
	}
}

function SelCategoria1(){

	var strRes; 
		if (ricercaxx.readyState == 4 && ricercaxx.status == 200) { 
		strRes=ricercaxx.responseText;


		strRes = strRes.replace(/1/g,"à");
		strRes = strRes.replace(/2/g,"è");
		strRes = strRes.replace(/3/g,"ì");
		strRes = strRes.replace(/4/g,"ò");
		strRes = strRes.replace(/5/g,"ù");
		tendina = document.getElementById("tipologia")
		var i
		for(i=tendina.length-1;i>=0;i--){
		tendina.remove(i);	
		}


		var optn = document.createElement("OPTION");
		optn.text = "Scegli la tipologia"
 	  	optn.value = "%"
 		tendina.options.add(optn);

		var tipologie=strRes.split(",");
		var inizio=0;
		while (inizio < tipologie.length)
 		{
 var optn = document.createElement("OPTION");
 optn.text = tipologie[inizio]
 optn.value = tipologie[inizio]
 tendina.options.add(optn);
 
 
 
  inizio+=1;
  }
 $("#tipologia").sb("refresh");
	AlertClose();
}
	
}


function SelZone(valore){
AlertOpen("Attendere prego....",4);

	if (window.XMLHttpRequest) {
		ricercaxx = new XMLHttpRequest();
		ricercaxx.onreadystatechange = SelZone1;
		ricercaxx.open("GET", "ax_zona.php?valore=" + valore  + "&rand=" + Math.random() ,true);
		ricercaxx.send(null);
	} else if (window.ActiveXObject) {
		ricercaxx = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricercaxx) {
		ricercaxx.onreadystatechange = SelZone1;
		ricercaxx.open("GET", "ax_zona.php.php?valore=" + valore  + "&rand=" + Math.random() ,true);
		ricercaxx.send(null);
	}
	}
}

function SelZone1(){
	var strRes; 
		if (ricercaxx.readyState == 4 && ricercaxx.status == 200) { 
		strRes=ricercaxx.responseText;
		strRes = strRes.replace(/1/g,"à");
		strRes = strRes.replace(/2/g,"è");
		strRes = strRes.replace(/3/g,"ì");
		strRes = strRes.replace(/4/g,"ò");
		strRes = strRes.replace(/5/g,"ù");
		tendina = document.getElementById("zona")
		var i
		for(i=tendina.length-1;i>=0;i--){
		tendina.remove(i);	
		}


		var optn = document.createElement("OPTION");
		optn.text = "Scegli il quartiere"
 	  	optn.value = "%"
 		tendina.options.add(optn);

		var zona=strRes.split(",");
		var inizio=0;
		while (inizio < zona.length)
 		{
 var optn = document.createElement("OPTION");
 optn.text = zona[inizio]
 optn.value = zona[inizio]
 tendina.options.add(optn);
 
 
 
  inizio+=1;
  }
 $("#zona").sb("refresh");
	AlertClose();
}
	
}

