var MapViewType={ROAD:0,AERIAL:1,HYBRID:2,STREET:3,BIRDSEYE:4,TERRAIN:5,BIRDSEYEHYBRID:6,OBLIQUE:7,SHADED:8},G_STREET_TYPE="Z",MapModes={Mode2D:0,Mode3D:1},LatLong={Lat:0,Long:1},MapEngines={Google:0,Bing:1},DashBoardSize={Normal:0},GoogleMapViewTypes=[],BingMapViewTypes=[],BingMapModes=[];function Maps(a){this.mapType=MapEngines.Google;this.earth_radius=3963.191;this.map_initialised=false;this.sv_initialised=false;this.map=null;this.streetview={hasStreetView:true,flashSupport:true,proplatlong:null,panoClient:null,myPano:null,myPOV:null,yaw:null,panoOptions:{}};this.mapContainer=null;this.svContainer=null;this.mapTabs=null;this.dash=null;this.mapPoint=null;this.haltServices=false;this.infoWindows=[];this.mapOptions={zoom:5,mapId:"#map",streetViewId:"#streetview",center:[54.071032055,-2.78397635452],mapstyle:MapViewType.ROAD,EnableBirdseye:false,enableDragging:true,enableInfoWindow:true,enableDoubleClickZoom:true,enableScrollWheelZoom:true,ShowSwitch:true,Fixed:false,MapMode:MapModes.Mode2D,ShowDashboard:true,ShowFindControl:false,ShowMiniMap:false,shapeDetailUrl:"/property/gmap_shapeDetails/id/[referenceId]/",infoWindowUrl:"/property/gmap_descriptionTabs/ids/[referenceIds]/",descriptionMaxWidth:300,DashboardSize:DashBoardSize.Normal,panControl:false,zoomControl:false,scaleControl:false,googleOptions:{},agentView:false,resultsView:false,searchUrl:"",ignore:null,circuit:null};this.mapOptions=$.extend(this.mapOptions,a||{});this.additionalTypes={Attraction:{data:null,icon:"attractionicon",inRange:false,minZoomLevel:12,on:false,url:"1/",zoomLevel:1},Restaurant:{data:null,icon:"restauranticon",inRange:false,minZoomLevel:12,on:false,url:"18/st/23/",zoomLevel:1},School:{data:null,icon:"schoolicon",inRange:false,minZoomLevel:12,on:false,url:"24/",zoomLevel:1},Transport:{data:null,icon:null,inRange:false,minZoomLevel:12,on:false,url:"31/st/",zoomLevel:1}};this.localPropertiesOn=false;}Maps.prototype.InitMap=function(){if(this.mapOptions.mapstyle==MapViewType.BIRDSEYEHYBRID){this.mapOptions.mapstyle=MapViewType.ROAD;}this.mapContainer=$(this.mapOptions.mapId);if(typeof this.mapOptions.rectangle!=="undefined"){var a=this.calculateView(this.mapOptions.rectangle);this.mapOptions.center=a.centerPoint;this.mapOptions.zoom=a.zoom;}if(this.mapType==MapEngines.Google){this.InitGoogleMap(false);}this.initNavigation(null,true);};Maps.prototype.InitMapWithStreetView=function(){this.InitMap();this.InitStreetView();};Maps.prototype.InitGoogleMap=function(a){GoogleMapViewTypes=[google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.SATELLITE,google.maps.MapTypeId.HYBRID,null,google.maps.MapTypeId.ROADMAP,google.maps.MapTypeId.TERRAIN,google.maps.MapTypeId.ROADMAP,null,null];if(a!=true){a=false;}if(this.mapContainer.length>0){if(typeof google.maps.Map!="undefined"){var b={zoom:this.mapOptions.zoom,center:this.getLatLng(this.mapOptions.center),mapTypeId:GoogleMapViewTypes[this.mapOptions.mapstyle],disableDefaultUI:this.mapOptions.ShowDashboard,panControl:this.mapOptions.panControl,zoomControl:this.mapOptions.zoomControl,scaleControl:this.mapOptions.scaleControl,streetViewControl:a,addressControl:false,draggable:this.mapOptions.enableDragging};$.extend(true,b,this.mapOptions.googleOptions||{});this.map=new google.maps.Map(this.mapContainer[0],b);$.each(this.additionalTypes,function(d,f){f.inRange=(f.minZoomLevel<b.zoom);if(!f.inRange){var e="plot"+d+"Control";$("li."+e).attr("class",e+"Disabled");}});this.map_initialised=true;}}};Maps.prototype.InitStreetViewLink=function(a){this.referenceId=typeof a.referenceId==="undefined"?"":a.referenceId;this.circuit=typeof a.circuit==="undefined"?"":a.circuit;this.lat=typeof a.lat==="undefined"?0:a.lat;this.lng=typeof a.lng==="undefined"?0:a.lng;this.panoramaLat=typeof a.panoramaLat==="undefined"?0:a.panoramaLat;this.panoramaLng=typeof a.panoramaLng==="undefined"?0:a.panoramaLng;this.linkContainerId=typeof a.linkContainerId==="undefined"?"":a.linkContainerId;this.overlayId=typeof a.overlayId==="undefined"?"":a.overlayId;this.panoContainerId=typeof a.panoContainerId==="undefined"?"":a.panoContainerId;this.orientationMsgContainerId=typeof a.orientationMsgContainerId==="undefined"?"":a.orientationMsgContainerId;this.client=null;this.place=null;var b=this;this.getNearestPanoramaLatLng=function(c){if(this.place===null){this.place=new google.maps.LatLng(this.lat,this.lng);this.client=new google.maps.StreetViewService();}this.client.getPanoramaByLocation(this.place,50,c);};this.getPanoramaExists=function(){this.getNearestPanoramaLatLng(this.setLocalInfoImageState);};this.setLocalInfoImageState=function(d,c){if((typeof window.arrow!=="undefined")&&(c==="OK")){window.arrow.setStreetviewOn();}};this.getPanoramaLink=function(){this.getNearestPanoramaLatLng(this.setPanoramaLink);};this.setPanoramaLink=function(e,d){if(e!=null){var f="/"+b.circuit+"/streetview/id/"+b.referenceId+"/";var c=$("a[id$="+b.linkContainerId+"]","#StreetviewTab");if(typeof c!=="undefined"){jQuery(c).click(function(){var g=window.open(f,"GStreetviewPanorama","height=650,width=800,toolbar=0");g.focus();return false;});}else{jQuery("#StreetviewTab").hide();}}};};Maps.prototype.InitStreetView=function(){if(!this.sv_initialised){if(typeof(this.mapOptions.center[LatLong.Long])!="undefined"&&typeof(this.mapOptions.center[LatLong.Lat])!="undefined"){this.streetview.proplatlng=this.getLatLng(this.mapOptions.center);var a={position:this.streetview.proplatlng,features:{userPhotos:false},enableFullScreen:false,enableCloseButton:false,addressControl:false,navigationControl:false,navigationControlOptions:{style:google.maps.NavigationControlStyle.DEFAULT,position:google.maps.ControlPosition.LEFT}};$.extend(true,a,this.streetview.panoOptions||{});if(this.mapType===MapEngines.Google){if(this.mapContainer.length>0){this.svContainer=this.mapContainer;}else{this.svContainer=$(this.mapOptions.streetViewId);}}this.streetview.myPano=new google.maps.StreetViewPanorama(this.svContainer[0],a);var b=this;this.bind(this.streetview.myPano,"error",b.handleNoFlash);this.bind(this.streetview.myPano,"pov_changed",function(){b.handlePovChanged();});if(this.dash==null){this.dash=new GoogleMapDashboard(this.map,this.mapOptions.EnableBirdseye,this.streetview.myPano);this.dash.dashboard=this.mapTabs;}this.dash.pano=this.streetview.myPano;this.dash.dashboard.append(this.dash.getPanoZoomControls()).addClass("panoActive");if(typeof(this.streetview.yaw)!="undefined"){yaw=parseInt(this.streetview.yaw);if(isNaN(yaw)){yaw=0;}}else{yaw=this.computeAngle(this.streetview.myPano.getPosition(),this.streetview.proplatlng);}this.streetview.myPOV={heading:yaw,pitch:-10,zoom:1};this.streetview.myPano.setPov(this.streetview.myPOV);this.sv_initialised=true;}}else{if(this.dash==null){this.dash=new GoogleMapDashboard(this.map,this.mapOptions.EnableBirdseye,this.streetview.myPano);this.dash.dashboard=this.mapTabs;}this.dash.dashboard.addClass("panoActive");this.streetview.myPano.setVisible(true);}};Maps.prototype.initNavigation=function(a,b){if(typeof(b)=="undefined"){b=false;}if(this.mapTabs&&this.mapTabs.length>0){this.BindViewHandlers(this.mapTabs,b);}else{if(this.mapOptions.ShowDashboard){if(this.mapType==MapEngines.Google){this.dash=new GoogleMapDashboard(this.map,this.mapOptions.EnableBirdseye,this.streetview.myPano);this.dash.Init();this.mapTabs=this.dash.dashboard.find("#mapTabs");this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(this.dash.CreateDashboard()[0]);this.mapContainer.append(this.dash.dashboard.css({zIndex:10,position:"absolute",top:0,left:0}));this.map.controls[google.maps.ControlPosition.LEFT].push(this.dash.InitPanMapControl()[0]);this.initNavigation(null,b);}}else{if(a&&a.length>0){this.mapTabs=$(a);this.initNavigation(null,b);}}}};Maps.prototype.initNavigation=function(a,b){if(this.mapOptions.ShowDashboard){this.dash=new GoogleMapDashboard(this.map,this.mapOptions.EnableBirdseye,this.streetview.myPano);this.dash.dashboard=this.mapContainer;this.dash.dashboard.before(this.mapTabs=$(MapDashboard.createDiv("mapTabs")).append($('<ul id="mapViewControl" class="tab_list">'+((this.streetview.hasStreetView)?'<li id="streetviewbutton"><span>Street View</span></li>':"")+'<li id="roadbutton"><span>Map</span></li><li id="satellitebutton"><span>Satellite</span></li><li id="hybridbutton"><span>Satellite &amp; Map</span></li><li id="terrainbutton"><span>Terrain</span></li></ul>')));this.BindViewHandlers(this.mapTabs,b);}};Maps.prototype.handlePovChanged=function(){var b=this.streetview.myPano.getPov().heading;this.mapTabs.siblings("#messagebox").html("You are facing "+a(b));function a(c){if(c>=337.5||c<=22.49){return"north";}else{if(c>=22.5&&c<=67.49){return"north east";}else{if(c>=67.5&&c<=112.49){return"east";}else{if(c>=112.5&&c<=157.49){return"south east";}else{if(c>=157.5&&c<=202.49){return"south";}else{if(c>=202.5&&c<=247.49){return"south west";}else{if(c>=247.5&&c<=292.49){return"west";}else{if(c>=292.49&&c<=337.49){return"north west";}}}}}}}}}};Maps.prototype.handlePovChanged=function(){};Maps.prototype.BindViewHandlers=function(b,a){var c=this;b.bind("click",function(h){var d=h.target,g=$(d).closest("li, div"),f=MapViewType.ROAD;if(d.tagName=="A"||d.tagName=="SPAN"||d.tagName=="INPUT"){switch(g[0].id){case"roadbutton":f=MapViewType.ROAD;break;case"aerialbutton":f=MapViewType.AERIAL;if($("#roadtoggle").find(":checkbox")[0].checked){f=MapViewType.HYBRID;}break;case"roadtoggle":if(d.checked){f=MapViewType.HYBRID;g=$("#aerialbutton");}else{f=MapViewType.AERIAL;g=$("#aerialbutton");}break;case"birdseyebutton":f=MapViewType.BIRD;break;case"terrainbutton":f=MapViewType.TERRAIN;break;case"streetviewbutton":f=MapViewType.STREET;break;case"hybridbutton":f=MapViewType.HYBRID;break;case"satellitebutton":f=MapViewType.AERIAL;break;}c.setMapType(f,a,g);}});};Maps.prototype.PanoramaAvailable=function(a,c){var d=new google.maps.StreetViewService(),b=(a instanceof google.maps.LatLng)?a:new google.maps.LatLng(a[LatLong.Lat],a[LatLong.Long]);d.getPanoramaByLocation(b,50,c);};Maps.prototype.distance=function(j,h,g,e){var m=6371007;var f=Math.PI/180;var n=(g-j)*f;var l=(e-h)*f;var i=Math.sin(n/2)*Math.sin(n/2)+Math.cos(j*f)*Math.cos(g*f)*Math.sin(l/2)*Math.sin(l/2);var k=2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i));var b=m*k;return b;};Maps.prototype.calculateView=function(l){var f=new Array(78271.52,39135.76,19567.88,9783.94,4891.97,2445.98,1222.99,611.5,305.75,152.87,76.44,38.22,19.11,9.55,4.78,2.39,1.19,0.6,0.3);var h=l.sw[LatLong.Lat];var i=l.ne[LatLong.Lat];var t=l.ne[LatLong.Long];var a=l.sw[LatLong.Long];var q=(h+i)/2,c=(t+a)/2;var o=this.distance(q,a,q,t);var p=this.distance(h,c,i,c);var e=parseFloat(this.mapContainer.width(),10),s=parseFloat(this.mapContainer.height(),10);var d=o/e,n=p/s;var r=(d>n)?d:n;var k=156543.04*Math.cos(q*Math.PI/180);var g=Math.log(k/r);var j=Math.log(2);var b=Math.max(1,Math.min(Math.floor(g/j),19));return{centerPoint:[q,c],zoom:b};};Maps.prototype.computeAngle=function(g,e){var f=Math.PI/180,a=180/Math.PI,b=e.lat()-g.lat(),d=e.lng()-g.lng(),c=Math.atan2(d*Math.cos(e.lat()*f),b)*a;return this.wrapAngle(c);};Maps.prototype.wrapAngle=function(a){if(a>=360){a-=360;}else{if(a<0){a+=360;}}return a;};Maps.prototype.handleNoFlash=function(a){if(a==603){this.flash_support=false;this.hasStreetView=false;if(typeof HandleNoStreetView=="function"){HandleNoStreetView.call(this);}this.setMapType(MapViewType.ROAD,true);return;}};Maps.prototype.setGoogleMapType=function(a){if(this.map==null){return;}if(GoogleMapViewTypes[a]!=null){this.map.setMapTypeId(GoogleMapViewTypes[a]);}};Maps.prototype.setMapType=function(c,b,a){if(this.map==null){return;}if(a&&a.hasClass("notavailable")){return;}this.mapOptions.mapstyle=c;if(typeof(b)=="undefined"){b=false;}if(typeof(c)=="undefined"||c===""){var c=this.mapOptions.mapstyle;}if(this.mapType==MapEngines.Google){this.setGoogleMapType(c);}if(this.mapTabs&&this.mapTabs.length>0){if(this.mapContainer.data("selectedTab")){this.mapContainer.data("selectedTab").removeClass("selected");}else{this.mapContainer.find(".selected").removeClass("selected");}if(a){this.mapContainer.data("selectedTab",a.addClass("selected"));}}(c==MapViewType.ROAD||c==MapViewType.STREET)?$("#roadtoggle").hide():$("#roadtoggle").show();if(b){if(c==MapViewType.STREET){this.clearInfoWindows();this.InitStreetView();}else{if(this.sv_initialised===true){this.streetview.myPano.setVisible(false);this.dash.dashboard.removeClass("panoActive");this.dash.dashboard.find("#messagebox").empty();}}}};Maps.prototype.toggleStreetView=function(){var a=this.streetview.myPano.getVisible();if(a==false){this.streetview.myPano.setVisible(true);}else{this.streetview.myPano.setVisible(false);}};Maps.prototype.GetMapView=function(){if(this.mapType==MapEngines.Google){var c=this.map.getBounds();if(c){var a=c.getNorthEast(),d=c.getSouthWest();return{sw:[d.lat(),d.lng()],ne:[a.lat(),a.lng()]};}else{return this.mapOptions.rectangle;}}};Maps.prototype.groupPropertyData=function(f){var b=65;var h=f.recordcount;var m={};for(var j=0;j<h;j++){var e=f.data.referenceid[j],o=f.data.description[j],g=f.data.title[j],l=f.data.latitude[j],a=f.data.longitude[j],k="<div><div>"+o+"</div></div>";if(l!=""&&a!=""){var n=String.fromCharCode(b++),p=[l,a];m=this.appendDataRow(m,p,g,n,k);}}return m;};Maps.prototype.groupLocalPropertyData=function(j,f){var e=j.recordcount;var h={};for(var b=0,m;b<e;b++){m=j.data;var l=m.latitude[b],k=m.longitude[b];if(m.referenceid[b]!=f&&l!=""&&k!=""){var c=[l,k],d=j.data.title[b],g=parseInt(m.bedrooms[b],10),a=(isNaN(g)||g===0)?"-":(g>9)?"+":g;h=this.appendDataRow(h,c,d,a,m.description[b]);}}return h;};Maps.prototype.groupAgentData=function(o){var b=65;var f=o.recordcount;var m={};for(var j=0;j<f;j++){var h=o.data.agentcode[j];var g=o.data.description[j];var k=o.data.title[j];var e=o.data.url[j];var c=o.data.latitude[j];var a=o.data.longitude[j];var l="";l+="<div>";l+="<div>"+g+"</div>";l+="</div>";if(c!=""&&a!=""){var d="";var n=[c,a];m=this.appendAgentDataRow(m,n,k,d,l,e);}}return m;};Maps.prototype.appendDataRow=function(f,b,c,a,e){var g=b.toString();g="ll_"+g.replace(/[\(,\.\s\)-]/g,"_");if(typeof f[g]==="undefined"){f[g]={character:a,description:[],labels:{},ll:b,title:c};}else{f[g].character="+";}f[g].description.push(e);var d=f[g].description;if(d.length>1){f[g].title=d.length+" Properties";}f.size=typeof f.size==="undefined"?0:f.size;f.size++;return f;};Maps.prototype.appendAgentDataRow=function(j,l,g,b,d,i){var e=l.toString();e="ll_"+e.replace(/[\(,\.\s\)-]/g,"_");var k='<a href="'+i+'">'+g+"</a>";var f=d;if(typeof j[e]==="undefined"){j[e]={character:b,description:[],labels:{},ll:l,title:k,url:i};}else{j[e].character="+";f="<br />"+k+"<br />"+f;}j[e].description.push(f);var h=j[e].description;if(h.length==2){var a=j[e].description[0];var m=j[e].title;var c="<br />"+m+"<br />"+a;j[e].description[0]=c;}if(h.length>1){j[e].title=h.length+" Branches";}j.size=typeof j.size=="undefined"?0:j.size;j.size++;return j;};Maps.prototype.validCoords=function(c,a,d){var b=[c,a];if((c===0)||(a===0)){return false;}d=d||this.GetMapView();if(this.mapType==MapEngines.Google){if((c<d.ne[LatLong.Lat])&&(c>d.sw[LatLong.Lat])&&(a<d.ne[LatLong.Long])&&(a>d.sw[LatLong.Long])){return[c,a];}else{return false;}}else{var b=(c instanceof VELatLong)?c:(typeof c=="number"&&typeof a=="number")?new VELatLong(c,a):null;if((b.Latitude<d.ne[LatLong.Lat])&&(b.Latitude>d.sw[LatLong.Lat])&&(b.Longitude>d.ne[LatLong.Long])&&(b.Longitude<d.sw[LatLong.Long])){return b;}}return false;};Maps.prototype.DeleteShapeLayer=function(a){if(this.mapType===MapEngines.Google){if(a.length>0){$.each(a,function(b,c){c.setMap(null);});a.length=0;}}else{this.map.DeleteShapeLayer(a);}};Maps.prototype.getLatLngArray=function(a){if(this.mapType===MapEngines.Google){return[a.lat(),a.lng()];}else{return[a.Latitude,a.Longitude];}return[0,0];};Maps.prototype.getLatLng=function(a){if(this.mapType===MapEngines.Google){return new google.maps.LatLng(a[LatLong.Lat],a[LatLong.Long]);}else{return new VELatLong(a[LatLong.Lat],a[LatLong.Long]);}return null;};Maps.prototype.getBounds=function(b,a){if(this.mapType===MapEngines.Google){return new google.maps.LatLngBounds(this.getLatLng(b),this.getLatLng(a));}else{return new VERectangle(this.getLatLng(a),this.getLatLng(b));}return null;};Maps.prototype.GetZoom=function(){var a=this.mapOptions.zoom;if(this.mapType===MapEngines.Google){a=this.map.getZoom();}else{a=this.map.GetZoomLevel();}return a;};Maps.prototype.bind=function(a,d,e,c){if(c!==true){c=false;}var b=null;if(this.mapType===MapEngines.Google){b=(c)?google.maps.event.addDomListener(a,d,e):google.maps.event.addListener(a,d,e);}else{switch(d){case"dragend":d="onendpan";break;case"zoom_changed":d="onendzoom";break;default:d="on"+d;break;}this.AttachEvent(d,e);}return b;};Maps.prototype.unbind=function(a,b,c){if(this.mapType===MapEngines.Google){if(typeof a!=="undefined"&&a!==null){google.maps.event.removeListener(a);}}else{switch(b){case"dragend":b="onendpan";break;case"zoom_changed":b="onendzoom";break;}this.map.DetachEvent(b,c);}};Maps.prototype.Clear=function(){if(this.mapContainer.data("defaultLabels")){this.DeleteShapeLayer(this.mapContainer.data("defaultLabels"));this.mapContainer.data("defaultLabels",null);}};Maps.prototype.PixelToLatLong=function(a,b){if(this.mapType===MapEngines.Google){return this.getLatLngArray(this.map.getProjection().fromPointToLatLng(this.getPixel(a)));}else{return this.getLatLngArray(this.map.PixelToLatLong(this.getPixel(a),b));}};Maps.prototype.getPixel=function(b){var a=null;if(this.mapType===MapEngines.Google){a=new google.maps.Point(b.x,b.y);}else{a=new VEPixel();a.x=b.x;a.y=b.y;}return a;};Maps.prototype.plotDefaultShape=function(c,d,a,b,f,e){var g=this.getDefaultShape(c,d,a,b);if(typeof e!=="undefined"){var h=[];if(this.mapType===MapEngines.Google){h=g.get("listeners");}h.push(this.bind(g.label,"click",function(i){_self.clusterClick(e);},true));}return g;};Maps.prototype.plotInlineAgents=function(){if(this.mapType==MapEngines.Google){var b=$("a","div.agentLister");var a={columnlist:"agentcode,description,latitude,longitude,title,url",data:{},recordcount:b.length};$.each(a.columnlist.split(","),function(c,d){a.data[d]=[];});b.each(function(d){var e={},c=this.rel.substr(this.rel.indexOf(":")+1).replace(/[\{\}]/g,"").split(","),f=$(this);$.each(c,function(h,j){var g=j.split(":");if(g[0]=="code"){e[g[0]]=g[1].replace(/'/g,"");}else{e[g[0]]=parseFloat(g[1]);}});if((e.lat!==0)&&(e.lng!==0)){a.data.agentcode.push(e.code);a.data.latitude.push(e.lat);a.data.longitude.push(e.lng);a.data.description.push(f.parent().next().text());a.data.title.push(f.text());a.data.url.push(this.href);}});this.plotAgentsSub(a);}};Maps.prototype.plotAgentsSub=function(g){var b=this.groupAgentData(g);var l=[];for(var c in b){if(c.substring(0,3)=="ll_"){var j=b[c];var e=j.title;var d=j.ll;var a=j.character;var h=j.description;var f=j.url;var k=this.getAgentShape(d,e,a,h,f);l.push(k);}}if(l.length>0){if(this.mapType===MapEngines.Bing){var i=new VEShapeLayer();plMap.AddShapeLayer(i);i.AddShape(l);}}};Maps.prototype.plotAgents=function(b){var a=function(d){var c=$.parseJSON(d.d);if(c===null){return;}this.plotAgentsSub(c);};$.ajax({type:"POST",url:"/svc/mapresultsservice.asmx/GetAgentBranchResults",contentType:"application/json; charset=utf-8",dataType:"json",data:"{'searchRequest':'"+b+"'}",success:function(c){a(c);}});};Maps.prototype.togglePlotAdditionals=function(a){var g=a.target.tagName.toLowerCase();if(("span|input").indexOf(g)===-1){return;}var c=window.map;a=$(a.target).parent(),className=a.attr("class");if(className==="plotLocalPropertiesControl"){if(a.find(":checkbox")[0].checked){c.togglePlotLocalProperties(true);}else{c.togglePlotLocalProperties(false);}}else{var e=/^plot(.*?)Control(Disabled|On)?$/.exec(className)[1];if((e==="")||(!window.map.additionalTypes[e].inRange&&!window.map.additionalTypes[e].on)){return;}a.data("on",typeof a.data("on")==="undefined"?true:a.data("on"));if(a.data("on")){var h=true;$.each(window.map.additionalTypes,function(i,j){if(j.on===true){h=false;return false;}});c.additionalTypes[e].on=true;a.attr("class","plot"+e+"ControlOn");c.plotAdditionalType(e);if(h===true){c.mapContainer.data("dragendPOI",c.bind(c.map,"dragend",function(){var i={eventName:"onendpan"};c.plotAdditionals.call(c,i);}));c.mapContainer.data("zoom_changedPOI",c.bind(c.map,"zoom_changed",function(){var i={eventName:"onendzoom"};c.plotAdditionals.call(c,i);}));}}else{window.map.additionalTypes[e].on=false;a.attr("class","plot"+e+"Control"+(window.map.additionalTypes[e].inRange?"":"Disabled"));var b=e.toLowerCase()+"ShapeLayer";var d=(c.mapType==MapEngines.Google)?c.mapContainer.data(b):c.map[b];if(typeof d!=="undefined"){c.DeleteShapeLayer(d);if(window.map.mapType==MapEngines.Google){}else{delete window.map[b];}}var f=true;$.each(window.map.additionalTypes,function(i,j){if(j.on===true){f=false;return false;}});if(f){if(c.mapContainer.data("dragendPOI")&&c.mapContainer.data("dragendPOI")!=null){c.unbind(c.mapContainer.data("dragendPOI"),"dragend",c.plotAdditionals);}if(c.mapContainer.data("zoom_changedPOI")&&c.mapContainer.data("zoom_changedPOI")!=null){c.unbind(c.mapContainer.data("zoom_changedPOI"),"zoom_changed",c.plotAdditionals);}c.mapContainer.data("dragendPOI",null);c.mapContainer.data("zoom_changedPOI",null);}}a.data("on",!a.data("on"));}};Maps.prototype.plotSearchResults=function(a){var b=function(o){if(o.d===null){return;}var l=this.groupPropertyData(o.d);var q=[],h=[];for(var p in l){if(p.substring(0,3)=="ll_"){var m=l[p],j=m.title,k=m.ll,n=m.character,g=m.description,e=this.getDefaultShape(k,j,n,g);q.push(e);h.push(k);}}if(h.length>0){var d=h[0],i=h[0];this.unbind(this.mapContainer.data("dragend"),"dragend",function(){SearchMapControlManager.prototype.toggleMapSearchControls({eventName:"dragend"});});this.unbind(this.mapContainer.data("zoom_changed"),"zoom_changed",function(){SearchMapControlManager.prototype.toggleMapSearchControls({eventName:"zoom_changed"});});this.mapContainer.data("dragend",null);this.mapContainer.data("zoom_changed",null);if(this.mapType===MapEngines.Bing){var f=new VEShapeLayer();this.map.AddShapeLayer(f);f.AddShape(q);}$.each(h,function(r,s){d[LatLong.Lat]=Math.max(s[LatLong.Lat],d[LatLong.Lat]);d[LatLong.Long]=Math.min(s[LatLong.Long],d[LatLong.Long]);i[LatLong.Lat]=Math.min(s[LatLong.Lat],i[LatLong.Lat]);i[LatLong.Long]=Math.max(s[LatLong.Long],i[LatLong.Long]);});if(q.length===1){this.SetCenterAndZoom(d,14);}else{this.SetView({sw:i,ne:d});}}};var c=this;$.ajax({type:"POST",url:"/svc/mapresultsservice.asmx/GetPropertyResults",contentType:"application/json; charset=utf-8",dataType:"json",data:'{"propertyIdList":"'+a+'"}',success:function(d){b.call(c,d);}});};Maps.prototype.SetCenterAndZoom=function(b,a){if(this.mapType===MapEngines.Google){this.map.setCenter(this.getLatLng(b));this.map.setZoom(a);}else{this.map.SetCenterAndZoom(this.getLatLng(b),a);}};Maps.prototype.SetView=function(a){if(this.mapType===MapEngines.Google){this.map.panToBounds(this.getBounds(a.sw,a.ne));}else{this.map.SetMapView(this.getBounds(a.sw,a.ne));}};Maps.prototype.plotAdditionals=function(f){var d=this.GetZoom(),a,c=(f.eventName==="onendpan");for(var b in this.additionalTypes){a=this.additionalTypes[b];if(a.on===true){if(!c){c=!a.inRange;}if(c){this.additionalTypes[b].data=null;if(f.eventName==="onendzoom"){c=false;}}this.plotAdditionalType(b);}}};Maps.prototype.plotAdditionalType=function(h){if(h===""){return;}if(this.haltServices){this.haltServices=false;return;}var m=this.additionalTypes[h].minZoomLevel,n=this.GetZoom();var r=this;var g=function(F,E){if(E){r.additionalTypes[h].data=F;r.additionalTypes[h].zoomLevel=n;}var G=F.d;if((G===null)||((typeof G.recordcount!=="undefined")&&(G.recordcount==0))){return;}var H=[];var w=r.additionalTypes[h].icon;var u=r.buildPoiIcon(w);for(var x=0,B=G.recordcount;x<B;x++){var D=r.validCoords(G.data.latitude[x],G.data.longitude[x],k);if(D!=false){var A=[G.data.description[x]],C=G.data.title[x];if(h=="Transport"){w=G.data.subtype[x].toLowerCase().replace(/\s/g,"_")+"icon";u=r.buildPoiIcon(w);}var t=r.getShape(D,C,u,A);if(h=="Transport"){t.subtypeid=G.data.subtypeid[x];}H.push(t);}}var z=h.toLowerCase()+"ShapeLayer";if(this.mapType==MapEngines.Bing){if(H.length>0){if(typeof this.map[z]!=="undefined"){r.map.DeleteShapeLayer(plMap[z]);delete plMap[z];}r.map[z]=new VEShapeLayer();r.map.AddShapeLayer(this.map[z]);if(h=="Transport"){for(var y=0,v=H.length;y<v;++y){t=H[y];switch(t.subtypeid){case 35:case 36:case 37:t.SetMaxZoomLevel(14);H[y]=t;break;}}}r.map[z].AddShape(H);}}else{if(r.mapContainer.data(z)&&r.mapContainer.data(z).length>0){r.DeleteShapeLayer(r.mapContainer.data(z));r.mapContainer.data(z,null);}r.mapContainer.data(z,H);}};var p="",a="32,33,34,35,36,37",k=null,d=MapViewType.ROAD;if(this.mapType===MapEngines.Google){k=this.GetMapView();}else{k=(d==BingMapViewTypes[MapViewType.BIRDSEYE]||d==BingMapViewTypes[MapViewType.BIRDSEYEHYBRID])?this.map.GetBirdseyeScene().GetBoundingRectangle():this.map.GetMapView();}var l=k.ne,o=k.sw;if((typeof o[LatLong.Lat]==="undefined")||(o[LatLong.Lat]===null)||(typeof l[LatLong.Lat]==="undefined")||(l[LatLong.Lat]===null)||(typeof o[LatLong.Long]==="undefined")||(o[LatLong.Long]===null)||(typeof l[LatLong.Long]==="undefined")||(l[LatLong.Long]===null)){var e=this.mapContainer;if(this.mapType===MapEngines.Bing){var i=this.map.PixelToLatLong(new VEPixel(0,0),this.map.GetZoomLevel());l=[i.Latitude,i.Longitude];i=this.map.PixelToLatLong(new VEPixel(e.width(),e.height()),this.map.GetZoomLevel());o=[i.Latitude,i.Longitude];k={sw:o,ne:l};}else{var i;}}var j=l[LatLong.Lat],b=o[LatLong.Long];var f=o[LatLong.Lat],q=l[LatLong.Long];var c="/"+this.mapOptions.circuit+"/poisearch/nt/"+f+"/xt/"+j+"/ng/"+q+"/xg/"+b+"/t/"+this.additionalTypes[h].url;if(h=="Transport"){if(typeof this.mapOptions.resultsView!=="undefined"&&this.mapOptions.resultsView===true){p="rv/1/";a="32,33,34,35,36,37";}c+=a+"/"+p;}if(this.additionalTypes[h].data!==null){g(this.additionalTypes[h].data,false);return;}if(n>m){$.ajax({type:"POST",url:"/svc/mapresultsservice.asmx/Get"+h+"Results",contentType:"application/json; charset=utf-8",dataType:"json",data:'{"neLatitude":'+o[LatLong.Lat]+', "neLongitude":'+o[LatLong.Long]+',"swLatitude":'+l[LatLong.Lat]+', "swLongitude":'+l[LatLong.Long]+"}",success:function(s){g(s,true);}});}};Maps.prototype.plotPrimaryShape=function(c,e,b,d){var a="/content/images-2011/maps/primary.gif";this.plotShape(c,"",a,null);};Maps.prototype.plotBrowseClusterShape=function(b,c,f,a,d,e,h){if(typeof b.lat!=="undefined"){b=[b.lat,b.lng];}var g=this.getBrowseClusterShape(b,c,f,a,d,h);return g;};Maps.prototype.plotPrimaryClusterShape=function(b,c,e,a,d){if(typeof b.lat!=="undefined"){b=[b.lat,b.lng];}var f=this.getPrimaryClusterShape(b,c,e,a);return f;};Maps.prototype.buildPoiIcon=function(b){if(this.mapType===MapEngines.Google){var a;switch(b){case null:case"metroicon":case"metro_and_railicon":case"railicon":a="rail";break;case"ferriesicon":a="boat";break;case"airportsicon":a="airport";case"busicon":a="bus";case"schoolicon":a="school1";break;case"restauranticon":a="food";break;case"attractionicon":a="attractions";break;default:a="rail.png";break;}return"/content/images-2011/maps/"+a+".png";}else{return'<div class="'+b+'">&nbsp;</div>';}};Maps.prototype.buildBrowseClusterIcon=function(a,b){return['<span class="browse',(b=="background"?"related":""),'clustericon">',(a||""),"</span>"].join("");};Maps.prototype.buildPrimaryClusterIcon=function(a){return'<span class="primaryclustericon">'+(a||"")+"</span>";};Maps.prototype.buildDefaultIcon=function(a){return'<div class="defaulticon">'+(a||"")+"</div>";};Maps.prototype.getDefaultShape=function(b,c,e,a){var d=this.buildDefaultIcon(e);var f=this.getLabel(b,c,d,a);return f;};Maps.prototype.getAgentShape=function(b,c,f,a,d){var e=this.buildDefaultIcon(f);var g=this.getLabel(b,c,e,a);if(this.mapType===MapEngines.Google){listeners=g.get("listeners");}listeners.push(this.bind(g.label,"click",function(h){_self.clusterClick(d);},true));listeners.push(this.bind(g.label,"doubleclick",function(h){_self.clusterClick(d);},true));return g;};Maps.prototype.getBrowseClusterShape=function(b,d,h,a,f,k){var g=this.buildBrowseClusterIcon(h,k);var c=[];if(a&&a.length>0){c=['<div class="browseclusterdescription">'+(a||"")+"</div>"];}var i=this.getLabel(b,h,g,c),e=this,j=[];if(this.mapType===MapEngines.Google){j=i.get("listeners");}j.push(this.bind(i.label,"click",function(l){e.clusterClick(f);},true));j.push(this.bind(i.label,"doubleclick",function(l){e.clusterClick(f);},true));return i;};Maps.prototype.getPrimaryClusterShape=function(b,d,h,a,f){var g=this.buildPrimaryClusterIcon(h);var c=['<span class="browseclusterdescription">'+(a||"")+"</span>"];var i=this.getLabel(b,h,g,c),e=this,j=[];if(this.mapType===MapEngines.Google){j=i.get("listeners");}j.push(this.bind(i.label,"click",function(k){e.clusterClick(f);},true));j.push(this.bind(i.label,"doubleclick",function(k){e.clusterClick(f);},true));return i;};Maps.prototype.clusterClick=function(a){if(typeof a!="undefined"){location.href=a;}};Maps.prototype.getLabel=function(b,d,g,a){var h=new GoogleLabel({map:this.map,text:g,title:d,position:this.getLatLng(b)});var c="",i=35;if(a&&a.length>0){if(typeof a==="string"){a=[a];}c=['<div class="',"infowindow"+(a.length>1?" multi_infowindow":""),'">',a.join(""),"</div>"];c=c.join("");}if(c.length>0){var f=h.get("listeners"),e=this;f.push(this.bind(h.label,"mouseover",function(){e.addInfoWindow({latlng:h.get("position"),map:h.get("map"),body:c,title:d,offsetVertical:h.label.offsetHeight,offsetHorizontal:$(h.label).width(),disableAutoPan:true},true);},true));}return h;};Maps.prototype.clearInfoWindows=function(){if(this.mapType==MapEngines.Google){if(this.infoWindows.length>0){$.each(this.infoWindows,function(a,b){b.setMap(null);});this.infoWindows=[];}this.unbind(this.mapContainer.data("center_changedInfoWindow"));this.mapContainer.data("center_changedInfoWindow",null);}};Maps.prototype.addInfoWindow=function(c,b){if(this.mapType==MapEngines.Google){if(b){if(this.infoWindows.length>0){this.clearInfoWindows();}}var a=new InfoBox(c);this.infoWindows.push(a);if(this.infoWindows.length==1){var d=this;this.mapContainer.data("center_changedInfoWindow",this.bind(this.map,"center_changed",function(){d.clearInfoWindows();},false));}}};Maps.prototype.getShape=function(c,e,h,b){var i;if(this.mapType==MapEngines.Google){var a=this.getLatLng(c);i=new google.maps.Marker({position:a,map:this.map,icon:h});var d="";if(b){if(typeof b==="string"){b=[b];}d=['<div class="',"infowindow"+(b.length>1?" multi_infowindow":""),'">',b.join(""),"</div>"];d=d.join("");}if((e&&e.length>0)||d.length>0){var g=[];var f=this;g.push(this.bind(i,"mouseover",function(){f.addInfoWindow({latlng:i.getPosition(),map:this.map,title:e,body:d,disableAutoPan:true,offsetHorizontal:14,offsetHorizontalRight:14},true);}));}}else{i=new VEShape(VEShapeType.Pushpin,c);i.SetCustomIcon(h);i.SetTitle(e);if(b!==null){if(typeof b==="string"){b=[b];}var d=['<div class="',"infowindow"+(b.length>1?" multi_infowindow":""),'">',b.join(""),"</div>"];i.SetDescription(d.join(""));}}return i;};Maps.prototype.plotShape=function(c,e,a,d){var b=null;if(this.mapType==MapEngines.Google){b=this.getShape(c,e,a,d);}else{}return b;};SearchMapControlManager=function(d,c,e,a,f,b){_self=this;this.map=d;this.form=c;this.buttonTop=e;this.buttonBottom=a;this.inputReset=b;this.panned=false;this.searchText=f||"searching...";if(typeof e!=="undefined"){e.bind("click",_self.search);}if(typeof a!=="undefined"){a.bind("click",_self.search);}this.listeners=[this.map.bind(this.map.map,"dragend",function(){_self.toggleMapSearchControls({eventName:"dragend"});}),this.map.bind(this.map.map,"zoom_changed",function(){_self.toggleMapSearchControls({eventName:"zoom_changed"});})];};SearchMapControlManager.prototype.hideMapSearchControls=function(a){$.each(a?[a]:[this.buttonTop,this.buttonBottom],function(b,c){this[0].className="mapSearchControlDisabled";this[0].isActive=false;});};SearchMapControlManager.prototype.showMapSearchControls=function(){$.each([this.buttonTop,this.buttonBottom],function(a,c){if(typeof this!=="undefined"){if(!_self.panned){var b=_self.map.GetZoom(),d=(_self.map.mapType==MapEngines.Google)?_self.map.mapOptions.zoom:_self.map.initialZoomLevel;if((b==d)&&this.hideMapSearchControls){this.hideMapSearchControls(this);return;}}this[0].className="mapSearchControl";this[0].isActive=true;if($.browser.msie6){this.width(this.parent().width());}}});};SearchMapControlManager.prototype.toggleMapSearchControls=function(c){if(c.eventName==="dragend"){this.panned=true;}var b=this.map.GetZoom(),a=this.map;$("ul.plotControlsList li").each(function(d,f){var e=/^plot(.*?)Control(Disabled|On)?$/.exec(this.className)[1];a.additionalTypes[e].inRange=(a.additionalTypes[e].minZoomLevel<b);if(!a.additionalTypes[e].inRange){this.className="plot"+e+"Control"+(a.additionalTypes[e].on?"On":"Disabled");}else{this.className="plot"+e+"Control"+(a.additionalTypes[e].on?"On":"");}});if(b>10){if(this.showMapSearchControls){this.showMapSearchControls();}}else{if(this.hideMapSearchControls){this.hideMapSearchControls();}}};SearchMapControlManager.prototype.search=function(b){var a=b.target;a.blur();if(arguments.callee.init||!a.isActive){return false;}arguments.callee.init=true;_self.buttonTop.val(_self.searchText);_self.buttonBottom.val(_self.searchText);_self.setCoords();$("#"+_self.inputReset).val("14");};SearchMapControlManager.prototype.setCoords=function(){var c=_self.map.mapContainer,d=_self.map.GetMapView();var a=d.ne,b=(_self.map.mapType==MapEngines.Google)?d.sw:_self.map.PixelToLatLong(new VEPixel(c.width()-4,c.height()-4));$("input:hidden[id$=ne]").val(a[LatLong.Lat]+", "+a[LatLong.Long]);$("input:hidden[id$=sw]").val(b[LatLong.Lat]+", "+b[LatLong.Long]);};SearchMapControlManager.prototype.toggleHelpTip=function(a,b,c){if(!a.isActive){var d=$("#"+c);if(b=="show"){d.show();}else{d.hide();}}};GoogleMapDashboard=function(b,c,a){this.showStreetView=c;this.map=b;this.pano=a||this.map.getStreetView();this.isStreetViewDash=false;this.dashboard=null;this.panoZoom=1;};GoogleMapDashboard.prototype.InitStreetViewDash=function(a){this.isStreetViewDash=true;this.pano=a||this.map.getStreetView();this.dashboard=this.CreateDashboard();this.dashboard.append(this.getPanoZoomControls());this.dashboard.append(MapDashboard.createDiv("mapTabs").append(this.getStreetViewButton(this.isStreetViewDash,true)).append(this.getAerialViewButton()).append(this.getRoadViewButton(!this.isStreetViewDash)).append(this.getMapRoadsToggle()));return this.dashboard;};GoogleMapDashboard.prototype.Init=function(){this.dashboard=this.CreateDashboard();this.dashboard.append(this.getZoomControls()).append(MapDashboard.createDiv("mapTabs").append(this.getStreetViewButton(this.isStreetViewDash)).append(this.getAerialViewButton()).append(this.getRoadViewButton(!this.isStreetViewDash)).append(this.getMapRoadsToggle())).append(MapDashboard.createDiv("messagebox"));return this.dashboard;};GoogleMapDashboard.prototype.InitPanMapControl=function(){var a=MapDashboard.createDiv("mapPanControl");var c=MapDashboard.createDiv("mapPan");var d=this;var b=function(){var f=0,e=0;if(typeof(window.pageYOffset)=="number"){e=window.pageYOffset;f=window.pageXOffset;}else{if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){e=document.body.scrollTop;f=document.body.scrollLeft;}else{if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){e=document.documentElement.scrollTop;f=document.documentElement.scrollLeft;}}}return[f,e];};c.bind("click",function(p){if(!p){var p=window.event;}var l=$(p.target);var g=l.offset();var o=l.width();var m=l.height();var j=b();var e=p.clientX-(g.left-j[0])-o/2;var f=p.clientY-(g.top-j[1])-m/2;var q=Math.sqrt(Math.pow(e,2));var k=Math.sqrt(Math.pow(f,2));var t=q>k?q:k;var u=e/t;var h=f/t;var s=(q/(o/2))*100;var n=(k/(m/2))*100;var i=Math.round(u*s);var r=Math.round(h*n);d.map.panBy(i,r);});a.append(c);return a;};GoogleMapDashboard.prototype.updatePanel=function(){this.setZoomBar(this.map.getZoom());this.setPanoZoomBar(this.pano.getPov().zoom);};GoogleMapDashboard.prototype.CreateDashboard=function(){var a=MapDashboard.createDiv("pldashboard");return a;};GoogleMapDashboard.prototype.getAerialViewButton=function(){var b=MapDashboard.createDivWithLink("aerialbutton","",null,"Switch to 'Aerial' view"),a=this;return b;};GoogleMapDashboard.prototype.getStreetViewButton=function(d,b){if(this.showStreetView){var c=MapDashboard.createDivWithLink("streetviewbutton",(d)?"selected":"",null,"Switch to 'street view'"),a=this;if(typeof b==="undefined"){Maps.prototype.PanoramaAvailable(this.map.getCenter(),function(e,f){if(f!=="OK"){$(c).addClass("notavailable");}});}return c;}};GoogleMapDashboard.prototype.getRoadViewButton=function(b){var c=MapDashboard.createDivWithLink("roadbutton",(b)?"selected":"",null,"Switch to 'Road' view"),a=this;return c;};GoogleMapDashboard.prototype.getMapRoadsCheckbox=function(){var a=this,b=$('<input type="checkbox" id="displayRoad" name="displayRoad"  />');return b;};GoogleMapDashboard.prototype.getMapRoadsToggle=function(){var c=this,d=MapDashboard.createDiv("roadtoggle"),a=$("<label></label>"),b=this.getMapRoadsCheckbox(true);a.html("Roads").attr("for","displayRoad");d.hide().append(a.append(b));return d;};GoogleMapDashboard.prototype.CheckBirdseyeButton=function(){};GoogleMapDashboard.prototype.setPanoZoomBar=function(b){for(var a=4;a>=0;a--){var c=document.getElementById("zoom_"+a);if(c){if(a>b){c.className="mapZoomBars";}else{c.className="mapZoomBars_selected";}}}};GoogleMapDashboard.prototype.setZoomBar=function(b){for(var a=19;a>=1;a--){var c=document.getElementById("zoom_"+a);if(c){if(a>b){c.className="mapZoomBars";}else{c.className="mapZoomBars_selected";}}}};GoogleMapDashboard.prototype.getPanoZoomControls=function(){var b=MapDashboard.createDiv("panoZoomControls","mapzoomcontrols");var a=this;b.append(this.getZoomControl("in"));b.append(this.getZoomLevelsControl("pano"));b.append(this.getZoomControl("out"));google.maps.event.addListener(this.pano,"pov_changed",function(c){if(a.panoZoom!=Math.floor(a.pano.getPov().zoom)){a.panoZoom=a.pano.getPov().zoom;a.setPanoZoomBar(a.panoZoom);}});return b;};GoogleMapDashboard.prototype.getPanoZoomControls=function(){};GoogleMapDashboard.prototype.getZoomControls=function(){var b=MapDashboard.createDiv("mapZoomControls","mapzoomcontrols");b.append(this.getZoomControl("in"));b.append(this.getZoomLevelsControl("map"));b.append(this.getZoomControl("out"));var a=this;google.maps.event.addListener(this.map,"zoom_changed",function(){a.CheckBirdseyeButton();a.setZoomBar(a.map.getZoom());});return b;};GoogleMapDashboard.prototype.getZoomControl=function(a){var b=this;var c=MapDashboard.createDivWithLink("mapzoom"+a,null,null,"Zoom "+a+" one level");c.bind("click",function(d){b.zoomMap(d);});return c;};GoogleMapDashboard.prototype.zoomMap=function(f){var d=$(f.target).closest("div"),a=d.parent("div"),b=11;if(a[0].id==="mapZoomControls"){b=this.map.getZoom();}else{if(a[0].id==="panoZoomControls"){b=this.pano.getPov().zoom;}}if(d[0].id=="mapzoomin"){b++;}else{b--;}if(a[0].id==="mapZoomControls"){this.map.setZoom(b);}else{if(a[0].id==="panoZoomControls"){if(b>4){b=4;}if(b<0){b=0;}var c=this.pano.getPov();c.zoom=b;this.pano.setPov(c);}}};GoogleMapDashboard.prototype.getZoomLevelsControl=function(a){var c=MapDashboard.createDiv("zoomLevels"),b=this;if(a==="pano"){var d=this.panoZoom;c.append(this.getZoomBar(4,d));c.append(this.getZoomBar(3,d));c.append(this.getZoomBar(2,d));c.append(this.getZoomBar(1,d));c.append(this.getZoomBar(0,d));c.bind("click",function(i){if(i.target.tagName==="A"){var h=$(i.target).closest("div");if(h.length>0){var f=parseInt(h.get(0).id.replace("zoom_",""));var g=b.pano.getPov();if(isNaN(f)){f=1;}if(g.zoom!=f){g.zoom=f;b.pano.setPov(g);b.setPanoZoomBar(f);}}}return false;});}else{c.append(this.getZoomBar(19));c.append(this.getZoomBar(18));c.append(this.getZoomBar(17));c.append(this.getZoomBar(16));c.append(this.getZoomBar(15));c.append(this.getZoomBar(13));c.append(this.getZoomBar(11));c.bind("click",function(h){if(h.target.tagName==="A"){var g=$(h.target).closest("div");if(g.length>0){var f=parseInt(g.get(0).id.replace("zoom_",""));if(isNaN(f)){f=11;}b.map.setZoom(f);}}return false;});}return c;};GoogleMapDashboard.prototype.getZoomBar=function(a,d){var b=d||this.map.getZoom(),e=(a<=b)?"mapZoomBars_selected":"mapZoomBars",c=MapDashboard.createDivWithLink("zoom_"+a,e);return c;};var MapDashboard={_self:this,createDiv:function(a,b){var c=document.createElement("div");c.id=a;if(b&&b.length>0){c.className=b;}return $(c);},createDivWithLink:function(c,e,a,b){var f=MapDashboard.createDiv(c);if(e!==null&&typeof e!=="undefined"){f.addClass(e);}var d=document.createElement("a");d.href=(a===null||typeof a==="undefined")?"javascript:void(0);":a;if(b!==null&&typeof b!=="undefined"){d.title=b;}f.append(d);return f;}};function InfoBox(a){this.setValues(a);this.latlng_=a.latlng;this.map_=a.map;this.offsetVertical_=a.offsetVertical+20||20;this.offsetHorizontal_=a.offsetHorizontal||5;this.offsetHorizontalRight_=a.offsetHorizontalRight||0;this.height_=0;this.width_;this.title_=a.title;this.body_=a.body;this.disableAutoPan_=a.disableAutoPan||false;this.listeners=this.listeners_=[];this.container=null;var b=this;this.boundsChangedListener_=google.maps.event.addListener(this.map_,"bounds_changed",function(){return b.panMap.apply(b);});this.setMap(this.map_);}if(window.google){InfoBox.prototype=new google.maps.OverlayView;InfoBox.prototype.onRemove=function(){if(this.div_){this.div_.parentNode.removeChild(this.div_);this.div_=null;}for(var a=0,b=this.listeners_.length;a<b;a++){google.maps.event.removeListener(this.listeners_[a]);}};InfoBox.prototype.draw=function(){if(!this.div_){return;}var c=this.getProjection().fromLatLngToContainerPixel(this.latlng_),i=function(){var r,s;if(window.pageYOffset){s=window.pageYOffset;r=window.pageXOffset;}else{if(document.documentElement&&document.documentElement.scrollTop){s=document.documentElement.scrollTop;r=document.documentElement.scrollLeft;}else{if(document.body){s=document.body.scrollTop;r=document.body.scrollLeft;}}}return new Array(r,s);};if(!c){return;}var f=$(this.div_),d=f.offset(),b=$(window).width(),q=$(this.map_.getDiv()),k=q.offset();this.height_=f.height();this.width_=f.width();var a=k.left+this.width_+c.x+this.offsetHorizontal_,e=k.top+c.y-this.height_+this.offsetVertical_,l=i(),m=b-a,n=l[1]-e;var o=(c.x+this.offsetHorizontal_),p=c.y-this.height_+this.offsetVertical_,j=f.find(".ero-beak");this.div_.style.position="absolute";this.div_.style.visibility="visible";if(n>0){var g=parseInt(j.css("bottom").replace("px",""));this.div_.style.top=p+n+"px";j[0].style.bottom=18+n+"px";}else{this.div_.style.top=p+"px";}if(m<0){this.div_.className=this.div_.className.replace("ero-leftBeak","ero-rightBeak");var h=parseInt(f.css("padding-right").replace("px",""));if(isNaN(h)){h=0;}o=c.x-this.width_-h-this.offsetHorizontalRight_;}else{this.div_.className=this.div_.className.replace("ero-rightBeak","ero-leftBeak");}this.div_.style.left=o+"px";if(c.x<-8||c.y<-8||c.y>q.height()+8||c.x>q.width()){this.div_.style.display="none";}else{this.div_.style.display="block";}};InfoBox.prototype.removeWindow=function(a){return function(){a.setMap(null);};};InfoBox.prototype.GetBodyPanes=function(){var a;var b=this.map.getDiv();a=$("#IB_"+b.id);if(a.length==0){a=document.createElement("div");var c=$(b).offset();a.setAttribute("id","IB_"+b.id);$(a).css({position:"absolute",top:c.top+"px",left:c.left+"px"}).appendTo("body");}else{a=a[0];}return a;};InfoBox.prototype.onAdd=function(){var e=this.GetBodyPanes();var d=this.div_;if(!d){d=this.div_=document.createElement("div");d.className="ero-leftBeak ero";d.setAttribute("style","zoom:1;");var c=document.createElement("div"),a=document.createElement("div"),b=document.createElement("div");c.className="ero-beak";a.className="ero-shadow";a.innerHTML='<div class="ero-body"><div class="ero-actionsBackground"><div class="ero-previewArea"><div class="firstChild"><p></p>'+((this.title_.length>0)?'<div class="VE_Pushpin_Popup_Title"><b>'+this.title_+"</b></div>":"")+((this.body_!="")?('<div class="VE_Pushpin_Popup_Body">'+this.body_+"</div>"):"")+'</div></div><div class="ero-paddingHack"></div></div></div>';b.className="ero-close";this.listeners_.push(google.maps.event.addDomListener(b,"click",InfoBox.prototype.removeWindow(this)));d.appendChild(b);d.appendChild(a);d.appendChild(c);d.style.visibility="hidden";e.appendChild(d);this.container=d;this.panMap();}else{if(d.parentNode!=e.floatPane&&d.parentNode.id.indexOf("IB_")==-1){}else{}}};InfoBox.prototype.panMap=function(){if(!this.disableAutoPan_){var a=this.map_,f=a.getBounds();if(!f){return;}if(!this.div_){return;}var u=$(this.div_);this.height_=u.height();this.width_=u.width();var E=this.latlng_,q=this.width_,A=this.height_,o=this.offsetHorizontal_,p=this.offsetVertical_,C=23,v=4;var z=a.getDiv(),r=z.offsetWidth,g=z.offsetHeight,t=f.toSpan(),k=t.lng(),b=t.lat(),s=k/r,n=b/g;var l=f.getSouthWest().lng(),w=f.getNorthEast().lng(),m=f.getNorthEast().lat(),e=f.getSouthWest().lat();var B=E.lng()+(o-C)*s,d=E.lng()+(o+q+C)*s,i=E.lat()-(p-v)*n,x=E.lat()-(p+A+v)*n;var y=(B<l?l-B:0)+(d>w?w-d:0),h=(i>m?m-i:0)+(x<e?e-x:0);var j=a.getCenter();var D=j.lng()-y,c=j.lat()-h;this.haltServices=true;a.setCenter(new google.maps.LatLng(c,D));google.maps.event.removeListener(this.boundsChangedListener_);this.boundsChangedListener_=null;}};function GoogleLabel(c){this.setValues(c);var a=this.span_=document.createElement("a");var b=this.div_=document.createElement("div");this.label=b;this.listeners=this.listeners_=[];b.appendChild(a);b.style.cssText="position: absolute; display: none;";}GoogleLabel.prototype=new google.maps.OverlayView;GoogleLabel.prototype.onAdd=function(){var a=this.getPanes().overlayLayer;a.appendChild(this.div_);var b=this;this.listeners_.push(google.maps.event.addListener(this,"position_changed",function(){b.draw();}));this.listeners_.push(google.maps.event.addListener(this,"text_changed",function(){b.draw;}));};GoogleLabel.prototype.onRemove=function(){this.div_.parentNode.removeChild(this.div_);for(var a=0,b=this.listeners_.length;a<b;a++){google.maps.event.removeListener(this.listeners_[a]);}};GoogleLabel.prototype.draw=function(){var a=this.getProjection(),c=a.fromLatLngToDivPixel(this.get("position")),b=this.div_;b.style.left=c.x+"px";b.style.top=c.y+"px";b.style.display="block";b.setAttribute("title",this.get("title").toString());this.span_.innerHTML=this.get("text").toString();};}function localInfoArrow(b,a){this.birdsEyeOn=false;this.streetviewOn=false;this.container=jQuery("#"+a);this.arrowImage=jQuery("a[id$="+b+"]",this.container);this.imageUrl="none";this.setStreetviewOn=function(){this.streetviewOn=true;this.updateDisplay();};this.setBirdsEyeOn=function(){this.birdsEyeOn=true;this.updateDisplay();};this.setImage=function(c){this.imageUrl=c;this.displayImage();};this.displayImage=function(){if(typeof this.arrowImage!=="undefined"){this.arrowImage.css({"background-image":this.imageUrl});}};this.updateDisplay=function(){if(this.container.is("#BirdViewTab")){var c=this.birdsEyeOn?"_b":"";if(this.streetviewOn){c+="_S";}if(c.length){this.setImage("url(/content/images-2011/maps/arrow-art"+c+"_final.gif)");}}else{this.container=$("#StreetviewTab");if(typeof this.container!=="undefined"){if(this.streetviewOn){this.container.show();}else{this.container.hide();}}}};}if(window.PL){window.PL.controls.browsemap.plot=function(b){if(!b){return;}switch(window.PL.controls.browsemap.type){case"Area":var a=[];if(window.map.mapType===MapEngines.Google){$.each(b,function(c,d){if(d.type==="area"){if(d.current&&!window.map.mapOptions.agentView){a.push(window.map.plotPrimaryClusterShape(d.coords,d.name,d.name,d.description,window.map.clusterShapeLayer));}else{a.push(window.map.plotBrowseClusterShape(d.coords,d.name,d.name,d.description,d.url,window.map.clusterShapLayer,d.neighbour?"background":"forground"));}}else{a.push(window.map.plotDefaultShape(d.coords,d.name,"",d.description,undefined,d.url));}});}else{window.map.clusterShapeLayer=new VEShapeLayer();window.map.AddShapeLayer(window.map.clusterShapeLayer);$.each(b,function(c,e){var d=(typeof e.coords.lat==="undefined")?e.coords:new VELatLong(e.coords.lat,e.coords.lng);if(e.type==="area"){if(e.current&&!window.map.options.agentView){a.push(window.map.plotPrimaryClusterShape(d,e.name,e.name,e.description,window.map.clusterShapeLayer));}else{a.push(window.map.plotBrowseClusterShape(d,e.name,e.name,e.description,e.url,window.map.clusterShapeLayer,e.neighbour?"background":"foreground"));}}else{a.push(window.map.plotDefaultShape(d,e.name,"",e.description,undefined,e.url));}});}window.map.mapContainer.data("defaultLabels",a);break;case"Property":$.each(b,function(c,d){if(d.type=="localinfo"){window.map.plotPrimaryShape(d.coords,d.description,"");}else{window.map.plotDefaultShape(d.coords,d.name,"",d.description,undefined,d.url);}});break;default:throw new Error("No type set for the map");break;}};window.PL.controls.browsemap.redraw=function(b,c){if(!b||!c){return;}var e=(typeof b.ne==="undefined")?b:{sw:[b.sw.lat,b.sw.lng],ne:[b.ne.lat,b.ne.lng]};var a=window.map.GetMapView();if(e.ne!=a.ne&&e.sw!=a.sw){var d=window.map.calculateView(e);window.map.SetCenterAndZoom(d.centerPoint,d.zoom);}window.map.Clear();window.PL.controls.browsemap.plot(c);};}Maps.prototype.togglePlotLocalProperties=function(a){if(a){this.localPropertiesOn=true;this.plotLocalProperties(null);var b=this;this.mapContainer.data("dragendLocalProps",this.bind(this.map,"dragend",function(){b.plotLocalProperties();}));this.mapContainer.data("zoom_changedLocalProps",this.bind(this.map,"zoom_changed",function(){b.plotLocalProperties();}));}else{this.localPropertiesOn=false;if(this.mapContainer.data("localPropertiesShapeLayer")){this.DeleteShapeLayer(this.mapContainer.data("localPropertiesShapeLayer"));this.mapContainer.data("localPropertiesShapeLayer",null);}if(this.mapContainer.data("dragendLocalProps")){this.unbind(this.mapContainer.data("dragendLocalProps"),"dragend",function(){b.plotLocalProperties();});this.mapContainer.data("dragendLocalProps",null);}if(this.mapContainer.data("zoom_changedLocalProps")){this.unbind(this.mapContainer.data("zoom_changedLocalProps"),"zoom_changed",function(){b.plotLocalProperties();},this.mapContainer.data("zoom_changedLocalProps",null));}}};Maps.prototype.plotLocalProperties=function(callback){var rectangle;var style=this.mapOptions.mapstyle;if(style==MapViewType.BIRDSEYE||style==MapViewType.BIRDSEYEHYBRID){if(this.map.GetBirdseyeScene){rectangle=this.map.GetBirdseyeScene().GetBoundingRectangle();}}else{rectangle=this.GetMapView();}var nw=rectangle.ne,se=rectangle.sw;if((typeof se[LatLong.Lat]=="undefined")||(se[LatLong.Lat]==null)||(typeof nw[LatLong.Lat]=="undefined")||(nw[LatLong.Lat]==null)||(typeof se[LatLong.Long]=="undefined")||(se[LatLong.Long]==null)||(typeof nw[LatLong.Long]=="undefined")||(nw[LatLong.Long]==null)){nw=this.PixelToLatLong({x:0,y:0},this.GetZoom());var ux=this.mapContainer.get(0).offsetWidth,uy=this.mapContainer.get(0).offsetHeight;se=this.PixelToLatLong({x:ux,y:uy},this.GetZoom());}var min_lat=se[LatLong.Lat];var max_lat=nw[LatLong.Lat];var min_lng=se[LatLong.Long];var max_lng=nw[LatLong.Long];var url=this.mapOptions.searchUrl;var regexp=new RegExp("/p/[^/]*/");url=url.replace(regexp,"/");regexp=new RegExp("/nt/[^/]*/");url=url.replace(regexp,"/");regexp=new RegExp("/xt/[^/]*/");url=url.replace(regexp,"/");regexp=new RegExp("/ng/[^/]*/");url=url.replace(regexp,"/");regexp=new RegExp("/xg/[^/]*/");url=url.replace(regexp,"/");url+="outputFormat/json/nt/"+min_lat+"/xt/"+max_lat+"/ng/"+min_lng+"/xg/"+max_lng;ignore=this.mapOptions.ignore;callback=callback||function(transport){if(this.mapContainer.data("localPropertiesShapeLayer")){this.DeleteShapeLayer(this.mapContainer.data("localPropertiesShapeLayer"));this.mapContainer.data("localPropertiesShapeLayer",null);}if(this.localPropertiesOn){if(this.mapType===MapEngines.Bing){this.mapContainer.data("localPropertiesShapeLayer",new VEShapeLayer());this.map.AddShapeLayer(this.mapContainer.data("localPropertiesShapeLayer"));}var properties=$.parseJSON(transport.d);if(properties===null){return;}var data=this.groupLocalPropertyData(properties,ignore);var shapeArray=[];for(var llKey in data){if(llKey.substring(0,3)=="ll_"){var property=eval("data."+llKey);var title=property.title;var ll=property.ll;var character=property.character;var description=property.description;var shape=this.getDefaultShape(ll,title,character,description);shapeArray.push(shape);}}if(shapeArray.length>0){if(this.mapType===MapEngines.Google){this.mapContainer.data("localPropertiesShapeLayer",shapeArray);}else{this.mapContainer.data("localPropertiesShapeLayer").AddShape(shapeArray);}}}};alert("get local properties not implemented on PL.Net");return;$.ajax({type:"POST",url:url,contentType:"application/json; charset=utf-8",dataType:"json",success:function(transport){callback(transport);}});};
