
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



var ajax = null;



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 cerca() {
	
	document.form1.pag.value=""
	document.form1.ordine.value=""
	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 preferiti(x) {
	
	prf="preferito"+x
	document.getElementById(prf).innerHTML="<img src=\"img/preferiti.gif\" alt=\"Cogi Group\" width=\"170\" height=\"23\" border=\"0\" />"
	var r = Math.random();
    ajax = CreateXmlHttpReq(handlerpreferiti);
    ajax.open("GET","preferiti.php?cod="+escape(x)+"&rand="+escape(r));
	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 handlerzone() {


    if (ajax.readyState == 4 && ajax.status == 200) {

        e = document.getElementById("zonediv");
        e.innerHTML = ajax.responseText;

    }
	
	
}

function handlerzone2() {


    if (ajax.readyState == 4 && ajax.status == 200) {

        e = document.getElementById("zonediv");
        e.innerHTML = ajax.responseText;
		checkzona()
    }
	
	
}




function cambiazona(x) {
	
  //alert(x)
  	
  if ( (x==1) || (x==2) || (x==3) ) {
	  
	var r = Math.random();
    ajax = CreateXmlHttpReq(handlerzone);
    ajax.open("GET","ajax_zone.php?cod="+escape(x)+"&rand="+escape(r));
	ajax.setRequestHeader("connection", "close");
    ajax.send(null);
  
  } else {
	  
	e = document.getElementById("zonediv");
	e.innerHTML ="<select name=\"zona\" class=\"alignleft verdana testo10\" style=\"width:200px; margin-left:-23px; margin-top:8px;\" id=\"zona\" disabled=\"disabled\"><option value=\"\" selected=\"selected\">Seleziona la zona</option></select>"

  }






}


function cambiazona2(x) {
	
	
  if ( (x==1) || (x==2) || (x==3) ) {
	  
	var r = Math.random();
    ajax = CreateXmlHttpReq(handlerzone2);
    ajax.open("GET","ajax_zone.php?cod="+escape(x)+"&rand="+escape(r));
	ajax.setRequestHeader("connection", "close");
    ajax.send(null);
	  
  
  } else {
	  
	e = document.getElementById("zonediv");
	e.innerHTML ="<select name=\"zona\" class=\"alignleft verdana testo10\" style=\"width:200px; margin-left:-23px; margin-top:8px;\" id=\"zona\" disabled=\"disabled\"><option value=\"\" selected=\"selected\">Seleziona la zona</option></select>"
  
	  
	  

  }






}




function mediazione(x) {
	
	
	if (x=="locazione") {
		
		document.getElementById("prezzov").style.display="none"
		document.getElementById("prezzol").style.display=""
		
	} else {
		
		document.getElementById("prezzov").style.display=""
		document.getElementById("prezzol").style.display="none"
	
	}
	
	
	
}



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 cambia() {
	
	
zz=document.getElementById("locindex").value
//alert(zz)	
cambiazona2(zz)

}


function checkzona() {

//alert("funzione")
zz=document.getElementById("zonaindex").value
//alert(document.getElementById("zona").length)	
for (var i = 0; i < document.getElementById("zona").length; i++) {
     
	 
     if (document.getElementById("zona")[i].value == zz) {
		 
	 		//alert(document.getElementById("zona")[i].value)
           document.getElementById("zona").selectedIndex=i;
		   return true;
		   
     }
	 
}



}



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 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 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


}


