
JMap.util.AjaxRequest=function(params){if(window.XMLHttpRequest){this._request=new XMLHttpRequest();if(params)this.asyncRequest(params);}else if(window.ActiveXObject){this._request=new ActiveXObject("Microsoft.XMLHTTP");if(params)this.asyncRequest(params);}else
return null;}
JMap.util.AjaxRequest.prototype.abort=function(){this._response=null;this._onDataRetrieved=null;this._request.abort();}
JMap.util.AjaxRequest.prototype.asyncRequest=function(params){var method=params.method;var url=params.url;var paramString=params.paramString;var onData=params.onData;this.url=url;if(onData)this.onData=onData;method?method=method.toUpperCase():method="GET";var fullURL=url;if(method=="GET"){if(params)fullURL+="?"+paramString;this._request.open(method,fullURL,true);var _this=this;this._request.onreadystatechange=function(){if(_this._onDataRetrieved)_this._onDataRetrieved()};this._request.send(null);}else if(method=="POST"){this._request.open(method,fullURL,true);var _this=this;if(params){this._request.setRequestHeader('Content-type','application/x-www-form-urlencoded');this._request.setRequestHeader('Content-length',paramString.length);this._request.setRequestHeader('Connection','close');this._request.onreadystatechange=function(){if(_this._onDataRetrieved)_this._onDataRetrieved()};this._request.send(params);}else{this._request.send(null);}}}
JMap.util.AjaxRequest.prototype.syncRequest=function(params){var method=params.method;var url=params.url;var paramString=params.paramString;method?method=method.toUpperCase():method="GET";var fullURL=url;if(method=="GET"){if(params)fullURL+="?"+paramString;this._request.open(method,fullURL,false);this._request.send(null);}else if(method=="POST"){this._request.open(method,fullURL,false);if(paramString){this._request.setRequestHeader("Cache-Control","no-store");this._request.setRequestHeader('Content-type','application/x-www-form-urlencoded');this._request.setRequestHeader('Connection','close');this._request.setRequestHeader('Content-length',paramString.length);this._request.send(paramString);}else{this._request.send(null);}}
if(this._onDataRetrieved)this._onDataRetrieved();}
JMap.util.AjaxRequest.prototype._onDataRetrieved=function(){if(this._request.readyState==4){if(this._request.status==200){this._response=this._request.responseText;if(this.onData){this.onData(this);this.onData=null;}}else{this._response="An error occurred retrieving data: "+this._request.status;}}}
JMap.util.AjaxRequest.prototype.getResponseText=function(){return this._response;}
JMap.util.AjaxRequest.prototype.getResponseXML=function(){var theDocument=false;if(window.ActiveXObject){try{theDocument=new ActiveXObject("Microsoft.XMLDOM");theDocument.async=false;theDocument.loadXML(this._response);}catch(e){alert("Error parsing XML of Ajax response.");return false;}}else if(window.XMLHttpRequest){try{var parser=new DOMParser();theDocument=parser.parseFromString(this._response,"text/xml");}catch(e){alert("Error parsing XML of Ajax response.");return false;}}
return theDocument;}
JMap.web.mapLayer.ArcTMSLayer=function(params){this.format='jpeg';JMap.web.mapLayer.Layer.call(this,params);}
JMap.web.mapLayer.ArcTMSLayer.prototype=new JMap.web.mapLayer.Layer();JMap.web.mapLayer.ArcTMSLayer.prototype.getSourceURL=function(x,y){var tempBase='';if(this.serverIndex!=undefined){this.serverIndex=(x*y)%this.baseUrls.length;tempBase=this.baseUrls[this.serverIndex];}else{tempBase=this.baseUrl;}
var tpmx=this.map.getTilesPerMapX()
var tpmy=this.map.getTilesPerMapY();var src=tempBase+this.map.zoom+'/'+(tpmy-y-1)+'/'+(x%tpmx);return src;}
JMap.foi.FOI=function(params){if(params!=undefined){this.map;this.offsetXPx=0;this.offsetYPx=0;this.lat=params.lat;this.lon=params.lon;}}
JMap.foi.FOI.prototype._createHTML=function(){var _this=this;this.offsetXPx=5;this.offsetYPx=5;this.foi=document.createElement('div');this.foi.style.position='absolute';this.foi.style.backgroundColor='red';this.foi.style.border="dotted black 1px";this.foi.style.overflow='hidden';this.foi.style.width='10px';this.foi.style.height='10px';this.foi.style.top='0px';this.foi.style.left='0px';this.foi.onmouseover=function(){_this.FOIManager.explode();};this.moveToLatLon(this.lat,this.lon)
this.map.pane.appendChild(this.foi);}
JMap.foi.FOI.prototype.moveBy=function(dx,dy){var foiLeft=parseInt(this.foi.style.left,10);var foiTop=parseInt(this.foi.style.top,10);var newX=(foiLeft+dx);var newY=(foiTop+dy);this.foi.style.left=newX+'px';this.foi.style.top=newY+'px';}
JMap.foi.FOI.prototype.moveToPx=function(x,y){this.foi.style.top=(y-this.offsetYPx)+'px';this.foi.style.left=(x-this.offsetXPx)+'px';}
JMap.foi.FOI.prototype.moveToLatLon=function(lat,lon){this.lat=lat;this.lon=lon;var mapCoordsPx=this.map.transformLatLonToScreenSpace(lat,lon);if(mapCoordsPx.x<0)mapCoordsPx.x+=this.map.getTilesPerMapX()*this.map.tileSize;this.moveToPx(mapCoordsPx.x,mapCoordsPx.y);}
JMap.foi.FOI.prototype.resetPositionOnZoom=function(){this.moveToLatLon(this.lat,this.lon);}
JMap.foi.FOI.prototype.kill=function(){this.map.pane.removeChild(this.foi);this.map=null;}
JMap.foi.FOIManager=function(map){this.map=map;this.fois=[];}
JMap.foi.FOIManager.prototype.updateOnMove=function(){}
JMap.foi.FOIManager.prototype.updateOnZoom=function(){for(var i=0;i<this.fois.length;i++){this.fois[i].resetPositionOnZoom();}}
JMap.foi.FOIManager.prototype.moveBy=function(dx,dy){for(var i=0;i<this.fois.length;i++){this.fois[i].moveBy(dx,dy);}}
JMap.foi.FOIManager.prototype.explode=function(){}
JMap.foi.FOIManager.prototype.addFOI=function(foi){foi.map=this.map;foi.FOIManager=this;foi._createHTML();this.fois.push(foi);}
JMap.foi.FOIManager.prototype.removeFOI=function(foi){for(var i=0;i<this.fois.length;i++){if(this.fois[i]==foi){foi.kill();this.fois.splice(i,1);break;}}}
JMap.foi.FOIManager.prototype.removeAllFOIs=function(){for(var i=0;i<this.fois.length;i++){this.removeFOI(this.fois[i]);i--;}}
JMap.foi.FOIManager.prototype.hideFOI=function(foi){foi.hide();}
JMap.foi.FOIManager.prototype.showFOI=function(foi){foi.show();}
JMap.foi.FOIManager.prototype.kill=function(){for(var i=0;i<this.fois.length;i++){this.fois[i].kill();}
this.map=null;}
JMap.web.mapLayer.GoogleMapsLayer=function(params){JMap.web.mapLayer.Layer.call(this,params);}
JMap.web.mapLayer.GoogleMapsLayer.prototype=new JMap.web.mapLayer.Layer();JMap.web.mapLayer.GoogleMapsLayer.prototype.getSourceURL=function(x,y){var tempBase=this.baseUrl;if(this.serverIndex!=undefined){this.serverIndex=(x*y)%this.baseUrls.length;tempBase=this.baseUrls[this.serverIndex];}
var src=tempBase+'&hl=en&s=&x='+x+'&y='+(this.map.getTilesPerMapY()-y-1)+'&z='+(this.map.zoom);return src;}
JMap.hud.HUDManager=function(map,params){this.map=map;if(params){if(params.scaleRake){this._HUDScaleRake=new JMap.hud.ScaleRake(this);}
if(params.overviewMap){this._HUDOverviewMap=new JMap.hud.OverviewMap(this,params.overviewMap);}
if(params.latLonLabel){this._HUDLatLonLabel=new JMap.hud.LatLonLabel(this);}
if(params.zoomSlider){this._HUDZoomSlider=new JMap.hud.ZoomSlider(this);}
if(params.zoomButtons){this._HUDZoomSlider=new JMap.hud.ZoomSlider(this,true);}}}
JMap.hud.HUDManager.prototype.update=function(){if(this._HUDScaleRake){this._HUDScaleRake.update();}
if(this._HUDOverviewMap){this._HUDOverviewMap.update();}
if(this._HUDZoomSlider){this._HUDZoomSlider.update();}}
JMap.hud.HUDManager.prototype.updateOnMouseMove=function(event){event=event||window.event;if(this._HUDLatLonLabel){this._HUDLatLonLabel.update(event);}}
JMap.hud.HUDManager.prototype.updateOnMouseOut=function(event){event=event||window.event;if(this._HUDLatLonLabel){this._HUDLatLonLabel.clear();}}
JMap.hud.HUDManager.prototype.updateOnZoom=function(){if(this._HUDScaleRake){this._HUDScaleRake.update();}
if(this._HUDOverviewMap){this._HUDOverviewMap.update();}
if(this._HUDZoomSlider){this._HUDZoomSlider.update();}}
JMap.hud.HUDManager.prototype.updateOnMapMoved=function(){if(this._HUDScaleRake){this._HUDScaleRake.update();}
if(this._HUDOverviewMap){this._HUDOverviewMap.update();}}
JMap.hud.HUDManager.prototype.redrawZoomSlider=function(){if(this._HUDZoomSlider&&!this._HUDZoomSlider.hideSlider){this._HUDZoomSlider.kill();this._HUDZoomSlider=new JMap.hud.ZoomSlider(this);}}
JMap.hud.HUDManager.prototype.kill=function(){if(this._HUDScaleRake){this._HUDScaleRake.kill();}
if(this._HUDOverviewMap){this._HUDOverviewMap.kill();}
if(this._HUDLatLonLabel){this._HUDLatLonLabel.kill();}
if(this._HUDZoomSlider){this._HUDZoomSlider.kill();}}
JMap.hud.LatLonLabel=function(pHUD){this.HUD=pHUD
this._createHTML();}
JMap.hud.LatLonLabel.prototype._createHTML=function(){this.latLonLabel=document.createElement('div');this.latLonLabel.className='hud-lat-lon-label';if(this.HUD._HUDOverviewMap){this.latLonLabel.style.right=this.HUD._HUDOverviewMap.overviewMap.viewportWidth+10+'px';}else{this.latLonLabel.style.right='0px';}
this.HUD.map.mapViewport.appendChild(this.latLonLabel);}
JMap.hud.LatLonLabel.prototype.update=function(event){if(!document.onmousemove){var coords=JMap.util.getRelativeCoords(event,this.HUD.map.mapViewport);var mousePosition=this.HUD.map.getLatLonFromPixel(coords.x,coords.y);var tLat=mousePosition.lat;var tLon=mousePosition.lon;var latDegrees=Math.floor(tLat);var latMinutes=Math.floor((tLat-latDegrees)*60);var latSeconds=Math.floor((((tLat-latDegrees)*60)-latMinutes)*60);var lonDegrees=Math.floor(tLon);var lonMinutes=Math.floor((tLon-lonDegrees)*60);var lonSeconds=Math.floor((((tLon-lonDegrees)*60)-lonMinutes)*60);if(tLat>0){tLat=latDegrees+'\u00B0 '+latMinutes+"' "+latSeconds+'" N';}else if(tLat<0){tLat=Math.abs(latDegrees)+'\u00B0 '+latMinutes+"' "+latSeconds+'" S';}else{tLat="0\u00B0 0' "+' 0"';}
if(tLon>0){tLon=lonDegrees+'\u00B0 '+lonMinutes+"' "+lonSeconds+'" E';}else if(tLon<0){tLon=Math.abs(lonDegrees)+'\u00B0 '+lonMinutes+"' "+lonSeconds+'" W';}else{tLon="0\u00B0 0' "+' 0"';}
this.latLonLabel.innerHTML=tLat+'<br/>'+tLon;}}
JMap.hud.LatLonLabel.prototype.clear=function(){this.latLonLabel.innerHTML='';}
JMap.hud.LatLonLabel.prototype.kill=function(){this.HUD.map.mapViewport.removeChild(this.latLonLabel);this.latLonLabel=null;}
JMap.web.LayerManager=function(map){this.map=map;this.servicesFiles=[];this.mapLayers=[];this.activeMapLayers=[];this.selectedNotAvailable=[];}
JMap.web.LayerManager.prototype.loadMapLayerServicesFile=function(params){var _this=this;this.servicesFiles.push(new JMap.web.MapServicesFile({url:params.url,isHiddenFromUser:params.isHiddenFromUser,isOnByDefault:params.isOnByDefault,name:params.name,onLoad:function(arg1,arg2){_this._loadLayersToMap(arg1,arg2);}}));}
JMap.web.LayerManager.prototype._loadLayersToMap=function(layersXML,servicesFile){if(layersXML){var services=layersXML.getElementsByTagName('Service');for(var i=0;i<services.length;i++){var version=JMap.util.getNodeValue(services[i],'Version');var baseUrl=JMap.util.getNodeValue(services[i],'GetMapURL');var serviceType=JMap.util.getNodeValue(services[i],'serviceType','wms').toLowerCase();var formatType=JMap.util.getNodeValue(services[i],'format','image/png');var request=JMap.util.getNodeValue(services[i],'request','GetMap');var layers=services[i].getElementsByTagName('Layer');for(var j=0;j<layers.length;j++){var dataSource=JMap.util.getNodeValue(layers[j],'datasource');var overlap=JMap.util.getNodeValue(layers[j],'overlapTiles',0);var name=JMap.util.getNodeValue(layers[j],'Name');var title=JMap.util.getNodeValue(layers[j],'Title');var id=layers[j].getAttribute('id');var zDepth=layers[j].getElementsByTagName('Classification')[0].getAttribute('zdepth');var classTheme=JMap.util.getNodeValue(layers[j].getElementsByTagName('Classification')[0],'Theme');var className=JMap.util.getNodeValue(layers[j].getElementsByTagName('Classification')[0],'Name');var srs=JMap.util.getNodeValue(layers[j],'SRS');var scaleMin=JMap.util.getNodeValue(layers[j],'MinScale',0);var scaleMax=JMap.util.getNodeValue(layers[j],'MaxScale',10);var layerName=JMap.util.getNodeValue(layers[j],'Name');var re=RegExp("\\s","g");var layersUrlParam=layerName.replace(re,'+');var legendUrl=JMap.util.getNodeValue(layers[j],'LegendURL');var metaUrl=JMap.util.getNodeValue(layers[j],'MetadataURL');var opacity=JMap.util.getNodeValue(layers[j],'opacity',100);var boundingBox=JMap.util.getNodeValue(layers[j],'LatLon','-180,-90,180,90');var description=JMap.util.getNodeValue(layers[j],'Description','No description');var sld=JMap.util.getNodeValue(layers[j],'SLDURL');var isHidden=JMap.util.getNodeValue(layers[j],'hiddenFromUser',false);if(isHidden=='false'){isHidden=false}
var isDefault=JMap.util.getNodeValue(layers[j],'onByDefault',false);if(isDefault=='false'){isDefault=false}
var cacheLayer=JMap.util.getNodeValue(layers[j],'cacheLayer',true);if(cacheLayer=='false'){cacheLayer=false}
if(!this.getMapLayer(id)){var layerObj;var layerObjParams={map:this.map,id:id,title:title,name:name,scaleMin:scaleMin,scaleMax:scaleMax,baseUrl:baseUrl,zDepth:zDepth,opacity:opacity,version:version,srs:srs,request:request,format:formatType,legendUrl:legendUrl,metaUrl:metaUrl,description:description,classTheme:classTheme,className:className,sld:sld,overlap:overlap,dataSource:dataSource,isHiddenFromUser:(servicesFile.isHiddenFromUser||!!isHidden),isOnByDefault:(servicesFile.isOnByDefault||!!isDefault),validBoundingBox:boundingBox,serviceType:serviceType,layersUrlParam:layersUrlParam,cacheLayer:cacheLayer};if(serviceType=='tms'){layerObj=new JMap.web.mapLayer.TMSLayer(layerObjParams);}else if(serviceType=='arctms'){layerObj=new JMap.web.mapLayer.ArcTMSLayer(layerObjParams);}else if(serviceType=='mapcache'){layerObj=new JMap.web.mapLayer.MVMapCacheLayer(layerObjParams);}else if(serviceType=='mvwms'){layerObj=new JMap.web.mapLayer.MVWMSLayer(layerObjParams);}else if(serviceType=='basemap'){layerObj=new JMap.web.mapLayer.MVBaseMapLayer(layerObjParams);}else if(serviceType=='google'){layerObj=new JMap.web.mapLayer.GoogleMapLayer(layerObjParams);}else{layerObj=new JMap.web.mapLayer.WMSLayer(layerObjParams);}
this.loadMapLayer(layerObj);if(layerObj.isOnByDefault&&this.isLayerAvailable(layerObj)){layerObj.isOnByDefault=false;this.appendLayerToMap(layerObj.id);if(this.map.onLayerAppend){this.map.onLayerAppend(layerObj.id);}}else if(layerObj.isOnByDefault){this.selectedNotAvailable.push(layerObj);}}}}}
layersXML=null;}
JMap.web.LayerManager.prototype.loadMapLayer=function(layer){if(!this.getMapLayer(layer.id)){this.mapLayers.push(layer);}}
JMap.web.LayerManager.prototype.unloadMapLayer=function(layerId){for(var i=0;i<this.mapLayers.length;i++){if(this.mapLayers[i].id==layerId){var layer=this.mapLayers[i];this.removeLayerFromMap(layerId);this.mapLayers.splice(i,1);layer.kill();break;}}}
JMap.web.LayerManager.prototype.appendLayerToMap=function(layerId){var layer=this.getMapLayer(layerId);if(layer&&!this.getActiveLayer(layerId)&&this.isLayerAvailable(layer)){layer.activate();var inserted=false;for(var i=0;i<this.activeMapLayers.length;i++){if(parseInt(layer.zDepth,10)>parseInt(this.activeMapLayers[i].zDepth,10)){this.activeMapLayers.splice(i,0,layer);inserted=true;break;}}
if(!inserted){this.activeMapLayers.push(layer);}}else if(layer&&!this.getActiveLayer(layerId)){this.selectedNotAvailable.push(layer);}}
JMap.web.LayerManager.prototype.removeLayerFromMap=function(layerId){var layer=this.getMapLayer(layerId);if(layer&&this.getActiveLayer(layer.id)){layer.deactivate();for(var i=0;i<this.activeMapLayers.length;i++){if(this.activeMapLayers[i]==layer){this.activeMapLayers.splice(i,1);break;}}}else{for(var i=0;i<this.selectedNotAvailable.length;i++){if(this.selectedNotAvailable[i]==layer){this.selectedNotAvailable.splice(i,1);break;}}}}
JMap.web.LayerManager.prototype.getMapLayer=function(layerId){for(var i=0;i<this.mapLayers.length;i++){if(this.mapLayers[i].id==layerId){return this.mapLayers[i];}}
return null;}
JMap.web.LayerManager.prototype.getActiveLayer=function(layerId){for(var i=0;i<this.activeMapLayers.length;i++){if(this.activeMapLayers[i].id==layerId){return this.activeMapLayers[i];}}
return null;}
JMap.web.LayerManager.prototype.isLayerAvailable=function(layer){var scale=this.map.getScale();if(scale>=layer.scaleMin&&scale<=layer.scaleMax){return true;}
return false;}
JMap.web.LayerManager.prototype.getAvailableLayers=function(){var available=[];for(var i=0;i<this.mapLayers.length;i++){if(this.isLayerAvailable(this.mapLayers[i])){available.push(this.mapLayers[i]);}}
return available;}
JMap.web.LayerManager.prototype.updateActiveMapLayers=function(){for(var i=0;i<this.activeMapLayers.length;i++){var tLayer=this.activeMapLayers[i];if(!this.isLayerAvailable(tLayer)){this.removeLayerFromMap(tLayer.id);if(this.map.onLayerRemove){this.map.onLayerRemove(tLayer.id);}
this.selectedNotAvailable.push(tLayer);i--;}}
for(var i=0;i<this.selectedNotAvailable.length;i++){var tLayer=this.selectedNotAvailable[i];if(this.isLayerAvailable(tLayer)){this.selectedNotAvailable.splice(i,1);this.appendLayerToMap(tLayer.id);if(this.map.onLayerAppend){this.map.onLayerAppend(tLayer.id);}
i--;}}
for(var i=0;i<this.mapLayers.length;i++){var tLayer=this.mapLayers[i];if(tLayer.isOnByDefault&&this.isLayerAvailable(tLayer)){tLayer.isOnByDefault=false;this.appendLayerToMap(tLayer);if(this.map.onLayerAppend){this.map.onLayerAppend(tLayer.id);}}}}
JMap.web.LayerManager.prototype.clearLayers=function(){for(var i=0;i<this.activeMapLayers.length;i++){this.activeMapLayers[i].clear();}}
JMap.web.LayerManager.prototype.drawLayers=function(){for(var i=0;i<this.activeMapLayers.length;i++){this.activeMapLayers[i].draw();}}
JMap.web.LayerManager.prototype.syncWithMapCoordinates=function(){for(var i=0;i<this.activeMapLayers.length;i++){this.activeMapLayers[i].syncWithMapCoordinates();}}
JMap.web.LayerManager.prototype.kill=function(){for(var i=0;i<this.mapLayers.length;i++){this.mapLayers[i].kill();}}
JMap.svg.Line=function(params){var polyLineParams={points:[params.startLon,params.startLat,params.endLon,params.endLat],properties:params.properties,events:params.events};JMap.svg.PolyLine.call(this,polyLineParams);this.properties.fill='none';}
JMap.svg.Line.prototype=new JMap.svg.PolyLine();
JMap.web.mapLayer.LiveMapsLayer=function(params){JMap.web.mapLayer.Layer.call(this,params);}
JMap.web.mapLayer.LiveMapsLayer.prototype=new JMap.web.mapLayer.Layer();JMap.web.mapLayer.LiveMapsLayer.prototype.getSourceURL=function(x,y){y=(this.map.getTilesPerMapY()-y-1);var tempBase=this.baseUrl;if(this.serverIndex!=undefined){this.serverIndex=(x*y)%this.baseUrls.length;tempBase=this.baseUrls[this.serverIndex];}
var quadKey='';for(var i=this.map.zoom;i>0;i--){var digit=0;var mask=1<<(i-1);if((x&mask)!=0){digit++;}
if((y&mask)!=0){digit+=2;}
quadKey+=''+digit;}
var src=tempBase+'/r'+quadKey+'.png?g=282&mkt=en-us&shading=hill';return src;}
JMap.web.mapLayer.MVBaseMapLayer=function(params){JMap.web.mapLayer.Layer.call(this,params);this.serviceType='wms';}
JMap.web.mapLayer.MVBaseMapLayer.prototype=new JMap.web.mapLayer.Layer();JMap.web.mapLayer.MVBaseMapLayer.prototype.getSourceURL=function(x,y){var src=this.baseUrl;if(src.indexOf('?')==-1){src+='?';}else if(src.indexOf('?')!=src.length-1){src+='&';}
var degreesPerPxX=(360/this.map.tileSize)/this.map.projection.getTilesPerMapX();var degreesPerPxY=(180/this.map.tileSize)/this.map.projection.getTilesPerMapY();var xmin=((x*(degreesPerPxX*this.map.tileSize))%360)-180;if(180-xmin<0.0000001)xmin=-180;var xmax=xmin+(degreesPerPxX*this.map.tileSize);var ymin=((y*(degreesPerPxY*this.map.tileSize)))-90;var ymax=ymin+(degreesPerPxY*this.map.tileSize);xmin-=(this.overlapX*degreesPerPxX);xmax+=(this.overlapX*degreesPerPxX);ymin-=(this.overlapY*degreesPerPxY);ymax+=(this.overlapY*degreesPerPxY);src+='request=GetMap';src+='&srs=EPSG:'+this.srs;src+='&version='+this.version;src+='&layers=';src+='&datasource='+this.dataSource;src+='&basemap='+this.name;src+="&BBOX="+xmin+","+ymin+","+xmax+","+ymax;src+="&width="+(this.map.tileSize-(this.overlapX*-2));src+="&height="+(this.map.tileSize-(this.overlapY*-2));src+='&transparent=true';src+='&format='+this.format;return src;}
JMap.web.mapLayer.MVMapCacheLayer=function(params){this.format='PNG';this.request='gettile';this.serviceType='mapcache';JMap.web.mapLayer.Layer.call(this,params);}
JMap.web.mapLayer.MVMapCacheLayer.prototype=new JMap.web.mapLayer.Layer();JMap.web.mapLayer.MVMapCacheLayer.prototype.getSourceURL=function(x,y){var tempBase='';if(this.serverIndex!=undefined){this.serverIndex=(x*y)%this.baseUrls.length;tempBase=this.baseUrls[this.serverIndex];}else{tempBase=this.baseUrl;}
var src='';if(src.indexOf('?')==-1){src+='?';}else if(src.indexOf('?')!=src.length-1){src+='&';}
src+='request='+this.request;src+='&zoomlevel='+this.map.zoom;src+='&mx='+(x%this.map.getTilesPerMapX());src+='&my='+y;src+='&mapcache='+this.dataSource+"."+this.name;src+='&format='+this.format;return tempBase+src;}
JMap.web.mapLayer.MVWMSLayer=function(params){JMap.web.mapLayer.Layer.call(this,params);this.serviceType='wms';}
JMap.web.mapLayer.MVWMSLayer.prototype=new JMap.web.mapLayer.Layer();JMap.web.mapLayer.MVWMSLayer.prototype.getSourceURL=function(x,y){var src=this.baseUrl;if(src.indexOf('?')==-1){src+='?';}else if(src.indexOf('?')!=src.length-1){src+='&';}
var degreesPerPxX=(360/this.map.tileSize)/this.map.projection.getTilesPerMapX();var degreesPerPxY=(180/this.map.tileSize)/this.map.projection.getTilesPerMapY();var xmin=((x*(degreesPerPxX*this.map.tileSize))%360)-180;if(180-xmin<0.0000001)xmin=-180;var xmax=xmin+(degreesPerPxX*this.map.tileSize);var ymin=((y*(degreesPerPxY*this.map.tileSize)))-90;var ymax=ymin+(degreesPerPxY*this.map.tileSize);xmin-=(this.overlapX*degreesPerPxX);xmax+=(this.overlapX*degreesPerPxX);ymin-=(this.overlapY*degreesPerPxY);ymax+=(this.overlapY*degreesPerPxY);var src='request=GetMap';src+='&datasource='+this.datasource;src+='&srs=EPSG:'+this.srs;src+='&version='+this.version;src+='&layers='+this.layersUrlParam;src+="&BBOX="+xmin+","+ymin+","+xmax+","+ymax;src+="&width="+(this.map.tileSize-(this.overlapX*-2));src+="&height="+(this.map.tileSize-(this.overlapY*-2));src+='&transparent=true';src+='&format='+this.format;return src;}
JMap.web.Map=function(params){this.layerManager=new JMap.web.LayerManager(this);this.containerEl=document.getElementById(params.containerEl);this.zoom=0;this.maxZoom=(params.maxZoom||18);this.minZoom=(params.minZoom||0);this.centerLat=(params.centerLat||0);this.centerLon=(params.centerLon||0);this.tileSize=(params.tileSize||256);this.numTilesX=(params.numTilesX||6);this.numTilesY=(params.numTilesY||5);this.mapWidthPx=params.mapWidthPx;this.mapHeightPx=params.mapHeightPx;this.overviewMap=params.overviewMap;this.cacheTiles=(params.cacheTiles||false);this.epsg=params.epsg;this.border=params.border;if(params.validBBox){this.noLoop=true;}
this.tempValidBBox=params.validBBox;this.svg=params.svg;if(params.validBBox&&!params.centerLat){this.centerLat=((params.validBBox.ymax+params.validBBox.ymin)/2);}
if(params.validBBox&&!params.centerLon){this.centerLon=((params.validBBox.xmax+params.validBBox.xmin)/2);}
this.centerLatLon={lat:this.centerLat,lon:this.centerLon};this.parentMap=params.parentMap;var tZoom=(params.zoomLevel||0);if(tZoom<this.minZoom)tZoom=this.minZoom;if(params.listeners){this.onDrop=params.listeners.onDrop;this.onZoomIn=params.listeners.onZoomIn;this.onZoomOut=params.listeners.onZoomOut;this.onDblClick=params.listeners.onDblClick;this.onLayerAppend=params.listeners.onLayerAppend;this.onLayerRemove=params.listeners.onLayerRemove;this.onResize=params.listeners.onResize;}
this.x=0;this.xNoLoop=0;this.y=0;this.isZooming=false;this.dontDraw=false;this.isJumping=false;this.isMoving=false;this.blankImage=document.createElement('img');this.blankImage.src='../js/scrollable_map/images/blank.gif';if(!params.projection){params.projection=new JMap.projection.Mercator(this);}
this.projection=new params.projection.constructor(this);this.animator=false;this.pathIndex=0;this.path=[];this.snapBackTimer=null;this._createMapHTML();if(this.parentMap){this.tileManager=this.parentMap.tileManager;}else{var _this=this;this.tileManager=new JMap.web.TileManager({map:_this,cachingOn:_this.cacheTiles,onStartLoadingImages:function(){if(_this.tilesLoadingImage){_this.tilesLoadingImage.style.display='block';}},onEndLoadingImages:function(){if(_this.tilesLoadingImage){_this.tilesLoadingImage.style.display='none';}}});}
this._HUDManager=new JMap.hud.HUDManager(this,params.HUD);this.FOIManager=new JMap.foi.FOIManager(this);if(!params.validBBox){this.moveTo(this.centerLat,this.centerLon);this.zoomIn(tZoom);}else{this.fitToBBox(params.validBBox.xmin,params.validBBox.ymin,params.validBBox.xmax,params.validBBox.ymax);this.minZoom=this.zoom;this.maxZoom+=this.zoom;if(this.maxZoom>18){this.maxZoom=18;}
this._HUDManager.redrawZoomSlider();this.validBBox=params.validBBox;this.validXMinPx=Math.floor(this.projection.getXFromLon(this.validBBox.xmin));this.validXMaxPx=Math.floor(this.projection.getXFromLon(this.validBBox.xmax));this.validYMinPx=Math.floor(this.projection.getYFromLat(this.validBBox.ymin));this.validYMaxPx=Math.floor(this.projection.getYFromLat(this.validBBox.ymax));}
if(this.svg){this._SVGManager=new JMap.svg.SVGManager(this);this._SVGManager.update();}
this.centerLatLon={lat:this.centerLat,lon:this.centerLon};if(params.layers){for(var i=0;i<params.layers.length;i++){this.appendLayer(params.layers[i]);}}
if(params.layersFile){this.loadMapLayerServicesFile(params.layersFile);}}
JMap.web.Map.prototype._createMapHTML=function(){var _this=this;this.mapLayerContainer=document.createElement('div');this.mapLayerContainer.className='map-layer-container';this.mapLayerContainer.style.width=(this.numTilesX*this.tileSize)+'px';this.mapLayerContainer.style.height=(this.numTilesY*this.tileSize)+'px';this.mapLayerContainer.style.top=-this.tileSize+'px';this.mapLayerContainer.style.left='0px';this.mapViewport=document.createElement('div');this.mapViewport.className='map-viewport';this.mapViewport.style.width=(this.mapWidthPx||((this.numTilesX-1)*this.tileSize))+'px';this.mapViewport.style.height=(this.mapHeightPx||((this.numTilesY-1)*this.tileSize))+'px';if(!this.border)this.mapViewport.style.borderWidth='0px';this.containerEl.style.width=this.mapViewport.style.width;this.containerEl.style.height=this.mapViewport.style.height;this.pane=document.createElement('div');this.pane.className='map-pane cursor-hand-open';this.pane.style.left='0px';this.pane.style.top='0px';this.pane.style.width=this.mapViewport.style.width;this.pane.style.height=this.mapViewport.style.height;this.pane.onmousedown=function(event){return _this._performAction(event);};this.pane.ondblclick=function(event){return _this.animateMove(event);};this.pane.oncontextmenu=function(){return false;};this.pane.onmousemove=function(event){_this._HUDManager.updateOnMouseMove(event);return false;};this.pane.onmouseout=function(event){_this._HUDManager.updateOnMouseOut(event);return false;};this.containerEl.appendChild(this.mapViewport);this.mapViewport.appendChild(this.mapLayerContainer);this.viewportWidth=parseFloat(this.mapViewport.style.width,10);this.viewportHeight=parseFloat(this.mapViewport.style.height,10);if(!this.parentMap){this.tilesLoadingImage=document.createElement('img');this.tilesLoadingImage.className='tiles-loading-image';this.tilesLoadingImage.src='scrollable_map/images/rotating_arrow.gif';this.tilesLoadingImage.style.display='none';this.mapViewport.appendChild(this.tilesLoadingImage);}
this.mapViewport.appendChild(this.pane);}
JMap.web.Map.prototype.resize=function(viewportWidthPx,viewportHeightPx){this.pane.style.width=viewportWidthPx+'px';this.pane.style.height=viewportHeightPx+'px';this.mapViewport.style.width=viewportWidthPx+'px';this.mapViewport.style.height=viewportHeightPx+'px';this.containerEl.style.width=this.mapViewport.style.width;this.containerEl.style.height=this.mapViewport.style.height;this.viewportWidth=viewportWidthPx;this.viewportHeight=viewportHeightPx;this.moveTo(this.centerLatLon.lat,this.centerLatLon.lon)
this._testSnapBack();if(this._HUDManager)this._HUDManager.update();if(this._SVGManager)this._SVGManager.update();if(this.onResize)this.onResize();}
JMap.web.Map.prototype.clear=function(){this.layerManager.clearLayers();}
JMap.web.Map.prototype.draw=function(){this.tileManager.cancelAllLoads();this.layerManager.drawLayers();}
JMap.web.Map.prototype.appendLayer=function(layer){var layerId=layer;if(typeof layer=='object'){if(!this.getMapLayer(layer.id)){layer.map=this;layer._createLayerHTML();this.layerManager.loadMapLayer(layer);}
layerId=layer.id;}
this.layerManager.appendLayerToMap(layerId);if(this.onLayerAppend){this.onLayerAppend(layerId);}}
JMap.web.Map.prototype.removeLayer=function(layer){var layerId=layer;if(typeof layer=='object'){layerId=layer.id;}
this.layerManager.removeLayerFromMap(layerId);if(this.onLayerRemove){this.onLayerRemove(layerId);}}
JMap.web.Map.prototype.getMapLayer=function(layerId){return this.layerManager.getMapLayer(layerId);}
JMap.web.Map.prototype.loadMapLayerServicesFile=function(params){this.layerManager.loadMapLayerServicesFile(params);}
JMap.web.Map.prototype.drawShape=function(shape){map1._SVGManager.addShape(shape);}
JMap.web.Map.prototype.removeShape=function(shape){map1._SVGManager.removeShape(shape);}
JMap.web.Map.prototype.setMouseAction=function(func){this.toolAction=func;if(func){this.pane.className='map-pane '+func.cursor;}else{this.pane.className='map-pane cursor-hand-open';}}
JMap.web.Map.prototype._performAction=function(event){event=event||window.event;(!this.toolAction)?this._startDrag(event):this.toolAction(event,this);if(this.onaction){this.onaction(event);}
return false;}
JMap.web.Map.prototype._startDrag=function(event){this.pane.className='map-pane cursor-hand-closed';var _this=this;event=event||window.event;this.startDragAt=event.clientX+':'+event.clientY;this.lastMouseX=event.clientX;this.lastMouseY=event.clientY;document.onmousemove=function(event){return _this._drag(event);};document.onmouseup=function(event){return _this._endDrag(event);};return false;}
JMap.web.Map.prototype._drag=function(event){var _this=this;if(this.snapBackTimer)clearTimeout(this.snapBackTimer);this.snapBackTimer=null;event=event||window.event;var currentMouseX=event.clientX;var currentMouseY=event.clientY;this.moveBy(currentMouseX-this.lastMouseX,currentMouseY-this.lastMouseY);this.lastMouseX=currentMouseX;this.lastMouseY=currentMouseY;if(!this.animator)
this.snapBackTimer=setTimeout(function(){_this._testSnapBack()},50);return false;}
JMap.web.Map.prototype._endDrag=function(event){event=event||window.event;document.onmousemove=null;document.onmouseup=null;if(this.startDragAt!=event.clientX+':'+event.clientY){if(this.snapBackTimer){this._testSnapBack();clearTimeout(this.snapBackTimer);}
this.snapBackTimer=false;this._HUDManager.updateOnMapMoved(event);if(this._SVGManager)this._SVGManager.update();if(this.onDrop){this.onDrop();}}
this.pane.className='map-pane cursor-hand-open';return false;}
JMap.web.Map.prototype._scroll=function(event){event=event||window.event;var delta=0;if(event.wheelDelta){delta=event.wheelDelta/120;if(window.opera)delta=-delta;}else if(event.detail){delta=-event.detail/3;}
if(delta){if(delta>0){this.zoomIn(1);}else if(delta<0){this.zoomOut(1);}}
if(event.preventDefault)
event.preventDefault();event.returnValue=false;return false;}
JMap.web.Map.prototype.zoomIn=function(n){(n==undefined)?n=1:n=n;var center=this.centerLatLon;this.clear();this.isZooming=true;for(var i=0;i<n;i++){if(this.zoom<this.maxZoom){this.zoom++;this.x=(this.x*2)+Math.floor(this.numTilesX/2);this.xNoLoop=this.x;this.y=(this.y*2)+Math.floor(this.numTilesY/2);if(!this.noLoop){this.x=this.x%this.getTilesPerMapX();if(this.x<0){this.x=(this.getTilesPerMapX()-1);}}
if(this.validBBox){this.validXMinPx=Math.floor(this.projection.getXFromLon(this.validBBox.xmin));this.validXMaxPx=Math.floor(this.projection.getXFromLon(this.validBBox.xmax));this.validYMinPx=Math.floor(this.projection.getYFromLat(this.validBBox.ymin));this.validYMaxPx=Math.floor(this.projection.getYFromLat(this.validBBox.ymax));}
this.layerManager.syncWithMapCoordinates();this.moveTo(center.lat,center.lon);}else{break;}}
this.isZooming=false;this.draw();if(this.onZoomIn)this.onZoomIn(this.zoom);this._HUDManager.updateOnZoom();if(this._SVGManager)this._SVGManager.updateOnZoom();this.FOIManager.updateOnZoom();this.layerManager.updateActiveMapLayers();}
JMap.web.Map.prototype.zoomOut=function(n){(n==undefined)?n=1:n=n;var center=this.centerLatLon;this.clear();this.isZooming=true;for(var i=0;i<n;i++){if(this.zoom>=this.minZoom+1){this.zoom--;this.x=Math.floor((this.x-Math.floor(this.numTilesX/2))/2);this.xNoLoop=this.x;this.y=Math.floor((this.y-Math.floor(this.numTilesY/2))/2);if(!this.noLoop){this.x=(this.x)%this.getTilesPerMapX();if(this.x<0){this.x=this.getTilesPerMapX()-1;}}
if(this.validBBox){this.validXMinPx=Math.floor(this.projection.getXFromLon(this.validBBox.xmin));this.validXMaxPx=Math.floor(this.projection.getXFromLon(this.validBBox.xmax));this.validYMinPx=Math.floor(this.projection.getYFromLat(this.validBBox.ymin));this.validYMaxPx=Math.floor(this.projection.getYFromLat(this.validBBox.ymax));}
this.layerManager.syncWithMapCoordinates();this.moveTo(center.lat,center.lon);}else{break;}}
this.isZooming=false;this.draw();if(this.onZoomOut)this.onZoomOut(this.zoom);this._HUDManager.updateOnZoom();if(this._SVGManager)this._SVGManager.updateOnZoom();this.FOIManager.updateOnZoom();this.layerManager.updateActiveMapLayers();}
JMap.web.Map.prototype.jumpTo=function(lat,lon,zoom){this.isJumping=true;var toZoom=this.zoom;if(zoom!=undefined)toZoom=zoom;this.zoomOut(this.zoom);this.moveTo(lat,lon);this.centerLatLon={lat:lat,lon:lon};this.zoomIn(toZoom);this.isJumping=false;this.draw();}
JMap.web.Map.prototype.moveTo=function(lat,lon){this.isMoving=true
var center=this.getCenterLatLon();var centerPx=this.projection.getPixelFromLatLon(center.lat,center.lon);var moveToPx=this.projection.getPixelFromLatLon(lat,lon);this.moveBy(centerPx.x-moveToPx.x,moveToPx.y-centerPx.y);this._testSnapBack();this.isMoving=false;this.draw();this._HUDManager.updateOnMapMoved();if(this._SVGManager)this._SVGManager.update();}
JMap.web.Map.prototype.moveBy=function(dx,dy){var mapLayerContainerTop=parseInt(this.mapLayerContainer.style.top,10);var mapLayerContainerLeft=parseInt(this.mapLayerContainer.style.left,10);if(this.validBBox){var mapCoords=this.getMapCoordsInPixelSpace();if(this.viewportWidth<(this.validXMaxPx-this.validXMinPx)){if(mapCoords.x-dx<=this.validXMinPx){dx=(mapCoords.x-this.validXMinPx);}else if(mapCoords.x+this.viewportWidth-dx>=this.validXMaxPx){dx=((mapCoords.x+this.viewportWidth)-this.validXMaxPx);}}else{dx=(mapCoords.x+(this.viewportWidth/2))-((this.validXMinPx+this.validXMaxPx)/2);}
if(this.viewportHeight<(this.validYMaxPx-this.validYMinPx)){if(mapCoords.y+dy<=this.validYMinPx){dy=(this.validYMinPx-mapCoords.y);}else if(mapCoords.y+this.viewportHeight+dy>=this.validYMaxPx){dy=(this.validYMaxPx-(mapCoords.y+this.viewportHeight));}}else{dy=((this.validYMinPx+this.validYMaxPx)/2)-(mapCoords.y+(this.viewportHeight/2));}}
if(this._SVGManager)this._SVGManager.moveBy(dx,dy);this.FOIManager.moveBy(dx,dy);this.mapLayerContainer.style.left=(mapLayerContainerLeft+dx)+'px';this.mapLayerContainer.style.top=(mapLayerContainerTop+dy)+'px';if(!this.isZooming&&!this.isJumping){this.centerLatLon=this.getCenterLatLon();}}
JMap.web.Map.prototype.fitToBBox=function(xmin,ymin,xmax,ymax){this.isJumping=true;this.zoomOut((this.zoom-this.minZoom));var yminPx=this.projection.getYFromLat(ymin);var ymaxPx=this.projection.getYFromLat(ymax);var xminPx=this.projection.getXFromLon(xmin);var xmaxPx=this.projection.getXFromLon(xmax);var moveToLon=this.projection.getLonFromX(((xminPx+xmaxPx)/2));var moveToLat=this.projection.getLatFromY(((yminPx+ymaxPx)/2));this.moveTo(moveToLat,moveToLon);this.centerLatLon={lat:moveToLat,lon:moveToLon};var xExtent=xmax-xmin;var yExtent=ymax-ymin;while(this.zoom<this.maxZoom){var mapBBox=this.getViewportBoundingBox();if(xExtent>=(mapBBox.xmax-mapBBox.xmin)||yExtent>=(mapBBox.ymax-mapBBox.ymin)){this.zoomOut(1);break;}
this.zoomIn(1);}
this.isJumping=false;this.draw();}
JMap.web.Map.prototype.animateMove=function(event){event=event||window.event;var coords=JMap.util.getRelativeCoords(event,this.pane);this.animateMoveToPx(coords.x,coords.y);}
JMap.web.Map.prototype.animateMoveByPx=function(dx,dy){var startX=this.viewportWidth/2;var startY=this.viewportHeight/2;this.animateMoveToPx(startX+dx,startY+dy);}
JMap.web.Map.prototype.animateMoveToLatLon=function(lat,lon){var coords=this.getPixelFromLatLon(lat,lon);var px=this.transformPixelToScreenSpace(coords.x,coords.y);this.animateMoveToPx(px.x,px.y);}
JMap.web.Map.prototype.animateMoveToPx=function(endX,endY){this.path=[];this.pathIndex=0;clearInterval(this.animator);var startX=this.viewportWidth/2;var startY=this.viewportHeight/2;var dx=(startX-endX);var dy=(startY-endY);var dirVect=[];if(dx!=0||dy!=0){if(Math.abs(dx)>=Math.abs(dy)){dirVect.push(dx/Math.abs(dx));dirVect.push(dy/Math.abs(dx));while(Math.abs(dx)>5){dx/=2;dx=Math.floor(dx);dy=Math.floor(Math.abs(dx)*(dirVect[1]));this.path.push([dx,dy]);}
var ubound=Math.abs(dx);for(var i=0;i<ubound;i++){dx-=(dx/Math.abs(dx));dy=Math.floor(Math.abs(dx)*(dirVect[1]));this.path.push([dx,dy]);}}else if(Math.abs(dx)<Math.abs(dy)){dirVect.push(dx/Math.abs(dy));dirVect.push(dy/Math.abs(dy));while(Math.abs(dy)>5){dy/=2;dy=Math.floor(dy);dx=Math.floor(Math.abs(dy)*(dirVect[0]));this.path.push([dx,dy]);}
var ubound=Math.abs(dx);for(var i=0;i<ubound;i++){dy-=(dy/Math.abs(dy));dx=Math.floor(Math.abs(dy)*(dirVect[0]));this.path.push([dx,dy]);}}
var _this=this;this.pathIndex=0;this.animator=setInterval(function(){_this._animateMapStep();},20);}}
JMap.web.Map.prototype._animateMapStep=function(){var vector=this.path[this.pathIndex];if(vector){this.moveBy(vector[0],vector[1]);this.pathIndex++;if(this.pathIndex==this.path.length){clearInterval(this.animator);this.animator=false;this._testSnapBack();this.path=null;this._HUDManager.updateOnMapMoved();if(this._SVGManager)this._SVGManager.update();if(this.onDrop){this.onDrop();}
return true;}else{return false;}}}
JMap.web.Map.prototype._testSnapBack=function(){clearTimeout(this.snapBackTimer);this.snapBackTimer=null;var curMapX=parseInt(this.mapLayerContainer.style.left,10);var curMapY=parseInt(this.mapLayerContainer.style.top,10);var resizeOffsetX=(((this.numTilesX-1)*this.tileSize)-this.viewportWidth)/2;var resizeOffsetY=(((this.numTilesY-1)*this.tileSize)-this.viewportHeight)/2;if(curMapX>(0.0*this.tileSize)-resizeOffsetX){var numCycles=Math.floor((curMapX+resizeOffsetX)/this.tileSize)+1;curMapX-=(numCycles*this.tileSize);this.mapLayerContainer.style.left=curMapX+'px';for(var i=0;i<Math.abs(numCycles);i++){this._mapTileCycle(1,0);}}else if(curMapX<(-1.0*this.tileSize)-resizeOffsetX){var numCycles=Math.ceil(curMapX/this.tileSize);curMapX-=(numCycles*this.tileSize);this.mapLayerContainer.style.left=curMapX+'px';for(var i=0;i<Math.abs(numCycles);i++){this._mapTileCycle(-1,0);}}
if(curMapY>(-0.0*this.tileSize)-resizeOffsetY){var numCycles=Math.floor((curMapY+resizeOffsetY)/this.tileSize)+1;curMapY-=(numCycles*this.tileSize);this.mapLayerContainer.style.top=curMapY+'px';for(var i=0;i<Math.abs(numCycles);i++){this._mapTileCycle(0,1);}}else if(curMapY<(-1.0*this.tileSize)-resizeOffsetY){var numCycles=Math.ceil(curMapY/this.tileSize);curMapY-=(numCycles*this.tileSize);this.mapLayerContainer.style.top=curMapY+'px';for(var i=0;i<Math.abs(numCycles);i++){this._mapTileCycle(0,-1);}}}
JMap.web.Map.prototype._mapTileCycle=function(dx,dy){for(var i=0;i<this.layerManager.activeMapLayers.length;i++){this.layerManager.activeMapLayers[i].mapTileCycle(dx,dy);}
this.xNoLoop-=dx;if(!this.noLoop){this.x=(this.x-dx)%this.getTilesPerMapX();if(this.x<0){this.x=this.getTilesPerMapX()-dx;}}else{this.x=this.xNoLoop;}
this.y+=dy;}
JMap.web.Map.prototype.getLatLonFromScreenPixel=function(x,y){var mapCoords=this.getMapCoordsInPixelSpace();var clickLL=this.getLatLonFromPixel(mapCoords.x+x,mapCoords.y+(this.viewportHeight-y));return{lat:clickLL.lat,lon:clickLL.lon};}
JMap.web.Map.prototype.getMapCoordsInPixelSpace=function(){var mapLayerContainerTop=parseInt(this.mapLayerContainer.style.top,10);var y=((this.y+1)*this.tileSize)+(mapLayerContainerTop);y+=(((this.numTilesY-1)*this.tileSize)-this.viewportHeight);var mapLayerContainerLeft=parseInt(this.mapLayerContainer.style.left,10);var x=((this.x)*this.tileSize)-mapLayerContainerLeft;x=x%(this.getTilesPerMapX()*this.tileSize);return{x:x,y:y};}
JMap.web.Map.prototype.transformPixelToScreenSpace=function(x,y){var mapCoords=this.getMapCoordsInPixelSpace();x=x-mapCoords.x;y=this.viewportHeight-(y-mapCoords.y);var pixelsPerMapX=this.getTilesPerMapX()*this.tileSize;if(pixelsPerMapX<this.viewportWidth){var shiftX=Math.round(Math.floor(this.viewportWidth/pixelsPerMapX)/2);if(mapCoords.x<pixelsPerMapX/2&&Math.round(this.viewportWidth/pixelsPerMapX)==1){shiftX-=1;}
x+=(pixelsPerMapX*shiftX);}
return{x:x,y:y};}
JMap.web.Map.prototype.transformLatLonToScreenSpace=function(lat,lon){var mapCoords=this.getPixelFromLatLon(lat,lon);return this.transformPixelToScreenSpace(mapCoords.x,mapCoords.y);}
JMap.web.Map.prototype.getCenterLatLon=function(){var mapCoords=this.getMapCoordsInPixelSpace();var centerLL=this.getLatLonFromPixel(mapCoords.x+(this.viewportWidth/2),mapCoords.y+(this.viewportHeight/2));if(!this.noLoop){centerLL.lon=(((centerLL.lon+180)%360)-180);}
return{lat:centerLL.lat,lon:centerLL.lon};}
JMap.web.Map.prototype.getLatLonFromPixel=function(x,y){return this.projection.getLatLonFromPixel(x,y);}
JMap.web.Map.prototype.getPixelFromLatLon=function(lat,lon){return this.projection.getPixelFromLatLon(lat,lon);}
JMap.web.Map.prototype.getTilesPerMapX=function(atZoom){return this.projection.getTilesPerMapX(atZoom);}
JMap.web.Map.prototype.getTilesPerMapY=function(atZoom){return this.projection.getTilesPerMapY(atZoom);}
JMap.web.Map.prototype.getScale=function(){var bbox=this.getViewportBoundingBox();var mapCoords=this.getMapCoordsInPixelSpace()
var yHeightInPx=mapCoords.y+this.viewportHeight;var vertScale=(bbox.ymax-bbox.ymin)/(yHeightInPx);var xWidthInPx=mapCoords.x+this.viewportWidth;var horzScale=(bbox.xmax-bbox.xmin)/(xWidthInPx);return((vertScale+horzScale)/2.0);}
JMap.web.Map.prototype.getViewportBoundingBox=function(){var mapCoords=this.getMapCoordsInPixelSpace();var bboxMin=this.getLatLonFromPixel(mapCoords.x,mapCoords.y);var bboxMax=this.getLatLonFromPixel(mapCoords.x+this.viewportWidth,mapCoords.y+this.viewportHeight);if(bboxMax.lon<bboxMin.lon){if(bboxMin.lon<0){bboxMax.lon+=360;}else{bboxMin.lon-=360;}}
return{xmin:bboxMin.lon,ymin:bboxMin.lat,xmax:bboxMax.lon,ymax:bboxMax.lat};}
JMap.web.Map.prototype.getViewportBoundingBoxString=function(){var bbox=this.getViewportBoundingBox();return bbox.xmin+','+bbox.ymin+','+bbox.xmax+','+bbox.ymax;}
JMap.web.Map.prototype.getUnclippedBoundingBox=function(){var mapLayerContainerTop=parseInt(this.mapLayerContainer.style.top,10);var y=((this.y+1)*this.tileSize);y+=(((this.numTilesY-1)*this.tileSize)-(this.tileSize*this.numTilesY));var mapLayerContainerLeft=parseInt(this.mapLayerContainer.style.left,10);var x=((this.x)*this.tileSize)%(this.getTilesPerMapX()*this.tileSize);var bboxMin=this.getLatLonFromPixel(x,y);var bboxMax=this.getLatLonFromPixel(x+(this.tileSize*this.numTilesX),y+(this.tileSize*this.numTilesY));if(bboxMax.lon<bboxMin.lon){if(bboxMin.lon<0){bboxMax.lon+=360;}else{bboxMin.lon-=360;}}
return{xmin:bboxMin.lon,ymin:bboxMin.lat,xmax:bboxMax.lon,ymax:bboxMax.lat};}
JMap.web.Map.prototype.getUnclippedBoundingBoxString=function(){var bbox=this.getUnclippedBoundingBox();return bbox.xmin+","+bbox.ymin+","+bbox.xmax+","+bbox.ymax;}
JMap.web.Map.prototype.kill=function(){this.containerEl.removeChild(this.mapViewport);this.mapViewport.removeChild(this.pane);this.mapViewport.removeChild(this.mapLayerContainer);this.layerManager.kill();if(this.tileManager)this.tileManager.kill();this.tileManager=null;this.pane.oncontextmenu=null;this.pane.onmousedown=null;this.pane.ondblclick=null;document.onmousemove=null;document.onmouseup=null;this.mapLayerContainer=null;this.pane=null;this.mapViewport=null;this.containerEl=null;}
JMap.web.MapServicesFile=function(params){this.url=params.url;this.name=params.name;this.isOnByDefault=params.isOnByDefault;if(this.isOnByDefault==undefined){this.isOnByDefault=true;}
this.isHiddenFromUser=params.isHiddenFromUser;this.onLoad=params.onLoad;var _this=this;new JMap.util.AjaxRequest({method:'GET',url:this.url,paramString:'nocache='+(new Date()).getTime(),onData:function(arg){_this._fileLoaded(arg);}});}
JMap.web.MapServicesFile.prototype._fileLoaded=function(req){var _this=this;var xml=req.getResponseXML();req=null;this.onLoad(xml,_this);}
JMap.web.MapTile=function(params){this.layer=params.layer;this.initX=params.initX;this.initY=params.initY;this.x=(this.initX+this.layer.map.x)%this.layer.map.getTilesPerMapX();this.y=this.initY+this.layer.map.y;this.height=this.layer.map.tileSize-(this.layer.overlapY*-2);this.width=this.layer.map.tileSize-(this.layer.overlapX*-2);this._createHTML();}
JMap.web.MapTile.prototype._createHTML=function(){this.img=document.createElement('img');this.img.src=this.layer.map.blankImage.src;this.img.className='map-tile';this.img.style.width=this.width+'px';this.img.style.height=this.height+'px';this.img.style.left=(this.layer.map.tileSize*this.initX)-this.layer.overlapX+'px';this.img.style.top=(this.layer.map.tileSize*(this.layer.map.numTilesY-1-this.initY))-this.layer.overlapY+'px';this.layer.mapLayer.appendChild(this.img);}
JMap.web.MapTile.prototype.moveBy=function(dx,dy){var curTileX=parseInt(this.img.style.left.split("px")[0],10)+this.layer.overlapX;var curTileY=parseInt(this.img.style.top.split("px")[0],10)+this.layer.overlapY;var newTileX=(curTileX+(dx*this.layer.map.tileSize));var newTileY=(curTileY+(dy*this.layer.map.tileSize));if(newTileX>=(this.layer.map.tileSize*this.layer.map.numTilesX)){newTileX=0;var tx=(this.layer.map.x-dx)%this.layer.map.getTilesPerMapX();if(tx<0){tx=this.layer.map.getTilesPerMapX()-dx;}
this.x-=this.layer.map.numTilesX;if(!this.layer.map.noLoop){if(this.x<0){this.x=tx;}}
this.draw();}else if(newTileX<=-(this.layer.map.tileSize)){newTileX=this.layer.map.tileSize*(this.layer.map.numTilesX-1);this.x+=this.layer.map.numTilesX;if(!this.layer.map.noLoop){if(this.x>=this.layer.map.getTilesPerMapX()){this.x=((this.layer.map.x-(this.layer.map.getTilesPerMapX()))+(this.layer.map.numTilesX));this.x=this.x%this.layer.map.getTilesPerMapX();}}
this.draw();}else if(newTileY>=(this.layer.map.tileSize*this.layer.map.numTilesY)){newTileY=0;this.y+=+this.layer.map.numTilesY;this.draw();}else if(newTileY<=-(this.layer.map.tileSize)){newTileY=this.layer.map.tileSize*(this.layer.map.numTilesY-1);this.y-=+this.layer.map.numTilesY;this.draw();}
this.img.style.left=newTileX-this.layer.overlapX+"px";this.img.style.top=newTileY-this.layer.overlapY+"px";}
JMap.web.MapTile.prototype.syncWithMapCoordinates=function(){this.img.style.left=parseInt((this.layer.map.tileSize*this.initX)-this.layer.overlapX,10)+'px';this.img.style.top=parseInt((this.layer.map.tileSize*(this.layer.map.numTilesY-1-this.initY))-this.layer.overlapY,10)+'px';this.x=this.initX+this.layer.map.x;this.y=this.initY+this.layer.map.y;if(this.x>=this.layer.map.getTilesPerMapX()){this.x-=this.layer.map.getTilesPerMapX();}
this.x=this.x%this.layer.map.getTilesPerMapX();}
JMap.web.MapTile.prototype.clear=function(){this.img.src='../js/scrollable_map/images/blank.gif';}
JMap.web.MapTile.prototype.draw=function(){this.tempX=this.x;if(this.layer.map.noLoop){if(this.x>=this.layer.map.getTilesPerMapX()){this.tempX=((this.layer.map.x-(this.layer.map.getTilesPerMapX()))+(this.layer.map.numTilesX));}else if(this.x<0){this.tempX=this.layer.map.getTilesPerMapX()+this.x;}}
if(!(this.layer.map.isZooming||this.layer.map.isMoving||this.layer.map.isJumping||this.layer.map.dontDraw)){this.clear();if(this.y>=0&&this.y<this.layer.map.getTilesPerMapY()){var src=this.layer.getSourceURL(this.tempX,this.y);this.layer.map.tileManager.loadTile(this,src);}else{this.layer.map.tileManager.loadBlankTile(this);}}}
JMap.web.MapTile.prototype.kill=function(){this.layer.mapLayer.removeChild(this.img);this.img=null;this.layer=null;this.initX=null;this.initY=null;this.x=null;this.y=null;}
JMap.util.sorter=function(t1,t2){if(t1.zdepth<t2.zdepth)return-1;if(t1.zdepth>t2.zdepth)return 1;return 0;}
JMap.util.unselect=function(){if(document.selection)
document.selection.empty();if(window.getSelection)
window.getSelection().removeAllRanges();}
JMap.util.getElementsByClassName=function(node,classname){var a=[];var re=new RegExp('\\b'+classname+'\\b');var els=node.getElementsByTagName("*");for(var i=0,j=els.length;i<j;i++)
if(re.test(els[i].className))a.push(els[i]);return a;}
JMap.util.getRelativeCoords=function(evt,elem){var sx,sy;if(self.pageYOffset){sx=self.pageXOffset;sy=self.pageYOffset;}else if(document.documentElement&&document.documentElement.scrollTop){sx=document.documentElement.scrollLeft;sy=document.documentElement.scrollTop;}else if(document.body){sx=document.body.scrollLeft;sy=document.body.scrollTop;}
var x=evt.clientX-JMap.util.findPosX(elem)+sx;var y=evt.clientY-JMap.util.findPosY(elem)+sy;return{x:x,y:y};}
JMap.util.findPosX=function(obj)
{var curleft=0;if(obj.offsetParent){while(obj.offsetParent){curleft+=obj.offsetLeft
obj=obj.offsetParent;}}
else if(obj.x){curleft+=obj.x;}
return curleft;}
JMap.util.findPosY=function(obj){var curtop=0;if(obj.offsetParent){while(obj.offsetParent){curtop+=obj.offsetTop
obj=obj.offsetParent;}}
else if(obj.y){curtop+=obj.y;}
return curtop;}
JMap.util.getWindowDimensions=function(){var width=0;var height=0;if(window.innerWidth){width=window.innerWidth;}else{width=document.documentElement.clientWidth;}
if(window.innerHeight){height=window.innerHeight;}else{height=document.documentElement.clientHeight;}
return{width:width-2,height:height-2};}
JMap.util.getNodeValue=function(node,tagname,default_val){var elems=node.getElementsByTagName(tagname);if(elems&&elems[0]&&elems[0].firstChild&&elems[0].firstChild.nodeValue){return elems[0].firstChild.nodeValue;}
return default_val;}
JMap.util.clone=function(obj){var c={};for(var x in obj){c[x]=obj[x];}
return c;}
JMap.util.pad=function(str,len,pad,dir){var STR_PAD_LEFT=1;var STR_PAD_RIGHT=2;var STR_PAD_BOTH=3;if(typeof(len)=="undefined"){var len=0;}
if(typeof(pad)=="undefined"){var pad=' ';}
if(typeof(dir)=="undefined"){var dir=STR_PAD_RIGHT;}
if(len+1>=str.length){switch(dir){case STR_PAD_LEFT:str=Array(len+1-str.length).join(pad)+str;break;case STR_PAD_BOTH:var right=Math.ceil((padlen=len-str.length)/2);var left=padlen-right;str=Array(left+1).join(pad)+str+Array(right+1).join(pad);break;default:str=str+Array(len+1-str.length).join(pad);break;}}
return str;}
JMap.projection.Mercator=function(map){this.map=map;}
JMap.projection.Mercator.prototype.getLatLonFromPixel=function(x,y){return{lon:this.getLonFromX(x),lat:this.getLatFromY(y)};}
JMap.projection.Mercator.prototype.getLatFromY=function(y,atZoom){var yRatio=(y-((this.map.getTilesPerMapY()*this.map.tileSize)/2))/(this.map.getTilesPerMapY(atZoom)*this.map.tileSize);var yRad=(2*Math.PI)*yRatio;var lat=((2*Math.atan(Math.exp(yRad)))-(Math.PI/2))*(180/Math.PI);return lat;}
JMap.projection.Mercator.prototype.getLonFromX=function(x,atZoom){return(x*((360/this.map.tileSize)/this.getTilesPerMapX(atZoom)))-180;}
JMap.projection.Mercator.prototype.getPixelFromLatLon=function(lat,lon,atZoom){return{x:this.getXFromLon(lon,atZoom),y:this.getYFromLat(lat,atZoom)};}
JMap.projection.Mercator.prototype.getXFromLon=function(lon,atZoom){return((lon+180)/360)*(this.map.getTilesPerMapX(atZoom)*this.map.tileSize);}
JMap.projection.Mercator.prototype.getYFromLat=function(lat,atZoom){var latRad=(lat+90)*(Math.PI/180);var radY=Math.log(Math.tan((latRad/2)))+Math.PI;var radRat=radY/(2*Math.PI);var y=(this.map.getTilesPerMapY(atZoom)*this.map.tileSize)*radRat;return y;}
JMap.projection.Mercator.prototype.getTilesPerMapX=function(atZoom){atZoom=atZoom||this.map.zoom;return Math.pow(2,atZoom);}
JMap.projection.Mercator.prototype.getTilesPerMapY=function(atZoom){atZoom=atZoom||this.map.zoom;return Math.pow(2,atZoom);}
JMap.web.mapLayer.OpenStreetMapsLayer=function(params){this.format='png';JMap.web.mapLayer.Layer.call(this,params);}
JMap.web.mapLayer.OpenStreetMapsLayer.prototype=new JMap.web.mapLayer.Layer();JMap.web.mapLayer.OpenStreetMapsLayer.prototype.getSourceURL=function(x,y){var src=this.baseUrl+'/'+this.map.zoom+'/'+x+'/'+(this.map.getTilesPerMapY()-y-1)+'.'+this.format;return src;}
JMap.hud.OverviewMap=function(pHUD,params){var _this=this;this.HUD=pHUD;if(!params.containerEl){this._createHTML((params.mapWidthPx||150),(params.mapHeightPx||150));}else{this.containerEl=document.getElementById(params.containerEl);}
this.autoPanInterval;this.overviewMap=new JMap.web.Map({parentMap:this.HUD.map,containerEl:this.containerEl.id,centerLat:this.HUD.map.centerLatLon.lat,centerLon:this.HUD.map.centerLatLon.lon,validBBox:this.HUD.map.tempValidBBox,numTilesX:(params.numTilesX||3),numTilesY:(params.numTilesY||3),tileSize:(params.tileSize||256),projection:this.HUD.map.projection,border:(!params.containerEl),layersFile:(params.layersFile),mapWidthPx:(params.mapWidthPx||150),mapHeightPx:(params.mapHeightPx||150),listeners:{onDrop:function(){_this.syncParentMap()}}});if(!params.containerEl){this.minMax=document.createElement('div');this.minMax.className='hud-overview-minmax-open';this.minMax.onclick=function(){_this.toggleOverviewMap();};this.containerEl.appendChild(this.minMax);}
this.pan=document.createElement('div');this.pan.className='hud-pan-controller';this.panBackground=document.createElement('div');this.panBackground.className='hud-pan-background';this.pan.appendChild(this.panBackground);this.pan.onmousedown=function(event){return _this._startDrag(event);};this.overviewMap.mapViewport.appendChild(this.pan);}
JMap.hud.OverviewMap.prototype._createHTML=function(mapWidth,mapHeight){var numOverviews=JMap.util.getElementsByClassName(document,'overview-map');if(numOverviews){numOverviews=numOverviews.length;}else{numOverviews=0;}
this.containerEl=document.createElement('div');this.containerEl.className='hud-overview-map';this.containerEl.id='hud-overview-map-'+numOverviews;this.containerEl.style.width=mapWidth+'px';this.containerEl.style.height=mapHeight+'px';this.HUD.map.mapViewport.appendChild(this.containerEl);}
JMap.hud.OverviewMap.prototype.update=function(){var center=this.HUD.map.getCenterLatLon();this.overviewMap.moveTo(center.lat,center.lon);this.overviewMap.centerLatLon=center;var bbox=this.HUD.map.getViewportBoundingBox();var topleft=this.overviewMap.transformLatLonToScreenSpace(bbox.ymax,bbox.xmin);var bottomright=this.overviewMap.transformLatLonToScreenSpace(bbox.ymin,bbox.xmax);var overviewCoords=this.overviewMap.getMapCoordsInPixelSpace();this.pan.style.width=(bottomright.x-topleft.x)+'px';this.pan.style.left=topleft.x+'px';this.pan.style.height=bottomright.y-topleft.y+'px';this.pan.style.top=topleft.y+'px';if(((bottomright.x-topleft.x)<(this.overviewMap.viewportWidth*(3/10))&&this.HUD.map.viewportWidth>=this.HUD.map.viewportHeight)||((bottomright.y-topleft.y)<(this.overviewMap.viewportHeight*(3/10))&&this.HUD.map.viewportWidth<this.HUD.map.viewportHeight)){this.overviewMap.zoomIn();}else{if(((bottomright.x-topleft.x)>=(this.overviewMap.viewportWidth*(6/10))&&this.HUD.map.viewportWidth>=this.HUD.map.viewportHeight)||((bottomright.y-topleft.y)>=(this.overviewMap.viewportHeight*(6/10))&&this.HUD.map.viewportWidth<this.HUD.map.viewportHeight)){if(this.overviewMap.zoom>this.overviewMap.minZoom){this.overviewMap.zoomOut();}else{this.pan.style.display='none';}}else{this.pan.style.display='block';if(bottomright.x>(this.overviewMap.getTilesPerMapX()*this.overviewMap.tileSize)){topleft.x-=(this.overviewMap.getTilesPerMapX()*this.overviewMap.tileSize);}else if(topleft.x<0){topleft.x+=(this.overviewMap.getTilesPerMapX()*this.overviewMap.tileSize);}
this.pan.style.left=topleft.x+'px';this.pan.style.top=topleft.y+'px';}}}
JMap.hud.OverviewMap.prototype.syncParentMap=function(){var center=this.overviewMap.getCenterLatLon();this.overviewMap.dontDraw=true;this.HUD.map.moveTo(center.lat,center.lon);this.overviewMap.dontDraw=false;this.HUD.map.centerLatLon=center;}
JMap.hud.OverviewMap.prototype.toggleOverviewMap=function(){if(this.minMax.className=='hud-overview-minmax-open'){this.minimize();}else{this.maximize();}}
JMap.hud.OverviewMap.prototype.minimize=function(){this.minMax.className='hud-overview-minmax-close';this.containerEl.style.width='15px';this.containerEl.style.height='15px';this.containerEl.style.paddingTop='0em';this.containerEl.style.paddingLeft='0em';}
JMap.hud.OverviewMap.prototype.maximize=function(){this.minMax.className='hud-overview-minmax-open';this.containerEl.style.width=this.overviewMap.viewportWidth+'px';this.containerEl.style.height=this.overviewMap.viewportHeight+'px';this.containerEl.style.paddingTop='0.3em';this.containerEl.style.paddingLeft='0.3em';}
JMap.hud.OverviewMap.prototype._startDrag=function(event){var _this=this;event=event||window.event;this.lastMouseX=event.clientX;this.lastMouseY=event.clientY;this.validX=this.lastMouseX;this.validY=this.lastMouseY;this.startDragAt=event.clientX+':'+event.clientY;document.onmousemove=function(event){return _this._drag(event);};document.onmouseup=function(event){return _this._endDrag(event);};return false;}
JMap.hud.OverviewMap.prototype._drag=function(event){event=event||window.event;if(navigator.appVersion.indexOf("MSIE")!=-1)JMap.util.unselect();var currentMouseX=event.clientX;var currentMouseY=event.clientY;var dx=currentMouseX-this.lastMouseX;var dy=currentMouseY-this.lastMouseY;var panLeft=parseFloat(this.pan.style.left.split('px')[0],10);var panTop=parseFloat(this.pan.style.top.split('px')[0],10);var panWidth=parseFloat(this.pan.style.width.split('px')[0],10);var panHeight=parseFloat(this.pan.style.height.split('px')[0],10);var xMinLoc=panLeft+dx;var yMinLoc=panTop+dy;var xMaxLoc=xMinLoc+panWidth;var yMaxLoc=yMinLoc+panHeight;this.pan.style.left=xMinLoc+'px';this.pan.style.top=yMinLoc+'px';this.lastMouseX=currentMouseX;this.lastMouseY=currentMouseY;if(xMinLoc<0||yMinLoc<0||xMaxLoc>this.overviewMap.viewportWidth||yMaxLoc>this.overviewMap.viewportHeight){var _this=this;clearInterval(this.autoPanInterval);this.autoPanInterval=setInterval(function(){_this._autoPan();},10);}else{clearInterval(this.autoPanInterval);}
return false;}
JMap.hud.OverviewMap.prototype._endDrag=function(event){event=event||window.event;document.onmousemove=null;document.onmouseup=null;clearInterval(this.autoPanInterval);if(this.startDragAt!=event.clientX+':'+event.clientY){var panLeft=parseFloat(this.pan.style.left.split('px')[0],10);var panTop=parseFloat(this.pan.style.top.split('px')[0],10);var panWidth=parseFloat(this.pan.style.width.split('px')[0],10);var panHeight=parseFloat(this.pan.style.height.split('px')[0],10);var overviewCoords=this.overviewMap.getMapCoordsInPixelSpace();var panCenterX=panLeft+(panWidth/2);var panCenterY=this.overviewMap.viewportHeight-(panTop+(panHeight/2));var centerLatLon=this.overviewMap.getLatLonFromPixel(overviewCoords.x+panCenterX,overviewCoords.y+panCenterY);if(this.overviewMap.validBBox){if(centerLatLon.lon<this.overviewMap.validBBox.xmin){centerLatLon.lon=this.overviewMap.validBBox.xmin;}else if(centerLatLon.lon>this.overviewMap.validBBox.xmax){centerLatLon.lon=this.overviewMap.validBBox.xmax;}}
this.HUD.map.moveTo(centerLatLon.lat,centerLatLon.lon);this.HUD.map.centerLatLon=centerLatLon;this.HUD.map.draw();}
return false;}
JMap.hud.OverviewMap.prototype._autoPan=function(){var panLeft=parseFloat(this.pan.style.left.split('px')[0],10);var panTop=parseFloat(this.pan.style.top.split('px')[0],10);var panWidth=parseFloat(this.pan.style.width.split('px')[0],10);var panHeight=parseFloat(this.pan.style.height.split('px')[0],10);var xMinLoc=panLeft;var yMinLoc=panTop;var xMaxLoc=xMinLoc+panWidth;var yMaxLoc=yMinLoc+panHeight;var panCenterX=panLeft+(panWidth/2);var panCenterY=panTop+(panHeight/2);var centerLatLon=this.overviewMap.getLatLonFromPixel(panCenterX,panCenterY,true);var dx=0;if(xMinLoc<0){dx=1;}else if(xMaxLoc>this.overviewMap.viewportWidth){dx=-1;}
var dy=0;if(yMinLoc<0){dy=1;}else if(yMaxLoc>this.overviewMap.viewportHeight){dy=-1;}
this.overviewMap.moveBy(dx,dy);this.overviewMap._testSnapBack();}
JMap.hud.OverviewMap.prototype.kill=function(){this.pan.onmousedown=null;this.overviewMap.mapViewport.removeChild(this.pan);this.pan=null;if(this.minMax){this.minMax.onclick=null;this.HUD.map.mapViewport.removeChild(this.containerEl);}
this.overviewMap.kill();}
JMap.projection.PlateCarree=function(map){this.map=map;}
JMap.projection.PlateCarree.prototype.getLatLonFromPixel=function(x,y,atZoom){return{lon:this.getLonFromX(x,atZoom),lat:this.getLatFromY(y,atZoom)};}
JMap.projection.PlateCarree.prototype.getLatFromY=function(y,atZoom){return(y*((180/this.map.tileSize)/this.getTilesPerMapY(atZoom)))-90;}
JMap.projection.PlateCarree.prototype.getLonFromX=function(x,atZoom){return(x*((360/this.map.tileSize)/this.getTilesPerMapX(atZoom)))-180;}
JMap.projection.PlateCarree.prototype.getPixelFromLatLon=function(lat,lon,atZoom){return{x:this.getXFromLon(lon,atZoom),y:this.getYFromLat(lat,atZoom)};}
JMap.projection.PlateCarree.prototype.getXFromLon=function(lon,atZoom){return((lon+180)/360)*(this.map.getTilesPerMapX(atZoom)*this.map.tileSize);}
JMap.projection.PlateCarree.prototype.getYFromLat=function(lat,atZoom){return((lat+90)/180)*(this.map.getTilesPerMapY(atZoom)*this.map.tileSize);}
JMap.projection.PlateCarree.prototype.getTilesPerMapX=function(atZoom){atZoom=atZoom||this.map.zoom;return Math.pow(2,(atZoom+1));}
JMap.projection.PlateCarree.prototype.getTilesPerMapY=function(atZoom){atZoom=atZoom||this.map.zoom;return Math.pow(2,atZoom);}
JMap.svg.Polygon=function(params){JMap.svg.Path.call(this,params);this.points=params.points;}
JMap.svg.Polygon.prototype=new JMap.svg.Path();JMap.svg.Polygon.prototype.createSVG=function(){if(!this.SVGManager.isIE){this.shape=document.createElementNS('http://www.w3.org/2000/svg','path');}else{this.shape=document.createElement('v:shape');this.shape.setAttribute('stroked',true);this.shape.setAttribute('filled',true);this.shape.style.height=(3*this.SVGManager.map.viewportHeight)+'px';this.shape.style.width=(3*this.SVGManager.map.viewportWidth)+'px';this.shape.style.left=(-this.SVGManager.map.viewportWidth+'px');this.shape.style.top=(-this.SVGManager.map.viewportHeight+'px');this.shape.setAttribute('coordorigin',(-this.SVGManager.map.viewportWidth)+','+-this.SVGManager.map.viewportHeight);this.shape.setAttribute('coordsize',(3*this.SVGManager.map.viewportWidth)+','+(3*this.SVGManager.map.viewportHeight));}
this.draw();JMap.svg.Path.prototype.createSVG.call(this);this.SVGManager.canvas.appendChild(this.shape);}
JMap.svg.Polygon.prototype.draw=function(){var translatedPoints=this.translatePointsToMapSpace(this.points);if(!this.SVGManager.isIE){this.shape.setAttribute('d','M'+translatedPoints[0]+','+translatedPoints[1]+' L'+translatedPoints.join(' ')+' Z');}else{this.shape.setAttribute('path','m '+translatedPoints[0]+','+translatedPoints[1]+' l '+translatedPoints.join()+' x e');}}
document.write('<!--[if IE]> '+'<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v"/>'+'<style type="text/css">'+'v\\:* { behavior: url(#default#VML);}'+'</style>     '+'<![endif]-->  ');JMap.svg.SVGManager=function(map){this.isIE=(navigator.appName=='Microsoft Internet Explorer');this.propertyEnum=[];if(this.isIE){this.propertyEnum['stroke']='strokecolor';this.propertyEnum['fill']='fillcolor';this.propertyEnum['stroke-width']='strokeweight';}else{this.propertyEnum['stroke']='stroke';this.propertyEnum['fill']='fill';this.propertyEnum['stroke-width']='stroke-width';}
this.map=map;this.x=-this.map.viewportWidth;this.y=-this.map.viewportHeight;this.shapes=[];this._createHTML();}
JMap.svg.SVGManager.prototype._createHTML=function(){this.width=this.map.viewportWidth*3;this.height=this.map.viewportHeight*3;if(!this.isIE){this.canvas=document.createElementNS('http://www.w3.org/2000/svg','svg');this.canvas.setAttribute('width',(this.width+1));this.canvas.setAttribute('height',(this.height+1));this.canvas.setAttribute('viewBox',(this.x-0.5)+' '+(this.y-0.5)+' '+(this.width+1)+' '+(this.height+1));this.canvas.setAttribute('preserveAspectRatio',"xMidYMid slice");this.canvas.style.position='absolute';this.canvas.style.top=this.y+'px';this.canvas.style.left=this.x+'px';}else{this.canvas=document.createElement('v:group');this.canvas.style.width=this.width+'px';this.canvas.style.height=this.height+'px';this.canvas.style.top=this.y+'px';this.canvas.style.left=this.x+'px';this.canvas.style.position='absolute';this.canvas.setAttribute('coordsize',this.width+' '+this.height);this.canvas.setAttribute('coordorigin',this.x+', '+this.y);}
this.map.pane.appendChild(this.canvas);this.draw();}
JMap.svg.SVGManager.prototype.update=function(){this.width=this.map.viewportWidth*3;this.height=this.map.viewportHeight*3;var canvasTop=parseInt(this.canvas.style.top.split('px')[0],10);var canvasLeft=parseInt(this.canvas.style.left.split('px')[0],10);this.x-=(canvasLeft+this.map.viewportWidth);this.y-=(canvasTop+this.map.viewportHeight);this.canvas.style.visibility='hidden';if(!this.isIE){this.canvas.setAttribute('viewBox',(this.x-0.5)+' '+(this.y-0.5)+' '+(this.width+1)+' '+(this.height+1));this.canvas.setAttribute('width',(this.width+1));this.canvas.setAttribute('height',(this.height+1));}else{this.canvas.setAttribute('coordorigin',this.x+', '+this.y);this.canvas.setAttribute('coordsize',this.width+' '+this.height);this.canvas.style.width=this.width+'px';this.canvas.style.height=this.height+'px';}
this.canvas.style.top=-this.map.viewportHeight+'px';this.canvas.style.left=-this.map.viewportWidth+'px';this.canvas.style.visibility='visible';}
JMap.svg.SVGManager.prototype.updateOnZoom=function(){this.x=-this.map.viewportWidth;this.y=-this.map.viewportHeight;this.canvas.style.visibility='hidden';if(!this.isIE){this.canvas.setAttribute('viewBox',(this.x-0.5)+' '+(this.y-0.5)+' '+(this.width+1)+' '+(this.height+1));}else{this.canvas.setAttribute('coordorigin',this.x+', '+this.y);this.canvas.setAttribute('coordsize',this.width+' '+this.height);}
this.canvas.style.top=-this.map.viewportHeight+'px';this.canvas.style.left=-this.map.viewportWidth+'px';this.draw();this.canvas.style.visibility='visible';}
JMap.svg.SVGManager.prototype.draw=function(){for(var i=0;i<this.shapes.length;i++){this.shapes[i].draw();}}
JMap.svg.SVGManager.prototype.moveBy=function(dx,dy){var canvasTop=parseInt(this.canvas.style.top.split('px')[0],10);var canvasLeft=parseInt(this.canvas.style.left.split('px')[0],10);this.canvas.style.top=(canvasTop+dy)+'px';this.canvas.style.left=(canvasLeft+dx)+'px';}
JMap.svg.SVGManager.prototype.addShape=function(shape){shape.SVGManager=this;this.shapes.push(shape);shape.createSVG();}
JMap.svg.SVGManager.prototype.removeShape=function(shape){for(var i=0;i<this.shapes.length;i++){if(this.shapes[i]==shape){this.shapes.splice(i,1);break;}}
shape.kill();}
JMap.svg.SVGManager.prototype.removeAllShapes=function(){for(var i=0;i<this.shapes.length;i++){this.shapes[i].kill();}
this.shapes=[];}
JMap.svg.SVGManager.prototype.kill=function(){}
JMap.hud.ScaleRake=function(pHUD){this.HUD=pHUD;this._createHTML();this.update();}
JMap.hud.ScaleRake.prototype._createHTML=function(){var sb=document.createElement("div");sb.className='hud-scale-bars';this.HUDScaleRakeDiv=sb;var sbm=document.createElement('div');sbm.className='hud-scale-bar-mi'
sb.appendChild(sbm);this.HUDScaleRakeMI=sbm;var sbk=document.createElement('div');sbk.className='hud-scale-bar-km';sb.appendChild(sbk);this.HUDScaleRakeKM=sbk;this.HUD.map.mapViewport.appendChild(this.HUDScaleRakeDiv);}
JMap.hud.ScaleRake.prototype.update=function(){this.scale('mi');this.scale('km');}
JMap.hud.ScaleRake.prototype.scale=function(units){var mapCoordY=this.HUD.map.getMapCoordsInPixelSpace().y;var baseScaleLat=this.HUD.map.projection.getLatFromY(mapCoordY+(this.HUD.map.viewportHeight/2));var degPerPxLon=((360/this.HUD.map.tileSize)/this.HUD.map.projection.getTilesPerMapX());var unitFactor=3963.0;var distanceUnit=" mi.";if(units=='km'){unitFactor=6377.0;distanceUnit=" km.";}
var rad=180/Math.PI;var barInDeg=60*degPerPxLon;var scale=unitFactor*Math.acos(Math.sin(baseScaleLat/rad)*Math.sin(baseScaleLat/rad)+
Math.cos(baseScaleLat/rad)*Math.cos(baseScaleLat/rad)*Math.cos((barInDeg/rad)-(0/rad)));var barScale=500;if(scale>=5000){barScale=10000;}else if(scale>=2500){barScale=5000;}else if(scale>=1000){barScale=2500;}else if(scale>=500){barScale=1000;}else if(scale>=250){barScale=500;}else if(scale>=100){barScale=250;}else if(scale>=50){barScale=100;}else if(scale>=25){barScale=50;}else if(scale>=10){barScale=25;}else if(scale>=5){barScale=10;}else if(scale>=2){barScale=5;}else if(scale>=1){barScale=2;}else if(scale>=0.5){barScale=1;}else{if(units=='mi'){distanceUnit=" ft.";}else{distanceUnit=" m.";}
if(scale>=0.2){barScale=0.5;}else if(scale>=0.1){barScale=0.25;}else if(scale>=0.05){barScale=0.1;}else if(scale>=0.025){barScale=0.05;}else if(scale>=0.01){barScale=0.025;}else if(scale>=0.005){barScale=0.01;}else if(scale>=0.0025){barScale=0.005;}else{barScale=0.005;}}
var barLength=rad*(Math.acos((Math.cos(barScale/unitFactor)-(Math.sin(baseScaleLat/rad)*Math.sin(baseScaleLat/rad)))/(Math.cos(baseScaleLat/rad)*Math.cos(baseScaleLat/rad))))/degPerPxLon;if(distanceUnit==" ft."){barScale*=5280;}
if(distanceUnit==" m."){barScale*=1000;}
if(units=='mi'){this.HUDScaleRakeMI.innerHTML=parseInt(barScale,10)+""+distanceUnit;this.HUDScaleRakeMI.style.width=(Math.floor(barLength)||'0')+'px';}else{this.HUDScaleRakeKM.innerHTML=parseInt(barScale,10)+""+distanceUnit;this.HUDScaleRakeKM.style.width=(Math.floor(barLength)||'0')+'px';}}
JMap.hud.ScaleRake.prototype.kill=function(){this.HUD.map.mapViewport.removeChild(this.HUDScaleRakeDiv);this.HUDScaleRakeDiv=null;}
JMap.web.mapLayer.TMSLayer=function(params){this.format='PNG';JMap.web.mapLayer.Layer.call(this,params);}
JMap.web.mapLayer.TMSLayer.prototype=new JMap.web.mapLayer.Layer();JMap.web.mapLayer.TMSLayer.prototype.getSourceURL=function(x,y){var tempBase='';if(this.serverIndex!=undefined){this.serverIndex=(x*y)%this.baseUrls.length;tempBase=this.baseUrls[this.serverIndex];}else{tempBase=this.baseUrl;}
var tx=JMap.util.pad(''+(x%this.map.getTilesPerMapX()),9,'0',1);var ty=JMap.util.pad(''+y,9,'0',1);var x10e8=tx.substring(0,3);var x10e5=tx.substring(3,6);var x10e2=tx.substring(6,9);var y10e8=ty.substring(0,3);var y10e5=ty.substring(3,6);var y10e2=ty.substring(6,9);var z=JMap.util.pad(''+this.map.zoom,2,'0',1);var src=tempBase+z+'/'+x10e8+'/'+x10e5+'/'+x10e2+'/'+y10e8+'/'+y10e5+'/'+y10e2+'.'+this.format;return src;}
JMap.web.tile.TileCache=function(manager){this.cache={};this.tempCache={};this.manager=manager;}
JMap.web.tile.TileCache.prototype.addTile=function(src,imageElement){var _this=this;this.manager.startLoadingImage();var image=document.createElement('img');imageElement.loading=true;image.imageElement=imageElement;image.onload=function(event){_this.onload(event,this);}
image.src=src;this.tempCache[src]=image;return this.tempCache[src];}
JMap.web.tile.TileCache.prototype.getTile=function(src){if(this.cache[src]){return this.cache[src];}else{return false;}}
JMap.web.tile.TileCache.prototype.onerror=function(event,image){}
JMap.web.tile.TileCache.prototype.onabort=function(event,image){}
JMap.web.tile.TileCache.prototype.cancelAllLoads=function(){for(var i in this.cache){if(this.cache[i]&&this.cache[i].onload!=null){this.cache[i].onload=null;this.cache[i].imageElement=null;delete this.cache[i];}}}
JMap.web.tile.TileCache.prototype.onload=function(event,image){this.manager.endLoadingImage();this.cache[image.src]=this.tempCache[image.src];image.imageElement.src=image.src;image.onload=null;image.imageElement.loading=null;delete this.tempCache[image.src];}
JMap.web.tile.TileCache.prototype.kill=function(){for(var i in this.cache){if(this.cache[i]){this.cache[i].imageElement=null;this.cache[i].onload=null;this.cache[i].onerror=null;this.cache[i].onabort=null;delete this.cache[i];}}
this.cache=null}
JMap.web.tile.TileLoader=function(manager){this.image=document.createElement('img');this.manager=manager;}
JMap.web.tile.TileLoader.prototype.loadTile=function(src,imageElement){var _this=this;this.manager.startLoadingImage();this.image.onload=null;this.image.imageElement=imageElement;this.image.onload=function(event){_this.onload(event,this);}
this.image.src=src;return this.image;}
JMap.web.tile.TileLoader.prototype.onload=function(event,image){this.manager.endLoadingImage();image.imageElement.src=image.src;image.imageElement.loading=null;image.onload=null;}
JMap.web.tile.TileLoader.prototype.onerror=function(event,image){}
JMap.web.tile.TileLoader.prototype.onabort=function(event,image){}
JMap.web.tile.TileLoader.prototype.kill=function(){if(this.image&&this.image.onload){this.image.onload=null;}
this.image=null;}
JMap.web.TileManager=function(params){this.numImagesLoading=0;this.map=params.map;this.cachingOn=params.cachingOn;this.onStartLoadingImages=params.onStartLoadingImages;this.onEndLoadingImages=params.onEndLoadingImages;if(this.cachingOn&&navigator.appName.indexOf("Microsoft Internet Explorer")==-1){this.tileCache=new JMap.web.tile.TileCache(this);}}
JMap.web.TileManager.prototype.startLoadingImage=function(){if(this.imageLoadingTimeout){clearTimeout(this.imageLoadingTimeout);}
this.numImagesLoading++;if(this.numImagesLoading==1){this.onStartLoadingImages();}
var _this=this;this.imageLoadingTimeout=setTimeout(function(){_this.numImagesLoading=0;_this.onEndLoadingImages();},5000);}
JMap.web.TileManager.prototype.endLoadingImage=function(){if(this.imageLoadingTimeout){clearTimeout(this.imageLoadingTimeout);}
this.numImagesLoading--;if(this.numImagesLoading<=0){this.numImagesLoading=0;this.onEndLoadingImages();}
var _this=this;this.imageLoadingTimeout=setTimeout(function(){_this.numImagesLoading=0;_this.onEndLoadingImages();},5000);}
JMap.web.TileManager.prototype.loadTile=function(tile,src){if(this.tileCache&&tile.layer.map.cacheTiles&&tile.layer.cacheLayer){if(tile.cachedImage){tile.cachedImage.onload=null;}
var cachedTile=this.tileCache.getTile(src);if(!cachedTile){tile.cachedImage=this.tileCache.addTile(src,tile.img);}else{tile.img.src=cachedTile.src;}}else{if(tile.tileLoader){tile.tileLoader.kill();}
tile.tileLoader=new JMap.web.tile.TileLoader(this);tile.tileLoader.loadTile(src,tile.img);}}
JMap.web.TileManager.prototype.cancelAllLoads=function(){if(this.tileCache){this.tileCache.cancelAllLoads();}
this.numImagesLoading=0;this.endLoadingImage();}
JMap.web.TileManager.prototype.loadBlankTile=function(tile){if(tile.cachedImage){tile.cachedImage.onload=null;}else if(tile.tileLoader){tile.tileLoader.kill();}
tile.img.src=tile.layer.map.blankImage.src;}
JMap.web.TileManager.prototype.kill=function(){if(this.tileCache){this.tileCache.kill();}}
JMap.util.Tools.zoomOut=function(event,map){var c=JMap.util.getRelativeCoords(event,map.pane);var clickLL=map.getLatLonFromScreenPixel(c.x,c.y);map.zoomOut();map.moveTo(clickLL.lat,clickLL.lon);}
JMap.util.Tools.zoomOut.cursor='cursor-zoom-out';JMap.util.Tools.zoomIn=function(event,map){var zoomInBBox=new JMap.util.Tools.zoomIn._ZoomInBBox(event,map);}
JMap.util.Tools.zoomIn.cursor='cursor-zoom-in';JMap.util.Tools.zoomIn._ZoomInBBox=function(event,map){this.map=map;var mapPixelCoords=JMap.util.getRelativeCoords(event,this.map.pane);var _this=this;this.startDragX=mapPixelCoords.x;this.startDragY=mapPixelCoords.y;document.onmousemove=function(event){return _this._ZoomInDrag(event);}
document.onmouseup=function(event){return _this._ZoomInEndDrag(event);}
this.bbox=document.createElement('div');this.bbox.className='tools-zoom-bbox';this.bbox.style.display='none';this.map.pane.appendChild(this.bbox);}
JMap.util.Tools.zoomIn._ZoomInBBox.prototype._ZoomInDrag=function(event){JMap.util.unselect();this.bbox.style.display='block';event=event||window.event;var mapScreenPixelCoords=JMap.util.getRelativeCoords(event,this.map.pane);var dx=mapScreenPixelCoords.x-this.startDragX;if(dx<0){dx=-dx;this.bbox.style.left=mapScreenPixelCoords.x+'px';}else{this.bbox.style.left=this.startDragX+'px';}
this.bbox.style.width=dx+'px';var dy=mapScreenPixelCoords.y-this.startDragY;if(dy<0){dy=-dy;this.bbox.style.top=mapScreenPixelCoords.y+'px';}else{this.bbox.style.top=this.startDragY+'px';}
this.bbox.style.height=dy+'px';return false;}
JMap.util.Tools.zoomIn._ZoomInBBox.prototype._ZoomInEndDrag=function(event){var mapCoords=this.map.getMapCoordsInPixelSpace();event=event||window.event;var mapPixelCoords=JMap.util.getRelativeCoords(event,this.map.pane);var dragBBoxWidth=parseInt(this.bbox.style.width.split('px')[0]);if(isNaN(dragBBoxWidth))dragBBoxWidth=0;var dragBBoxHeight=parseInt(this.bbox.style.height.split('px')[0]);if(isNaN(dragBBoxHeight))dragBBoxHeight=0;var dragBBoxTop=parseInt(this.bbox.style.top.split('px')[0]);if(dragBBoxTop<0)dragBBoxTop=0;var dragBBoxLeft=parseInt(this.bbox.style.left.split('px')[0]);if(dragBBoxLeft<0)dragBBoxLeft=0;var dragBBoxBottom=(dragBBoxTop+dragBBoxHeight);if(dragBBoxBottom>this.map.viewportHeight)dragBBoxBottom=this.map.viewportHeight;var dragBBoxRight=dragBBoxLeft+dragBBoxWidth;if(dragBBoxRight>this.map.viewportWidth)dragBBoxRight=this.map.viewportWidth;if(dragBBoxHeight<=10||dragBBoxWidth<=10){this.map.pane.removeChild(this.bbox);var clickLL=this.map.getLatLonFromPixel(mapCoords.x+mapPixelCoords.x,mapCoords.y+(this.map.viewportHeight-mapPixelCoords.y));clickLL.lon=(((clickLL.lon+180)%360)-180);this.map.moveTo(clickLL.lat,clickLL.lon);this.map.zoomIn();}else{var minLL=this.map.getLatLonFromPixel(mapCoords.x+dragBBoxLeft,mapCoords.y+(this.map.viewportHeight-dragBBoxBottom));var maxLL=this.map.getLatLonFromPixel(mapCoords.x+dragBBoxRight,mapCoords.y+(this.map.viewportHeight-dragBBoxTop));this.map.pane.removeChild(this.bbox);minLL.lon=(((minLL.lon+180)%360)-180);maxLL.lon=(((maxLL.lon+180)%360)-180);this.map.fitToBBox(minLL.lon,minLL.lat,maxLL.lon,maxLL.lat);}
this.map=null;this.bbox=null;document.onmousemove=null;document.onmouseup=null;return false;}
JMap.util.Tools.debug=function(event,map){console.log(map.getScale());}
JMap.web.mapLayer.WMSLayer=function(params){this.format='image/png';this.request='GetMap';JMap.web.mapLayer.Layer.call(this,params);}
JMap.web.mapLayer.WMSLayer.prototype=new JMap.web.mapLayer.Layer();JMap.web.mapLayer.WMSLayer.prototype.getSourceURL=function(x,y){var src=this.baseUrl;if(src.indexOf('?')==-1){src+='?';}else if(src.indexOf('?')!=src.length-1){src+='&';}
var xmin=this.map.projection.getLonFromX(((x)*this.map.tileSize)-this.overlapX);var xmax=this.map.projection.getLonFromX(((x+1)*this.map.tileSize)+this.overlapX);var ymin=this.map.projection.getLatFromY(((y)*this.map.tileSize)-this.overlapY);var ymax=this.map.projection.getLatFromY(((y+1)*this.map.tileSize)+this.overlapY);src+='request='+this.request;src+='&srs=EPSG:'+this.srs;src+='&version='+this.version;src+='&layers='+this.layersUrlParam;src+="&BBOX="+xmin+","+ymin+","+xmax+","+ymax;src+="&width="+(this.map.tileSize-(this.overlapX*-2));src+="&height="+(this.map.tileSize-(this.overlapY*-2));src+='&transparent=true';src+='&format='+this.format;if(this.sld)src+='&sld='+this.sld;if(this.customParams){for(var x in this.customParams){src+='&'+x+'='+this.customParams[x];}}
return src;}
JMap.web.mapLayer.YahooMapsLayer=function(params){JMap.web.mapLayer.Layer.call(this,params);}
JMap.web.mapLayer.YahooMapsLayer.prototype=new JMap.web.mapLayer.Layer();JMap.web.mapLayer.YahooMapsLayer.prototype.getSourceURL=function(x,y){var tempBase=this.baseUrl;if(this.serverIndex!=undefined){this.serverIndex=(x*y)%this.baseUrls.length;tempBase=this.baseUrls[this.serverIndex];}
var src=tempBase+'&.intl=en&r=1&x='+x+'&y='+(y-Math.floor(this.map.getTilesPerMapY()/2))+'&z='+(this.map.zoom+1);return src;}
JMap.hud.ZoomSlider=function(pHUD,hideSlider){this.HUD=pHUD;this.maxZoom=this.HUD.map.maxZoom+1;this.minZoom=this.HUD.map.minZoom;this.currentZoom=this.HUD.map.zoom;this.hideSlider=hideSlider;this._createHTML();this.update();}
JMap.hud.ZoomSlider.prototype._createHTML=function(){var _this=this;this.zoomIn=document.createElement('div');this.zoomIn.className='hud-zoom-in-button';this.zoomIn.onclick=function(){_this.HUD.map.zoomIn(1);};this.zoomOut=document.createElement('div');this.zoomOut.className='hud-zoom-out-button';this.zoomOut.onclick=function(){_this.HUD.map.zoomOut(1);};if(this.hideSlider){this.zoomOut.style.top='25px';}else{this.zoomOut.style.top=((this.maxZoom-this.minZoom)*10)+30+'px';}
this.rail=document.createElement('div');this.rail.className='hud-slider-rail';this.railTop=document.createElement('div');this.railTop.className='hud-rail-top';this.railMid=document.createElement('div');this.railMid.className='hud-rail-mid';this.railMid.style.height=((this.maxZoom-this.minZoom)*10)+'px';this.railMid.onmousedown=function(event){_this.jumpTo(event);};this.railBottom=document.createElement('div');this.railBottom.className='hud-rail-bottom';this.sliderHandle=document.createElement('div');this.sliderHandle.className='hud-slider-handle';this.sliderHandle.style.top=(((this.maxZoom-this.currentZoom)-1)*10)+2+'px';this.sliderHandle.onmousedown=function(event){_this._startDrag(event);};this.rail.appendChild(this.railTop);this.rail.appendChild(this.railMid);this.rail.appendChild(this.railBottom);this.rail.appendChild(this.sliderHandle);this.HUD.map.mapViewport.appendChild(this.zoomIn);if(!this.hideSlider){this.HUD.map.mapViewport.appendChild(this.rail);}
this.HUD.map.mapViewport.appendChild(this.zoomOut);}
JMap.hud.ZoomSlider.prototype._startDrag=function(event){event=event||window.event;var _this=this;this.lastMouseY=event.clientY;this.curMouseY=this.lastMouseY;document.onmousemove=function(event){_this._drag(event);};document.onmouseup=function(){_this._endDrag();};return false;}
JMap.hud.ZoomSlider.prototype._drag=function(event){event=event||window.event;this.curMouseY=event.clientY;var dy=this.curMouseY-this.lastMouseY;this.moveBy(dy);this.lastMouseY=this.curMouseY;JMap.util.unselect(event);return false;}
JMap.hud.ZoomSlider.prototype._endDrag=function(){var _this=this;var oldLevel=this.level;this.y=this.ypos;var ypos=this.ypos;var newLevel=Math.floor((((this.maxZoom-1)*10)-ypos)/10);if(oldLevel!=newLevel){var n=newLevel-oldLevel;this.level=newLevel;if(n>0){this.HUD.map.zoomIn(n);}else if(n<0){this.HUD.map.zoomOut(-n);}}
document.onmousemove=null;document.onmouseup=null;return false;}
JMap.hud.ZoomSlider.prototype.jumpTo=function(event){event=event||window.event;var coords=JMap.util.getRelativeCoords(event,this.railMid)
this.moveTo(coords.y-5);return false;}
JMap.hud.ZoomSlider.prototype.moveBy=function(dy){this.y+=dy;if(this.y>=0&&this.y<=(((this.maxZoom-this.minZoom)-1)*10)){this.ypos=Math.floor((this.y+3)/10)*10;if(this.ypos<0)this.ypos=0;if(this.ypos>(((this.maxZoom-this.minZoom)-1)*10))this.ypos=((this.maxZoom-this.minZoom-1)*10);this.sliderHandle.style.top=(this.ypos+2)+"px";}else{if(this.y<0){this.sliderHandle.style.top='2px';}else{this.sliderHandle.style.top=((this.maxZoom-this.minZoom-1)*10)+2+'px';}}}
JMap.hud.ZoomSlider.prototype.moveTo=function(y){this.y=y;this.ypos=Math.floor((this.y+3)/10)*10;this.sliderHandle.style.top=(this.ypos+2)+"px";this._endDrag();}
JMap.hud.ZoomSlider.prototype.update=function(){this.level=this.HUD.map.zoom;this.y=((((this.maxZoom)-1)-this.level)*10);this.ypos=Math.floor((this.y+3)/10)*10;this.sliderHandle.style.top=(this.ypos+2)+"px";}
JMap.hud.ZoomSlider.prototype.kill=function(){this.level=null;this.y=null;this.ypos=null;this.railMid.onmousedown=null;this.railMid=null;this.sliderHandle.onmousedown=null;this.sliderHandle=null;this.HUD.map.mapViewport.removeChild(this.zoomIn);if(!this.hideSlider){this.HUD.map.mapViewport.removeChild(this.rail);}
this.HUD.map.mapViewport.removeChild(this.zoomOut);}
