
var dove;
var caricaDove;
var ricerca_pro;// = getHTTPObject();

//FUNZIONE PER RICHIEDERE LE INFO
function cerca()
{
var valorecampo = document.registra.x_IdNazione.options[document.registra.x_IdNazione.selectedIndex].value;
//alert(valorecampo)

// per l'oggetto nativo XMLHttpRequest
if (window.XMLHttpRequest) {
	ricerca_pro = new XMLHttpRequest();
	ricerca_pro.onreadystatechange = ricevi;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=0",true);
	ricerca_pro.send(null);
	} else if (window.ActiveXObject) {
	ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricerca_pro) {
	ricerca_pro.onreadystatechange = ricevi;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=0",true);
	ricerca_pro.send(null);
				}
	}
}


//FUNZIONE PER RICEVERE LE INFO
function ricevi() {
var arrValori;
if (ricerca_pro.readyState == 4) {
arrValori=ricerca_pro.responseText.split('---');
document.registra.x_IdRegione.options.length=0;
for(i=0;i<arrValori.length;i++)
	{
	var option = new Option();
	option.value = arrValori[i].split("---");
	i++;
	option.text = arrValori[i].split("---");
	document.registra.x_IdRegione.options[document.registra.x_IdRegione.options.length] = option;
	}
}
}


function cerca1()
{
var valorecampo = escape(document.registra.x_IdRegione.options[document.registra.x_IdRegione.selectedIndex].value);
//alert(valorecampo)
// per l'oggetto nativo XMLHttpRequest
if (window.XMLHttpRequest) {
	ricerca_pro = new XMLHttpRequest();
	ricerca_pro.onreadystatechange = ricevi1;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=1",true);
	ricerca_pro.send(null);
	} else if (window.ActiveXObject) {
	ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricerca_pro) {
	ricerca_pro.onreadystatechange = ricevi1;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=1",true);
	ricerca_pro.send(null);
	ricerca_pro.send(null);
				}
	}



}


//FUNZIONE PER RICEVERE LE INFO
function ricevi1() {
var arrValori;
if (ricerca_pro.readyState == 4) {
arrValori=ricerca_pro.responseText.split('---');
document.registra.x_IdProvincia.options.length=0;
for(i=0;i<arrValori.length;i++)
{

	var option = new Option();
	option.value = arrValori[i].split("---");
	i++;
	option.text = arrValori[i].split("---");
	document.registra.x_IdProvincia.options[document.registra.x_IdProvincia.options.length] = option;
//document.registra.x_IdProvincia.options[document.registra.x_IdProvincia.options.length]= new Option(arrValori[i].split("---"));
}
}
}


function cerca2()
{
var valorecampo = document.registra.x_IdProvincia.options[document.registra.x_IdProvincia.selectedIndex].value;
// per l'oggetto nativo XMLHttpRequest
if (window.XMLHttpRequest) {
	ricerca_pro = new XMLHttpRequest();
	ricerca_pro.onreadystatechange = ricevi2;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=2",true);
	ricerca_pro.send(null);
	} else if (window.ActiveXObject) {
	ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricerca_pro) {
	ricerca_pro.onreadystatechange = ricevi2;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=2",true);
	ricerca_pro.send(null);
	ricerca_pro.send(null);
				}
	}



}


//FUNZIONE PER RICEVERE LE INFO
function ricevi2() {
var arrValori;
if (ricerca_pro.readyState == 4) {
arrValori=ricerca_pro.responseText.split('---');
//alert(arrValori);
document.registra.x_IdComune.options.length=0;
for(i=0;i<arrValori.length;i++)
{

	

	var option = new Option();
	option.value = arrValori[i].split("---");
	i++;
	option.text = arrValori[i].split("---");
	document.registra.x_IdComune.options[document.registra.x_IdComune.options.length] = option;
//document.registra.x_IdProvincia.options[document.registra.x_IdProvincia.options.length]= new Option(arrValori[i].split("---"));

//document.registra.x_IdProvincia.options[document.registra.x_IdProvincia.options.length]= new Option(arrValori[i].split("---"));
}
}
}


function cercaU()
{
var valorecampo = document.registra.x_IdNazione1.options[document.registra.x_IdNazione1.selectedIndex].value;
//alert(valorecampo)

// per l'oggetto nativo XMLHttpRequest
if (window.XMLHttpRequest) {
	ricerca_pro = new XMLHttpRequest();
	ricerca_pro.onreadystatechange = riceviU;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=0",true);
	ricerca_pro.send(null);
	} else if (window.ActiveXObject) {
	ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricerca_pro) {
	ricerca_pro.onreadystatechange = riceviU;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=0",true);
	ricerca_pro.send(null);
				}
	}
}


//FUNZIONE PER RICEVERE LE INFO
function riceviU() {
var arrValori;
if (ricerca_pro.readyState == 4) {
arrValori=ricerca_pro.responseText.split('---');
document.registra.x_IdRegione1.options.length=0;
for(i=0;i<arrValori.length;i++)
	{
	var option = new Option();
	option.value = arrValori[i].split("---");
	i++;
	option.text = arrValori[i].split("---");
	document.registra.x_IdRegione1.options[document.registra.x_IdRegione1.options.length] = option;
	}
}
}


function cercaU1()
{
var valorecampo = document.registra.x_IdRegione1.options[document.registra.x_IdRegione1.selectedIndex].value;
//alert(valorecampo)
// per l'oggetto nativo XMLHttpRequest
if (window.XMLHttpRequest) {
	ricerca_pro = new XMLHttpRequest();
	ricerca_pro.onreadystatechange = riceviU1;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=1",true);
	ricerca_pro.send(null);
	} else if (window.ActiveXObject) {
	ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricerca_pro) {
	ricerca_pro.onreadystatechange = riceviU1;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=1",true);
	ricerca_pro.send(null);
				}
	}



}


//FUNZIONE PER RICEVERE LE INFO
function riceviU1() {
var arrValori;
if (ricerca_pro.readyState == 4) {
arrValori=ricerca_pro.responseText.split('---');
document.registra.x_IdProvincia1.options.length=0;
for(i=0;i<arrValori.length;i++)
{

	var option = new Option();
	option.value = arrValori[i].split("---");
	i++;
	option.text = arrValori[i].split("---");
	document.registra.x_IdProvincia1.options[document.registra.x_IdProvincia1.options.length] = option;
//document.registra.x_IdProvincia1.options[document.registra.x_IdProvincia1.options.length]= new Option(arrValori[i].split("---"));
}
}
}


function cercaU2()
{
var valorecampo = document.registra.x_IdProvincia1.options[document.registra.x_IdProvincia1.selectedIndex].value;
//alert(valorecampo)
// per l'oggetto nativo XMLHttpRequest
if (window.XMLHttpRequest) {
	ricerca_pro = new XMLHttpRequest();
	ricerca_pro.onreadystatechange = riceviU2;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=2",true);
	ricerca_pro.send(null);
	} else if (window.ActiveXObject) {
	ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricerca_pro) {
	ricerca_pro.onreadystatechange = riceviU2;
	ricerca_pro.open("GET", "province.asp?reg="+valorecampo+"&campo=2",true);
	ricerca_pro.send(null);
				}
	}



}


//FUNZIONE PER RICEVERE LE INFO
function riceviU2() {
var arrValori;
if (ricerca_pro.readyState == 4) {
arrValori=ricerca_pro.responseText.split('---');
document.registra.x_IdComune1.options.length=0;
for(i=0;i<arrValori.length;i++)
{
	

	var option = new Option();
	option.value = arrValori[i].split("---");
	i++;
	option.text = arrValori[i].split("---");
	document.registra.x_IdComune1.options[document.registra.x_IdComune1.options.length] = option;
//document.registra.x_IdProvincia1.options[document.registra.x_IdProvincia1.options.length]= new Option(arrValori[i].split("---"));

//document.registra.x_IdProvincia1.options[document.registra.x_IdProvincia1.options.length]= new Option(arrValori[i].split("---"));
}
}
}
function cercaRisultati(id,i){
	dove=document.getElementById(id)
	var laform=document.forms[i];
	var passa="";
	for (i=0;i< laform.length; i++)
	{	
		if (passa=="")
		{
			passa= laform[i].name + "=" + laform[i].value;
		}
		else
		{
			passa=passa+"&"+laform[i].name + "=" + laform[i].value;
		}
	}
	//alert(passa)
	if (window.XMLHttpRequest) {
		ricerca_pro = new XMLHttpRequest();
		ricerca_pro.onreadystatechange = riceviRisultati;
		ricerca_pro.open("GET", "ricercaAnnunci.asp?"+passa,true);
		ricerca_pro.send(null);
		} else if (window.ActiveXObject) {
		ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
		if (ricerca_pro) {
		ricerca_pro.onreadystatechange = riceviRisultati;
		ricerca_pro.open("GET", "ricercaAnnunci.asp?"+passa,true);
		ricerca_pro.send(null);
					}
	}



}
function cercaRisultati2(id,i){
	dove=document.getElementById(id)
	var laform=document.forms[i];
	var passa="";
	for (i=0;i<laform.length; i++)
	{	
		if (passa=="")
		{
			passa=laform[i].name + "=" +laform[i].value;
		}
		else
		{
			passa=passa+"&"+laform[i].name + "=" +laform[i].value;
		}
	}

	if (window.XMLHttpRequest) {
		ricerca_pro = new XMLHttpRequest();
		ricerca_pro.onreadystatechange = riceviRisultati;
		ricerca_pro.open("GET", "ricerca.asp?ricerca=true&"+passa,true);
		ricerca_pro.send(null);
		} else if (window.ActiveXObject) {
		ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
		if (ricerca_pro) {
		ricerca_pro.onreadystatechange = riceviRisultati;
		ricerca_pro.open("GET", "ricerca.asp?ricerca=true&"+passa,true);
		ricerca_pro.send(null);
					}
	}



}


//FUNZIONE PER RICEVERE LE INFO
function riceviRisultati() {
	var arrValori;
	if (ricerca_pro.readyState == 4 && ricerca_pro.status==200) {
		arrValori=ricerca_pro.responseText
		dove.innerHTML=arrValori;
		
		caricaPagine();

		}
}


function giorni() {
	var igiorni=document.getElementsByName("Giorno");
	var stringa="";
		for (i=0;i<igiorni.length ;i++ )
			{
			//	alert(giorni[i].value)
				if (igiorni[i].checked)
				{
					if (stringa=="")
					{
						stringa=igiorni[i].value;
					}
					else
					{
						stringa=stringa+", "+igiorni[i].value;
					}
				}
			}
			Ricerca.giorniPendolari.value=stringa;
}


function caricaForm(id,pagina){
	caricaDove=id;
	dove=document.getElementById(id)
	var laform=document.myForm;
	var passa="";
	for (i=0;i<laform.length; i++)
	{	
		if (passa=="")
		{
			passa=laform[i].name + "=" +laform[i].value;
		}
		else
		{
			passa=passa+"&"+laform[i].name + "=" +laform[i].value;
		}
	}

	if (window.XMLHttpRequest) {
		ricerca_pro = new XMLHttpRequest();
		ricerca_pro.onreadystatechange = ricevicaricaForm;
		ricerca_pro.open("GET", pagina+"&"+passa,true);
		ricerca_pro.send(null);
		} else if (window.ActiveXObject) {
		ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
		if (ricerca_pro) {
		ricerca_pro.onreadystatechange = ricevicaricaForm;
		ricerca_pro.open("GET", pagina+"&"+passa,true);
		ricerca_pro.send(null);
					}
	}



}


//FUNZIONE PER RICEVERE LE INFO
function ricevicaricaForm() {
	var arrValori;
	if (ricerca_pro.readyState == 4) {
		arrValori=ricerca_pro.responseText

		if (caricaDove=="messaggio")
		{	

			document.getElementById("sfondoOpaco").style.display="block";
			
			arrValori="<div class='chiudiPopUp'><SPAN style='cursor:pointer;' onclick='closePopUp()'>Chiudi X </SPAN></div>"+arrValori;		
		}
	document.getElementById(caricaDove).innerHTML=arrValori;
	}
}
