function creaAjax(){
  var objetoAjax=false;
  try {
   /*Para navegadores distintos a internet explorer*/
   objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
     /*Para explorer*/
     objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
     } 
     catch (E) {
     objetoAjax = false;
   }
  }

  if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
   objetoAjax = new XMLHttpRequest();
  }
  return objetoAjax;
}

function carregadret(idMunicipio){ 
	var ajax=creaAjax();
	
	//document.getElementById = el nombre del <div> que se va refrescar 	
	var capaContenedora = document.getElementById("zona");
	ajax.open ('post',"busquedaNueva_ajax.php",true);

    ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                 capaContenedora.innerHTML="Cargando.......";
         }
         else if (ajax.readyState==4){
            if(ajax.status==200)
            {
                 capaContenedora.innerHTML=ajax.responseText; 
            }
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("idMunicipio="+idMunicipio);
	return
}

function cargarZonas(idMunicipio,op){ //** esta funcion puede ir a "busqueda2_ajax.php" y me crearia una lista en vez de checkbox-es"
	var ajax=creaAjax();
	if (op == 1){
	    if( idMunicipio == -1 )
	    {
	       hide('veure_mes');
	     }else{
	       show2('veure_mes');
	     }
		}
	//document.getElementById = el nombre del <div> que se va refrescar 	
	var capaContenedora = document.getElementById("barrios");
	ajax.open ('post',"busqueda3_ajax.php",true);

    ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                 capaContenedora.innerHTML="Cargando.......";
         }
         else if (ajax.readyState==4){
            if(ajax.status==200)
            {
                 capaContenedora.innerHTML=ajax.responseText; 
            }
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("idMunicipio="+idMunicipio);
	return
}



function cargarFoto(foto2){
	var ajax=creaAjax();
	
	//document.getElementById = el nombre del <div> que se va refrescar 	
	var capaContenedora = document.getElementById("foto");
	ajax.open ('post',"verInmueble2_ajax.php",true);

    ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                 capaContenedora.innerHTML="Cargando.......";
         }
         else if (ajax.readyState==4){
            if(ajax.status==200)
            {
                 capaContenedora.innerHTML=ajax.responseText; 
            }
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("foto2="+foto2);
	return
}


function habOperacion(x){
	
	var ajax=creaAjax();
	
	//document.getElementById = el nombre del <div> que se va refrescar 	
	var capaContenedora = document.getElementById("preu");
	ajax.open ('post',"http://www.fincascatalanas.com/busqueda_operacion.php",true);

    ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                 capaContenedora.innerHTML="Cargando.......";
         }
         else if (ajax.readyState==4){
            if(ajax.status==200)
            {
                 capaContenedora.innerHTML=ajax.responseText; 
            }
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	//alert(x);
	ajax.send("x="+x);
	return
}



