
	var changeComune = function(id, force, ext){
		dojo.xhrPost({
			url: "/requests/comuni.php",
			handleAs: "xml",
			postData: "p=" + id,
			handle: function(data,args){
				if(typeof data == "error"){
					console.warn("error!");
					console.log(args);
				}else{
					if (typeof ext == 'undefined'){
						ext = "";
					}
					if (typeof force == 'undefined'){
						force = '1';
					}
					explodeComuni(data, force, ext);
				}
			}
		});
	};
	
	var explodeComuni = function (data, force, ext) {
		var collection = data.documentElement.getElementsByTagName("rs");
		var countComuni = collection.length;
		if(countComuni) {
			var oSelC = document.getElementById('divComune'+ext);
			if(oSelC) {
				if ( force == '0') {
					strOption = '<option value="">Tutti</option>';
				}else {
					strOption = '';
				}
				for (var i = 0; i < countComuni; i++) {
					strOption += '<option value="' + collection[i].getAttribute("id") + '">' + collection[i].getAttribute("nome") + '</option>';
				}
				oSelC.innerHTML = '<select id="comune'+ext+'" name="comune" class="selectForm">' + strOption + '</select>';
			}
		}
	}

