/* (c) LoopNet Map Manager Version 5.8 */
LNJS.__mapmanager=true;VEShape.ShowDetailOnMouseOver=false;VEShape.prototype.LN={};VEShape.prototype.orgZIndex=0;window.LNVEOpt={};window.LNVEInit=function(VEOpt){return VEOpt.extend(LNVEOpt);};LNJS.MapManager=Class.create();LNJS.MapManager.prototype=(new LNJS.Base()).extend({initialize:function(container,options){this.__className="LNJS.MapManager";this.options={mapAccuracy:VEShapeAccuracy.Pushpin,zoomToCenter:false,mapMode:VEMapMode.Mode2D,disableObliqueNotification:false,showOnClick:true,mapStyle:VEMapStyle.Road,showSwitch:false,mapFixed:false,latitude:34.108277,longitude:-118.330807,zoomlevel:15,pinOffsets:{rbb:8,rba:-10,lr:28,lbb:7,lba:-10,ll:-2},showMapLegend:false,showMinimap:false,hideCopyright:false,disableLogo:false,showScaleBar:true,showDashboard:true,dashboardSize:VEDashboardSize.Normal,dashboardX:3,dashboardY:3,hidePins:false,obliqueEnabled:true}.extend(options||{});LNVEOpt=this.options;this.mapInitialized=false;this.zoomlevel=this.options.zoomlevel;this.lastZoomLevel=null;this.lastMapEvent=null;this.mapCenter=null;this._mapDimensions=null;this.container=$(container);if(LNJS.isNull(this.container))throw this.Err(this.__className+" requires a valid container element! cannot find "+container);this.MapErr=this.OnMapErr.bindAsEventListener(this);this.Map=new VEMap(this.container.id);this.Map.onLoadMap=this._onLoadMap.bindAsEventListener(this);this.Map.SetDashboardSize(this.options.dashboardSize);this.Map.LoadMap(new VELatLong(this.options.latitude,this.options.longitude),this.options.zoomlevel,this.options.mapStyle,this.options.mapFixed,this.options.mapMode,this.options.showSwitch);if(typeof(AddDMPParcelLayer)!='undefined')AddDMPParcelLayer(this.Map);this.Map.AttachEvent("onerror",this.MapErr);this.Map.SetMouseWheelZoomToCenter(this.options.zoomToCenter);if(!this.options.showDashboard){this.Map.HideDashboard();}this.toggleObliqueNotification(this.options.disableObliqueNotification);if(this.options.showOnClick){this.Map.AttachEvent("onmouseover",this._disableEvt);this.Map.AttachEvent("onmouseout",this._disableEvt);}this.Map.AttachEvent("onmousedown",this._disableEvt);},OnMapErr:function(err){var msg=err.message?err.message:err.error;LNJS.Trace.error(msg);if(msg=="Sorry, bird's eye images aren't available here."){alert(msg);}else{throw this.Err(msg);}},checkXY:function(args){var x=LNJS.User.rPID.x();var callout=1;var mapOffset=Position.cumulativeOffset(this.container);var mapSize=Element.getDimensions(this.container);if(args.pin){pinLoc=Position.cumulativeOffset(args.pin);}else if(args.vepin){el=this.getShapeElByID(args.vepin.GetID());if(el!=null)pinLoc=Position.cumulativeOffset(el);else return;}else{return;}if(pinLoc==null)return;if(args.popup){var top=parseInt(Element.getStyle(el,'top'));var left=parseInt(Element.getStyle(el,'left'));var width=24;el=null;}if(pinLoc[0]<(mapOffset[0]+(mapSize.width/2))){if(pinLoc[1]<(mapOffset[1]+(mapSize.height/2))){callout=1;if(args.popup)args.popup.style.top=pinLoc[1]+this.options.pinOffsets.rbb+'px';}else{callout=3;if(args.popup)args.popup.style.top=(pinLoc[1]+this.options.pinOffsets.rba-args.popup.offsetHeight)+'px';}if(args.popup)args.popup.style.left=pinLoc[0]+this.options.pinOffsets.lr+'px';}else{if(pinLoc[1]<(mapOffset[1]+(mapSize.height/2))){callout=2;if(args.popup)args.popup.style.top=pinLoc[1]+this.options.pinOffsets.lbb+'px';}else{callout=4;if(args.popup)args.popup.style.top=(pinLoc[1]+this.options.pinOffsets.lba-args.popup.offsetHeight)+'px';}if(args.popup)args.popup.style.left=pinLoc[0]+this.options.pinOffsets.ll-args.popup.offsetWidth+'px';}x=mapOffset=mapSize=pinLoc=null;return callout;},addShape:function(VEshape,layerIndex){if(this.mapInitialized){this._getaddShapeLayer(layerIndex).AddShape(VEshape);}},getShapeByIndex:function(index,layerIndex){if(this.mapInitialized)return this._getaddShapeLayer(layerIndex).GetShapeByIndex(index);},getShapeCount:function(layerIndex){if(this.mapInitialized)return this._getaddShapeLayer(layerIndex).GetShapeCount();},showLayer:function(layerIndex){if(this.mapInitialized){this._getaddShapeLayer(layerIndex).Show();}},hideLayer:function(layerIndex){if(this.mapInitialized){this._getaddShapeLayer(layerIndex).Hide();}},deleteAllShapesFromLayer:function(layerIndex){if(this.mapInitialized){var oLayer=this.getShapeLayerByIndex(layerIndex);if(oLayer)oLayer.DeleteAllShapes();oLayer=null;}},isBirdseyeAvailable:function(){if(this.mapInitialized)return this.Map.IsBirdseyeAvailable();},getBirdseyeScene:function(){if(this.mapInitialized)return this.Map.GetBirdseyeScene();},getShapeByID:function(shapeID){if(this.mapInitialized)return this.Map.GetShapeByID(shapeID);},getShapeElByID:function(ElID){if(this.mapInitialized){var shape=this.getShapeByID(ElID);if(shape){if(shape.Primitives[0])return $(shape.Primitives[0].iid);}}},getShapeElByIndex:function(index){if(this.mapInitialized){var shape=this.getShapeByIndex(index);if(shape){if(shape.Primitives[0])return $(shape.Primitives[0].iid);}}},getShapeLayerByIndex:function(layerIndex){return this.Map.GetShapeLayerByIndex(layerIndex);},getShapeLayerCount:function(){return this.Map.GetShapeLayerCount();},deleteShape:function(VEshape){if(this.mapInitialized){this.Map.DeleteShape(VEshape);}},deleteAllShapes:function(){if(this.mapInitialized)this.Map.DeleteAllShapes();},deleteAllShapeLayers:function(){if(this.mapInitialized)this.Map.DeleteAllShapeLayers();},addShapeLayer:function(oLayer){if(this.mapInitialized){this.Map.AddShapeLayer(oLayer);}},setMapView:function(location){if(this.mapInitialized){return this.Map.SetMapView(location);}},refreshLayers:function(){if(this.mapInitialized){this.Map._RefreshLayers();}},setAnimationEnabled:function(bool){if(this.mapInitialized){this.Map.SetAnimationEnabled(bool);}},addPushpin:function(id,location,icon_url,title,details,iconStyle,titleStyle,detailsStyle){if(this.mapInitialized){var pin=new VEPushpin(id,location,icon_url,title,details,iconStyle,titleStyle,detailsStyle);this.Map.AddPushpin(pin);return pin;}},addPushpinBC:function(id,latitude,longitude,width,height,className,innerHTML,zIndex,pinType){if(this.mapInitialized){var pin=new VEPushpin(id,new VELatLong(latitude,longitude),null,"test"+innerHTML,innerHTML,className);this.Map.AddPushpin(pin);return pin;}},attachEvent:function(eventName,methodToCall){if(this.mapInitialized)this.Map.AttachEvent(eventName,methodToCall);},getCenter:function(){if(this.mapInitialized)return this.Map.GetCenter();},getCenterLatitude:function(){if(this.mapInitialized)return this.getCenter().Latitude;},getCenterLongitude:function(){if(this.mapInitialized)return this.getCenter().Longitude;},getZoomLevel:function(){if(this.mapInitialized)return this.Map.GetZoomLevel();},getMapView:function(){if(this.mapInitialized)return this.Map.GetMapView();},getMapStyle:function(){if(this.mapInitialized)return this.Map.GetMapStyle();},isBirdsEye:function(){if(this.mapInitialized){return(this.Map.GetMapStyle()=="o"||this.Map.GetMapStyle()=="b");}return false;},getBirdseyeScene:function(){if(this.mapInitialized)return this.Map.GetBirdseyeScene();},getDashboard:function(){if(this.mapInitialized)return this.Map.GetDashboard();},pixelToLatLong:function(vePixel){if(this.mapInitialized){var tempLatLong=this.Map.vemapcontrol.PixelToLatLong(vePixel);var latLong=new VELatLong(tempLatLong.latitude,tempLatLong.longitude);latLong._reserved=new VELatLongEncoding().Encode(latLong.Latitude,latLong.Longitude);return latLong;}},getLatitude:function(pixel){if(this.mapInitialized)return this.Map.PixelToLatLong(new VEPixel(0,pixel)).Latitude;},getLongitude:function(pixel){if(this.mapInitialized)return this.Map.PixelToLatLong(new VEPixel(pixel,0)).Longitude;},getShapeByID:function(id){if(this.mapInitialized)return this.Map.GetShapeByID(id);},setCenterAndZoom:function(VELatLong,zoomlevel){if(this.mapInitialized)this.Map.SetCenterAndZoom(VELatLong,zoomlevel);},latLongToPixel:function(VELatLong){if(this.mapInitialized)return this.Map.LatLongToPixel(VELatLong);},setMapStyle:function(mapStyle){if(this.mapInitialized)this.Map.SetMapStyle(mapStyle);},zoomOut:function(){if(this.mapInitialized)this.Map.ZoomOut();},setZoomToAerial:function(level){if(this.mapInitialized){this.setMapStyle('a');this.Map.SetZoom(level);}},showInfoBox:function(pin){if(this.mapInitialized)this.Map.ShowInfoBox(pin);},setPrintOptions:function(enable){if(this.mapInitialized){var printOpt=new VEPrintOptions(enable);this.Map.SetPrintOptions(printOpt);}},find:function(what,where,findType,shapeLayer,startIndex,numberOfResults,showResults,createResults,useDefaultDisambiguation,setBestMapView,callback){if(this.mapInitialized)this.Map.Find(what,where,findType,shapeLayer,startIndex,numberOfResults,showResults,createResults,useDefaultDisambiguation,setBestMapView,callback);},findPlace:function(where,callback){if(this.mapInitialized)this.find(null,where,null,null,0,1,false,false,false,true,callback);},mapHeight:function(refresh){if(refresh!==false||this._mapDimensions===null)this._mapDimensions=Element.getDimensions(this.container);return this._mapDimensions.height;},mapWidth:function(refresh){if(refresh!==false||this._mapDimensions===null)this._mapDimensions=Element.getDimensions(this.container);return this._mapDimensions.width;},toggleObliqueNotification:function(state){state=state!=null?state:true;if(this.mapInitialized)this.Map.SetDisableObliqueNotification(state);},setMapState:function(params,SearchMgr){SearchMgr.EvtFromHistory=true;var debug=[];debug.push('<br>map style: '+params[1]);debug.push('<br>zoom level: '+params[0]);debug.push('<br>encoded bounds: '+params[2]);debug.push('<br>center lat/lon: '+LNJS.Util.decodeBounds(params[2])[0]);this.setMapStyle(params[1]);this.setCenterAndZoom(LNJS.Util.decodeBounds(params[2])[0],params[0]);$('HistoryState').innerHTML+=debug.join('');},printMap:function(){this.setPrintOptions(true);window.print();},decodeLatLong:function(veLatLong){if(veLatLong._reserved&&(!veLatLong.Latitude||!veLatLong.Longitude)){var tempLatLong=new VELatLongEncoding().Decode(veLatLong._reserved);veLatLong.Latitude=tempLatLong[0];veLatLong.Longitude=tempLatLong[1];tempLatLong=null;}return veLatLong;},dispose:function(){this.mapInitialized=false;if(this.Map!=null)this.Map.Dispose();this.Map=null;},HideAllPins:function(){return this.options.hidePins;},_getaddShapeLayer:function(layerIndex){if(this.mapInitialized){var layerIndex=(!layerIndex)?0:layerIndex;if(this.getShapeLayerCount()<=layerIndex){this.addShapeLayer(new VEShapeLayer());}var layer=this.getShapeLayerByIndex(layerIndex);if(!layer){}else{return layer;}}},_onLoadMap:function(e){this.mapInitialized=true;if(this.options.showMinimap){oLatLongRect=this.getMapView();oPixel=this.latLongToPixel(oLatLongRect.BottomRightLatLong);this.Map.ShowMiniMap((oPixel.x-155),5);oLatLongRect=oPixel=null;}if(!LNJS.isNull(this.options.onMapInit)){this.options.onMapInit(this);}if(this.options.mapView){var v=this.options.mapView;this.setMapView(new VELatLongRectangle(new VELatLong(v.minlat,v.minlon),new VELatLong(v.maxlat,v.maxlon)));v=null;}},_disableEvt:function(e){if(e.elementID!=null){return true;}}});VEMap.prototype.SetDisableObliqueNotification=function(state){if(this.vemapcontrol!=null&&this.vemapcontrol!="undefined")this.vemapcontrol.disableobliquenotification=state;};VEShape.prototype.Redraw=function(c,d,e,f,b){if(this.GetVisibility()&&this._shplayer&&this._shplayer._mapGuid&&this._shplayer.GetVisibility()){var a=GetVEMapInstance(this._shplayer._mapGuid);if(a==null)return;if(a.GetMapMode()==Msn.VE.MapActionMode.Mode3D||!this._isDrawn)this.Show();else{if(c)a.m_vegraphicsmanager.UpdatePoints(this,true);if(d)a.m_vegraphicsmanager.UpdateIconPoints(this);if(e){if(!this._isDrawn||this.Primitives[0].type!=VEShapeType.Pushpin){a.m_vegraphicsmanager.UpdateStyle(this);}else{$ID(this.Primitives[0].iid).style.zIndex=this.Primitives[0].symbol.style_zIndex;}}if(f)a.m_vegraphicsmanager.UpdateIconStyle(this);if(b)if(this.GetIconVisibility())a.m_vegraphicsmanager.ShowIcon(this);else a.m_vegraphicsmanager.HideIcon(this)}}};var VELatLongEncoding=_xz1;