if(!MNP.Map){MNP.Map={}}if(!MNP.Map.Provider){MNP.Map.Provider=[]}if(!MNP.Map.Maps){MNP.Map.Maps=[]}if(!MNP.Map.StaticMaps){MNP.Map.StaticMaps=[]}LazyLoad.css("/css/map/mapping.css".addBuildNumberAndCDN());MNP.Map.Settings=function(){this.logballoon=false;this.featuredListSize=3;this.propInfoUrl="/propertyinfo/{propertyKey}?ln=Map";this.cluster={radius:35.5};this.zoom={max:19,min:7,def:13};this.pan={tollerance:10,panLevel:70};this.list={autoPage:false};this.markers={delayStart:100,anchorPoint:"center"};this.criteria=null;this.bounds={minLat:null,minLon:null,maxLat:null,maxLon:null};this.css={attach:function(a){var b=Object.extend({marker:"/css/map/marker4.css"},a||{});MNP.Util.attachCss(b.marker.addBuildNumberAndCDN());this.css.attached=true}.bind(this)};this.setZoomBoundaries=function(b,a){if(a){this.zoom.max=a}if(b){this.zoom.min=b}};this.setIcons=function(a){this.icons=a};this.setCriteria=function(a){this.criteria=a};this.setBounds=function(d,a,b,c){if(d){this.bounds.minLat=d}if(a){this.bounds.minLon=a}if(b){this.bounds.maxLat=b}if(c){this.bounds.maxLon=c}};this.getMarkers=function(){if(!this.css.attached){this.css.attach()}if(this.markers){return this.markers}var a=function(f){var d=$("tmpmkr");if(!d){d=$E("div",{id:"tmpmkr",parentNode:this.mapEl})}var c;d.className="mnpmarker "+f;c=Element.getStyle(d,"background-image");if(c){var e=c.indexOf("/images/");c=c.substring(e,c.indexOf(")"));c=c.replace('"',"")}return c};var b={green:a("green"),green_hover:a("green-h"),gray:a("gray"),gray_hover:a("gray-h"),green_large:a("green-l"),gray_large:a("gray-l"),featured:a("featured"),featured_large:a("featured-l"),home:a("home"),home_large:a("home-l"),city:a("green")};if($("tmpmkr")){Element.hide("tmpmkr")}return b};this.interfaceElements={mapToggle:"maptoggle",paginationTop:"pg",paginationBottom:"pg",sortWidget:"sortwidget",propertyCount:"propertyCount",resultsTable:"results_table",searchForm:"searchCriteria"};return this};MNP.Map.Marker={items:[],idMap:null,keyMap:null,shapes:[],shapesPKMap:null,newItems:null,markerMap:null,firstLoad:true,getByKey:function(a){if(!this.keyMap){this.keyMap=this._mapKeys()}return this.items[this.keyMap[a]]},getByProperty_id:function(a){if(!this.idMap){this.idMap=this._mapObj("property_id")}return this.items[this.idMap[a]]},getByMarkerId:function(b){if(!this.markerMap){this.markerMap=this._mapObj("id")}var c=this.markerMap[b];if(c==null){this.markerMap=this._mapObj("id");c=this.markerMap[b]}var a=this.items[c];if(a){return a}},isNew:function(a){return this.newItems[a]},add:function(a){this.items[this.items.length]=a},marker:function(a){return new MNP.Map.Marker.markerObject(a)},initNew:function(){this.newItems={}},_mapKeys:function(){var g={};var a=this.items;for(var e=0,d=a.length;e<d;e++){var c=a[e].property_id.split(",");for(var f=0,b=c.length;f<b;f++){g[c[f]]=e}}return g},_mapObj:function(d){var c={};var e=this.items;for(var b=0,a=e.length;b<a;b++){c[e[b][d]]=b}return c},resetMaps:function(){this.keyMap=null;this.markerMap=null;this.idMap=null;this.shapesPKMap=null},reset:function(){this.items=[];this.resetMaps()},fixIEPngs:function(){if(MNP.Browser.IE6){var a=this.items;for(var c=0,b=a.length;c<b;c++){this.fixIEPng(a[c])}}},fixIEPng:function(b){if(b.getId()&&!b.customIcon){var a=$(b.id);if(a){a.className="VEAPI_Pushpin "+b.style;if(b.icon&&!a.style.filter){a.style.background="none";a.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b.icon+"', sizingMethod='image')"}}}},hoverIn:function(b,a){this._hoverOpts(a,this.hoverInAction)},hoverOut:function(b,a){this._hoverOpts(a,this.hoverOutAction)},_hoverOpts:function(b,c){var a=Object.extend({pk:null},b||{});if(a.pk){return c(this.getByKey(a.pk))}},hoverInAction:function(){},hoverOutAction:function(){}};MNP.Map.Marker.markerObject=Class.create();MNP.Map.Marker.markerObject.prototype={initialize:function(d,c,b){if(d){var f=(b?b:14);var e=function(j,h){if(!c.icons){c.icons=c.getMarkers()}var g=(!h)?j:j+"_"+h;var i=c.icons[g];return(!i)?c.icons.none:i};var a;d.property_id=d.id;this.lat=d.lat;this.lon=d.lon;this.title=d.title;this.style+=" marker-"+d.style;this.type=d.style;this.property_id=d.id;this.size=f;this.text=d.text||null;if(d.cluster){this.content=d.cluster;this.cluster=d.cluster;this.customIcon=true}if(this.type=="city"){this.content=d.title;this.customIcon=true;this.showlabel=false;if(d.link){this.action=d.link}}if(this.size>=16){this.style+="-l large";a="large"}if(d.icon){this.icon=d.icon}else{this.icon=e(this.type,a)}if(d.url){this.url=d.url.replace("{propertyKey}",d.id)}this.zIndex="1500";if(this.type=="featured"){this.zIndex="2000"}if(this.type=="gray"){this.zIndex="1000"}this.persistInfo=false}},id:null,lat:null,lon:null,provider:null,nativeMarker:null,property_id:0,url:null,type:"green",customIcon:null,shape:null,icon:null,showlabel:true,style:"mnpmarker",persistInfo:true,getElInfo:function(d){if(!this._dim||!this.persistInfo){var b=this.getElement();if(b){var e={};var f=Position.cumulativeOffset(b);var c=Element.getDimensions(b);e.top=f[1];e.left=f[0];e.height=c.height;e.width=c.width;this._dim=e;if(!e.top&&MNP.Browser.Saf){var a=this.getWebKitTransformTranslateOffset(b);e.top+=a[1];e.left+=a[0]}}}return this._dim[d]},getUrl:function(){if(!this.url){this.url="/propertyinfo/"+this.property_id+"?ln=Map"}if(MNP.pn){this.url=this.url.addParam("pageSource",MNP.pn)}return this.url},getElement:function(){if(!this.element){this.element=$(this.getId())}return this.element},getId:function(){if(!this.id){if(this.shape){this.id=this.shape.Primitives[0].iid}if(this.provider=="google"){this.id=MNP.Map.Provider.google.GetMarkerId(this.nativeMarker)}}return this.id},getWebKitTransformTranslateOffset:function(d){var a=0,e=0;do{var c=d.style["-webkit-transform"];if(c){var b=c.match(/translate\((.+)px,\s(.+)px\)/);if(b.length>2){a+=parseInt(b[2])||0;e+=parseInt(b[1])||0}}d=d.offsetParent}while(d);return[e,a]},highlightOn:function(){var a=this.getElement();if(a){a.className=a.className.replace(this.style,this.style+"-hover");a.style.zIndex="1000"}},highlightOff:function(){var a=this.getElement();if(a){a.className=a.className.replace(this.style+"-hover",this.style);a.style.zIndex=this.zIndex}}};MNP.Map.Popups={isMarkerVisibleArea:function(d,i){var c=d.getElInfo("top"),g=d.getElInfo("left"),f=d.getElInfo("height"),e,b;if(i&&i.mapEl){var h=i.mapEl;b=Position.cumulativeOffset(h);e=Element.getDimensions(h);if(g<b[0]){return}if(c<0){return}var a=getAbsoluteTop(i.mapParent||h.parentNode)+h.offsetTop;if((c+f)<=a){return}if(e){if(g>e.width+b[0]){return}if(c>e.height+b[1]){return}}}return[e,b]},_zoom:function(a){MNP.Map.Nav.centerZoom(marker.lat,marker.lon,12)},_getTitleWidth:function(b){var a=$("twca");if(!a){a=$E("a",{attributes:{href:"#",id:"twca"},parentNode:$E("div",{attributes:{id:"twc",className:"markerlabel"}})})}a.innerHTML=b;return getElWidth(a)+5}};MNP.Map.Infobox=function(q){var t=this,g=q,k,a=0,b=false,l,u=390,A=84,v,E,r,B,n,m,d,w,C,j,f="",o="",F="infoboxiframe",e="infobox";function D(O,S){k=O;s(k,500);if(k&&!k.contentErr){if(k.type==="cluster"){return g.ToolTipLabel.show(k)}if(i()){j=S;var N=$("page").offsetWidth-20,L=k.getElInfo("top"),T=k.getElInfo("left"),R=k.getElInfo("height"),M=k.getElInfo("width"),G=C[1],P=C[0];f="";v=c();v.className=e;var I=T-(u/2)+(M/2);var K=L;var H=(u/2)-(A/2);if(G){if(I<G[0]){H-=(G[0]-I);if(H<25){H=T-G[0];f="left";o="align-"+f;Element.addClassName(v,o)}I=G[0]}}if(I+u>N){var J=(I+u)-N-(M/2);I-=J;H+=J;if(H>(u-A)){f="right";o="align-"+f;Element.addClassName(v,o);H-=A/2}}E.style.left=H+"px";if(d){d.transport.abort()}if(!k.content){if(g.staticContentPrefix){var Q=$(g.staticContentPrefix+"_"+k.property_id);if(Q){k.content=Q.innerHTML;p(k,K,I)}}else{d=new MNP.Ajax.Request(k.getUrl(),{method:"get",onSuccess:function(U){k.content=U.responseText;k.content=k.content.replace("_"+k.property_id,"_"+k.property_id+"_info");p(k,K,I);d=null}.bind(this),onFailure:function(U){k.contentErr=1}.bind(this)})}}else{p(k,K,I)}MNP.UI.Popups.add(e,z.bind(this));g.ToolTipLabel.close()}}else{s()}}function i(){var G=k.getId();if(m){window.clearTimeout(m);m=null}if(G===a){if(b){return}}if(G!=a){if(!k.showlabel){return}a=G;l=$(G)}if(!l){return}C=t.isMarkerVisibleArea.call(this,k,g);if(!C){return}if(q.UI.isEnabled&&!q.UI.isEnabled()){return}return true}function p(H,I,J){if(!H.contentErr){MnpEffect.Opacity(v,0);Element.show(v);w.innerHTML=H.content;var G=$C("rr",w)[0];if(G){G.pk=H.property_id;G.pkelid=G.id}I-=v.offsetHeight-10;if(I<getScrollTop()){I=x()}v.style.top=I+"px";v.style.left=J+"px";g.Label.close();MnpEffect.Opacity(v,1);b=true;h(v)}else{s()}}function x(){var G=k.getElInfo("top"),H=k.getElInfo("height");Element.removeClassName(v,o);o="align-top";if(f){o+="-"+f}Element.addClassName(v,o);return G+H}function z(){s(null,null,1)}function s(I,G,H){if(I){if(I===k){return}else{k=I}}if(m){window.clearTimeout(m);m=null}if(j&&!H){return}m=window.setTimeout(function(){c().hide();if(MNP.Browser.IE){var J=$(F);if(J){Element.hide(J)}}b=false;MNP.UI.Popups.remove(e)}.bind(this),G||1)}function c(){if(!v){var I="div";var G=$E(I,{id:e,className:e,hide:true});var H=$E(I,{className:y("content"),parentNode:G});w=$E(I,{className:y("content-container"),parentNode:H});$E(I,{className:y("content-bottom"),parentNode:H});E=$E(I,{parentNode:G,className:"beak",id:y("beak")});if(window.Cons){Event.observe(w,"click",Cons.Plist.click.bindAsEventListener(Cons.Plist))}v=$(G)}return v}function y(G){return e+"-"+G}function h(G){if(window.setHideFrame){setHideFrame(G,F)}}return{show:D,close:s}};MNP.Map.Infobox.prototype=MNP.Map.Popups;MNP.Map.ToolTipLabel=function(l){var e=l;var n=this,f,c,d=false,g,p=180,r=17,t=28,k=30,j,i,q,s,a,h;n.oType="Label";function u(x){if(!x){return}f=x;m(f,1);var w=f.getId();if(i){window.clearTimeout(i)}if((w===c)&&d){return}if(!f.showlabel){return}if(w!=c){c=w;g=$(w)}if(!g){return}if(j){window.clearTimeout(j)}if(!n.isMarkerVisibleArea.call(this,f,e)){return}var z=f.getElInfo("top");var F=f.getElInfo("left");var D=f.getElInfo("height");var A=f.getElInfo("width");var C=f.style;z+=D;var B=getWinWidth()-20;var E=f.title;var v=n._getTitleWidth(E)+k;s=b();s.show();a.show();a.innerHTML=E;d=true;var G=F+v;if(G>B){F=F-v;F=F+t+(A/2);Element.addClassName(s,"align-right")}else{Element.removeClassName(s,"align-right");var y=t-(A/2);F-=y}s.style.width=v+"px";s.style.top=z+"px";s.style.left=F+"px";e.Infobox.close();MNP.UI.Popups.add(n.oType,m.bind(this))}function m(w,v){if(d){if(w){if(w==f){return}}if(i){window.clearTimeout(i);i=null}i=window.setTimeout(function(){b().hide();d=false;MNP.UI.Popups.remove(this.oType)}.bind(this),v||1)}}function b(){if(!s){var w="div";s=$E(w,{className:"markertooltip",anonymous:true});s.style.left="-400px";var v=$E(w,{className:"lblinfo",par:s});$E(w,{par:s,className:"lpl-rcap"});$E(w,{par:s,className:"beak"});a=$E("span",{par:v});$T("body")[0].appendChild(s);o(s,"mousemove",m);s=$(s)}if(f.cluster){h="clustertooltip"}else{h="markertooltip"}s.className=h;return s}function o(v,x,w){Event.observe(v,x,w.bindAsEventListener(n))}return{close:m,show:u}};MNP.Map.ToolTipLabel.prototype=MNP.Map.Popups;MNP.UI.SlideManager=function(h){var j,l,d=false;var q={parentObject:null,defaultId:"column2",listArea:"plistcol",listEl:"results_table",pageContentArea:"content-main",mapFooter:"map_footer",mapHeader:"map_header",mapContainerArea:"map_column",mapInsert:"mapinsert",slideToggle:"mapslidetoggle"};var b=Object.extend(q,h||{});b.mapFooter=$(b.mapFooter);b.mapHeader=$(b.mapHeader);if(b.pageContentArea.split){b.pageContentArea=$($C(b.pageContentArea)[0])}b.listArea=$(b.listArea);b.slideToggle=$(b.slideToggle);var o=$(b.defaultId),t=$(b.pageContentArea),i,a=0;var e={getSize:function(v,w){return this.keys[v]={width:w.offsetWidth,height:w.offsetHeight,el:w}},reset:function(){for(var v in this.keys){this.getSize(v,this.keys[v].el)}},keys:{}};function u(){if(t){e.getSize("mapParent",t);e.getSize("map",o);Event.observe(window,"scroll",k);if(b.slideToggle){Event.observe(b.slideToggle,"click",r)}k()}}function s(){Event.stopObserving(window,"scrol",k)}function k(){if(j){window.clearTimeout(j)}j=window.setTimeout(n,500)}function r(){c()}function c(){var v=d;if(b.slideToggle&&b.slideToggle.checked===true){v=true}else{v=false}if(v!=d){d=v;new SimpleAjax.Request("/map-settings?stayPut="+d)}return d}function n(){if(c()===true){return}var v=f()||0;m(v,1000);a=v}function m(A,w){g();if(b.parentObject){b.parentObject.UI.disable.call(b.parentObject)}var v=parseInt(o.style.marginTop),x=A-v,z=Math.PI/(2*w),y=new Date().getTime();l=setInterval(function(){var B=new Date().getTime()-y;if(B<w){var C=Math.abs(Math.sin(B*z));p(Math.round(C*x+v))}else{g();p(A)}},10)}function p(v){o.style.marginTop=(v||0).toPixels()}function g(){clearInterval(l);if(b.parentObject){b.parentObject.UI.enable.call(b.parentObject)}if(b.parentObject){b.parentObject.UI.reset.call(b.parentObject)}if(b.afterFinish){b.afterFinish()}}function f(){var x=getScrollTop(),C=getWinHeight()+x,B=o.offsetHeight,F=getAbsoluteTop(o.parentNode),y=b.mapFooter,v=0,A=0,E=0;if(y){B+=y.offsetHeight}var D=F+B+a;if(x>F){A=a+F}if(i>x){E=1}i=x;if(E){if(x>A){return}}else{if(D>C){return}}var z=t.offsetHeight;if(x>F){v=x-F}var w=F+v+B;if(E){if(w>=z){v=z-B}}else{if(w>C){v-=(w-C);w=F+v+B}if(w>z){v-=(w-z)}}if(v<0){v=1}j=null;return v}u();return{destroy:s}};MNP.Map.Provider.google={_map:null,loadApi:function(a){LazyLoad.js("http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0",function(){setTimeout(function(){MNP.Map.Maps[a].mapInterface.loadApiParts(a)},1000)})},loadApiParts:function(a){MNP.Map.Maps[a].init()},apiReady:function(){return !!window.Microsoft&&!!window.Microsoft.Maps&&!!window.Microsoft.Maps.Location},getMap:function(){return this._map},GetMapStyle:function(){var a={Map:"r",Hybrid:"h"};var b=this.getMap().getCurrentMapType().getName();return a[b]},GetZoomLevel:function(a){var b=this.getMap();if(a){b.fitBounds(a)}return b.getZoom()},SetZoomLevel:function(a){return this.getMap().setZoom(parseInt(a))},ZoomOut:function(){return this.getMap().zoomOut()},ZoomIn:function(){return this.getMap().zoomIn()},SetCenterAndZoom:function(a,b){this.Center(a.lat,a.lon,b)},SetMapStyle:function(a){var b={r:G_NORMAL_MAP,h:G_HYBRID_MAP};this.getMap().setMapType(b[a]);return this.GetMapStyle()},Pan:function(a,b){return this.getMap().panBy(new GSize(a,b))},Map:function(a,d){var b={credentials:"Alngj3Ew0PvbTkI1NQv_bcBBh-PM7EYKLkiyKym3-iPMIKQZGxfRC8-1jK5yj5dV",mapTypeId:Microsoft.Maps.MapTypeId.road,enableSearchLogo:false,zoom:12};if(d&&Microsoft.Maps.Location){b.center=new Microsoft.Maps.Location(d.latitude,d.longitude)}var c=new Microsoft.Maps.Map(document.getElementById("map"),b);this._map=c;return c},Center:function(d,a,c){var b=this.getMap();b.setZoom(c);b.setCenter(new Microsoft.Maps.Location(d,a))},GetBounds:function(e){var f;if(e){var a=[];for(var c=0,b=e.length;c<b;c++){var d=e[c];if(e.lat!==""){a[c]=(new Microsoft.Maps.Location(parseFloat(d.lat),parseFloat(d.lon)))}}f=new Microsoft.Maps.LocationRect.fromLocations(a)}else{f=this.getMap().getBounds()}return f},FitBounds:function(a){this.getMap().setView({bounds:this.GetBounds(a)})},GetCenter:function(){return this.getMap().getCenter()},PixelToLatLong:function(a,b){var c=this.getMap();return c.tryPixelToLocation(a,b)},Clear:function(){this.getMap().clearOverlays()},_PdMIA:null,GetMarkerId:function(d){if(!this._PdMIA){for(var c in d){var a=d[c];if(a){if(a.constructor==Array){if(a[0].src){this._PdMIA=c}}}}}if(d.div_){var b="cluster"+rnd();d.div_.id=b;return b}if(this._PdMIA){return d[this._PdMIA][0].id}},Resize:function(){Microsoft.Maps.Events.invoke(this.getMap(),"resize")}};MNP.Map.BaseMarker={create:function(){var a=function(c,b){this.zIndex=1;this.options=b};a.prototype.onRemove=MNP.Map.BaseMarker.onRemove;a.prototype.draw=MNP.Map.BaseMarker.draw;a.prototype.setZIndex=MNP.Map.BaseMarker.setZIndex;return a},draw:function(){var b=this.getProjection(),a=b.fromLatLngToDivPixel(this.options.point),f=this.div_,c=this.div_shadow,e=(a.x-(f.offsetWidth/2)).toPixels(),d=(a.y-f.offsetHeight).toPixels();if(this.options.anchorPointLeft=="left"){e=(a.x).toPixels()}if(this.options.anchorPointLeft=="right"){e=(a.x-f.offsetWidth).toPixels()}f.style.left=e;f.style.top=d;f.style.zIndex=this.zIndex;if(c){c.style.left=e;c.style.top=d}},onRemove:function(){var c=this.listeners_,d=Microsoft.Maps.Events.removeHandler;this.div_.parentNode.removeChild(this.div_);if(this.div_shadow){this.div_shadow.parentNode.removeChild(this.div_shadow)}for(var b=0,a=c.length;b<a;++b){d(c[b])}this.div_=null;this.div_shadow=null},setZIndex:function(a){this.zIndex=a;if(this.div_){this.div_.style.zIndex=a}}};MNP.Map.StandardMarker=function(){var a;function c(e,d){if(!a){b()}return new a(e,d)}function b(){a=MNP.Map.BaseMarker.create();a.prototype.onAdd=function(){var h=this.options,e=h.InfoboxObject,d=h.markerObject,k=h.thisMap,j=d.text;var g=$E("div",{className:"mnpmarker-shadow"});var f=$E("div",{className:d.style,id:d.id});if(j&&j!=""){f.appendChild($E("span",{text:j}))}var i=this;this.listeners_=[Microsoft.Maps.Events.addHandler(this,"position_changed",function(){i.draw()}),Microsoft.Maps.Events.addHandler(this,"text_changed",function(){i.draw()}),Microsoft.Maps.Events.addHandler(f,"click",function(){if(h.options.showBalloon){e.show(d,1)}}),Microsoft.Maps.Events.addHandler(f,"mouseover",function(){k.Events.mouseover(d)}),Microsoft.Maps.Events.addHandler(f,"mouseout",function(){k.Events.mouseout(d)})];this.div_=f;this.div_shadow=g}}return{add:c}}();MNP.Map.CustomMarker=function(){var c;function b(e,d){if(!c){a()}return new c(e,d)}function a(){c=MNP.Map.BaseMarker.create();c.prototype.onAdd=function(){var f=this.options;var h=f.thisMap;var d=f.markerObject;var g=h.getMap();var e=$E("div",{className:"mnpmarker-shadow"});var i=$E("div",{className:d.style,id:d.id});i.innerHTML="<span>"+f.text+"</span>";this.div_shadow=e;this.div_=i;this.listeners_=[Microsoft.Maps.Events.addhandlerr(i,"mouseover",function(){h.Events.mouseover(d)}),Microsoft.Maps.Events.addhandler(i,"mouseout",function(){h.Events.mouseout(d)}),Microsoft.Maps.Events.addhandler(i,"click",function(){if(d.type=="city"){window.location=d.action}else{setTimeout(function(){MNP.UI.Popups.close()},400);var l=f.point,k=f.padding,n=g.tryLocationToPixel(l);var j=new Microsoft.Maps.Point(n.x-k,n.y+k);j=g.fromPointToLatLng(j);var m=new Microsoft.Maps.Point(n.x+k,n.y-k);m=g.fromPointToLatLng(m);g.fitBounds(new Microsoft.Maps.Location(j,m))}})]}}return{add:b}}();MNP.Map.CityMarker=function(){var b;function a(e,d){if(!b){c()}return new b(e,d)}function c(){b=MNP.Map.BaseMarker.create();b.prototype.onAdd=function(){var e=this.options,f=e.thisMap,d=e.markerObject,h=this.getPanes().overlayImage;var g=$E("div",{className:d.style,id:d.id,par:h});g.innerHTML="<span>"+e.text+"</span>";this.div_=g;this.listeners_=[Microsoft.Maps.Events.addhandler(g,"mouseover",function(){f.Events.mouseover(d)}),Microsoft.Maps.Events.addhandler(g,"mouseout",function(){f.Events.mouseout(d)}),Microsoft.Maps.Events.addhandler(g,"click",function(){window.location=d.action})]}}return{add:a}}();if(!MNP.Map.Google){MNP.Map.Google={}}MNP.Map.Google.Local=function(){var i=0,s=[],t,x="search",k="http://www.google.com/uds/solutions/localsearch/gmlocalsearch",q=k+".js",p=k+".css",g;function j(z,A){g=$(z).parentNode;if(m){n(A)}else{MNP.Map.StaticMaps[z].loadDynamicMap(function(){google.load(x,"1",{callback:function(){a(A)}})})}}var y;var m;var l;var o;var d;var c=[];var h,e,f;function a(z){m=1;h=new google.maps.MarkerImage("http://labs.google.com/ridefinder/images/mm_20_yellow.png",new google.maps.Size(12,20),new google.maps.Point(0,0),new google.maps.Point(6,20));e=new google.maps.MarkerImage("http://labs.google.com/ridefinder/images/mm_20_red.png",new google.maps.Size(12,20),new google.maps.Point(0,0),new google.maps.Point(6,20));f=new google.maps.MarkerImage("http://labs.google.com/ridefinder/images/mm_20_shadow.png",new google.maps.Size(22,20),new google.maps.Point(0,0),new google.maps.Point(6,20));l=MNP.Map.Maps.map.getMap();o=new google.maps.InfoWindow;google.maps.event.addListener(o,"closeclick",function(){u()});y=new GlocalSearch();y.setSearchCompleteCallback(null,b);d=$($E("div",{className:"search-result-panel",par:g}));n(z)}function u(){for(var z=0;z<c.length;z++){c[z].unselect()}}function w(){u();v();d.hide()}function v(){for(var z=0;z<c.length;z++){c[z].marker().setMap(null)}o.close()}function n(z){y.setCenterPoint(l.getCenter());y.execute(z)}function b(){if(!y.results){return}d.show();d.innerHTML="";v();c=[];for(var A=0;A<y.results.length;A++){c.push(new r(y.results[A]))}var z=y.getAttribution();if(z){d.appendChild(z)}MNP.DOM.Graft(d,["div",{"class":"local-search-actions"},["span",{onclick:w},"Clear Results"]])}function r(K){var A=C();var B=G();var F;var E=K.html;function J(){google.maps.event.addDomListener(A,"mouseover",function(){z(true)});google.maps.event.addDomListener(A,"mouseout",function(){if(!F){z(false)}});google.maps.event.addDomListener(A,"click",function(){I()});d.appendChild(A)}function C(){if(A){return A}return H()}function G(){if(B){return B}var L=B=new google.maps.Marker({position:new google.maps.LatLng(parseFloat(K.lat),parseFloat(K.lng)),icon:h,shadow:f,map:l});google.maps.event.addListener(L,"click",function(){I()});return L}function I(){u();F=true;z(true);o.setContent(E);o.open(l,G())}function D(){F=false;z(false)}function H(){var L=$($E("div",{className:"unselected local-entry"}));$E("span",{className:"local-title",text:K.titleNoFormatting,par:L});$E("span",{className:"local-address",text:K.streetAddress,par:L});return L}function z(L){G().setOptions({icon:L?e:h});if(L){C().addClassName("red")}else{C().removeClassName("red")}}J();return{marker:G,unselect:D}}return{search:j}}();MNP.Map.Locations=MNP.Map.Google.Local;MNP.Map.Search=function(j,f,v,s){var y=j.mapInterface;var p=new d(y,j.mapEl,v);var c=new p.MapDimensions(y,j.mapEl);var B=s||false;var C;var b;var z;var o="/mapsearch/find",u="/mapsearch/findnearby",h="zoom",k="lat",e="lon",m="mapcache",G=MNP.Cache.get,D=MNP.Cache.set,x="Interactive Map Toggle ";function n(){F(true);MNP.Track.link(x+"on");Element.addClassName($T("body")[0],"interactive-map")}function l(){MNP.Track.link(x+"off");var I=navigator.userAgent.toLowerCase();if(I.indexOf("msie")!=-1){var H=document.createElement("a");H.href="/search?type=listmap";document.body.appendChild(H);H.click()}else{document.location="/search?type=listmap"}}function F(H){new SimpleAjax.Request(uncache("/enable-dynamic-map?interactiveMapActive="+H));B=H;D("mapEnabled",H)}function a(I){var H=A(o);H=H.addParam("height",c.areaHeight());H=H.addParam("width",c.areaWidth());H=H.addParam("centerLat",y.GetCenter().latitude);H=H.addParam("centerLon",y.GetCenter().longitude);H=H.addParam("offsetLeft","0");H+="&"+Form.serialize(f);t(H)}function q(){var J=c.topLeft();var H=c.bottomRight();var I=A(u);I=I.addParam("extentTopLeftLat",J.Latitude);I=I.addParam("extentTopLeftLon",J.Longitude);I=I.addParam("extentBottomRightLat",H.Latitude);I=I.addParam("extentBottomRightLon",H.Longitude);I+="&"+Form.serialize(f);t(I)}function A(H){H=H.addParam("nodescription","true");H=H.addParam("dataType","json");H=H.addParam(h,y.GetZoomLevel());H=H.addParam("pushPinRadius",p.getPushPinRadius());return H}function t(H){i.setSearching();if(C){C.transport.abort()}if(b){window.clearTimeout(b)}z=H;b=window.setTimeout(r,1000)}function r(){if(!MNP.Cache.useCache(m)){D(h,y.GetZoomLevel());var H=y.GetCenter();D(k,H.latitude);D(e,H.longitude);C=new Ajax.Request(uncache(z),{method:"get",on200:g})}else{y.SetCenterAndZoom({lat:G(k),lon:G(e)},G(h));g({responseText:MNP.Cache.get(m)})}}function g(I){C=null;var H=I.responseText;D(m,H);w(H)}function w(H){var I=getEval("("+H+")");i.setMappingComplete();j.addNewMarkers(I.items,true);E.GetResults("newsearch",I)}function d(M,I,J){function L(){var N;N=K(J.cluster.radius);return N}function K(P){var T=M.PixelToLatLong(new Microsoft.Maps.Point(0,0),M.GetZoomLevel());var Q=M.PixelToLatLong(new Microsoft.Maps.Point(P,0),M.GetZoomLevel());var S=3963.19;var O=T.longitude/180*Math.PI;var N=T.latitude/180*Math.PI;var U=Q.longitude/180*Math.PI;var R=Q.latitude/180*Math.PI;var V=Math.acos(Math.sin(N)*Math.sin(R)+Math.cos(N)*Math.cos(R)*Math.cos(U-O))*S;return V*10}function H(){var U,P;function O(W){var V=W.GetBounds().getSoutheast();var X=W.GetBounds().getNorthwest();return{TopLeftLatLong:{Latitude:X.latitude,Longitude:X.longitude},BottomRightLatLong:{Latitude:V.latitude,Longitude:V.longitude}}}function T(){return O(M).TopLeftLatLong}function R(){return O(M).BottomRightLatLong}function Q(){if(!U){N()}return U}function S(){if(!P){N()}return P}function N(){U=getElWidth(I);P=getElHeight(I)}return{topLeft:T,bottomRight:R,areaWidth:Q,areaHeight:S}}return{MapDimensions:H,getPushPinRadius:L}}var i=function(){var Y=v.interfaceElements;var Z,R,J=Element.addClassName,N=Element.removeClassName,S;function P(ab){W(ab.description)}function X(){if(!Z){Z=$(Y.resultsTable)}return Z}function Q(){if(!R){var ab=j.mapEl.parentNode;J(j.mapEl,"map");R=$($E("div",{par:ab,className:"busy-indicator",text:"Searching ..."}));R.setStyle({top:((ab.offsetHeight/2)-40).toPixels(),left:((ab.offsetWidth/2)-40).toPixels()});graft(R,["div",{className:"slow-search"},"Search results not appearing?",["p",["a",{href:"/search?type=listmap"},"Turn off 'Redo search as I move the map'"]]])}R.setStyle({marginTop:(parseInt(j.mapEl.style.marginTop)||0).toPixels()});return R}function T(){H();S=setTimeout(V,10000);I(J);aa()}function M(){H();I(N);U()}function K(){I(N)}function I(ab){ab($(j.mapEl).parentNode,"map-inactive")}function O(ab){ab(X(),"inactive")}function aa(){O(J)}function U(){O(N)}function H(){setTimeout(MNP.UI.Popups.close,100);clearTimeout(S);Element.removeClassName(Q(),"search-timeout")}function V(){Element.addClassName(Q(),"search-timeout")}function L(ag,af){var ac=$C("pagination")[0];var ad=$C("back",ac)[0];var ae=$C("next",ac)[0];var ab=$C("pgnum",ac)[0];if(af===0){J(ac,"inactive")}else{N(ac,"inactive");if(ab){ab.innerHTML="Page "+ag+" of "+af;if(ag==1){J(ad,"disabled")}if(ag>1){N(ad,"disabled")}if(ag==af){J(ae,"disabled")}else{N(ae,"disabled")}}}var ah=$("pagination2");if(ah){ah.innerHTML="";ah.appendChild(ac.cloneNode(1));ah.parentNode.id="rn1"}}function W(ac){var ab=$(Y.propertyCount);if(ab){ab.innerHTML=ac}}return{update:P,setSearching:T,setSearchComplete:M,setPaginating:aa,setPaginatingComplete:U,setMappingComplete:K,updatePagination:L,getResultsTable:X}}();var E=function(){var O=1,ac,Y,L,V,J,ab,am="",an="",aa="fplistcache",Z="plistcache",Q="/mapsearch/page/",al="/mapsearch/featured",W="/mapsearch/morefeatured?dataType=json",H="/mapsearch/sort?list=simplePropertyList",ag="pageback",ad="pagenext",T="morefeatured",X="lukUpKey";function af(){MNP.Page.addLinkClickByRel(ag,N);MNP.Page.addLinkClickByRel(ad,N);MNP.Page.addLinkClickByRel(T,M);ab=$(X);if(ab){ab.form.uberSubmit=aj}}function N(at,ar,ap){if(B){Event.stop(at);var aq=O+1;if(ap===ag){aq=O-1}R(aq);window.scrollTo(0,0)}}function aj(ap){if(B){Event.stop(ap);P(H.addParam(X,ab.value))}else{ab.form.submit()}}function M(ap){Event.stop(ap);ao(W,aa,S)}function S(ap){try{var ar=$("featured_rows"),aq=$(T);aq.hide();ar.innerHTML+=ap.data}catch(at){}}function ai(ap,aq){L=ap;V=aq;if(ac){window.clearTimeout(ac)}ac=window.setTimeout(function(){R()},100)}function R(ap){if(ap>J){return}var aq=Q+(ap||1);if(L){L=null;aq=aq.addParam("initialrequest","1");var ar=$("expand-map");if(ar){if(ar.hasClassName("collapse-map")){aq=aq.addParam("collapse","false")}else{aq=aq.addParam("collapse","true")}}}P(aq)}function P(ap){i.setPaginating();MNP.Track.view("MapListSearchResultsPage"+O,"/");Y=ao(ap,Z,I)}function ae(aq){var ar=al,at=aq.source,ap=aq.page;ar=ar.addParam("source",at);ar=ar.addParam("page",ap);if(MNP.Cache.useCache("fp")){ar=ar.addParam("fp",MNP.Cache.get("fp"))}ao(ar,aa,K)}function I(ap){am=ap.data;O=parseFloat(ap.page);J=parseFloat(ap.total_pages);i.update(ap);if(ap.mode=="city"){U()}else{ae(ap)}}function K(ap){an=ap.data;U()}function U(){var aq=i.getResultsTable();var ap=[an,am].join("");aq.innerHTML=ap;i.updatePagination(O,J);i.setSearchComplete();an="";am=""}function ao(ap,ar,aq){function at(av){var au=ah(av,ar);aq(au)}if(MNP.Cache.useCache(ar)){at({responseText:MNP.Cache.get(ar)})}else{return new ak(ap,at)}}function ak(ap,aq){return new SimpleAjax.Request(uncache(ap.addParam("mapVendor","google")),{method:"get",onSuccess:aq})}function ah(ar,aq){var ap=cleanJsonResponse(ar.responseText);MNP.Cache.set(aq,ap);return getEval(ap)}af();return{GetResults:ai}}();return{FindProperties:a,FindNearby:q,enableSearch:n,disableSearch:l,isSearchEnabled:function(){return B}}};MNP.Map.Google.map3={};MNP.Map.create=function(l,p){var k;var n;var e=Object.extend({showBalloon:0,showSwitch:0,customNav:0,fixed:0,zoom:12,slide:0,scrollList:0,latitude:0,longitude:0,bounds:[],markers:[]},p||{});var C,i=this,c=false,f,x=[],y=[];var d=MNP.Map.Marker,r=new MNP.Map.Infobox(this),D=new MNP.Map.ToolTipLabel(this),g;this.mapEl=$(l);var z=e.settings;var s=i.mapInterface;for(var A in s){i[A]=s[A]}function w(){var F;if(!s.apiReady()){s.loadApi(l);return}MNP.Util.attachCss("/css/map/map.css");Element.removeClassName($(l),"mwsmap");if(document.getElementById("map_mapinsert")){Element.remove("map_mapinsert")}if(e.latitude&&e.longitude){F={latitude:e.latitude,longitude:e.longitude}}C=s.Map($(l),F);v();k=Microsoft.Maps.Events.addHandler(C,"tilesloaded",B);B()}function v(){if(!q()){var F=e.zoom||z.zoom.def;if(e.bounds.length>1&&e.markers.length!==1){s.FitBounds(e.bounds)}else{s.Center(e.latitude,e.longitude,F)}}}function B(){i.Events.parentObj=i;if(window.Cons){Cons.Plist.attachMap(i)}if(e.slide){new MNP.UI.SlideManager({parentObject:i})}if(e.searchEnabled){var F=$(z.interfaceElements.searchForm);if(F){g=new MNP.Map.Search(i,F,z,e.searchActive)}if(e.searchActive&&F){function H(){g.FindProperties();c=1}H()}else{a(e.markers)}var G=$(z.interfaceElements.mapToggle);if(G){Event.observe(G,"click",function(J){var I=G;I.blur();setTimeout(function(){c=I.checked;if(c){g.enableSearch();g.FindNearby()}else{g.disableSearch()}},200)})}}else{a(e.markers)}if(MNP.Cache.get("mapEnabled")=="true"){g.enableSearch();g.FindNearby();c=1}Event.observe(window,"unload",function(){g=null;D=null;r=null;s=null});Event.observe(l,"click",h.reset);Microsoft.Maps.Events.addHandler(C,"viewchangestart",h.reset);Microsoft.Maps.Events.addHandler(C,"viewchangeend",h.update);Microsoft.Maps.Events.removeHandler(k);MNP.Page.addLinkClickByRel("close-balloon",function(){r.close(0,0,1)});if(typeof e.afterFinish=="function"){e.afterFinish(i)}}function q(){var G=MNP.Cache.get,F=G("lat");if(F&&F!==""){s.Center(F,G("lon"),parseFloat(G("zoom")));return true}}function a(J){x=J;x.sort(t);var G=J.length;var I=MNP.Map.Provider.google.getMap();I.entities.clear();if(G>0){do{var N=J[G-1];var K=new d.markerObject(N,e.settings);K.id="marker_"+N.property_id;K.zIndex=G+10;Microsoft.Maps.Pushpin.prototype.infobox=null;Microsoft.Maps.Pushpin.prototype.marker=null;Microsoft.Maps.Pushpin.prototype.setInfoBox=function(O,P){this.infobox=O;this.marker=P;this.mouseoverHandler=Microsoft.Maps.Events.addHandler(this,"mouseover",function(R){var Q=this.target;Q.infobox.show(Q.marker);Event.observe("infobox","mouseover",function(){window.clearTimeout(n);n=null});Event.observe("infobox","mouseout",function(){if(n){window.clearTimeout(n);n=null}n=setTimeout(function(){Q.infobox.close();n=null},2000)})});this.mouseoutHandler=Microsoft.Maps.Events.addHandler(this,"mouseout",function(R){var Q=this.target;if(n){window.clearTimeout(n);n=null}n=setTimeout(function(){Q.infobox.close()},2000)})};var M=new Microsoft.Maps.Location(K.lat,K.lon);var L;if(K.style.indexOf("cluster")!=-1){L={id:K.id,icon:"",typeName:K.style,zIndex:G+10,width:"44",height:"58"}}else{L={id:K.id,icon:"",typeName:K.style,zIndex:G+10}}var H=new Microsoft.Maps.Pushpin(M,L);H.setInfoBox(r,K);d.add(K);var F={thisMap:i,InfoboxObject:r,padding:40,options:e,anchorPointLeft:z.markers.anchorPoint,point:new Microsoft.Maps.Location(K.lat,K.lon)};m(H,K,F);I.entities.push(H)}while(--G)}}function m(H,F,G){if(F.type=="cluster"){Microsoft.Maps.Events.addHandler(H,"click",function(){var K=G.point,J=G.padding,M=C.tryLocationToPixel(K);var I=new Microsoft.Maps.Point(M.x-J,M.y+J);I=C.tryPixelToLocation(I);var L=new Microsoft.Maps.Point(M.x+J,M.y-J);L=C.tryPixelToLocation(L);C.setView({bounds:Microsoft.Maps.LocationRect.fromLocations(I,L)})})}else{if(F.type=="city"){Microsoft.Maps.Events.addHandler(H,"click",function(){window.location=F.action})}}}function E(F){d.reset();e.markers=F||[];if(F){u(F);a(F)}}function u(K){var J=[],I=[];for(var G=0;G<K.length;G++){var H=K[G];J[H.id]=H}for(var F in y){if(J[F]){I[F]=y[F]}else{if(y[F].setMap){y[F].setMap(null)}}}y=I}function t(G,F){return(F.lon+F.lat)-(G.lon+G.lat)}function j(){return C}function b(){return c}var h=function(){var F=true;function G(K){var J;if(K){var I=Event.element(K);if(Element.hasClassName(I,"mnpmarker")||(I.parentNode&&Element.hasClassName(I.parentNode,"mnpmarker"))){J=1}if(I.parentNode&&Element.hasClassName(I.parentNode,"mnpmarker")){J=1}}if(!J){D.close();r.close(null,null,1)}}function H(){if(f){window.clearTimeout(f)}D.close();r.close(null,null,1);if(g&&g.isSearchEnabled()){f=window.setTimeout(function(){g.FindNearby();MNP.Cache.set("fplistcache","");MNP.Cache.set("plistcache","");MNP.Cache.set("mapcache","")},100)}}return{reset:G,update:H,disable:function(){F=false},enable:function(){F=true},isEnabled:function(){return F}}}();var o={addNewMarkers:E,addMarkers:a,init:w,getMap:j,centerMap:v,ToolTipLabel:D,Label:D,Infobox:r,Marker:d,UI:h,getSearchActive:b,Search:g,clearTimer:function(){if(n){window.clearTimeout(n)}n=null},getSearch:function(){return g}};for(var A in o){i[A]=o[A]}MNP.Map.Maps[l]=i;w();return i};MNP.Map.create.prototype.mapInterface=MNP.Map.Provider.google;MNP.Map.create.prototype.Events={parentObj:null,mouseover:function(a){this.parentObj.ToolTipLabel.show(a);if(a){a.highlightOn()}},mouseout:function(a){this.parentObj.ToolTipLabel.close(a,10);if(a){a.highlightOff()}}};
