function go_to_page(){


tipologia = document.getElementById("tipologia").value;
comune = document.getElementById("Comune").value;

	if (window.XMLHttpRequest) {
		ricercaxx = new XMLHttpRequest();
		ricercaxx.onreadystatechange = go_to_page1;
		ricercaxx.open("GET", "ax_seo_ricerca.php?comune=" + comune + "&tipologia=" + tipologia  + "&rand=" + Math.random() ,true);
		ricercaxx.send(null);
	} else if (window.ActiveXObject) {
		ricercaxx = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricercaxx) {
		ricercaxx.onreadystatechange = go_to_page1;
		ricercaxx.open("GET", "ax_seo_ricerca.php?comune=" + comune + "&tipologia=" + tipologia  + "&rand=" + Math.random() ,true);
		ricercaxx.send(null);
	}
	}


}

function go_to_page1(){


categoria = document.getElementById("categoria").value;
if(categoria=="%"){
categoria="Residenziale";
}
provincia = document.getElementById("provincia").value;
if(document.getElementById("radio1").checked==true){
contratto="Vendita"
}
if(document.getElementById("radio2").checked==true){
contratto="Affitto"
}

	var strRes; 
		if (ricercaxx.readyState == 4 && ricercaxx.status == 200) { 
		strRes=ricercaxx.responseText;

		stringa = strRes.split(";");
		comune = stringa[0];
		tipologia = stringa[1];
		

	
		if(provincia=="%" && comune=="%"){
		stringalink ="Ricerca-" + categoria + "-" + tipologia + "_in_" + contratto + ".html";
		}
		if(provincia!="%" && comune=="%"){
		stringalink ="Ricerca-" + categoria + "-" + tipologia + "_in_" + contratto + "-in-" + provincia + "_e_provincia.html";
		}
		if(provincia!="%" && comune!="%"){
		stringalink ="Ricerca-" + categoria + "-" + tipologia + "_in_" + contratto + "-a-" + comune + ".html";
		}
	



document.forma.action = stringalink;
document.forma.submit();

}
}


function riempi_input(valore){



nomec = document.getElementById(valore).name;
valorec = document.getElementById(valore).value;

if(valorec==""){
document.getElementById(valore).value = nomec;
}

}

function svuota_input(valore){


nomec = document.getElementById(valore).name;
valorec = document.getElementById(valore).value;



if(valorec==nomec){
document.getElementById(valore).value = "";
}

}




var stato;
function slider(valore){

document.getElementById("mappa_dett_immobile_bg").style.display = "none";

//**** slider + gestione loghi new (inline o none --> stato) temporizzata

if(valore==0){
stato = "inline"
$("#slider").animate({marginLeft:valore},300,"linear");
setTimeout(gestione_loghi_new, 300);
}
else
{
stato = "none"
setTimeout(gestione_loghi_new, 1);
$("#slider").animate({marginLeft:valore},300,"linear");
}
}


function gestione_loghi_new(){
for(i=1;i<10;i++){
if(document.getElementById("logo_new_" + i)){
document.getElementById("logo_new_" + i).style.display = stato;
}
}
}




function SelZoneLayer(){

	
	valore = document.getElementById("Comune").value;
	valore = valore.replace("'","$")
	


	if(valore==null || valore==""){

	document.getElementById("sel_zone").style.display = "none";
	layer = document.getElementById("form_zone_cont")
	layer.innerHTML = "";
	document.getElementById('zona_filtro').value = "";
	return;
	}
	else
	{
	document.getElementById("sel_zone").style.display = "inline";
	}



	if (window.XMLHttpRequest) {
		ricercaxx = new XMLHttpRequest();
		ricercaxx.onreadystatechange = SelZoneLayer1;
		ricercaxx.open("GET", "ax_zona.php?valore=" + valore  + "&rand=" + Math.random() ,true);
		ricercaxx.send(null);
	} else if (window.ActiveXObject) {
		ricercaxx = new ActiveXObject("Microsoft.XMLHTTP");
	if (ricercaxx) {
		ricercaxx.onreadystatechange = SelZoneLayer1;
		ricercaxx.open("GET", "ax_zona.php.php?valore=" + valore  + "&rand=" + Math.random() ,true);
		ricercaxx.send(null);
	}
	}
}

function SelZoneLayer1(){
	var strRes; 
		if (ricercaxx.readyState == 4 && ricercaxx.status == 200) { 
		strRes=ricercaxx.responseText;
		strRes = strRes.replace(/1/g,"à");
		strRes = strRes.replace(/2/g,"è");
		strRes = strRes.replace(/3/g,"ì");
		strRes = strRes.replace(/4/g,"ò");
		strRes = strRes.replace(/5/g,"ù");
		layer = document.getElementById("form_zone_cont")
		layer.innerHTML = "";
		document.getElementById('zona_filtro').value = "";



		var zona=strRes.split(",");
		var inizio=0;
		var conta = 1;
		while (inizio < zona.length)
 		{


 layer.innerHTML = layer.innerHTML + "<div class='r_zona'><input name='' type='checkbox' id='ck" + conta + "' value=" + zona[inizio] + "  onclick=\"Add_zona('"  +  zona[inizio] +  "','ck" + conta + "') \"/> <span>" + zona[inizio] + "</span></div>";

 	 inizio+=1;
	conta+=1;
  }

}
	
}

function ShowZoneLayer(){

	document.getElementById("form_zone").style.display = "inline";
	
	
}


function HiddenZoneLayer(){


	document.getElementById("form_zone").style.display = "none";

	
}

function Add_zona(valore,id){



stringa_zone = document.getElementById('zona_filtro').value;
if(document.getElementById(id).checked==true){
stringa_zone = stringa_zone +  valore.replace("$","'") + "--"

}
else
{
stringa_zone = stringa_zone.replace(  valore.replace("$","'")  + "--","");
}
document.getElementById('zona_filtro').value = stringa_zone;


}


function showDettaglioMappa(valore){

valori_dettaglio = valore.split("$$");

document.getElementById("md_immagine").src = valori_dettaglio[4];
document.getElementById("md_contratto").innerText = valori_dettaglio[1];
document.getElementById("md_superficie").innerText = valori_dettaglio[2] + " mq";
document.getElementById("md_locali").innerText = valori_dettaglio[3] + " locali";
document.getElementById("md_dettaglio").innerHTML = "<strong>" + valori_dettaglio[5] + "</strong>";
document.getElementById("md_link").href =  valori_dettaglio[6] ;

document.getElementById("mappa_dett_immobile_bg").style.display = "inline";



//document.getElementById("mappa_dett_immobile_bg").innerHTML = valore;

}

function hideDettaglioMappa(){
document.getElementById("mappa_dett_immobile_bg").style.display = "none";
}

function ShowDetails(valore){

document.forma.action = valore;
document.forma.submit();
}




