
var mdvLib;if(!mdvLib){mdvLib={};};mdvLib.$=function(){var elements=[];for(var i=0;i<arguments.length;i++){var element=arguments[i];if(typeof element==='string')element=document.getElementById(element);if(arguments.length===1)return element;elements.push(element);};return elements;};mdvLib.getElementPosition=function(el){var leftPos=el.offsetLeft;var topPos=el.offsetTop;var parentEl=el.offsetParent;while(parentEl!==null){leftPos+=parentEl.offsetLeft;topPos+=parentEl.offsetTop;parentEl=parentEl.offsetParent;};return{left:leftPos,top:topPos};};mdvLib.getMousePosition=function(e){var posx=0;var posy=0;var e=e||window.event;if(e.pageX||e.pageY){posx=e.pageX;posy=e.pageY;}else if(e.clientX||e.clientY){posx=e.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);posy=e.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);};return{left:posx,top:posy};};mdvLib.style=function(a,o){if(mdvLib.typeOf(a)!=='array'){return false;};for(var i=0;i<a.length;i++){for(var s in o){mdvLib.$(a[i]).style[s]=o[s];}};return true;};mdvLib.typeOf=function(value){var s=typeof value;if(s==='object'){if(value){if(value instanceof Array){s='array';}}else{s='null';}};return s;};mdvLib.createImg=function(styleObj,propObj){var img=document.createElement('img');if(mdvLib.typeOf(propObj)==='object'){for(var prop in propObj){img[prop]=propObj[prop];}};if(mdvLib.typeOf(styleObj)==='object'){mdvLib.style([img],styleObj);};return img;};mdvLib.correctPNG=function(map,img){if(!document.body.filters||!img||!map){return;};if(img.src==map.transparent.src){return true;};if(mdvLib.typeOf(img)==='array'){for(var i=0;i<img.length;i++){addFilter(img[i]);}}else{addFilter(img);};function addFilter(image){var src=image.src;var s=image.runtimeStyle;s.width=image.offsetWidth+"px";s.height=image.offsetHeight+"px";s.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\'), sizingMethod=\'crop\'';image.src=map.transparent.src;}};if(typeof Function.prototype.bind!=='function'){Function.prototype.bind=function(obj){var method=this,temp=function(){return method.apply(obj,arguments);};return temp;};};if(typeof String.prototype.trim!=='function'){String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"");};};var MDVEventID=0;var MDVEvent_ERROR=MDVEventID++;var MDVEvent_DEBUG=MDVEventID++;var MDVEvent_WARNING=MDVEventID++;var MDVEvent_INITIALISED=MDVEventID++;var MDVEvent_MAP_INITIALISED=MDVEventID++;var MDVEvent_ZOOM_CHANGED=MDVEventID++;var MDVEvent_CENTRE_CHANGED=MDVEventID++;var MDVEvent_CONTEXT_MENU=MDVEventID++;var MDVEvent_GADGET_REGISTERED=MDVEventID++;var MDVEvent_LAYER_ADDED=MDVEventID++;var MDVEvent_LAYER_UPDATED=MDVEventID++;var MDVEvent_AJAX_CALLBACK=MDVEventID++;var MDVEvent_MOUSE_MOVED=MDVEventID++;var MDVEvent_TOOLTIP=MDVEventID++;var MDVEvent_OBJECT_CLICKED=MDVEventID++;var MDVEvent_ROUTE_TRACE_FINISHED=MDVEventID++;var MDVEvent_MOUSE_UP=MDVEventID++;var MDVEvent_MOUSE_DOWN=MDVEventID++;function MDVMap(viewport,name){this.config=null;this.name=name;this.viewport=viewport;this.viewport.mdvMap=this;this.markerObjects=null;this.markerLayer=null;this.tileRealWidth=-1;this.tileRealHeight=-1;this.tileCountWidth=-1;this.tileCountHeight=-1;this.startTileWidth=-1;this.startTileHeight=-1;this.imgCountWidth=0;this.imgCountHeight=0;this.viewportRealWidth=-1;this.viewportRealHeight=-1;this.tlReal=null;this.tlTileReal=null;this.offset=null;this.wrapOffset=null;this.real=new MDVCoordinates();this.viewport.style.overflow='hidden';this.viewport.style.position='relative';this.viewportHeight=-1;this.viewportWidth=-1;this.state=-1;this.lastTileLayerID=0;this.lastImageID=0;this.lastMarkerID=0;this.lastLayerID=0;this.lastToolTipID=0;this.lastContainerID=0;this.lastPolylineID=0;this.maxFailCount=3;this.transparent=new Image(1,1);this.mapper=null;this.mappers=new Array();this.events=new MDVEvents();this.gadgets=new Array();this.layers=new Array();this.overlays=new Array();this.renderer=null;this.toolTips=new MDVToolTipManager(this);this.hotspots=null;this.speed=1;this.stepTime=40;this.stepPx=4.0;this.steps=null;this.moveJobID=null;this.crossHairSrc=new Image();this.crossHair=null;for(var i=0;i<MDVEventID;i++){this.events.addEventID(i);}};MDVMap.prototype.cleanMagnifyMapper=function(){var mapper=this.getMagnifyMapper();var children=mapper.childNodes.length;for(var i=0;i<children;i++){mapper.childNodes[children-i-1].mdvMap=null;if(mapper.childNodes[children-i-1].className!='mdvLayer')mapper.removeChild(mapper.childNodes[children-i-1]);};return true;};MDVMap.prototype.getMapper=function(){return this.mapper;};MDVMap.prototype.getMagnifyMapper=function(){var mapper=null;for(var m=0;m<this.mappers.length;m++){if(this.mappers[m].id!=this.mapper.id){mapper=this.mappers[m];break;}};return mapper;};MDVMap.prototype.switchMapper=function(){var src=null;var trg=null;for(var m=0;m<this.mappers.length;m++){if(this.mappers[m].id==this.mapper.id)src=this.mappers[m];else trg=this.mappers[m];};var children=src.childNodes.length;var markers=null;for(var c=0;c<children;c++){if(src.childNodes[c].id==this.getName()+'_mdvMarkers'){markers=src.childNodes[c];src.removeChild(markers);trg.appendChild(markers);break;}};src.style.zIndex=1;trg.style.zIndex=30;this.mapper=trg;this._removeImages();this.update();if(markers){markers.style.display='block';};return true;};MDVMap.prototype.getToolTipManager=function(){return this.toolTips;};MDVMap.prototype.getViewportExtends=function(){return{width:this.viewportWidth,height:this.viewportHeight};};MDVMap.prototype.getViewportRealExtends=function(){return{width:this.viewportRealWidth,height:this.viewportRealHeight};};MDVMap.prototype.getPoint=function(coords){if(coords==null)return null;this._updateMapValues();var zoomLevel=this.config.getZoomLevel(this.config.currentZoomLevelIndex);var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var pxToRealRatioWidth=pxWidthAll/parseInt(zoomLevel.get('realWidth'));var pxHeightAll=parseInt(zoomLevel.get('tileSizeY'))*parseInt(zoomLevel.get('numberOfTilesY'));var pxToRealRatioHeight=pxHeightAll/parseInt(zoomLevel.get('realHeight'));var retPoint=new MDVPoint(Math.floor(0.5+(coords.x-this.tlTileReal.x)*pxToRealRatioWidth),Math.floor(0.5+(coords.y-this.tlTileReal.y)*pxToRealRatioHeight));retPoint.x=retPoint.x-this.wrapOffset.x;retPoint.y=retPoint.y-this.wrapOffset.y;return retPoint;};MDVMap.prototype.getCoordinates=function(point){if(point==null)return null;this._updateMapValues();var zoomLevel=this.config.getZoomLevel(this.config.currentZoomLevelIndex);var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var realToPxRatioWidth=parseInt(zoomLevel.get('realWidth'))/pxWidthAll;var pxHeightAll=parseInt(zoomLevel.get('tileSizeY'))*parseInt(zoomLevel.get('numberOfTilesY'));var realToPxRatioHeight=parseInt(zoomLevel.get('realHeight'))/pxHeightAll;var retCoord=new MDVCoordinates(this.config.get('mapName'),Math.floor(0.5+this.tlReal.x+(point.x*realToPxRatioWidth)),Math.floor(0.5+this.tlReal.y+(point.y*realToPxRatioHeight)));return retCoord;};MDVMap.prototype.createMarker=function(coords,factor,imgSrc){if(imgSrc!='')return new MDVMarker(this,coords,imgSrc,factor);else return null;};MDVMap.prototype.createToolTip=function(innerHTML){if(arguments.length==2){var tt=new MDVToolTip(this,arguments[1],'bubble');tt.setSize(arguments[0]);return tt;}else{return new MDVToolTip(this,innerHTML,'simple');}};MDVMap.prototype._updateLayers=function(){for(var l=0;l<this.layers.length;l++){this.layers[l].update();};return true;};MDVMap.prototype.release=function(event){for(var i=0;i<this.gadgets.length;i++){var g=this.gadgets[i];if(g.name=='MapNavigator'){g.onmouseup(event);return true;}};return false;};MDVMap.prototype.addMarker=function(marker){return this.markerLayer.addMarker(marker);};MDVMap.prototype.removeMarker=function(marker){return this.markerLayer.removeMarker(marker);};MDVMap.prototype.addLayer=function(layer){var found=false;for(var l=0;l<this.layers.length;l++){if(this.layers[l].id==layer.id)found=true;};if(!found){this.layers.push(layer);this.events.triggerEvent(MDVEvent_LAYER_ADDED,'MDVMap has added a new layer ('+this.layers[l].name+')',this.layers[l]);this.layers.append=true;layer.update();}};MDVMap.prototype.getLayer=function(name){for(var l=0;l<this.layers.length;l++){if(this.layers[l].name==name)return this.layers[l];};return null;};MDVMap.prototype.getLayers=function(){return this.layers;};MDVMap.prototype.registerGadget=function(gadget){var found=false;for(var g=0;g<this.gadgets.length;g++){if(this.gadgets[g].name==gadget.name)found=true;};if(gadget.name=='GadgetBase')found=true;if(!found){this.gadgets.push(gadget);this.events.triggerEvent(MDVEvent_GADGET_REGISTERED,'MDVMap registered a new gadget ('+gadget.name+')',gadget);}};MDVMap.prototype.getCentre=function(){if(this.real.x>0&&this.real.y>0)return this.real;else return null;};MDVMap.prototype.setCentre=function(centre){if(centre&&(!this.getCentre()||centre.x!=this.getCentre().x||centre.y!=this.getCentre().y)){var ret=false;if(this._checkBoundariesX(centre)){this.real.x=centre.x;this.real.mapName=centre.mapName;ret=true;};if(this._checkBoundariesY(centre)){this.real.y=centre.y;this.real.mapName=centre.mapName;ret=true;};if(ret)this.events.triggerEvent(MDVEvent_CENTRE_CHANGED,'MDVMap centre has been changed',centre);return ret;}else{return false;}};MDVMap.prototype._checkBoundariesX=function(coord){var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());var realOffsetX=parseInt(zoomLevel.get('realOffsetX'));var realWidth=parseInt(zoomLevel.get('realWidth'));var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var realToPxRatioWidth=realWidth/pxWidthAll;if(coord.x>=realOffsetX&&coord.x<=(realOffsetX+realWidth))return true;else return false;};MDVMap.prototype._checkBoundariesY=function(coord){var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());var realOffsetY=parseInt(zoomLevel.get('realOffsetY'));var realHeight=parseInt(zoomLevel.get('realHeight'));var pxHeightAll=parseInt(zoomLevel.get('tileSizeY'))*parseInt(zoomLevel.get('numberOfTilesY'));var realToPxRatioHeight=realHeight/pxHeightAll;if(coord.y>=realOffsetY&&coord.y<=(realOffsetY+realHeight))return true;else return false;};MDVMap.prototype.setZoomLevel=function(zoomLevelIndex){var zoomLevel=this.config.getZoomLevel(zoomLevelIndex);if(this.config.getZoomLevelIndex()!=zoomLevelIndex&&zoomLevel){this.config.setZoomLevelIndex(zoomLevelIndex);if(this.config.get('showHotspotLevel')&&(zoomLevelIndex>=parseInt(this.config.get('showHotspotLevel')))&&this.hotspots.json==null){this.hotspots.retrieve();};this.events.triggerEvent(MDVEvent_ZOOM_CHANGED,'MDVMap zoom level has been changed',zoomLevelIndex);return true;}else{if(!zoomLevel)this.events.triggerEvent(MDVEvent_ERROR,'MDVMap wasn\'t able to set new zoom level.');return false;}};MDVMap.prototype.getObjWidth=function(obj){var result=0;if(obj.offsetWidth){result=obj.offsetWidth;}else if(obj.clip&&obj.clip.width){result=obj.clip.width;}else if(obj.style&&obj.style.pixelWidth){result=obj.style.pixelWidth;};return parseInt(result);};MDVMap.prototype.getObjHeight=function(obj){var result=0;if(obj.offsetHeight){result=obj.offsetHeight;}else if(obj.clip&&obj.clip.height){result=obj.clip.height;}else if(obj.style&&obj.style.pixelHeight){result=obj.style.pixelHeight;};return parseInt(result);};MDVMap.prototype._setBackgroundColour=function(color){this.viewport.style.backgroundColor=color;};MDVMap.prototype.getName=function(){return this.name;};MDVMap.prototype.resize=function(){this.viewportHeight=this.getObjHeight(this.viewport);this.viewportWidth=this.getObjWidth(this.viewport);if(this.viewportHeight<=2||this.viewportWidth<=2)this.events.triggerEvent(MDVEvent_ERROR,'MDVMap couldn\'t get size from target map object(' + this.viewport.id + ').');if(this.state==1)this.update();};MDVMap.prototype.execute=function(config){this.resize();this.wrapOffset=new MDVPoint(0,0);if(config&&this.config==null)this.config=config;else{this.events.triggerEvent(MDVEvent_ERROR,'MDVMap couldn\'t find an appropriate configuration or already has one.');this.state=-1;return false;};this.name=this.viewport.id;if(!document.mdvMaps)document.mdvMaps=new Array();document.mdvMaps['mdvMap_'+this.name]=this;if(this.config.get('defaultScale')>=0)this.setZoomLevel(parseInt(this.config.get('defaultScale')));else this.setZoomLevel(3);if(!this.getCentre()){var newReal=new MDVCoordinates(this.config.get('mapName'),parseInt(this.config.get('xCenterReal')),parseInt(this.config.get('yCenterReal')));this.setCentre(newReal);};this._updateMapValues();if(this.config.get('enableHotspots')){new MDVHotspots(this.name);};this.mappers[0]=document.createElement('div');this.mappers[0].id=this.name+'_mapper0';this.mappers[0].style.position='absolute';this.mappers[0].style.left='0px';this.mappers[0].style.top='0px';this.mappers[0].style.zIndex='30';this.mappers[0].mdvMap=this;this.mappers[0].tiles=new Array();this.mappers[1]=document.createElement('div');this.mappers[1].id=this.name+'_mapper1';this.mappers[1].style.position='absolute';this.mappers[1].style.left='0px';this.mappers[1].style.top='0px';this.mappers[1].style.zIndex='1';this.mappers[1].mdvMap=this;this.mappers[1].tiles=new Array();this.mapper=this.mappers[0];this.viewport.appendChild(this.mappers[0]);this.viewport.appendChild(this.mappers[1]);this.mappers[0].onmousemove=MDVMap_onmousemove;this.mappers[0].onmouseover=MDVMap_onmouseover;this.mappers[0].onmousedown=MDVMap_onmousedown;this.mappers[0].onmouseup=MDVMap_onmouseup;this.mappers[0].onkeypress=MDVMap_onkeypress;this.mappers[0].ondblclick=MDVMap_ondblclick;this.mappers[0].oncontextmenu=MDVMap_oncontextmenu;this.mappers[0].onmousewheel=MDVMap_onmousewheel;this.mappers[0].onclick=MDVMap_onclick;this.mappers[1].onmousemove=MDVMap_onmousemove;this.mappers[1].onmouseover=MDVMap_onmouseover;this.mappers[1].onmousedown=MDVMap_onmousedown;this.mappers[1].onmouseup=MDVMap_onmouseup;this.mappers[1].onkeypress=MDVMap_onkeypress;this.mappers[1].ondblclick=MDVMap_ondblclick;this.mappers[1].oncontextmenu=MDVMap_oncontextmenu;this.mappers[1].onmousewheel=MDVMap_onmousewheel;this.mappers[1].onclick=MDVMap_onclick;this.viewport.onmouseout=MDVMap_onmouseout;if(window.addEventListener&&navigator.product&&navigator.product=='Gecko'){this.viewport.addEventListener('DOMMouseScroll',MDVMap_onmousewheel,false);};if(this.config.get('maxFailCount')){this.maxFailCount=parseInt(this.config.get('maxFailCount'));};if(this.config.get('crosshair')){var ipath='images/';if(this.config.get('imagePath'))ipath=this.config.get('imagePath');this.crossHairSrc.src=ipath+this.config.get('crosshair');};this.mappers[0].ondragstart=new Function([],'var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;');this.mappers[1].ondragstart=new Function([],'var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;');this.transparent.src=this.config.get('transparentImg');if(this.config.get('cursorIdle')){this.mappers[0].style.cursor=this.config.get('cursorIdle');this.mappers[1].style.cursor=this.config.get('cursorIdle');};this._viewMap();this.renderer=(document.createElementNS)?new MDVSVGRenderer(this,this.markerObjects):new MDVVMLRenderer(this,this.markerObjects);};MDVMap.prototype.destroy=function(){if(this.state==-1)return;var gLength=this.gadgets.length;for(var g=0;g<gLength;g++){var gadget=this.gadgets.pop();if(gadget)gadget.destroy();};var lLength=this.layers.length;for(var l=0;l<lLength;l++){var layer=this.layers.pop();if(layer)layer.destroy();};for(var t=0;t<this.getMapper().tiles.length;t++){var tiles=this.getMapper().tiles[t];for(var i=0;i<tiles.div.childNodes.length;i++){if(tiles.div.childNodes[i].mdvMap)tiles.div.childNodes[i].mdvMap=null;}};if(this.mapper){this.mapper.onmousemove=null;this.mapper.onmouseover=null;this.mapper.onmousedown=null;this.mapper.onmouseup=null;this.viewport.onmouseout=null;this.mapper.onkeypress=null;this.mapper.ondblclick=null;this.mapper.oncontextmenu=null;this.mapper.onmousewheel=null;this.mapper.onclick=null;this.mapper.mdvMap=null;};if(this.markerObjects&&this.markerObjects.mdvMap)this.markerObjects.mdvMap=null;if(this.viewport&&this.viewport.mdvMap)this.viewport.mdvMap=null;if(this.crossHair)this.crossHair=null;if(this.crossHairSrc)this.crossHairSrc=null;this.transparent=null;document.mdvMaps['mdvMap_'+this.name]=null;};MDVMap.prototype._updateVisibleMap=function(){var zoomLevel=this.config.getZoomLevel(this.config.currentZoomLevelIndex);this._updateMapValues();var startColumn=parseInt((this.tlReal.x-parseInt(zoomLevel.get('realOffsetX')))/this.tileRealWidth);if(startColumn<0)startColumn=0;var endColumn=parseInt((this.tlReal.x+this.viewportRealWidth-zoomLevel.get('realOffsetX'))/this.tileRealWidth);if(endColumn>=parseInt(zoomLevel.get('numberOfTilesX')))endColumn=parseInt(zoomLevel.get('numberOfTilesX'))-1;var startRow=parseInt((this.tlReal.y-parseInt(zoomLevel.get('realOffsetY')))/this.tileRealHeight);if(startRow<0)startRow=0;var endRow=parseInt((this.tlReal.y+this.viewportRealHeight-parseInt(zoomLevel.get('realOffsetY')))/this.tileRealHeight);if(endRow>=parseInt(zoomLevel.get('numberOfTilesY')))endRow=parseInt(zoomLevel.get('numberOfTilesY'))-1;this.tileVisibleWidth=endColumn-startColumn+2;this.tileVisibleHeight=endRow-startRow+2;this.startTileWidth=startColumn;this.startTileHeight=startRow;if(zoomLevel.get('numberOfTilesX')<=1){this.tileVisibleWidth--;};if(zoomLevel.get('numberOfTilesY')<=1){this.tileVisibleHeight--;};var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var pxToRealRatioWidth=pxWidthAll/parseInt(zoomLevel.get('realWidth'));var pxHeightAll=parseInt(zoomLevel.get('tileSizeY'))*parseInt(zoomLevel.get('numberOfTilesY'));var pxToRealRatioHeight=pxHeightAll/parseInt(zoomLevel.get('realHeight'));var viewportCentre=new MDVPoint((this.getCentre().x-parseInt(zoomLevel.get('realOffsetX')))*pxToRealRatioWidth,(this.getCentre().y-parseInt(zoomLevel.get('realOffsetY')))*pxToRealRatioHeight);var tlViewport=new MDVPoint((this.tlReal.x-parseInt(zoomLevel.get('realOffsetX')))*pxToRealRatioWidth,(this.tlReal.y-parseInt(zoomLevel.get('realOffsetY')))*pxToRealRatioHeight);var tlTile=new MDVPoint();tlTile.x=(this.tlTileReal.x-parseInt(zoomLevel.get('realOffsetX')))*pxToRealRatioWidth;tlTile.y=(this.tlTileReal.y-parseInt(zoomLevel.get('realOffsetY')))*pxToRealRatioHeight;tlTile.x=Math.floor(tlTile.x+0.5);tlTile.y=Math.floor(tlTile.y+0.5);var tlOffset=new MDVPoint(tlTile.x-parseInt(tlViewport.x),tlTile.y-parseInt(tlViewport.y));this.getMapper().style.left=tlOffset.x+'px';this.getMapper().style.top=tlOffset.y+'px';this.getCentre().x=Math.floor(this.getCentre().x+0.5);this.getCentre().y=Math.floor(this.getCentre().y+0.5);this.wrapOffset=new MDVPoint(0,0);};MDVMap.prototype._updateMapValues=function(){var zoomLevel=this.config.getZoomLevel(this.config.currentZoomLevelIndex);if(!zoomLevel){this.events.triggerEvent(MDVEvent_ERROR,'MDVMap has an invalid zoom level.');return false;};var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var pxToRealRatioWidth=pxWidthAll/parseInt(zoomLevel.get('realWidth'));var pxHeightAll=parseInt(zoomLevel.get('tileSizeY'))*parseInt(zoomLevel.get('numberOfTilesY'));var pxToRealRatioHeight=pxHeightAll/parseInt(zoomLevel.get('realHeight'));this.tileRealWidth=parseInt(zoomLevel.get('realWidth'))/parseInt(zoomLevel.get('numberOfTilesX'));this.tileRealHeight=parseInt(zoomLevel.get('realHeight'))/parseInt(zoomLevel.get('numberOfTilesY'));this.tileCountWidth=parseInt(this.viewportWidth)/parseInt(zoomLevel.get('tileSizeX'));this.tileCountHeight=parseInt(this.viewportHeight)/parseInt(zoomLevel.get('tileSizeY'));this.viewportRealWidth=parseInt(this.tileRealWidth*this.tileCountWidth);this.viewportRealHeight=parseInt(this.tileRealHeight*this.tileCountHeight);this.tlReal=new MDVCoordinates(this.config.get('mapName'),parseInt(this.getCentre().x-(this.viewportRealWidth/2)),parseInt(this.getCentre().y-(this.viewportRealHeight/2)));var tlViewport=new MDVPoint((this.tlReal.x-parseInt(zoomLevel.get('realOffsetX')))*pxToRealRatioWidth,(this.tlReal.y-parseInt(zoomLevel.get('realOffsetY')))*pxToRealRatioHeight);var tlTileColumn=parseInt(tlViewport.x/parseInt(zoomLevel.get('tileSizeX')));var tlTileRow=parseInt(tlViewport.y/parseInt(zoomLevel.get('tileSizeY')));this.tlTileReal=new MDVCoordinates(this.config.get('mapName'),tlTileColumn*this.tileRealWidth+parseInt(zoomLevel.get('realOffsetX')),tlTileRow*this.tileRealHeight+parseInt(zoomLevel.get('realOffsetY')));this.tlTileReal.x=Math.floor(this.tlTileReal.x+0.5);this.tlTileReal.y=Math.floor(this.tlTileReal.y+0.5);return true;};MDVMap.prototype.getTopLeftTileReal=function(){return this.tlTileReal;};MDVMap.prototype._checkWrap=function(){var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());var tileSize=new MDVPoint(zoomLevel.get('tileSizeX'),zoomLevel.get('tileSizeY'));var tempX=this.viewportWidth-parseInt(zoomLevel.get('numberOfTilesX'))*parseInt(zoomLevel.get('tileSizeX'));var tempY=this.viewportWidth-parseInt(zoomLevel.get('numberOfTilesY'))*parseInt(zoomLevel.get('tileSizeY'));var wrapX=zoomLevel.get('numberOfTilesX')<=1|tempX>0;var wrapY=zoomLevel.get('numberOfTilesY')<=1|tempY>0;this.offset=new MDVPoint(parseInt(this.getMapper().style.left)-this.wrapOffset.x,parseInt(this.getMapper().style.top)-this.wrapOffset.y);if(this.offset.x>0){if(wrapX)return false;this._applyWrapR2L();};if(this.offset.x<-(tileSize.x)){if(wrapX)return false;this._applyWrapL2R();};if(this.offset.y>0){if(wrapY)return false;this._applyWrapB2T();};if(this.offset.y<-(tileSize.y)){if(wrapY)return false;this._applyWrapT2B();};return true;};MDVMap.prototype._applyWrapT2B=function(){for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());var tileSize=new MDVPoint(zoomLevel.get('tileSizeX'),zoomLevel.get('tileSizeY'));var lastTile=parseInt(mapTiles.div.childNodes[this.imgCountHeight*this.imgCountWidth-1].style.top);for(var x=0;x<this.imgCountWidth;x++){var bottomImg=mapTiles.div.childNodes[0];bottomImg.style.filter='';bottomImg.src=this.transparent.src;bottomImg.style.top=(parseInt(lastTile)+parseInt(tileSize.y))+'px';bottomImg.src=this.transparent.src;mapTiles.div.removeChild(bottomImg);mapTiles.div.appendChild(bottomImg);}};this.wrapOffset.y-=parseInt(tileSize.y);this.startTileHeight++;this._setMapTiles(false);};MDVMap.prototype._applyWrapB2T=function(){for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());var tileSize=new MDVPoint(zoomLevel.get('tileSizeX'),zoomLevel.get('tileSizeY'));var topTile=parseInt(mapTiles.div.childNodes[0].style.top);for(var x=0;x<this.imgCountWidth;x++){var topImg=mapTiles.div.childNodes[(this.imgCountHeight*this.imgCountWidth)-1];topImg.style.filter='';topImg.src=this.transparent.src;topImg.style.top=(parseInt(topTile)-parseInt(tileSize.y))+'px';topImg.src=this.transparent.src;mapTiles.div.removeChild(topImg);mapTiles.div.insertBefore(topImg,mapTiles.div.childNodes[0]);}};this.wrapOffset.y+=parseInt(tileSize.y);this.startTileHeight--;this._setMapTiles(false);};MDVMap.prototype._applyWrapL2R=function(){for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());var tileSize=new MDVPoint(zoomLevel.get('tileSizeX'),zoomLevel.get('tileSizeY'));var lastTile=parseInt(mapTiles.div.childNodes[this.imgCountWidth-1].style.left);for(var y=0;y<this.imgCountHeight;y++){var firstImg=mapTiles.div.childNodes[y*this.imgCountWidth];var beforeImg;if(y<(this.imgCountHeight-1)){beforeImg=mapTiles.div.childNodes[(y+1)*this.imgCountWidth];}else{beforeImg=null;};firstImg.style.filter='';firstImg.src=this.transparent.src;firstImg.style.left=(parseInt(lastTile)+parseInt(tileSize.x))+'px';firstImg.src=this.transparent.src;mapTiles.div.removeChild(firstImg);if(beforeImg){mapTiles.div.insertBefore(firstImg,beforeImg);}else{mapTiles.div.appendChild(firstImg);}}};this.wrapOffset.x-=parseInt(tileSize.x);this.startTileWidth++;this._setMapTiles(false);};MDVMap.prototype._applyWrapR2L=function(){for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());var tileSize=new MDVPoint(zoomLevel.get('tileSizeX'),zoomLevel.get('tileSizeY'));var firstTile=parseInt(mapTiles.div.childNodes[0].style.left);for(var y=0;y<this.imgCountHeight;y++){var lastImg=mapTiles.div.childNodes[((y+1)*this.imgCountWidth)-1];var nextImg=mapTiles.div.childNodes[y*this.imgCountWidth];lastImg.style.filter='';lastImg.src=this.transparent.src;lastImg.style.left=(firstTile-tileSize.x)+'px';lastImg.src=this.transparent.src;mapTiles.div.removeChild(lastImg);mapTiles.div.insertBefore(lastImg,nextImg);}};this.wrapOffset.x+=parseInt(tileSize.x);this.startTileWidth--;this._setMapTiles(false);};MDVMap.prototype.update=function(){this._updateVisibleMap();this._setLayers();this._updateLayers();if(this._setImages()){this._setOptimisedMapTiles();}else{var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());var cX=parseInt(zoomLevel.get('realOffsetX'))+parseInt(zoomLevel.get('realWidth'))/2;var cY=parseInt(zoomLevel.get('realOffsetY'))+parseInt(zoomLevel.get('realHeight'))/2;var cNew=new MDVCoordinates(this.config.get('mapName'),parseInt(cX),parseInt(cY));this.events.triggerEvent(MDVEvent_ERROR,'MDVMap has determined that the given coordinates are out of bounds. Setting zoom level centre.',cNew);this.setCentre(cNew);this.update();};this.events.triggerEvent(MDVEvent_MAP_INITIALISED,'MDVMap tiles have been initialised',this);};MDVMap.prototype._viewMap=function(){this.state=0;if(this.config.get('backgroundColour'))this._setBackgroundColour(this.config.get('backgroundColour'));else this._setBackgroundColour('#E5E5E5');this.events.triggerEvent(MDVEvent_INITIALISED,'MDVMap has been initialised',this);this._setLayers();this.update();this.state=1;};MDVMap.prototype._setMapTiles=function(adjust){for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];mapTiles.display();var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());if(!(this.imgCountWidth*this.imgCountHeight==mapTiles.div.childNodes.length)){this.events.triggerEvent(MDVEvent_ERROR,'MDVMap noticed an inconsistency within the tile layer.');this._removeImages();this.update();return;};if(!mapTiles.isActive())continue;var fileType=mapTiles.getFileType();for(var y=0;y<this.imgCountHeight;y++){for(var x=0;x<this.imgCountWidth;x++){var img=mapTiles.div.childNodes[(y*this.imgCountWidth)+x];if(!img){this.events.triggerEvent(MDVEvent_ERROR,'Error accessing tile within DOM.');return false;};var pos=new MDVPoint(x*parseInt(zoomLevel.get('tileSizeX')),y*parseInt(zoomLevel.get('tileSizeY')));var src=mapTiles.getImageURL(x,y);if(img.src!=src&&img.style.filter!='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\');'){img.style.filter='';img.src=src;if(adjust&&!document.all)img.style.visibility='hidden';}else if(!adjust){continue;};if(mapTiles.isOverlay())img.overlay=true;else img.overlay=false;img.style.width=zoomLevel.get('tileSizeX');img.style.height=zoomLevel.get('tileSizeY');img.width=zoomLevel.get('tileSizeX');img.height=zoomLevel.get('tileSizeY');if(this.config.get('debug')){img.alt=src;img.title=src;};img.failCount=0;if(adjust){img.style.left=pos.x+'px';img.style.top=pos.y+'px';}}}}};MDVMap.prototype._setOptimisedMapTiles=function(){var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];mapTiles.display();var tileLayer=new Array();if(!(this.imgCountWidth*this.imgCountHeight==mapTiles.div.childNodes.length)){this.events.triggerEvent(MDVEvent_ERROR,'MDVMap noticed an inconsistency within the tile layer.');this._removeImages();this.update();return;};if(!mapTiles.isActive())continue;var fileType=mapTiles.getFileType();for(var y=0;y<this.imgCountHeight;y++){for(var x=0;x<this.imgCountWidth;x++){var img=mapTiles.div.childNodes[(y*this.imgCountWidth)+x];if(!img){this.events.triggerEvent(MDVEvent_ERROR,'Error accessing tile within DOM.');return false;};var pos=new MDVPoint(x*parseInt(zoomLevel.get('tileSizeX')),y*parseInt(zoomLevel.get('tileSizeY')));var src=mapTiles.getImageURL(x,y);if(mapTiles.isOverlay())img.overlay=true;else img.overlay=false;tileLayer.push({priority:mapTiles.quantifier(pos),img:img,src:src,pos:pos,size:new MDVPoint(zoomLevel.get('tileSizeX'),zoomLevel.get('tileSizeY'))});}};tileLayer.sort(mapTiles.sorter);for(var i=0;i<tileLayer.length;i++){var item=tileLayer[i];if(item.img.src!=item.src){item.img.style.filter='';item.img.src=item.src;if(!document.all)item.img.style.visibility='hidden';};item.img.style.width=item.size.x+'px';item.img.style.height=item.size.y+'px';item.img.width=item.size.x;item.img.height=item.size.y;if(this.config.get('debug')){item.img.alt=src;item.img.title=src;};item.img.failCount=0;item.img.style.left=item.pos.x+'px';item.img.style.top=item.pos.y+'px';}}};MDVMap.prototype.createOverlay=function(name,url){var overlay=null;overlay={mdvMap:this,name:name,url:url,imgURL:arguments.length>=3?arguments[2]:null,quantifier:arguments.length>=3?arguments[3]:null,sorter:arguments.length>=3?arguments[4]:null};return overlay;};MDVMap.prototype.addOverlay=function(overlay){for(var o=0;o<this.overlays.length;o++){if(this.overlays[o].getName()==overlay.getName())return false;};this.overlays.push(overlay);return true;};MDVMap.prototype._setLayers=function(){if(this.getMapper().tiles.length<=0&&this.getMapper()){this.getMapper().tiles.push(new MDVTiles(this,this.getMapper().id+'_mapTiles'));var tiles=null;for(var o=0;o<this.overlays.length;o++){if(this.overlays[o].imgURL){tiles=new MDVTiles(this.overlays[o].mdvMap,this.getMapper().id+'_overlay_'+this.overlays[o].name,this.overlays[o].imgURL);tiles.setOverlay(true);tiles.setSrcPath(this.overlays[o].url);if(this.overlays[o].quantifier)tiles.setQuantifier(this.overlays[o].quantifier);if(this.overlays[o].sorter)tiles.setSorter(this.overlays[o].sorter);}else{tiles=new MDVTiles(this.overlays[o].mdvMap,this.getMapper().id+'_overlay_'+this.overlays[o].name);};this.getMapper().tiles.push(tiles);}};if(!this.markerObjects&&this.getMapper()){this.markerObjects=document.createElement('div');this.markerObjects.className='mdvLayer';this.markerObjects.style.zIndex='55';this.markerObjects.id=this.getName()+'_mdvMarkers';this.markerObjects.style.position='absolute';this.markerObjects.style.visibility='visible';this.markerObjects.style.left='0px';this.markerObjects.style.top='0px';this.markerObjects.style.width='3000px';this.markerObjects.style.height='3000px';this.markerObjects.mdvMap=this;this.getMapper().appendChild(this.markerObjects);this.markerObjects.append=true;};if(!this.markerLayer){this.markerLayer=this.createLayer('mdvMarkers');this.addLayer(this.markerLayer);}};MDVMap.prototype._setImages=function(){if(this.tileVisibleWidth<=0||this.tileVisibleHeight<=0)return false;while(this.imgCountWidth<this.tileVisibleWidth){this._addColumn();}while(this.imgCountHeight<this.tileVisibleHeight){this._addRow();}while(this.imgCountHeight>this.tileVisibleHeight){this._removeRow();}while(this.imgCountWidth>this.tileVisibleWidth){this._removeColumn();};return true;};MDVMap.prototype._removeImages=function(){for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];var count=mapTiles.div.childNodes.length;for(var i=0;i<count;i++){var remove=mapTiles.div.childNodes[count-i-1];remove.onmousedown=null;remove.onmousemove=null;remove.onmouseout=null;remove.onmouseover=null;remove.onmouseup=null;remove.onmousewheel=null;remove.onclick=null;remove.onload=null;remove.onerror=null;if(remove.mdvMap)remove.mdvMap=null;mapTiles.div.removeChild(remove);};this.imgCountWidth=0;this.imgCountHeight=0;};if(this.getMapper().tiles.length==0){this.imgCountWidth=0;this.imgCountHeight=0;}};MDVMap.prototype._addColumn=function(){if(this.tileVisibleWidth==0)return;for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());for(var i=0;i<this.imgCountHeight;i++){var pos=new MDVPoint((this.imgCountWidth+1)*parseInt(zoomLevel.get('tileSizeX')),i*parseInt(zoomLevel.get('tileSizeY')));var img=this._createImage(pos);mapTiles.div.appendChild(img);}};this.imgCountWidth++;};MDVMap.prototype._removeColumn=function(){if(this.imgCountWidth<=1)return;for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];var children=mapTiles.div.childNodes.length+this.imgCountWidth-2;for(var y=0;y<this.imgCountHeight;y++){var index=(this.imgCountHeight*y)+(this.imgCountWidth-1);var img=mapTiles.div.childNodes[(children-index)];if(!img){this.events.triggerEvent(MDVEvent_ERROR,'Error accessing tile.');return false;};img.onmousedown=null;img.onmousemove=null;img.onmouseout=null;img.onmouseover=null;img.onmouseup=null;img.onmousewheel=null;img.onclick=null;if(img.mdvMap)img.mdvMap=null;img.onload=null;img.onerror=null;mapTiles.div.removeChild(img);}};this.imgCountWidth--;};MDVMap.prototype._addRow=function(){if(this.tileVisibleWidth==0)return;for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());var i;for(i=0;i<this.tileVisibleWidth;i++){var pos=new MDVPoint(i*parseInt(zoomLevel.get('tileSizeX')),this.imgCountHeight*parseInt(zoomLevel.get('tileSizeY')));var img=this._createImage(pos);mapTiles.div.appendChild(img);this.imgCountWidth++;}};this.imgCountWidth=i;this.imgCountHeight++;};MDVMap.prototype._removeRow=function(){if(this.imgCountHeight<=1)return;for(var t=0;t<this.getMapper().tiles.length;t++){var mapTiles=this.getMapper().tiles[t];var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());for(var i=0;i<this.imgCountWidth;i++){var index=(this.imgCountHeight*this.imgCountWidth)-i-1;var img=mapTiles.div.childNodes[index];if(!img){this.events.triggerEvent(MDVEvent_ERROR,'MDVMap has problems while accessing tile.');return false;};img.onload=null;img.onerror=null;mapTiles.div.removeChild(img);}};this.imgCountHeight--;};MDVMap.prototype._createImage=function(pos){var zoomLevel=this.config.getZoomLevel(this.config.getZoomLevelIndex());var img=document.createElement('img');img.src=this.transparent.src;img.width=parseInt(zoomLevel.get('tileSizeX'));img.height=parseInt(zoomLevel.get('tileSizeY'));img.setAttribute('style','position:absolute; top:'+pos.y+'px; left:'+pos.x+'px;');img.style.position='absolute';img.style.width=parseInt(zoomLevel.get('tileSizeX'))+"px";img.style.height=parseInt(zoomLevel.get('tileSizeY'))+"px";img.style.top=pos.y;img.style.left=pos.x;img.galleryimg="no";img.onerror=MDVMap_imgOnError;img.onload=MDVMap_imgOnLoad;img.mdvMap=this;img.id="t"+this.lastImageID++;img.failCount=0;return img;};MDVMap.prototype.getPolylinePoints=function(){var xArr=new Array();var yArr=new Array();for(var l=0;l<this.layers.length;l++){var coords=this.layers[l].getPolylineCoords();for(var c=0;c<coords.length;c++){var point=this.getPoint(coords[c]);xArr.push(point.x);yArr.push(point.y);}};return[xArr,yArr];};MDVMap.prototype.getPolylineCoords=function(){var xArr=new Array();var yArr=new Array();for(var l=0;l<this.layers.length;l++){var coords=this.layers[l].getPolylineCoords();for(var c=0;c<coords.length;c++){xArr.push(coords[c].x);yArr.push(coords[c].y);}};return[xArr,yArr];};MDVMap.prototype.createLayer=function(name){var retLayer=new MDVLayer(this,name);return retLayer;};MDVMap.prototype.hideToolTips=function(){var layers=this.getLayers();var ret=false;for(var l=0;l<layers.length;l++){ret=layers[l].hideToolTips();};return ret;};MDVMap.prototype.createPolyline=function(coords){var polyline=new MDVPolyline(this,coords);return polyline;};MDVMap.prototype.moveBySeq=function(coordSeq){var update=true;if(this.moveJobID)mdvTimer.remove(this.moveJobID);this.cleanMagnifyMapper();var mSeq=this.getMoveSeq(coordSeq);var crosshair=null;if(arguments.length>=2){if(arguments[1])crosshair=arguments[1];if(arguments.length==3)update=arguments[2];};if(mSeq.length>0&&(crosshair!=null||this.config.get('crosshair'))){var crs=this.crossHairSrc.src;if(crosshair)crs=crosshair;if(this.crossHair==null){this.crossHair=this.createMarker(mSeq[0].clone(),new MDVPoint(0.5,0.5),crs);this.addMarker(this.crossHair);}};if(mSeq.length>0&&update){var centre=mSeq[0].clone();this.setCentre(centre);this.update();};this.moveJobID=mdvTimer.add(this.stepTime,this,this.move,[mSeq,0]);return true;};MDVMap.prototype.getMoveSeq=function(coordSeq){if(coordSeq.length<=0)return null;var zoomLevel=this.config.getZoomLevel(this.config.currentZoomLevelIndex);var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var realRatioWidthToPx=parseInt(zoomLevel.get('realWidth'))/pxWidthAll;var steps=new Array();var current=coordSeq[0].clone();var distance=0;var offset=null;var dest=null;var stepReal=this.stepPx*realRatioWidthToPx;for(var c=1;c<coordSeq.length;c++){dest=coordSeq[c];var vec=new MDVPoint(dest.x-current.x,dest.y-current.y);if(vec.x==0&&vec.y==0)continue;distance=Math.sqrt(Math.pow(vec.x,2)+Math.pow(vec.y,2));var norm=stepReal/distance;offset=new MDVPoint(vec.x*norm,vec.y*norm);while(distance>stepReal){current.x=(current.x+offset.x);current.y=(current.y+offset.y);steps.push(current.clone());distance=distance-stepReal;};if(distance>0){offset=new MDVPoint(dest.x-current.x,dest.y-current.y);current.x=(current.x+offset.x);current.y=(current.y+offset.y);steps.push(current.clone());};distance=0;};return steps;};MDVMap.prototype.move=function(mSeq,index){if(index>=mSeq.length){if(this.moveJobID)mdvTimer.remove(this.moveJobID);this.moveJobID=null;this.removeMarker(this.crossHair);if(this.crossHair)this.crossHair.destroy();this.crossHair=null;this.events.triggerEvent(MDVEvent_ROUTE_TRACE_FINISHED,'MDVMap has finished moving...',mSeq);return false;};this.moveTo(mSeq[index]);index++;this.moveJobID=mdvTimer.add(this.stepTime,this,this.move,[mSeq,index]);};MDVMap.prototype.cancelMoveBySeq=function(){var success=false;if(mdvTimer)success=mdvTimer.remove(this.moveJobID);this.moveJobID=null;if(this.crossHair){this.removeMarker(this.crossHair);this.crossHair.destroy();this.crossHair=null;};return success;};MDVMap.prototype.moveTo=function(coords){var centre=this.getPoint(this.getCentre());var target=this.getPoint(coords);if(this.crossHair)this.crossHair.setCoords(coords.clone());var tl=new MDVPoint(parseInt(this.getMapper().style.left),parseInt(this.getMapper().style.top));if(centre==null||target==null)return false;var offset=new MDVPoint(target.x-centre.x,target.y-centre.y);this.getMapper().style.left=(tl.x-offset.x)+'px';this.getMapper().style.top=(tl.y-offset.y)+'px';if(this.getMagnifyMapper()){this.getMagnifyMapper().style.left=(parseInt(this.getMagnifyMapper().style.left)-offset.x)+'px';this.getMagnifyMapper().style.top=(parseInt(this.getMagnifyMapper().style.top)-offset.y)+'px';};this.setCentre(coords);this._checkWrap();return true;};MDVMap.prototype.magnify=function(zlTarget){var current=this.config.getZoomLevel(this.config.getZoomLevelIndex());var target=this.config.getZoomLevel(zlTarget);if(current==null||target==null||current.level==target.level)return false;var currentTileWidth=parseInt(current.get('realWidth'))/parseInt(current.get('numberOfTilesX'));var targetTileWidth=parseInt(target.get('realWidth'))/parseInt(target.get('numberOfTilesX'));var ratio=currentTileWidth/targetTileWidth;var active=null;for(var t=0;t<this.getMapper().tiles.length;t++){if(!this.getMapper().tiles[t].isOverlay()){active=this.getMapper().tiles[t];}else{this.getMapper().tiles[t].hide();}};if(active==null)return false;this.markerObjects.style.display='none';var point=this.getPoint(this.getCentre());var delta=new MDVPoint(point.x*(1-ratio),point.y*(1-ratio));for(var i=0;i<active.div.childNodes.length;i++){var img=active.div.childNodes[i];img.style.width=Math.floor(0.5+(parseInt(img.style.width)*ratio))+'px';img.style.height=Math.floor(0.5+(parseInt(img.style.height)*ratio))+'px';img.style.top=(parseInt(img.style.top)*ratio)+'px';img.style.left=(parseInt(img.style.left)*ratio)+'px';};this.getMapper().style.left=(parseInt(this.getMapper().style.left)+delta.x)+'px';this.getMapper().style.top=(parseInt(this.getMapper().style.top)+delta.y)+'px';this.setZoomLevel(zlTarget);return true;};MDVMap.prototype.setDefaultCursor=function(){if(this.config.get('cursorIdle')){if(document.all){this.getMapper().style.cursor='url(\'' + this.config.get('cursorIdle') + '\')';}else{this.getMapper().style.cursor='-moz-grab';}}};function MDVTiles(mdvMap,name){this.mdvMap=mdvMap;this.name=name;this.id=this.mdvMap.lastTileLayerID++;this.zIndex=this.id;this.srcPath=this.mdvMap.config.get('serverURL');this.block=parseInt(this.mdvMap.config.get('block'));this.fileType='.png';this.active=true;this.overlay=false;this.div=document.createElement('div');this.div.className='mdvLayer';this.div.style.zIndex=this.zIndex;this.div.id=this.mdvMap.getName()+'_'+this.name;this.div.style.position='absolute';this.div.style.visibility='visible';this.div.style.left='0px';this.div.style.top='0px';this.div.style.width='3000px';this.div.style.height='3000px';this.div.mdvMap=this;if(arguments.length==3&&arguments[2])this.getImageURL=arguments[2];this.mdvMap.getMapper().appendChild(this.div);this.div.append=true;};MDVTiles.prototype.hide=function(visibility){this.div.style.display='none';};MDVTiles.prototype.display=function(){this.div.style.display='block';};MDVTiles.prototype.getName=function(){return this.name;};MDVTiles.prototype.isOverlay=function(){return this.overlay;};MDVTiles.prototype.setOverlay=function(overlay){this.overlay=overlay;};MDVTiles.prototype.getSrcPath=function(){return this.srcPath;};MDVTiles.prototype.setSrcPath=function(srcPath){this.srcPath=srcPath;};MDVTiles.prototype.getBlock=function(){return this.block;};MDVTiles.prototype.setBlock=function(block){this.block=block;};MDVTiles.prototype.getFileType=function(){return this.fileType;};MDVTiles.prototype.setFileType=function(fileType){this.fileType=fileType;};MDVTiles.prototype.setActive=function(active){this.active=active;};MDVTiles.prototype.isActive=function(){return this.active;};MDVTiles.prototype.setQuantifier=function(quantifier){this.quantifier=quantifier;};MDVTiles.prototype.setSorter=function(sorter){this.sorter=sorter;};MDVTiles.prototype.getImageURL=function(x,y){var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var src=this.getSrcPath();var level=this.mdvMap.config.getZoomLevelIndex();if(zoomLevel.get('zoomLevel'))level=zoomLevel.get('zoomLevel');if(this.getBlock()){var block=this.getBlock();var columnMin=Math.floor((this.mdvMap.startTileWidth+x)/block)*block;var columnMax=columnMin+block-1;var rowMin=Math.floor((this.mdvMap.startTileHeight+y)/block)*block;var rowMax=rowMin+block-1;src+='zoomlevel';src+=level;src+='/columns'+columnMin+'-'+columnMax;src+='/column';src+=(this.mdvMap.startTileWidth+x);src+='/rows'+rowMin+'-'+rowMax+'/';src+=(this.mdvMap.startTileHeight+y);src+='_';src+=(this.mdvMap.startTileWidth+x);src+='_';src+=level;src+=this.getFileType();}else{src+='zoomlevel';src+=level;src+='/column';src+=(this.mdvMap.startTileWidth+x);src+='/'+this.mdvMap.config.get('network')+'_';src+=(this.mdvMap.startTileHeight+y);src+='_';src+=(this.mdvMap.startTileWidth+x);src+=this.getFileType();};return src;};MDVTiles.prototype.sorter=function(a,b){return a.priority-b.priority;};MDVTiles.prototype.quantifier=function(pos){var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var tOrigin=this.mdvMap.getPoint(this.mdvMap.getCentre());var vec=new MDVPoint((pos.x+parseInt(zoomLevel.get('tileSizeX'))/2)-tOrigin.x,(pos.y+parseInt(zoomLevel.get('tileSizeY'))/2)-tOrigin.y);return Math.floor(0.5+(Math.pow(vec.x,2)+Math.pow(vec.y,2)));};function MDVMapConfig(){this.zoomLevels=new Array();this.currentZoomLevelIndex=null;this.params=new Array();};MDVMapConfig.prototype.clone=function(){var ret=new MDVMapConfig();for(var z=0;z<=100;z++){if(this.zoomLevels[z]==null)continue;var zl=new MDVMapConfigZoomLevel(this.zoomLevels[z].getLevel());zl.setScale(this.zoomLevels[z].getScale());for(var p in this.zoomLevels[z].params){if(this.zoomLevels[z].params[p])zl.add(p,this.zoomLevels[z].params[p]);};ret.registerZoomLevel(zl);};return ret;};MDVMapConfig.prototype.registerZoomLevel=function(zoomLevelObj){this.zoomLevels[zoomLevelObj.level]=zoomLevelObj;};MDVMapConfig.prototype.getZoomLevels=function(){return this.zoomLevels;};MDVMapConfig.prototype.getZoomLevel=function(index){if(this.zoomLevels[index])return this.zoomLevels[index];else return null;};MDVMapConfig.prototype.add=function(key,value){this.params[key]=value;};MDVMapConfig.prototype.get=function(key){return this.params[key];};MDVMapConfig.prototype.setZoomLevelIndex=function(zoomLevelIndex){this.currentZoomLevelIndex=zoomLevelIndex;};MDVMapConfig.prototype.getZoomLevelIndex=function(){return this.currentZoomLevelIndex;};function MDVMapConfigZoomLevel(level){this.level=level;this.scale=null;this.params=new Array();};MDVMapConfigZoomLevel.prototype.add=function(key,value){this.params[key]=value;};MDVMapConfigZoomLevel.prototype.get=function(key){return this.params[key];};MDVMapConfigZoomLevel.prototype.setScale=function(scale){this.scale=scale;};MDVMapConfigZoomLevel.prototype.getScale=function(){return this.scale;};MDVMapConfigZoomLevel.prototype.getLevel=function(){return this.level;};function MDVEvents(){this.events=[];this.lastEventID=0;};MDVEvents.prototype.addEventID=function(id){if(!this.events[id]){this.events[id]=[];}};MDVEvents.prototype.registerEvent=function(id,target,func){if(this.events[id]){this.events[id].push([target,func]);}};MDVEvents.prototype.deregisterEvent=function(id,obj,func){var retVal=false;if(!this.events[id])return false;for(var i=0;i<this.events[id].length;i++){if(this.events[id][i][0]==obj&&this.events[id][i][1]==func){this.events[id].splice(i,1);retVal=true;}};return retVal;};MDVEvents.prototype.triggerEvent=function(id){if(!this.events[id]){return false;};var args=new Array();for(var i=0;i<arguments.length;i++)args[args.length]=arguments[i];if(document.getElementById&&document.getElementById('MDVMap_Console')&&args.length>=2){var curDate=new Date();var dateHr=curDate.getHours();var dateMin=curDate.getMinutes();var dateSec=curDate.getSeconds();if(dateHr<=9)dateHr='0'+dateHr;if(dateMin<=9)dateMin='0'+dateMin;if(dateSec<=9)dateSec='0'+dateSec;var dateStr=dateHr+':'+dateMin+':'+dateSec;document.getElementById('MDVMap_Console').value=dateStr+' '+args[1]+' (id: '+id+')'+'\n'+document.getElementById('MDVMap_Console').value;};for(var i=0;i<this.events[id].length;i++)this.events[id][i][1].apply(this.events[id][i][0],arguments);return true;};MDVMap_onmousemove=function(e){e=e?e:window.event;var ret=true;if(e.button==2)this.mdvMap.events.triggerEvent(MDVEvent_CONTEXT_MENU);for(var g=0;g<this.mdvMap.gadgets.length;g++){if(!this.mdvMap.gadgets[g].onmousemove(e)){ret=false;break;}};return ret;};MDVMap_onmouseover=function(e){e=e?e:window.event;var ret=true;for(var g=0;g<this.mdvMap.gadgets.length;g++){if(!this.mdvMap.gadgets[g].onmouseover(e))ret=false;};return ret;};MDVMap_onmousedown=function(e){e=e?e:window.event;var ret=true;this.mdvMap.events.triggerEvent(MDVEvent_MOUSE_DOWN,'MDVMap noticed a mouse down event.',e);for(var g=0;g<this.mdvMap.gadgets.length;g++){if(!this.mdvMap.gadgets[g].onmousedown(e)){ret=false;break;}};return ret;};MDVMap_onmouseup=function(e){e=e?e:window.event;this.mdvMap.events.triggerEvent(MDVEvent_MOUSE_UP,'MDVMap noticed a mouse up event.',e);for(var g=0;g<this.mdvMap.gadgets.length;g++){if(!this.mdvMap.gadgets[g].onmouseup(e)){ret=false;break;}};return true;};MDVMap_onmouseout=function(e){e=e?e:window.event;for(var g=0;g<this.mdvMap.gadgets.length;g++){if(!this.mdvMap.gadgets[g].onmouseout(e))return false;};return true;};MDVMap_onkeypress=function(e){e=e?e:window.event;for(var g=0;g<this.mdvMap.gadgets.length;g++){if(!this.mdvMap.gadgets[g].onkeypress(e))return false;};return true;};MDVMap_ondblclick=function(e){e=e?e:window.event;for(var g=0;g<this.mdvMap.gadgets.length;g++){if(!this.mdvMap.gadgets[g].ondblclick(e))return false;};return true;};MDVMap_oncontextmenu=function(e){e=e?e:window.event;for(var g=0;g<this.mdvMap.gadgets.length;g++){if(!this.mdvMap.gadgets[g].oncontextmenu(e))return false;};return true;};MDVMap_onmousewheel=function(e){e=e?e:window.event;for(var g=0;g<this.mdvMap.gadgets.length;g++){if(!this.mdvMap.gadgets[g].onmousewheel(e))return false;};return true;};MDVMap_onclick=function(e){e=e?e:window.event;if(!(this.mdvMap.config.get('enableHotspots'))){return;};if(this.mdvMap.hotspots.current==null){return true;};this.mdvMap.events.triggerEvent(MDVEvent_OBJECT_CLICKED,'MDVMap Object clicked....',this.mdvMap.hotspots.current);return true;};MDVMap_imgOnError=function(e){e=e?e:window.event;if(this.mdvMap){this.mdvMap.events.triggerEvent(MDVEvent_WARNING,'MDVMap couldn\'t load tile ' + this.id + '(failCount:' + this.failCount + ')');this.failCount++;var failSrc=this.src;this.src=this.mdvMap.transparent.src;if(this.failCount<=this.mdvMap.maxFailCount){this.src=failSrc;}else{this.src=this.mdvMap.transparent.src;}}};MDVMap_imgOnLoad=function(e){e=e?e:window.event;this.style.visibility='visible';var ua=navigator.userAgent;if(this.src==this.mdvMap.transparent.src)return true;if(document.all&&ua.indexOf('Opera')<0&&this.overlay){var src=this.src;this.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\');';this.src=this.mdvMap.transparent.src;};if(this.failCount>0&&this.src!=this.mdvMap.transparent.src)this.mdvMap.events.triggerEvent(MDVEvent_WARNING,'MDVMap recovered tile '+this.id+' (failCount: '+this.failCount+')');};function MDVCoordinates(mapName,x,y){this.x=x;this.y=y;if(typeof x=='string')this.x=parseInt(this.x);if(typeof y=='string')this.y=parseInt(this.y);this.mapName=mapName;};MDVCoordinates.prototype.toString=function(){return this.mapName+', x: '+this.x+', y: '+this.y;};MDVCoordinates.prototype.equals=function(coords){if(!coords||!coords.x||!coords.y)return false;var x=this.x;var y=this.y;var targetX=coords.x;var targetY=coords.y;if(x%1>0)x=parseInt(Math.floor(x+0.5));if(y%1>0)y=parseInt(Math.floor(y+0.5));if(targetX%1>0)targetX=parseInt(Math.floor(targetX+0.5));if(targetY%1>0)targetY=parseInt(Math.floor(targetY+0.5));return(x==targetX&&y==targetY&&this.mapName==coords.mapName);};MDVCoordinates.prototype.clone=function(){return new MDVCoordinates(this.mapName,this.x,this.y);};function MDVPoint(x,y){this.x=x;this.y=y;if(typeof x=='string')this.x=parseInt(this.x);if(typeof y=='string')this.y=parseInt(this.y);};MDVPoint.prototype.toString=function(){return 'x: '+this.x+', y: '+this.y;};MDVPoint.prototype.equals=function(point){if(!point||!point.x||!point.y)return false;var x=this.x;var y=this.y;var targetX=point.x;var targetY=point.y;if(x%1>0)x=parseInt(Math.floor(x+0.5));if(y%1>0)y=parseInt(Math.floor(y+0.5));if(targetX%1>0)targetX=parseInt(Math.floor(targetX+0.5));if(targetY%1>0)targetY=parseInt(Math.floor(targetY+0.5));return(x==targetX&&y==targetY);};MDVPoint.prototype.clone=function(){return new MDVPoint(this.x,this.y);};function MDVMarker(mdvMap,coords,imgSrc,factor){if(!mdvMap)return;this.mdvMap=mdvMap;this.img=new Image();this.img.marker=this;this.img.mdvMap=mdvMap;this.img.onload=MDVMarker_onload;this.img.onclick=MDVMarker_onclick;this.img.oncontextmenu=MDVMarker_oncontextmenu;this.imgSrc=imgSrc;this.marker=this;this.id=mdvMap.lastMarkerID++;this.coords=coords;this.toolTip=null;this.visible=true;this.objectId={type:'coord',desc:'',id:this.getCoords().x+':'+this.getCoords().y+':'+this.getCoords().mapName,omc:'',marker:this};this.append=false;if(typeof factor=='object'&&factor&&factor.x>=0&&factor.y>=0){this.xFactor=factor.x;this.yFactor=factor.y;}else{this.xFactor=factor;this.yFactor=1;}};MDVMarker.prototype.setVisibility=function(visible){var value=visible?'visible':'hidden';this.img.style.visibility=value;this.visible=visible;return true;};MDVMarker.prototype.isVisible=function(){return this.visible;};MDVMarker.prototype.equals=function(marker){return this.id==marker.id;};MDVMarker.prototype.intersects=function(mrkr){if(mrkr==null)return false;var recThis=this.getRectangle();var recMrkr=mrkr.getRectangle();return recMrkr.width>0&&recMrkr.height>0&&recThis.width>0&&recThis.height>0&&recMrkr.x<recThis.x+recThis.width&&recMrkr.x+recMrkr.width>recThis.x&&recMrkr.y<recThis.y+recThis.height&&recMrkr.y+recMrkr.height>recThis.y;};MDVMarker.prototype.getRectangle=function(){var point=this.mdvMap.getPoint(this.getCoords());var width=this.img.width;var height=this.img.height;var xFactor=this.getXFactor();var yFactor=this.getYFactor();var upperLeft=new MDVPoint(point.x-width*xFactor,point.y-height*yFactor);return{x:upperLeft.x,y:upperLeft.y,width:width,height:height};};MDVMarker.prototype.update=function(){var point=this.mdvMap.getPoint(this.getCoords());var ttUpdate=true;if(!point){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,'MDVMap wasn\'t able to get px coordinates for marker.');return false;};if(arguments.length>0)ttUpdate=arguments[0];var width=this.img.width;var height=this.img.height;var xFactor=this.getXFactor();var yFactor=this.getYFactor();this.img.style.position='absolute';this.img.style.left=(point.x-width*xFactor)+'px';this.img.style.top=(point.y-height*yFactor)+'px';if(this.layer&&this.layer.zIndex)this.img.style.zIndex=this.layer.zIndex;var visb=this.visible?'visible':'hidden';if(this.img.style.visibility!=visb)this.img.style.visibility=visb;if(this.toolTip&&this.toolTip.isVisible()&&ttUpdate)this.toolTip.update();return true;};MDVMarker.prototype.destroy=function(){this.img.marker=null;this.img.mdvMap=null;if(this.toolTip)this.toolTip.destroy();if(this.marker.layer)this.marker.layer=null;this.toolTip=null;this.objectId=null;this.coords=null;this.marker=null;this.img.onload=null;this.img=null;};MDVMarker.prototype.getCoords=function(){if(this.coords&&this.coords.x>0&&this.coords.y>0){return this.coords;};return null;};MDVMarker.prototype.setCoords=function(coords){this.coords=coords;this.update();};MDVMarker.prototype.getXFactor=function(){return this.xFactor;};MDVMarker.prototype.getYFactor=function(){return this.yFactor;};MDVMarker.prototype.setTitle=function(title){this.img.title=title;this.img.alt=title;};MDVMarker.prototype.setToolTip=function(tooltip){if(!tooltip)return false;var update=false;if(arguments.length==2)update=arguments[1];var ttCoords=this.coords.clone();this.toolTip=tooltip;this.toolTip.setParent(this);this.img.toolTip=tooltip;this.toolTip.setCoords(ttCoords);if(update&&this.toolTip.isVisible())this.toolTip.update();this.img.onmouseover=MDVMarker_displayToolTip;this.img.onmouseout=MDVMarker_hideToolTip;return true;};MDVMarker.prototype.setObjectId=function(objectId){this.objectId=objectId;};MDVMarker.prototype.getObjectId=function(){return this.objectId;};MDVMarker.prototype.getImage=function(){return this.img;};function MDVMarker_onload(e){e=e?e:window.event;if(this.marker){this.marker.update();if(!this.marker.append&&this.marker.layer){this.mdvMap.markerObjects.appendChild(this);this.marker.append=true;}}};function MDVMarker_displayToolTip(e){e=e?e:window.event;var element=this.marker||this;if(element){element.mdvMap.cancelMoveBySeq();if(element.toolTip.isFixed())return;if(element.toolTip)element.toolTip.cancelHide();if(this.parentPolyline){var mX=e.pageX||(e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var mY=e.pageY||(e.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var offsetL=0;var offsetT=0;var obj=this.mdvMap.viewport;while(obj){offsetL+=obj.offsetLeft;offsetT+=obj.offsetTop;obj=obj.offsetParent;};var mousePos=new MDVPoint(mX-offsetL-1,mY-offsetT-1);var mouseReal=this.mdvMap.getCoordinates(mousePos);if(element.toolTip&&!element.toolTip.isVisible())this.parentPolyline.setMouse(mouseReal);};if(element.toolTip)element.toolTip.triggerDisplay();}};function MDVMarker_hideToolTip(e){e=e?e:window.event;var element=this.marker||this;if(element&&element.toolTip){element.toolTip.cancelDisplay();element.toolTip.triggerHide();}};function MDVMarker_onclick(e){if(this.marker){this.marker.objectId.right=false;this.mdvMap.events.triggerEvent(MDVEvent_OBJECT_CLICKED,'MDVMap Object clicked....',this.marker.objectId);};return false;};function MDVMarker_oncontextmenu(e){e=e?e:window.event;if(this.marker){this.marker.objectId.right=true;this.mdvMap.events.triggerEvent(MDVEvent_OBJECT_CLICKED,'MDVMap Object clicked....',this.marker.objectId);};e.cancelBubble=true;e.returnValue=false;if(e.stopPropogation)e.stopPropogation();if(e.preventDefault)e.preventDefault();return false;};function MDVToolTip(mdvMap,innerHTML,type){this.mdvMap=mdvMap;this.innerHTML=innerHTML;this.id=this.mdvMap.lastToolTipID++;this.slidable=false;this.parentMarker=null;this.type=type;this.coords=null;this.container=null;this.size=null;this.fixed=false;this.jobs=new Array();this.overflow=false;this.pin=false;this.disabled=false;this.jobs['display']=null;this.jobs['hide']=null;};MDVToolTip.prototype.setDisabled=function(disabled){this.disabled=disabled;};MDVToolTip.prototype.isDisabled=function(){return this.disabled;};MDVToolTip.prototype.setPin=function(pin){this.pin=pin;};MDVToolTip.prototype.hasPin=function(){return this.pin;};MDVToolTip.prototype.setOverflow=function(flow){this.overflow=flow;};MDVToolTip.prototype.isOverflow=function(){return this.overflow;};MDVToolTip.prototype.setSlidable=function(slidable){this.slidable=slidable;};MDVToolTip.prototype.isSlidable=function(){return this.slidable;};MDVToolTip.prototype.setInnerHTML=function(innerHTML){this.innerHTML=innerHTML;if(this.container){this.container.setInnerHTML(innerHTML);}};MDVToolTip.prototype.getInnerHTML=function(){return this.innerHTML;};MDVToolTip.prototype.setContainer=function(container){this.container=container;};MDVToolTip.prototype.getContainer=function(){return this.container;};MDVToolTip.prototype.getManager=function(){return this.manager;};MDVToolTip.prototype.setCoords=function(coords){this.coords=coords;};MDVToolTip.prototype.getCoords=function(){return this.coords;};MDVToolTip.prototype.setType=function(type){this.type=type;};MDVToolTip.prototype.getType=function(){return this.type;};MDVToolTip.prototype.setParent=function(marker){this.parentMarker=marker;};MDVToolTip.prototype.getParent=function(){return this.parentMarker;};MDVToolTip.prototype.setSize=function(size){this.size=size;};MDVToolTip.prototype.getSize=function(){return this.size;};MDVToolTip.prototype.setFixed=function(fixed){this.fixed=fixed;};MDVToolTip.prototype.isFixed=function(){return this.fixed;};MDVToolTip.prototype.display=function(){if(this.isDisabled())return false;if(this.mdvMap)this.mdvMap.hideToolTips();if(!this.getContainer())this.require();var update=this.update();this.getContainer().setInnerHTML(this.getInnerHTML());this.setVisibility(true);this.mdvMap.events.triggerEvent(MDVEvent_TOOLTIP,'MDVMap Tool Tip...',this);return update;};MDVToolTip.prototype.hide=function(){if(this.isFixed())return false;this.setVisibility(false);if(this.mdvMap&&this.mdvMap.events)this.mdvMap.events.triggerEvent(MDVEvent_TOOLTIP,'MDVMap Tool Tip...',this);if(this.getParent()&&this.getParent().layer&&(this.getParent().layer.name=='efa_stops'||this.getParent().layer.name=='efa_poi')){var zl=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());if(this.getParent().objectId.type=='stop'&&zl.get('showSTOP')&&zl.get('showSTOP')=='false')this.getParent().layer.removeMarker(this.getParent());if(this.getParent().objectId.type=='poi'&&zl.get('showPOI')&&zl.get('showPOI')=='false')this.getParent().layer.removeMarker(this.getParent());};return this.free();};MDVToolTip.prototype.require=function(){if(this.container)this.free(this.container);var container=null;if(this.getSize())container=this.mdvMap.getToolTipManager().require(this.getType(),this.getSize());else container=this.mdvMap.getToolTipManager().require(this.getType());if(container){container.setParent(this.getParent());container.setToolTip(this);container.setInnerHTML(this.getInnerHTML());};this.setContainer(container);};MDVToolTip.prototype.free=function(){if(this.container){if(this.mdvMap.getToolTipManager().free(this.container)){this.container.setParent(null);this.container.setToolTip(null);this.setContainer(null);return true;}};return false;};MDVToolTip.prototype.destroy=function(){if(this.container){this.hide();};this.parentMarker=null;this.mdvMap=null;};MDVToolTip.prototype.isVisible=function(){if(this.container)return this.container.isVisible();return false;};MDVToolTip.prototype.setVisibility=function(visible){if(this.container)return this.container.setVisibility(visible);return false;};MDVToolTip.prototype.update=function(){if(this.container)return this.container.update();};MDVToolTip.prototype.triggerDisplay=function(){var timeout=250;this.jobs['display']=mdvTimer.add(timeout,this,this.display,[]);};MDVToolTip.prototype.triggerHide=function(){var timeout=100;this.jobs['hide']=mdvTimer.add(timeout,this,this.hide,[]);};MDVToolTip.prototype.cancelDisplay=function(){if(this.jobs['display']!=null){if(mdvTimer.remove(this.jobs['display'])){this.jobs['display']=null;return true;}};return false;};MDVToolTip.prototype.cancelHide=function(){if(this.jobs['hide']!=null){if(mdvTimer.remove(this.jobs['hide'])){this.jobs['hide']=null;return true;}};return false;};function MDVToolTipContainer(mdvMap){this.mdvMap=mdvMap;this.id=this.mdvMap.lastContainerID++;this.div=null;this.point=null;this.append=false;this.visibility=false;this.mousePos=null;this.parentMarker=null;this.vacant=true;this.type='simple';this.init();};MDVToolTipContainer.prototype.isVacant=function(){return this.vacant;};MDVToolTipContainer.prototype.setVacant=function(vacant){this.vacant=vacant;};MDVToolTipContainer.prototype.setParent=function(parentMarker){this.parentMarker=parentMarker;};MDVToolTipContainer.prototype.getParent=function(){return this.parentMarker;};MDVToolTipContainer.prototype.setVisibility=function(visible){this.visibility=visible;this.div.style.visibility=visible?'visible':'hidden';};MDVToolTipContainer.prototype.isVisible=function(){return this.visibility;};MDVToolTipContainer.prototype.getInnerHTML=function(){return this.div.innerHTML;};MDVToolTipContainer.prototype.setInnerHTML=function(innerHTML){this.div.innerHTML=innerHTML;};MDVToolTipContainer.prototype.setAppend=function(append){this.append=append;};MDVToolTipContainer.prototype.isAppend=function(){this.append;};MDVToolTipContainer.prototype.getType=function(){return this.type;};MDVToolTipContainer.prototype.update=function(){return false;};MDVToolTipContainer.prototype.setToolTip=function(toolTip){if(this.div)this.div.toolTip=toolTip;};MDVToolTipContainer.prototype.init=function(){this.div=document.createElement('div');this.div.style.zIndex=100;this.div.style.position='absolute';this.div.style.top='0px';this.div.style.left='0px';this.div.toolTip=null;if(!this.isAppend()){this.mdvMap.markerObjects.appendChild(this.div);this.setAppend(true);};this.div.onmouseover=MDVToolTipContainer_cancelHide;this.div.onmouseout=MDVToolTipContainer_triggerHide;this.div.onmousedown=MDVToolTipContainer_onMouseDown;this.setVisibility(false);return this.div!=null;};function MDVToolTipContainer_triggerHide(e){e=e?e:window.event;if(this.toolTip)this.toolTip.triggerHide();};function MDVToolTipContainer_cancelHide(e){e=e?e:window.event;if(this.toolTip)this.toolTip.cancelHide();};function MDVToolTipContainer_onMouseDown(e){e=e?e:window.event;if(!this.toolTip.isSlidable()){e.cancelBubble=true;e.returnValue=false;if(e.stopPrpogation)e.stopPropogation();if(e.preventDefault)e.preventDefault();return false;};return true;};function MDVToolTipBubble(mdvMap,size){this.mdvMap=mdvMap;this.id=this.mdvMap.lastContainerID++;this.div=null;this.point=null;this.append=false;this.visibility=false;this.complex=new Array();this.mousePos=null;this.parentMarker=null;this.margins=null;this.vacant=true;this.innerHTML='';this.type='bubble';this.lastParent=null;this.pointerSize=new MDVPoint(63,15);this.pointerBorder=new MDVPoint(34,34);this.pointerState=3;this.innerOffset=new MDVPoint(0,this.pointerSize.y-1);this.offset=null;this.size=size;this.delta=new MDVPoint(0,0);for(var method in MDVToolTipContainer.prototype){if(!MDVToolTipBubble.prototype[method])MDVToolTipBubble.prototype[method]=MDVToolTipContainer.prototype[method];};this.init();this.createBubble();this.updateBubble();this.setVisibility(false);};MDVToolTipBubble.prototype.setVisibility=function(visible){this.visibility=visible;var flow=false;var parent=this.getParent();if(parent&&parent.toolTip&&parent.toolTip.isOverflow())flow=true;if(this.complex['body']&&flow)this.complex['body'].style.overflow=visible?'auto':'hidden';this.div.style.visibility=visible?'visible':'hidden';};MDVToolTipBubble.prototype.setLastParent=function(obj){this.lastParent=obj;};MDVToolTipBubble.prototype.getLastParent=function(){return this.lastParent;};MDVToolTipBubble.prototype.getInnerHTML=function(){return this.complex['body'].innerHTML;};MDVToolTipBubble.prototype.setInnerHTML=function(innerHTML){this.complex['body'].innerHTML=innerHTML;};MDVToolTipBubble.prototype.setSize=function(size){if(this.size){switch(this.pointerState){case 0:this.delta.x=0;this.delta.y=this.size.y-size.y;break;case 1:this.delta.x=0;this.delta.y=this.size.y-size.y;break;case 2:this.delta.x=0;this.delta.y=0;break;case 3:this.delta.x=0;this.delta.y=0;break;}};this.size=size;};MDVToolTipBubble.prototype.getSize=function(){return this.size;};MDVToolTipBubble.prototype.createBubble=function(){var ipath='images/';if(this.mdvMap.config.get('imagePath'))ipath=this.mdvMap.config.get('imagePath');var tempImg=document.createElement('img');tempImg.src=ipath+'bubble.png';tempImg.style.position='relative';tempImg.style.left=0+'px';tempImg.style.top=0+'px';tempImg.galleryimg='no';tempImg.unselectable='no';this.complex['upperLeftCorner']=document.createElement('div');this.complex['upperLeftCorner'].appendChild(tempImg);this.div.appendChild(this.complex['upperLeftCorner']);var tempImg=document.createElement('img');tempImg.src=ipath+'bubble.png';tempImg.style.position='relative';tempImg.style.left=-30+'px';tempImg.style.top=0+'px';tempImg.galleryimg='no';tempImg.unselectable='no';this.complex['upperBorder']=document.createElement('div');this.complex['upperBorder'].appendChild(tempImg);this.div.appendChild(this.complex['upperBorder']);var tempImg=document.createElement('img');tempImg.src=ipath+'bubble.png';tempImg.style.position='relative';tempImg.style.left=-672+'px';tempImg.style.top=0+'px';tempImg.galleryimg='no';tempImg.unselectable='no';this.complex['upperRightCorner']=document.createElement('div');this.complex['upperRightCorner'].appendChild(tempImg);this.div.appendChild(this.complex['upperRightCorner']);var tempImg=document.createElement('img');tempImg.src=ipath+'bubble.png';tempImg.style.position='relative';tempImg.style.left=0+'px';tempImg.style.top=-30+'px';tempImg.galleryimg='no';tempImg.unselectable='no';this.complex['leftBorderBody']=document.createElement('div');this.complex['leftBorderBody'].appendChild(tempImg);this.div.appendChild(this.complex['leftBorderBody']);var tempImg=document.createElement('img');tempImg.src=ipath+'bubble.png';tempImg.style.position='relative';tempImg.style.left=-670+'px';tempImg.style.top=-670+'px';tempImg.galleryimg='no';tempImg.unselectable='no';this.complex['lowerRightCorner']=document.createElement('div');this.complex['lowerRightCorner'].appendChild(tempImg);this.div.appendChild(this.complex['lowerRightCorner']);var tempImg=document.createElement('img');tempImg.src=ipath+'bubble.png';tempImg.style.position='relative';tempImg.style.left=-698+'px';tempImg.style.top=0+'px';tempImg.galleryimg='no';tempImg.unselectable='no';this.complex['rightBorder']=document.createElement('div');this.complex['rightBorder'].appendChild(tempImg);this.div.appendChild(this.complex['rightBorder']);var tempImg=document.createElement('img');tempImg.src=ipath+'bubble.png';tempImg.style.position='relative';tempImg.style.left=0+'px';tempImg.style.top=-670+'px';tempImg.galleryimg='no';tempImg.unselectable='no';this.complex['lowerLeftCorner']=document.createElement('div');this.complex['lowerLeftCorner'].appendChild(tempImg);this.div.appendChild(this.complex['lowerLeftCorner']);var tempImg=document.createElement('img');tempImg.src=ipath+'bubble.png';tempImg.style.position='relative';tempImg.style.left=-30+'px';tempImg.style.top=-670+'px';tempImg.galleryimg='no';tempImg.unselectable='no';this.complex['lowerBorder']=document.createElement('div');this.complex['lowerBorder'].appendChild(tempImg);this.div.appendChild(this.complex['lowerBorder']);this.complex['body']=document.createElement('div');this.complex['body'].className='MDVToolTipBubble_Body';this.div.appendChild(this.complex['body']);var tempImg=document.createElement('img');tempImg.src=ipath+'bubble.png';tempImg.style.position='relative';tempImg.style.left=this.pointerState*-64+'px';tempImg.style.top=-704+'px';tempImg.galleryimg='no';tempImg.unselectable='no';this.complex['pointer']=document.createElement('div');this.complex['pointer'].appendChild(tempImg);this.div.appendChild(this.complex['pointer']);var tempImg=document.createElement('img');tempImg.src=ipath+'bubble.png';tempImg.style.position='relative';tempImg.style.left=-662+'px';tempImg.style.top=-701+'px';tempImg.galleryimg='no';tempImg.unselectable='no';tempImg.onclick=MDVToolTipBubble_OnPinClick;tempImg.bubble=this;this.complex['pin']=document.createElement('div');this.complex['pin'].mdvMap=this.mdvMap;this.complex['pin'].appendChild(tempImg);this.div.appendChild(this.complex['pin']);};MDVToolTipBubble.prototype.updateBubble=function(){var size=this.size;var ipath='images/';if(this.mdvMap.config.get('imagePath'))ipath=this.mdvMap.config.get('imagePath');this.complex['upperLeftCorner'].style.position='absolute';this.complex['upperLeftCorner'].style.overflow='hidden';this.complex['upperLeftCorner'].style.width=30+'px';this.complex['upperLeftCorner'].style.height=30+'px';this.complex['upperLeftCorner'].style.left=0+'px';this.complex['upperLeftCorner'].style.top=(0+this.innerOffset.y)+'px';this.complex['upperBorder'].style.position='absolute';this.complex['upperBorder'].style.overflow='hidden';this.complex['upperBorder'].style.width=(size.x-2*28)+'px';this.complex['upperBorder'].style.height=30+'px';this.complex['upperBorder'].style.left=30+'px';this.complex['upperBorder'].style.top=(0+this.innerOffset.y)+'px';this.complex['upperRightCorner'].style.position='absolute';this.complex['upperRightCorner'].style.overflow='hidden';this.complex['upperRightCorner'].style.width=30+'px';this.complex['upperRightCorner'].style.height=30+'px';this.complex['upperRightCorner'].style.left=(size.x-26)+'px';this.complex['upperRightCorner'].style.top=(0+this.innerOffset.y)+'px';this.complex['leftBorderBody'].style.position='absolute';this.complex['leftBorderBody'].style.overflow='hidden';this.complex['leftBorderBody'].style.width=size.x+'px';this.complex['leftBorderBody'].style.height=(size.y-(this.pointerSize.y-1-this.innerOffset.y)-2*30)+'px';this.complex['leftBorderBody'].style.left=0+'px';this.complex['leftBorderBody'].style.top=(30+this.innerOffset.y)+'px';this.complex['lowerRightCorner'].style.position='absolute';this.complex['lowerRightCorner'].style.overflow='hidden';this.complex['lowerRightCorner'].style.width=30+'px';this.complex['lowerRightCorner'].style.height=30+'px';this.complex['lowerRightCorner'].style.left=(size.x-28)+'px';this.complex['lowerRightCorner'].style.top=(size.y-(this.pointerSize.y-1-this.innerOffset.y)-30)+'px';this.complex['rightBorder'].style.position='absolute';this.complex['rightBorder'].style.overflow='hidden';this.complex['rightBorder'].style.width=2+'px';this.complex['rightBorder'].style.height=(size.y-(this.pointerSize.y-1-this.innerOffset.y)-30)+'px';this.complex['rightBorder'].style.left=(size.x)+'px';this.complex['rightBorder'].style.top=(0+this.innerOffset.y)+'px';this.complex['lowerLeftCorner'].style.position='absolute';this.complex['lowerLeftCorner'].style.overflow='hidden';this.complex['lowerLeftCorner'].style.width=30+'px';this.complex['lowerLeftCorner'].style.height=30+'px';this.complex['lowerLeftCorner'].style.left=0+'px';this.complex['lowerLeftCorner'].style.top=(size.y-(this.pointerSize.y-1-this.innerOffset.y)-30)+'px';this.complex['lowerBorder'].style.position='absolute';this.complex['lowerBorder'].style.overflow='hidden';this.complex['lowerBorder'].style.width=(size.x-2*28)+'px';this.complex['lowerBorder'].style.height=30+'px';this.complex['lowerBorder'].style.left=30+'px';this.complex['lowerBorder'].style.top=(size.y-(this.pointerSize.y-1-this.innerOffset.y)-30)+'px';var pinOffset=0;if(this.getParent()&&this.getParent().toolTip&&this.getParent().toolTip.hasPin())pinOffset=-18;this.complex['body'].style.position='absolute';this.complex['body'].style.width=(size.x-30+pinOffset)+'px';this.complex['body'].style.height=(size.y-35)+'px';this.complex['body'].style.left=15+'px';this.complex['body'].style.top=(10+this.innerOffset.y)+'px';this.innerOffset.y>=this.pointerSize.y-1;var pointerTop=this.innerOffset.y>=this.pointerSize.y-1?0:this.size.y-this.pointerSize.y;this.complex['pointer'].style.position='absolute';this.complex['pointer'].style.overflow='hidden';this.complex['pointer'].style.width=this.pointerSize.x+'px';this.complex['pointer'].style.height=this.pointerSize.y+'px';this.complex['pointer'].style.left=this.pointerBorder.x+'px';this.complex['pointer'].style.top=pointerTop+'px';if(this.complex['pointer'].firstChild)this.complex['pointer'].firstChild.style.left=this.pointerState*-64+'px';var hasPin=(this.getParent()&&this.getParent().toolTip&&this.getParent().toolTip.hasPin());if(this.complex['pin'].firstChild){this.complex['pin'].firstChild.src=hasPin?(ipath+'bubble.png'):this.mdvMap.transparent.src;this.complex['pin'].firstChild.onclick=hasPin?MDVToolTipBubble_OnPinClick:null;this.complex['pin'].firstChild.style.top=-701+'px';};this.complex['pin'].style.position='absolute';this.complex['pin'].style.overflow='hidden';this.complex['pin'].style.width='19px';this.complex['pin'].style.height='18px';this.complex['pin'].style.left=(size.x-29)+'px';this.complex['pin'].style.top=(10+this.innerOffset.y)+'px';};MDVToolTipBubble.prototype.update=function(){var point=this.mdvMap.getPoint(this.getParent().getCoords());if(!point){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,'MDVMap wasn\'t able to get px coordinates for marker.');return false;};var parent=this.getParent();var margin=new MDVPoint(0,0);var iwidth=0;var iheight=0;if(parent&&parent.img){margin.x=parent.img.width*parent.getXFactor();margin.y=parent.img.height*parent.getYFactor();iwidth=parent.img.width;iheight=parent.img.height;};if(parent.img&&(this.margins==null||(this.getLastParent()&&this.getLastParent().id!=this.getParent().id))){var tempPos=new MDVPoint(parseInt(this.div.style.left),parseInt(this.div.style.top));if(this.margins){this.div.style.left=(tempPos.x-this.margins.x)+'px';this.div.style.top=(tempPos.y-this.margins.y)+'px';};switch(this.pointerState){case 0:this.margins=new MDVPoint(iwidth-margin.x,0-margin.y);break;case 1:this.margins=new MDVPoint(0-margin.x,0-margin.y);break;case 2:this.margins=new MDVPoint(0-margin.x,iheight-margin.y);break;case 3:this.margins=new MDVPoint(iwidth-margin.x,iheight-margin.y);break;};this.setLastParent(this.getParent());}else if(parent.img==null){this.margins=null;this.setLastParent(null);};var viewport=this.mdvMap.getViewportExtends();if(!this.offset){this.offset=new MDVPoint(0+this.delta.x-this.pointerBorder.x,0);}else{this.offset.x+=this.delta.x;this.offset.y+=this.delta.y;};this.delta.x=0;this.delta.y=0;var xMargin=this.margins?this.margins.x:0;var yMargin=this.margins?this.margins.y:0;this.div.style.left=(point.x+this.offset.x+xMargin)+'px';this.div.style.top=(point.y+this.offset.y+yMargin)+'px';var pos=new MDVPoint(parseInt(this.div.style.left)+parseInt(this.mdvMap.mapper.style.left),parseInt(this.div.style.top)+parseInt(this.mdvMap.mapper.style.top));var update=false;var wrap={upper:true,lower:false,left:true,right:false};if(pos.y<=0){this.innerOffset.y=this.pointerSize.y-1;this.offset.y=0;if(this.margins)this.margins.y=(iheight-margin.y);wrap.upper=true;update=true;}else{wrap.upper=false;};if(pos.y+this.size.y+2*2>=viewport.height){this.innerOffset.y=0;this.offset.y=this.size.y*-1;if(this.margins)this.margins.y=0-margin.y;wrap.lower=true;update=true;}else{wrap.lower=false;};if(pos.x<0){this.pointerBorder.x=34;this.offset.x=0-34;if(this.margins)this.margins.x=iwidth-margin.x;wrap.left=true;update=true;}else{wrap.left=false;};if(pos.x+this.size.x+2*2+margin.x>viewport.width){this.offset.x=this.size.x*-1+34;this.pointerBorder.x=this.size.x-this.pointerSize.x-34;if(this.margins)this.margins.x=0-margin.x;wrap.right=true;update=true;}else{wrap.right=false;};if(update){var xMargin=this.margins?this.margins.x:0;var yMargin=this.margins?this.margins.y:0;this.div.style.left=(point.x+this.offset.x+xMargin)+'px';this.div.style.top=(point.y+this.offset.y+yMargin)+'px';};this.pointerState=this.wrapPointer(wrap);this.updateBubble();return true;};MDVToolTipBubble.prototype.wrapPointer=function(wrap){var p=this.pointerState;switch(this.pointerState){case 0:if(wrap.upper&&wrap.right)p=2;else if(wrap.right)p=1;else if(wrap.upper)p=3;break;case 1:if(wrap.upper&&wrap.left)p=3;else if(wrap.left)p=0;else if(wrap.upper)p=2;break;case 2:if(wrap.lower&&wrap.left)p=0;else if(wrap.left)p=3;else if(wrap.lower)p=1;break;case 3:if(wrap.lower&&wrap.right)p=1;else if(wrap.right)p=2;else if(wrap.lower)p=0;break;};return p;};function MDVToolTipBubble_OnPinClick(e){if(this.bubble&&this.bubble.getParent()&&this.bubble.getParent().toolTip){var fixed=this.bubble.getParent().toolTip.isFixed();this.bubble.complex['pin'].firstChild.style.left=(fixed?-662:-681)+'px';this.bubble.getParent().toolTip.setFixed(!fixed);}};function MDVToolTipSimple(mdvMap){this.mdvMap=mdvMap;this.id=this.mdvMap.lastContainerID++;this.div=null;this.point=null;this.append=false;this.visibility=false;this.mousePos=null;this.parentMarker=null;this.vacant=true;this.type='simple';for(var method in MDVToolTipContainer.prototype){if(!MDVToolTipSimple.prototype[method])MDVToolTipSimple.prototype[method]=MDVToolTipContainer.prototype[method];};this.init();this.div.className='MDVToolTip';};MDVToolTipSimple.prototype.update=function(){var point=this.mdvMap.getPoint(this.getParent().getCoords());var toolTipOffset=4;if(!point){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,'MDVMap wasn\'t able to get px coordinates for marker.');return false;};var parent=this.getParent();var xFactor=0;var iwidth=0;var iheight=0;if(parent.img){xFactor=parent.img.width*parent.getXFactor();iwidth=parent.img.width;iheight=parent.img.height;};this.div.style.position='absolute';this.div.style.left=(point.x+xFactor+toolTipOffset)+'px';this.div.style.top=(point.y+toolTipOffset)+'px';var width=this.mdvMap.getObjWidth(this.div);var height=this.mdvMap.getObjHeight(this.div);var offset=new MDVPoint(parseInt(this.mdvMap.mapper.style.left),parseInt(this.mdvMap.mapper.style.top));if(point.x+offset.x+width+xFactor+toolTipOffset>(this.mdvMap.viewportWidth-2)){this.div.style.left=(point.x-width-iwidth+xFactor-toolTipOffset)+'px';if(point.x-width-iwidth+xFactor-(toolTipOffset*2)+offset.x<=0){var moveLeft=point.x-width-iwidth+xFactor-(toolTipOffset*2)+offset.x;this.div.style.left=parseInt(this.div.style.left)-moveLeft+'px';}};if(point.y+offset.y+height+toolTipOffset>(this.mdvMap.viewportHeight-2)){var deltaTop=(point.y-height-iheight-(toolTipOffset*2)+offset.y);if(deltaTop>0)deltaTop=0;this.div.style.top=(point.y-height-iheight-toolTipOffset-deltaTop)+'px';};return true;};function MDVToolTipManager(mdvMap){this.mdvMap=mdvMap;this.growBy=1;this.containers=new Array();};MDVToolTipManager.prototype.require=function(type){var size=null;if(arguments.length==2)size=arguments[1];if(this.containers[type]==null){this.containers[type]=new Array();};for(var i=0;i<this.containers[type].length;i++){if(this.containers[type][i].isVacant()){var tip=this.containers[type][i];tip.setVacant(false);if(size&&tip.setSize)tip.setSize(size);return tip;}};var container=null;for(var i=0;i<this.growBy;i++){switch(type){case 'bubble':var tip=new MDVToolTipBubble(this.mdvMap,size);this.containers[type].push(tip);if(!container){container=tip;container.setVacant(false);};break;default:var tip=new MDVToolTipSimple(this.mdvMap);this.containers[type].push(tip);if(!container){container=tip;container.setVacant(false);};break;}};return container;};MDVToolTipManager.prototype.free=function(container){var type=container.getType();if(!this.containers[type])return false;for(var i=0;i<this.containers[type].length;i++){if(this.containers[type][i].id==container.id){this.containers[type][i].setVacant(true);return true;}};return false;};function MDVToolTipConsumer(){this.toolTip=null;this.coords=null;};MDVToolTipConsumer.prototype.getCoords=function(){return this.coords;};MDVToolTipConsumer.prototype.hide=function(){if(this.getToolTip())this.getToolTip().hide();};MDVToolTipConsumer.prototype.setCoords=function(coords){this.coords=coords;};MDVToolTipConsumer.prototype.getToolTip=function(){return this.toolTip;};MDVToolTipConsumer.prototype.setToolTip=function(toolTip){this.toolTip=toolTip;this.toolTip.setParent(this);this.toolTip.setCoords(this.coords);};function MDVLayer(mdvMap,layerName){if(!mdvMap||layerName=='')return;this.name=layerName;this.mdvMap=mdvMap;this.zIndex=0;this.id=mdvMap.lastLayerID++;this.visible=true;this.append=false;this.markers=new Array();this.polylines=new Array();};MDVLayer.prototype.getPolylineCoords=function(){var arr=new Array();for(var i=0;i<this.polylines.length;i++){if(this.polylines[i]==null)continue;for(var c=0;c<this.polylines[i].coords.length;c++){arr.push(this.polylines[i].coords[c]);}};return arr;};MDVLayer.prototype.getName=function(){return this.name;};MDVLayer.prototype.destroy=function(){var pLength=this.polylines.length;for(var p=0;p<pLength;p++){var polyline=this.polylines.pop();if(polyline)polyline.destroy();};this.mdvMap=null;this.layer=null;this.renderer=null;};MDVLayer.prototype.addPolyline=function(polyline){if(!polyline)return false;var update=true;for(var p=0;p<this.polylines.length;p++){if(this.polylines[p]&&this.polylines[p].id==polyline.id)return false;};if(arguments.length==2)update=arguments[1];polyline.layer=this;this.polylines.push(polyline);if(update){this.update();};return true;};MDVLayer.prototype.removePolyline=function(polyline){if(!polyline)return false;for(var p=0;p<this.polylines.length;p++){if(this.polylines[p]&&this.polylines[p].id==polyline.id){if(this.mdvMap.renderer.removePolyline(this.polylines[p]))this.polylines[p]=null;return true;}};return false;};MDVLayer.prototype.hideToolTips=function(){var ret=false;for(var m=0;m<this.markers.length;m++){if(this.markers[m].toolTip){mdvTimer.remove(this.markers[m].toolTip.job);if(this.markers[m].toolTip.isVisible()){this.markers[m].toolTip.hide();ret=true;}}};for(var p=0;p<this.polylines.length;p++){if(this.polylines[p]&&this.polylines[p].toolTip){mdvTimer.remove(this.polylines[p].toolTip.job);if(this.polylines[p].toolTip.isVisible())this.polylines[p].toolTip.hide();ret=true;}};return ret;};MDVLayer.prototype.setVisibility=function(visibility){if(this.visible!=visibility){this.visible=visibility;for(var m=0;m<this.markers.length;m++){this.markers[m].setVisibility(this.visible)}}};MDVLayer.prototype.update=function(){for(var m=0;m<this.markers.length;m++){if(this.name!='efa_trip')this.markers[m].setVisibility(this.visible);this.markers[m].update();};if(this.mdvMap.renderer)this.mdvMap.renderer.update();for(var p=0;p<this.polylines.length;p++){if(this.polylines[p]&&this.polylines[p].append)this.mdvMap.renderer.removePolyline(this.polylines[p]);this.mdvMap.renderer.drawPolyline(this.polylines[p]);};this.mdvMap.events.triggerEvent(MDVEvent_LAYER_UPDATED,'MDVMap has updated layer ('+this.name+')',this);};MDVLayer.prototype.addMarker=function(marker){var update=true;for(var m=0;m<this.markers.length;m++){if(this.markers[m].id==marker.id){return false;}};if(arguments.length==2)update=arguments[1];marker.layer=this;this.markers.push(marker);marker.img.src=marker.imgSrc;return true;};MDVLayer.prototype.removeMarker=function(marker){if(marker==null)return false;var tempArr=new Array();var update=false;var markersLength=this.markers.length;for(var m=0;m<markersLength;m++){var temp=this.markers.shift();if(temp.id==marker.id){this.markers=tempArr.concat(this.markers);this.mdvMap.markerObjects.removeChild(temp.img);temp.append=false;update=true;break;};tempArr.push(temp);};return update;};MDVLayer.prototype.getMarkers=function(){return this.markers;};MDVLayer.prototype.getPolylines=function(){return this.polylines;};MDVLayer.prototype.removeAll=function(){var markers=this.removeAllMarkers();var polylines=this.removeAllPolylines();return markers&&polylines;};MDVLayer.prototype.removeAllPolylines=function(){var p=null;var ret=false;while(p=this.polylines.pop()){if(this.mdvMap.renderer.removePolyline(p)){ret=true;}};return ret;};MDVLayer.prototype.removeAllMarkers=function(){var markersLength=this.markers.length;var remain=new Array();for(var m=0;m<markersLength;m++){var temp=this.markers.pop();if(temp.toolTip&&temp.toolTip.isVisible()&&temp.toolTip.isFixed()){remain.push(temp);continue;};if(temp.append){this.mdvMap.markerObjects.removeChild(temp.img);temp.append=false;};temp.destroy();};this.markers=remain;return true;};MDVLayer.prototype.setZIndex=function(zIndex){this.zIndex=zIndex*this.id;};function MDVTimer(){this.jobs=new Array();};MDVTimer.prototype.add=function(timeout,target,func,arg){var pos=this.jobs.length;for(var i=0;i<this.jobs.length;i++){if(this.jobs[i]==null){pos=i;break;}};var id=window.setTimeout('MDVTimer_execute('+pos+')',timeout);this.jobs[pos]=new MDVTimerJob(id,target,func,arg);return pos;};MDVTimer.prototype.remove=function(id){if(this.jobs[id]!=null){window.clearTimeout(this.jobs[id].id);this.jobs[id]=null;return true;};return false;};var mdvTimer=new MDVTimer();function MDVTimerJob(id,target,func,arg){this.id=id;this.target=target;this.func=func;this.arg=arg;};function MDVTimer_execute(pos){if(mdvTimer.jobs[pos]!=null){var target=mdvTimer.jobs[pos].target;var func=mdvTimer.jobs[pos].func;if(mdvTimer.jobs[pos].arg!=null&&target!=null)func.apply(target,mdvTimer.jobs[pos].arg);else func.apply(target);mdvTimer.jobs[pos]=null;}};function MDVRenderer(mdvMap,container){this.mdvMap=mdvMap;this.container=container;this.max=null;this.min=null;this.border=10;this.offset=new MDVPoint(0,0);this.boundingBox=null;};MDVRenderer.prototype.drawPolyline=function(polyline){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,'MDVMap: Not implemented.');return false;};MDVRenderer.prototype.removePolyline=function(polyline){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,'MDVMap: Not implemented.');return false;};MDVRenderer.prototype.setBoundingBox=function(){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,'MDVMap: Not implemented.');return false;};MDVRenderer.prototype.update=function(){var coords=this.mdvMap.getPolylinePoints();if(coords.length!=2||coords[0].length<=0||coords[1].length<=0)return false;var x=coords[0];var y=coords[1];x.sort(MDVMap_NumSort);y.sort(MDVMap_NumSort);this.max=new MDVPoint(x[x.length-1],y[y.length-1]);this.min=new MDVPoint(x[0],y[0]);var bBoxMax=this.max.clone();var bBoxMin=this.min.clone();bBoxMax.x+=this.getBorder();bBoxMax.y+=this.getBorder();bBoxMin.x-=this.getBorder();bBoxMin.y-=this.getBorder();this.boundingBox=[bBoxMin.clone(),bBoxMax.clone()];this.setBoundingBox();return true;};MDVRenderer.prototype.getBorder=function(){return this.border;};function MDVVMLRenderer(mdvMap,container){this.mdvMap=mdvMap;this.container=container;this.max=null;this.min=null;this.border=50;this.offset=new MDVPoint(0,0);this.boundingBox=null;this.group=null;document.namespaces.add("v","urn:schemas-microsoft-com:vml");var style=document.createStyleSheet();style.addRule('v\\:*',"behavior: url(#default#VML);");this.group=document.createElement('v:group');this.container.appendChild(this.group);for(var method in MDVRenderer.prototype){if(!MDVVMLRenderer.prototype[method])MDVVMLRenderer.prototype[method]=MDVRenderer.prototype[method];}};MDVVMLRenderer.prototype.drawPolyline=function(polyline){if(!polyline)return false;var pathStr='m';for(var i=0;i<polyline.coords.length;i++){var point=this.mdvMap.getPoint(polyline.coords[i]);var x=point.x-this.offset.x;var y=point.y-this.offset.y;pathStr+=x+','+y;if(i<polyline.coords.length-1)pathStr+=' ';if(i==0)pathStr+='l';};pathStr+=' e';var width=this.boundingBox[1].x-this.boundingBox[0].x;var height=this.boundingBox[1].y-this.boundingBox[0].y;var left=this.boundingBox[0].x;var top=this.boundingBox[0].y;var colour=polyline.get('colour');if(!colour)colour='red';var weight=polyline.get('weight');if(!weight)weight='4px';var opacity=polyline.get('opacity');if(!opacity)opacity='0.5';if(!polyline.append){var shape=document.createElement("v:shape");shape.style.position='relative';shape.style.top='0px';shape.style.left='0px';shape.style.width=width;shape.style.height=height;shape.setAttribute('filled','false');shape.setAttribute('stroked','true');shape.setAttribute('strokecolor',colour);shape.setAttribute('strokeweight',weight);shape.setAttribute('path',pathStr);var stroke=document.createElement("v:stroke");stroke.setAttribute('opacity',opacity);stroke.setAttribute('joinstyle','round');stroke.setAttribute('endcap','round');shape.appendChild(stroke);this.group.appendChild(shape);shape.parentPolyline=polyline;polyline.element=shape;polyline.element.mdvMap=this.mdvMap;polyline.append=true;}else if(polyline.element.path.value!=pathStr){polyline.element.path.value=pathStr;};if(polyline.toolTip)polyline.setToolTip(polyline.toolTip);return true;};MDVVMLRenderer.prototype.removePolyline=function(polyline){if(!polyline||!polyline.append||polyline.element==null)return false;this.group.removeChild(polyline.element);polyline.element.onmousedown=null;polyline.element.onmousemove=null;polyline.element.onmouseout=null;polyline.element.onmouseover=null;polyline.element.onmouseup=null;if(polyline.element.toolTip)polyline.element.toolTip=null;if(polyline.element.mdvMap)polyline.element.mdvMap=null;polyline.element=null;polyline.append=false;return true;};MDVVMLRenderer.prototype.setBoundingBox=function(){var width=this.boundingBox[1].x-this.boundingBox[0].x;var height=this.boundingBox[1].y-this.boundingBox[0].y;var left=this.boundingBox[0].x;var top=this.boundingBox[0].y;this.offset=new MDVPoint(left,top);this.group.style.behavior='url(#default#VML)';this.group.style.width=width+'px';this.group.style.height=height+'px';this.group.style.position='absolute'
this.group.style.left=left+'px';this.group.style.top=top+'px';this.group.setAttribute('coordsize',width+','+height);return true;};function MDVSVGRenderer(mdvMap,container){this.mdvMap=mdvMap;this.container=container;this.max=null;this.min=null;this.border=10;this.offset=new MDVPoint(0,0);this.boundingBox=null;this.svgNS='http://www.w3.org/2000/svg';this.svg=document.createElementNS(this.svgNS,"svg");this.svg.setAttributeNS(null,'overflow','visible');this.container.appendChild(this.svg);for(var method in MDVRenderer.prototype){if(!MDVSVGRenderer.prototype[method])MDVSVGRenderer.prototype[method]=MDVRenderer.prototype[method];}};MDVSVGRenderer.prototype.drawPolyline=function(polyline){if(!polyline)return false;var pathStr='M';for(var i=0;i<polyline.coords.length;i++){var point=this.mdvMap.getPoint(polyline.coords[i]);var x=point.x-this.offset.x;var y=point.y-this.offset.y;pathStr+=x+','+y;if(i<polyline.coords.length-1)pathStr+=' ';if(i==0)pathStr+='L';};if(!polyline.append){var colour=polyline.get('colour');if(!colour)colour='red';var weight=polyline.get('weight');if(!weight)weight='4px';var opacity=polyline.get('opacity');if(!opacity)opacity='0.50';var path=document.createElementNS(this.svgNS,'path');path.setAttributeNS(null,'d',pathStr);path.setAttributeNS(null,'stroke-linejoin','round');path.setAttributeNS(null,'stroke-linecap','round');path.setAttributeNS(null,'stroke-opacity',opacity);path.setAttributeNS(null,'stroke-width',weight);path.setAttributeNS(null,'stroke',colour);path.setAttributeNS(null,'fill','none');this.svg.appendChild(path);path.parentPolyline=polyline;polyline.element=path;polyline.element.mdvMap=this.mdvMap;polyline.append=true;}else{if(polyline.element)polyline.element.setAttributeNS(null,'d',pathStr);};if(polyline.toolTip)polyline.setToolTip(polyline.toolTip);return true;};MDVSVGRenderer.prototype.removePolyline=function(polyline){if(!polyline||!polyline.append||polyline.element==null)return false;this.svg.removeChild(polyline.element);polyline.element.onmousedown=null;polyline.element.onmousemove=null;polyline.element.onmouseout=null;polyline.element.onmouseover=null;polyline.element.onmouseup=null;if(polyline.element.toolTip)polyline.element.toolTip=null;if(polyline.element.mdvMap)polyline.element.mdvMap=null;polyline.element=null;polyline.append=false;return true;};MDVSVGRenderer.prototype.setBoundingBox=function(){var width=this.boundingBox[1].x-this.boundingBox[0].x;var height=this.boundingBox[1].y-this.boundingBox[0].y;var left=this.boundingBox[0].x;var top=this.boundingBox[0].y;this.offset=new MDVPoint(left,top);this.svg.setAttributeNS(null,'width',width+'px');this.svg.setAttributeNS(null,'height',height+'px');this.svg.setAttributeNS(null,'style','position: absolute; left: '+left+'px; top: '+top+'px;');return true;};function MDVPolyline(mdvMap,coords){if(!mdvMap)return;this.mdvMap=mdvMap;this.id=mdvMap.lastPolylineID++;this.coords=null;this.toolTip=null;this.attributes=new Array();this.element=null;this.renderer=this.mdvMap.renderer;this.layer=null;this.append=false;this.markers=new Array();this.mouse=null;this.arrows=new Array();if(typeof coords=='string')this.coords=this.parseString(coords);else if(typeof coords=='object')this.coords=coords;};MDVPolyline.prototype.setMouse=function(mouse){this.mouse=mouse;};MDVPolyline.prototype.destroy=function(){this.mdvMap=null;this.coords=null;if(this.toolTip)this.toolTip.destroy();this.coords=null;this.mdvMap=null;if(this.element){if(this.element.mdvMap)this.element.mdvMap=null;this.element.onmouseover=null;this.element.onmouseout=null;this.element.onclick=null;this.element=null;}};MDVPolyline.prototype.parseString=function(coordStr){var coordArray=coordStr.split(' ');var retArr=new Array();for(var i=0;i<coordArray.length;i++){var couple=coordArray[i].split(',');if(couple[0]&&couple[1]){var tempCoords=new MDVCoordinates(this.mdvMap.config.get('mapName'),couple[0],couple[1]);retArr.push(tempCoords);}};return retArr;};MDVPolyline.prototype.add=function(key,value){for(var i=0;i<this.attributes.length;i++){if(this.attributes[i].key==key)return false;};this.attributes[key]=value;return true;};MDVPolyline.prototype.get=function(key){if(this.attributes[key])return this.attributes[key];else return false;};MDVPolyline.prototype.getAllCoords=function(){return this.coords;};MDVPolyline.prototype.getCoords=function(){if(this.mouse)return this.mouse;var coords=new Array();coords['x']=new Array();coords['y']=new Array();var c=this.getAllCoords();for(var i=0;i<c.length;i++){coords['x'].push(c[i].x);coords['y'].push(c[i].y);};coords['x'].sort(MDVMap_NumSort);coords['y'].sort(MDVMap_NumSort);return new MDVCoordinates(c[0].mapName,Math.floor(0.5+(coords['x'][coords['x'].length-1]+coords['x'][0])/2),Math.floor(0.5+(coords['y'][coords['y'].length-1]+coords['y'][0])/2));};MDVPolyline.prototype.setToolTip=function(tooltip){if(!tooltip)return false;var update=true;if(arguments.length==2)update=arguments[1];var ttCoords=this.coords[0].clone();ttCoords.x=Math.floor(0.5+(parseInt(ttCoords.x)+parseInt(this.coords[this.coords.length-1].x))/2);ttCoords.y=Math.floor(0.5+(parseInt(ttCoords.y)+parseInt(this.coords[this.coords.length-1].y))/2);this.toolTip=tooltip;this.toolTip.setParent(this);this.toolTip.setCoords(ttCoords);if(update)this.toolTip.update();if(this.element){this.element.toolTip=tooltip;this.element.onmouseover=MDVMarker_displayToolTip;this.element.onmouseout=MDVMarker_hideToolTip;};return true;};MDVPolyline.prototype.getArrow=function(pos,next){var p=this;var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.currentZoomLevelIndex);var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var pxToRealRatioWidth=parseInt(zoomLevel.get('realWidth'))/pxWidthAll;var pxHeightAll=parseInt(zoomLevel.get('tileSizeY'))*parseInt(zoomLevel.get('numberOfTilesY'));var pxToRealRatioHeight=parseInt(zoomLevel.get('realHeight'))/pxHeightAll;var a=next.x-pos.x;var b=next.y-pos.y;var angle=Math.atan2(b,a);var arrow=new Array();var retArrow=null;arrow.push([new MDVCoordinates(pos.mapName,pos.x-5*pxToRealRatioWidth,pos.y-6*pxToRealRatioHeight),new MDVCoordinates(pos.mapName,pos.x,pos.y)]);arrow.push([new MDVCoordinates(pos.mapName,pos.x-5*pxToRealRatioWidth,pos.y+6*pxToRealRatioHeight),new MDVCoordinates(pos.mapName,pos.x,pos.y)]);for(var i=0;i<arrow.length;i++){var v=new MDVPoint(arrow[i][0].x-arrow[i][1].x,arrow[i][0].y-arrow[i][1].y);var n=new MDVPoint(0,0);n.x=v.x*Math.cos(angle)-v.y*Math.sin(angle);n.y=v.x*Math.sin(angle)+v.y*Math.cos(angle);arrow[i][0].x=arrow[i][1].x+n.x;arrow[i][0].y=arrow[i][1].y+n.y;};retArrow=this.mdvMap.createPolyline(arrow[0][0].x+','+arrow[0][0].y+' '+arrow[0][1].x+','+arrow[0][1].y+' '+arrow[1][0].x+','+arrow[1][0].y+' '+arrow[1][1].x+','+arrow[1][1].y);if(p.get('weight'))retArrow.add('weight',p.get('weight'));else retArrow.add('weight','3');if(p.get('colour'))retArrow.add('colour',p.get('colour'));if(p.get('opacity'))retArrow.add('opacity',p.get('opacity'));else retArrow.add('opacity','0.5');return retArrow;};MDVPolyline.prototype.getArrows=function(){var coordSeq=this.getAllCoords();var max=20;var arrows=new Array();var counter=0;var iter=0;if(this.mdvMap.config.get('trips.polyline.arrows.max'))max=parseInt(this.mdvMap.config.get('trips.polyline.arrows.max'));var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.currentZoomLevelIndex);var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var realToPxRatioWidth=pxWidthAll/parseInt(zoomLevel.get('realWidth'));while(counter<=0&&iter<3){for(var c=0;c<coordSeq.length-1;c++){if(!coordSeq[c]||!coordSeq[c+1])return null;var vec=new MDVPoint(coordSeq[c+1].x-coordSeq[c].x,coordSeq[c+1].y-coordSeq[c].y);var dist=Math.sqrt(Math.pow(vec.x,2)+Math.pow(vec.y,2));dist*=realToPxRatioWidth;if(dist>max){arrows.push(this.getArrow(new MDVCoordinates(coordSeq[c].mapName,coordSeq[c].x+vec.x/ 2, coordSeq[c].y+ vec.y/ 2),coordSeq[c+1].clone()));counter++;}};max-=4;iter++;};return arrows;};function MDVMap_NumSort(a,b){return a-b;};function MDVHotspots(mapName){if(!mdvMap){return;};this.mdvMap=mdvMap;this.name='MDVHotspots';this.data=[];this.current=null;this.json=null;this.viewportRealTl=new MDVCoordinates(this.mdvMap.name,parseInt(this.mdvMap.config.get('xCenterReal')-(this.mdvMap.viewportRealWidth*0.5)),parseInt(this.mdvMap.config.get('xCenterReal')-(this.mdvMap.viewportRealHeight*0.5)));this.viewportRealBr=new MDVCoordinates(this.mdvMap.name,parseInt(this.mdvMap.config.get('xCenterReal')+(this.mdvMap.viewportRealWidth*0.5)),parseInt(this.mdvMap.config.get('xCenterReal')+(this.mdvMap.viewportRealHeight*0.5)));;this.level=null;this.mapNavigator=null;this.tooltip=new MDVToolTipConsumer();var tempTT=this.mdvMap.createToolTip();this.tooltip.setToolTip(tempTT);this.mdvMap.hotspots=this;this.mdvMap.events.registerEvent(MDVEvent_CENTRE_CHANGED,this,this.onCentreChanged);this.mdvMap.events.registerEvent(MDVEvent_MOUSE_MOVED,this,this.check);this.mdvMap.events.registerEvent(MDVEvent_MOUSE_UP,this,this.appendExec);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.onLevelChanged);};MDVHotspots.prototype.onCentreChanged=function(id,msg,obj){if(this.json===null){return;};if(this.mdvMap.config.getZoomLevelIndex()<this.mdvMap.config.get('showHotspotLevel')){return true;};this.viewportRealTl=new MDVCoordinates(this.mdvMap.name,parseInt(obj.x-(this.mdvMap.viewportRealWidth*0.5)),parseInt(obj.y-(this.mdvMap.viewportRealHeight*0.5)));this.viewportRealBr=new MDVCoordinates(this.mdvMap.name,parseInt(obj.x+(this.mdvMap.viewportRealWidth*0.5)),parseInt(obj.y+(this.mdvMap.viewportRealHeight*0.5)));};MDVHotspots.prototype.onLevelChanged=function(){if(this.json===null){return;};var level=this.mdvMap.config.getZoomLevelIndex();if(level<this.mdvMap.config.get('showHotspotLevel')||level===this.level){return true;};var newCentre=this.mdvMap.getCentre();this.viewportRealTl=new MDVCoordinates(this.mdvMap.name,parseInt(newCentre.x-(this.mdvMap.viewportRealWidth*0.5)),parseInt(newCentre.y-(this.mdvMap.viewportRealHeight*0.5)));this.viewportRealBr=new MDVCoordinates(this.mdvMap.name,parseInt(newCentre.x+(this.mdvMap.viewportRealWidth*0.5)),parseInt(newCentre.y+(this.mdvMap.viewportRealHeight*0.5)));this.appendExec();};MDVHotspots.prototype.isInArea=function(point,area_tl,area_br){if(!point.x||!point.y||!area_tl.x||!area_tl.y||!area_tl.x||!area_br.y){return;};if(point.x>area_tl.x==false){return false;};if(point.x<area_br.x==false){return false;};if(point.y>area_tl.y==false){return false;};if(point.y<area_br.y==false){return false;};return true;};MDVHotspots.prototype.appendExec=function(){if(this.json===null){return;};if(this.mdvMap.config.getZoomLevelIndex()<this.mdvMap.config.get('showHotspotLevel')){return true;};var that=this.mdvMap;this.data.length=0;function areaContains(box){var mn=that.config.get('mapName');var poi_tl=new MDVCoordinates(mn,parseInt(box[0]),parseInt(box[1]));var poi_br=new MDVCoordinates(mn,parseInt(box[2]),parseInt(box[3]));var vp_tl=this.viewportRealTl;var vp_br=this.viewportRealBr;if(this.isInArea(poi_tl,vp_tl,vp_br)||this.isInArea(poi_br,vp_tl,vp_br)){return true;}else{return false;}};var pois=this.json||[];for(var i=0,p=pois.length;i<p;i++){if(areaContains.bind(this)(pois[i][2])){this.data.push(pois[i]);}}};MDVHotspots.prototype.retrieve=function(){if(!this.mdvMap.config.get('hotspotURL')){return;};for(var i=0;i<this.mdvMap.gadgets.length;i++){if(this.mdvMap.gadgets[i].name==='MapNavigator'){this.mapNavigator=this.mdvMap.gadgets[i];break;}};if(this.json==null){if($.get){$.get(this.mdvMap.config.get('hotspotURL'),assignAjaxResponse.bind(this));}else{new Ajax.Request(this.mdvMap.config.get('hotspotURL'),{method:'get',onComplete:assignAjaxResponse.bind(this)});}};function assignAjaxResponse(response){var _response=response.responseText||response;this.json=eval(_response);this.onLevelChanged();}};MDVHotspots.prototype.check=function(id,msg,obj){if(this.mdvMap.config.getZoomLevelIndex()<this.mdvMap.config.get('showHotspotLevel')){return true;};if(!obj||!this.data||this.data.length==0){return;};var that=this.mdvMap;var mn=that.config.get('mapName');for(var i=0,j=this.data.length;i<j;i++){var c=this.data[i][2];var poi_tl=new MDVCoordinates(mn,parseInt(c[0]),parseInt(c[1]));var poi_br=new MDVCoordinates(mn,parseInt(c[2]),parseInt(c[3]));if(this.isInArea(obj,poi_tl,poi_br)){that.getMapper().style.cursor='pointer';this.current=this.data[i];this.triggerTooltip(id,msg,obj);break;}else{that.setDefaultCursor();this.tooltip.getToolTip().hide();this.current=null;}}};MDVHotspots.prototype.triggerTooltip=function(id,msg,obj){var centerX=obj.x+10;var centerY=obj.y+10;this.tooltip.setCoords(new MDVCoordinates(this.mdvMap.name,centerX,centerY));this.tooltip.getToolTip().setInnerHTML(this.current[1]);this.tooltip.getToolTip().display();};function MDVGadgetBase(mdvMap){if(!mdvMap)return;this.name='GadgetBase';this.mdvMap=mdvMap;this.active=true;this.mdvMap.registerGadget(this);};MDVGadgetBase.prototype.stopEvent=function(e){if(!e)return true;e.cancelBubble=true;e.returnValue=false;if(e.stopPropagation)e.stopPropagation();if(e.preventDefault)e.preventDefault();return false;};MDVGadgetBase.prototype.destroy=function(){if(this.mdvMap)this.mdvMap=null;this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null;};MDVGadgetBase.prototype.setActive=function(active){this.active=active;};MDVGadgetBase.prototype.isActive=function(){return this.active;};MDVGadgetBase.prototype.ondblclick=function(e){return true;};MDVGadgetBase.prototype.onkeypress=function(e){return true;};MDVGadgetBase.prototype.onmousedown=function(e){return true;};MDVGadgetBase.prototype.onmousemove=function(e){return true;};MDVGadgetBase.prototype.onmouseout=function(e){return true;};MDVGadgetBase.prototype.onmouseover=function(e){return true;};MDVGadgetBase.prototype.onmouseup=function(e){return true;};MDVGadgetBase.prototype.onmousewheel=function(e){return true;};MDVGadgetBase.prototype.oncontextmenu=function(e){return true;};function MDVMapNavigator(mdvMap){if(!mdvMap)return;this.name='MapNavigator';this.mdvMap=mdvMap;this.mouseDown=false;this.centre;this.mouseLast=new MDVPoint(-1,-1);this.mouseStart=new MDVPoint(-1,-1);this.mwHotSpot=null;this.mdvMap.registerGadget(this);for(var method in MDVGadgetBase.prototype){if(!MDVMapNavigator.prototype[method])MDVMapNavigator.prototype[method]=MDVGadgetBase.prototype[method];};this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.setDefaultCursor);this.mdvMap.events.registerEvent(MDVEvent_MOUSE_MOVED,this,this.updateMWHotSpot);};MDVMapNavigator.prototype.destroy=function(){if(this.mdvMap)this.mdvMap=null;this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null;};MDVMapNavigator.prototype.updateMWHotSpot=function(id,msg,coords){if(this.mdvMap.config.get('centreOnMouseWheel')&&this.mdvMap.config.get('centreOnMouseWheel')=='true')this.mwHotSpot=coords.clone();};MDVMapNavigator.prototype.setDefaultCursor=function(){if(this.mdvMap.config.get('cursorIdle')){if(document.all)this.mdvMap.getMapper().style.cursor='url(\'' + this.mdvMap.config.get('cursorIdle') + '\')';else this.mdvMap.getMapper().style.cursor='-moz-grab';}};MDVMapNavigator.prototype.oncontextmenu=function(e){return false;};MDVMapNavigator.prototype.ondblclick=function(e){e=e?e:window.event;var mX=e.pageX||(e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var mY=e.pageY||(e.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var offsetL=0;var offsetT=0;var obj=this.mdvMap.viewport;while(obj){offsetL+=obj.offsetLeft;offsetT+=obj.offsetTop;obj=obj.offsetParent;};mX=mX-(offsetL);mY=mY-(offsetT);var magnify=(this.mdvMap.config.get('useMagnifyGlass')&&this.mdvMap.config.get('useMagnifyGlass')=='true');var point=new MDVPoint(mX,mY);var newC=this.mdvMap.getCoordinates(point);var oldP=this.mdvMap.getPoint(this.mdvMap.getCentre());oldP.x+=parseInt(this.mdvMap.getMapper().style.left);oldP.y+=parseInt(this.mdvMap.getMapper().style.top);var delta=new MDVPoint(oldP.x-point.x,oldP.y-point.y);if(this.mdvMap.config.get('zoomOnDoubleClick')&&this.mdvMap.config.get('zoomOnDoubleClick')=='true'){this.mdvMap.setCentre(newC);this.mdvMap.getMapper().style.left=parseInt(this.mdvMap.getMapper().style.left)+delta.x+'px';this.mdvMap.getMapper().style.top=parseInt(this.mdvMap.getMapper().style.top)+delta.y+'px';var newZoomLevel=this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1);if(newZoomLevel!=null&&magnify){this.mdvMap._checkWrap();this.mdvMap.magnify(parseInt(this.mdvMap.config.getZoomLevelIndex())+1);this.mdvMap.switchMapper();}else if(newZoomLevel!=null&&!magnify){this.mdvMap.setZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1);this.mdvMap.update();}else{this.mdvMap.update();}}else if(this.mdvMap.config.get('moveOnDoubleClick')&&this.mdvMap.config.get('moveOnDoubleClick')=='true'){var seq=[this.mdvMap.getCentre().clone(),newC.clone()];this.mdvMap.moveBySeq(seq);}else{this.mdvMap.setCentre(newC);this.mdvMap.update();this.mdvMap.events.triggerEvent(MDVEvent_MAP_INITIALISED,'MDVMap tiles have been initialised',this.mdvMap);};this.stopEvent(e);return false;};MDVMapNavigator.prototype.onmousewheel=function(e){e=e?e:window.event;var ua=navigator.userAgent;var newC=null;if(this.mdvMap.config.get('centreOnMouseWheel')&&this.mdvMap.config.get('centreOnMouseWheel')=='true')newC=this.mwHotSpot;var wheelDelta=e.wheelDelta?e.wheelDelta:e.detail*-1;if(ua.indexOf('Opera')>=0)wheelDelta*=-1;if(wheelDelta>0){var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex()+1);if(zoomLevel!=null){if(newC)this.mdvMap.setCentre(newC);newC=null;if(this.mdvMap.config.get('useMagnifyGlass')&&this.mdvMap.config.get('useMagnifyGlass')=='true'){this.mdvMap.magnify(this.mdvMap.config.getZoomLevelIndex()+1);this.mdvMap.switchMapper();}else{this.mdvMap.setZoomLevel(this.mdvMap.config.getZoomLevelIndex()+1);this.mdvMap.update();}}}else{var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex()-1);if(zoomLevel!=null){newC=null;if(this.mdvMap.config.get('useMagnifyGlass')&&this.mdvMap.config.get('useMagnifyGlass')=='true'){this.mdvMap.magnify(this.mdvMap.config.getZoomLevelIndex()-1);this.mdvMap.switchMapper();}else{this.mdvMap.setZoomLevel(this.mdvMap.config.getZoomLevelIndex()-1);this.mdvMap.update();}}};this.stopEvent(e);return false;};MDVMapNavigator.prototype.onmousedown=function(e){e=e?e:window.event;var ua=navigator.userAgent;if((e.button==0&&!window.event)||(e.button==1&&window.event)||(e.button==0&&ua.indexOf('Opera')>=0)||(e.button==0&&ua.indexOf('Safari')>=0)){var mX=e.pageX||(e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var mY=e.pageY||(e.clientY+(document.documentElement.scrollTop||document.body.scrollTop));this.mouseLast.x=mX;this.mouseLast.y=mY;this.mouseStart.x=this.mouseLast.x;this.mouseStart.y=this.mouseLast.y;if(!this.mouseDown){if(this.mdvMap.config.get('cursorMove')){if(document.all)this.mdvMap.getMapper().style.cursor='url(\'' + this.mdvMap.config.get('cursorMove') + '\')';else this.mdvMap.getMapper().style.cursor='-moz-grabbing';}else this.mdvMap.getMapper().style.cursor='auto';};this.centre=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);this.mouseDown=true;return this.stopEvent(e);}else{return true;}};MDVMapNavigator.prototype.onmouseup=function(e){e=e?e:window.event;if(this.mouseDown){if(document.all&&e.type=='mouseout')return true;if(this.mdvMap.config.get('cursorIdle')){if(document.all)this.mdvMap.getMapper().style.cursor='url(\'' + this.mdvMap.config.get('cursorIdle') + '\')';else this.mdvMap.getMapper().style.cursor='-moz-grab';}else{this.mdvMap.getMapper().style.cursor='auto';};var centre=this.mdvMap.getCentre();if(this.centre&&(this.centre.x!=centre.x||this.centre.y!=centre.y)){this.mdvMap.events.triggerEvent(MDVEvent_MAP_INITIALISED,'MDVMap tiles have been initialised',this.mdvMap);}};this.mouseDown=false;return false;};MDVMapNavigator.prototype.onmouseout=function(e){e=e?e:window.event;var src=e.srcElement?e.srcElement:e.target;var obj=e.srcElement?src.parentElement:src.parentNode;while(obj){if(obj.className=='mdvLayer')return true;obj=e.srcElement?obj.parentElement:obj.parentNode;};return this.onmouseup(e);};MDVMapNavigator.prototype.onmousemove=function(e){e=e?e:window.event;var mouseX=e.pageX||(e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var mouseY=e.pageY||(e.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var offsetL=0;var offsetT=0;var obj=this.mdvMap.viewport;while(obj){offsetL+=obj.offsetLeft;offsetT+=obj.offsetTop;obj=obj.offsetParent;};mouseX=mouseX-(offsetL);mouseY=mouseY-(offsetT);var centrePoint=new MDVPoint(mouseX,mouseY);var centreCoords=this.mdvMap.getCoordinates(centrePoint);this.mdvMap.events.triggerEvent(MDVEvent_MOUSE_MOVED,'MDVMap noticed a mouse movement.',centreCoords);if(this.mouseDown){if(this.mdvMap.config.get('cursorMove')){if(document.all)this.mdvMap.getMapper().style.cursor='url(\'' + this.mdvMap.config.get('cursorMove') + '\')';else this.mdvMap.getMapper().style.cursor='-moz-grabbing';}else this.mdvMap.getMapper().style.cursor='auto';var mX=e.pageX||(e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var mY=e.pageY||(e.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var tl=new MDVPoint(parseInt(this.mdvMap.getMapper().style.left),parseInt(this.mdvMap.getMapper().style.top));var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.currentZoomLevelIndex);var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var realToPxRatioWidth=parseInt(zoomLevel.get('realWidth'))/pxWidthAll;var pxHeightAll=parseInt(zoomLevel.get('tileSizeY'))*parseInt(zoomLevel.get('numberOfTilesY'));var realToPxRatioHeight=parseInt(zoomLevel.get('realHeight'))/pxHeightAll;var realOffset=new MDVPoint(((mX-this.mouseLast.x)*realToPxRatioWidth),(mY-this.mouseLast.y)*realToPxRatioHeight);var newCentre=new MDVCoordinates(this.mdvMap.config.get('mapName'),this.mdvMap.real.x-realOffset.x,this.mdvMap.real.y-realOffset.y);this.mdvMap.setCentre(newCentre);if(this.mdvMap.getCentre().x==newCentre.x){this.mdvMap.getMapper().style.left=(tl.x+(mX-this.mouseLast.x))+'px';this.mdvMap.getMagnifyMapper().style.left=(parseInt(this.mdvMap.getMagnifyMapper().style.left)+(mX-this.mouseLast.x))+'px';};if(this.mdvMap.getCentre().y==newCentre.y){this.mdvMap.getMapper().style.top=(tl.y+(mY-this.mouseLast.y))+'px';this.mdvMap.getMagnifyMapper().style.top=(parseInt(this.mdvMap.getMagnifyMapper().style.top)+(mY-this.mouseLast.y))+'px';};this.mouseLast.x=mX;this.mouseLast.y=mY;this.mdvMap._checkWrap();}};function MDVMapCrosshair(mdvMap){if(!mdvMap)return;this.name='MapCrosshair';this.mdvMap=mdvMap;this.mdvMap.registerGadget(this);for(var method in MDVGadgetBase.prototype){if(!MDVMapCrosshair.prototype[method])MDVMapCrosshair.prototype[method]=MDVGadgetBase.prototype[method];};this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.execute);};MDVMapCrosshair.prototype.execute=function(){if(this.mdvMap.config.get('crosshair')){var crosshair=this.mdvMap.config.get('crosshair');var vpMapper=this.mdvMap.getMapper();if(!document.getElementById('crosshairLayer')){var div=document.createElement('div');div.id='crosshairLayer';div.style.position='absolute';div.style.top=(this.mdvMap.viewportHeight)/2-parseInt(vpMapper.style.top);div.style.left=(this.mdvMap.viewportWidth)/2-parseInt(vpMapper.style.left);div.style.zIndex=10;var img=new Image();img.src=crosshair;div.appendChild(img);this.mdvMap.getMapper().appendChild(div);}else{var div=document.getElementById('crosshairLayer');if(div){div.style.position='absolute';div.style.top=(this.mdvMap.viewportHeight)/2-parseInt(vpMapper.style.top)+'px';div.style.left=(this.mdvMap.viewportWidth)/2-parseInt(vpMapper.style.left)+'px';div.style.zIndex=10;}}}};function MDVMapEFAInfo(mdvMap){this.mdvMap=mdvMap;this.name='MapEFAInfo';this.stops=null;this.poi=null;this.centre=null;this.id=null;this.lastCentre=null;this.stopImg=new Image();this.mot1Img=new Image();this.mot2Img=new Image();this.mot3Img=new Image();this.mot4Img=new Image();this.mot5Img=new Image();this.mot6Img=new Image();this.mot7Img=new Image();this.mot8Img=new Image();this.mot9Img=new Image();this.mot10Img=new Image();this.mot11Img=new Image();this.mot12Img=new Image();this.poiImg=new Image();this.imgsLoaded=false;this.comparator=null;if(arguments.length>=2&&arguments[1]!=null)this.comparator=arguments[1];if(arguments.length>=2&&arguments[2]!=null)this.getMOTImage=arguments[2];for(var method in MDVGadgetBase.prototype){if(!MDVMapEFAInfo.prototype[method])MDVMapEFAInfo.prototype[method]=MDVGadgetBase.prototype[method];};this.mdvMap.registerGadget(this);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.trigger);this.mdvMap.events.registerEvent(MDVEvent_AJAX_CALLBACK,this,this.processPins);};MDVMapEFAInfo.prototype.destroy=function(){this.stopImg.onclick=null;this.stopImg=null;this.mot1Img.onclick=null;this.mot1Img=null;this.mot2Img.onclick=null;this.mot2Img=null;this.mot3Img.onclick=null;this.mot3Img=null;this.mot4Img.onclick=null;this.mot4Img=null;this.mot5Img.onclick=null;this.mot5Img=null;this.mot6Img.onclick=null;this.mot6Img=null;this.mot7Img.onclick=null;this.mot7Img=null;this.mot8Img.onclick=null;this.mot8Img=null;this.mot9Img.onclick=null;this.mot9Img=null;this.mot10Img.onclick=null;this.mot10Img=null;this.mot11Img.onclick=null;this.mot11Img=null;this.mot12Img.onclick=null;this.mot12Img=null;this.poiImg.onclick=null;this.poiImg=null;if(this.stops)this.stops.removeAll();if(this.poi)this.poi.removeAll();};MDVMapEFAInfo.prototype.createLayers=function(){if(!this.stops){this.stops=this.mdvMap.createLayer('efa_stops');this.stops.setZIndex(2);this.mdvMap.addLayer(this.stops);};if(!this.poi){this.poi=this.mdvMap.createLayer('efa_poi');this.poi.setZIndex(1);this.mdvMap.addLayer(this.poi);}};MDVMapEFAInfo.prototype.trigger=function(){var ipath='images/';if(this.mdvMap.config.get('imagePath'))ipath=this.mdvMap.config.get('imagePath');if(!this.imgsLoaded){this.stopImg.src=ipath+'stop.gif';this.mot1Img.src=ipath+'mot1.gif';this.mot2Img.src=ipath+'mot2.gif';this.mot3Img.src=ipath+'mot3.gif';this.mot4Img.src=ipath+'mot4.gif';this.mot5Img.src=ipath+'mot5.gif';this.mot6Img.src=ipath+'mot6.gif';this.mot7Img.src=ipath+'mot7.gif';this.mot8Img.src=ipath+'mot8.gif';this.mot9Img.src=ipath+'mot9.gif';this.mot10Img.src=ipath+'mot10.gif';this.mot11Img.src=ipath+'mot11.gif';this.mot12Img.src=ipath+'mot12.gif';this.poiImg.src=ipath+'pin.gif'
this.imgsLoaded=true;};if(this.id){mdvTimer.remove(this.id);this.id=null;};this.id=mdvTimer.add(700,this,this.execute,[]);};MDVMapEFAInfo.prototype.execute=function(){mdvTimer.remove(this.id);this.id=null;this.createLayers();var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var showStops=zoomLevel.get('showSTOP')=="true";var showPOI=zoomLevel.get('showPOI')=="true";if(showStops||showPOI){this.fetchPins();}else{this.stops.removeAll();this.poi.removeAll();}};MDVMapEFAInfo.prototype.getMOTImage=function(mot,type,pin,attrbs){switch(parseInt(mot)){case 1:return this.mot1Img.src;break;case 2:return this.mot2Img.src;break;case 3:return this.mot3Img.src;break;case 4:return this.mot4Img.src;break;case 5:return this.mot5Img.src;break;case 6:return this.mot6Img.src;break;case 7:return this.mot7Img.src;break;case 8:return this.mot8Img.src;break;case 9:return this.mot9Img.src;break;case 10:return this.mot10Img.src;break;case 11:return this.mot11Img.src;break;case 12:return this.mot12Img.src;break;default:if(type.toUpperCase()=='POI')return this.poiImg.src;else return this.stopImg.src;break;};return null;};MDVMapEFAInfo.prototype.processPins=function(id,gadName,request){if(gadName!='MapEFAInfo')return false;mdvTimer.remove(this.id);this.id=null;var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var showStops=zoomLevel.get('showSTOP')=="true"?true:false;var showPOI=zoomLevel.get('showPOI')=="true"?true:false;var pins=request.getElementsByTagName('itdPinElem');var mapRequest=request.getElementsByTagName('itdMapRequest');this.stops.removeAll();this.poi.removeAll();if(mapRequest&&mapRequest.length>0){var reqCoord=new MDVCoordinates(mapRequest[0].getAttribute('mapName'),mapRequest[0].getAttribute('xCenterReal'),mapRequest[0].getAttribute('yCenterReal'));if(!reqCoord.equals(this.mdvMap.getCentre())){return false;}};var updateStops=false;var updatePOI=false;if(pins.length<=0||mapRequest.length<=0){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,'MDVMap wasn\'t able to get pins from map request.');return false;};for(var i=0;i<pins.length;i++){var pinName=pins[i].getAttribute('desc');var	pinId=pins[i].getAttribute('id');var	pinType=pins[i].getAttribute('type');var	pinOmc=pins[i].getAttribute('omc');var genericAttrbs=new Array();var tmpImg=new Image();var sMeans=pins[i].getElementsByTagName('genAttrElem');if(sMeans.length>0){var nodeValue='';var tmpNode=sMeans[0];while(tmpNode){if(tmpNode.nodeType!=1||!tmpNode.firstChild){tmpNode=tmpNode.nextSibling;continue;};if(tmpNode.firstChild&&tmpNode.firstChild.firstChild&&tmpNode.firstChild.firstChild.nodeValue=='STOP_MAJOR_MEANS'&&tmpNode.firstChild.nextSibling&&tmpNode.firstChild.nextSibling.firstChild){nodeValue=tmpNode.firstChild.nextSibling.firstChild.nodeValue;};if(tmpNode.firstChild&&tmpNode.firstChild.firstChild&&tmpNode.firstChild.nextSibling&&tmpNode.firstChild.nextSibling.firstChild){genericAttrbs.push({name:tmpNode.firstChild.firstChild.nodeValue,value:tmpNode.firstChild.nextSibling.firstChild.nodeValue});};tmpNode=tmpNode.nextSibling;};tmpImg.src=this.getMOTImage(nodeValue,pinType,pins[i],genericAttrbs);}else{if(pinType.toUpperCase()=='POI')tmpImg.src=this.poiImg.src;else tmpImg.src=this.stopImg.src;};var bubbleSize=new Array();bubbleSize['poi']=new MDVPoint(284,190);bubbleSize['stop']=new MDVPoint(284,190);if(this.mdvMap.config.get('info.stop.size.width')&&this.mdvMap.config.get('info.stop.size.height')){bubbleSize['stop']=new MDVPoint(this.mdvMap.config.get('info.stop.size.width'),this.mdvMap.config.get('info.stop.size.height'));};if(this.mdvMap.config.get('info.poi.size.width')&&this.mdvMap.config.get('info.poi.size.height')){bubbleSize['poi']=new MDVPoint(this.mdvMap.config.get('info.poi.size.width'),this.mdvMap.config.get('info.poi.size.height'));};var coords=new MDVCoordinates(mapRequest[0].getAttribute('mapName'),parseInt(pins[i].firstChild.getAttribute('x')),parseInt(pins[i].firstChild.getAttribute('y')));var mapPin=this.mdvMap.createMarker(coords,0.5,tmpImg.src);mapPin.objectId={type:pinType,desc:pinName,id:pinId,omc:pinOmc,marker:mapPin};if(mapPin.objectId)mapPin.objectId.attrs=genericAttrbs;if(this.comparator){if(!this.comparator(mapPin.objectId))continue;};switch(pinType){case 'stop':var mapPinTitle=null;if(this.mdvMap.config.get('useBubbleForEFAInfo')&&this.mdvMap.config.get('useBubbleForEFAInfo')=='true'){mapPinTitle=this.mdvMap.createToolTip(bubbleSize['stop'],'<b>'+pinName+'</b>');if(this.mdvMap.config.get('useBubbleOverflowForEFAInfo')&&this.mdvMap.config.get('useBubbleOverflowForEFAInfo')=='true')mapPinTitle.setOverflow(true);if(this.mdvMap.config.get('useBubblePinForEFAInfo')&&this.mdvMap.config.get('useBubblePinForEFAInfo')=='true')mapPinTitle.setPin(true);mapPin.setToolTip(mapPinTitle,false);}else{mapPinTitle=this.mdvMap.createToolTip('Stop: <b>'+pinName+'</b>');mapPin.setToolTip(mapPinTitle,false);};break;case 'poi':var mapPinTitle=null;if(this.mdvMap.config.get('useBubbleForEFAInfo')&&this.mdvMap.config.get('useBubbleForEFAInfo')=='true'){mapPinTitle=this.mdvMap.createToolTip(bubbleSize['poi'],'<b>'+pinName+'</b>');if(this.mdvMap.config.get('useBubbleOverflowForEFAInfo')&&this.mdvMap.config.get('useBubbleOverflowForEFAInfo')=='true')mapPinTitle.setOverflow(true);if(this.mdvMap.config.get('useBubblePinForEFAInfo')&&this.mdvMap.config.get('useBubblePinForEFAInfo')=='true')mapPinTitle.setPin(true);mapPin.setToolTip(mapPinTitle,false);}else{mapPinTitle=this.mdvMap.createToolTip('Landmark: <b>'+pinName+'</b>');mapPin.setToolTip(mapPinTitle,false);};break;};switch(pinType){case 'poi':if(showPOI){for(var m=0;m<this.poi.getMarkers().length;m++){var pois=this.poi.getMarkers();if(pois[m].objectId.id==mapPin.objectId.id&&pois[m].objectId.omc==mapPin.objectId.omc){stopIt=true;break;}};if(stopIt)continue;this.poi.addMarker(mapPin,false);updatePOI=true;};break;default:if(showStops){var stopIt=false;for(var m=0;m<this.stops.getMarkers().length;m++){var stops=this.stops.getMarkers();if(stops[m].objectId.id==mapPin.objectId.id){stopIt=true;break;}};if(stopIt)continue;this.stops.addMarker(mapPin,false);updateStops=true;};break;}};if(updateStops)this.stops.update();if(updatePOI)this.poi.update();this.centre=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);return true;};MDVMapEFAInfo.prototype.fetchPins=function(){if(this.mdvMap.config.get('efaURL')){var host=this.mdvMap.config.get('efaURL');var centre=this.mdvMap.getCentre();var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var showStops=zoomLevel.get('showSTOP')=="true"?1:0;var showPOI=zoomLevel.get('showPOI')=="true"?1:0;var language=this.mdvMap.config.get('language')!=null?this.mdvMap.config.get('language'):'en';var _params={language:language,xCenterReal:Math.floor(centre.x+0.5),yCenterReal:Math.floor(centre.y+0.5),mapName:centre.mapName,pinTypePOI:showPOI,pinTypeStop:showStops,createImage:'0',realHeight:this.mdvMap.viewportRealHeight,realWidth:this.mdvMap.viewportRealWidth,screenWidth:this.mdvMap.viewportWidth,screenHeight:this.mdvMap.viewportHeight,command:'mapData',hideBannerInfo:'1',itdLPxx_mdvMapName:'mdvMap_'+this.mdvMap.getName(),itdLPxx_mdvMap:this.name};if($.post){var _ajax=$.post(host,_params,MDVMapEFAInfo_onAjaxComplete);}else{_params=$H(_params);_params=_params.toQueryString();var _ajax=new Ajax.Request(host,{method:'post',parameters:_params,onComplete:MDVMapEFAInfo_onAjaxComplete});}}};MDVMapEFAInfo.prototype.onmousedown=function(e){mdvTimer.remove(this.id);this.id=null;this.lastCentre=this.mdvMap.getCentre().clone();return true;};MDVMapEFAInfo.prototype.onmouseup=function(e){if(this.lastCentre&&this.lastCentre.equals(this.mdvMap.getCentre())){this.trigger();};return true;};function MDVMapEFAInfo_onAjaxComplete(request){var xml=null;if(request&&request.responseXML){xml=request.responseXML;}else if(request){xml=request;};var itdLPs=xml.getElementsByTagName("itdLayoutParam");for(var i=0;i<itdLPs.length;i++){if(itdLPs[i].getAttribute('name')=='mdvMapName'){if(document.mdvMaps[itdLPs[i].getAttribute('value')])document.mdvMaps[itdLPs[i].getAttribute('value')].events.triggerEvent(MDVEvent_AJAX_CALLBACK,'MapEFAInfo',xml);return;}}};function MDVMapEFATrips(mdvMap){this.mdvMap=mdvMap;this.name='MDVMapEFATrips';this.layer=null;this.wizardJobID=null;this.wizardIndex=null;this.wizardScreenPlay=new Array();this.response=null;this.polylines=new Array();this.zoomLevel=null;this.doBeautify=true;this.imgs=new Array();this.imgs['stop']=new Image();this.imgs['1']=new Image();this.imgs['1_follow']=new Image();this.imgs['2']=new Image();this.imgs['2_follow']=new Image();this.imgs['3']=new Image();this.imgs['3_follow']=new Image();this.imgs['4']=new Image();this.imgs['4_follow']=new Image();this.imgs['5']=new Image();this.imgs['5_follow']=new Image();this.imgs['6']=new Image();this.imgs['6_follow']=new Image();this.imgs['7']=new Image();this.imgs['7_follow']=new Image();this.imgs['8']=new Image();this.imgs['8_follow']=new Image();this.imgs['9']=new Image();this.imgs['9_follow']=new Image();this.imgs['10']=new Image();this.imgs['10_follow']=new Image();this.imgs['11']=new Image();this.imgs['11_follow']=new Image();this.imgs['12']=new Image();this.imgs['12_follow']=new Image();this.imgs['99']=new Image();this.imgs['99_follow']=new Image();this.imgs['100']=new Image();this.imgs['100_follow']=new Image();this.imgs['100_arrival']=new Image();this.imgs['100_departure']=new Image();this.imgs['101']=new Image();this.imgs['101_follow']=new Image();this.imgs['101_arrival']=new Image();this.imgs['101_departure']=new Image();this.imgs['102']=new Image();this.imgs['102_follow']=new Image();this.imgs['102_arrival']=new Image();this.imgs['102_departure']=new Image();this.imgs['103']=new Image();this.imgs['103_follow']=new Image();this.imgs['103_arrival']=new Image();this.imgs['103_departure']=new Image();this.imgs['104']=new Image();this.imgs['104_follow']=new Image();this.imgs['104_arrival']=new Image();this.imgs['104_departure']=new Image();this.imgs['105']=new Image();this.imgs['105_follow']=new Image();this.imgs['105_arrival']=new Image();this.imgs['105_departure']=new Image();this.imgs['106']=new Image();this.imgs['106_follow']=new Image();this.imgs['106_arrival']=new Image();this.imgs['106_departure']=new Image();this.imgs['107']=new Image();this.imgs['107_follow']=new Image();this.imgs['107_arrival']=new Image();this.imgs['107_departure']=new Image();this.imgs['poi']=new Image();for(var method in MDVGadgetBase.prototype){if(!MDVMapEFATrips.prototype[method])MDVMapEFATrips.prototype[method]=MDVGadgetBase.prototype[method];};this.mdvMap.registerGadget(this);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.execute);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.update);this.mdvMap.events.registerEvent(MDVEvent_AJAX_CALLBACK,this,this.processTrip);};MDVMapEFATrips.prototype.prefetchImgs=function(){var ipath='images/';if(this.mdvMap.config.get('imagePath'))ipath=this.mdvMap.config.get('imagePath');this.imgs['stop'].src=ipath+'stop.gif';this.imgs['1'].src=ipath+'mot1.gif';this.imgs['1_follow'].src=ipath+'mot1_follow.gif'
this.imgs['2'].src=ipath+'mot2.gif';this.imgs['2_follow'].src=ipath+'mot2_follow.gif';this.imgs['3'].src=ipath+'mot3.gif';this.imgs['3_follow'].src=ipath+'mot3_follow.gif';this.imgs['4'].src=ipath+'mot4.gif';this.imgs['4_follow'].src=ipath+'mot4_follow.gif';this.imgs['5'].src=ipath+'mot5.gif';this.imgs['5_follow'].src=ipath+'mot5_follow.gif';this.imgs['6'].src=ipath+'mot6.gif';this.imgs['6_follow'].src=ipath+'mot6_follow.gif';this.imgs['7'].src=ipath+'mot7.gif';this.imgs['7_follow'].src=ipath+'mot7_follow.gif';this.imgs['8'].src=ipath+'mot8.gif';this.imgs['8_follow'].src=ipath+'mot8_follow.gif';this.imgs['9'].src=ipath+'mot9.gif';this.imgs['9_follow'].src=ipath+'mot9_follow.gif';this.imgs['10'].src=ipath+'mot10.gif';this.imgs['10_follow'].src=ipath+'mot10_follow.gif';this.imgs['11'].src=ipath+'mot11.gif';this.imgs['11_follow'].src=ipath+'mot11_follow.gif';this.imgs['12'].src=ipath+'mot12.gif';this.imgs['12_follow'].src=ipath+'mot12_follow.gif';this.imgs['99'].src=ipath+'mot99.gif';this.imgs['99_follow'].src=ipath+'mot99_follow.gif';this.imgs['100'].src=ipath+'mot100.gif';this.imgs['100_follow'].src=ipath+'mot100_follow.gif';this.imgs['100_arrival'].src=ipath+'mot100_arrival.gif';this.imgs['100_departure'].src=ipath+'mot100.gif';this.imgs['101'].src=ipath+'mot101.gif';this.imgs['101_follow'].src=ipath+'mot101_follow.gif';this.imgs['101_arrival'].src=ipath+'mot101_arrival.gif';this.imgs['101_departure'].src=ipath+'mot101_departure.gif';this.imgs['102'].src=ipath+'mot102.gif';this.imgs['102_follow'].src=ipath+'mot102_follow.gif';this.imgs['102_arrival'].src=ipath+'mot102_arrival.gif';this.imgs['102_departure'].src=ipath+'mot102_departure.gif';this.imgs['103'].src=ipath+'mot103.gif';this.imgs['103_follow'].src=ipath+'mot103_follow.gif';this.imgs['103_arrival'].src=ipath+'mot103_arrival.gif';this.imgs['103_departure'].src=ipath+'mot103_departure.gif';this.imgs['104'].src=ipath+'mot104.gif';this.imgs['104_follow'].src=ipath+'mot104_follow.gif';this.imgs['104_arrival'].src=ipath+'mot104_arrival.gif';this.imgs['104_departure'].src=ipath+'mot104_departure.gif';this.imgs['105'].src=ipath+'mot105.gif';this.imgs['105_follow'].src=ipath+'mot105_follow.gif';this.imgs['105_arrival'].src=ipath+'mot105_arrival.gif';this.imgs['105_departure'].src=ipath+'mot105_departure.gif';this.imgs['106'].src=ipath+'mot106.gif';this.imgs['106_follow'].src=ipath+'mot106_follow.gif';this.imgs['106_arrival'].src=ipath+'mot106_arrival.gif';this.imgs['106_departure'].src=ipath+'mot106_departure.gif';this.imgs['107'].src=ipath+'mot107.gif';this.imgs['107_follow'].src=ipath+'mot107_follow.gif';this.imgs['107_arrival'].src=ipath+'mot107_arrival.gif';this.imgs['107_departure'].src=ipath+'mot107_departure.gif';this.imgs['poi'].src=ipath+'pin.gif'};MDVMapEFATrips.prototype.onmousedown=function(e){mdvTimer.remove(this.wizardJobID);this.mdvMap.cancelMoveBySeq();this.wizardJobID=null;for(var w=0;w<this.wizardScreenPlay.length;w++){if(this.wizardScreenPlay[w].type=='marker'&&this.wizardScreenPlay[w].object.toolTip)this.wizardScreenPlay[w].object.toolTip.hide();};return true;};MDVMapEFATrips.prototype.execute=function(){if(this.layer==null){this.prefetchImgs();this.layer=this.mdvMap.createLayer('efa_trip');this.mdvMap.addLayer(this.layer);}};MDVMapEFATrips.prototype.clear=function(){if(this.mdvMap){mdvTimer.remove(this.wizardJobID);this.mdvMap.cancelMoveBySeq();this.wizardJobID=null;this.mdvMap.hideToolTips();};this.layer.removeAll();while(this.polylines.pop()){};while(this.wizardScreenPlay.pop()){};this.wizardJobID=null;this.wizardIndex=null;};MDVMapEFATrips.prototype.loadTrip=function(sessionID,requestID,tripIndex){if(!this.mdvMap.config.get('tripURL')){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,'No tripURL specified.');return false;};if(arguments.length==4)this.doBeautify=arguments[3];var language=this.mdvMap.config.get('language')!=null?this.mdvMap.config.get('language'):'en';var host=this.mdvMap.config.get('tripURL');var selector=('tripSelector'+tripIndex);var _params={language:language,sessionID:sessionID,requestID:requestID,coordListOutputFormat:'STRING',command:'nop',tripSelection:'on',itdLPxx_mdvMap:'MDVMapEFATrips',itdLPxx_mdvMapName:this.mdvMap.getName(),showItdPathCoordinates:'1'};_params[selector]='on';if($.post){var _ajax=$.post(host,_params,MDVMapEFATrips_onAjaxComplete);}else{_params=$H(_params);_params=_params.toQueryString();var _ajax=new Ajax.Request(host,{method:'post',parameters:_params,onComplete:MDVMapEFATrips_onAjaxComplete});};return true;};MDVMapEFATrips.prototype.processTrip=function(id,gName,efa){if(gName!='MDVMapEFATrips')return false;this.response=efa;this.clear();var leg=null;if(this.response.trips.trip.legs.leg&&!this.response.trips.trip.legs.length){leg=this.response.trips.trip.legs.leg;}else if(this.response.trips.trip.legs.length){leg=this.response.trips.trip.legs[0];};var l=0;while(leg){var type=leg.mode.type;var colour=this.getLegColour(type);var opacity='0.5';var weight=3;if(this.mdvMap.config.get('trips.polyline.opacity'))opacity=this.mdvMap.config.get('trips.polyline.opacity');if(this.mdvMap.config.get('trips.polyline.weight'))weight=this.mdvMap.config.get('trips.polyline.weight');var pathStr=leg.path.replace(/\.00000/gi,'');this.polylines.push(this.mdvMap.createPolyline(pathStr));this.polylines[l].add('colour',colour);this.polylines[l].add('opacity',opacity);this.polylines[l].add('weight',weight);if(!this.polylines[l].markers['departure']){var coords=this.polylines[l].getAllCoords();var src;if(type>=100&&this.imgs[type+"_departure"])src=this.imgs[type+"_departure"];else if(this.imgs[type])src=this.imgs[type];else src=this.imgs['stop'];this.polylines[l].markers['departure']=this.mdvMap.createMarker(coords[0],0.5,src.src);this.polylines[l].markers['departure'].mode=type;this.polylines[l].markers['departure'].point=leg.points[0];};if(!this.polylines[l].markers['arrival']){var coords=this.polylines[l].getAllCoords();var src;if(type>=100&&this.imgs[type+"_arrival"]&&this.imgs[type+"_arrival"].complete)src=this.imgs[type+"_arrival"];else if(this.imgs[type])src=this.imgs[type];else src=this.imgs['stop'];this.polylines[l].markers['arrival']=this.mdvMap.createMarker(coords[coords.length-1],0.5,src.src);this.polylines[l].markers['arrival'].mode=type;this.polylines[l].markers['arrival'].point=leg.points[1];};this.polylines[l].leg=leg;this.layer.addPolyline(this.polylines[l],false);l++;leg=this.response.trips.trip.legs[l];};if(this.doBeautify)this.beautify();this.processMarkers();this.mdvMap.update();this.processPolylines();};MDVMapEFATrips.prototype.updateWizard=function(){var _polyline=this.polylines[0];for(var sp=this.wizardScreenPlay.length;sp>0;sp--)this.wizardScreenPlay.pop();if(_polyline.markers['departure']&&_polyline.markers['departure'].img&&_polyline.markers['departure'].img.toolTip){this.wizardScreenPlay.push({object:_polyline.markers['departure'],type:'marker',state:true,timeout:2200});this.wizardScreenPlay.push({object:_polyline.markers['departure'],type:'marker',state:false,timeout:50});this.wizardScreenPlay.push({object:_polyline,type:'polyline',state:true,timeout:10});};for(var p=1;p<this.polylines.length;p++){if(_polyline.markers['arrival']&&_polyline.markers['arrival'].img&&_polyline.markers['arrival'].img.toolTip){this.wizardScreenPlay.push({object:_polyline.markers['arrival'],type:'marker',state:true,timeout:2200});this.wizardScreenPlay.push({object:_polyline.markers['arrival'],type:'marker',state:false,timeout:50});var test='';};_polyline=this.polylines[p];if(_polyline.markers['departure']&&_polyline.markers['departure'].img&&_polyline.markers['departure'].img.toolTip){this.wizardScreenPlay.push({object:_polyline.markers['departure'],type:'marker',state:true,timeout:2200});this.wizardScreenPlay.push({object:_polyline.markers['departure'],type:'marker',state:false,timeout:50});var test='';};this.wizardScreenPlay.push({object:_polyline,type:'polyline',state:true,timeout:10});};if(_polyline.markers['arrival']&&_polyline.markers['arrival'].img&&_polyline.markers['arrival'].img.toolTip){this.wizardScreenPlay.push({object:_polyline.markers['arrival'],type:'marker',state:true,timeout:2200});this.wizardScreenPlay.push({object:_polyline.markers['arrival'],type:'marker',state:false,timeout:50});var test='';};return true;};MDVMapEFATrips.prototype.beautify=function(){var coords=this.mdvMap.getPolylineCoords();var x=coords[0];var y=coords[1];x.sort(MDVMap_NumSort);y.sort(MDVMap_NumSort);var width=x[x.length-1]-x[0];var height=y[y.length-1]-y[0];var newX=parseInt(x[0])+Math.floor(0.5+width/2);var newY=parseInt(y[0])+Math.floor(0.5+height/2);var centre=new MDVCoordinates(this.mdvMap.config.get('mapName'),newX,newY);var zoom=0;var extd=this.mdvMap.getViewportExtends();var zls=this.mdvMap.config.getZoomLevels();for(var i=zls.length-1;i>=0;i--){var zl=zls[i];var bWidth=false;var bHeight=false;var vpTiles=new MDVPoint(extd.width/zl.get('tileSizeX'),0.5+extd.height/zl.get('tileSizeY'));var numTiles=new MDVPoint(zl.get('numberOfTilesX'),zl.get('numberOfTilesY'));var realExtends=new MDVPoint(zl.get('realWidth'),zl.get('realHeight'));var tileSize=new MDVPoint(Math.floor(0.5+realExtends.x/numTiles.x),Math.floor(0.5+realExtends.y/numTiles.y));var real=new MDVPoint(tileSize.x*vpTiles.x,tileSize.y*vpTiles.y);if(real.x>(width*1.15)&&!bWidth){zoom=i;bWidth=true;};if(real.y>(height*1.15)&&!bHeight){zoom=i;bHeight=true;};if(bWidth&&bHeight)break;};this.mdvMap.setCentre(centre);this.mdvMap.setZoomLevel(zoom);};MDVMapEFATrips.prototype.processMarkers=function(){var sessionID=0;var requestID=0;for(var p=0;p<this.response.parameters.length;p++){if(this.response.parameters[p].name=='sessionID')sessionID=this.response.parameters[p].value;if(this.response.parameters[p].name=='requestID')requestID=this.response.parameters[p].value;};var markers=new Array();for(var p=0;p<this.polylines.length;p++){var polyline=this.polylines[p];markers.push([p,'departure',polyline.markers['departure']]);markers.push([p,'arrival',polyline.markers['arrival']]);};var map='';var size=new MDVPoint(220,124);if(this.mdvMap.config.get('trips.marker.size.width')&&this.mdvMap.config.get('trips.marker.size.height'))size=new MDVPoint(this.mdvMap.config.get('trips.marker.size.width'),this.mdvMap.config.get('trips.marker.size.height'));for(var m=markers.length-1;m>=0;m--){var marker=markers[m];var text='';if(marker[2].point&&marker[2].point.desc)text=marker[2].point.desc;if(this.mdvMap.config.get('useBubbleForEFATrips')&&this.mdvMap.config.get('useBubbleForEFATrips')=='false'){marker[2].setToolTip(this.mdvMap.createToolTip(text));}else{marker[2].setToolTip(this.mdvMap.createToolTip(size,text));};this.layer.addMarker(marker[2],false);}};MDVMapEFATrips.prototype.update=function(id,msg,obj){if(this.polylines.length<=0||this.zoomLevel==obj.config.getZoomLevelIndex())return false;this.zoomLevel=obj.config.getZoomLevelIndex();for(var p=0;p<this.polylines.length;p++){if(this.polylines[p]&&this.polylines[p].markers['departure'])this.polylines[p].markers['departure'].visible=false;if(this.polylines[p]&&this.polylines[p].markers['arrival'])this.polylines[p].markers['arrival'].visible=false;for(var a=0;a<this.polylines[p].arrows.length;a++){this.layer.removePolyline(this.polylines[p].arrows[a]);if(this.polylines[p].arrows[a])this.polylines[p].arrows[a].destroy();};var maxScale=25000;if(this.mdvMap.config.get('trips.polyline.arrows.maxScale'))maxScale=parseInt(this.mdvMap.config.get('trips.polyline.arrows.maxScale'));var zl=this.mdvMap.config.getZoomLevel(this.zoomLevel);var displayArrows=zl.getScale()<=maxScale;if(this.mdvMap.config.get('useArrowsForEFATrips')&&this.mdvMap.config.get('useArrowsForEFATrips')=='true'&&displayArrows){this.polylines[p].arrows=this.polylines[p].getArrows();for(var a=0;a<this.polylines[p].arrows.length;a++){var update=a==this.polylines[p].arrows.length-1?true:false;this.layer.addPolyline(this.polylines[p].arrows[a],update);}}};if(this.polylines[0].markers['departure'])this.polylines[0].markers['departure'].setVisibility(true);if(this.polylines[this.polylines.length-1].markers['arrival'])this.polylines[this.polylines.length-1].markers['arrival'].setVisibility(true);for(var i=this.polylines.length-1;i>0;i--){var current=this.polylines[i];var prev=this.polylines[i-1];if(!current||!prev)continue;var temparr=[[i,'departure',current.markers['departure']],[i,'arrival',prev.markers['arrival']]];temparr.sort(MDVMapEFATrips_PrioritySort);temparr[0][2].setVisibility(true);if(!temparr[1][2].intersects(temparr[0][2])||!temparr[0][2].isVisible())temparr[1][2].setVisibility(true);else temparr[1][2].setVisibility(false);};this.updateWizard();return true;};MDVMapEFATrips.prototype.processPolylines=function(){for(var l=0;l<this.polylines.length;l++){var polyline=this.polylines[l];var text=polyline.leg.mode.desc;var size=new MDVPoint(220,150);if(this.mdvMap.config.get('trips.polyline.size.width')&&this.mdvMap.config.get('trips.polyline.size.height'))size=new MDVPoint(this.mdvMap.config.get('trips.polyline.size.width'),this.mdvMap.config.get('trips.polyline.size.height'));var tooltip=null;if(this.mdvMap.config.get('useBubbleForEFATrips')&&this.mdvMap.config.get('useBubbleForEFATrips')=='false'){tooltip=this.mdvMap.createToolTip(text);}else{tooltip=this.mdvMap.createToolTip(size,text);};polyline.setToolTip(tooltip,false);polyline.element.mdvMap=this.mdvMap;}};MDVMapEFATrips.prototype.getLegColour=function(type){if(this.mdvMap.config.get('motColour_'+type))return this.mdvMap.config.get('motColour_'+type);return '#FF0000';};MDVMapEFATrips.prototype.launchWizard=function(zoomLevel){mdvTimer.remove(this.wizardJobID);this.mdvMap.stepPx=4;this.mdvMap.stepTime=40;this.mdvMap.cancelMoveBySeq();this.wizardJobID=null;if(this.polylines.length>0){if(zoomLevel>=0)this.mdvMap.setZoomLevel(zoomLevel);this.mdvMap.setCentre(this.polylines[0].getAllCoords()[0].clone());this.mdvMap.update();};this.wizardIndex=0;this.wizardJobID=mdvTimer.add(1,this,this.wizardRun,[null,null,null]);};MDVMapEFATrips.prototype.wizardRun=function(id,msg,obj){var _sp=this.wizardScreenPlay[this.wizardIndex];this.wizardIndex++;if(id==MDVEvent_ROUTE_TRACE_FINISHED)this.mdvMap.events.deregisterEvent(MDVEvent_ROUTE_TRACE_FINISHED,this,this.wizardRun);if(_sp){switch(_sp.type){case 'marker':if(_sp.state)_sp.object.toolTip.display();else _sp.object.toolTip.hide();this.wizardJobID=mdvTimer.add(_sp.timeout,this,this.wizardRun,[null,null,null]);break;default:this.mdvMap.events.registerEvent(MDVEvent_ROUTE_TRACE_FINISHED,this,this.wizardRun);var coords=_sp.object.getAllCoords();var mrkr=null;if(_sp.object.leg.mode.type&&this.imgs[_sp.object.leg.mode.type+'_follow']&&this.imgs[_sp.object.leg.mode.type+'_follow'].complete)mrkr=this.imgs[_sp.object.leg.mode.type+'_follow'].src;this.wizardJobID=mdvTimer.add(_sp.timeout,this,this.wizardMoveBySeq,[coords,mrkr]);break;}}};MDVMapEFATrips.prototype.wizardMoveBySeq=function(coords,marker){this.mdvMap.moveBySeq(coords,marker);};function MDVMapEFATrips_onAjaxComplete(request){var efa;var json=null;var mdvMapName='';if(request&&request.responseText)json=request.responseText;else if(request)json=request;eval('efa = '+json+';');for(var i=0;i<efa.parameters.length;i++){if(efa.parameters[i].name=='mdvMapName'){mdvMapName=efa.parameters[i].value;break;}};if(document.mdvMaps['mdvMap_'+mdvMapName])document.mdvMaps['mdvMap_'+mdvMapName].events.triggerEvent(MDVEvent_AJAX_CALLBACK,'MDVMapEFATrips',efa);};function MDVMapEFATrips_PrioritySort(a,b){return MDVMapEFATrips_GetPrority(a)-MDVMapEFATrips_GetPrority(b);};function MDVMapEFATrips_GetPrority(marker){if(marker[1]=='departure'&&marker[2].mode>0&&marker[2].mode<96)return 10;else if(marker[1]=='arrival'&&marker[2].mode>0&&marker[2].mode<96)return 20;else if(marker[1]=='departure'&&marker[2].mode>100)return 30;else if(marker[1]=='arrival'&&marker[2].mode>100)return 40;else if(marker[1]=='departure'&&marker[2].mode==100)return 50;else if(marker[1]=='arrival'&&marker[2].mode==100)return 60;else return 1000;};function MDVMapContextMenu(mdvMap,contMenu){if(!mdvMap)return;this.name='MapContextMenu';this.mdvMap=mdvMap;this.mdvMap.registerGadget(this);this.mdvMap.events.registerEvent(MDVEvent_ZOOM_CHANGED,this,this.zoomLevelChange);this.contextMenu=contMenu;for(var i=0;i<this.contextMenu.div.childNodes.length;i++){if(this.contextMenu.div.childNodes[i]){this.contextMenu.div.childNodes[i].mdvMap=this.mdvMap;}};var _clickOnContextMenu=false;document.body.contextMenu=this;this.contextMenu.div.onmousedown=function(){_clickOnContextMenu=true;};document.body.onmousedown=function(e){e=e?e:window.event;if(!_clickOnContextMenu)this.contextMenu.contextMenu.div.style.display='none';_clickOnContextMenu=false;};this.contextMenu.div.oncontextmenu=function(){return false;};for(var method in MDVGadgetBase.prototype){if(!MDVMapContextMenu.prototype[method])MDVMapContextMenu.prototype[method]=MDVGadgetBase.prototype[method];}};MDVMapContextMenu.prototype.destroy=function(){if(this.mdvMap)this.mdvMap=null;for(var i=0;i<this.contextMenu.div.childNodes.length;i++){if(this.contextMenu.div.childNodes[i]&&this.contextMenu.div.childNodes[i].mdvMap){this.contextMenu.div.childNodes[i].mdvMap=null;}};this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null;};MDVMapContextMenu.prototype.oncontextmenu=function(e){e=e?e:window.event;var scrollTop=document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;var scrollLeft=document.body.scrollLeft?document.body.scrollLeft:document.documentElement.scrollLeft;var x=e.clientX+scrollLeft;var y=e.clientY+scrollTop;var mX=e.pageX||(e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var mY=e.pageY||(e.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var offsetL=0;var offsetT=0;var obj=this.mdvMap.viewport;while(obj){offsetL+=obj.offsetLeft;offsetT+=obj.offsetTop;obj=obj.offsetParent;};mX=mX-offsetL-3;mY=mY-offsetT-3;this.contextMenu.div.style.display='none';this.contextMenu.div.style.left=x+'px';this.contextMenu.div.style.top=y+'px';this.contextMenu.div.style.display='block';var mousePoint=new MDVPoint(mX,mY);var mouseCoord=this.mdvMap.getCoordinates(mousePoint);this.mdvMap.events.triggerEvent(MDVEvent_CONTEXT_MENU,true,mouseCoord);return false;};MDVMapContextMenu.prototype.hideContextMenu=function(){this.contextMenu.div.style.display='none';this.mdvMap.events.triggerEvent(MDVEvent_CONTEXT_MENU,false,null);};MDVMapContextMenu.prototype.onmousedown=function(e){e=e?e:window.event;if(e==null||e.button!=2){this.hideContextMenu();};this.stopEvent(e);return true;};MDVMapContextMenu.prototype.zoomLevelChange=function(id,message,zoomLevelIndex){this.onmousedown(null);};function MDVMapMenu(menuItems){this.menuItems=menuItems;var menu=document.createElement("div");menu.className="mapContextMenu";document.body.appendChild(menu);menu.style.cursor='default';for(var i=0;i<this.menuItems.length;i++){if(this.menuItems[i].func){var item=document.createElement("div");item.className="mapContextMenuItem";item.onmouseover=function(){this.className='mapContextMenuItem_active';menu.style.cursor='pointer';};item.onmouseout=function(){this.className='mapContextMenuItem';menu.style.cursor='default';};item.onclick=this.menuItems[i].func;item.onmouseup=hideMenu;var itemDescription=document.createTextNode(" "+this.menuItems[i].description+" ");item.appendChild(itemDescription);menu.appendChild(item);}else{var item=document.createElement("hr");menu.appendChild(item);}};function hideMenu(){menu.style.display='none';};this.div=menu;};function MDVMapMenuItem(description,func){this.description=description;if(func){this.func=func;}};function MDVMapControl(mdvMap){if(!mdvMap)return;this.name='MapControl';this.mdvMap=mdvMap;this.origin=null;this.zoomLevel=null;this.images=new Array();this.images['top_normal']=new Image();this.images['top_hover']=new Image();this.images['left_normal']=new Image();this.images['left_hover']=new Image();this.images['centre_normal']=new Image();this.images['centre_hover']=new Image();this.images['right_normal']=new Image();this.images['right_hover']=new Image();this.images['bottom_normal']=new Image();this.images['bottom_hover']=new Image();this.images['zoomIn_normal']=new Image();this.images['zoomIn_hover']=new Image();this.images['zoomOut_normal']=new Image();this.images['zoomOut_hover']=new Image();this.images['zoomLevel_normal']=new Image();this.images['zoomLevel_hover']=new Image();this.images['zoomLevel_active']=new Image();this.images['transparent']=new Image();this.images['spacer']=new Image();this.text=new Array();this.text['goNorth']='Go north';this.text['goWest']='Go west';this.text['goEast']='Go east';this.text['goSouth']='Go south';this.text['lastResult']='Last result';this.text['zoomIn']='Zoom in';this.text['zoomOut']='Zoom out';if(arguments.length==2&&arguments[1])this.text=arguments[1];this.mapControl=null;this.arrowContainer=null;this.zoomContainer=null;this.mdvMap.registerGadget(this);for(var method in MDVGadgetBase.prototype){if(!MDVMapControl.prototype[method])MDVMapControl.prototype[method]=MDVGadgetBase.prototype[method];};this.mdvMap.events.registerEvent(MDVEvent_INITIALISED,this,this.execute);this.mdvMap.events.registerEvent(MDVEvent_ZOOM_CHANGED,this,this.update);};MDVMapControl.prototype.preloadImgs=function(){var ipath='images/';if(this.mdvMap.config.get('imagePath'))ipath=this.mdvMap.config.get('imagePath');var imgPath=ipath+'MDVMapControl/';this.images['top_normal'].src=imgPath+'topNormal.gif';this.images['top_normal'].alt=this.text['goNorth'];this.images['top_normal'].title=this.images['top_normal'].alt;this.images['top_hover'].src=imgPath+'topHover.gif';this.images['top_hover'].alt=this.images['top_normal'].alt;this.images['top_hover'].title=this.images['top_normal'].alt;this.images['left_normal'].src=imgPath+'leftNormal.gif';this.images['left_normal'].alt=this.text['goWest'];this.images['left_normal'].title=this.images['left_normal'].alt;this.images['left_hover'].src=imgPath+'leftHover.gif';this.images['left_hover'].alt=this.images['left_normal'].alt;this.images['left_hover'].title=this.images['left_normal'].alt;this.images['centre_normal'].src=imgPath+'centreNormal.gif';this.images['centre_normal'].alt=this.text['lastResult'];this.images['centre_normal'].title=this.images['centre_normal'].alt;this.images['centre_hover'].src=imgPath+'centreHover.gif';this.images['centre_hover'].alt=this.images['centre_normal'].alt;this.images['centre_hover'].title=this.images['centre_normal'].alt;this.images['right_normal'].src=imgPath+'rightNormal.gif';this.images['right_normal'].alt=this.text['goEast'];this.images['right_normal'].title=this.images['right_normal'].alt;this.images['right_hover'].src=imgPath+'rightHover.gif';this.images['right_hover'].alt=this.images['right_normal'].alt;this.images['right_hover'].title=this.images['right_normal'].alt;this.images['bottom_normal'].src=imgPath+'bottomNormal.gif';this.images['bottom_normal'].alt=this.text['goSouth'];this.images['bottom_normal'].title=this.images['bottom_normal'].alt;this.images['bottom_hover'].src=imgPath+'bottomHover.gif';this.images['bottom_hover'].alt=this.images['bottom_normal'].alt;this.images['bottom_hover'].title=this.images['bottom_normal'].alt;this.images['zoomIn_normal'].src=imgPath+'zoomInNormal.gif';this.images['zoomIn_normal'].alt=this.text['zoomIn'];this.images['zoomIn_normal'].title=this.images['zoomIn_normal'].alt;this.images['zoomIn_hover'].src=imgPath+'zoomInHover.gif';this.images['zoomIn_hover'].alt=this.images['zoomIn_normal'].alt;this.images['zoomIn_hover'].title=this.images['zoomIn_normal'].alt;this.images['zoomOut_normal'].src=imgPath+'zoomOutNormal.gif';this.images['zoomOut_normal'].alt=this.text['zoomOut'];this.images['zoomOut_normal'].title=this.images['zoomOut_normal'].alt;this.images['zoomOut_hover'].src=imgPath+'zoomOutHover.gif';this.images['zoomOut_hover'].alt=this.images['zoomOut_normal'].alt;this.images['zoomOut_hover'].title=this.images['zoomOut_normal'].alt;this.images['zoomLevel_normal'].src=imgPath+'zoomLevelNormal.gif';this.images['zoomLevel_active'].src=imgPath+'zoomLevelActive.gif';this.images['zoomLevel_hover'].src=imgPath+'zoomLevelHover.gif';this.images['transparent'].src=imgPath+'transparent.gif';this.images['spacer'].src=imgPath+'spacer.gif';};MDVMapControl.prototype.createDiv=function(){var newDiv=document.createElement('div');return newDiv;};MDVMapControl.prototype.execute=function(){this.preloadImgs();this.origin=new MDVCoordinates(this.mdvMap.config.get('mapName'),parseInt(this.mdvMap.config.get('xCenterReal')),parseInt(this.mdvMap.config.get('yCenterReal')));this.zoomLevel=this.mdvMap.config.get('defaultScale');this.mapControl=this.createDiv();this.mapControl.className='MDVMapControl';this.mdvMap.viewport.appendChild(this.mapControl);this.arrowContainer=this.createDiv();this.zoomContainer=this.createDiv();this.zoomContainer.className='MDVMapControl_ZoomLevels';this.zoomLevels=new Array();this.mapControl.appendChild(this.arrowContainer);this.mapControl.appendChild(this.zoomContainer);this.populateContainers();this.update();};MDVMapControl.prototype.destroy=function(){if(this.mdvMap)this.mdvMap=null;for(var row=0;row<this.arrowContainer.childNodes.length;row++){for(var div=0;div<this.arrowContainer.childNodes[row].childNodes.length;div++){for(var i=0;i<this.arrowContainer.childNodes[row].childNodes[div].childNodes.length;i++){if(this.arrowContainer.childNodes[row].childNodes[div].childNodes[i].mdvMap){this.arrowContainer.childNodes[row].childNodes[div].childNodes[i].mdvMap=null;};if(this.arrowContainer.childNodes[row].childNodes[div].childNodes[i].normal){this.arrowContainer.childNodes[row].childNodes[div].childNodes[i].normal=null;};if(this.arrowContainer.childNodes[row].childNodes[div].childNodes[i].hover){this.arrowContainer.childNodes[row].childNodes[div].childNodes[i].hover=null;}}}};for(var row=0;row<this.zoomContainer.childNodes.length;row++){for(var i=0;i<this.zoomContainer.childNodes[row].childNodes.length;i++){var tmp=this.zoomContainer.childNodes[row].childNodes[i];tmp.onmouseover=null;tmp.onmouseout=null;tmp.onclick=null;tmp.hover=null;tmp.normal=null;if(tmp.mdvMap)tmp.mdvMap=null;}};this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null;if(this.arrowContainer){this.arrowContainer.onmouseover=null;this.arrowContainer.onmouseout=null;this.arrowContainer.onclick=null;this.arrowContainer=null;};if(this.zoomContainer){this.zoomContainer.onmouseover=null;this.zoomContainer.onmouseout=null;this.zoomContainer.onclick=null;this.zoomContainer=null;};if(this.mapControl){this.mapControl.onmouseover=null;this.mapControl.onmouseout=null;this.mapControl.onclick=null;this.mapControl=null;}};MDVMapControl.prototype.setZoomLevel=function(zoomLevel){if(this.mdvMap.config.getZoomLevel(zoomLevel)){this.zoomLevel=zoomLevel;return true;};return false;};MDVMapControl.prototype.setOriginCoords=function(coord){if(coord&&coord.x&&coord.y&&coord.mapName){this.origin=coord;return true;};return false;};MDVMapControl.prototype.populateContainers=function(){if(!this.arrowContainer||!this.zoomContainer)return false;var firstRow=this.createDiv();var secondRow=this.createDiv();var thirdRow=this.createDiv();this.arrowContainer.appendChild(firstRow);this.arrowContainer.appendChild(secondRow);this.arrowContainer.appendChild(thirdRow);var arrow_1_1=this.createDiv();arrow_1_1.className='MDVMapControl_Arrow';arrowImg_1_1=this.createImage();arrowImg_1_1.src=this.images['transparent'].src;arrow_1_1.appendChild(arrowImg_1_1);var arrow_2_1=this.createDiv();arrow_2_1.className='MDVMapControl_Arrow';arrowImg_2_1=this.createImage();arrowImg_2_1.hover=this.images['top_hover'];arrowImg_2_1.normal=this.images['top_normal'];arrowImg_2_1.alt=this.images['top_normal'].alt;arrowImg_2_1.title=this.images['top_normal'].title;arrowImg_2_1.onclick=this.goNorth;arrowImg_2_1.src=this.images['top_normal'].src;arrow_2_1.appendChild(arrowImg_2_1);var arrow_3_1=this.createDiv();arrow_3_1.className='MDVMapControl_Arrow';arrowImg_3_1=this.createImage();arrowImg_3_1.src=this.images['transparent'].src;arrow_3_1.appendChild(arrowImg_3_1);firstRow.appendChild(arrow_1_1);firstRow.appendChild(arrow_2_1);firstRow.appendChild(arrow_3_1);var arrow_1_2=this.createDiv();arrow_1_2.className='MDVMapControl_Arrow';arrowImg_1_2=this.createImage();arrowImg_1_2.hover=this.images['left_hover'];arrowImg_1_2.normal=this.images['left_normal'];arrowImg_1_2.alt=this.images['left_normal'].alt;arrowImg_1_2.title=this.images['left_normal'].title;arrowImg_1_2.onclick=this.goEast;arrowImg_1_2.src=this.images['left_normal'].src;arrow_1_2.appendChild(arrowImg_1_2);var arrow_2_2=this.createDiv();arrow_2_2.className='MDVMapControl_Arrow';arrowImg_2_2=this.createImage();arrowImg_2_2.hover=this.images['centre_hover'];arrowImg_2_2.normal=this.images['centre_normal'];arrowImg_2_2.alt=this.images['centre_normal'].alt;arrowImg_2_2.title=this.images['centre_normal'].title;arrowImg_2_2.onclick=this.goBack;arrowImg_2_2.mapControl=this;arrowImg_2_2.src=this.images['centre_normal'].src;arrow_2_2.appendChild(arrowImg_2_2);var arrow_3_2=this.createDiv();arrow_3_2.className='MDVMapControl_Arrow';arrowImg_3_2=this.createImage();arrowImg_3_2.hover=this.images['right_hover'];arrowImg_3_2.normal=this.images['right_normal'];arrowImg_3_2.alt=this.images['right_normal'].alt;arrowImg_3_2.title=this.images['right_normal'].title;arrowImg_3_2.onclick=this.goWest;arrowImg_3_2.src=this.images['right_normal'].src;arrow_3_2.appendChild(arrowImg_3_2);secondRow.appendChild(arrow_1_2);secondRow.appendChild(arrow_2_2);secondRow.appendChild(arrow_3_2);var arrow_1_3=this.createDiv();arrow_1_3.className='MDVMapControl_Arrow';arrowImg_1_3=this.createImage();arrowImg_1_3.src=this.images['transparent'].src;arrow_1_3.appendChild(arrowImg_1_3);var arrow_2_3=this.createDiv();arrow_2_3.className='MDVMapControl_Arrow';arrowImg_2_3=this.createImage();arrowImg_2_3.hover=this.images['bottom_hover'];arrowImg_2_3.normal=this.images['bottom_normal'];arrowImg_2_3.alt=this.images['bottom_normal'].alt;arrowImg_2_3.title=this.images['bottom_normal'].title;arrowImg_2_3.onclick=this.goSouth;arrowImg_2_3.src=this.images['bottom_normal'].src;arrow_2_3.appendChild(arrowImg_2_3);var arrow_3_3=this.createDiv();arrow_3_3.className='MDVMapControl_Arrow';arrowImg_3_3=this.createImage();arrowImg_3_3.src=this.images['transparent'].src;arrow_3_3.appendChild(arrowImg_3_3);thirdRow.appendChild(arrow_1_3);thirdRow.appendChild(arrow_2_3);thirdRow.appendChild(arrow_3_3);var arrow_spacer=this.createDiv();arrow_spacer.className='MDVMapControl_Arrow';arrowImg_spacer=this.createImage();arrowImg_spacer.style.height="20px";arrowImg_spacer.src=this.images['spacer'].src;arrow_spacer.appendChild(arrowImg_spacer);this.zoomContainer.appendChild(arrow_spacer);var zoomIn=this.createDiv();zoomIn.className='MDVMapControl_Zoom';zoomInImg=this.createImage();zoomInImg.hover=this.images['zoomIn_hover'];zoomInImg.normal=this.images['zoomIn_normal'];zoomInImg.alt=this.images['zoomIn_normal'].alt;zoomInImg.title=this.images['zoomIn_normal'].title;zoomInImg.src=this.images['zoomIn_normal'].src;zoomInImg.onclick=this.zoomIn;zoomIn.appendChild(zoomInImg);this.zoomContainer.appendChild(zoomIn);var arrow_spacer=this.createDiv();arrow_spacer.className='MDVMapControl_Arrow';arrowImg_spacer=this.createImage();arrowImg_spacer.height=10;arrowImg_spacer.src=this.images['spacer'].src;arrow_spacer.appendChild(arrowImg_spacer);this.zoomContainer.appendChild(arrow_spacer);var zoomLevels=0;var zoomLevelArr=this.mdvMap.config.getZoomLevels();if(zoomLevelArr)zoomLevels=zoomLevelArr.length;for(var z=0;z<zoomLevels;z++){var level=zoomLevelArr[zoomLevels-z-1];if(level){var tmpZL=this.createDiv();tmpZL.className='MDVMapControl_ZoomLevel';tmpZLImg=this.createImage();tmpZLImg.level=level.level;tmpZLImg.hover=this.images['zoomLevel_hover'];tmpZLImg.normal=this.images['zoomLevel_normal'];tmpZLImg.src=this.images['zoomLevel_normal'].src;tmpZLImg.alt="1:"+level.getScale();tmpZLImg.title=tmpZLImg.alt;tmpZLImg.onclick=MDVMapControl_onclick;tmpZL.appendChild(tmpZLImg);this.zoomContainer.appendChild(tmpZL);this.zoomLevels.push(tmpZLImg);}};var zoomOut=this.createDiv();zoomOut.className='MDVMapControl_Zoom';zoomOutImg=this.createImage();zoomOutImg.hover=this.images['zoomOut_hover'];zoomOutImg.normal=this.images['zoomOut_normal'];zoomOutImg.alt=this.images['zoomOut_normal'].alt;zoomOutImg.title=this.images['zoomOut_normal'].title;zoomOutImg.src=this.images['zoomOut_normal'].src;zoomOutImg.onclick=this.zoomOut;zoomOut.appendChild(zoomOutImg);this.zoomContainer.appendChild(zoomOut);return true;};MDVMapControl.prototype.createImage=function(){var newImage=new Image();newImage.mdvMap=this.mdvMap;newImage.hover=null;newImage.normal=null;newImage.onmouseover=MDVMapControl_onmouseover;newImage.onmouseout=MDVMapControl_onmouseout;newImage.onclick=MDVMapControl_onclick;newImage.ondragstart=new Function([],'var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;');return newImage;};MDVMapControl.prototype.update=function(){if(!this.zoomLevels)return false;var currentZoomLevel=this.mdvMap.config.getZoomLevelIndex();var len=this.zoomLevels.length;for(var i=0;i<len;i++){if(this.zoomLevels[i].level==currentZoomLevel){this.zoomLevels[i].src=this.images['zoomLevel_active'].src;this.zoomLevels[i].hover=this.images['zoomLevel_active'];this.zoomLevels[i].normal=this.images['zoomLevel_active'];}else{this.zoomLevels[i].src=this.images['zoomLevel_normal'].src;this.zoomLevels[i].hover=this.images['zoomLevel_hover'];this.zoomLevels[i].normal=this.images['zoomLevel_normal'];}};return true;};MDVMapControl.prototype.zoomIn=function(){var zoomLevel=this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1);if(zoomLevel!=null){this.mdvMap.setZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1);this.mdvMap.update();};return true;};MDVMapControl.prototype.zoomOut=function(){var zoomLevel=this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())-1);if(zoomLevel!=null){this.mdvMap.setZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())-1);this.mdvMap.update();};return true;};MDVMapControl.prototype.goEast=function(){var realWidth=this.mdvMap.viewportRealWidth*0.6;var newCoords=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);newCoords.x=newCoords.x-Math.floor(realWidth+0.5);this.mdvMap.setCentre(newCoords);this.mdvMap.update();return true;};MDVMapControl.prototype.goWest=function(){var realWidth=this.mdvMap.viewportRealWidth*0.6;var newCoords=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);newCoords.x=newCoords.x+Math.floor(realWidth+0.5);this.mdvMap.setCentre(newCoords);this.mdvMap.update();return true;};MDVMapControl.prototype.goNorth=function(){var realHeight=this.mdvMap.viewportRealHeight*0.6;var newCoords=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);newCoords.y=newCoords.y-Math.floor(realHeight+0.5);this.mdvMap.setCentre(newCoords);this.mdvMap.update();return true;};MDVMapControl.prototype.goSouth=function(){var realHeight=this.mdvMap.viewportRealHeight*0.6;var newCoords=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);newCoords.y=newCoords.y+Math.floor(realHeight+0.5);this.mdvMap.setCentre(newCoords);this.mdvMap.update();return true;};MDVMapControl.prototype.goBack=function(){this.mdvMap.setZoomLevel(this.mapControl.zoomLevel);this.mdvMap.setCentre(this.mapControl.origin);this.mdvMap.update();};function MDVMapControl_onmouseover(e){if(this.hover&&this.hover.src){this.src=this.hover.src;this.style.cursor='pointer';};return true;};function MDVMapControl_onmouseout(e){if(this.normal&&this.normal.src){this.src=this.normal.src;this.style.cursor='auto';};return true;};function MDVMapControl_onclick(e){if(this.level){var zoomLevel=this.mdvMap.config.getZoomLevel(this.level);if(zoomLevel!=null){this.mdvMap.setZoomLevel(this.level);this.mdvMap.update();}};return true;};function MDVMapZoomBar(mdvMap){this.mdvMap=mdvMap;this.zoomBars=new Array();this.zoomImg=null;for(var method in MDVGadgetBase.prototype){if(!MDVMapZoomBar.prototype[method])MDVMapZoomBar.prototype[method]=MDVGadgetBase.prototype[method];};this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.preloadImgs);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.update);};MDVMapZoomBar.prototype.preloadImgs=function(){if(this.zoomImg)return false;var zoomlevels=this.mdvMap.config.getZoomLevels();var serverURL='';if(this.mdvMap.config.get('serverURL'))serverURL=this.mdvMap.config.get('serverURL');else{this.mdvMap.events.triggerEvent(MDVEvent_ERROR,'MDVMap wasn\'t able to find serverURL.');return false;};for(var z=0;z<zoomlevels.length;z++){this.zoomBars[zoomlevels[z].level]=new Image();this.zoomBars[zoomlevels[z].level].src=serverURL+'zoomlevel'+zoomlevels[z].level+'/ZoomBar_'+zoomlevels[z].level+'.gif';};this.zoomImg=document.createElement('img');this.zoomImg.className='MDVMap_ScaleBar';this.zoomImg.src=this.zoomBars[this.mdvMap.config.getZoomLevelIndex()].src;this.mdvMap.viewport.appendChild(this.zoomImg);return true;};MDVMapZoomBar.prototype.update=function(){if(this.zoomBars[this.mdvMap.config.getZoomLevelIndex()]==null){this.mdvMap.events.triggerEvent(MDVEvent_WARNING,'MDVMap wasn\'t able to load appropriate zoom bar image.');this.zoomImg.style.visibility='hidden';return false;};this.zoomImg.style.visibility='visible';this.zoomImg.src=this.zoomBars[this.mdvMap.config.getZoomLevelIndex()].src;return true;};MDVMapZoomBar.prototype.destroy=function(){if(this.mdvMap)this.mdvMap=null;this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null;for(var i=0;i<this.zoomBars.length;i++){this.zoomBars[i].onload=null;this.zoomBars[i].onerror=null;this.zoomBars[i].available=null;}};function MDVMapSync(mdvMap,mdvMiniMap){this.mdvMap=mdvMap;this.mdvMiniMap=mdvMiniMap;this.active=true;this.lastMap=null;this.lastMiniMap=null;for(var method in MDVGadgetBase.prototype){if(!MDVMapSync.prototype[method])MDVMapSync.prototype[method]=MDVGadgetBase.prototype[method];};this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.updateMiniMap);this.mdvMiniMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.updateMap);};MDVMapSync.prototype.updateMiniMap=function(id,msg,mdvMap){if(this.mdvMap.state!=1||this.mdvMiniMap.state!=1||!this.isActive())return false;if(this.lastMiniMap&&this.lastMiniMap.centre.equals(mdvMap.getCentre())&&this.lastMiniMap.zoomLevel==mdvMap.config.getZoomLevelIndex())return false;this.mdvMiniMap.setCentre(mdvMap.getCentre().clone());this.mdvMiniMap.setZoomLevel(mdvMap.config.getZoomLevelIndex());this.lastMiniMap={centre:this.mdvMiniMap.getCentre(),zoomLevel:this.mdvMiniMap.config.getZoomLevelIndex()};return this.mdvMiniMap.update();};MDVMapSync.prototype.updateMap=function(id,msg,mdvMiniMap){if(this.mdvMap.state!=1||this.mdvMiniMap.state!=1||!this.isActive())return false;if(this.lastMap&&this.lastMap.centre.equals(mdvMiniMap.getCentre())&&this.lastMap.zoomLevel==mdvMiniMap.config.getZoomLevelIndex())return false;this.mdvMap.setCentre(mdvMiniMap.getCentre().clone());this.mdvMap.setZoomLevel(mdvMiniMap.config.getZoomLevelIndex());this.lastMap={centre:this.mdvMap.getCentre(),zoomLevel:this.mdvMap.config.getZoomLevelIndex()};return this.mdvMap.update();};function MDVMapSyncBound(mdvMap,mdvMiniMap){for(var method in MDVGadgetBase.prototype){if(!MDVMapSync.prototype[method])MDVMapSync.prototype[method]=MDVGadgetBase.prototype[method];};for(var method in MDVMapSync.prototype){if(!MDVMapSyncBound.prototype[method])MDVMapSyncBound.prototype[method]=MDVMapSync.prototype[method];};this.mdvMap=mdvMap;this.mdvMiniMap=mdvMiniMap;this.active=true;this.lastMap=null;this.lastMiniMap=null;this.border=null;this.inner=null;this.bounds=null;this.mouseDown=false;this.last=null;this.stepTime=40;this.stepPx=4;this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.updateMiniMap);this.mdvMap.events.registerEvent(MDVEvent_ROUTE_TRACE_FINISHED,this,this.onTraceFinished);this.mdvMap.events.registerEvent(MDVEvent_CENTRE_CHANGED,this,this.onCentreChanged);this.mdvMiniMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.updateMap);this.mdvMiniMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.update);this.update();};MDVMapSyncBound.prototype.update=function(){if(this.mdvMap.state!=1||this.mdvMiniMap.state==-1)return false;if(!this.border){this.border=document.createElement('div');this.border.className='MDVMapSync_Outer';this.border.style.zIndex='150';this.border.style.position='absolute';this.border.setAttribute('unselectable','on');this.inner=document.createElement('div');this.inner.setAttribute('unselectable','on');this.inner.className='MDVMapSync_Inner';this.bounds=document.createElement('div');this.bounds.style.position='absolute';this.bounds.style.zIndex='140';this.bounds.className='MDVMapSync_Outer';this.bounds.setAttribute('unselectable','on');this.mdvMiniMap.viewport.appendChild(this.bounds);this.border.appendChild(this.inner);this.mdvMiniMap.viewport.appendChild(this.border);this.border.ondragstart=new Function([],'var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;');this.inner.ondragstart=new Function([],'var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;');this.bounds.ondragstart=new Function([],'var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;');this.border.mdvMap=this.mdvMap;this.border.mdvSyncBound=this;this.border.onmousedown=MDVMapSyncBound_onmousedown;this.border.onmouseup=MDVMapSyncBound_onmouseup;this.border.onmousemove=MDVMapSyncBound_onmousemove;this.border.onmousewheel=MDVMap_onmousewheel;if(window.addEventListener&&navigator.product&&navigator.product=='Gecko'){this.border.addEventListener('DOMMouseScroll',MDVMap_onmousewheel,false);}};var tl=this.mdvMiniMap.getPoint(this.mdvMap.tlReal);tl=this.getAbsolutePoint(tl);this.border.style.left=tl.x+'px';this.border.style.top=tl.y+'px';this.bounds.style.left=tl.x+'px';this.bounds.style.top=tl.y+'px';var ext=this.mdvMap.getViewportRealExtends();ext=this.getExtends(ext);this.inner.style.width=ext.width+'px';this.inner.style.height=ext.height+'px';this.bounds.style.width=ext.width+'px';this.bounds.style.height=ext.height+'px';return true;};MDVMapSyncBound.prototype.getAbsolutePoint=function(point){var offset=new MDVPoint(parseInt(this.mdvMiniMap.getMapper().style.left),parseInt(this.mdvMiniMap.getMapper().style.top));point.x+=offset.x;point.y+=offset.y;return point;};MDVMapSyncBound.prototype.getExtends=function(ext){var zoomLevel=this.mdvMiniMap.config.getZoomLevel(this.mdvMiniMap.config.getZoomLevelIndex());var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var realToPxRatioWidth=pxWidthAll/parseInt(zoomLevel.get('realWidth'));var pxHeightAll=parseInt(zoomLevel.get('tileSizeY'))*parseInt(zoomLevel.get('numberOfTilesY'));var realToPxRatioHeight=pxHeightAll/parseInt(zoomLevel.get('realHeight'));var ext={width:Math.floor(0.5+(ext.width*realToPxRatioWidth)),height:Math.floor(0.5+(ext.height*realToPxRatioHeight))};return ext;};MDVMapSyncBound.prototype.setMouseDown=function(mouseDown){this.mouseDown=mouseDown;};MDVMapSyncBound.prototype.isMouseDown=function(){return this.mouseDown;};MDVMapSyncBound.prototype.apply=function(){var prev=new MDVPoint(this.bounds.style.left,this.bounds.style.top);var curr=new MDVPoint(this.border.style.left,this.border.style.top);var delta=new MDVPoint(curr.x-prev.x,curr.y-prev.y);if(this.mdvMap.cancelMoveBySeq())this.update();this.setActive(false);this.centre=null;this.stepTime=this.mdvMap.stepTime;this.stepPx=this.mdvMap.stepPx;var zoomLevel=this.mdvMiniMap.config.getZoomLevel(this.mdvMiniMap.config.getZoomLevelIndex());var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var realToPxRatioWidth=parseInt(zoomLevel.get('realWidth'))/pxWidthAll;var pxHeightAll=parseInt(zoomLevel.get('tileSizeY'))*parseInt(zoomLevel.get('numberOfTilesY'));var realToPxRatioHeight=parseInt(zoomLevel.get('realHeight'))/pxHeightAll;var newC=this.mdvMiniMap.getCentre().clone();newC.x+=Math.floor(0.5+delta.x*realToPxRatioWidth);newC.y+=Math.floor(0.5+delta.y*realToPxRatioHeight);var oldC=this.mdvMap.getCentre().clone();var path=[oldC,newC];this.mdvMap.stepTime=20;this.mdvMap.stepPx=15.0;this.mdvMap.moveBySeq(path);this.last=null;return true;};MDVMapSyncBound.prototype.onTraceFinished=function(id,msg,obj){this.centre=null;this.mdvMap.stepTime=this.stepTime;this.mdvMap.stepPx=this.stepPx;this.setActive(true);this.updateMiniMap(-1,'',this.mdvMap);};MDVMapSyncBound.prototype.onCentreChanged=function(id,msg,centre){if(this.isActive())return false;var offset=new MDVPoint(parseInt(this.bounds.style.width)/2, parseInt(this.bounds.style.height)/2);var point=this.mdvMiniMap.getPoint(centre);point=this.getAbsolutePoint(point);point.x-=offset.x;point.y-=offset.y;this.bounds.style.left=point.x+'px';this.bounds.style.top=point.y+'px';return true;};function MDVMapSyncBound_onmousedown(e){this.mdvSyncBound.setMouseDown(true);};function MDVMapSyncBound_onmouseup(e){this.mdvSyncBound.setMouseDown(false);this.mdvSyncBound.apply();};function MDVMapSyncBound_onmousemove(e){if(this.mdvSyncBound.isMouseDown()){e=e?e:window.event;var mouseX=e.pageX||(e.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var mouseY=e.pageY||(e.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var offsetL=0;var offsetT=0;var obj=this.mdvMap.viewport;while(obj){offsetL+=obj.offsetLeft;offsetT+=obj.offsetTop;obj=obj.offsetParent;};mouseX=mouseX-(offsetL);mouseY=mouseY-(offsetT);var centrePoint=new MDVPoint(mouseX,mouseY);if(this.mdvSyncBound.last!=null){var newPoint=new MDVPoint(centrePoint.x-this.mdvSyncBound.last.x,centrePoint.y-this.mdvSyncBound.last.y);this.mdvSyncBound.border.style.left=parseInt(this.mdvSyncBound.border.style.left)+newPoint.x+'px';this.mdvSyncBound.border.style.top=parseInt(this.mdvSyncBound.border.style.top)+newPoint.y+'px';};this.mdvSyncBound.last=centrePoint.clone();};return false;};function MDVMapEFAInfoEx(mdvMap){this.mdvMap=mdvMap;this.name='MapEFAInfo';this.stops=null;this.poi=null;this.centre=null;this.id=null;this.lastCentre=null;this.stopImg=new Image();this.mot1Img=new Image();this.mot2Img=new Image();this.mot3Img=new Image();this.mot4Img=new Image();this.mot5Img=new Image();this.mot6Img=new Image();this.mot7Img=new Image();this.mot8Img=new Image();this.mot9Img=new Image();this.mot10Img=new Image();this.mot11Img=new Image();this.mot12Img=new Image();this.poiImg=new Image();this.entranceImg=new Image();this.pointImg=new Image();this.letters=new Array();this.letters['0']=new Image();this.letters['1']=new Image();this.letters['2']=new Image();this.letters['3']=new Image();this.letters['4']=new Image();this.letters['5']=new Image();this.letters['6']=new Image();this.letters['7']=new Image();this.letters['8']=new Image();this.letters['9']=new Image();this.letters['A']=new Image();this.letters['B']=new Image();this.letters['C']=new Image();this.letters['D']=new Image();this.letters['E']=new Image();this.letters['F']=new Image();this.letters['G']=new Image();this.letters['H']=new Image();this.letters['I']=new Image();this.letters['J']=new Image();this.letters['K']=new Image();this.letters['L']=new Image();this.letters['M']=new Image();this.letters['N']=new Image();this.letters['O']=new Image();this.letters['P']=new Image();this.letters['Q']=new Image();this.letters['R']=new Image();this.letters['S']=new Image();this.letters['T']=new Image();this.letters['U']=new Image();this.letters['V']=new Image();this.letters['W']=new Image();this.letters['X']=new Image();this.letters['Y']=new Image();this.letters['Z']=new Image();this.stopsOnly=false;this.imgsLoaded=false;this.comparator=null;if(arguments.length>=2&&arguments[1]!=null)this.comparator=arguments[1];if(arguments.length>=2&&arguments[2]!=null)this.getMOTImage=arguments[2];for(var method in MDVGadgetBase.prototype){if(!MDVMapEFAInfoEx.prototype[method])MDVMapEFAInfoEx.prototype[method]=MDVGadgetBase.prototype[method];};this.mdvMap.registerGadget(this);this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this.trigger);this.mdvMap.events.registerEvent(MDVEvent_AJAX_CALLBACK,this,this.processPins);};MDVMapEFAInfoEx.prototype.destroy=function(){this.stopImg.onclick=null;this.stopImg=null;this.mot1Img.onclick=null;this.mot1Img=null;this.mot2Img.onclick=null;this.mot2Img=null;this.mot3Img.onclick=null;this.mot3Img=null;this.mot4Img.onclick=null;this.mot4Img=null;this.mot5Img.onclick=null;this.mot5Img=null;this.mot6Img.onclick=null;this.mot6Img=null;this.mot7Img.onclick=null;this.mot7Img=null;this.mot8Img.onclick=null;this.mot8Img=null;this.mot9Img.onclick=null;this.mot9Img=null;this.mot10Img.onclick=null;this.mot10Img=null;this.mot11Img.onclick=null;this.mot11Img=null;this.mot12Img.onclick=null;this.mot12Img=null;this.poiImg.onclick=null;this.poiImg=null;this.entranceImg.onclick=null;this.entranceImg=null;this.pointImg.onclick=null;this.pointImg=null;if(this.stops)this.stops.removeAll();if(this.poi)this.poi.removeAll();};MDVMapEFAInfoEx.prototype.createLayers=function(){if(!this.stops){this.stops=this.mdvMap.createLayer('efa_stops');this.stops.setZIndex(2);this.mdvMap.addLayer(this.stops);};if(!this.poi){this.poi=this.mdvMap.createLayer('efa_poi');this.poi.setZIndex(1);this.mdvMap.addLayer(this.poi);}};MDVMapEFAInfoEx.prototype.trigger=function(){var ipath='images/';if(this.mdvMap.config.get('imagePath'))ipath=this.mdvMap.config.get('imagePath');if(!this.imgsLoaded){this.stopImg.src=ipath+'stop.gif';this.mot1Img.src=ipath+'mot1.gif';this.mot2Img.src=ipath+'mot2.gif';this.mot3Img.src=ipath+'mot3.gif';this.mot4Img.src=ipath+'mot4.gif';this.mot5Img.src=ipath+'mot5.gif';this.mot6Img.src=ipath+'mot6.gif';this.mot7Img.src=ipath+'mot7.gif';this.mot8Img.src=ipath+'mot8.gif';this.mot9Img.src=ipath+'mot9.gif';this.mot10Img.src=ipath+'mot10.gif';this.mot11Img.src=ipath+'mot11.gif';this.mot12Img.src=ipath+'mot12.gif';this.poiImg.src=ipath+'pin.gif'
this.entranceImg.src=ipath+'entrance.gif';this.pointImg.src=ipath+'point.gif';if(this.mdvMap.config.get('info.stop.only')&&this.mdvMap.config.get('info.stop.only')=='true')this.stopsOnly=true;this.imgsLoaded=true;};if(this.id){mdvTimer.remove(this.id);this.id=null;};this.id=mdvTimer.add(700,this,this.execute,[]);};MDVMapEFAInfoEx.prototype.execute=function(){mdvTimer.remove(this.id);this.id=null;this.createLayers();var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var showStops=zoomLevel.get('showSTOP')=="true";var showPOI=zoomLevel.get('showPOI')=="true";if(showStops||showPOI){this.fetchPins();}else{this.stops.removeAll();this.poi.removeAll();}};MDVMapEFAInfoEx.prototype.getMOTImage=function(mot,type,pin){switch(parseInt(mot)){case 1:return this.mot1Img.src;break;case 2:return this.mot2Img.src;break;case 3:return this.mot3Img.src;break;case 4:return this.mot4Img.src;break;case 5:return this.mot5Img.src;break;case 6:return this.mot6Img.src;break;case 7:return this.mot7Img.src;break;case 8:return this.mot8Img.src;break;case 9:return this.mot9Img.src;break;case 10:return this.mot10Img.src;break;case 11:return this.mot11Img.src;break;case 12:return this.mot12Img.src;break;default:if(type.toUpperCase()=='BUS_POINT')return this.getBusPointImg(request.coordInfo.pins[i]);else if(type.toUpperCase()=='ENTRANCE')return this.entranceImg.src;else if(type.toUpperCase()=='POI_POINT')return this.poiImg.src;else return this.stopImg.src;break;}};MDVMapEFAInfoEx.prototype.processPins=function(id,gadName,request){if(gadName!='MDVMapEFAInfoEx')return false;mdvTimer.remove(this.id);this.id=null;var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var showStops=zoomLevel.get('showSTOP')=="true"?true:false;var showPOI=zoomLevel.get('showPOI')=="true"?true:false;this.stops.removeAll();this.poi.removeAll();if(request.coordInfo&&request.coordInfo.request){var reqCoord=new MDVCoordinates(request.coordInfo.request.coords.mapName,request.coordInfo.request.coords.x,request.coordInfo.request.coords.y);if(!reqCoord.equals(this.mdvMap.getCentre())){return false;}};var updateStops=false;var updatePOI=false;if(request.coordInfo.pins.length<=0){this.mdvMap.events.triggerEvent(MDVEvent_ERROR,'MDVMap wasn\'t able to get pins from map request.');return false;};for(var i=0;i<request.coordInfo.pins.length;i++){var pinName=request.coordInfo.pins[i].desc;var	pinId=request.coordInfo.pins[i].id;var	pinType=request.coordInfo.pins[i].type;var	pinOmc=request.coordInfo.pins[i].omc;var pinIdentifier=request.coordInfo.pins[i].identifier;var tmpImg=new Image();var sMeans=request.coordInfo.pins[i].attrs;if(sMeans&&sMeans.length>0){var nodeValue='';for(var m=0;m<sMeans.length;m++){var tmpNode=sMeans[m];if(tmpNode.name=='STOP_MAJOR_MEANS'){nodeValue=tmpNode.value;break;}};tmpImg.src=this.getMOTImage(nodeValue,pinType,request.coordInfo.pins[i]);}else{if(pinType.toUpperCase()=='BUS_POINT')tmpImg.src=this.getBusPointImg(request.coordInfo.pins[i]);else if(pinType.toUpperCase()=='ENTRANCE')tmpImg.src=this.entranceImg.src;else if(pinType.toUpperCase()=='POI_POINT')tmpImg.src=this.poiImg.src;else tmpImg.src=this.stopImg.src;};var bubbleSize=new Array();bubbleSize['poi']=new MDVPoint(284,190);bubbleSize['stop']=new MDVPoint(284,190);if(this.mdvMap.config.get('info.stop.size.width')&&this.mdvMap.config.get('info.stop.size.height')){bubbleSize['stop']=new MDVPoint(this.mdvMap.config.get('info.stop.size.width'),this.mdvMap.config.get('info.stop.size.height'));};if(this.mdvMap.config.get('info.poi.size.width')&&this.mdvMap.config.get('info.poi.size.height')){bubbleSize['poi']=new MDVPoint(this.mdvMap.config.get('info.poi.size.width'),this.mdvMap.config.get('info.poi.size.height'));};var coordList=request.coordInfo.pins[i].coords.split(',');var coords=new MDVCoordinates(request.coordInfo.request.coords.mapName,coordList[0],coordList[1]);var pos=0.5;switch(pinType.toUpperCase()){case 'ENTRANCE':pos=new MDVPoint(0.5,0.5);break;case 'BUSPOINT':pos=new MDVPoint(0.5,0.5);break;};var mapPin=this.mdvMap.createMarker(coords,pos,tmpImg.src);var attrs=null;if(request.coordInfo.pins[i].attrs)attrs=request.coordInfo.pins[i].attrs;mapPin.objectId={type:pinType,desc:pinName,id:pinId,omc:pinOmc,identifier:pinIdentifier,marker:mapPin,attrs:attrs};if(this.comparator){if(!this.comparator(mapPin.objectId))continue;};switch(pinType.toUpperCase()){case 'POI_POINT':var mapPinTitle=null;if(this.mdvMap.config.get('useBubbleForEFAInfo')&&this.mdvMap.config.get('useBubbleForEFAInfo')=='true'){mapPinTitle=this.mdvMap.createToolTip(bubbleSize['poi'],'<b>'+pinName+'</b>');if(this.mdvMap.config.get('useBubbleOverflowForEFAInfo')&&this.mdvMap.config.get('useBubbleOverflowForEFAInfo')=='true')mapPinTitle.setOverflow(true);if(this.mdvMap.config.get('useBubblePinForEFAInfo')&&this.mdvMap.config.get('useBubblePinForEFAInfo')=='true')mapPinTitle.setPin(true);mapPin.setToolTip(mapPinTitle,false);}else{mapPinTitle=this.mdvMap.createToolTip('Landmark: <b>'+pinName+'</b>');mapPin.setToolTip(mapPinTitle,false);};break;default:var mapPinTitle=null;if(this.mdvMap.config.get('useBubbleForEFAInfo')&&this.mdvMap.config.get('useBubbleForEFAInfo')=='true'){mapPinTitle=this.mdvMap.createToolTip(bubbleSize['stop'],'<b>'+pinName+'</b>');if(this.mdvMap.config.get('useBubbleOverflowForEFAInfo')&&this.mdvMap.config.get('useBubbleOverflowForEFAInfo')=='true')mapPinTitle.setOverflow(true);if(this.mdvMap.config.get('useBubblePinForEFAInfo')&&this.mdvMap.config.get('useBubblePinForEFAInfo')=='true')mapPinTitle.setPin(true);mapPin.setToolTip(mapPinTitle,false);}else{mapPinTitle=this.mdvMap.createToolTip('Stop: <b>'+pinName+'</b>');mapPin.setToolTip(mapPinTitle,false);};break;};switch(pinType.toUpperCase()){case 'POI_POINT':if(showPOI){for(var m=0;m<this.poi.getMarkers().length;m++){var pois=this.poi.getMarkers();if(pois[m].objectId.id==mapPin.objectId.id&&pois[m].objectId.omc==mapPin.objectId.omc){stopIt=true;break;}};if(stopIt)continue;this.poi.addMarker(mapPin,false);updatePOI=true;};break;default:if(showStops){var stopIt=false;for(var m=0;m<this.stops.getMarkers().length;m++){var stops=this.stops.getMarkers();if(stops[m].objectId.id==mapPin.objectId.id){stopIt=true;break;}};if(stopIt)continue;this.stops.addMarker(mapPin,false);updateStops=true;};break;}};if(updateStops)this.stops.update();if(updatePOI)this.poi.update();this.centre=new MDVCoordinates(this.mdvMap.getCentre().mapName,this.mdvMap.getCentre().x,this.mdvMap.getCentre().y);return true;};MDVMapEFAInfoEx.prototype.getBusPointImg=function(pin){if(this.letters[pin.identifier]&&this.letters[pin.identifier].src)return this.letters[pin.identifier].src;else{var imgPath='images/';if(this.mdvMap.config.get('imagePath'))imgPath=this.mdvMap.config.get('imagePath');imgPath+='point_'+pin.identifier+'.gif';return imgPath;}};MDVMapEFAInfoEx.prototype.fetchPins=function(){if(this.mdvMap.config.get('efaURL')){var host=this.mdvMap.config.get('efaURL');var centre=this.mdvMap.getCentre();var language=this.mdvMap.config.get('language')!=null?this.mdvMap.config.get('language'):'en';var zoomLevel=this.mdvMap.config.getZoomLevel(this.mdvMap.config.getZoomLevelIndex());var isLast=this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1)==null;var isOneBeforeLast=this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+2)==null&&this.mdvMap.config.getZoomLevel(parseInt(this.mdvMap.config.getZoomLevelIndex())+1)!=null;var showStops=zoomLevel.get('showSTOP')=="true"&&this.stops.visible?1:0;var showPOI=zoomLevel.get('showPOI')=="true"&&this.poi.visible?1:0;var vpReal=this.mdvMap.getViewportRealExtends();var radius=Math.floor(0.5+Math.sqrt((Math.pow(vpReal.width/2, 2)+ Math.pow(vpReal.height/2,2))));var _params={language:language,coord:Math.floor(centre.x+0.5)+':'+Math.floor(centre.y+0.5)+':'+centre.mapName,inclFilter:1,purpose:'',max:-1,coordListFormat:'STRING',language:'en',itdLPxx_mdvMapName:'mdvMap_'+this.mdvMap.getName(),coordListOutputFormat:'STRING'};var ifilter=1;if(showStops){var temp='';if(zoomLevel.get('showSTOP.majorMeans')){temp=zoomLevel.get('showSTOP.majorMeans');};_params['type_'+ifilter]='STOP';_params['radius_'+ifilter]=radius;_params['inclDrawClasses_'+ifilter]=temp;ifilter++;if((isLast||isOneBeforeLast)&&!this.stopsOnly){temp='';if(isLast){_params['type_'+ifilter]='ENTRANCE';_params['radius_'+ifilter]=radius;_params['inclDrawClasses_'+ifilter]=temp;ifilter++;};temp='';_params['type_'+ifilter]='BUS_POINT';_params['radius_'+ifilter]=radius;_params['inclDrawClasses_'+ifilter]=temp;ifilter++;}};if(showPOI){var temp='';for(var ii=39;ii<=80;ii++){temp+=ii+':';};_params['type_'+ifilter]='POI_POINT';_params['radius_'+ifilter]=radius;_params['inclDrawClasses_'+ifilter]=temp;ifilter++;};if($.post){var _ajax=$.post(host,_params,MDVMapEFAInfoEx_onAjaxComplete);}else{_params=$H(_params);_params=_params.toQueryString();var _ajax=new Ajax.Request(host,{method:'post',parameters:_params,onComplete:MDVMapEFAInfoEx_onAjaxComplete});}}};MDVMapEFAInfoEx.prototype.onmousedown=function(e){mdvTimer.remove(this.id);this.id=null;this.lastCentre=this.mdvMap.getCentre().clone();return true;};MDVMapEFAInfoEx.prototype.onmouseup=function(e){if(this.lastCentre&&this.lastCentre.equals(this.mdvMap.getCentre())){this.trigger();};return true;};function MDVMapEFAInfoEx_onAjaxComplete(request){var json=null;var efa=null;if(request&&request.responseText){json=request.responseText;}else if(request){json=request;};eval('efa = '+json+';');for(var i=0;i<efa.parameters.length;i++){if(efa.parameters[i].name=='mdvMapName'){mdvMapName=efa.parameters[i].value;break;}};if(document.mdvMaps[mdvMapName])document.mdvMaps[mdvMapName].events.triggerEvent(MDVEvent_AJAX_CALLBACK,'MDVMapEFAInfoEx',efa);};function MDVMapScale(mdvMap,options){if(!mdvMap){return;};this.mdvMap=mdvMap;this.init=false;this.maxScaleWidth=100;this.minScaleWidth=60;this.levels=[];this.divScale=null;this.divScaleLeft=null;this.divScaleBar=null;this.divScaleTickTop=null;this.divScaleTickBottom=null;this.divScaleTextTop=null;this.divScaleTextBottom=null;if(options){for(var val in options){this[val]=options[val];}};if(this.mdvMap.viewportRealWidth!==-1){this._execute();}else{this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this._execute);}};MDVMapScale.prototype._execute=function(){if(this.init){return true;};this.calculateScales();var that=this;this.scaleImg=new Image();this.scaleImg.failCount=0;this.scaleImg.onload=this.createDivs.bind(this);this.scaleImg.onerror=function(){if(that.mdvMap){that.scaleImg.failCount++;var failSrc=that.scaleImg.src;if(that.scaleImg.failCount<=10){that.scaleImg.src=failSrc;}else{return;}}}.bind(that);this.scaleImg.src=this.mdvMap.config.get('imagePath')+'scale.gif';};MDVMapScale.prototype.calculateScales=function(){var that=this;var MILE=1604.134;var MILETOYARD=1754.302;var milesOut,meterOut,milesUnit,meterUnit,pxMiles,pxMeter;for(var i=0,zl=this.mdvMap.config.zoomLevels.length;i<zl;i++){var zoomLevel=this.mdvMap.config.getZoomLevel(i);var pxWidthAll=parseInt(zoomLevel.get('tileSizeX'))*parseInt(zoomLevel.get('numberOfTilesX'));var realWidthAll=parseInt(zoomLevel.get('realWidth'));var pxToRealRatioWidth=pxWidthAll/realWidthAll;var milesIn=toMiles(this.maxScaleWidth/pxToRealRatioWidth);calculateMiles(milesIn);calculateMeter();this.levels[i]={};this.levels[i].milesOut=milesOut;this.levels[i].meterOut=meterOut;this.levels[i].milesUnit=milesUnit;this.levels[i].meterUnit=meterUnit;this.levels[i].pxMiles=pxMiles;this.levels[i].pxMeter=pxMeter;};function calculateMiles(miles){var factor=1;var temp=miles*1000;if(temp>=1000){factor=1000;}else if(temp>=100){temp=temp*MILETOYARD/1000;factor=100;}else if(temp>=10){temp=temp*MILETOYARD/1000;factor=10;};if(factor>100){var m=Math.floor(temp/factor);if(m>10){if(Math.round(m/10) < m/10){m=Math.round(m/10)*10;}else{m=(Math.round(m/10)*10)-10;}};milesOut=m;}else{milesOut=Math.floor(temp/factor)*factor;};milesUnit=(factor>100)?((milesOut===1)?'mile':'miles'):'yards';pxMiles=(factor>100)?(Math.round(toMeter(milesOut)*pxToRealRatioWidth)):(Math.round(toMeter(milesOut/MILETOYARD)*pxToRealRatioWidth));while(pxMiles<that.minScaleWidth){calculateMiles(miles+0.1);}};function calculateMeter(){var factor=1;var meterIn=(milesUnit.indexOf('mile')!==-1)?toMeter(milesOut):toMeter(milesOut/MILETOYARD);if(meterIn>=1000){factor=1000;}else if(meterIn>=100){factor=100;}else if(meterIn>=10){factor=10;};if(factor>100){var m=Math.floor(meterIn/factor);if(m>10){if(Math.round(m/10) < m/10){m=Math.round(m/10)*10;}else{m=(Math.round(m/10)*10)-10;}};meterOut=m;}else{meterOut=Math.floor(meterIn/factor)*factor;};meterUnit=(factor>100)?'km':'m';pxMeter=(factor>100)?(Math.round(meterOut*1000*pxToRealRatioWidth)):(Math.round(meterOut*pxToRealRatioWidth));};function toMiles(meter){return meter/MILE;};function toMeter(miles){return miles*MILE;}};MDVMapScale.prototype.setScale=function(){var level=this.levels[this.mdvMap.config.getZoomLevelIndex()];var topText=level.milesOut+' '+level.milesUnit;var bottomText=level.meterOut+' '+level.meterUnit;if(this.divScaleTextTop){this.divScaleTextTop.innerHTML=topText;};if(this.divScaleTextBottom){this.divScaleTextBottom.innerHTML=bottomText;};mdvLib.style([this.divScaleBar],{width:level.pxMiles+'px',backgroundPosition:((this.scaleImg.width-level.pxMiles)*-1)+'px 0'});this.divScaleTickTop.style.left=level.pxMiles-1+'px';this.divScaleTickBottom.style.left=level.pxMeter-1+'px';return true;};MDVMapScale.prototype.createDivs=function(){this.divScale=createDiv('divScale');this.divScaleLeft=createDiv('divScaleLeft');this.divScaleBar=createDiv('divScaleBar');this.divScaleTickTop=createDiv('divScaleTickTop');this.divScaleTickBottom=createDiv('divScaleTickBottom');this.divScaleTextTop=createDiv('divScaleTextTop');this.divScaleTextBottom=createDiv('divScaleTextBottom');mdvLib.style([this.divScale],{position:'absolute',top:this.mdvMap.viewportHeight-40+'px',left:'15px',zIndex:999});mdvLib.style([this.divScaleBar,this.divScaleLeft,this.divScaleTextBottom,this.divScaleTextTop,this.divScaleTickBottom,this.divScaleTickTop],{position:'absolute',display:'inline'});mdvLib.style([this.divScaleBar,this.divScaleLeft,this.divScaleTickBottom,this.divScaleTickTop],{background:'transparent',backgroundImage:'url('+this.scaleImg.src+')',backgroundPosition:'0 0',backgroundRepeat:'no-repeat'});mdvLib.style([this.divScaleLeft],{width:'4px',height:'26px'});mdvLib.style([this.divScaleBar],{width:'100px',height:'4px',left:'3px',top:'11px'});mdvLib.style([this.divScaleTickTop],{width:'4px',height:'12px',backgroundPosition:'-4px 0',top:'0px'});mdvLib.style([this.divScaleTickBottom],{width:'4px',height:'12px',backgroundPosition:'-8px 0',top:'14px'});mdvLib.style([this.divScaleTextTop],{width:'60px',left:'8px',top:'-2px',fontSize:'10px'});mdvLib.style([this.divScaleTextBottom],{width:'60px',left:'8px',top:'15px',fontSize:'10px'});this.divScale.appendChild(this.divScaleLeft);this.divScale.appendChild(this.divScaleBar);this.divScale.appendChild(this.divScaleTickTop);this.divScale.appendChild(this.divScaleTickBottom);this.divScale.appendChild(this.divScaleTextTop);this.divScale.appendChild(this.divScaleTextBottom);this.mdvMap.viewport.appendChild(this.divScale);this.mdvMap.events.registerEvent(MDVEvent_ZOOM_CHANGED,this,this.setScale);this.init=true;this.setScale();function createDiv(id){var div=document.createElement('div');div.id=id;return div;}};function MDVMapSlider(mdvMap,options){if(!mdvMap){return;};this.mdvMap=mdvMap;this.mdvMap.registerGadget(this);for(var method in MDVGadgetBase.prototype){if(!MDVMapSlider.prototype[method])MDVMapSlider.prototype[method]=MDVGadgetBase.prototype[method];};this.name='MapSlider';this.imgs={plus:'zoom_Plus.png',minus:'zoom_Minus.png',tick:'tick.png',knob:'dragbar.png',indicator:'sizableBar_Large.png',bg:'zoomBG_separate.png'};this.sliderOffsetTop=30;this.sliderOffsetLeft=20;this.tickDiv=null;this.tickOffset=18;this.tickOffsetLeft=10;this.tickPositions=[];this.knob=null;this.knobDiv=null;this.knobActive=false;this.timer=null;this.timerDelay=20;this.currentLevel=0;this.zoomLevels=0;this.indicator=null;this.imagePath=this.mdvMap.config.get('imagePath');this.imagePath+='zoom/';this.imageRolloverPath='rollover/';this.plus=null;this.plusOver=null;this.minus=null;this.minusOver=null;this.bg=null;this.bgPos=0;this.garbage=[];this.init=false;if(options!==null){for(var setting in options){if(this[setting]){this[setting]=options[setting];}}};if(this.mdvMap.viewportRealWidth!==-1){this._execute();}else{this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this._execute);}};MDVMapSlider.prototype.destroy=function(){for(var i=0,len=this.garbage.length;i<len;i++){var target=this.garbage[i];switch(mdvLib.typeOf(target)){case 'string':if(this[target]){this[target]=null;};break;case 'object':target=null;break;case 'array':var obj=this.garbage[i][0];var evt=this.garbage[i][1];if(this[obj][evt]){this[obj][evt]=null;};break;default:break;}}};MDVMapSlider.prototype.createContainer=function(){var divSlider=createDiv('divSlider');var divSliderPlus=createDiv('divSliderPlus');var divSliderBG=createDiv('divSliderBG');var divSliderKnob=createDiv('divSliderKnob');var divSliderTicks=createDiv('divSliderTicks');var divSliderMinus=createDiv('divSliderMinus');mdvLib.style([divSlider],{position:'absolute',top:this.sliderOffsetTop+'px',left:this.sliderOffsetLeft+'px',zIndex:999});mdvLib.style([divSliderPlus,divSliderMinus,divSliderBG],{position:'relative'});mdvLib.style([divSliderPlus,divSliderMinus],{marginLeft:'3px',zIndex:6,height:'18px',width:'18px'});divSliderPlus.onclick=function(){if((this.currentLevel+1)<=(this.zoomLevels-1)){this.setZoomLevel(this.getZoomLevel()+1);};this.clearTimer();this.animate.bind(this)();return false;}.bind(this);divSliderPlus.onmouseover=function(){this.plus.style.left='-2000px';this.plusOver.style.left='0px';}.bind(this);divSliderPlus.onmouseout=function(){this.plus.style.left='0px';this.plusOver.style.left='-2000px';}.bind(this);divSliderMinus.onclick=function(){if((this.currentLevel-1)>=0){this.setZoomLevel(this.getZoomLevel()-1);};this.clearTimer();this.animate.bind(this)();return false;}.bind(this);divSliderMinus.onmouseover=function(){this.minus.style.left='-2000px';this.minusOver.style.left='0px';}.bind(this);divSliderMinus.onmouseout=function(){this.minus.style.left='0px';this.minusOver.style.left='-2000px';}.bind(this);divSliderTicks.style.zIndex=6;divSliderBG.appendChild(divSliderKnob);divSliderBG.appendChild(divSliderTicks);divSlider.appendChild(divSliderPlus);divSlider.appendChild(divSliderBG);divSlider.appendChild(divSliderMinus);this.mdvMap.viewport.appendChild(divSlider);function createDiv(id){var div=document.createElement('div');div.id=id;return div;}};MDVMapSlider.prototype.loadImages=function(){for(var i in this.imgs){MDVMapSliderImages[i]=new Image();MDVMapSliderImages.over[i]=new Image();if(i==='bg'){MDVMapSliderImages[i].failCount=0;MDVMapSliderImages[i].onload=function(){this.setImages();this.drawTicks();this.createKnob();mdvLib.correctPNG(this.mdvMap,[this.plus,this.plusOver,this.minus,this.minusOver,this.bg,this.knob])}.bind(this);MDVMapSliderImages[i].onerror=function(){if(this.mdvMap){MDVMapSliderImages.bg.failCount++;var failSrc=MDVMapSliderImages.bg.src;if(MDVMapSliderImages.bg.failCount<=10){MDVMapSliderImages.bg.src=failSrc;}else{return;}}}.bind(this);};MDVMapSliderImages[i].src=this.imagePath+this.imgs[i];MDVMapSliderImages.over[i].src=this.imagePath+this.imageRolloverPath+this.imgs[i];}};MDVMapSlider.prototype.setImages=function(){var that=this;this.plus=mdvLib.createImg({position:'absolute',left:'0px'},{src:MDVMapSliderImages.plus.src,id:'MDVMapSliderPlus',title:'zoom in',alt:'zoom in'});this.plusOver=mdvLib.createImg({position:'absolute',left:'-2000px'},{src:MDVMapSliderImages.over.plus.src,id:'MDVMapSliderPlusOver',title:'zoom in',alt:'zoom in'});var plusDiv=mdvLib.$('divSliderPlus');plusDiv.appendChild(this.plus);plusDiv.appendChild(this.plusOver);this.bg=mdvLib.createImg({},{id:'MDVMapSliderBg',src:MDVMapSliderImages.bg.src,zIndex:2,onclick:that.setKnob.bind(that),onmousemove:that.onKnobMove.bind(that),onmouseup:that.onKnobUp.bind(that)});this.bgPos=mdvLib.getElementPosition(mdvLib.$('divSliderBG'));this.garbage.push(['bg','onclick'],['bg','onmousemove'],['bg','onmouseup']);mdvLib.$('divSliderBG').appendChild(this.bg);this.minus=mdvLib.createImg({position:'absolute',left:'0'},{src:MDVMapSliderImages.minus.src,id:'MDVMapSliderMinus',title:'zoom out',alt:'zoom out'});this.minusOver=mdvLib.createImg({position:'absolute',left:'-2000px'},{src:MDVMapSliderImages.over.minus.src,id:'MDVMapSliderMinusOver',title:'zoom out',alt:'zoom out'});var minusDiv=mdvLib.$('divSliderMinus');minusDiv.appendChild(this.minus);minusDiv.appendChild(this.minusOver);};MDVMapSlider.prototype.drawTicks=function(){var tickMargin=Math.floor((MDVMapSliderImages.bg.height-this.tickOffset)/this.zoomLevels);var tickPos=MDVMapSliderImages.bg.height-this.tickOffset;var that=this;this.tickDiv=mdvLib.$('divSliderTicks');this.tickDiv.appendChild(createTick(tickPos));this.tickPositions.push(tickPos);tickPos=tickPos-tickMargin;for(var i=2;i<=this.zoomLevels;i++){this.tickDiv.appendChild(createTick(tickPos));this.tickPositions.push(tickPos);tickPos=tickPos-tickMargin;};function createTick(pos){var img=document.createElement('img');img.src=MDVMapSliderImages.tick.src;img.style.position='absolute';img.style.top=pos+'px';img.style.left=that.tickOffsetLeft+'px';img.id="tick"+pos;return img;}};MDVMapSlider.prototype.createKnob=function(){this.knobDiv=mdvLib.$('divSliderKnob');var that=this;mdvLib.style([this.knobDiv],{position:'absolute',top:(this.tickPositions[this.getZoomLevel()]-(MDVMapSliderImages.knob.height/2))+'px',zIndex:5});this.knob=mdvLib.createImg({},{src:MDVMapSliderImages.knob.src,id:'MDVMapSliderKnob',onmousedown:function(){that.knobActive=true;that.clearTimer();return false;},onmousemove:that.onKnobMove.bind(that),onmouseup:that.onKnobUp.bind(that)});this.garbage.push(['knob','onmousedown'],['knob','onmousemove'],['knob','onmouseup']);this.indicator=mdvLib.createImg({position:'absolute',top:that.tickPositions[this.getZoomLevel()]+(MDVMapSliderImages.knob.height/2)-3+'px',left:'8px',zIndex:3},{id:'MDVMapSliderIndicator',src:MDVMapSliderImages.indicator.src,height:that.tickPositions[0]-that.tickPositions[this.getZoomLevel()]+7,width:MDVMapSliderImages.indicator.width,onclick:that.setKnob.bind(that),resize:function(posTop,plus){this.height=(plus)?this.height+1:this.height-1;this.style.top=posTop+(MDVMapSliderImages.knob.height/2)+'px';return true;}});this.garbage.push(['indicator','onclick']);this.knobDiv.appendChild(this.knob);mdvLib.$('divSliderBG').appendChild(this.indicator);this.mdvMap.events.registerEvent(MDVEvent_ZOOM_CHANGED,this,this.onZoomChanged);this.init=true;this.clearTimer();};MDVMapSlider.prototype.setKnob=function(e){var e=e||window.event;this.clearTimer();var posMouse=mdvLib.getMousePosition(e);var posMouseEl=MDVMapSliderImages.bg.height-(posMouse.top-this.bgPos.top);var hlp=this.tickPositions.slice().reverse();for(var i=0;i<hlp.length;i++){if(posMouseEl<=hlp[i+1]){var to=(posMouseEl<=((hlp[i]+hlp[i+1])/2))?i:i+1;this.setZoomLevel(parseInt(to,10));break;}};if(posMouseEl>=hlp[this.zoomLevels-1]){this.setZoomLevel(this.zoomLevels-1);};this.animate();return true;};MDVMapSlider.prototype.animate=function(){this.timer=window.setInterval(move.bind(this),this.timerDelay);var currentPos=parseInt(this.knobDiv.style.top,10);var targetPos=this.tickPositions[this.currentLevel]-MDVMapSliderImages.knob.height/2;function move(){if(targetPos>currentPos){currentPos++;this.knobDiv.style.top=currentPos+'px';this.indicator.resize(currentPos,false);return;};if(targetPos<currentPos){currentPos--;this.knobDiv.style.top=currentPos+'px';this.indicator.resize(currentPos,true);return;};this.clearTimer();}};MDVMapSlider.prototype.clearTimer=function(){window.clearInterval(this.timer);window.clearTimeout(this.timer);this.timer=null;};MDVMapSlider.prototype.setZoomLevel=function(value){if(value===this.currentLevel){return true;};var magnify=(this.mdvMap.config.get('useMagnifyGlass')&&this.mdvMap.config.get('useMagnifyGlass')=='true');if(magnify&&(this.currentLevel<value)){this.currentLevel=value;this.mdvMap._checkWrap();this.mdvMap.magnify(value);this.mdvMap.switchMapper();}else{this.currentLevel=value;this.mdvMap.setZoomLevel(value);this.mdvMap.update();};return true;};MDVMapSlider.prototype.onZoomChanged=function(){if(this.currentLevel==this.getZoomLevel()){return;};this.clearTimer();this.currentLevel=this.getZoomLevel();this.animate();};MDVMapSlider.prototype.getZoomLevel=function(){return(typeof this.mdvMap.config.getZoomLevelIndex()==='number')?this.mdvMap.config.getZoomLevelIndex():this.mdvMap.config.params.defaultScale;};MDVMapSlider.prototype.onKnobMove=function(e){if(this.knobActive!==true){return true;};var e=e||window.event;var posMouse=mdvLib.getMousePosition(e);var knobTop=(posMouse.top-(this.bgPos.top+Math.floor(this.knob.height/2)));var knobTopCurrent=parseInt(this.knobDiv.style.top,10);if((knobTop<this.tickPositions[this.zoomLevels-1])||(knobTop>this.tickPositions[0])){return true;};if(knobTopCurrent>knobTop){this.indicator.style.top=knobTop+(MDVMapSliderImages.knob.height/2)+'px';this.indicator.height=this.indicator.height+(knobTopCurrent-knobTop);}else{this.indicator.style.top=knobTop+(MDVMapSliderImages.knob.height/2)+'px';this.indicator.height=this.indicator.height-(knobTop-knobTopCurrent);};this.knobDiv.style.top=knobTop+'px';return false;};MDVMapSlider.prototype.onKnobUp=function(e){if(this.knobActive===true){this.knobActive=false;this.setKnob(e);};return false;};MDVMapSlider.prototype._execute=function(){if(this.init===true){return;};this.currentLevel=this.getZoomLevel();this.zoomLevels=this.mdvMap.config.zoomLevels.length;this.createContainer();this.loadImages();};var MDVMapSliderImages={over:{}};MDVMapSync.prototype.execute=function(container){if(!container){return false;};this.container=container;var that=this;var height=parseInt(this.container.offsetHeight,10);var width=parseInt(this.container.offsetWidth,10);this.container.style.left=this.mdvMap.viewportWidth-width-2+'px';this.container.style.top=this.mdvMap.viewportHeight-height-2+'px';this.isVisible=true;this.timerDelay=10;this.timer=null;this.buttonN=null;this.buttonO=null;this.buttonA=null;this.buttonPos=null;this.normal=new Image();this.normal.src=this.mdvMap.config.get('imagePath')+'mapStretch.png';this.over=new Image();this.over.src=this.mdvMap.config.get('imagePath')+'mapStretch_rollover.png';this.active=new Image();this.active.failCount=0;this.active.onload=this.createImages.bind(this);this.active.onerror=function(){if(that.mdvMap){that.active.failCount++;var failSrc=that.active.src;if(that.active.failCount<=10){that.active.src=failSrc;}else{return;}}}.bind(that);this.active.src=this.mdvMap.config.get('imagePath')+'mapStretch_act.png';this.stepsX=[];this.stepsY=[];this.leftPos=parseInt(this.container.style.left,10);this.topPos=parseInt(this.container.style.top,10);this.topPosHidden=this.topPos+height;var ratio=Math.floor(width/height);var steps=15;while(this.topPos<=this.topPosHidden+steps){this.stepsX.push(this.leftPos);this.stepsY.push(this.topPos);this.topPos+=steps;this.leftPos+=(steps*ratio);}};MDVMapSync.prototype.createImages=function(){var that=this;var toggleImgDiv=document.createElement('div');toggleImgDiv.id='toggleImgDiv';mdvLib.style([toggleImgDiv],{position:'absolute',top:this.mdvMap.viewportHeight-this.normal.height+'px',left:this.mdvMap.viewportWidth-this.normal.width+'px',zIndex:152});toggleImgDiv.onclick=function(){that.clearTimer();that.animate.bind(that)();return false;};toggleImgDiv.onmouseover=function(){if(this.buttonA.style.left=='0px'){return true;};this.buttonN.style.left='-2000px';this.buttonO.style.left='0px';}.bind(this);toggleImgDiv.onmouseout=function(){if(this.buttonA.style.left=='0px'){return true;};this.buttonN.style.left='0px';this.buttonO.style.left='-2000px';}.bind(this);this.buttonN=mdvLib.createImg({position:'absolute',left:'0px'},{src:that.normal.src,id:'togNormal',title:'hide MiniMap',alt:'hide MiniMap'});this.buttonO=mdvLib.createImg({position:'absolute',left:'-2000px'},{src:that.over.src,id:'togOver',title:'hide MiniMap',alt:'hide MiniMap'});this.buttonA=mdvLib.createImg({position:'absolute',left:'-2000px'},{src:that.active.src,id:'togActive',title:'show MiniMap',alt:' show MiniMap'});toggleImgDiv.appendChild(this.buttonN);toggleImgDiv.appendChild(this.buttonO);toggleImgDiv.appendChild(this.buttonA);this.mdvMap.viewport.appendChild(toggleImgDiv);mdvLib.correctPNG(this.mdvMap,[this.buttonN,this.buttonO,this.buttonA]);};MDVMapSync.prototype.animate=function(){var currentPos=parseInt(this.container.style.left,10);if(this.container.style.display==='none'){if(this.buttonA.style.left=='0px'){this.container.style.display='block';this.isVisible=false;}else{return;}}else{if((!this.isVisible)&&(currentPos<=(this.mdvMap.viewportWidth-this.container.offsetWidth))){this.isVisible=true;}};var tempX=this.stepsX.slice();var tempY=this.stepsY.slice();if(this.isVisible){tempX.reverse();tempY.reverse();this.setImgActive(true);this.isVisible=false;}else{this.setImgActive(false);this.isVisible=true;};this.timer=window.setInterval(move.bind(this),this.timerDelay);function move(){this.container.style.top=tempY.pop()+'px';this.container.style.left=tempX.pop()+'px';if(tempY.length==0){this.clearTimer();}}};MDVMapSync.prototype.clearTimer=function(){window.clearInterval(this.timer);this.timer=null;};MDVMapSync.prototype.setImgActive=function(flag){if(flag===true){this.buttonN.style.left='-2000px';this.buttonO.style.left='-2000px';this.buttonA.style.left='0px';}else{this.buttonA.style.left='-2000px';this.buttonO.style.left='-2000px';this.buttonN.style.left='0px';}};MDVMapSync.prototype.hideButton=function(flag){mdvLib.$('toggleImgDiv').style.display=(flag)?'none':'block';};function MDVRectZoom(mdvMap,options){if(!mdvMap){return;};this.mdvMap=mdvMap;this.mdvMap.registerGadget(this);this.name='RectZoom';this.init=false;this.bDragging=false;this.mc=null;this.mct=null;this.mcr=null;this.mcb=null;this.mcl=null;this.oOutline=null;this.mcOpacity=0.2;this.mcFilter='alpha(opacity=20)';this.gadgetBorder='1px solid #000';this.useButton=false;this.buttonN=null;this.buttonO=null;this.buttonA=null;if(options){this.options=options;};this.nBorderCorrect=this.gadgetBorder.split(' ')[0].replace(/px/,'')*2;this.oMapPos=null;this.nMapWidth=0;this.nMapHeight=0;this.nMapRatio=0;this.nStartX=0;this.nStartY=0;if(this.mdvMap.viewportRealWidth!==-1){this._execute();}else{this.mdvMap.events.registerEvent(MDVEvent_MAP_INITIALISED,this,this._execute);}};MDVRectZoom.prototype.onmousedown=function(e){if(this.useButton){return true;};if(e.shiftKey){this._showCover();this._coverMousedown(e);return false;};return true;};MDVRectZoom.prototype.onmousemove=function(e){if(this.useButton){return true;};if(e.shiftKey){this._coverDrag(e);return false;};return true;};MDVRectZoom.prototype.onmouseup=function(e){if(this.useButton){return true;};if(this.bDragging){return false;};return true;};MDVRectZoom.prototype.onmouseover=function(e){return true;};MDVRectZoom.prototype.onkeypress=function(e){return true;};MDVRectZoom.prototype.onmouseout=function(e){return true;};MDVRectZoom.prototype.oncontextmenu=function(e){return true;};MDVRectZoom.prototype.ondblclick=function(e){return true;};MDVRectZoom.prototype.onmousewheel=function(e){return true;};MDVRectZoom.prototype.destroy=function(){if(this.mdvMap){this.mdvMap=null;};this.ondblclick=null;this.onkeypress=null;this.onmousedown=null;this.onmousemove=null;this.onmouseout=null;this.onmouseover=null;this.onmouseup=null;this.onmousewheel=null;this.oncontextmenu=null;if(this.mc){this.mc.onmousemove=null;}};MDVRectZoom.prototype._execute=function(){if(this.init===true){return;};if(this.options){var that=this;if(typeof this.options.opacity!=='undefined'){this.mcOpacity=this.options.opacity;this.mcFilter=this.mcFilter.replace(/20/,this.options.opacity*100);};if(typeof this.options.border!=='undefined'){var tmp=this.options.border.split(' ');if(tmp[0].indexOf('px')===-1){tmp.reverse();};this.gadgetBorder=tmp.join(' ');this.nBorderCorrect=this.gadgetBorder.split(' ')[0].replace(/px/,'')*2;};if(typeof this.options.useButton!=='undefined'){if(this.options.useButton===true){this.useButton=true;this.normal=new Image();this.normal.src=that.mdvMap.config.get('imagePath')+this.options.buttonImg;this.over=new Image();this.over.src=that.mdvMap.config.get('imagePath')+this.options.buttonImgOver;this.active=new Image();this.active.failCount=0;this.active.onload=this._createButton.bind(this);this.active.onerror=function(){if(that.mdvMap){that.active.failCount++;var failSrc=that.active.src;if(that.active.failCount<=10){that.active.src=failSrc;}else{that.active.src=that.mdvMap.transparent.src;}}}.bind(that);this.active.src=that.mdvMap.config.get('imagePath')+this.options.buttonImgActive;}}};this._createGadgetElements();this.oOutline=mdvLib.$("rz-outline");if(this.useButton){this.oButton=mdvLib.$("rz_Button");};this.mc=mdvLib.$("rz_MapCover");this.mct=mdvLib.$("rz-mct");this.mcr=mdvLib.$("rz-mcr");this.mcb=mdvLib.$("rz-mcb");this.mcl=mdvLib.$("rz-mcl");this.oMapPos=mdvLib.getElementPosition(this.mdvMap.viewport);this._setDimensions();this._initStyles();if(this.useButton){this.mc.onmousedown=this._coverMousedown.bind(this);};document.onmouseup=this._coverMouseup.bind(this);this.mdvMap.events.deregisterEvent(MDVEvent_MAP_INITIALISED,this,this._execute);if(!this.useButton){this.init=true;}};MDVRectZoom.prototype._createGadgetElements=function(){var oCover=document.createElement('div');oCover.id='rz_MapCover';oCover.innerHTML='<div id="rz-outline"></div><div id="rz-mct"></div><div id="rz-mcl"></div><div id="rz-mcr"></div><div id="rz-mcb"></div>';oCover.onmousemove=this._coverDrag.bind(this);mdvLib.style([oCover],{position:'absolute',display:'none',overflow:'hidden',cursor:'crosshair',zIndex:101});this.mdvMap.viewport.appendChild(oCover);return true;};MDVRectZoom.prototype._createButton=function(){var oButton=document.createElement('div');oButton.id='rz_Button';mdvLib.style([oButton],{position:'absolute',zIndex:102,left:'10px',top:'10px'});oButton.onclick=this._buttonClick.bind(this);oButton.onmouseover=function(){if(this.buttonA.style.left=='0px'){return true;};this.buttonN.style.left='-2000px';this.buttonO.style.left='0px';}.bind(this);oButton.onmouseout=function(){if(this.buttonA.style.left=='0px'){return true;};this.buttonN.style.left='0px';this.buttonO.style.left='-2000px';}.bind(this);var that=this;this.buttonN=mdvLib.createImg({position:'absolute',left:'0px'},{src:that.normal.src,id:'rzbNormal',title:'click to draw a zoom rectangle',alt:'click to draw a zoom rectangle'});this.buttonO=mdvLib.createImg({position:'absolute',left:'-2000px'},{src:that.over.src,id:'rzbOver',title:'click to draw a zoom rectangle',alt:'click to draw a zoom rectangle'});this.buttonA=mdvLib.createImg({position:'absolute',left:'-2000px'},{src:that.active.src,id:'rzbActive',title:'draw a rectangle',alt:'draw a rectangle'});oButton.style.top=(this.mdvMap.viewportHeight-this.buttonN.height-50)+'px';oButton.appendChild(this.buttonN);oButton.appendChild(this.buttonO);oButton.appendChild(this.buttonA);this.mdvMap.viewport.appendChild(oButton);mdvLib.correctPNG(this.mdvMap,[this.buttonN,this.buttonO,this.buttonA]);this.init=true;this._toggleButton();};MDVRectZoom.prototype._showCover=function(){mdvLib.style([this.mc],{display:'block',top:'0px',left:'0px',backgroundColor:'#000',width:this.mdvMap.viewportWidth+'px',height:this.mdvMap.viewportHeight+'px',opacity:this.mcOpacity,filter:this.mcFilter});if(this.useButton){this._toggleButton('zoom');};return true;};MDVRectZoom.prototype._toggleButton=function(action){if(action=='zoom'){this.buttonN.style.left='-2000px';this.buttonO.style.left='-2000px';this.buttonA.style.left='0px';}else{this.buttonA.style.left='-2000px';this.buttonO.style.left='-2000px';this.buttonN.style.left='0px';}};MDVRectZoom.prototype._buttonClick=function(){(this.mc.style.display=='block')?this._resetDragZoom():this._showCover();return false;};MDVRectZoom.prototype._coverMousedown=function(e){oPos=this._getRelPos(e);this.nStartX=oPos.left;this.nStartY=oPos.top;mdvLib.style([this.mc],{background:'transparent',opacity:1,filter:'alpha(opacity=100)'});mdvLib.style([this.oOutline],{left:this.nStartX+'px',top:this.nStartY+'px',display:'block',width:'1px',height:'1px'});this.bDragging=true;this.mct.style.top=(this.nStartY-this.nMapHeight)+'px';this.mct.style.display='block';this.mcl.style.left=(this.nStartX-this.nMapWidth)+'px';this.mcl.style.top=(this.nStartY)+'px';this.mcl.style.width=this.nMapWidth+'px';this.mcl.style.display='block';this.mcr.style.left=this.nStartX+'px';this.mcr.style.top=this.nStartY+'px';this.mcr.style.display='block';this.mcb.style.left=this.nStartX+'px';this.mcb.style.top=this.nStartY+'px';this.mcb.style.width='0px';this.mcb.style.display='block';return true;};MDVRectZoom.prototype._coverDrag=function(e){if(this.bDragging){var oPos=this._getRelPos(e);var oRec=this._getRectangle(this.nStartX,this.nStartY,oPos,this.nMapRatio);this.oOutline.style.width=oRec.nWidth+"px";this.oOutline.style.height=oRec.nHeight+"px";this.mcb.style.width=(oRec.nWidth+this.nBorderCorrect)+'px';if(oRec.xFactor===1){this.oOutline.style.left=this.nStartX+'px';this.oOutline.style.top=this.nStartY+'px';this.mcb.style.left=this.nStartX+'px';this.mcl.style.width=this.nMapWidth+'px';this.mcb.style.top=(oRec.nEndY+this.nBorderCorrect)+'px';this.mcr.style.left=(oRec.nEndX+this.nBorderCorrect)+'px';}else{this.oOutline.style.left=(oRec.nStartX-(oRec.nWidth+this.nBorderCorrect))+'px';this.mcr.style.left=this.nStartX+'px';this.mcl.style.width=(this.nMapWidth-(oRec.nWidth+this.nBorderCorrect))+'px';this.mcb.style.left=(oRec.nStartX-(oRec.nWidth+this.nBorderCorrect))+'px';this.mcb.style.top=(oRec.nEndY+this.nBorderCorrect)+'px';};return false;}};MDVRectZoom.prototype._coverMouseup=function(e){if(this.bDragging){var oPos=this._getRelPos(e);this.bDragging=false;var oRec=this._getRectangle(this.nStartX,this.nStartY,oPos,this.nMapRatio);this._resetDragZoom();if(oRec.nStartX>oRec.nEndX){var t=oRec.nStartX;oRec.nStartX=oRec.nEndX;oRec.nEndX=t;};var nwpx=new MDVPoint(oRec.nStartX,oRec.nStartY);var nepx=new MDVPoint(oRec.nEndX,oRec.nStartY);var sepx=new MDVPoint(oRec.nEndX,oRec.nEndY);var swpx=new MDVPoint(oRec.nStartX,oRec.nEndY);var nw=this.mdvMap.getCoordinates(nwpx);var ne=this.mdvMap.getCoordinates(nepx);var se=this.mdvMap.getCoordinates(sepx);var sw=this.mdvMap.getCoordinates(swpx);var path=nw.x+','+nw.y+' '+ne.x+','+ne.y+' '+se.x+','+se.y+' '+sw.x+','+sw.y+' '+nw.x+','+nw.y;var nRealDistx=se.x-nw.x;var nRealDisty=se.y-nw.y;var curZoomLevel=this.mdvMap.config.currentZoomLevelIndex;while(this.mdvMap.config.getZoomLevel(curZoomLevel)!==null){var zoomLevel=this.mdvMap.config.getZoomLevel(curZoomLevel);var viewportRealWidth=Math.floor(zoomLevel.get('realWidth')/zoomLevel.get('numberOfTilesX')*this.mdvMap.tileCountWidth);if(viewportRealWidth<nRealDistx){curZoomLevel--;break;};curZoomLevel++;};if(this.mdvMap.config.getZoomLevel(curZoomLevel)===null){curZoomLevel--;};var nCenter=new MDVPoint(nw.x+(nRealDistx/ 2), nw.y+(nRealDisty/ 2));var rectZoom=this.mdvMap.createLayer('rect_zoom');this.mdvMap.addLayer(rectZoom);var oZoomArea=this.mdvMap.createPolyline(path);oZoomArea.add('weight',this.gadgetBorder.split(' ')[0].replace(/px/,''));oZoomArea.add('colour',this.gadgetBorder.split(' ')[2]);oZoomArea.add('opacity','1');rectZoom.addPolyline(oZoomArea);this.mdvMap.renderer.update();this.mdvMap.setCentre(nCenter);this.mdvMap.setZoomLevel(curZoomLevel);this.mdvMap.update();this.mdvMap.renderer.drawPolyline(oZoomArea);window.setTimeout(function(){rectZoom.removePolyline(oZoomArea);},1000);}};MDVRectZoom.prototype._getRelPos=function(e){var oPos=mdvLib.getMousePosition(e);return{top:(oPos.top-this.oMapPos.top),left:(oPos.left-this.oMapPos.left)};};MDVRectZoom.prototype._setDimensions=function(){this.nMapWidth=this.mdvMap.viewportWidth;this.nMapHeight=this.mdvMap.viewportHeight;this.nMapRatio=this.nMapHeight/this.nMapWidth;mdvLib.style([this.mc,this.mct,this.mcr,this.mcb,this.mcl],{width:this.nMapWidth+'px',height:this.nMapHeight+'px'});return true;};MDVRectZoom.prototype._initStyles=function(){mdvLib.style([this.mc,this.mct,this.mcr,this.mcb,this.mcl],{position:'absolute',display:'none',background:'#000',opacity:this.mcOpacity,filter:this.mcFilter});mdvLib.style([this.oOutline],{position:'absolute',display:'none'});this.oOutline.style.border=this.gadgetBorder;return true;};MDVRectZoom.prototype._getRectangle=function(nStartX,nStartY,oPos,nRatio){var dX=oPos.left-nStartX;var dY=oPos.top-nStartY;var xFactor=1;if(dX<0){dX=dX*-1;xFactor=-1;};if(dY<0){dY=dY*-1;};var delta=(dX>dY)?dX:dY;return{nStartX:nStartX,nStartY:nStartY,nEndX:(xFactor===1)?nStartX+delta:nStartX-delta,nEndY:nStartY+parseInt(delta*nRatio,10),nWidth:delta,nHeight:parseInt(delta*nRatio,10),xFactor:xFactor};};MDVRectZoom.prototype._resetDragZoom=function(){mdvLib.style([this.oOutline,this.mc,this.mct,this.mcr,this.mcb,this.mcl],{display:'none'});if(this.useButton){this._toggleButton();};return true;};



