function GSUtil(){}GSUtil.extend=function(c,a){function b(){}b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.baseConstructor=a;c.superClass=a.prototype};GSUtil.merge=function(b,c){if(!c){c={}}for(var a in b){c[a]=b[a]}return c};GSUtil.getPropertyArray=function(c,b){var f=[];for(var d=0,a=c.length;d<a;d++){var g=c[d];if(g[b]!=undefined){f.push(g[b])}}return f};GSUtil.getMinimum=function(b){var d=Infinity;for(var c=0,a=b.length;c<a;c++){d=Math.min(d,b[c])}return d};GSUtil.getMaximum=function(c){var a=-Infinity;for(var d=0,b=c.length;d<b;d++){a=Math.max(a,c[d])}return a};GSUtil.findPosX=function(a){var b=0;if(a.offsetParent){while(a.offsetParent){b+=a.offsetLeft;a=a.offsetParent}}else{if(a.x){b+=a.x}}return b};GSUtil.findPosY=function(c){var a=c;var b=0;if(c.offsetParent){while(c.offsetParent){b+=c.offsetTop;c=c.offsetParent}}else{if(c.y){b+=c.y}}if(_browser.isOpera||((_browser.isWebkit&&a.style.position=="absolute")||(_browser.isSafari&&a.style.position=="relative"))){b-=document.body.offsetTop}return b};GSUtil.getMousePixelCoordinate=function(b,a){if(!b){b=window.event}if(typeof b.pageX!="undefined"){var f=GSUtil.getElementPosition(a);return new GSPoint(b.pageX-f.x,b.pageY-f.y)}else{if(typeof b.offsetX!="undefined"){var d=b.target||b.srcElement;var c=GSUtil.getOffsetFromAncestor(d,a);return new GSPoint(b.offsetX+c.x,b.offsetY+c.y)}else{return new GSPoint(0,0)}}};GSUtil.getElementPosition=function(a){var b=new GSPoint(0,0);while(a){b.x+=a.offsetLeft;b.y+=a.offsetTop;a=a.offsetParent}return b};GSUtil.getWindowSize=function(){var a={};if(self.innerHeight){a.width=self.innerWidth;a.height=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){a.width=document.documentElement.clientWidth;a.height=document.documentElement.clientHeight}else{if(document.body){a.width=document.body.clientWidth;a.height=document.body.clientHeight}}}return a};GSUtil.getOffsetFromAncestor=function(c,a){var b=new GSPoint(0,0);while(c&&c!=a){b.x+=c.offsetLeft;b.y+=c.offsetTop;c=c.offsetParent}return b};GSUtil.getMousePos=function(b){var a=b?b:window.event;if(typeof a.pageX!="undefined"){return new GSPoint(a.pageX,a.pageY)}else{if(typeof a.clientX!="undefined"){return new GSPoint(a.clientX+document.body.scrollLeft,a.clientY+document.body.scrollTop)}else{return new GSPoint(0,0)}}};GSUtil.cancelEvent=function(a){a=a?a:window.event;GSUtil.eventStopPropagation(a);GSUtil.eventPreventDefault(a);return false};GSUtil.eventStopPropagation=function(a){if(a.stopPropagation){a.stopPropagation()}else{a.cancelBubble=true}};GSUtil.eventPreventDefault=function(a){if(a.preventDefault){a.preventDefault()}else{a.returnValue=false}};GSUtil.positionElement=function(d,g,f,c,b){var a=GSUtil.getComputedStyle(d,"position");if(a!="absolute"&&a!="relative"){d.style.position="absolute"}if(g||g==0){d.style.left=g+"px"}if(f||f==0){d.style.top=f+"px"}if(b||b==0){d.style.bottom=b+"px"}if(c||c==0){d.style.right=c+"px"}};GSUtil.createElement=function(a){if(document.createElementNS){return document.createElementNS(_globals.xmlns,a)}else{return document.createElement(a)}};GSUtil.innerXHTML=function(d,g){if(window.DOMParser){var h=new DOMParser();var f=h.parseFromString(g,"application/xhtml+xml");var b=f.documentElement;for(var c=0,a=b.childNodes.length;c<a;c++){d.appendChild(document.importNode(b.childNodes[c],true))}}else{d.innerHTML=g}};GSUtil.createContainer=function(i,f,c,j,d,h,b,g){var a=GSUtil.createElement("div");i.appendChild(a);a.className=f;if(c){a.style.width=c=="auto"?"auto":c+"px"}if(j){a.style.height=j=="auto"?"auto":j+"px"}if(d||h||d==0||h==0){a.style.position="absolute";a.style.left=d+"px";a.style.top=h+"px"}if(b){a.style.visibility=b}if(g!=undefined){a.style.zIndex=g}return a};GSUtil.createImage=function(b,a,c,l,f,k,j,i,h,d){var g=null;var m=a.substring(a.lastIndexOf(".")+1);if(m.toLowerCase()=="png"&&_browser.pngAlpha){d=d?d:"scale";g=GSUtil.createElement("div");g.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+a+"',sizingMethod='"+d+"')"}else{g=GSUtil.createElement("img");g.src=a;g.border=0;g.margin=0;g.padding=0}g.id=b;if(c||l){g.width=c;g.height=l;g.style.width=c+"px";g.style.height=l+"px"}if(f||k||f==0||k==0){g.style.position="absolute";g.style.left=f+"px";g.style.top=k+"px"}if(i!=undefined){g.className=i}if(j!=null){g.style.zIndex=j}if(h!=undefined){g.title=h}if(_browser.isIE){g.setAttribute("galleryimg","no");g.unselectable="on";g.onselectstart=GSUtil.cancelEvent}else{g.style.MozUserSelect="none"}return g};GSUtil.setImageSrc=function(b,c){var a=c.substring(c.lastIndexOf(".")+1);if(a.toLowerCase()=="png"&&_browser.pngAlpha){b.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+c+"',sizingMethod='image')"}else{b.src=c}};GSUtil.getImageSrc=function(c){var d="";if(c.src!=undefined){d=c.src}if(c.style.filter){var b=/src='([^']+)'/;var a=c.style.filter.match(b);d=a[1]}return d};GSUtil.createImageMap=function(b,i,k,c,h,f,g,j){var a=GSUtil.createElement("map");a.id=b;a.setAttribute("name",b);var d=GSUtil.createElement("area");d.setAttribute("shape",i);d.setAttribute("coords",k.toString());d.setAttribute("href",c);d.setAttribute("title",h);if(j!=undefined){d.peer=j}if(g!=undefined){GSEventManager.addEventListener(d,f,g)}a.appendChild(d);return a};GSUtil.getTransparentBackgroundImageStyleRule=function(a,b){if(_browser.pngAlpha){return'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+a+'", sizingMethod="scale"); background-repeat: '+b}else{return"background: url("+a+") "+b}};GSUtil.setOpacity=function(b,a){a=(a==100)?99.999:a;b.style.filter="alpha(opacity:"+a+")";b.style.KHTMLOpacity=a/100;b.style.MozOpacity=a/100;b.style.opacity=a/100};GSUtil.getComputedStyle=function(a,c){if(typeof a=="string"){a=document.getElementById(a)}if(a.style[c]){return a.style[c]}else{if(a.currentStyle){return a.currentStyle[c]}else{if(document.defaultView&&document.defaultView.getComputedStyle){c=c.replace(/([A-Z])/g,"-$1");c=c.toLowerCase();var b=document.defaultView.getComputedStyle(a,"");if(b){return b.getPropertyValue(c)}return null}else{return null}}}};GSUtil.getFeatureById=function(c,f){for(var d=0,b=c.length;d<b;d++){if(c[d].id==f){return c[d]}}return undefined};GSUtil.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)};GSUtil.getBaseName=function(a){return a.substring(a.lastIndexOf("/")+1)};GSUtil.getBaseNameWithoutExtension=function(b){var a=GSUtil.getBaseName(b);return a.substring(0,a.indexOf("."))};GSUtil.getDirName=function(a){return a.substring(0,a.lastIndexOf("/"))};GSUtil.clone=function(f,a){try{var b=new f.constructor();for(var c in f){if(!a){if(c!="eventListeners"){b[c]=f[c]}}else{if(c!="eventListeners"){if(typeof f[c]=="object"){b[c]=GSUtil.clone(f[c],a)}else{b[c]=f[c]}}}}return b}catch(d){return undefined}};GSUtil.toXML=function(c){try{if(typeof ActiveXObject!="undefined"&&typeof GetObject!="undefined"){var b=new ActiveXObject("Microsoft.XMLDOM");b.loadXML(c);return b}else{if(typeof DOMParser!="undefined"){return(new DOMParser()).parseFromString(c,"text/xml")}else{return undefined}}}catch(a){alert("parse error: "+a.message);return undefined}};GSUtil.stringToBoolean=function(a){if(!a){return false}if(a=="true"){return true}if(a=="false"){return false}if(a=="yes"){return true}if(a=="no"){return false}return a==true};GSUtil.getCaseInsensitiveProperty=function(d,b,a){if(!d||!(d instanceof Object)){return undefined}var c=undefined;if(d[b]!=undefined){c=d[b]}else{if(d[b.toLowerCase()]){c=d[b.toLowerCase()]}}if(c!=undefined&&(typeof c).toLowerCase()=="string"&&c!="null"){return c}else{return c!=undefined?c:(a!=undefined?a:undefined)}};GSUtil.populateTemplate=function(d,a,c){for(var b in a){var f=new RegExp("{"+b+"}","g");d=d.replace(f,a[b]?a[b]:"")}if(c){for(var b in c){var f=new RegExp("{"+b+"}","g");d=d.replace(f,c[b]?c[b]:"")}}return d};GSUtil.joinAssociativeArray=function(f,d,c){var b=[];for(var a in f){b.push(a+c+(f[a]!=undefined?f[a]:""))}return b.join(d)};GSUtil.getParameter=function(c,b,a){if(c[b]==undefined){if(arguments.length<3){throw new Error("Missing parameter: "+b)}else{return a}}else{return c[b]}};GSUtil.makeUnselectable=function(a){if(typeof a.style.MozUserSelect=="string"){a.style.MozUserSelect="none"}else{if(typeof a.style.KhtmlUserSelect!="undefined"){a.style.KhtmlUserSelect="none"}else{if(typeof a.onselectstart!="undefined"){a.setAttribute("galleryimg","no");a.onselectstart=function(){return false}}}}};GSUtil.objToJson=function(f){var c=["{"];var d,a;for(d in f){if(f.hasOwnProperty(d)){if(a){c.push(",")}a=true;c.push(d,":",((typeof f[d])=="object"&&f[d].toJson?f[d].toJson():GSUtil.serialize(f[d])))}}c.push("}");return c.join("")};GSUtil.arrayToJson=function(g){var f=["["];var c;for(var h=0,d=g.length;h<d;h++){if(c){f.push(",")}c=true;f.push(g[h].toJson?g[h].toJson():GSUtil.serialize(g[h]))}f.push("]");return f.join("")};GSUtil.serialize=function(a){switch(typeof a){case"object":if(a instanceof Array){return GSUtil.arrayToJson(a)}else{return GSUtil.objToJson(a)}case"string":return'"'+a+'"';case"number":return isFinite(a)?String(a):"null";case"boolean":return String(a);default:return""}};GSUtil.toCC=function(d){var b={};for(var c in d){var a=c;for(var f=/-([a-z])/;f.test(a);a=a.replace(f,RegExp.$1.toUpperCase())){}b[a]=d[c]}return b};GSUtil.getMinimumBoundingRectangle=function(d){var b=[];for(var j=0,g=d.length;j<g;j++){var k=d[j];if(k.getBounds){b.push(k.getBounds())}}var h=GSUtil.getMinimum(GSUtil.getPropertyArray(b,"minX"));var f=GSUtil.getMinimum(GSUtil.getPropertyArray(b,"minY"));var c=GSUtil.getMaximum(GSUtil.getPropertyArray(b,"maxX"));var a=GSUtil.getMaximum(GSUtil.getPropertyArray(b,"maxY"));return new GSBounds(h,f,c,a)};GSUtil.bind=function(c,b){var a=GSUtil.toArray(arguments);c=a.shift(),b=a.shift();return function(){return c.apply(b,a.concat(GSUtil.toArray(arguments)))}};GSUtil.bindAsEventListener=function(c,b){var a=GSUtil.toArray(arguments);c=a.shift(),b=a.shift();return function(d){return c.apply(b,[d||window.event].concat(a))}};GSUtil.toArray=function(f){var c=[];for(var d=0,b=f.length;d<b;d++){c.push(f[d])}return c};_globals={xmlns:"http://www.w3.org/1999/xhtml",svgns:"http://www.w3.org/2000/svg",vmlns:"urn:schemas-microsoft-com:vml",vmlnsPrefix:"v",nzCenterX:2530000,nzCenterY:5990000,nzTopY:6748000,resourceURL:"http://api.geosmart.co.nz/images/sfapi-v3-b/",tilePxWidth:256,tilePxHeight:256,tilesURL:(document.location.protocol.indexOf("http")==-1?"http:":document.location.protocol)+"//tiles.geosmart.co.nz/nz/v14/carto",multipleTileHosts:true,loggingEnabled:false,loggingBaseURL:"http://logs.geosmart.co.nz/",loggingSessionTimeout:20*(1000*60),maps:[],DEBUG:false};var GSKeyEvents={KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34};function Console(){win=null}Console.prototype={debug:function(a){if((this.win==null)||(this.win.closed)){this.win=window.open("","console","width=600,height=300,screenX=400,resizable,scrollbars=yes");this.win.document.open("text/html")}this.win.focus();a=new Date().toLocaleTimeString()+" "+a+"<br/>";this.win.document.writeln(a)}};var _console=new Console();function GSAnimator(h,g,b,f,a,c,d){this.from=h;this.to=g;this.framerate=b;this.duration=f;this.setvalue=a;this.onstart=c;this.onfinish=d;this.currentValue=h;this.startTime=0;this.timer=undefined}GSAnimator.prototype.animate=function(){if(!this.timer){this.startTime=new Date().getTime()-this.framerate}this.timer=setInterval(GSUtil.bind(this.frame,this),this.framerate);if(this.onstart){this.onstart(this)}};GSAnimator.prototype.frame=function(){var b=new Date().getTime()-this.startTime;if(b>=this.duration){this.stopAnimate();this.currentValue=this.to;this.setvalue(this,this.currentValue);if(this.onfinish){setTimeout(GSUtil.bind(this.onfinish,this,this),0)}}else{var c=0.5-(0.5*Math.cos(Math.PI*Math.max(b,0)/this.duration));var a=this.interpolate(this.from.x,this.to.x,c);var d=this.interpolate(this.from.y,this.to.y,c);this.currentValue=new GSPoint(a,d);this.setvalue(this,this.currentValue)}};GSAnimator.prototype.stopAnimate=function(){if(this.timer){clearInterval(this.timer);this.timer=null}};GSAnimator.prototype.interpolate=function(c,b,a){return c+(b-c)*a};function GSBounds(a,d,c,b){this.minX=parseFloat(a);this.minY=parseFloat(d);this.maxX=parseFloat(c);this.maxY=parseFloat(b)}GSBounds.prototype.contains=function(a){return(a.x>=this.minX&&a.x<=this.maxX)&&(a.y>=this.minY&&a.y<=this.maxY)};GSBounds.prototype.toString=function(){return"Bounds: minX=["+this.minX+"], minY=["+this.minY+"], maxX=["+this.maxX+"], maxY=["+this.maxY+"]"};function GSBrowser(){var a=navigator.userAgent.toLowerCase();this.isFirefox=a.indexOf("firefox")!=-1;this.firefoxVersion=parseFloat(a.substring(a.indexOf("firefox")+8));this.isWebkit=a.indexOf("applewebkit")!=-1;this.webkitVersion=a.substr(a.indexOf("applewebkit")+12,3);this.isGecko=!this.isWebkit&&a.indexOf("gecko")!=-1;this.isCamino=a.indexOf("camino")!=-1;this.caminoVersion=parseFloat(a.substring(a.indexOf("camino")+7));this.isIE=((a.indexOf("msie")!=-1)&&(a.indexOf("opera")==-1));this.versionMinor=parseFloat(navigator.appVersion);if(this.isIE&&this.versionMinor>=4){this.versionMinor=parseFloat(a.substring(a.indexOf("msie ")+5))}this.versionMajor=parseInt(this.versionMinor);this.isIE6x=(this.isIE&&this.versionMajor==6);this.isIE6up=(this.isIE&&this.versionMajor>=6);this.isIE7x=(this.isIE&&this.versionMajor==7);this.isOpera=a.indexOf("opera")!=-1;this.isWin=(a.indexOf("win")!=-1);this.isWin32=(this.isWin&&(a.indexOf("95")!=-1||a.indexOf("98")!=-1||a.indexOf("nt")!=-1||a.indexOf("win32")!=-1||a.indexOf("32bit")!=-1));this.pngAlpha=(this.isIE6x&&this.isWin32);this.svg=((this.isFirefox&&this.firefoxVersion>=1.5)||(this.isCamino&&this.caminoVersion>=1)||(this.isOpera&&this.versionMajor>=8)||(this.isWebkit&&this.webkitVersion>=500))}GSBrowser.prototype.isSmartfindCompatible=function(){return(this.isIE6up||this.isGecko||this.isWebkit)};GSBrowser.prototype.isVectorGraphicsCapable=function(){return(this.isIE6up||this.svg)};_browser=new GSBrowser();function GSControl(a){this.name=a;this.element;this.map=null;this.position=null;this.hidden=false}GSControl.prototype.setElement=function(a){this.element=a;this.element.style.zIndex=10;if(!this.element.style.cursor){this.element.style.cursor="default"}};GSControl.prototype.setPosition=function(a){if(!a.offset){a.offset=new GSPoint(0,0)}switch(a.anchor){case GSControl.ANCHOR_TOP_LEFT:GSUtil.positionElement(this.element,a.offset.x,a.offset.y);break;case GSControl.ANCHOR_TOP_RIGHT:GSUtil.positionElement(this.element,null,a.offset.x,a.offset.y);break;case GSControl.ANCHOR_BOTTOM_LEFT:GSUtil.positionElement(this.element,a.offset.x,null,null,a.offset.y);break;case GSControl.ANCHOR_BOTTOM_RIGHT:GSUtil.positionElement(this.element,null,null,a.offset.x,a.offset.y);break;case GSControl.ANCHOR_CENTER:GSUtil.positionElement(this.element,((this.map.pxWidth-this.element.offsetWidth)/2)+a.offset.x,((this.map.pxHeight-this.element.offsetHeight)/2)+a.offset.y);break}this.position=a};GSControl.prototype.getPosition=function(){return this.position};GSControl.prototype.render=function(a){};GSControl.prototype.getDefaultPosition=function(){return{anchor:GSControl.ANCHOR_TOP_LEFT,offset:new GSPoint(7,7)}};GSControl.prototype.getWidth=function(){return 0};GSControl.prototype.getHeight=function(){return 0};GSControl.prototype.getOrientation=function(){return undefined};GSControl.prototype.remove=function(b){try{b.container.removeChild(this.element)}catch(a){}this.element=null};GSControl.prototype.hide=function(){this.element.style.visibility="hidden";this.hidden=true};GSControl.prototype.show=function(){this.element.style.visibility="visible";this.hidden=false};GSControl.ANCHOR_TOP_LEFT=0;GSControl.ANCHOR_TOP_RIGHT=1;GSControl.ANCHOR_BOTTOM_LEFT=2;GSControl.ANCHOR_BOTTOM_RIGHT=3;GSControl.ANCHOR_CENTER=4;GSUtil.extend(GSCompactZoomControl,GSControl);function GSCompactZoomControl(){GSCompactZoomControl.baseConstructor.call(this,GSMap.COMPACT_ZOOM_CONTROL);this.width=22;this.height=43}GSCompactZoomControl.prototype.render=function(c){this.map=c;var b=GSUtil.createElement("div");b.style.width=this.width+"px";b.style.height=this.height+"px";var f=GSUtil.createImage("gscompactzoomcontrol-shadow",_globals.resourceURL+"smallZoomBG.png",22,43,0,0,0,"noprint",undefined,"image");GSEventManager.addEventListener(f,"contextmenu",GSUtil.cancelEvent);b.appendChild(f);var d=GSUtil.createImage("gscompactzoomcontrol_zoomin",_globals.resourceURL+"zoomIn.png",14,13,2,3,10,"noprint","Zoom in","image");d.style.cursor="pointer";b.appendChild(d);GSEventManager.addEventListener(d,"click",GSUtil.bindAsEventListener(this.zoomIn,this));GSEventManager.addEventListener(d,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(d,"contextmenu",GSUtil.cancelEvent);var a=GSUtil.createImage("gscompactzoomcontrol_zoomout",_globals.resourceURL+"zoomOut.png",14,13,2,22,10,"noprint","Zoom out","image");a.style.cursor="pointer";b.appendChild(a);GSEventManager.addEventListener(a,"click",GSUtil.bindAsEventListener(this.zoomOut,this));GSEventManager.addEventListener(a,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(a,"contextmenu",GSUtil.cancelEvent);return b};GSCompactZoomControl.prototype.zoomIn=function(a){GSUtil.cancelEvent(a);var b=this.map.getZoomLevel();if(b-1<0){return}this.map.zoom(b-1)};GSCompactZoomControl.prototype.zoomOut=function(a){GSUtil.cancelEvent(a);var b=this.map.getZoomLevel();if(b+1>=this.map.scaleRange.length){return}this.map.zoom(b+1)};GSUtil.extend(GSMapControl,GSControl);function GSMapControl(a){GSMapControl.baseConstructor.call(this,GSMap.MAP_CONTROL);this.width=54;this.height=55;this.zoomControl=new GSZoomControl(a)}GSMapControl.prototype.getWidth=function(){return this.width};GSMapControl.prototype.getHeight=function(){return this.height};GSMapControl.prototype.render=function(f){this.map=f;var c=GSUtil.createElement("div");c.style.width=this.width+"px";c.style.height=this.height+"px";var i=GSUtil.createImage("gsmapcontrol-shadow",_globals.resourceURL+"compassBG.png",54,55,0,0,100,"noprint",undefined,"image");GSEventManager.addEventListener(i,"contextmenu",GSUtil.cancelEvent);c.appendChild(i);var a=GSUtil.createImage("gsmapcontrol_up",_globals.resourceURL+"arrowUp.png",14,13,18,3,100,"noprint","Move up","image");a.style.cursor="pointer";GSEventManager.addEventListener(a,"click",GSUtil.bindAsEventListener(this.panTo,this,"up"));GSEventManager.addEventListener(a,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(a,"contextmenu",GSUtil.cancelEvent);c.appendChild(a);var d=GSUtil.createImage("gsmapcontrol_left",_globals.resourceURL+"arrowLeft.png",14,13,3,19,100,"noprint","Move left","image");d.style.cursor="pointer";d.direction="left";GSEventManager.addEventListener(d,"click",GSUtil.bindAsEventListener(this.panTo,this,"left"));GSEventManager.addEventListener(d,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(d,"contextmenu",GSUtil.cancelEvent);c.appendChild(d);var b=GSUtil.createImage("gsmapcontrol_right",_globals.resourceURL+"arrowRight.png",14,13,33,19,100,"noprint","Move right","image");b.style.cursor="pointer";b.direction="right";GSEventManager.addEventListener(b,"click",GSUtil.bindAsEventListener(this.panTo,this,"right"));GSEventManager.addEventListener(b,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(b,"contextmenu",GSUtil.cancelEvent);c.appendChild(b);var h=GSUtil.createImage("gsmapcontrol_down",_globals.resourceURL+"arrowDown.png",14,13,18,35,100,"noprint","Move down","image");h.style.cursor="pointer";h.direction="down";GSEventManager.addEventListener(h,"click",GSUtil.bindAsEventListener(this.panTo,this,"down"));GSEventManager.addEventListener(h,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(h,"contextmenu",GSUtil.cancelEvent);c.appendChild(h);var g=this.zoomControl.render(f);f.container.appendChild(g);this.zoomControl.setElement(g);return c};GSMapControl.prototype.hide=function(){this.zoomControl.hide();GSMapControl.superClass.hide.call(this)};GSMapControl.prototype.show=function(){this.zoomControl.show();GSMapControl.superClass.show.call(this)};GSMapControl.prototype.setPosition=function(a){if(a.anchor==GSControl.ANCHOR_TOP_LEFT||a.anchor==GSControl.ANCHOR_BOTTOM_LEFT){this.zoomControl.setPosition({anchor:a.anchor,offset:new GSPoint(21,65)})}else{this.zoomControl.setPosition({anchor:a.anchor,offset:new GSPoint(25,65)})}GSMapControl.superClass.setPosition.call(this,a)};GSMapControl.prototype.panTo=function(f,h){var i=0.25;var a=this.map.getBounds();var g=this.map.getMapCenter();var b=a.maxX-a.minX;var l=a.maxY-a.minY;var d=g.x;var c=g.y;switch(h){case"up":var j=i*l;c+=j;break;case"left":var j=i*b;d-=j;break;case"right":var j=i*b;d+=j;break;case"down":var j=i*l;c-=j;break}var k=new GSPoint(d,c);this.map.centerAtCoordinate(k);GSUtil.cancelEvent(f)};GSMapControl.prototype.remove=function(a){this.zoomControl.remove(a);GSMapControl.superClass.remove.call(this,a)};GSUtil.extend(GSRubberbandControl,GSControl);function GSRubberbandControl(a){this.options={modifierKey:undefined,fill:"#a80510",fillOpacity:25,stroke:"#a80510",strokeOpacity:100,strokeWidth:1};GSUtil.merge(a,this.options);GSRubberbandControl.baseConstructor.call(this,"rubberband-control");this.dragging=false;this.eventListeners={}}GSRubberbandControl.prototype.getDefaultPosition=function(){return{anchor:GSControl.ANCHOR_CENTER}};GSRubberbandControl.prototype.render=function(a){this.map=a;this.map.addListener(this);GSEventManager.bind(document,"keypress",this,this.handleKeyPress);return this.createElement()};GSRubberbandControl.prototype.handleKeyPress=function(a){if(a.keyCode==27){this.reset()}};GSRubberbandControl.prototype.createElement=function(){var element=GSUtil.createElement("div");element.style.visibility="hidden";this.fill=GSUtil.createElement("div");with(this.fill.style){position="absolute";backgroundColor=this.options.fill}GSUtil.setOpacity(this.fill,this.options.fillOpacity);element.appendChild(this.fill);this.stroke=GSUtil.createElement("div");with(this.stroke.style){position="absolute";border=this.options.strokeWidth+"px solid "+this.options.stroke}GSUtil.setOpacity(this.stroke,this.options.strokeOpacity);element.appendChild(this.stroke);return element};GSRubberbandControl.prototype.mapClicked=function(c,d,b){if(!this.dragging){if(this.options.modifierKey){var a=this.options.modifierKey.toLowerCase()+"Key";if(b[a]){this.dragStart(b)}}else{this.dragStart(b)}}else{this.dragStop(b)}GSUtil.cancelEvent(b)};GSRubberbandControl.prototype.dragStart=function(a){this.dragging=true;this.eventListeners.mousemove=GSEventManager.bind(document,"mousemove",this,this.dragMove);this.startPos=GSUtil.getMousePos(a);GSUtil.positionElement(this.element,this.startPos.x,this.startPos.y);document.body.style.cursor="crosshair";this.element.style.visibility="visible"};GSRubberbandControl.prototype.dragMove=function(c){var d=GSUtil.getMousePos(c);var b=d.x-this.startPos.x;var a=d.y-this.startPos.y;this.element.style.width=Math.abs(b)+"px";this.element.style.height=Math.abs(a)+"px";this.fill.style.width=Math.abs(b)+"px";this.fill.style.height=Math.abs(a)+"px";this.stroke.style.width=Math.abs(b)-2+"px";this.stroke.style.height=Math.abs(a)-2+"px";if(b<0){this.element.style.left=(this.startPos.x-Math.abs(b))+"px"}if(a<0){this.element.style.top=(this.startPos.y-Math.abs(a))+"px"}GSUtil.cancelEvent(c)};GSRubberbandControl.prototype.dragStop=function(a){GSEventManager.release(this.eventListeners.mousemove);this.zoom(a);this.reset();this.dragging=false};GSRubberbandControl.prototype.reset=function(){with(this.element.style){width="0px";height="0px";visibility="hidden"}with(this.fill.style){width="0px";height="0px"}with(this.stroke.style){width="0px";height="0px"}document.body.style.cursor="default"};GSRubberbandControl.prototype.zoom=function(d){var b=this.map.translateToRealWorldCoordinate(this.startPos);var a=this.map.getMouseCoordinate(d);var c=new GSBounds(b.x,b.y,a.x,a.y);this.map.setBounds(c)};GSUtil.extend(GSSnapbackControl,GSControl);function GSSnapbackControl(a){GSSnapbackControl.baseConstructor.call(this,GSMap.SNAPBACK_CONTROL);if(!a){a={}}this.options=a;this.width=16;this.height=16;this.tooltip=this.options.tooltip?this.options.tooltip:"Snapback to saved map position"}GSSnapbackControl.prototype.getWidth=function(){return this.width};GSSnapbackControl.prototype.getHeight=function(){return this.height};GSSnapbackControl.prototype.getDefaultPosition=function(){return{anchor:GSControl.ANCHOR_TOP_RIGHT,offset:new GSPoint(7,7)}};GSSnapbackControl.prototype.render=function(b){this.map=b;var a=GSUtil.createImage("snapback-control",_globals.resourceURL+"snapback.png",this.width,this.height,undefined,undefined,10,"noprint",this.tooltip,"image");a.style.cursor="pointer";GSEventManager.bind(a,"click",this,this.snapback);return a};GSSnapbackControl.prototype.snapback=function(a){GSUtil.cancelEvent(a);this.map.snapback()};GSUtil.extend(GSScalebarControl,GSControl);function GSScalebarControl(){GSSnapbackControl.baseConstructor.call(this,GSMap.SCALEBAR_CONTROL);this.width=220;this.height=30;this.scalebarPreloads=[]}GSScalebarControl.prototype.getWidth=function(){return this.width};GSScalebarControl.prototype.getHeight=function(){return this.height};GSScalebarControl.prototype.getDefaultPosition=function(){return{anchor:GSControl.ANCHOR_BOTTOM_LEFT,offset:new GSPoint(7,7)}};GSScalebarControl.prototype.render=function(a){this.map=a;this.preloadScalebarImages();var b=_globals.resourceURL+"scalebar/"+a.scaleIdx+".png";element=GSUtil.createImage("scalebar",b,this.width,this.height,null,null,20,"noprint","","image");GSEventManager.addEventListener(element,"contextmenu",GSUtil.cancelEvent);this.map.addListener(this);return element};GSScalebarControl.prototype.preloadScalebarImages=function(){var b;for(var c=0,a=this.map.scaleRange.length;c<a;c++){b=new Image();b.src=_globals.resourceURL+"scalebar/"+c+".png";this.scalebarPreloads.push(b)}};GSScalebarControl.prototype.mapBoundsChanged=function(c,a,b){this.updateScalebar()};GSScalebarControl.prototype.mapZoomed=function(c,b,a){this.updateScalebar()};GSScalebarControl.prototype.updateScalebar=function(){var a=_globals.resourceURL+"scalebar/"+this.map.scaleIdx+".png";GSUtil.setImageSrc(this.element,a)};GSUtil.extend(GSTextZoomControl,GSControl);function GSTextZoomControl(a){GSTextZoomControl.baseConstructor.call(this,GSMap.TEXT_ZOOM_CONTROL);this.labels=a;if(!this.labels){this.labels=[{level:9,value:"Region"},{level:7,value:"District"},{level:3,value:"Suburb"},{level:1,value:"Street"}]}}GSTextZoomControl.prototype.getWidth=function(){return this.element.offsetWidth};GSTextZoomControl.prototype.getHeight=function(){return this.element.offsetHeight};GSTextZoomControl.prototype.render=function(f){var c=GSUtil.createElement("div");for(var b=0,a=this.labels.length;b<a;b++){var d=GSUtil.createElement("a");d.href="#";GSEventManager.addEventListener(d,"click",GSUtil.bindAsEventListener(this.zoom,this,this.labels[b].level));d.className="GSTextZoomControl";d.innerHTML=this.labels[b].value;c.appendChild(d);if(b<a-1){c.appendChild(document.createTextNode(" | "))}}this.element=c;return c};GSTextZoomControl.prototype.zoom=function(a,b){this.map.zoom(b);GSUtil.cancelEvent(a)};GSUtil.extend(GSZoomControl,GSControl);function GSZoomControl(a){GSZoomControl.baseConstructor.call(this,GSMap.ZOOM_CONTROL);this.sliderBar=null;this.sliderThumb=null;this.labelContainer=null;this.zooming=false;this.width=22;this.height=135;this.labels=a}GSZoomControl.prototype.getWidth=function(){return this.width};GSZoomControl.prototype.getHeight=function(){return this.height};GSZoomControl.prototype.render=function(h){this.map=h;var d=GSUtil.createElement("div");d.style.width=this.width+"px";d.style.height=this.height+"px";this.map.addListener(this);var g=GSUtil.createElement("div");g.style.position="absolute";g.style.left="2px";g.style.top="0px";d.appendChild(g);var b=GSUtil.createImage("gszoomcontrol_zoomin",_globals.resourceURL+"zoomIn.png",14,13,2,3,110,"noprint","Zoom in","image");b.style.cursor="pointer";g.appendChild(b);var f=GSUtil.createImage("gszoomcontrol_zoomout",_globals.resourceURL+"zoomOut.png",14,13,2,115,110,"noprint","Zoom out","image");f.style.cursor="pointer";g.appendChild(f);this.sliderBar=GSUtil.createImage("gszoomcontrol_sliderbar",_globals.resourceURL+"sliderBG.png",22,135,0,0,100,"noprint","Click to set zoom level","image");this.sliderBar.style.cursor="pointer";g.appendChild(this.sliderBar);this.sliderThumb=GSUtil.createImage("gszoomcontrol_sliderthumb",_globals.resourceURL+"sliderThumb.png",15,12,1,GSZoomControl.SLIDER_MAX-4,115,"noprint","Drag to zoom","image");if(!_browser.isWebkit){this.sliderThumb.style.cursor="url("+_globals.resourceURL+"cursor-grab.cur),-moz-grab"}else{this.sliderThumb.style.cursor="pointer"}if(this.labels){this.labelContainer=GSUtil.createElement("div");this.labelContainer.style.position="absolute";this.labelContainer.style.display="none";g.appendChild(this.labelContainer);for(var c=0,a=this.labels.length;c<a;c++){this.createLabel(this.labelContainer,this.labels[c])}}GSEventManager.addEventListener(b,"click",GSUtil.bindAsEventListener(this.zoomIn,this));GSEventManager.addEventListener(b,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(b,"contextmenu",GSUtil.cancelEvent);GSEventManager.addEventListener(f,"click",GSUtil.bindAsEventListener(this.zoomOut,this));GSEventManager.addEventListener(f,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(f,"contextmenu",GSUtil.cancelEvent);GSDrag.init(this.sliderThumb,null,1,1,GSZoomControl.SLIDER_MIN,GSZoomControl.SLIDER_MAX);this.sliderThumb.onDragStart=GSUtil.bind(this.dragStartHandler,this);this.sliderThumb.onDragEnd=GSUtil.bind(this.dragEndHandler,this);GSEventManager.bind(this.sliderBar,"click",this,this.sliderClicked);GSEventManager.addEventListener(this.sliderBar,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(this.sliderBar,"contextmenu",GSUtil.cancelEvent);g.appendChild(this.sliderThumb);if(this.labels){GSEventManager.addEventListener(this.sliderBar,"mouseover",GSUtil.bindAsEventListener(this.showLabels,this));GSEventManager.addEventListener(this.sliderBar,"mouseout",GSUtil.bindAsEventListener(this.delayHideLabels,this))}this.mapBoundsChanged(this.map);return d};GSZoomControl.prototype.showLabels=function(a){this.labelContainer.style.display="block";GSUtil.cancelEvent(a)};GSZoomControl.prototype.delayHideLabels=function(a){setTimeout(GSUtil.bind(this.hideLabels,this),3000);GSUtil.cancelEvent(a)};GSZoomControl.prototype.hideLabels=function(){this.labelContainer.style.display="none"};GSZoomControl.prototype.createLabel=function(c,b){var d=GSUtil.createElement("div");d.style.cursor="pointer";d.style.position="absolute";d.style.left="16px";d.style.top=(GSZoomControl.SLIDER_OFFSET+(b.level*GSZoomControl.SLIDER_INCREMENT))+"px";d.style.zIndex=115;c.appendChild(d);var a=GSUtil.createImage(null,_globals.resourceURL+"zoomLabel.png",82,17,0,-2,0,"noprint",undefined,"image");d.img=a;d.appendChild(a);var f=GSUtil.createElement("div");f.style.width="76px";f.style.paddingRight="6px";f.style.textAlign="right";f.style.fontFamily="Arial, Helvetica, Sans-serif";f.style.fontWeight="bold";f.style.fontSize="11px";f.style.lineHeight="11px";f.style.position="absolute";f.style.top="1px";f.innerHTML=b.value;GSUtil.makeUnselectable(f);d.appendChild(f);GSEventManager.addEventListener(d,"click",GSUtil.bindAsEventListener(this.zoom,this,b.level));GSEventManager.addEventListener(d,"mouseover",GSUtil.bindAsEventListener(this.onLabelOver,d));GSEventManager.addEventListener(d,"mouseout",GSUtil.bindAsEventListener(this.onLabelOut,d));GSEventManager.addEventListener(d,"contextmenu",GSUtil.cancelEvent)};GSZoomControl.prototype.zoom=function(a,b){this.map.zoom(b);GSUtil.cancelEvent(a)};GSZoomControl.prototype.onLabelOver=function(a){GSUtil.setImageSrc(this.img,_globals.resourceURL+"zoomLabelOver.png")};GSZoomControl.prototype.onLabelOut=function(a){GSUtil.setImageSrc(this.img,_globals.resourceURL+"zoomLabel.png")};GSZoomControl.prototype.zoomIn=function(a){GSUtil.cancelEvent(a);var b=this.map.getZoomLevel();if(b-1<0){return}this.map.zoom(b-1)};GSZoomControl.prototype.zoomOut=function(a){GSUtil.cancelEvent(a);var b=this.map.getZoomLevel();if(b+1>=this.map.scaleRange.length){return}this.map.zoom(b+1)};GSZoomControl.prototype.dragStartHandler=function(a,b){if(!_browser.isWebkit){this.sliderThumb.style.cursor="url("+_globals.resourceURL+"cursor-grabbing.cur),-moz-grabbing"}};GSZoomControl.prototype.dragEndHandler=function(a,b){if(!_browser.isWebkit){this.sliderThumb.style.cursor="url("+_globals.resourceURL+"cursor-grab.cur),-moz-grab"}this.sliderMoved(a,b)};GSZoomControl.prototype.sliderClicked=function(g){GSUtil.cancelEvent(g);var d,b;if(_browser.isIE){d=g.offsetX;b=g.offsetY}else{d=(window.pageXOffset+g.clientX-GSUtil.findPosX(this.sliderBar));b=(window.pageYOffset+g.clientY-GSUtil.findPosY(this.sliderBar))}if(b<GSZoomControl.SLIDER_MIN||b>GSZoomControl.SLIDER_MAX){return}var f=this;var j=GSUtil.bind(this.onSlideFrame,this);var a=GSUtil.bind(this.onSlideComplete,this,d,b);var h=new GSPoint(parseInt(this.sliderThumb.style.left),parseInt(this.sliderThumb.style.top));var i=new GSPoint(parseInt(this.sliderThumb.style.left),b);var c=new GSAnimator(h,i,16,500,j,null,a);c.animate()};GSZoomControl.prototype.onSlideFrame=function(b,a){this.sliderThumb.style.top=a.y+"px"};GSZoomControl.prototype.onSlideComplete=function(c,b,a){this.sliderMoved(c,b)};GSZoomControl.prototype.sliderMoved=function(a,c){this.zooming=true;var b=Math.round((c-GSZoomControl.SLIDER_OFFSET)/GSZoomControl.SLIDER_INCREMENT);this.map.zoom(b)};GSZoomControl.prototype.mapBoundsChanged=function(d,b,c){var a=this.map.scaleIdx;this.mapZoomed(this.map,null,a)};GSZoomControl.prototype.mapZoomed=function(c,b,a){var d=Math.round(a*GSZoomControl.SLIDER_INCREMENT);d+=GSZoomControl.SLIDER_OFFSET;d=d<GSZoomControl.SLIDER_MIN?GSZoomControl.SLIDER_MIN:d>GSZoomControl.SLIDER_MAX?GSZoomControl.SLIDER_MAX:d;this.sliderThumb.style.top=d+"px"};GSZoomControl.prototype.remove=function(a){this.map.removeListener(this);this.labelContainer=null;this.sliderBar=null;GSDrag.obj=null;this.sliderThumb.root=null;this.sliderThumb=null;GSZoomControl.superClass.remove.call(this,a)};GSZoomControl.SLIDER_OFFSET=22;GSZoomControl.SLIDER_INCREMENT=7;GSZoomControl.SLIDER_MIN=22;GSZoomControl.SLIDER_MAX=102;function GSDimension(b,a){this.width=parseInt(b);this.height=parseInt(a)}GSDimension.prototype.toString=function(){return"Dimension: width=["+this.width+"], h=["+this.height+"]"};function GSEventBroadcaster(){}GSEventBroadcaster.initialize=function(a){a.listeners=[];a.broadcastMessage=this.broadcastMessage;a.addListener=this.addListener;a.removeListener=this.removeListener};GSEventBroadcaster.broadcastMessage=function(){var b=arguments[0];var c=[];for(var d=1,a=arguments.length;d<a;d++){c.push(arguments[d])}var f=[];for(var d=0,a=this.listeners.length;d<a;d++){f.push(this.listeners[d])}for(var d=0;d<f.length;d++){if(f[d][b]){f[d][b].apply(f[d],c)}}};GSEventBroadcaster.addListener=function(a){this.removeListener(a);this.listeners.push(a);return true};GSEventBroadcaster.removeListener=function(c){for(var b=0,a=this.listeners.length;b<a;b++){if(this.listeners[b]===c){this.listeners.splice(b,1);return true}}return false};function GSEventManager(){}GSEventManager.bind=function(h,g,c,j){var d=[];for(var f=4,b=arguments.length;f<b;f++){d.push(arguments[f])}var a=GSEventManager.createAdapter(c,j,d);return GSEventManager.addEventListener(h,g,a)};GSEventManager.createAdapter=function(a,c){var b=GSUtil.toArray(arguments);a=b.shift();c=b.shift();return function(d){return c.apply(a,[d||window.event].concat(b[0]))}};GSEventManager.release=function(a){GSEventManager.removeEventListener(a)};GSEventManager.addEventListener=function(c,a,b){if(_browser.isWebkit&&a=="dblclick"){c["on"+a]=b;return GSEventCache.add(c,a,b)}if(c.attachEvent){c.attachEvent("on"+a,b)}else{c.addEventListener(a,b,false)}return GSEventCache.add(c,a,b)};GSEventManager.removeEventListener=function(a){GSEventCache.remove(a)};var GSEventCache=function(){var c=0;var b={};var a={handlerId:c,handlers:b,nextHandlerId:function(){return"h"+this.handlerId++},add:function(g,d,f){var h=this.nextHandlerId();this.handlers[h]=arguments;return h},flush:function(){for(var d in this.handlers){this.remove(d)}},remove:function(g){try{var d=this.handlers[g];if(d){if(d[0].removeEventListener){d[0].removeEventListener(d[1],d[2],d[3])}if(d[1].substring(0,2)!="on"){d[1]="on"+d[1]}if(d[0].detachEvent){d[0].detachEvent(d[1],d[2])}d[0][d[1]]=null}this.handlers[g]=undefined;delete this.handlers[g]}catch(f){}}};return a}();function GSUnload(){var d=null;for(var b=0,a=_globals.maps.length;b<a;b++){d=_globals.maps[b];d.remove();for(var c in d){d[c]=null}}}GSEventManager.addEventListener(window,"unload",GSUnload);function GSMouseWheel(){}GSMouseWheel.bind=function(d,a,f,b){var c=(window.addEventListener&&!_browser.isWebkit)?"DOMMouseScroll":"mousewheel";return GSEventManager.addEventListener(d,c,GSUtil.bindAsEventListener(this.wheelHandler,a,f,b))};GSMouseWheel.wheelHandler=function(c,b,a){if(a==undefined||c[a+"Key"]){var d=0;if(c.wheelDelta){d=c.wheelDelta/120;if(window.opera){d=-d}}else{if(c.detail){d=-c.detail/3}}if(d){b.call(this,d)}GSUtil.cancelEvent(c)}};function GSIcon(a){this.imageSrc=undefined;if(a){this.imageSrc=a.imageSrc}this.imageSize=undefined;if(a){this.imageSize=a.imageSize}this.printSrc=undefined;if(a){this.printSrc=a.printSrc}this.printSize=undefined;if(a){this.printSize=a.printSize}this.shadowSrc=undefined;if(a){this.shadowSrc=a.shadowSrc}this.shadowSize=undefined;if(a){this.shadowSize=a.shadowSize}this.alt=undefined;this.iconOffset=new GSPoint(0,0);if(a){this.iconOffset=new GSPoint(a.iconOffset.x,a.iconOffset.y)}this.iconInfoWindowOffset=new GSPoint(0,0);if(a){this.iconInfoWindowOffset=new GSPoint(a.iconInfoWindowOffset.x,a.iconInfoWindowOffset.y)}this.imageMap=undefined;if(a){this.imageMap=a.imageMap}this.imageMapShape="poly";if(a){this.imageMapShape=a.imageMapShape}this.layer=undefined;this.visible=true;this.arcHeight=20}GSIcon.iconId=0;GSIcon.nextId=function(){return GSIcon.iconId++};GSIcon.prototype.initialize=function(){this.image=GSUtil.createImage("",this.imageSrc,this.imageSize.width,this.imageSize.height,0,0,10,"noprint gsicon_image",this.alt,"image");GSEventManager.addEventListener(this.image,"contextmenu",GSUtil.cancelEvent);this.image.style.cursor="pointer";this.dragCrosshair=GSUtil.createImage("",_globals.resourceURL+"dragCross.png",16,16,0,0,0,"noprint",null,"image");this.dragCrosshair.style.display="none";if(_globals.DEBUG){this.image.style.border="1px solid #FF0000"}if(this.printSrc!=null){this.printImage=GSUtil.createImage("",this.printSrc,this.printSize.width,this.printSize.height,0,0,0,"noscreen gsicon_printImage",null,"image")}if(this.shadowSrc!=null){this.shadow=GSUtil.createImage("",this.shadowSrc,this.shadowSize.width,this.shadowSize.height,0,0,0,"noprint gsicon_shadowImage",null,"image");GSEventManager.addEventListener(this.shadow,"contextmenu",GSUtil.cancelEvent)}if(_browser.isGecko&&this.imageMap!=null){var a="map_"+GSIcon.nextId();this.image.setAttribute("usemap",a);this.htmlImageMap=GSUtil.createImageMap(a,this.imageMapShape,this.imageMap,"#",this.alt);GSEventManager.addEventListener(this.htmlImageMap,"contextmenu",GSUtil.cancelEvent)}};GSIcon.prototype.setVisible=function(a){this.visible=a};GSIcon.prototype.addToLayer=function(a){this.layer=a;this.layer.iconContainer.appendChild(this.image);this.layer.iconContainer.appendChild(this.dragCrosshair);if(this.printImage){this.layer.iconContainer.appendChild(this.printImage)}if(this.shadow){this.layer.iconShadowContainer.appendChild(this.shadow)}if(this.htmlImageMap){this.layer.iconContainer.appendChild(this.htmlImageMap)}};GSIcon.prototype.render=function(b,g){if(b.map.contains(g)){var f=b.map.translateToMapCoordinate(g);var d=(f.x+this.iconOffset.x);var c=(f.y+this.iconOffset.y);GSUtil.positionElement(this.image,d,c);if(this.shadow){GSUtil.positionElement(this.shadow,d,c)}if(this.printImage){GSUtil.positionElement(this.printImage,d,c)}var a=this.visible?"visible":"hidden";if(this.printImage){this.printImage.style.visibility=a}if(this.shadow){this.shadow.style.visibility=a}this.image.style.visibility=a;if(_globals.DEBUG){_console.debug("GSIcon: left: "+this.image.style.left+", top: "+this.image.style.top)}return a=="visible"}else{this.image.style.visibility="hidden";if(this.printImage){this.printImage.style.visibility="hidden"}if(this.shadow){this.shadow.style.visibility="hidden"}return false}};GSIcon.prototype.repositionDragCrosshair=function(a,b){GSUtil.positionElement(this.dragCrosshair,a-8,b-8)};GSIcon.prototype.getEventTarget=function(){return this.image};GSIcon.prototype.remove=function(){try{this.layer.iconContainer.removeChild(this.image);this.image=null;if(this.htmlImageMap!=null){this.layer.iconContainer.removeChild(this.htmlImageMap);this.htmlImageMap=null}if(this.printImage!=null){this.layer.iconContainer.removeChild(this.printImage);this.printImage=null}if(this.shadow!=null){this.layer.iconShadowContainer.removeChild(this.shadow);this.shadow=null}}catch(a){}};GSIcon.prototype.toString=function(){var a="";a+=("image src: "+this.imageSrc+"<br/>");a+=("print image src: "+this.printSrc+"<br/>");a+=("shadow image src: "+this.shadowSrc+"<br/>");a+=("icon offset: "+this.iconOffset+"<br/>");a+=("icon info window offset: "+this.iconInfoWindowOffset+"<br/>");if(_browser.isGecko&&this.imageMap){a+=("image map: "+this.imageMap.name)}return a};GSIcon.defaultIcon=new GSIcon();GSIcon.defaultIcon.imageSrc=_globals.resourceURL+"defaultIcon.png";GSIcon.defaultIcon.printSrc=_globals.resourceURL+"defaultIcon.gif";GSIcon.defaultIcon.shadowSrc=_globals.resourceURL+"defaultIconShadow.png";GSIcon.defaultIcon.imageSize=new GSDimension(22,16);GSIcon.defaultIcon.printSize=new GSDimension(22,16);GSIcon.defaultIcon.shadowSize=new GSDimension(25,19);if(_browser.isGecko){GSIcon.defaultIcon.imageMap=[0,0,0,14,16,14,18,15,21,15,21,12,19,10,19,0]}GSIcon.defaultIcon.iconOffset=new GSPoint(-22,-16);GSIcon.defaultIcon.iconInfoWindowOffset=new GSPoint(10,-1);function GSLayer(b,c,a){if(!a){a={}}this.type="GSLayer";this.name=b;this.zIndex=a.zIndex?a.zIndex:0;this.visible=true;this.data=[];this.map=c;this.createOverlayContainers()}GSLayer.prototype.setZIndex=function(a){this.zIndex=a;if(this.contentContainer){this.contentContainer.style.zIndex=a}};GSLayer.prototype.setVisible=function(c){this.visible=c;for(var b=0,a=this.data.length;b<a;b++){this.data[b].setVisible(c);if(c){this.data[b].render()}}};GSLayer.prototype.isVisible=function(){return this.visible};GSLayer.prototype.getFeatures=function(){return this.data};GSLayer.prototype.addFeatures=function(c){for(var b=0,a=c.length;b<a;b++){this.addFeature(c[b])}};GSLayer.prototype.addFeaturesJson=function(h,g){var b;if(arguments.length>2){b=[];for(var d=2,a=arguments.length;d<a;d++){b.push(arguments[d])}}for(var d=0,a=h.length;d<a;d++){var f=h[d].jsclass;if(f){if(window[f]){var c=new window[f](h[d]);if(g){g(c,h[d],b)}this.addFeature(c)}else{throw new Error("Trying to instantiate a non-existent class: "+f)}}}};GSLayer.prototype.addFeature=function(a){this.data.push(a);a.setVisible(this.visible);a.addToLayer(this);if(a.snappable){this.map.addSnappable(a)}};GSLayer.prototype.removeFeature=function(c){for(var b=0,a=this.data.length;b<a;b++){if(c==this.data[b]){c.remove();return this.data.splice(b,1)}}return null};GSLayer.prototype.clear=function(){for(var b=0,a=this.data.length;b<a;b++){this.data[b].remove()}this.data.length=0};GSLayer.prototype.remove=function(){this.clear();this.map.layerContainer.removeChild(this.contentContainer);this.contentContainer=null;this.lineContainer=null;this.iconShadowContainer=null;this.iconContainer=null};GSLayer.prototype.getBounds=function(){return GSUtil.getMinimumBoundingRectangle(this.data)};GSLayer.prototype.createOverlayContainers=function(){this.contentContainer=GSUtil.createContainer(this.map.layerContainer,null,null,null,0,0,null,this.zIndex);this.contentContainer.id="gs_layer_"+this.name;this.lineContainer=GSUtil.createContainer(this.contentContainer,null,null,null,0,0,null,10);this.iconShadowContainer=GSUtil.createContainer(this.contentContainer,null,null,null,0,0,null,30);this.iconContainer=GSUtil.createContainer(this.contentContainer,null,null,null,0,0,null,40)};GSLayer.prototype.createVectorContainer=function(){var a=null;var b=this.map;if(_browser.svg){a=document.createElementNS(_globals.svgns,"svg");this.contentContainer.appendChild(a);a.style.zIndex=20;GSUtil.positionElement(a,0,0);a.setAttributeNS(null,"width",b.pxWidth+"px");a.setAttributeNS(null,"height",b.pxHeight+"px");a.mapResized=GSUtil.bind(this.mapResized,a,b)}else{if(_browser.isIE6up){a=document.createElement(_globals.vmlnsPrefix+":group");this.contentContainer.appendChild(a);a.style.zIndex=20;GSUtil.positionElement(a,0,0);a.style.width=b.pxWidth+"px";a.style.height=b.pxHeight+"px";a.setAttribute("coordsize",b.pxWidth+" "+b.pxHeight);a.mapResized=GSUtil.bind(this.mapResizedIE,a,b)}}b.addListener(a);return a};GSLayer.prototype.mapResized=function(a){this.setAttributeNS(null,"width",a.pxWidth+"px");this.setAttributeNS(null,"height",a.pxHeight+"px")};GSLayer.prototype.mapResizedIE=function(a){this.style.width=a.pxWidth+"px";this.style.height=a.pxHeight+"px";this.setAttribute("coordsize",a.pxWidth+" "+a.pxHeight)};GSLayer.prototype.toJson=function(){var a={type:this.type,zIndex:this.zIndex,visible:this.visible,feature:this.data};return GSUtil.objToJson(a)};GSLayer.prototype.toString=function(){var c="";for(var b=0,a=this.data.length;b<a;b++){c+=this.data[b].toString()}return c};function GSMap(a,b){_globals.maps.push(this);this.options=b?b:{};GSEventBroadcaster.initialize(this);if(arguments[0]){if((typeof arguments[0])=="string"){this.container=document.getElementById(a)}else{this.container=a}}else{throw new Error("Cannot create map, no container argument provided.")}this.isChildMap=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(this.options,"isChildMap",false));this.useLogo=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(this.options,"useLogo",true));if(this.isChildMap){this.useLogo=false}this.centerOnDblClick=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(this.options,"centerOnDblClick",true));this.dragToPan=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(this.options,"dragToPan",true));this.useMouseWheelZooming=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(this.options,"useMouseWheelZooming",true));this.mouseWheelModifierKey=GSUtil.getCaseInsensitiveProperty(this.options,"mouseWheelModifierKey");this.useInfoWindow=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(this.options,"useInfoWindow",true));this.useScalebar=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(this.options,"useScalebar",true));this.scaleRange=[2,4,8,16,32,64,128,256,512,1024,2048,4096];this.scaleRange.indexOf=function(f){for(var d=0,c=this.length;d<c;d++){if(f==this[d]){return d}}return -1};this.scaleIdx=Number(GSUtil.getCaseInsensitiveProperty(this.options,"zoomLevel",this.scaleRange.length-1));this.mpx=this.scaleRange[this.scaleIdx];this.centerX=GSUtil.getCaseInsensitiveProperty(this.options,"centerX")?parseFloat(GSUtil.getCaseInsensitiveProperty(this.options,"centerX")):2530000;this.centerY=GSUtil.getCaseInsensitiveProperty(this.options,"centerY")?parseFloat(GSUtil.getCaseInsensitiveProperty(this.options,"centerY")):5990000;this.pxWidth=GSUtil.getCaseInsensitiveProperty(this.options,"width")?Number(GSUtil.getCaseInsensitiveProperty(this.options,"width")):500;this.pxHeight=GSUtil.getCaseInsensitiveProperty(this.options,"height")?Number(GSUtil.getCaseInsensitiveProperty(this.options,"height")):400;this.resizeable=false;if(this.options.width&&this.options.height){this.resizeable=false}else{this.resizeable=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(this.options,"resizeable",true))}this.customCursor=GSUtil.getCaseInsensitiveProperty(this.options,"customCursor");this.recalculateMapExtents();this.initDOM();this.eventListeners={};this.addMapEventListeners();this.layers=new Array();this.createLayer("base");this.controls=new Array();this.initControls();this.snappables=new Array();if(this.useLogo){this.addLogo()}this.infoWindow=undefined;if(this.useInfoWindow){this.infoWindow=new GSInfoWindow2(this,this.options.infoWindowOptions)}if(this.useMouseWheelZooming){this.enableMouseWheelZooming()}if(GSUtil.getCaseInsensitiveProperty(this.options,"centerX")&&GSUtil.getCaseInsensitiveProperty(this.options,"centerY")&&GSUtil.getCaseInsensitiveProperty(this.options,"zoomLevel")!=undefined){this.update(function(){this.broadcastMessage("mapZoomed",this,0,this.scaleIdx)})}this.logger=new GSLogger(this);this.panning=false}GSMap.SUPPRESS_MESSAGING=1;GSMap.ZOOM_CONTROL="zoom";GSMap.COMPACT_ZOOM_CONTROL="compact-zoom";GSMap.TEXT_ZOOM_CONTROL="text-zoom";GSMap.MAP_CONTROL="map";GSMap.SNAPBACK_CONTROL="snapback";GSMap.SCALEBAR_CONTROL="scalebar";GSMap.prototype.initDOM=function(){if(GSUtil.getComputedStyle(this.container,"position")!="absolute"){this.container.style.position="relative"}this.container.style.overflow="hidden";if(!this.resizeable){this.container.style.width=this.pxWidth+"px";this.container.style.height=this.pxHeight+"px"}else{this.sizeToContainerDimensions()}if(this.dragToPan&&!this.customCursor){new Image().src=_globals.resourceURL+"cursor-grab.cur";new Image().src=_globals.resourceURL+"cursor-grabbing.cur"}this.setCursor();this.createOverlayContainers()};GSMap.prototype.initControls=function(){if(this.useScalebar){this.addControl(GSMap.SCALEBAR_CONTROL)}var a=GSUtil.getCaseInsensitiveProperty(this.options,"mapControls");if(a&&a!="none"){this.addControl(a)}};GSMap.prototype.setCursor=function(a){if(this.customCursor){this.container.style.cursor=this.customCursor}else{if(_browser.isWebkit){this.container.style.cursor="default"}else{a=this.panning?"url("+_globals.resourceURL+"cursor-grabbing.cur),-moz-grabbing":"url("+_globals.resourceURL+"cursor-grab.cur),-moz-grab";this.container.style.cursor=a}}};GSMap.prototype.addLogo=function(){var a=GSUtil.createImage("geosmartLogo",_globals.resourceURL+"smartfindLogo.png",120,19,undefined,undefined,40,"noprint","GeoSmart Web Site");a.style.position="absolute";a.style.cursor="pointer";GSEventManager.addEventListener(a,"contextmenu",GSUtil.cancelEvent);GSUtil.positionElement(a,undefined,undefined,7,7);this.container.appendChild(a);GSEventManager.addEventListener(a,"click",function(b){window.open("http://www.geosmart.co.nz","geosmart");GSUtil.cancelEvent(b)})};GSMap.prototype.setMapOptions=function(a){for(var b in a){switch(b){case"centerOnDblClick":this.centerOnDblClick=a[b];break;case"dragToPan":this.dragToPan=a[b];break;case"useMouseWheelZooming":this.useMouseWheelZooming=a[b];if(this.useMouseWheelZooming){this.enableMouseWheelZooming()}else{this.disableMouseWheelZooming()}break;case"mouseWheelModifierKey":this.mouseWheelModifierKey=a[b];break;case"useInfoWindow":this.useInfoWindow=a[b];break;case"useScalebar":this.useScalebar=a[b];if(this.useScalebar){this.addControl(GSMap.SCALEBAR_CONTROL)}else{this.removeControl(GSMap.SCALEBAR_CONTROL)}break;case"resizeable":this.resizeable=a[b];if(this.resizeable){this.enableResizing()}else{this.disableResizing()}break;default:throw new Error('Property "'+b+'" not supported by GSMap');break}}};GSMap.prototype.enableMouseWheelZooming=function(){var a=function(b){if(b<0){if(this.scaleIdx+1<=(this.scaleRange.length-1)){this.zoom(this.scaleIdx+1)}}else{if(this.scaleIdx-1>=0){this.zoom(this.scaleIdx-1)}}};this.eventListeners.mousewheel_zooming=GSMouseWheel.bind(this.container,this,a,this.mouseWheelModifierKey)};GSMap.prototype.disableMouseWheelZooming=function(){GSEventManager.release(this.eventListeners.mousewheel_zooming)};GSMap.prototype.enableResizing=function(){this.eventListeners.resize=GSEventManager.bind(window,"resize",this,this.updateSize);this.resizeable=true};GSMap.prototype.disableResizing=function(){if(this.eventListeners.resize){GSEventManager.release(this.eventListeners.resize)}this.resizeable=false};GSMap.prototype.sizeToContainerDimensions=function(){this.pxWidth=this.container.offsetWidth;this.pxHeight=this.container.offsetHeight};GSMap.prototype.setContextMenu=function(a){this.contextMenu=a;GSContextMenuManager.setContextMenu("map",this.contextMenu);this.contextMenu.addToMap(this);this.enableContextMenu()};GSMap.prototype.removeContextMenu=function(){var a=this.contextMenu;if(a){this.disableContextMenu();a.remove();this.contextMenu=undefined}return a};GSMap.prototype.enableContextMenu=function(){if(this.contextMenu){GSEventManager.removeEventListener(this.eventListeners.contextmenu);this.eventListeners.contextmenu=GSEventManager.addEventListener(this.container,"contextmenu",GSUtil.bindAsEventListener(this.displayContextMenu,this))}return this.contextMenu};GSMap.prototype.disableContextMenu=function(){GSEventManager.removeEventListener(this.eventListeners.contextmenu);this.eventListeners.contextmenu=GSEventManager.addEventListener(this.container,"contextmenu",GSUtil.cancelEvent)};GSMap.prototype.displayContextMenu=function(a){if(GSContextMenuManager.activeMenu&&GSContextMenuManager.activeMenu.showing){GSContextMenuManager.activeMenu.hide()}var b=GSUtil.getMousePixelCoordinate(a,this.container);this.contextMenu.show(b,this);GSContextMenuManager.contextMenuOpened(this.contextMenu);GSUtil.cancelEvent(a)};GSMap.prototype.remove=function(){this.clearLayers();for(var b=0,a=this.controls.length;b<a;b++){this.removeControl(this.controls[b])}if(this.infoWindow){this.infoWindow.remove()}while(this.container.hasChildNodes()){this.container.removeChild(this.container.firstChild)}if(!this.isChildMap){GSEventCache.flush()}};GSMap.prototype.updateSize=function(){var b=new GSDimension(this.pxWidth,this.pxHeight);this.sizeToContainerDimensions();this.recalculateMapExtents();var a=function(){this.broadcastMessage("mapResized",this,b,new GSDimension(this.pxWidth,this.pxHeight))};this.update(a)};GSMap.prototype.getMapCenter=function(){return new GSPoint(this.centerX,this.centerY)};GSMap.prototype.getZoomLevel=function(){return this.scaleIdx};GSMap.prototype.getSize=function(){return new GSDimension(this.pxWidth,this.pxHeight)};GSMap.prototype.setSize=function(a){if(this.resizeable){this.pxWidth=a.width;this.pxHeight=a.height}else{throw new Error("Map is not configured as resizeable. Use GSMap.setMapOptions() to set map as resizeable before calling GSMap.setSize()")}};GSMap.prototype.setBounds=function(b,o){var g=this.mpx;var c=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);var k=b.minX;var j=b.minY;var d=b.maxX;var a=b.maxY;var f=d-k;var r=a-j;var m=f/2;var l=r/2;this.centerX=k+m;this.centerY=j+l;this.mpx=Math.ceil(Math.max(f/this.pxWidth,r/this.pxHeight));this.mpx=this.fitToScaleRange(this.mpx);this.scaleIdx=this.scaleRange.indexOf(this.mpx);var q=(this.pxWidth*this.mpx);var i=(this.pxHeight*this.mpx);this.minX=this.centerX-(q/2);this.minY=this.centerY-(i/2);this.maxX=this.centerX+(q/2);this.maxY=this.centerY+(i/2);this.centerX=this.minX+((this.maxX-this.minX)/2);this.centerY=this.minY+((this.maxY-this.minY)/2);var h=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);var n=this.mpx;this.update(function(){this.broadcastMessage("mapBoundsChanged",this,c,h);if(o){o()}})};GSMap.prototype.createOverlayContainers=function(){this.tileContainer=GSUtil.createContainer(this.container,null,null,null,0,0,null,5);this.tileContainer.id="tileContainer";this.contentContainer=GSUtil.createContainer(this.container,"contentContainer",null,null,0,0,null,10);this.contentContainer.style.width="21600px";this.contentContainer.style.height="21600px";this.imageContainer=GSUtil.createContainer(this.contentContainer,"imageContainer",null,null,0,0,null,5);this.layerContainer=GSUtil.createContainer(this.contentContainer,"layerContainer",null,null,0,0,null,10)};GSMap.prototype.dragStart=function(b){if(this.panning){return}if(this.dragToPan){this.panning=true;this.setCursor();b=b?b:window.event;var a=false;if(b.which){a=(b.which==3)}else{if(b.button){a=(b.button==2)}}if(!a){this.startPixel=new GSPoint(b.clientX,b.clientY);this.startTilePixel=new GSPoint(parseInt(this.tileContainer.style.left),parseInt(this.tileContainer.style.top));this.startNzmg=new GSPoint(this.centerX,this.centerY);this.eventListeners.drag_mousemove=GSEventManager.bind(document,"mousemove",this,this.dragMove);this.eventListeners.drag_mouseup=GSEventManager.bind(document,"mouseup",this,this.dragStop);GSUtil.cancelEvent(b)}}};GSMap.prototype.dragMove=function(a){a=a?a:window.event;if(!this.hasDragged(a)){return}GSUtil.positionElement(this.contentContainer,(a.clientX-this.startPixel.x),(a.clientY-this.startPixel.y));GSUtil.positionElement(this.tileContainer,(this.startTilePixel.x+(a.clientX-this.startPixel.x)),(this.startTilePixel.y+(a.clientY-this.startPixel.y)));GSUtil.cancelEvent(a)};GSMap.prototype.dragStop=function(f){f=f?f:window.event;if(this.hasDragged(f)){var b=(f.clientX-this.startPixel.x)*this.mpx;var a=(f.clientY-this.startPixel.y)*this.mpx;if(b!=0||a!=0){var d=this.getBounds();var c=GSUtil.bind(function(){this.broadcastMessage("mapBoundsChanged",this,d,this.getBounds());GSUtil.positionElement(this.contentContainer,0,0);this.logger.log("map",{map_op:"drag",tile_count:this.tileCount})},this);this.centerAtCoordinate({x:this.startNzmg.x-(f.clientX-this.startPixel.x)*this.mpx,y:this.startNzmg.y+(f.clientY-this.startPixel.y)*this.mpx},c,GSMap.SUPPRESS_MESSAGING)}}GSEventManager.release(this.eventListeners.drag_mousemove);GSEventManager.release(this.eventListeners.drag_mouseup);this.startPixel=undefined;this.startTilePixel=undefined;this.startNzmg=undefined;this.dragMoveToken=undefined;this.dragStopToken=undefined;this.panning=false;this.setCursor();GSUtil.cancelEvent(f)};GSMap.prototype.click=function(a){if(!this.panning){a=a?a:window.event;var b=this.getMouseCoordinate(a);this.broadcastMessage("mapClicked",this,b,a)}else{this.panning=false}if(GSContextMenuManager.activeMenu&&GSContextMenuManager.activeMenu.showing){GSContextMenuManager.activeMenu.hide()}GSUtil.cancelEvent(a)};GSMap.prototype.dblclick=function(a){var b=this.getMouseCoordinate(a);if(this.centerOnDblClick){this.panTo(b)}this.broadcastMessage("mapDblClicked",this,b,a);GSUtil.cancelEvent(a)};GSMap.prototype.addMapEventListeners=function(){this.eventListeners.mousedown=GSEventManager.bind(this.container,"mousedown",this,this.dragStart);this.eventListeners.click=GSEventManager.bind(this.container,"click",this,this.click);this.eventListeners.dblclick=GSEventManager.bind(this.container,"dblclick",this,this.dblclick);this.eventListeners.contextmenu=GSEventManager.addEventListener(this.container,"contextmenu",GSUtil.cancelEvent);if(this.resizeable){this.enableResizing()}};GSMap.prototype.getMouseCoordinate=function(a){return this.translateToRealWorldCoordinate(GSUtil.getMousePixelCoordinate(a,this.container))};GSMap.prototype.hasDragged=function(c){if(!this.startPixel){return false}var b=2;var d=new GSPoint(c.clientX,c.clientY);var a=(Math.abs(this.startPixel.x-d.x)>b)||(Math.abs(this.startPixel.y-d.y)>b);return a};GSMap.prototype.zoom=function(c,a){var b=this.scaleIdx;c=parseInt(c);if(b==c){return}if(c<0){c=0}if(c>=this.scaleRange.length){c=this.scaleRange.length-1}this.mpx=this.scaleRange[c];this.scaleIdx=c;this.recalculateMapExtents(true);this.update(function(){this.broadcastMessage("mapZoomed",this,b,this.scaleIdx);if(a){a()}this.logger.log("map",{map_op:"zoom",tile_count:this.tileCount})})};GSMap.prototype.panTo=function(i,f){if(this.panning){return}var a=this.getBounds();if(!a.contains(i)){return this.centerAtCoordinate(i,f)}this.panning=true;var d=this.getMapCenter();var g=this.translateToMapCoordinate(new GSPoint(this.centerX,this.centerY));var h=this.translateToMapCoordinate(i);var j=new GSPoint(parseInt(this.tileContainer.style.left),parseInt(this.tileContainer.style.top));var k=GSUtil.bind(this.onPanFrame,this,j,g,h);var b=GSUtil.bind(this.onPanComplete,this,f);var c=new GSAnimator(g,h,16,850,k,null,b);c.animate()};GSMap.prototype.onPanFrame=function(c,h,g,b,a){a.x=Math.floor(a.x);a.y=Math.floor(a.y);var f=c.x+(h.x-a.x);var d=c.y+(h.y-a.y);GSUtil.positionElement(this.contentContainer,(h.x-a.x),(h.y-a.y));GSUtil.positionElement(this.tileContainer,f,d)};GSMap.prototype.onPanComplete=function(a,b){var c=function(){GSUtil.positionElement(this.contentContainer,0,0);this.panning=false;if(a){a()}this.logger.log("map",{map_op:"panTo",tile_count:this.tileCount})};this.centerAtCoordinate(this.translateToRealWorldCoordinate(b.to),GSUtil.bind(c,this))};GSMap.prototype.centerAtCoordinate=function(f,a,d){var b=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);this.centerX=f.x;this.centerY=f.y;this.recalculateMapExtents();var c=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);this.update(function(){if(!d){this.broadcastMessage("mapBoundsChanged",this,b,c);this.logger.log("map",{map_op:"centerAtCoordinate",tile_count:this.tileCount})}if(a){a()}})};GSMap.prototype.centerAndZoom=function(d,c,a){this.broadcastMessage("mapZoom",this);var b=this.scaleIdx;this.centerX=d.x;this.centerY=d.y;if(c!=undefined){c=parseInt(c);if(c<0||c>=this.scaleRange.length){alert("Zoom level out of range: "+c);return}this.mpx=this.scaleRange[c];this.scaleIdx=c}this.recalculateMapExtents();this.update(function(){this.broadcastMessage("mapZoomed",this,b,this.scaleIdx);if(a){a()}this.logger.log("map",{map_op:"centerAndZoom",tile_count:this.tileCount})})};GSMap.prototype.centerOnNewZealand=function(b){var d=this.scaleIdx;this.centerX=_globals.nzCenterX;this.centerY=_globals.nzCenterY;for(var c=0,a=this.scaleRange.length;c<a;c++){if(_globals.nzCenterY+((this.scaleRange[c]*this.pxHeight)/2)>_globals.nzTopY){this.mpx=this.scaleRange[c];this.scaleIdx=c;break}}this.recalculateMapExtents();this.update(function(){this.broadcastMessage("mapZoomed",this,d,this.scaleIdx);if(b){b()}this.logger.log("map",{map_op:"centerOnNewZealand",tile_count:this.tileCount})})};GSMap.prototype.fitToScaleRange=function(d){var f=this.scaleRange[0];for(var b=0,a=this.scaleRange.length;b<a;b++){if((typeof this.scaleRange[b]).toString().toLowerCase()!="function"){var c=this.scaleRange[b];if(c==d){return d}else{if(c>d){f=c;break}}}}return f};GSMap.prototype.addControl=function(f,a){var d=null;var c=false;if(GSControl.prototype.isPrototypeOf){c=GSControl.prototype.isPrototypeOf(f)}else{if(f.__proto__){c=(typeof f).toLowerCase()=="object"}}if(c){d=f}else{d=this.instantiateControl(f)}if(d!=null){this.controls.push(d);var b=d.render(this);this.container.appendChild(b);d.setElement(b);d.setPosition(a?a:d.getDefaultPosition())}return d};GSMap.prototype.removeControl=function(f){var c="";var b=false;if(GSControl.prototype.isPrototypeOf){b=GSControl.prototype.isPrototypeOf(f)}else{if(f.__proto__){b=(typeof f).toLowerCase()=="object"}}if(b){c=f.name}else{c=f}for(var d=0,a=this.controls.length;d<a;d++){if(this.controls[d].name==c){this.controls[d].remove(this);this.controls.splice(d,1);return true}}return false};GSMap.prototype.getControl=function(b){for(var c=0,a=this.controls.length;c<a;c++){if(this.controls[c].name==b){return this.controls[c]}}return null};GSMap.prototype.hideControls=function(){for(var b=0,a=this.controls.length;b<a;b++){this.controls[b].hide()}};GSMap.prototype.showControls=function(){for(var b=0,a=this.controls.length;b<a;b++){this.controls[b].show()}};GSMap.prototype.instantiateControl=function(a){var b;switch(a){case GSMap.ZOOM_CONTROL:b=new GSZoomControl();break;case GSMap.COMPACT_ZOOM_CONTROL:b=new GSCompactZoomControl();break;case GSMap.MAP_CONTROL:b=new GSMapControl();break;case GSMap.TEXT_ZOOM_CONTROL:b=new GSTextZoomControl();break;case GSMap.SNAPBACK_CONTROL:b=new GSSnapbackControl();break;case GSMap.SCALEBAR_CONTROL:b=new GSScalebarControl();break}return b};GSMap.prototype.centerOnLayer=function(c,b){var f=this.getLayer(c);if(f==undefined){throw new Error("Layer ["+c+"] does not exist, map will not be re-centered")}if(!f.isVisible()){f.mapBoundsChanged=function(l,j,k){this.setVisible(true);l.removeListener(this)};this.addListener(f)}var h=f.getBounds();var g=h.maxX-h.minX;var a=h.maxY-h.minY;var d=g*0.05;var i=a*0.05;h.minX-=d;h.maxX+=d;h.minY-=i;h.maxY+=i;this.setBounds(h,b)};GSMap.prototype.createLayer=function(b,a){a=a?a:{};var c=this.getLayer(b);if(c!=undefined){this.removeLayer(b)}if(a.type=="route"){c=new GSRouteLayer(b,this,a)}else{c=new GSLayer(b,this,a)}this.layers.push(c);return c};GSMap.prototype.removeLayer=function(b){if(b=="base"){return}for(var d=0,a=this.layers.length;d<a;d++){var c=this.layers[d];if(c.name==b){c.remove();this.layers.splice(d,1);return true}}return false};GSMap.prototype.clearLayers=function(){for(var b=0,a=this.layers.length;b<a;b++){this.layers[b].clear()}};GSMap.prototype.getLayers=function(){return this.layers};GSMap.prototype.getLayer=function(b){for(var d=0,a=this.layers.length;d<a;d++){var c=this.layers[d];if(c.name==b){return c}}return null};GSMap.prototype.addFeature=function(b){var a=this.getLayer("base");a.addFeature(b)};GSMap.prototype.removeFeature=function(b){var a=this.getLayer("base");a.removeFeature(b)};GSMap.prototype.recalculateMapExtents=function(a){var h=this.pxWidth*this.mpx;var b=this.pxHeight*this.mpx;if(a&&this.infoWindow&&this.infoWindow.canAnchorOnInfoWindow()){var k=this.infoWindow.coordinate;var d=k.x-this.minX;var c=k.y-this.minY;var f=this.maxX-this.minX;var i=this.maxY-this.minY;var g=d/f;var j=c/i;this.minX=k.x-(g*h);this.maxX=k.x+((1-g)*h);this.minY=k.y-(j*b);this.maxY=k.y+((1-j)*b);this.centerX=this.minX+(h/2);this.centerY=this.minY+(b/2)}else{this.minX=this.centerX-(h/2);this.minY=this.centerY-(b/2);this.maxX=this.centerX+(h/2);this.maxY=this.centerY+(b/2)}};GSMap.prototype.translateToMapCoordinate=function(f){var b=f.x;var d=f.y;var c=(b-this.minX);var a=(this.maxY-d);return new GSPoint((c/this.mpx),(a/this.mpx))};GSMap.prototype.translateToRealWorldCoordinate=function(g,c){if(!c){c=new GSBounds(this.minX,this.minY,this.maxX,this.maxY)}var b=this.pxWidth*this.mpx;var d=this.pxHeight*this.mpx;var a=c.minX+(b*(g.x/this.pxWidth));var f=c.maxY-(d*(g.y/this.pxHeight));return new GSPoint(Math.round(a),Math.round(f))};GSMap.prototype.contains=function(a){return(a.x>this.minX&&a.x<this.maxX&&a.y>this.minY&&a.y<this.maxY)};GSMap.prototype.getBounds=function(){return new GSBounds(this.minX,this.minY,this.maxX,this.maxY)};GSMap.prototype.featureClicked=function(a){this.broadcastMessage("mapClicked",this,a,e)};GSMap.prototype.update=function(n){this.tilesLoaded=this.tileCount=0;var m=_globals.tilePxWidth*this.mpx;var k=_globals.tilePxHeight*this.mpx;var j=Math.floor(this.minX/m)*m;var d=Math.floor(this.maxX/m)*m;var i=Math.floor(this.minY/k)*k;var b=Math.ceil(this.maxY/k)*k;while(this.tileContainer.firstChild){this.tileContainer.removeChild(this.tileContainer.firstChild)}GSUtil.positionElement(this.tileContainer,Math.floor((j-this.minX)/this.mpx),Math.ceil((this.maxY-b)/this.mpx));var l=GSUtil.bind(this.tileLoaded,this);var c=xIdx=0;for(var f=b;f>=i;f-=k){xIdx=0;for(var h=j;h<=d;h+=m){this.tileCount++;var a=this.buildTileUrl(h,f,this.mpx);var g=this.createTileImage(a,xIdx*_globals.tilePxWidth,c*_globals.tilePxHeight,l);this.tileContainer.appendChild(g);xIdx++}c++}if(n){n.call(this)}};GSMap.prototype.createTileImage=function(f,d,c,b){var a=GSUtil.createElement("img");a.onload=b;a.onError=b;a.border=0;a.style.position="absolute";a.style.left=d+"px";a.style.top=c+"px";GSUtil.makeUnselectable(a);a.src=f;return a};GSMap.prototype.tileLoaded=function(){if(++this.tilesLoaded==this.tileCount){this.broadcastMessage("mapTilesLoaded",this)}};GSMap.prototype.openMapBlowup=function(i,c){c=c?c:{};if(c.offset==undefined){c.offset=new GSPoint(0,0)}if(c.zoomLevel==undefined){c.zoomLevel=0}if(c.size==undefined){c.size=new GSDimension(180,180)}var a=GSUtil.getComputedStyle(this.container,"background-color");if(!a){a="#c5c5c5"}var f=GSUtil.createElement("div");f.style.backgroundColor=a;f.style.border="1px solid #a0a0a4";var b={width:c.size.width+15,height:c.size.height,isChildMap:true,resizeable:false,useScalebar:false,centerOnDblClick:true,dragToPan:true,useInfoWindow:false,useMouseWheelZooming:false};var h=new GSMap(f,b);h.addControl(GSMap.COMPACT_ZOOM_CONTROL);h.addControl(GSMap.SNAPBACK_CONTROL);var d=GSUtil.bind(h.onMapBlowupOpen,h,i,c);var g=GSUtil.bind(h.onMapBlowupClose,h,c);this.infoWindow.open(i,f,{offset:c.offset,onopen:d,onclose:function(){if(c.onclose){c.onclose(h)}h.remove()}})};GSMap.prototype.onMapBlowupOpen=function(c,a){var b=this;this.centerAndZoom(c,a.zoomLevel,function(){b.markForSnapback();if(a.onopen){a.onopen(b)}})};GSMap.prototype.onMapBlowupClose=function(a){if(a.onclose){a.onclose(this)}this.remove()};GSMap.prototype.openInfoWindow=function(c,b,a){this.infoWindow.open(c,b,a)};GSMap.prototype.closeInfoWindow=function(){this.infoWindow.close()};GSMap.prototype.getInfoWindow=function(){if(this.infoWindow){return this.infoWindow}else{return undefined}};GSMap.prototype.addSnappable=function(a){this.snappables.push(a)};GSMap.prototype.getSnappables=function(){return this.snappables};GSMap.prototype.removeSnappable=function(c){for(var a=this.snappables.length,b=null;b=this.snappables[a];a--){if(b===c){this.snappables.splice(a,1);return true}}return false};GSMap.prototype.buildTileUrl=function(a,g,f){var b=a+"_"+g+".png";if(_globals.multipleTileHosts){var d=GSCrypt.hex_md5(b).charCodeAt(0)&3;var c=_globals.tilesURL.replace("tiles.","tiles"+d+".")+"/"+f+"/"+a+"/"+b;return c}else{return _globals.tilesURL+"/"+f+"/"+a+"/"+b}};GSMap.prototype.markForSnapback=function(a){this.snapbackState={coordinate:this.getMapCenter(),zoomLevel:this.scaleIdx};if(a){if(GSCookie.accept()){GSCookie.set("gssnapback",GSUtil.serialize(this.snapbackState),90)}else{throw new Error("Cookies must be enabled to persist map snapback state")}}};GSMap.prototype.snapback=function(){if(!this.snapbackState){var val=GSCookie.get("gssnapback");if(val){this.snapbackState=eval("("+val+")")}}if(this.snapbackState){try{this.centerAndZoom(this.snapbackState.coordinate,this.snapbackState.zoomLevel);return true}catch(e){return false}}return false};GSMap.prototype.toJson=function(){var a={map:{type:"GSMap",mpx:this.mpx,width:this.pxWidth,height:this.pxHeight,useScalebar:this.useScalebar,baseResourceUrl:GSUtil.getDirName(location.href),boundingBox:this.getBounds()},layers:this.layers};return GSUtil.objToJson(a)};GSMap.prototype.print=function(printServiceUrl,options){if(!options){options={}}var obj={map:{type:"GSMap",scale:options.scale!==undefined?options.scale:true,mpx:this.mpx,width:options.width?options.width:this.pxWidth,height:options.height?options.height:this.pxHeight,useScalebar:options.useScalebar!==undefined?options.useScalebar:this.useScalebar,useLogo:options.useLogo!==undefined?options.useLogo:this.useLogo,baseResourceUrl:GSUtil.getDirName(location.href),boundingBox:this.getBounds()},layers:this.layers};var data=encodeURIComponent(GSUtil.objToJson(obj));var req=new XMLHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){if(req.status>=200&&req.status<300){if(options.onSuccess){options.onSuccess(eval("("+req.responseText+")"))}}else{if(options.onFailure){options.onFailure(eval("("+req.responseText+")"))}}}};var imageFormat=options.imageFormat!==undefined?options.imageFormat:"image/jpeg";if(options.method&&options.method=="get"){printServiceUrl+="?d="+data;req.open("get",printServiceUrl,true);req.setRequestHeader("Accept",imageFormat);req.send()}else{req.open("post",printServiceUrl,true);req.setRequestHeader("Content-Type","application/json");req.setRequestHeader("Accept",imageFormat);req.send(data)}};if(!window.XMLHttpRequest&&window.ActiveXObject){window.XMLHttpRequest=function(){try{req=new ActiveXObject("Msxml2.XMLHTTP")}catch(a){try{req=new ActiveXObject("Microsoft.XMLHTTP")}catch(a){throw"Could not instantiate XMLHttpRequest object: "+a}}return req}}try{document.write('<style type="text/css" media="screen">.noscreen{display: none;}.noprint{display:block}</style>');document.write('<style type="text/css" media="print">.noscreen{display: block;}.noprint{display:none}</style>')}catch(e){}function GSPoint(a,b){this.x=Number(a);this.y=Number(b)}GSPoint.prototype.toString=function(){return"Point: x=["+this.x+"], y=["+this.y+"]"};GSPoint.prototype.equals=function(a){return(a.x==this.x&&a.y==this.y)};function GSMapFeature(){GSEventBroadcaster.initialize(this);this.type="GSMapFeature";this.graphicsEl=undefined;this.layer=undefined;this.map=undefined;this.visible=true;this.tip=undefined;this.eventListeners={};this.contextMenuItems=[];this.properties={}}GSMapFeature.prototype.getProperties=function(){return this.properties};GSMapFeature.prototype.setProperty=function(a,b){this.properties[a]=b};GSMapFeature.prototype.getProperty=function(a){return this.properties[a]};GSMapFeature.prototype.deleteProperty=function(a){delete this.properties[a]};GSMapFeature.prototype.addToLayer=function(a){this.layer=a;this.map=a.map;this.map.addListener(this);if(this.tip){this.tip.addToParent(this.map.container)}if(this.contextMenu&&!this.contextMenu.onmap){this.contextMenu.addToMap(this.map)}this.onmap=true;this.render()};GSMapFeature.prototype.render=function(){};GSMapFeature.prototype.addEventHandler=function(b,c){var a=GSEventManager.bind(this.graphicsEl,b,this,function(){c.apply(this,arguments)});this.addListenerToken(b,a);return a};GSMapFeature.prototype.removeEventHandler=function(a){GSEventManager.release(a)};GSMapFeature.prototype.setTip=function(b,a){if(!this.graphicsEl){throw new Error("Cannot set tool tip, graphics element does not exist")}if(this.tip){this.tip.remove()}if(!a){a={}}a.text=b;this.tip=new GSTip(this.graphicsEl,a)};GSMapFeature.prototype.setVisible=function(a){this.visible=a};GSMapFeature.prototype.isVisible=function(){return this.visible};GSMapFeature.prototype.addListenerToken=function(a,b){if(this.eventListeners[a]){if((typeof this.eventListeners[a]).toLowerCase()!="array"){this.eventListeners[a]=[this.eventListeners[a]]}this.eventListeners[a].push(b)}else{this.eventListeners[a]=b}};GSMapFeature.prototype.remove=function(){for(var c in this.eventListeners){if((typeof this.eventListeners[c]).toLowerCase()=="array"){for(var a=this.eventListeners[c].length,b=null;b=this.eventListeners[c][a];a--){GSEventManager.release(b)}}else{GSEventManager.release(this.eventListeners[c])}}if(this.onmap){this.map.removeListener(this)}if(this.tip){this.tip.remove()}this.graphicsEl=null};GSMapFeature.prototype.toJson=function(){var a={type:this.type};return GSUtil.objToJson(a)};GSMapFeature.prototype.mapResized=function(c,b,a){this.render()};GSMapFeature.prototype.mapZoomed=function(c,b,a){this.render()};GSMapFeature.prototype.mapBoundsChanged=function(c,a,b){this.render()};GSMapFeature.prototype.mapClicked=function(b,c,a){if(this.contextMenu&&this.contextMenu.showing){this.contextMenu.hide()}};GSMapFeature.prototype.showInfoWindow=function(c,b){if(this.onmap){if(this.map.infoWindow){c=c!=undefined?c:this.infoHtml;if(c==undefined){throw new Error("Tried to open info window for feature without any HTML content")}var d=this.getInfoWindowOptions();var a=this.getInfoWindowPosition();this.map.openInfoWindow(a,c,GSUtil.merge(b,d));this.isShowingInfo=true}else{throw new Error("Info window is not enabled for the map this feature has been added to")}}};GSMapFeature.prototype.getInfoWindowOptions=function(){};GSMapFeature.prototype.getInfoWindowPosition=function(){};GSMapFeature.prototype.infoWindowOpened=function(a){};GSMapFeature.prototype.infoWindowClosed=function(a){if(this.isShowingInfo){this.isShowingInfo=false}};GSMapFeature.prototype.setContextMenu=function(a){this.contextMenu=a;this.enableContextMenu()};GSMapFeature.prototype.addContextMenuItem=function(a){if(!this.contextMenu){throw new Error("Must set a context menu before adding a context menu item")}this.contextMenuItems.push({item:a,pos:0})};GSMapFeature.prototype.addContextMenuItemAt=function(a,b){if(!this.contextMenu){throw new Error("Must set a context menu before adding a context menu item")}this.contextMenuItems.push({item:a,pos:b})};GSMapFeature.prototype.enableContextMenu=function(){if(this.contextMenu){GSEventManager.removeEventListener(this.eventListeners.contextmenu);this.eventListeners.contextmenu=GSEventManager.addEventListener(this.graphicsEl,"contextmenu",GSUtil.bindAsEventListener(this.displayContextMenu,this))}return this.contextMenu};GSMapFeature.prototype.disableContextMenu=function(){GSEventManager.removeEventListener(this.eventListeners.contextmenu);this.eventListeners.contextmenu=GSEventManager.addEventListener(this.graphicsEl,"contextmenu",GSUtil.cancelEvent)};GSMapFeature.prototype.getContextMenu=function(){return this.contextMenu};GSMapFeature.prototype.displayContextMenu=function(d){if(GSContextMenuManager.activeMenu&&GSContextMenuManager.activeMenu.showing){GSContextMenuManager.activeMenu.hide()}for(var b=0,a=this.contextMenuItems.length;b<a;b++){var c=this.contextMenuItems[b];this.contextMenu.addItemAt(c.item,c.pos)}this.contextMenu.addListener(this);var f=GSUtil.getMousePixelCoordinate(d,this.map.container);this.contextMenu.show(f,this);GSContextMenuManager.contextMenuOpened(this.contextMenu);GSUtil.cancelEvent(d)};GSMapFeature.prototype.contextMenuHide=function(c){for(var b=0,a=this.contextMenuItems.length;b<a;b++){var d=this.contextMenuItems[b];this.contextMenu.removeItem(d.item)}this.contextMenu.removeListener(this)};GSUtil.extend(GSPointFeature,GSMapFeature);function GSPointFeature(b){GSPointFeature.baseConstructor.call(this);this.type="GSPointFeature";this.id=GSUtil.getCaseInsensitiveProperty(b,"id");this.coordinate=GSUtil.getCaseInsensitiveProperty(b,"coordinate");if(this.coordinate==undefined){var a=GSUtil.getCaseInsensitiveProperty(b,"x");var c=GSUtil.getCaseInsensitiveProperty(b,"y");this.coordinate=(a&&c)?new GSPoint(a,c):new GSPoint(0,0)}this.name=GSUtil.getCaseInsensitiveProperty(b,"name");this.suburb=GSUtil.getCaseInsensitiveProperty(b,"suburb");this.district=GSUtil.getCaseInsensitiveProperty(b,"district");this.region=GSUtil.getCaseInsensitiveProperty(b,"region");this.iconType=undefined;this.infoHtml=GSUtil.getCaseInsensitiveProperty(b,"infoHtml");this.draggable=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(b,"draggable",false));this.label=undefined;this.isShowingInfo=false;this.visibleOnMap=false;this.icon=GSUtil.getCaseInsensitiveProperty(b,"icon");if(!this.icon){this.icon=new GSIcon(GSIcon.defaultIcon)}this.icon.alt=this.name;this.icon.initialize();this.graphicsEl=this.icon.getEventTarget();if(this.draggable){this.enableDragging()}this.icon.setVisible(this.visible)}GSPointFeature.prototype.addToLayer=function(a){this.icon.addToLayer(a);if(this.label){this.label.addToLayer(a)}GSPointFeature.superClass.addToLayer.call(this,a)};GSPointFeature.prototype.enableDragging=function(){GSEventManager.bind(this.graphicsEl,"mousedown",this,this.startDrag)};GSPointFeature.prototype.startDrag=function(a){this.dragStartPos=GSUtil.getMousePixelCoordinate(a);if(this.isShowingInfo){this.map.infoWindow.close()}this.eventListeners.mousemove=GSEventManager.bind(document,"mousemove",this,this.dragMove);this.eventListeners.mouseup=GSEventManager.bind(document,"mouseup",this,this.dragEnd);GSUtil.cancelEvent(a)};GSPointFeature.prototype.dragMove=function(a){if(!this.hasDragged(a)){return}if(!this.dragging){this.dragging=true;this.icon.dragCrosshair.style.display="block";document.body.style.cursor="move";this.broadcastMessage("featureDragStart",this)}else{var c=GSUtil.getMousePixelCoordinate(a,this.map.container);this.icon.repositionDragCrosshair(c.x,c.y-10);this.coordinate=this.map.translateToRealWorldCoordinate(new GSPoint(c.x,c.y-10));c=new GSPoint(c.x+this.icon.iconOffset.x,c.y+this.icon.iconOffset.y);var b=c.y-this.icon.arcHeight;GSUtil.positionElement(this.icon.image,c.x,b);if(this.icon.shadow){GSUtil.positionElement(this.icon.shadow,c.x,b)}this.broadcastMessage("featureDrag",this)}GSUtil.cancelEvent(a)};GSPointFeature.prototype.dragEnd=function(a){if(this.hasDragged(a)){var b=GSUtil.getMousePixelCoordinate(a,this.map.container);this.coordinate=this.map.translateToRealWorldCoordinate(new GSPoint(b.x,b.y-10));this.renderIcon();this.dragging=false;this.icon.dragCrosshair.style.display="none";document.body.style.cursor="default";this.broadcastMessage("featureDragEnd",this)}GSEventManager.release(this.eventListeners.mousemove);GSEventManager.release(this.eventListeners.mouseup);GSUtil.cancelEvent(a)};GSPointFeature.prototype.clone=function(){var a=this.layer;var b=this.icon;var c=this.tip;this.layer=undefined;this.icon=undefined;this.tip=undefined;var d=GSUtil.clone(this);d.icon=new GSIcon(b);d.icon.alt=this.name;d.icon.initialize();d.onmap=false;d.isShowingInfo=false;this.layer=a;this.icon=b;this.tip=c;return d};GSPointFeature.prototype.setLabel=function(a){if(!this.graphicsEl){throw new Error("Cannot set label, graphics element does not exist")}if(this.label){this.label.remove()}this.label=a;this.label.graphicsEl.style.zIndex=1000;this.label.setCoordinate(this.coordinate);this.label.updatePosition=GSUtil.bind(this.updateLabelPosition,this.label,this)};GSPointFeature.prototype.updateLabelPosition=function(a,d){var c=d.x;var b=d.y;if(this.options.position.left!==undefined){c=d.x+this.options.position.left}else{if(this.options.position.right!==undefined){c=d.x-(this.textEl.offsetWidth+this.options.position.right)}else{c=d.x+a.icon.iconOffset.x+((a.icon.image.offsetWidth-this.backgroundEl.offsetWidth)/2)}}if(this.options.position.top!==undefined){b=d.y+this.options.position.top}else{if(this.options.position.bottom!==undefined){b=d.y-(this.textEl.offsetHeight+this.options.position.bottom)}}GSUtil.positionElement(this.graphicsEl,c,b)};GSPointFeature.prototype.setVisible=function(a){this.visible=a;if(this.icon){this.icon.setVisible(a);if(this.onmap){this.renderIcon()}}if(this.label){this.label.setVisible(a)}if(!a){if(this.isShowingInfo){this.map.infoWindow.close()}}};GSPointFeature.prototype.isVisible=function(){return this.visible};GSPointFeature.prototype.isDraggable=function(){return this.draggable};GSPointFeature.prototype.setCoordinate=function(a){this.coordinate=a;this.render()};GSPointFeature.prototype.setImage=function(a){GSUtil.setImageSrc(this.icon.image,a);this.renderIcon()};GSPointFeature.prototype.setIcon=function(f){if(this.layer){this.icon.remove(this.layer)}this.icon=f;this.icon.initialize();this.graphicsEl=this.icon.getEventTarget();if(this.draggable){this.enableDragging()}for(var c in this.eventListeners){if((typeof this.eventListeners[c]).toLowerCase()=="array"){for(var a=this.eventListeners[c].length,b=null;b=this.eventListeners[c][a];a--){var d=GSEventCache.handlers[b];GSEventManager.bind(this.graphicsEl,d[1],this,d[2])}}else{var d=GSEventCache.handlers[this.eventListeners[c]];GSEventManager.bind(this.graphicsEl,d[1],this,d[2])}}if(this.layer){this.icon.addToLayer(this.layer);if(this.onmap){this.renderIcon()}}};GSPointFeature.prototype.hasDragged=function(c){if(!this.dragStartPos){return false}var b=2;var d=GSUtil.getMousePixelCoordinate(c);var a=(Math.abs(this.dragStartPos.x-d.x)>b)||(Math.abs(this.dragStartPos.y-d.y)>b);return a};GSPointFeature.prototype.openMapBlowup=function(b){b=b?b:0;if(this.onmap){this.isShowingInfo=true;var a=this.icon.iconOffset.x+this.icon.iconInfoWindowOffset.x;var d=this.icon.iconOffset.y+this.icon.iconInfoWindowOffset.y;var c=this.clone();this.map.openMapBlowup(this.coordinate,{zoomLevel:0,offset:new GSPoint(a,d),onopen:function(f){f.addFeature(c)}})}};GSPointFeature.prototype.getInfoWindowOptions=function(){var a=this.icon.iconOffset.x+this.icon.iconInfoWindowOffset.x;var c=this.icon.iconOffset.y+this.icon.iconInfoWindowOffset.y;var b={offset:new GSPoint(a,c),title:this.name?this.name:""};return b};GSPointFeature.prototype.getInfoWindowPosition=function(){return this.coordinate};GSPointFeature.prototype.closestPoint=function(d,c){var f=this.map.translateToMapCoordinate(this.coordinate);var b=Math.abs(f.x-d.x);var a=Math.abs(f.y-d.y);if(b<c&&a<c){return{point:this.coordinate,delta:Math.min(b,a)}}else{return null}};GSPointFeature.prototype.getBounds=function(){return new GSBounds(this.coordinate.x,this.coordinate.y,this.coordinate.x,this.coordinate.y)};GSPointFeature.prototype.render=function(){this.renderIcon()};GSPointFeature.prototype.renderIcon=function(){var a=this.visibleOnMap;this.visibleOnMap=this.icon.render(this.layer,this.coordinate);if(!a&&this.visibleOnMap){this.broadcastMessage("featureVisibleOnMap",this)}else{if(a&&!this.visibleOnMap){this.broadcastMessage("featureNotVisibleOnMap",this)}}};GSPointFeature.prototype.remove=function(){GSPointFeature.superClass.remove.call(this);if(this.onmap){this.icon.remove(this.layer);if(this.isShowingInfo){this.map.infoWindow.close()}}if(this.label){this.label.remove()}};GSPointFeature.prototype.toJson=function(){var a={type:this.type,coordinate:this.coordinate,iconImageSrc:this.icon.imageSrc,iconOffset:this.icon.iconOffset,visible:this.visible};return GSUtil.objToJson(a)};GSPointFeature.prototype.toGML=function(){var a=[];a.push('<Point xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:27200">');a.push("<gml:coordinates>"+this.coordinate.x+","+this.coordinate.y+"</gml:coordinates>");a.push("</Point>");return a.join("")};GSPointFeature.prototype.toWKT=function(){return"POINT("+this.coordinate.x+" "+this.coordinate.y+")"};GSPointFeature.prototype.toString=function(){var a="Feature:<br/>";for(p in this){if(this[p] instanceof Function){a+=(p+" : [Function]<br/>")}else{a+=(p+" : "+this[p]+"<br/>")}}return a};var GSDrag={obj:null,init:function(d,i,g,b,f,a,j,h,k,c){GSEventManager.addEventListener(d,"mousedown",GSUtil.bindAsEventListener(GSDrag.start,d));GSEventManager.addEventListener(d,"contextmenu",GSDrag.stopPropagation);d.hmode=j?false:true;d.vmode=h?false:true;d.root=i&&i!=null?i:d;if(d.hmode&&isNaN(parseInt(d.root.style.left))){d.root.style.left="0px"}if(d.vmode&&isNaN(parseInt(d.root.style.top))){d.root.style.top="0px"}if(!d.hmode&&isNaN(parseInt(d.root.style.right))){d.root.style.right="0px"}if(!d.vmode&&isNaN(parseInt(d.root.style.bottom))){d.root.style.bottom="0px"}d.minX=typeof g!="undefined"?g:null;d.minY=typeof f!="undefined"?f:null;d.maxX=typeof b!="undefined"?b:null;d.maxY=typeof a!="undefined"?a:null;d.xMapper=k?k:null;d.yMapper=c?c:null;d.root.onDragStart=new Function();d.root.onDragEnd=new Function();d.root.onDrag=new Function()},start:function(b){GSDrag.stopPropagation(b);var c=GSDrag.obj=this;b=GSDrag.fixE(b);var f=parseInt(c.vmode?c.root.style.top:c.root.style.bottom);var a=parseInt(c.hmode?c.root.style.left:c.root.style.right);c.root.onDragStart(a,f);var d=GSUtil.getMousePos(b);c.lastMouseX=d.x;c.lastMouseY=d.y;if(c.hmode){if(c.minX!=null){c.minMouseX=d.x-a+c.minX}if(c.maxX!=null){c.maxMouseX=c.minMouseX+c.maxX-c.minX}}else{if(c.minX!=null){c.maxMouseX=-c.minX+d.x+a}if(c.maxX!=null){c.minMouseX=-c.maxX+d.x+a}}if(c.vmode){if(c.minY!=null){c.minMouseY=d.y-f+c.minY}if(c.maxY!=null){c.maxMouseY=c.minMouseY+c.maxY-c.minY}}else{if(c.minY!=null){c.maxMouseY=-c.minY+d.y+f}if(c.maxY!=null){c.minMouseY=-c.maxY+d.y+f}}document.onmousemove=GSDrag.drag;document.onmouseup=GSDrag.end;return false},drag:function(d){GSDrag.stopPropagation(d);d=GSDrag.fixE(d);var a=GSDrag.obj;var h=GSUtil.getMousePos(d);var g=h.x;var f=h.y;var i=parseInt(a.vmode?a.root.style.top:a.root.style.bottom);var j=parseInt(a.hmode?a.root.style.left:a.root.style.right);var c,b;if(a.minX!=null){g=a.hmode?Math.max(g,a.minMouseX):Math.min(g,a.maxMouseX)}if(a.maxX!=null){g=a.hmode?Math.min(g,a.maxMouseX):Math.max(g,a.minMouseX)}if(a.minY!=null){f=a.vmode?Math.max(f,a.minMouseY):Math.min(f,a.maxMouseY)}if(a.maxY!=null){f=a.vmode?Math.min(f,a.maxMouseY):Math.max(f,a.minMouseY)}c=j+((g-a.lastMouseX)*(a.hmode?1:-1));b=i+((f-a.lastMouseY)*(a.vmode?1:-1));if(a.xMapper){c=a.xMapper(i)}else{if(a.yMapper){b=a.yMapper(j)}}GSDrag.obj.root.style[a.hmode?"left":"right"]=c+"px";GSDrag.obj.root.style[a.vmode?"top":"bottom"]=b+"px";GSDrag.obj.lastMouseX=g;GSDrag.obj.lastMouseY=f;GSDrag.obj.root.onDrag(c,b,d);return false},end:function(a){GSDrag.stopPropagation(a);a=GSDrag.fixE(a);document.onmousemove=null;document.onmouseup=null;GSDrag.obj.root.onDragEnd(parseInt(GSDrag.obj.root.style[GSDrag.obj.hmode?"left":"right"]),parseInt(GSDrag.obj.root.style[GSDrag.obj.vmode?"top":"bottom"]),a);GSDrag.obj=null},fixE:function(a){if(typeof a=="undefined"){a=window.event}if(typeof a.layerX=="undefined"){a.layerX=a.offsetX}if(typeof a.layerY=="undefined"){a.layerY=a.offsetY}return a},stopPropagation:function(a){a=a?a:window.event;if(a.stopPropagation){a.preventDefault();a.stopPropagation()}else{a.cancelBubble=true;a.returnValue=false}}};GSUtil.extend(GSRasterImageFeature,GSMapFeature);function GSRasterImageFeature(a){GSRasterImageFeature.baseConstructor.call(this);this.type="GSRasterImageFeature";this.callback=a;this.image=null}GSRasterImageFeature.prototype.setVisible=function(a){this.visible=a;if(this.graphicsEl){this.graphicsEl.style.visibility=a?"visible":"hidden"}};GSRasterImageFeature.prototype.render=function(){if(!this.layer){throw new Error("GSRasterImageFeature has not been added to a map")}if(this.graphicsEl){this.layer.map.imageContainer.removeChild(this.graphicsEl)}this.graphicsEl=GSUtil.createElement("img");this.graphicsEl.className="gsimagefeature";GSUtil.makeUnselectable(this.graphicsEl);this.graphicsEl.src=this.callback(this.map.scaleIdx,this.map.getBounds(),this.map.getSize());this.layer.map.imageContainer.appendChild(this.graphicsEl)};GSRasterImageFeature.prototype.remove=function(){if(this.graphicsEl){this.layer.map.imageContainer.removeChild(this.graphicsEl)}if(this.map){this.map.removeListener(this)}this.map=null};function GSInfoWindow2(a){this.map=a;this.map.addListener(this);this.coordinate;this.offset=new GSPoint(0,0);this.isOpen=false;this.hidden=true;this.buttons={};this.element=undefined;this.restoreSize=undefined;this.maximized=false;this.createWindow();this.preloadImages();GSEventManager.bind(this.element,"click",this,this.processMouseEvent);GSEventManager.bind(this.element,"mousedown",this,this.processMouseEvent);GSEventManager.bind(this.element,"dblclick",this,this.processMouseEvent);GSEventManager.bind(window,"resize",this,this.windowResizeHandler)}GSInfoWindow2.CALLOUT_WIDTH=24;GSInfoWindow2.CALLOUT_HEIGHT=40;GSInfoWindow2.BORDER_WIDTH=1;GSInfoWindow2.TITLE_HEIGHT=24;GSInfoWindow2.MIN_BODY_WIDTH=100;GSInfoWindow2.MIN_BODY_HEIGHT=40;GSInfoWindow2.MAX_BODY_WIDTH=1000;GSInfoWindow2.MAX_BODY_HEIGHT=800;GSInfoWindow2.H_BODY_MARGIN=10;GSInfoWindow2.PRELOAD_IMAGES=[_globals.resourceURL+"iw2/buttons.gif",_globals.resourceURL+"iw2/callout.gif",_globals.resourceURL+"iw2/hd-sprite.gif",_globals.resourceURL+"iw2/left.gif",_globals.resourceURL+"iw2/mid.gif",_globals.resourceURL+"iw2/right.gif"];GSInfoWindow2.prototype.preloadImages=function(){var a=[];var c=null;for(var d=0,b=GSInfoWindow2.PRELOAD_IMAGES.length;d<b;d++){a.push(new Image().src=GSInfoWindow2.PRELOAD_IMAGES[d])}};GSInfoWindow2.prototype.processMouseEvent=function(a){GSUtil.eventStopPropagation(a)};GSInfoWindow2.prototype.canAnchorOnInfoWindow=function(){return this.isOpen&&this.map.contains(this.coordinate)};GSInfoWindow2.prototype.open=function(g,c,b){this.options={maximizable:false,maxContent:"",maxSize:new GSDimension(GSInfoWindow2.MAX_BODY_WIDTH,GSInfoWindow2.MAX_BODY_HEIGHT)};GSUtil.merge(b,this.options);if(this.isOpen){this.close()}this.isOpen=true;this.onclose=this.options.onclose;this.coordinate=g;if(this.options.offset){this.offset=this.options.offset}if((typeof c).toLowerCase()=="string"){var f=GSUtil.createElement("div");f.innerHTML=c;c=f}this.setContent(c);this.setTitle(this.options.title);if(this.options.maximizable){if((typeof this.options.maxContent).toLowerCase()=="string"){this.maxContent=document.createElement("div");this.maxContent.innerHTML=this.options.maxContent}else{this.maxContent=this.options.maxContent}this.buttons.maximizeBtn.style.display="block"}else{this.buttons.maximizeBtn.style.display="none"}var d=this.map;var a=GSUtil.bind(function(){if(this.options.onopen){this.options.onopen()}d.broadcastMessage("infoWindowOpened",this)},this);this.updatePosition(a)};GSInfoWindow2.prototype.getEdgeConstraint=function(){if(!this.map){return new GSPoint(0,0)}var h={top:5,right:5,bottom:5,left:5};for(var d=0,b=this.map.controls.length;d<b;d++){var g=this.map.controls[d];var f=g.getWidth();var a=g.getHeight();if(f&&a){var c=g.getOrientation()?g.getOrientation():(f>a?"horizontal":"vertical");var j=g.getPosition();switch(j.anchor){case GSControl.ANCHOR_TOP_LEFT:if(c=="horizontal"){h.top=Math.max(h.top,5+j.offset.y+a)}else{h.left=Math.max(h.left,5+j.offset.x+f)}break;case GSControl.ANCHOR_BOTTOM_LEFT:if(c=="horizontal"){h.bottom=Math.max(h.bottom,5+j.offset.y+a)}else{h.left=Math.max(h.left,5+j.offset.x+f)}break;case GSControl.ANCHOR_TOP_RIGHT:if(c=="horizontal"){h.top=Math.max(h.top,5+j.offset.y+a)}else{h.right=Math.max(h.right,5+j.offset.x+f)}break;case GSControl.ANCHOR_BOTTOM_RIGHT:if(c=="horizontal"){h.bottom=Math.max(h.bottom,5+j.offset.y+a)}else{h.right=Math.max(h.right,5+j.offset.x+f)}break}}}return h};GSInfoWindow2.prototype.update=function(){this.updateSize();this.updatePosition()};GSInfoWindow2.prototype.updateSize=function(c){this.element.style.width="auto";if(!c){c=new GSDimension()}var b=c.width||Math.max(this.body.offsetWidth,GSInfoWindow2.MIN_BODY_WIDTH);var f=c.height||Math.max(this.body.offsetHeight,GSInfoWindow2.MIN_BODY_HEIGHT);var d=b+((GSInfoWindow2.H_BODY_MARGIN)*2);var a=f+GSInfoWindow2.TITLE_HEIGHT+10;this.element.style.width=d+"px";this.element.style.height=a+"px";this.strut.style.height=(f+10)+"px";this.callout.style.left=((d-GSInfoWindow2.CALLOUT_WIDTH)/2)+"px";this.reposition()};GSInfoWindow2.prototype.updatePosition=function(d){var a=this.getEdgeConstraint();var k=this.getSize();var l=k.width;var q=k.height;var r=this.offset.x;var o=this.offset.y-(q+GSInfoWindow2.CALLOUT_HEIGHT);var j=new GSPoint(r,o);var i,g;var n=this.map.translateToMapCoordinate(this.coordinate);if(this.coordinate.x>this.map.minX&&this.coordinate.x<this.map.maxX&&this.coordinate.y>this.map.minY&&this.coordinate.y<this.map.maxY){var c=n.x+j.x;var m=n.y+j.y;var h=0;var f=0;if((c+(l/2)+a.right)>this.map.pxWidth){h=this.map.pxWidth-(c+(l/2)+a.right)}else{if((c-(l/2)-a.left)<0){h=((l/2)+a.left)-c}}if((m-a.top)<0){f=0-(m-a.top)}else{if((m+q+GSInfoWindow2.CALLOUT_HEIGHT+a.bottom)>this.map.pxHeight){f=this.map.pxHeight-(m+q+GSInfoWindow2.CALLOUT_HEIGHT+a.bottom-this.offset.y)}}if(h==0&&f==0){if(d){d()}return}i=this.map.centerX-(h*this.map.mpx);g=this.map.centerY+(f*this.map.mpx)}else{var h=(this.map.pxWidth/2)>(j.x+(l/2)+a.left)?0:(j.x+(l/2)+a.left)-(this.map.pxWidth/2);var f=(this.map.pxHeight/2)>(Math.abs(j.y)+a.top)?0:(Math.abs(j.y)+a.top)-(this.map.pxHeight/2);i=this.coordinate.x+(h*this.map.mpx);g=this.coordinate.y+(f*this.map.mpx)}var b=this.map;this.map.panTo(new GSPoint(i,g),d)};GSInfoWindow2.prototype.getSize=function(){return new GSDimension(this.element.offsetWidth,this.element.offsetHeight)};GSInfoWindow2.prototype.updateContent=function(a){if(!this.isOpen){return}if((typeof a).toLowerCase()=="string"){var b=GSUtil.createElement("div");b.innerHTML=a;a=b}this.setContent(a);this.updatePosition()};GSInfoWindow2.prototype.close=function(a){if(a){GSUtil.cancelEvent(a)}if(this.onclose){this.onclose()}if(this.maximized){this.restore()}this.hide();this.isOpen=false;this.map.broadcastMessage("infoWindowClosed",this)};GSInfoWindow2.prototype.hide=function(){this.element.style.visibility="hidden";this.hidden=true};GSInfoWindow2.prototype.show=function(){this.element.style.visibility="visible";this.hidden=false};GSInfoWindow2.prototype.isHidden=function(){return this.hidden};GSInfoWindow2.prototype.getCoordinate=function(){return this.coordinate};GSInfoWindow2.prototype.getPixelOffset=function(){return this.offset};GSInfoWindow2.prototype.remove=function(){this.map.contentContainer.removeChild(this.element);this.element=null};GSInfoWindow2.prototype.mapResized=function(){this.reposition()};GSInfoWindow2.prototype.mapZoomed=function(){this.reposition()};GSInfoWindow2.prototype.mapBoundsChanged=function(){this.reposition()};GSInfoWindow2.prototype.reposition=function(){if(!this.isOpen){return}var c=this.getSize();var d=c.height;var b=c.width;var g=this.map.translateToMapCoordinate(this.coordinate);var a=g.x+this.offset.x-(b/2);var f=g.y+(this.offset.y-(d+GSInfoWindow2.CALLOUT_HEIGHT));GSUtil.positionElement(this.element,a,f);this.show()};GSInfoWindow2.prototype.setContent=function(c,a){if(a===undefined){a=true}c.className="info-window";var b=null;if(this.body.firstChild){b=this.body.replaceChild(c,this.body.firstChild)}else{this.body.appendChild(c)}if(a){this.updateSize()}return b};GSInfoWindow2.prototype.createWindow=function(){this.element=this.createElement("div",{styles:{position:"absolute",visibility:"hidden",cursor:"default",zIndex:1000}});GSEventManager.addEventListener(this.element,"contextmenu",GSUtil.cancelEvent);this.map.contentContainer.appendChild(this.element);var f=this.createElement("div",{styles:{position:"absolute",top:"0px",left:"0px",width:"100%",height:"100%"}});this.element.appendChild(f);var a=this.createElement("div",{styles:{padding:"0 0 0 9px",background:"url("+_globals.resourceURL+"iw2/hd-sprite.gif) no-repeat left top"}});f.appendChild(a);var c=this.createElement("div",{styles:{padding:"0 9px 0 0",background:"url("+_globals.resourceURL+"iw2/hd-sprite.gif) no-repeat right -24px"}});a.appendChild(c);var d=this.createElement("div",{attributes:{"class":"iw-title"},styles:{height:"24px",background:"url("+_globals.resourceURL+"iw2/hd-sprite.gif) repeat-x 0px -48px"}});c.appendChild(d);this.titleText=this.createElement("div",{styles:{fontSize:"12px",fontFamily:'"Lucida Grande", Arial, Helvetica, sans-serif',lineHeight:"12px",padding:"5px 0 0 0",textAlign:"center"}});d.appendChild(this.titleText);var g=this.createElement("div",{styles:{padding:"0 0 0 8px",background:"url("+_globals.resourceURL+"iw2/left.gif) no-repeat left bottom"}});f.appendChild(g);var b=this.createElement("div",{styles:{padding:"0 8px 0 0",background:"url("+_globals.resourceURL+"iw2/right.gif) no-repeat right bottom"}});g.appendChild(b);this.strut=this.createElement("div",{attributes:{"class":"iw-strut"},styles:{height:"70px",background:"url("+_globals.resourceURL+"iw2/mid.gif) repeat-x center bottom"}});b.appendChild(this.strut);this.callout=this.createElement("div",{attributes:{"class":"callout"},styles:{width:"24px",height:"42px",background:"url("+_globals.resourceURL+"iw2/callout.gif) no-repeat",position:"absolute",bottom:((GSInfoWindow2.CALLOUT_HEIGHT+1)*-1)+"px"}});GSUtil.makeUnselectable(this.callout);f.appendChild(this.callout);this.body=this.createElement("div",{attributes:{"class":"iw-body"},styles:{position:"absolute",top:"28px",background:"#fff",margin:"0px "+GSInfoWindow2.H_BODY_MARGIN+"px"}});this.element.appendChild(this.body);this.buttons.maximizeBtn=this.createElement("a",{attributes:{href:"#",title:"Maximize"},styles:{display:"block",overflow:"hidden",position:"absolute",right:"22px",top:"5px",width:"14px",height:"14px",background:"url("+_globals.resourceURL+"iw2/buttons.gif) no-repeat -14px 0px",cursor:"pointer"}});GSEventManager.addEventListener(this.buttons.maximizeBtn,"click",GSUtil.bindAsEventListener(this.maximize,this));GSEventManager.addEventListener(this.buttons.maximizeBtn,"mouseover",GSUtil.bindAsEventListener(this.maximizeBtnOver,this.buttons.maximizeBtn));GSEventManager.addEventListener(this.buttons.maximizeBtn,"mouseout",GSUtil.bindAsEventListener(this.maximizeBtnOut,this.buttons.maximizeBtn));this.element.appendChild(this.buttons.maximizeBtn);this.buttons.restoreBtn=this.createElement("a",{attributes:{href:"#",title:"Restore"},styles:{display:"none",overflow:"hidden",position:"absolute",right:"22px",top:"5px",width:"14px",height:"14px",background:"url("+_globals.resourceURL+"iw2/buttons.gif) no-repeat -28px 0px",cursor:"pointer"}});GSEventManager.addEventListener(this.buttons.restoreBtn,"click",GSUtil.bindAsEventListener(this.restore,this));GSEventManager.addEventListener(this.buttons.restoreBtn,"mouseover",GSUtil.bindAsEventListener(this.restoreBtnOver,this.buttons.restoreBtn));GSEventManager.addEventListener(this.buttons.restoreBtn,"mouseout",GSUtil.bindAsEventListener(this.restoreBtnOut,this.buttons.restoreBtn));this.element.appendChild(this.buttons.restoreBtn);this.buttons.closeBtn=this.createElement("a",{attributes:{href:"#",title:"Close"},styles:{display:"block",overflow:"hidden",position:"absolute",right:"5px",top:"5px",width:"14px",height:"14px",background:"url("+_globals.resourceURL+"iw2/buttons.gif) no-repeat 0px 0px",cursor:"pointer"}});GSEventManager.addEventListener(this.buttons.closeBtn,"click",GSUtil.bindAsEventListener(this.close,this));GSEventManager.addEventListener(this.buttons.closeBtn,"mouseover",GSUtil.bindAsEventListener(this.closeBtnOver,this.buttons.closeBtn));GSEventManager.addEventListener(this.buttons.closeBtn,"mouseout",GSUtil.bindAsEventListener(this.closeBtnOut,this.buttons.closeBtn));this.element.appendChild(this.buttons.closeBtn)};GSInfoWindow2.prototype.createElement=function(b,a){if(!a){a={}}if(!a.attributes){a.attributes={}}if(!a.styles){a.styles={}}var d=null;if(document.createElementNS){d=document.createElementNS(_globals.xmlns,b)}else{d=document.createElement(b)}for(var c in a.attributes){if(d.setAttributeNS){d.setAttributeNS(null,c,a.attributes[c])}else{d.setAttribute(c,a.attributes[c])}}for(var c in a.styles){d.style[c]=a.styles[c]}return d};GSInfoWindow2.prototype.maximize=function(h){if(h){GSUtil.cancelEvent(h)}if(this.maximized){return}this.restoreSize=new GSDimension(this.body.offsetWidth,this.body.offsetHeight);var g=GSUtil.bind(function(){this.map.hideControls();this.sizeToMapWindow();this.buttons.maximizeBtn.style.display="none";this.buttons.restoreBtn.style.display="block";this.restoreContent=this.setContent(this.maxContent,false);this.maximized=true;map.broadcastMessage("infoWindowMaximized",this)},this);var b=new GSPoint(Math.round(this.coordinate.x),Math.round(this.map.centerY+(this.coordinate.y-this.map.minY)-(this.getEdgeConstraint().top*this.map.mpx)));var d=this.map.getMapCenter();var c=Math.abs(b.x/this.map.mpx-d.x/this.map.mpx);var a=Math.abs(b.y/this.map.mpx-d.y/this.map.mpx);if(c<20&&a<20){this.map.centerAtCoordinate(b,g)}else{this.map.panTo(b,g)}};GSInfoWindow2.prototype.restore=function(a){if(a){GSUtil.cancelEvent(a)}if(!this.maximized){return}this.body.replaceChild(this.restoreContent,this.maxContent);this.updateSize(this.restoreSize);this.buttons.restoreBtn.style.display="none";this.buttons.maximizeBtn.style.display="block";this.map.showControls();this.maximized=false;map.broadcastMessage("infoWindowRestored",this)};GSInfoWindow2.prototype.windowResizeHandler=function(){if(this.maximized){var b=new GSPoint(Math.round(this.coordinate.x),Math.round(this.map.centerY+(this.coordinate.y-this.map.minY)-(this.getEdgeConstraint().top*this.map.mpx)));var d=this.map.getMapCenter();var c=Math.abs(b.x/this.map.mpx-d.x/this.map.mpx);var a=Math.abs(b.y/this.map.mpx-d.y/this.map.mpx);if(c<20&&a<20){this.map.centerAtCoordinate(b,GSUtil.bind(this.sizeToMapWindow,this))}else{this.map.panTo(b,GSUtil.bind(this.sizeToMapWindow,this))}}};GSInfoWindow2.prototype.setTitle=function(b){while(this.titleText.firstChild){this.titleText.removeChild(this.titleText.firstChild)}var a=b?this.truncateTitle(b):"";this.titleText.appendChild(document.createTextNode(a))};GSInfoWindow2.prototype.truncateTitle=function(b){var a=Math.floor(this.element.offsetWidth/7)-3;if(b.length<=a){return b}return b.substr(0,a)+"..."};GSInfoWindow2.prototype.sizeToMapWindow=function(){var c=this.getEdgeConstraint();var a=this.map.pxWidth-(c.left*2);a=a<this.options.maxSize.width?a:this.options.maxSize.width;var b=this.map.pxHeight-(c.top*2)-GSInfoWindow2.CALLOUT_HEIGHT+this.offset.y;b=b<this.options.maxSize.height?b:this.options.maxSize.height;this.element.style.width=a+"px";this.element.style.height=b+"px";this.strut.style.height=(b-GSInfoWindow2.TITLE_HEIGHT)+"px";this.callout.style.left=((a-GSInfoWindow2.CALLOUT_WIDTH)/2)+"px";this.reposition()};GSInfoWindow2.prototype.closeBtnOver=function(a){this.style.backgroundPosition="0px -14px"};GSInfoWindow2.prototype.closeBtnOut=function(a){this.style.backgroundPosition="0px 0px"};GSInfoWindow2.prototype.maximizeBtnOver=function(a){this.style.backgroundPosition="-14px -14px"};GSInfoWindow2.prototype.maximizeBtnOut=function(a){this.style.backgroundPosition="-14px 0px"};GSInfoWindow2.prototype.restoreBtnOver=function(a){this.style.backgroundPosition="-28px -14px"};GSInfoWindow2.prototype.restoreBtnOut=function(a){this.style.backgroundPosition="-28px 0px"};function GSLogger(a){if(!_globals.loggingEnabled){return}this.map=a;this.sessionid;this.user=this.getAPIUser();this.version=this.getAPIVersion();this.lastlogtime;this.transport=new Image();if(!this.user){throw new Error("Cannot log, user parameter not provided in API query")}this.startSession()}GSLogger.prototype.startSession=function(){var a=this.getSessionIdFromCookie();if(a){this.sessionid=a}else{this.sessionid=this.uuid();if(GSCookie.accept()){GSCookie.set("gssessionid",this.sessionid)}}};GSLogger.prototype.stopSession=function(){GSCookie.erase("gssessionid");this.sessionid=undefined};GSLogger.prototype.getAPIUser=function(){var c=this.getAPIScriptTag();if(!c){throw new Error("Cannot log, API loaded from a non-Geosmart domain")}var b=/user=([^&]+)(&|$)/;var a=c.src.match(b)[1];return a};GSLogger.prototype.getAPIVersion=function(){var c=this.getAPIScriptTag();if(!c){throw new Error("Cannot log, API loaded from a non-Geosmart domain")}var b=/&v=([^&]+)(&|$)/;var a=c.src.match(b)[1];return a};GSLogger.prototype.getAPIScriptTag=function(){var a=document.getElementsByTagName("script");var d=/api\.geosmart\.co\.nz/;for(var f=0,b=a.length;f<b;f++){var c=a[f];if(d.test(c.src)){return c}}return undefined};GSLogger.prototype.log=function(d,a){if(!_globals.loggingEnabled){return}if(arguments.length==1&&(typeof arguments[0]).toLowerCase()!="string"){throw new Error("Cannot log, must name a log file to log to")}if(this.lastlogtime&&(new Date()-this.lastlogtime>_globals.loggingSessionTimeout)){this.stopSession();this.startSession()}var f=this.map.getMapCenter();a.center_x=f.x;a.center_y=f.y;a.zoom_level=this.map.scaleIdx;a.user=this.user;a.api_version=this.version;a.session_id=this.sessionid;var g="";for(var c in a){if((typeof a[c]).toLowerCase()=="function"){continue}g+=(c+"="+encodeURIComponent(a[c])+"&")}var b=_globals.loggingBaseURL+d+".log?"+g;this.transport.src=b;this.lastlogtime=new Date()};GSLogger.prototype.getSessionIdFromCookie=function(){if(GSCookie.accept()){return GSCookie.get("gssessionid")}else{return undefined}};GSLogger.prototype.uuid=function(){var a,c,b;a="";for(b=0;b<32;b++){if(b==8||b==12||b==16||b==20){a=a+"-"}c=Math.floor(Math.random()*16).toString(16).toUpperCase();a=a+c}return a};GSUtil.extend(GSRouteLayer,GSLayer);function GSRouteLayer(b,c,a){if(!a){a={}}if(!a.routeStyle){a.routeStyle={}}GSRouteLayer.baseConstructor.call(this,b,c,a);this.type="GSRouteLayer";this.waypointsVisible=a.waypointsVisible!==undefined?a.waypointsVisible:true;this.returnToStart=a.returnToStart!==undefined?a.returnToStart:false;this.color=a.routeStyle.color?a.routeStyle.color:"3,74,152";this.lineWeight=a.routeStyle.weight!==undefined?a.routeStyle.weight:5;this.opacity=a.routeStyle.opacity!==undefined?a.routeStyle.opacity:255;this.directionsServiceUrl=a.directionsServiceUrl}GSRouteLayer.prototype.addFeature=function(a){this.data.push(a);if(a.type=="GSPointFeature"){if(this.visible&&this.waypointsVisible){a.setVisible(true)}else{a.setVisible(false)}}else{a.setVisible(this.visible)}a.addToLayer(this);if(a.snappable){this.map.addSnappable(a)}};GSRouteLayer.prototype.insertFeatureBefore=function(d,b){for(var c=0,a=this.data.length;c<a;c++){if(b==this.data[c]){this.data.splice(c,0,d);return}}this.data.push(d)};GSRouteLayer.prototype.insertFeatureAfter=function(d,b){for(var c=0,a=this.data.length;c<a;c++){if(b==this.data[c]){this.data.splice(c+1,0,d);return}}this.data.push(d)};GSRouteLayer.prototype.hideWaypoints=function(){this.waypointsVisible=false;this.setVisible(this.visible)};GSRouteLayer.prototype.showWaypoints=function(){this.waypointsVisible=true;this.setVisible(this.visible)};GSRouteLayer.prototype.getDirectionsServiceUrl=function(){return this.directionsServiceUrl};GSRouteLayer.prototype.setDirectionsServiceUrl=function(a){this.directionsServiceUrl=a};GSRouteLayer.prototype.setReturnToStart=function(a){this.returnToStart=a};GSRouteLayer.prototype.calculateRoute=function(){if(!this.directionsServiceUrl){throw"Must set directions service URL before calculating route."}var c=0;for(var b=0,a=this.data.length;b<a;b++){if(this.data[b].type=="GSPointFeature"){c++}}if(c<2){if(this.routePath){this.routePath.remove();this.routePath=null}return}var d=GSUtil.bind(this.imageCallback,this);if(!this.routePath){this.routePath=new GSRasterImageFeature(d);this.addFeature(this.routePath)}else{this.routePath.callback=d;this.routePath.render()}};GSRouteLayer.prototype.removeRoute=function(){if(this.routePath){this.removeFeature(this.routePath);this.routePath=undefined}};GSRouteLayer.prototype.imageCallback=function(d,b,c){var a=(this.directionsServiceUrl.indexOf("?")!=-1?this.directionsServiceUrl+"&":this.directionsServiceUrl+"?")+"stops="+this.serializeStops();a+="&xmin="+b.minX+"&ymin="+b.minY+"&xmax="+b.maxX+"&ymax="+b.maxY;a+="&width="+c.width+"&height="+c.height;a+="&color="+encodeURIComponent(this.color)+"&weight="+this.lineWeight+"&opacity="+this.opacity;return a};GSRouteLayer.prototype.serializeStops=function(){var b=[];for(var d=0,a=this.data.length;d<a;d++){var c=this.data[d];if(c.type=="GSPointFeature"){b.push(c.coordinate.x+":"+c.coordinate.y+":"+c.name)}}if(this.returnToStart){b.push(this.data[0].coordinate.x+":"+this.data[0].coordinate.y+":"+this.data[0].name)}return encodeURIComponent(b.join(","))};GSRouteLayer.prototype.clear=function(){GSRouteLayer.superClass.clear.call(this);this.routePath=undefined};GSRouteLayer.prototype.setVisible=function(d){this.visible=d;for(var c=0,a=this.data.length;c<a;c++){var b=this.data[c];if(b.type=="GSPointFeature"){if(d&&this.waypointsVisible){b.setVisible(true)}else{b.setVisible(false)}}else{b.setVisible(d)}b.render()}};GSRouteLayer.prototype.toJson=function(){var f={type:this.type,zIndex:this.zIndex,visible:this.visible,waypointsVisible:this.waypointsVisible,routeStyle:{color:this.color,weight:this.lineWeight,opacity:this.opacity}};var d=[];for(var c=0,a=this.data.length;c<a;c++){var b=this.data[c];if(b.type!="GSRasterImageFeature"){d.push(b)}}f.feature=d;return GSUtil.objToJson(f)};var GSCookie={set:function(c,f,b){var a="";if(b!=undefined){var g=new Date();g.setTime(g.getTime()+(86400000*parseFloat(b)));a="; expires="+g.toGMTString()}return(document.cookie=escape(c)+"="+escape(f||"")+a)},get:function(a){var b=document.cookie.match(new RegExp("(^|;)\\s*"+escape(a)+"=([^;\\s]*)"));return(b?unescape(b[2]):null)},erase:function(a){var b=GSCookie.get(a)||true;GSCookie.set(a,"",-1);return b},accept:function(){if(typeof navigator.cookieEnabled=="boolean"){if(document.cookie!==undefined){return navigator.cookieEnabled}else{return false}}GSCookie.set("_test","1");return(GSCookie.erase("_test")==="1")}};function GSContextMenu(a){this.options=a?a:{};this.edgeOffset=5;this.menuItems=[];this.selectedIndex=-1;this.eventListeners={};this.element;this.map;this.onmap=false;this.showing=false;this.initialize()}GSContextMenu.prototype.addToMap=function(a){this.map=a;a.container.appendChild(this.element);this.onmap=true};GSContextMenu.prototype.getItems=function(){return this.menuItems};GSContextMenu.prototype.addItem=function(a){a.parent=this;this.menuItems.push(a);a.addToMenu(this)};GSContextMenu.prototype.addItemAt=function(b,a){b.parent=this;this.menuItems.splice(a,0,b);b.addToMenu(this,a)};GSContextMenu.prototype.removeItem=function(c){for(var b=0,a=this.menuItems.length;b<a;b++){if(this.menuItems[b]===c){this.menuItems.splice(b,1)[0].remove();return}}};GSContextMenu.prototype.removeItemAt=function(a){this.menuItems.splice(a,1)[0].remove()};GSContextMenu.prototype.hide=function(){this.broadcastMessage("contextMenuHide",this);this.element.style.visibility="hidden";this.unsubscribeForKeyEvents();this.selectedIndex=-1;this.updateItemsSelection();GSContextMenuManager.contextMenuHidden(this);this.showing=false};GSContextMenu.prototype.show=function(a,f){this.broadcastMessage("contextMenuShow",this,f);if(a){this.position=a;var d=[this.element.offsetWidth,this.element.offsetHeight];var c=this.position.y+d[1]+this.edgeOffset>this.map.pxHeight?"bottom":"top";var b=this.position.x+d[0]+this.edgeOffset>this.map.pxWidth?"right":"left";if(c=="top"){this.element.style.top=this.position.y+"px";this.element.style.bottom="auto"}else{this.element.style.top="auto";this.element.style.bottom=(this.map.pxHeight-this.position.y)+"px"}if(b=="left"){this.element.style.left=this.position.x+"px";this.element.style.right="auto"}else{this.element.style.left="auto";this.element.style.right=(this.map.pxWidth-this.position.x)+"px"}}this.element.style.visibility="visible";this.subscribeToKeyEvents();this.showing=true};GSContextMenu.prototype.subscribeToKeyEvents=function(){this.eventListeners.keydown=GSEventManager.addEventListener(document,"keydown",GSUtil.bindAsEventListener(this.keyHandler,this))};GSContextMenu.prototype.unsubscribeForKeyEvents=function(){GSEventManager.removeEventListener(this.eventListeners.keydown)};GSContextMenu.prototype.keyHandler=function(a){switch(a.keyCode){case GSKeyEvents.KEY_ESC:this.hide();return;case GSKeyEvents.KEY_RETURN:this.dispatchClickEvent(this.menuItems[this.selectedIndex]);return;case GSKeyEvents.KEY_UP:this.selectPrevious();return;case GSKeyEvents.KEY_DOWN:this.selectNext();return}};GSContextMenu.prototype.selectNext=function(){if(this.selectedIndex<this.menuItems.length-1){var a=this.selectedIndex;do{a+=1}while(!this.menuItems[a].isFocusTraversable()&&a<this.menuItems.length-1);if(this.menuItems[a].isFocusTraversable()){this.selectedIndex=a}this.updateItemsSelection()}};GSContextMenu.prototype.selectPrevious=function(){if(this.selectedIndex>0){var a=this.selectedIndex;do{a-=1}while(!this.menuItems[a].isFocusTraversable()&&a>0);if(this.menuItems[a].isFocusTraversable()){this.selectedIndex=a}this.updateItemsSelection()}};GSContextMenu.prototype.selectItem=function(c){for(var b=0,a=this.menuItems.length;b<a;b++){if(this.menuItems[b]===c){this.selectedIndex=b;this.updateItemsSelection();return}}};GSContextMenu.prototype.dispatchClickEvent=function(a){var b=document.createEvent("MouseEvents");b.initEvent("click",true,true);a.element.dispatchEvent(b)};GSContextMenu.prototype.updateItemsSelection=function(){for(var b=0,a=this.menuItems.length;b<a;b++){if(b==this.selectedIndex){this.menuItems[b].select()}else{this.menuItems[b].deselect()}}};GSContextMenu.prototype.initialize=function(){this.element=document.createElement("div");this.element.className="gs_contextmenu";with(this.element.style){visibility="hidden";position="absolute";zIndex=1000;color="#000";backgroundColor="#f0f0f0";borderColor="#ccc rgb(103, 103, 103) rgb(103, 103, 103) #ccc";borderStyle="solid";borderWidth="1px";fontFamily=this.options.fontFamily?this.options.fontFamily:"Arial, Helvetica, Sans-serif";fontSize=this.options.fontSize?this.options.fontSize:"11px"}GSEventBroadcaster.initialize(this);GSEventManager.addEventListener(this.element,"contextmenu",GSUtil.cancelEvent);if(this.options.highlightBackgroundImage){new Image().src=this.options.highlightBackgroundImage}};GSContextMenu.prototype.remove=function(){if(this.map){map.container.removeChild(this.element)}this.onmap=false};function GSMenuItem(b,a){this.options=a?a:{};this.label=b;this.enabled=this.options.enabled!==undefined?this.options.enabled:true;this.isSeparator=this.options.isSeparator!==undefined?this.options.isSeparator:false;this.parent;this.element;this.initialize()}GSMenuItem.prototype.initialize=function(){this.element=document.createElement("div");this.element.className="gs_menuitem";this.element.style.clear="left";if(this.isSeparator){this.element.className+=" gs_separator";this.element.style.width="150px";this.element.style.borderTop="1px solid #ccc";this.element.appendChild(document.createElement("div"))}else{this.element.style.width="130px";this.element.style.padding="3px 10px";if(!this.enabled){this.applyDisabledStyle()}else{this.applyEnabledStyle()}var a="";if(this.options.icon){a+='<img src="'+this.options.icon+'" alt="" style="float: left; margin-right: 3px"/>'}a+=this.label;this.element.innerHTML=a;this.addEventHandlers()}if(this.options.action){GSEventManager.addEventListener(this.element,"click",GSUtil.bindAsEventListener(this.performAction,this,this.options.action))}};GSMenuItem.prototype.addEventHandlers=function(){GSEventManager.addEventListener(this.element,"mouseover",GSUtil.bindAsEventListener(this.mouseoverHandler,this));GSEventManager.addEventListener(this.element,"contextmenu",GSUtil.cancelEvent);GSEventManager.addEventListener(this.element,"dblclick",GSUtil.cancelEvent)};GSMenuItem.prototype.addToMenu=function(g,c){this.menu=g;var b=this.menu.element;if(c!==undefined){var f=null;for(var d=0,a=b.childNodes.length;d<a;d++){if(d==c){f=b.childNodes[d];break}}b.insertBefore(this.element,f)}else{b.appendChild(this.element)}};GSMenuItem.prototype.remove=function(){this.element.parentNode.removeChild(this.element)};GSMenuItem.prototype.addEventHandler=function(b,c){var a=GSEventManager.addEventListener(this.element,b,GSUtil.bindAsEventListener(c,this));return a};GSMenuItem.prototype.removeEventHandler=function(a){GSEventManager.release(a)};GSMenuItem.prototype.isFocusTraversable=function(){return this.enabled&&!this.isSeparator};GSMenuItem.prototype.setEnabled=function(a){this.enabled=a;if(this.enabled){this.applyEnabledStyle()}else{this.applyDisabledStyle()}};GSMenuItem.prototype.performAction=function(a,b){if(this.enabled){b(this);this.parent.hide()}};GSMenuItem.prototype.select=function(){this.element.style.color=this.menu.options.highlightColor?this.menu.options.highlightColor:"#fff";if(this.menu.options.highlightBackgroundImage){this.element.style.background="url("+this.menu.options.highlightBackgroundImage+") repeat-x"}else{this.element.style.backgroundColor=this.menu.options.highlightBackgroundColor?this.menu.options.highlightBackgroundColor:"#336fcb"}};GSMenuItem.prototype.deselect=function(){if(this.enabled){this.applyEnabledStyle()}else{this.applyDisabledStyle()}this.element.style.background="none"};GSMenuItem.prototype.applyEnabledStyle=function(){this.element.style.color="#000";this.element.style.cursor="pointer"};GSMenuItem.prototype.applyDisabledStyle=function(){this.element.style.color="#8c8c8c";this.element.style.cursor="default"};GSMenuItem.prototype.mouseoverHandler=function(a){if(this.isFocusTraversable()){this.menu.selectItem(this)}};GSUtil.extend(GSLabel,GSMapFeature);function GSLabel(b,c,a){GSLabel.baseConstructor.call(this);this.type="GSLabel";this.text=b;this.textEl=null;this.backgroundEl=null;this.coordinate=c;this.blink=null;this.options={color:"#fff",backgroundColor:"#000",opacity:0.6,padding:1,fontSize:12,fontWeight:"normal",fontFamily:"Arial, Helvetica, Sans-serif",position:{},textShadow:true};GSUtil.merge(a,this.options);this.options.borderRadius=this.options.borderRadius?this.options.borderRadius:(Number(this.options.fontSize)+Number(this.options.padding)*2)/2,this.initialize()}GSLabel.prototype.initialize=function(){this.graphicsEl=document.createElement("div");this.graphicsEl.className="gs_label";with(this.graphicsEl.style){fontSize=this.options.fontSize+"px";lineHeight=this.options.fontSize+"px";fontWeight=this.options.fontWeight;fontFamily=this.options.fontFamily;visibility="visible"}this.backgroundEl=document.createElement("div");with(this.backgroundEl.style){position="absolute";padding=this.options.padding+"px 4px";backgroundColor=this.options.backgroundColor;MozBorderRadius=this.options.borderRadius+"px";khtmlBorderRadius=this.options.borderRadius+"px";webkitBorderRadius=this.options.borderRadius+"px";opacity=this.options.opacity;filter="Alpha(opacity="+(this.options.opacity*100)+")"}this.backgroundEl.innerHTML=this.text;this.graphicsEl.appendChild(this.backgroundEl);this.textEl=document.createElement("div");with(this.textEl.style){position="absolute";zIndex=2;color=this.options.color;padding=this.options.padding+"px 4px";opacity="1";filter="Alpha(opacity=100)"}if(this.options.textShadow){this.textEl.style.textShadow="0 1px 2px "+this.options.backgroundColor}this.textEl.innerHTML=this.text;this.graphicsEl.appendChild(this.textEl)};GSLabel.prototype.setText=function(a){this.textEl.innerHTML=a;this.backgroundEl.innerHTML=a;this.render()};GSLabel.prototype.getText=function(){return this.text};GSLabel.prototype.showBackground=function(){this.backgroundEl.style.display="block"};GSLabel.prototype.hideBackground=function(){this.backgroundEl.style.display="none"};GSLabel.prototype.setColor=function(a){this.options.color=a;this.textEl.style.color=a};GSLabel.prototype.setBackgroundColor=function(a){this.options.backgroundColor=a;this.backgroundEl.style.backgroundColor=a};GSLabel.prototype.setOpacity=function(a){this.options.opacity=a;this.backgroundEl.style.opacity=a;this.backgroundEl.style.filter="Alpha(opacity="+(a*100)+")"};GSLabel.prototype.setCoordinate=function(b,a){this.coordinate=b;this.render()};GSLabel.prototype.setDisplayLevels=function(a){this.options.displayLevels=a;this.render()};GSLabel.prototype.blink=function(a){this.blink={duration:a,start:new Date().getTime(),tic:setInterval(GSUtil.bind(this.doBlink,this),250)}};GSLabel.prototype.doBlink=function(){this.setVisible(!this.isVisible());if(new Date().getTime()-this.blink.start>=this.blink.duration){clearInterval(this.blink.tic);this.blink=null}};GSLabel.prototype.setVisible=function(a){this.visible=a;if(this.onmap&&this.visible){this.render()}else{this.graphicsEl.style.visibility="hidden"}};GSLabel.prototype.addToLayer=function(a){a.contentContainer.appendChild(this.graphicsEl);GSLabel.superClass.addToLayer.call(this,a)};GSLabel.prototype.render=function(){if(this.onmap&&this.isVisible()&&this.shouldRender(this.layer.map)&&this.layer.map.contains(this.coordinate)){var a=this.layer.map.translateToMapCoordinate(this.coordinate);this.updatePosition(a);this.graphicsEl.style.visibility="visible"}else{this.graphicsEl.style.visibility="hidden"}};GSLabel.prototype.updatePosition=function(c){var b=c.x;var a=c.y;if(this.options.position.left!==undefined){b=c.x+this.options.position.left}else{if(this.options.position.right!==undefined){b=c.x-(this.textEl.offsetWidth+this.options.position.right)}}if(this.options.position.top!==undefined){a=c.y+this.options.position.top}else{if(this.options.position.bottom!==undefined){a=c.y-(this.textEl.offsetHeight+this.options.position.bottom)}}GSUtil.positionElement(this.graphicsEl,b,a)};GSLabel.prototype.shouldRender=function(f){var b=this.options.displayLevels;if(b){var g=f.scaleIdx;if(b instanceof Array){for(var c=0,a=b.length;c<a;c++){if(b[c]===g){return true}}return false}else{if((typeof b).toLowerCase()=="string"){var d=b.match(/([0-9]+)-([0-9]+)/);return g>=Number(d[1])&&g<=Number(d[2])}else{return true}}}else{return true}};GSLabel.prototype.addEventHandler=function(a,b){if(a==="click"){this.graphicsEl.style.cursor="pointer"}GSLabel.superClass.addEventHandler.call(this,a,b)};GSLabel.prototype.remove=function(){if(this.graphicsEl.parentNode){this.graphicsEl.parentNode.removeChild(this.graphicsEl)}GSLabel.superClass.remove.call(this)};function GSTip(b,a){this.element=b;this.options={fixed:false,showDelay:100,hideDelay:100,maxDisplayChars:999999,offset:new GSPoint(16,16)};GSUtil.merge(a,this.options);var c=this.options.text?this.options.text:(this.element.title?this.element.title:"");if(c.length>this.options.maxDisplayChars){c=c.substring(0,this.options.maxDisplayChars)+"&hellip;"}this.element.removeAttribute("title");this.text=c;this.visible=false;this.eventHandlers={};this.build();return this}GSTip.prototype.build=function(){this.tipEl=document.createElement("div");with(this.tipEl.style){display="none";position="absolute";zIndex=100000}if(this.options.className){this.tipEl.className=this.options.className}else{this.tipEl.className="gs_tip";with(this.tipEl.style){color="#000";backgroundColor="#f0f0f0";fontFamily="Arial, Helvetica, Sans-serif";fontSize="11px";borderColor="#999 rgb(103, 103, 103) rgb(103, 103, 103) #999";borderStyle="solid";borderWidth="1px";padding="2px 4px"}}this.tipEl.innerHTML=this.text;this.addEventHandlers()};GSTip.prototype.addToParent=function(a){this.parentNode=a;this.parentNode.appendChild(this.tipEl);return this};GSTip.prototype.addEventHandlers=function(){var c=GSUtil.bind(this.show,this);this.eventHandlers.mouseover=GSEventManager.addEventListener(this.element,"mouseover",c);var b=GSUtil.bind(this.hide,this);this.eventHandlers.mouseout=GSEventManager.addEventListener(this.element,"mouseout",b);var a=GSUtil.bindAsEventListener(this.onMouseMove,this);this.eventHandlers.mousemove=GSEventManager.addEventListener(this.element,"mousemove",a)};GSTip.prototype.position=function(){var a=new GSPoint(parseInt(GSUtil.getComputedStyle(this.element,"left")),parseInt(GSUtil.getComputedStyle(this.element,"top")));this.positionRelativeToParent(a)};GSTip.prototype.positionRelativeToParent=function(g){var d=this.getDimensions();var a=d.width;var c=d.height;var b=(g.x+a+this.options.offset.x)>parseInt(GSUtil.getComputedStyle(this.parentNode,"width"));var f=(g.y+c+this.options.offset.y)>parseInt(GSUtil.getComputedStyle(this.parentNode,"height"));if(b){this.tipEl.style.left="auto";this.tipEl.style.right=this.options.offset.x+"px"}else{this.tipEl.style.left=g.x+this.options.offset.x+"px";this.tipEl.style.right="auto"}if(f){this.tipEl.style.top="auto";this.tipEl.style.bottom=this.options.offset.y+"px"}else{this.tipEl.style.top=g.y+this.options.offset.y+"px";this.tipEl.style.bottom="auto"}};GSTip.prototype.getDimensions=function(){this.tipEl.style.left="-1000px";this.tipEl.style.right="auto";if(!this.visible){this.tipEl.style.display="block"}var a=parseInt(GSUtil.getComputedStyle(this.tipEl,"width"));var d=parseInt(GSUtil.getComputedStyle(this.tipEl,"height"));var c=parseInt(GSUtil.getComputedStyle(this.tipEl,"padding-left"));var i=parseInt(GSUtil.getComputedStyle(this.tipEl,"padding-right"));var g=parseInt(GSUtil.getComputedStyle(this.tipEl,"padding-top"));var b=parseInt(GSUtil.getComputedStyle(this.tipEl,"padding-bottom"));if(!this.visible){this.tipEl.style.display="none"}var f=new GSDimension(a+c+i,d+g+b);return f};GSTip.prototype.show=function(){this.position();setTimeout(GSUtil.bind(this.onShow,this,this.tipEl),this.options.showDelay)};GSTip.prototype.hide=function(){setTimeout(GSUtil.bind(this.onHide,this,this.tipEl),this.options.hideDelay)};GSTip.prototype.onShow=function(a){a.style.display="block";this.visible=true};GSTip.prototype.setText=function(a){this.text=a;this.tipEl.innerHTML=this.text};GSTip.prototype.onHide=function(a){a.style.display="none";this.visible=false};GSTip.prototype.onMouseMove=function(a){if(!this.options.fixed){var b=GSUtil.getMousePixelCoordinate(a,this.parentNode);this.positionRelativeToParent(b)}else{var b=GSUtil.getElementPosition(this.element);this.positionRelativeToParent(b)}};GSTip.prototype.remove=function(){for(var a in this.eventHandlers){GSEventManager.release(this.eventHandlers[a])}this.parentNode.removeChild(this.tipEl)};var GSCrypt={};GSCrypt.hexcase=0;GSCrypt.chrsz=8;GSCrypt.hex_md5=function(a){return GSCrypt.binl2hex(GSCrypt.core_md5(GSCrypt.str2binl(a),a.length*GSCrypt.chrsz))};GSCrypt.str_md5=function(a){return GSCrypt.binl2str(GSCrypt.core_md5(GSCrypt.str2binl(a),a.length*GSCrypt.chrsz))};GSCrypt.md5_vm_test=function(){return GSCrypt.hex_md5("abc")=="900150983cd24fb0d6963f7d28e17f72"};GSCrypt.core_md5=function(r,l){r[l>>5]|=128<<((l)%32);r[(((l+64)>>>9)<<4)+14]=l;var q=1732584193;var o=-271733879;var n=-1732584194;var m=271733878;for(var h=0;h<r.length;h+=16){var k=q;var j=o;var g=n;var f=m;q=GSCrypt.md5_ff(q,o,n,m,r[h+0],7,-680876936);m=GSCrypt.md5_ff(m,q,o,n,r[h+1],12,-389564586);n=GSCrypt.md5_ff(n,m,q,o,r[h+2],17,606105819);o=GSCrypt.md5_ff(o,n,m,q,r[h+3],22,-1044525330);q=GSCrypt.md5_ff(q,o,n,m,r[h+4],7,-176418897);m=GSCrypt.md5_ff(m,q,o,n,r[h+5],12,1200080426);n=GSCrypt.md5_ff(n,m,q,o,r[h+6],17,-1473231341);o=GSCrypt.md5_ff(o,n,m,q,r[h+7],22,-45705983);q=GSCrypt.md5_ff(q,o,n,m,r[h+8],7,1770035416);m=GSCrypt.md5_ff(m,q,o,n,r[h+9],12,-1958414417);n=GSCrypt.md5_ff(n,m,q,o,r[h+10],17,-42063);o=GSCrypt.md5_ff(o,n,m,q,r[h+11],22,-1990404162);q=GSCrypt.md5_ff(q,o,n,m,r[h+12],7,1804603682);m=GSCrypt.md5_ff(m,q,o,n,r[h+13],12,-40341101);n=GSCrypt.md5_ff(n,m,q,o,r[h+14],17,-1502002290);o=GSCrypt.md5_ff(o,n,m,q,r[h+15],22,1236535329);q=GSCrypt.md5_gg(q,o,n,m,r[h+1],5,-165796510);m=GSCrypt.md5_gg(m,q,o,n,r[h+6],9,-1069501632);n=GSCrypt.md5_gg(n,m,q,o,r[h+11],14,643717713);o=GSCrypt.md5_gg(o,n,m,q,r[h+0],20,-373897302);q=GSCrypt.md5_gg(q,o,n,m,r[h+5],5,-701558691);m=GSCrypt.md5_gg(m,q,o,n,r[h+10],9,38016083);n=GSCrypt.md5_gg(n,m,q,o,r[h+15],14,-660478335);o=GSCrypt.md5_gg(o,n,m,q,r[h+4],20,-405537848);q=GSCrypt.md5_gg(q,o,n,m,r[h+9],5,568446438);m=GSCrypt.md5_gg(m,q,o,n,r[h+14],9,-1019803690);n=GSCrypt.md5_gg(n,m,q,o,r[h+3],14,-187363961);o=GSCrypt.md5_gg(o,n,m,q,r[h+8],20,1163531501);q=GSCrypt.md5_gg(q,o,n,m,r[h+13],5,-1444681467);m=GSCrypt.md5_gg(m,q,o,n,r[h+2],9,-51403784);n=GSCrypt.md5_gg(n,m,q,o,r[h+7],14,1735328473);o=GSCrypt.md5_gg(o,n,m,q,r[h+12],20,-1926607734);q=GSCrypt.md5_hh(q,o,n,m,r[h+5],4,-378558);m=GSCrypt.md5_hh(m,q,o,n,r[h+8],11,-2022574463);n=GSCrypt.md5_hh(n,m,q,o,r[h+11],16,1839030562);o=GSCrypt.md5_hh(o,n,m,q,r[h+14],23,-35309556);q=GSCrypt.md5_hh(q,o,n,m,r[h+1],4,-1530992060);m=GSCrypt.md5_hh(m,q,o,n,r[h+4],11,1272893353);n=GSCrypt.md5_hh(n,m,q,o,r[h+7],16,-155497632);o=GSCrypt.md5_hh(o,n,m,q,r[h+10],23,-1094730640);q=GSCrypt.md5_hh(q,o,n,m,r[h+13],4,681279174);m=GSCrypt.md5_hh(m,q,o,n,r[h+0],11,-358537222);n=GSCrypt.md5_hh(n,m,q,o,r[h+3],16,-722521979);o=GSCrypt.md5_hh(o,n,m,q,r[h+6],23,76029189);q=GSCrypt.md5_hh(q,o,n,m,r[h+9],4,-640364487);m=GSCrypt.md5_hh(m,q,o,n,r[h+12],11,-421815835);n=GSCrypt.md5_hh(n,m,q,o,r[h+15],16,530742520);o=GSCrypt.md5_hh(o,n,m,q,r[h+2],23,-995338651);q=GSCrypt.md5_ii(q,o,n,m,r[h+0],6,-198630844);m=GSCrypt.md5_ii(m,q,o,n,r[h+7],10,1126891415);n=GSCrypt.md5_ii(n,m,q,o,r[h+14],15,-1416354905);o=GSCrypt.md5_ii(o,n,m,q,r[h+5],21,-57434055);q=GSCrypt.md5_ii(q,o,n,m,r[h+12],6,1700485571);m=GSCrypt.md5_ii(m,q,o,n,r[h+3],10,-1894986606);n=GSCrypt.md5_ii(n,m,q,o,r[h+10],15,-1051523);o=GSCrypt.md5_ii(o,n,m,q,r[h+1],21,-2054922799);q=GSCrypt.md5_ii(q,o,n,m,r[h+8],6,1873313359);m=GSCrypt.md5_ii(m,q,o,n,r[h+15],10,-30611744);n=GSCrypt.md5_ii(n,m,q,o,r[h+6],15,-1560198380);o=GSCrypt.md5_ii(o,n,m,q,r[h+13],21,1309151649);q=GSCrypt.md5_ii(q,o,n,m,r[h+4],6,-145523070);m=GSCrypt.md5_ii(m,q,o,n,r[h+11],10,-1120210379);n=GSCrypt.md5_ii(n,m,q,o,r[h+2],15,718787259);o=GSCrypt.md5_ii(o,n,m,q,r[h+9],21,-343485551);q=GSCrypt.safe_add(q,k);o=GSCrypt.safe_add(o,j);n=GSCrypt.safe_add(n,g);m=GSCrypt.safe_add(m,f)}return Array(q,o,n,m)};GSCrypt.md5_cmn=function(i,f,d,c,h,g){return GSCrypt.safe_add(GSCrypt.bit_rol(GSCrypt.safe_add(GSCrypt.safe_add(f,i),GSCrypt.safe_add(c,g)),h),d)};GSCrypt.md5_ff=function(h,g,l,k,f,j,i){return GSCrypt.md5_cmn((g&l)|((~g)&k),h,g,f,j,i)};GSCrypt.md5_gg=function(h,g,l,k,f,j,i){return GSCrypt.md5_cmn((g&k)|(l&(~k)),h,g,f,j,i)};GSCrypt.md5_hh=function(h,g,l,k,f,j,i){return GSCrypt.md5_cmn(g^l^k,h,g,f,j,i)};GSCrypt.md5_ii=function(h,g,l,k,f,j,i){return GSCrypt.md5_cmn(l^(g|(~k)),h,g,f,j,i)};GSCrypt.safe_add=function(a,d){var c=(a&65535)+(d&65535);var b=(a>>16)+(d>>16)+(c>>16);return(b<<16)|(c&65535)};GSCrypt.bit_rol=function(a,b){return(a<<b)|(a>>>(32-b))};GSCrypt.str2binl=function(d){var c=Array();var a=(1<<GSCrypt.chrsz)-1;for(var b=0;b<d.length*GSCrypt.chrsz;b+=GSCrypt.chrsz){c[b>>5]|=(d.charCodeAt(b/GSCrypt.chrsz)&a)<<(b%32)}return c};GSCrypt.binl2str=function(c){var d="";var a=(1<<GSCrypt.chrsz)-1;for(var b=0;b<c.length*32;b+=GSCrypt.chrsz){d+=String.fromCharCode((c[b>>5]>>>(b%32))&a)}return d};GSCrypt.binl2hex=function(c){var b=GSCrypt.hexcase?"0123456789ABCDEF":"0123456789abcdef";var d="";for(var a=0;a<c.length*4;a++){d+=b.charAt((c[a>>2]>>((a%4)*8+4))&15)+b.charAt((c[a>>2]>>((a%4)*8))&15)}return d};function GSContextMenuManager(){}GSContextMenuManager.defaultOptions={fontFamily:"Lucida Grande, Arial, Helvetica, Sans-serif",fontSize:"12px"};GSContextMenuManager.menus={};GSContextMenuManager.activeMenu;GSContextMenuManager.getContextMenu=function(a){if(GSContextMenuManager.menus.map){return GSContextMenuManager.menus.map}else{if(GSContextMenuManager.menus["default"]){return GSContextMenuManager.menus["default"]}else{var a=GSUtil.merge(GSContextMenuManager.defaultOptions,a);var b=new GSContextMenu(a);GSContextMenuManager.menus["default"]=b;return b}}};GSContextMenuManager.getContextMenuByName=function(a){var b=null;if(GSContextMenuManager.menus[a]){b=GSContextMenuManager.menus[a]}return b};GSContextMenuManager.setContextMenu=function(a,b){GSContextMenuManager.menus[a]=b};GSContextMenuManager.contextMenuOpened=function(a){GSContextMenuManager.activeMenu=a};GSContextMenuManager.contextMenuHidden=function(a){GSContextMenuManager.activeMenu=null};