
function GSUtil(){}
GSUtil.extend=function(subClass,baseClass){function inheritance(){}
inheritance.prototype=baseClass.prototype;subClass.prototype=new inheritance();subClass.prototype.constructor=subClass;subClass.baseConstructor=baseClass;subClass.superClass=baseClass.prototype;};GSUtil.getPropertyArray=function(ar,propertyName){var props=[];for(var i=0,l=ar.length;i<l;i++){var e=ar[i];if(e[propertyName]!=undefined)
props.push(e[propertyName]);}
return props;};GSUtil.getMinimum=function(ar){var min=Infinity;for(var i=0,l=ar.length;i<l;i++){min=Math.min(min,ar[i]);}
return min;};GSUtil.getMaximum=function(ar){var max=-Infinity;for(var i=0,l=ar.length;i<l;i++){max=Math.max(max,ar[i]);}
return max;};GSUtil.findPosX=function(obj){var curleft=0;if(obj.offsetParent){while(obj.offsetParent){curleft+=obj.offsetLeft;obj=obj.offsetParent;}}else if(obj.x){curleft+=obj.x;}
return curleft;};GSUtil.findPosY=function(obj){var el=obj;var curtop=0;if(obj.offsetParent){while(obj.offsetParent){curtop+=obj.offsetTop;obj=obj.offsetParent;}}else if(obj.y){curtop+=obj.y;}
if(_browser.isOpera||((_browser.isSafari&&el.style.position=="absolute")||(_browser.isSafari&&el.style.position=="relative"))){curtop-=document.body.offsetTop;}
return curtop;};GSUtil.getClickPixelCoordinate=function(e,container){if(typeof e.pageX!="undefined"){var pos=GSUtil.getElementPosition(container);return new GSPoint(e.pageX-pos.x,e.pageY-pos.y);}else if(typeof e.offsetX!="undefined"){var src=e.target||e.srcElement;var offset=GSUtil.getOffsetFromAncestor(src,container);return new GSPoint(e.offsetX+offset.x,e.offsetY+offset.y);}else{return new GSPoint(0,0);}};GSUtil.getElementPosition=function(elem){var pos=new GSPoint(0,0);while(elem){pos.x+=elem.offsetLeft;pos.y+=elem.offsetTop;elem=elem.offsetParent;}
return pos;};GSUtil.getWindowSize=function(){var size={};if(self.innerHeight){size.width=self.innerWidth;size.height=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){size.width=document.documentElement.clientWidth;size.height=document.documentElement.clientHeight;}else if(document.body){size.width=document.body.clientWidth;size.height=document.body.clientHeight;}
return size;};GSUtil.getOffsetFromAncestor=function(src,ancestor){var offset=new GSPoint(0,0);while(src&&src!=ancestor){offset.x+=src.offsetLeft;offset.y+=src.offsetTop;src=src.offsetParent;}
return offset;};GSUtil.getMousePos=function(e){var ev=e?e:window.event;if(typeof ev.pageX!="undefined")
return new GSPoint(ev.pageX,ev.pageY);else if(typeof ev.clientX!="undefined")
return new GSPoint(ev.clientX+document.body.scrollLeft,ev.clientY+document.body.scrollTop);else
return new GSPoint(0,0);};GSUtil.cancelEvent=function(e){e=e?e:window.event;GSUtil.eventStopPropagation(e);GSUtil.eventPreventDefault(e);return false;};GSUtil.eventStopPropagation=function(e){if(e.stopPropagation){e.stopPropagation();}else{e.cancelBubble=true;}};GSUtil.eventPreventDefault=function(e){if(e.stopPropagation){e.preventDefault();}else{e.returnValue=false;}};GSUtil.positionElement=function(elem,left,top,right,bottom){var position=GSUtil.getComputedStyle(elem,"position");if(position!="absolute"&&position!="relative"){elem.style.position="absolute";}
if(left||left==0)elem.style.left=left+"px";if(top||top==0)elem.style.top=top+"px";if(bottom||bottom==0)elem.style.bottom=bottom+"px";if(right||right==0)elem.style.right=right+"px";};GSUtil.createElement=function(name){if(document.createElementNS){return document.createElementNS(_globals.xmlns,name);}else{return document.createElement(name);}};GSUtil.createContainer=function(parent,className,width,height,left,top,visibility,zIndex){var container=document.createElement("div");parent.appendChild(container);container.className=className;if(width)
container.style.width=width=="auto"?"auto":width+"px";if(height)
container.style.height=height=="auto"?"auto":height+"px";if(left||top||left==0||top==0){container.style.position="absolute";container.style.left=left+"px";container.style.top=top+"px";}
if(visibility){container.style.visibility=visibility;}
if(zIndex){container.style.zIndex=zIndex;}
return container;};GSUtil.createImage=function(id,src,width,height,left,top,zIndex,className,alt,sizingMethod){var img=null;var fileType=src.substring(src.lastIndexOf(".")+1);if(fileType.toLowerCase()=="png"&&_browser.pngAlpha){sizingMethod=sizingMethod?sizingMethod:'scale';img=document.createElement("div");img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',"+"sizingMethod='"+sizingMethod+"')";}else{img=document.createElement("img");img.src=src;img.border=0;img.margin=0;img.padding=0;}
img.id=id;if(width||height){img.width=width;img.height=height;img.style.width=width+"px";img.style.height=height+"px";}
if(left||top||left==0||top==0){img.style.position="absolute";img.style.left=left+"px";img.style.top=top+"px";}
if(className!=undefined)
img.className=className;if(zIndex!=null)
img.style.zIndex=zIndex;if(alt!=undefined)
img.title=alt;if(_browser.isIE){img.setAttribute("galleryimg","no");img.unselectable="on";img.onselectstart=GSUtil.cancelEvent;}else{img.style.MozUserSelect="none";}
return img;};GSUtil.setImageSrc=function(image,src){var fileType=src.substring(src.lastIndexOf(".")+1);if(fileType.toLowerCase()=="png"&&_browser.pngAlpha){image.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',"+"sizingMethod='scale')";}else{image.src=src;}};GSUtil.getImageSrc=function(image){var src="";if(image.src!=undefined)
src=image.src;if(image.style.filter){var pattern=/src='([^']+)'/;var result=image.style.filter.match(pattern);src=result[1];}
return src;};GSUtil.createImageMap=function(name,shape,coords,href,alt,eventType,func,peer){var map=document.createElement("map");map.id=name;map.setAttribute("name",name);var area=document.createElement("area");area.setAttribute("shape",shape);area.setAttribute("coords",coords.toString());area.setAttribute("href",href);area.setAttribute("title",alt);if(peer!=undefined)
area.peer=peer;if(func!=undefined)
GSEventManager.addEventListener(area,eventType,func);map.appendChild(area);return map;};GSUtil.getTransparentBackgroundImageStyleRule=function(url,repeat){if(_browser.pngAlpha){return"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\""+url+"\", sizingMethod=\"scale\"); background-repeat: "+repeat;}else{return"background: url("+url+") "+repeat;}};GSUtil.setOpacity=function(obj,opacity){opacity=(opacity==100)?99.999:opacity;obj.style.filter="alpha(opacity:"+opacity+")";obj.style.KHTMLOpacity=opacity/100;obj.style.MozOpacity=opacity/100;obj.style.opacity=opacity/100;};GSUtil.getComputedStyle=function(element,prop){if(typeof element=='string')element=document.getElementById(element);if(element.style[prop]){return element.style[prop];}else if(element.currentStyle){return element.currentStyle[prop];}else if(document.defaultView&&document.defaultView.getComputedStyle){prop=prop.replace(/([A-Z])/g,"-$1");prop=prop.toLowerCase();var style=document.defaultView.getComputedStyle(element,"");if(style){return style.getPropertyValue(prop);}
return null;}else{return null;}}
GSUtil.getFeatureById=function(a,id){for(var i=0,l=a.length;i<l;i++){if(a[i].id==id)return a[i];}
return undefined;};GSUtil.roundNumber=function(value,rlength){return Math.round(value*Math.pow(10,rlength))/Math.pow(10,rlength);};GSUtil.getBaseName=function(path){return path.substring(path.lastIndexOf("/")+1);};GSUtil.getBaseNameWithoutExtension=function(path){var baseName=GSUtil.getBaseName(path);return baseName.substring(0,baseName.indexOf("."));};GSUtil.getDirName=function(path){return path.substring(0,path.lastIndexOf("/"));};GSUtil.clone=function(obj,deep){try{var objectClone=new obj.constructor();for(var property in obj){if(!deep){if(property!='eventListeners'){objectClone[property]=obj[property];}}else if(property!='eventListeners'){if(typeof obj[property]=='object'){objectClone[property]=GSUtil.clone(obj[property],deep);}else{objectClone[property]=obj[property];}}}
return objectClone;}catch(e){return undefined;}};GSUtil.toXML=function(str){try{if(typeof ActiveXObject!="undefined"&&typeof GetObject!="undefined"){var doc=new ActiveXObject("Microsoft.XMLDOM");doc.loadXML(str);return doc;}else if(typeof DOMParser!="undefined"){return(new DOMParser()).parseFromString(str,"text/xml");}else{return undefined;}}catch(e){alert("parse error: "+e.message);return undefined;}};GSUtil.stringToBoolean=function(str){if(!str){return false;}
if(str=="true"){return true;}
if(str=="false"){return false;}
if(str=="yes"){return true;}
if(str=="no"){return false;}
return str==true;};GSUtil.getCaseInsensitiveProperty=function(obj,name,defaultValue){if(!obj||!(obj instanceof Object)){return undefined;}
var value=undefined;if(obj[name]!=undefined){value=obj[name];}else if(obj[name.toLowerCase()]){value=obj[name.toLowerCase()];}
if(value!=undefined&&(typeof value).toLowerCase()=="string"&&value!="null"){return value;}else{return value!=undefined?value:(defaultValue!=undefined?defaultValue:undefined);}};GSUtil.populateTemplate=function(template,model,secondaryModel){for(var key in model){var pattern=new RegExp("\{"+key+"\}","g");template=template.replace(pattern,model[key]?model[key]:"");}
if(secondaryModel){for(var key in secondaryModel){var pattern=new RegExp("\{"+key+"\}","g");template=template.replace(pattern,secondaryModel[key]?secondaryModel[key]:"");}}
return template;};GSUtil.joinAssociativeArray=function(array,pairSeparator,keyValueSeparator){var pairs=[];for(var key in array)
pairs.push(key+keyValueSeparator+(array[key]!=undefined?array[key]:""));return pairs.join(pairSeparator);};GSUtil.getParameter=function(obj,key,defaultValue){if(obj[key]==undefined){if(arguments.length<3)
throw new Error("Missing parameter: "+key);else
return defaultValue;}else{return obj[key];}};GSUtil.makeUnselectable=function(elem){if(typeof elem.style.MozUserSelect=="string"){elem.style.MozUserSelect="none";}else if(typeof elem.style.KhtmlUserSelect){elem.style.KhtmlUserSelect="none";}else if(typeof elem.onselectstart!="undefined"){elem.onselectstart=function(){return false;};}};_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://api2.geosmart.co.nz/images/sfapi-v2/",tilePxWidth:256,tilePxHeight:256,tilesURL:"http://tiles2.geosmart.co.nz/nz/v1",loggingBaseURL:'http://logs2.geosmart.co.nz/',loggingSessionTimeout:20*(1000*60),DEBUG:false};function Console(){win=null;}
Console.prototype={debug:function(msg){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();msg=new Date().toLocaleTimeString()+" "+msg+"<br/>";this.win.document.writeln(msg);}};var _console=new Console();function GSAnimator(from,to,framerate,duration,setvalue,onstart,onfinish){this.from=from;this.to=to;this.framerate=framerate;this.duration=duration;this.setvalue=setvalue;this.onstart=onstart;this.onfinish=onfinish;this.currentValue=from;this.startTime=0;this.timer=undefined;}
GSAnimator.prototype.animate=function(){if(!this.timer){this.startTime=new Date().getTime()-this.framerate;}
var self=this;this.timer=setInterval(function(){self.frame();},this.framerate);if(this.onstart)this.onstart(this);};GSAnimator.prototype.frame=function(){var time=new Date().getTime()-this.startTime;if(time>=this.duration){this.stopAnimate();this.currentValue=this.to;this.setvalue(this,this.currentValue);if(this.onfinish){var self=this;setTimeout(function(){self.onfinish(self);},0);}}else{var scale=0.5-(0.5*Math.cos(Math.PI*Math.max(time,0)/this.duration));var x=this.interpolate(this.from.x,this.to.x,scale);var y=this.interpolate(this.from.y,this.to.y,scale);this.currentValue=new GSPoint(x,y);this.setvalue(this,this.currentValue);}};GSAnimator.prototype.stopAnimate=function(){if(this.timer){clearInterval(this.timer);this.timer=null;}};GSAnimator.prototype.interpolate=function(from,to,ease){return from+(to-from)*ease;};function GSBounds(minX,minY,maxX,maxY){this.minX=parseFloat(minX);this.minY=parseFloat(minY);this.maxX=parseFloat(maxX);this.maxY=parseFloat(maxY);}
GSBounds.prototype.contains=function(point){return(point.x>=this.minX&&point.x<=this.maxX)&&(point.y>=this.minY&&point.y<=this.maxY);};GSBounds.prototype.toString=function(){return"Bounds: minX=["+this.minX+"], minY=["+this.minY+"]"+", maxX=["+this.maxX+"], maxY=["+this.maxY+"]";};function GSBrowser(){var ua=navigator.userAgent.toLowerCase();this.isFirefox=ua.indexOf("firefox")!=-1;this.firefoxVersion=parseFloat(ua.substring(ua.indexOf("firefox")+8));this.isSafari=ua.indexOf("applewebkit")!=-1;this.isGecko=!this.isSafari&&ua.indexOf('gecko')!=-1;this.isCamino=ua.indexOf('camino')!=-1;this.caminoVersion=parseFloat(ua.substring(ua.indexOf("camino")+7));this.isIE=((ua.indexOf("msie")!=-1)&&(ua.indexOf("opera")==-1));this.isOpera=ua.indexOf("opera")!=-1;this.versionMinor=parseFloat(navigator.appVersion);if(this.isIE&&this.versionMinor>=4){this.versionMinor=parseFloat(ua.substring(ua.indexOf('msie ')+5));}
this.versionMajor=parseInt(this.versionMinor);this.isIE55=(this.isIE&&this.versionMinor==5.5);this.isIE6x=(this.isIE&&this.versionMajor==6);this.isIE7x=(this.isIE&&this.versionMajor==7);this.isIE6up=(this.isIE&&this.versionMajor>=6);this.isWin=(ua.indexOf('win')!=-1);this.isWin32=(this.isWin&&(ua.indexOf('95')!=-1||ua.indexOf('98')!=-1||ua.indexOf('nt')!=-1||ua.indexOf('win32')!=-1||ua.indexOf('32bit')!=-1));this.pngAlpha=((this.isIE55||this.isIE6x)&&this.isWin32);this.svg=((this.isFirefox&&this.firefoxVersion>=1.5)||(this.isCamino&&this.caminoVersion>=1.0)||(this.isOpera&&this.versionMajor>=8));}
GSBrowser.prototype.isSmartfindCompatible=function(){return(this.isIE6up||this.isGecko||this.isSafari);};GSBrowser.prototype.isVectorGraphicsCapable=function(){return(this.isIE6up||this.svg);};_browser=new GSBrowser();function GSControl(name){this.name=name;this.element;this.map=null;};GSControl.prototype.setElement=function(element){this.element=element;this.element.style.zIndex=10;};GSControl.prototype.setPosition=function(position){switch(position.anchor){case GSControl.ANCHOR_TOP_LEFT:GSUtil.positionElement(this.element,position.offset.x,position.offset.y);break;case GSControl.ANCHOR_TOP_RIGHT:GSUtil.positionElement(this.element,null,position.offset.x,position.offset.y);break;case GSControl.ANCHOR_BOTTOM_LEFT:GSUtil.positionElement(this.element,position.offset.x,null,null,position.offset.y);break;case GSControl.ANCHOR_BOTTOM_RIGHT:GSUtil.positionElement(this.element,null,null,position.offset.x,position.offset.y);break;}};GSControl.prototype.render=function(map){};GSControl.prototype.getDefaultPosition=function(){return{anchor:GSControl.ANCHOR_TOP_LEFT,offset:new GSPoint(7,7)};};GSControl.prototype.remove=function(map){map.container.removeChild(this.element);};GSControl.ANCHOR_TOP_LEFT=0;GSControl.ANCHOR_TOP_RIGHT=1;GSControl.ANCHOR_BOTTOM_LEFT=2;GSControl.ANCHOR_BOTTOM_RIGHT=3;GSUtil.extend(GSTextZoomControl,GSControl);function GSTextZoomControl(labels){GSTextZoomControl.baseConstructor.call(this,GSMap.TEXT_ZOOM_CONTROL);this.labels=labels;if(!this.labels){this.labels=[{level:9,value:"Region"},{level:7,value:"District"},{level:3,value:"Suburb"},{level:1,value:"Street"}];}};GSTextZoomControl.prototype.render=function(map){var element=document.createElement('div');for(var i=0,l=this.labels.length;i<l;i++){var link=document.createElement('a');link.href="#";GSEventManager.bind(link,"click",this,function(e,level){map.zoom(level);GSUtil.cancelEvent(e);},this.labels[i].level);link.className='GSTextZoomControl';link.innerHTML=this.labels[i].value;element.appendChild(link);if(i<l-1){element.appendChild(document.createTextNode(" | "));}}
return element;};GSUtil.extend(GSCompactZoomControl,GSControl);function GSCompactZoomControl(){GSCompactZoomControl.baseConstructor.call(this,GSMap.COMPACT_ZOOM_CONTROL);}
GSCompactZoomControl.prototype.render=function(map){var element=document.createElement("div");element.style.width='22px';element.style.height='43px';var shadow=GSUtil.createImage("gscompactzoomcontrol-shadow",_globals.resourceURL+"smallZoomBG.png",22,43,0,0,0,"noprint",undefined,"image");element.appendChild(shadow);var zoomIn=GSUtil.createImage("gscompactzoomcontrol_zoomin",_globals.resourceURL+"zoomIn.png",14,13,2,3,10,"noprint","Zoom in","image");zoomIn.style.cursor="pointer";element.appendChild(zoomIn);GSEventManager.bind(zoomIn,"click",this,function(e){GSUtil.cancelEvent(e);if(map.getZoomLevel()-1<0)return;map.zoom(map.getZoomLevel()-1);});GSEventManager.addEventListener(zoomIn,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(zoomIn,"contextmenu",GSUtil.cancelEvent);var zoomOut=GSUtil.createImage("gscompactzoomcontrol_zoomout",_globals.resourceURL+"zoomOut.png",14,13,2,22,10,"noprint","Zoom out","image");zoomOut.style.cursor="pointer";element.appendChild(zoomOut);GSEventManager.bind(zoomOut,"click",this,function(e){GSUtil.cancelEvent(e);if(map.getZoomLevel()+1>=map.scaleRange.length)return;map.zoom(map.getZoomLevel()+1);});GSEventManager.addEventListener(zoomOut,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(zoomOut,"contextmenu",GSUtil.cancelEvent);return element;};GSUtil.extend(GSMapControl,GSControl);function GSMapControl(labels){GSMapControl.baseConstructor.call(this,GSMap.MAP_CONTROL);this.zoomControl=new GSZoomControl(labels);}
GSMapControl.prototype.render=function(map){var element=document.createElement("div");element.style.width='54px';element.style.height='55px';var shadow=GSUtil.createImage("gsmapcontrol-shadow",_globals.resourceURL+"compassBG.png",54,55,0,0,100,"noprint",undefined,"image");element.appendChild(shadow);var up=GSUtil.createImage("gsmapcontrol_up",_globals.resourceURL+"arrowUp.png",14,13,18,3,100,"noprint","Move up","image");up.style.cursor="pointer";GSEventManager.bind(up,"click",this,this.pan,'up',map);GSEventManager.addEventListener(up,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(up,"contextmenu",GSUtil.cancelEvent);element.appendChild(up);var left=GSUtil.createImage("gsmapcontrol_left",_globals.resourceURL+"arrowLeft.png",14,13,3,19,100,"noprint","Move left","image");left.style.cursor="pointer";left.direction="left";GSEventManager.bind(left,"click",this,this.pan,'left',map);GSEventManager.addEventListener(left,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(left,"contextmenu",GSUtil.cancelEvent);element.appendChild(left);var right=GSUtil.createImage("gsmapcontrol_right",_globals.resourceURL+"arrowRight.png",14,13,33,19,100,"noprint","Move right","image");right.style.cursor="pointer";right.direction="right";GSEventManager.bind(right,"click",this,this.pan,'right',map);GSEventManager.addEventListener(right,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(right,"contextmenu",GSUtil.cancelEvent);element.appendChild(right);var down=GSUtil.createImage("gsmapcontrol_down",_globals.resourceURL+"arrowDown.png",14,13,18,35,100,"noprint","Move down","image");down.style.cursor="pointer";down.direction="down";GSEventManager.bind(down,"click",this,this.pan,'down',map);GSEventManager.addEventListener(down,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(down,"contextmenu",GSUtil.cancelEvent);element.appendChild(down);var zoomContainer=this.zoomControl.render(map);map.container.appendChild(zoomContainer);this.zoomControl.setElement(zoomContainer);return element;};GSMapControl.prototype.setPosition=function(position){if(position.anchor==GSControl.ANCHOR_TOP_LEFT||position.anchor==GSControl.ANCHOR_BOTTOM_LEFT){this.zoomControl.setPosition({anchor:position.anchor,offset:new GSPoint(21,65)});}else{this.zoomControl.setPosition({anchor:position.anchor,offset:new GSPoint(25,65)});}
GSMapControl.superClass.setPosition.call(this,position);};GSMapControl.prototype.pan=function(e,direction,map){var percentOfWindow=0.25;var bounds=map.getBounds();var mapCenter=map.getMapCenter();var width=bounds.maxX-bounds.minX;var height=bounds.maxY-bounds.minY;var centerX=mapCenter.x;var centerY=mapCenter.y;switch(direction){case"up":var delta=percentOfWindow*height;centerY+=delta;break;case"left":var delta=percentOfWindow*width;centerX-=delta;break;case"right":var delta=percentOfWindow*width;centerX+=delta;break;case"down":var delta=percentOfWindow*height;centerY-=delta;break;}
var coordinate=new GSPoint(centerX,centerY);map.centerAtCoordinate(coordinate);GSUtil.cancelEvent(e);};GSMapControl.prototype.remove=function(map){this.zoomControl.remove(map);GSMapControl.superClass.remove.call(this,map);};GSUtil.extend(GSZoomControl,GSControl);function GSZoomControl(labels){GSZoomControl.baseConstructor.call(this,GSMap.ZOOM_CONTROL);this.sliderBar=null;this.sliderThumb=null;this.labelContainer=null;this.zooming=false;this.labels=labels;}
GSZoomControl.prototype.render=function(map){this.map=map;var element=document.createElement("div");element.style.width='22px';element.style.height='135px';this.map.addListener(this);var sliderContainer=document.createElement("div");sliderContainer.style.position="absolute";sliderContainer.style.left="2px";sliderContainer.style.top="0px";element.appendChild(sliderContainer);var zoomInBtn=GSUtil.createImage("gszoomcontrol_zoomin",_globals.resourceURL+"zoomIn.png",14,13,2,3,110,"noprint","Zoom in","image");zoomInBtn.style.cursor="pointer";sliderContainer.appendChild(zoomInBtn);GSEventManager.bind(zoomInBtn,"click",this,function(e){GSUtil.cancelEvent(e);if(map.getZoomLevel()-1<0)return;map.zoom(map.getZoomLevel()-1);});GSEventManager.addEventListener(zoomInBtn,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(zoomInBtn,"contextmenu",GSUtil.cancelEvent);var zoomOutBtn=GSUtil.createImage("gszoomcontrol_zoomout",_globals.resourceURL+"zoomOut.png",14,13,2,115,110,"noprint","Zoom out","image");zoomOutBtn.style.cursor="pointer";sliderContainer.appendChild(zoomOutBtn);GSEventManager.bind(zoomOutBtn,"click",this,function(e){GSUtil.cancelEvent(e);if(map.getZoomLevel()+1>=map.scaleRange.length)return;map.zoom(map.getZoomLevel()+1);});GSEventManager.addEventListener(zoomOutBtn,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(zoomOutBtn,"contextmenu",GSUtil.cancelEvent);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";sliderContainer.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");this.sliderThumb.style.cursor="pointer";if(this.labels){this.labelContainer=document.createElement("div");this.labelContainer.style.position="absolute";this.labelContainer.style.display="none";sliderContainer.appendChild(this.labelContainer);for(var i=0,l=this.labels.length;i<l;i++){var label=this.labels[i];var labelDiv=document.createElement("div");labelDiv.style.cursor="pointer";labelDiv.style.position="absolute";labelDiv.style.left="14px";labelDiv.style.top=(GSZoomControl.SLIDER_OFFSET+(label.level*GSZoomControl.SLIDER_INCREMENT))+"px";labelDiv.style.zIndex=115;var img=GSUtil.createImage(null,_globals.resourceURL+"zoomLabel.png",70,14,0,0,0,"noprint",undefined,"image");labelDiv.img=img;labelDiv.appendChild(img);var text=document.createElement("div");text.style.width="66px";text.style.paddingRight="4px";text.style.textAlign="right";text.style.fontFamily="Arial, Helvetica, Sans-serif";text.style.fontWeight="bold";text.style.fontSize="10px";text.style.position="relative";text.innerHTML=label.value;labelDiv.appendChild(text);GSEventManager.bind(labelDiv,"click",this,function(e,level){map.zoom(level);GSUtil.cancelEvent(e);},label.level);GSEventManager.bind(labelDiv,"mouseover",labelDiv,function(){GSUtil.setImageSrc(this.img,_globals.resourceURL+"zoomLabelOver.png");});GSEventManager.bind(labelDiv,"mouseout",labelDiv,function(){GSUtil.setImageSrc(this.img,_globals.resourceURL+"zoomLabel.png");});this.labelContainer.appendChild(labelDiv);}}
Drag.init(this.sliderThumb,null,1,1,GSZoomControl.SLIDER_MIN,GSZoomControl.SLIDER_MAX);this.sliderThumb.onDragEnd=this.getDragEndHandler(this);GSEventManager.bind(this.sliderBar,"click",this,this.sliderClicked);GSEventManager.addEventListener(this.sliderBar,"dblclick",GSUtil.cancelEvent);GSEventManager.addEventListener(this.sliderBar,"contextmenu",GSUtil.cancelEvent);sliderContainer.appendChild(this.sliderThumb);if(this.labels){GSEventManager.bind(this.sliderBar,"mouseover",this,function(){this.labelContainer.style.display="block";});GSEventManager.bind(this.sliderBar,"mouseout",this,function(){var labelContainer=this.labelContainer;if(!labelContainer.timeout){labelContainer.timeout=setInterval(function(){clearInterval(labelContainer.timeout);labelContainer.timeout=null;labelContainer.style.display="none";},3000);}});}
this.mapBoundsChanged(this.map);return element;};GSZoomControl.prototype.getDragEndHandler=function(element){return function(x,y){element.sliderMoved(x,y);};};GSZoomControl.prototype.sliderClicked=function(e){GSUtil.cancelEvent(e);var mouseX,mouseY;if(_browser.isIE){mouseX=e.offsetX;mouseY=e.offsetY;}else{mouseX=(window.pageXOffset+e.clientX-GSUtil.findPosX(this.sliderBar));mouseY=(window.pageYOffset+e.clientY-GSUtil.findPosY(this.sliderBar));}
if(mouseY<GSZoomControl.SLIDER_MIN||mouseY>GSZoomControl.SLIDER_MAX){return}
this.sliderThumb.style.top=mouseY+"px";this.sliderMoved(mouseX,mouseY);};GSZoomControl.prototype.sliderMoved=function(x,y){this.zooming=true;var zoomLevel=Math.round((y-GSZoomControl.SLIDER_OFFSET)/GSZoomControl.SLIDER_INCREMENT);this.map.zoom(zoomLevel);};GSZoomControl.prototype.mapBoundsChanged=function(map,oldBounds,newBounds){var newZoomLevel=this.map.scaleIdx;this.mapZoomed(this.map,null,newZoomLevel);};GSZoomControl.prototype.mapZoomed=function(map,oldZoomLevel,newZoomLevel){var y=Math.round(newZoomLevel*GSZoomControl.SLIDER_INCREMENT);y+=GSZoomControl.SLIDER_OFFSET;y=y<GSZoomControl.SLIDER_MIN?GSZoomControl.SLIDER_MIN:y>GSZoomControl.SLIDER_MAX?GSZoomControl.SLIDER_MAX:y;this.sliderThumb.style.top=y+"px";};GSZoomControl.prototype.remove=function(map){this.map.removeListener(this);GSZoomControl.superClass.remove.call(this,map);};GSZoomControl.SLIDER_OFFSET=22;GSZoomControl.SLIDER_INCREMENT=7;GSZoomControl.SLIDER_MIN=22;GSZoomControl.SLIDER_MAX=102;GSUtil.extend(GSSnapbackControl,GSControl);function GSSnapbackControl(){GSSnapbackControl.baseConstructor.call(this,GSMap.SNAPBACK_CONTROL);}
GSSnapbackControl.prototype.getDefaultPosition=function(){return{anchor:GSControl.ANCHOR_TOP_RIGHT,offset:new GSPoint(7,7)};};GSSnapbackControl.prototype.render=function(map){this.map=map;var element=GSUtil.createImage('snapback-control',_globals.resourceURL+'snapback.png',16,16,undefined,undefined,10,'noprint','Snapback to saved map position','image');element.style.cursor='pointer';GSEventManager.bind(element,'click',this,this.snapback);return element;};GSSnapbackControl.prototype.snapback=function(e){GSUtil.cancelEvent(e);this.map.snapback();};function GSDimension(width,height){this.width=parseInt(width);this.height=parseInt(height);}
GSDimension.prototype.toString=function(){return"Dimension: width=["+this.width+"], h=["+this.height+"]";};function GSEventBroadcaster(){}
GSEventBroadcaster.initialize=function(obj){obj.listeners=[];obj.broadcastMessage=this.broadcastMessage;obj.addListener=this.addListener;obj.removeListener=this.removeListener;};GSEventBroadcaster.broadcastMessage=function(){var eventName=arguments[0];var args=[];for(var i=1,l=arguments.length;i<l;i++){args.push(arguments[i]);}
for(var i=0;i<this.listeners.length;i++){if(this.listeners[i][eventName])
this.listeners[i][eventName].apply(this.listeners[i],args);}};GSEventBroadcaster.addListener=function(obj){this.removeListener(obj);this.listeners.push(obj);return true;};GSEventBroadcaster.removeListener=function(obj){for(var i=0,l=this.listeners.length;i<l;i++){if(this.listeners[i]==obj){this.listeners.splice(i,1);return true;}}
return false;};function GSEventManager(){}
GSEventManager.bind=function(subject,eventType,observer,method){var args=[];for(var i=4,l=arguments.length;i<l;i++){args.push(arguments[i]);}
var adapter=GSEventManager.createAdapter(observer,method,args);return GSEventManager.addEventListener(subject,eventType,adapter);};GSEventManager.createAdapter=function(observer,method,args){if(!args){args=[];}else{args.unshift(undefined);}
return function(e){e=!e?window.event:e;args[0]=e;method.apply(observer,args);};};GSEventManager.release=function(token){GSEventManager.removeEventListener(token);};GSEventManager.addEventListener=function(obj,eventType,func){if(_browser.isSafari&&eventType=="dblclick"){obj["on"+eventType]=func;return GSEventCache.add(obj,eventType,func);}
if(obj.attachEvent){obj.attachEvent("on"+eventType,func);}else{obj.addEventListener(eventType,func,false);}
return GSEventCache.add(obj,eventType,func);};GSEventManager.removeEventListener=function(token){GSEventCache.remove(token);};var GSEventCache=function(){var handlerId=0;var handlers={};var cache={handlerId:handlerId,handlers:handlers,nextHandlerId:function(){return"h"+this.handlerId++;},add:function(obj,eventType,func){var id=this.nextHandlerId();this.handlers[id]=arguments;return id;},flush:function(){for(var i in this.handlers){this.remove(i);}},remove:function(id){try{var item=this.handlers[id];if(item[0].removeEventListener){item[0].removeEventListener(item[1],item[2],item[3]);}
if(item[1].substring(0,2)!="on"){item[1]="on"+item[1];}
if(item[0].detachEvent){item[0].detachEvent(item[1],item[2]);}
item[0][item[1]]=null;this.handlers[id]=undefined;delete this.handlers[id];}catch(e){}}};return cache;}();function GSMouseWheel(){}
GSMouseWheel.bind=function(subject,observer,func,preventDefault){preventDefault=(preventDefault!==undefined)?preventDefault:true;var eventType=(window.addEventListener&&!_browser.isSafari)?'DOMMouseScroll':'mousewheel';var handler=GSMouseWheel.getWheelHandler(observer,func,preventDefault);return GSEventManager.addEventListener(subject,eventType,handler);};GSMouseWheel.getWheelHandler=function(observer,func,preventDefault){return function(event){var delta=0;event=event?event:window.event;if(event.wheelDelta){delta=event.wheelDelta/120;if(window.opera){delta=-delta;}}else if(event.detail){delta=-event.detail/3;}
if(delta){func.call(observer,delta);}
if(preventDefault){GSUtil.cancelEvent(event);}}};function GSIcon(copy){this.imageSrc=undefined;if(copy){this.imageSrc=copy.imageSrc;}
this.imageSize=undefined;if(copy){this.imageSize=copy.imageSize;}
this.printSrc=undefined;if(copy){this.printSrc=copy.printSrc;}
this.printSize=undefined;if(copy){this.printSize=copy.printSize;}
this.shadowSrc=undefined;if(copy){this.shadowSrc=copy.shadowSrc;}
this.shadowSize=undefined;if(copy){this.shadowSize=copy.shadowSize;}
this.alt=undefined;this.iconOffset=new GSPoint(0,0);if(copy){this.iconOffset=new GSPoint(copy.iconOffset.x,copy.iconOffset.y);}
this.iconInfoWindowOffset=new GSPoint(0,0);if(copy){this.iconInfoWindowOffset=new GSPoint(copy.iconInfoWindowOffset.x,copy.iconInfoWindowOffset.y);}
this.imageMap=undefined;if(copy){this.imageMap=copy.imageMap;}
this.imageMapShape="poly";if(copy){this.imageMapShape=copy.imageMapShape;}
this.visible=true;this.rendered=false;this.arcHeight=0;this.arcRatio=1.2;}
GSIcon.iconId=0;GSIcon.nextId=function(){return GSIcon.iconId++;};GSIcon.prototype.prerender=function(){this.image=GSUtil.createImage("",this.imageSrc,this.imageSize.width,this.imageSize.height,0,0,10,"noprint gsicon_image",this.alt,"image");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");}
if(_browser.isGecko&&this.imageMap!=null){var iconId="map_"+GSIcon.nextId();this.image.setAttribute("usemap",iconId);this.htmlImageMap=GSUtil.createImageMap(iconId,this.imageMapShape,this.imageMap,"#",this.alt);}};GSIcon.prototype.setVisible=function(visible){this.visible=visible;};GSIcon.prototype.render=function(map,coordinate,dragging){if(this.canRender(map,coordinate)){if(!this.rendered){map.iconContainer.appendChild(this.image);map.iconContainer.appendChild(this.dragCrosshair);if(this.printImage){map.iconContainer.appendChild(this.printImage);}
if(this.shadow){map.iconShadowContainer.appendChild(this.shadow);}
if(this.htmlImageMap){map.iconContainer.appendChild(this.htmlImageMap);}
this.rendered=true;}
var pos=map.translateToMapCoordinate(coordinate);var left=(pos.x+this.iconOffset.x);var maxArcHeight=(Math.floor(this.imageSize.height*this.arcRatio));var top=!dragging?(pos.y+this.iconOffset.y):(pos.y+this.iconOffset.y)-(this.arcHeight<maxArcHeight?++this.arcHeight:maxArcHeight);GSUtil.positionElement(this.image,left,top);if(this.shadow){GSUtil.positionElement(this.shadow,left,top);}
if(this.printImage){GSUtil.positionElement(this.printImage,left,top);}
if(dragging){this.repositionDragCrosshair(pos.x,pos.y);}
var v=this.visible?"visible":"hidden";if(this.printImage)
this.printImage.style.visibility=v;if(this.shadow)
this.shadow.style.visibility=v;this.image.style.visibility=v;if(_globals.DEBUG)
_console.debug("GSIcon: left: "+this.image.style.left+", top: "+this.image.style.top);return true;}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.canRender=function(map,coordinate){var iconXOffset=this.iconOffset.x*map.mpx;var iconYOffset=this.iconOffset.y*map.mpx;return(coordinate.x>map.minX&&coordinate.x<map.maxX&&coordinate.y>map.minY&&coordinate.y<map.maxY);};GSIcon.prototype.repositionDragCrosshair=function(x,y){GSUtil.positionElement(this.dragCrosshair,x-8,y-8);};GSIcon.prototype.dragStart=function(feature){document.body.style.cursor="move";var startPos=feature.map.translateToMapCoordinate(feature.coordinate);if(this.htmlImageMap){this.startPos=startPos;}
this.repositionDragCrosshair(startPos.x,startPos.y);this.dragCrosshair.style.display="block";};GSIcon.prototype.dragEnd=function(x,y,feature){if(this.htmlImageMap){GSUtil.positionElement(this.getEventTarget(),0,0);x=this.startPos.x+x+this.iconOffset.x;y=this.startPos.y+y+this.iconOffset.y;this.startPos=null;}
var icon=this;var onFrame=function(animator,point){icon.render(feature.map,feature.map.translateToRealWorldCoordinate(point),false);};var start=new GSPoint(x-this.iconOffset.x,y-this.iconOffset.y-this.arcHeight);var end=feature.map.translateToMapCoordinate(feature.coordinate);var animator=new GSAnimator(start,end,24,200,onFrame,null,function(){icon.dragCrosshair.style.display="none";feature.broadcastMessage("featureDragEnd",feature);});animator.animate();this.arcHeight=0;document.body.style.cursor="default";};GSIcon.prototype.getEventTarget=function(){return this.htmlImageMap?this.htmlImageMap.firstChild:this.image;};GSIcon.prototype.finalize=function(map){if(this.rendered){map.iconContainer.removeChild(this.image);if(this.htmlImageMap!=null){map.iconContainer.removeChild(this.htmlImageMap);}
if(this.printImage!=null){map.iconContainer.removeChild(this.printImage);}
if(this.shadow!=null){map.iconShadowContainer.removeChild(this.shadow);}
this.rendered=false;}};GSIcon.prototype.toString=function(){var out="";out+=("image src: "+this.imageSrc+"<br/>");out+=("print image src: "+this.printSrc+"<br/>");out+=("shadow image src: "+this.shadowSrc+"<br/>");out+=("icon offset: "+this.iconOffset+"<br/>");out+=("icon info window offset: "+this.iconInfoWindowOffset+"<br/>");if(_browser.isGecko&&this.imageMap)
out+=("image map: "+this.imageMap.name);return out;};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(name){this.name=name;this.visible=true;this.data=[];this.map;}
GSLayer.prototype.setVisible=function(visible){this.visible=visible;for(var i=0,l=this.data.length;i<l;i++){this.data[i].setVisible(visible);if(visible){this.data[i].render(this.map);}}};GSLayer.prototype.isVisible=function(){return this.visible;};GSLayer.prototype.getFeatures=function(){return this.data;};GSLayer.prototype.addFeatures=function(features){for(var i=0,l=features.length;i<l;i++){this.addFeature(features[i]);}};GSLayer.prototype.addFeaturesJson=function(data,onCreate){var args;if(arguments.length>2){args=[];for(var i=2,l=arguments.length;i<l;i++){args.push(arguments[i]);}}
for(var i=0,l=data.length;i<l;i++){var className=data[i].jsclass;if(className){if(window[className]){var feature=new window[className](data[i]);if(onCreate){onCreate(feature,data[i],args);}
this.addFeature(feature);}else{throw new Error('Trying to instantiate a non-existent class: '+className);}}}};GSLayer.prototype.addFeature=function(feature){this.data.push(feature);feature.setVisible(this.visible);feature.addToMap(this.map);if(feature.snappable){this.map.addSnappable(feature);}};GSLayer.prototype.removeFeature=function(feature){for(var i=0,l=this.data.length;i<l;i++){if(feature==this.data[i]){feature.finalize(this.map);this.data.splice(i,1);}}};GSLayer.prototype.clear=function(){for(var i=0,l=this.data.length;i<l;i++){this.data[i].finalize(this.map);}
this.data.length=0;};GSLayer.prototype.getBounds=function(){var bounds=[];for(var i=0,l=this.data.length;i<l;i++){var feature=this.data[i];bounds.push(feature.getBounds());}
var minX=GSUtil.getMinimum(GSUtil.getPropertyArray(bounds,"minX"));var minY=GSUtil.getMinimum(GSUtil.getPropertyArray(bounds,"minY"));var maxX=GSUtil.getMaximum(GSUtil.getPropertyArray(bounds,"maxX"));var maxY=GSUtil.getMaximum(GSUtil.getPropertyArray(bounds,"maxY"));return new GSBounds(minX,minY,maxX,maxY);};GSLayer.prototype.toString=function(){var s="";for(var i=0,l=this.data.length;i<l;i++){s+=this.data[i].toString();}
return s;};function GSMap(container,options){if(!options)options={};this.container=container;if(this.container){if((typeof this.container).toLowerCase()=='string'){this.container=document.getElementById(this.container);}else{if(!this.container.nodeName){throw new Error("Cannot create map, first constructor argument must be a DOM element or an element ID.");}}}
if(!this.container){throw new Error("Cannot create map, no container argument provided.");}
this.eventListeners={};this.isChildMap=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(options,"isChildMap",false));GSEventBroadcaster.initialize(this);this.centerOnDblClick=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(options,"centerOnDblClick",true));this.dragToPan=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(options,"dragToPan",true));this.panning=false;this.useMouseWheelZooming=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(options,"useMouseWheelZooming",true));this.useInfoWindow=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(options,"useInfoWindow",true));this.scaleRange=[2,4,8,16,32,64,128,256,512,1024,2048,4096];this.scaleRange.indexOf=function(element){for(var i=0,l=this.length;i<l;i++){if(element==this[i]){return i;}}
return-1;};this.scaleIdx=Number(GSUtil.getCaseInsensitiveProperty(options,"zoomLevel",this.scaleRange.length-1));this.useScalebar=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(options,"useScalebar",true));this.mpx=this.scaleRange[this.scaleIdx];this.centerX=GSUtil.getCaseInsensitiveProperty(options,"centerX")?parseFloat(GSUtil.getCaseInsensitiveProperty(options,"centerX")):2530000;this.centerY=GSUtil.getCaseInsensitiveProperty(options,"centerY")?parseFloat(GSUtil.getCaseInsensitiveProperty(options,"centerY")):5990000;this.minX=1500000;this.minY=5700000;this.maxX=3500000;this.maxY=7300000;this.pxWidth=GSUtil.getCaseInsensitiveProperty(options,"width")?Number(GSUtil.getCaseInsensitiveProperty(options,"width")):500;this.pxHeight=GSUtil.getCaseInsensitiveProperty(options,"height")?Number(GSUtil.getCaseInsensitiveProperty(options,"height")):400;this.resizeable=false;if(options.width&&options.height){this.resizeable=false;}else{this.resizeable=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(options,"resizeable",true));}
if(!this.resizeable){this.container.style.width=this.pxWidth+"px";this.container.style.height=this.pxHeight+"px";}
if(GSUtil.getComputedStyle(this.container,"position")!="absolute"){this.container.style.position="relative";}
this.container.style.overflow="hidden";this.controls=new Array();this.snappables=new Array();this.layers=new Array();var baseLayer=new GSLayer("base");baseLayer.map=this;this.layers.push(baseLayer);if(!this.isChildMap){this.addLogo();}
this.scalebar=undefined;if(this.useScalebar){this.enableScalebar();}
if(this.resizeable){this.sizeToContainerDimensions();}
this.createOverlayContainers();this.infoWindow=undefined;if(this.useInfoWindow){this.infoWindow=new GSInfoWindow(this);}
this.addMapEventListeners();var mapControls=GSUtil.getCaseInsensitiveProperty(options,"mapControls");if(mapControls&&mapControls!="none"){this.addControl(mapControls);}
this.recalculateMapExtents();if(GSUtil.getCaseInsensitiveProperty(options,"centerX")&&GSUtil.getCaseInsensitiveProperty(options,"centerY")&&GSUtil.getCaseInsensitiveProperty(options,"zoomLevel")!=undefined){this.update(function(){this.broadcastMessage("mapZoomed",this,0,this.scaleIdx);});}
if(this.useMouseWheelZooming){this.enableMouseWheelZooming();}
this.logger=new GSLogger(this);};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.prototype.addLogo=function(){var geosmartLogo=GSUtil.createImage("geosmartLogo",_globals.resourceURL+"smartfindLogo.png",120,19,undefined,undefined,40,"noprint","GeoSmart Web Site");geosmartLogo.style.position="absolute";geosmartLogo.style.cursor="pointer";GSUtil.positionElement(geosmartLogo,undefined,undefined,0,0);this.container.appendChild(geosmartLogo);GSEventManager.addEventListener(geosmartLogo,"click",function(e){window.open("http://www.geosmart.co.nz","geosmart");GSUtil.cancelEvent(e);});};GSMap.prototype.setMapOptions=function(options){for(var i in options){switch(i){case'centerOnDblClick':this.centerOnDblClick=options[i];break;case'dragToPan':this.dragToPan=options[i];break;case'useMouseWheelZooming':this.useMouseWheelZooming=options[i];if(this.useMouseWheelZooming){this.enableMouseWheelZooming();}else{this.disableMouseWheelZooming();}
break;case'useInfoWindow':this.useInfoWindow=options[i];break;case'useScalebar':this.useScalebar=options[i];if(this.useScalebar){this.enableScalebar();}else{this.disableScalebar();}
break;case'resizeable':this.resizeable=options[i];if(this.resizeable){this.enableResizing();}else{this.disableResizing();}
break;default:throw new Error('Property "'+i+'" not supported by GSMap');break;}}};GSMap.prototype.enableScalebar=function(){this.scalebarPreloads=[];var img;for(var i=0,l=this.scaleRange.length;i<l;i++){img=new Image();img.src=_globals.resourceURL+"scalebar/"+i+'.png';this.scalebarPreloads.push(img);}
var src=_globals.resourceURL+"scalebar/"+this.scaleIdx+'.png';this.scalebar=GSUtil.createImage("scalebar",src,220,30,null,null,20,"noprint");GSUtil.positionElement(this.scalebar,7,undefined,undefined,7);this.container.appendChild(this.scalebar);};GSMap.prototype.disableScalebar=function(){this.container.removeChild(this.scalebar);};GSMap.prototype.enableMouseWheelZooming=function(){var handleMouseWheel=function(delta){if(delta<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,handleMouseWheel,true);};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.remove=function(){this.finalize();};GSMap.prototype.finalize=function(){if(this.infoWindow){this.infoWindow.finalize();}
this.clearLayers();while(this.container.hasChildNodes()){this.container.removeChild(this.container.firstChild);}
if(!this.isChildMap){GSEventCache.flush();}};GSMap.prototype.updateScalebar=function(){var src=_globals.resourceURL+"scalebar/"+this.scaleIdx+'.png';GSUtil.setImageSrc(this.scalebar,src);};GSMap.prototype.updateSize=function(){var oldSize=new GSDimension(this.pxWidth,this.pxHeight);this.sizeToContainerDimensions();this.recalculateMapExtents();this.broadcastMessage("mapResized",this,oldSize,new GSDimension(this.pxWidth,this.pxHeight));var map=this;setTimeout(function(){map.update();},10);};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(size){if(this.resizeable){this.pxWidth=size.width;this.pxHeight=size.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(bounds,onBoundsChanged){var oldMpx=this.mpx;var oldBounds=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);var minX=bounds.minX;var minY=bounds.minY;var maxX=bounds.maxX;var maxY=bounds.maxY;var width=maxX-minX;var height=maxY-minY;var deltaX=width/2;var deltaY=height/2;this.centerX=minX+deltaX;this.centerY=minY+deltaY;this.mpx=Math.ceil(Math.max(width/this.pxWidth,height/this.pxHeight));this.mpx=this.fitToScaleRange(this.mpx);this.scaleIdx=this.scaleRange.indexOf(this.mpx);var metresWidth=(this.pxWidth*this.mpx);var metresHeight=(this.pxHeight*this.mpx);this.minX=this.centerX-(metresWidth/2);this.minY=this.centerY-(metresHeight/2);this.maxX=this.centerX+(metresWidth/2);this.maxY=this.centerY+(metresHeight/2);this.centerX=this.minX+((this.maxX-this.minX)/2);this.centerY=this.minY+((this.maxY-this.minY)/2);var newBounds=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);var newMpx=this.mpx;this.update(function(){if(this.scalebar&&oldMpx!=newMpx){this.updateScalebar();}
this.broadcastMessage("mapBoundsChanged",this,oldBounds,newBounds);if(onBoundsChanged)onBoundsChanged();});};GSMap.prototype.createOverlayContainers=function(){this.tileContainer=GSUtil.createContainer(this.container,null,null,null,0,0,null,5);this.mapContentContainer=GSUtil.createContainer(this.container,"mapContent",null,null,0,0,null,10);this.mapContentContainer.style.width='21600px';this.mapContentContainer.style.height='21600px';this.lineContainer=GSUtil.createContainer(this.mapContentContainer,null,null,null,0,0,null,15);if(window.GSVectorGraphics&&_browser.isVectorGraphicsCapable()){this.vectorContainer=this.createVectorContainer(this.mapContentContainer,17);}
this.iconShadowContainer=GSUtil.createContainer(this.mapContentContainer,null,null,null,0,0,null,20);this.iconContainer=GSUtil.createContainer(this.mapContentContainer,null,null,null,0,0,null,30);};GSMap.prototype.createVectorContainer=function(parent,zIndex){var container=null;var map=this;if(_browser.svg){container=document.createElementNS(_globals.svgns,'svg');parent.appendChild(container);container.style.zIndex=zIndex;GSUtil.positionElement(container,0,0);container.setAttributeNS(null,'width','100%');container.setAttributeNS(null,'height','100%');var shapeContainer=document.createElementNS(_globals.svgns,'g');shapeContainer.setAttributeNS(null,'id','gs_svg_shape_container');container.appendChild(shapeContainer);var handleContainer=document.createElementNS(_globals.svgns,'g');handleContainer.setAttributeNS(null,'id','gs_svg_handle_container');container.appendChild(handleContainer);}else if(_browser.isIE6up){container=document.createElement(_globals.vmlnsPrefix+":group");parent.appendChild(container);container.style.zIndex=zIndex;GSUtil.positionElement(container,0,0);container.style.width=this.pxWidth+"px";container.style.height=this.pxHeight+"px";container.setAttribute("coordsize",this.pxWidth+" "+this.pxHeight);container.mapResized=function(){this.style.width=map.pxWidth+"px";this.style.height=map.pxHeight+"px";this.setAttribute("coordsize",map.pxWidth+" "+map.pxHeight);};}
this.addListener(container);return container;};GSMap.prototype.dragStart=function(e){if(this.panning){return;}
if(this.dragToPan){e=e?e:window.event;this.startPixel=new GSPoint(e.clientX,e.clientY);var self=this;this.dragTimer=setInterval(function(){clearInterval(self.dragTimer);self.initDrag(e);},150);GSUtil.cancelEvent(e);}};GSMap.prototype.initDrag=function(){this.panning=true;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);};GSMap.prototype.dragMove=function(e){if(!e)
e=window.event;GSUtil.positionElement(this.mapContentContainer,(e.clientX-this.startPixel.x),(e.clientY-this.startPixel.y));GSUtil.positionElement(this.tileContainer,(this.startTilePixel.x+(e.clientX-this.startPixel.x)),(this.startTilePixel.y+(e.clientY-this.startPixel.y)));GSUtil.cancelEvent(e);};GSMap.prototype.cancelDrag=function(e){if(this.dragTimer){clearInterval(this.dragTimer);}};GSMap.prototype.dragStop=function(e){e=e?e:window.event;var deltaX=(e.clientX-this.startPixel.x)*this.mpx;var deltaY=(e.clientY-this.startPixel.y)*this.mpx;if(deltaX!=0||deltaY!=0){this.centerAtCoordinate({x:this.startNzmg.x-(e.clientX-this.startPixel.x)*this.mpx,y:this.startNzmg.y+(e.clientY-this.startPixel.y)*this.mpx},null,GSMap.SUPPRESS_MESSAGING);}
this.panning=false;GSEventManager.release(this.eventListeners["drag_mousemove"]);GSEventManager.release(this.eventListeners["drag_mouseup"]);this.broadcastMessage("mapBoundsChanged",this);GSUtil.positionElement(this.mapContentContainer,0,0);this.startPixel=undefined;this.startTilePixel=undefined;this.startNzmg=undefined;this.dragMoveToken=undefined;this.dragStopToken=undefined;GSUtil.cancelEvent(e);this.logger.log('map',{map_op:'drag',tile_count:this.tileCount});};GSMap.prototype.click=function(e){if(!this.panning){if(!e)e=window.event;var coordinate=this.getClickCoordinate(e);this.broadcastMessage("mapClicked",this,coordinate,e);}else{self.panning=false;}
GSUtil.cancelEvent(e);};GSMap.prototype.dblclick=function(e){var coordinate=this.getClickCoordinate(e);if(this.centerOnDblClick){this.panTo(coordinate);}
this.broadcastMessage("mapDblClicked",this,coordinate,e);GSUtil.cancelEvent(e);};GSMap.prototype.addMapEventListeners=function(){this.eventListeners["mousedown"]=GSEventManager.bind(this.container,"mousedown",this,this.dragStart);this.eventListeners["mouseup"]=GSEventManager.bind(this.container,"mouseup",this,this.cancelDrag);this.eventListeners["click"]=GSEventManager.bind(this.container,"click",this,this.click);this.eventListeners["dblclick"]=GSEventManager.bind(this.container,"dblclick",this,this.dblclick);if(this.resizeable){this.enableResizing();}
this.eventListeners["unload"]=GSEventManager.bind(window,"unload",this,this.finalize);};GSMap.prototype.getClickCoordinate=function(e){return this.translateToRealWorldCoordinate(GSUtil.getClickPixelCoordinate(e,this.container));};GSMap.prototype.zoom=function(zoomLevel,onZoom){var oldZoomLevel=this.scaleIdx;if(zoomLevel<0||zoomLevel>=this.scaleRange.length){alert("Zoom level out of range: "+zoomLevel);return;}
this.mpx=this.scaleRange[zoomLevel];this.scaleIdx=zoomLevel;this.recalculateMapExtents(true);if(oldZoomLevel!=this.scaleIdx){this.broadcastMessage("preMapZoom",this);}
this.update(function(){if(this.scalebar){this.updateScalebar();}
this.broadcastMessage("mapZoomed",this,oldZoomLevel,this.scaleIdx);if(onZoom)onZoom();this.logger.log('map',{map_op:'zoom',tile_count:this.tileCount});});};GSMap.prototype.panTo=function(coordinate,onPan){var bounds=this.getBounds();if(!bounds.contains(coordinate)){return this.centerAtCoordinate(coordinate,onPan);}
this.panning=true;var from=this.translateToMapCoordinate(new GSPoint(this.centerX,this.centerY));var to=this.translateToMapCoordinate(coordinate);var self=this;var onFrame=function(animator,point){point.x=Math.floor(point.x);point.y=Math.floor(point.y);GSUtil.positionElement(self.mapContentContainer,(from.x-point.x),(from.y-point.y));self.centerAtCoordinate(self.translateToRealWorldCoordinate(point,bounds),null,GSMap.SUPPRESS_MESSAGING);};var animator=new GSAnimator(from,to,16,500,onFrame,null,function(){self.panning=false;self.broadcastMessage("mapBoundsChanged",self,bounds,self.getBounds());GSUtil.positionElement(self.mapContentContainer,0,0);if(onPan){onPan();}
self.logger.log('map',{map_op:'panTo',tile_count:this.tileCount});});animator.animate();};GSMap.prototype.centerAtCoordinate=function(coordinate,onCenter,suppressMessaging){var oldBounds=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);this.centerX=coordinate.x;this.centerY=coordinate.y;this.recalculateMapExtents();var newBounds=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);this.update(function(){if(!suppressMessaging){this.broadcastMessage("mapBoundsChanged",this,oldBounds,newBounds);this.logger.log('map',{map_op:'centerAtCoordinate',tile_count:this.tileCount});}
if(onCenter){onCenter();}});};GSMap.prototype.centerAndZoom=function(coordinate,zoomLevel,onCenter){this.broadcastMessage("mapZoom",this);var oldZoomLevel=this.scaleIdx;this.centerX=coordinate.x;this.centerY=coordinate.y;if(zoomLevel!=undefined){if(zoomLevel<0||zoomLevel>=this.scaleRange.length){alert("Zoom level out of range: "+zoomLevel);return;}
this.mpx=this.scaleRange[zoomLevel];this.scaleIdx=zoomLevel;}
this.recalculateMapExtents();this.update(function(){if(this.scalebar){this.updateScalebar();}
this.broadcastMessage("mapZoomed",this,oldZoomLevel,this.scaleIdx);if(onCenter)onCenter();this.logger.log('map',{map_op:'centerAndZoom',tile_count:this.tileCount});});};GSMap.prototype.centerOnNewZealand=function(onCenter){var oldZoomLevel=this.scaleIdx;this.centerX=_globals.nzCenterX;this.centerY=_globals.nzCenterY;for(var i=0,l=this.scaleRange.length;i<l;i++){if(_globals.nzCenterY+((this.scaleRange[i]*this.pxHeight)/2)>_globals.nzTopY){this.mpx=this.scaleRange[i];this.scaleIdx=i;break;}}
this.recalculateMapExtents();if(oldZoomLevel!=this.scaleIdx){this.broadcastMessage("preMapZoom",this);}
this.update(function(){if(this.scalebar){this.updateScalebar();}
this.broadcastMessage("mapZoomed",this,oldZoomLevel,this.scaleIdx);if(onCenter)onCenter();this.logger.log('map',{map_op:'centerOnNewZealand',tile_count:this.tileCount});});};GSMap.prototype.fitToScaleRange=function(scale){var newScale=this.scaleRange[0];for(var i=0,l=this.scaleRange.length;i<l;i++){if((typeof this.scaleRange[i]).toString().toLowerCase()!="function"){var mapScale=this.scaleRange[i];if(mapScale==scale){return scale;}else if(mapScale>scale){newScale=mapScale;break;}}}
return newScale;};GSMap.prototype.addControl=function(control,position){var obj=null;var haveControl=false;if(GSControl.prototype.isPrototypeOf){haveControl=GSControl.prototype.isPrototypeOf(control);}else if(control.__proto__){haveControl=(typeof control).toLowerCase()=="object";}
if(haveControl){obj=control;}else{obj=this.instantiateControl(control);}
if(obj!=null){this.controls.push(obj);var controlContainer=obj.render(this);this.container.appendChild(controlContainer);obj.setElement(controlContainer);obj.setPosition(position?position:obj.getDefaultPosition());}
return obj;};GSMap.prototype.removeControl=function(control){var name="";var haveControl=false;if(GSControl.prototype.isPrototypeOf){haveControl=GSControl.prototype.isPrototypeOf(control);}else if(control.__proto__){haveControl=(typeof control).toLowerCase()=="object";}
if(haveControl){name=control.name;}else{name=control;}
for(var i=0,l=this.controls.length;i<l;i++){if(this.controls[i].name==name){this.controls[i].remove(this);this.controls.splice(i,1);return true;}}
return false;};GSMap.prototype.instantiateControl=function(name){var control;switch(name){case GSMap.ZOOM_CONTROL:control=new GSZoomControl();break;case GSMap.COMPACT_ZOOM_CONTROL:control=new GSCompactZoomControl();break;case GSMap.MAP_CONTROL:control=new GSMapControl();break;case GSMap.TEXT_ZOOM_CONTROL:control=new GSTextZoomControl();break;case GSMap.SNAPBACK_CONTROL:control=new GSSnapbackControl();break;}
return control;};GSMap.prototype.centerOnLayer=function(name,onCenter){var layer=this.getLayer(name);if(layer==undefined){return;}
if(!layer.isVisible()){layer.mapBoundsChanged=function(map,oldBounds,newBounds){this.setVisible(true);map.removeListener(this);};this.addListener(layer);}
var bounds=layer.getBounds();var width=bounds.maxX-bounds.minX;var height=bounds.maxY-bounds.minY;var padW=width*0.05;var padH=height*0.05;bounds.minX-=padW;bounds.maxX+=padW;bounds.minY-=padH;bounds.maxY+=padH;this.setBounds(bounds,onCenter);};GSMap.prototype.createLayer=function(name){var layer=this.getLayer(name);if(layer!=undefined){this.removeLayer(name);}
layer=new GSLayer(name);layer.map=this;this.layers.push(layer);return layer;};GSMap.prototype.removeLayer=function(name){if(name=="base"){return;}
for(var i=0,l=this.layers.length;i<l;i++){var layer=this.layers[i];if(layer.name==name){layer.clear();this.layers.splice(i,1);return true;}}
return false;};GSMap.prototype.clearLayers=function(){for(var i=0,l=this.layers.length;i<l;i++){this.layers[i].clear();}};GSMap.prototype.getLayers=function(){return this.layers;};GSMap.prototype.getLayer=function(name){for(var i=0,l=this.layers.length;i<l;i++){var layer=this.layers[i];if(layer.name==name){return layer;}}
return null;};GSMap.prototype.addFeature=function(feature){var baseLayer=this.getLayer("base");baseLayer.addFeature(feature);};GSMap.prototype.removeFeature=function(feature){var baseLayer=this.getLayer("base");baseLayer.removeFeature(feature);};GSMap.prototype.recalculateMapExtents=function(zooming){var metresWidth=this.pxWidth*this.mpx;var metresHeight=this.pxHeight*this.mpx;if(zooming&&this.infoWindow&&this.infoWindow.isOpen){var coordinate=this.infoWindow.coordinate;var deltaX=coordinate.x-this.minX;var deltaY=coordinate.y-this.minY;var oldMetresWidth=this.maxX-this.minX;var oldMetresHeight=this.maxY-this.minY;var percentWidth=deltaX/oldMetresWidth;var percentHeight=deltaY/oldMetresHeight;this.minX=coordinate.x-(percentWidth*metresWidth);this.maxX=coordinate.x+((1-percentWidth)*metresWidth);this.minY=coordinate.y-(percentHeight*metresHeight);this.maxY=coordinate.y+((1-percentHeight)*metresHeight);this.centerX=this.minX+(metresWidth/2);this.centerY=this.minY+(metresHeight/2);}else{this.minX=this.centerX-(metresWidth/2);this.minY=this.centerY-(metresHeight/2);this.maxX=this.centerX+(metresWidth/2);this.maxY=this.centerY+(metresHeight/2);}};GSMap.prototype.translateToMapCoordinate=function(coordinate){var x=coordinate.x;var y=coordinate.y;var deltaX=(x-this.minX);var deltaY=(this.maxY-y);return new GSPoint((deltaX/this.mpx),(deltaY/this.mpx));};GSMap.prototype.translateToRealWorldCoordinate=function(coordinate,bounds){if(!bounds){bounds=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);}
var metresWidth=this.pxWidth*this.mpx;var metresHeight=this.pxHeight*this.mpx;var x=bounds.minX+(metresWidth*(coordinate.x/this.pxWidth));var y=bounds.maxY-(metresHeight*(coordinate.y/this.pxHeight));return new GSPoint(Math.round(x),Math.round(y));};GSMap.prototype.getBounds=function(){return new GSBounds(this.minX,this.minY,this.maxX,this.maxY);};GSMap.prototype.featureClicked=function(feature){this.broadcastMessage("mapClicked",this,"click",feature);};GSMap.prototype.update=function(postUpdateFunc){var tileWidth=_globals.tilePxWidth*this.mpx;var tileHeight=_globals.tilePxHeight*this.mpx;var tilesMinX=Math.floor(this.minX/tileWidth)*tileWidth;var tilesMaxX=Math.floor(this.maxX/tileWidth)*tileWidth;var tilesMinY=Math.floor(this.minY/tileHeight)*tileHeight;var tilesMaxY=Math.ceil(this.maxY/tileHeight)*tileHeight;while(this.tileContainer.firstChild){this.tileContainer.removeChild(this.tileContainer.firstChild);}
GSUtil.positionElement(this.tileContainer,Math.floor((tilesMinX-this.minX)/this.mpx),Math.ceil((this.maxY-tilesMaxY)/this.mpx));var yIdx=xIdx=0;for(var ty=tilesMaxY;ty>=tilesMinY;ty-=tileHeight){xIdx=0;for(var tx=tilesMinX;tx<=tilesMaxX;tx+=tileWidth){var src=this.buildTileUrl(tx,ty,this.mpx);var img=this.createTileImage(src,xIdx*_globals.tilePxWidth,yIdx*_globals.tilePxHeight);this.tileContainer.appendChild(img);xIdx++;}
yIdx++;}
this.tileCount=yIdx*xIdx;if(postUpdateFunc)postUpdateFunc.call(this);};GSMap.prototype.createTileImage=function(src,left,top){var img=document.createElement('img');img.border=0;img.style.position="absolute";img.style.left=left+"px";img.style.top=top+"px";if(_browser.isIE){img.setAttribute("galleryimg","no");img.unselectable="on";img.onselectstart=GSUtil.cancelEvent;}else{img.style.MozUserSelect="none";}
img.src=src;return img;};GSMap.prototype.openMapBlowup=function(coordinate,options){options=options?options:{};if(options.offset==undefined){options.offset=new GSPoint(0,0);}
if(options.zoomLevel==undefined){options.zoomLevel=0;}
if(options.size==undefined){options.size=new GSDimension(180,180);}
var html=document.createElement("div");html.style.backgroundColor="#c5c5c5";html.style.border="1px solid #a0a0a4";var mapOptions={width:options.size.width+15,height:options.size.height,isChildMap:true,resizeable:false,useScalebar:false,centerOnDblClick:true,dragToPan:true,useInfoWindow:false,useMouseWheelZooming:false};var map=new GSMap(html,mapOptions);map.addControl(GSMap.COMPACT_ZOOM_CONTROL);map.addControl(GSMap.SNAPBACK_CONTROL);this.infoWindow.open(coordinate,html,{offset:options.offset,onopen:function(){map.centerAndZoom(coordinate,options.zoomLevel,function(){map.markForSnapback();if(options.onopen){options.onopen(map);}});},onclose:function(){if(options.onclose){options.onclose(map);}
map.finalize();}});};GSMap.prototype.openInfoWindow=function(coordinate,html,options){this.infoWindow.open(coordinate,html,options);};GSMap.prototype.closeInfoWindow=function(){this.infoWindow.close();};GSMap.prototype.getInfoWindow=function(){if(this.infoWindow){return this.infoWindow;}else{return undefined;}};GSMap.prototype.addSnappable=function(feature){this.snappables.push(feature);};GSMap.prototype.getSnappables=function(){return this.snappables;};GSMap.prototype.removeSnappable=function(snappable){for(var i=this.snappables.length,s=null;s=this.snappables[i];i--){if(s===snappable){this.snappables.splice(i,1);return true;}}
return false;};GSMap.prototype.buildTileUrl=function(x,y,mpx){return _globals.tilesURL+"/"+mpx+"/"+x+"/"+x+"_"+y+".png";};GSMap.prototype.markForSnapback=function(){this.snapbackState={coordinate:this.getMapCenter(),zoomLevel:this.scaleIdx};};GSMap.prototype.snapback=function(){this.centerAndZoom(this.snapbackState.coordinate,this.snapbackState.zoomLevel);};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(x,y){this.x=Number(x);this.y=Number(y);}
GSPoint.prototype.toString=function(){return"Point: x=["+this.x+"], y=["+this.y+"]";};function GSPointFeature(params){GSEventBroadcaster.initialize(this);this.id=GSUtil.getCaseInsensitiveProperty(params,"id");this.coordinate=GSUtil.getCaseInsensitiveProperty(params,"coordinate");if(this.coordinate==undefined){var x=GSUtil.getCaseInsensitiveProperty(params,"x");var y=GSUtil.getCaseInsensitiveProperty(params,"y");this.coordinate=(x&&y)?new GSPoint(x,y):new GSPoint(0,0);}
this.name=GSUtil.getCaseInsensitiveProperty(params,"name");this.suburb=GSUtil.getCaseInsensitiveProperty(params,"suburb");this.district=GSUtil.getCaseInsensitiveProperty(params,"district");this.region=GSUtil.getCaseInsensitiveProperty(params,"region");this.iconType=undefined;this.infoHtml=GSUtil.getCaseInsensitiveProperty(params,"infoHtml");this.map=undefined;this.draggable=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(params,"draggable",false));this.onmap=false;this.isShowingInfo=false;this.visible=true;this.eventListeners={};this.icon=GSUtil.getCaseInsensitiveProperty(params,"icon");if(!this.icon){this.icon=new GSIcon(GSIcon.defaultIcon);}
this.icon.alt=this.name;this.icon.prerender();if(this.draggable){this.enableDragging();}
this.icon.setVisible(this.visible);}
GSPointFeature.prototype.enableDragging=function(){GSEventManager.bind(this.icon.getEventTarget(),'mousedown',this,function(e){this.dragStartPos=GSUtil.getClickPixelCoordinate(e);});var target=this.icon.getEventTarget();Drag.init(target);var feature=this;var icon=feature.icon;target.onDragStart=function(x,y){if(feature.isShowingInfo){feature.map.infoWindow.close();}};target.onDrag=function(x,y,e){if(!feature.hasDragged(e)){return;}else{if(!this.dragging){icon.dragStart(feature);feature.broadcastMessage("featureDragStart",feature);this.dragging=true;}else{if(icon.htmlImageMap){x=icon.startPos.x+icon.iconOffset.x+x;y=icon.startPos.y+icon.iconOffset.y+y;}else{y+=icon.arcHeight;}
feature.coordinate=feature.map.translateToRealWorldCoordinate(new GSPoint(x-icon.iconOffset.x,y-icon.iconOffset.y));icon.render(feature.map,feature.coordinate,true);feature.broadcastMessage("featureDrag",feature);}}};target.onDragEnd=function(x,y,e){if(feature.hasDragged(e)){icon.dragEnd(x,y,feature);this.dragging=false;}};};GSPointFeature.prototype.clone=function(){var map=this.map;var icon=this.icon;this.map=undefined;this.icon=undefined;var clone=GSUtil.clone(this);clone.icon=new GSIcon(icon);clone.icon.alt=this.name;clone.icon.prerender();clone.onmap=false;clone.isShowingInfo=false;this.map=map;this.icon=icon;return clone;};GSPointFeature.prototype.setVisible=function(visible){this.visible=visible;if(this.icon){this.icon.setVisible(visible);if(this.onmap){this.icon.render(this.map,this.coordinate);}}};GSPointFeature.prototype.isVisible=function(){return this.visible;};GSPointFeature.prototype.isDraggable=function(){return this.draggable;};GSPointFeature.prototype.setIcon=function(icon){this.icon.finalize(this.map);this.icon=icon;this.icon.prerender();if(this.draggable){this.enableDragging();}
for(var i in this.eventListeners){if((typeof this.eventListeners[i]).toLowerCase()=='array'){for(var j=this.eventListeners[i].length,token=null;token=this.eventListeners[i][j];j--){var handler=GSEventCache.handlers[token];var eventTarget=this.icon.getEventTarget();if(eventTarget){GSEventManager.bind(eventTarget,handler[1],this,handler[2]);}}}else{var handler=GSEventCache.handlers[this.eventListeners[i]];var eventTarget=icon.getEventTarget();if(eventTarget){GSEventManager.bind(eventTarget,handler[1],this,handler[2]);}}}
if(this.onmap){this.icon.render(this.map,this.coordinate);}};GSPointFeature.prototype.addEventHandler=function(eventType,func){var eventTarget=this.icon.getEventTarget();if(eventTarget){var token=GSEventManager.bind(eventTarget,eventType,this,function(){if(!this.hasDragged(arguments[0])){func.apply(this,arguments);}});this.addListenerToken(eventType,token);return token;}};GSPointFeature.prototype.hasDragged=function(e){if(!this.dragStartPos){return false;}
var tolerance=2;var coord=GSUtil.getClickPixelCoordinate(e);var dragged=(Math.abs(this.dragStartPos.x-coord.x)>tolerance)||(Math.abs(this.dragStartPos.y-coord.y)>tolerance);return dragged;};GSPointFeature.prototype.addListenerToken=function(eventType,listenerToken){if(this.eventListeners[eventType]){if((typeof this.eventListeners[eventType]).toLowerCase()!='array'){this.eventListeners[eventType]=[this.eventListeners[eventType]];}
this.eventListeners[eventType].push(listenerToken);}else{this.eventListeners[eventType]=listenerToken;}};GSPointFeature.prototype.removeEventHandler=function(token){GSEventManager.release(token);};GSPointFeature.prototype.openMapBlowup=function(zoomLevel){zoomLevel=zoomLevel?zoomLevel:0;if(this.onmap){this.isShowingInfo=true;var offsetX=this.icon.iconOffset.x+this.icon.iconInfoWindowOffset.x;var offsetY=this.icon.iconOffset.y+this.icon.iconInfoWindowOffset.y;var clone=this.clone();this.map.openMapBlowup(this.coordinate,{zoomLevel:0,offset:new GSPoint(offsetX,offsetY),onopen:function(map){map.addFeature(clone);}});}};GSPointFeature.prototype.showInfoWindow=function(html){if(this.onmap){this.isShowingInfo=true;if(this.map.infoWindow){html=html!=undefined?html:this.infoHtml;var offsetX=this.icon.iconOffset.x+this.icon.iconInfoWindowOffset.x;var offsetY=this.icon.iconOffset.y+this.icon.iconInfoWindowOffset.y;this.map.openInfoWindow(this.coordinate,html,{offset:new GSPoint(offsetX,offsetY)});}else{throw new Error('Info window is not enabled for the map this feature has been added to');}}};GSPointFeature.prototype.closestPoint=function(pxCoord,tolerance){var thisPxCoord=this.map.translateToMapCoordinate(this.coordinate);var deltaX=Math.abs(thisPxCoord.x-pxCoord.x);var deltaY=Math.abs(thisPxCoord.y-pxCoord.y);if(deltaX<tolerance&&deltaY<tolerance){return{point:this.coordinate,delta:Math.min(deltaX,deltaY)};}else{return null;}};GSPointFeature.prototype.addToMap=function(map){this.map=map;map.addListener(this);this.onmap=true;this.render(map);};GSPointFeature.prototype.mapClicked=function(map,obj){if(_globals.DEBUG)
_console.debug("mapClicked: "+obj);};GSPointFeature.prototype.mapResized=function(map,oldSize,newSize){if(_globals.DEBUG)
_console.debug("mapResized: "+oldSize+"\n"+newSize);this.render(map);};GSPointFeature.prototype.mapZoomed=function(map,oldZoomLevel,newZoomLevel){if(_globals.DEBUG)
_console.debug("mapZoomed: "+oldZoomLevel+"\n"+newZoomLevel);this.render(map);};GSPointFeature.prototype.mapBoundsChanged=function(map,oldBounds,newBounds){if(_globals.DEBUG)
_console.debug("mapBoundsChanged: "+oldBounds+"\n"+newBounds);this.render(map);};GSPointFeature.prototype.infoWindowOpened=function(){};GSPointFeature.prototype.infoWindowClosed=function(infoWindow){if(this.isShowingInfo)
this.isShowingInfo=false;};GSPointFeature.prototype.getBounds=function(){return new GSBounds(this.coordinate.x,this.coordinate.y,this.coordinate.x,this.coordinate.y);};GSPointFeature.prototype.render=function(map){this.icon.render(map,this.coordinate);};GSPointFeature.prototype.finalize=function(map){for(var i in this.eventListeners){if((typeof this.eventListeners[i]).toLowerCase()=='array'){for(var j=this.eventListeners[i].length,token=null;token=this.eventListeners[i][j];j--){GSEventManager.release(token);}}else{GSEventManager.release(this.eventListeners[i]);}}
if(this.onmap){this.icon.finalize(this.map);if(this.isShowingInfo)
this.map.infoWindow.close();this.map.removeListener(this);}};GSPointFeature.prototype.toString=function(){var out="Feature:<br/>";for(p in this){if(this[p]instanceof Function){out+=(p+" : [Function]<br/>");}else{out+=(p+" : "+this[p]+"<br/>");}}
return out;};var Drag={obj:null,init:function(o,oRoot,minX,maxX,minY,maxY,bSwapHorzRef,bSwapVertRef,fXMapper,fYMapper)
{o.onmousedown=Drag.start;if(o.addEventListener){o.addEventListener("contextmenu",Drag.stopPropagation,false);}else if(o.attachEvent){o.attachEvent("oncontextmenu",Drag.stopPropagation);}else{o["on"+eventType]=Drag.stopPropagation;}
o.hmode=bSwapHorzRef?false:true;o.vmode=bSwapVertRef?false:true;o.root=oRoot&&oRoot!=null?oRoot:o;if(o.hmode&&isNaN(parseInt(o.root.style.left)))o.root.style.left="0px";if(o.vmode&&isNaN(parseInt(o.root.style.top)))o.root.style.top="0px";if(!o.hmode&&isNaN(parseInt(o.root.style.right)))o.root.style.right="0px";if(!o.vmode&&isNaN(parseInt(o.root.style.bottom)))o.root.style.bottom="0px";o.minX=typeof minX!='undefined'?minX:null;o.minY=typeof minY!='undefined'?minY:null;o.maxX=typeof maxX!='undefined'?maxX:null;o.maxY=typeof maxY!='undefined'?maxY:null;o.xMapper=fXMapper?fXMapper:null;o.yMapper=fYMapper?fYMapper:null;o.root.onDragStart=new Function();o.root.onDragEnd=new Function();o.root.onDrag=new Function();},start:function(e)
{Drag.stopPropagation(e);var o=Drag.obj=this;e=Drag.fixE(e);var y=parseInt(o.vmode?o.root.style.top:o.root.style.bottom);var x=parseInt(o.hmode?o.root.style.left:o.root.style.right);o.root.onDragStart(x,y);o.lastMouseX=e.clientX;o.lastMouseY=e.clientY;if(o.hmode){if(o.minX!=null)o.minMouseX=e.clientX-x+o.minX;if(o.maxX!=null)o.maxMouseX=o.minMouseX+o.maxX-o.minX;}else{if(o.minX!=null)o.maxMouseX=-o.minX+e.clientX+x;if(o.maxX!=null)o.minMouseX=-o.maxX+e.clientX+x;}
if(o.vmode){if(o.minY!=null)o.minMouseY=e.clientY-y+o.minY;if(o.maxY!=null)o.maxMouseY=o.minMouseY+o.maxY-o.minY;}else{if(o.minY!=null)o.maxMouseY=-o.minY+e.clientY+y;if(o.maxY!=null)o.minMouseY=-o.maxY+e.clientY+y;}
document.onmousemove=Drag.drag;document.onmouseup=Drag.end;return false;},drag:function(e)
{Drag.stopPropagation(e);e=Drag.fixE(e);var o=Drag.obj;var ey=e.clientY;var ex=e.clientX;var y=parseInt(o.vmode?o.root.style.top:o.root.style.bottom);var x=parseInt(o.hmode?o.root.style.left:o.root.style.right);var nx,ny;if(o.minX!=null)ex=o.hmode?Math.max(ex,o.minMouseX):Math.min(ex,o.maxMouseX);if(o.maxX!=null)ex=o.hmode?Math.min(ex,o.maxMouseX):Math.max(ex,o.minMouseX);if(o.minY!=null)ey=o.vmode?Math.max(ey,o.minMouseY):Math.min(ey,o.maxMouseY);if(o.maxY!=null)ey=o.vmode?Math.min(ey,o.maxMouseY):Math.max(ey,o.minMouseY);nx=x+((ex-o.lastMouseX)*(o.hmode?1:-1));ny=y+((ey-o.lastMouseY)*(o.vmode?1:-1));if(o.xMapper)nx=o.xMapper(y);else if(o.yMapper)ny=o.yMapper(x);Drag.obj.root.style[o.hmode?"left":"right"]=nx+"px";Drag.obj.root.style[o.vmode?"top":"bottom"]=ny+"px";Drag.obj.lastMouseX=ex;Drag.obj.lastMouseY=ey;Drag.obj.root.onDrag(nx,ny,e);return false;},end:function(e)
{Drag.stopPropagation(e);e=Drag.fixE(e);document.onmousemove=null;document.onmouseup=null;Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode?"left":"right"]),parseInt(Drag.obj.root.style[Drag.obj.vmode?"top":"bottom"]),e);Drag.obj=null;},fixE:function(e)
{if(typeof e=='undefined')e=window.event;if(typeof e.layerX=='undefined')e.layerX=e.offsetX;if(typeof e.layerY=='undefined')e.layerY=e.offsetY;return e;},stopPropagation:function(e)
{e=e?e:window.event;if(e.stopPropagation){e.preventDefault();e.stopPropagation();}else{e.cancelBubble=true;e.returnValue=false;}}};function GSRasterImageFeature(callback){GSEventBroadcaster.initialize(this);this.callback=callback;this.map=null;this.image=null;};GSRasterImageFeature.prototype.setVisible=function(visible){this.visible=visible;if(this.image)this.image.style.visibility=visible?"visible":"hidden";};GSRasterImageFeature.prototype.isVisible=function(){return this.visible;};GSRasterImageFeature.prototype.addToMap=function(map){this.map=map;this.map.addListener(this);this.render(map);};GSRasterImageFeature.prototype.render=function(){if(!this.map)throw new Error("GSRasterImageFeature has not been added to a map");if(this.image)this.map.lineContainer.removeChild(this.image);this.image=window.document.createElement("img");this.image.className='gsimagefeature';if(_browser.isIE){this.image.setAttribute("galleryimg","no");this.image.unselectable="on";this.image.onselectstart=GSUtil.cancelEvent;}else{this.image.style.MozUserSelect="none";}
this.image.src=this.callback(this.map.scaleIdx,this.map.getBounds(),this.map.getSize());this.map.lineContainer.appendChild(this.image);};GSRasterImageFeature.prototype.finalize=function(){if(this.image)this.map.lineContainer.removeChild(this.image);this.image=null;if(this.map)this.map.removeListener(this);this.map=null;};GSRasterImageFeature.prototype.mapZoomed=GSRasterImageFeature.prototype.render;GSRasterImageFeature.prototype.mapBoundsChanged=GSRasterImageFeature.prototype.render;GSRasterImageFeature.prototype.mapResized=GSRasterImageFeature.prototype.render;function GSInfoWindow(map){this.map=map;this.map.addListener(this);this.coordinate;this.offset=new GSPoint(0,0);this.isOpen=false;this.hidden=true;this.element=undefined;this.createWindow();GSEventManager.bind(this.element,"click",this,this.processMouseEvent);GSEventManager.bind(this.element,"mousedown",this,this.processMouseEvent);GSEventManager.bind(this.element,"dblclick",this,this.processMouseEvent);};GSInfoWindow.prototype.processMouseEvent=function(e){GSUtil.eventStopPropagation(e);};GSInfoWindow.prototype.open=function(coordinate,html,options){if(!options)options={};if(this.isOpen){this.close();}
this.isOpen=true;this.onclose=options.onclose;if((typeof html).toLowerCase()=='string'){var div=document.createElement('div');div.innerHTML=html;html=div;}
this.setContent(html);this.coordinate=coordinate;if(options.offset){this.offset=options.offset;}
var map=this.map;this.updatePosition(function(){if(options.onopen){options.onopen();}
map.broadcastMessage("infoWindowOpened");});};GSInfoWindow.prototype.updatePosition=function(onUpdate){var bufferX=5;var bufferY=5;var infoWindowWidth=this.element.offsetWidth;var infoWindowHeight=this.element.offsetHeight;var x=this.offset.x;var y=this.offset.y-(infoWindowHeight-7);var offset=new GSPoint(x,y);var centerX,centerY;var pos=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 left=pos.x+offset.x;var top=pos.y+offset.y;var deltaX=0;var deltaY=0;if((left+infoWindowWidth+bufferX)>this.map.pxWidth){deltaX=this.map.pxWidth-(left+infoWindowWidth+bufferX);}
if((top-bufferY)<0){deltaY=0-(top-bufferY);}
if(deltaX==0&&deltaY==0){this.reposition();if(onUpdate){onUpdate();}
return;}
if(offset.x+infoWindowWidth>this.map.pxWidth){var maxX=this.coordinate.x+(offset.x+infoWindowWidth*this.map.mpx);centerX=maxX-(this.map.pxWidth*this.map.mpx)/2;centerY=this.coordinate.y;}
centerX=this.map.centerX-(deltaX*this.map.mpx);centerY=this.map.centerY+(deltaY*this.map.mpx);}else{var deltaX=(this.map.pxWidth/2)>(offset.x+infoWindowWidth+bufferX)?0:(offset.x+infoWindowWidth+bufferX)-(this.map.pxWidth/2);var deltaY=(this.map.pxHeight/2)>(Math.abs(offset.y)+bufferY)?0:(Math.abs(offset.y)+bufferY)-(this.map.pxHeight/2);centerX=this.coordinate.x+(deltaX*this.map.mpx);centerY=this.coordinate.y+(deltaY*this.map.mpx);}
var map=this.map;this.map.panTo(new GSPoint(centerX,centerY),onUpdate);};GSInfoWindow.prototype.updateContent=function(html){if(!this.isOpen)return;if((typeof html).toLowerCase()=='string'){var div=document.createElement("div");div.innerHTML=html;html=div;}
this.setContent(html);this.updatePosition();};GSInfoWindow.prototype.close=function(){if(this.onclose){this.onclose();}
this.element.style.visibility="hidden";this.isOpen=false;this.map.broadcastMessage("infoWindowClosed",this);};GSInfoWindow.prototype.hide=function(){this.element.style.display='none';this.hidden=true;};GSInfoWindow.prototype.show=function(){this.element.style.display='block';this.hidden=false;};GSInfoWindow.prototype.isHidden=function(){return this.hidden;};GSInfoWindow.prototype.getCoordinate=function(){return this.coordinate;};GSInfoWindow.prototype.getPixelOffset=function(){return this.offset;};GSInfoWindow.prototype.finalize=function(){this.map.mapContentContainer.removeChild(this.element);};GSInfoWindow.prototype.mapResized=function(){this.reposition();};GSInfoWindow.prototype.mapZoomed=function(){this.reposition();};GSInfoWindow.prototype.mapBoundsChanged=function(){this.reposition();};GSInfoWindow.prototype.reposition=function(){if(!this.isOpen)return;var infoWindowHeight=this.element.offsetHeight;var pos=this.map.translateToMapCoordinate(this.coordinate);var x=pos.x+this.offset.x;var y=pos.y+(this.offset.y-(infoWindowHeight-7));GSUtil.positionElement(this.element,x,y);this.element.style.visibility="visible";};GSInfoWindow.prototype.setContent=function(content){content.className="info-window";while(this.contentOuter.firstChild){this.contentOuter.removeChild(this.contentOuter.firstChild);}
this.contentOuter.appendChild(content);};GSInfoWindow.prototype.createWindow=function(){var table=document.createElement('table');table.cellSpacing=0;table.cellPadding=0;table.style.position='absolute';table.style.visibility='hidden';table.style.zIndex=60;table.className='iw_table noprint';var tbody=document.createElement('tbody');table.appendChild(tbody);var tr=this.createIWRow(tbody);this.createIWCell(tr,'iw_tl',_globals.resourceURL+'iw/tl.png','no-repeat',12,9);this.createIWCell(tr,'iw_t',_globals.resourceURL+'iw/t.png','repeat-x',null,9);var td=this.createIWCell(tr,'iw_tr',_globals.resourceURL+'iw/tr.png','no-repeat',28,9);div=document.createElement('div');div.style.position='relative';td.appendChild(div);var closeBtn=document.createElement('img');closeBtn.src=_globals.resourceURL+'iw/close.png';closeBtn.title='Close';closeBtn.style.marginLeft='3px';closeBtn.style.position='absolute';if(_browser.isIE){closeBtn.style.top='5px';}else{closeBtn.style.top='1px';}
closeBtn.style.cursor='pointer';GSUtil.makeUnselectable(closeBtn);div.appendChild(closeBtn);td.appendChild(div);tr=this.createIWRow(tbody);this.createIWCell(tr,'iw_cl',_globals.resourceURL+'iw/cl.png','repeat-y',12);this.contentOuter=this.createIWCell(tr,'iw_c');this.contentOuter.style.backgroundColor='#fff';this.createIWCell(tr,'iw_cr',_globals.resourceURL+'iw/cr.png','repeat-y',28);tr=this.createIWRow(tbody);this.createIWCell(tr,'iw_bl',_globals.resourceURL+'iw/bl.png','no-repeat',12,21);this.createIWCell(tr,'iw_b',_globals.resourceURL+'iw/b.png','repeat-x',null,21);this.createIWCell(tr,'iw_br',_globals.resourceURL+'iw/br.png','no-repeat',28,21);this.map.mapContentContainer.appendChild(table);this.element=table;GSEventManager.bind(closeBtn,"click",this,this.close);};GSInfoWindow.prototype.createIWRow=function(parent){var tr=document.createElement('tr');parent.appendChild(tr);return tr;};GSInfoWindow.prototype.createIWCell=function(parent,id,src,repeat,width,height){var td=document.createElement('td');if(id){td.id=id;}
if(src){if(_browser.pngAlpha){td.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',sizingMethod='scale')";}else{td.style.backgroundImage='url('+src+')';td.style.backgroundRepeat=repeat;}}
if(width){td.style.width=width+'px';}
if(height){td.style.height=height+'px';}
parent.appendChild(td);return td;};function GSLogger(map){this.map=map;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 sessionid=this.getSessionIdFromCookie();if(sessionid){this.sessionid=sessionid;}else{this.sessionid=this.uuid();document.cookie='gssessionid='+this.sessionid;}};GSLogger.prototype.stopSession=function(){document.cookie='gssessionid=';this.sessionid=undefined;};GSLogger.prototype.getAPIUser=function(){var scriptTag=this.getAPIScriptTag();if(!scriptTag){throw new Error('Cannot log, API loaded from a non-Geosmart domain');}
var regExp=/user=([^&]+)(&|$)/;var user=scriptTag.src.match(regExp)[1];return user;};GSLogger.prototype.getAPIVersion=function(){var scriptTag=this.getAPIScriptTag();if(!scriptTag){throw new Error('Cannot log, API loaded from a non-Geosmart domain');}
var regExp=/&v=([^&]+)(&|$)/;var version=scriptTag.src.match(regExp)[1];return version;};GSLogger.prototype.getAPIScriptTag=function(){var scripts=document.getElementsByTagName('script');var regExp=/api2\.geosmart\.co\.nz/;for(var i=0,l=scripts.length;i<l;i++){var script=scripts[i];if(regExp.test(script.src)){return script;}}
return undefined;};GSLogger.prototype.log=function(log,arg){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 mapCenter=this.map.getMapCenter();arg.center_x=mapCenter.x;arg.center_y=mapCenter.y;arg.zoom_level=this.map.scaleIdx;arg.user=this.user;arg.api_version=this.version;arg.session_id=this.sessionid;var query='';for(var i in arg){if((typeof arg[i]).toLowerCase()=='function')continue;query+=(i+'='+encodeURIComponent(arg[i])+'&');}
var url=_globals.loggingBaseURL+log+'.log?'+query;this.transport.src=url;this.lastlogtime=new Date();};GSLogger.prototype.getSessionIdFromCookie=function(){var allcookies=document.cookie;var pos=allcookies.indexOf('gssessionid=');if(pos!=-1){var start=pos+12;var end=allcookies.indexOf(';',start);if(end==-1)end=allcookies.length;return allcookies.substring(start,end);}else{return undefined;}};GSLogger.prototype.uuid=function(){var result,i,j;result='';for(j=0;j<32;j++){if(j==8||j==12||j==16||j==20)result=result+'-';i=Math.floor(Math.random()*16).toString(16).toUpperCase();result=result+i;}
return result};
