CM=window.CM||{};CM.extend=function(A,C){for(var B in C){if(C.hasOwnProperty(B)){A[B]=C[B]}}return A};CM.bind=function(A,B){return function(){return A.apply(B,arguments)}};CM.addEvent=(function(){var B=0;var A=function(){var D=window.event;if(!D){var C=A.caller;while(C){D=C["arguments"][0];if(D&&Event==D.constructor){break}C=C.caller}}return D};return function(F,E,D,C){if(!D.guid){D.guid=B++}F[E+D.guid]=function(G){return D.call(C||F,G||A())};if(F.addEventListener){if(E=="mousewheel"){F.addEventListener("DOMMouseScroll",F[E+D.guid],false)}F.addEventListener(E,F[E+D.guid],false)}else{if(F.attachEvent){F.attachEvent("on"+E,F[E+D.guid])}}}})();CM.removeEvent=function(C,B,A){if(C.removeEventListener){if(B=="mousewheel"){C.removeEventListener("DOMMouseScroll",C[B+A.guid],false)}C.removeEventListener(B,C[B+A.guid],false)}else{if(C.detachEvent){C.detachEvent("on"+B,C[B+A.guid]);C[B+A.guid]=null}}};CM.stopEvent=function(A){CM.stopPropagation(A);CM.preventDefault(A)};CM.stopPropagation=function(A){if(A.stopPropagation){A.stopPropagation()}else{A.cancelBubble=true}};CM.preventDefault=function(A){if(A.preventDefault){A.preventDefault()}else{A.returnValue=false}};CM.getMousePosition=function(B){var A=0,C=0;if(B.pageX||B.pageY){A=B.pageX;C=B.pageY}else{if(B.clientX||B.clientY){A=B.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;C=B.clientY+document.body.scrollTop+document.documentElement.scrollTop}}return new CM.Point(A,C)};CM.cumulativeOffset=function(A){var C=0,B=0;do{C+=A.offsetTop||0;B+=A.offsetLeft||0;A=A.offsetParent}while(A);return new CM.Point(B,C)};CM.addCustomEvent=(function(){var A=0;return function(E,D,C,B){if(!C.guid){C.guid=A++}C.context=B;E["custom"+D]=E["custom"+D]||{};E["custom"+D][C.guid]=C}})();CM.removeCustomEvent=function(C,B,A){delete C["custom"+B][A.guid]};CM.fireCustomEvent=function(F,D){var A=F["custom"+D];function E(I){if(!I){return[]}if(I.toArray){return I.toArray()}var H=I.length||0,G=new Array(H);while(H--){G[H]=I[H]}return G}if(A){for(var B in A){if(A.hasOwnProperty(B)){var C=A[B];C.apply(C.context||F,E(arguments).slice(2))}}}};CM.setStyles=function(B,C){for(var A in C){if(C.hasOwnProperty(A)){if((A=="opacity")&&CM.BrowserEngine.isIE){B.style.filter="alpha(opacity="+Math.round(parseFloat(C[A])*100)+")"}else{B.style[A]=C[A]+""}}}};(function(){CM.BrowserEngine={};if(window.opera){CM.BrowserEngine.isOpera=true}else{if(window.ActiveXObject){CM.BrowserEngine.isIE=true;if(navigator.userAgent.indexOf("MSIE 5")!=-1){CM.BrowserEngine.isIE5=true}else{CM.BrowserEngine["isIE"+(window.XMLHttpRequest?"7":"6")]=true}}else{if(!navigator.taintEnabled){CM.BrowserEngine.isWebKit=true;if(navigator.userAgent.indexOf("Safari")!=-1){CM.BrowserEngine.isSafari=true}}else{if(document.getBoxObjectFor){CM.BrowserEngine.isGecko=true;if(navigator.userAgent.indexOf("Firefox")!=-1){CM.BrowserEngine.isFirefox=true}}}}}})();CM.disableTextSelection=function(){if(document.selection&&document.selection.empty){document.selection.empty()}if(!CM._onselectstart){CM._onselectstart=document.onselectstart;document.onselectstart=function(){return false}}};CM.enableTextSelection=function(){document.onselectstart=CM._onselectstart;CM._onselectstart=null};CM.DraggableObject=function(B,A){this.element=B;CM.extend(this,A);this.enable()};CM.DraggableObject.prototype={enable:function(){CM.addEvent(this.element,"mousedown",this._onMouseDown,this);this._draggingEnabled=true},disable:function(){CM.removeEvent(this.element,"mousedown",this._onMouseDown);this._draggingEnabled=false},moved:function(){return(this.startX!=this.x||this.startY!=this.y)},_captureDelta:function(A){this.dx=this.x?A.clientX-this.x:0;this.dy=this.y?A.clientY-this.y:0;this.x=A.clientX;this.y=A.clientY},_onMove:function(A){this._captureDelta(A);this.left+=this.dx;this.top+=this.dy;CM.setStyles(this.element,{left:this.left+"px",top:this.top+"px"});if(this._fireDragStart){CM.fireCustomEvent(this,"dragstart");this._fireDragStart=false}},_onMouseDown:function(A){if(A.shiftKey||((A.which!=1)&&(A.button!=1))){return false}this.left=parseInt(this.element.style.left);this.top=parseInt(this.element.style.top);this.started=true;this._fireDragStart=true;CM.disableTextSelection();this._captureDelta(A);this.startX=this.x;this.startY=this.y;if(!CM.BrowserEngine.isIE6){document.body.style.cursor="move";if(this.element.style.cursor){this.cursor=this.element.style.cursor}this.element.style.cursor="move"}CM.addEvent(document,"mousemove",this._onMove,this);CM.addEvent(document,"mouseup",this._stopDragging,this);if(this.container){CM.addEvent(this.container,"mouseout",this._onMouseOut,this)}CM.stopEvent(A)},_stopDragging:function(){if(!this.started){return false}this.started=false;CM.enableTextSelection();if(!CM.BrowserEngine.isIE6){document.body.style.cursor="";this.element.style.cursor=this.cursor||"";this.cursor=null}CM.removeEvent(document,"mousemove",this._onMove);CM.removeEvent(document,"mouseup",this._stopDragging);if(this.container){CM.removeEvent(this.container,"mouseout",this._onMouseOut)}if(this.moved()){CM.fireCustomEvent(this,"dragend")}},_onMouseOut:function(A){var B=function(C){var D=A.relatedTarget?A.relatedTarget:A.toElement;while(D!=C&&D!=null){D=D.parentNode}return(D!=C)};if(this.container&&B(this.container)){this._stopDragging()}}};CM=window.CM||{};CM.Point=function(A,B){this.x=A;this.y=B};CM.Size=function(B,A){this.width=B;this.height=A};CM.LatLng=function(B,A){this._lat=B;this._lng=A};CM.LatLng.prototype={toMercator:function(){var A=this._lng*20037508.34/180;var B=Math.log(Math.tan((90+this._lat)*Math.PI/360))/(Math.PI/180);B=B*20037508.34/180;return new CM.LatLng(B,A)},fromMercator:function(){var A=this._lng*180/20037508.34;var B=this._lat*180/20037508.34;B=180/Math.PI*(2*Math.atan(Math.exp(B*Math.PI/180))-Math.PI/2);return new CM.LatLng(B,A)},lat:function(){return this._lat},lng:function(){return this._lng},toString:function(A){var C;if(A){C=Math.pow(10,A)}var D=C?Math.round(this._lat*C)/C:this._lat;var B=C?Math.round(this._lng*C)/C:this._lng;return"("+D+", "+B+")"}};CM.Bounds=function(B){if(B.length<2){throw"Invalid arguments for Bounds constructor."}for(var A=0;A<B.length;A++){if(!this.minX||(B[A].x<this.minX)){this.minX=B[A].x}if(!this.maxX||(B[A].x>this.maxX)){this.maxX=B[A].x}if(!this.minY||(B[A].y<this.minY)){this.minY=B[A].y}if(!this.maxY||(B[A].y>this.maxY)){this.maxY=B[A].y}}};CM.Bounds.prototype={min:function(){return new CM.Point(this.minX,this.minY)},max:function(){return new CM.Point(this.maxX,this.maxY)},mid:function(){return new CM.Point(Math.round((this.minX+this.maxX)/2),Math.round((this.minY+this.maxY)/2))}};CM.LatLngBounds=function(A,B){this._sw=A;this._ne=B};CM.LatLngBounds.prototype={getSouthWest:function(){return this._sw},getNorthEast:function(){return this._ne},getCenter:function(){var A=(this._sw.lng()+this._ne.lng())/2;var B=(this._sw.lat()+this._ne.lat())/2;return new CM.LatLng(B,A)}};CM=window.CM||{};CM.Map=function(B,A){this.container=(typeof B=="string"?document.getElementById(B):B);this.mapId=this._generateId();this._defaultLayerOptions={rootUrl:"http://tile.cloudmade.com",subdomains:"abc",styleId:1,tileSize:256,numZoomLevels:19};this._defaultOtherOptions={tileErrorUrl:CM.IMAGE_ROOT+"/empty-tile.png",maxExtent:{left:-20037508,bottom:-20037508,right:20037508,top:20037508},siteUrl:"http://cloudmade.com",copyrightText:"&copy; 2009 <a style='color: #0078A8' href='${siteUrl}'>CloudMade</a> - Map data <a style='color: #0078A8' href='http://creativecommons.org/licenses/by-sa/2.0/'>CCBYSA</a> 2009 <a style='color: #0078A8' href='http://openstreetmap.org'>OpenStreetMap.org</a> contributors - <a style='color: #0078A8' href='${siteUrl}/terms_conditions'>Terms of Use</a>"};CM.extend(this,this._defaultLayerOptions);CM.extend(this,this._defaultOtherOptions);CM.extend(this,A);this._initLayout();this._initEvents();this._initMousePosCapture();this.enableDragging();this._initWheelZoom();this._initDoubleClickZoom();this._initShiftDragZoom();this._initTileUrl();this._calculateResolutions()};CM.Map.prototype={setCenter:function(F,D){if(typeof D=="undefined"){D=this.zoom}var C=(this.zoom!=D)||!this.isLoaded();if((D<=this.numZoomLevels-1)&&(D>=0)){this.zoom=D}else{C=false}if(this.isLoaded()){CM.fireCustomEvent(this,"movestart")}if(C){this.center=F;this.mapLayer.innerHTML="";this._calcViewPosition()}else{var E=this.getCenter().toMercator();var B=F.toMercator();var A=this._getResolution();this.mapLeft+=Math.round((E.lng()-B.lng())/A);this.mapTop-=Math.round((E.lat()-B.lat())/A);this.mapLayer.style.left=this.mapLeft+"px";this.mapLayer.style.top=this.mapTop+"px"}if(!this.isLoaded()){this._loaded=true;if(!this.savedCenter){this.savePosition()}}else{if(C){CM.fireCustomEvent(this,"zoomend")}CM.fireCustomEvent(this,"moveend")}this._renderView()},getCenter:function(){this._checkIfLoaded();return this._fromPxDeltaToLatLng(this.center,this._getMapOffset())},getSize:function(){return new CM.Size(this.container.offsetWidth,this.container.offsetHeight)},getBounds:function(){var A=this.getSize();return new CM.LatLngBounds(this.fromContainerPixelToLatLng(new CM.Point(0,0)),this.fromContainerPixelToLatLng(new CM.Point(A.width,A.height)))},getContainer:function(){return this.container},isLoaded:function(){return !!this._loaded},fromContainerPixelToLatLng:function(C){var B=this.getSize();var A=Math.round(C.x-B.width/2);var D=Math.round(C.y-B.height/2);return this._fromPxDeltaToLatLng(this.getCenter(),new CM.Point(A,D))},fromLatLngToDivPixel:function(D){var B=this._getResolution();var A=D.toMercator();var C=new CM.LatLng(-this.startTileTop*B*this.tileSize+this.maxExtent.top-A.lat(),-this.startTileLeft*B*this.tileSize-this.maxExtent.left+A.lng());return new CM.Point(Math.round(C.lng()/B),Math.round(C.lat()/B))},panTo:function(A){this._checkIfLoaded();this.setCenter(A)},setZoom:function(A){this._checkIfLoaded();this.setCenter(this.getCenter(),A)},getZoom:function(){this._checkIfLoaded();return this.zoom},getBoundsZoomLevel:function(E){var C=this.getSize();var A=E.maxX-E.minX;var G=E.maxY-E.minY;var B=G*(C.width/C.height);B=(A>=B?A:B);var D=this.getZoom();var F=C.width;while(F>=B){F*=(this._getResolution(D+1)/this._getResolution(D));D++}return D-1},zoomIn:function(){if(this.zoom==this.numZoomLevels-1){return false}this.setZoom(this.zoom+1)},zoomOut:function(){if(this.zoom===0){return false}this.setZoom(this.zoom-1)},enableDragging:function(){if(!this._draggingEnabled){this.dragObject=new CM.DraggableObject(this.mapLayer,{container:this.container});CM.addCustomEvent(this.dragObject,"dragend",function(){this.mapLeft=this.dragObject.left;this.mapTop=this.dragObject.top;this._renderView();CM.fireCustomEvent(this,"dragend");CM.fireCustomEvent(this,"moveend")},this);CM.addCustomEvent(this.dragObject,"dragstart",function(){CM.fireCustomEvent(this,"dragstart");CM.fireCustomEvent(this,"movestart")},this);this._draggingEnabled=true}else{this.dragObject.enable()}},disableDragging:function(){this.dragObject.disable()},draggingEnabled:function(){return !!this._draggingEnabled},enableScrollWheelZoom:function(){if(!this.scrollWheelZoomEnabled()){this._addWheelZoomEvents()}},disableScrollWheelZoom:function(){if(this.scrollWheelZoomEnabled()){this._removeWheelZoomEvents()}},scrollWheelZoomEnabled:function(){return !!this._wheelZoomEnabled},enableDoubleClickZoom:function(){if(!this.doubleClickZoomEnabled()){this._addDblClickZoomEvents()}},disableDoubleClickZoom:function(){if(this.doubleClickZoomEnabled()){this._removeDblClickZoomEvents()}},doubleClickZoomEnabled:function(){return !!this._dblClickZoomEnabled},enableShiftDragZoom:function(){if(!this.shiftDragZoomEnabled()){this._addShiftDragZoomEvents()}},disableShiftDragZoom:function(){if(this.shiftDragZoomEnabled()){this._removeShiftDragZoomEvents()}},shiftDragZoomEnabled:function(){return !!this._shiftDragZoomEnabled},savePosition:function(){this.savedCenter=this.getCenter();this.savedZoom=this.getZoom()},returnToSavedPosition:function(){this.setCenter(this.savedCenter,this.savedZoom)},addOverlay:function(A){A.initialize(this)},addControl:function(B,A){B.initialize(this,A)},checkResize:function(){this._renderView()},usePermalink:function(){this._permalinkUsed=true;var G=function(I){I=I.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var K=new RegExp("[\\?&]"+I+"=([^&#]*)");var J=window.location.href.match(K);return(J?J[1]:"")};var H=parseFloat(G("lat"));var D=parseFloat(G("lng"));var F=parseInt(G("zoom"));var B=G("marker");var C=parseInt(G("styleId"));var E=function(){for(var I=0;I<arguments.length;I++){if(isNaN(arguments[I])){return false}}return true};if(E(H,D,F)){var A=new CM.LatLng(H,D);if(C){this.styleId=C;this._initTileUrl()}this.setCenter(A,F);if(B){this.addOverlay(new CM.Marker(A))}return true}else{return false}},getPermalink:function(){if(!this._permalinkUsed){throw"Permalink is not used on this page. Use map.usePermalink() method."}var G=function(J){var I=Math.pow(10,5);return Math.round(J*I)/I};var B=this.getCenter();var F=G(B.lat());var D=G(B.lng());var E=this.getZoom();var H=window.location.href.split("#");var C=H[0];var A=function(){for(var I=0;I<arguments.length;I++){C=C.replace(new RegExp("[&?]"+arguments[I]+"=[^&#?]+","g"),"")}C=C.replace("&","?")};A("lat","lng","zoom","styleId");C+=(C.match(/\?.+/)?"&":"?")+"lat="+F;C+="&lng="+D;C+="&zoom="+E;C+="&styleId="+this.styleId;return C+(H[1]?"#"+H[1]:"")},getIFrameCode:function(D,C,B){var A=this.getCenter();C=C||460;B=B||350;var E=this.siteUrl.replace("http://","http://maps.");return'<iframe width="'+C+'" height="'+B+'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+E+"/iframe?"+(D?"key="+D+"&":"")+"lat="+A.lat()+"&lng="+A.lng()+"&zoom="+this.getZoom()+"&styleId="+this.styleId+'"></iframe>'},refresh:function(){this.postfix=+new Date();var A=this.getCenter();this._loaded=false;this.setCenter(A,this.zoom)},_generateId:function(){if(typeof CM.Map.lastId==="undefined"){CM.Map.lastId=0}else{CM.Map.lastId++}return CM.Map.lastId},_initTileUrl:function(){var A=this.rootUrl.replace("http://","");if(this.key&&this.styleId){A+="/"+this.key;A+="/"+this.styleId;A+="/"+this.tileSize}this.tilesUrl=[];if(typeof this.subdomains=="string"){for(var B=0;B<this.subdomains.length;B++){this.tilesUrl.push("http://"+this.subdomains.charAt(B)+"."+A)}}if(this.tilesUrl.length===0){this.tilesUrl="http://"+A}},_calculateResolutions:function(){this.maxResolution=Math.round((this.maxExtent.right-this.maxExtent.left)/this.tileSize);this.resolutions=[];for(var B=0;B<this.numZoomLevels;B++){var A=this.maxResolution/Math.pow(2,B);this.resolutions.push(A)}},_checkIfLoaded:function(){if(!this.isLoaded()){throw"Map is not initialized, call setCenter first."}},_initLayout:function(){this.container.className+=" osmview-container";CM.setStyles(this.container,{position:"relative",background:"#dddddd",overflow:"hidden"});this.loadingIcon=document.createElement("div");CM.setStyles(this.loadingIcon,{position:"absolute",width:"40px",height:"40px",background:"url("+CM.IMAGE_ROOT+"/loading.gif) no-repeat",margin:"-20px 0 0 -20px",left:"50%",top:"50%"});this.container.appendChild(this.loadingIcon);this.mapLayer=document.createElement("div");this.mapLayer.className="osmview-map";this.mapLayer.style.position="absolute";this.container.appendChild(this.mapLayer);this.bgLayer=document.createElement("div");this.bgLayer.className="copyright-background";CM.setStyles(this.bgLayer,{position:"absolute",bottom:"0",right:"0",width:"100%",height:"18px",backgroundColor:"#fff",opacity:"0.7"});this.copyright=document.createElement("div");this.copyright.className="osmview-copyright";CM.setStyles(this.copyright,{position:"absolute",bottom:"0px",right:"0px",padding:"3px 4px",whiteSpace:"nowrap",font:"11px Arial, sans-serif"});this.copyright.innerHTML=this.copyrightText.replace(/\$\{siteUrl\}/g,this.siteUrl);CM.addEvent(this.copyright,"mousedown",CM.stopPropagation);CM.addEvent(this.copyright,"dblclick",CM.stopPropagation);if(this.copyright.innerHTML){this.container.appendChild(this.bgLayer)}this.container.appendChild(this.copyright)},_initEvents:function(){CM.addEvent(window,"resize",function(){var B=this.getSize();if((this._size&&((B.width!=this._size.width)||(B.height!=this._size.height)))||!this._size){this._size=B;this.checkResize()}},this);var A=function(B){return function(C){if(!this.dragObject.moved()){var D=CM.cumulativeOffset(this.container);var E=CM.getMousePosition(C);this.mouse.x=E.x-D.x;this.mouse.y=E.y-D.y;CM.fireCustomEvent(this,B,this.fromContainerPixelToLatLng(new CM.Point(this.mouse.x,this.mouse.y)))}}};CM.addEvent(this.container,"mousedown",A("mousedown"),this);CM.addEvent(this.container,"click",A("click"),this);CM.addEvent(this.container,"dblclick",A("dblclick"),this)},_getTileUrl:function(A,D){var B=Math.pow(2,this.zoom);if(D<0||D>=B){return this.tileErrorUrl}A=((A%B)+B)%B;var C=(typeof this.tilesUrl=="string"?this.tilesUrl:this.tilesUrl[(A+D)%3]);return C+"/"+this.zoom+"/"+A+"/"+D+".png"+(this.postfix?"?"+this.postfix:"")},_renderTile:function(A,F){var C=A-this.startTileLeft;var B=F-this.startTileTop;var D="osmview-map"+this.mapId+"-tile"+C+"x"+B;if(!document.getElementById(D)){var E=document.createElement("div");CM.setStyles(E,{backgroundImage:"url("+this._getTileUrl(A,F)+")",position:"absolute",left:(C*this.tileSize)+"px",top:(B*this.tileSize)+"px",width:this.tileSize+"px",height:this.tileSize+"px"});E.onmousedown=function(){return false};E.id=D;this.mapLayer.appendChild(E)}},_getResolution:function(A){return this.resolutions[(A||this.zoom)]},_renderView:function(){var K=Math.floor(-this.mapLeft/this.tileSize)||0;var H=Math.floor(-this.mapTop/this.tileSize)||0;var M=this.getSize();var E=Math.ceil(M.width/this.tileSize)+1;var C=Math.ceil(M.height/this.tileSize)+1;var L=(E-E%2)/2+E%2-1;var I=(C-C%2)/2+C%2-1;var J=function(){return(L>=0)&&(L<E)&&(I>=0)&&(I<C)};var A=function(){var N=Math.max(E,C);return(L>=E-N)&&(L<N)&&(I>=C-N)&&(I<N)};var B={e:"s",s:"w",w:"n",n:"e"};var G=1,F=0,D="e";while(A()){if(J()){this._renderTile(this.startTileLeft+K+L,this.startTileTop+H+I)}if(D=="e"){L++}else{if(D=="s"){I++}else{if(D=="w"){L--}else{if(D=="n"){I--}}}}F++;if(F==G){if((D=="s")||(D=="n")){G++}D=B[D];F=0}}},_calcViewPosition:function(){var B=this.center.toMercator();var D=this._getResolution();var C=this.getSize();var A=((B.lng()-D*C.width/2)-this.maxExtent.left)/(D*this.tileSize);var E=(this.maxExtent.top-(B.lat()+D*C.height/2))/(D*this.tileSize);this.startTileLeft=Math.floor(A);this.startTileTop=Math.floor(E);this.startMapLeft=this.mapLeft=Math.round((this.startTileLeft-A)*this.tileSize);this.startMapTop=this.mapTop=Math.round((this.startTileTop-E)*this.tileSize);CM.setStyles(this.mapLayer,{left:this.startMapLeft+"px",top:this.startMapTop+"px"})},_getMapOffset:function(){return new CM.Size(this.startMapLeft-this.mapLeft,this.startMapTop-this.mapTop)},_getZoomCenterFromMousePos:function(H,E){var G=this._getMapOffset();var D=this.getSize();var C=this._getResolution();var F=this._getResolution(E);var B=G.width+(H.x-D.width/2)*(1-F/C);var A=G.height+(H.y-D.height/2)*(1-F/C);return this._fromPxDeltaToLatLng(this.center,new CM.Point(B,A))},_fromPxDeltaToLatLng:function(E,C,D){var A=E.toMercator();var B=this._getResolution(D);return new CM.LatLng(A.lat()-B*(C.y||C.height||0),A.lng()+B*(C.x||C.width||0)).fromMercator()},_initMousePosCapture:function(){this.mouse={};CM.addEvent(this.container,"mousemove",function(A){var B=CM.cumulativeOffset(this.container);var C=CM.getMousePosition(A);this.mouse.x=C.x-B.x;this.mouse.y=C.y-B.y},this)},_initWheelZoom:function(){var A=function(D){var E=0;if(D.wheelDelta){E=D.wheelDelta/120}else{if(D.detail){E=-D.detail/3}}if(E){var C=this.zoom+(E>0?1:-1);if((C<this.numZoomLevels)&&(C>=0)){var B=this._getZoomCenterFromMousePos(new CM.Point(this.mouse.x,this.mouse.y),C);this.setCenter(B,C)}}if(D.preventDefault){D.preventDefault()}D.returnValue=false};this._addWheelZoomEvents=function(){CM.addEvent(this.container,"mousewheel",A,this);this._wheelZoomEnabled=true};this._removeWheelZoomEvents=function(){CM.removeEvent(this.container,"mousewheel",A,this);this._wheelZoomEnabled=false}},_initDoubleClickZoom:function(){var A=function(){var C=this.zoom+1;var B=this.fromContainerPixelToLatLng(new CM.Point(this.mouse.x,this.mouse.y));this.setCenter(B,C)};this._addDblClickZoomEvents=function(){CM.addEvent(this.container,"dblclick",A,this);this._dblClickZoomEnabled=true};this._removeDblClickZoomEvents=function(){CM.removeEvent(this.container,"dblclick",A,this);this._dblClickZoomEnabled=false}},_initShiftDragZoom:function(){var E,D;var B,A;var G=function(J){var I=this.mouse.x-B;var H=this.mouse.y-A;if(I<0){E.style.left=this.mouse.x+"px"}if(H<0){E.style.top=this.mouse.y+"px"}CM.setStyles(E,{width:Math.abs(I)+"px",height:Math.abs(H)+"px"})};var C=function(){this.container.removeChild(E);this.container.style.cursor="";CM.enableTextSelection();CM.removeEvent(this.container,"mousemove",G);CM.removeEvent(this.container,"mouseup",C);var J=Math.abs(this.mouse.x-B);var I=Math.abs(this.mouse.y-A);B=Math.min(this.mouse.x,B);A=Math.min(this.mouse.y,A);var L=new CM.Bounds([new CM.Point(B,A),new CM.Point(B+J,A+I)]);var K=this.getBoundsZoomLevel(L);var H=this.fromContainerPixelToLatLng(L.mid());this.setCenter(H,K)};var F=function(H){if(!H.shiftKey||((H.which!=1)&&(H.button!=1))){return false}CM.disableTextSelection();B=this.mouse.x;A=this.mouse.y;E=document.createElement("div");CM.setStyles(E,{position:"absolute",top:A+"px",left:B+"px",border:"2px solid red",background:"white",opacity:0.4,width:0,height:0});this.container.appendChild(E);this.container.style.cursor="crosshair";CM.addEvent(this.container,"mousemove",G,this);CM.addEvent(this.container,"mouseup",C,this)};this._addShiftDragZoomEvents=function(){CM.addEvent(this.container,"mousedown",F,this);this._shiftDragZoomEnabled=true};this._removeShiftDragZoomEvents=function(){CM.removeEvent(this.container,"mousedown",F);this._shiftDragZoomEnabled=false}},_switchLayer:function(B){CM.extend(this,B);this._initTileUrl();this._calculateResolutions();var A=this.getCenter();var C=this.getZoom();this._loaded=false;this.setCenter(A,C);CM.fireCustomEvent(this,"stylechange")}};if(!CM.IMAGE_ROOT){CM.IMAGE_ROOT="http://cloudmade.com/js-api/images"}CM=window.CM||{};CM.ANCHOR_TOP_LEFT=0;CM.ANCHOR_TOP_RIGHT=1;CM.ANCHOR_BOTTOM_LEFT=2;CM.ANCHOR_BOTTOM_RIGHT=3;CM.ControlPosition=function(B,C){var A;switch(B){case 0:A=["left","top"];break;case 1:A=["right","top"];break;case 2:A=["left","bottom"];break;case 3:A=["right","bottom"];break}this.positionProperties=A;this.offset=C};CM.ControlPosition.prototype={setPosition:function(B,A){B.style.position="absolute";B.style[this.positionProperties[0]]=this.offset.width+"px";B.style[this.positionProperties[1]]=this.offset.height+"px"}};(function(){var B={position:"absolute",width:"18px",height:"18px"};var A=function(G,C,H){var E=G.getCenter().toMercator();var F=G._getResolution();var D=new CM.LatLng(E.lat()-F*H,E.lng()+F*C).fromMercator();G.panTo(D)};CM.Buttons={zoomIn:function(F,E,D){var C=document.createElement("a");CM.setStyles(C,B);CM.setStyles(C,{top:"70px",left:"10px",background:"url("+CM.IMAGE_ROOT+"/zoomin.png)"});CM.setStyles(C,D);C.href="#zoomIn";C.title="Zoom in";CM.addEvent(C,"mousedown",CM.stopPropagation);CM.addEvent(C,"click",CM.stopPropagation);CM.addEvent(C,"dblclick",CM.stopPropagation);C.onclick=function(){F.zoomIn();return false};E.appendChild(C)},zoomOut:function(F,E,D){var C=document.createElement("a");CM.extend(C.style,B);CM.extend(C.style,{top:"90px",left:"10px",background:"url("+CM.IMAGE_ROOT+"/zoomout.png)"});CM.setStyles(C,D);C.href="#zoomOut";C.title="Zoom out";CM.addEvent(C,"mousedown",CM.stopPropagation);CM.addEvent(C,"click",CM.stopPropagation);CM.addEvent(C,"dblclick",CM.stopPropagation);C.onclick=function(){F.zoomOut();return false};E.appendChild(C)},goEast:function(F,E,D){var C=document.createElement("a");CM.extend(C.style,B);CM.extend(C.style,{top:"20px",left:"20px",background:"url("+CM.IMAGE_ROOT+"/east.png)"});CM.setStyles(C,D);C.href="#goEast";C.title="Go east";CM.addEvent(C,"mousedown",CM.stopPropagation);CM.addEvent(C,"click",CM.stopPropagation);CM.addEvent(C,"dblclick",CM.stopPropagation);C.onclick=function(){A(F,256,0);return false};E.appendChild(C)},goWest:function(F,E,D){var C=document.createElement("a");CM.extend(C.style,B);CM.extend(C.style,{top:"20px",left:"0px",background:"url("+CM.IMAGE_ROOT+"/west.png)"});CM.setStyles(C,D);C.href="#goWest";C.title="Go west";CM.addEvent(C,"mousedown",CM.stopPropagation);CM.addEvent(C,"click",CM.stopPropagation);CM.addEvent(C,"dblclick",CM.stopPropagation);C.onclick=function(){A(F,-256,0);return false};E.appendChild(C)},goNorth:function(F,E,D){var C=document.createElement("a");CM.extend(C.style,B);CM.extend(C.style,{top:"0px",left:"10px",background:"url("+CM.IMAGE_ROOT+"/north.png)"});CM.setStyles(C,D);C.href="#goNorth";C.title="Go north";CM.addEvent(C,"mousedown",CM.stopPropagation);CM.addEvent(C,"click",CM.stopPropagation);CM.addEvent(C,"dblclick",CM.stopPropagation);C.onclick=function(){A(F,0,-256);return false};E.appendChild(C)},goSouth:function(F,E,D){var C=document.createElement("a");CM.extend(C.style,B);CM.extend(C.style,{top:"40px",left:"10px",background:"url("+CM.IMAGE_ROOT+"/south.png)"});CM.setStyles(C,D);C.href="#goSouth";C.title="Go south";CM.addEvent(C,"mousedown",CM.stopPropagation);CM.addEvent(C,"click",CM.stopPropagation);CM.addEvent(C,"dblclick",CM.stopPropagation);C.onclick=function(){A(F,0,256);return false};E.appendChild(C)}};CM.Buttons.goBack=function(F,E,D){var C=document.createElement("a");CM.extend(C.style,B);CM.extend(C.style,{top:"20px",left:"20px",background:"url("+CM.IMAGE_ROOT+"/back.png)"});CM.setStyles(C,D);C.href="#goBack";C.title="Return to the initial result";CM.addEvent(C,"mousedown",CM.stopPropagation);CM.addEvent(C,"click",CM.stopPropagation);CM.addEvent(C,"dblclick",CM.stopPropagation);C.onclick=function(){F.returnToSavedPosition();return false};E.appendChild(C)}})();CM.SmallMapControl=function(){};CM.SmallMapControl.prototype={initialize:function(A,G){var B=A.getContainer();var J=G||this.getDefaultPosition();var F=document.createElement("div");J.setPosition(F);var K=new CM.Buttons.goEast(A,F);var C=new CM.Buttons.goWest(A,F);var H=new CM.Buttons.goNorth(A,F);var D=new CM.Buttons.goSouth(A,F);var I=new CM.Buttons.zoomIn(A,F);var E=new CM.Buttons.zoomOut(A,F);CM.setStyles(F,{width:"40px",height:"110px"});B.appendChild(F)},getDefaultPosition:function(){return new CM.ControlPosition(CM.ANCHOR_TOP_LEFT,new CM.Size(10,10))}};CM.iPhoneControl=function(){};CM.iPhoneControl.prototype={initialize:function(A){var B=A.getContainer();var F=document.createElement("div");var I=new CM.Buttons.goEast(A,F,{top:"50%",marginTop:"-15px",left:"280px",width:"30px",height:"30px",background:"url("+CM.IMAGE_ROOT+"/i-east.png)"});var C=new CM.Buttons.goWest(A,F,{top:"50%",marginTop:"-15px",left:"10px",width:"30px",height:"30px",background:"url("+CM.IMAGE_ROOT+"/i-west.png)"});var G=new CM.Buttons.goNorth(A,F,{left:"50%",marginLeft:"-15px",top:"10px",width:"30px",height:"30px",background:"url("+CM.IMAGE_ROOT+"/i-north.png)"});var D=new CM.Buttons.goSouth(A,F,{left:"50%",marginLeft:"-15px",top:"310px",width:"30px",height:"30px",background:"url("+CM.IMAGE_ROOT+"/i-south.png)"});var H=new CM.Buttons.zoomIn(A,F,{top:"10px",width:"30px",height:"30px",background:"url("+CM.IMAGE_ROOT+"/i-zoomin.png)"});var E=new CM.Buttons.zoomOut(A,F,{top:"45px",width:"30px",height:"30px",background:"url("+CM.IMAGE_ROOT+"/i-zoomout.png)"});B.appendChild(F)}};CM.Buttons.Slider=function(B,F){var A=document.createElement("div");var I=B.numZoomLevels*5;this.sliderHeight=I;this.map=B;CM.setStyles(A,{position:"absolute",width:"17px",left:"20px",top:"89px",height:I+"px",background:"url("+CM.IMAGE_ROOT+"/zoompoint.png) repeat-y"});var K=B.getZoom();var C=I-K*5-6;this.handle=document.createElement("div");CM.setStyles(this.handle,{position:"absolute",left:0,top:C+"px",width:"17px",height:"7px",background:"url("+CM.IMAGE_ROOT+"/zoomhandler.png) no-repeat"});var D=B.getContainer();var H=B.getZoom();var J=function(M){var O=CM.getMousePosition(M);var N=O.y-CM.cumulativeOffset(A).y;var L=Math.floor(B.numZoomLevels-N/5);if((L<0)||(L>=B.numZoomLevels)){return H}else{return L}};var E=function(M){var L=J(M);this.update(L);H=L};var G=function(){B.setZoom(H);D.style.cursor="";CM.removeEvent(document,"mousemove",E);CM.removeEvent(document,"mouseup",G)};CM.addEvent(this.handle,"mousedown",function(L){if((L.which!=1)&&(L.button!=1)){return false}CM.addEvent(document,"mousemove",E,this);CM.addEvent(document,"mouseup",G,this);D.style.cursor="n-resize";CM.stopPropagation(L)},this);CM.addEvent(this.handle,"dblclick",CM.stopPropagation);CM.addEvent(this.handle,"click",CM.stopPropagation);A.appendChild(this.handle);CM.addEvent(A,"mousedown",function(L){if((L.which!=1)&&(L.button!=1)){return false}B.setZoom(J(L));CM.stopPropagation(L)});CM.addCustomEvent(B,"zoomend",this.update,this);F.appendChild(A)};CM.Buttons.Slider.prototype={getHeight:function(){return this.sliderHeight},update:function(B){if(typeof B=="undefined"){B=this.map.getZoom()}var A=this.sliderHeight-B*5-5;this.handle.style.top=(A-1)+"px"}};CM.LargeMapControl=function(){};CM.LargeMapControl.prototype={initialize:function(A,G){var B=A.getContainer();var L=G||this.getDefaultPosition();var F=document.createElement("div");F.className="cm-large-map-control";L.setPosition(F);var M=new CM.Buttons.goEast(A,F,{left:"40px"});var C=new CM.Buttons.goWest(A,F);var I=new CM.Buttons.goNorth(A,F,{left:"20px"});var D=new CM.Buttons.goSouth(A,F,{left:"20px"});var H=new CM.Buttons.goBack(A,F);var K=new CM.Buttons.zoomIn(A,F,{left:"20px"});this.slider=new CM.Buttons.Slider(A,F);var J=this.slider.getHeight();var E=new CM.Buttons.zoomOut(A,F,{left:"20px",top:(90+J)+"px"});CM.setStyles(F,{width:"60px",height:(110+J)+"px"});B.appendChild(F)},getDefaultPosition:function(){return new CM.ControlPosition(CM.ANCHOR_TOP_LEFT,new CM.Size(10,10))}};CM.PermalinkControl=function(){};CM.PermalinkControl.prototype={initialize:function(C,A){var B=document.createElement("a");B.innerHTML="Permalink";CM.setStyles(B,{color:"#0078A8",font:"11px Arial, sans-serif"});var D=A||this.getDefaultPosition();D.setPosition(B);C._updatePermalink=function(){B.href=C.getPermalink()};C._updatePermalink();C.getContainer().appendChild(B);CM.addCustomEvent(C,"moveend",C._updatePermalink);CM.addCustomEvent(C,"zoomend",C._updatePermalink);CM.addCustomEvent(C,"stylechange",C._updatePermalink)},getDefaultPosition:function(){return new CM.ControlPosition(CM.ANCHOR_BOTTOM_LEFT,new CM.Size(5,3))}};CM.StyleSwitchControl=function(A){this.styles=A};CM.StyleSwitchControl.prototype={initialize:function(G,A){var F=document.createElement("div");CM.setStyles(F,{border:"1px solid #B5B5B5"});var E={background:"white",color:"#0078A8",textDecoration:"none"};function D(K){var I=F.getElementsByTagName("a");for(var J=0;J<I.length;J++){CM.setStyles(I[J],E)}CM.setStyles(K,{background:"#0066CB",color:"white"})}function B(K,I){var J=document.createElement("a");J.href="#";J.innerHTML=I;CM.setStyles(J,{display:"block",padding:"3px 5px",font:"11px Arial, sans-serif"});CM.setStyles(J,E);if(G.styleId==K){D(J)}J.onclick=function(){D(J);G._switchLayer({styleId:K,tileSize:G.tileSize});return false};F.appendChild(J)}for(var C in this.styles){if(this.styles.hasOwnProperty(C)){B(C,this.styles[C])}}var H=A||this.getDefaultPosition();H.setPosition(F);G.getContainer().appendChild(F)},getDefaultPosition:function(){return new CM.ControlPosition(CM.ANCHOR_TOP_RIGHT,new CM.Size(0,0))}};CM.ScaleControl=function(){};CM.ScaleControl.prototype={initialize:function(D,A){this.map=D;var C=document.createElement("div");CM.setStyles(C,{font:"10px Arial, sans-serif"});var B={textAlign:"center",border:"2px solid black"};this.scale1=document.createElement("div");CM.setStyles(this.scale1,B);CM.setStyles(this.scale1,{borderTop:"none"});this.scale2=document.createElement("div");CM.setStyles(this.scale2,B);CM.setStyles(this.scale2,{borderBottom:"none",marginTop:"-2px"});C.appendChild(this.scale1);C.appendChild(this.scale2);this.position=A||this.getDefaultPosition();this.position.setPosition(C);this._update();CM.addCustomEvent(this.map,"moveend",this._update,this);CM.addCustomEvent(this.map,"zoomend",this._update,this);D.getContainer().appendChild(C)},getDefaultPosition:function(){return new CM.ControlPosition(CM.ANCHOR_BOTTOM_LEFT,new CM.Size(5,20))},_update:function(){var J=60;this.scale1.style.width=this.scale2.style.width=J+"px";var G=this.map._getResolution();var K=this.map.getSize();var I=new CM.Point(0,(this.position.positionProperties[1]=="top"?-1:1)*(Math.round(K.height/2)-12-this.position.offset.height));var A=this.map.getCenter();var H=this.map._fromPxDeltaToLatLng(A,I,this.map.getZoom()).lat();var B=J*G*Math.cos(H*Math.PI/180);var C=parseInt(B);var F=parseInt(B*3.2808399);var E,D;E=(C>1000?(Math.round(C/100)/10)+" km":C+" m");D=(F>5000?(Math.round(F*10/5280)/10)+" mi":F+" ft");this.scale1.innerHTML=E;this.scale2.innerHTML=D}};CM=window.CM||{};CM.Icon=function(B,A){if(B){CM.extend(this,B)}if(A){this.image=A}};CM._initDefaultIcon=function(){var A=new CM.Icon();A.image=CM.IMAGE_ROOT+"/balloon.png";A.iconSize=new CM.Size(21,30);A.iconAnchor=new CM.Point(10,28);CM.DEFAULT_ICON=A;CM._initDefaultIcon=function(){}};CM.Marker=function(C,B){CM._initDefaultIcon();var A={icon:CM.DEFAULT_ICON,clickable:true,draggable:false};CM.extend(this,A);if(B instanceof CM.Icon){this.icon=B}else{if(B){CM.extend(this,B)}}this.position=C};CM.Marker.prototype={initialize:function(A){this.element=document.createElement("div");this.mapLayer=A.mapLayer;this.container=A.getContainer();this.map=A;CM.setStyles(this.element,{width:this.icon.iconSize.width+"px",height:this.icon.iconSize.height+"px",position:"absolute",zIndex:"1000",background:"url("+this.icon.image+") no-repeat"});if(this.clickable){this.element.style.cursor="pointer"}if(this.title){this.element.title=this.title}function B(){this.redraw(true)}CM.addCustomEvent(A,"zoomend",B,this);CM.addCustomEvent(A,"stylechange",B,this);if(this.draggable){this.enableDragging()}if(this.clickable){CM.addEvent(this.element,"mousedown",CM.stopPropagation);CM.addEvent(this.element,"click",function(C){if(this._draggingEnabled&&this.dragObject.moved()){return false}CM.fireCustomEvent(this,"click")},this)}this.redraw(true)},redraw:function(A){if(A){var B=this.map.fromLatLngToDivPixel(this.position);CM.setStyles(this.element,{left:(B.x-this.icon.iconAnchor.x)+"px",top:(B.y-this.icon.iconAnchor.y)+"px"});this.mapLayer.appendChild(this.element)}},getIcon:function(){return this.icon},getTitle:function(){return this.title},getLatLng:function(){return this.position},setLatLng:function(A){this.position=A;this.redraw(true)},setImage:function(A){this.icon.image=A;this.element.style.background="url("+this.icon.image+") no-repeat"},hide:function(){this.element.style.visibility="hidden"},show:function(){this.element.style.visibility=""},isHidden:function(){return(this.element.style.visibility=="hidden")},enableDragging:function(){if(!this.dragObject){this.dragObject=new CM.DraggableObject(this.element,{container:this.container});CM.addCustomEvent(this.dragObject,"dragend",function(){CM.fireCustomEvent(this,"dragend");this.position=this.map._fromPxDeltaToLatLng(this.position,new CM.Point(this.dragObject.x-this.dragObject.startX,this.dragObject.y-this.dragObject.startY))},this)}else{this.dragObject.enable()}this._draggingEnabled=true},disableDragging:function(){if(this.dragObject){this.dragObject.disable()}this._draggingEnabled=false},dragingEnabled:function(){return !!this._draggingEnabled}};