// JavaScript Document
 function visFoto(img)
   {
	   window.open('visFoto.asp?immagine=' + img,'POPFOTO','top=0, left=0, width=200, height=200, scrollbars=no, resizable=yes');
   } 
 function StampaFoto(img)
   {
	   window.open('StampaFoto.asp?immagine=' + img,'POPFOTO','top=0, left=0, width=200, height=200, scrollbars=no, resizable=yes');
   } 
   
    function pop_info(codice)
   {
	   window.open('richiedi_info.asp?codice=' + codice ,'POPINFO','top=100, left=200, width=500, height=650, scrollbars=yes, resizable=no');
   } 
   
       function pop_segnala(id_imm)
   {
	   window.open('segnala.asp?id_imm=' + id_imm ,'POPSEGNALA','top=100, left=200, width=445, height=500, scrollbars=yes, resizable=no');
   } 

       function pop_segnala_eng(id_imm)
   {
	   window.open('segnala.asp?id_imm=' + id_imm ,'POPSEGNALA','top=100, left=200, width=485, height=540, scrollbars=yes, resizable=no');
   } 


function pop_mappa(indirizzo, citta, provincia)
   {
	   window.open('http://maps.google.it/maps?f=q&hl=it&q=' + indirizzo + ", +" + citta + ",+" + provincia + "&om=0&z=16",'POPMAPPA','top=100, left=200, width=900, height=650, scrollbars=yes, resizable=no');
   } 

   
   

   
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
   
 
 function controlla_form() {
		if(document.form_contatti.nome.value=="")
		    {
				  alert("Specificare il proprio nome")
				  document.form_contatti.nome.focus();
				  return false
			}
		 if(document.form_contatti.cognome.value=="")
		    {
				  alert("Specificare il proprio cognome")
				  document.form_contatti.cognome.focus();
				  return false
			}	
		if(document.form_contatti.email.value=="")
		    {
				  alert("Inserire una email valida")
				  document.form_contatti.email.focus();
				  return false
			}
	   if(document.form_contatti.email.value.search(".")==-1)
		 {
			  alert("Inserire una email valida") 
			  document.form_contatti.email.focus();		
			  return false
		 }
	   if(document.form_contatti.email.value.search("@")==-1)
		 {
			  alert("Inserire una email valida") 
			  document.form_contatti.email.focus();
			  return false
		 }

		if(document.form_contatti.telefono.value=="")
		    {
				  alert("Specificare il proprio recapito telefonico")
					document.form_contatti.telefono.focus();
					return false
			}
		if(document.form_contatti.informativa.checked==false)
		    {
				  alert("Acconsentire al trattamento dei dati personali")
				  document.form_contatti.informativa.focus();
				  return false
			}	

			return true

 }
 
 /* Versione inglese */
 
  function controlla_form_eng() {
		if(document.form_contatti.nome.value=="")
		    {
				  alert("Please, specify your Name")
				  document.form_contatti.nome.focus();
				  return false
			}
		 if(document.form_contatti.cognome.value=="")
		    {
				  alert("Please, specify your Surname")
				  document.form_contatti.cognome.focus();
				  return false
			}	
		if(document.form_contatti.email.value=="")
		    {
				  alert("Please, insert a valid email")
				  document.form_contatti.email.focus();
				  return false
			}
	   if(document.form_contatti.email.value.search(".")==-1)
		 {
			  alert("Please, insert a valid email") 
			  document.form_contatti.email.focus();		
			  return false
		 }
	   if(document.form_contatti.email.value.search("@")==-1)
		 {
			  alert("Please, insert a valid email") 
			  document.form_contatti.email.focus();
			  return false
		 }

		if(document.form_contatti.telefono.value=="")
		    {
				  alert("Please, insert a valid phone number")
					document.form_contatti.telefono.focus();
					return false
			}
		if(document.form_contatti.informativa.checked==false)
		    {
				  alert("Please, consent to the treatment of the personal data")
				  document.form_contatti.informativa.focus();
				  return false
			}	

			return true

 }

 
 /*-------------------------*/
 
 
  function controlla_form_proponi() {
	  var telefono=document.form_proponi.telefono.value;
	  
		if(document.form_proponi.nome.value=="")
		    {
				  alert("Specificare il proprio nome")
				  document.form_proponi.nome.focus();
				  return false
			}
		 if(document.form_proponi.cognome.value=="")
		    {
				  alert("Specificare il proprio cognome")
				  document.form_proponi.cognome.focus();
				  return false
			}
			
		if(document.form_proponi.email.value=="")
		    {
				  alert("Inserire una email valida")
				  document.form_proponi.email.focus();
				  return false
			}
	   if(document.form_proponi.email.value.search(".")==-1)
		 {
			  alert("Inserire una email valida") 
			  document.form_proponi.email.focus();		
			  return false
		 }
	   if(document.form_proponi.email.value.search("@")==-1)
		 {
			  alert("Inserire una email valida") 
			  document.form_proponi.email.focus();
			  return false
		 }

		if ((isNaN(telefono)) || (telefono == "") || (telefono == "undefined")) {
           alert("Inserire un numero di telefono valido");
           document.form_proponi.telefono.value = "";
           document.form_proponi.telefono.focus();
           return false;
        }

		if(document.form_proponi.indirizzo_imm.value=="")
		    {
				  alert("Specificare l'indirizzo dell'immobile")
				  document.form_proponi.indirizzo_imm.focus();
				  return false
			}

		if(document.form_proponi.descrizione.value=="")
		    {
				  alert("Inserire una descrizione, anche breve, dell'immobile")
					document.form_proponi.descrizione.focus();
					return false
			}

		if(document.form_proponi.informativa.checked==false)
		    {
				  alert("Acconsentire al trattamento dei dati personali")
				  document.form_proponi.informativa.focus();
				  return false
			}	

			return true

 }
 
 /* Versione inglese */
 
   function controlla_form_proponi_eng() {
	  var telefono=document.form_proponi.telefono.value;
	  
		if(document.form_proponi.nome.value=="")
		    {
				  alert("Please, specify your Name")
				  document.form_proponi.nome.focus();
				  return false
			}
		 if(document.form_proponi.cognome.value=="")
		    {
				  alert("Please, specify your Surname")
				  document.form_proponi.cognome.focus();
				  return false
			}
			
		if(document.form_proponi.email.value=="")
		    {
				  alert("Please, insert a valid email")
				  document.form_proponi.email.focus();
				  return false
			}
	   if(document.form_proponi.email.value.search(".")==-1)
		 {
			  alert("Please, insert a valid email") 
			  document.form_proponi.email.focus();		
			  return false
		 }
	   if(document.form_proponi.email.value.search("@")==-1)
		 {
			  alert("Please, insert a valid email") 
			  document.form_proponi.email.focus();
			  return false
		 }

		if ((isNaN(telefono)) || (telefono == "") || (telefono == "undefined")) {
           alert("Please, insert a valid phone number");
           document.form_proponi.telefono.value = "";
           document.form_proponi.telefono.focus();
           return false;
        }

		if(document.form_proponi.indirizzo_imm.value=="")
		    {
				  alert("Please, specify where the apartment is")
				  document.form_proponi.indirizzo_imm.focus();
				  return false
			}

		if(document.form_proponi.descrizione.value=="")
		    {
				  alert("Insert a short description of the piece of real estate")
					document.form_proponi.descrizione.focus();
					return false
			}

		if(document.form_proponi.informativa.checked==false)
		    {
				  alert("Please, consent to the treatment of the personal data")
				  document.form_proponi.informativa.focus();
				  return false
			}	

			return true

 }
 /*-----------------------*/
 
 
   function controlla_form_richiedi() {
		if(document.getElementById("nome").value=="")
		    {
				  alert("Specificare il proprio nome")
				  document.getElementById("nome").focus();
				  return false
			}
		 if(document.getElementById("cognome").value=="")
		    {
				  alert("Specificare il proprio cognome")
				  document.getElementById("cognome").focus();
				  return false
			}	
		 if(document.getElementById("citta").value=="")
		    {
				  alert("Indicare la citta' o il comune di residenza")
				  document.getElementById("citta").focus();
				  return false
			}	

		if(document.getElementById("email").value=="")
		    {
				  alert("Inserire una email valida")
				  document.getElementById("email").focus();
				  return false
			}
	   if(document.getElementById("email").value.search(".")==-1)
		 {
			  alert("Inserire una email valida") 
			  document.getElementById("email").focus();		
			  return false
		 }
	   if(document.getElementById("email").value.search("@")==-1)
		 {
			  alert("Inserire una email valida") 
			  document.getElementById("email").focus();
			  return false
		 }
		if(document.getElementById("telefono").value=="")
		    {
				  alert("Specificare un recapito telefonico")
				  document.getElementById("telefono").focus();
				  return false
			}

		if(document.getElementById("informativa").checked==false)
		    {
				  alert("Acconsentire al trattamento dei dati personali")
				  document.getElementById("informativa").focus();
				  return false
			}	

			return true

 }
 
    function controlla_form_richiedi_eng() {
		if(document.getElementById("nome").value=="")
		    {
				  alert("Please, specify your Name")
				  document.getElementById("nome").focus();
				  return false
			}
		 if(document.getElementById("cognome").value=="")
		    {
				  alert("Please, specify your Surname")
				  document.getElementById("cognome").focus();
				  return false
			}	
		 if(document.getElementById("citta").value=="")
		    {
				  alert("Indicare la citta' o il comune di residenza")
				  document.getElementById("citta").focus();
				  return false
			}	

		if(document.getElementById("email").value=="")
		    {
				  alert("Please, insert a valid email")
				  document.getElementById("email").focus();
				  return false
			}
	   if(document.getElementById("email").value.search(".")==-1)
		 {
			  alert("Please, insert a valid email") 
			  document.getElementById("email").focus();		
			  return false
		 }
	   if(document.getElementById("email").value.search("@")==-1)
		 {
			  alert("Please, insert a valid email") 
			  document.getElementById("email").focus();
			  return false
		 }
		if(document.getElementById("telefono").value=="")
		    {
				  alert("Please, specify a valid phone number")
				  document.getElementById("telefono").focus();
				  return false
			}

		if(document.getElementById("informativa").checked==false)
		    {
				  alert("Please, consent to the treatment of the personal data")
				  document.getElementById("informativa").focus();
				  return false
			}	

			return true

 }


 
 
 // Inizio AJAX 
 
var xmlhttp
var btnClick=false;
var divDest

function avviaAjax(url,azione,nomeCampo,divDestinazione)
{
  //alert("sto caricando...");
  divDest=divDestinazione
  
  if(!btnClick)
    {
	      
		 btnClick=true;
		        
				url+="?param=" + document.getElementById(nomeCampo).options[document.getElementById(nomeCampo).selectedIndex].value + "&azione=" + azione
			
			// codice per Mozilla, etc.
			if (window.XMLHttpRequest)
			  {			  
			  xmlhttp=new XMLHttpRequest()
			  xmlhttp.onreadystatechange=xmlhttpChange
			  xmlhttp.open("GET",url,true)
			  xmlhttp.send(null)
			  }
			// codice per  IExplore
			else if (window.ActiveXObject)
			  {
			  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
				if (xmlhttp)
				{
				xmlhttp.onreadystatechange=xmlhttpChange
				xmlhttp.open("GET",url,true)
				xmlhttp.send()
				}
			  }
	}

}

function xmlhttpChange()
{
// if xmlhttp shows "loaded"

if (xmlhttp.readyState==1) 
 {
  // var htmlAttesa= "<img src=\"images/attesa_2.gif\"/> Attendere!! Operazione in corso";
   //document.getElementById(divDest).innerHTML=htmlAttesa;
  }
if (xmlhttp.readyState==4)
  {
  // if "OK"
  if (xmlhttp.status==200)
    {
	 btnClick=false;
     document.getElementById(divDest).innerHTML=xmlhttp.responseText;
    }
  else
    {
	  btnClick=false;
      document.getElementById(divDest).innerHTML="Impossibile ricevere i dati"
    }
  }
}

function checkCampiRicerca(nomeForm){
	var ok=true; 
	var valid = "0123456789"; // array di valori ammessi 
	
	if(nomeForm=="formCerca")
	{
		for (var i=0; i<document.formCerca.prezzoDa.value.length; i++) 
				{ 
				 temp = "" + document.formCerca.prezzoDa.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Il formato del valore del campo prezzo da è errato."); 
				 return false
			   } 
			   
		for (var i=0; i<document.formCerca.prezzoA.value.length; i++) 
				{ 
				 temp = "" + document.formCerca.prezzoA.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Il formato del valore del campo prezzo a è errato."); 
				 return false
			   }
			 
		 for (var i=0; i<document.formCerca.metriDa.value.length; i++) 
				{ 
				 temp = "" + document.formCerca.metriDa.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Il formato del valore del campo superfice da è errato."); 
				 return false
			   } 	
			   
		for (var i=0; i<document.formCerca.metriA.value.length; i++) 
				{ 
				 temp = "" + document.formCerca.metriA.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Il formato del valore del campo superfice a è errato."); 
				 return false
			   } 		   
	}
	else
	{
		for (var i=0; i<document.form_cerca.prezzoDa.value.length; i++) 
				{ 
				 temp = "" + document.form_cerca.prezzoDa.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Il formato del valore del campo prezzo da è errato."); 
				 return false
			   } 
			   
		for (var i=0; i<document.form_cerca.prezzoA.value.length; i++) 
				{ 
				 temp = "" + document.form_cerca.prezzoA.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Il formato del valore del campo prezzo a è errato."); 
				 return false
			   }
			 
		 for (var i=0; i<document.form_cerca.metriDa.value.length; i++) 
				{ 
				 temp = "" + document.form_cerca.metriDa.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Il formato del valore del campo superfice da è errato."); 
				 return false
			   } 	
			   
		for (var i=0; i<document.form_cerca.metriA.value.length; i++) 
				{ 
				 temp = "" + document.form_cerca.metriA.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Il formato del valore del campo superfice a è errato."); 
				 return false
			   } 
		
	}
	
	
	return true;
	
}

/* In inglese */

function checkCampiRicerca_eng(nomeForm){
	var ok=true; 
	var valid = "0123456789"; // array di valori ammessi 
	
	if(nomeForm=="formCerca")
	{
		for (var i=0; i<document.formCerca.prezzoDa.value.length; i++) 
				{ 
				 temp = "" + document.formCerca.prezzoDa.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Please insert a valid value for the price field."); 
				 return false
			   } 
			   
		for (var i=0; i<document.formCerca.prezzoA.value.length; i++) 
				{ 
				 temp = "" + document.formCerca.prezzoA.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Please insert a valid value for the initial price field."); 
				 return false
			   }
			 
		 for (var i=0; i<document.formCerca.metriDa.value.length; i++) 
				{ 
				 temp = "" + document.formCerca.metriDa.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Please insert a valid value for the dimension field."); 
				 return false
			   } 	
			   
		for (var i=0; i<document.formCerca.metriA.value.length; i++) 
				{ 
				 temp = "" + document.formCerca.metriA.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Please insert a valid value for the final dimension field."); 
				 return false
			   } 		   
	}
	else
	{
		for (var i=0; i<document.form_cerca.prezzoDa.value.length; i++) 
				{ 
				 temp = "" + document.form_cerca.prezzoDa.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Please insert a valid value for the initial price field."); 
				 return false
			   } 
			   
		for (var i=0; i<document.form_cerca.prezzoA.value.length; i++) 
				{ 
				 temp = "" + document.form_cerca.prezzoA.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Please insert a valid value for the final price field."); 
				 return false
			   }
			 
		 for (var i=0; i<document.form_cerca.metriDa.value.length; i++) 
				{ 
				 temp = "" + document.form_cerca.metriDa.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Please insert a valid value for the initial dimension field."); 
				 return false
			   } 	
			   
		for (var i=0; i<document.form_cerca.metriA.value.length; i++) 
				{ 
				 temp = "" + document.form_cerca.metriA.value.substring(i, i+1); 
				 if (valid.indexOf(temp) =="-1") ok = false;
				} 
			if (!ok) // alla presenza di caratteri non ammessi...
			   { 
				 alert("Please insert a valid value for the final dimension field."); 
				 return false
			   } 
		
	}
	
	
	return true;
	
}



// Fine AJAX
 

 
 
 

