
var ajax = null;


function stampa(url) {

	schedaWindow = window.open(url, "schedaWindow", "scrollbars=yes,menubar=yes,toolbar=yes,resizable=yes,width=768,height=500,left=50,top=50");

}



function myHandler() {

//stati del readyState
//* 0 Uninitialized l'oggetto XMLHttpRequest esiste, ma non è stato richiamato alcun metodo per inizializzare una comunicazione
//* 1 Open è stato richiamato il metodo open() ed il metodo send() non ha ancora effettuato l'invio dati
//* 2 Sent il metodo send() è stato eseguito ed ha effettuato la richiesta
//* 3 Receiving i dati in risposta cominciano ad essere letti
//* 4 Loaded l'operazione è stata completata

cc=document.formcella.cella.value
//alert(cc)

//stati della status su http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
	//alert(ajax.readyState+" "+ajax.status)
    if (ajax.readyState == 4 && ajax.status == 200) {
        e = document.getElementById(cc);
		//alert(e)
		//alert(ajax.responseText)
        //e.innerHTML = ajax.responseText;
		//alert(e.innerHTML);
        e.innerHTML = ajax.responseText;
		
//		e=document.getElementById("pagina2")
//		alert(e)
		
		//nel caso in cui si parsi un XML
		//if(ajax.responseXML)
        // visualizzazione risultato parsing
        //e.innerHTML = parseXml(ajax.responseXML); la funzione parseXML è da creare alla bisogna
     // else
        // visualizzazione contenuto letto
        // evitando di scrivere la risposta in modo
        // interpretabile dal browser
        //e.innerHTML = "L'XML restituito dalla richiesta non è valido.<br />" +

    }
	
	
}





function inserisci(da,campo,t,i,a,n) {

document.formcella.cella.value=campo+a
	//alert("risultati_ajax.php?mqmin="+escape(mqmin)+"&piano="+escape(piano)+"&altre="+escape(altre)+"&frazione="+escape(frazione)+"&provincia="+escape(provincia)+"&parola="+escape(parola)+"&categoria="+escape(categoria)+"&funzionario="+escape(funzionario)+"&incaricato="+escape(incaricato)+"&proprietario="+escape(proprietario)+"&telefono="+escape(telefono)+"&mqmax="+escape(mqmax)+"&cameremin="+escape(cameremin)+"&cameremax="+escape(cameremax)+"&nvanimin="+escape(nvanimin)+"&nvanimax="+escape(nvanimax)+"&totbagni="+escape(totbagni)+"&prezzo="+escape(prezzo)+"&prezzomin="+escape(prezzomin)+"&tipomediaz="+escape(tipomediaz)+"&datainserim="+escape(datainserim)+"&datadiagg="+escape(datadiagg))
    //alert(campo)
	//alert(document.formcella.cella.value)
	//alert("annunci_modifica.php?t="+escape(t)+"&i="+escape[i]+"&a="+escape(a)+"&da="+da+"&campo="+campo+"&rand="+escape(r)+"&n="+escape(n))
	
	var r = Math.random();
    ajax = CreateXmlHttpReq(myHandler);
    ajax.open("GET","annunci_inserisci.php?t="+escape(t)+"&i="+escape(i)+"&a="+escape(a)+"&da="+da+"&campo="+campo+"&rand="+escape(r)+"&n="+escape(n));
	ajax.setRequestHeader("connection", "close");
    ajax.send(null);
	


}


function apriricerca() {
	
	x=document.getElementById("ricerca").style.display
	
	if (x!="")
  		document.getElementById("ricerca").style.display=""
	else
  		document.getElementById("ricerca").style.display="none"
	
	
}




function check(val,status) {

    //alert(status+" "+val);
	//$colorecella="#BA591E; color:#FFFFFF; font-weight:bold ";
   //$colorecella="#FFFFCC; color:#000000";

	valore=val.replace("1","")
	v1=valore+"cella1"
	v2=valore+"cella2"
	totale=""
	
    for (i=0; i<document.form1x.elements.length; i=i+1) {
	
	//alert(document.form1x.elements[i].id+" "+valore)
	
       if (document.form1x.elements[i].id==valore) {
	      //alert(v1)
		  
		  if (status) {
		    
//			e=document.getElementById(v1)
//			e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    document.form1x.elements[i].checked=true
			colore2(document.form1x.elements[i],document.form1x.elements[i].value,true)
//			e.style.backgroundColor="#BA591E";
//			e.style.color="#FFFFFF";
//			e.style.fontWeight="bold";
//			e2.style.backgroundColor="#BA591E";
//			e2.style.color="#FFFFFF";
//			e2.style.fontWeight="bold";
			//e.style.backgroundColor="#BA591E";
		  
		  }
		  
		  if (!status) {
		  
			//e=document.getElementById(v1)
			//e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    document.form1x.elements[i].checked=false
			colore2(document.form1x.elements[i],document.form1x.elements[i].value,false)
//			e.style.backgroundColor="#BA591E";
//			e.style.color="#FFFFFF";
//			e.style.fontWeight="bold";
//			e2.style.backgroundColor="#BA591E";
//			e2.style.color="#FFFFFF";
//			e2.style.fontWeight="bold";
			//e.style.backgroundColor="#BA591E";
			
		  }
		  
	   }

    }
	
	valorezone()

}


function colore2(a,z,status) {

	     v1=z+"cella1"
	     v2=z+"cella2"

		  if (status) {
		    
			e=document.getElementById(v1)
			e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    a.checked=true
			e.style.backgroundColor="#D3B3AF";
			e.style.color="#000000";
			e.style.fontWeight="normal";
			e2.style.backgroundColor="#D3B3AF";
			e2.style.color="#000000";
		  
		  }
		  
		  if (!status) {
		  
			e=document.getElementById(v1)
			e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    a.checked=false
			e.style.backgroundColor="";
			e.style.color="#000000";
			e.style.fontWeight="normal";
			e2.style.backgroundColor="";
			e2.style.color="#000000";
			
		  }


}



function colore(a,z,status) {

	     v1=z+"cella1"
	     v2=z+"cella2"
		 
		 //alert(a+z+status)

		  if (status) {
		    
			e=document.getElementById(v1)
			e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    a.checked=true
			e.style.backgroundColor="#D3B3AF";
			e.style.color="";
			e.style.fontWeight="normal";
			e2.style.backgroundColor="#D3B3AF";
			e2.style.color="";
			//e.style.backgroundColor="#BA591E";
			//valorezone();
			totale=document.getElementById("zonaval_cont").innerHTML
			//alert(totale)
			//alert("METTO "+a.value) 
          if (  (totale=="&nbsp;") || (totale=="") )
			totale=a.value
		  else
			totale=totale+", "+a.value
			//alert(totale)
		  
		  }
		  
		  if (!status) {
		  
			e=document.getElementById(v1)
			e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    a.checked=false
			e.style.backgroundColor="";
			e.style.color="#000000";
			e.style.fontWeight="normal";
			e2.style.backgroundColor="";
			e2.style.color="#000000";
			//e.style.backgroundColor="#BA591E";
			//valorezone()
			totale=document.getElementById("zonaval_cont").innerHTML
//			alert(totale)
//			alert("TOLGO "+a.value) 
			stringa=a.value+", "
			stringa2=", "+a.value
			stringa3=a.value
			//alert(totale)
          if (  (totale=="&nbsp;") || (totale=="") )
			totale=a.value
		  else
			totale=totale+", "+a.value

			totale=totale.replace(stringa,"")
			totale=totale.replace(stringa2,"")
			totale=totale.replace(stringa3,"")
			//alert(totale)
			
		  }
		  
          	document.getElementById("zonaval_cont").innerHTML=totale


}




function valorezone() {

   totale=""

    for (i=0; i<document.form1x.elements.length; i++) {
	
	//alert(document.form1.elements[i].id+" "+valore)
	   if (  (document.form1x.elements[i].checked==true) && ((document.form1x.elements[i].value).indexOf('1')==-1)  )  {
	      //alert(document.form1x.elements[i].value)
	      if (totale=="")
		     totale=document.form1x.elements[i].value
		  else
		     totale=totale+", "+document.form1x.elements[i].value
	   
	   }

    }

    //alert(totale)
	
	if (totale=="")
	  totale="&nbsp;"

	document.getElementById("zonaval_cont").innerHTML=totale

}




function tipo() {
	
	
   
 
 document.getElementById("contenutozone").style.display="none"
 document.getElementById("contenutotipologie").style.display=""

//alert(val)
//document.getElementById("bologna").style.display="none"
//document.getElementById("provincia").style.display="none"
//document.getElementById("fuori").style.display="none"



}






function zone() {
	



for (i=0; i < document.form1.zon.length; i++)   {
	
   if (document.form1.zon[i].checked)
         val = document.form1.zon[i].value
		 
   }
   
   

 
 document.getElementById("contenutozone").style.display=""
 document.getElementById("contenutotipologie").style.display="none"

//alert(val)
//document.getElementById("bologna").style.display="none"
//document.getElementById("provincia").style.display="none"
//document.getElementById("fuori").style.display="none"


if (val=="bologna") {
	
	document.getElementById("bologna").style.display=""
	document.getElementById("provincia").style.display="none"

}


if (val=="provincia") {
	
	document.getElementById("bologna").style.display="none"
	document.getElementById("provincia").style.display=""

}


if (val=="tutte") {
	
	document.getElementById("bologna").style.display=""
	document.getElementById("provincia").style.display=""

}





//switchzone(val);


}











function switchzone(val) {
	
	
    for (i=0; i<document.form1x.elements.length; i++) {
	
	document.form1x.elements[i].checked=false
	
	z=document.form1x.elements[i].value
	
	v1=z+"cella1"
	v2=z+"cella2"
	e=document.getElementById(v1)
	e2=document.getElementById(v2)
	
	if (e!=null) {
		e.style.backgroundColor="#E6E5DE";
		e.style.color="#000000";
		e.style.fontWeight="normal";
		e2.style.backgroundColor="#E6E5DE";
		e2.style.color="#000000";
	}

	
	   
	}
	
	
	
if (val=="bologna") {
	
	document.getElementById("bologna").style.display=""
	document.getElementById("provincia").style.display="none"

}


if (val=="provincia") {
	
	document.getElementById("bologna").style.display="none"
	document.getElementById("provincia").style.display=""

}


if (val=="tutte") {
	
	document.getElementById("bologna").style.display=""
	document.getElementById("provincia").style.display=""

}


document.getElementById("zonaval_cont").innerHTML=""


}














function checkt(val,status) {

    //alert(status+" "+val);
	//$colorecella="#BA591E; color:#FFFFFF; font-weight:bold ";
   //$colorecella="#FFFFCC; color:#000000";

	valore=val.replace("1","")
	v1=valore+"cella1"
	v2=valore+"cella2"
	totale=""
	
    for (i=0; i<document.form1xt.elements.length; i=i+1) {
	
	//alert(document.form1x.elements[i].id+" "+valore)
	
       if (document.form1xt.elements[i].id==valore) {
	      //alert(v1)
		  
		  if (status) {
		    
//			e=document.getElementById(v1)
//			e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    document.form1xt.elements[i].checked=true
			colore2t(document.form1xt.elements[i],document.form1xt.elements[i].value,true)
//			e.style.backgroundColor="#BA591E";
//			e.style.color="#FFFFFF";
//			e.style.fontWeight="bold";
//			e2.style.backgroundColor="#BA591E";
//			e2.style.color="#FFFFFF";
//			e2.style.fontWeight="bold";
			//e.style.backgroundColor="#BA591E";
		  
		  }
		  
		  if (!status) {
		  
			//e=document.getElementById(v1)
			//e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    document.form1xt.elements[i].checked=false
			colore2t(document.form1xt.elements[i],document.form1xt.elements[i].value,false)
//			e.style.backgroundColor="#BA591E";
//			e.style.color="#FFFFFF";
//			e.style.fontWeight="bold";
//			e2.style.backgroundColor="#BA591E";
//			e2.style.color="#FFFFFF";
//			e2.style.fontWeight="bold";
			//e.style.backgroundColor="#BA591E";
			
		  }
		  
	   }

    }
	
	valoretipo()

}


function colore2t(a,z,status) {

	     v1=z+"cella1"
	     v2=z+"cella2"
		 
		 //alert("V1:"+v1)
		 //alert("V2"+v2)

		  if (status) {
		    
			e=document.getElementById(v1)
			e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    a.checked=true
			e.style.backgroundColor="#D3B3AF";
			e.style.color="#000000";
			e.style.fontWeight="normal";
			e2.style.backgroundColor="#D3B3AF";
			e2.style.color="#000000";
		  
		  }
		  
		  if (!status) {
		  
			e=document.getElementById(v1)
			e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    a.checked=false
			e.style.backgroundColor="";
			e.style.color="#000000";
			e.style.fontWeight="normal";
			e2.style.backgroundColor="";
			e2.style.color="#000000";
			
		  }
		  
          


}

function coloret(a,z,status) {

	     v1=z+"cella1"
	     v2=z+"cella2"

		  if (status) {
		    
			e=document.getElementById(v1)
			e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    a.checked=true
			e.style.backgroundColor="#D3B3AF";
			e.style.color="#000000";
			e.style.fontWeight="normal";
			e2.style.backgroundColor="#D3B3AF";
			e2.style.color="#000000";
			//e.style.backgroundColor="#BA591E";
			//valorezone();
			totale=document.getElementById("tipoval_cont").innerHTML
//			alert(totale)
//			alert("METTO "+a.value) 
          if (  (totale=="&nbsp;") || (totale=="") )
			totale=a.value
		  else
			totale=totale+", "+a.value
			//alert(totale)
		  
		  }
		  
		  if (!status) {
		  
			e=document.getElementById(v1)
			e2=document.getElementById(v2)
			//alert(e.style.backgroundColor)
		    a.checked=false
			e.style.backgroundColor="";
			e.style.color="#000000";
			e.style.fontWeight="normal";
			e2.style.backgroundColor="";
			e2.style.color="#000000";
			//e.style.backgroundColor="#BA591E";
			//valorezone()
			totale=document.getElementById("tipoval_cont").innerHTML
//			alert(totale)
//			alert("TOLGO "+a.value) 
			stringa=a.value+", "
			stringa2=", "+a.value
			stringa3=a.value
			
          if (  (totale=="&nbsp;") || (totale=="") )
			totale=a.value
		  else
			totale=totale+", "+a.value

			totale=totale.replace(stringa,"")
			totale=totale.replace(stringa2,"")
			totale=totale.replace(stringa3,"")
			//alert(totale)
			
		  }
		  
          	document.getElementById("tipoval_cont").innerHTML=totale



}




function valoretipo() {

   totale=""

    for (i=0; i<document.form1xt.elements.length; i++) {
	
	//alert(document.form1.elements[i].id+" "+valore)
	   if (  (document.form1xt.elements[i].checked==true) && ((document.form1xt.elements[i].value).indexOf('1')==-1)  )  {
	      
	      if (totale=="")
		     totale=document.form1xt.elements[i].value
		  else
		     totale=totale+", "+document.form1xt.elements[i].value
	   
	   }

    }

    //alert(totale)
	if (totale=="")
	  totale="&nbsp;"
	  
	document.getElementById("tipoval_cont").innerHTML=totale

}




function minmax(campo) {
	
	
	x=campo.value
	if ( (x=="min") || (x=="max") )
	   campo.value=""

}
	


function riordina() {

i=document.getElementById('ordinamento').selectedIndex
x=document.getElementById('ordinamento').options[i].value
document.form1.ordine.value=x
document.form1.submit()

}




function cercapreferiti() {
	
	document.form1.action="risultati.php"
	document.form1.pag.value=""
	document.form1.ordine.value=""
	document.form1.submit()
	
	
}



function pagina(val) {

document.form1.pag.value=val
document.form1.submit()

}


function cambiascheda(valore) {
	
	
	document.getElementById("dettagli").style.display="none"
	document.getElementById("informazioni").style.display="none"
	document.getElementById("immagini").style.display="none"
	document.getElementById("planimetrie").style.display="none"
	
	document.getElementById("dettagli_img").src="img/scheda01.gif"
	document.getElementById("immagini_img").src="img/scheda02.gif"
	document.getElementById("planimetrie_img").src="img/scheda03.gif"
	document.getElementById("informazioni_img").src="img/scheda04.gif"
	//document.getElementById("appuntamento_img").src="img/scheda05.gif"

	
	document.getElementById(valore).style.display=""
	
	if (valore=="dettagli") 
		document.getElementById("dettagli_img").src="img/scheda01_on.gif"
		
	if (valore=="immagini") 
		document.getElementById("immagini_img").src="img/scheda02_on.gif"

	if (valore=="planimetrie") 
		document.getElementById("planimetrie_img").src="img/scheda03_on.gif"

	if (valore=="informazioni") 
		document.getElementById("informazioni_img").src="img/scheda04_on.gif"

//	if (valore=="appuntamento") 
//		document.getElementById("appuntamento_img").src="img/scheda05_on.gif"

	
}


function fotobig(f,x) {
	
	//alert(document.getElementById("menu").style.display)
	document.getElementById("bigfoto").src=f
	document.getElementById("fotobig").style.display=""
	document.getElementById("menu").style.display="none"
	document.getElementById("immagini").style.display="none"
	
	xavanti=parseInt(x)+1
	xindietro=parseInt(x)-1
	
	
	tfoto=document.getElementById("totalefoto").value
	totfoto=parseInt(tfoto)
	
//	alert(x)
//	alert(xavanti)
//	alert(xindietro)
//	alert(totfoto)
//	alert(xavanti<=totfoto)
	
	if (xindietro>0)
  		document.getElementById("linkindietro").innerHTML="<a href=\"javascript:muovifoto("+xindietro+")\" id=\"linkindietro\"><img src=\"img/foto_prec.gif\" width=\"104\" height=\"52\" border=\"0\" /></a>"
	else
  		document.getElementById("linkindietro").innerHTML=""
	
	if (xavanti<=totfoto)
		document.getElementById("linkavanti").innerHTML="<a href=\"javascript:muovifoto("+xavanti+")\" id=\"linkindietro\"><img src=\"img/foto_succ.gif\" width=\"99\" height=\"52\" border=\"0\" /></a>"
	else
  		document.getElementById("linkavanti").innerHTML=""

}


function immagini(f) {
	
	document.getElementById("fotobig").style.display="none"
	document.getElementById("menu").style.display=""
	document.getElementById("immagini").style.display=""
	
	

}

function muovifoto(x) {
	
	
	
	f=document.getElementById(x).value
	
	xavanti=parseInt(x)+1
	xindietro=parseInt(x)-1
	
//	alert(x)
//	alert(xavanti)
//	alert(xindietro)
//	alert(totfoto)
	
	tfoto=document.getElementById("totalefoto").value
	totfoto=parseInt(tfoto)
	
	if (xindietro>0)
  		document.getElementById("linkindietro").innerHTML="<a href=\"javascript:muovifoto("+xindietro+")\" id=\"linkindietro\"><img src=\"img/foto_prec.gif\" width=\"104\" height=\"52\" border=\"0\" /></a>"
	else
  		document.getElementById("linkindietro").innerHTML=""
	
	if (xavanti<=totfoto)
		document.getElementById("linkavanti").innerHTML="<a href=\"javascript:muovifoto("+xavanti+")\" id=\"linkindietro\"><img src=\"img/foto_succ.gif\" width=\"99\" height=\"52\" border=\"0\" /></a>"
	else
  		document.getElementById("linkavanti").innerHTML=""
		
	//alert(f)
	document.getElementById("bigfoto").src=f


}



function handlerpreferiti() {


    if (ajax.readyState == 4 && ajax.status == 200) {
        //e = document.getElementById(cc);
		//alert(e)
		//alert(ajax.responseText)
        //e.innerHTML = ajax.responseText;
		//alert(e.innerHTML);
        //e.innerHTML = ajax.responseText;

    }
	
	
}




function handler_preferito(ID, x) {

	//alert(ajax.status)

    if (ajax.readyState == 4 && ajax.status == 200) {
		
		//alert("fine")
		valret=ajax.responseText
		//alert(valret)
		valret=valret.replace("<body>", "")
		//alert(valret)
		valret=valret.replace("</body>", "")
		//alert(valret)
		document.getElementById("preferiti_val").value=valret
		
		if (x==1)
			document.location.reload()
		
    }
	
}





function aggiungipreferito(ID, x) {

		//alert(document.location)
		

		val="stella_"+ID
		
		val2=document.getElementById(val).src
		//alert(val2.indexOf("info_aggiungi.gif"))
		
		if (val2.indexOf("preferiti_rimuovi")==-1) {
		
			if (val2.indexOf("info_aggiungi.gif")!=-1) {
				statusx="on"
				document.getElementById(val).src=(document.getElementById(val).src).replace("info_aggiungi.gif", "preferiti.gif")
			}
			else {
				statusx="off"
				document.getElementById(val).src=(document.getElementById(val).src).replace("preferiti.gif", "info_aggiungi.gif")
			}
		
		} else {
		
			statusx="off"
			x=1
		
		
		
		}
		
		//alert(status)

		var r = Math.random();
		
		urlx="ajax/preferiti.php?rand="+escape(r)+"&status="+statusx+"&cod="+ID

		//alert(urlx)
//		
		ajax=CreateXmlHttpReq(function() {handler_preferito(ID, x)})
		ajax.open("GET",urlx);
		ajax.setRequestHeader("connection", "close");
		ajax.send(null);

}






function handlerpreferiti_rimuovi() {


    if (ajax.readyState == 4 && ajax.status == 200) {
        //e = document.getElementById(cc);
		//alert(e)
		//alert(ajax.responseText)
        //e.innerHTML = ajax.responseText;
		//alert(e.innerHTML);
        //e.innerHTML = ajax.responseText;
		document.location.reload()

    }
	
	
}



function preferiti_rimuovi(x) {
	
	var r = Math.random();
    ajax = CreateXmlHttpReq(handlerpreferiti_rimuovi);
    ajax.open("GET","preferiti_rimuovi.php?cod="+escape(x)+"&rand="+escape(r));
	ajax.setRequestHeader("connection", "close");
    ajax.send(null);
	


}


function metodo(x) {
	
	
	if (x!="") {
		
	document.getElementById("dettagli").style.display="none"
	document.getElementById("informazioni").style.display="none"
	document.getElementById("appuntamento").style.display="none"
	document.getElementById("immagini").style.display="none"
	document.getElementById("planimetrie").style.display="none"
	
	document.getElementById(x).style.display=""
	
	if (x=="informazioni")  {
		document.getElementById("Image11").src="img/scheda04_on.gif"
		document.getElementById("Image8").src="img/scheda01.gif"
	}

	if (x=="appuntamento")  {
		document.getElementById("Image12").src="img/scheda05_on.gif"
		document.getElementById("Image8").src="img/scheda01.gif"
	}

	}
	

}



function chiama(x) {
	
//alert(x)
v="chiama_"+x
//alert(document.getElementById(v).style.display)
if (document.getElementById(v).style.display!="")
	document.getElementById(v).style.display=""
else
	document.getElementById(v).style.display="none"

//alert(document.getElementById(v).style.display)

	
}


function scambia(IDfoto) {


	foto=document.getElementById(IDfoto).src
	
	//alert(IDfoto)
	
	//alert(foto.indexOf("_on"))
	
	if (foto.indexOf("_on")!=-1) 
		foto=foto.replace("_on.gif", ".gif")
	else
		foto=foto.replace(".gif", "_on.gif")
	
	document.getElementById(IDfoto).src=foto


}



function chiudimail() {

		
        e = document.getElementById("mail_inviata");
        e.style.display = "none";
        e = document.getElementById("mail_inviata2");
        e.style.display = "none";
		cambiascheda('dettagli')

	
	
}


function handlermail() {

	//alert(ajax.readyState+" "+ajax.status)
    if (ajax.readyState == 4 && ajax.status == 200) {
		
        e = document.getElementById("mail_inviata");
        e.style.display = "";
        e = document.getElementById("mail_inviata2");
        e.style.display = "";

    }
	
	
}





function mail_info() {

	urlx=""
	
	for (i=0;i<document.forminfo.length; i=i+1) {
	
		
		if ( (document.forminfo.elements[i].id!="appuntamento") && (document.forminfo.elements[i].id!="informazioni") ) {
		
			//alert(document.forminfo.elements[i].id)
		
			if (urlx=="")
				urlx=document.forminfo.elements[i].id+"="+document.forminfo.elements[i].value
			else
				urlx=urlx+"&"+document.forminfo.elements[i].id+"="+document.forminfo.elements[i].value
		
		} else {
		
			if (document.forminfo.elements[i].checked) {
		
				if (urlx=="")
					urlx=document.forminfo.elements[i].id+"=si"
				else
					urlx=urlx+"&"+document.forminfo.elements[i].id+"=si"

			
			}
		
		
		}
	
	
	}


	var r = Math.random();
    ajax = CreateXmlHttpReq(handlermail);
    ajax.open("GET","mail_informazioni.php?r="+escape(r)+urlx);
	ajax.setRequestHeader("connection", "close");
    ajax.send(null);


}



function gallery() {


	document.getElementById("menux").style.display="none";
	document.getElementById("testatax").style.display="none";
	document.getElementById("testata-gallery").style.display="";
	document.getElementById("contenitore_gallery").style.display="";
	
	//alert("vai")

	cambiascheda('informazioni')
	
	return true


}


function chiudigallery(totfoto) {


	resetfoto(totfoto)
	document.getElementById("contenitore_gallery").style.display="none";
	document.getElementById("testata-gallery").style.display="none";
	document.getElementById("menux").style.display="";
	document.getElementById("testatax").style.display="";
	cambiascheda('immagini')
	

}




function fotoprossima(totfoto) {

	for (i=1; i<=totfoto; i=i+1) {
	
		val="foto"+i
//		ml=document.getElementById(val).style.marginLeft
//		mlval=ml.replace("px", "")
//		mlval=parseInt(mlval)
//		mlval=mlval-947
		//document.getElementById(val).style.marginLeft=mlval+"px"
		
		new Effect.Move(val, { x: -947, y: 0, mode: 'relative' });
		//alert(mlval)
	
	}
	
	dida=document.getElementById("didascalia").innerHTML
	dida=dida.replace("foto ", "")
	dida=dida.replace(" di "+totfoto, "")
	//alert(dida)
	didaval=parseInt(dida)+1
	//alert(didaval)
	
	document.getElementById("indietro").style.display="";
	
	if(didaval==totfoto)
		document.getElementById("avanti").style.display="none";
	else	
		document.getElementById("avanti").style.display="";
		
	didaval=didaval.toString()
	dida="foto "+didaval+" di "+totfoto
	document.getElementById("didascalia").innerHTML=dida
	
	


}

function fotoprecedente(totfoto) {

	for (i=1; i<=totfoto; i=i+1) {
	
		val="foto"+i
//		ml=document.getElementById(val).style.marginLeft
//		mlval=ml.replace("px", "")
//		mlval=parseInt(mlval)
//		mlval=mlval-947
		//document.getElementById(val).style.marginLeft=mlval+"px"
		
		new Effect.Move(val, { x: +947, y: 0, mode: 'relative' });
		//alert(mlval)
	
	}
	
	dida=document.getElementById("didascalia").innerHTML
	dida=dida.replace("foto ", "")
	dida=dida.replace(" di "+totfoto, "")
	//alert(dida)
	didaval=parseInt(dida)-1
	
	document.getElementById("avanti").style.display="";
	
	if(didaval==1)
		document.getElementById("indietro").style.display="none";
	else	
		document.getElementById("indietro").style.display="";
		
	//alert(didaval)
	didaval=didaval.toString()
	dida="foto "+didaval+" di "+totfoto
	document.getElementById("didascalia").innerHTML=dida
	


}




function vaifoto(totfoto, num) {

	gallery()
	
	offset=947*(num-1)

	for (i=1; i<=totfoto; i=i+1) {
	
		val="foto"+i
//		ml=document.getElementById(val).style.marginLeft
//		mlval=ml.replace("px", "")
//		mlval=parseInt(mlval)
//		mlval=mlval-947
		//document.getElementById(val).style.marginLeft=mlval+"px"
		
		new Effect.Move(val, { x: -offset, y: 0, mode: 'relative' });
		//alert(mlval)
	
	}
	
	document.getElementById("indietro").style.display="";
	document.getElementById("avanti").style.display="";

	
	if(num==1)
		document.getElementById("indietro").style.display="none";
		
	if(num==totfoto)
		document.getElementById("avanti").style.display="none";
		
	

	dida="foto "+num+" di "+totfoto
	document.getElementById("didascalia").innerHTML=dida
	

}


function resetfoto(totfoto) {

	num=1
	
	dida=document.getElementById("didascalia").innerHTML
	dida=dida.replace("foto ", "")
	dida=dida.replace(" di "+totfoto, "")
	//alert(dida)
	didaval=parseInt(dida)
	//alert(didaval)
	
	
	offset=947*(didaval-1)

	for (i=1; i<=totfoto; i=i+1) {
	
		val="foto"+i
		
		new Effect.Move(val, { x: offset, y: 0, mode: 'relative' });
	
	}
		

	dida="foto 1 di "+totfoto
	document.getElementById("didascalia").innerHTML=dida
	

}



function apridettaglio(liv) {
	
	//alert(liv)

	if (liv!="zona")
		Effect.BlindUp("zona", { duration: 0.7 });
		
	if (liv!="zonaprov")
		Effect.BlindUp("zonaprov", { duration: 0.7 });
		
	if (liv!="tipologia")
		Effect.BlindUp("tipologia", { duration: 0.7 });
		
	if (liv!="prezzo")
		Effect.BlindUp("prezzo", { duration: 0.7 });
		
	if (liv!="camere")
		Effect.BlindUp("camere", { duration: 0.7 });
		
	if (liv!="bagni")
		Effect.BlindUp("bagni", { duration: 0.7 });
		
	if (liv!="piano")
		Effect.BlindUp("piano", { duration: 0.7 });
		
	if (liv!="metriquadri")
		Effect.BlindUp("metriquadri", { duration: 0.7 });
		
	valurl=document.location
	v1=valurl.toString()
	xxx=v1.indexOf("ipad")
	//alert(xxx)
	
	if (xxx!=-1)	
        Effect.ScrollTo('ricerca');	
	
	Effect.BlindDown(liv, { duration: 0.7 });

}




function updateval(valore, valricerca, status, settore) {

	valval=settore+"val";
	valtxt=settore+"txt";
	
	
	//alert(settore)
	
	if (status) {
		
		if ((settore!="zona") && (settore!="tipologia")) {
		
			resetform(settore, valricerca);
		
		
		}
	
	
		if (settore=="zona") {
			
			if (document.getElementById(valtxt).innerHTML!="tutte le zone") {
					
			  document.getElementById(valval).value=document.getElementById(valval).value+"*"+valricerca+"*"
			  document.getElementById(valtxt).innerHTML=document.getElementById(valtxt).innerHTML+" - "+valore
		  
			}
			else {
			
			  document.getElementById(valval).value="*"+valricerca+"*"
			  document.getElementById(valtxt).innerHTML=valore
			
			}
		
		}
		
		if (settore=="tipologia") {
			
			if (document.getElementById(valtxt).innerHTML!="tutte le tipologie") {
					
			  document.getElementById(valval).value=document.getElementById(valval).value+"*"+valricerca+"*"
			  document.getElementById(valtxt).innerHTML=document.getElementById(valtxt).innerHTML+" - "+valore
		  
			}
			else {
			
			  document.getElementById(valval).value="*"+valricerca+"*"
			  document.getElementById(valtxt).innerHTML=valore
			
			}
		
		}
		
		if ( (settore!="tipologia") && (settore!="zona") ) {
		
			  document.getElementById(valval).value="*"+valricerca+"*"
			  document.getElementById(valtxt).innerHTML=settore+": "+valore
		
		}
		
		
		
	} 
	else {

		  v1=document.getElementById(valval).value
		  v2=document.getElementById(valtxt).innerHTML
		  
		  v1=v1.replace("*"+valricerca+"*", "")
		  v2=v2.replace(" - "+valore, "")
		  v2=v2.replace(valore, "")
		  
		  if (v2.substr(0,3)==" - ")
		  	v2=v2.substr(3)
		
		  if ( (v2=="") && (settore=="zona")  )
		  	v2="tutte le zone"
		  
		  if ( (v2=="") && (settore=="tipologia")  )
		  	v2="tutte le tipologie"
		  
		  //alert(v2+"-"+settore)
		  
		  if (v2==settore+":") 
		  	v2=settore+": nessuna scelta"
		  
		  if (v2==settore+": ") 
		  	v2=settore+": nessuna scelta"
		  
		  //v2=v2.replace("metriquadri", "metri quadri")
		  
		  document.getElementById(valval).value=v1
		  document.getElementById(valtxt).innerHTML=v2

	}



}




function updatecodice(val) {

	if (val=="")
		val2="nessuna scelta"
	else
		val2=val
	
	document.getElementById("codicetxt").innerHTML="codice: "+val2
	document.getElementById("codiceval").value=val


}



function updatemediazione(val) {


	document.getElementById("mediazionetxt").innerHTML=val
	document.getElementById("prezzotxt").innerHTML="prezzo: nessuna scelta"
	
	if (val=="vendita")
		document.getElementById("formprezzo").innerHTML=document.getElementById("formprezzov").innerHTML
	else
		document.getElementById("formprezzo").innerHTML=document.getElementById("formprezzoa").innerHTML
		

}



function resetform(val, nm) {


	id="form"+val
	
	for (i=0;i<document.getElementById(id).length; i=i+1) {

	  if (document.getElementById(id).elements[i].name!=nm)
		  document.getElementById(id).elements[i].checked=false

	}

	return true;


}




function cerca() {
	
	mediazionex=document.getElementById("mediazionetxt").innerHTML	
	zonax=document.getElementById("zonatxt").innerHTML	
	tipologiax=document.getElementById("tipologiatxt").innerHTML	
	camerex=document.getElementById("cameretxt").innerHTML	
	bagnix=document.getElementById("bagnitxt").innerHTML	
	pianox=document.getElementById("pianotxt").innerHTML	
	metriquadrix=document.getElementById("metriquadritxt").innerHTML	
	prezzox=document.getElementById("prezzotxt").innerHTML	
	codicex=document.getElementById("codicetxt").innerHTML
	
	urlx="zona="+zonax+"&mediazione="+mediazionex+"&tipologia="+tipologiax+"&camere="+camerex+"&bagni="+bagnix+"&piano="+pianox+"&metriquadri="+metriquadrix+"&prezzo="+prezzox+"&codice="+codicex
		
	
	document.location='risultatix.php?'+urlx

	
	
}

function cercacodice() {
	
	
	codicex=document.getElementById("codicetxt").innerHTML
	
	urlx="&codice="+codicex
		
	
	document.location='risultatix.php?'+urlx

	
	
}


function cerca_ipad() {
	
	mediazionex=document.getElementById("mediazionetxt").innerHTML	
	zonax=document.getElementById("zonatxt").innerHTML	
	tipologiax=document.getElementById("tipologiatxt").innerHTML	
	camerex=document.getElementById("cameretxt").innerHTML	
	bagnix=document.getElementById("bagnitxt").innerHTML	
	pianox=document.getElementById("pianotxt").innerHTML	
	metriquadrix=document.getElementById("metriquadritxt").innerHTML	
	prezzox=document.getElementById("prezzotxt").innerHTML	
	codicex=document.getElementById("codicetxt").innerHTML
	
	urlx="http://www.lasoffittaimmobiliare.com/ipad-risultatix.php?zona="+zonax+"&mediazione="+mediazionex+"&tipologia="+tipologiax+"&camere="+camerex+"&bagni="+bagnix+"&piano="+pianox+"&metriquadri="+metriquadrix+"&prezzo="+prezzox+"&codice="+codicex

	
	//alert(urlx)
	
	document.location=urlx

	
	
}



function check_riga() {


	v=document.getElementById("immobile-val").value
	
	if (v!="") {
		
		val="immobile-"+v
		Effect.ScrollTo(val);


	}


}


