function cargaBanner(){separador="_";posicion="trp";switch(parseInt(operacion)){case 1:sPosicion="";break;case 2:sPosicion="al";break;case 4:sPosicion="on";break;default:sPosicion="";break}ubicacion=posicion+sPosicion.substring(0,sPosicion.length-1)+separador+provincia;if(area!=undefined&&area!=0){ubicacion="tra"+sPosicion+separador+area}if(subarea!=undefined&&subarea!=0){ubicacion="sa"+sPosicion+separador+subarea}if(distrito!=undefined&&distrito!=0){ubicacion="trd"+sPosicion.substring(0,sPosicion.length-1)+separador+distrito}if(barrio!=undefined&&barrio!=0){ubicacion="b"+sPosicion.substring(0,sPosicion.length-1)+separador+barrio}if(municipio!=undefined&&municipio!=0){ubicacion="muni"+sPosicion+separador+municipio}if(ubicacionDefBanner!=""){ubicacion=ubicacionDefBanner}$.ajax({type:"POST",dataType:"json",url:"/ajax/busqueda/getBanner.php",data:"ubicacion="+ubicacion,success:function(A){if(A.error==0){$("#cabeceraBanner").html("<h2>publicidad</h2>"+A.datos.codigo)}else{$("#cabeceraBanner").html("")}}})}function construyeCookie(){$.cookie("ultListHash",dameHash(0),{expires:1,path:"/",domain:dominio,secure:false});$.cookie("ultList",thisUrl,{expires:1,path:"/",domain:dominio,secure:false})}function inicializaVistaMapa(){htmlListado=$("#divListado").html();if(datosMapa==null){$.ajax({type:"POST",dataType:"json",url:"/ajax/busqueda/getMarkers.php",data:"latitud="+lat+"&longitud="+lng+"&operacion="+operacion+"&radio="+radio+"&vp="+vp+"&provincia="+provincia+"&precioMax="+precioMax+"&precioMin="+precioMin+"&area="+area+"&subarea="+subarea+"&municipio="+municipio+"&distrito="+distrito+"&barrio="+barrio+"&tamanioMax="+tamanioMax+"&tamanioMin="+tamanioMin+"&dormitoriosMax="+dormitoriosMax+"&dormitoriosMin="+dormitoriosMin+"&tipoInmueble="+tipoInmueble+"&baniosMax="+baniosMax+"&baniosMin="+baniosMin+"&antiguedadMax="+antiguedadMax+"&antiguedadMin="+antiguedadMin+"&estado="+estado+"&exterior="+exterior+"&ascensor="+ascensor+"&garaje="+garaje+"&terraza="+terraza+"&piscina="+piscina+"&accesible="+accesible+"&orden="+orden+"&tipoOrden="+tipoOrden+"&pagina="+pagina+"&txtLibre="+txtLibre+"&telefono="+telefono+"&id_empresa="+id_empresa,beforeSend:function(A){$.blockUI(mensajeCargando)},success:function(A){if(A.error==0){insertaMapa(A)}else{htmlListado=null;$("#btnVerList").trigger("click")}$.unblockUI()},error:function(C,B,A){$.unblockUI()}})}else{insertaMapa(datosMapa)}}function insertaMapa(D){$("#divListado").html('<div id="mapa" style="height:615px; width:100%;"></div>');if(GBrowserIsCompatible()){map=new GMap2(document.getElementById("mapa"));map.setCenter(new GLatLng(D.centro.latitud,D.centro.longitud),D.zoom);var A=new GMapTypeControl();var C=new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(10,10));var B=new GControlPosition(G_ANCHOR_BOTTOM_RIGHT,new GSize(10,10));map.enableContinuousZoom();map.addControl(new GScaleControl());agregarFalda(map);agregarControlZoom(map);agregarControlTipoMapa(map);var E=addOptionsToIcon(new GIcon(G_DEFAULT_ICON),{iconSize:new GSize(20,34),iconAnchor:new GPoint(10,29),image:"/recursos/imgs/marcaVerde.png"});for(i=0;i<D.datos.length;i++){point=new GLatLng(D.datos[i].latitud,D.datos[i].longitud);marker=creaMarker(point,E,D.datos[i]);map.addOverlay(marker)}}if(datosMapa==null){datosMapa=D}}function creaMarker(A,E,C){precioHtml=(C.precio!=false&&C.precio!="")?"<br/>Precio desde: "+C.precio+" &euro;":"";var B='<div style="width:420px; ">';B+='			<table cellspacing="0" cellpadding="0" style=" border:0px; margin:0px;" class="tablamapa">';B+="				<tr>";B+='					<td class="foto_promo"><a href="'+C.ficha+'" ><img src="'+C.imgPresentacion+'" width=150 height=100 /></a></td>';B+='					<td class="info_promo"><strong style="text-transform:uppercase;"><a href="'+C.ficha+'" >'+C.nompromo+"</a></strong><br/>"+C.zona+precioHtml+"</td>";B+='					<td class="logo_promo" align="center"><img class="logo" src="'+C.logo+'"  /></td>';B+="				</tr>";B+="			</table>";B+="</div>";var D=new GMarker(A,E);GEvent.addListener(D,"click",function(){D.openInfoWindowHtml(B)});return D}function addOptionsToIcon(C,B){for(var A in B){C[A]=B[A]}return C}function destruyeMapa(){$("#divListado").html(htmlListado);htmlListado=null}function construyeFiltros(A){hash=dameHash(A);construyeCookie();$.ajaxHistory.update(hash);document.location.href=hash}function dameHash(A){if(A!=0){pagina=1}tipoInmueble="";jQuery.each($(".checkTipoInmo"),function(B,C){tipoInmueble+=(this.checked)?(this.value+";"):""});filtroAvanzado="";jQuery.each($(".chkAvanzado:checked"),function(B,C){filtroAvanzado+=this.value+";"});dormitoriosMin=$("#dormitorios").val();if(typeof (dormitoriosMin)=="undefined"){dormitoriosMin=0}baniosMin=$("#banios").val();if(typeof (baniosMin)=="undefined"){baniosMin=0}hash="#p;"+precioMin+";"+precioMax+"-t;"+tamanioMin+";"+tamanioMax+"-d;"+dormitoriosMin+";"+dormitoriosMax+"-v;"+tipoInmueble+"-b;"+baniosMin+";"+baniosMax+"-o;"+orden+"-z;"+tipoOrden+"-x;"+pagina+"-f;"+filtroAvanzado+"-s;"+txtLibre;return hash}function ordename(A){if(orden==A){tipoOrden=(tipoOrden==1)?0:1}else{tipoOrden=0}pintaOrden(A,tipoOrden);orden=A;construyeFiltros(1)}function pintaOrden(A,B){$("#imgOrden"+orden).html("");if(B==0){$("#imgOrden"+A).html(flechitaAsc)}else{$("#imgOrden"+A).html(flechitaDesc)}}function paginado(A){pagina=A;construyeFiltros(0)}function filtrame(){if(tipoInmueble==","){tipoInmueble=tipoInmuebleIni}$.ajax({type:"POST",dataType:"json",url:"/ajax/busqueda/getListado.php",data:"latitud="+lat+"&longitud="+lng+"&operacion="+operacion+"&ofertas="+ofertas+"&radio="+radio+"&vp="+vp+"&provincia="+provincia+"&precioMax="+precioMax+"&precioMin="+precioMin+"&area="+area+"&subarea="+subarea+"&municipio="+municipio+"&distrito="+distrito+"&barrio="+barrio+"&tamanioMax="+tamanioMax+"&tamanioMin="+tamanioMin+"&dormitoriosMax="+dormitoriosMax+"&dormitoriosMin="+dormitoriosMin+"&tipoInmueble="+tipoInmueble+"&baniosMax="+baniosMax+"&baniosMin="+baniosMin+"&antiguedadMax="+antiguedadMax+"&antiguedadMin="+antiguedadMin+"&estado="+estado+"&exterior="+exterior+"&ascensor="+ascensor+"&garaje="+garaje+"&terraza="+terraza+"&piscina="+piscina+"&accesible="+accesible+"&orden="+orden+"&tipoOrden="+tipoOrden+"&pagina="+pagina+"&txtLibre="+txtLibre+"&telefono="+telefono+"&id_empresa="+id_empresa,beforeSend:function(A){$.blockUI(mensajeCargando)},success:function(A){if(A.error==0){$("#items").html(A.datos.html);$("#paginado").html(A.datos.paginado);$("#numResultados").html("("+A.datos.resultados+")");$("#precioMedio").html(A.datos.precioMedio+" &#8364;");$("#precioMedioInf").html(A.datos.precioMedio+" &#8364;");$("#precioMetros").html(A.datos.precioMetros+" &#8364;/m&sup2;");$("#precioMetrosInf").html(A.datos.precioMetros+" &#8364;/m&sup2;");mapas=[];escuchaTRs();GUnload()}else{alert(A.error)}$.unblockUI();cargaFooter()}})}function dameInfoFila(D,E,B,C){if($("#infoInmueble_"+D).is(":hidden")){$("#enlacePreview_"+D).removeClass("active")}else{$("#enlacePreview_"+D).addClass("active")}if($("#mapa_"+D).css("display")!="none"&&$.browser.msie){$("#mapa_"+D+"").hide()}$("#infoInmueble_"+D).slideToggle(1000,function(){if($("#mapa_"+D).css("display")=="none"&&$.browser.msie){$("#mapa_"+D+"").show()}});if(jQuery.inArray(D,mapas)==-1){mapas.push(D);map=new GMap2(document.getElementById("mapa_"+D));map.enableScrollWheelZoom();map.enableContinuousZoom();map.setCenter(new GLatLng(E,B),15);$.each($("#infoInmueble_"+D+" > ul > li > div > a > img"),function(F,G){G.src=G.title;G.title="Foto del Inmueble"});if(C==1){var A=new GLatLng(E,B);map.addOverlay(new GMarker(A))}}else{}}function muestraAvanzados(){if($("#filtrosAvanzados").is(":hidden")){$("#enlaceFiltrosAvanzados").removeClass("active")}else{$("#enlaceFiltrosAvanzados").addClass("active")}$("#filtrosAvanzados").slideToggle("normal")}function marcaChkAvz(A){if(isNaN(A)){return }jQuery.each($(".chkAvanzado"),function(B,C){if(this.value==A){this.checked=true}})}function marcaChkTipoViv(A){jQuery.each($(".checkTipoInmo"),function(B,C){if(this.value==A){this.checked=true}})}function comparaInmuebles(){ids="";cont=0;jQuery.each($(".chkComparacion:checked"),function(A,B){ids+="&id[]="+this.value;cont++});if(cont<2){alert("Selecciona al menos dos inmuebles para compararlos entre si")}else{if(cont>6){alert("No puede seleccionar mas de 6 inmuebles a comparar")}else{window.document.location="/busca/compara.php?"+ids+"&"+window.location.search.substring(1)}}}function btnBusca(){txtLibre=$("#txtBusca").attr("value");if(typeof txtLibre=="undefined"){txtLibre=""}construyeFiltros(1)}function escuchaTRs(){return ;$("tr").bind("mouseenter",function(){if($(":first-child",this).is("th")){return }miclase=$("td:first",this).attr("class");if(typeof (miclase)=="undefined"){coloreaBorde(this)}else{if(miclase.indexOf("preview")==-1){coloreaBorde(this)}}}).bind("mouseleave",function(){deColoreaBorde(this)})}function coloreaBorde(A){jQuery.each($(A).children(),function(B,C){if(B==0){$(C).addClass("filaPadrePrimeroArriba")}else{if(B==9){$(C).addClass("filaPadreUltimoArriba")}else{$(C).addClass("filaPadre")}}})}function deColoreaBorde(A){jQuery.each($(A).children(),function(B,C){clase=$(C).attr("class");if(typeof (clase)!="undefined"){posicion=clase.indexOf("filaPadre");if(posicion!=-1){valor=clase.substring(posicion,clase.length);$(C).removeClass(valor)}}})}var zoomMax=16;var zoomMin=5;function agregarControlZoom(C,A){if(A!=undefined){zoomMin=zoomMax-A}function B(){}B.prototype=new GControl();B.prototype.initialize=function(D){var E=document.createElement("div");var L=document.createElement("div");E.appendChild(L);var K=document.createElement("img");K.setAttribute("src","/recursos/imgs/zoom_out.gif");K.setAttribute("style","cursor: pointer; float: left;");K.style.border="none";K.style.marginTop=0;K.style.paddingTop=0;L.appendChild(K);L.style.cursor="pointer";L.style.display="inline";GEvent.addDomListener(L,"click",function(){if(D.getZoom()>zoomMin){D.zoomOut();repintarZooms(D)}});var H=new Array();var I=new Array();for(i=zoomMin;i<zoomMax;i++){H[i]=document.createElement("div");var G="";if(D.getZoom()>=i){G="#52CE31"}else{G="#FFFFFF"}H[i].setAttribute("style","cursor: pointer; float: left; margin-left: 3px; width: 3px; height: 20px; background-color: "+G);H[i].setAttribute("id","z"+i);H[i].style.cursor="pointer";H[i].style.display="inline";H[i].style.marginLeft=3;H[i].style.border="none";H[i].style.backgroundColor=G;I[i]=document.createElement("img");I[i].setAttribute("src","/recursos/imgs/spacer.gif");I[i].style.width=3;I[i].style.height=16;I[i].style.border="none";I[i].style.padding=0;I[i].style.margin=0;H[i].appendChild(I[i]);E.appendChild(H[i]);GEvent.addDomListener(H[i],"click",function(){var M=parseInt(this.id.substr(1));D.setZoom(M);repintarZooms(D)})}var J=document.createElement("div");E.appendChild(J);var F=document.createElement("img");F.setAttribute("src","/recursos/imgs/zoom_in.gif");F.setAttribute("style","cursor:pointer; float:left;");F.style.border="none";F.style.marginTop="0px";F.style.padding="0px";F.style.marginLeft="4px";J.appendChild(F);J.style.cursor="pointer";J.style.display="inline";GEvent.addDomListener(J,"click",function(){if(D.getZoom()<zoomMax-1){D.zoomIn();repintarZooms(D)}});D.getContainer().appendChild(E);return E};B.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(8,6))};C.addControl(new B())}function agregarFalda(B){function A(){}A.prototype=new GControl();A.prototype.initialize=function(D){var C=document.createElement("div");C.setAttribute("style","background-color: #000000; width: 100%; height: 35px; opacity: 0.5");C.style.backgroundColor="#000000";C.style.filter="alpha(opacity=50)";C.style.width="100%";C.style.height=35;D.getContainer().appendChild(C);return C};A.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(0,0))};B.addControl(new A())}function agregarControlTipoMapa(B){function A(){}A.prototype=new GControl();A.prototype.initialize=function(C){var F="mapa";var G="satélite";var I="híbrido";var D=document.createElement("div");var J=" color: #000000; cursor: pointer;   float: left; ";J+="font-family:Arial, Helvetica, sans-serif; font-size: 12px; text-align: center; margin-left: 0px; vertical-align: center;";var E=document.createElement("input");E.setAttribute("style",J+" color: #000000;");E.setAttribute("id","bMap");E.style.backgroundColor="#ffffff";E.style.cursor="pointer";E.style.fontFamily="Arial, Helvetica, sans-serif";E.style.fontSize=12;E.style.textAlign="center";E.style.marginLeft=0;E.style.fontWeight="bold";E.style.display="inline";E.type="button";E.value=F;E.style.border="1px solid #000";D.appendChild(E);GEvent.addDomListener(E,"click",function(){C.setMapType(G_NORMAL_MAP);repintarTypes(C)});var K=document.createElement("input");K.setAttribute("style",J);K.setAttribute("id","bSat");K.style.backgroundColor="#ffffff";K.style.cursor="pointer";K.style.fontFamily="Arial, Helvetica, sans-serif";K.style.fontSize=11;K.style.textAlign="center";K.style.marginLeft=0;K.style.display="inline";K.type="button";K.value=G;K.style.border="1px solid #000";D.appendChild(K);GEvent.addDomListener(K,"click",function(){C.setMapType(G_SATELLITE_MAP);repintarTypes(C)});var H=document.createElement("input");H.setAttribute("style",J);H.setAttribute("id","bHib");H.style.backgroundColor="#ffffff";H.style.cursor="pointer";H.style.fontFamily="Arial, Helvetica, sans-serif";H.style.fontSize=11;H.style.textAlign="center";H.style.marginLeft=0;H.style.display="inline";H.type="button";H.value=I;H.style.border="1px solid #000";D.appendChild(H);GEvent.addDomListener(H,"click",function(){C.setMapType(G_HYBRID_MAP);repintarTypes(C)});C.getContainer().appendChild(D);return D};A.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(8,8))};B.addControl(new A())}function repintarZooms(B){for(i=zoomMin;i<zoomMax;i++){var A=document.getElementById("z"+i);if(B.getZoom()>=i){document.getElementById("z"+i).style.backgroundColor="#52CE31"}else{document.getElementById("z"+i).style.backgroundColor="#ffffff"}}}function repintarTypes(B){document.getElementById("bMap").style.fontWeight="normal";document.getElementById("bSat").style.fontWeight="normal";document.getElementById("bHib").style.fontWeight="normal";var A=B.getCurrentMapType();switch(A){case G_NORMAL_MAP:document.getElementById("bMap").style.fontWeight="bold";break;case G_SATELLITE_MAP:document.getElementById("bSat").style.fontWeight="bold";break;case G_HYBRID_MAP:document.getElementById("bHib").style.fontWeight="bold";break}}function debug(A){if(typeof (console)!="undefined"){console.info(A)}};