var tipologiaURI	= 'xml_tipologie.php';	var resultTipologia	= 'slct_tipologia';
var comuniURI		= 'xml_comuni.php';		var resultComuni		= 'slct_comune';
var countURI		= 'xml_count.php';		var resultCount		= 'risultato_ricerca';

// se !IE inizializiamo il servizio
if (window.XMLHttpRequest) {
	tipologieObj = new XMLHttpRequest();
	comuniObj = new XMLHttpRequest();
	countObj = new XMLHttpRequest();
}

/* AGGIORNAMENTI TIPOLOGIE */
function elencoTipologie(aggiorna) {
	if (window.XMLHttpRequest) { /* ovviamente IE si comporta diversamente... */ } else if (window.ActiveXObject) { tipologieObj = new ActiveXObject("Microsoft.XMLHTTP"); }
	if (tipologieObj && tipologieObj.readyState < 4) { tipologieObj.abort(); }
	tipologieObj.onreadystatechange = elencoTipologieChange;
	tipologieObj.open("GET", tipologiaURI + "?uso=" + document.frmricerca.uso.options[document.frmricerca.uso.selectedIndex].value, 1);
	tipologieObj.send(null);
	if (aggiorna == 1) { aggiornaConteggio(); }
}
function elencoTipologieChange() {
	if (tipologieObj.readyState == 4) { document.getElementById(resultTipologia).innerHTML = tipologieObj.responseText; }
}

/* AGGIORNAMENTI COMUNI */
function elencoComuni(aggiorna) {
	if (window.XMLHttpRequest) { /* ovviamente IE si comporta diversamente... */ } else if (window.ActiveXObject) { comuniObj = new ActiveXObject("Microsoft.XMLHTTP"); }
	if (comuniObj && comuniObj.readyState < 4) { comuniObj.abort(); }
	comuniObj.onreadystatechange = elencoComuniChange;
	comuniObj.open("GET", comuniURI + "?prov=" + document.frmricerca.provincia.options[document.frmricerca.provincia.selectedIndex].label + "&aggiorna=" + aggiorna, 1);
	comuniObj.send(null);
	if (aggiorna == 1) { aggiornaConteggio(); }
}
function elencoComuniChange() {
	if (comuniObj.readyState == 4) { document.getElementById(resultComuni).innerHTML = comuniObj.responseText; }
}

/* AGGIORNAMENTO DEL NUMERO DI RISULTATI */
function aggiornaConteggio() {
	if (window.XMLHttpRequest) { /* ovviamente IE si comporta diversamente... */ } else if (window.ActiveXObject) { countObj = new ActiveXObject("Microsoft.XMLHTTP"); }
	if (countURI && countURI.readyState < 4) { countURI.abort(); }
	countObj.onreadystatechange = aggiornaConteggioChange;
	countObj.open("GET", countURI
	+ "?uso=" + document.frmricerca.uso.options[document.frmricerca.uso.selectedIndex].value
	+ "&tipologia=" + document.frmricerca.tipologia.options[document.frmricerca.tipologia.selectedIndex].value
	+ "&prov=" + document.frmricerca.provincia.options[document.frmricerca.provincia.selectedIndex].value
	+ "&comune=" + document.frmricerca.comune.options[document.frmricerca.comune.selectedIndex].value
	+ "&p_minimo=" + document.frmricerca.p_minimo.options[document.frmricerca.p_minimo.selectedIndex].value
	+ "&p_massimo=" + document.frmricerca.p_massimo.options[document.frmricerca.p_massimo.selectedIndex].value
	+ "&tipologia=" + document.frmricerca.tipologia.options[document.frmricerca.tipologia.selectedIndex].value
	+ "&pagina=" + document.frmricerca.pagina.value
	, 1);
	countObj.send(null);
}
function aggiornaConteggioChange() {
	if (countObj.readyState == 4) { document.getElementById(resultCount).innerHTML = countObj.responseText; }
}

function mostraFoto(link, windowWidth, windowHeight) {
	var windowWidth = windowWidth + 18;
	var windowHeight = windowHeight + 18;

	if (screen.availWidth > windowWidth) {
		var aw = screen.availWidth;
		var ah = screen.availHeight;
	} else {
		var aw = (screen.availWidth - windowWidth ) / 2;
		var ah = (screen.availHeight - windowHeight) / 2;
	}

	var winAttr = "width=" + windowWidth + ",height=" + windowHeight + ",left=" + aw + ",top=" + ah + "scrollbars=0,status=0,resizable=0";

	newWindow=window.open(link, "Anteprima", winAttr);
}
