$(function(){function lt(){s=et?window.pageYOffset:ot?document.documentElement.scrollTop:document.body.scrollTop;at()}function at(){v||requestAnimationFrame(vt);v=!0}function vt(){var t=s,r=window.innerHeight,e=(r-h-w-25)/r,f=(t-t*e)/1.4,n;v=!1;r-t<=it+w+5?c&&(c=!1,nt.removeClass("site-search__expanded"),ht.removeClass("in"),st.removeClass("site-search__by-code").addClass("site-search__by-geo"),isMobile.any&&u.css({top:""}),y.hide(),isMobile.any?g.addClass("mobile-navbar-fixed"):u.css({top:"","-moz-transform":"translate3d(0, 0, 0)","-webkit-transform":"translate3d(0, 0, 0)",transform:"translate3d(0, 0, 0)"})):(c||(c=!0,nt.addClass("site-search__expanded"),isMobile.any&&u.css({top:h+"px"}),y.show()),isMobile.any?g.removeClass("mobile-navbar-fixed"):(t<=20?n=1:(n=((r-t*2)/r).toFixed(2),n<0&&(n=.01)),y.css({opacity:n}),ct.css({opacity:n}),i&&i.length?i.css({opacity:n}):tt.css({opacity:n}),$.support.transition?u.css({"-moz-transform":"translate3d(0, -"+f+"px, 0)","-webkit-transform":"translate3d(0, -"+f+"px, 0)",transform:"translate3d(0, -"+f+"px, 0)"}):u.css({top:h-f+"px"})))}function rt(n){var i=$(".poll-option",n),t=$(".alert-danger",n);return i.filter(":checked").length==0?(t.html("Hola!, por favor responde con una de las opciones.").show(),!1):(t.empty().hide(),!0)}function yt(n){var t=encodeURIComponent("https://www.portalinmobiliario.com"+n);window.location=PI.config.meli.login.url+"&go="+t}var ut=function(n){if(!n.data("media-restored")){var t;n.find(".media-block-thumb img").each(function(n,i){i=$(i);t=i.data("src");t&&i.attr("src",t)});n.data("media-restored",!0)}},ft=function(n){if(!n.data("media-restored")){var t,i;n.find(".media-block-thumb img").each(function(n,r){r=$(r);i=r.closest(".media-block-img");t=r.data("src");t&&i.css("background-image","url("+t+")")});n.data("media-restored",!0)}},p,t,n,b,a,k,o,e,d;$("#btn-mas-urbes").on("click",function(){$(".popular-geo-item").each(function(n,t){$(t).css("display","block")});$(this).hide()});$(".featured-projs-slider").flexslider({animation:"slide",animationLoop:!1,controlNav:!1,directionNav:!0,slideshow:!1,before:ft});$(".featured-props-slider").flexslider({animation:"slide",animationLoop:!1,controlNav:!1,directionNav:!0,slideshow:!1,itemWidth:270,minItems:3,maxItems:3,before:ut});var et=window.pageXOffset!==undefined,ot=(document.compatMode||"")==="CSS1Compat",s=0,v=!1,g=$("html"),y=$(".slogan-container"),st=$(".site-search__container"),u=$(".site-search"),nt=$(".navbar-fixed-top"),tt=$(".scroll-helper"),i,ht=$(".site-search__block-code"),pt=$(".site-search__code-toggle"),wt=$(".site-search__geo-toggle"),ct=$(".site-search__type-toggler"),h=parseFloat(u.css("top"));isMobile.any&&(p=$(".hero-section"),u.css({top:h+"px"}),p.css({height:p.height()+"px"}));var it=68,w=54,c=!0;window.addEventListener&&window.addEventListener("scroll",lt,!1);window.scrollY&&window.scrollTo(0,window.scrollY-1);tt.on("click",function(){$("html, body").animate({scrollTop:window.innerHeight-it-w},250)});var f=$(".hero-unit"),l=f.length,r=!1;l>1?f.each(function(t,u){var e=$(u),o,h,v=e.find(".hero-project-pag-prev"),y=e.find(".hero-project-pag-next"),c,a;o=t+1===l?f.eq(0):f.eq(t+1);h=t===0?f.eq(l-1):f.eq(t-1);t>0?e.css({display:"block"}):(e.addClass("active"),i=e.find(".hero-project-data"));y.on("click",function(){if(r)return!1;if(s>0&&(i.css({opacity:1}),$("html, body").animate({scrollTop:0},250)),r=!0,e.css({"z-index":20}),i=o.find(".hero-project-data"),$.support.transition)o.addClass("active").one($.support.transition.end,function(){o.siblings().not(o).removeClass("active");e.css({"z-index":""});r=!1});else o.css({"z-index":30}).animate({opacity:1},400,function(){o.addClass("active").css({opacity:""}).siblings().not(o).removeClass("active");e.css({"z-index":"",opacity:0});r=!1});var u=$(".hero-section").data("sid"),f=i.data("pyimg"),t=i.data("idpp");ga&&ga("send",n,$("meta[name=friendly-title]").attr("content"),"Ver producto - "+t,"Producto interactivo Home");callService(interactivoService.RegistrarViewProyecto,JSON.stringify({idProductoProyecto:t,idProyectoImagen:f,sessionID:u}))});v.on("click",function(){if(r)return!1;if(s>0&&(i.css({opacity:1}),$("html, body").animate({scrollTop:0},250)),r=!0,e.css({"z-index":20}),i=h.find(".hero-project-data"),$.support.transition)h.addClass("active").one($.support.transition.end,function(){h.siblings().not(h).removeClass("active");e.css({"z-index":""});r=!1});else h.css({"z-index":30}).animate({opacity:1},400,function(){h.addClass("active").css({opacity:""}).siblings().not(h).removeClass("active");e.css({"z-index":"",opacity:0});r=!1});var u=$(".hero-section").data("sid"),f=i.data("pyimg"),t=i.data("idpp");ga&&ga("send",n,$("meta[name=friendly-title]").attr("content"),"Ver producto - "+t,"Producto interactivo Home");callService(interactivoService.RegistrarViewProyecto,JSON.stringify({idProductoProyecto:t,idProyectoImagen:f,sessionID:u}))});c=window.innerWidth;a="sm";c>=992&&c<1200?a="md":c>=1200&&(a="lg");setTimeout(function(){e.css({"background-image":"url("+e.data("srcset-"+a)+")"})},t*600)}):l===1&&(i=f.first().find(".hero-project-data"));$(".poll").on("submit",function(n){n.preventDefault();var t=$(this),i=$(".poll-option",t);i.off("change").on("change",function(){rt(t)});rt(t)&&t.get(0).submit()});t=$("meta[name=friendly-title]").attr("content");n="event";$(".scroll-helper").on("click",function(){ga("send",n,t,"Boton Scroll to content","Franja Superior")});$("#divProyectosDestacados").on("click",".flex-next",function(){ga("send",n,t,"Siguiente Proyecto","Franja Superior")}).on("click",".flex-prev",function(){ga("send",n,t,"Anterior Proyecto","Franja Superior")}).find(".media-block a").on("click",function(){ga("send",n,t,"Ver Proyecto Destacado - "+$(this).data("id"),"Franja Superior")});b="Login";$("#divProyectosDestacados .user-fav-toggle").bind("click",function(){if(PI.Login.isLoggedIn())$(this).hasClass("active")?ga("send",n,t,"Eliminar Favorito - Proyecto - "+$(this).data("pid")+" - Logueado - OK","Franja Superior"):ga("send",n,t,"Guardar Favorito - Proyecto - "+$(this).data("pid")+" - Logueado - OK","Franja Superior");else{b="Login";ga("send",n,t,"Guardar Favorito - Proyecto - "+$(this).data("pid")+" - Intento","Franja Superior");$("#modalLoginPi .close").one("click",function(){$("#modalLoginPi #divRegistroContainer").is(":visible")&&ga("send",n,t,"Guardar Favorito - Proyecto - "+$("#divProyectosDestacados .flex-active-slide .user-fav-toggle").data("pid")+" - Registro - Cerrar","Franja Superior")});$("#modalLoginPi #linkIngresarFacebook").one("click",function(){b="Login FB"})}});$("#divPropiedadesDestacadas").on("click",".flex-next",function(){ga("send",n,t,"Siguiente Propiedad","Franja Superior")}).on("click",".flex-prev",function(){ga("send",n,t,"Anterior Propiedad","Franja Superior")}).find(".media-block a").on("click",function(){ga("send",n,t,"Ver Propiedad Destacada - "+$(this).data("id"),"Franja Superior")});a="Login";$("#divPropiedadesDestacadas .user-fav-toggle").bind("click",function(){if(PI.Login.isLoggedIn())$(this).hasClass("active")?ga("send",n,t,"Eliminar Favorito - Propiedad - "+$(this).data("pid")+" - Logueado - OK","Franja Superior"):ga("send",n,t,"Guardar Favorito - Propiedad - "+$(this).data("pid")+" - Logueado - OK","Franja Superior");else{a="Login";ga("send",n,t,"Guardar Favorito - Propiedad - "+$(this).data("pid")+" - Intento","Franja Superior");$("#modalLoginPi .close").one("click",function(){$("#modalLoginPi #divRegistroContainer").is(":visible")&&ga("send",n,t,"Guardar Favorito - Propiedad - "+$("#divPropiedadesDestacadas .user-fav-toggle").data("pid")+" - Registro - Cerrar","Franja Superior")});$("#modalLoginPi #linkIngresarFacebook").one("click",function(){a="Login FB"})}});k="#divPropiedadesDestacadas .user-fav-toggle";PI.Login.bind(k,"user.login",function(){ga("send",n,t,"Guardar Favorito - Propiedad - "+$(this).data("pid")+" - "+a+" - OK","Franja Superior")});PI.Login.bind(k,"user.register",function(){ga("send",n,t,"Guardar Favorito - Propiedad - "+$(this).data("pid")+" - Registro - OK","Franja Superior")});o=$(".hero-project-data");o.length&&ga("send",n,t,"Ver producto - "+o.data("idpp"),"Producto interactivo Home");o.find(".hero-project-title a").on("click",function(){ga("send",n,t,"Ver proyecto - "+$(this).closest(".hero-project-data").data("idpp"),"Producto interactivo Home")});o.find(".hero-project-cotizar").on("click",function(){ga("send",n,t,"Ver cotizar proyecto - "+$(this).closest(".hero-project-data").data("idpp"),"Producto interactivo Home")});$("#divBannerFranjaSuperior a").bind("click",function(){ga("send",n,t,"Banner ","Franja Superior")});$("#divPromociones a").bind("click",function(){ga("send",n,t,"Ver PYL - "+$(this).data("id"),"Contenido Principal")});$(".poll-answers :radio").bind("click",function(){ga("send",n,t,"Respuesta Encuesta - "+$("#EncuestaID").val(),"Encuesta")});$(".poll-vote").bind("click",function(){ga("send",n,t,"Boton Responder - "+$("#EncuestaID").val(),"Encuesta")});$(".popular-geo-content a").on("click",function(){ga("send",n,t,"Ver urbes - "+$(this).text(),"Contenedor SEO")});$(".popular-searches-list a").on("click",function(){ga("send",n,t,"Ver búsquedas populares - "+$(this).text(),"Contenedor SEO")});$(".popular-props-types a").on("click",function(){ga("send",n,t,"Ver tipos destacados - "+$(this).text(),"Contenedor SEO")});$(".news-list-item-featured a").bind("click",function(){ga("send",n,t,"Ver Especial - "+($(this).closest(".col-md-6").index()+1),"Contenido Principal")});$(".news-list-item-normal a").bind("click",function(){ga("send",n,t,"Ver Especial - "+($(this).closest(".col-md-6").index()+1),"Contenido Principal")});$("#linkMasNoticias").bind("click",function(){ga("send",n,t,"Ver Todas las Noticias","Carrusel Noticias")});window.location.href.indexOf("lg=1&r")>0?(d=window.location.href.toString(),e=decodeURIComponent(d.substr(d.indexOf("&")+3))):window.location.href.indexOf("lg=1")>0&&(e="/MiPortal/MiPortal.aspx");e&&(PI.Login.isLoggedIn()?window.location=e:window.location.href.indexOf("lg=1&ar=0")>0?PI.Login.show("invalidResetToken"):window.location.href.indexOf("lg=1&ar=1")>0?PI.Login.show("resetPassword"):PI.Login.meliAuth.FlowStatus("login")?yt(e):(PI.Login.setOption("login",{redirect:e}),PI.Login.show()))})