 var isCSS, isW3C, isIE4, isNN4; function initDHTMLAPI() { if (document.images) { isCSS=(document.body && document.body.style) ? true : false; isW3C=(isCSS && document.getElementById) ? true : false; isIE4=(isCSS && document.all) ? true : false; isNN4=(document.layers) ? true : false; isIE6CSS=(document.compatMode && document.compatMode.indexOf("CSS1") >=0) ? true : false; }} function seekLayer(doc, name) { var theObj; for (var i=0; i < doc.layers.length; i++) { if (doc.layers[i].name==name) { theObj=doc.layers[i]; break; } if (doc.layers[i].document.layers.length > 0) { theObj=seekLayer(document.layers[i].document, name); } } return theObj;} function getRawObject(obj) { var theObj; if (typeof obj=="string") { if (isW3C) { theObj=document.getElementById(obj); } else if (isIE4) { theObj=document.all(obj); } else if (isNN4) { theObj=seekLayer(document, obj); } } else { theObj=obj; } return theObj;} function getObject(obj) { var theObj=getRawObject(obj); if (theObj && isCSS) { theObj=theObj.style; } return theObj;} function shiftTo(obj, x, y) { var theObj=getObject(obj); if (theObj) { if (isCSS) { var units=(typeof theObj.left=="string") ? "px" : 0; theObj.left=x + units; theObj.top=y + units; } else if (isNN4) { theObj.moveTo(x,y) } }} function shiftBy(obj, deltaX, deltaY) { var theObj=getObject(obj); if (theObj) { if (isCSS) { var units=(typeof theObj.left=="string") ? "px" : 0; theObj.left=getObjectLeft(obj) + deltaX + units; theObj.top=getObjectTop(obj) + deltaY + units; } else if (isNN4) { theObj.moveBy(deltaX, deltaY); } }} function setZIndex(obj, zOrder) { var theObj=getObject(obj); if (theObj) { theObj.zIndex=zOrder; }} function setBGColor(obj, color) { var theObj=getObject(obj); if (theObj) { if (isNN4) { theObj.bgColor=color; } else if (isCSS) { theObj.backgroundColor=color; } }} function show(obj) { var theObj=getObject(obj); if (theObj) { theObj.visibility="visible"; }} function hide(obj) { var theObj=getObject(obj); if (theObj) { theObj.visibility="hidden"; }} function getObjectLeft(obj) { var elem=getRawObject(obj); var result=0; if (document.defaultView) { var style=document.defaultView; var cssDecl=style.getComputedStyle(elem, ""); result=cssDecl.getPropertyValue("left"); } else if (elem.currentStyle) { result=elem.currentStyle.left; } else if (elem.style) { result=elem.style.left; } else if (isNN4) { result=elem.left; } return parseInt(result);} function getObjectTop(obj) { var elem=getRawObject(obj); var result=0; if (document.defaultView) { var style=document.defaultView; var cssDecl=style.getComputedStyle(elem, ""); result=cssDecl.getPropertyValue("top"); } else if (elem.currentStyle) { result=elem.currentStyle.top; } else if (elem.style) { result=elem.style.top; } else if (isNN4) { result=elem.top; } return parseInt(result);} function getObjectWidth(obj) { var elem=getRawObject(obj); var result=0; if (elem.offsetWidth) { result=elem.offsetWidth; } else if (elem.clip && elem.clip.width) { result=elem.clip.width; } else if (elem.style && elem.style.pixelWidth) { result=elem.style.pixelWidth; } return parseInt(result);} function getObjectHeight(obj) { var elem=getRawObject(obj); var result=0; if (elem.offsetHeight) { result=elem.offsetHeight; } else if (elem.clip && elem.clip.height) { result=elem.clip.height; } else if (elem.style && elem.style.pixelHeight) { result=elem.style.pixelHeight; } return parseInt(result);} function getInsideWindowWidth() { if (window.innerWidth) { return window.innerWidth; } else if (isIE6CSS) { return document.body.parentElement.clientWidth; } else if (document.body && document.body.clientWidth) { return document.body.clientWidth; } return 0;} function getInsideWindowHeight() { if (window.innerHeight) { return window.innerHeight; } else if (isIE6CSS) { return document.body.parentElement.clientHeight; } else if (document.body && document.body.clientHeight) { return document.body.clientHeight; } return 0;}  var aXmlHttp=new Array();var aXmlResponse=new Array();function xmlResult(){ for(var i=0;i<aXmlHttp.length;i++) { if(aXmlHttp[i] && aXmlHttp[i][0] && aXmlHttp[i][0].readyState==4&&aXmlHttp[i][0].responseText) { var f=aXmlHttp[i][2]; var o=aXmlHttp[i][1]; var s=aXmlHttp[i][0].responseText; aXmlHttp[i][0]=null; aXmlHttp[i][1]=null; aXmlHttp[i]=null; f.apply(o,new Array(s)); } }} function call(u,o,f){ var method="GET"; var dat; if (arguments.length==4){ method="POST"; tmp=u.split(/\?/); u=tmp[0]; dat=tmp[1]; } var idx=aXmlHttp.length; for(var i=0; i<idx;i++) if (aXmlHttp[i]==null) { idx=i; break; } aXmlHttp[idx]=new Array(2); aXmlHttp[idx][0]=getXMLHTTP(); aXmlHttp[idx][1]=o; aXmlHttp[idx][2]=f; if(aXmlHttp[idx]) { aXmlHttp[idx][0].open(method,u,true); if(method=="POST"){ aXmlHttp[idx][0].setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); aXmlHttp[idx][0].send(dat); } aXmlHttp[idx][0].onreadystatechange=xmlResult; if(method=="GET"){ aXmlHttp[idx][0].send(null);} }} function getXMLHTTP(){ var A=null; if(!A && typeof XMLHttpRequest !="undefined") { A=new XMLHttpRequest(); } if (!A) { try { A=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { A=new ActiveXObject("Microsoft.XMLHTTP"); } catch(oc) { A=null } } } return A;} var gnLastEventId=0;var KAMAP_ERROR=gnLastEventId ++;var KAMAP_WARNING=gnLastEventId ++;var KAMAP_NOTICE=gnLastEventId++;var KAMAP_INITIALIZED=gnLastEventId ++;var KAMAP_MAP_INITIALIZED=gnLastEventId ++;var KAMAP_EXTENTS_CHANGED=gnLastEventId ++;var KAMAP_SCALE_CHANGED=gnLastEventId ++;var KAMAP_LAYERS_CHANGED=gnLastEventId ++;var KAMAP_LAYER_STATUS_CHANGED=gnLastEventId ++;var KAMAP_CONTEXT_MENU=gnLastEventId ++;var KAMAP_METAEXTENTS_CHANGED=gnLastEventId++;var KAMAP_MAP_CLICKED=gnLastEventId++; function kaMap( szID ) { this.isCSS=false; this.isW3C=false; this.isIE4=false; this.isNN4=false; this.isIE6CSS=false; if (document.images) { this.isCSS=(document.body && document.body.style) ? true : false; this.isW3C=(this.isCSS && document.getElementById) ? true : false; this.isIE4=(this.isCSS && document.all) ? true : false; this.isNN4=(document.layers) ? true : false; this.isIE6CSS=(document.compatMode && document.compatMode.indexOf("CSS1") >=0) ? true : false; } this.domObj=this.getRawObject( szID ); this.domObj.style.overflow='hidden'; this.hideLayersOnMove=false; this.loadUnchecked=false; this.initializationState=0; this.bMouseDown=false; this.lastx=0; this.lasty=0; this.theInsideLayer=null; this.viewportWidth=this.getObjectWidth(this.domObj); this.viewportHeight=this.getObjectHeight(this.domObj); this.xOffset=0; this.yOffset=0; this.xOrigin=0; this.yOrigin=0; this.currentMap=''; this.nWide=0; this.nHigh=0; this.nCurrentTop=0; this.nCurrentLeft=0; this.aPixel=new Image(1,1); this.aPixel.src='images/a_pixel.gif'; this.imgErrors=new Array(); this.aMaps=new Array(); this.tileWidth=null; this.tileHeight=null; this.nBuffer=1; this.baseURL=''; this.cellSize=null; this.gImageID=0; this.eventManager=new _eventManager(); this.as=slideid=null; this.accelerationFactor=1; this.pixelsPerStep=30; this.timePerStep=25; this.server='/map/index/'; this.init="init"; this.tileURL=null; this.aObjects=[]; this.aCanvases=[]; this.layersHidden=false; this.aTools=[]; this.aInfoTools=[]; for (var i=0; i<gnLastEventId; i++) { this.registerEventID( i ); } this.createLayers();}; kaMap.prototype.seekLayer=function(doc, name) { var theObj; for (var i=0; i < doc.layers.length; i++) { if (doc.layers[i].name==name) { theObj=doc.layers[i]; break; } if (doc.layers[i].document.layers.length > 0) { theObj=this.seekLayer(document.layers[i].document, name); } } return theObj;}; kaMap.prototype.getRawObject=function(obj) { var theObj; if (typeof obj=="string") { if (this.isW3C) { theObj=document.getElementById(obj); } else if (this.isIE4) { theObj=document.all(obj); } else if (this.isNN4) { theObj=seekLayer(document, obj); } } else { theObj=obj; } return theObj;}; kaMap.prototype.getObject=function(obj) { var theObj=this.getRawObject(obj); if (theObj && this.isCSS) { theObj=theObj.style; } return theObj;}; kaMap.prototype.getObjectWidth=function(obj) { var elem=this.getRawObject(obj); var result=0; if (elem.offsetWidth) { result=elem.offsetWidth; } else if (elem.clip && elem.clip.width) { result=elem.clip.width; } else if (elem.style && elem.style.pixelWidth) { result=elem.style.pixelWidth; } return parseInt(result);}; kaMap.prototype.getObjectHeight=function(obj) { var elem=this.getRawObject(obj); var result=0; if (elem.offsetHeight) { result=elem.offsetHeight; } else if (elem.clip && elem.clip.height) { result=elem.clip.height; } else if (elem.style && elem.style.pixelHeight) { result=elem.style.pixelHeight; } return parseInt(result);}; kaMap.prototype.zoomTo=function( cgX, cgY ) { var oMap=this.getCurrentMap(); var inchesPerUnit=new Array(1, 12, 63360.0, 39.3701, 39370.1, 4374754); var newScale; var bScaleChanged=false; if (arguments.length==3) { newScale=arguments[2]; bScaleChanged=(newScale !=this.getCurrentScale()) } else { newScale=this.getCurrentScale(); } var bZoomTo=true; if (!bScaleChanged) { var extents=this.getGeoExtents(); if (cgX >=extents[0] && cgX <=extents[2] && cgY >=extents[1] && cgY <=extents[3]) { var cx=(extents[0]+extents[2])/2; var cy=(extents[1]+extents[3])/2; var dx=(cx - cgX)/this.cellSize; var dy=(cgY - cy)/this.cellSize; this.slideBy(dx,dy); bZoomTo=false; } } if (bZoomTo) { this.cellSize=newScale/(oMap.resolution * inchesPerUnit[oMap.units]); var nFactor=oMap.zoomToScale( newScale ); this.setMapLayers(); var cpX=cgX / this.cellSize; var cpY=cgY / this.cellSize; var vpLeft=Math.round(cpX - this.viewportWidth/2); var vpTop=Math.round(cpY + this.viewportHeight/2); var cTileX=Math.floor(cpX/this.tileWidth)*this.tileWidth; var cTileY=Math.floor(cpY/this.tileHeight)*this.tileHeight; var nTilesLeft=Math.ceil(this.viewportWidth/(2*this.tileWidth))*this.tileWidth; var nTilesUp=Math.ceil(this.viewportHeight/(2*this.tileHeight))*this.tileHeight; this.nCurrentLeft=cTileX - nTilesLeft; this.nCurrentTop=-1*(cTileY + nTilesUp); this.xOrigin=this.nCurrentLeft; this.yOrigin=this.nCurrentTop; this.theInsideLayer.style.left=-1*(vpLeft - this.xOrigin) + "px"; this.theInsideLayer.style.top=(vpTop + this.yOrigin) + "px"; var layers=oMap.getLayers(); for( var k=0; k<layers.length; k++) { var d=layers[k].domObj; for(var j=0; j<this.nHigh; j++) { for( var i=0; i<this.nWide; i++) { var img=d.childNodes[(j*this.nWide)+i]; img.src=this.aPixel.src; img.style.top=(this.nCurrentTop + j*this.tileHeight - this.yOrigin) + "px"; img.style.left=(this.nCurrentLeft + i*this.tileWidth - this.xOrigin) + "px"; layers[k].setTile(img); } } } this.checkWrap( ); this.updateObjects(); } if (bScaleChanged) { this.triggerEvent( KAMAP_SCALE_CHANGED, this.getCurrentScale() ); } this.triggerEvent( KAMAP_EXTENTS_CHANGED, this.getGeoExtents() );}; kaMap.prototype.zoomToExtents=function(minx, miny, maxx, maxy) { var inchesPerUnit=new Array(1, 12, 63360.0, 39.3701, 39370.1, 4374754); var oMap=this.getCurrentMap(); var cgX=(maxx+minx)/2; var cgY=(maxy+miny)/2; var tmpCellSizeX=(maxx - minx)/this.viewportWidth; var tmpCellSizeY=(maxy - miny)/this.viewportHeight; var tmpCellSize=Math.max( tmpCellSizeX, tmpCellSizeY ); var tmpScale=tmpCellSize * oMap.resolution * inchesPerUnit[oMap.units]; var newScale=oMap.aScales[0]; for (var i=1; i<oMap.aScales.length; i++) { if (tmpScale >=oMap.aScales[i]) { break; } newScale=oMap.aScales[i]; } this.cellSize=newScale/(oMap.resolution * inchesPerUnit[oMap.units]); var nFactor=oMap.zoomToScale( newScale ); this.setMapLayers(); var cpX=cgX / this.cellSize; var cpY=cgY / this.cellSize; var vpLeft=Math.round(cpX - this.viewportWidth/2); var vpTop=Math.round(cpY + this.viewportHeight/2); var cTileX=Math.floor(cpX/this.tileWidth)*this.tileWidth; var cTileY=Math.floor(cpY/this.tileHeight)*this.tileHeight; var nTilesLeft=Math.ceil(this.viewportWidth/(2*this.tileWidth))*this.tileWidth; var nTilesUp=Math.ceil(this.viewportHeight/(2*this.tileHeight))*this.tileHeight; this.nCurrentLeft=cTileX - nTilesLeft; this.nCurrentTop=-1*(cTileY + nTilesUp); this.xOrigin=this.nCurrentLeft; this.yOrigin=this.nCurrentTop; this.theInsideLayer.style.left=-1*(vpLeft - this.xOrigin) + "px"; this.theInsideLayer.style.top=(vpTop + this.yOrigin) + "px"; var layers=oMap.getLayers(); for( var k=0; k<layers.length; k++) { var d=layers[k].domObj; for(var j=0; j<this.nHigh; j++) { for( var i=0; i<this.nWide; i++) { var img=d.childNodes[(j*this.nWide)+i]; img.src=this.aPixel.src; img.style.top=(this.nCurrentTop + j*this.tileHeight - this.yOrigin) + "px"; img.style.left=(this.nCurrentLeft + i*this.tileWidth - this.xOrigin) + "px"; layers[k].setTile(img); } } } this.checkWrap( ); this.updateObjects(); this.triggerEvent( KAMAP_SCALE_CHANGED, this.getCurrentScale() ); this.triggerEvent( KAMAP_EXTENTS_CHANGED, this.getGeoExtents() );}; kaMap.prototype.createDrawingCanvas=function( idx, id ) { var d=document.createElement( 'div' ); if(id){ d.id=id; } d.style.position='absolute'; d.style.left='0px'; d.style.top='0px'; d.style.width='3000px'; d.style.height='3000px'; d.style.zIndex=idx; this.theInsideLayer.appendChild( d ); this.aCanvases.push( d ); d.kaMap=this; return d;}; kaMap.prototype.removeDrawingCanvas=function( canvas ) { for (var i=0; i<this.aCanvases.length;i++) { if (this.aCanvases[i]==canvas) { this.aCanvases.splice( i, 1 ); } } this.theInsideLayer.removeChild(canvas); canvas.kaMap=null; return true;}; kaMap.prototype.addObjectGeo=function( canvas, lon, lat, obj ) { obj.lon=lon; obj.lat=lat; var aPix=this.geoToPix( lon, lat ); return this.addObjectPix( canvas, aPix[0], aPix[1], obj );}; kaMap.prototype.addObjectPix=function( canvas, x, y, obj ) { var xOffset=(obj.xOffset) ? obj.xOffset : 0; var yOffset=(obj.yOffset) ? obj.yOffset : 0; var top=(y - this.yOrigin + yOffset); var left=(x - this.xOrigin + xOffset); obj.style.position='absolute'; obj.style.top=top + "px"; obj.style.left=left + "px"; obj.canvas=canvas; canvas.appendChild( obj ); this.aObjects.push( obj ); return true;}; kaMap.prototype.shiftObject=function( x, y, obj ) { var top=safeParseInt(obj.style.top); var left=safeParseInt(obj.style.left); obj.style.top=(top + y) + "px"; obj.style.left=(left + x) + "px"; return true;}; kaMap.prototype.removeObject=function( obj ) { if (obj==null) { for (var i=0; i<this.aObjects.length; i++) { obj=this.aObjects[i]; if (obj.canvas) { obj.canvas.removeChild(obj); } } this.aObjects=[]; return true; } else { for (var i=0; i<this.aObjects.length; i++) { if (this.aObjects[i]==obj) { obj=this.aObjects[i]; if (obj.canvas) { obj.canvas.removeChild( obj ); obj.canvas=null; } this.aObjects.splice(i,1); return true; } } return false; }}; kaMap.prototype.removeAllObjects=function(canvas) { for (var i=0; i<this.aObjects.length; i++) { obj=this.aObjects[i]; if (obj.canvas && obj.canvas==canvas) { obj.canvas.removeChild( obj ); obj.canvas=null; this.aObjects.splice(i--,1); } } return true;}; kaMap.prototype.centerObject=function(obj) { var vpX=-safeParseInt(this.theInsideLayer.style.left) + this.viewportWidth/2; var vpY=-safeParseInt(this.theInsideLayer.style.top) + this.viewportHeight/2; var xOffset=(obj.xOffset)?obj.xOffset:0; var yOffset=(obj.yOffset)?obj.yOffset:0; var dx=safeParseInt(obj.style.left) - xOffset- vpX; var dy=safeParseInt(obj.style.top) - yOffset - vpY; this.slideBy(-dx, -dy); return true;}; kaMap.prototype.geoToPix=function( gX, gY ) { var pX=gX / this.cellSize; var pY=-1 * gY / this.cellSize; return [Math.floor(pX), Math.floor(pY)];}; kaMap.prototype.pixToGeo=function( pX, pY ) { var bAdjust=(arguments.length==3 && arguments[2]) ? true : false; if (bAdjust) { pX=pX + this.xOrigin; pY=pY + this.yOrigin; } var gX=-1 * pX * this.cellSize; var gY=pY * this.cellSize; return [gX, gY];}; kaMap.prototype.adjustPixPosition=function( x, y ) { var obj=this.domObj; var offsetLeft=0; var offsetTop=0; while (obj) { offsetLeft +=parseInt(obj.offsetLeft); offsetTop +=parseInt(obj.offsetTop); obj=obj.offsetParent; } var pX=parseInt(this.theInsideLayer.style.left) + offsetLeft - this.xOrigin - x; var pY=parseInt(this.theInsideLayer.style.top) + offsetTop - this.yOrigin - y; return [pX,pY];}; kaMap.prototype.initialize=function() { if (this.initializationState==2) { this.triggerEvent( KAMAP_ERROR, 'ERROR: ka-Map! is already initialized!' ); return false; } else if (this.intializationState==1) { this.triggerEvent( KAMAP_WARNING, 'WARNING: ka-Map! is currently initializing ... wait for the KAMAP_INITIALIZED event to be triggered.' ); return false; } this.initializationState=1; var szURL=this.server+this.init; var sep=(this.init.indexOf("?")==-1) ? "?" : "&"; if (arguments.length > 0 && arguments[0] !='') { szURL=szURL + sep + "map="+ arguments[0]; sep="&"; } if (arguments.length > 1 && arguments[1] !='') { szURL=szURL + sep + "extents="+ arguments[1]; sep="&"; } if (arguments.length > 2 && arguments[2] !='') { szURL=szURL + sep + "centerPoint="+ arguments[2]; sep="&"; } call(szURL, this, this.initializeCallback); return true;}; kaMap.prototype.initializeCallback=function( szInit ) { if (szInit.substr(0, 1) !="/") { this.triggerEvent( KAMAP_ERROR, 'ERROR: ka-Map! initialization '+ 'failed on the server. Message returned was:\n' + szInit); return false; } eval(szInit); this.triggerEvent( KAMAP_INITIALIZED ); this.initializationState=2;}; kaMap.prototype.setBackgroundColor=function( color ) { this.domObj.style.backgroundColor=color; return true;}; kaMap.prototype.createLayers=function() { this.theInsideLayer=document.createElement('div'); this.theInsideLayer.id='theInsideLayer'; this.theInsideLayer.style.position='absolute'; this.theInsideLayer.style.left='0px'; this.theInsideLayer.style.top='0px'; this.theInsideLayer.style.zIndex='1'; this.theInsideLayer.kaMap=this; if (this.currentTool) { this.theInsideLayer.style.cursor=this.currentTool.cursor; } this.domObj.appendChild(this.theInsideLayer); this.domObj.kaMap=this; this.theInsideLayer.onmousedown=kaMap_onmousedown; this.theInsideLayer.onmouseup=kaMap_onmouseup; this.theInsideLayer.onmousemove=kaMap_onmousemove; this.theInsideLayer.onmouseover=kaMap_onmouseover; this.domObj.onmouseout=kaMap_onmouseout; this.theInsideLayer.onkeypress=kaMap_onkeypress; this.theInsideLayer.ondblclick=kaMap_ondblclick; this.theInsideLayer.oncontextmenu=kaMap_oncontextmenu; this.theInsideLayer.onmousewheel=kaMap_onmousewheel; if (window.addEventListener && navigator.product && navigator.product=="Gecko") { this.domObj.addEventListener( "DOMMouseScroll", kaMap_onmousewheel, false ); } this.theInsideLayer.ondragstart=new Function([], 'var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;'); this.theInsideLayer.onfocus=kaMap_onfocus;}; kaMap.prototype.initializeLayers=function(nFactor) { var deltaMouseX=this.nCurrentLeft + safeParseInt(this.theInsideLayer.style.left) - this.xOrigin; var deltaMouseY=this.nCurrentTop + safeParseInt(this.theInsideLayer.style.top) - this.yOrigin; var vpTop=this.nCurrentTop - deltaMouseY; var vpLeft=this.nCurrentLeft - deltaMouseX; var vpCenterX=vpLeft + this.viewportWidth/2; var vpCenterY=vpTop + this.viewportHeight/2; var currentTileX=Math.floor(vpCenterX/this.tileWidth)*this.tileWidth; var currentTileY=Math.floor(vpCenterY/this.tileHeight)*this.tileHeight; var tileDeltaX=currentTileX - this.nCurrentLeft; var tileDeltaY=currentTileY - this.nCurrentTop; var newVpCenterX=vpCenterX * nFactor; var newVpCenterY=vpCenterY * nFactor; var newTileX=Math.floor(newVpCenterX/this.tileWidth) * this.tileWidth; var newTileY=Math.floor(newVpCenterY/this.tileHeight) * this.tileHeight; var newCurrentLeft=newTileX - tileDeltaX; var newCurrentTop=newTileY - tileDeltaY; this.nCurrentLeft=newCurrentLeft; this.nCurrentTop=newCurrentTop; var newTilLeft=-newVpCenterX + this.viewportWidth/2; var newTilTop=-newVpCenterY + this.viewportHeight/2; var xOldOrigin=this.xOrigin; var yOldOrigin=this.yOrigin; this.xOrigin=this.nCurrentLeft; this.yOrigin=this.nCurrentTop; this.theInsideLayer.style.left=(newTilLeft + this.xOrigin) + "px"; this.theInsideLayer.style.top=(newTilTop + this.yOrigin) + "px"; var layers=this.aMaps[this.currentMap].getLayers(); for( var k=0; k<layers.length; k++) { var d=layers[k].domObj; for(var j=0; j<this.nHigh; j++) { for( var i=0; i<this.nWide; i++) { var img=d.childNodes[(j*this.nWide)+i]; img.src=this.aPixel.src; img.style.top=(this.nCurrentTop + j*this.tileHeight - this.yOrigin) + "px"; img.style.left=(this.nCurrentLeft + i*this.tileWidth - this.xOrigin) + "px"; layers[k].setTile(img); } } } this.checkWrap(); this.updateObjects();}; kaMap.prototype.paintLayer=function(l) { var d=l.domObj; for(var j=0; j<this.nHigh; j++) { for( var i=0; i<this.nWide; i++) { var img=d.childNodes[(j*this.nWide)+i]; img.style.top=(this.nCurrentTop + j*this.tileHeight - this.yOrigin) + "px"; img.style.left=(this.nCurrentLeft + i*this.tileWidth - this.xOrigin) + "px"; l.setTile(img); } } this.checkWrap();}; kaMap.prototype.updateObjects=function() { for (var i=0; i<this.aObjects.length;i++) { var obj=this.aObjects[i]; var xOffset=(obj.xOffset) ? obj.xOffset : 0; var yOffset=(obj.yOffset) ? obj.yOffset : 0; var aPix=this.geoToPix( obj.lon, obj.lat ); var top=(aPix[1] - this.yOrigin + yOffset); var left=(aPix[0] - this.xOrigin + xOffset); obj.style.top=top + "px"; obj.style.left=left + "px"; }}; kaMap.prototype.resize=function( ) { if (this.initializationState !=2) { return false; } var newViewportWidth=this.getObjectWidth(this.domObj); var newViewportHeight=this.getObjectHeight(this.domObj); if (this.viewportWidth==null) { this.theInsideLayer.style.top=(-1*this.nCurrentTop + this.yOrigin) + "px"; this.theInsideLayer.style.left=(-1*this.nCurrentLeft + this.xOrigin) + "px"; this.viewportWidth=newViewportWidth; this.viewportHeight=newViewportHeight; } var newWide=Math.ceil((newViewportWidth / this.tileWidth) + 2*this.nBuffer); var newHigh=Math.ceil((newViewportHeight / this.tileHeight) + 2*this.nBuffer); this.viewportWidth=newViewportWidth; this.viewportHeight=newViewportHeight; if (this.nHigh==0 && this.nWide==0) { this.nWide=newWide; } while (this.nHigh < newHigh) { this.appendRow(); } while (this.nHigh > newHigh && newHigh > 3) { this.removeRow(); } while (this.nWide < newWide) { this.appendColumn(); } while (this.nWide > newWide && newWide > 3) { this.removeColumn(); } var map=this.getCurrentMap(); var layers=map.getLayers(); for(i=0;i<layers.length;i++) { layers[i].setTileLayer(); } this.triggerEvent( KAMAP_EXTENTS_CHANGED, this.getGeoExtents() ); this.triggerEvent( KAMAP_EXTENTS_CHANGED, this.getGeoExtents() );}; kaMap.prototype.createImage=function( top, left, obj ) { var img=document.createElement('img'); img.src=this.aPixel.src; img.width=this.tileWidth; img.height=this.tileHeight; img.setAttribute('style', 'position:absolute; top:'+top+'px; left:'+left+'px;' ); img.style.position='absolute'; img.style.top=(top - this.yOrigin)+'px'; img.style.left=(left - this.xOrigin)+'px'; img.style.width=this.tileWidth + "px"; img.style.height=this.tileHeight + "px"; img.style.visibility='hidden'; img.galleryimg="no"; img.onerror=kaMap_imgOnError; img.onload=kaMap_imgOnLoad; img.errorCount=0; img.id="i" + this.gImageID; img.layer=obj; img.kaMap=this; this.gImageID=this.gImageID + 1; img.ie_hack=false; if (this.isIE4) { if (obj.imageformat && (obj.imageformat.toLowerCase()=="alpha")) { img.ie_hack=true; } } return img;}; kaMap.prototype.resetTile=function( id, bForce ) { var img=this.DHTMLapi.getRawObject(id); if (img.layer) { img.layer.setTile(this, bForce); }}; kaMap.prototype.reloadImage=function(id) {}; kaMap.prototype.resetImage=function(id) {}; kaMap_imgOnError=function(e) { if (this.layer) { this.layer.setTile(this, true); }}; kaMap_imgOnLoad=function(e) { if ((this.ie_hack) && (this.src !=this.kaMap.aPixel.src)) { var src=this.src; this.src=this.kaMap.aPixel.src; this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"')"; } this.style.visibility='visible';}; kaMap.prototype.appendRow=function(layer) { if (this.nWide==0) { return; } var layers=null; if(arguments.length==1) { layers=Array(layer); } else { layers=this.aMaps[this.currentMap].getLayers(); } for( var i=0; i<layers.length; i++) { var obj=layers[i].domObj; for (var j=0; j<this.nWide; j++) { var top=this.nCurrentTop + (this.nHigh * this.tileHeight); var left=this.nCurrentLeft + (j * this.tileWidth); var img=this.createImage( top, left, layers[i] ); if (this.isIE4) { img.style.filter="Alpha(opacity="+layers[i].opacity+")"; } obj.appendChild( img ); } } this.nHigh=this.nHigh + 1;}; kaMap.prototype.appendColumn=function(layer) { if (this.nHigh==0) { return; } var layers=null; if(arguments.length==1) { layers=Array(layer); } else { layers=this.aMaps[this.currentMap].getLayers(); } for( var i=0; i<layers.length; i++) { var obj=layers[i].domObj; for(var j=this.nHigh-1; j>=0; j--) { var top=this.nCurrentTop + (j * this.tileHeight); var left=this.nCurrentLeft + (this.nWide * this.tileWidth); var img=this.createImage( top, left, layers[i] ); if (this.isIE4) { img.style.filter="Alpha(opacity="+layers[i].opacity+")"; } if (j < this.nHigh-1) { obj.insertBefore(img, obj.childNodes[((j+1)*this.nWide)]); } else { obj.appendChild(img); } } } this.nWide=this.nWide + 1;}; kaMap.prototype.removeColumn=function(layer) { if (this.nWide < 3) { return; } var layers=null; if(arguments.length==1) { layers=Array(layer); } else { layers=this.aMaps[this.currentMap].getLayers(); } for( var i=0; i<layers.length; i++) { var d=layers[i].domObj; for(var j=this.nHigh - 1; j >=0; j--) { var img=d.childNodes[((j+1)*this.nWide)-1]; d.removeChild( img ); img.onload=null; img.onerror=null; } } this.nWide=this.nWide - 1;}; kaMap.prototype.removeRow=function(layer) { if (this.nHigh < 3) { return; } var layers=null; if(arguments.length==1) { layers=Array(layer); } else { layers=this.aMaps[this.currentMap].getLayers(); } for( var i=0; i<layers.length; i++) { var d=layers[i].domObj; for(var j=this.nWide - 1; j >=0; j--) { var img=d.childNodes[((this.nHigh-1)*this.nWide)+j]; d.removeChild( img ); img.onload=null; img.onerror=null; } } this.nHigh=this.nHigh - 1;}; kaMap.prototype.hideLayers=function() { if (!this.hideLayersOnMove) { return; } if (this.layersHidden) { return; } var layers=this.aMaps[this.currentMap].getLayers(); for( var i=0; i<layers.length; i++) { layers[i]._visible=layers[i].visible; if (layers[i].name !='__base__') { layers[i].setVisibility( false ); } } for( var i=0; i < this.aCanvases.length; i++) { this.aCanvases[i].style.visibility='hidden'; this.aCanvases[i].style.display='none'; } this.layersHidden=true;}; kaMap.prototype.showLayers=function() { if (!this.hideLayersOnMove) { return; } if (!this.layersHidden) { return; } var layers=this.aMaps[this.currentMap].getLayers(); for( var i=0; i<layers.length; i++) { layers[i].setVisibility( layers[i]._visible ); } for( var i=0; i < this.aCanvases.length; i++) { this.aCanvases[i].style.visibility='visible'; this.aCanvases[i].style.display='block'; } this.layersHidden=false;}; kaMap.prototype.moveBy=function( x, y ) { var til=this.theInsideLayer; til.style.top=(safeParseInt(til.style.top)+y) + 'px'; til.style.left=(safeParseInt(til.style.left)+x )+ 'px'; this.checkWrap();}; kaMap.prototype.slideBy=function(x,y) { if (this.slideid!=null) { goQueueManager.dequeue( this.slideid ); } this.as=[]; var absX=Math.abs(x); var absY=Math.abs(y); var signX=x/absX; var signY=y/absY; var distance=absX>absY?absX:absY; var steps=Math.floor(distance/this.pixelsPerStep); var dx=dy=0; if (steps > 0) { dx=(x)/(steps*this.pixelsPerStep); dy=(y)/(steps*this.pixelsPerStep); } var remainderX=x - dx*steps*this.pixelsPerStep; var remainderY=y - dy*steps*this.pixelsPerStep; var px=py=0; var curspeed=this.accelerationFactor; var i=0; while(i<steps) { if (i>0) { px+=this.as[i-1][0]; py+=this.as[i-1][1]; } var cx=px+Math.round(dx*this.pixelsPerStep); var cy=py+Math.round(dy*this.pixelsPerStep); this.as[i]=new Array(cx-px,cy-py); i++; } if (remainderX !=0 || remainderY !=0) { this.as[i]=[remainderX, remainderY]; } this.hideLayers(); this.slideid=goQueueManager.enqueue(this.timePerStep,this,this.slide,[0]);}; kaMap.prototype.slide=function(pos) { if (pos>=this.as.length) { this.as=slideid=null; this.showLayers(); this.triggerEvent( KAMAP_EXTENTS_CHANGED, this.getGeoExtents() ); return; } this.moveBy( this.as[pos][0], this.as[pos][1] ); pos ++; this.slideid=goQueueManager.enqueue(this.timePerStep,this,this.slide,[ pos]);}; kaMap.prototype.indexInArray=function(theArray, theValue){ var arLength=theArray.length; for(var i=0; i < arLength; i++) { if (theArray[i]==theValue){ return i; } } return false;}; kaMap_onkeypress=function( e ) { if (this.kaMap.currentTool) { this.kaMap.currentTool.onkeypress( e ); } if (this.kaMap.aInfoTools.length > 0) { for (var i=0; i<this.kaMap.aInfoTools.length; i++) { this.kaMap.aInfoTools[i].onkeypress(e); } }}; kaMap_onmousemove=function( e ) { e=(e)?e:((event)?event:null); if (e.button==2) { this.kaMap.triggerEvent( KAMAP_CONTEXT_MENU ); } if (this.kaMap.currentTool) { this.kaMap.currentTool.onmousemove( e ); } if (this.kaMap.aInfoTools.length > 0) { for (var i=0; i<this.kaMap.aInfoTools.length; i++) { this.kaMap.aInfoTools[i].onmousemove(e); } }}; kaMap_onmousedown=function( e ) { if (this.kaMap.currentTool) { this.kaMap.currentTool.onmousedown( e ); } if (this.kaMap.aInfoTools.length > 0) { for (var i=0; i<this.kaMap.aInfoTools.length; i++) { this.kaMap.aInfoTools[i].onmousedown(e); } }}; kaMap_onmouseup=function( e ) { if (this.kaMap.currentTool) { this.kaMap.currentTool.onmouseup( e ); } if (this.kaMap.aInfoTools.length > 0) { for (var i=0; i<this.kaMap.aInfoTools.length; i++) { this.kaMap.aInfoTools[i].onmouseup(e); } }}; kaMap_onmouseover=function( e ) { this.kaMap.theInsideLayer.focus=true; if (this.kaMap.currentTool) { this.kaMap.currentTool.onmouseover( e ); } if (this.kaMap.aInfoTools.length > 0) { for (var i=0; i<this.kaMap.aInfoTools.length; i++) { this.kaMap.aInfoTools[i].onmouseover(e); } }}; kaMap_onmouseout=function( e ) { this.kaMap.theInsideLayer.focus=false; if (this.kaMap.currentTool) { this.kaMap.currentTool.onmouseout( e ); } if (this.kaMap.aInfoTools.length > 0) { for (var i=0; i<this.kaMap.aInfoTools.length; i++) { this.kaMap.aInfoTools[i].onmouseout(e); } }}; kaMap_oncontextmenu=function( e ) { e=e?e:event; if (e.preventDefault) { e.preventDefault(); } return false;}; kaMap_ondblclick=function( e ) { if (this.kaMap.currentTool) { this.kaMap.currentTool.ondblclick( e ); } if (this.kaMap.aInfoTools.length > 0) { for (var i=0; i<this.kaMap.aInfoTools.length; i++) { this.kaMap.aInfoTools[i].ondblclick(e); } }}; kaMap_onmousewheel=function( e ) { if (this.kaMap.currentTool) { this.kaMap.currentTool.onmousewheel( e ); }}; kaMap_onfocus=function( e ) { alert("focus"); if (this.kaMap.currentTool) { this.kaMap.currentTool.onfocus( e ); } }; kaMap.prototype.cancelEvent=function(e) { e=(e)?e:((event)?event:null); e.returnValue=false; if (e.preventDefault) { e.preventDefault(); } return false;}; kaMap.prototype.registerTool=function( toolObj ) { this.aTools.push( toolObj );}; kaMap.prototype.activateTool=function( toolObj ) { if (toolObj.isInfoTool()) { this.aInfoTools.push(toolObj); } else { if (this.currentTool) { this.currentTool.deactivate(); } this.currentTool=toolObj; if (this.theInsideLayer) { this.setCursor(this.currentTool.cursor); } }}; kaMap.prototype.deactivateTool=function( toolObj ) { if (toolObj.isInfoTool()) { for (var i=0; i<this.aInfoTools.length; i++) { if (this.aInfoTools[i]==toolObj) { this.aInfoTools.splice(i,1); break; } } } else { if (this.currentTool==toolObj) { this.currentTool=null; } if (this.theInsideLayer) { this.theInsideLayer.style.cursor='auto'; } }}; kaMap.prototype.setCursor=function(cursor) { if (cursor && cursor.length && typeof cursor=='object') { for (var i=0; i < cursor.length; i++) { this.theInsideLayer.style.cursor=cursor[i]; if (this.theInsideLayer.style.cursor==cursor[i]) { break; } } } else if (typeof cursor=='string') { this.theInsideLayer.style.cursor=cursor; } else { this.theInsideLayer.style.cursor='auto'; }}; kaMap.prototype.checkWrap=function() { var bWrapped=false; this.checkMaxExtents(); this.xOffset=safeParseInt(this.theInsideLayer.style.left) + this.nCurrentLeft - this.xOrigin; this.yOffset=safeParseInt(this.theInsideLayer.style.top) + this.nCurrentTop - this.yOrigin; while (this.xOffset > 0) { this.wrapR2L(); bWrapped=true; } while (this.xOffset < -(this.nBuffer*this.tileWidth)) { this.wrapL2R(); bWrapped=true; } while (this.yOffset > -(this.nBuffer*this.tileHeight)) { this.wrapB2T(); bWrapped=true; } while (this.yOffset < -(2*this.nBuffer*this.tileHeight)) { this.wrapT2B(); bWrapped=true; } var layer=this.aMaps[this.currentMap].getLayers()[0]; if (layer) { var img=layer.domObj.childNodes[0].style; this.nCurrentTop=safeParseInt(img.top) + this.yOrigin; this.nCurrentLeft=safeParseInt(img.left) + this.xOrigin; } if (bWrapped) { this.triggerEvent( KAMAP_METAEXTENTS_CHANGED, this.getMetaExtents() ); }}; kaMap.prototype.checkMaxExtents=function() { var maxExtents=this.getCurrentMap().maxExtents; if (maxExtents.length==4) { if ((maxExtents[0] >=maxExtents[2]) || (maxExtents[1] >=maxExtents[3])) { return false; } var geoExtents=this.getGeoExtents(); var hPixelAdjustment=0; var vPixelAdjustment=0; if (geoExtents[0] < maxExtents[0]) { hPixelAdjustment=Math.round((maxExtents[0] - geoExtents[0]) / this.cellSize); } if (geoExtents[2] > maxExtents[2]) { if(hPixelAdjustment !=0) { hPixelAdjustment +=Math.round((maxExtents[2] - geoExtents[2]) / this.cellSize); hPixelAdjustment /=2; } else { hPixelAdjustment +=Math.round((maxExtents[2] - geoExtents[2]) / this.cellSize); } } if(hPixelAdjustment !=0) { this.theInsideLayer.style.left=(safeParseInt(this.theInsideLayer.style.left) - hPixelAdjustment) + 'px'; } if(geoExtents[1] < maxExtents[1]) { vPixelAdjustment=Math.round((maxExtents[1] - geoExtents[1]) / this.cellSize); } if(geoExtents[3] > maxExtents[3]) { if(vPixelAdjustment !=0) { vPixelAdjustment +=Math.round((maxExtents[3] - geoExtents[3]) / this.cellSize); vPixelAdjustment /=2; } else { vPixelAdjustment=Math.round((maxExtents[3] - geoExtents[3]) / this.cellSize); } } if(vPixelAdjustment !=0) { this.theInsideLayer.style.top=(safeParseInt(this.theInsideLayer.style.top) + vPixelAdjustment) + 'px'; } }}; kaMap.prototype.wrapR2L=function() { this.xOffset=this.xOffset - (this.nBuffer * this.tileWidth); var layers=this.aMaps[this.currentMap].getLayers(); for( var k=0; k<layers.length; k++) { var d=layers[k].domObj; var refLeft=safeParseInt(d.childNodes[0].style.left); for (var j=0; j<this.nHigh; j++) { var imgLast=d.childNodes[((j+1)*this.nWide)-1]; var imgNext=d.childNodes[j*this.nWide]; imgLast.style.left=(refLeft - this.tileWidth) + 'px'; imgLast.src=this.aPixel.src; d.removeChild(imgLast); d.insertBefore(imgLast, imgNext); if (layers[k].visible) { layers[k].setTile(imgLast); } } }}; kaMap.prototype.wrapL2R=function() { this.xOffset=this.xOffset + (this.nBuffer*this.tileWidth); var layers=this.aMaps[this.currentMap].getLayers(); for( var k=0; k<layers.length; k++) { var d=layers[k].domObj; var refLeft=safeParseInt(d.childNodes[this.nWide-1].style.left); for (var j=0; j<this.nHigh; j++) { var imgFirst=d.childNodes[j*this.nWide]; var imgNext; if (j < this.nHigh-1) { imgNext=d.childNodes[((j+1)*this.nWide)]; } else { imgNext=null; } imgFirst.style.left=(refLeft + this.tileWidth) + 'px'; imgFirst.src=this.aPixel.src; d.removeChild(imgFirst); if (imgNext) { d.insertBefore(imgFirst, imgNext); } else { d.appendChild(imgFirst); } if (layers[k].visible) { layers[k].setTile(imgFirst); } } }}; kaMap.prototype.wrapT2B=function() { this.yOffset=this.yOffset + (this.nBuffer*this.tileHeight); var layers=this.aMaps[this.currentMap].getLayers(); for( var k=0; k<layers.length; k++) { var d=layers[k].domObj; var refTop=safeParseInt(d.childNodes[(this.nHigh*this.nWide)-1].style.top); for (var i=0; i<this.nWide; i++) { var imgBottom=d.childNodes[0]; imgBottom.style.top=(refTop + this.tileHeight) + 'px'; imgBottom.src=this.aPixel.src; d.removeChild(imgBottom); d.appendChild(imgBottom); if (layers[k].visible) { layers[k].setTile(imgBottom); } } }}; kaMap.prototype.wrapB2T=function() { this.yOffset=this.yOffset - (this.nBuffer*this.tileHeight); var layers=this.aMaps[this.currentMap].getLayers(); for( var k=0; k<layers.length; k++) { var d=layers[k].domObj; var refTop=safeParseInt(d.childNodes[0].style.top); for (var i=0; i<this.nWide; i++) { var imgTop=d.childNodes[(this.nHigh*this.nWide)-1]; imgTop.style.top=(refTop - this.tileHeight) + 'px'; imgTop.src=this.aPixel.src; d.removeChild(imgTop); d.insertBefore(imgTop, d.childNodes[0]); if (layers[k].visible) { layers[k].setTile(imgTop); } } }}; kaMap.prototype.addMap=function( oMap ) { oMap.kaMap=this; this.aMaps[oMap.name]=oMap;}; kaMap.prototype.getMaps=function() { return this.aMaps;}; kaMap.prototype.getCurrentMap=function() { return this.aMaps[this.currentMap];}; kaMap.prototype.selectMap=function( name ) { if (!this.aMaps[name]) { return false; } else { this.currentMap=name; var oMap=this.getCurrentMap(); this.setBackgroundColor(oMap.backgroundColor); this.setMapLayers(); if (arguments[1] && arguments[1].length==3) { this.zoomTo(arguments[1][0], arguments[1][1], arguments[1][2]); oMap.aZoomTo.length=0; } else if (oMap.aZoomTo.length !=0) { this.zoomTo(oMap.aZoomTo[0], oMap.aZoomTo[1], oMap.aZoomTo[2]); oMap.aZoomTo.length=0; } else if (arguments[1] && arguments[1].length==4) { this.zoomToExtents( arguments[1][0], arguments[1][1], arguments[1][2], arguments[1][3] ); } else { this.zoomToExtents( oMap.currentExtents[0], oMap.currentExtents[1], oMap.currentExtents[2], oMap.currentExtents[3] ); } this.triggerEvent( KAMAP_MAP_INITIALIZED, this.currentMap ); return true; }}; kaMap.prototype.setMapLayers=function( ) { var oMap=this.getCurrentMap(); for(var i=this.theInsideLayer.childNodes.length - 1; i>=0; i-- ) { if (this.theInsideLayer.childNodes[i].className=='mapLayer') { this.theInsideLayer.childNodes[i].appended=false; this.theInsideLayer.removeChild(this.theInsideLayer.childNodes[i]); } } layers=oMap.getLayers(); for( var i=0; i<layers.length; i++) { if(!layers[i].domObj) { var d=this.createMapLayer( layers[i].name ); this.theInsideLayer.appendChild( d ); d.appended=true; layers[i].domObj=d; layers[i].setOpacity( layers[i].opacity ); layers[i].setZIndex( layers[i].zIndex ); layers[i].setVisibility( layers[i].visible ); this.nWide=0; this.nHigh=0; this.drawGroup(layers[i]); } else if (!layers[i].domObj.appended) { this.theInsideLayer.appendChild( layers[i].domObj ); layers[i].domObj.appended=true; layers[i].setZIndex( layers[i].zIndex ); } } return true;}; kaMap.prototype.drawGroup=function(group) { var newViewportWidth=this.getObjectWidth(this.domObj); var newViewportHeight=this.getObjectHeight(this.domObj); if (this.viewportWidth==null) { this.theInsideLayer.style.top=(-1*this.nCurrentTop + this.yOrigin) + "px"; this.theInsideLayer.style.left=(-1*this.nCurrentLeft + this.xOrigin) + "px"; this.viewportWidth=newViewportWidth; this.viewportHeight=newViewportHeight; } var newWide=Math.ceil((newViewportWidth / this.tileWidth) + 2*this.nBuffer); var newHigh=Math.ceil((newViewportHeight / this.tileHeight) + 2*this.nBuffer); this.viewportWidth=newViewportWidth; this.viewportHeight=newViewportHeight; if (this.nHigh==0 && this.nWide==0) { this.nWide=newWide; } while (this.nHigh < newHigh) { this.appendRow(group); } while (this.nHigh > newHigh) { this.removeRow(group); } while (this.nWide < newWide) { this.appendColumn(group); } while (this.nWide > newWide) { this.removeColumn(group); } return true;}; kaMap.prototype.createMapLayer=function( id ) { var d=document.createElement( 'div' ); d.id=id; d.className='mapLayer'; d.style.position='absolute'; d.style.visibility='visible'; d.style.left='0px'; d.style.top='0px'; d.style.width='3000px'; d.style.height='3000px'; d.appended=false; return d;}; kaMap.prototype.getLayerByName=function( layerName ) { var layerName=layerName; var oMap=this.getCurrentMap(); var aLayers=oMap.getAllLayers(); for(var i=0; i < aLayers.length; i++) { if(aLayers[i].name==layerName) { var oLayer=aLayers[i]; break; } } return oLayer;}; kaMap.prototype.addMapLayer=function( l ) { var map=this.getCurrentMap(); map.addLayer(l); this.setMapLayers(); this.paintLayer(l); this.triggerEvent( KAMAP_LAYERS_CHANGED, this.currentMap );}; kaMap.prototype.removeMapLayer=function( id ) { var map=this.getCurrentMap(); var layer=map.getLayer(id); if (!layer) { return false; } if (map.removeLayer ( map.getLayer(id) )) { this.setMapLayers(); this.triggerEvent( KAMAP_LAYERS_CHANGED, this.currentMap ); }}; kaMap.prototype.getCenter=function() { var deltaMouseX=this.nCurrentLeft - this.xOrigin + safeParseInt(this.theInsideLayer.style.left); var deltaMouseY=this.nCurrentTop - this.yOrigin + safeParseInt(this.theInsideLayer.style.top); var vpTop=this.nCurrentTop - deltaMouseY; var vpLeft=this.nCurrentLeft - deltaMouseX; var vpCenterX=vpLeft + this.viewportWidth/2; var vpCenterY=vpTop + this.viewportHeight/2; return new Array( vpCenterX, vpCenterY );}; kaMap.prototype.cancelEvent=function(e) { e=(e)?e:((event)?event:null); e.cancelBubble=true; e.returnValue=false; if (e.stopPropogation) { e.stopPropogation(); } if (e.preventDefault) { e.preventDefault(); } return false;}; kaMap.prototype.getGeoExtents=function() { var minx=-1*(safeParseInt(this.theInsideLayer.style.left) - this.xOrigin) * this.cellSize; var maxx=minx + this.viewportWidth * this.cellSize; var maxy=(safeParseInt(this.theInsideLayer.style.top) - this.yOrigin) * this.cellSize; var miny=maxy - this.viewportHeight * this.cellSize; return [minx,miny,maxx,maxy];}; kaMap.prototype.getGeoExpandedExtents=function() { var ex=this.getGeoExtents(); var span=Math.abs(ex[0]-ex[2])/2; ex[0]-=span; ex[1]-=span; ex[2]+=span; ex[3]+=span; return ex;}; kaMap.prototype.extentsWithin=function(bigExt){ var big=bigExt; var ex=this.getGeoExtents(); if(ex[0]>big[0] && ex[2]<big[2] && ex[1]>big[1] && ex[3]<big[3]){ return true; } return false;}; kaMap.prototype.getMetaExtents=function() { var result=this.getGeoExtents(); var oMap=this.getCurrentMap(); layers=oMap.getLayers(); for( var i=0; i<layers.length; i++) { if(layers[i].domObj) { var d=layers[i].domObj; var pl=safeParseInt(d.childNodes[0].style.left); var pt=safeParseInt(d.childNodes[0].style.top); var glt=this.pixToGeo(pl,pt,true); var left=-1*glt[0]; var top=-1*glt[1]; var right=left + this.nWide*this.tileWidth*this.cellSize; var bottom=top - this.nHigh*this.tileHeight*this.cellSize; result=[left, bottom, right, top]; break; } } return result;}; kaMap.prototype.zoomIn=function() { var nFactor=this.getNFactor(1); new theZoomedLayer(this, nFactor); this.zoomByFactor(this.aMaps[this.currentMap].zoomIn());}; kaMap.prototype.zoomOut=function() { var nFactor=this.getNFactor(-1); new theZoomedLayer(this, nFactor); this.zoomByFactor(this.aMaps[this.currentMap].zoomOut());}; kaMap.prototype.getNFactor=function(scalePosition){ var aScales=this.getCurrentMap().aScales; var currentScale=this.getCurrentScale(); for(var i=0; i < aScales.length; i++){ if(aScales[i]==currentScale){ var newScale=aScales[parseInt(i) + scalePosition]; } } if(currentScale > newScale){ var nFactor=currentScale / newScale; } else{ var nFactor=1 / (newScale / currentScale); } return nFactor; }; kaMap.prototype.getElementPosition=function(obj){ var curleft=curtop=0; if (obj.offsetParent) { curleft=obj.offsetLeft; curtop=obj.offsetTop; while (obj=obj.offsetParent) { curleft +=obj.offsetLeft; curtop +=obj.offsetTop; } curleft + (document.documentElement.scrollLeft || document.body.scrollLeft); curtop + (document.documentElement.scrollTop || document.body.scrollTop); } return [curleft,curtop]; }; kaMap.prototype.zoomToScale=function( scale ) { this.zoomByFactor(this.aMaps[this.currentMap].zoomToScale(scale));}; kaMap.prototype.zoomByFactor=function( nZoomFactor ) { if (nZoomFactor==1) { this.triggerEvent( KAMAP_NOTICE, "NOTICE: changing to current scale aborted"); return; } this.cellSize=this.cellSize/nZoomFactor; this.setMapLayers(); this.initializeLayers(nZoomFactor); this.triggerEvent( KAMAP_SCALE_CHANGED, this.getCurrentScale() ); this.triggerEvent( KAMAP_EXTENTS_CHANGED, this.getGeoExtents() );}; kaMap.prototype.getCurrentScale=function() { return this.aMaps[this.currentMap].aScales[this.aMaps[this.currentMap].currentScale];}; kaMap.prototype.setLayerQueryable=function( name, bQueryable ) { this.aMaps[this.currentMap].setLayerQueryable( name, bQueryable );}; kaMap.prototype.setLayerVisibility=function( name, bVisible ) { if(!this.loadUnchecked && bVisible) { layer=this.aMaps[this.currentMap].getLayer(name); layer.visible=true; this.setMapLayers(); this.aMaps[this.currentMap].setLayerVisibility( name, bVisible ); this.paintLayer(layer); } else { this.aMaps[this.currentMap].setLayerVisibility( name, bVisible ); }}; kaMap.prototype.setLayerOpacity=function( name, opacity ) { this.aMaps[this.currentMap].setLayerOpacity( name, opacity );}; kaMap.prototype.registerEventID=function( eventID ) { return this.eventManager.registerEventID(eventID);}; kaMap.prototype.registerForEvent=function( eventID, obj, func ) { return this.eventManager.registerForEvent(eventID, obj, func);}; kaMap.prototype.deregisterForEvent=function( eventID, obj, func ) { return this.eventManager.deregisterForEvent(eventID, obj, func);}; kaMap.prototype.triggerEvent=function( eventID ) { return this.eventManager.triggerEvent.apply( this.eventManager, arguments );}; function safeParseInt( val ) { return Math.round(parseFloat(val));}; function _map(o) { this.aLayers=[]; this.aZoomTo=[]; this.kaMap=null; this.name=(typeof(o.name) !='undefined') ? o.name : 'noname'; this.title=(typeof(o.title) !='undefined') ? o.title : 'no title'; this.aScales=(typeof(o.scales) !='undefined') ? o.scales : [1]; this.currentScale=(typeof(o.currentScale) !='undefined') ? parseFloat(o.currentScale) : 0; this.units=(typeof(o.units) !='undefined') ? o.units : 5; this.resolution=(typeof(o.resolution) !='undefined') ? o.resolution:72; this.defaultExtents=(typeof(o.defaultExtents) !='undefined') ? o.defaultExtents:[]; this.currentExtents=(typeof(o.currentExtents) !='undefined') ? o.currentExtents:[]; this.maxExtents=(typeof(o.maxExtents) !='undefined') ? o.maxExtents : []; this.backgroundColor=(typeof(o.backgroundColor) !='undefined') ? o.backgroundColor : '#ffffff'; this.version=(typeof(o.version) !='undefined') ? o.version : "";}; _map.prototype.addLayer=function( layer ) { layer._map=this; layer.zIndex=this.aLayers.length; this.aLayers.push( layer );}; _map.prototype.removeLayer=function( l ) { var alayer=Array(); for(i=0,a=0;i<this.aLayers.length;i++) { if(this.aLayers[i]!=l) { alayer[a]=this.aLayers[i]; a++; } } this.aLayers=alayer; return true;}; _map.prototype.getQueryableLayers=function() { var r=[]; var l=this.getLayers(); for( var i=0; i<l.length; i++) { if (l[i].isQueryable()) { r.push(l[i]); } } return r;}; _map.prototype.getLayers=function() { var r=[]; for( var i=0; i<this.aLayers.length; i++) { if (this.aLayers[i].isVisible() && (this.aLayers[i].visible || this.kaMap.loadUnchecked) ) { r.push(this.aLayers[i]); } } return r;}; _map.prototype.getAllQueryableLayers=function() { var r=[]; for( var i=0; i<this.aLayers.length; i++) { if (this.aLayers[i].isQueryable()) { r.push(this.aLayers[i]); } } return r;}; _map.prototype.getAllLayers=function() { return this.aLayers;}; _map.prototype.getLayer=function( name ) { for (var i=0; i<this.aLayers.length; i++) { if (this.aLayers[i].name==name) { return this.aLayers[i]; } }}; _map.prototype.getScales=function() { return this.aScales;}; _map.prototype.zoomIn=function() { var nZoomFactor=1; if (this.currentScale < this.aScales.length - 1) { nZoomFactor=this.aScales[this.currentScale]/this.aScales[this.currentScale+1]; this.currentScale=this.currentScale + 1; } return nZoomFactor;}; _map.prototype.zoomOut=function() { var nZoomFactor=1; if (this.currentScale > 0) { nZoomFactor=this.aScales[this.currentScale]/this.aScales[this.currentScale-1]; this.currentScale=this.currentScale - 1; } return nZoomFactor;}; _map.prototype.zoomToScale=function( scale ) { var nZoomFactor=1; for (var i=0; i<this.aScales.length; i++) { if (this.aScales[i]==scale) { nZoomFactor=this.aScales[this.currentScale]/scale; this.currentScale=parseInt(i); } } return nZoomFactor;}; _map.prototype.setLayerQueryable=function( name, bQueryable ) { var layer=this.getLayer( name ); if(typeof(layer) !='undefined') { layer.setQueryable( bQueryable ); }}; _map.prototype.setLayerVisibility=function( name, bVisible ) { var layer=this.getLayer( name ); if(typeof(layer) !='undefined') { layer.setVisibility( bVisible ); }}; _map.prototype.setLayerOpacity=function( name, opacity ) { var layer=this.getLayer( name ); if(typeof(layer) !='undefined') { layer.setOpacity( opacity ); }}; _map.prototype.setDefaultExtents=function( minx, miny, maxx, maxy ){ this.defaultExtents=[minx, miny, maxx, maxy]; if (this.currentExtents.length==0) this.setCurrentExtents( minx, miny, maxx, maxy );}; _map.prototype.setCurrentExtents=function( minx, miny, maxx, maxy ) { this.currentExtents=[minx, miny, maxx, maxy];}; _map.prototype.setMaxExtents=function( minx, miny, maxx, maxy ) { this.maxExtents=[minx, miny, maxx, maxy];}; _map.prototype.setBackgroundColor=function( szBgColor ) { this.backgroundColor=szBgColor;}; function _layer( o ) { this.domObj=null; this._map=null; this.name=(typeof(o.name) !='undefined') ? o.name : 'unnamed'; this.visible=(typeof(o.visible) !='undefined') ? o.visible : true; this.opacity=(typeof(o.opacity) !='undefined') ? o.opacity : 100; this.imageformat=(typeof(o.imageformat) !='undefined') ? o.imageformat : null; this.queryable=(typeof(o.queryable) !='undefined') ? o.queryable : false; this.queryState=(typeof(o.queryable) !='undefined') ? o.queryable : false; this.tileSource=(typeof(o.tileSource) !='undefined') ? o.tileSource : 'auto'; this.scales=(typeof(o.scales) !='undefined') ? o.scales : new Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); this.toLoad=0; var ts=new Date(); this.timeStamp=Math.round(ts.getTime()/1000) + ts.getTimezoneOffset() * 60; this.redrawInterval=(typeof(o.redrawInterval) !='undefined') ? o.redrawInterval : -1; this.refreshInterval=(typeof(o.refreshInterval) !='undefined') ? o.refreshInterval : -1; if (this.refreshInterval > 0) { goQueueManager.enqueue( this.refreshInterval*1000, this, this.redraw ); }}; _layer.prototype.isQueryable=function() { return this.queryState;}; _layer.prototype.setQueryable=function( bQueryable ) { if (this.queryable) { this.queryState=bQueryable; }}; _layer.prototype.isVisible=function() { return (this.scales[this._map.currentScale]==1)? true:false;}; _layer.prototype.setOpacity=function( amount ) { this.opacity=amount; if (this.domObj) { this.domObj.style.opacity=amount/100; this.domObj.style.mozOpacity=amount/100; for(var i=0;i<this.domObj.childNodes.length;i++) { this.domObj.childNodes[i].style.filter="Alpha(opacity="+amount+")"; } }}; _layer.prototype.setTile=function(img) { var l=safeParseInt(img.style.left) + this._map.kaMap.xOrigin; var t=safeParseInt(img.style.top) + this._map.kaMap.yOrigin; var szImageformat=''; var image_format=''; if (this.imageformat && this.imageformat !='') { image_format=this.imageformat; szImageformat='&i='+image_format; } if(this.tileSource=='cache') { var metaLeft=Math.floor(l/(this._map.kaMap.tileWidth * this._map.kaMap.metaWidth)) * this._map.kaMap.tileWidth * this._map.kaMap.metaWidth; var metaTop=Math.floor(t/(this._map.kaMap.tileHeight * this._map.kaMap.metaHeight)) * this._map.kaMap.tileHeight * this._map.kaMap.metaHeight; var metaTileId='t' + metaTop + 'l' + metaLeft; var groupsDir=(this.name !='') ? this.name.replace(/\W/g, '_') : 'def'; var cacheDir=this._map.kaMap.webCache + this._map.name + '/' + this._map.aScales[this._map.currentScale] + '/' + groupsDir + '/def/' + metaTileId; var tileId="t" + t + "l" + l; var imageExtension=this.imageformat.toLowerCase().replace(/[\de]/g, ''); var src=cacheDir + "/" + tileId + "." + imageExtension; } else { var szVersion=''; if (this._map.version !='') { szVersion='&version='+this._map.version; } var szForce=''; var szLayers=''; if (arguments[1]) { szForce='&force=true'; } var szTimestamp=''; if (this.tileSource=='redraw' || this.tileSource=="refresh") { szTimestamp='&ts='+this.timeStamp; if (this.redrawInterval) { szTimestamp=szTimestamp + '&interval='+this.redrawInterval; } } var szGroup='&g='+img.layer.domObj.id; var szScale='&s='+this._map.aScales[this._map.currentScale]; var q='?'; if (this._map.kaMap.tileURL.indexOf('?') !=-1) { if (this._map.kaMap.tileURL.slice(-1) !='&') { q='&'; } else { q=''; } } if (this.tileSource=='nocache') { var src=this._map.kaMap.server + this._map.kaMap.tileURL.replace('tile.php', 'tile_nocache.php') + q + 'map=' + this._map.name + '&t=' + t + '&l=' + l + szScale + szForce + szGroup + szImageformat; if(typeof(this.replacementVariables) !='undefined') { for(var key in this.replacementVariables) { src +='&' + encodeURIComponent(key) + '=' + encodeURIComponent(this.replacementVariables[key]); } } } else { var src=this._map.kaMap.server + this._map.kaMap.tileURL + q + 'map=' + this._map.name + '&t=' + t + '&l=' + l + szScale + szForce + szGroup + szImageformat + szTimestamp + szVersion; } } if (img.src !=src) { img.style.visibility='hidden'; img.src=src; }}; _layer.prototype.setVisibility=function( bVisible ) { this.visible=bVisible; if (this.domObj) { this.domObj.style.visibility=bVisible?'visible':'hidden'; this.domObj.style.display=bVisible?'block':'none'; for( var i=0; i<this.domObj.childNodes.length; i++) { this.setTile(this.domObj.childNodes[i]); } this._map.kaMap.triggerEvent( KAMAP_LAYER_STATUS_CHANGED, this ); }}; _layer.prototype.setZIndex=function( zIndex ) { this.zIndex=zIndex; if (this.domObj) { this.domObj.style.zIndex=zIndex; }}; _layer.prototype.setTileLayer=function() { this.loaded=0; for(i=0; i < this.domObj.childNodes.length; i++) { img=this.domObj.childNodes[i]; if(arguments[0]) { this.setTile(img, arguments[0]); } else { this.setTile(img); } }}; _layer.prototype.redraw=function() { if (arguments[0]) { this.refreshInterval=arguments[0]; } if (this.visible) { var ts=new Date(); this.timeStamp=Math.round(ts.getTime()/1000) + ts.getTimezoneOffset() * 60; this.setTileLayer(); } if (this.refreshInterval > 0) { goQueueManager.enqueue( this.refreshInterval*1000, this, this.redraw ); }}; function _eventManager( ){ this.events=[]; this.lastEventID=0;} _eventManager.prototype.registerEventID=function( eventID ) { var ev=new String(eventID); if (!this.events[eventID]) { this.events[eventID]=[]; }}; _eventManager.prototype.registerForEvent=function(eventID, obj, func) { var ev=new String(eventID); this.events[eventID].push( [obj, func] );}; _eventManager.prototype.deregisterForEvent=function( eventID, obj, func ) { var ev=new String(eventID); var bResult=false; if (!this.events[eventID]) { return false; } for (var i=0;i<this.events[eventID].length;i++) { if (this.events[eventID][i][0]==obj && this.events[eventID][i][1]==func) { this.events[eventID].splice(i,1); bResult=true; } } return bResult;}; _eventManager.prototype.triggerEvent=function( eventID ) { var ev=new String(eventID); if (!this.events[eventID]) { return false; } var args=new Array(); for(i=1; i<arguments.length; i++) { args[args.length]=arguments[i]; } for (var i=0; i<this.events[eventID].length; i++) { this.events[eventID][i][1].apply( this.events[eventID][i][0], arguments ); } return true;}; var goQueueManager=new _queueManager(); function _queueManager() { this.queue=new Array();} _queueManager.prototype.enqueue=function( timeout, obj, func, args ) { var pos=this.queue.length; for (var i=0; i< this.queue.length; i++) { if (this.queue[i]==null) { pos=i; break; } } var id=window.setTimeout( "_queueManager_execute("+pos+")", timeout ); this.queue[pos]=new Array( id, obj, func, args ); return pos;}; _queueManager.prototype.dequeue=function( pos ) { if (this.queue[pos] !=null) { window.clearTimeout( this.queue[pos][0] ); this.queue[pos]=null; }}; function _queueManager_execute( pos) { if (goQueueManager.queue[pos] !=null) { var obj=goQueueManager.queue[pos][1]; var func=goQueueManager.queue[pos][2]; if (goQueueManager.queue[pos][3] !=null) { func.apply( obj, goQueueManager.queue[pos][3] ); } else { func.apply( obj ); } goQueueManager.queue[pos]=null; }}; function divConstruct(domObj, className, id){ var div=document.createElement('div'); div.className=className; div.id=id; domObj.appendChild(div); return div; }; function imgConstruct(domObj, className, id, imgTag){ var img=document.createElement('img'); img.src=imgTag; img.id=id; img.className=className; if(domObj){ domObj.appendChild(img); } return img;}; function spanConstruct(domObj, className, id, textString){ var span=document.createElement('span'); span.className=className; if(textString){ span.innerHTML=textString; } domObj.appendChild(span); return span; }; function paragraphConstruct(domObj, className, id, textString){ var p=document.createElement('p'); p.className=className; if(textString){ p.innerHTML=textString; } domObj.appendChild(p); return p; }; function textNodeConstruct(domObj, className, id, textString){ var textNode=document.createTextNode(textString); domObj.appendChild(textNode); return textNode; }; function selectConstruct(domObj, className, id, searchObj){ var fSelect=document.createElement('select'); fSelect.className=className; fSelect.id=id; fSelect.searchObj=searchObj; fSelect.selectConstruct=this; domObj.appendChild(fSelect); return fSelect; }; function optionConstruct(domObj, sValue, sInnerHTML){ var option=document.createElement('option'); option.innerHTML=sInnerHTML; option.value=sValue; domObj.appendChild(option); return option;}; function buttonConstruct(domObj, id, className, text, parentObj){ var button=document.createElement('input'); button.id=id; button.className=className; button.type='button'; button.defaultValue=text; button.parentObject=parentObj; domObj.appendChild(button); }; function inputConstruct(domObj, id, className, text){ var input=document.createElement('input'); input.id=id; input.className=className; input.type='text'; input.value=text; domObj.appendChild(input); }; function closeHeader(domObj, textClass, divClass, headerText){ header=new divConstruct(domObj, divClass, 'headerText'); var headerNode=new spanConstruct(header, textClass, null, headerText); var closeTab=new imgConstruct(header,'closeTab', null, '/images/buttons/closeTab.png'); closeTab.onclick=function(){ domObj.innerHTML=''; domObj.style.display='none'; } }; function helpMessage(domObj,headerText, innerHTML) { var oHelpMessage=new divConstruct(domObj, 'messageBox', 'messageBox'); new closeHeader(oHelpMessage, 'headerText','headerDiv', headerText); oHelpMessage.body=new divConstruct(oHelpMessage, 'messageText', 'messageBox'); oHelpMessage.textNode=new textNodeConstruct(oHelpMessage.body, null, null, innerHTML);}; function constructHelpMessage(domObj, helpText){ var header_node=$.create("div", {"class": "helpBoxHeader", "id": "helpBoxHeader"}, ["img", {"class": "helpBoxClose", "id": "helpBoxClose", "src": "images/icon_set_aruna/tab_close.png" }, [], "Help Box!"]); var body_node=$.create("div", { "class": "helpBoxBody", "id": "helpBoxBody", "display": "open" }, [helpText]); var container_node=$.create("div", {"class": "helpBoxContainer", "id": "helpBoxContainer"}, [header_node, body_node]); domObj.appendChild(container_node); function expandCollapse(){ if($(body_node).attr("display")=="open") { $(body_node).slideUp("normal"); $(body_node).attr("display", "closed"); $("#helpBoxClose").attr("src", "images/icon_set_aruna/tab_open.png"); } else{ $(body_node).slideDown("normal"); $(body_node).attr("display", "open"); $("#helpBoxClose").attr("src", "images/icon_set_aruna/tab_close.png"); } } $("#helpBoxClose").bind("click", function(){ expandCollapse(); }); } function constructOption(domObj, sValue, sInnerHTML){ var option_node=$.create("option", {"value": sValue }, [sInnerHTML]); domObj.appendChild(option_node); return option;}; var kaCurrentTool=null; function kaTool( oKaMap ) { this.kaMap=oKaMap; this.name='kaTool'; this.bInfoTool=false; this.wheelMinus=new Array(oKaMap, oKaMap.zoomOut, null); this.wheelPlus=new Array(oKaMap, oKaMap.zoomIn, null); this.kaMap.registerTool( this );}; kaTool.prototype.isInfoTool=function() { return this.bInfoTool;}; kaTool.prototype.activate=function() { this.kaMap.activateTool( this ); document.kaCurrentTool=this;}; kaTool.prototype.deactivate=function() { this.kaMap.deactivateTool( this ); document.kaCurrentTool=null;}; kaTool.prototype.onmousemove=function(e) { return false;}; kaTool.prototype.onmousedown=function(e) { return false;}; kaTool.prototype.onmouseup=function(e) { return false;}; kaTool.prototype.ondblclick=function(e) { return false;}; kaTool.prototype.setMouseWheel=function(minusSet, plusSet) { this.wheelMinus=minusSet; this.wheelPlus=plusSet;}; kaTool.prototype.onmousewheel=function(e) { if(this.kaMap.theInsideLayer.focus){ e=(e)?e:((event)?event:null); var wheelDelta=e.wheelDelta ? e.wheelDelta : e.detail*-1; var wheelSet=null; if (wheelDelta > 0) wheelSet=this.wheelPlus; else wheelSet=this.wheelMinus; if (wheelSet) { obj=(wheelSet[0]) ? wheelSet[0] : null; func=(wheelSet[1]) ? wheelSet[1] : null; args=(wheelSet[2]) ? wheelSet[2] : null; if (func) { if (args) { func.apply(obj, args); } else{ func.apply(obj); } } } }}; function kaTool_redirect_onkeypress(e) { if (document.kaCurrentTool) { document.kaCurrentTool.onkeypress(e); }}; kaTool.prototype.onkeypress=function(e) { e=(e)?e:((event)?event:null); if (e) { var charCode=(e.charCode)?e.charCode:e.keyCode; var b=true; var nStep=16; switch(charCode) { case 38: this.kaMap.moveBy(0,nStep); this.kaMap.triggerEvent( KAMAP_EXTENTS_CHANGED, this.kaMap.getGeoExtents() ); break; case 40: this.kaMap.moveBy(0,-nStep); this.kaMap.triggerEvent( KAMAP_EXTENTS_CHANGED, this.kaMap.getGeoExtents() ); break; case 37: this.kaMap.moveBy(nStep,0); this.kaMap.triggerEvent( KAMAP_EXTENTS_CHANGED, this.kaMap.getGeoExtents() ); break; case 39: this.kaMap.moveBy(-nStep,0); this.kaMap.triggerEvent( KAMAP_EXTENTS_CHANGED, this.kaMap.getGeoExtents() ); break; case 33: this.kaMap.slideBy(0, this.kaMap.viewportHeight/2); break; case 34: this.kaMap.slideBy(0,-this.kaMap.viewportHeight/2); break; case 36: this.kaMap.slideBy(this.kaMap.viewportWidth/2,0); break; case 35: this.kaMap.slideBy(-this.kaMap.viewportWidth/2,0); break; case 43: case 61: this.kaMap.zoomIn(); break; case 45: this.kaMap.zoomOut(); break; default: b=false; } if (b) { return this.cancelEvent(e); } return true; }}; kaTool.prototype.onmouseover=function(e) { return false;}; kaTool.prototype.onmouseout=function(e) { if (this.kaMap.isIE4) { document.onkeydown=null; } document.onkeypress=null; return false;}; kaTool.prototype.cancelEvent=function(e) { e=(e)?e:((event)?event:null); e.cancelBubble=true; e.returnValue=false; if (e.stopPropogation) { e.stopPropogation(); } if (e.preventDefault) { e.preventDefault(); } return false;}; function kaNavigator( oKaMap ) { kaTool.apply( this, [oKaMap] ); this.name='kaNavigator'; this.cursorNormal=["url('images/grab.cur'),move", '-moz-grab', 'grab', 'move']; this.cursorDrag=["url('images/grabbing.cur'),move", '-moz-grabbing', 'grabbing', 'move']; this.cursor=this.cursorNormal; this.activeImage=this.kaMap.server + 'images/button_pan_3.png'; this.disabledImage=this.kaMap.server + 'images/button_pan_2.png'; this.lastx=null; this.lasty=null; this.bMouseDown=false; for (var p in kaTool.prototype) { if (!kaNavigator.prototype[p]) kaNavigator.prototype[p]=kaTool.prototype[p]; }}; kaNavigator.prototype.onmouseout=function(e) { e=(e)?e:((event)?event:null); if (!e.target) e.target=e.srcElement; if (e.target.id==this.kaMap.domObj.id) { this.bMouseDown=false; return kaTool.prototype.onmouseout.apply(this, [e]); }}; kaNavigator.prototype.onmousemove=function(e) { e=(e)?e:((event)?event:null); if (!this.bMouseDown) { return false; } if (!this.kaMap.layersHidden) { this.kaMap.hideLayers(); } var newTop=safeParseInt(this.kaMap.theInsideLayer.style.top); var newLeft=safeParseInt(this.kaMap.theInsideLayer.style.left); var x=e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)); var y=e.pageY || (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop)); newTop=newTop - this.lasty + y; newLeft=newLeft - this.lastx + x; var removed=removeZoomedLayer(this.kaMap); this.kaMap.theInsideLayer.style.top=newTop + 'px'; this.kaMap.theInsideLayer.style.left=newLeft + 'px'; if(this.kaMap.theZoomedLayer){ this.kaMap.theZoomedLayer.style.top=newTop + 'px'; this.kaMap.theZoomedLayer.style.left=newLeft + 'px'; } this.kaMap.checkWrap.apply(this.kaMap, []); this.lastx=x; this.lasty=y; return false;}; kaNavigator.prototype.onmousedown=function(e) { e=(e)?e:((event)?event:null); if (e.button==2) { var x=e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)); var y=e.pageY || (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop)); } else { this.cursor=this.cursorDrag; this.kaMap.setCursor(this.cursorDrag); if (this.kaMap.isIE4) { document.onkeydown=kaTool_redirect_onkeypress; } document.onkeypress=kaTool_redirect_onkeypress; this.bMouseDown=true; var x=e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)); var y=e.pageY || (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop)); this.lastx=x; this.lasty=y; this.startx=this.lastx; this.starty=this.lasty; e.cancelBubble=true; e.returnValue=false; if (e.stopPropogation) e.stopPropogation(); if (e.preventDefault) e.preventDefault(); return false; }}; var gDblClickTimer=null; kaNavigator.prototype.onmouseup=function(e) { this.cursor=this.cursorNormal; this.kaMap.setCursor(this.cursorNormal); e=(e)?e:((event)?event:null); this.bMouseDown=false; var x=e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)); var y=e.pageY || (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop)); if (Math.abs(x-this.startx) < 2 && Math.abs(y-this.starty) < 2) { if (!gDblClickTimer) { gDblClickTimer=window.setTimeout(bind(this.dispatchMapClicked, this, x, y), 250); } } else { gDblClickTimer=null; this.kaMap.showLayers(); this.kaMap.triggerEvent(KAMAP_EXTENTS_CHANGED, this.kaMap.getGeoExtents()); } return false;}; kaNavigator.prototype.dispatchMapClicked=function(px,py) { var a=this.kaMap.adjustPixPosition( px,py ); var p=this.kaMap.pixToGeo( a[0],a[1] ); gDblClickTimer=null; this.kaMap.triggerEvent(KAMAP_MAP_CLICKED, p);}; kaNavigator.prototype.ondblclick=function(e) { if (gDblClickTimer) { window.clearTimeout(gDblClickTimer); gDblClickTimer=null; } e=(e)?e:((event)?event:null); var x=e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)); var y=e.pageY || (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop)); var a=this.kaMap.adjustPixPosition( x,y ); var p=this.kaMap.pixToGeo( a[0], a[1] ); this.kaMap.zoomTo(p[0],p[1]);}; function bind(m,o) { var __method=arguments[0]; var __object=arguments[1]; var args=[]; for (var i=2; i<arguments.length; i++) { args.push(arguments[i]) } return function() { return __method.apply(__object, args); }} function ScaleBar(scaleDenominator) { this.scaleDenominator=(scaleDenominator==null) ? 1 : scaleDenominator; this.displaySystem='metric'; this.minWidth=100; this.maxWidth=180; this.divisions=2; this.subdivisions=2; this.showMinorMeasures=false; this.abbreviateLabel=false; this.singleLine=false; this.resolution=72; this.align='center'; this.container=document.createElement('div'); this.container.className='sbWrapper'; this.labelContainer=document.createElement('div'); this.labelContainer.className='sbUnitsContainer'; this.labelContainer.style.position='absolute'; this.graphicsContainer=document.createElement('div'); this.graphicsContainer.style.position='absolute'; this.graphicsContainer.className='sbGraphicsContainer'; this.numbersContainer=document.createElement('div'); this.numbersContainer.style.position='absolute'; this.numbersContainer.className='sbNumbersContainer'; var markerMajor=document.createElement('div'); markerMajor.className='sbMarkerMajor'; this.graphicsContainer.appendChild(markerMajor); var markerMinor=document.createElement('div'); markerMinor.className='sbMarkerMinor'; this.graphicsContainer.appendChild(markerMinor); var barPiece=document.createElement('div'); barPiece.className='sbBar'; this.graphicsContainer.appendChild(barPiece); var barPieceAlt=document.createElement('div'); barPieceAlt.className='sbBarAlt'; this.graphicsContainer.appendChild(barPieceAlt);}ScaleBar.prototype.update=function(scaleDenominator) { if(scaleDenominator !=null) { this.scaleDenominator=scaleDenominator; }; function HandsomeNumber(smallUglyNumber, bigUglyNumber, sigFigs) { var sigFigs=(sigFigs==null) ? 10 : sigFigs; var bestScore=Number.POSITIVE_INFINITY; var bestTieBreaker=Number.POSITIVE_INFINITY; var handsomeValue=smallUglyNumber; var handsomeNumDec=3; for(var halvingExp=0; halvingExp < 3; ++halvingExp) { var comelyMultiplicand=Math.pow(2, (-1 * halvingExp)); var maxTensExp=Math.floor(Math.log(bigUglyNumber / comelyMultiplicand) / Math.LN10); for(var tensExp=maxTensExp; tensExp > (maxTensExp - sigFigs + 1); --tensExp) { var numDec=Math.max(halvingExp - tensExp, 0); var testMultiplicand=comelyMultiplicand * Math.pow(10, tensExp); if((testMultiplicand * Math.floor(bigUglyNumber / testMultiplicand)) >=smallUglyNumber) { if(smallUglyNumber % testMultiplicand==0) { var testMultiplier=smallUglyNumber / testMultiplicand; } else { var testMultiplier=Math.floor(smallUglyNumber / testMultiplicand) + 1; } var testScore=testMultiplier + (2 * halvingExp); var testTieBreaker=(tensExp < 0) ? (Math.abs(tensExp) + 1) : tensExp; if((testScore < bestScore) || ((testScore==bestScore) && (testTieBreaker < bestTieBreaker))) { bestScore=testScore; bestTieBreaker=testTieBreaker; handsomeValue=(testMultiplicand * testMultiplier).toFixed(numDec); handsomeNumDec=numDec; } } } } this.value=handsomeValue; this.score=bestScore; this.tieBreaker=bestTieBreaker; this.numDec=handsomeNumDec; }; HandsomeNumber.prototype.toString=function() { return this.value.toString(); }; HandsomeNumber.prototype.valueOf=function() { return this.value; }; function styleValue(aSelector, styleKey) { var aValue=0; if(document.styleSheets) { for(var sheetIndex=document.styleSheets.length - 1; sheetIndex >=0; --sheetIndex) { var aSheet=document.styleSheets[sheetIndex]; if(!aSheet.disabled) { var allRules; if(typeof(aSheet.cssRules)=='undefined') { if(typeof(aSheet.rules)=='undefined') { return 0; } else { allRules=aSheet.rules; } } else { allRules=aSheet.cssRules; } for(var ruleIndex=0; ruleIndex < allRules.length; ++ruleIndex) { var aRule=allRules[ruleIndex]; if(aRule.selectorText && (aRule.selectorText.toLowerCase()==aSelector.toLowerCase())) { if(aRule.style[styleKey] !='') { aValue=parseInt(aRule.style[styleKey]); } } } } } } return aValue ? aValue : 0; }; function formatNumber(aNumber, numDecimals) { numDecimals=(numDecimals) ? numDecimals : 0; var formattedInteger='' + Math.round(aNumber); var thousandsPattern=/(-?[0-9]+)([0-9]{3})/; while(thousandsPattern.test(formattedInteger)) { formattedInteger=formattedInteger.replace(thousandsPattern, '$1,$2'); } if(numDecimals > 0) { var formattedDecimal=Math.floor(Math.pow(10, numDecimals) * (aNumber - Math.round(aNumber))); if(formattedDecimal==0) { return formattedInteger; } else { return formattedInteger + '.' + formattedDecimal; } } else { return formattedInteger; } }; this.container.title='scale 1:' + formatNumber(this.scaleDenominator); var measurementProperties=new Object(); measurementProperties.english={ units: ['miles', 'feet', 'inches'], abbr: ['mi', 'ft', 'in'], inches: [63360, 12, 1] }; measurementProperties.metric={ units: ['kilometers', 'meters', 'centimeters'], abbr: ['km', 'm', 'cm'], inches: [39370.07874, 39.370079, 0.393701] }; var comparisonArray=new Array(); for(var unitIndex=0; unitIndex < measurementProperties[this.displaySystem].units.length; ++unitIndex) { comparisonArray[unitIndex]=new Object(); var pixelsPerDisplayUnit=this.resolution * measurementProperties[this.displaySystem].inches[unitIndex] / this.scaleDenominator; var minSDDisplayLength=(this.minWidth / pixelsPerDisplayUnit) / (this.divisions * this.subdivisions); var maxSDDisplayLength=(this.maxWidth / pixelsPerDisplayUnit) / (this.divisions * this.subdivisions); for(var valueIndex=0; valueIndex < (this.divisions * this.subdivisions); ++valueIndex) { var minNumber=minSDDisplayLength * (valueIndex + 1); var maxNumber=maxSDDisplayLength * (valueIndex + 1); var niceNumber=new HandsomeNumber(minNumber, maxNumber); comparisonArray[unitIndex][valueIndex]={value: (niceNumber.value / (valueIndex + 1)), score: 0, tieBreaker: 0, numDec: 0, displayed: 0}; for(var valueIndex2=0; valueIndex2 < (this.divisions * this.subdivisions); ++valueIndex2) { displayedValuePosition=niceNumber.value * (valueIndex2 + 1) / (valueIndex + 1); niceNumber2=new HandsomeNumber(displayedValuePosition, displayedValuePosition); var isMajorMeasurement=((valueIndex2 + 1) % this.subdivisions==0); var isLastMeasurement=((valueIndex2 + 1)==(this.divisions * this.subdivisions)); if((this.singleLine && isLastMeasurement) || (!this.singleLine && (isMajorMeasurement || this.showMinorMeasures))) { comparisonArray[unitIndex][valueIndex].score +=niceNumber2.score; comparisonArray[unitIndex][valueIndex].tieBreaker +=niceNumber2.tieBreaker; comparisonArray[unitIndex][valueIndex].numDec=Math.max(comparisonArray[unitIndex][valueIndex].numDec, niceNumber2.numDec); comparisonArray[unitIndex][valueIndex].displayed +=1; } else { comparisonArray[unitIndex][valueIndex].score +=niceNumber2.score / this.subdivisions; comparisonArray[unitIndex][valueIndex].tieBreaker +=niceNumber2.tieBreaker / this.subdivisions; } } var scoreAdjustment=(unitIndex + 1) * comparisonArray[unitIndex][valueIndex].tieBreaker / comparisonArray[unitIndex][valueIndex].displayed; comparisonArray[unitIndex][valueIndex].score *=scoreAdjustment; } } var subdivisionDisplayLength=null; var displayUnits=null; var displayUnitsAbbr=null; var subdivisionPixelLength=null; var bestScore=Number.POSITIVE_INFINITY; var bestTieBreaker=Number.POSITIVE_INFINITY; var numDec=0; for(var unitIndex=0; unitIndex < comparisonArray.length; ++unitIndex) { for(valueIndex in comparisonArray[unitIndex]) { if((comparisonArray[unitIndex][valueIndex].score < bestScore) || ((comparisonArray[unitIndex][valueIndex].score==bestScore) && (comparisonArray[unitIndex][valueIndex].tieBreaker < bestTieBreaker))) { bestScore=comparisonArray[unitIndex][valueIndex].score; bestTieBreaker=comparisonArray[unitIndex][valueIndex].tieBreaker; subdivisionDisplayLength=comparisonArray[unitIndex][valueIndex].value; numDec=comparisonArray[unitIndex][valueIndex].numDec; displayUnits=measurementProperties[this.displaySystem].units[unitIndex]; displayUnitsAbbr=measurementProperties[this.displaySystem].abbr[unitIndex]; pixelsPerDisplayUnit=this.resolution * measurementProperties[this.displaySystem].inches[unitIndex] / this.scaleDenominator; subdivisionPixelLength=pixelsPerDisplayUnit * subdivisionDisplayLength; } } } var xOffsetMarkerMajor=(styleValue('.sbMarkerMajor', 'borderLeftWidth') + styleValue('.sbMarkerMajor', 'width') + styleValue('.sbMarkerMajor', 'borderRightWidth')) / 2; var xOffsetMarkerMinor=(styleValue('.sbMarkerMinor', 'borderLeftWidth') + styleValue('.sbMarkerMinor', 'width') + styleValue('.sbMarkerMinor', 'borderRightWidth')) / 2; var xOffsetBar=(styleValue('.sbBar', 'borderLeftWidth') + styleValue('.sbBar', 'borderRightWidth')) / 2; var xOffsetBarAlt=(styleValue('.sbBarAlt', 'borderLeftWidth') + styleValue('.sbBarAlt', 'borderRightWidth')) / 2; if(!document.styleSheets) { xOffsetMarkerMajor=0.5; xOffsetMarkerMinor=0.5; } while(this.labelContainer.hasChildNodes()) { this.labelContainer.removeChild(this.labelContainer.firstChild); } while(this.graphicsContainer.hasChildNodes()) { this.graphicsContainer.removeChild(this.graphicsContainer.firstChild); } while(this.numbersContainer.hasChildNodes()) { this.numbersContainer.removeChild(this.numbersContainer.firstChild); } var aMarker, aBarPiece, numbersBox, xOffset; var alignmentOffset={ left: 0, center: (-1 * this.divisions * this.subdivisions * subdivisionPixelLength / 2), right: (-1 * this.divisions * this.subdivisions * subdivisionPixelLength) }; var xPosition=0 + alignmentOffset[this.align]; var markerMeasure=0; for(var divisionIndex=0; divisionIndex < this.divisions; ++divisionIndex) { xPosition=divisionIndex * this.subdivisions * subdivisionPixelLength; xPosition +=alignmentOffset[this.align]; markerMeasure=(divisionIndex==0) ? 0 : ((divisionIndex * this.subdivisions) * subdivisionDisplayLength).toFixed(numDec); aMarker=document.createElement('div'); aMarker.className='sbMarkerMajor'; aMarker.style.position='absolute'; aMarker.style.overflow='hidden'; aMarker.style.left=Math.round(xPosition - xOffsetMarkerMajor) + 'px'; aMarker.appendChild(document.createTextNode(' ')); this.graphicsContainer.appendChild(aMarker); if(!this.singleLine) { numbersBox=document.createElement('div'); numbersBox.className='sbNumbersBox'; numbersBox.style.position='absolute'; numbersBox.style.overflow='hidden'; numbersBox.style.textAlign='center'; if(this.showMinorMeasures) { numbersBox.style.width=Math.round(subdivisionPixelLength * 2) + 'px'; numbersBox.style.left=Math.round(xPosition - subdivisionPixelLength) + 'px'; } else { numbersBox.style.width=Math.round(this.subdivisions * subdivisionPixelLength * 2) + 'px'; numbersBox.style.left=Math.round(xPosition - (this.subdivisions * subdivisionPixelLength)) + 'px'; } numbersBox.appendChild(document.createTextNode(markerMeasure)); this.numbersContainer.appendChild(numbersBox); } for(var subdivisionIndex=0; subdivisionIndex < this.subdivisions; ++subdivisionIndex) { aBarPiece=document.createElement('div'); aBarPiece.style.position='absolute'; aBarPiece.style.overflow='hidden'; aBarPiece.style.width=Math.round(subdivisionPixelLength) + 'px'; if((subdivisionIndex % 2)==0) { aBarPiece.className='sbBar'; aBarPiece.style.left=Math.round(xPosition - xOffsetBar) + 'px'; } else { aBarPiece.className='sbBarAlt'; aBarPiece.style.left=Math.round(xPosition - xOffsetBarAlt) + 'px'; } aBarPiece.appendChild(document.createTextNode(' ')); this.graphicsContainer.appendChild(aBarPiece); if(subdivisionIndex < (this.subdivisions - 1)) { xPosition=((divisionIndex * this.subdivisions) + (subdivisionIndex + 1)) * subdivisionPixelLength; xPosition +=alignmentOffset[this.align]; markerMeasure=(divisionIndex * this.subdivisions + subdivisionIndex + 1) * subdivisionDisplayLength; aMarker=document.createElement('div'); aMarker.className='sbMarkerMinor'; aMarker.style.position='absolute'; aMarker.style.overflow='hidden'; aMarker.style.left=Math.round(xPosition - xOffsetMarkerMinor) + 'px'; aMarker.appendChild(document.createTextNode(' ')); this.graphicsContainer.appendChild(aMarker); if(this.showMinorMeasures && !this.singleLine) { numbersBox=document.createElement('div'); numbersBox.className='sbNumbersBox'; numbersBox.style.position='absolute'; numbersBox.style.overflow='hidden'; numbersBox.style.textAlign='center'; numbersBox.style.width=Math.round(subdivisionPixelLength * 2) + 'px'; numbersBox.style.left=Math.round(xPosition - subdivisionPixelLength) + 'px'; numbersBox.appendChild(document.createTextNode(markerMeasure)); this.numbersContainer.appendChild(numbersBox); } } } } xPosition=(this.divisions * this.subdivisions) * subdivisionPixelLength; xPosition +=alignmentOffset[this.align]; markerMeasure=((this.divisions * this.subdivisions) * subdivisionDisplayLength).toFixed(numDec); aMarker=document.createElement('div'); aMarker.className='sbMarkerMajor'; aMarker.style.position='absolute'; aMarker.style.overflow='hidden'; aMarker.style.left=Math.round(xPosition - xOffsetMarkerMajor) + 'px'; aMarker.appendChild(document.createTextNode(' ')); this.graphicsContainer.appendChild(aMarker); if(!this.singleLine) { numbersBox=document.createElement('div'); numbersBox.className='sbNumbersBox'; numbersBox.style.position='absolute'; numbersBox.style.overflow='hidden'; numbersBox.style.textAlign='center'; if(this.showMinorMeasures) { numbersBox.style.width=Math.round(subdivisionPixelLength * 2) + 'px'; numbersBox.style.left=Math.round(xPosition - subdivisionPixelLength) + 'px'; } else { numbersBox.style.width=Math.round(this.subdivisions * subdivisionPixelLength * 2) + 'px'; numbersBox.style.left=Math.round(xPosition - (this.subdivisions * subdivisionPixelLength)) + 'px'; } numbersBox.appendChild(document.createTextNode(markerMeasure)); this.numbersContainer.appendChild(numbersBox); } var labelBox=document.createElement('div'); labelBox.style.position='absolute'; var labelText; if(this.singleLine) { labelText=markerMeasure; labelBox.className='sbLabelBoxSingleLine'; labelBox.style.top='-0.6em'; labelBox.style.left=(xPosition + 10) + 'px'; } else { labelText=''; labelBox.className='sbLabelBox'; labelBox.style.textAlign='center'; labelBox.style.width=Math.round(this.divisions * this.subdivisions * subdivisionPixelLength) + 'px'; labelBox.style.left=Math.round(alignmentOffset[this.align]) + 'px'; labelBox.style.overflow='hidden'; } if(this.abbreviateLabel) { labelText +=' ' + displayUnitsAbbr; } else { labelText +=' ' + displayUnits; } labelBox.appendChild(document.createTextNode(labelText)); this.labelContainer.appendChild(labelBox); if(!document.styleSheets) { var defaultStyle=document.createElement('style'); defaultStyle.type='text/css'; var styleText='.sbBar {top: 0px; background: #666666; height: 1px; border: 0;}'; styleText +='.sbBarAlt {top: 0px; background: #666666; height: 1px; border: 0;}'; styleText +='.sbMarkerMajor {height: 7px; width: 1px; background: #666666; border: 0;}'; styleText +='.sbMarkerMinor {height: 5px; width: 1px; background: #666666; border: 0;}'; styleText +='.sbLabelBox {top: -16px;}'; styleText +='.sbNumbersBox {top: 7px;}'; defaultStyle.appendChild(document.createTextNode(styleText)); document.getElementsByTagName('head').item(0).appendChild(defaultStyle); } this.container.appendChild(this.graphicsContainer); this.container.appendChild(this.labelContainer); this.container.appendChild(this.numbersContainer);};ScaleBar.prototype.place=function(elementId) { if(elementId==null) { document.body.appendChild(this.container); } else { var anElement=document.getElementById(elementId); if(anElement !=null) { anElement.appendChild(this.container); } } this.update();};function toolItem (kaMap, id, name, path, toolMethod){ this.kaMap=kaMap; this.id=id; this.name=name; this.path=path; var toolMenu=getRawObject('topBar'); this.toolDiv=getRawObject(this.id); var toolImg=new imgConstruct(toolMenu, 'toolButton', null, '/images/buttons/' + name + '.png'); toolImg.style.cursor='pointer'; toolImg.style.position='relative'; toolImg.className='topBarNode'; toolImg.style.marginLeft='2px'; toolImg.title=name; toolImg.toolItem=this; var vMethod=eval('this.' + toolMethod); toolImg.onclick=vMethod;}; toolItem.prototype.sideBar=function (){ var bActive=this.toolItem.searchArray(this.toolItem.id, document.aActiveTools); var sideBar=getRawObject('sideBar'); if(sideBar.style.display=='none'){ expandCollapseLeft('leftSide'); } var sideBarCurrent=getRawObject(document.sideBarCurrent); sideBarCurrent.style.display='none'; if(bActive){ this.toolItem.toolDiv.style.display=''; if(this.myArunaTool && this.myArunaTool.refresh){ this.myArunaTool.refresh(); } } else{ this.loader=getRawObject('arunaLoading'); this.loader.style.display=''; document.aActiveTools.push(this.toolItem.id); call(this.toolItem.path ,this,this.toolItem.processTool); } document.sideBarCurrent=this.toolItem.id;}; toolItem.prototype.helpWindow=function (){ this.helpWindow=getRawObject('infoWindow'); this.helpWindow.innerHTML=''; this.helpWindow.style.display='inline'; call('help_no_html.html',this, this.toolItem.displayHelp);}; toolItem.prototype.panTool=function (){ myKaNavigator.activate();}; toolItem.prototype.displayHelp=function(result){ var headerObj=new closeHeader(this.helpWindow, 'metaHeaderClass','metaDivClass',''); var helpContainer=document.createElement('div'); helpContainer.style.position='relative'; helpContainer.innerHTML=result; this.helpWindow.appendChild(helpContainer);}; toolItem.prototype.zoomToFullExtent=function(){ getFullExtent();}; toolItem.prototype.linkToView=function(){ window.location=document.viewURL;}; toolItem.prototype.processTool=function(toolCode){ this.loader.style.display='none'; eval(toolCode); var construct='new ' + this.toolItem.id + '(this.toolItem.kaMap)'; this.myArunaTool=eval(construct);}; toolItem.prototype.searchArray=function (id, array){ for(element in array){ if (array[element]==id){ return true; } } return false;}; function kaKeymap(oKaMap, szID ) { this.kaMap=oKaMap; this.domObj=this.kaMap.getRawObject(szID); this.domObj.kaKeymap=this; this.width=getObjectWidth(szID)+"px"; this.height=getObjectHeight(szID)+"px"; this.pxExtent=null; this.domExtents=null; this.aExtents=null; this.domImg=null; this.imgSrc=null; this.imgWidth=null; this.imgHeight=null; this.cellWidth=null; this.cellHeight=null; this.initialExtents=null; this.domObj.ondblclick=this.onclick; if ( this.domObj.captureEvents) { this.domObj.captureEvents(Event.DBLCLICK); } this.kaMap.registerForEvent( KAMAP_EXTENTS_CHANGED, this, this.update ); this.kaMap.registerForEvent( KAMAP_MAP_INITIALIZED, this, this.initialize );}; kaKeymap.prototype.initialize=function(id) { this.pxExtent=null; this.initialExtents=this.kaMap.getGeoExtents(); call('/map/keymap/?map='+this.kaMap.currentMap,this,this.draw);}; kaKeymap.prototype.draw=function( szResult ) { eval( szResult ); this.cellWidth=(this.aExtents[2] - this.aExtents[0]) / this.imgWidth; this.cellHeight=(this.aExtents[3] - this.aExtents[1]) / this.imgHeight; for(var i=this.domObj.childNodes.length - 1; i >=0; i--) this.domObj.removeChild (this.domObj.childNodes[i]); this.domObj.style.width=this.imgWidth + "px"; this.domObj.style.height=this.imgHeight + "px"; this.domImg=document.createElement( 'img' ); this.domImg.src=this.imgSrc; this.domImg.width=this.imgWidth; this.domImg.height=this.imgHeight; this.domObj.appendChild( this.domImg ); this.domExtents=document.createElement( 'div' ); this.domExtents.kaKeymap=this; this.domExtents.id="keymapDomExtents"; this.domExtents.style.position='absolute'; this.domExtents.style.border='1px solid red'; this.domExtents.style.top="1px"; this.domExtents.style.left="1px"; this.domExtents.style.width="1px"; this.domExtents.style.height="1px"; this.domExtents.style.backgroundColor='transparent'; this.domExtents.style.visibility='visible'; this.domObj.appendChild(this.domExtents); this.domEvent=document.createElement( 'div' ); this.domEvent.kaKeymap=this; this.domEvent.onmousedown=this.mousedown; this.domEvent.onmouseup=this.mouseup; this.domEvent.onmousemove=this.mousemove; this.domEvent.onmouseout=this.mouseup; if (this.domEvent.captureEvents) { this.domEvent.captureEvents(Event.MOUSEDOWN); this.domEvent.captureEvents(Event.MOUSEUP); this.domEvent.captureEvents(Event.MOUSEMOVE); this.domEvent.captureEvents(Event.MOUSEOUT); } this.domEvent.style.position='absolute'; this.domEvent.id='keymapDomEvent'; this.domEvent.style.border='1px solid red'; this.domEvent.style.top="1px"; this.domEvent.style.left="1px"; this.domEvent.style.width="1px"; this.domEvent.style.height="1px"; this.domEvent.style.backgroundColor='white'; this.domEvent.style.visibility='visible'; this.domEvent.style.opacity=0.01; this.domEvent.style.mozOpacity=0.01; this.domEvent.style.filter="Alpha(opacity=0.01)"; this.domObj.appendChild(this.domEvent); var d=document.createElement( 'img' ); d.id="keymapCrossImage"; d.src="/images/keymap/cross.png"; d.style.position='absolute'; d.style.top='0px'; d.style.left='0px'; d.style.width="19px"; d.style.height="19px"; d.style.visibility='hidden'; this.domExtents.appendChild(d); this.domCross=d; if (this.initialExtents !=null) { this.update( null, this.initialExtents); }}; kaKeymap.prototype.update=function( eventID, extents ) { if (!this.aExtents || !this.domExtents) { this.initialExtents=extents; return; } var left=(extents[0] - this.aExtents[0]) / this.cellWidth; var width=(extents[2] - extents[0]) / this.cellWidth; var top=-1 * (extents[3] - this.aExtents[3]) / this.cellHeight; var height=(extents[3] - extents[1]) / this.cellHeight; this.pxExtent=new Array(left,top,width,height); this.domExtents.style.top=parseInt(top+0.5)+"px"; this.domExtents.style.left=parseInt(left+0.5)+"px"; this.domEvent.style.top=parseInt(top+0.5)+"px"; this.domEvent.style.left=parseInt(left+0.5)+"px"; if (parseInt(width+0.5) < parseInt(this.domCross.style.width) || parseInt(height+0.5) < parseInt(this.domCross.style.height) ) { var ix=parseInt(this.domCross.style.width)/2; var iy=parseInt(this.domCross.style.height)/2; var ox=width/2; var oy=height/2; this.domExtents.style.width=this.domCross.style.width; this.domExtents.style.height=this.domCross.style.height; this.domEvent.style.width=this.domCross.style.width; this.domEvent.style.height=this.domCross.style.height; this.domExtents.style.top=(parseInt(this.domExtents.style.top) -iy + oy) + 'px'; this.domExtents.style.left=(parseInt(this.domExtents.style.left) -ix + ox) + 'px'; this.domEvent.style.top=(parseInt(this.domEvent.style.top) -iy + oy) + 'px'; this.domEvent.style.left=(parseInt(this.domEvent.style.left) -ix + ox) + 'px'; this.domCross.style.visibility='visible'; this.domExtents.style.border='1px solid white'; this.domEvent.style.border='none'; } else { this.domExtents.style.width=parseInt(width+0.5) + "px"; this.domExtents.style.height=parseInt(height+0.5) + "px"; this.domEvent.style.width=parseInt(width+0.5) + "px"; this.domEvent.style.height=parseInt(height+0.5) + "px"; this.domCross.style.visibility='hidden'; this.domExtents.style.border='1px solid red'; this.domEvent.style.border='1px solid red'; this.domEvent.style.visibility='visible'; this.domExtents.style.visibility='visible'; }}; kaKeymap.prototype.onclick=function(e) { e=(e)?e:((event)?event:null); this.kaKeymap.centerMap(e);}; kaKeymap.prototype.centerMap=function(e) { var pos=this.aPixPos( e.clientX, e.clientY ); this.kaMap.zoomTo(pos[0],pos[1]);}; kaKeymap.prototype.aPixPos=function( x, y ) { var obj=this.domObj; var offsetLeft=0; var offsetTop=0; while (obj) { offsetLeft +=parseFloat(obj.offsetLeft); offsetTop +=parseFloat(obj.offsetTop); obj=obj.offsetParent; } var pX=x - offsetLeft ; var pY=y - offsetTop ; pX=parseFloat(this.aExtents[0] + (this.cellWidth *pX)); pY=parseFloat(this.aExtents[3] - (this.cellHeight *pY)); return [pX,pY];}; kaKeymap.prototype.mousedown=function(e) { e=(e)?e:((event)?event:null); this.kaKeymap.domEvent.style.top="0px"; this.kaKeymap.domEvent.style.left="0px"; this.kaKeymap.domEvent.style.width=this.kaKeymap.domObj.style.width; this.kaKeymap.domEvent.style.height=this.kaKeymap.domObj.style.height; this.kaKeymap.domExtents.init=1; this.kaKeymap.domExtents.oX=e.clientX; this.kaKeymap.domExtents.oY=e.clientY; var amount=50; this.kaKeymap.domExtents.style.backgroundColor='pink'; this.kaKeymap.domExtents.style.opacity=amount/100; if (this.kaKeymap.kaMap.isIE4) { this.kaKeymap.domExtents.style.filter="Alpha(opacity="+amount+")"; } e=null;}; kaKeymap.prototype.mouseup=function(e) { if(this.kaKeymap.domExtents.init) { e=(e)?e:((event)?event:null); this.kaKeymap.domExtents.style.backgroundColor='transparent'; this.kaKeymap.domExtents.style.opacity=1; if (this.kaKeymap.kaMap.isIE4) { this.kaKeymap.domExtents.style.filter="Alpha(opacity=100)"; } this.kaKeymap.domExtents.init=0; var cG=this.kaKeymap.geoCentCoord(); this.kaKeymap.kaMap.zoomTo(cG[0],cG[1]); }}; kaKeymap.prototype.mousemove=function(e) { e=(e)?e:((event)?event:null); if(this.kaKeymap.domExtents.init) { var xMov=(this.kaKeymap.domExtents.oX-e.clientX); var yMov=(this.kaKeymap.domExtents.oY-e.clientY); var oX=this.kaKeymap.pxExtent[0]; var oY=this.kaKeymap.pxExtent[1]; var nX=oX-xMov; var nY=oY-yMov; this.kaKeymap.domExtents.oX=e.clientX; this.kaKeymap.domExtents.oY=e.clientY; this.kaKeymap.pxExtent[0]=nX; this.kaKeymap.pxExtent[1]=nY; if(this.kaKeymap.domCross.style.visibility=='visible') { var ix=parseInt(this.kaKeymap.domCross.style.width)/2; var iy=parseInt(this.kaKeymap.domCross.style.height)/2; var ox=this.kaKeymap.pxExtent[2]/2; var oy=this.kaKeymap.pxExtent[3]/2; this.kaKeymap.domExtents.style.top=parseInt((nY+0.5)-iy+oy) + "px"; this.kaKeymap.domExtents.style.left=parseInt((nX+0.5)-ix+ox) + "px"; } else { this.kaKeymap.domExtents.style.top=parseInt(nY+0.5) + "px"; this.kaKeymap.domExtents.style.left=parseInt(nX+0.5) + "px"; } }}; kaKeymap.prototype.geoCentCoord=function() { var cpX=this.pxExtent[0] + this.pxExtent[2]/2; var cpY=this.pxExtent[1] + this.pxExtent[3]/2; var cX=this.aExtents[0] + (this.cellWidth *cpX); var cY=this.aExtents[3] - (this.cellHeight *cpY); return [cX,cY];};function theZoomedLayer(oKaMap, nFactor, zoomDirection){ goQueueManager.enqueue( 15000, null, zoomedLayerStopWatch, [null] ); this.kaMap=oKaMap; var removed=removeZoomedLayer(this.kaMap); if(document.ballisticReady){ goQueueManager.enqueue( 60000, null, removeZoomedLayer, [this.kaMap] ); this.nFactor=nFactor; this.kaMap.theZoomedLayer=this.kaMap.theInsideLayer.cloneNode(true); this.kaMap.theZoomedLayer.id='theZoomedLayer'; this.kaMap.theZoomedLayer.kaMap=this.kaMap; this.kaMap.theZoomedLayer.style.zIndex=0; this.kaMap.theZoomedLayer.ondblclick=kaMap_ondblclick; this.kaMap.domObj.appendChild(this.kaMap.theZoomedLayer); this.layerChildNodes=this.kaMap.theZoomedLayer.childNodes; this.vpWidthCenter=-1*(this.kaMap.viewportWidth/2); this.vpHeightCenter=-1*(this.kaMap.viewportHeight/2); this.ilCenterX=parseInt(this.kaMap.theInsideLayer.style.left) + this.vpWidthCenter; this.ilCenterY=parseInt(this.kaMap.theInsideLayer.style.top) + this.vpHeightCenter; this.incriment=1; for(var z=1; z <=this.incriment; z++){ var nFactor=(this.nFactor/this.incriment)*z; goQueueManager.enqueue( z*40, this, this.zoomLayer, [nFactor] ); } document.ballisticReady=false; goQueueManager.enqueue( 15000, null, zoomedLayerStopWatch, [null] ); } }; theZoomedLayer.prototype.zoomLayer=function (nFactor){ var zoomLeft=(this.ilCenterX * nFactor) - this.vpWidthCenter; var zoomTop=(this.ilCenterY * nFactor) - this.vpHeightCenter; this.kaMap.theZoomedLayer.style.left=zoomLeft + 'px'; this.kaMap.theZoomedLayer.style.top=zoomTop + 'px'; for(layerNode in this.layerChildNodes){ if(this.layerChildNodes[layerNode].className=='mapLayer'){ var aTileNodes=this.layerChildNodes[layerNode].childNodes; for(var t=0; t < aTileNodes.length; t++){ if(!aTileNodes[t].startLeft && !aTileNodes[t].startTop){ aTileNodes[t].startLeft=aTileNodes[t].style.left; aTileNodes[t].startTop=aTileNodes[t].style.top; } aTileNodes[t].style.width=Math.round(this.kaMap.tileWidth * nFactor) + 'px'; aTileNodes[t].style.height=Math.round(this.kaMap.tileHeight * nFactor) + 'px'; aTileNodes[t].style.left=Math.round(parseInt(aTileNodes[t].startLeft) * nFactor) + 'px'; aTileNodes[t].style.top=Math.round(parseInt(aTileNodes[t].startTop) * nFactor) + 'px'; } } } };var KAMAP_MOUSE_TRACKER=gnLastEventId ++; function kaMouseTracker( oKaMap ) { kaTool.apply( this, [oKaMap] ); this.name='kaMouseTracker'; this.bInfoTool=true; for (var p in kaTool.prototype) { if (!kaMouseTracker.prototype[p]) kaMouseTracker.prototype[p]=kaTool.prototype[p]; }}; kaMouseTracker.prototype.onmousemove=function(e) { e=(e)?e:((event)?event:null); var x=e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)); var y=e.pageY || (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop)); var a=this.kaMap.adjustPixPosition( x,y ); var p=this.kaMap.pixToGeo( a[0], a[1] ); this.kaMap.triggerEvent(KAMAP_MOUSE_TRACKER, {x:p[0], y:p[1]}); return false;};function arunaNavBar(oKaMap){ this.kaMap=oKaMap; var self=this; this.oMap=this.kaMap.getCurrentMap(); this.fractions=parseInt(this.oMap.aScales.length - 1); $('.slider').css("height", (this.fractions + 1) * 15 + "px"); this.startPos=this.getScaleIndex() * 15; this.kaMap.registerForEvent( KAMAP_SCALE_CHANGED, this, this.scaleChanged ); $('.slider').Slider( { accept : '.indicator', fractions : this.fractions, onSlide : function( cordx, cordy) { var iZoomPos=parseInt(cordy / (100 / self.fractions) - self.fractions) / -1; document.getElementById('cordy').value=iZoomPos; self.zoomBy(iZoomPos); }, values: [ [0,this.startPos] ] } ); $('#sliderOut').click( function(){ self.kaMap.zoomOut(); } ); $('#sliderIn').click( function(){ self.kaMap.zoomIn(); } ); $('#sliderUp').click( function(){ self.slideBy(0,256); } ); $('#sliderDown').click( function(){ self.slideBy(0,-256); } ); $('#sliderLeft').click( function(){ self.slideBy(256,0); } ); $('#sliderReset').click( function(){ getFullExtent(); } ); $('#sliderRight').click( function(){ self.slideBy(-256,0); } ); } arunaNavBar.prototype.getScaleIndex=function(){ var currentScale=this.kaMap.getCurrentScale(); return this.fractions - this.kaMap.indexInArray(this.oMap.aScales,currentScale); }; arunaNavBar.prototype.slideBy=function(x,y){ this.kaMap.slideBy(x,y);}; arunaNavBar.prototype.zoomBy=function(iZoomPos){ if(this.oMap.aScales[iZoomPos] !=this.kaMap.getCurrentScale()){ this.kaMap.zoomToScale(this.oMap.aScales[iZoomPos]); }}; arunaNavBar.prototype.scaleChanged=function(){ var currentScale=this.kaMap.getCurrentScale(); var scaleIndex=this.kaMap.indexInArray(this.oMap.aScales,currentScale); var adjust=document.getElementById('cordy').value - scaleIndex; if(adjust !=0){ $('.slider').SliderSetValues( [ [0,adjust * 15] ] ); }}; function arunaLegend(oKaMap){ this.kaMap=oKaMap; this.domObj=$('#arunaLegend').element(); this.aLegendGroups=[]; this.aLayers=[]; this.initialized=null; document.aActiveTools.push('arunaLegend'); this.kaMap.registerForEvent( KAMAP_MAP_INITIALIZED, this, this.__Construct ); this.kaMap.registerForEvent( KAMAP_SCALE_CHANGED, this, this.checkLayerScale );} arunaLegend.prototype.__Construct=function(){ if(this.kaMap.initializationState !==0){ this.domObj.innerHTML=''; this.drawHeaderHtml(); this.initialized=true; var currentMap=this.kaMap.getCurrentMap().name; var self=this; $.ajax({ type: "GET", url: "/map/legend/groups", data: null, success: function(msg){ self.processGroups(msg);}}); }}; arunaLegend.prototype.drawHeaderHtml=function(){ var sText="Map Legend"; var div=$.create("div", {"id": "legendHeaderBox", "class": "helpHeaderBox"}, [ "img", {"src": "/images/buttons/help_button.png", "alt": "/map/help/legend/?width=600", "class": "jTip", "id": "legendHelp", "name": "Legend Help Details:", "title":""},[], sText ] ); this.domObj.appendChild(div); JT_init();}; arunaLegend.prototype.processGroups=function(json){ this.setGroupsArray(json); this.drawGroups();}; arunaLegend.prototype.setGroupsArray=function(json){ this.aLegendGroupsObjects=eval("(" + json + ")");}; arunaLegend.prototype.drawGroups=function(){ this.groupWrapperHtml(); var aGroupCellHtml=this.drawGroupCells();}; arunaLegend.prototype.groupWrapperHtml=function(){ this.groupWrapper=$.create("div", {"id": "legendGroupWrapper"}, []); this.domObj.appendChild(this.groupWrapper);}; arunaLegend.prototype.drawGroupCells=function(){ for(var i=0; i < this.aLegendGroupsObjects.length; i++){ var groupCellHtml=this.drawGroupCellHtml(this.aLegendGroupsObjects[i].sGroup, this.aLegendGroupsObjects[i].bVisible); this.groupWrapper.appendChild(groupCellHtml); if(this.aLegendGroupsObjects[i].bVisible){ var oCheck=$(groupCellHtml).find('.legendGroupCheck').element(); oCheck.setAttribute("checked",true); } } this.setGroupCellLogic();}; arunaLegend.prototype.drawGroupCellHtml=function(sGroupName, bGroupVisible){ var div=$.create( "div", {"id": "lgHolder" + sGroupName, "class": "legendGroupCell"}, [ "img", {"id": "lgImg" + sGroupName, "class": "legendGroupTab", "src": "/images/buttons/expand.png", "title": "Click to view layers"}, [], "input", {"type": "checkbox", "id": "lgCheck" + sGroupName, "class": "legendGroupCheck", "title": "Uncheck to hide group"}, [], "img", {"id": "lgFad" + sGroupName, "class": "legendGroupFad", "src": "/images/buttons/faderBox.png", "title": "Click to activate fader bar"}, [], "span", {"id": "lgSpan" + sGroupName}, [sGroupName] ]); return div;}; arunaLegend.prototype.setGroupCellLogic=function(){ var self=this; $(".legendGroupTab").click( function(){ var sGroup=this.id.replace(/lgImg/, ""); if(!getRawObject("lgLayerWrap" + sGroup)){ var layerWrapper=self.layerWrapperHtml(sGroup); this.src='/images/buttons/collapse.png'; var args="group=" + sGroup; $.ajax({ type: "GET", url: "/map/legend/layers", data: args, success: function(json){ self.processLayers(json, sGroup);}}); } else { self.layerWrapperClicked(sGroup, this); } } ); $(".legendGroupCheck").click( function(){ self.groupCheckPressed(this.id.replace(/lgCheck/, ""), this); return; } ); $(".legendGroupFad").click( function(){ self.launchFader(this.id.replace(/lgFad/, ""), this); } ); }; arunaLegend.prototype.groupCheckPressed=function(sGroupName, oCheckBox){ if(oCheckBox.checked){ oCheckBox.checked=true; this.checkVisibleLayers(); this.kaMap.setLayerVisibility( sGroupName, true ); } else { oCheckBox.checked=false; removeZoomedLayer(this.kaMap); this.kaMap.setLayerVisibility( sGroupName, false ); this.checkVisibleLayers(); }}; arunaLegend.prototype.checkVisibleLayers=function(){ var iCheckedGroups=0; $('.legendGroupCheck').each( function(){ if(this.checked){ iCheckedGroups++; } } ); if(iCheckedGroups > 3 && !this.warning){ alert("Having more than three groups visible simultaneously could adversely affect performance in terms of application and download speed when zooming and panning. Unless you are using a fast computer with a fast broadband internet connection it is recommended that you close one group of layers before opening another one."); this.warning=true; }}; arunaLegend.prototype.launchFader=function(sGroupName, oFaderTab){ var text=document.getElementById('lgSpan' + sGroupName); $(text).hide(); var oFader=this.createFaderHtml(sGroupName, oFaderTab); this.createFaderLogic(sGroupName, oFader); }; arunaLegend.prototype.createFaderHtml=function(sGroupName, oFaderTab){ var aXy=this.kaMap.getElementPosition(oFaderTab); var div=$.create( "div", { "id": "lgFadDiv" + sGroupName, "class": "legendFadDiv", "title": "Click to fade" }, [ "div", { "id": "lgFadTab" + sGroupName, "class": "legendFadTab", "title": "Drag me" }, [] ] ); var oSidebar=$("#sideBar").element(); var horScroll=oSidebar.scrollLeft; var verScroll=oSidebar.scrollTop; var horAdj=($.browser.msie) ? 3 + horScroll : -3 + horScroll; var verAdj=($.browser.msie) ? 1 + verScroll : 1 + verScroll; $(div).css("left", (aXy[0] - horAdj) + "px"); $(div).css("top", (aXy[1] - verAdj) + "px"); document.body.appendChild(div); return div; }; arunaLegend.prototype.createFaderLogic=function(sGroupName, oFader){ var self=this; $(oFader).mouseout( function(e){ e=(e)?e:((event)?event:null); var from=(e.srcElement) ? e.srcElement : (e.target) ? e.target : null; var to=e.relatedTarget || e.toElement; if(from.id.indexOf('lgFadDiv') !=-1 && to.id.indexOf('lgFadTab')==-1 || to.id.indexOf('lgHolder') !=-1){ $(oFader).hide(); var text=document.getElementById('lgSpan' + sGroupName); $(text).show(); } } ); var oLayer=this.kaMap.getLayerByName(sGroupName); try { $('.legendFadDiv').Slider( { accept : '.legendFadTab', fractions : 13, onSlide : function( cordx, cordy) { var iTrans=parseInt(100 - cordx); self.kaMap.setLayerOpacity(sGroupName, iTrans ); }, values: [ [100 - oLayer.opacity,0] ] } ); } catch(err) { return null; } }; arunaLegend.prototype.processLayers=function(json, sGroup){ var aLegendLayers=this.setLayersArray(json); var sGroupDivId='lgHolder' + sGroup; var oGroupDiv=getRawObject('lgHolder' + sGroup); this.drawLayers(aLegendLayers, oGroupDiv, sGroup);}; arunaLegend.prototype.setLayersArray=function(json){ return eval("(" + json + ")");}; arunaLegend.prototype.drawLayers=function(aLegendLayers, oGroupDiv, sGroup){ var layerWrapperHtml=getRawObject("lgLayerWrap" + sGroup); layerWrapperHtml.innerHTML=""; var aLayerCellHtml=this.drawLayerCells(layerWrapperHtml, aLegendLayers);}; arunaLegend.prototype.layerWrapperHtml=function(sGroup){ var oGroupDiv=getRawObject('lgHolder' + sGroup); var layerWrapper=$.create("div", {"id": "lgLayerWrap" + sGroup, "class": "legendLayerWrapper"}, []); oGroupDiv.appendChild(layerWrapper); var loadImg=$.create( "img", {"id": "lgLoader" + sGroup, "class": "lgLoaderBar", "src": "/images/loaders/loader_bar_gray.gif"}, [] ); layerWrapper.appendChild(loadImg); return layerWrapper;}; arunaLegend.prototype.drawLayerCells=function(layerWrapperHtml, aLegendLayers){ for(var i=0; i < aLegendLayers.length; i++){ this.aLayers.push(aLegendLayers[i]); var layerCellHtml=this.drawLayerCellHtml(aLegendLayers[i].sLayer, aLegendLayers[i].iSmin, aLegendLayers[i].iSmax); layerWrapperHtml.appendChild(layerCellHtml); this.setLayerCellLogic(layerCellHtml, aLegendLayers[i].sLayer); }}; arunaLegend.prototype.drawLayerCellHtml=function(sLayerName, iScaleMin, iScaleMax){ var div=$.create( "div", {"id": "llHolder" + sLayerName, "class": "legendLayerCell"}, [ "img", {"id": "llImg" + sLayerName, "class": "legendLayerTab", "src": "/images/buttons/expand.png", "title": "Click to view class attributes"}, [], "span", {"id": "llSpan" + sLayerName, "class": "legendLayerSpan", "title": "Click to view layer meta data"}, [sLayerName] ]); var iCurrentScale=this.kaMap.getCurrentScale(); if(iScaleMax && iScaleMax < iCurrentScale || iScaleMin && iScaleMin > iCurrentScale){ $(div).find('.legendLayerSpan').css("color", "#cccccc"); } return div;}; arunaLegend.prototype.setLayerCellLogic=function(layerCellHtml, sLayerName){ var self=this; $(layerCellHtml).find('.legendLayerTab').click( function(){ if(!getRawObject("lgClassWrap" + sLayerName)){ this.src='/images/buttons/collapse.png'; var classWrapper=self.classWrapperHtml(sLayerName); var args="layer=" + sLayerName; $.ajax({ type: "GET", url: "/map/legend/classes", data: args, success: function(json){ self.processClasses(json, sLayerName);}}); } else { self.classWrapperClicked(sLayerName, this); } } ); $(layerCellHtml).find('.legendLayerSpan').click( function(){ drawInfoWindow(sLayerName, self.kaMap); } ); }; arunaLegend.prototype.layerWrapperClicked=function(sGroup, oExpandTab){ var layerWrapper=getRawObject("lgLayerWrap" + sGroup); if($(layerWrapper).css("display") !="none"){ $(layerWrapper).slideUp('fast'); oExpandTab.src='/images/buttons/expand.png'; } else{ $(layerWrapper).slideDown('fast'); oExpandTab.src='/images/buttons/collapse.png'; }}; arunaLegend.prototype.checkLayerScale=function(){ if(this.initialized){ for(var i=0; i < this.aLayers.length; i++){ var span=getRawObject('llSpan' + this.aLayers[i].sLayer); var iCurrentScale=this.kaMap.getCurrentScale(); if(this.aLayers[i].iSmax && this.aLayers[i].iSmax < iCurrentScale || this.aLayers[i].iSmin && this.aLayers[i].iSmin > iCurrentScale){ $(span).css("color", "#cccccc"); } else { $(span).css("color", ""); } } }}; arunaLegend.prototype.processClasses=function(json, sLayer){ var aLegendClasses=this.setClassesArray(json); var sLayerDivId='llHolder' + sLayer; var oLayerDiv=getRawObject('llHolder' + sLayer); this.drawClasses(aLegendClasses, oLayerDiv, sLayer);}; arunaLegend.prototype.setClassesArray=function(json){ return eval("(" + json + ")");}; arunaLegend.prototype.drawClasses=function(aLegendClasses, oLayerDiv, sLayer){ var classWrapperHtml=getRawObject("lgClassWrap" + sLayer); classWrapperHtml.innerHTML=""; var aClassCellHtml=this.drawClassCells(classWrapperHtml, aLegendClasses);}; arunaLegend.prototype.classWrapperHtml=function(sLayer){ var oLayerDiv=getRawObject('llHolder' + sLayer); var classWrapper=$.create("div", {"id": "lgClassWrap" + sLayer, "class": "legendClassWrapper"}, []); oLayerDiv.appendChild(classWrapper); var loadImg=$.create( "img", {"id": "lgLoader" + sLayer, "class": "lgLoaderBar", "src": "/images/loaders/loader_bar_gray.gif"}, [] ); classWrapper.appendChild(loadImg); return classWrapper;}; arunaLegend.prototype.drawClassCells=function(classWrapperHtml, aLegendClasses){ for(var i=0; i < aLegendClasses.length; i++){ var classCellHtml=this.drawClassCellHtml(aLegendClasses[i].sClass, aLegendClasses[i].sImgUrl); classWrapperHtml.appendChild(classCellHtml); }}; arunaLegend.prototype.drawClassCellHtml=function(sClassName, iImgUrl){ var div=$.create( "div", {"id": "lcHolder" + sClassName, "class": "legendClassCell"}, [ "img", {"id": "lcImg" + sClassName, "class": "legendClassImg", "src": iImgUrl}, [], "span", {"id": "lcSpan" + sClassName, "class": "legendClassSpan"}, [sClassName] ]); return div;}; arunaLegend.prototype.classWrapperClicked=function(sLayerName, oExpandTab){ var classWrapper=getRawObject("lgClassWrap" + sLayerName); if($(classWrapper).css("display") !="none"){ $(classWrapper).slideUp('fast'); oExpandTab.src='/images/buttons/expand.png'; } else{ $(classWrapper).slideDown('fast'); oExpandTab.src='/images/buttons/collapse.png'; }};function arunaMetaData(layerName, oKaMap){ this.kaMap=oKaMap; this.layerName=layerName; this.domObj=$("#infoWindow").element(); var jInfoWindow=$("#infoWindow"); var loader=$.create("img", {"src": "/images/loaders/bigrotation2.gif", "class": "loadGifInfoWindow"}, []); jInfoWindow.empty(); this.domObj.appendChild(loader); jInfoWindow.show(); call('/map/metadata/metadata/?layerName=' + this.layerName,this,this.recieveResults ); return this;}; arunaMetaData.prototype.metaConstruct=function (oDiv, domObj){ var container=new divConstruct(domObj, 'metaContainer', null); var header=new divConstruct(container, 'metaHeader', null); var body=new divConstruct(container, 'metaBody', null); var minImage=new imgConstruct(header,'minImage', null, '/images/buttons/expand.png'); minImage.body=body; minImage.onclick=this.expandCollapse; minImage.status='collapsed'; var headerText=new textNodeConstruct(header, null, null, oDiv.header.value); for(node in oDiv.nodes){ var layer=new divConstruct(body, 'layer', null); layer.style.display='none'; var nodeName=new divConstruct(layer, 'nodeName', null); nodeName.innerHTML=oDiv.nodes[node].name; var nodeValue=new divConstruct(layer, 'nodeValue', null); var nodeValueText=oDiv.nodes[node].value; if(nodeValueText==""){ nodeValueText="Unknown"; } nodeValue.innerHTML=nodeValueText; } }; arunaMetaData.prototype.headerConstruct=function(){ var headerObj=new closeHeader(this.domObj, 'metaHeaderClass','metaDivClass',this.layerName + ' Layer Meta Data');}; arunaMetaData.prototype.recieveResults=function (json){ $(".loadGifInfoWindow").hide(); var oMetaData=eval("(" + json + ")"); if( oMetaData.length > 0 ){ this.headerConstruct(); for(oDiv in oMetaData){ this.metaConstruct(oMetaData[oDiv], this.domObj); } } else{ $("#infoWindow").hide(); alert("Sorry there is no meta data available for this layer."); }}; arunaMetaData.prototype.expandCollapse=function(){ var aChildNodes=this.body.childNodes; if(this.status=='expanded'){ this.status='collapsed'; this.src='/images/buttons/expand.png'; for(var i=0; i < aChildNodes.length; i++){ aChildNodes[i].style.display='none'; } } else{ this.status='expanded'; this.src='/images/buttons/collapse.png'; for(var i=0; i < aChildNodes.length; i++){ aChildNodes[i].style.display=''; } } }; inputManipulating=function(){ var iBuffer=0, bEdit=false; var self=this; this.browser={ version: (navigator.userAgent.toLowerCase().match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1], safari: /webkit/.test( navigator.userAgent.toLowerCase() ), opera: /opera/.test( navigator.userAgent.toLowerCase() ), msie: /msie/.test( navigator.userAgent.toLowerCase() ) && !/opera/.test( navigator.userAgent.toLowerCase() ), mozilla: /mozilla/.test( navigator.userAgent.toLowerCase() ) && !/(compatible|webkit)/.test( navigator.userAgent.toLowerCase() ) }; this.cancelBubbling=function(e){ e=(e)?e:((event)?event:null); e.cancelBubble=true; e.returnValue=false; if (e.stopPropogation) { e.stopPropogation(); } if (e.preventDefault) { e.preventDefault(); } }; this.addDomListener=function(domObj, type, callback){ if(domObj.addEventListener){ domObj.addEventListener(type, callback, false); } else { domObj.attachEvent("on" + type, callback); } }; this.addValue=function (valObj){ self.addDomListener( valObj.domObjInput, "click", function(e){ var tmpOpt=[], enabled=false; for(var j=0 ; j < valObj.tmpOpt ; j++){ if(valObj.input[j].value) enabled=true; } if(enabled){ for(var i=1 ; i <=valObj.tmpOpt ; i++){ tmpOpt[i]=document.createElement('option'); (valObj.input[i-1].value)? tmpOpt[i].text=valObj.input[i-1].value : tmpOpt[i].text="N/A"; valObj.input[i-1].value=""; if(bEdit){ valObj.select[i-1].remove(tmpIndex); (self.browser.mozilla)? valObj.select[i-1].add(tmpOpt[i], valObj.select[i-1].options[tmpIndex]) : valObj.select[i-1].add(tmpOpt[i], tmpIndex); (iBuffer <=valObj.tmpOpt)? iBuffer++ : 0; } else{ (self.browser.mozilla) ? valObj.select[i-1].add(tmpOpt[i], null) : valObj.select[i-1].add(tmpOpt[i]); } valObj.input[i-1].focus(); if(iBuffer > valObj.tmpOpt)bEdit=false; } } self.cancelBubbling(e); } ); }; this.selectValue=function(obj, valObj, domObjAdd){ self.addDomListener( obj.opt1, "click", function(e){ domObjAdd.value="Update"; for(var j=0 ; j < obj.opt1.length ; j++){ obj.opt2.options[j].selected=false; if(obj.opt3) obj.opt3.options[j].selected=false; if(obj.opt1.options[j].selected){ bEdit=true; iBuffer=1; tmpIndex=j; valObj.input[0].value=valObj.select[0].options[j].text; valObj.input[1].value=valObj.select[1].options[j].text; if(valObj.input[2]) valObj.input[2].value=valObj.select[2].options[j].text; obj.opt2.options[j].selected=true; if(obj.opt3) obj.opt3.options[j].selected=true; } } } ); }; this.removeValue=function(obj, valObj, domObjRemove, domObjAdd){ self.addDomListener( domObjRemove, "click", function(e){ for(var i=0; i< obj.opt1.length; i++){ if(obj.opt1.options[i].selected){ obj.opt1.remove(i); obj.opt2.remove(i); if(obj.opt3)obj.opt3.remove(i); } } valObj.input[0].value=""; valObj.input[1].value=""; if(valObj.input[2]) valObj.input[2].value=""; self.cancelBubbling(e); domObjAdd.value="Add"; } ); }; this.setMultipleValue=function(myEvent){ var tmpIndex, tmpText, myOutput, myIndicator, myAchievements, myActivity, myProgress, myDocument, myOpt1, myOpt2, myOpt3, myOpt4, myOpt5, myOpt6, myOpt7, myOpt8; myOutput=document.getElementById('myOutput'); myIndicator=document.getElementById('myIndicator'); myAchievements=document.getElementById('myAchievements'); myActivity=document.getElementById('myActivity'); myProgress=document.getElementById('myProgress'); myDocument=document.getElementById('myDocument'); myOpt1=document.getElementById('mySelect1'); myOpt2=document.getElementById('mySelect2'); myOpt3=document.getElementById('mySelect3'); myOpt4=document.getElementById('mySelect4'); myOpt5=document.getElementById('mySelect5'); myOpt6=document.getElementById('mySelect6'); myOpt7=document.getElementById('mySelect7'); myOpt8=document.getElementById('mySelect8'); var valObj1={}; var Obj1={}, obj2={}, obj3={}; valObj1.domObjInput=document.getElementById('add'); valObj1.tmpOpt=3; valObj1.input=[myOutput, myIndicator, myAchievements]; valObj1.select=[myOpt1, myOpt2, myOpt3]; self.addValue(valObj1); Obj1.opt1=myOpt1; Obj1.opt2=myOpt2; Obj1.opt3=myOpt3; self.selectValue(Obj1, valObj1, document.getElementById('add')); self.removeValue(Obj1, valObj1, document.getElementById('removeOutput'), document.getElementById('add')); obj2.opt1=myOpt2; obj2.opt2=myOpt1; obj2.opt3=myOpt3; self.selectValue(obj2, valObj1, document.getElementById('add')); self.removeValue(obj2, valObj1, document.getElementById('removeOutput'), document.getElementById('add')); obj3.opt1=myOpt3; obj3.opt2=myOpt1; obj3.opt3=myOpt2; self.selectValue(obj3, valObj1, document.getElementById('add')); self.removeValue(obj3, valObj1, document.getElementById('removeOutput'), document.getElementById('add')); var valObj_1={}; var Obj_1={}, obj_2={}, obj_3={}; valObj_1.domObjInput=document.getElementById('addActivity'); valObj_1.tmpOpt=2; valObj_1.input=[myActivity, myProgress, false]; valObj_1.select=[myOpt4, myOpt5, false]; self.addValue(valObj_1); Obj_1.opt1=myOpt4; Obj_1.opt2=myOpt5; Obj_1.opt3=false; self.selectValue(Obj_1, valObj_1, document.getElementById('addActivity')); self.removeValue(Obj_1, valObj_1, document.getElementById('removeActivity'), document.getElementById('addActivity')); obj_2.opt1=myOpt5; obj_2.opt2=myOpt4; obj_2.opt3=false; self.selectValue(obj_2, valObj_1, document.getElementById('add')); self.removeValue(obj_2, valObj_1, document.getElementById('removeActivity'), document.getElementById('addActivity')); self.addDomListener( document.getElementById('addDocument'), "click", function(e){ var doc={}; var fileName, fileSize, tmpMyOpt=document.createElement('option'); if(myDocument.value){ $("#loading") .ajaxStart( function(){ $(this).show(); } ) .ajaxComplete( function(){ $(this).hide(); } ); $.ajaxFileUpload ( { url:'/admin/form/uploadFile', secureuri:false, fileElementId:'fileToUpload', dataType: 'json', success: function (data, status) { fileName=data.msg['fileName']; fileSize=(data.msg['fileSize']/1024).toFixed(3) + "KB"; (myDocument.value)? doc.description=myDocument.value : tmpMyOpt.text="N/A"; doc.fileName=fileName; doc.fileSize=fileSize; tmpMyOpt.text=doc.description; myDocument.value=""; (self.browser.mozilla) ? myOpt6.add(tmpMyOpt, null) : myOpt6.add(tmpMyOpt); myDocument.focus(); var tmpMyOpt2=document.createElement('option'); tmpMyOpt2.text=fileName; (self.browser.mozilla) ? myOpt7.add(tmpMyOpt2, null) : myOpt7.add(tmpMyOpt2); var tmpMyOpt3=document.createElement('option'); tmpMyOpt3.text=fileSize; (self.browser.mozilla) ? myOpt8.add(tmpMyOpt3, null) : myOpt8.add(tmpMyOpt3); }, error: function (data, status, e) { alert("Files not support or already exist"); } } ); }else alert("give file a description"); self.cancelBubbling(e); document.getElementById('addDocument').value='Add'; } ); self.addDomListener( document.getElementById('removeDocument'), "click", function(e){ for(var i=0; i< myOpt6.length; i++){ if(myOpt6.options[i].selected){ file=myOpt7.options[i].text; myOpt6.remove(i); myOpt7.remove(i); myOpt8.remove(i); $.ajax({ type: "POST", url: "/admin/form/deleteFile", data: "file="+ file, success: function(){ alert("File successfully removed."); } }); myDocument.value=""; document.getElementById('addDocument').value='Add'; } self.cancelBubbling(e); } } ); self.addDomListener( document.getElementById('mySelect6'), "click", function(e){ var domObj; for(var i=0; i< myOpt6.length; i++){ myOpt7.options[i].selected=false; myOpt8.options[i].selected=false; if(myOpt6.options[i].selected){ bEdit=true; iBuffer=1; tmpIndex=i; myOpt7.options[i].selected=true; myOpt8.options[i].selected=true; } } } ); self.addDomListener( document.getElementById('mySelect7'), "click", function(e){ var domObj, file; for(var i=0; i< myOpt7.length; i++){ myOpt6.options[i].selected=false; myOpt8.options[i].selected=false; if(myOpt7.options[i].selected){ bEdit=true; iBuffer=1; tmpIndex=i; file=myOpt7.options[i].text; window.open("/admin/form/downLoadFile/?file="+ file); myOpt6.options[i].selected=true; myOpt8.options[i].selected=true; } } } ); self.addDomListener( document.getElementById('mySelect8'), "click", function(e){ var domObj; for(var i=0; i< myOpt8.length; i++){ myOpt6.options[i].selected=false; myOpt7.options[i].selected=false; if(myOpt8.options[i].selected){ bEdit=true; iBuffer=1; tmpIndex=i; myOpt6.options[i].selected=true; myOpt7.options[i].selected=true; } } } ); }; this.processSelect=function(arrSelectVal){ var arrHiddenVal=new Array(); for(var i=0 ; i < arrSelectVal.length ; i++){ arrHiddenVal[i]=new Array(); for(var j=0 ; j < arrSelectVal[i].length ; j++){ arrHiddenVal[i][j]=arrSelectVal[i].options[j].text; } } return arrHiddenVal; }; }; function groupFormInit(){ var arrHiddenValue, myData, myEvent, domObjBody; arrHiddenValue=[]; myData=new inputManipulating(); domObjBody=document.getElementById("myBody"); if(myData.browser.mozilla) domObjBody.style.overflow="scroll"; myData.setMultipleValue(myEvent); myData.addDomListener( document.getElementById('Submit'), "click", function(e){ var selectVal=[], arrHiddenVal=[]; selectVal[0]=document.getElementById('mySelect1'); selectVal[1]=document.getElementById('mySelect2'); selectVal[2]=document.getElementById('mySelect3'); selectVal[3]=document.getElementById('mySelect4'); selectVal[4]=document.getElementById('mySelect5'); selectVal[5]=document.getElementById('mySelect6'); selectVal[6]=document.getElementById('mySelect7'); selectVal[7]=document.getElementById('mySelect8'); arrHiddenVal=myData.processSelect(selectVal); for(var i=0 ; i < arrHiddenVal.length ; i++ ){ document.getElementById('hiddenID'+ (i+1)).value=arrHiddenVal[i]; } var i=0; if(document.getElementById('programme').value==""){ i=i + 1; } if(document.getElementById('component').value==""){ i=i + 1; } if(document.getElementById('agency').value==""){ i=i + 1; } if(document.getElementById('personName').value==""){ i=i + 1; } if(document.getElementById('startDate').value==""){ i=i + 1; } if(document.getElementById('endDate').value==""){ i=i + 1; } if(i !=0){ alert("please fill in all the required information fields (*)"); myData.cancelBubbling(e); } } ); }; function processRecordInit(action){ var domObj=window.opener; var myData=new inputManipulating(); if(action==='delete'){ if(window.opener){ window.opener.userHasDeletedPoint(); } } if(window.opener){ window.opener.userHasSubmittedForm(); } myData.addDomListener( document.getElementById('closeForm'), 'click', function(e){ window.close(); } ); } function groupFormShowInit(){ var domObjEdit, domObjDel, myEvent, myData, domObjBody; myData=new inputManipulating(); domObjBody=document.getElementById("myBody"); if(myData.browser.mozilla) domObjBody.style.overflow="scroll"; domObjEdit=document.getElementById('edit'); domObjDel=document.getElementById('delete'); if(document.getElementById('writePermission').value==='false'){ domObjEdit.setAttribute("disabled",''); domObjDel.setAttribute("disabled",''); }else{ myData.addDomListener( domObjEdit, 'click', function(e){ var outDomFset, actDomFset, docDomFset; var selectVal=[], arrHiddenVal=[]; myData.setMultipleValue(); document.getElementById('programme').removeAttribute('disabled'); document.getElementById('component').removeAttribute('disabled'); document.getElementById('agency').removeAttribute('disabled'); document.getElementById('personName').removeAttribute('disabled'); document.getElementById('contactNo').removeAttribute('disabled'); document.getElementById('partner').removeAttribute('disabled'); document.getElementById('startDate').removeAttribute('disabled'); document.getElementById('endDate').removeAttribute('disabled'); document.getElementById('objectiveComp').removeAttribute('disabled'); document.getElementById('objectiveLoc').removeAttribute('disabled'); document.getElementById('fundSource').removeAttribute('disabled'); document.getElementById('mySelect1').removeAttribute('disabled'); document.getElementById('mySelect2').removeAttribute('disabled'); document.getElementById('mySelect3').removeAttribute('disabled'); document.getElementById('mySelect4').removeAttribute('disabled'); document.getElementById('mySelect5').removeAttribute('disabled'); document.getElementById('mySelect6').removeAttribute('disabled'); document.getElementById('mySelect7').removeAttribute('disabled'); document.getElementById('mySelect8').removeAttribute('disabled'); outDomFset=document.getElementById('fieldset_output'); outDomFset.removeAttribute("style"); outDomFset.setAttribute("style","width:400px; height:150pdx;"); document.getElementById('tdOutput').appendChild(outDomFset); actDomFset=document.getElementById('fieldset_activity'); actDomFset.removeAttribute("style"); actDomFset.setAttribute("style","width:400px; height:150pdx;"); document.getElementById('tdAct').appendChild(actDomFset); docDomFset=document.getElementById('fieldset_doc'); docDomFset.removeAttribute("style"); docDomFset.setAttribute("style","width:400px; height:150pdx;"); document.getElementById('tdDoc').appendChild(docDomFset); if(domObjEdit.value==='Edit Form'){ myData.cancelBubbling(e); domObjEdit.setAttribute("value","Save Record"); }else{ selectVal[0]=document.getElementById('mySelect1'); selectVal[1]=document.getElementById('mySelect2'); selectVal[2]=document.getElementById('mySelect3'); selectVal[3]=document.getElementById('mySelect4'); selectVal[4]=document.getElementById('mySelect5'); selectVal[5]=document.getElementById('mySelect6'); selectVal[6]=document.getElementById('mySelect7'); selectVal[7]=document.getElementById('mySelect8'); arrHiddenVal=myData.processSelect(selectVal); for(var i=0 ; i < arrHiddenVal.length ; i++ ){ document.getElementById('hiddenID'+ (i+1)).value=arrHiddenVal[i]; } } var formControl=document.getElementById('createForm'); formControl.setAttribute("action","/admin/form/editRecordProcess"); } ); myData.addDomListener( document.getElementById('delete'), "click", function(e){ var x=window.confirm("Are you sure you want to delete this record?"); if (x){ var formControl=document.getElementById('createForm'); formControl.setAttribute("action","/admin/form/deleteRecord?"+ document.getElementById('point_gid'). value + "&point_table="+document.getElementById('point_table'). value + "&poinId="+ document.getElementById('poinTableId').value +"" ); }else{ myData.cancelBubbling(e); } } ); } }if(typeof(iMonth)=="undefined")iMonth=new Date().getMonth();if(typeof(iYear)=="undefined")iYear=new Date().getFullYear();if(typeof(iDay)=="undefined")iDay=new Date().getDate();if(typeof(itype)=="undefined")itype="loose";if(typeof(imaxDays)=="undefined")imaxDays=330;if(typeof(stDay)=="undefined")startDay=iDay;if(typeof(stMonth)=="undefined")startMonth=iMonth;if(typeof(stYear)=="undefined")startYear=iYear;if(typeof(addZero)=="undefined")addZero=true;if(typeof(offX)=="undefined")offX=10;if(typeof(offY)=="undefined")offY=-10;if(typeof(formatInputs)=="undefined")formatInputs=1;if(typeof(formatSplitter)=="undefined")formatSplitter="-";if(typeof(monthFormat)=="undefined")monthFormat="mmm";if(typeof(yearFormat)=="undefined")yearFormat="yyyy";if(typeof(folowMouse)=="undefined")folowMouse=true;if(typeof(formatType)=="undefined")formatType=yearFormat+formatSplitter+monthFormat+formatSplitter+"dd";if(typeof(callNotice)=="undefined")callNotice="fallsilent()";if(window.addEventListener)window.addEventListener("load",createBase,false);else if(window.attachEvent)window.attachEvent("onload",createBase);else if(document.getElementById)window.onload=createBase;document.onmousemove=getMouseXY;var IE=document.all?true:false;if(!IE)document.captureEvents(Event.MOUSEMOVE);var tempX=0;var tempY=0;function getMouseXY(e){if(IE){tempX=event.clientX+document.body.scrollLeft;tempY=event.clientY+document.body.scrollTop}else{tempX=e.pageX;tempY=e.pageY}if(tempX<0){tempX=0}if(tempY<0){tempY=0}return true}; function getScrollXY(){var scrOfX=0,scrOfY=0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft}return[scrOfX,scrOfY]}; var d=document;function cel(obj){return d.createElement(obj)}function sa(obj,atname,atprop){return obj.setAttribute(atname,atprop)}function appendc(obj,elem){return obj.appendChild(elem)}function cNode(obj,txt){return obj.appendChild(d.createTextNode(txt))}function getID(elem){return d.getElementById(elem)}var DayCol=new Array("M","T","W","T","F","S","S");var MonthCol=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");function getDaysInMonth(mnt,yr){var DaysInMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);if(mnt==1)DaysInMonth[1]=((yr%400==0)||((yr%4==0)&&(yr%100!=0)))?29:28;return DaysInMonth[mnt]}; var cw={currMonth:iMonth,currYear:iYear,currDay:iDay,selMonth:iMonth,selYear:iYear,selDay:iDay,config:itype,maxDays:imaxDays,stMonth:startMonth,stYear:startYear,stDay:startDay,endMonth:11,endYear:iYear,endDay:31,addZ:addZero,setMarks:function(){if(this.config=='strict'){this.stDay=iDay;this.stMonth=iMonth;this.stYear=iYear;this.getEnd()}},getConfMonths:function(){if(this.config=='strict')cw.setMarks();mthCol=cel("ul");mthCol.id="months";k=0;for(i=0;i<12;i++){mth=cel("li");if(cw.isValidMonth(i)){mth.className="months";if(cw.isCurrentMonth(i))mth.className="currMonth";mtha=cel("a");mtha.href="javascript:modMonth("+this.selYear+","+i+")";mtha.innerHTML=MonthCol[i];appendc(mth,mtha)}else{mth.className="monthDisabled";mth.innerHTML=MonthCol[i]}appendc(mthCol,mth)}cw.setBrowseYears();return mthCol},getConfDays:function(){dayCol=cel("ul");dayCol.id="days";for(i=0;i<7;i++){dayCell=cel("li");dayCell.className="headDay";dayCell.innerHTML=DayCol[i];appendc(dayCol,dayCell)}var iFirstDay=new Date(this.selYear,this.selMonth,1).getDay();iFirstDay--;if(iFirstDay<0){iFirstDay=6}for(i=0;i<iFirstDay;i++){dayCell=cel('li');dayCell.className="dayBlank";dayCell.innerHTML="&nbsp;";appendc(dayCol,dayCell)}for(i=1;i<=getDaysInMonth(this.selMonth,this.selYear);i++){dayCell=cel('li');if(cw.isValidDate(i)){dayCell.className="dayNormal";if(cw.isWeekend(i))dayCell.className="dayWeekend";if(cw.isCurrentDay(i))dayCell.className="dayCurrent";dayLink=cel('a');dayLink.href="javascript: newDay("+i+");fillBackDate("+i+","+this.selMonth+","+this.selYear+")";dayLink.innerHTML=i;appendc(dayCell,dayLink)}else{dayCell.className="dayDisabled";dayCell.innerHTML=i}appendc(dayCol,dayCell)}return dayCol},getEnd:function(){imaxD=imaxDays-(getDaysInMonth(this.stMonth,this.stYear)-this.stDay);tmpM=this.stMonth;tmpY=this.stYear;tmpD=this.stDay;i=0;while(imaxD>=getDaysInMonth(tmpM,tmpY)){tmpM++;if(tmpM>11){tmpM=0;tmpY++}tmpD=imaxD-=getDaysInMonth(tmpM,tmpY)}tmpM++;if(tmpM>11){tmpM=0;tmpY++}this.endMonth=tmpM;this.endDay=tmpD;this.endYear=tmpY},isValidDate:function(tDay){if(this.config=="loose")return true;if(this.selYear==this.stYear){if(this.selMonth<this.stMonth)return false;if(this.selMonth==this.stMonth&&tDay<this.stDay)return false}if(this.selYear==this.endYear){if(this.selMonth>this.endMonth)return false;if(this.selMonth==this.endMonth&&tDay>this.endDay)return false}if(this.selYear==this.endYear&&this.selYear==this.stYear){if(this.selMonth>this.endMonth||this.selMonth<this.stMonth)return false}if(this.selYear>this.endYear)return false;return true},isWeekend:function(tDay){sun=new Date(this.selYear,this.selMonth,tDay).getDay();if(sun==6||sun==0)return true;return false},isCurrentDay:function(tDay){if(this.selDay==tDay)return true;return false},setBrowseYears:function(){brsY=cel('li');brsY.className="yearBrowse";if(this.selYear<=this.stYear&&this.config=="strict"){backB=cel('span')}else{backB=cel('a');backB.href="javascript: modYear(-1)"}backB.innerHTML="&laquo";yText=cel("b");yText.innerHTML=cw.selYear;if(this.selYear>=this.endYear&&this.config=="strict")fwdB=cel('span');else{fwdB=cel('a');fwdB.href="javascript: modYear(1)"}fwdB.innerHTML="&raquo;";appendc(brsY,backB);appendc(brsY,yText);appendc(brsY,fwdB);appendc(mthCol,brsY)},isValidMonth:function(m){if(this.config=="loose")return true;else{if(this.selYear<this.stYear)return false;if(this.selYear==this.stYear&&m<this.stMonth)return false;if(this.selYear>this.endYear)return false;if(this.selYear==this.endYear&&m>this.endMonth)return false}return true},isCurrentMonth:function(i){if(i==this.selMonth)return true;return false}}; cw.setMarks();function createBase(){var el=cel('div');el.id="calendar";el.style.display="none";if(typeof(elToAppend)=="undefined")tDocument=document.getElementsByTagName('body').item(0);else{var tt=elToAppend;tDocument=document.getElementById(tt)}appendc(tDocument,el)}; function createCalendarElements(){var el='calendar';var calCon=cel('div');calCon.id="elements";while(document.getElementById(el).firstChild)document.getElementById(el).removeChild(document.getElementById(el).firstChild);appendc(document.getElementById(el),calCon);mthCol=cw.getConfMonths();appendc(calCon,mthCol);dayStruct=cw.getConfDays();appendc(calCon,dayStruct);closeBtn=cel('div');closeBtn.id="closeBtn";closeBtna=cel('a');closeBtna.href="javascript: closeCalendar()";closeBtna.innerHTML="close";appendc(closeBtn,closeBtna);appendc(document.getElementById(el),closeBtn)}; function modMonth(newY,newM){cw.selYear=newY;cw.selMonth=newM;createCalendarElements()};function newDay(newD){cw.selDay=newD;createCalendarElements()};function modYear(way){cw.selYear=parseInt(cw.selYear)+parseInt(way);createCalendarElements()}; var datas;var elem1;var elem2;var elem3;var mA=0;var yA=0;var mm=new Array('mm','mmm');var yy=new Array('yy','yyyy');function fPopCalendar(param1,param2,param3){tmpString=new String();if(formatInputs==1){elem1=param1;tmpString=document.getElementById(elem1).value}if(formatInputs==2){elem1=param1;elem2=param2;tmpString=document.getElementById(elem1).value+formatSplitter+document.getElementById(elem2).value}if(formatInputs==3){elem1=param1;elem2=param2;elem3=param3;tmpString=document.getElementById(elem1).value+formatSplitter+document.getElementById(elem2).value+formatSplitter+document.getElementById(elem3).value}datas=tmpString.split(formatSplitter);tmpo=formatType.split(formatSplitter);dC="";tC="";if(datas.length==tmpo.length){for(i=0;i<datas.length;i++){if(datas[i].length<2)datas[i]="0"+datas[i];dC+=datas[i];tC+=tmpo[i]}if(dC.length==tC.length)orderData()}else datas=new Array(cw.selDay,cw.selMonth,cw.selYear);createCalendarElements();offsets=getScrollXY();document.getElementById('calendar').style.display="block";if(folowMouse){var browser=navigator.appName;if(browser=="Microsoft Internet Explorer"){document.getElementById('calendar').style.left=parseInt(tempX)+parseInt(offX)+parseInt(offsets[0])+'px';document.getElementById('calendar').style.top=parseInt(tempY)+parseInt(offY)+parseInt(offsets[1])+'px'}else{document.getElementById('calendar').style.left=parseInt(tempX)+parseInt(offX)+'px';document.getElementById('calendar').style.top=parseInt(tempY)+parseInt(offY)+'px'}}order=new String(formatType).split(formatSplitter);for(i=0;i<mm.length;i++){for(j=0;j<order.length;j++){if(mm[i]==order[j])mA=i;if(yy[i]==order[j])yA=i}}}; function orderData(){order=new String(formatType).split(formatSplitter);for(i=0;i<order.length;i++){for(j=0;j<mm.length;j++){if(mm[j]==order[i]){cw.selMonth=datas[i];if(cw.selMonth.slice(0,1)==0)cw.selMonth=parseInt(cw.selMonth.slice(1,cw.selMonth.length))-1;else if(cw.selMonth.length<3)cw.selMonth=parseInt(cw.selMonth)-1;if(j==1){for(k=0;k<MonthCol.length;k++){if(MonthCol[k].toLowerCase()==cw.selMonth.toLowerCase()){cw.selMonth=k;break}}}}if(yy[j]==order[i]){cw.selYear=datas[i];if(cw.selYear.slice(0,1)==0)cw.selYear=parseInt(cw.selYear.slice(1,cw.selYear.length));if(j==0)cw.selYear=2000+parseInt(cw.selYear)}}if(order[i].toLowerCase()=='dd'){cw.selDay=datas[i];if(cw.selDay.slice(0,1)==0)cw.selDay=parseInt(cw.selDay.slice(1,cw.selDay.length))}}}; function fillBackDate(tDay,tMonth,tYear){if(mA==1)tMonth=MonthCol[tMonth];if(mA==0){tMonth++;if(tMonth<10&&cw.addZ==true)tMonth="0"+tMonth}if(yA==0)tYear=new String(tYear).slice(2,4);if(tDay<10&&cw.addZ==true){tDay="0"+tDay}if(formatType.slice(0,2)!="dd"){tmpDATA=tDay;tDay=tYear;tYear=tmpDATA}if(formatInputs==1){document.getElementById(elem1).value=tDay+formatSplitter+tMonth+formatSplitter+tYear}if(formatInputs==2){document.getElementById(elem1).value=tDay;document.getElementById(elem2).value=tMonth+formatSplitter+tYear}if(formatInputs==3){document.getElementById(elem1).value=tDay;document.getElementById(elem2).value=tMonth;document.getElementById(elem3).value=tYear}setTimeout(callNotice,0);closeCalendar()};function closeCalendar(){var el='calendar';document.getElementById(el).style.display="none"};function fallsilent(){};