function GetInnerText(node){
	return (node.textContent || node.innerText || node.text) ;
}

function getComuni(Container, ID){
	var ddl = $(Container);
	new Ajax.Request('/ajax.php?T' + Math.random(), 
		{
		method      : "post",
		parameters  : {action: 'Comuni', IDProvincia: ID},
		onLoading   : function(rq){ddl.options.length=0;ddl.options[ddl.length]=new Option('...caricamento...','',false,false);},
		onFailure   : function(rq){ddl.options.length=0;ddl.options[ddl.length]=new Option('--','',false,false);alert('Errore ' + rq.status + ' -- ' + rq.statusText);},
		onSuccess   : function(rq){
						ddl.options.length=0;
						ddl.options[ddl.options.length]=new Option("--", "",  false, false);
						var XMLDoc    = rq.responseXML.documentElement;
						var XMLResult = XMLDoc.getElementsByTagName('result');
						for (var i=0; i<XMLResult.length; i++){ddl.options[ddl.length]=new Option(GetInnerText(XMLResult[i]), XMLResult[i].getAttribute("id"),  false, false);}
					}
		}
	);
}

function getZone(Container, ID){
	var ddl = $(Container);
	new Ajax.Request('/ajax.php?T' + Math.random(), 
		{
		method      : "post",
		parameters  : {action: 'Zone', IDComune: ID},
		onLoading   : function(rq){ddl.options.length=0;ddl.options[ddl.length]=new Option('...caricamento...','',false,false);},
		onFailure   : function(rq){ddl.options.length=0;ddl.options[ddl.length]=new Option('--','',false,false);alert('Errore ' + rq.status + ' -- ' + rq.statusText);},
		onSuccess   : function(rq){
						ddl.options.length=0;
						ddl.options[ddl.options.length]=new Option("--", "",  false, false);
						var XMLDoc    = rq.responseXML.documentElement;
						var XMLResult = XMLDoc.getElementsByTagName('result');
						for (var i=0; i<XMLResult.length; i++){ddl.options[ddl.length]=new Option(GetInnerText(XMLResult[i]), XMLResult[i].getAttribute("id"),  false, false);}
					}
		}
	);
}

