/**********************************************************************
 * Icepick Communications Ltd. 
 * customised by Brendan Cervin: The original uncompressed version of 
 * each file mentioned here can be found at http://www.mapfinder.co.nz/{name}.js
 * There have been some modifications to the kaMap.js code. Copyright of
 * original author follows.
 *
 * 
 * this file is compressed and contains some work 
 * by Pual Spencer, copyright follows. 
 *
 * kaTool.js
 * kaZoomer.js
 * xhr.js
 * kaMap.js
 * author: Paul Spencer (pspencer@dmsolutions.ca)
 *
 * The original kaMap code was written by DM Solutions Group.  
 * bug fixes contributed by Lorenzo Becchi and Andrea Cappugi
 *
 * TODO:
 * 
 *   - convert to prototype
 *   - code refactoring for simplification/speed
 *   - code refactoring
 *
 **********************************************************************
 *
 * Copyright (c) 2005, DM Solutions Group Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 *
 **********************************************************************/
/* ***********************************************************
this file also contains, DHTMLapi.js, copyright follows:
Example 4-3 (DHTMLapi.js)
"Dynamic HTML:The Definitive Reference"
2nd Edition
by Danny Goodman
Published by O'Reilly & Associates  ISBN 1-56592-494-0
http://www.oreilly.com
Copyright 2002 Danny Goodman.  All Rights Reserved.
************************************************************ */
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;} if (elem.clip && elem.clip.width) { result = elem.clip.width;} 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;} if (elem.clip && elem.clip.height) { result = elem.clip.height;} 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 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_CONTEXT_MENU = gnLastEventId ++; var KAMAP_DISPLAY_PANEL = gnLastEventId ++; var KAMAP_HIDE_PANEL = gnLastEventId ++; var KAMAP_DATA_DRAWN = gnLastEventId ++; var KAMAP_DATA_UPDATED = gnLastEventId ++; var MAP_POINTS_SELECTED = 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.server = ''; 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 = safeParseInt(this.domObj.style.width); this.viewportHeight = safeParseInt(this.domObj.style.height); 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 = this.server+'images/a_pixel.gif'; this.imgErrors = new Array(); this.aMaps = new Array(); this.nBuffer = 1; this.middleX = null; this.middleY = null; this.baseURL = ''; this.cellSize = null; this.gImageID = 0; this.eventManager = new _eventManager(); this.as=slideid=null; this.accelerationFactor=100; this.pixelsPerStep = 15; this.timePerStep = 20; this.pin_canvas = null; this.panel_canvas = null; this.aObjects = []; this.aCanvases = []; this.layersHidden = false; this.aTools = []; for (var i=0; i<gnLastEventId; i++)
{ this.registerEventID( i );}
this.createLayers(); if('locatorMapDiv' == szID){ aszScales=new Array(32000000,8500000,4000000,1000000,300000,100000,40000,10000,3500); this.middleX=1550000; this.middleY=5450000; this.init_map = null; this.init_map = new _map( 'NZTM_V4', 'New Zealand', 0, 3, aszScales); this.init_map.setDefaultExtents(1000000,4700000,2100000,6200000); this.init_map.setBackgroundColor('rgb(151,180,198)'); this.init_map.addLayer(new _layer( '__base__', true, 100, 'gif',false, new Array(1,1,1,1,1,1,1,1,1))); this.init_map.resolution = 96; this.addMap( this.init_map );}else{ aszScales=new Array(8500000,4000000,1000000,300000,100000,40000,18000,10000,3500); this.middleX=1550000; this.middleY=5450000; this.init_map = null; this.init_map = new _map( 'NZTM_V4', 'New Zealand', 0, 3, aszScales); this.init_map.setDefaultExtents(1000000,4700000,2100000,6200000); this.init_map.setBackgroundColor('rgb(151,180,198)'); this.init_map.addLayer(new _layer( '__base__', true, 100, 'gif',false, new Array(1,1,1,1,1,1,1,1,1))); this.init_map.resolution = 96; this.aerial_map = null; this.aerial_map = new _map( 'aerial', 'New Zealand', 0, 3, aszScales); this.aerial_map.setDefaultExtents(1000000,4700000,2100000,6200000); this.aerial_map.setBackgroundColor('rgb(151,180,198)'); this.aerial_map.addLayer(new _layer( 'aerial', true, 100, 'jpeg',false, new Array(1,1,1,1,1,1,1,1,1))); this.aerial_map.resolution = 96; this.addMap( this.init_map ); this.addMap( this.aerial_map );}
if (arguments.length == 4){ xpos = arguments[1]; ypos = arguments[2]; zoom = arguments[3]; this.init_map.aZoomTo = new Array(xpos,ypos,zoom);}
this.tileWidth=300; this.tileHeight=300; this.tileURL = 'tile.php'; this.mapLive = false;}
kaMap.prototype.makeMapLive = function(){ var oMap = this.getCurrentMap(); var layers = oMap.getLayers(); for( var k=0; k<layers.length; k++)
{ var d = layers[k].domObj; layers[k].setMapLive(true); 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 = img.temp;}
}
}
}
kaMap.prototype.pauseMapLive = function(){ var oMap = this.getCurrentMap(); var layers = oMap.getLayers(); for( var k=0; k<layers.length; k++)
{ layers[k].setMapLive(false);}
}
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();}
this.cellSize = (newScale*(0.0254 / oMap.resolution)); 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.getCurrentPos = 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; var x = ((maxx - minx)/2)+minx; var y = ((maxy - miny)/2)+miny; var scale = this.getCurrentScale(); return [x, y, scale];}
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*(0.0254 / oMap.resolution)); 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.zoomToExtentsUpdate = function(id, extents)
{ var minx = extents[0]; var maxx = extents[2]; var miny = extents[1]; var maxy = extents[3]; 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*(0.0254 / oMap.resolution)); 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 )
{ var d = document.createElement( 'div' ); d.style.position = 'absolute'; d.style.left = '0px'; d.style.top = '0px'; d.style.width= '100%'; d.style.height = '100%'; d.style.cursor = 'move'; 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'; if(isNaN(top) && isNaN(left) && top > 0 && left > 0){ obj.style.top = top + "px"; obj.style.left = left + "px";}else{ obj.style.top = "0px"; obj.style.left = "0px";}
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 )
{ for (var i=0; i<this.aObjects.length; i++)
{ if (this.aObjects[i] == obj || obj == null)
{ if (!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.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.initialize = function()
{ this.selectMap('NZTM_V4'); 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.ondragstart = new Function([], 'var e=e?e:event;e.cancelBubble=true;e.returnValue=false;return false;');}
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.updateCanvasObjects = function(canvas)
{ for (var i=0; i< canvas.childNodes.length;i++ )
{ var obj = canvas.childNodes[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.checkWrap(); 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; 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)
{ this.style.visibility = 'visible';}
kaMap.prototype.appendRow = function(layer)
{ if (this.nWide == 0)
return; if(arguments.length==1) var layers = Array(layer); else var 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] ); obj.appendChild( img );}
}
this.nHigh = this.nHigh + 1;}
kaMap.prototype.appendColumn = function(layer)
{ if (this.nHigh == 0)
return; if(arguments.length==1) var layers = Array(layer); else var 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 (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; if(arguments.length==1) var layers = Array(layer); else var 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; if(arguments.length==1) var layers = Array(layer); else var 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.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_onkeypress = function( e )
{ if (this.kaMap.currentTool)
this.kaMap.currentTool.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 );}
kaMap_onmousedown = function( e )
{ if (this.kaMap.currentTool)
this.kaMap.currentTool.onmousedown( e );}
kaMap_onmouseup = function( e )
{ if (this.kaMap.currentTool)
this.kaMap.currentTool.onmouseup( e );}
kaMap_onmouseover = function( e )
{ if (this.kaMap.currentTool)
this.kaMap.currentTool.onmouseover( e );}
kaMap_onmouseout = function( e )
{ if (this.kaMap.currentTool)
this.kaMap.currentTool.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 );}
kaMap_onmousewheel = function( e )
{ if (this.kaMap.currentTool)
this.kaMap.currentTool.onmousewheel( 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 (this.currentTool)
{ this.currentTool.deactivate();}
this.currentTool = toolObj; if (this.theInsideLayer)
this.setCursor(this.currentTool.cursor);}
kaMap.prototype.deactivateTool = function( toolObj )
{ 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()
{ 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();}
while (this.xOffset < -(this.nBuffer*this.tileWidth))
{ this.wrapL2R();}
while (this.yOffset > -(this.nBuffer*this.tileHeight))
{ this.wrapB2T();}
while (this.yOffset < -(this.nBuffer*this.tileHeight))
{ this.wrapT2B();}
var layers = this.aMaps[this.currentMap].getLayers(); var layer = layers[0].domObj; var img = layer.childNodes[0].style; this.nCurrentTop = safeParseInt(img.top) + this.yOrigin; this.nCurrentLeft = safeParseInt(img.left) + this.xOrigin;}
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++)
{ if (layers[k].visible){ 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); 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++)
{ if (layers[k].visible){ 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); 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++)
{ if (layers[k].visible){ 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); 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++)
{ if (layers[k].visible){ 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]); 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 (oMap.aZoomTo.length != 0)
{ this.zoomTo(oMap.aZoomTo[0], oMap.aZoomTo[1], oMap.aZoomTo[2]); oMap.aZoomTo.length = 0;}
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].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) + this.nBuffer); var newHigh = Math.ceil((newViewportHeight / this.tileHeight) + 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.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.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.zoomIn = function()
{ this.zoomByFactor(this.aMaps[this.currentMap].zoomIn());}
kaMap.prototype.zoomOut = function()
{ this.zoomByFactor(this.aMaps[this.currentMap].zoomOut());}
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.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(szName,szTitle,nCurrentScale, units, aszScales )
{ this.name = szName; this.title = szTitle; this.aScales = aszScales; this.currentScale = parseFloat(nCurrentScale); this.units = units; this.resolution = 72; this.aLayers = []; this.defaultExtents = []; this.currentExtents = []; this.maxExtents = []; this.backgroundColor = '#ffffff'; this.version = "0"; this.aZoomTo = []; this.kaMap = null;}
_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 ); layer.setQueryable( bQueryable );}
_map.prototype.setLayerVisibility = function( name, bVisible )
{ var layer = this.getLayer( name ); layer.setVisibility( bVisible );}
_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( szName, bVisible, opacity, imageformat, bQueryable , scales)
{ this.mapLive = false; this.name = szName; this.visible = bVisible; this.domObj = null; this._map = null; this.imageformat = imageformat; this.queryable = bQueryable; this.queryState = bQueryable; if(scales)this.scales = scales; else this.scales=Array(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); this.toLoad=0;}
_layer.prototype.setMapLive = function(set)
{ this.mapLive = set;}
_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.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 szForce = ''; var szLayers = ''; if (arguments[1] || this.tileSource == 'redraw') { szForce = '&force=true';}
var szGroup = '&g='+img.layer.domObj.id; var szScale = '&s='+this._map.aScales[this._map.currentScale]; var src = this._map.kaMap.server+ this._map.kaMap.tileURL+ '?map='+this._map.name+ '&t='+t+ '&l='+l+ szScale+szForce+szGroup+szImageformat;}
if ((this.isIE4) && (image_format.toLowerCase() == "png24")) { img.style.visibility = 'hidden'; img.src = this._map.kaMap.aPixel.src; img.style.width = this.tileWidth+"px"; img.style.height = this.tileHeight+"px"; img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')";} else { if (img.src != src) { img.temp = src; img.style.visibility = 'hidden'; if(this.mapLive){ 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]);}
}
_layer.prototype.setZIndex = function( zIndex )
{ this.zIndex = zIndex; if (this.domObj)
{ this.domObj.style.zIndex = zIndex;}
}
_layer.prototype.setTileLayer = function()
{ var szForce = ''; var szLayers = ''; this.loaded=0; if (arguments[0])
szForce = '&force=true'; var szGroup = "&g="+this.name; var szScale = '&s='+this._map.aScales[this._map.currentScale]; var szImageformat = ''; var image_format = ''; if (this.imageformat && this.imageformat != '')
{ image_format = this.imageformat; szImageformat = '&i='+image_format;}
for(i=0;i<this.domObj.childNodes.length;i++){ img=this.domObj.childNodes[i]; var l = safeParseInt(img.style.left) + this._map.kaMap.xOrigin; var t = safeParseInt(img.style.top) + this._map.kaMap.yOrigin; var src = this._map.kaMap.server+ this._map.kaMap.tileURL+ '?map='+this._map.name+ '&t='+t+ '&l='+l+ szScale+szForce+szGroup+szImageformat; if ((this.isIE4) && (image_format.toLowerCase() == "png24")){ img.style.visibility = 'hidden'; img.src = this._map.kaMap.aPixel.src; img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')";}else if (img.src != src){ img.temp = src; img.style.visibility = 'hidden'; if(this.mapLive){ img.src = src;}
}
}
}
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;}
}


var kaCurrentTool = null; function kaTool( oKaMap )
{ this.kaMap = oKaMap; this.kaMap.registerTool( this ); this.name = 'kaTool';}
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.onmousewheel = function(e)
{ e = (e)?e:((event)?event:null); var wheelDelta = e.wheelDelta ? e.wheelDelta : e.detail*-1; if (wheelDelta > 0)
this.kaMap.zoomIn(); else
this.kaMap.zoomOut();}
kaTool.prototype.adjustPixPosition = function( x, y )
{ var obj = this.kaMap.domObj; var offsetLeft = 0; var offsetTop = 0; while (obj)
{ offsetLeft += parseInt(obj.offsetLeft); offsetTop += parseInt(obj.offsetTop); obj = obj.offsetParent;}
var pX = parseInt(this.kaMap.theInsideLayer.style.left) + offsetLeft - this.kaMap.xOrigin - x; var pY = parseInt(this.kaMap.theInsideLayer.style.top) + offsetTop - this.kaMap.yOrigin - y; return [pX,pY];}
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:
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 = 'move'; this.cursorDrag = 'move'; this.cursorSelect = 'crosshair'; this.cursor = this.cursorNormal; this.activeImage = this.kaMap.server + 'images/mapToolBar/button_pan_3.png'; this.disabledImage = this.kaMap.server + 'images/mapToolBar/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 || e.target.id == this.kaMap.theInsideLayer.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); newTop = newTop - this.lasty + e.clientY; newLeft = newLeft - this.lastx + e.clientX; this.kaMap.theInsideLayer.style.top=newTop + 'px'; this.kaMap.theInsideLayer.style.left=newLeft + 'px'; this.kaMap.checkWrap.apply(this.kaMap, []); this.lastx=e.clientX; this.lasty=e.clientY; return false;}
kaNavigator.prototype.onmousedown = function(e)
{ if(this.cursor == this.cursorSelect){ this.dataInput(e); this.cursor = this.cursorNormal; this.kaMap.setCursor(this.cursorNormal); return;}
e = (e)?e:((event)?event:null); if (e.button==2)
{ return this.cancelEvent(e);}
else
{ this.cursor = this.cursorNormal; this.kaMap.setCursor(this.cursorNormal); if (this.kaMap.isIE4) document.onkeydown = kaTool_redirect_onkeypress; document.onkeypress = kaTool_redirect_onkeypress; this.bMouseDown=true; this.lastx=e.clientX; this.lasty=e.clientY; e.cancelBubble = true; e.returnValue = false; if (e.stopPropogation) e.stopPropogation(); if (e.preventDefault) e.preventDefault(); return false;}
}
kaNavigator.prototype.onmouseup = function(e)
{ this.cursor = this.cursorNormal; this.kaMap.setCursor(this.cursorNormal); e = (e)?e:((event)?event:null); this.bMouseDown=false; this.kaMap.showLayers(); this.kaMap.triggerEvent(KAMAP_EXTENTS_CHANGED, this.kaMap.getGeoExtents()); return false;}
kaNavigator.prototype.ondblclick = function(e)
{ e = (e)?e:((event)?event:null); var posX = 0, posY = 0; if (e.pageX && e.pageY) { posX = e.pageX; posY = e.pageY;} else { var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
var scrollX = iebody.scrollLeft?iebody.scrollLeft:(window.pageXOffset?window.pageXOffset:0); var scrollY = iebody.scrollTop?iebody.scrollTop:(window.pageYOffset?window.pageYOffset:0); posX = e.clientX + scrollX; posY = e.clientY + scrollY;}
var aPixPos = this.adjustPixPosition( posX, posY); var vpX = this.kaMap.viewportWidth/2; var vpY = this.kaMap.viewportHeight/2; var dx = parseInt(this.kaMap.theInsideLayer.style.left) - this.kaMap.xOrigin - vpX - aPixPos[0]; var dy = parseInt(this.kaMap.theInsideLayer.style.top) - this.kaMap.yOrigin - vpY - aPixPos[1]; this.kaMap.slideBy(-dx, -dy);}
kaNavigator.prototype.startDataCollection = function(e)
{ alert("Please click on the map to set the position of this Listing"); this.cursor = this.cursorSelect; this.kaMap.setCursor(this.cursorSelect);}
kaNavigator.prototype.dataInput = function(e)
{ e = (e)?e:((event)?event:null); if (e.pageX && e.pageY) { posX = e.pageX; posY = e.pageY;} else { var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
var scrollX = iebody.scrollLeft?iebody.scrollLeft:(window.pageXOffset?window.pageXOffset:0); var scrollY = iebody.scrollTop?iebody.scrollTop:(window.pageYOffset?window.pageYOffset:0); posX = e.clientX + scrollX; posY = e.clientY + scrollY;}
var aPixPos = this.adjustPixPosition( posX, posY); var coords = this.kaMap.pixToGeo( aPixPos[0], aPixPos[1] ); this.kaMap.triggerEvent( KAMAP_DATA_UPDATED, coords );}


function kaZoomer(oKaMap)
{ this.kaMap = oKaMap; this.root_url = this.kaMap.server; this.domObj = oKaMap.domObj; this.nZoomImageHeight = 15; this.left = 7; this.top = 7; this.right = null; this.bottom = null; this.zoomControlObj = null; this.road = kaZoomer_road; this.aerial = kaZoomer_aerial; this.draw = kaZoomer_draw; this.update = kaZoomer_update; this.kaMap.registerForEvent( KAMAP_MAP_INITIALIZED, this, this.draw );}
function kaZoomer_setPosition( left, top, right, bottom )
{ this.left = left; this.top = top; this.right = right; this.bottom = bottom; if (this.zoomControlObj != null)
{ if (this.left != null)
{ oZoomControl.style.left = this.left + 'px';}
else if (this.right != null)
{ oZoomControl.style.right = this.right + 'px';}
if (this.top != null)
{ oZoomControl.style.top = this.top + 'px';}
else if (this.bottom != null)
{ oZoomControl.style.bottom = this.bottom + 'px';}
}
}
function kaZoomer_update()
{ var nThumbHeight = dd.elements.zoomTrack.div.elementHeight; var nTrackTop = dd.elements.zoomTrack.y; var oKaMap = dd.elements.zoomTrack.div.kaZoomer.kaMap; var oMap = oKaMap.getCurrentMap(); var nCurrentScale = parseInt(oMap.currentScale) + 1; var nScales = oMap.getScales().length; var nTrackHeight = this.nZoomImageHeight * nScales; var nPos = (nScales-nCurrentScale)*nThumbHeight; dd.elements.zoomThumb.moveTo(dd.elements.zoomThumb.x,nTrackTop + nPos);}
function kaZoomer_draw()
{ this.kaMap.deregisterForEvent( KAMAP_MAP_INITIALIZED, this, this.draw); var oMap = this.kaMap.getCurrentMap(); var nScales = oMap.getScales().length; var nCurrentScale = oMap.currentScale; var nTrackHeight = this.nZoomImageHeight * nScales; var nTrackMaxPosition = this.nZoomImageHeight * (nScales - 1); var nInitialPosition = dd.Int(this.nZoomImageHeight * (nScales - nCurrentScale - 1)); var szThumbImg = this.root_url+'images/mapToolBar_2/slider_button.png'; var szTrackTopImg = this.root_url+'images/mapToolBar_2/slider_tray_top.png'; var szTrackBottomImg = this.root_url+'images/mapToolBar_2/slider_tray_bottom.png'; this.zoomControlObj = document.createElement('div'); this.zoomControlObj.id = 'zoomControl'; this.zoomControlObj.style.cursor = 'default'; this.zoomControlObj.style.position = 'absolute'; if (this.left != null)
{ this.zoomControlObj.style.left = this.left + 'px';}
else if (this.right != null)
{ this.zoomControlObj.style.right = this.right + 'px';}
if (this.top != null)
{ this.zoomControlObj.style.top = this.top + 'px';}
else if (this.bottom != null)
{ this.zoomControlObj.style.bottom = this.bottom + 'px';}
var directionPanelHeight = 45; this.zoomControlObj.style.width = 26 + "px"; this.zoomControlObj.style.height = (directionPanelHeight+ nTrackHeight + 2 * this.nZoomImageHeight + 6) + "px"; this.zoomControlObj.style.zIndex = 300; this.zoomControlObj.kaZoomer = this; this.kaMap.domObj.appendChild(this.zoomControlObj); var oZoomTrack = document.createElement( 'div' ); oZoomTrack.id = 'zoomTrack'; oZoomTrack.kaZoomer = this; oZoomTrack.style.position = 'absolute'; oZoomTrack.style.left = '15px'; oZoomTrack.style.top = (directionPanelHeight + 18)+'px'; oZoomTrack.style.height = parseInt(nTrackHeight) + 'px'; oZoomTrack.style.width = '8px'; oZoomTrack.style.backgroundImage = "url("+this.root_url+"images/mapToolBar_2/slider_tray_fill.png)"; oZoomTrack.elementHeight = this.nZoomImageHeight; oZoomTrack.onclick = kaZoomer_zoomTo; this.zoomControlObj.appendChild(oZoomTrack); var oZoomThumb = document.createElement( 'div' ); oZoomThumb.id = 'zoomThumb'; oZoomThumb.style.position = 'absolute'; oZoomThumb.style.height = '14px'; oZoomThumb.style.width = '15px'; oZoomThumb.innerHTML = '<img src="' + szThumbImg +'" border="0" width="14" height="15" class="png24">'; this.zoomControlObj.appendChild(oZoomThumb); var oZoomTrackTop = document.createElement( 'div' ); oZoomTrackTop.id = 'zoomTrackTop'; oZoomTrackTop.style.position = 'absolute'; oZoomTrackTop.style.left = '15px'; oZoomTrackTop.style.top = (directionPanelHeight+ 14)+'px'; oZoomTrackTop.style.width = '8px'; oZoomTrackTop.style.height = '4px'; oZoomTrackTop.innerHTML = '<img src="' + szTrackTopImg +'" border="0" width="8" height="4" class="png24">'; this.zoomControlObj.appendChild(oZoomTrackTop); var oZoomTrackBottom = document.createElement( 'div' ); oZoomTrackBottom.id = 'zoomTrackBottom'; oZoomTrackBottom.style.position = 'absolute'; oZoomTrackBottom.style.left = '15px'; oZoomTrackBottom.style.top = (directionPanelHeight+18 + nTrackHeight) + 'px'; oZoomTrackBottom.style.width = '8px'; oZoomTrackBottom.style.height = '4px'; oZoomTrackBottom.innerHTML = '<img src="' + szTrackBottomImg +'" border="0" width="8" height="4" class="png24">'; this.zoomControlObj.appendChild(oZoomTrackBottom); var zoomEast = document.createElement('div'); zoomEast.id = 'zoomEast'; zoomEast.style.position = 'absolute'; zoomEast.style.top = '12px'; zoomEast.style.left = '27px'; zoomEast.style.width = '12px'; zoomEast.style.height = '15px'; zoomEast.kaZoomer = this; zoomEast.onclick = kaZoomer_east; zoomEast.innerHTML= "<img src='"+this.root_url+"images/mapToolBar_2/direction_east.png' border='0' width='12' height='15' class='png24'>"; this.zoomControlObj.appendChild(zoomEast); var zoomWest = document.createElement('div'); zoomWest.id = 'zoomWest'; zoomWest.style.position = 'absolute'; zoomWest.style.top = '12px'; zoomWest.style.left = '0px'; zoomWest.style.width = '12px'; zoomWest.style.height = '15px'; zoomWest.kaZoomer = this; zoomWest.onclick = kaZoomer_west; zoomWest.innerHTML= "<img src='"+this.root_url+"images/mapToolBar_2/direction_west.png' border='0' width='12' height='15' class='png24'>"; this.zoomControlObj.appendChild(zoomWest); var zoomCenter = document.createElement('div'); zoomCenter.id = 'zoomCenter'; zoomCenter.style.position = 'absolute'; zoomCenter.style.top = '12px'; zoomCenter.style.left = '13px'; zoomCenter.style.width = '13px'; zoomCenter.style.height = '15px'; zoomCenter.kaZoomer = this; zoomCenter.innerHTML= "<img src='"+this.root_url+"images/mapToolBar_2/direction_center.png' border='0' width='13' height='15' class='png24'>"; this.zoomControlObj.appendChild(zoomCenter); var zoomAerial = document.createElement('div'); zoomAerial.id = 'zoomAerial'; zoomAerial.style.position = 'absolute'; zoomAerial.style.top = '12px'; zoomAerial.style.left = '41px'; zoomAerial.style.width = '34px'; zoomAerial.style.height = '14px'; zoomAerial.kaZoomer = this; zoomAerial.innerHTML= "<a href='javascript: clientMap.showAerial();'><img src='"+this.root_url+"images/mapToolBar_2/photo_button.png' class='png24' border='0' width='34' height='14'></a>"; this.zoomControlObj.appendChild(zoomAerial); var zoomNorth = document.createElement('div'); zoomNorth.id = 'zoomNorth'; zoomNorth.style.position = 'absolute'; zoomNorth.style.top = '0px'; zoomNorth.style.left = '12px'; zoomNorth.style.width = '15px'; zoomNorth.style.height = '12px'; zoomNorth.kaZoomer = this; zoomNorth.onclick = kaZoomer_north; zoomNorth.innerHTML= "<img src='"+this.root_url+"images/mapToolBar_2/direction_north.png' border='0' width='15' height='12' class='png24'>"; this.zoomControlObj.appendChild(zoomNorth); var zoomSouth = document.createElement('div'); zoomSouth.id = 'zoomSouth'; zoomSouth.style.position = 'absolute'; zoomSouth.style.top = '27px'; zoomSouth.style.left = '12px'; zoomSouth.style.width = '15px'; zoomSouth.style.height = '12px'; zoomSouth.kaZoomer = this; zoomSouth.onclick = kaZoomer_south; zoomSouth.innerHTML= "<img src='"+this.root_url+"images/mapToolBar_2/direction_south.png' border='0' width='15' height='12' class='png24'>"; this.zoomControlObj.appendChild(zoomSouth); var oZoomIn = document.createElement('div'); oZoomIn.id = 'zoomIn'; oZoomIn.style.position = 'absolute'; oZoomIn.style.top = directionPanelHeight+'px'; oZoomIn.style.left = '11px'; oZoomIn.style.width = '16px'; oZoomIn.style.height = '14px'; oZoomIn.kaZoomer = this; oZoomIn.onclick = kaZoomer_zoomIn; oZoomIn.innerHTML= "<img src='"+this.root_url+"images/mapToolBar_2/slider_button_zoomin.png' border='0' width='16' height='14' class='png24'>"; this.zoomControlObj.appendChild(oZoomIn); var oZoomOut = document.createElement('div'); oZoomOut.id = 'zoomOut'; oZoomOut.style.position = 'absolute'; oZoomOut.style.top = (directionPanelHeight +23 + nTrackHeight) + 'px'; oZoomOut.style.left = '11px'; oZoomOut.style.width = '16px'; oZoomOut.style.height = '14px'; oZoomOut.kaZoomer = this; oZoomOut.onclick = kaZoomer_zoomOut; oZoomOut.innerHTML= "<img src='"+this.root_url+"images/mapToolBar_2/slider_button_zoomout.png' border='0' width='16' height='14' class='png24'>"; this.zoomControlObj.appendChild(oZoomOut); ADD_DHTML('zoomThumb'+MAXOFFTOP+0+MAXOFFBOTTOM+nTrackMaxPosition+VERTICAL); ADD_DHTML('zoomTrack'+NO_DRAG); dd.elements.zoomThumb.moveTo(dd.elements.zoomTrack.x-3, dd.elements.zoomTrack.y + nInitialPosition); dd.elements.zoomThumb.setZ(dd.elements.zoomTrack.z+1); dd.elements.zoomTrack.addChild('zoomThumb'); dd.elements.zoomThumb.defx = dd.elements.zoomTrack.x-3; dd.elements.zoomThumb.defy = dd.elements.zoomTrack.y; dd.elements.zoomThumb.my_DropFunc = kaZoomer_DropFunc; this.kaMap.registerForEvent( KAMAP_SCALE_CHANGED, this, this.update );}
function kaZoomer_aerial(){ var childList = this.zoomControlObj.childNodes; for(i = 0; i < childList.length; i++){ if(childList[i].id == 'zoomAerial')
var zoomCenter = childList[i];}
zoomCenter.innerHTML= "<a href='javascript: clientMap.showRoad();'><img src='"+this.root_url+"images/mapToolBar_2/map_button.png' class='png24' border='0' width='34' height='14'></a>";}
function kaZoomer_road(){ var childList = this.zoomControlObj.childNodes; for(i = 0; i < childList.length; i++){ if(childList[i].id == 'zoomAerial')
var zoomCenter = childList[i];}
zoomCenter.innerHTML= "<a href='javascript: clientMap.showAerial();'><img src='"+this.root_url+"images/mapToolBar_2/photo_button.png' class='png24' border='0' width='34' height='14'></a>";}
function kaZoomer_DropFunc()
{ var nTrackTop = dd.elements.zoomTrack.y; var nThumbTop = dd.elements.zoomThumb.y - nTrackTop; var nThumbHeight = dd.elements.zoomTrack.div.elementHeight; var nNearestIndex = Math.round(nThumbTop / nThumbHeight); dd.elements.zoomThumb.moveTo(dd.elements.zoomThumb.x,nTrackTop +(nNearestIndex*nThumbHeight)); var oKaMap = dd.elements.zoomTrack.div.kaZoomer.kaMap; var oMap = oKaMap.getCurrentMap(); var nCurrentScale = oMap.getScales()[oMap.aScales.length - nNearestIndex - 1]; oKaMap.zoomToScale(nCurrentScale);}
function kaZoomer_zoomTo( e )
{ e = (e)?e:((event)?event:null); var nClickTop = (e.layerY)?e.layerY:e.offsetY; var oKaZoomer = dd.elements.zoomTrack.div.kaZoomer; var oKaMap = oKaZoomer.kaMap; var oMap = oKaMap.getCurrentMap(); var nScales = oMap.getScales().length; var nTrackHeight = dd.Int(oKaZoomer.nZoomImageHeight) * nScales; var nNearestIndex = Math.floor(nClickTop / nTrackHeight * nScales); var nNewScale = oMap.getScales()[oMap.aScales.length - nNearestIndex - 1]; oKaMap.zoomToScale(nNewScale);}
function kaZoomer_zoomIn()
{ this.kaZoomer.kaMap.zoomIn();}
function kaZoomer_zoomOut()
{ this.kaZoomer.kaMap.zoomOut();}
function kaZoomer_south()
{ this.kaZoomer.kaMap.moveBy(0,-50);}
function kaZoomer_east()
{ this.kaZoomer.kaMap.moveBy(-50,0);}
function kaZoomer_west()
{ this.kaZoomer.kaMap.moveBy(50,0);}
function kaZoomer_north()
{ this.kaZoomer.kaMap.moveBy(0,50);}


function locatorMap(mapFinder, szID )
{ this.kaMap = mapFinder.map; this.clientMapName = mapFinder.dynamicInstanceName; this.domObj = this.kaMap.getRawObject(szID); this.domObj.locatorMap=this; this.width=getObjectWidth(szID); this.height=getObjectHeight(szID); this.domEvent = null; this.pxExtent =null; this.domExtents = null; this.aExtents = null; this.cellWidth = null; this.cellHeight = null; this.keyx = null; this.keyy = null; this.MainScales=new Array(32000000, 8500000,4000000,1000000,300000,100000,40000,10000,3500); this.initialExtents = null; this.Keymap = new kaMap( szID ); this.kaMap.registerForEvent(KAMAP_EXTENTS_CHANGED, this, this.updateExtentKeymap); this.kaMap.registerForEvent(KAMAP_SCALE_CHANGED, this, this.updateScaleKeymap);}
locatorMap.prototype.toggleDisplay = function()
{ background = this.kaMap.getRawObject(this.domObj.id+'Background'); if(background.style.visibility == 'visible'){ this.domObj.style.top = (safeParseInt(this.domObj.style.top) + this.height - 10)+'px'; this.Keymap.domObj.style.width = '0px'; this.Keymap.domObj.style.height = '0px'; this.domObj.style.height = '11px'; this.domObj.style.width = '11px'; this.minMaxIcon.style.top='0px'; this.domObj.style.border = '0px solid #656565'; background.style.visibility = 'hidden'; this.minMaxIcon.innerHTML = '<img onclick="javascript: '+this.clientMapName+'myLocatorMap.toggleDisplay(); return false;" src="'+this.kaMap.server+'images/keymap/show-map.gif" alt="Maximise" unselectable="on"/>';}else{ this.Keymap.domObj.style.width = '140px'; this.Keymap.domObj.style.height = '140px'; this.domObj.style.top = (safeParseInt(this.domObj.style.top) - this.height + 10)+'px'; this.domObj.style.height = '140px'; this.domObj.style.width = '140px'; this.minMaxIcon.style.top='130px'; this.domObj.style.border = '1px solid #656565'; this.Keymap.resize(); background.style.visibility = 'visible'; this.minMaxIcon.innerHTML = '<img onclick="javascript: '+this.clientMapName+'myLocatorMap.toggleDisplay(); return false;" src="'+this.kaMap.server+'images/keymap/hide-map.gif" alt="Minimise" unselectable="on"/>';}
}
locatorMap.prototype.initialize = function( id )
{ this.Keymap.initialize(); this.initialExtents=this.Keymap.getGeoExtents(); this.Keymap.accelerationFactor=1; this.Keymap.pixelsPerStep = 11; this.Keymap.timePerStep = 20; this.minMaxIcon = document.createElement( 'div' ); this.minMaxIcon.id='minMaxIcon'; this.minMaxIcon.style.border = '0px solid #656565'; this.minMaxIcon.style.position = 'absolute'; this.minMaxIcon.style.left='0px'; this.minMaxIcon.style.top='130px'; this.minMaxIcon.style.width='10px'; this.minMaxIcon.unselectable = 'on'; this.minMaxIcon.style.height='10px'; this.minMaxIcon.style.zIndex = 145; this.minMaxIcon.style.cursor = 'default'; this.minMaxIcon.innerHTML = '<img onclick="javascript: '+this.clientMapName+'myLocatorMap.toggleDisplay(); return false;" src="'+this.kaMap.server+'images/keymap/hide-map.gif" alt="Minimise" unselectable="on"/>'; this.domObj.appendChild(this.minMaxIcon); this.domExtents = document.createElement( 'div' ); this.domExtents.locatorMap=this; this.domExtents.style.position = 'absolute'; this.domExtents.id = 'keymapDomExtent'; this.domExtents.style.border = '1px solid #656565'; this.domExtents.style.zIndex = 149; this.domExtents.style.backgroundColor = 'white'; this.domExtents.style.visibility = 'visible'; this.domExtents.unselectable = 'on'; this.domExtents.style.opacity=.40; this.domExtents.style.mozOpacity=.40; this.domExtents.style.filter = "Alpha(opacity=40)"; this.domObj.appendChild(this.domExtents); this.domEvent = document.createElement( 'div' ); this.domEvent.locatorMap=this; if (this.domEvent.addEventListener){ this.domEvent.addEventListener('mousedown', this.mousedown, false); this.domEvent.addEventListener('mouseup', this.mouseup, false); this.domEvent.addEventListener('mousemove', this.mousemove, false); this.domEvent.addEventListener('mouseout', this.mouseup, false);}else{ this.domEvent.onmousedown= this.mousedown; this.domEvent.onmouseup= this.mouseup; this.domEvent.onmousemove= this.mousemove;}
this.domEvent.style.position = 'absolute'; this.domEvent.id = 'keymapDomEvent'; this.domEvent.style.border = '1px solid #656565'; this.domEvent.style.zIndex = 150; this.domEvent.style.top = "0px"; this.domEvent.style.left = "0px"; this.domEvent.style.width = "140px"; this.domEvent.style.height = "140px"; 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=01)"; this.domObj.appendChild(this.domEvent);}
locatorMap.prototype.updateExtentKeymap = function(id, extents)
{ midx = (this.kaMap.viewportWidth/2+this.kaMap.nCurrentLeft- this.kaMap.xOffset)*this.kaMap.cellSize; midy = (this.kaMap.nCurrentTop- this.kaMap.yOffset+ this.kaMap.viewportHeight/2)*this.kaMap.cellSize; this.keyx = (this.Keymap.viewportWidth/2+this.Keymap.nCurrentLeft- this.Keymap.xOffset)*this.Keymap.cellSize; this.keyy = (this.Keymap.nCurrentTop- this.Keymap.yOffset+ this.Keymap.viewportHeight/2)*this.Keymap.cellSize; changex = (midx - this.keyx)/this.Keymap.cellSize; changey = (midy - this.keyy)/this.Keymap.cellSize; tempWidth = (extents[2]-extents[0])/this.Keymap.cellSize; tempHeight = (extents[3]-extents[1])/this.Keymap.cellSize; this.domExtents.style.top = 70-tempHeight/2+"px"; this.domExtents.style.left = 70-tempWidth/2+"px"; this.domExtents.style.width = tempWidth+"px"; this.domExtents.style.height = tempHeight+"px"; this.domEvent.style.top = 70-tempHeight/2+"px"; this.domEvent.style.left = 70-tempWidth/2+"px"; this.domEvent.style.width = tempWidth+"px"; this.domEvent.style.height = tempHeight+"px"; if(Math.abs(changey) < 500 && Math.abs(changex) < 500){ this.Keymap.slideBy(-changex, -changey);}else{ this.Keymap.zoomTo(midx, -midy);}
}
locatorMap.prototype.updateScaleKeymap = function( eventID, scale ){ var scale = this.kaMap.getCurrentScale(); var currentMap = this.Keymap.getCurrentMap(); index = 0; for (x in this.MainScales){ if(this.MainScales[x] == scale){ if(index > 8){ index = 6;}else{ index = index-2;}
if(index < 0){ index = 0;}
this.Keymap.zoomToScale(this.MainScales[index]);}
index++;}
}
locatorMap.prototype.onclick = function(e)
{ e = (e)?e:((event)?event:null); this.locatorMap.centerMap(e);}
locatorMap.prototype.centerMap = function(e)
{ var pos= this.aPixPos( e.clientX, e.clientY ); this.kaMap.zoomTo(pos[0],pos[1]);}
locatorMap.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;}
if(this.kaMap.isIE4 || myKaMap.isIE6CSS){ var pX = x - offsetLeft ; var pY = -(y - offsetTop);}else{ var pX = x - offsetLeft -2 ; var pY = -(y - offsetTop + this.domExtents.style.width)+22;}
pX = parseFloat(this.aExtents[0] + (this.cellWidth *pX)); pY = parseFloat(this.aExtents[3] + (this.cellHeight *pY)); return [pX,pY];}
locatorMap.prototype.mousedown = function(e)
{ e = (e)?e:((event)?event:null); this.locatorMap.domEvent.style.top= "0px"; this.locatorMap.domEvent.style.left= "0px"; this.locatorMap.domEvent.style.width =this.locatorMap.domObj.style.width; this.locatorMap.domEvent.style.height = this.locatorMap.domObj.style.height; this.locatorMap.domExtents.init=1; this.locatorMap.domExtents.oX=e.clientX + this.locatorMap.Keymap.xOffset; this.locatorMap.domExtents.oY=e.clientY + this.locatorMap.Keymap.yOffset; var amount= 50; this.locatorMap.domExtents.style.backgroundColor = 'pink'; this.locatorMap.domExtents.style.opacity=amount/100; this.locatorMap.keyx = (this.locatorMap.Keymap.viewportWidth/2+this.locatorMap.Keymap.nCurrentLeft- this.locatorMap.Keymap.xOffset)*this.locatorMap.Keymap.cellSize; this.locatorMap.keyy = (this.locatorMap.Keymap.nCurrentTop- this.locatorMap.Keymap.yOffset+ this.locatorMap.Keymap.viewportHeight/2)*this.locatorMap.Keymap.cellSize; if (this.locatorMap.kaMap.isIE4)
this.locatorMap.domExtents.style.filter = "Alpha(opacity="+amount+")"; e=null;}
locatorMap.prototype.mouseup = function(e)
{ if(this.locatorMap.domExtents.init)
{ e = (e)?e:((event)?event:null); this.locatorMap.domExtents.style.backgroundColor = 'white'; this.locatorMap.domExtents.style.opacity=.40; if (this.locatorMap.kaMap.isIE4)
this.locatorMap.domExtents.style.filter = "Alpha(opacity=40)"; this.locatorMap.domExtents.init=0; cG=this.locatorMap.geoCentCoord(); changex = (this.locatorMap.keyx - cG[0])/this.locatorMap.kaMap.cellSize; changey = (this.locatorMap.keyy - cG[1])/this.locatorMap.kaMap.cellSize; this.locatorMap.kaMap.slideBy(changex,changey); this.locatorMap.keyx = cG[0]; this.locatorMap.keyy = cG[1];}
}
locatorMap.prototype.mousemove = function(e)
{ xOffset = this.locatorMap.Keymap.xOffset + this.locatorMap.kaMap.xOffset; yOffset = this.locatorMap.Keymap.yOffset + this.locatorMap.kaMap.yOffset; e = (e)?e:((event)?event:null); if(this.locatorMap.domExtents.init)
{ var xMov=(this.locatorMap.domExtents.oX-(e.clientX + this.locatorMap.Keymap.xOffset)); var yMov=(this.locatorMap.domExtents.oY-(e.clientY + this.locatorMap.Keymap.yOffset)); var oX=parseInt(this.locatorMap.domExtents.style.left); var oY=parseInt(this.locatorMap.domExtents.style.top); this.locatorMap.domExtents.style.left = oX-xMov + "px"; this.locatorMap.domExtents.style.top = oY-yMov + "px"; this.locatorMap.domExtents.oX= e.clientX + this.locatorMap.Keymap.xOffset; this.locatorMap.domExtents.oY= e.clientY + this.locatorMap.Keymap.yOffset;}
}
locatorMap.prototype.geoCentCoord=function(){ cX = (parseInt(this.domExtents.style.left)+this.Keymap.nCurrentLeft- this.Keymap.xOffset +parseInt(this.domExtents.style.width)/2)*this.Keymap.cellSize; cY = (this.Keymap.nCurrentTop- this.Keymap.yOffset+ parseInt(this.domExtents.style.top)+parseInt(this.domExtents.style.height)/2)*this.Keymap.cellSize; return [cX,cY];}


var spacer = 'transparentpixel.gif'; var CLONE = 'C10nE'; var COPY = 'C0pY'; var DETACH_CHILDREN = 'd37aCH'; var HORIZONTAL = 'H0r1Z'; var MAXHEIGHT = 'm7x8I'; var MAXOFFBOTTOM = 'm7xd0wN'; var MAXOFFLEFT = 'm7x23Ft'; var MAXOFFRIGHT = 'm7x0Ff8'; var MAXOFFTOP = 'm7xu9'; var MAXWIDTH = 'm7xW1'; var MINWIDTH = 'm1nw1'; var MINHEIGHT = 'm1n8I'; var NO_ALT = 'no81T'; var NO_DRAG = 'N0d4Ag'; var RESET_Z = 'r35E7z'; var RESIZABLE = 'r5IZbl'; var SCALABLE = 'SCLbl'; var SCROLL = 'sC8lL'; var TRANSPARENT = 'dIApHAn'; var VERTICAL = 'V3Rt1C'; var dd_cursors = new Array( 'c:default', 'c:crosshair', 'c:e-resize', 'c:hand', 'c:help', 'c:move', 'c:n-resize', 'c:ne-resize', 'c:nw-resize', 'c:s-resize', 'c:se-resize', 'c:sw-resize', 'c:text', 'c:w-resize', 'c:wait' ); var dd_i = dd_cursors.length; while(dd_i--)
eval('var CURSOR_' + (dd_cursors[dd_i].substring(2).toUpperCase().replace('-', '_')) + ' = "' + dd_cursors[dd_i] + '";'); function WZDD()
{ this.elements = new Array(0); this.obj = null; this.n = navigator.userAgent.toLowerCase(); this.db = (document.compatMode && document.compatMode.toLowerCase() != "backcompat")?
document.documentElement
: (document.body || null); this.op = !!(window.opera && document.getElementById); this.op6 = !!(this.op && !(this.db && this.db.innerHTML)); if (this.op && !this.op6) document.onmousedown = new Function('e', 'if (((e = e || window.event).target || e.srcElement).tagName == "IMAGE") return false;'); this.ie = !!(this.n.indexOf("msie") >= 0 && document.all && this.db && !this.op); this.iemac = !!(this.ie && this.n.indexOf("mac") >= 0); this.ie4 = !!(this.ie && !document.getElementById); this.n4 = !!(document.layers && typeof document.classes != "undefined"); this.n6 = !!(typeof window.getComputedStyle != "undefined" && typeof document.createRange != "undefined"); this.w3c = !!(!this.op && !this.ie && !this.n6 && document.getElementById); this.ce = !!(document.captureEvents && document.releaseEvents); this.px = (this.n4 || this.op6)? '' : 'px'; this.tiv = this.w3c? 40 : 10;}
var dd = new WZDD(); dd.Int = function(d_x, d_y)
{ return isNaN(d_y = parseInt(d_x))? 0 : d_y;}; dd.getWndW = function()
{ return dd.Int( (dd.db && !dd.op && !dd.w3c && dd.db.clientWidth)? dd.db.clientWidth
: (window.innerWidth || 0) );}; dd.getWndH = function()
{ return dd.Int( (dd.db && !dd.op && !dd.w3c && dd.db.clientHeight)? dd.db.clientHeight
: (window.innerHeight || 0) );}; dd.getScrollX = function()
{ return dd.Int(window.pageXOffset || (dd.db? dd.db.scrollLeft : 0));}; dd.getScrollY = function()
{ return dd.Int(window.pageYOffset || (dd.db? dd.db.scrollTop : 0));}; dd.getPageXY = function(d_o)
{ if (dd.n4 && d_o)
{ dd.x = d_o.pageX || 0; dd.y = d_o.pageY || 0;}
else
{ dd.x = dd.y = 0; while (d_o)
{ dd.x += dd.Int(d_o.offsetLeft); dd.y += dd.Int(d_o.offsetTop); d_o = d_o.offsetParent || null;}
}
}; dd.getCssXY = function(d_o)
{ if (d_o.div)
{ if (dd.n4)
{ d_o.cssx = d_o.div.x; d_o.cssy = d_o.div.y;}
else if (dd.ie4)
{ d_o.cssx = d_o.css.pixelLeft; d_o.cssy = d_o.css.pixelTop;}
else
{ d_o.css.left = d_o.css.top = 0 + dd.px; dd.getPageXY(d_o.div); d_o.cssx = d_o.x - dd.x; d_o.cssy = d_o.y - dd.y; d_o.css.left = d_o.cssx + dd.px; d_o.css.top = d_o.cssy + dd.px;}
}
else
{ d_o.cssx = 0; d_o.cssy = 0;}
}; dd.getImgW = function(d_o)
{ return d_o? dd.Int(d_o.width) : 0;}; dd.getImgH = function(d_o)
{ return d_o? dd.Int(d_o.height) : 0;}; dd.getDivW = function(d_o)
{ return dd.Int( dd.n4? (d_o.div? d_o.div.clip.width : 0)
: d_o.div? (d_o.div.offsetWidth || d_o.css.pixelWidth || d_o.css.width || 0)
: 0 );}; dd.getDivH = function(d_o)
{ return dd.Int( dd.n4? (d_o.div? d_o.div.clip.height : 0)
: d_o.div? (d_o.div.offsetHeight || d_o.css.pixelHeight || d_o.css.height || 0)
: 0 );}; dd.getWH = function(d_o)
{ d_o.w = dd.getDivW(d_o); d_o.h = dd.getDivH(d_o); if (d_o.css)
{ d_o.css.width = d_o.w + dd.px; d_o.css.height = d_o.h + dd.px; d_o.dw = dd.getDivW(d_o)-d_o.w; d_o.dh = dd.getDivH(d_o)-d_o.h; d_o.css.width = (d_o.w-d_o.dw) + dd.px; d_o.css.height = (d_o.h-d_o.dh) + dd.px;}
else d_o.dw = d_o.dh = 0;}; dd.getCssProp = function(d_o, d_pn6, d_pstyle, d_pn4)
{ if (d_o && dd.n6) return ''+window.getComputedStyle(d_o, null).getPropertyValue(d_pn6); if (d_o && d_o.currentStyle) return ''+eval('d_o.currentStyle.'+d_pstyle); if (d_o && d_o.style) return ''+eval('d_o.style.'+d_pstyle); if (d_o && dd.n4) return ''+eval('d_o.'+d_pn4); return '';}; dd.getDiv = function(d_x, d_d)
{ d_d = d_d || document; if (dd.n4)
{ if (d_d.layers[d_x]) return d_d.layers[d_x]; for (var d_i = d_d.layers.length; d_i--;)
{ var d_y = dd.getDiv(d_x, d_d.layers[d_i].document); if (d_y) return d_y;}
}
if (dd.ie) return d_d.all[d_x] || null; if (d_d.getElementById) return d_d.getElementById(d_x) || null; return null;}; dd.getImg = function(d_o, d_nm, d_xy, d_w)
{ d_w = d_w || window; var d_img; if (document.images && (d_img = d_w.document.images[d_nm]) && d_img.name == d_nm)
{ if (d_xy)
{ if (dd.n4)
{ dd.getPageXY(d_w); d_o.defx = d_img.x + dd.x; d_o.defy = d_img.y + dd.y;}
else
{ dd.getPageXY(d_img); d_o.defx = dd.x; d_o.defy = dd.y;}
}
return d_img;}
if (dd.n4) for (var d_i = d_w.document.layers.length; d_i--;)
{ var d_y = dd.getImg(d_o, d_nm, d_xy, d_w.document.layers[d_i]); if (d_y) return d_y;}
return null;}; dd.getParent = function(d_o, d_p)
{ if (dd.n4)
{ for (d_p, d_i = dd.elements.length; d_i--;)
{ if (!((d_p = dd.elements[d_i]).is_image) && d_p.div && (d_p.div.document.layers[d_o.name] || d_o.oimg && d_p.div.document.images[d_o.oimg.name]))
d_p.addChild(d_o, d_p.detach, 1);}
}
else
{ d_p = d_o.is_image? dd.getImg(d_o, d_o.oimg.name) : (d_o.div || null); while (d_p && !!(d_p = d_p.offsetParent || d_p.parentNode || null))
{ if (d_p.ddObj)
{ d_p.ddObj.addChild(d_o, d_p.ddObj.detach, 1); break;}
}
}
}; dd.getCmd = function(d_o, d_cmd, d_cmdStr)
{ var d_i = d_o.id.indexOf(d_cmd), d_j, d_y = (d_i >= 0)*1; if (d_y)
{ d_j = d_i+d_cmd.length; if (d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j); d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);}
return d_y;}; dd.getCmdVal = function(d_o, d_cmd, d_cmdStr, int0)
{ var d_i = d_o.id.indexOf(d_cmd), d_j, d_y = (d_o.id.indexOf(d_cmd) >= 0)? dd.Int(d_o.id.substring(d_o.id.indexOf(d_cmd)+d_cmd.length)) : int0? -1 : 0; if (!int0 && d_y || int0 && d_y >= 0)
{ d_j = d_i+d_cmd.length+(""+d_y).length; if (d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j); d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);}
return d_y;}; dd.addElt = function(d_o, d_p)
{ dd.elements[d_o.name] = dd.elements[d_o.index = dd.elements.length] = d_o; if (d_p) d_p.copies[d_o.name] = d_p.copies[d_p.copies.length] = d_o;}; dd.mkWzDom = function()
{ var d_o, d_i = dd.elements.length; while(d_i--) dd.getParent(dd.elements[d_i]); d_i = dd.elements.length; while(d_i--)
{ d_o = dd.elements[d_i]; if (d_o.children && !d_o.parent)
{ var d_j = d_o.children.length; while(d_j--)
d_o.children[d_j].setZ(d_o.z+d_o.children[d_j].z, 1);}
}
}; dd.addProps = function(d_o)
{ var d_i, d_c; if (d_o.is_image)
{ d_o.div = dd.getDiv(d_o.id); if (d_o.div && typeof d_o.div.style != "undefined") d_o.css = d_o.div.style; d_o.nimg = (dd.n4 && d_o.div)? d_o.div.document.images[0] : (document.images[d_o.id+'NImG'] || null); if (d_o.nimg && !d_o.noalt && !dd.noalt)
{ d_o.nimg.alt = d_o.oimg.alt || ''; if (d_o.oimg.title) d_o.nimg.title = d_o.oimg.title;}
d_o.bgColor = '';}
else
{ d_o.bgColor = dd.getCssProp(d_o.div, 'background-color','backgroundColor','bgColor').toLowerCase(); if (dd.n6 && d_o.div)
{ if ((d_c = d_o.bgColor).indexOf('rgb') >= 0)
{ d_c = d_c.substring(4, d_c.length-1).split(','); d_o.bgColor = '#'; for (d_i = 0; d_i < d_c.length; d_i++) d_o.bgColor += parseInt(d_c[d_i]).toString(0x10);}
else d_o.bgColor = d_c;}
}
if (dd.scalable) d_o.scalable = d_o.resizable^1; else if (dd.resizable) d_o.resizable = d_o.scalable^1; d_o.setZ(d_o.defz); d_o.cursor = d_o.cursor || dd.cursor || 'auto'; d_o._setCrs(d_o.nodrag? 'auto' : d_o.cursor); d_o.diaphan = d_o.diaphan || dd.diaphan || 0; d_o.visible = true;}; dd.initz = function()
{ if (!(dd && (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c))) return; if (dd.op6) WINSZ(2); else if (dd.n6 || dd.ie || dd.op && !dd.op6 || dd.w3c) dd.recalc(1); var d_drag = (document.onmousemove == DRAG), d_resize = (document.onmousemove == RESIZE); if (dd.loadFunc) dd.loadFunc(); if (d_drag && document.onmousemove != DRAG) dd.setEvtHdl(1, DRAG); else if (d_resize && document.onmousemove != RESIZE) dd.setEvtHdl(1, RESIZE); if ((d_drag || d_resize) && document.onmouseup != DROP) dd.setEvtHdl(2, DROP); dd.setEvtHdl(0, PICK);}; dd.finlz = function()
{ if (dd.ie && dd.elements)
{ var d_i = dd.elements.length; while (d_i--)
dd.elements[d_i].del();}
}; dd.setEvtHdl = function(d_typ, d_func)
{ if (!d_typ)
{ if (document.onmousedown != d_func) dd.downFunc = document.onmousedown || null; document.onmousedown = d_func;}
else if (d_typ&1)
{ if (document.onmousemove != d_func) dd.moveFunc = document.onmousemove || null; document.onmousemove = d_func;}
else
{ if (document.onmouseup != d_func) dd.upFunc = document.onmouseup || null; document.onmouseup = d_func;}
if (dd.ce)
{ var d_e = (!d_typ)? Event.MOUSEDOWN : (d_typ&1)? Event.MOUSEMOVE : Event.MOUSEUP; d_func? document.captureEvents(d_e) : document.releaseEvents(d_e);}
}; dd.evt = function(d_e)
{ this.but = (this.e = d_e || window.event).which || this.e.button || 0; this.button = (this.e.type == 'mousedown')? this.but
: (dd.e && dd.e.button)? dd.e.button
: 0; this.src = this.e.target || this.e.srcElement || null; this.src.tag = ("" + (this.src.tagName || this.src)).toLowerCase(); this.x = dd.Int(this.e.pageX || this.e.clientX || 0); this.y = dd.Int(this.e.pageY || this.e.clientY || 0); if (dd.ie)
{ this.x += dd.getScrollX() - (dd.ie && !dd.iemac)*1; this.y += dd.getScrollY() - (dd.ie && !dd.iemac)*1;}
this.modifKey = this.e.modifiers? this.e.modifiers&Event.SHIFT_MASK : (this.e.shiftKey || false);}; dd.recalc = function(d_x)
{ var d_o, d_i = dd.elements.length; while(d_i--)
{ if (!(d_o = dd.elements[d_i]).is_image && d_o.div)
{ dd.getWH(d_o); if (d_o.div.pos_rel)
{ dd.getPageXY(d_o.div); var d_dx = dd.x - d_o.x, d_dy = dd.y - d_o.y; d_o.defx += d_dx; d_o.x += d_dx; d_o.defy += d_dy; d_o.y += d_dy; var d_p, d_j = d_o.children.length; while(d_j--)
{ if (!(d_p = d_o.children[d_j]).detached && (d_o != d_p.defparent || !(d_p.is_image && dd.getImg(d_p, d_p.oimg.name, 1))))
{ d_p.defx += d_dx; d_p.defy += d_dy; d_p.moveBy(d_dx, d_dy);}
}
}
}
else if (d_o.is_image && !dd.op6 && !dd.n4)
{ if (dd.n6 && d_x && !d_o.defw) d_o.resizeTo(d_o.defw = dd.getImgW(d_o.oimg), d_o.defh = dd.getImgH(d_o.oimg)); var d_defx = d_o.defx, d_defy = d_o.defy; if (!(d_o.parent && d_o.parent != d_o.defparent) && (d_x || !d_o.detached || d_o.horizontal || d_o.vertical) && dd.getImg(d_o, d_o.oimg.name, 1))
d_o.moveBy(d_o.defx-d_defx, d_o.defy-d_defy);}
}
}; function WINSZ(d_x)
{ if (d_x)
{ if (dd.n4 || dd.op6 && d_x&2)
{ dd.iW = innerWidth; dd.iH = innerHeight; if (dd.op6) setTimeout("WINSZ()", 0x1ff);}
window.onresize = new Function('WINSZ();');}
else if ((dd.n4 || dd.op6) && (innerWidth != dd.iW || innerHeight != dd.iH)) location.reload(); else if (dd.op6) setTimeout("WINSZ()", 0x1ff); else if (!dd.n4) setTimeout('dd.recalc()', 0xa);}
WINSZ(1); function DDObj(d_o, d_i)
{ this.id = d_o; this.cmd = ''; this.cpy_n = dd.getCmdVal(this, COPY); this.maxoffb = dd.getCmdVal(this, MAXOFFBOTTOM, 0, 1); this.maxoffl = dd.getCmdVal(this, MAXOFFLEFT, 0, 1); this.maxoffr = dd.getCmdVal(this, MAXOFFRIGHT, 0, 1); this.maxofft = dd.getCmdVal(this, MAXOFFTOP, 0, 1); var d_j = dd_cursors.length; while(d_j--)
if (dd.getCmd(this, dd_cursors[d_j], 1)) this.cursor = dd_cursors[d_j].substring(2); this.clone = dd.getCmd(this, CLONE, 1); this.detach = dd.getCmd(this, DETACH_CHILDREN); this.scalable = dd.getCmd(this, SCALABLE, 1); this.horizontal = dd.getCmd(this, HORIZONTAL); this.noalt = dd.getCmd(this, NO_ALT, 1); this.nodrag = dd.getCmd(this, NO_DRAG); this.scroll = dd.getCmd(this, SCROLL, 1); this.resizable = dd.getCmd(this, RESIZABLE, 1); this.re_z = dd.getCmd(this, RESET_Z, 1); this.diaphan = dd.getCmd(this, TRANSPARENT, 1); this.vertical = dd.getCmd(this, VERTICAL); this.maxw = dd.getCmdVal(this, MAXWIDTH, 1, 1); this.minw = Math.abs(dd.getCmdVal(this, MINWIDTH, 1, 1)); this.maxh = dd.getCmdVal(this, MAXHEIGHT, 1, 1); this.minh = Math.abs(dd.getCmdVal(this, MINHEIGHT, 1, 1)); this.name = this.id + (d_i || ''); this.oimg = dd.getImg(this, this.id, 1); this.is_image = !!this.oimg; this.copies = new Array(); this.children = new Array(); this.parent = this.original = null; if (this.oimg)
{ this.id = this.name + 'div'; this.w = dd.getImgW(this.oimg); this.h = dd.getImgH(this.oimg); this.dw = this.dh = 0; this.defz = dd.Int(dd.getCssProp(this.oimg, 'z-index','zIndex','zIndex')) || 1; this.defsrc = this.src = this.oimg.src; this.htm = '<img name="' + this.id + 'NImG"'+ ' src="' + this.oimg.src + '" '+ 'width="' + this.w + '" height="' + this.h + '">'; this.t_htm = '<div id="' + this.id + '" style="position:absolute;'+ 'left:' + (this.cssx = this.x = this.defx) + 'px;'+ 'top:' + (this.cssy = this.y = this.defy) + 'px;'+ 'width:' + this.w + 'px;'+ 'height:' + this.h + 'px;">'+ this.htm + '<\/div>';}
else
{ if (!!(this.div = dd.getDiv(this.id)) && typeof this.div.style != "undefined") this.css = this.div.style; dd.getWH(this); if (this.div)
{ this.div.ddObj = this; this.div.pos_rel = ("" + (this.div.parentNode? this.div.parentNode.tagName : this.div.parentElement? this.div.parentElement.tagName : '').toLowerCase().indexOf('body') < 0);}
dd.getPageXY(this.div); this.defx = this.x = dd.x; this.defy = this.y = dd.y; dd.getCssXY(this); this.defz = dd.Int(dd.getCssProp(this.div, 'z-index','zIndex','zIndex'));}
this.defw = this.w || 0; this.defh = this.h || 0;}
DDObj.prototype.moveBy = function(d_x, d_y, d_kds, d_o)
{ if (!this.div) return; this.x += (d_x = dd.Int(d_x)); this.y += (d_y = dd.Int(d_y)); if (!d_kds || this.is_image || this.parent != this.defparent)
{ (d_o = this.css || this.div).left = (this.cssx += d_x) + dd.px; d_o.top = (this.cssy += d_y) + dd.px;}
var d_i = this.children.length; while (d_i--)
{ if (!(d_o = this.children[d_i]).detached) d_o.moveBy(d_x, d_y, 1); d_o.defx += d_x; d_o.defy += d_y;}
}; DDObj.prototype.moveTo = function(d_x, d_y)
{ this.moveBy(dd.Int(d_x)-this.x, dd.Int(d_y)-this.y);}; DDObj.prototype.hide = function(d_m, d_o, d_p)
{ if (this.div && this.visible)
{ d_p = this.css || this.div; if (d_m && !dd.n4)
{ this.display = dd.getCssProp(this.div, "display", "display", "display"); if (this.oimg)
{ this.oimg.display = dd.getCssProp(this.oimg, "display", "display", "display"); this.oimg.style.display = "none";}
d_p.display = "none"; dd.recalc();}
else d_p.visibility = "hidden";}
this.visible = false; var d_i = this.children.length; while (d_i--)
if (!(d_o = this.children[d_i]).detached) d_o.hide(d_m);}; DDObj.prototype.show = function(d_o, d_p)
{ if (this.div)
{ d_p = this.css || this.div; if (d_p.display && d_p.display == "none")
{ d_p.display = this.display || "block"; if (this.oimg) this.oimg.style.display = this.oimg.display || "inline"; dd.recalc();}
else d_p.visibility = "visible";}
this.visible = true; var d_i = this.children.length; while (d_i--)
if (!(d_o = this.children[d_i]).detached) d_o.show();}; DDObj.prototype.resizeTo = function(d_w, d_h, d_o)
{ if (!this.div) return; d_w = (this.w = dd.Int(d_w))-this.dw; d_h = (this.h = dd.Int(d_h))-this.dh; if (dd.n4)
{ this.div.resizeTo(d_w, d_h); if (this.is_image)
{ this.write('<img src="' + this.src + '" width="' + d_w + '" height="' + d_h + '">'); (this.nimg = this.div.document.images[0]).src = this.src;}
}
else if (typeof this.css.pixelWidth != "undefined")
{ this.css.pixelWidth = d_w; this.css.pixelHeight = d_h; if (this.is_image)
{ (d_o = this.nimg.style).pixelWidth = d_w; d_o.pixelHeight = d_h;}
}
else
{ this.css.width = d_w + dd.px; this.css.height = d_h + dd.px; if (this.is_image)
{ (d_o = this.nimg).width = d_w; d_o.height = d_h; if (!d_o.complete) d_o.src = this.src;}
}
}; DDObj.prototype.resizeBy = function(d_dw, d_dh)
{ this.resizeTo(this.w+dd.Int(d_dw), this.h+dd.Int(d_dh));}; DDObj.prototype.swapImage = function(d_x, d_cp)
{ if (!this.nimg) return; this.nimg.src = d_x; this.src = this.nimg.src; if (d_cp)
{ var d_i = this.copies.length; while (d_i--)
this.copies[d_i].src = this.copies[d_i].nimg.src = this.nimg.src;}
}; DDObj.prototype.setBgColor = function(d_x)
{ if (dd.n4 && this.div) this.div.bgColor = d_x; else if (this.css) this.css.background = d_x; this.bgColor = d_x;}; DDObj.prototype.write = function(d_x, d_o)
{ this.text = d_x; if (!this.div) return; if (dd.n4)
{ (d_o = this.div.document).open(); d_o.write(d_x); d_o.close(); dd.getWH(this);}
else if (!dd.op6)
{ this.css.height = 'auto'; this.div.innerHTML = d_x; if (!dd.ie4) dd.recalc(); if (dd.ie4 || dd.n6) setTimeout('dd.recalc();', 0);}
}; DDObj.prototype.copy = function(d_n, d_p)
{ if (!this.oimg) return; d_n = d_n || 1; while (d_n--)
{ var d_l = this.copies.length, d_o = new DDObj(this.name+this.cmd, d_l+1); if (dd.n4)
{ d_o.id = (d_p = new Layer(d_o.w)).name; d_p.clip.height = d_o.h; d_p.visibility = 'show'; (d_p = d_p.document).open(); d_p.write(d_o.htm); d_p.close();}
else if (dd.db.insertAdjacentHTML) dd.db.insertAdjacentHTML("AfterBegin", d_o.t_htm); else if (document.createElement && dd.db && dd.db.appendChild)
{ dd.db.appendChild(d_p = document.createElement('div')); d_p.innerHTML = d_o.htm; d_p.id = d_o.id; d_p.style.position = 'absolute'; d_p.style.width = d_o.w + 'px'; d_p.style.height = d_o.h + 'px';}
else if (dd.db && dd.db.innerHTML) dd.db.innerHTML += d_o.t_htm; d_o.defz = this.defz+1+d_l; dd.addProps(d_o); d_o.original = this; dd.addElt(d_o, this); if (this.parent)
{ this.parent.addChild(d_o, this.detached); d_o.defparent = this.defparent;}
d_o.moveTo(d_o.defx = this.defx, d_o.defy = this.defy); if (dd.n4) d_o.defsrc = d_o.src = this.defsrc; d_o.swapImage(this.src);}
}; DDObj.prototype.addChild = function(d_kd, detach, defp)
{ if (typeof d_kd != "object") d_kd = dd.elements[d_kd]; if (d_kd.parent && d_kd.parent == this || d_kd == this || !d_kd.is_image && d_kd.defparent && !defp) return; this.children[this.children.length] = this.children[d_kd.name] = d_kd; d_kd.detached = detach || 0; if (defp) d_kd.defparent = this; else if (this == d_kd.defparent && d_kd.is_image) dd.getImg(this, d_kd.oimg.name, 1); if (!d_kd.defparent || this != d_kd.defparent)
{ d_kd.defx = d_kd.x; d_kd.defy = d_kd.y;}
if (!detach)
{ d_kd.defz = d_kd.defz+this.defz-(d_kd.parent? d_kd.parent.defz : 0)+(!d_kd.is_image*1); d_kd.setZ(d_kd.z+this.z-(d_kd.parent? d_kd.parent.z : 0)+(!d_kd.is_image*1), 1);}
if (d_kd.parent) d_kd.parent._removeChild(d_kd, 1); d_kd.parent = this;}; DDObj.prototype._removeChild = function(d_kd, d_newp)
{ if (typeof d_kd != "object") d_kd = this.children[d_kd]; var d_oc = this.children, d_nc = new Array(); for (var d_i = 0; d_i < d_oc.length; d_i++)
if (d_oc[d_i] != d_kd) d_nc[d_nc.length] = d_oc[d_i]; this.children = d_nc; d_kd.parent = null; if (!d_newp)
{ d_kd.detached = d_kd.defp = 0; if (d_kd.is_image) dd.getImg(d_kd, d_kd.oimg.name, 1);}
}; DDObj.prototype.attachChild = function(d_kd)
{ (d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 0; d_kd.setZ(d_kd.defz + this.z-this.defz, 1);}; DDObj.prototype.detachChild = function(d_kd)
{ (d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 1;}; DDObj.prototype.setZ = function(d_x, d_kds, d_o)
{ if (d_kds)
{ var d_dz = d_x-this.z, d_i = this.children.length; while (d_i--)
if (!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.z+d_dz, 1);}
dd.z = Math.max(dd.z, this.z = this.div? ((this.css || this.div).zIndex = d_x) : 0);}; DDObj.prototype.maximizeZ = function()
{ this.setZ(dd.z+1, 1);}; DDObj.prototype._resetZ = function(d_o)
{ if (this.re_z || dd.re_z)
{ this.setZ(this.defz); var d_i = this.children.length; while (d_i--)
if (!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.defz);}
}; DDObj.prototype.setCursor = function(d_x)
{ this._setCrs(this.cursor = (d_x.indexOf('c:')+1)? d_x.substring(2) : d_x);}; DDObj.prototype._setCrs = function(d_x)
{ if (this.css) this.css.cursor = ((!dd.ie || dd.iemac) && d_x == 'hand')? 'pointer' : d_x;}; DDObj.prototype.setDraggable = function(d_x)
{ this.nodrag = !d_x*1; this._setCrs(d_x? this.cursor : 'auto');}; DDObj.prototype.setResizable = function(d_x)
{ this.resizable = d_x*1; if (d_x) this.scalable = 0;}; DDObj.prototype.setScalable = function(d_x)
{ this.scalable = d_x*1; if (d_x) this.resizable = 0;}; DDObj.prototype.del = function(d_os, d_o)
{ var d_i; if (this.parent && this.parent._removeChild) this.parent._removeChild(this); if (this.original)
{ this.hide(); if (this.original.copies)
{ d_os = new Array(); for (d_i = 0; d_i < this.original.copies.length; d_i++)
if ((d_o = this.original.copies[d_i]) != this) d_os[d_o.name] = d_os[d_os.length] = d_o; this.original.copies = d_os;}
}
else if (this.is_image)
{ this.hide(); if (this.oimg)
{ if (dd.n4) this.oimg.src = this.defsrc; else this.oimg.style.visibility = 'visible';}
}
else if (this.moveTo)
{ if (this.css) this.css.cursor = 'default'; this.moveTo(this.defx, this.defy); this.resizeTo(this.defw, this.defh);}
d_os = new Array(); for (d_i = 0; d_i < dd.elements.length; d_i++)
{ if ((d_o = dd.elements[d_i]) != this) d_os[d_o.name] = d_os[d_o.index = d_os.length] = d_o; else d_o._free();}
dd.elements = d_os; if (!dd.op6 && !dd.n4) dd.recalc();}; DDObj.prototype._free = function()
{ for (var d_i in this)
this[d_i] = null; dd.elements[this.name] = null;}; dd.n4RectVis = function(vis)
{ for (var d_i = 4; d_i--;)
{ dd.rectI[d_i].visibility = dd.rectA[d_i].visibility = vis? 'show' : 'hide'; if (vis) dd.rectI[d_i].zIndex = dd.rectA[d_i].zIndex = dd.z+2;}
}; dd.n4RectPos = function(d_o, d_x, d_y, d_w, d_h)
{ d_o.x = d_x; d_o.y = d_y; d_o.clip.width = d_w; d_o.clip.height = d_h;}; dd.n4Rect = function(d_w, d_h)
{ var d_i; if (!dd.rectI)
{ dd.rectI = new Array(); dd.rectA = new Array();}
if (!dd.rectI[0])
{ for (d_i = 4; d_i--;)
{ (dd.rectI[d_i] = new Layer(1)).bgColor = '#000000'; (dd.rectA[d_i] = new Layer(1)).bgColor = '#ffffff';}
}
if (!dd.rectI[0].visibility || dd.rectI[0].visibility == 'hide') dd.n4RectVis(1); dd.obj.w = d_w; dd.obj.h = d_h; for (d_i = 4; d_i--;)
{ dd.n4RectPos(dd.rectI[d_i], dd.obj.x + (!(d_i-1)? (dd.obj.w-1) : 0), dd.obj.y + (!(d_i-2)? (dd.obj.h-1) : 0), d_i&1 || dd.obj.w, !(d_i&1) || dd.obj.h); dd.n4RectPos(dd.rectA[d_i], !(d_i-1)? dd.rectI[1].x+1 : (dd.obj.x-1), !(d_i-2)? dd.rectI[2].y+1 : (dd.obj.y-1), d_i&1 || dd.obj.w+2, !(d_i&1) || dd.obj.h+2);}
}; dd.reszTo = function(d_w, d_h)
{ if (dd.n4 && dd.obj.is_image) dd.n4Rect(d_w, d_h); else dd.obj.resizeTo(d_w, d_h);}; dd.embedVis = function(d_vis)
{ var d_o = new Array('iframe', 'applet', 'embed', 'object'); var d_i = d_o.length; while (d_i--)
{ var d_p = dd.ie? document.all.tags(d_o[d_i]) : document.getElementsByTagName? document.getElementsByTagName(d_o[d_i]) : null; if (d_p)
{ var d_j = d_p.length; while (d_j--)
{ var d_q = d_p[d_j]; while (d_q.offsetParent || d_q.parentNode)
{ if ((d_q = d_q.parentNode || d_q.offsetParent || null) == dd.obj.div)
{ d_p[d_j].style.visibility = d_vis; break;}
}
}
}
}
}; dd.maxOffX = function(d_x, d_y)
{ return ( (dd.obj.maxoffl+1 && (d_y = dd.obj.defx-dd.obj.maxoffl)-d_x > 0 || dd.obj.maxoffr+1 && (d_y = dd.obj.defx+dd.obj.maxoffr)-d_x < 0)? d_y
: d_x );}; dd.maxOffY = function(d_x, d_y)
{ return ( (dd.obj.maxofft+1 && (d_y = dd.obj.defy-dd.obj.maxofft)-d_x > 0 || dd.obj.maxoffb+1 && (d_y = dd.obj.defy+dd.obj.maxoffb)-d_x < 0)? d_y
: d_x );}; dd.inWndW = function(d_x, d_y)
{ var d_wx = dd.getScrollX(), d_ww = dd.getWndW(); return ( ((d_y = d_wx+2)-d_x > 0) || ((d_y = d_wx+d_ww+dd.obj.w-2)-d_x < 0)? d_y
: d_x );}; dd.inWndH = function(d_x, d_y)
{ var d_wy = dd.getScrollY(), d_wh = dd.getWndH(); return ( ((d_y = d_wy+2)-d_x > 0) || ((d_y = d_wy+d_wh+dd.obj.h-2)-d_x < 0)? d_y
: d_x );}; dd.limW = function(d_w)
{ return ( (dd.obj.minw-d_w > 0)? dd.obj.minw
: (dd.obj.maxw > 0 && dd.obj.maxw-d_w < 0)? dd.obj.maxw
: d_w );}; dd.limH = function(d_h)
{ return ( (dd.obj.minh-d_h > 0)? dd.obj.minh
: (dd.obj.maxh > 0 && dd.obj.maxh-d_h < 0)? dd.obj.maxh
: d_h );}; function DDScroll()
{ if (!dd.obj || !dd.obj.scroll && !dd.scroll || dd.op || dd.ie4 || dd.whratio)
{ dd.scrx = dd.scry = 0; return;}
var d_bnd = 0x1c, d_wx = dd.getScrollX(), d_wy = dd.getScrollY(); if (dd.msmoved)
{ var d_ww = dd.getWndW(), d_wh = dd.getWndH(), d_y; dd.scrx = ((d_y = dd.e.x-d_ww-d_wx+d_bnd) > 0)? (d_y>>=2)*d_y
: ((d_y = d_wx+d_bnd-dd.e.x) > 0)? -(d_y>>=2)*d_y
: 0; dd.scry = ((d_y = dd.e.y-d_wh-d_wy+d_bnd) > 0)? (d_y>>=2)*d_y
: ((d_y = d_wy+d_bnd-dd.e.y) > 0)? -(d_y>>=2)*d_y
: 0;}
if (dd.scrx || dd.scry)
{ window.scrollTo( d_wx + (dd.scrx = dd.obj.is_resized? dd.limW(dd.obj.w+dd.scrx)-dd.obj.w : dd.obj.vertical? 0 : (dd.maxOffX(dd.obj.x+dd.scrx)-dd.obj.x)), d_wy + (dd.scry = dd.obj.is_resized? dd.limH(dd.obj.h+dd.scry)-dd.obj.h : dd.obj.horizontal? 0 : (dd.maxOffY(dd.obj.y+dd.scry)-dd.obj.y)) ); dd.obj.is_dragged? dd.obj.moveTo(dd.obj.x+dd.getScrollX()-d_wx, dd.obj.y+dd.getScrollY()-d_wy)
: dd.reszTo(dd.obj.w+dd.getScrollX()-d_wx, dd.obj.h+dd.getScrollY()-d_wy);}
dd.msmoved = 0; window.setTimeout('DDScroll()', 0x33);}
function PICK(d_ev)
{ dd.e = new dd.evt(d_ev); if (dd.e.x >= dd.getWndW()+dd.getScrollX() || dd.e.y >= dd.getWndH()+dd.getScrollY()) return true; var d_o, d_cmp = -1, d_i = dd.elements.length; while (d_i--)
{ d_o = dd.elements[d_i]; if (dd.n4 && dd.e.but > 1 && dd.e.src == d_o.oimg && !d_o.clone) return false; if (d_o.visible && dd.e.but <= 1 && dd.e.x >= d_o.x && dd.e.x <= d_o.x+d_o.w && dd.e.y >= d_o.y && dd.e.y <= d_o.y+d_o.h)
{ if (d_o.z > d_cmp && dd.e.src.tag.indexOf('input') < 0 && dd.e.src.tag.indexOf('textarea') < 0 && dd.e.src.tag.indexOf('select') < 0 && dd.e.src.tag.indexOf('option') < 0)
{ d_cmp = d_o.z; dd.obj = d_o;}
}
}
if (dd.obj)
{ if (dd.obj.nodrag) dd.obj = null; else
{ dd.e.e.cancelBubble = true; var d_rsz = dd.e.modifKey && (dd.obj.resizable || dd.obj.scalable); if (dd.op && !dd.op6)
{ (d_o = document.getElementById('OpBlUr')).style.pixelLeft = dd.e.x; d_o.style.pixelTop = dd.e.y; (d_o = d_o.children[0].children[0]).focus(); d_o.blur();}
else if (dd.ie && !dd.ie4)
{ if (document.selection && document.selection.empty) document.selection.empty(); dd.db.onselectstart = function()
{ event.returnValue = false;};}
if (d_rsz)
{ dd.obj._setCrs('se-resize'); dd.obj.is_resized = 1; dd.whratio = dd.obj.scalable? dd.obj.defw/dd.obj.defh : 0; if (dd.ie)
{ if (dd.ie4)
{ window.dd_x = dd.getScrollX(); window.dd_y = dd.getScrollY();}
setTimeout( 'if (dd.obj && document.selection && document.selection.empty)'+ '{'+ 'document.selection.empty();'+ 'if (dd.ie4) window.scrollTo(window.dd_x, window.dd_y);'+ '}' ,0);}
dd.setEvtHdl(1, RESIZE); dd.reszTo(dd.obj.w, dd.obj.h);}
else
{ dd.obj.is_dragged = 1; dd.setEvtHdl(1, DRAG);}
dd.setEvtHdl(2, DROP); dd.embedVis('hidden'); dd.obj.maximizeZ(); dd.ofx = dd.obj.x+dd.obj.w-dd.e.x; dd.ofy = dd.obj.y+dd.obj.h-dd.e.y; if (window.my_PickFunc) my_PickFunc(); DDScroll(); return !( dd.obj.is_resized || dd.n4 && dd.obj.is_image || dd.n6 || dd.w3c );}
}
if (dd.downFunc) return dd.downFunc(d_ev); return true;}
function DRAG(d_ev)
{ if (!dd.obj || !dd.obj.visible) return true; if (dd.ie4 || dd.w3c || dd.n6 || dd.obj.children.length > 0xf)
{ if (dd.wait) return false; dd.wait = 1; setTimeout('dd.wait = 0;', dd.tiv);}
dd.e = new dd.evt(d_ev); if (dd.ie && !dd.e.but)
{ DROP(d_ev); return true;}
dd.msmoved = 1; dd.obj.moveTo( dd.obj.vertical? dd.obj.x : dd.maxOffX(dd.inWndW(dd.ofx+dd.e.x)-dd.obj.w), dd.obj.horizontal? dd.obj.y : dd.maxOffY(dd.inWndH(dd.ofy+dd.e.y)-dd.obj.h) ); if (window.my_DragFunc) my_DragFunc(); return false;}
function RESIZE(d_ev)
{ if (!dd.obj || !dd.obj.visible) return true; if (dd.wait) return false; dd.wait = 1; setTimeout('dd.wait = 0;', dd.tiv); dd.e = new dd.evt(d_ev); if (dd.ie && !dd.e.but)
{ DROP(d_ev); return true;}
dd.msmoved = 1; var d_w = dd.limW(dd.inWndW(dd.ofx+dd.e.x)-dd.obj.x), d_h; if (!dd.whratio) d_h = dd.limH(dd.inWndH(dd.ofy+dd.e.y)-dd.obj.y); else
{ d_h = dd.limH(dd.inWndH(Math.round(d_w/dd.whratio)+dd.obj.y)-dd.obj.y); d_w = Math.round(d_h*dd.whratio);}
dd.reszTo(d_w, d_h); if (window.my_ResizeFunc) my_ResizeFunc(); return false;}
function DROP(d_ev)
{ if (dd.obj)
{ if (dd.obj.is_dragged)
{ if (!dd.obj.is_image) dd.getWH(dd.obj);}
else if (dd.n4)
{ if (dd.obj.is_image)
{ dd.n4RectVis(0); dd.obj.resizeTo(dd.obj.w, dd.obj.h);}
}
if (!dd.n4 && !dd.op6 || !dd.obj.is_image) dd.recalc(); dd.setEvtHdl(1, dd.moveFunc); dd.setEvtHdl(2, dd.upFunc); if (dd.db) dd.db.onselectstart = null; dd.obj._setCrs(dd.obj.cursor); dd.embedVis('visible'); dd.obj._resetZ(); if (window.my_DropFunc)
{ dd.e = new dd.evt(d_ev); my_DropFunc();}
dd.msmoved = dd.obj.is_dragged = dd.obj.is_resized = dd.whratio = 0; dd.obj = null;}
dd.setEvtHdl(0, PICK);}
function SET_DHTML()
{ var d_a = arguments, d_ai, d_htm = '', d_o, d_i = d_a.length; while (d_i--)
{ if (dd.op6)
{ var d_t0 = (new Date()).getTime(); while ((new Date()).getTime()-d_t0 < 0x99);}
if (!(d_ai = d_a[d_i]).indexOf('c:')) dd.cursor = d_ai.substring(2); else if (d_ai == NO_ALT) dd.noalt = 1; else if (d_ai == SCROLL) dd.scroll = 1; else if (d_ai == RESET_Z) dd.re_z = 1; else if (d_ai == RESIZABLE) dd.resizable = 1; else if (d_ai == SCALABLE) dd.scalable = 1; else if (d_ai == TRANSPARENT) dd.diaphan = 1; else
{ d_o = new DDObj(d_ai); dd.addElt(d_o); d_htm += d_o.t_htm || ''; if (d_o.oimg && d_o.cpy_n)
{ var d_j = 0; while (d_j < d_o.cpy_n)
{ var d_p = new DDObj(d_o.name+d_o.cmd, ++d_j); dd.addElt(d_p, d_o); d_p.defz = d_o.defz+d_j; d_p.original = d_o; d_htm += d_p.t_htm;}
}
}
}
if (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c) document.write( (dd.n4? '<div style="position:absolute;"><\/div>\n'
: (dd.op && !dd.op6)? '<div id="OpBlUr" style="position:absolute;visibility:hidden;width:0px;height:0px;"><form><input type="text" style="width:0px;height:0px;"><\/form><\/div>'
: '') + d_htm ); dd.z = 0x33; d_i = dd.elements.length; while (d_i--)
{ dd.addProps(d_o = dd.elements[d_i]); if (d_o.is_image && !d_o.original && !d_o.clone)
dd.n4? d_o.oimg.src = spacer : d_o.oimg.style.visibility = 'hidden';}
dd.mkWzDom(); if (window.onload) dd.loadFunc = window.onload; document.onmousedown = document.onmousedown||null; document.onmousemove = document.onmousemove||null; document.onmouseup = document.onmouseup||null; window.onload = dd.initz; window.onunload = dd.finlz; dd.setEvtHdl(0, PICK);}
function ADD_DHTML(d_o)
{ d_o = new DDObj(d_o); dd.addElt(d_o); dd.addProps(d_o); dd.mkWzDom();}
dd.d = document; var RESET_ZINDEX = RESET_Z; var KEYDOWN_RESIZE = RESIZABLE; var CURSOR_POINTER = CURSOR_HAND; var NO_SCROLL = ''; function my_PickFunc()
{ if (dd.obj.my_PickFunc)
{ dd.obj.my_PickFunc();}
}
function my_DragFunc()
{ if (dd.obj.my_DragFunc)
{ dd.obj.my_DragFunc();}
}
function my_ResizeFunc()
{ if (dd.obj.my_ResizeFunc)
{ dd.obj.my_ResizeFunc();}
}
function my_DropFunc()
{ if (dd.obj.my_DropFunc)
{ dd.obj.my_DropFunc();}
}


var KAMAP_QUERY = gnLastEventId ++; var KAMAP_POINT_QUERY = 0; var KAMAP_RECT_QUERY = 1; var KAMAP_MOUSE_STOPPED = 2; function kaQuery( oKaMap, type ) { kaTool.apply( this, [oKaMap] ); this.type = type; if(this.type == KAMAP_MOUSE_STOPPED){ this.bInfoTool = true; if(arguments.length == 4){ this.delay = arguments[3];} else { alert("Incorrect nb of arguments for instance kaQuery. Delay will be set by default to 500ms"); this.delay = 500;}
}
this.name = 'kaQuery'; this.cursor = 'help'; this.startx = null; this.starty = null; this.endx = null; this.endy = null; this.bMouseDown = false; this.coords = new Array(); this.mouseStopped = false; this.chrono = null; this.domObj = document.createElement( 'div' ); this.domObj.style.position = 'absolute'; this.domObj.style.top = '0px'; this.domObj.style.left = '0px'; this.domObj.style.width = '1px'; this.domObj.style.height = '1px'; this.domObj.style.zIndex = 50; this.domObj.style.visibility = 'hidden'; this.domObj.style.border = '1px solid #656565'; this.domObj.style.backgroundColor = 'white'; this.domObj.style.opacity = 0.50; this.domObj.style.mozOpacity = 0.50; this.domObj.style.filter = 'Alpha(opacity=50)'; this.kaMap.theInsideLayer.appendChild( this.domObj ); for (var p in kaTool.prototype) { if (!kaQuery.prototype[p])
kaQuery.prototype[p]= kaTool.prototype[p];}
}; kaQuery.prototype.drawZoomBox = function() { if (this.startx == null || this.starty == null || this.endx == null || this.endy == null ) { this.domObj.style.visibility = 'hidden'; this.domObj.style.top = '0px'; this.domObj.style.left = '0px'; this.domObj.style.width = '1px'; this.domObj.style.height = '1px'; return;}
this.domObj.style.visibility = 'visible'; if (this.endx < this.startx) { this.domObj.style.left = (this.endx - this.kaMap.xOrigin) + 'px'; this.domObj.style.width = (this.startx - this.endx) + "px";}
else { this.domObj.style.left = (this.startx - this.kaMap.xOrigin) + 'px'; this.domObj.style.width = (this.endx - this.startx) + "px";}
if (this.endy < this.starty) { this.domObj.style.top = (this.endy - this.kaMap.yOrigin) + 'px'; this.domObj.style.height = (this.starty - this.endy) + "px";} else { this.domObj.style.top = (this.starty - this.kaMap.yOrigin) + 'px'; this.domObj.style.height = (this.endy - this.starty) + "px";}
}; kaQuery.prototype.onmousemove = function(e) { e = (e)?e:((event)?event:null); if(this.type != KAMAP_MOUSE_STOPPED){ if (!this.bMouseDown) { return 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)); var adjCoords = this.adjustPixPosition( x, y ); if(this.type == KAMAP_MOUSE_STOPPED){ var p = this.kaMap.pixToGeo(adjCoords[0], adjCoords[1]); this.coords[0] = p[0]; this.coords[1] = p[1]; if(this.chrono != null)
clearTimeout(this.chrono); var t = this; if(this.mouseStopped == false){ this.chrono = setTimeout(function(){t.onmousestop()}, this.delay);}
}
if (this.type == KAMAP_RECT_QUERY) { this.endx = -adjCoords[0]; this.endy = -adjCoords[1]; this.drawZoomBox();}
return false;}; kaQuery.prototype.onmousestop = function(){ clearTimeout(this.chrono); this.mouseStopped = true; this.kaMap.triggerEvent(KAMAP_MOUSE_STOPPED, this.type, this.coords); this.mouseStopped = false; return;}; kaQuery.prototype.onmouseout = function(e) { e = (e)?e:((event)?event:null); clearTimeout(this.chrono); if (!e.target) e.target = e.srcElement; if (e.target.id == this.kaMap.domObj.id) { this.bMouseDown = false; this.startx = this.endx = this.starty = this.endy = null; this.drawZoomBox(); return kaTool.prototype.onmouseout.apply(this, [e]);}
}; kaQuery.prototype.onmousedown = function(e) { e = (e)?e:((event)?event:null); if(this.type != KAMAP_MOUSE_STOPPED){ if (e.button==2) { return this.cancelEvent(e);}
else { 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)); var aPixPos = this.adjustPixPosition( x,y ); this.startx=this.endx = -aPixPos[0]; this.starty=this.endy = -aPixPos[1]; this.drawZoomBox(); e.cancelBubble = true; e.returnValue = false; if (e.stopPropagation) e.stopPropagation(); if (e.preventDefault) e.preventDefault(); return false;}
}
}; kaQuery.prototype.onmouseup = function(e) { e = (e)?e:((event)?event:null); if(this.type != KAMAP_MOUSE_STOPPED){ var type = KAMAP_POINT_QUERY; var start = this.kaMap.pixToGeo( -this.startx, -this.starty ); var coords = start; if (this.startx!=this.endx&&this.starty!=this.endy) { type = KAMAP_RECT_QUERY; coords = start.concat(this.kaMap.pixToGeo( -this.endx, -this.endy )); if(coords[2] < coords[0]) { var minx = coords[2]; var maxx = coords[0]; coords[0] = minx; coords[2] = maxx;}
if(coords[1] < coords[3]){ var miny = coords[1]; var maxy = coords[3]; coords[3] = miny; coords[1] = maxy;}
}
this.kaMap.triggerEvent(KAMAP_QUERY, type, coords); this.startx = this.endx = this.starty = this.endy = null; this.drawZoomBox();}
return false;}; 


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 XMLHTTP(); A.onerror = function(description) { alert('Error: ' + description)
}
}
if (!A)
{ try
{ A=new XMLHTTP();}
catch(e)
{ try
{ A=new ActiveXObject("Msxml2.XMLHTTP");}
catch(oc)
{ try
{ A=new ActiveXObject("Microsoft.XMLHTTP");}
catch(oc)
{ A=new XMLHttpRequest();}
}
}
}
return A;}


XMLHTTP = function() { var _options = { maxRequestLength: 1500, apiURL: 'http://www.mapfinder.co.nz/php.server/index.php', apiKey: '', overrideMime: ''
}
this.onreadystatechange = function() { }
this.onerror = function() { }
this.onload = function() { }
this.abort = function() { _stop = true
_transport.abort()
}
this.setRequestHeader = function(name, value) { _request.headers[name] = value
}
this.getAllResponseHeaders = function() { var result = ''
for (property in _responseHeaders)
result += property + ': ' + _responseHeaders[property] + '\r\n'
return result
}
this.getResponseHeader = function(name) { for(property in _responseHeaders) { if(property.toLowerCase() == name.toLowerCase())
return _responseHeaders[property]
}
return ''
}
this.overrideMimeType = function(type) { _options.overrideMime = type
}
this.setAPI = function(url) { _options.apiURL = url
}
this.setKey = function(key) { _options.apiKey = key
}
this.open = function(method, url, sync, username, password) { _request.method = _is_defined(method)
_request.url = _is_defined(url)
var username = _is_defined(username)
var password = _is_defined(password)
var pos = _request.url.indexOf('://') + 3
if((username || password) && pos > 2) { _request.url = _request.url.substr(0, pos) + username + ':' + password + '@' + _request.url.substr(pos)
}
_setReadyState(1)
}
this.openRequest = function(method, url, sync, username, password) { return this.open(method, url, sync, username, password)
}
this.send = function(data) { if (_stop) return
_recallCookies()
_request.data = _is_defined(data)
_transport.send(_request, _options)
}
var _is_defined = function(value) { return ('undefined' == typeof value) ? '' : value
}
var _throwError = function(description) { self.onerror(description)
self.abort()
return false
}
var _setReadyState = function(number) { self.readyState = number
self.onreadystatechange()
if(number == 4) self.onload()
}
var _parse = function(object) { if(_stop) return
if('object' != typeof object)
return _throwError('There seems to be a problem with your server script')
if(object.multipart)
return
if(!object.success)
return _throwError(object.description)
_responseHeaders = object.responseHeaders
if (_options.overrideMime)
var mime = _options.overrideMime
else
var mime = self.getResponseHeader('Content-type')
self.status = object.status
self.statusText = object.statusText
self.responseText = object.responseText
self.responseXML = _xmlparser.parse(object.responseText, mime)
_recordCookies(object.cookies)
_setReadyState(4)
}
var _recordCookies = function(cookies) { if (!cookies) return
for (i in cookies)
XMLHTTP.Cookies.save(cookies[i])
}
var _recallCookies = function() { cookies = XMLHTTP.Cookies.find(_request.url)
self.setRequestHeader('Cookie', cookies)
}
var self = this
var _request = { headers: { "HTTP-Referer": document.location, "Content-Type": "application/x-www-form-urlencoded"
}, method: 'GET', data: '', url: 'http://www.ajaxextended.com/'
}
this.status = null
this.statusText = null
this.responseText = null
this.responseXML = null
this.synchronous = false
this.readyState = 0
var _response = { }
var _responseHeaders = { }
var _stop = false
var _transport = new XMLHTTP.Transport(_parse)
var _xmlparser = new XMLHTTP.XMLParser()
}
XMLHTTP.Cookies = { data: [], save: function(cookie) { var entry = cookie
entry.expires = Date.parse(entry.expires)
this.data.push(entry)
}, check: function(cookie, domain, path) { if (cookie.expires < Date()) return false
if (path.indexOf(cookie.path) != 0) return false
if (cookie.domain == domain) return true
if (domain.indexOf(cookie.domain.substr(1)) > -1 &&
cookie.domain.substr(0,1) == '.') return true
return false
}, find: function(url) { var result = ''
url = url.split('/')
domain = url[2]
path = '/' + url.slice(3).join('/')
for (i in this.data) { var cookie = this.data[i]
if(this.check(cookie, domain, path))
result += cookie.name + '=' + cookie.value + '; '
}
return result
}
}
XMLHTTP.Transport = function(handler) { var _registerCallback = function(handler) { _id = 'v' + Math.random().toString().substr(2)
window[_id] = _onComplete
_handler = handler
}
var _onComplete = function(data) { if(_parts-- == 1) _destroyScripts()
handler(data)
}
var _encode = function(params) { var headers = ''
for (property in params.headers)
headers += _encodeUTF(property + ': ' + params.headers[property]) + '&'
var data = params.method + '&' + _encodeUTF(params.url) + '&' + _encodeUTF(params.data) + '&' + headers
return base64encode(data)
}
var _encodeUTF = function(string) { return base64encode(utf8encode(string))
}
var _split = function(data, options) { var max = options.maxRequestLength - options.apiURL.length - 60
var urls = [], total = Math.floor(data.length / max) + 1
for (var part = 0; part < total; part++) { urls.push(options.apiURL + '?id=' + _id + '&key=' + options.apiKey + '&part=' + part + '&total=' + total + '&data=' + data.substr(0, max))
data = data.substr(max)
}
_parts = urls.length
return urls
}
this.send = function(params, options) { var urls = _split(_encode(params), options)
for(var i = 0; i < urls.length; i++)
_createScript(urls[i])
}
var _createScript = function(url) { var script = document.createElement('script')
script.src = url
script.type = 'text/javascript'
script.charset = 'utf-8'
script = document.getElementsByTagName('head')[0].appendChild(script)
_scripts.push(script)
}
var _destroyScripts = function() { for(var i = 0; i < _scripts.length; i++)
if(_scripts[i].parentNode)
_scripts[i].parentNode.removeChild(_scripts[i])
}
var self = this
var _id, _scripts = []
var _parts = 0
var _handler = function() { }
_registerCallback(handler)
}
XMLHTTP.XMLParser = function() { this.parse = function(text, type) { if(!(type.indexOf('html') > -1 || type.indexOf('xml') > -1)) return
if(document.implementation &&
document.implementation.createDocument &&
navigator.userAgent.indexOf('Opera') == -1) { var parser = new DOMParser()
return parser.parseFromString(text, "text/xml")
} else if (window.ActiveXObject) { var xml = new ActiveXObject('MSXML2.DOMDocument.3.0')
if (xml.loadXML(text)) return xml
} else { var xml = document.body.appendChild(document.createElement('div'))
xml.style.display = 'none'
xml.innerHTML = self.responseText
_cleanWhitespace(xml, true)
return xml.childNodes[0]
}
}
var _cleanWhitespace = function(element, deep) { var i = element.childNodes.length
if (i == 0) return
do { var node = element.childNodes[--i]
if (node.nodeType == 3 && !_cleanEmptySymbols(node.nodeValue))
element.removeChild(node)
if (node.nodeType == 1 && deep)
_cleanWhitespace(node, true)
} while(i > 0)
}
}
var base64encode = function(input) { var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = "", chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0; do { chr1 = input.charCodeAt(i++)
chr2 = input.charCodeAt(i++)
chr3 = input.charCodeAt(i++)
enc1 = chr1 >> 2
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4)
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6)
enc4 = chr3 & 63
if (isNaN(chr2)) { enc3 = enc4 = 64
} else if (isNaN(chr3)) { enc4 = 64
}
output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4)
} while (i < input.length)
return output
}
function utf8encode(input) { if ('string' != typeof input) return ''
input = input.replace(/\r\n/g,"\n"); var output = ""; for(var n = 0; n < input.length; n++) { var c = input.charCodeAt(n)
if('null' != typeof c) { if (c < 128) { output += String.fromCharCode(c);}
else if((c > 127) && (c < 2048)) { output += String.fromCharCode((c >> 6) | 192); output += String.fromCharCode((c & 63) | 128);}
else { output += String.fromCharCode((c >> 12) | 224); output += String.fromCharCode(((c >> 6) & 63) | 128); output += String.fromCharCode((c & 63) | 128);}
}
}
return output;}
