function DSRange(A,B){this.low=A;this.high=B}DSRange.prototype.contains=function(A){return A>=this.low&&A<=this.high};DSRange.prototype.limitNumber=function(A){A=Math.max(parseFloat(A),this.low);return Math.min(A,this.high)};function DSCircle(A,B){this.low=A;this.high=B}DSCircle.prototype.limitNumber=function(A){A=parseFloat(A);while(A>this.high){A-=this.high-this.low}while(A<this.low){A+=this.high-this.low}return A};function DSCircleSegment(C,A,B){this.circle=C;this.low=A;this.high=B}DSCircleSegment.prototype.contains=function(A){var B=this.circle.limitNumber(A);if(this.low>this.high){return(B>=this.low&&B<=this.circle.high)||(B>=this.circle.low&&B<=this.high)}else{return B>=this.low&&B<=this.high}};var DSLatitude=new DSRange(-90,90);var DSLongitude=new DSCircle(-180,180);function DSBoundingBox(A,B){this.lower=A;this.upper=B;this.width=new DSCircleSegment(DSLongitude,A.lng,B.lng);this.height=new DSRange(A.lat,B.lat)}DSBoundingBox.prototype.contains=function(A){return this.width.contains(A.lng)&&this.height.contains(A.lat)};function DSMapTileUrlFactory(B,A,E,D,C){this.base=B||"";this.tileSet=A||"";this.extension=E||"";this.map=D;this.locale=D.locale||"";this.suffix=C||"";this.post=this.extension+"?";this.setPre()}DSMapTileUrlFactory.prototype.setPre=function(){this.pre=this.base+(this.locale.length?this.locale+"/":"")};DSMapTileUrlFactory.prototype.getPost=function(){return this.post+"w="+this.map.width+"&h="+this.map.height+this.suffix};DSMapTileUrlFactory.prototype.getUrl=function(A,C,B){return this.pre+B+"/"+A+"/"+C+this.getPost()};DSMapTileUrlFactory.prototype.setLocale=function(A){this.locale=A;this.setPre()};function DSCopyright(E,C,A,B,D){this.text=E;this.boxes=(typeof C.length=="undefined"?[C]:C);this.minzoom=A;this.maxzoom=B;this.tileset=D}DSCopyright.prototype.contains=function(A,D,F){var C=(!F||!this.tileset||(F==this.tileset));var G=(!this.minzoom||D>=this.minzoom)&&(!this.maxzoom||D<=this.maxzoom);var E=false;for(var B=0;B<this.boxes.length;++B){if(this.boxes[B].contains(A)){E=true;break}}return E&&G&&C};function DSCopyrightSet(){this.copyrights=[]}DSCopyrightSet.prototype.getCopyright=function(A,D,E){var C=[];if(A&&D){for(var B=0;B<this.copyrights.length;++B){if(this.copyrights[B].contains(A,D,E)){C.push(this.copyrights[B].text)}}}return C.join(" - ")};DSCopyrightSet.prototype.addCopyright=function(A){this.copyrights.push(A)};function DSMapDecoratorCollection(){this.init()}LMI.Lang.extend(DSMapDecoratorCollection,DSCollection);DSMapDecoratorCollection.prototype.getByType=function(C){var B=new DSIterator(this),A=[],D;while((D=B.next())){if(D.type==C){A.push(D)}}return A};DSMapDecoratorCollection.prototype.getByName=function(A){var B=new DSIterator(this),C;while((C=B.next())){if(C.name==A){return C}}return ret};function DSMapDecorator(D,C,E,B,A){this.init(D,C,E,B,A)}DSMapDecorator.prototype.init=function(D,C,E,B,A){this.map=D;this.element=C;this.position=E;this.type=B;this.name=A;this.updatePosition()};DSMapDecorator.prototype.getElement=function(){return this.element};DSMapDecorator.prototype.getFirstElement=function(){for(i=0,iLen=this.element.childNodes.length;i<iLen;++i){var A=this.element.childNodes[i];if(!LMI.StyleSheet.isClass(A,"skip")){return A}}};DSMapDecorator.prototype.updatePosition=function(){this.element.style.position="absolute";if(typeof this.position.left!="undefined"){this.element.style.left=parseInt(this.position.left,10)+"px"}if(typeof this.position.right!="undefined"){this.element.style.right=parseInt(this.position.right,10)+"px"}if(typeof this.position.top!="undefined"){this.element.style.top=parseInt(this.position.top,10)+"px"}if(typeof this.position.bottom!="undefined"){this.element.style.bottom=parseInt(this.position.bottom,10)+"px"}for(var A in {width:"",height:""}){if(typeof this.position[A]!="undefined"){this.element.style[A]=parseInt(this.position[A],10)+"px"}}if(typeof this.position.zIndex!="undefined"){this.element.style.zIndex=parseInt(this.position.zIndex,10)}};DSMapDecorator.prototype.setPosition=function(B){for(var A in B){this.position[A]=B[A]}this.updatePosition()};DSMapDecorator.prototype.getPosition=function(){return this.position};(function(){function B(){this.name="InvalidLatException"}LMI.Lang.extend(B,TypeError);function A(){this.name="InvalidLngException"}LMI.Lang.extend(A,TypeError);function C(E){return E*(180/Math.PI)}var D=LMI.Lang.getObject("LMI.Mapping",true);D.Point=function(F,E){this.init(F,E)};D.Point.prototype={init:function(H,G){var F=parseFloat(H),E=parseFloat(G);if(F!=H||isNaN(F)){throw new B()}if(E!=G||isNaN(E)){throw new A()}this.lat=Math.round(this.limitLat(F)*100000)/100000;this.lng=Math.round(this.limitLng(E)*100000)/100000},latAsRad:function(){return radians(this.lat)},lngAsRad:function(){return radians(this.lng)},equals:function(E){return E&&this.lat===E.lat&&this.lng===E.lng},limitLat:function(E){return DSLatitude.limitNumber(E)},limitLng:function(E){return DSLongitude.limitNumber(E)},toString:function(){return"LMI.Mapping.Point("+this.lat+","+this.lng+")"}};D.Point.fromRadians=function(F,E){return new D.Point(C(F),C(E))}})();function DSMapObject(B,C,D,E,A){this.init(B,C,D,E,A)}DSMapObject.prototype={init:function(B,C,D,E,A){this.setPoint(B);this.element=C;this.xOffset=(D?D:0);this.yOffset=(E?E:0);this.zOffset=(A?A:0);this.properties={};this.initEventListeners()},setPoint:function(A){this.point=A},setProperty:function(A,B){return this.properties[A]=B},setProperties:function(){for(var A=0;A<arguments.length;A++){this.properties[arguments[A]]=arguments[++A]}return this},getProperty:function(A){return(A&&A in this.properties?this.properties[A]:"")},getXOffset:function(){return this.xOffset},getYoffset:function(){return this.yOffset},getZOffset:function(){return this.zOffset},getWidth:function(){return this.element.offsetWidth},getHeight:function(){return this.element.offsetHeight},isIncludedInBestFit:function(){return !this.getProperty("excludeFromBestFit")},update:function(){},remove:function(){},initEventListeners:function(){this.initEvents("click","mouseout","mouseover")}};LMI.Lang.importFunctions(DSMapObject,LMI.Event);DSMapObject.prototype._addEventListener=DSMapObject.prototype.addEventListener;DSMapObject.prototype.addEventListener=function(B,D){var C=this,A;switch(B){case"click":LMI.StyleSheet.setCursor(this.element,"pointer");case"mouseout":case"mouseover":if(this.getListeners(B).length==0){A=function(E){var F=new LMI.BrowserEventObject(E,window.event,this);C.triggerEvent(B,F,C)};this["_"+B+"Listener"]=A;LMI.BrowserEvent.addListener(this.element,B,A)}break}this._addEventListener(B,D)};DSMapObject.prototype._removeEventListener=DSMapObject.prototype.removeEventListener;DSMapObject.prototype.removeEventListener=function(A,B){this._removeEventListener(A,B);if(A=="click"||A=="mouseout"||A=="mouseover"){if(this.getListeners(A).length==0){LMI.BrowserEvent.removeListener(this.element,A,this["_"+A+"Listener"]);delete this["_"+A+"Listener"]}}};DSMapObject.prototype.bindEvent=function(B,E,C,A){var D=function(F,G){C.call(E,F,G,A)};return this.addEventListener(B,D)};function DSMapObject_Iterator(A,B){this.coll=A;this.pos=(B?B:0)}function DSMapObject_HasNext(){if(this.coll&&(this.pos+1)<=this.coll.order.length){return true}this.pos=0;return false}function DSMapObject_Next(){return(this.coll.objects[this.coll.order[this.pos++]])}function DSMapObject_GetId(){return this.coll.order[this.pos-1]}function DSMapObject_SetIteratorOffset(A){this.pos=A}function DSMapObject_GetIteratorOffset(){return this.pos}function DSMapObject_Add(A){this.objects[this.currIdx]=A;this.order.push(this.currIdx);return this.currIdx++}function DSMapObject_Remove(B){if(this.objects[B]){delete this.objects[B];for(var A=0;A<this.order.length;++A){if(this.order[A]==B){this.order.splice(A,1)}}return true}return false}function DSMapObject_RemoveAll(){this.objects={};this.order=[];this.currPos=this.currIdx=0}function DSMapObject_GetByIndex(A){return this.objects[this.order[A]]}function DSMapObject_GetById(A){return this.objects[A]?this.objects[A]:null}function DSMapObject_Size(){return this.order.length}function DSMapObject_GetByProperty(A,C){for(var B=0;B<this.order.length;++B){if(this.objects[this.order[B]].getProperty(A)==C){return this.objects[this.order[B]]}}return null}function DSMapObject_GetIdsByProperty(A,D){var C=[];for(var B=0;B<this.order.length;++B){if(this.objects[this.order[B]].getProperty(A)==D){C.push(this.order[B])}}return C}function DSMapObject_Collection(){this.objects={};this.order=[];this.currPos=this.currIdx=0}DSMapObject_Collection.prototype.add=DSMapObject_Add;DSMapObject_Collection.prototype.remove=DSMapObject_Remove;DSMapObject_Collection.prototype.getById=DSMapObject_GetById;DSMapObject_Collection.prototype.getByIndex=DSMapObject_GetByIndex;DSMapObject_Collection.prototype.size=DSMapObject_Size;DSMapObject_Collection.prototype.getByProperty=DSMapObject_GetByProperty;DSMapObject_Collection.prototype.getIdsByProperty=DSMapObject_GetIdsByProperty;DSMapObject_Collection.prototype.removeAll=DSMapObject_RemoveAll;DSMapObject_Iterator.prototype.next=DSMapObject_Next;DSMapObject_Iterator.prototype.getId=DSMapObject_GetId;DSMapObject_Iterator.prototype.hasNext=DSMapObject_HasNext;DSMapObject_Iterator.prototype.setOffset=DSMapObject_SetIteratorOffset;DSMapObject_Iterator.prototype.getOffset=DSMapObject_GetIteratorOffset;function DSIcon(B,C,D,E,A){this.init(B,C,D,E,A)}LMI.Lang.extend(DSIcon,DSMapObject);DSIcon.prototype.init=function(B,C,E,F,A){var D=this.getIcon(C);DSIcon.superclass.init.call(this,B,D,E,F,A)};DSIcon.prototype.initEventListeners=function(){LMI.BrowserEvent.addListener(this.element,"error",DSIcon.ImageError);DSIcon.superclass.initEventListeners.call(this)};DSIcon.prototype.getIcon=function(A){return LMI.Element.createImage(A)};DSIcon.ImageError=function(A){var C=new LMI.BrowserEventObject(A,window.event,this),B=C.getCurrentTarget(),D=LMI.Urls.getImg("map_icon_blank.png");if(!LMI.Element.getImageSrc(B).match(D)){LMI.Element.setImageSrc(B,D)}};function DSOutline(B,C,A){this.init(B,C,A)}LMI.Lang.extend(DSOutline,DSMapObject);DSOutline.prototype.init=function(B,C,A){var E=LMI.Element.create("div",null);var D=LMI.Element.create("div",E);LMI.StyleSheet.addClass(E,"outline");LMI.StyleSheet.addClass(D,"fill");LMI.StyleSheet.setOpacity(E,60);LMI.StyleSheet.setOpacity(D,25);DSOutline.superclass.init.call(this,B,E);this.setWidth(C);this.setHeight(A)};DSOutline.prototype.setWidth=function(A){this.element.style.width=A+"px"};DSOutline.prototype.setHeight=function(A){this.element.style.height=A+"px"};function DSPolyLine(D,B,A,C){this.init(D,B,A,C)}LMI.Lang.extend(DSPolyLine,DSMapObject);DSPolyLine.prototype.init=function(E,B,A,D){this.eventsInited=false;this.shapePoints=E;this.routeArea=A;this.routeRect=null;this.setVisibleArea(D);this.timeout=null;var C;if(B){C=document.createElement("img");LMI.BrowserEvent.addListener(C,"load",DSPolyLine.ImageLoad);DSPolyLine.superclass.init.call(this,this.point,C,0,0,-1);this.setLineUrl(B);this.url=B}else{alert("TODO: create poly line element");C=LMI.Element.create("div",null);DSPolyLine.superclass.init.call(this,this.point,C,0,0,-1)}};DSPolyLine.prototype.updateCallback=function(A){if(A.routeUrl){this.setLineUrl(A.routeUrl);this.setVisibleArea(A.visibleRouteArea);this.map.positionObject(this)}};DSPolyLine.prototype.doUpdateLine=function(A){if(this.timeout){window.clearTimeout(this.timeout)}var B=this;this.timeout=window.setTimeout(function(){B.timeout=null;B.element.style.display="none";var E=A.getMapLayerURPoint();var D=A.getMapLayerLLPoint();var C=[D.lng,D.lat,E.lng,E.lat];this.center=A.getCenterPoint();LMI.AjaxController.getRouteImageUrl(function(F){B.updateCallback(F)},B.shapePoints,B.routeArea,C,A.zoomLevel)},250)};DSPolyLine.prototype.updateLine=function(G,F){if(!this.center&&G.previousCenter){this.center=G.previousCenter}if(G.eventType=="zoom"&&G.previousZoomLevel!=F.zoomLevel){this.routeRect=null;this.doUpdateLine(F)}else{if(G.eventType=="recenter"){var A=this.center;var B=F.getCenterPoint();var J=F.gridSystem.getUL(B.lng,B.lat,this.map.width,this.map.height);var I=F.gridSystem.getLR(B.lng,B.lat,this.map.width,this.map.height);var D=new Rectangle(J.y,J.x,I.y,I.x);if(!this.routeRect){this.routeRect=this.calculateRect(this.routeArea,F)}if(!this.visibleRect){this.visibleRect=this.calculateRect(this.visibleArea,F)}var E=D.intersection(this.routeRect);var C=D.intersection(this.visibleRect);var H=E.intersection(C);if(!E.equals(H)){this.doUpdateLine(F)}}}};DSPolyLine.prototype.calculateRect=function(C,D){var A=D.gridSystem.toXY(C[0],C[3]);var B=D.gridSystem.toXY(C[2],C[1]);return new Rectangle(A.y,A.x,B.y,B.x)};DSPolyLine.prototype.update=function(B){if(!this.eventsInited){this.eventsInited=true;this.map=B;var A=this;this.updateFunc=function(D,C){A.updateLine(D,C)};B.addEventListener("zoom",this.updateFunc);B.addEventListener("recenter",this.updateFunc)}};DSPolyLine.prototype.remove=function(){if(this.eventsInited){this.eventsInited=false;this.map.removeEventListener("zoom",this.updateFunc);this.map.removeEventListener("recenter",this.updateFunc)}};DSPolyLine.prototype.setVisibleArea=function(A){this.visibleArea=A;this.point=new LMI.Mapping.Point(A[3],A[0]);this.visibleRect=null};DSPolyLine.prototype.setLineUrl=function(B){this.url=B;if(LMI.Browser.browser==="Explorer"&&LMI.Browser.version<7){var C=this.element;var A=B.split("?",2);LMI.Element.setAlphaImageLoader(C,A[0]+"?"+A[1].replace(/%/g,"%25"))}else{this.element.src=B}};DSPolyLine.ImageLoad=function(A){var C=new LMI.BrowserEventObject(A,window.event,this);var B=C.getCurrentTarget();B.style.display="block";B.style.height="auto";B.style.width="auto"};function Rectangle(D,C,A,B){this.top=D;this.left=C;this.bottom=A;this.right=B}Rectangle.prototype.intersection=function(F,C){var B=Math.max(this.left,F.left);var E=Math.max(this.top,F.top);var A=Math.min(this.right,F.right);var D=Math.min(this.bottom,F.bottom);if(!C){C=new Rectangle()}C.top=E;C.left=B;C.bottom=D;C.right=A;return C};Rectangle.prototype.equals=function(A){return this.left==A.left&&this.top==A.top&&this.right==A.right&&this.bottom==A.bottom};var EQUITORIAL_EARTH_RADIUS_MEAN_METERS=6378245;var HALF_PI=Math.PI/2;(function(){var A=LMI.Lang.getObject("LMI.Mapping"),B=EQUITORIAL_EARTH_RADIUS_MEAN_METERS*0.000621371192;A.getDistance=function(I,G){if(I.equals(G)){return 0}var H=I.latAsRad(),F=G.latAsRad(),E=I.lngAsRad(),D=G.lngAsRad(),J=Math.cos,C=Math.sin;return Math.acos(J(H)*J(E)*J(F)*J(D)+J(H)*C(E)*J(F)*C(D)+C(H)*C(F))*B}})();function coord(A,B){this.x=A;this.y=B}coord.prototype.toString=function(){return"coord("+this.x+","+this.y+")"};function radians(A){return A*(Math.PI/180)}LMI.Mapping.Grid=function(G,D,B,C,H,A,F,E){this._P=G;this._x_grid_size=D;this._y_grid_size=B;this._x_upg=C;this._y_upg=H;this._invert_y=A;this._origin_lon=radians(F);this._origin_lat=radians(E);this.reset()};LMI.Mapping.Grid.prototype=(function(){return{reset:function(){var A=this._P.forward(this._origin_lon,this._origin_lat);this._x_translation=-A.x;this._y_translation=-A.y;this._x_scale=(this._x_upg/this._x_grid_size);this._y_scale=(this._y_upg/this._y_grid_size)*(this._invert_y?-1:1)},getXScale:function(){return this._x_scale},getYScale:function(){return this._y_scale},gridX:function(A){return Math.floor(A/this._x_upg)},gridY:function(A){return Math.floor(A/this._y_upg)},grid:function(A,C){if(arguments.length===1){var B=A;return new coord(this.gridX(B.x),this.gridY(B.y))}else{return new coord(this.gridX(A),this.gridY(C))}},offsetX:function(A){return A%this._x_upg},offsetY:function(A){return A%this._y_upg},offset:function(A,C){if(arguments.length===1){var B=A;return new coord(this.offsetX(B.x),this.offsetY(B.y))}else{return new coord(this.offsetX(A),this.offsetY(C))}},toX:function(A){var B=(arguments.length==2?arguments[1]:0);return(A*this._x_upg)+B},toY:function(A){var B=(arguments.length==2?arguments[1]:0);return(A*this._y_upg)+B},toXY:function(B,A,G,F){if(arguments.length==2){var E=B;var D=A;var C=this._P.forward(radians(E),radians(D));return new coord((C.x+this._x_translation)*this._x_scale,(C.y+this._y_translation)*this._y_scale)}else{return new coord(this.toX(B,A),this.toY(G,F))}},toLL:function(A,B){if(arguments.length==1){B=arguments[0].y;A=arguments[0].x}return this._P.inverse((A/this._x_scale)-this._x_translation,(B/this._y_scale)-this._y_translation)},getUL:function(C,B,D,A){var E=this.toXY(C,B);if(this._invert_y){return new coord(E.x-(D/2),E.y-(A/2))}else{return new coord(E.x-(D/2),E.y+(A/2))}},getLR:function(C,B,D,A){var E=this.toXY(C,B);if(this._invert_y){return new coord(E.x+(D/2),E.y+(A/2))}else{return new coord(E.x+(D/2),E.y-(A/2))}},getLL:function(C,B,D,A){var E=this.toXY(C,B);if(this._invert_y){return new coord(E.x-(D/2),E.y+(A/2))}else{return new coord(E.x-(D/2),E.y-(A/2))}},getUR:function(C,B,D,A){var E=this.toXY(C,B);if(this._invert_y){return new coord(E.x+(D/2),E.y-(A/2))}else{return new coord(E.x+(D/2),E.y+(A/2))}}}})();LMI.Mapping.Grid.newInstance=function(D,B,C,A,E){return new LMI.Mapping.Grid(new EquiRectangularMapProjection(radians(0),radians(E)),D,B,C,A,true,-180,90)};function EquiRectangularMapProjection(B,A){this._center_lon=B;this._center_lat=A;this._cos_center_lat=Math.cos(A);this._R=EQUITORIAL_EARTH_RADIUS_MEAN_METERS}function adjust_lon(A){if(A<-Math.PI){return A-(Math.floor(A/Math.PI)*Math.PI)}else{if(A>Math.PI){return -(Math.PI-A+(Math.floor(A/Math.PI)*Math.PI))}}return A}EquiRectangularMapProjection.prototype.forward=function(B,A){return new coord(this._R*adjust_lon(B-this._center_lon)*this._cos_center_lat,this._R*A)};EquiRectangularMapProjection.prototype.inverse=function(A,B){return LMI.Mapping.Point.fromRadians(Math.min(B/this._R,HALF_PI),adjust_lon(this._center_lon+A/(this._R*this._cos_center_lat)))};(function(){var D=LMI.Lang.getObject("LMI.Mapping",true),C=[1.7021276,3.4042553,6.80851064,13.61702128,27.23404256,54.46808512,108.93617024,217.87234048,435.74468096,871.48936192,1742.97872384,3485.95744768,6971.9148953,13943.82979072],B=[],A=false;D.Map=function(E,F){this.init(E,F)};D.Map.prototype={setZoomLevel:function(F,E){this.prepareEventObject();if(F<1){F=1}else{if(F>C.length){F=C.length}}if(this.zoomSlider&&this.zoomSlider.shown){this.zoomSlider.setPosition(((F-1)/(C.length-1)))}if(E&&!E.equals(this.getCenterPoint())){this.setCenterPoint(E)}this.zoomLevel=F;this.setScale();this.loadTiles();this.triggerEvent("zoom",this.getEventObject(),this)},bestFit:function(O,M){if(typeof O==="number"){this.factor=O}else{if(typeof this.factor==="number"){O=this.factor}else{this.factor=O=0.9}}M=M||this.objects;var J,G,T,H=null,E=null,I=new DSMapObject_Iterator(M);P=this.gridSystem._P;while(I.hasNext()){G=I.next();if(!G.isIncludedInBestFit()){continue}if(H===null){H=P.forward(G.point.lngAsRad(),G.point.latAsRad())}if(E===null){E=new coord(H.x,H.y)}T=P.forward(G.point.lngAsRad(),G.point.latAsRad());if(T.x<E.x){E.x=T.x}if(T.x>H.x){H.x=T.x}if(T.y<E.y){E.y=T.y}if(T.y>H.y){H.y=T.y}}if(H===null){if(this.getOption("defaultLat")&&this.getOption("defaultLng")&&this.getOption("emptyZoom")){this.centerAndZoom(new D.Point(this.getOption("defaultLat"),this.getOption("defaultLng")),this.getOption("emptyZoom"))}}else{if(E.x===H.x&&E.y===H.y){var Q=P.inverse(E.x,E.y);this.centerAndZoom(Q,this.getOption("singleZoom"))}else{var N=P.inverse((E.x+H.x)/2,(E.y+H.y)/2);var F=this.width*O;var R=this.height*O;var L=H.x-E.x;var K=H.y-E.y;L*=F/R;for(J=0;J<C.length;++J){if(L<=(F/B[J].getXScale())&&K<=Math.abs(R/B[J].getYScale())){break}}var S=Math.min(J,C.length-1);this.centerAndZoom(N,S+1)}}},centerOnPoint:function(E){if(!E.equals(this.getCenterPoint())){this.prepareEventObject();this.setCenterPoint(new D.Point(E.lat,E.lng));this.loadTiles();var F=this.getEventObject();this.triggerEvent("recenter",F,this)}},centerAndZoom:function(E,G){this.prepareEventObject();this.setZoomLevel(G,E);var F=this.getEventObject();this.triggerEvent("recenter",F,this)},init:function(E,G){var F=(typeof E==="string")?F=LMI.Element.getOne(E):E;if(!F){throw ('Map: unable to find container: "'+E+'"')}this.container=F;LMI.StyleSheet.addClass(F,"dsMap");this.initOptions(G);this.decorators=new DSMapDecoratorCollection();this.centerPoint=null;this.zoomLevel=C.length;this.locale=this.getOption("defaultLocale");if(!A){for(var H=0;H<C.length;++H){B[H]=LMI.Mapping.Grid.newInstance(C[H]*this.getOption("tileWidth"),C[H]*this.getOption("tileHeight"),this.getOption("tileWidth"),this.getOption("tileHeight"),this.getOption("standardParallel"))}A=true}var I=new Date().getYear();if(I<1000){I+=1900}this.copyrightTxt="\xa9"+I+" Local Matters, Inc.";this.copyrightSet=DSMapCopyrightSet;this.setScale();this.setGridLeft(null);this.setGridTop(null);this.columns=this.rows=0;this.initContainer();this.tileUrlFactory=new DSMapTileUrlFactory(this.getOption("tileBase"),"",this.getOption("tileExtension"),this,this.getOption("tileSuffix"));this.objects=new DSMapObject_Collection();this.initEvents("zoom","recenter","resize")},initOptions:function(E){this.options=LMI.Mapping.Map.Defaults;if(typeof E!="undefined"){for(var F in E){this.options[F]=E[F]}}},setLocale:function(E){this.locale=E;this.tileUrlFactory.setLocale(E)},setOption:function(E,F){this.options[E]=F},getOption:function(E){return this.options[E]||""},addDecorator:function(E){this.decorators.push(E);this.decoratorLayer.appendChild(E.getElement())},removeDecorator:function(G){var E=this.decorators.getLength();for(var F=0;F<E;++F){if(this.decorators.getByIndex(F)===G){this.decorators.remove(F);this.decoratorLayer.removeChild(G.getElement());return }}},positionTile:function(F){var E=this.tiles[F];E.setLeft(((F%this.columns)*E.getWidth()+this.mlOffsetLeft)+"px");E.setTop((Math.floor(F/this.columns)*E.getHeight()+this.mlOffsetTop)+"px")},prepareEventObject:function(){this.beforeEvent={previousZoomLevel:this.zoomLevel,previousCenter:this.getCenterPoint()}},getEventObject:function(){var E=this.beforeEvent;this.beforeEvent={};E.zoomLevel=this.zoomLevel;E.center=this.getCenterPoint();return E},setCopyright:function(E){this.copyright.getElement().firstChild.nodeValue=this.copyrightTxt=E},setGridLeft:function(E){return(this.gridLeft=E)},getGridLeft:function(){return this.gridLeft},setGridTop:function(E){return(this.gridTop=E)},getGridTop:function(){return this.gridTop},getScale:function(E){if(typeof E=="number"){return C[E-1]}return this.scale},setScale:function(){this.scale=C[this.zoomLevel-1];this.gridSystem=B[this.zoomLevel-1]},positionMap:function(){var E=this.getMapLayerXYByPoint(this.getCenterPoint());this.mapLayer.style.left=Math.round((this.width/2)-E.x)+"px";this.mapLayer.style.top=Math.round((this.height/2)-E.y)+"px"},updateTiles:function(){for(var E=0;E<this.tiles.length;++E){this.tiles[E].setSize(this.getOption("tileWidth"),this.getOption("tileHeight"));this.positionTile(E)}this.updateDataCopyright()},updateMap:function(){this.updateTiles()},calculateGridPosition:function(){var F=this.getCenterPoint();var E=this.gridSystem.getUL(F.lng,F.lat,this.mapLayerWidth,this.mapLayerHeight);var G=this.gridSystem.grid(E);this.setGridLeft(G.x);this.setGridTop(G.y)},loadTiles:function(){this.mlOffsetTop=this.mlOffsetLeft=0;var G=0;this.calculateGridPosition();for(var F=this.getGridTop();F<this.getGridTop()+this.rows;++F){for(var E=this.getGridLeft();E<this.getGridLeft()+this.columns;++E){this.tiles[G++].setUrl(this.tileUrlFactory.getUrl(E,F,this.zoomLevel))}}this.updateMap();this.positionMap();this.updateObjects()},updateObjects:function(){for(var E=new DSMapObject_Iterator(this.objects);E.hasNext();){this.positionObject(E.next())}},getMapLayerULXY:function(){var E=this.mapLayer.style;return new coord(parseInt(E.left,10),parseInt(E.top,10))},getMapLayerXYByPoint:function(G){if(this.getGridLeft()!==null&&this.getGridTop()!==null){var E=this.gridSystem.toX(this.getGridLeft());var H=this.gridSystem.toY(this.getGridTop());var F=this.gridSystem.toXY(G.lng,G.lat);return new coord(Math.round(F.x-E),Math.round(F.y-H))}return null},getXYByPoint:function(F){var E=this.getMapLayerXYByPoint(F);if(E){E.x+=this.getMapLeft();E.y+=this.getMapTop()}return E},getPointByMapLayerXY:function(E,F){if(this.getGridLeft()!==null&&this.getGridTop()!==null){return this.gridSystem.toLL(this.gridSystem.toXY(this.getGridLeft(),E-this.mlOffsetLeft,this.getGridTop(),F-this.mlOffsetTop))}return null},getPointByXY:function(E,F){return this.getPointByMapLayerXY(E-this.getMapLeft(true),F-this.getMapTop(true))},setCenterPoint:function(E){this.centerPoint=E},getCenterPoint:function(){return this.centerPoint},getMapLayerCenterXY:function(){return new coord((this.width/2)-this.getMapLeft(),(this.height/2)-this.getMapTop())},getULPoint:function(){return this.getPointByXY(0,0)},getBRPoint:function(){return this.getPointByXY(this.width,this.height)},getURPoint:function(){return this.getPointByXY(this.width,0)},getBLPoint:function(){return this.getPointByXY(0,this.height)},calculateCenterPoint:function(){return this.getPointByXY(Math.floor(this.width/2),Math.floor(this.height/2))},recalculateCenterPoint:function(){this.setCenterPoint(this.calculateCenterPoint())},getMapLayerLLPoint:function(){var F=this.getCenterPoint();var E=this.gridSystem.getLL(F.lng,F.lat,this.mapLayerWidth,this.mapLayerHeight);return this.gridSystem.toLL(E.x,E.y)},getMapLayerURPoint:function(){var F=this.getCenterPoint();var E=this.gridSystem.getUR(F.lng,F.lat,this.mapLayerWidth,this.mapLayerHeight);return this.gridSystem.toLL(E.x,E.y)},positionObject:function(G,E){if(typeof E!="undefined"){G.setPoint(E)}var F=this.getMapLayerXYByPoint(G.point);if(F){G.element.style.left=(F.x-G.xOffset+this.mlOffsetLeft)+"px";G.element.style.top=(F.y-G.yOffset+this.mlOffsetTop)+"px"}G.update(this)},addObject:function(E){var F=this.objects.add(E);E.element.style.position="absolute";E.z=5+E.zOffset;E.element.style.zIndex=E.z;this.positionObject(E);this.mapLayer.appendChild(E.element);return F},removeObject:function(H){var I=-1;if(typeof H==="object"){for(var F=new DSMapObject_Iterator(this.objects);F.hasNext();){var E=F.next();if(E===H){I=F.getId();break}}}else{I=H}var G=this.objects.getById(I);if(G){G.remove(this);this.mapLayer.removeChild(G.element);this.objects.remove(I)}},removeAll:function(){var F;for(var E=new DSMapObject_Iterator(this.objects);E.hasNext();){F=E.next();F.remove(this);F.element.parentNode.removeChild(F.element)}this.objects.removeAll()},updateDataCopyright:function(){if(!this.dataCopyright){var F=LMI.Element.create("div",null,{textValue:" ",className:"dataCopyright"});var E={zIndex:100,bottom:0};if(this.width>=250){E.right=0}else{E.left=0}this.dataCopyright=new DSMapDecorator(this,F,E,"copyright","data copyright");this.addDecorator(this.dataCopyright)}this.dataCopyright.getElement().firstChild.nodeValue=this.copyrightSet.getCopyright(this.getCenterPoint(),this.zoomLevel)},addCopyright:function(){var E=LMI.Element.create("div",null,{textValue:this.copyrightTxt});LMI.StyleSheet.addClass(E,"copyright");this.copyright=new DSMapDecorator(this,E,{bottom:this.width>=250?0:10},"copyright","main copyright");this.addDecorator(this.copyright);this.updateDataCopyright()},sizeLayers:function(){this.width=parseInt(this.container.clientWidth,10);this.height=parseInt(this.container.clientHeight,10);this.desiredRows=Math.ceil(this.height/this.getOption("tileHeight"))+2;this.desiredColumns=Math.ceil(this.width/this.getOption("tileWidth"))+2;this.mapLayerWidth=this.desiredColumns*this.getOption("tileWidth");this.mapLayerHeight=this.desiredRows*this.getOption("tileHeight");this.mapLayer.style.height=this.mapLayerHeight+"px";this.mapLayer.style.width=this.mapLayerWidth+"px";this.viewport.style.height=this.height+"px";this.viewport.style.width=this.width+"px";this.decoratorLayer.style.height=this.height+"px";this.decoratorLayer.style.width=this.width+"px"},initContainer:function(){this.decoratorLayer=LMI.Element.create("div",this.container,{"class":"decLayer"});this.viewport=LMI.Element.create("div",this.decoratorLayer,{"class":"viewport"});this.mapLayer=LMI.Element.create("div",this.viewport,{"class":"mapLayer"});this.tileLayer=LMI.Element.create("div",this.mapLayer,{"class":"tileLayer"});if(!this.getOption("controlBuffer")){this.setOption("controlBuffer",0)}this.sizeLayers();this.tiles=[];for(var F=0;F<this.desiredRows;++F){for(var E=0;E<this.desiredColumns;++E){this.tiles.push(new D.Tile(this,this.tileLayer))}}this.rows=this.desiredRows;this.columns=this.desiredColumns;this.mlOffsetTop=this.mlOffsetLeft=0;this.addCopyright()},getMapLeft:function(F){var E=parseInt(this.mapLayer.offsetLeft,10);if(!F){E+=this.mlOffsetLeft}return E},getMapTop:function(E){var F=parseInt(this.mapLayer.offsetTop,10);if(!E){F+=this.mlOffsetTop}return F}};LMI.Lang.importFunctions(D.Map,LMI.Event);D.Map.setScales=function(E){C=E};D.Map.getScales=function(){return C}})();LMI.Mapping.Map.Defaults={singleZoom:3,emptyZoom:14,defaultLat:39.73926,defaultLng:-104.98478,defaultLocale:"",imageBase:"img/",pixelUrl:"img/pixel_trans.gif",brokenUrl:"img/map_unavailable.gif",tileBase:"http://localhost/tiles/",tileExtension:".png",tileSuffix:"",tileWidth:256,tileHeight:256,tileAttempts:1,standardParallel:40};(function(){var B={};LMI.Mapping.Tile=function(D,C){this.map=D;this.img=LMI.Element.create("img",C,{src:D.getOption("pixelUrl"),style:"position: absolute;",galleryImg:"no"});LMI.StyleSheet.setOpacity(this.img,0);LMI.BrowserEvent.bind(this.img,"load",this,this.load);LMI.BrowserEvent.bind(this.img,"error",this,this.error)};LMI.Mapping.Tile.prototype={error:function(){var E=this.img,D=this.map.getOption("tileAttempts"),G=this.map.getOption("brokenUrl"),C=this.map.getOption("pixelUrl");if(!B[E.src]){B[E.src]=1}if(B[E.src]++<D){var F=E.src;E.src=C;E.src=F}else{if(!E.src.match(G)){E.src=G}}},load:function(D){var C;if("Animation" in LMI){C=new LMI.Animation.Fade(this.img,0,100);C.setDuration(0.75);if(LMI.Browser.browser=="Explorer"){C.bindEvent("end",this,function(){this.img.style.filter=""})}C.start()}else{LMI.StyleSheet.setOpacity(this.img,100)}},removeFromDom:function(){LMI.Element.destroy(this.img)},setSize:function(D,C){this.width=this.img.width=D;this.height=this.img.height=C},getWidth:function(){return this.width},getHeight:function(){return this.height},setLeft:function(C){this.img.style.left=C},setTop:function(C){this.img.style.top=C},setUrl:function(C){if(this.loadTimeout){window.clearTimeout(this.loadTimeout);this.loadTimeout=null}if(typeof this.img.complete!="undefined"&&!this.img.complete){var D=this;this.loadTimeout=window.setTimeout(function(){D.loadTimeout=null;D.setUrl(C)},1000);return }if(C){if(this.img.src!=C){LMI.StyleSheet.setOpacity(this.img,1);A(this.img,C)}}else{A(this.img,this.map.getOption("brokenUrl"))}}};function A(C,D){window.setTimeout(function(){C.src=D},0)}})();var DSMapCopyrightSet=new DSCopyrightSet();(function(){var D=new Date().getYear(),E=LMI.Mapping.Point;if(D<1000){D+=1900}var C=new DSCopyright("\xa9"+D+" NAVTEQ",[new DSBoundingBox(new E(10,-135),new E(70,-60)),new DSBoundingBox(new E(48,-180),new E(75,-124)),new DSBoundingBox(new E(16.860777,-161.283172),new E(24.219651,-153.424705)),new DSBoundingBox(new E(12.5,-78.6),new E(33,-50))]);var B=new DSCopyright("\xa9"+D+" TeleAtlas",[new DSBoundingBox(new E(48.478825,1.322422),new E(52.521175,7.677558)),new DSBoundingBox(new E(31,-10),new E(44,5)),new DSBoundingBox(new E(48,-0.6),new E(56,11.5)),new DSBoundingBox(new E(46,-20),new E(61,4.7))]);var A="\xa9"+D+" Terralink Intl Ltd";DSMapCopyrightSet.addCopyright(C);DSMapCopyrightSet.addCopyright(B);DSMapCopyrightSet.addCopyright(new DSCopyright(A,new DSBoundingBox(new E(-70,133),new E(-11,180))))})();