var OutReg=''
var OutProv='';
var OutCity='';
var OutTipologia=''
var Gwhere='<?php echo $gaz_where;?>';

//********PROV****************
function getAvailableProv(reg) {
	
	OutProv='';
	OutReg=reg;
	
	var gURL = 'listprov.php?Prov='+OutProv+'&Reg='+OutReg+'&pagetype='+Gwhere;

	
	//create the Cross-browser XMLHttpRequest object
	if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
		xmlhttp=new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) {
			xmlhttp.overrideMimeType('text/xml');
		}	
		xmlhttp.onreadystatechange=loadProv;
		xmlhttp.open("GET", gURL, true);
		xmlhttp.send(null);
	} else if (window.ActiveXObject) { //IE 
		xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
		if (xmlhttp) {
			xmlhttp.onreadystatechange=loadProv;
			xmlhttp.open('GET', gURL, false);
			xmlhttp.send();
		}
	}
	
	OutCity='';
	OutTipologia='';
	
	
	//getAvailableCity("");
}

// function to handle asynchronus call
function loadProv() {
	if (xmlhttp.readyState==4) { 
		if (xmlhttp.status==200) { 
			document.getElementById('provlsp').innerHTML=xmlhttp.responseText;
			document.getElementById('citylsp').innerHTML='<select name="City" id="City" size="1" style="width:150px" ><option  value="">Tutti...</option>';
			document.getElementById('tipelsp').innerHTML='<select name="marca" id="tipologia" size="1" style="width:150px" ><option  value="">Tutti...</option>';
		}
	}
}
//*******Comune*********
function getAvailableCity(prov) {
	OutCity='';
	OutProv=prov;
	var Gwhere='<?php echo $gaz_where;?>';
	
	var gURL = 'listcity.php?Prov='+OutProv+'&city='+OutCity+'&pagetype='+Gwhere;

	//create the Cross-browser XMLHttpRequest object
	if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
		xmlhttp=new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) {
			xmlhttp.overrideMimeType('text/xml');
		}	
		xmlhttp.onreadystatechange=loadCity;
		xmlhttp.open("GET", gURL, true);
		xmlhttp.send(null);
	} else if (window.ActiveXObject) { //IE 
		xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
		if (xmlhttp) {
			xmlhttp.onreadystatechange=loadCity;
			xmlhttp.open('GET', gURL, false);
			xmlhttp.send();
		}
	}
	OutTipologia='';


	//getAvailableTipologia('');

}

// function to handle asynchronus call
function loadCity() {
	if (xmlhttp.readyState==4) { 
		if (xmlhttp.status==200) { 
	        
			document.getElementById('citylsp').innerHTML=xmlhttp.responseText;
			document.getElementById('tipelsp').innerHTML='<select name="marca" id="tipologia" size="1" style="width:150px" ><option value="">Tutti...</option>';
		}
	}
}
//**********Tipologia*********

function getAvailableTipologia(city) {
	OutTipologia='';
	OutCity=city;
	var Gwhere='<?php echo $gaz_where;?>';
	
	var gURL = 'listype.php?City='+OutCity+'&tipologia='+OutTipologia+'&pagetype='+Gwhere;


	//create the Cross-browser XMLHttpRequest object city='+OutCity+'&tipologia='+OutTipologia+'&pagetype='+Gwhere;

	if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
		xmlhttp=new XMLHttpRequest();
		if (xmlhttp.overrideMimeType) {
			xmlhttp.overrideMimeType('text/xml');
		}	
		xmlhttp.onreadystatechange=loadTipologia;
		xmlhttp.open("GET", gURL, true);
		xmlhttp.send(null);
	} else if (window.ActiveXObject) { //IE 
		xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
		if (xmlhttp) {
			xmlhttp.onreadystatechange=loadTipologia;
			xmlhttp.open('GET', gURL, false);
			xmlhttp.send();
		}
	}
	
}

// function to handle asynchronus call
function loadTipologia() {
	if (xmlhttp.readyState==4) { 
		if (xmlhttp.status==200) { 
			document.getElementById('tipelsp').innerHTML=xmlhttp.responseText;
			if (xmlhttp.responseText.indexOf('disabled')<=0) {
				//document.getElementById('city').focus();
			}	
		}
	}
}

// function to handle asynchronus call
function loadTree() {
	if (xmlhttp.readyState==4) { 
		if (xmlhttp.status==200) { 
			document.getElementById('tree').innerHTML=xmlhttp.responseText;
		}
	}
}

