/* mapbox.js 0.6.7 */!function(){var define;!function(e,t,n){typeof module!="undefined"?module.exports=n(e,t):typeof define=="function"&&typeof define.amd=="object"?define(n):t[e]=n(e,t)}("bean",this,function(e,t){var n=window,r=t[e],i=/over|out/,s=/[^\.]*(?=\..*)\.|.*/,o=/\..*/,u="addEventListener",a="attachEvent",f="removeEventListener",l="detachEvent",c="ownerDocument",h="target",p="querySelectorAll",d=document||{},v=d.documentElement||{},m=v[u],g=m?u:a,y=Array.prototype.slice,b=/click|mouse(?!(.*wheel|scroll))|menu|drag|drop/i,w=/mouse.*(wheel|scroll)/i,E=/^text/i,S=/^touch|^gesture/i,x={},T=function(e,t,n){for(n=0;n0){t=t.split(" ");for(a=t.length;a--;)I(e,t[a],n);return e}i=l&&t.replace(o,""),i&&N[i]&&(i=N[i].type);if(!t||l){if(u=l&&t.replace(s,""))u=u.split(".");f(e,i,n,u)}else if(typeof t=="function")f(e,null,t);else for(r in t)t.hasOwnProperty(r)&&I(e,r,t[r]);return e},q=function(e,t,n,r,i){var s,o,u,a,f=n,l=n&&typeof n=="string";if(t&&!n&&typeof t=="object")for(s in t)t.hasOwnProperty(s)&&q.apply(this,[e,s,t[s]]);else{a=arguments.length>3?y.call(arguments,3):[],o=(l?n:t).split(" "),l&&(n=F(t,f=r,i||O))&&(a=y.call(a,1)),this===x&&(n=H(I,e,t,n,f));for(u=o.length;u--;)j(e,o[u],n,f,a)}return e},R=function(){return q.apply(x,arguments)},U=m?function(e,t,r){var i=d.createEvent(e?"HTMLEvents":"UIEvents");i[e?"initEvent":"initUIEvent"](t,!0,!0,n,1),r.dispatchEvent(i)}:function(e,t,n){n=k(n,e),e?n.fireEvent("on"+t,d.createEventObject()):n["_on"+t]++},z=function(e,t,n){var r,i,u,a,f,l=t.split(" ");for(r=l.length;r--;){t=l[r].replace(o,"");if(a=l[r].replace(s,""))a=a.split(".");if(!a&&!n&&e[g])U(T[t],t,e);else{f=A.get(e,t),n=[!1].concat(n);for(i=0,u=f.length;i0)self._completeHandlers.shift()(e)}function success(resp){var r=resp.responseText;if(r)switch(type){case"json":try{resp=win.JSON?win.JSON.parse(r):eval("("+r+")")}catch(err){return error(resp,"Could not parse JSON in response",err)}break;case"js":resp=eval(r);break;case"html":resp=r;break;case"xml":resp=resp.responseXML}self._responseArgs.resp=resp,self._fulfilled=!0,fn(resp);while(self._fulfillmentHandlers.length>0)self._fulfillmentHandlers.shift()(resp);complete(resp)}function error(e,t,n){self._responseArgs.resp=e,self._responseArgs.msg=t,self._responseArgs.t=n,self._erred=!0;while(self._errorHandlers.length>0)self._errorHandlers.shift()(e,t,n);complete(e)}this.url=typeof o=="string"?o:o.url,this.timeout=null,this._fulfilled=!1,this._fulfillmentHandlers=[],this._errorHandlers=[],this._completeHandlers=[],this._erred=!1,this._responseArgs={};var self=this,type=o.type||setType(this.url);fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort()},o.timeout)),o.success&&this._fulfillmentHandlers.push(function(){o.success.apply(o,arguments)}),o.error&&this._errorHandlers.push(function(){o.error.apply(o,arguments)}),o.complete&&this._completeHandlers.push(function(){o.complete.apply(o,arguments)}),this.request=getRequest(o,success,error)}function reqwest(e,t){return new Reqwest(e,t)}function normalize(e){return e?e.replace(/\r?\n/g,"\r\n"):""}function serial(e,t){var n=e.name,r=e.tagName.toLowerCase(),i=function(e){e&&!e.disabled&&t(n,normalize(e.attributes.value&&e.attributes.value.specified?e.value:e.text))};if(e.disabled||!n)return;switch(r){case"input":if(!/reset|button|image|file/i.test(e.type)){var s=/checkbox/i.test(e.type),o=/radio/i.test(e.type),u=e.value;(!s&&!o||e.checked)&&t(n,normalize(s&&u===""?"on":u))}break;case"textarea":t(n,normalize(e.value));break;case"select":if(e.type.toLowerCase()==="select-one")i(e.selectedIndex>=0?e.options[e.selectedIndex]:null);else for(var a=0;e.length&&a"']/g,function(e){return s[e]||e})}var e=Object.prototype.toString;Array.isArray=Array.isArray||function(t){return e.call(t)=="[object Array]"};var t=String.prototype.trim,n;if(t)n=function(e){return e==null?"":t.call(e)};else{var r,i;/\S/.test(" ")?(r=/^[\s\xA0]+/,i=/[\s\xA0]+$/):(r=/^\s+/,i=/\s+$/),n=function(e){return e==null?"":e.toString().replace(r,"").replace(i,"")}}var s={"&":"&","<":"<",">":">",'"':""","'":"'"},u={},a=function(){};return a.prototype={otag:"{{",ctag:"}}",pragmas:{},buffer:[],pragmas_implemented:{"IMPLICIT-ITERATOR":!0},context:{},render:function(e,t,n,r){r||(this.context=t,this.buffer=[]);if(!this.includes("",e)){if(r)return e;this.send(e);return}e=this.render_pragmas(e);var i=this.render_section(e,t,n);i===!1&&(i=this.render_tags(e,t,n,r));if(r)return i;this.sendLines(i)},send:function(e){e!==""&&this.buffer.push(e)},sendLines:function(e){if(e){var t=e.split("\n");for(var n=0;n|&|\\{|%)?([^#\\^]+?)\\1?"+t+"+","g")})},u=s(),a=function(e,r,a){switch(r){case"!":return"";case"=":return i.set_delimiters(a),u=s(),"";case">":return i.render_partial(a,t,n);case"{":case"&":return i.find(a,t);default:return o(i.find(a,t))}},f=e.split("\n");for(var l=0;l0)r=i,i=i[n.shift()];return typeof i=="function"?i.apply(r):i},includes:function(e,t){return t.indexOf(this.otag+e)!=-1},create_context:function(e){if(this.is_object(e))return e;var t=".";this.pragmas["IMPLICIT-ITERATOR"]&&(t=this.pragmas["IMPLICIT-ITERATOR"].iterator);var n={};return n[t]=e,n},is_object:function(e){return e&&typeof e=="object"},map:function(e,t){if(typeof e.map=="function")return e.map(t);var n=[],r=e.length;for(var i=0;ithis.north&&(this.north=e.lat),e.latthis.east&&(this.east=e.lon),e.lonthis.north&&(this.north=e.north),e.souththis.east&&(this.east=e.east),e.west=this.south&&e.lat<=this.north&&e.lon>=this.west&&e.lon<=this.east},toArray:function(){return[this.northWest(),this.southEast()]}},e.Extent.fromString=function(t){var n=t.split(/\s*,\s*/);if(n.length!=4)throw"Invalid extent string (expecting 4 comma-separated numbers)";return new e.Extent(parseFloat(n[0]),parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]))},e.Extent.fromArray=function(t){var n=new e.Extent;return n.setFromLocations(t),n},e.Transformation=function(e,t,n,r,i,s){this.ax=e,this.bx=t,this.cx=n,this.ay=r,this.by=i,this.cy=s},e.Transformation.prototype={ax:0,bx:0,cx:0,ay:0,by:0,cy:0,transform:function(t){return new e.Point(this.ax*t.x+this.bx*t.y+this.cx,this.ay*t.x+this.by*t.y+this.cy)},untransform:function(t){return new e.Point((t.x*this.by-t.y*this.bx-this.cx*this.by+this.cy*this.bx)/(this.ax*this.by-this.ay*this.bx),(t.x*this.ay-t.y*this.ax-this.cx*this.ay+this.cy*this.ax)/(this.bx*this.ay-this.by*this.ax))}},e.deriveTransformation=function(t,n,r,i,s,o,u,a,f,l,c,h){var p=e.linearSolution(t,n,r,s,o,u,f,l,c),d=e.linearSolution(t,n,i,s,o,a,f,l,h);return new e.Transformation(p[0],p[1],p[2],d[0],d[1],d[2])},e.linearSolution=function(e,t,n,r,i,s,o,u,a){e=parseFloat(e),t=parseFloat(t),n=parseFloat(n),r=parseFloat(r),i=parseFloat(i),s=parseFloat(s),o=parseFloat(o),u=parseFloat(u),a=parseFloat(a);var f=((s-a)*(t-i)-(n-s)*(i-u))/((r-o)*(t-i)-(e-r)*(i-u)),l=((s-a)*(e-r)-(n-s)*(r-o))/((i-u)*(e-r)-(t-i)*(r-o)),c=n-e*f-t*l;return[f,l,c]},e.Projection=function(t,n){n||(n=new e.Transformation(1,0,0,0,1,0)),this.zoom=t,this.transformation=n},e.Projection.prototype={zoom:0,transformation:null,rawProject:function(e){throw"Abstract method not implemented by subclass."},rawUnproject:function(e){throw"Abstract method not implemented by subclass."},project:function(e){return e=this.rawProject(e),this.transformation&&(e=this.transformation.transform(e)),e},unproject:function(e){return this.transformation&&(e=this.transformation.untransform(e)),e=this.rawUnproject(e),e},locationCoordinate:function(t){var n=new e.Point(Math.PI*t.lon/180,Math.PI*t.lat/180);return n=this.project(n),new e.Coordinate(n.y,n.x,this.zoom)},coordinateLocation:function(t){t=t.zoomTo(this.zoom);var n=new e.Point(t.column,t.row);return n=this.unproject(n),new e.Location(180*n.y/Math.PI,180*n.x/Math.PI)}},e.LinearProjection=function(t,n){e.Projection.call(this,t,n)},e.LinearProjection.prototype={rawProject:function(t){return new e.Point(t.x,t.y)},rawUnproject:function(t){return new e.Point(t.x,t.y)}},e.extend(e.LinearProjection,e.Projection),e.MercatorProjection=function(t,n){e.Projection.call(this,t,n)},e.MercatorProjection.prototype={rawProject:function(t){return new e.Point(t.x,Math.log(Math.tan(.25*Math.PI+.5*t.y)))},rawUnproject:function(t){return new e.Point(t.x,2*Math.atan(Math.pow(Math.E,t.y))-.5*Math.PI)}},e.extend(e.MercatorProjection,e.Projection),e.MapProvider=function(e){e&&(this.getTile=e)},e.MapProvider.prototype={tileLimits:[new e.Coordinate(0,0,0),(new e.Coordinate(1,1,0)).zoomTo(18)],getTileUrl:function(e){throw"Abstract method not implemented by subclass."},getTile:function(e){throw"Abstract method not implemented by subclass."},releaseTile:function(e){},setZoomRange:function(e,t){this.tileLimits[0]=this.tileLimits[0].zoomTo(e),this.tileLimits[1]=this.tileLimits[1].zoomTo(t)},sourceCoordinate:function(t){var n=this.tileLimits[0].zoomTo(t.zoom).container(),r=this.tileLimits[1].zoomTo(t.zoom),i=Math.pow(2,t.zoom),s;return r=new e.Coordinate(Math.ceil(r.row),Math.ceil(r.column),Math.floor(r.zoom)),t.column<0?s=(t.column%i+i)%i:s=t.column%i,t.row=r.row?null:s=r.column?null:new e.Coordinate(t.row,s,t.zoom)}},e.Template=function(t,n){function s(e,t,n){var r="";for(var i=1;i<=n;i++)r+=(e>>n-i&1)<<1|t>>n-i&1;return r||"0"}var r=t.match(/{(Q|quadkey)}/);r&&(t=t.replace("{subdomains}","{S}").replace("{zoom}","{Z}").replace("{quadkey}","{Q}"));var i=n&&n.length&&t.indexOf("{S}")>=0,o=function(e){var o=this.sourceCoordinate(e);if(!o)return null;var u=t;if(i){var a=parseInt(o.zoom+o.row+o.column,10)%n.length;u=u.replace("{S}",n[a])}return r?u.replace("{Z}",o.zoom.toFixed(0)).replace("{Q}",s(o.row,o.column,o.zoom)):u.replace("{Z}",o.zoom.toFixed(0)).replace("{X}",o.column.toFixed(0)).replace("{Y}",o.row.toFixed(0))};e.MapProvider.call(this,o)},e.Template.prototype={getTile:function(e){return this.getTileUrl(e)}},e.extend(e.Template,e.MapProvider),e.TemplatedLayer=function(t,n,r){return new e.Layer(new e.Template(t,n),null,r)},e.getMousePoint=function(t,n){var r=new e.Point(t.clientX,t.clientY);r.x+=document.body.scrollLeft+document.documentElement.scrollLeft,r.y+=document.body.scrollTop+document.documentElement.scrollTop;for(var i=n.parent;i;i=i.offsetParent)r.x-=i.offsetLeft,r.y-=i.offsetTop;return r},e.MouseWheelHandler=function(){function o(t){var o=0;i=i||(new Date).getTime();try{r.scrollTop=1e3,r.dispatchEvent(t),o=1e3-r.scrollTop}catch(u){o=t.wheelDelta||-t.detail*5}var a=(new Date).getTime()-i,f=e.getMousePoint(t,n);return Math.abs(o)>0&&a>200&&!s?(n.zoomByAbout(o>0?1:-1,f),i=(new Date).getTime()):s&&n.zoomByAbout(o*.001,f),e.cancelEvent(t)}var t={},n,r,i,s=!1;return t.init=function(i){n=i,r=document.body.appendChild(document.createElement("div")),r.style.cssText="visibility:hidden;top:0;height:0;width:0;overflow-y:scroll";var s=r.appendChild(document.createElement("div"));return s.style.height="2000px",e.addEvent(n.parent,"mousewheel",o),t},t.precise=function(e){return arguments.length?(s=e,t):s},t.remove=function(){e.removeEvent(n .parent,"mousewheel",o),r.parentNode.removeChild(r)},t},e.DoubleClickHandler=function(){function r(t){var r=e.getMousePoint(t,n);return n.zoomByAbout(t.shiftKey?-1:1,r),e.cancelEvent(t)}var t={},n;return t.init=function(i){return n=i,e.addEvent(n.parent,"dblclick",r),t},t.remove=function(){e.removeEvent(n.parent,"dblclick",r)},t},e.DragHandler=function(){function i(t){if(t.shiftKey||t.button==2)return;return e.addEvent(document,"mouseup",s),e.addEvent(document,"mousemove",o),n=new e.Point(t.clientX,t.clientY),r.parent.style.cursor="move",e.cancelEvent(t)}function s(t){return e.removeEvent(document,"mouseup",s),e.removeEvent(document,"mousemove",o),n=null,r.parent.style.cursor="",e.cancelEvent(t)}function o(t){return n&&(r.panBy(t.clientX-n.x,t.clientY-n.y),n.x=t.clientX,n.y=t.clientY,n.t=+(new Date)),e.cancelEvent(t)}var t={},n,r;return t.init=function(n){return r=n,e.addEvent(r.parent,"mousedown",i),t},t.remove=function(){e.removeEvent(r.parent,"mousedown",i)},t},e.MouseHandler=function(){var t={},n,r;return t.init=function(i){return n=i,r=[e.DragHandler().init(n),e.DoubleClickHandler().init(n),e.MouseWheelHandler().init(n)],t},t.remove=function(){for(var e=0;ei||(h>r?(c.end=n,c.duration=h,g(c)):(c.time=n,y(c)))}var d={};for(var v=0;v=0;i--){var s=r[i];s.id in e||(this.loadingBay.removeChild(s),this.openRequestCount--,s.src=s.coord=s.onload=s.onerror=null)}for(var o in this.requestsById)if(!(o in e)&&this.requestsById.hasOwnProperty(o)){var u=this.requestsById[o];delete this.requestsById[o],u!==null&&(u=u.id=u.coord=u.url=null)}},hasRequest:function(e){return e in this.requestsById},requestTile:function(e,t,n){if(!(e in this.requestsById)){var r={id:e,coord:t.copy(),url:n};this.requestsById[e]=r,n&&this.requestQueue.push(r)}},getProcessQueue:function(){if(!this._processQueue){var e=this;this._processQueue=function(){e.processQueue()}}return this._processQueue},processQueue:function(e){e&&this.requestQueue.length>8&&this.requestQueue.sort(e);while(this.openRequestCount0){var t=this.requestQueue.pop();if(t){this.openRequestCount++;var n=document.createElement("img");n.id=t.id,n.style.position="absolute",n.coord=t.coord,this.loadingBay.appendChild(n),n.onload=n.onerror=this.getLoadComplete(),n.src=t.url,t=t.id=t.coord=t.url=null}}},_loadComplete:null,getLoadComplete:function(){if(!this._loadComplete){var e=this;this._loadComplete=function(t){t=t||window.event;var n=t.srcElement||t.target;n.onload=n.onerror=null,e.loadingBay.removeChild(n),e.openRequestCount--,delete e.requestsById[n.id],t.type==="load"&&(n.complete||n.readyState&&n.readyState=="complete")?e.dispatchCallback("requestcomplete",n):(e.dispatchCallback("requesterror",{element:n,url:""+n.src}),n.src=null),setTimeout(e.getProcessQueue(),0)}}return this._loadComplete}},e.Layer=function(t,n,r){this.parent=n||document.createElement("div"),this.parent.style.cssText="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; margin: 0; padding: 0; z-index: 0",this.name=r,this.levels={},this.requestManager=new e.RequestManager,this.requestManager.addCallback("requestcomplete",this.getTileComplete()),this.requestManager.addCallback("requesterror",this.getTileError()),t&&this.setProvider(t)},e.Layer.prototype={map:null,parent:null,name:null,enabled:!0,tiles:null,levels:null,requestManager:null,provider:null,_tileComplete:null,getTileComplete:function(){if(!this._tileComplete){var e=this;this._tileComplete=function(t,n){e.tiles[n.id]=n,e.positionTile(n)}}return this._tileComplete},getTileError:function(){if(!this._tileError){var e=this;this._tileError=function(t,n){n.element.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",e.tiles[n.element.id]=n.element,e.positionTile(n.element)}}return this._tileError},draw:function(){function n(e,n){if(e&&n){var r=e.coord,i=n.coord;if(r.zoom==i.zoom){var s=Math.abs(t.row-r.row-.5)+Math.abs(t.column-r.column-.5),o=Math.abs(t.row-i.row-.5)+Math.abs(t.column-i.column-.5);return so?-1:0}return r.zoomi.zoom?-1:0}return e?1:n?-1:0}if(!this.enabled||!this.map)return;var t=this.map.coordinate.zoomTo(Math.round(this.map.coordinate.zoom)),r=Math.round(this.map.coordinate.zoom),i=this.map.pointCoordinate(new e.Point(0,0)).zoomTo(r).container(),s=this.map.pointCoordinate(this.map.dimensions).zoomTo(r).container().right().down(),o={},u=this.createOrGetLevel(i.zoom),a=i.copy();for(a.column=i.column;a.column<=s.column;a.column++)for(a.row=i.row;a.row<=s.row;a.row++){var f=this.inventoryVisibleTile(u,a);while(f.length)o[f.pop()]=!0}for(var l in this.levels)if(this.levels.hasOwnProperty(l)){var c=parseInt(l,10);if(c>=i.zoom-5&&c0))return t.style.display="none",!1;t.style.display="block",i=Math.pow(2,this.map.coordinate.zoom-n),s=s.zoomTo(n);var o=this.map.tileSize.x*i,u=this.map.tileSize.y*i,a=new e.Point(this.map.dimensions.x/2,this.map.dimensions.y/2),f=this.tileElementsInLevel(t);while(f.length){var l=f.pop();r[l.id]?e.moveElement(l,{x:Math.round(a.x+(l.coord.column-s.column)*o),y:Math.round(a.y+(l.coord.row-s.row)*u),scale:i,width:this.map.tileSize.x,height:this.map.tileSize.y}):(this.provider.releaseTile(l.coord),this.requestManager.clearRequest(l.coord.toKey()),t.removeChild(l))}},createOrGetLevel:function(e){if(e in this.levels)return this.levels[e];var t=document.createElement("div");return t.id=this.parent.id+"-zoom-"+e,t.style.cssText="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; margin: 0; padding: 0;",t.style.zIndex=e,this.parent.appendChild(t),this.levels[e]=t,t},addTileImage:function(e,t,n){this.requestManager.requestTile(e,t,n)},addTileElement:function(e,t,n){n.id=e,n.coord=t.copy(),this.positionTile(n)},positionTile:function(t){var n=this.map.coordinate.zoomTo(t.coord.zoom);t.style.cssText="position:absolute;-webkit-user-select:none;-webkit-user-drag:none;-moz-user-drag:none;-webkit-transform-origin:0 0;-moz-transform-origin:0 0;-o-transform-origin:0 0;-ms-transform-origin:0 0;width:"+this.map.tileSize.x+"px; height: "+this.map.tileSize.y+"px;",t.ondragstart=function(){return!1};var r=Math.pow(2,this.map.coordinate.zoom-t.coord.zoom);e.moveElement(t,{x:Math.round(this.map.dimensions.x/2+(t.coord.column-n.column)*this.map.tileSize.x),y:Math.round(this.map.dimensions.y/2+(t.coord.row-n.row)*this.map.tileSize.y),scale:r,width:this.map.tileSize.x,height:this.map.tileSize.y});var i=this.levels[t.coord.zoom];i.appendChild(t),t.className="map-tile-loaded",Math.round(this.map.coordinate.zoom)==t.coord.zoom&&(i.style.display="block"),this.requestRedraw()},_redrawTimer:undefined,requestRedraw:function(){this._redrawTimer||(this._redrawTimer=setTimeout(this.getRedraw(),1e3))},_redraw:null,getRedraw:function(){if(!this._redraw){var e=this;this._redraw=function(){e.draw(),e._redrawTimer=0}}return this._redraw},setProvider:function(e){var t=this.provider===null;if(!t){this.requestManager.clear();for(var n in this.levels)if(this.levels.hasOwnProperty(n)){var r=this.levels[n];while(r.firstChild)this.provider.releaseTile(r.firstChild.coord),r.removeChild(r.firstChild)}}this.tiles={},this.provider=e,t||this.draw()},enable:function(){this.enabled=!0,this.parent.style.display="",this.draw()},disable:function(){this.enabled=!1,this.requestManager.clear(),this.parent.style.display="none"},destroy:function(){this.requestManager.clear(),this.requestManager.removeCallback("requestcomplete",this.getTileComplete()),this.requestManager.removeCallback("requesterror",this.getTileError()),this.provider=null,this.parent.parentNode&&this.parent.parentNode.removeChild(this.parent),this.map=null}},e.Map=function(t,n,r,i){if(typeof t=="string"){t=document.getElementById(t);if(!t)throw"The ID provided to modest maps could not be found."}this.parent=t,this.parent.style.padding="0",this.parent.style.overflow="hidden";var s=e.getStyle(this.parent,"position");s!="relative"&&s!="absolute"&&(this.parent.style.position="relative"),this.layers=[],n||(n=[]),n instanceof Array||(n=[n]);for(var o=0;o=this.layers.length)throw new Error("invalid index in setLayerAt(): "+t);if(this.layers[t]!=n){if(tthis.layers.length)throw new Error("invalid index in insertLayerAt(): "+t);if(t==this.layers.length)this.layers.push(n),this.parent.appendChild(n.parent);else{var r=this.layers[t];this.parent.insertBefore(n.parent,r.parent),this.layers.splice(t,0,n)}return n.map=this,e.getFrame(this.getRedraw()),this},removeLayerAt:function(e){if(e<0||e>=this.layers.length)throw new Error("invalid index in removeLayer(): "+e);var t=this.layers[e];return this.layers.splice(e,1),t.destroy(),this},swapLayersAt:function(e,t){if(e<0||e>=this.layers.length||t<0||t>=this.layers.length)throw new Error("invalid index in swapLayersAt(): "+index);var n=this.layers[e],r=this.layers[t],i=document.createElement("div");return this.parent.replaceChild(i,r.parent),this.parent.replaceChild(r.parent,n.parent),this.parent.replaceChild(n.parent,i),this.layers[e]=r,this.layers[t]=n,this},enableLayer:function(e){var t=this.getLayer(e);return t&&t.enable(),this},enableLayerAt:function(e){var t=this.getLayerAt(e);return t&&t.enable(),this},disableLayer:function(e){var t=this.getLayer(e);return t&&t.disable(),this},disableLayerAt:function(e){var t=this.getLayerAt(e);return t&&t.disable(),this},enforceZoomLimits:function(e){var t=this.coordLimits;if(t){var n=t[0].zoom,r=t[1].zoom;e.zoomr&&(e=e.zoomTo(r))}return e},enforcePanLimits:function(t){if(this.coordLimits){t=t.copy();var n=this.coordLimits[0].zoomTo(t.zoom),r=this.coordLimits[1].zoomTo(t.zoom),i=this.pointCoordinate(new e.Point(0,0)).zoomTo(t.zoom),s=this.pointCoordinate(this.dimensions).zoomTo(t.zoom);r.row-n.rowr.row&&(t.row-=s.row-r.row),r.column-n.columnr.column&&(t.column-=s.column-r.column)}return t},enforceLimits:function(e){return this.enforcePanLimits(this.enforceZoomLimits(e))},draw:function(){this.coordinate=this.enforceLimits(this.coordinate);if(this.dimensions.x<=0||this.dimensions.y<=0){if(!this.autoSize)return;var t=this.parent.offsetWidth,n=this.parent.offsetHeight;this.dimensions=new e.Point(t,n);if(t<=0||n<=0)return}for(var r=0;r"?">":"&",s)}}n.endDoc&&n.endDoc(s)}}function x(t){var n,r;return S({startDoc:function(e){n=[],r=!1},startTag:function(i,s,o){if(r)return;if(!e.ELEMENTS.hasOwnProperty(i))return;var u=e.ELEMENTS[i];if(u&e.eflags.FOLDABLE)return;if(u&e.eflags.UNSAFE){r=!(u&e.eflags.EMPTY);return}s=t(i,s);if(s){u&e.eflags.EMPTY||n.push(i),o.push("<",i);for(var a=0,f=s.length;a")}},endTag:function(t,i){if(r){r=!1;return}if(!e.ELEMENTS.hasOwnProperty(t))return;var s=e.ELEMENTS[t];if(!(s&(e.eflags.UNSAFE|e.eflags.EMPTY|e.eflags.FOLDABLE))){var o;if(s&e.eflags.OPTIONAL_ENDTAG)for(o=n.length;--o>=0;){var u=n[o];if(u===t)break;if(!(e.ELEMENTS[u]&e.eflags.OPTIONAL_ENDTAG))return}else for(o=n.length;--o>=0;)if(n[o]===t)break;if(o<0)return;for(var a=n.length;--a>o;){var u=n[a];e.ELEMENTS[u]&e.eflags.OPTIONAL_ENDTAG||i.push("")}n.length=o,i.push("")}},pcdata:function(e,t){r||t.push(e)},rcdata:function(e,t){r||t.push(e)},cdata:function(e,t){r||t.push(e)},endDoc:function(e){for(var t=n.length;--t>=0;)e.push("");n.length=0}})}function N(t,n,i){var s=[];return x(function(s,o){for(var u=0;u",amp:"&",nbsp:" ",quot:'"',apos:"'"},r=/^(?:https?|mailto|data)$/i,i=/^#(\d+)$/,s=/^#x([0-9A-Fa-f]+)$/,a=/\0/g,l=/&(#\d+|#x[0-9A-Fa-f]+|\w+);/g,h=/&/g,p=/&([^a-z#]|#(?:[^0-9x]|x(?:[^0-9a-f]|$)|$)|$)/gi,d=//g,m=/\"/g,g=/\=/g,w=new RegExp("^\\s*(?:(?:([a-z][a-z-]*)(\\s*=\\s*(\"[^\"]*\"|'[^']*'|(?=[a-z][a-z-]*\\s*=)|[^>\"'\\s]*))?)|(/?>)|[\\s\\S][^a-z\\s>]*)","i"),E=new RegExp("^(?:&(\\#[0-9]+|\\#[x][0-9a-f]+|\\w+);||]*>|<\\?[^>*]*>|<(/)?([a-z][a-z0-9]*)|([^<&>]+)|([<&>]))","i"),T=new RegExp("^(?:([^:/?#]+):)?");return{escapeAttrib:y,makeHtmlSanitizer:x,makeSaxParser:S,normalizeRCData:b,sanitize:N,unescapeEntities:c}}(html4),html_sanitize=html.sanitize;typeof window!="undefined"&&(window.html=html,window.html_sanitize=html_sanitize),html4.ATTRIBS["*::style"]=0,html4.ELEMENTS.style=0,html4.ATTRIBS["a::target"]=0,html4.ELEMENTS.video=0,html4.ATTRIBS["video::src"]=0,html4.ATTRIBS["video::poster"]=0,html4.ATTRIBS["video::controls"]=0,html4.ELEMENTS.audio=0,html4.ATTRIBS["audio::src"]=0,html4.ATTRIBS["video::autoplay"]=0,html4.ATTRIBS["video::controls"]=0,wax=wax||{},wax.attribution=function(){var e={},t=document.createElement("div");return t.className="map-attribution",e.content=function(e){return typeof e=="undefined"?t.innerHTML:(t.innerHTML=wax.u.sanitize(e),this)},e.element=function(){return t},e.init=function() {return this},e},wax=wax||{},wax.bwdetect=function(e,t){function a(){wax.bw=-1;var e=new Image;e.src=s;var t=!0,i=setTimeout(function(){t&&wax.bw==-1&&(n.bw(0),t=!1)},r);e.onload=function(){t&&wax.bw==-1&&(clearTimeout(i),n.bw(1),t=!1)}}var n={},r=e.threshold||400,s="http://a.tiles.mapbox.com/mapbox/1.0.0/blue-marble-topo-bathy-jul/0/0/0.png?preventcache="+ +(new Date),o=1,u=e.auto===undefined?!0:e.auto;return n.bw=function(e){if(!arguments.length)return o;var n=o;wax.bwlisteners&&wax.bwlisteners.length&&function(){listeners=wax.bwlisteners,wax.bwlisteners=[];for(i=0;i=93&&e--,e>=35&&e--,e-=32,e}t=t||{};var n={},r=t.resolution||4,i=t.tileSize||256;return n.grid_tile=function(){return e},n.getKey=function(t,n){if(!e||!e.grid)return;if(n<0||t<0)return;if(Math.floor(n)>=i||Math.floor(t)>=i)return;return s(e.grid[Math.floor(n/r)].charCodeAt(Math.floor(t/r)))},n.gridFeature=function(t,n){var r=this.getKey(t,n),i=e.keys;if(i&&i[r]&&e.data[i[r]])return e.data[i[r]]},n.tileFeature=function(t,n,r){if(!e)return;var i=wax.u.offset(r);return feature=this.gridFeature(t-i.left,n-i.top),feature},n},wax.gm=function(){function o(e){return typeof e=="string"&&(e=[e]),function(n){if(!n)return;var r=new RegExp("/(\\d+)\\/(\\d+)\\/(\\d+)\\.[\\w\\._]+"),i=r.exec(n);if(!i)return;return e[parseInt(i[2],10)%e.length].replace(/\{z\}/g,i[1]).replace(/\{x\}/g,i[2]).replace(/\{y\}/g,i[3])}}var e=4,t={},n={},r,i,s=function(e){if(e)return e.replace(/(\.png|\.jpg|\.jpeg)(\d*)/,".grid.json")};return n.formatter=function(e){return arguments.length?(i=wax.formatter(e),n):i},n.template=function(e){return arguments.length?(i=wax.template(e),n):i},n.gridUrl=function(e){return arguments.length?(e?s=typeof e=="function"?e:o(e):s=function(){return null},n):s},n.getGrid=function(t,r){var o=s(t);return!i||!o?r(null,null):(wax.request.get(o,function(t,n){if(t)return r(t,null);r(null,wax.gi(n,{formatter:i,resolution:e}))}),n)},n.tilejson=function(t){return arguments.length?(t.template?n.template(t.template):t.formatter?n.formatter(t.formatter):i=undefined,n.gridUrl(t.grids),t.resolution&&(e=t.resolution),r=t,n):r},n},wax=wax||{},wax.hash=function(e){function i(){return location.hash.substring(1)}function s(e){var t=window.location;t.replace(t.toString().replace(t.hash||/$/,"#"+e))}function o(t){var n=t.split("/");for(var r=0;re.y&&t[n][1]e.x)return t[n][2];return!1}function v(){return r?(window.clearTimeout(r),r=null,!0):!1}function m(r){if(n)return;var i=wax.u.eventoffset(r);t.screen_feature(i,function(n){n?bean.fire(t,"on",{parent:f(),data:n,formatter:e.formatter().format,e:r}):bean.fire(t,"off")})}function g(){n=!1}function y(e){n=!0,i=wax.u.eventoffset(e),e.type==="mousedown"?(bean.add(document.body,"click",w),bean.add(document.body,"mouseup",g)):e.type==="touchstart"&&e.touches.length===1&&(bean.fire(t,"off"),bean.add(e.srcElement,p))}function b(e){bean.remove(e.srcElement,p),n=!1}function w(e){var o={},u=wax.u.eventoffset(e);n=!1;for(var a in e)o[a]=e[a];return bean.remove(document.body,"mouseup",w),bean.remove(e.srcElement,p),e.type==="touchend"?t.click(e,i):Math.round(u.y/s)===Math.round(i.y/s)&&Math.round(u.x/s)===Math.round(i.x/s)&&(r?v():r=window.setTimeout(function(){r=null,t.click(o,u)},300)),w}var e=wax.gm(),t={},n=!1,r=null,i,s=4,o,u,a,f,l,c,h={mousemove:m,touchstart:y,mousedown:y},p={touchend:w,touchmove:w,touchcancel:b};return t.click=function(n,r){t.screen_feature(r,function(r){r&&bean.fire(t,"on",{parent:f(),data:r,formatter:e.formatter().format,e:n})})},t.screen_feature=function(t,n){var r=d(t);r||n(null),e.getGrid(r.src,function(e,i){if(e||!i)return n(null);var s=i.tileFeature(t.x,t.y,r);n(s)})},t.attach=function(e){return arguments.length?(u=e,t):u},t.detach=function(e){return arguments.length?(a=e,t):a},t.map=function(e){return arguments.length?(l=e,u&&u(l),bean.add(f(),h),bean.add(f(),"touchstart",y),t):l},t.grid=function(e){return arguments.length?(o=e,t):o},t.remove=function(e){return a&&a(l),bean.remove(f(),h),bean.fire(t,"remove"),t},t.tilejson=function(n){return arguments.length?(e.tilejson(n),t):e.tilejson()},t.formatter=function(){return e.formatter()},t.on=function(e,n){return bean.add(t,e,n),t},t.off=function(e,n){return bean.remove(t,e,n),t},t.gridmanager=function(n){return arguments.length?(e=n,t):e},t.parent=function(e){return f=e,t},t};var wax=wax||{};wax.legend=function(){var e,t={},n;return t.element=function(){return n},t.content=function(n){return arguments.length?(e.innerHTML=wax.u.sanitize(n),e.style.display="block",e.innerHTML===""&&(e.style.display="none"),t):e.innerHTML},t.add=function(){return n=document.createElement("div"),n.className="map-legends wax-legends",e=n.appendChild(document.createElement("div")),e.className="map-legend wax-legend",e.style.display="none",t},t.add()};var wax=wax||{};wax.location=function(){function t(e){if(e.e.type==="mousemove"||!e.e.type)return;var t=e.formatter({format:"location"},e.data);t&&(window.top.location.href=t)}var e={};return e.events=function(){return{on:t}},e};var wax=wax||{};wax.movetip={},wax.movetip=function(){function o(e){var t=wax.u.eventoffset(e);n.height+t.y>r.top+r.height&&r.height>n.height&&(t.y-=n.height,i.className+=" flip-y"),n.width+t.x>r.left+r.width&&(t.x-=n.width,i.className+=" flip-x"),i.style.left=t.x+"px",i.style.top=t.y+"px"}function u(e){var t=document.createElement("div");return t.className="map-tooltip map-tooltip-0",t.innerHTML=e,t}function a(){i&&(i.parentNode.removeChild(i),i=null)}function f(t){var f;if(e)return;if(t.e.type==="mousemove"||!t.e.type){f=t.formatter({format:"teaser"},t.data);if(!f)return;a(),s.style.cursor="pointer",i=document.body.appendChild(u(f))}else{f=t.formatter({format:"teaser"},t.data);if(!f)return;a();var l=document.body.appendChild(u(f));l.className+=" map-popup";var c=l.appendChild(document.createElement("a"));c.href="#close",c.className="close",c.innerHTML="Close",e=!0,i=l,n=wax.u.offset(i),r=wax.u.offset(s),o(t.e),bean.add(c,"click touchend",function(n){n.stop(),a(),e=!1})}i&&(n=wax.u.offset(i),r=wax.u.offset(s),o(t.e))}function l(){s.style.cursor="default",e||a()}var e=!1,t={},n,r,i,s;return t.parent=function(e){return arguments.length?(s=e,t):s},t.events=function(){return{on:f,off:l}},t};var wax=wax||{};wax.request={cache:{},locks:{},promises:{},get:function(e,t){if(this.cache[e])return t(this.cache[e][0],this.cache[e][1]);this.promises[e]=this.promises[e]||[],this.promises[e].push(t);if(this.locks[e])return;var n=this;this.locks[e]=!0,reqwest({url:e+(~e.indexOf("?")?"&":"?")+"callback=?",type:"jsonp",success:function(t){n.locks[e]=!1,n.cache[e]=[null,t];for(var r=0;r-1;t--)o.deleteLocation(a[t]);return o},o.deleteLocation=function(e,t){if(!t||confirm("Delete this point?")){e.pointDiv.parentNode.removeChild(e.pointDiv);for(var n=0;nthis.options.maxzoom)return null;t.row=this.options.scheme==="tms"?Math.pow(2,t.zoom)-t.row-1:t.row;var n=this.options.tiles[parseInt(Math.pow(2,t.zoom)*t.row+t.column,10)%this.options.tiles.length].replace("{z}",t.zoom.toFixed(0)).replace("{x}",t.column.toFixed(0)).replace("{y}",t.row.toFixed(0));return wax._&&wax._.bw&&(n=n.replace(".png",wax._.bw_png).replace(".jpg",wax._.bw_jpg)),n}},MM&&MM.extend(wax.mm._provider,MM.MapProvider),wax.mm.connector=function(e){var t=new wax.mm._provider(e);return new MM.Layer(t)},function(e,t){var n=function(){function l(e,t,n){return n===0?e:n===1?t:e+(t-e)*n}var e={},n=!1,r=!1,i,s={easeIn:function(e){return e*e},easeOut:function(e){return Math.sin(e*Math.PI/2)},easeInOut:function(e){return(1-Math.cos(Math.PI*e))/2},linear:function(e){return e}},o=s.easeOut,u,a,f;e.stop=function(e){r=!0,u=undefined,i=e},e.running=function(){return n},e.point=function(t){return a=f.pointCoordinate(t),e},e.zoom=function(t){return a||(a=f.coordinate.copy()),a=f.enforceZoomLimits(a.zoomTo(t)),e},e.location=function(t){return a=f.locationCoordinate(t),e},e.from=function(t){return arguments.length?(u=t.copy(),e):u?u.copy():u},e.to=function(t){return arguments.length?(a=f.enforceZoomLimits(t.copy()),e):a.copy()},e.path=function(t){return p=c[t],e},e.easing=function(t){return o=s[t],e},e.map=function(t){return arguments.length?(f=t,e):f};var c={},h=new t.Coordinate(0,0,0);c.screen=function(e,n,r,i){var s=l(e.zoom,n.zoom,r);if(!i)return new t.Coordinate(l(e.row,n.row*Math.pow(2,e.zoom-n.zoom),r)*Math.pow(2,s-e.zoom),l(e.column,n.column*Math.pow(2,e.zoom-n.zoom),r)*Math.pow(2,s-e.zoom),s);i.row=l(e.row,n.row*Math.pow(2,e.zoom-n.zoom),r)*Math.pow(2,s-e.zoom),i.column=l(e.column,n.column*Math.pow(2,e.zoom-n.zoom),r)*Math.pow(2,s-e.zoom),i.zoom=s},c.about=function(e,n,r,i){var s=l(e.zoom,n.zoom,r),o=f.dimensions.x/2,u=f.dimensions.y/2,a=f.tileSize.x,c=f.tileSize.y,h=o+a*(n.column*Math.pow(2,e.zoom-n.zoom)-e.column),p=u+c*(n.row*Math.pow(2,e.zoom-n.zoom)-e.row),d=o+a*(n.column*Math.pow(2,s-n.zoom)-e.column*Math.pow(2,s-e.zoom)),v=u+c*(n.row*Math.pow(2,s-n.zoom)-e.row*Math.pow(2,s-e.zoom));if(!i)return new t.Coordinate(e.column*Math.pow(2,s-e.zoom)-(h-d)/a,e.row*Math.pow(2,s-e.zoom)-(p-v)/c,s);i.column=e.column*Math.pow(2,s-e.zoom)-(h-d)/a,i.row=e.row*Math.pow(2,s-e.zoom)-(p-v)/c,i.zoom=s};var p=c.screen;e.t=function(t){return p(u,a,o(t),h),f.coordinate=h,f.draw(),e},e.future=function(e){var t=[];for(var n=0;ns){a.zoom!=u.zoom&&f.dispatchCallback("zoomed",a.zoom-u.zoom),n=!1,p(u,a,1,h),f.coordinate=h,a=u=undefined,f.draw();if(l)return l(f)}else p(u,a,o(e/s),h),f.coordinate=h,f.draw(),t.getFrame(c)}if(n)return e.stop(function(){e.run(s,l)});u||(u=f.coordinate.copy()),a||(a=f.coordinate.copy()),s=s||1e3,d=+(new Date),n=!0,t.getFrame(c)},e.optimal=function(r,i,s){function o(e){return e*e}function c(e){return(Math.exp(e)-Math.exp(-e))/2}function h(e){return(Math.exp(e)+Math.exp(-e))/2}function d(e){return c(e)/h(e)}function N(e){var t=o(y)-o(g)+(e?-1:1)*Math.pow(i,4)*o(T-x),n=2*(e?y:g)*o(i)*(T-x);return t/n}function C(e){return Math.log(-N(e)+Math.sqrt(o(N(e))+1))}if(n)return e.stop(function(){e.optimal(r,i,s)});r=r||.9,i=i||1.42,u?f.coordinate=u:u=f.coordinate.copy();var v=f.pointCoordinate(new t.Point(0,0)).zoomTo(0),m=f.pointCoordinate(f.dimensions).zoomTo(0),g=Math.max(m.column-v.column,m.row-v.row),y=g*Math.pow(2,u.zoom-a.zoom),b=u.zoomTo(0),w=a.zoomTo(0),E={x:b.column,y:b.row},S={x:w.column,y:w.row},x=0,T=Math.sqrt(o(S.x-E.x)+o(S.y-E.y)),k=C(0),L=C(1),A=(L-k)/i,O=function(e){return g*h(k)/h(i*e+k)},M=function(e){return g/o(i)*h(k)*d(i*e+k)-g/o(i)*c(k)+x};if(Math.abs(T)<1e-6){if(Math.abs(g-y)<1e-6)return;var _=yt?Math.floor(t):Math.ceil(t);easey().map(n).point(c).zoom(r).path("about").run(300),v(),l=!1}function x(e){t.removeEvent(e.target,"touchmove",y),t.removeEvent(e.target,"touchend",x);var n=(new Date).getTime();e.touches.length===0&&l&&S(e.changedTouches[0]),i.up();for(var r=0;ro||(h>s?(c.end=n,c.duration=h):(c.time=n,b(c)))}var d={};for(var v=0;v0?1:-1))).path("about").run(100,f),s=(new Date).getTime()}else a>150&&(i.zoom(i.to().zoom+(o>0?1:-1)).from(n.coordinate).resetRun(),s=(new Date).getTime());return t.cancelEvent(e)}var e={},n,r,i=easey(),s,o=!1;return e.init=function(i){n=i,r=document.body.appendChild(document.createElement("div")),r.style.cssText="visibility:hidden;top:0;height:0;width:0;overflow-y:scroll" ;var s=r.appendChild(document.createElement("div"));return s.style.height="2000px",t.addEvent(n.parent,"mousewheel",u),e},e.precise=function(t){return arguments.length?(o=t,e):o},e.remove=function(){t.removeEvent(n.parent,"mousewheel",u),r.parentNode.removeChild(r)},e},n.DragHandler=function(){function s(e){n.parent.focus()}function o(e){if(e.shiftKey||e.button==2)return;return t.addEvent(document,"mousemove",u),t.addEvent(document,"mouseup",a),i.down(e),n.parent.style.cursor="move",t.cancelEvent(e)}function u(e){return i.move(e),t.cancelEvent(e)}function a(e){return t.removeEvent(document,"mousemove",u),t.removeEvent(document,"mouseup",a),i.up(),n.parent.style.cursor="",t.cancelEvent(e)}var e={},n,i;return e.init=function(e){n=e,t.addEvent(n.parent,"click",s),t.addEvent(n.parent,"mousedown",o),i=r(n)},e.remove=function(){t.removeEvent(n.parent,"click",s),t.removeEvent(n.parent,"mousedown",o),i.up(),i.remove()},e},this.easey_handlers=n}(this,MM),typeof mapbox=="undefined"&&(mapbox={}),typeof mapbox.markers=="undefined"&&(mapbox.markers={}),mapbox.markers.layer=function(){function d(t){t.coord||(t.coord=e.map.locationCoordinate(t.location));var n=e.map.coordinatePoint(t.coord),r,i;n.x<0?(r=new MM.Location(t.location.lat,t.location.lon),r.lon+=Math.ceil((a.lon-t.location.lon)/360)*360,i=e.map.locationPoint(r),i.xe.map.dimensions.x&&(r=new MM.Location(t.location.lat,t.location.lon),r.lon-=Math.ceil((t.location.lon-f.lon)/360)*360,i=e.map.locationPoint(r),i.x>0&&(n=i,t.coord=e.map.locationCoordinate(r))),n.scale=1,n.width=n.height=0,MM.moveElement(t.element,n)}var e={},t=[],n=[],r=new MM.CallbackManager(e,["drawn","markeradded"]),i=null,s=mapbox.markers.simplestyle_factory,o=function(e,t){return t.geometry.coordinates[1]-e.geometry.coordinates[1]},u,a=null,f=null,l=function(){return!0},c=0,h=function(){return++c},p={};return e.parent=document.createElement("div"),e.parent.style.cssText="position: absolute; top: 0px;left:0px; width:100%; height:100%; margin:0; padding:0; z-index:0;pointer-events:none;",e.name="markers",e.addCallback=function(t,n){return r.addCallback(t,n),e},e.removeCallback=function(t,n){return r.removeCallback(t,n),e},e.draw=function(){if(!e.map)return;a=e.map.pointLocation(new MM.Point(0,0)),f=e.map.pointLocation(new MM.Point(e.map.dimensions.x,0)),r.dispatchCallback("drawn",e);for(var t=0;t=0;f--)n[f].touch===!1&&e.remove(n[f]);return e.map&&e.map.coordinate&&e.map.draw(),e},e.url=function(t,n){function r(t,r){if(t&&n)return n(t);var i=typeof r!="undefined"&&r.features?r.features:null;i&&e.features(i),n&&n(t,i,e)}if(!arguments.length)return u;if(typeof reqwest=="undefined")throw"reqwest is required for url loading";return typeof t=="string"&&(t=[t]),u=t,reqwest(u[0].match(/geojsonp$/)?{url:u[0]+(~u[0].indexOf("?")?"&":"?")+"callback=?",type:"jsonp",success:function(e){r(null,e)},error:r}:{url:u[0],type:"json",success:function(e){r(null,e)},error:r}),e},e.id=function(t,n){return e.url("http://a.tiles.mapbox.com/v3/"+t+"/markers.geojsonp",n)},e.csv=function(t){return e.features(mapbox.markers.csv_to_geojson(t))},e.extent=function(){var t=[{lat:Infinity,lon:Infinity},{lat:-Infinity,lon:-Infinity}],n=e.features();for(var r=0;rt[1].lon&&(t[1].lon=i[0]),i[1]>t[1].lat&&(t[1].lat=i[1])}return t},e.key=function(t){return arguments.length?(t===null?h=function(){return++c}:h=t,e):h},e.factory=function(t){return arguments.length?(s=t,e.features(e.features()),e):s},e.filter=function(t){return arguments.length?(l=t,e.features(e.features()),e):l},e.destroy=function(){e.parent.parentNode&&e.parent.parentNode.removeChild(e.parent)},e.named=function(t){return arguments.length?(e.name=t,e):e.name},e.enabled=!0,e.enable=function(){return this.enabled=!0,this.parent.style.display="",e},e.disable=function(){return this.enabled=!1,this.parent.style.display="none",e},e},mmg=mapbox.markers.layer,mapbox.markers.interaction=function(e){function f(){e.map.addCallback("panned",function(){if(i)while(n.length)e.remove(n.pop())})}if(e&&e.interaction)return e.interaction;var t={},n=[],r=!0,i=!0,s=!0,o=null,u=!0,a;t.formatter=function(e){return arguments.length?(a=e,t):a},t.formatter(function(e){var t="",n=e.properties;return n?(n.title&&(t+='
'+n.title+"
"),n.description&&(t+='
'+n.description+"
"),typeof html_sanitize!==undefined&&(t=html_sanitize(t,function(e){if(/^(https?:\/\/|data:image)/.test(e))return e},function(e){return e})),t):null}),t.hideOnMove=function(e){return arguments.length?(i=e,t):i},t.exclusive=function(e){return arguments.length?(r=e,t):r},t.showOnHover=function(e){return arguments.length?(s=e,t):s},t.hideTooltips=function(){while(n.length)e.remove(n.pop());for(var t=0;t0&&(t.hideTooltips(),o&&window.clearTimeout(o));var h=document.createElement("div");h.className="marker-tooltip",h.style.width="100%";var p=h.appendChild(document.createElement("div"));p.style.cssText="position: absolute; pointer-events: none;";var d=p.appendChild(document.createElement("div"));d.className="marker-popup",d.style.cssText="pointer-events: auto;",typeof c=="string"?d.innerHTML=c:d.appendChild(c),p.style.bottom=i.element.offsetHeight/2+20+"px",MM.addEvent(d,"mousedown",v),MM.addEvent(d,"touchstart",v),s&&(h.onmouseover=function(){o&&window.clearTimeout(o)},h.onmouseout=f);var m={element:h,data:{},interactive:!1,location:i.location.copy()};n.push(m),i.tooltip=m,e.add(m),e.draw()};i.showTooltip=l,i.element.onclick=i.element.ontouchstart=function(){l(),i.clicked=!0},i.element.onmouseover=l,i.element.onmouseout=f};if(e){e.addCallback("drawn",f);var l=e.markers();for(var c=0;c=e.length)return r;if(a)return a=!1,n;var t=s.lastIndex;if(e.charCodeAt(t)===34){var i=t;while(i++0;t--)if(!i.layers[t-1].features)return this.insertLayerAt(t,e);return this.insertLayerAt(0,e)},i.removeLayerAt=function(e){return MM.Map.prototype.removeLayerAt.call(this,e),MM.getFrame(this.getRedraw()),this},i.swapLayersAt=function(e,t){return MM.Map.prototype.swapLayersAt.call(this,e,t),MM.getFrame(this.getRedraw()),this},i},this.mapbox=mapbox,typeof mapbox=="undefined"&&(mapbox={}),mapbox.auto=function(e,t,n){mapbox.load(t,function(t){var r=t instanceof Array?t:[t],i=[],s=[];for(var o=0;o"):""),t.legend.content(f.length?f.join("
"):""),t.attribution.element().style.display=a.length?"":"none",t.legend.element().style.display=f.length?"":"none"},t},typeof mapbox=="undefined"&&(mapbox={}),mapbox.util={asyncMap:function(e,t,n){function s(e){return function(t){i[e]=t,r--,r||n(i)}}var r=e.length,i=[];for(var o=0;o=0;r--)if(n.layers[r].enabled){var i=n.layers[r].tilejson&&n.layers[r].tilejson();if(i&&i.template)return e.tilejson(i)}return e.tilejson({})},e.auto=function(){return t=!0,e.on(wax.tooltip().animate(!0).parent(e.map().parent).events()).on(wax.location().events()),e.refresh()},e},typeof mapbox=="undefined"&&(mapbox={}),mapbox.layer=function(){if(!(this instanceof mapbox.layer))return new mapbox.layer;this._tilejson={},this._url="",this._id="",this._composite=!0,this.name="",this.parent=document.createElement("div"),this.parent.style.cssText="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; margin: 0; padding: 0; z-index: 0",this.levels={},this.requestManager=new MM.RequestManager,this.requestManager.addCallback("requestcomplete",this.getTileComplete()),this.requestManager.addCallback("requesterror",this.getTileError()),this.setProvider(new wax.mm._provider({tiles:["data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"]}))},mapbox.layer.prototype.refresh=function(e){var t=this;return wax.tilejson(this._url,function(n){t.tilejson(n),e&&e(t)}),this},mapbox.layer.prototype.url=function(e,t){return arguments.length?(this._mapboxhosting=e.indexOf(mapbox.MAPBOX_URL)==0,this._url=e,this.refresh(t)):this._url},mapbox.layer.prototype.id=function(e,t){return arguments.length?(this.named(e),this._id=e,this.url(mapbox.MAPBOX_URL+e+".jsonp",t)):this._id},mapbox.layer.prototype.named=function(e){return arguments.length?(this.name=e,this):this.name},mapbox.layer.prototype.tilejson=function(e){if(!arguments.length)return this._tilejson;(!this._composite||!this._mapboxhosting)&&this.setProvider(new wax.mm._provider(e)),this._tilejson=e,this.name=this.name||e.id,this._id=this._id||e.id;if(e.bounds){var t=new MM.MercatorProjection(0,MM.deriveTransformation(-Math.PI,Math.PI,0,0,Math.PI,Math.PI,1,0,-Math.PI,-Math.PI,0,1));this.provider.tileLimits=[t.locationCoordinate(new MM.Location(e.bounds[3],e.bounds[0])).zoomTo(e.minzoom?e.minzoom:0),t.locationCoordinate(new MM.Location(e.bounds[1],e.bounds[2])).zoomTo(e.maxzoom?e.maxzoom:18)]}return this},mapbox.layer.prototype.draw=function(){if(!this.enabled||!this.map)return;if(this._composite&&this._mapboxhosting){var e=0;for(e;e=0;t--)if(this.map.getLayerAt(t).enabled){if(this.map.getLayerAt(t)._composite)return this.parent.style.display="none",this.compositeLayer=!1,this;break}var n=[];for(var r=e;r