text: var ERE_Property_Map_Search=ERE_Property_Map_Search||{};(function(z){"use strict";var B=ere_search_vars.ajax_url;var a=ere_search_vars.price_is_slider;var H=".ere-search-properties-map";var q,A=[];var D=false;var N=true;var Z;if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){N=false;D=true}ERE_Property_Map_Search={init:function(){var e=ere_search_vars.enable_filter_location;if(e=="1"){z(".ere-property-country-ajax",H).select2();z(".ere-property-state-ajax",H).select2();z(".ere-property-city-ajax",H).select2();z(".ere-property-neighborhood-ajax",H).select2()}this.full_screen();this.get_states_by_country();z(".ere-property-country-ajax",H).on("change",function(){ERE_Property_Map_Search.get_states_by_country()});this.get_cities_by_state();z(".ere-property-state-ajax",H).on("change",function(){ERE_Property_Map_Search.get_cities_by_state()});this.get_neighborhoods_by_city();z(".ere-property-city-ajax",H).on("change",function(){ERE_Property_Map_Search.get_neighborhoods_by_city()});z(".btn-status-filter",H).on("click",function(e){e.preventDefault();var a=z(this).data("value");z(this).parent().find("input").val(a);z(this).parent().find("button").removeClass("active");z(this).addClass("active");ERE_Property_Map_Search.change_price_on_status_change(a)});z('select[name="status"]',H).on("change",function(e){e.preventDefault();var a=z(this).val();ERE_Property_Map_Search.change_price_on_status_change(a)});this.execute_url_search();z(".ere-sliderbar-filter.ere-sliderbar-price",H).on("register.again",function(){z(".ere-sliderbar-filter.ere-sliderbar-price",H).each(function(){var e=z(this);ERE_Property_Map_Search.set_slider_filter(e)})});this.register_slider_filter();this.set_slider_value();z(".other-features-wrap .btn-other-features",H).on("click",function(e){e.preventDefault();z(".other-features-list",H).slideToggle();z(this).toggleClass("show");if(z(this).hasClass("show")==true){z('input[name="features-search"]',H).attr("value","1");z(this).find("i").removeClass("fa-chevron-down");z(this).find("i").addClass("fa-chevron-up")}else{z('input[name="features-search"]',H).attr("value","0");z(this).find("i").removeClass("fa-chevron-up");z(this).find("i").addClass("fa-chevron-down")}ERE_Property_Map_Search.search_on_change()});z(".ere-sliderbar-filter.ere-sliderbar-price",H).on("register.again",function(){z(".ere-sliderbar-filter.ere-sliderbar-price",H).each(function(){var e=z(this);ERE_Property_Map_Search.set_slider_filter(e)})});z(".ere-search-status-tab .btn-status-filter",H).on("click",function(){z(this).parent().find("input").val(z(this).data("value"));z(this).parent().find("button").removeClass("active");z(this).addClass("active")});z('select[name="type"], select[name="bedrooms"],select[name="bathrooms"] , '+'select[name="garage"], select[name="label"],input[name="address"],input[name="title"],input[name="property_identity"], '+'select[name="min-price"], select[name="max-price"],select[name="min-area"], select[name="max-area"],select[name="min-land-area"], select[name="min-land-area"], '+'select[name="city"], select[name="country"], select[name="state"], select[name="neighborhood"]',H).on("change",function(){ERE_Property_Map_Search.search_on_change()});z('input[name="other_features"]',H).on("change",function(){ERE_Property_Map_Search.search_on_change()});ERE_Property_Map_Search.search_properties("map_only")},get_states_by_country:function(){var e=z(".ere-property-country-ajax",H);if(e.length){var a=e.val();z.ajax({type:"POST",url:B,data:{action:"ere_get_states_by_country_ajax",country:a,type:1,is_slug:"1"},success:function(e){z(".ere-property-state-ajax",H).html(e);var a=z(".ere-property-state-ajax",H).attr("data-selected");if(typeof a!=="undefined"){z(".ere-property-state-ajax",H).val(a)}}})}},get_cities_by_state:function(){var e=z(".ere-property-state-ajax",H);if(e.length){var a=e.val();z.ajax({type:"POST",url:B,data:{action:"ere_get_cities_by_state_ajax",state:a,type:1},success:function(e){z(".ere-property-city-ajax",H).html(e);var a=z(".ere-property-city-ajax",H).attr("data-selected");if(typeof a!=="undefined"){z(".ere-property-city-ajax",H).val(a)}}})}},get_neighborhoods_by_city:function(){var e=z(".ere-property-city-ajax",H);if(e.length){var a=e.val();z.ajax({type:"POST",url:B,data:{action:"ere_get_neighborhoods_by_city_ajax",city:a,type:1,is_slug:"1"},success:function(e){z(".ere-property-neighborhood-ajax",H).html(e);var a=z(".ere-property-neighborhood-ajax",H).attr("data-selected");if(typeof a!=="undefined"){z(".ere-property-neighborhood-ajax",H).val(a)}}})}},execute_url_search:function(){z(".ere-advanced-search-btn",H).on("click",function(e){e.preventDefault();var a=z(this).closest(".search-properties-form"),t=a.data("href"),o=[],r="?";if(t.indexOf("?")!==-1){r="&"}z(".search-field",a).each(function(){var e=z(this),a=e.attr("name"),t=e.val(),r=e.data("default-value");if(t!=r){o[a]=t}});z(".ere-sliderbar-filter",a).each(function(){var e=z(this),a=e.find(".min-input-request").attr("name"),t=e.find(".max-input-request").attr("name"),r=e.find(".min-input-request").val(),i=e.find(".max-input-request").val(),n=e.data("min-default"),s=e.data("max-default");if(r!=n||i!=s){o[a]=r;o[t]=i}});if(typeof o["features-search"]!="undefined"){var i="";z('[name="other_features"]',a).each(function(){var e=z(this),a=e.attr("value");if(e.is(":checked")){i+=a+";"}});if(i!==""){i=i.substring("0",i.length-1);o["other_features"]=i}}if(o!==[]){for(var n in o){if(o.hasOwnProperty(n)){r+=n+"="+o[n]+"&"}}}r=r.substring("0",r.length-1);window.location.href=t+r})},set_slider_filter:function(e){var t=e,a=parseInt(t.attr("data-min-default")),r=parseInt(t.attr("data-max-default")),i=t.attr("data-min"),n=t.attr("data-max"),s=t.find(".sidebar-filter"),o,l;s.slider({min:a,max:r,range:true,values:[i,n],slide:function(e,a){o=a.values[0];l=a.values[1];t.attr("data-min",o);t.attr("data-max",l);t.find("input.min-input-request").attr("value",o);t.find("input.max-input-request").attr("value",l);if(t.find("span").hasClass("not-format")){t.find("span.min-value").html(o);t.find("span.max-value").html(l)}else{t.find("span.min-value:not(.not-format)").html(ERE.number_format(o));t.find("span.max-value:not(.not-format)").html(ERE.number_format(l))}},stop:function(e,a){ERE_Property_Map_Search.search_on_change()}})},register_slider_filter:function(){z(".ere-sliderbar-filter",H).each(function(){var e=z(this);ERE_Property_Map_Search.set_slider_filter(e)})},set_slider_value:function(){z(".ere-sliderbar-filter",H).each(function(){var e=z(this),a=e.attr("data-min-default"),t=e.attr("data-max-default"),r=e.attr("data-min"),i=e.attr("data-max"),n=(r-a)/(t-a)*100+"%",s=(i-r)/(t-a)*100+"%",o=(i-a)/(t-a)*100+"%";e.find(".ui-slider-range.ui-corner-all.ui-widget-header").css({left:n,width:s});e.find(".ui-slider-handle.ui-corner-all.ui-state-default").css("left",n);e.find(".ui-slider-handle.ui-corner-all.ui-state-default:last-child").css("left",o)})},change_price_on_status_change:function(e){z.ajax({type:"POST",url:B,dataType:"json",data:{action:"ere_ajax_change_price_on_status_change",status:e,price_is_slider:a},success:function(e){if(e.slide_html){z(".ere-sliderbar-price-wrap",H).html(e.slide_html);ERE_Property_Map_Search.register_slider_filter();ERE_Property_Map_Search.set_slider_value()}else{if(e.min_price_html){z('select[name="min-price"]',H).html(e.min_price_html)}if(e.max_price_html){z('select[name="max-price"]',H).html(e.max_price_html)}}ERE_Property_Map_Search.search_on_change()}})},full_screen:function(){if(z(".ere-search-properties-map.style-vertical").length>0){var e=z(window).outerHeight(),a=z("#wpadminbar").outerHeight();if(a==null){a=0}var t=z("header").outerHeight(),r=z("footer").outerHeight(),i=z(".wpadminbar").outerHeight(),n=e-a-t-r-i;z(".ere-search-properties-map.style-vertical .ere-map-search").css("height",n);z(".ere-search-properties-map.style-vertical .ere-map-search .ere-map-result").css("height",n);z(".col-scroll-vertical").css({height:n,"overflow-y":"scroll","overflow-x":"hidden"});var s=z(".owl-carousel",".list-property-result-ajax"),o=z(".property-item",s);s.trigger("destroy.owl.carousel");s.css("opacity",1);s.imagesLoaded(function(){ERE.set_item_effect(o,"hide");ERE_Carousel.owlCarousel();o=z(".property-item",s);ERE.set_item_effect(o,"show")})}},search_on_change:function(){var e="map_only";if(z(".list-property-result-ajax",H).length>0){e="map_and_content"}ERE_Property_Map_Search.search_properties(e)},search_properties:function(c){var e,a,t,r,i,n,s,o,l,p,d,f,u,_,h,m,g,v,y,b,x,E;var w=z(H);i=w.find('input[name="title"]').val();h=w.find('input[name="address"]').val();a=w.find('select[name="city"]').val();o=w.find('select[name="type"]').val();s=w.find('select[name="status"]').val();if(s==undefined){s=w.find('input[name="status"]').val()}l=w.find('select[name="bedrooms"]').val();p=w.find('select[name="bathrooms"]').val();if(z(".ere-sliderbar-price",w).length){d=w.find(".ere-sliderbar-filter.ere-sliderbar-price").attr("data-min");f=w.find(".ere-sliderbar-filter.ere-sliderbar-price").attr("data-max")}else{d=w.find('select[name="min-price"]').val();f=w.find('select[name="max-price"]').val()}if(z(".ere-sliderbar-area",w).length){u=w.find(".ere-sliderbar-filter.ere-sliderbar-area").attr("data-min");_=w.find(".ere-sliderbar-filter.ere-sliderbar-area").attr("data-max")}else{u=w.find('select[name="min-area"]').val();_=w.find('select[name="max-area"]').val()}if(z(".ere-sliderbar-land-area",w).length){y=w.find(".ere-sliderbar-filter.ere-sliderbar-land-area").attr("data-min");b=w.find(".ere-sliderbar-filter.ere-sliderbar-land-area").attr("data-max")}else{y=w.find('select[name="min-land-area"]').val();b=w.find('select[name="max-land-area"]').val()}t=w.find('select[name="state"]').val();e=w.find('select[name="country"]').val();r=w.find('select[name="neighborhood"]').val();v=w.find('select[name="label"]').val();m=w.find('select[name="garage"]').val();x=w.find('input[name="property_identity"]').val();E=w.find('input[name="features-search"]').val();if(E=="1"){g="";w.find(".other-features-list input[type=checkbox]:checked").each(function(){g+=z(this).val()+";"});if(g!=""){g=g.substring(0,g.length-1)}}var P=z("#ere_security_search_map").val();var R=z(w).find(".ere-map-result").attr("id");var j=z("#"+R);var S=null,M=ere_search_vars.googlemap_default_zoom,C=ere_search_vars.not_found,k=ere_search_vars.clusterIcon,L=ere_search_vars.google_map_style,O=ere_search_vars.pin_cluster_enable;var T={zoomControlOptions:{position:google.maps.ControlPosition.RIGHT_CENTER},scrollwheel:false,scroll:{x:z(window).scrollLeft(),y:z(window).scrollTop()},zoom:parseInt(M),mapTypeId:google.maps.MapTypeId.ROADMAP,draggable:N,fullscreenControl:true,fullscreenControlOptions:{position:google.maps.ControlPosition.RIGHT_CENTER}};Z=new InfoBox({disableAutoPan:true,maxWidth:310,alignBottom:true,pixelOffset:new google.maps.Size(-140,-55),zIndex:null,closeBoxMargin:"0 0 -16px -16px",infoBoxClearance:new google.maps.Size(1,1),isHidden:false,pane:"floatPane",enableEventPropagation:false});var I=function(e,p){z.each(e,function(e,a){var t=new google.maps.LatLng(a.lat,a.lng),r=a.marker_icon,i=new google.maps.Size(44,60);var n={url:r,size:i,scaledSize:new google.maps.Size(44,60),origin:new google.maps.Point(0,0),anchor:new google.maps.Point(7,27)};var s=new google.maps.Marker({position:t,map:p,icon:n,draggable:false,animation:google.maps.Animation.DROP});var o=a.data?a.data.post_title:a.title,l="";if(a.image_url==""||typeof a.image_url=="undefined"){l='style="display: none;"'}var c=document.createElement("div");c.className="marker-content clearfix";c.innerHTML='<div class="marker-content-inner clearfix">'+'<div class = "item-thumb" '+l+">"+'<a href="'+a.url+'">'+'<img src="'+a.image_url+'" alt="'+o+'" style="width: 100px;">'+"</a>"+"</div>"+'<div class="item-body">'+'<a href="'+a.url+'" class="title-marker">'+o+"</a>"+'<div class="price-marker">'+a.price+"</div>"+'<div class="address-marker"><i class="fa fa-map-marker"></i>'+a.address+"</div>"+"</div>"+"</div>";google.maps.event.addListener(s,"click",function(o,e){return function(){var e=Math.pow(2,p.getZoom()),a=100/e||0,t=p.getProjection(),r=o.getPosition(),i=t.fromLatLngToPoint(r),n=new google.maps.Point(i.x,i.y-a),s=t.fromPointToLatLng(n);p.setCenter(s);setTimeout(function(){Z.setContent(c);Z.open(p,o)},300)}}(s,e));A.push(s)})};z.ajax({dataType:"json",url:B,data:{action:"ere_property_search_ajax",title:i,address:h,country:e,state:t,city:a,neighborhood:r,type:o,status:s,bedrooms:l,bathrooms:p,min_price:d,max_price:f,min_area:u,max_area:_,label:v,garage:m,min_land_area:y,max_land_area:b,property_identity:x,features:g,search_type:c,ere_security_search_map:P},beforeSend:function(){j.parents("div.ere-search-properties-map").find("#ere-map-loading").fadeIn()},success:function(e){if(c=="map_and_content"){var a=z(".owl-carousel",".list-property-result-ajax"),t=z(".list-property-result-ajax");a.empty();if(e.success===false){t.find(".title-result h2 .number-result").hide();t.find(".title-result h2 .text-no-result").show();t.find(".title-result h2 .text-result").hide()}else{var r=z(".property-item",e.property_html);a.css("opacity",0);a.trigger("destroy.owl.carousel");a.html(r);a.css("opacity",1);a.imagesLoaded(function(){ERE.set_item_effect(r,"hide");ERE_Carousel.owlCarousel();r=z(".property-item",a);ERE.set_item_effect(r,"show")});if(r.length!="0"){t.find(".title-result h2 .number-result").html(r.length);t.find(".title-result h2 .number-result").show();t.find(".title-result h2 .text-no-result").hide();t.find(".title-result h2 .text-result").show()}}ERE.favorite();ERE.tooltip();ERE_Compare.register_event_compare()}q=new google.maps.Map(document.getElementById(R),T);q.set("scrollwheel",false);google.maps.event.trigger(q,"resize");if(e.success===true){if(e.properties){var i=e.properties.length}}if(i==1){var n=google.maps.event.addListener(q,"bounds_changed",function(e){this.setZoom(parseInt(M));google.maps.event.removeListener(n)})}if(L!==""){var s=JSON.parse(L);q.setOptions({styles:s})}var o=new google.maps.LatLng("","");q.setCenter(o);q.setZoom(parseInt(M));google.maps.event.addListener(q,"tilesloaded",function(){z("#ere-map-loading").fadeOut()});if(e.success===true){for(var l=0;l<A.length;l++){A[l].setMap(null)}A=[];I(e.properties,q);q.fitBounds(A.reduce(function(e,a){return e.extend(a.getPosition())},new google.maps.LatLngBounds));google.maps.event.trigger(q,"resize");if(O=="1"){S=new MarkerClusterer(q,A,{gridSize:60,styles:[{url:k,width:48,height:48,textColor:"#fff"}]})}if(!D){G()}}else{j.empty().html('<div class="map-notfound">'+C+"</div>")}j.closest("div.ere-search-properties-map").find("#ere-map-loading").fadeOut("slow")},error:function(){j.closest("div.ere-search-properties-map").find("#ere-map-loading").fadeOut("slow")}})}};var G=function(){z(".property-item",H).each(function(e){z(this).on("mouseenter",function(){if(q){google.maps.event.trigger(A[e],"click")}});z(this).on("mouseleave",function(){Z.open(null,null)})});return false};z(document).ready(function(){ERE_Property_Map_Search.init()});z(window).resize(function(){ERE_Property_Map_Search.full_screen()});z(window).on("orientationchange",function(){ERE_Property_Map_Search.full_screen()})})(jQuery);