// inizializzo le funzioni basilari di AJAX
var myRequest = null;

function CreateXmlHttpReqR(handler) {
  var xmlhttp = null;
  try {
    xmlhttp = new XMLHttpRequest();
  } catch(e) {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  xmlhttp.onreadystatechange = handler;
  return xmlhttp;
}

function myHandlerR() {
    if (myRequest.readyState == 4 && myRequest.status == 200) {
		strRes=myRequest.responseText;
		//alert(strRes);
       arrValori=strRes.split("@");
		document.moduloutenti.provincia.options.length=0;
		//alert(strRes+" "+arrValori.length);
		for(i=0;i<arrValori.length;i++)
		  {
		  	oProv=arrValori[i].split("--")
			//alert(unescape(oProv[1])+" | "+oProv[0]);
			//document.moduloutenti.provincia.options[document.moduloutenti.provincia.options.length]= new Option(unescape(oProv[1]),oProv[0]);
			document.moduloutenti.provincia.options[i]= new Option(unescape(oProv[1]),oProv[0]);
			//alert(document.moduloutenti.provincia.options[i].value);
			//document.moduloutenti.cap.value= oProv[2];
			//document.moduloutenti.provincia.options[document.moduloutenti.provincia.options.length]= new Option(arrValori[i].split("@"));  
		  }
    }
}

function  cercaR(){
	var regione = document.moduloutenti.regione.options[document.moduloutenti.regione.selectedIndex].value;
	myRequest = CreateXmlHttpReqR(myHandlerR);
	//alert("zone.php?regione="+escape(regione));
    //myRequest.open("GET","zone.php?regione="+escape(regione),false);
    myRequest.open("GET","zone.php?regione="+escape(regione));
	myRequest.send(null);
    
}