// JSONscriptRequest -- a simple class for accessing Yahoo! Web Services
// using dynamically generated script tags and JSON
//
// Author: Jason Levitt
// Date: December 7th, 2005
//
// A SECURITY WARNING FROM DOUGLAS CROCKFORD:
// "The dynamic <script> tag hack suffers from a problem. It allows a page 
// to access data from any server in the web, which is really useful. 
// Unfortunately, the data is returned in the form of a script. That script 
// can deliver the data, but it runs with the same authority as scripts on 
// the base page, so it is able to steal cookies or misuse the authorization 
// of the user with the server. A rogue script can do destructive things to 
// the relationship between the user and the base server."
//
// So, be extremely cautious in your use of this script.
//

// Constructor -- pass a REST request URL to the constructor
//
function JSONscriptRequest(fullUrl) {
    // REST request path
    this.fullUrl = fullUrl; 
    // Keep IE from caching requests
    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    // Get the DOM location to put the script tag
    this.headLoc = document.getElementsByTagName("head").item(0);
    // Generate a unique script tag id
    this.scriptId = 'JscriptId' + JSONscriptRequest.scriptCounter++;
}

// Static script ID counter
JSONscriptRequest.scriptCounter = 1;

// buildScriptTag method
//
JSONscriptRequest.prototype.buildScriptTag = function () {

    // Create the script tag
    this.scriptObj = document.createElement("script");
    
    // Add script object attributes
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
    this.scriptObj.setAttribute("id", this.scriptId);
}
 
// removeScriptTag method
// 
JSONscriptRequest.prototype.removeScriptTag = function () {
    // Destroy the script tag
    this.headLoc.removeChild(this.scriptObj);  
}

// addScriptTag method
//
JSONscriptRequest.prototype.addScriptTag = function () {
    // Create the script tag
    this.headLoc.appendChild(this.scriptObj);
}

_globals={nzCenterX:2530000,nzCenterY:5990000,nzTopY:6748000,serverHostname:"http://www.geosmartlbs.co.nz",serviceName:"smartfind-core-0.3",proxyURL:"http://www.geosmartlbs.co.nz/smartfind/legacyauth.js",resourceURL:"http://www.geosmartlbs.co.nz/smartfind/client-0.40",tilesURL:"http://www.geosmartlbs.co.nz/smartfind/nz0.2",clientKey:null,DEBUG:false};
function Console(){
win=null;
}
Console.prototype={debug:function(_1){
if((this.win==null)||(this.win.closed)){
this.win=window.open("","console","width=600,height=300,screenX=400,resizable,");
this.win.document.open("text/html");
}
this.win.focus();
_1=new Date().toLocaleTimeString()+" "+_1+"<br/>";
this.win.document.writeln(_1);
}};
var _console=new Console();
function GSBrowser(){
var ua=navigator.userAgent.toLowerCase();
this.isFirefox=ua.indexOf("firefox")!=-1;
this.isSafari=ua.indexOf("applewebkit")!=-1;
this.isGecko=!this.isSafari&&ua.indexOf("gecko")!=-1;
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));
var _3=false;
if((this.isIE55||this.isIE6up)&&this.isWin32){
this.pngAlpha=true;
}
}
GSBrowser.prototype.isSmartfindCompatible=function(){
return (this.isIE6up||this.isGecko||this.isSafari);
};
_browser=new GSBrowser();
function GSEventManager(){
}
GSEventManager.bind=function(_4,_5,_6,_7){
var _8=GSEventManager.createAdapter(_6,_7);
return GSEventManager.addEventListener(_4,_5,_8);
};
GSEventManager.createAdapter=function(_9,_a){
return function(e){
e=!e?window.event:e;
_a.call(_9,e);
};
};
GSEventManager.release=function(_c){
GSEventManager.removeEventListener(_c);
};
GSEventManager.addEventListener=function(_d,_e,_f){
if(_browser.isSafari&&_e=="dblclick"){
_d["on"+_e]=_f;
return GSEventCache.add(_d,_e,_f);
}
if(_d.attachEvent){
_d.attachEvent("on"+_e,_f);
}else{
_d.addEventListener(_e,_f,false);
}
return GSEventCache.add(_d,_e,_f);
};
GSEventManager.removeEventListener=function(_10){
GSEventCache.remove(_10);
};
var GSEventCache=function(){
var _11=0;
var _12={};
var _13={handlerId:_11,handlers:_12,nextHandlerId:function(){
return "h"+this.handlerId++;
},add:function(obj,_15,_16){
var id=this.nextHandlerId();
this.handlers[id]=arguments;
return id;
},flush:function(){
for(var i in this.handlers){
this.remove(i);
}
},remove:function(id){
var _1a=this.handlers[id];
if(_1a[0].removeEventListener){
_1a[0].removeEventListener(_1a[1],_1a[2],_1a[3]);
}
if(_1a[1].substring(0,2)!="on"){
_1a[1]="on"+_1a[1];
}
if(_1a[0].detachEvent){
_1a[0].detachEvent(_1a[1],_1a[2]);
}
_1a[0][_1a[1]]=null;
delete this.handlers[id];
}};
return _13;
}();
function GSInit(){
}
GSInit.onLoadHandlers=[];
GSInit.dependencies={};
GSInit.addOnLoad=function(obj,_1c){
if(arguments.length==1){
GSInit.onLoadHandlers.push(obj);
}else{
if(arguments.length>1){
GSInit.onLoadHandlers.push(function(){
obj[_1c];
});
}
}
};
GSInit.addDependency=function(_1d){
GSInit.dependencies[_1d]={name:_1d,loaded:false};
};
GSInit.removeDependency=function(_1e){
delete GSInit.dependencies[_1e];
};
GSInit.dependencyLoaded=function(_1f){
GSInit.dependencies[_1f].loaded=true;
};
GSInit.onload=function(){
if(GSInit.initialized()){
var _20=GSInit.onLoadHandlers;
for(var i in _20){
if((typeof _20[i]).toLowerCase()=="function"){
continue;
}
_20[i]();
}
}else{
setTimeout("GSInit.onload()",10);
}
};
GSInit.initialized=function(){
for(var i in GSInit.dependencies){
if(!GSInit.dependencies[i].loaded){
return false;
}
}
return true;
};
GSEventManager.addEventListener(window,"load",GSInit.onload);
if(!window.Node){
var Node={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_FRAGMENT_NODE:11};
}
function GSWidget(){
}
GSWidget.tags={};
GSWidget.widgets={};
GSWidget.idPrefix="gswidget_";
GSWidget.idIncrement=0;
GSWidget.registerWidget=function(_23,_24){
GSWidget.tags[_23]=_24;
};
GSWidget.deregisterWidget=function(_25){
if(GSWidget.tags[_25]){
delete GSWidget.tags[_25];
}
};
GSWidget.getWidgetById=function(id){
return GSWidget.widgets[id];
};
GSWidget.createWidgets=function(){
var _27=document.getElementsByTagName("body")[0]||document.body;
GSWidget.parse(_27);
GSInit.dependencyLoaded("widget");
};
GSWidget.parse=function(_28){
var _29=_28.childNodes;
for(var i=0;i<_29.length;i++){
var _2b=_29[i];
if(Node.ELEMENT_NODE==_2b.nodeType){
var _2c=GSWidget.getTagName(_2b);
if(GSWidget.tags[_2c]){
var _2d=GSWidget.elementToJSON(_2b);
_2d["sourceNode"]=_2b;
var _2e=new GSWidget.tags[_2c](_2d);
GSWidget.widgets[GSWidget.getWidgetId(_2b)]=_2e;
}
GSWidget.parse(_2b);
}
}
};
GSWidget.getWidgetId=function(_2f){
return _2f.getAttribute("id")?_2f.getAttribute("id"):GSWidget.nextWidgetId();
};
GSWidget.nextWidgetId=function(){
return GSWidget.idPrefix+(++GSWidget.idIncrement);
};
GSWidget.elementToJSON=function(_30){
var obj={};
var _32=_30.attributes;
for(var i=0;i<_32.length;i++){
if(GSWidget.getAttributeName(_32[i])!="widget"){
obj[GSWidget.getAttributeName(_32[i])]=_32[i].value;
}
}
var _34=_30.childNodes;
for(var i in _34){
if((typeof _34[i]).toLowerCase()=="function"){
continue;
}
var _35=_34[i];
if(Node.ELEMENT_NODE==_35.nodeType){
obj[_35.tagName]=GSWidget.getElementTextValue(_35);
}
}
return obj;
};
GSWidget.getElementTextValue=function(_36){
var _37=[];
var _38=_36.childNodes;
for(var i in _38){
if((typeof _38[i]).toLowerCase()=="function"){
continue;
}
if(Node.TEXT_NODE==_38[i].nodeType){
_37.push(_38[i].nodeValue);
}
}
return _37.join("");
};
GSWidget.getTagName=function(_3a){
var _3b=_3a.tagName;
if(_browser.isIE){
_3b=_3a.outerHTML.match(/<([^?][^\s>]+)/)[1];
}
if(_3b.substr(0,3).toLowerCase()!="gs:"){
if(_3b.substr(0,2).toLowerCase()=="gs"){
return "gs:"+_3b.substring(2).toLowerCase();
}
try{
var _3c=_3a.getAttribute("widget")||_3a.getAttribute("gs:widget");
if(_3c){
return "gs:"+_3c.toLowerCase();
}
}
catch(e){
}
}
return _3b.toLowerCase();
};
GSWidget.getAttributeName=function(_3d){
var _3e=_3d.name;
if(_3e.substr(0,3).toLowerCase()=="gs:"){
return _3e.substring(3).toLowerCase();
}
return _3e.toLowerCase();
};
GSInit.addDependency("widget");
GSEventManager.addEventListener(window,"load",GSWidget.createWidgets);
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 GSAnimator(_41,to,_43,_44,_45,_46,_47){
this.from=_41;
this.to=to;
this.framerate=_43;
this.duration=_44;
this.setvalue=_45;
this.onstart=_46;
this.onfinish=_47;
this.currentValue=_41;
this.startTime=0;
this.timer=undefined;
}
GSAnimator.prototype.animate=function(){
if(!this.timer){
this.startTime=new Date().getTime()-this.framerate;
}
var _48=this;
this.timer=setInterval(function(){
_48.frame();
},this.framerate);
if(this.onstart){
this.onstart(this);
}
};
GSAnimator.prototype.frame=function(){
var _49=new Date().getTime()-this.startTime;
if(_49>=this.duration){
this.stopAnimate();
this.currentValue=this.to;
this.setvalue(this,this.currentValue);
if(this.onfinish){
var _4a=this;
setTimeout(function(){
_4a.onfinish(_4a);
},0);
}
}else{
var _4b=0.5-(0.5*Math.cos(Math.PI*Math.max(_49,0)/this.duration));
var x=this.interpolate(this.from.x,this.to.x,_4b);
var y=this.interpolate(this.from.y,this.to.y,_4b);
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(_4e,to,_50){
return _4e+(to-_4e)*_50;
};
function GSAuthenticator(){
}
GSAuthenticator.authenticate=function(_51){
_globals.clientId=_51;
var src="_gsClientId="+_51+"&_gsHostname="+window.location.hostname;
src=_globals.proxyURL+"?path="+encodeURIComponent(_globals.serviceName+"/authenticate.js?"+src);
var _53="<script type='text/javascript' src='"+src+"'></script>";
_53+="<style type=\"text/css\">@media screen{.noscreen {display: none;}.noprint {display: block;}}"+"@media print{.noscreen {display: block;}.noprint {display: none;}}</style>";
document.write(_53);
};
GSAuthenticator.validateAuthentication=function(){
if(!_globals.clientKey||_globals.clientKey==""){
alert("SmartFIND Services not accessible.");
}
};
GSAuthenticator.getQueryParameters=function(){
var str="&_gsClientKey="+_globals.clientKey+"&_gsHostname="+window.location.hostname;
return str;
};
function GSBounds(_55,_56,_57,_58){
this.minX=parseFloat(_55);
this.minY=parseFloat(_56);
this.maxX=parseFloat(_57);
this.maxY=parseFloat(_58);
}
GSBounds.prototype.contains=function(_59){
return (_59.x>=this.minX&&_59.x<=this.maxX)&&(_59.y>=this.minY&&_59.y<=this.maxY);
};
GSBounds.prototype.toString=function(){
return "Bounds: minX=["+this.minX+"], minY=["+this.minY+"]"+", maxX=["+this.maxX+"], maxY=["+this.maxY+"]";
};
function GSUtil(){
}
GSUtil.getNode=function(id){
return document.getElementById(id);
};
GSUtil.getPropertyArray=function(_5b,_5c){
var _5d=new Array();
for(var i in _5b){
if((typeof _5b[i]).toLowerCase()=="function"){
continue;
}
var e=_5b[i];
if(e[_5c]!=undefined){
_5d.push(e[_5c]);
}
}
return _5d;
};
GSUtil.getMinimum=function(_60){
var min=Infinity;
for(var i in _60){
if((typeof _60[i]).toLowerCase()=="function"){
continue;
}
min=Math.min(min,_60[i]);
}
return min;
};
GSUtil.getMaximum=function(_63){
var max=-Infinity;
for(var i in _63){
if((typeof _63[i]).toLowerCase()=="function"){
continue;
}
max=Math.max(max,_63[i]);
}
return max;
};
GSUtil.findPosX=function(obj){
var _67=0;
if(obj.offsetParent){
while(obj.offsetParent){
_67+=obj.offsetLeft;
obj=obj.offsetParent;
}
}else{
if(obj.x){
_67+=obj.x;
}
}
return _67;
};
GSUtil.findPosY=function(obj){
var el=obj;
var _6a=0;
if(obj.offsetParent){
while(obj.offsetParent){
_6a+=obj.offsetTop;
obj=obj.offsetParent;
}
}else{
if(obj.y){
_6a+=obj.y;
}
}
if(_browser.isOpera||((_browser.isSafari&&el.style.position=="absolute")||(_browser.isSafari&&el.style.position=="relative"))){
_6a-=document.body.offsetTop;
}
return _6a;
};
GSUtil.getClickPixelCoordinate=function(e,_6c){
if(typeof e.offsetX!="undefined"){
var src=e.target||e.srcElement;
var _6e=GSUtil.getOffsetFromAncestor(src,_6c);
return new GSPoint(e.offsetX+_6e.x,e.offsetY+_6e.y);
}else{
if(typeof e.pageX!="undefined"){
var pos=GSUtil.getElementPosition(_6c);
return new GSPoint(e.pageX-pos.x,e.pageY-pos.y);
}else{
return new GSPoint(0,0);
}
}
};
GSUtil.getElementPosition=function(_70){
var pos=new GSPoint(0,0);
while(_70){
pos.x+=_70.offsetLeft;
pos.y+=_70.offsetTop;
_70=_70.offsetParent;
}
return pos;
};
GSUtil.getWindowSize=function(){
var _72={};
if(self.innerHeight){
_72.width=self.innerWidth;
_72.height=self.innerHeight;
}else{
if(document.documentElement&&document.documentElement.clientHeight){
_72.width=document.documentElement.clientWidth;
_72.height=document.documentElement.clientHeight;
}else{
if(document.body){
_72.width=document.body.clientWidth;
_72.height=document.body.clientHeight;
}
}
}
return _72;
};
GSUtil.getOffsetFromAncestor=function(src,_74){
var _75=new GSPoint(0,0);
while(src&&src!=_74){
_75.x+=src.offsetLeft;
_75.y+=src.offsetTop;
src=src.offsetParent;
}
return _75;
};
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(_7b,_7c,top,_7e,_7f){
if(_7c||_7c==0){
_7b.style.left=_7c+"px";
}
if(top||top==0){
_7b.style.top=top+"px";
}
if(_7f||_7f==0){
_7b.style.bottom=_7f+"px";
}
if(_7e||_7e==0){
_7b.style.right=_7e+"px";
}
};
GSUtil.createContainer=function(_80,_81,_82,_83,_84,top,_86,_87){
var _88=document.createElement("div");
_80.appendChild(_88);
_88.className=_81;
if(_82){
_88.style.width=_82=="auto"?"auto":_82+"px";
}
if(_83){
_88.style.height=_83=="auto"?"auto":_83+"px";
}
if(_84||top||_84==0||top==0){
_88.style.position="absolute";
_88.style.left=_84+"px";
_88.style.top=top+"px";
}
if(_86){
_88.style.visibility=_86;
}
if(_87){
_88.style.zIndex=_87;
}
return _88;
};
GSUtil.createImage=function(id,src,_8b,_8c,_8d,top,_8f,_90,alt){
var img=null;
var _93=src.substring(src.lastIndexOf(".")+1);
if(_93.toLowerCase()=="png"&&_browser.pngAlpha){
img=document.createElement("div");
img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',"+"sizingMethod='scale')";
}else{
img=document.createElement("img");
img.src=src;
img.border=0;
img.margin=0;
img.padding=0;
}
img.id=id;
if(_8b||_8c){
img.width=_8b;
img.height=_8c;
img.style.width=_8b+"px";
img.style.height=_8c+"px";
}
if(_8d||top||_8d==0||top==0){
img.style.position="absolute";
img.style.left=_8d+"px";
img.style.top=top+"px";
}
if(_90!=undefined){
img.className=_90;
}
if(_8f!=null){
img.style.zIndex=_8f;
}
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(_94,src){
var _96=src.substring(src.lastIndexOf(".")+1);
if(_96.toLowerCase()=="png"&&_browser.pngAlpha){
_94.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',"+"sizingMethod='scale')";
}else{
_94.src=src;
}
};
GSUtil.getImageSrc=function(_97){
var src="";
if(_97.src!=undefined){
src=_97.src;
}
if(_97.style.filter){
var _99=/src='([^']+)'/;
var _9a=_97.style.filter.match(_99);
src=_9a[1];
}
return src;
};
GSUtil.createImageMap=function(_9b,_9c,_9d,_9e,alt,_a0,_a1,_a2){
var map=document.createElement("map");
map.setAttribute("name",_9b);
var _a4=document.createElement("area");
_a4.setAttribute("shape",_9c);
_a4.setAttribute("coords",_9d.toString());
_a4.setAttribute("href",_9e);
_a4.setAttribute("title",alt);
if(_a2!=undefined){
_a4.peer=_a2;
}
if(_a1!=undefined){
GSEventManager.addEventListener(_a4,_a0,_a1);
}
map.appendChild(_a4);
return map;
};
GSUtil.getTransparentBackgroundImageStyleRule=function(url,_a6){
if(_browser.pngAlpha){
return "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\""+url+"\", sizingMethod=\"scale\"); background-repeat: "+_a6;
}else{
return "background: url("+url+") "+_a6;
}
};
GSUtil.setOpacity=function(obj,_a8){
_a8=(_a8==100)?99.999:_a8;
obj.style.filter="alpha(opacity:"+_a8+")";
obj.style.KHTMLOpacity=_a8/100;
obj.style.MozOpacity=_a8/100;
obj.style.opacity=_a8/100;
};
GSUtil.getComputedStyle=function(_a9,_aa){
var val="";
if(_a9.currentStyle){
val=_a9.currentStyle[_aa];
}else{
if(document.defaultView.getComputedStyle){
if(document.defaultView.getComputedStyle(_a9,null)){
val=document.defaultView.getComputedStyle(_a9,null).getPropertyValue(_aa);
}
}
}
return val;
};
GSUtil.getFeatureById=function(a,id){
for(var i in a){
if((typeof a[i]).toLowerCase()=="function"){
continue;
}
if(a[i].id==id){
return a[i];
}
}
return undefined;
};
GSUtil.roundNumber=function(_af,_b0){
return Math.round(_af*Math.pow(10,_b0))/Math.pow(10,_b0);
};
GSUtil.getBaseName=function(_b1){
return _b1.substring(_b1.lastIndexOf("/")+1);
};
GSUtil.getBaseNameWithoutExtension=function(_b2){
var _b3=GSUtil.getBaseName(_b2);
return _b3.substring(0,_b3.indexOf("."));
};
GSUtil.getDirName=function(_b4){
return _b4.substring(0,_b4.lastIndexOf("/"));
};
GSUtil.normalizeName=function(str){
str=str.replace(/\. /gi," ");
str=str.replace(/^St\b/i,"saint");
str=str.replace(/\bSt$/i,"street");
str=str.replace(/\bRd\b/i,"road");
str=str.replace(/\bAve\b/i,"avenue");
str=str.replace(/\bCrt\b/i,"court");
str=str.replace(/\bCres\b/i,"crescent");
str=str.replace(/\bHwy\b/i,"highway");
str=str.replace(/\bLn\b/i,"lane");
str=str.replace(/\bTrl\b/i,"trail");
str=str.replace(/\bSt\b/i,"saint");
str=str.replace(/\bMus\b/i,"museum");
str=str.replace(/\bExtn\b/i,"extension");
str=str.replace(/\bGr\b/i,"grove");
str=str.replace(/\bCl\b/i,"close");
str=str.replace(/\bPl\b/i,"place");
str=str.replace(/\bPde\b/i,"parade");
str=str.replace(/\bHts\b/i,"heights");
str=str.replace(/\bTce\b/i,"terrace");
str=str.replace(/\bSq\b/i,"square");
str=str.replace(/\bBlvd\b/i,"boulevard");
str=str.replace(/\bRes\b/i,"reserve");
str=str.replace(/\bCnr\b/i,"corner");
str=str.replace(/\bDr\b/i,"drive");
str=str.replace(/\bGl\b/i,"glade");
str=str.replace(/\bPen\b/i,"peninsula");
str=str.replace(/\bCem\b/i,"cemetery");
str=str.replace(/\bCir\b/i,"circle");
str=str.replace(/\bStn\b/i,"station");
str=str.replace(/\bComm Ctr\b/i,"community centre");
str=str.replace(/\bAmb\b/i,"ambulance");
str=str.replace(/\bRec\b/i,"recreation");
str=str.replace(/\bRes\b/i,"reserve");
str=str.replace(/\bArc\b/i,"arcade");
str=str.replace(/\bEsp\b/i,"esplanade");
str=str.replace(/\bGdns\b/i,"gardens");
str=str.replace(/\bMwy\b/i,"motorway");
str=str.replace(/\bMt\b/i,"mount");
str=str.replace(/\bPt\b/i,"point");
str=str.replace(/\bTrk\b/i,"track");
str=str.replace(/\bNth\b/i,"north");
str=str.replace(/\bSth\b/i,"south");
str=str.replace(/\bQd\b/i,"quadrant");
return str;
};
GSUtil.clone=function(obj,_b7){
try{
var _b8=new obj.constructor();
for(var _b9 in obj){
if(!_b7){
_b8[_b9]=obj[_b9];
}else{
if(typeof obj[_b9]=="object"){
_b8[_b9]=GSUtil.clone(obj[_b9],_b7);
}else{
_b8[_b9]=obj[_b9];
}
}
}
return _b8;
}
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.getIframeDocument=function(_bc){
var doc;
if(_bc.contentDocument){
doc=_bc.contentDocument;
}else{
if(_bc.contentWindow){
doc=_bc.contentWindow.document;
}else{
if(_bc.document){
doc=_bc.document;
}
}
}
return doc;
};
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,_c0,_c1){
if(!obj||!(obj instanceof Object)){
return undefined;
}
var _c2=undefined;
if(obj[_c0]!=undefined){
_c2=obj[_c0];
}else{
if(obj[_c0.toLowerCase()]){
_c2=obj[_c0.toLowerCase()];
}
}
if(_c2!=undefined&&(typeof _c2).toLowerCase()=="string"&&_c2!="null"){
return _c2;
}else{
return _c2!=undefined?_c2:(_c1!=undefined?_c1:undefined);
}
};
GSUtil.populateTemplate=function(_c3,_c4,_c5){
for(var key in _c4){
var _c7=new RegExp("{"+key+"}","g");
_c3=_c3.replace(_c7,_c4[key]?_c4[key]:"");
}
if(_c5){
for(var key in _c5){
var _c7=new RegExp("{"+key+"}","g");
_c3=_c3.replace(_c7,_c5[key]?_c5[key]:"");
}
}
return _c3;
};
GSUtil.joinAssociativeArray=function(_c8,_c9,_ca){
var _cb=[];
for(var key in _c8){
_cb.push(key+_ca+(_c8[key]!=undefined?_c8[key]:""));
}
return _cb.join(_c9);
};
GSUtil.getParameter=function(obj,key,_cf){
if(obj[key]==undefined){
if(arguments.length<3){
throw new Error("Missing parameter: "+key);
}else{
return _cf;
}
}else{
return obj[key];
}
};
GSUtil.makeUnselectable=function(_d0){
if(typeof _d0.style.MozUserSelect=="string"){
_d0.style.MozUserSelect="none";
}else{
if(typeof _d0.style.KhtmlUserSelect){
_d0.style.KhtmlUserSelect="none";
}else{
if(typeof _d0.onselectstart!="undefined"){
_d0.onselectstart=function(){
return false;
};
}
}
}
};
function GSEventBroadcaster(){
}
GSEventBroadcaster.initialize=function(obj){
obj.listeners=[];
obj.broadcastMessage=this.broadcastMessage;
obj.addListener=this.addListener;
obj.removeListener=this.removeListener;
};
GSEventBroadcaster.broadcastMessage=function(){
var _d2=arguments[0];
var _d3=[];
for(var i=1;i<arguments.length;i++){
_d3.push(arguments[i]);
}
for(var i in this.listeners){
if((typeof this.listeners[i]).toLowerCase()=="function"){
continue;
}
if(this.listeners[i][_d2]){
this.listeners[i][_d2].apply(this.listeners[i],_d3);
}
}
};
GSEventBroadcaster.addListener=function(obj){
this.removeListener(obj);
this.listeners.push(obj);
return true;
};
GSEventBroadcaster.removeListener=function(obj){
for(var i in this.listeners){
if((typeof this.listeners[i]).toLowerCase()=="function"){
continue;
}
if(this.listeners[i]==obj){
this.listeners.splice(i,1);
return true;
}
}
return false;
};
function GSRouteFeature(_d8){
this.coordinates=_d8;
this.image=null;
this.onmap=false;
this.rendered=false;
this.visible=true;
}
GSRouteFeature.prototype.addToMap=function(map){
map.addListener(this);
this.onmap=true;
this.map=map;
this.loadImage(map);
};
GSRouteFeature.prototype.setVisible=function(_da){
this.visible=_da;
if(this.image){
this.loadImage(this.map);
}
};
GSRouteFeature.prototype.mapResized=function(map,_dc,_dd){
this.loadImage(map);
};
GSRouteFeature.prototype.mapZoomed=function(map,_df,_e0){
this.loadImage(map);
};
GSRouteFeature.prototype.mapBoundsChanged=function(map,_e2,_e3){
this.loadImage(map);
};
GSRouteFeature.prototype.loadImage=function(map){
GSAuthenticator.validateAuthentication();
if(this.image==undefined){
this.image=GSUtil.createImage("","",map.pxWidth,map.pxHeight,null,null,null,"lineFeature",null);
}
this.image.style.visibility="hidden";
var url=this.buildURL(map);
if(_globals.DEBUG){
_console.debug("line feature image src: "+url);
}
GSEventManager.bind(this.image,"load",this,this.render);
this.image.src=url;
};
GSRouteFeature.prototype.buildURL=function(map){
var url="xmin="+map.minX;
url+="&xmax="+map.maxX;
url+="&ymin="+map.minY;
url+="&ymax="+map.maxY;
url+="&mapheight="+map.pxHeight;
url+="&mapwidth="+map.pxWidth;
url+="&features=";
for(var i in this.coordinates){
if((typeof this.coordinates[i]).toLowerCase()=="function"){
continue;
}
if(i>0){
url+=",";
}
var _e9=this.coordinates[i];
url+=_e9.x+":"+_e9.y;
}
url+=GSAuthenticator.getQueryParameters();
url=_globals.proxyURL+"?path="+encodeURIComponent(_globals.serviceName+"/route.png?"+url);
return url;
};
GSRouteFeature.prototype.render=function(){
if(this.image){
if(!this.rendered&&!this.finalized){
this.map.lineContainer.appendChild(this.image);
this.rendered=true;
}
this.setImageSize(this.map.pxWidth,this.map.pxHeight);
this.image.style.left="0px";
this.image.style.top="0px";
var v=this.visible?"visible":"hidden";
this.image.style.visibility=v;
}
};
GSRouteFeature.prototype.setImageSize=function(_eb,_ec){
if(!_browser.pngAlpha){
this.image.width=_eb;
this.image.height=_ec;
}
this.image.style.width=_eb+"px";
this.image.style.height=_ec+"px";
};
GSRouteFeature.prototype.finalize=function(){
if(this.rendered){
this.map.lineContainer.removeChild(this.image);
this.rendered=false;
this.map.removeListener(this);
this.finalized=true;
}
};
GSRouteFeature.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;
};
function GSLayer(_ee){
this.name=_ee;
this.visible=true;
this.data=[];
this.map;
}
GSLayer.prototype.setVisible=function(_ef){
this.visible=_ef;
for(var i in this.data){
if((typeof this.data[i]).toLowerCase()=="function"){
continue;
}
this.data[i].setVisible(_ef);
}
};
GSLayer.prototype.addFeatures=function(_f1){
for(var i in _f1){
if((typeof _f1[i]).toLowerCase()=="function"){
continue;
}
this.addFeature(_f1[i]);
}
};
GSLayer.prototype.addFeaturesJson=function(_f3,_f4){
for(var i=0;i<_f3.length;i++){
if(_f3[i].jsclass&&_f3[i].jsclass=="GSPointFeature"){
var _f6=new GSPointFeature(_f3[i]);
if(_f4){
_f4(_f6,_f3[i]);
}
this.addFeature(_f6);
}
}
};
GSLayer.prototype.addFeature=function(_f7){
this.data.push(_f7);
_f7.setVisible(this.visible);
_f7.addToMap(this.map);
};
GSLayer.prototype.removeFeature=function(_f8){
for(var i in this.data){
if((typeof this.data[i]).toLowerCase()=="function"){
continue;
}
if(_f8==this.data[i]){
_f8.finalize();
this.data.splice(i,1);
}
}
};
GSLayer.prototype.clear=function(){
for(var i in this.data){
if((typeof this.data[i]).toLowerCase()=="function"){
continue;
}
this.data[i].finalize();
}
this.data.length=0;
};
GSLayer.prototype.getBounds=function(){
var _fb=[];
for(var i in this.data){
if((typeof this.data[i]).toLowerCase()=="function"){
continue;
}
var _fd=this.data[i];
if(_fd instanceof GSRouteFeature){
for(var j in _fd.coordinates){
if((typeof _fd.coordinates[i]).toLowerCase()=="function"){
continue;
}
_fb.push(_fd.coordinates[j]);
}
}else{
if(_fd.coordinate){
_fb.push(_fd.coordinate);
}
}
}
var _ff=GSUtil.getMinimum(GSUtil.getPropertyArray(_fb,"x"));
var minY=GSUtil.getMinimum(GSUtil.getPropertyArray(_fb,"y"));
var maxX=GSUtil.getMaximum(GSUtil.getPropertyArray(_fb,"x"));
var maxY=GSUtil.getMaximum(GSUtil.getPropertyArray(_fb,"y"));
return new GSBounds(_ff,minY,maxX,maxY);
};
GSLayer.prototype.toString=function(){
var s="";
for(var i in this.data){
if((typeof this.data[i]).toLowerCase()=="function"){
continue;
}
s+=this.data[i].toString();
}
return s;
};
function GSDimension(_105,_106){
this.width=parseInt(_105);
this.height=parseInt(_106);
}
GSDimension.prototype.toString=function(){
return "Dimension: width=["+this.width+"], h=["+this.height+"]";
};
function GSMap(_107){
GSComponentManager.add(this);
if(_107["sourceNode"]){
this.container=document.createElement("div");
this.container.id=GSUtil.getCaseInsensitiveProperty(_107,"id");
var _108=_107["sourceNode"].parentNode;
_108.replaceChild(this.container,_107["sourceNode"]);
}else{
if(GSUtil.getCaseInsensitiveProperty(_107,"container")){
this.container=GSUtil.getCaseInsensitiveProperty(_107,"container");
}else{
if(GSUtil.getCaseInsensitiveProperty(_107,"id")){
this.container=document.getElementById(GSUtil.getCaseInsensitiveProperty(_107,"id"));
}else{
alert("Cannot create map, no container id supplied.");
return;
}
}
}
GSEventBroadcaster.initialize(this);
var w=GSUtil.getCaseInsensitiveProperty(_107,"width");
var h=GSUtil.getCaseInsensitiveProperty(_107,"height");
if(w){
this.container.style.width=w+"px";
}
if(h){
this.container.style.height=h+"px";
}
this.centerOnDblClick=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(_107,"centerOnDblClick",true));
this.dragToPan=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(_107,"dragToPan",true));
this.panning=false;
this.infoWindowEnabled=GSUtil.stringToBoolean(GSUtil.getCaseInsensitiveProperty(_107,"infoWindowEnabled",true));
this.scaleRange=[2,4,8,16,32,64,128,256,512,1024,2048,4096];
this.scaleRange.indexOf=function(_10b){
for(var i=0;i<this.length;i++){
if(_10b==this[i]){
return i;
}
}
return -1;
};
this.scaleIdx=Number(GSUtil.getCaseInsensitiveProperty(_107,"zoomLevel",this.scaleRange.length-1));
this.mpx=this.scaleRange[this.scaleIdx];
this.centerX=GSUtil.getCaseInsensitiveProperty(_107,"centerX")?parseFloat(GSUtil.getCaseInsensitiveProperty(_107,"centerX")):2530000;
this.centerY=GSUtil.getCaseInsensitiveProperty(_107,"centerY")?parseFloat(GSUtil.getCaseInsensitiveProperty(_107,"centerY")):5990000;
this.minX=1500000;
this.minY=5700000;
this.maxX=3500000;
this.maxY=7300000;
this.pxWidth=GSUtil.getCaseInsensitiveProperty(_107,"width")?Number(GSUtil.getCaseInsensitiveProperty(_107,"width")):500;
this.pxHeight=GSUtil.getCaseInsensitiveProperty(_107,"height")?Number(GSUtil.getCaseInsensitiveProperty(_107,"height")):400;
this.tilePxHeight=400;
this.tilePxWidth=400;
this.defaultTileUrl=_globals.tilesURL+"/default.png";
this.resizeable=GSUtil.getCaseInsensitiveProperty(_107,"resizeable")?GSUtil.getCaseInsensitiveProperty(_107,"resizeable"):true;
if(GSUtil.getComputedStyle(this.container,"position")!="absolute"){
this.container.style.position="relative";
}
this.container.style.overflow="hidden";
this.controls=new Array();
this.layers=new Array();
var _10d=new GSLayer("base");
_10d.map=this;
this.layers.push(_10d);
this.createOverlayContainers();
var _10e=GSUtil.createImage("geosmartIcon",_globals.resourceURL+"/resources/images/smartfindLogo.png",120,19,undefined,undefined,40,undefined,"GeoSmart Web Site");
_10e.style.position="absolute";
_10e.style.cursor="pointer";
GSUtil.positionElement(_10e,undefined,undefined,0,0);
this.container.appendChild(_10e);
GSEventManager.addEventListener(_10e,"click",function(e){
window.open("http://www.geosmart.co.nz","geosmart");
GSUtil.cancelEvent(e);
});
this.infoWindow=null;
if(this.infoWindowEnabled){
this.infoWindow=new GSInfoWindow(this);
}
this.sizeToContainerDimensions();
this.addMapEventListeners();
var _110=GSUtil.getCaseInsensitiveProperty(_107,"mapControls");
if(_110&&_110!="none"){
this.addControl(_110);
}
this.recalculateMapExtents();
if(GSUtil.getCaseInsensitiveProperty(_107,"centerX")&&GSUtil.getCaseInsensitiveProperty(_107,"centerY")&&GSUtil.getCaseInsensitiveProperty(_107,"zoomLevel")!=undefined){
this.update(function(){
this.broadcastMessage("mapZoomed",this,0,this.scaleIdx);
});
}
}
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.MAX_WIDTH=1600;
GSMap.MAX_HEIGHT=1200;
GSMap.TEXT_ZOOM_CONTROL=0;
GSMap.prototype.sizeToContainerDimensions=function(){
var _111=this.container.offsetWidth;
if(_111>0){
this.pxWidth=_111<GSMap.MAX_WIDTH?_111:GSMap.MAX_WIDTH;
}
var _112=this.container.offsetHeight;
if(_112>0){
this.pxHeight=_112<GSMap.MAX_HEIGHT?_112:GSMap.MAX_HEIGHT;
}
};
GSMap.prototype.finalize=function(){
if(this.infoWindowEnabled){
this.infoWindow.finalize();
}
this.clearLayers();
while(this.container.hasChildNodes()){
this.container.removeChild(this.container.firstChild);
}
GSEventCache.flush();
};
GSMap.prototype.resizeMap=function(){
var _113=new GSDimension(this.pxWidth,this.pxHeight);
this.sizeToContainerDimensions();
this.recalculateMapExtents();
this.broadcastMessage("mapResized",this,_113,new GSDimension(this.pxWidth,this.pxHeight));
this.update();
};
GSMap.prototype.getMapCenter=function(){
return new GSPoint(this.centerX,this.centerY);
};
GSMap.prototype.getSize=function(){
return new GSDimension(this.pxWidth,this.pxHeight);
};
GSMap.prototype.setSize=function(size,_115){
this.resizeable=_115;
if(!_115){
GSEventManager.release(this.eventListeners["resize"]);
}
this.pxWidth=size.width;
this.pxHeight=size.height;
};
GSMap.prototype.setBounds=function(_116,_117){
var _118=this.mpx;
var _119=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);
var minX=_116.minX;
var minY=_116.minY;
var maxX=_116.maxX;
var maxY=_116.maxY;
var _11e=maxX-minX;
var _11f=maxY-minY;
var _120=_11e/2;
var _121=_11f/2;
this.centerX=minX+_120;
this.centerY=minY+_121;
this.mpx=Math.ceil(Math.max(_11e/this.pxWidth,_11f/this.pxHeight));
this.mpx=this.fitToScaleRange(this.mpx);
this.scaleIdx=this.scaleRange.indexOf(this.mpx);
var _122=(this.pxWidth*this.mpx);
var _123=(this.pxHeight*this.mpx);
this.minX=this.centerX-(_122/2);
this.minY=this.centerY-(_123/2);
this.maxX=this.centerX+(_122/2);
this.maxY=this.centerY+(_123/2);
this.centerX=this.minX+((this.maxX-this.minX)/2);
this.centerY=this.minY+((this.maxY-this.minY)/2);
var _124=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);
this.update(function(){
this.broadcastMessage("mapBoundsChanged",this,_119,_124);
if(_117){
_117();
}
});
};
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.lineContainer=GSUtil.createContainer(this.mapContentContainer,null,null,null,0,0,null,15);
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);
this.infoWindowShadowContainer=GSUtil.createContainer(this.mapContentContainer,null,null,null,0,0,null,50);
this.infoWindowContainer=GSUtil.createContainer(this.mapContentContainer,null,null,null,0,0,null,60);
this.controlContainer=GSUtil.createContainer(this.container,null,null,null,0,0,null,10);
};
GSMap.prototype.dragStart=function(e){
if(this.panning){
return;
}
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.eventStopPropagation(e);
GSUtil.eventPreventDefault(e);
};
GSMap.prototype.initDrag=function(){
this.panning=true;
if(this.dragToPan){
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.eventStopPropagation(e);
GSUtil.eventPreventDefault(e);
};
GSMap.prototype.cancelDrag=function(e){
if(this.dragTimer){
clearInterval(this.dragTimer);
}
};
GSMap.prototype.dragStop=function(e){
e=e?e:window.event;
var _12a=(e.clientX-this.startPixel.x)*this.mpx;
var _12b=(e.clientY-this.startPixel.y)*this.mpx;
if(_12a!=0||_12b!=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.eventStopPropagation(e);
GSUtil.eventPreventDefault(e);
};
GSMap.prototype.click=function(e){
if(!this.panning){
if(this.infoWindowEnabled&&this.infoWindow.isOpen){
this.infoWindow.close();
}
if(!e){
e=window.event;
}
var _12d=this.getClickCoordinate(e);
this.broadcastMessage("mapClicked",this,_12d);
}else{
self.panning=false;
}
GSUtil.eventStopPropagation(e);
GSUtil.eventPreventDefault(e);
};
GSMap.prototype.dblclick=function(e){
var _12f=this.getClickCoordinate(e);
if(this.centerOnDblClick){
this.panTo(_12f);
}
this.broadcastMessage("mapDblClicked",this,_12f);
GSUtil.eventStopPropagation(e);
GSUtil.eventPreventDefault(e);
};
GSMap.prototype.addMapEventListeners=function(){
this.eventListeners={};
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.eventListeners["resize"]=GSEventManager.bind(window,"resize",this,this.resizeMap);
}
this.eventListeners["unload"]=GSEventManager.bind(window,"unload",this,this.finalize);
};
GSMap.prototype.getClickPixelCoordinate=function(e){
if(e.offsetX){
return {x:e.offsetX,y:e.offsetY};
}else{
if(e.layerX){
return {x:e.layerX,y:e.layerY};
}else{
return {x:(window.pageXOffset+e.clientX-GSUtil.findPosX(this)),y:(window.pageYOffset+e.clientY-GSUtil.findPosY(this))};
}
}
};
GSMap.prototype.getClickCoordinate=function(e){
return this.translateToRealWorldCoordinate(GSUtil.getClickPixelCoordinate(e,this.container));
};
GSMap.prototype.zoom=function(_132,_133){
var _134=this.scaleIdx;
if(_132<0||_132>=this.scaleRange.length){
alert("Zoom level out of range: "+_132);
return;
}
this.mpx=this.scaleRange[_132];
this.scaleIdx=_132;
this.recalculateMapExtents(true);
this.update(function(){
this.broadcastMessage("mapZoomed",this,_134,this.scaleIdx);
if(_133){
_133();
}
});
};
GSMap.prototype.panTo=function(_135,_136){
this.panning=true;
var _137=this.getBounds();
if(!_137.contains(_135)){
return this.centerAtCoordinate(_135,_136);
}
var from=this.translateToMapCoordinate(new GSPoint(this.centerX,this.centerY));
var to=this.translateToMapCoordinate(_135);
var self=this;
var _13b=function(_13c,_13d){
_13d.x=Math.floor(_13d.x);
_13d.y=Math.floor(_13d.y);
GSUtil.positionElement(self.mapContentContainer,(from.x-_13d.x),(from.y-_13d.y));
self.centerAtCoordinate(self.translateToRealWorldCoordinate(_13d,_137),null,GSMap.SUPPRESS_MESSAGING);
};
var _13e=new GSAnimator(from,to,16,500,_13b,null,function(){
self.panning=false;
self.broadcastMessage("mapBoundsChanged",self,_137,self.getBounds());
GSUtil.positionElement(self.mapContentContainer,0,0);
if(_136){
_136();
}
});
_13e.animate();
};
GSMap.prototype.centerAtCoordinate=function(_13f,_140,_141){
var _142=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);
this.centerX=_13f.x;
this.centerY=_13f.y;
this.recalculateMapExtents();
var _143=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);
this.update(function(){
if(!_141){
this.broadcastMessage("mapBoundsChanged",this,_142,_143);
}
if(_140){
_140();
}
});
};
GSMap.prototype.centerAndZoom=function(_144,_145,_146){
var _147=this.scaleIdx;
this.centerX=_144.x;
this.centerY=_144.y;
if(_145!=undefined){
if(_145<0||_145>=this.scaleRange.length){
alert("Zoom level out of range: "+_145);
return;
}
this.mpx=this.scaleRange[_145];
this.scaleIdx=_145;
}
this.recalculateMapExtents();
this.update(function(){
this.broadcastMessage("mapZoomed",this,_147,this.scaleIdx);
if(_146){
_146();
}
});
};
GSMap.prototype.centerOnNewZealand=function(_148){
var _149=this.scaleIdx;
this.centerX=_globals.nzCenterX;
this.centerY=_globals.nzCenterY;
for(var i=0;i<this.scaleRange.length;i++){
if(_globals.nzCenterY+((this.scaleRange[i]*this.pxHeight)/2)>_globals.nzTopY){
this.mpx=this.scaleRange[i];
this.scaleIdx=i;
break;
}
}
this.recalculateMapExtents();
this.update(function(){
this.broadcastMessage("mapZoomed",this,_149,this.scaleIdx);
if(_148){
_148();
}
});
};
GSMap.prototype.fitToScaleRange=function(_14b){
var _14c=this.scaleRange[0];
for(var i=0;i<this.scaleRange.length;i++){
if((typeof this.scaleRange[i]).toString().toLowerCase()!="function"){
var _14e=this.scaleRange[i];
if(_14e==_14b){
return _14b;
}else{
if(_14e>_14b){
_14c=_14e;
break;
}
}
}
}
return _14c;
};
GSMap.prototype.addControl=function(_14f){
var obj=null;
var _151=false;
if(GSControl.prototype.isPrototypeOf){
_151=GSControl.prototype.isPrototypeOf(_14f);
}else{
if(_14f.__proto__){
_151=(typeof _14f).toLowerCase()=="object";
}
}
if(_151){
obj=_14f;
}else{
obj=this.instantiateControl(_14f);
}
if(obj!=null){
obj.map=this;
this.controls.push(obj);
obj.render();
}
return obj;
};
GSMap.prototype.removeControl=function(_152){
var name="";
var _154=false;
if(GSControl.prototype.isPrototypeOf){
_154=GSControl.prototype.isPrototypeOf(_152);
}else{
if(_152.__proto__){
_154=(typeof _152).toLowerCase()=="object";
}
}
if(_154){
name=_152.name;
}else{
name=_152;
}
for(var i in this.controls){
if((typeof this.controls[i]).toLowerCase()=="function"){
continue;
}
if(this.controls[i].name==name){
this.controls[i].finalize();
this.controls.splice(i,1);
}
}
};
GSMap.prototype.instantiateControl=function(name){
var _157;
switch(name){
case GSMap.ZOOM_CONTROL:
_157=new GSZoomControl(this.controlContainer,new GSPoint(7,7));
break;
case GSMap.COMPACT_ZOOM_CONTROL:
_157=new GSCompactZoomControl(this.controlContainer,new GSPoint(7,7));
break;
case GSMap.MAP_CONTROL:
_157=new GSMapControl(this.controlContainer);
break;
case GSMap.TEXT_ZOOM_CONTROL:
_157=new GSTextZoomControl(this.controlContainer);
break;
}
return _157;
};
GSMap.prototype.centerOnLayer=function(name,_159){
var _15a=this.getLayer(name);
if(_15a==undefined){
return;
}
_15a.mapBoundsChanged=function(map,_15c,_15d){
this.setVisible(true);
map.removeListener(this);
};
this.addListener(_15a);
var _15e=_15a.getBounds();
var _15f=_15e.maxX-_15e.minX;
var _160=_15e.maxY-_15e.minY;
var padW=_15f*0.05;
var padH=_160*0.05;
_15e.minX-=padW;
_15e.maxX+=padW;
_15e.minY-=padH;
_15e.maxY+=padH;
this.setBounds(_15e,_159);
};
GSMap.prototype.createLayer=function(name){
var _164=this.getLayer(name);
if(_164!=undefined){
this.removeLayer(name);
}
_164=new GSLayer(name);
_164.map=this;
this.layers.push(_164);
return _164;
};
GSMap.prototype.removeLayer=function(name){
if(name=="base"){
return;
}
for(var i in this.layers){
if((typeof this.layers[i]).toLowerCase()=="function"){
continue;
}
var _167=this.layers[i];
if(_167.name==name){
_167.clear();
this.layers.splice(i,1);
return;
}
}
};
GSMap.prototype.clearLayers=function(){
for(var i in this.layers){
if((typeof this.layers[i]).toLowerCase()=="function"){
continue;
}
this.removeLayer(this.layers[i].name);
}
};
GSMap.prototype.getLayer=function(name){
for(var i in this.layers){
if((typeof this.layers[i]).toLowerCase()=="function"){
continue;
}
var _16b=this.layers[i];
if(_16b.name==name){
return _16b;
}
}
return null;
};
GSMap.prototype.addFeature=function(_16c){
var _16d=this.getLayer("base");
_16d.addFeature(_16c);
};
GSMap.prototype.removeFeature=function(_16e){
var _16f=this.getLayer("base");
_16f.removeFeature(_16e);
};
GSMap.prototype.recalculateMapExtents=function(_170){
var _171=this.pxWidth*this.mpx;
var _172=this.pxHeight*this.mpx;
if(_170&&this.infoWindowEnabled&&this.infoWindow.isOpen){
var _173=this.infoWindow.coordinate;
var _174=_173.x-this.minX;
var _175=_173.y-this.minY;
var _176=this.maxX-this.minX;
var _177=this.maxY-this.minY;
var _178=_174/_176;
var _179=_175/_177;
this.minX=_173.x-(_178*_171);
this.maxX=_173.x+((1-_178)*_171);
this.minY=_173.y-(_179*_172);
this.maxY=_173.y+((1-_179)*_172);
this.centerX=this.minX+(_171/2);
this.centerY=this.minY+(_172/2);
}else{
this.minX=this.centerX-(_171/2);
this.minY=this.centerY-(_172/2);
this.maxX=this.centerX+(_171/2);
this.maxY=this.centerY+(_172/2);
}
};
GSMap.prototype.translateToMapCoordinate=function(_17a){
var x=_17a.x;
var y=_17a.y;
var _17d=Math.round(x-this.minX);
var _17e=Math.round(this.maxY-y);
return new GSPoint(Math.round(_17d/this.mpx),Math.round(_17e/this.mpx));
};
GSMap.prototype.translateToRealWorldCoordinate=function(_17f,_180){
if(!_180){
_180=new GSBounds(this.minX,this.minY,this.maxX,this.maxY);
}
var _181=this.pxWidth*this.mpx;
var _182=this.pxHeight*this.mpx;
var x=_180.minX+(_181*(_17f.x/this.pxWidth));
var y=_180.maxY-(_182*(_17f.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.showInfoWindowForFeature=function(_185,html){
if(this.infoWindowEnabled){
html=html!=undefined?html:_185.infoHtml;
var _187=_185.icon.iconOffset.x+_185.icon.iconInfoWindowOffset.x;
var _188=_185.icon.iconOffset.y+_185.icon.iconInfoWindowOffset.y;
this.infoWindow.openHtml(_185.coordinate,html,new GSPoint(_187,_188));
}
};
GSMap.prototype.featureClicked=function(_189){
this.broadcastMessage("mapClicked",this,"click",_189);
};
GSMap.prototype.update=function(_18a){
var self=this;
if(this.updating){
setTimeout(function(){
self.update(_18a);
},250);
}
this.updating=true;
var _18c=this.tilePxWidth*this.mpx;
var _18d=this.tilePxHeight*this.mpx;
var _18e=Math.floor(this.minX/_18c)*_18c;
var _18f=Math.floor(this.maxX/_18c)*_18c;
var _190=Math.floor(this.minY/_18d)*_18d;
var _191=Math.ceil(this.maxY/_18d)*_18d;
this.tileContainer.innerHTML="";
GSUtil.positionElement(this.tileContainer,Math.floor((_18e-this.minX)/this.mpx),Math.ceil((this.maxY-_191)/this.mpx));
var _192=new Array();
var yIdx=0;
for(var ty=_191;ty>=_190;ty-=_18d){
var xIdx=0;
for(var tx=_18e;tx<=_18f;tx+=_18c){
var _197=new Object();
_197.left=(xIdx++*this.tilePxWidth);
_197.top=(yIdx*this.tilePxHeight);
var src=this.buildTileUrl(tx,ty-_18d,this.mpx);
_197.src=src;
_192.push(_197);
}
yIdx++;
}
new GSMapImageLoader(_192,this,_18a,this.defaultTileUrl);
};
GSMap.prototype.openInfoWindow=function(_199,html){
this.infoWindow.openHtml(_199,html);
};
GSMap.prototype.closeInfoWindow=function(){
this.infoWindow.close();
};
GSMap.prototype.buildTileUrl=function(x,y,mpx){
return _globals.tilesURL+"/"+mpx+"/"+y+"_"+x+".png";
};
function GSMapImageLoader(_19e,map,_1a0,_1a1){
this.map=map;
this.onloadFunc=_1a0;
this.defaultSrc=_1a1;
this.imgCount=_19e.length;
this.loadedCount=0;
for(var i=0;i<_19e.length;i++){
this.load(_19e[i]);
}
}
GSMapImageLoader.prototype.load=function(_1a3){
var img=document.createElement("img");
this.map.tileContainer.appendChild(img);
img.defaultSrc=this.defaultSrc;
img.border=0;
img.style.position="absolute";
GSUtil.positionElement(img,_1a3.left,_1a3.top);
if(_browser.isIE){
img.setAttribute("galleryimg","no");
img.unselectable="on";
img.onselectstart=GSUtil.cancelEvent;
}else{
img.style.MozUserSelect="none";
}
GSEventManager.bind(img,"load",this,this.onload);
img.src=_1a3.src;
};
GSMapImageLoader.prototype.onload=function(){
this.loadedCount++;
if(this.loadedCount==this.imgCount){
this.oncomplete.call(this.map,this.onloadFunc);
this.map.updating=false;
}
};
GSMapImageLoader.prototype.oncomplete=function(_1a5){
if(_1a5){
_1a5.call(this);
}
};
function GSInfoWindow(map){
this.map=map;
this.map.addListener(this);
this.coordinate;
this.offset;
this.contentOffset=new GSPoint(-5,-5);
this.isOpen=false;
this.windowDiv=GSUtil.createContainer(this.map.infoWindowContainer,"noprint",null,null,0,0,"hidden");
this.shadowDiv=GSUtil.createContainer(this.map.infoWindowShadowContainer,"noprint",null,null,0,0,"hidden");
this.offscreenContainer=GSUtil.createContainer(window.document.body,"noprint",screen.width,screen.height,-screen.width,-screen.height,"hidden");
this.offscreen=GSUtil.createContainer(this.offscreenContainer,null,"auto","auto",0,0,"hidden");
this.createWindow();
this.createShadow();
GSEventManager.bind(this.windowDiv,"click",this,this.processMouseEvent);
GSEventManager.bind(this.windowDiv,"mousedown",this,this.processMouseEvent);
GSEventManager.bind(this.windowDiv,"dblclick",this,this.processMouseEvent);
}
GSInfoWindow.prototype.getWindowHeight=function(){
return parseInt(this.window.c.style.height)+(20*2);
};
GSInfoWindow.prototype.processMouseEvent=function(e){
if(_browser.isIE){
GSUtil.eventStopPropagation(e);
}else{
var _1a8=this.map.getClickPixelCoordinate(e);
if(_1a8.y<=this.getWindowHeight()){
GSUtil.eventStopPropagation(e);
}
}
};
GSInfoWindow.prototype.openMapBlowup=function(_1a9,_1aa,_1ab,size){
if(this.isOpen){
this.close();
}
if(_1ab==undefined){
_1ab=new GSPoint(0,0);
}
var _1ad=document.createElement("div");
var _1ae=document.createElement("div");
_1ad.appendChild(_1ae);
_1ae.style.backgroundColor="#c5c5c5";
_1ae.style.border="1px solid #a0a0a4";
var _1af={container:_1ae,width:size.width,height:size.height};
var map=new GSMap(_1af);
map.setSize(size,false);
map.addControl(GSMap.COMPACT_ZOOM_CONTROL);
map.centerOnDblClick=true;
map.dragToPan=true;
map.infoWindowEnabled=false;
var _1b1=this.map;
map.infoWindowOpened=function(){
this.centerAndZoom(_1a9,_1aa);
_1b1.removeListener(this);
};
this.map.addListener(map);
map.finalize=function(){
this.clearLayers();
while(this.container.hasChildNodes()){
this.container.removeChild(this.container.firstChild);
}
};
this.onclose=function(){
map.finalize();
this.onclose=undefined;
};
this.open(_1a9,_1ad,_1ab);
return map;
};
GSInfoWindow.prototype.openHtml=function(_1b2,html,_1b4){
if(this.isOpen){
this.close();
}
if(_1b4==undefined){
_1b4=new GSPoint(0,0);
}
var _1b5=document.createElement("div");
_1b5.innerHTML=html;
this.open(_1b2,_1b5,_1b4);
};
GSInfoWindow.prototype.open=function(_1b6,_1b7,_1b8){
this.iconOffset=new GSPoint(_1b8.x,_1b8.y);
this.isOpen=true;
this.offscreen.appendChild(_1b7);
var _1b9=5;
var _1ba=5;
var _1bb=this.getContentSize();
this.resizeWindow(_1bb);
this.resizeShadow(_1bb);
this.setContent(_1bb);
var _1bc=20+_1bb.width+20;
var _1bd=_1bb.height+20+72;
this.coordinate=_1b6;
this.offset=_1b8;
this.offset.y-=_1bd;
var _1be,centerY;
var pos=this.map.translateToMapCoordinate(this.coordinate);
if(_1b6.x>this.map.minX&&_1b6.x<this.map.maxX&&_1b6.y>this.map.minY&&_1b6.y<this.map.maxY){
var left=pos.x+this.offset.x;
var top=pos.y+this.offset.y;
var _1c2=0;
var _1c3=0;
if((left+_1bc+_1b9)>this.map.pxWidth){
_1c2=this.map.pxWidth-(left+_1bc+_1b9);
}
if((top-_1ba)<0){
_1c3=0-(top-_1ba);
}
if(_1c2==0&&_1c3==0){
this.map.broadcastMessage("infoWindowOpened");
return this.reposition();
}
if(this.offset.x+_1bc>this.map.pxWidth){
var maxX=this.coordinate.x+(this.offset.x+_1bc*this.map.mpx);
_1be=maxX-(this.map.pxWidth*this.map.mpx)/2;
centerY=this.coordinate.y;
}
_1be=this.map.centerX-(_1c2*this.map.mpx);
centerY=this.map.centerY+(_1c3*this.map.mpx);
}else{
var _1c2=(this.map.pxWidth/2)>(this.offset.x+_1bc+_1b9)?0:(this.offset.x+_1bc+_1b9)-(this.map.pxWidth/2);
var _1c3=(this.map.pxHeight/2)>(Math.abs(this.offset.y)+_1ba)?0:(Math.abs(this.offset.y)+_1ba)-(this.map.pxHeight/2);
_1be=this.coordinate.x+(_1c2*this.map.mpx);
centerY=this.coordinate.y+(_1c3*this.map.mpx);
}
var map=this.map;
this.map.panTo(new GSPoint(_1be,centerY),function(){
map.broadcastMessage("infoWindowOpened");
});
};
GSInfoWindow.prototype.getContentSize=function(){
var _1c6=0;
var _1c7=0;
_1c6=Math.max(this.offscreen.offsetWidth+(this.contentOffset.x*2),100);
_1c7=Math.max(this.offscreen.offsetHeight+(this.contentOffset.y*2),10);
return new GSDimension(_1c6,_1c7);
};
GSInfoWindow.prototype.close=function(){
if(this.onclose){
this.onclose();
}
this.shadowDiv.style.visibility="hidden";
this.windowDiv.style.visibility="hidden";
this.offscreen.innerHTML="";
this.isOpen=false;
this.map.broadcastMessage("infoWindowClosed",this);
};
GSInfoWindow.prototype.finalize=function(){
window.document.body.removeChild(this.offscreenContainer);
this.map.infoWindowContainer.removeChild(this.windowDiv);
this.map.infoWindowShadowContainer.removeChild(this.shadowDiv);
};
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 pos=this.map.translateToMapCoordinate(this.coordinate);
GSUtil.positionElement(this.windowDiv,(pos.x+this.offset.x),(pos.y+this.offset.y));
GSUtil.positionElement(this.shadowDiv,(pos.x+this.offset.x),(pos.y-70+this.iconOffset.y-2));
if(!this.timer&&this.windowDiv.style.visibility=="hidden"){
var self=this;
self.timer=setInterval(function(){
self.windowDiv.style.visibility="visible";
self.shadowDiv.style.visibility="visible";
clearInterval(self.timer);
self.timer=undefined;
},50);
}
};
GSInfoWindow.prototype.setContent=function(_1ca){
var _1cb=_1ca.width;
var _1cc=_1ca.height;
if(this.content!=null){
this.windowDiv.removeChild(this.content);
}
var _1cd=this.offscreen.getElementsByTagName("div")[0];
this.content=this.offscreen.removeChild(_1cd);
this.content.className="info-window";
this.content.style.border="none";
this.content.style.position="absolute";
GSUtil.positionElement(this.content,15,15);
this.content.style.zIndex=3;
this.content.style.width=(_1cb-(this.contentOffset.x*2))+"px";
this.content.style.height=(_1cc-(this.contentOffset.y*2))+"px";
this.windowDiv.appendChild(this.content);
};
GSInfoWindow.prototype.createImage=function(_1ce,id,src,_1d1,_1d2,left,top,_1d5,_1d6,alt){
var img=GSUtil.createImage(id,src,_1d1,_1d2,left,top,_1d5,_1d6,alt);
img.style.width=_1d1+"px";
img.style.height=_1d2+"px";
_1ce.appendChild(img);
return img;
};
GSInfoWindow.prototype.createWindow=function(){
this.window=new Object();
this.window.nw=this.createImage(this.windowDiv,"",_globals.resourceURL+"/resources/images/nw.png",20,20,0,0,0);
this.window.n=this.createImage(this.windowDiv,"",_globals.resourceURL+"/resources/images/n.png",640,20,20,0,0);
this.window.ne=this.createImage(this.windowDiv,"",_globals.resourceURL+"/resources/images/ne.png",20,20,120,0,0);
this.window.closeImg=this.createImage(this.windowDiv,"",_globals.resourceURL+"/resources/images/close.gif",14,13,0,0,5,"info-window-close","Close");
this.window.closeImg.style.border="none";
this.window.closeImg.style.position="absolute";
this.window.closeImg.style.right="6px";
this.window.closeImg.style.top="6px";
this.window.closeImg.style.cursor="pointer";
this.window.w=this.createImage(this.windowDiv,"",_globals.resourceURL+"/resources/images/w.png",20,640,0,20,0);
this.window.c=this.createImage(this.windowDiv,"",_globals.resourceURL+"/resources/images/c.png",640,640,20,20,0);
this.window.e=this.createImage(this.windowDiv,"",_globals.resourceURL+"/resources/images/e.png",20,640,120,20,0);
this.window.sw=this.createImage(this.windowDiv,"",_globals.resourceURL+"/resources/images/sw.png",60,72,0,30,0);
this.window.s=this.createImage(this.windowDiv,"",_globals.resourceURL+"/resources/images/s.png",640,72,60,30,0);
this.window.se=this.createImage(this.windowDiv,"",_globals.resourceURL+"/resources/images/se.png",20,72,120,30,0);
GSEventManager.bind(this.window.closeImg,"click",this,this.close);
GSEventManager.bind(this.window.sw,"click",this,this.close);
GSEventManager.bind(this.window.s,"click",this,this.close);
GSEventManager.bind(this.window.se,"click",this,this.close);
};
GSInfoWindow.prototype.createShadow=function(){
this.shadow=new Object();
this.shadow.sNw=this.createImage(this.shadowDiv,"",_globals.resourceURL+"/resources/images/s_nw.png",60,30,55,0,0);
this.shadow.sN=this.createImage(this.shadowDiv,"",_globals.resourceURL+"/resources/images/s_n.png",640,30,(55+60),0,0);
this.shadow.sNe=this.createImage(this.shadowDiv,"",_globals.resourceURL+"/resources/images/s_ne.png",80,30,135,0,0);
this.shadow.sSw=this.createImage(this.shadowDiv,"",_globals.resourceURL+"/resources/images/s_sw.png",90,45,0,30,0);
this.shadow.sS=this.createImage(this.shadowDiv,"",_globals.resourceURL+"/resources/images/s_s.png",640,45,90,30,0);
this.shadow.sSe=this.createImage(this.shadowDiv,"",_globals.resourceURL+"/resources/images/s_se.png",70,45,110,30,0);
};
GSInfoWindow.prototype.resizeWindow=function(_1d9){
var _1da=_1d9.width;
var _1db=_1d9.height;
this.window.n.style.width=_1da+"px";
this.window.ne.style.left=(20+_1da)+"px";
this.window.closeImg.style.left=(20+_1da-5)+"px";
this.window.w.style.height=_1db+"px";
this.window.c.style.width=_1da+"px";
this.window.c.style.height=_1db+"px";
this.window.e.style.left=(20+_1da)+"px";
this.window.e.style.height=_1db+"px";
this.window.sw.style.top=(20+_1db)+"px";
this.window.s.style.top=(20+_1db)+"px";
this.window.s.style.width=(20+_1da-60)+"px";
this.window.se.style.left=(20+_1da)+"px";
this.window.se.style.top=(20+_1db)+"px";
};
GSInfoWindow.prototype.resizeShadow=function(_1dc){
var _1dd=_1dc.width-80;
this.shadow.sN.style.width=_1dd+"px";
this.shadow.sNe.style.left=(55+60+_1dd)+"px";
this.shadow.sS.style.width=_1dd+"px";
this.shadow.sSe.style.left=(90+_1dd)+"px";
};
GSWidget.registerWidget("gs:map",GSMap);
var Drag={obj:null,init:function(o,_1df,minX,maxX,minY,maxY,_1e4,_1e5,_1e6,_1e7){
o.onmousedown=Drag.start;
if(o.addEventListener){
o.addEventListener("click",Drag.stopPropagation,false);
o.addEventListener("dblclick",Drag.stopPropagation,false);
o.addEventListener("contextmenu",Drag.stopPropagation,false);
}else{
if(o.attachEvent){
o.attachEvent("onclick",Drag.stopPropagation);
o.attachEvent("ondblclick",Drag.stopPropagation);
o.attachEvent("oncontextmenu",Drag.stopPropagation);
}else{
o["on"+eventType]=Drag.stopPropagation;
}
}
o.hmode=_1e4?false:true;
o.vmode=_1e5?false:true;
o.root=_1df&&_1df!=null?_1df: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=_1e6?_1e6:null;
o.yMapper=_1e7?_1e7: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);
return false;
},end:function(e){
Drag.stopPropagation(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"]));
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 GSControl(){
}
GSControl.prototype.init=function(name,_1f7,_1f8){
this.name=name;
this.container=_1f7;
this.control=_1f8;
this.map=null;
this.rendered=false;
};
GSControl.prototype.render=function(){
this.container.appendChild(this.control);
this.rendered=true;
};
GSTextZoomControl.prototype=new GSControl();
GSTextZoomControl.superclass=GSControl.prototype;
function GSTextZoomControl(_1f9){
var _1fa=[GSMap.TEXT_ZOOM_CONTROL,_1f9,document.createElement("div")];
GSCompactZoomControl.superclass.init.apply(this,_1fa);
this.levels={"Region":16,"District":11,"Suburb":6,"Street":1};
this.className="GSTextZoomControl";
this.control.style.textAlign="right";
}
GSTextZoomControl.prototype.render=function(){
if(this.rendered){
return;
}
for(var _1fb in this.levels){
var _1fc=this.levels[_1fb];
var _1fd=document.createElement("a");
_1fd.href="";
GSEventManager.bind(_1fd,"click",this,this.getZoomFunction(_1fc));
GSEventManager.addEventListener(_1fd,"dblclick",GSUtil.cancelEvent);
GSEventManager.addEventListener(_1fd,"contextmenu",GSUtil.cancelEvent);
_1fd.className=this.className;
_1fd.appendChild(document.createTextNode(_1fb));
this.control.appendChild(_1fd);
this.control.appendChild(document.createTextNode(" | "));
}
this.control.removeChild(this.control.lastChild);
GSCompactZoomControl.superclass.render.apply(this);
};
GSTextZoomControl.prototype.getZoomFunction=function(_1fe){
return function(e){
e=e?e:window.event;
this.map.zoom(_1fe);
GSUtil.cancelEvent(e);
};
};
GSTextZoomControl.prototype.finalize=function(){
this.container.removeChild(this.control);
};
GSCompactZoomControl.prototype=new GSControl();
GSCompactZoomControl.superclass=GSControl.prototype;
function GSCompactZoomControl(_200,_201){
var _202=document.createElement("div");
_202.style.position="absolute";
_202.style.left=_201.x+"px";
_202.style.top=_201.y+"px";
var _203=[GSMap.COMPACT_ZOOM_CONTROL,_200,_202];
GSCompactZoomControl.superclass.init.apply(this,_203);
}
GSCompactZoomControl.prototype.render=function(){
if(this.rendered){
return;
}
var _204=GSUtil.createImage("gscompactzoomcontrol-shadow",_globals.resourceURL+"/resources/images/zoomcontrol-shadow.png",26,52,0,0,0,"noprint");
this.control.appendChild(_204);
var _205=GSUtil.createImage("gscompactzoomcontrol_zoomin",_globals.resourceURL+"/resources/images/zoomin.png",21,21,0,0,10,"noprint","Zoom in");
_205.style.cursor="pointer";
this.control.appendChild(_205);
GSEventManager.bind(_205,"click",this,this.zoomIn);
GSEventManager.addEventListener(_205,"dblclick",GSUtil.cancelEvent);
GSEventManager.addEventListener(_205,"contextmenu",GSUtil.cancelEvent);
var _206=GSUtil.createImage("gscompactzoomcontrol_zoomout",_globals.resourceURL+"/resources/images/zoomout.png",21,21,0,25,10,"noprint","Zoom out");
_206.style.cursor="pointer";
this.control.appendChild(_206);
GSEventManager.bind(_206,"click",this,this.zoomOut);
GSEventManager.addEventListener(_206,"dblclick",GSUtil.cancelEvent);
GSEventManager.addEventListener(_206,"contextmenu",GSUtil.cancelEvent);
GSCompactZoomControl.superclass.render.apply(this);
};
GSCompactZoomControl.prototype.zoomIn=function(e){
e=e?e:window.event;
if(this.map.scaleIdx-1<0){
return;
}
this.map.zoom(--this.map.scaleIdx);
GSUtil.cancelEvent(e);
};
GSCompactZoomControl.prototype.zoomOut=function(e){
e=e?e:window.event;
if(this.map.scaleIdx+1>=this.map.scaleRange.length){
return;
}
this.map.zoom(++this.map.scaleIdx);
GSUtil.cancelEvent(e);
};
GSCompactZoomControl.prototype.finalize=function(){
this.container.removeChild(this.control);
};
GSMapControl.prototype=new GSControl();
GSMapControl.superclass=GSControl.prototype;
function GSMapControl(_209){
var _20a=document.createElement("div");
_20a.style.position="absolute";
_20a.style.left="7px";
_20a.style.top="7px";
var _20b=[GSMap.MAP_CONTROL,_209,_20a];
GSMapControl.superclass.init.apply(this,_20b);
this.zoom=new GSZoomControl(_209,new GSPoint(20,87));
}
GSMapControl.prototype.render=function(){
if(this.rendered){
return;
}
this.zoom.map=this.map;
this.zoom.render();
var _20c=GSUtil.createImage("gsmapcontrol-shadow",_globals.resourceURL+"/resources/images/pancontrol-shadow.png",54,80,0,0,100,"noprint");
this.control.appendChild(_20c);
var up=GSUtil.createImage("gsmapcontrol_up",_globals.resourceURL+"/resources/images/upArrow.png",21,21,13,0,100,"noprint","Move up");
up.style.cursor="pointer";
GSEventManager.bind(up,"click",this,this.getPanFunction("up"));
GSEventManager.addEventListener(up,"dblclick",GSUtil.cancelEvent);
GSEventManager.addEventListener(up,"contextmenu",GSUtil.cancelEvent);
this.control.appendChild(up);
var left=GSUtil.createImage("gsmapcontrol_left",_globals.resourceURL+"/resources/images/leftArrow.png",21,21,0,25,100,"noprint","Move left");
left.style.cursor="pointer";
left.direction="left";
GSEventManager.bind(left,"click",this,this.getPanFunction("left"));
GSEventManager.addEventListener(left,"dblclick",GSUtil.cancelEvent);
GSEventManager.addEventListener(left,"contextmenu",GSUtil.cancelEvent);
this.control.appendChild(left);
var _20f=GSUtil.createImage("gsmapcontrol_right",_globals.resourceURL+"/resources/images/rightArrow.png",21,21,26,25,100,"noprint","Move right");
_20f.style.cursor="pointer";
_20f.direction="right";
GSEventManager.bind(_20f,"click",this,this.getPanFunction("right"));
GSEventManager.addEventListener(_20f,"dblclick",GSUtil.cancelEvent);
GSEventManager.addEventListener(_20f,"contextmenu",GSUtil.cancelEvent);
this.control.appendChild(_20f);
var down=GSUtil.createImage("gsmapcontrol_down",_globals.resourceURL+"/resources/images/downArrow.png",21,21,13,50,100,"noprint","Move down");
down.style.cursor="pointer";
down.direction="down";
GSEventManager.bind(down,"click",this,this.getPanFunction("down"));
GSEventManager.addEventListener(down,"dblclick",GSUtil.cancelEvent);
GSEventManager.addEventListener(down,"contextmenu",GSUtil.cancelEvent);
this.control.appendChild(down);
GSMapControl.superclass.render.apply(this);
};
GSMapControl.prototype.getPanFunction=function(_211){
return function(e){
e=e?e:window.event;
var _213=0.25;
var _214=this.map.maxX-this.map.minX;
var _215=this.map.maxY-this.map.minY;
var _216=this.map.centerX;
var _217=this.map.centerY;
switch(_211){
case "up":
var _218=_213*_215;
_217+=_218;
break;
case "left":
var _218=_213*_214;
_216-=_218;
break;
case "right":
var _218=_213*_214;
_216+=_218;
break;
case "down":
var _218=_213*_215;
_217-=_218;
break;
}
var _219=new GSPoint(_216,_217);
this.map.centerAtCoordinate(_219);
GSUtil.cancelEvent(e);
};
};
GSMapControl.prototype.finalize=function(){
this.zoom.finalize();
this.container.removeChild(this.control);
};
GSZoomControl.prototype=new GSControl();
GSZoomControl.superclass=GSControl.prototype;
function GSZoomControl(_21a,_21b){
var _21c=document.createElement("div");
_21c.style.position="absolute";
_21c.style.left=_21b.x+"px";
_21c.style.top=_21b.y+"px";
var _21d=[GSMap.ZOOM_CONTROL,_21a,_21c];
GSZoomControl.superclass.init.apply(this,_21d);
this.sliderBar=null;
this.sliderThumb=null;
this.zoomAnchor=_21b;
this.zooming=false;
}
GSZoomControl.prototype.render=function(){
if(this.rendered){
return;
}
this.map.addListener(this);
var _21e=GSUtil.createImage("gszoomcontrol_zoomin-shadow",_globals.resourceURL+"/resources/images/zoom-shadow.png",25,25,0,0,100,"noprint");
this.control.appendChild(_21e);
var _21f=GSUtil.createImage("gszoomcontrol_zoomin",_globals.resourceURL+"/resources/images/zoomin.png",21,21,0,0,110,"noprint","Zoom in");
_21f.style.cursor="pointer";
this.control.appendChild(_21f);
GSEventManager.bind(_21f,"click",this,this.zoomIn);
GSEventManager.addEventListener(_21f,"dblclick",GSUtil.cancelEvent);
GSEventManager.addEventListener(_21f,"contextmenu",GSUtil.cancelEvent);
var _220=GSUtil.createImage("gszoomcontrol_zoomout-shadow",_globals.resourceURL+"/resources/images/zoom-shadow.png",25,25,0,168,100,"noprint");
this.control.appendChild(_220);
var _221=GSUtil.createImage("gszoomcontrol_zoomout",_globals.resourceURL+"/resources/images/zoomout.png",21,21,0,168,110,"noprint","Zoom out");
_221.style.cursor="pointer";
this.control.appendChild(_221);
GSEventManager.bind(_221,"click",this,this.zoomOut);
GSEventManager.addEventListener(_221,"dblclick",GSUtil.cancelEvent);
GSEventManager.addEventListener(_221,"contextmenu",GSUtil.cancelEvent);
var _222=document.createElement("div");
_222.style.position="absolute";
_222.style.left="2px";
_222.style.top="25px";
this.control.appendChild(_222);
this.sliderBar=GSUtil.createImage("gszoomcontrol_sliderbar",_globals.resourceURL+"/resources/images/slider-bar.png",20,144,0,0,110,"noprint","Click to set zoom level");
this.sliderBar.style.cursor="pointer";
_222.appendChild(this.sliderBar);
this.sliderThumb=GSUtil.createImage("gszoomcontrol_sliderthumb",_globals.resourceURL+"/resources/images/slider-thumb.png",21,15,0,126,115,"noprint","Drag to zoom");
this.sliderThumb.style.cursor="pointer";
Drag.init(this.sliderThumb,null,0,0,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);
_222.appendChild(this.sliderThumb);
GSZoomControl.superclass.render.apply(this);
};
GSZoomControl.prototype.getDragEndHandler=function(_223){
return function(x,y){
_223.sliderMoved(x,y);
};
};
GSZoomControl.prototype.zoomIn=function(e){
e=e?e:window.event;
var _227=parseInt(this.sliderThumb.style.top);
_227-=GSZoomControl.SLIDER_INCREMENT;
_227=_227>GSZoomControl.SLIDER_MIN?_227:GSZoomControl.SLIDER_MIN;
this.sliderThumb.style.top=_227+"px";
this.sliderMoved(2,_227);
GSUtil.cancelEvent(e);
};
GSZoomControl.prototype.zoomOut=function(e){
e=e?e:window.event;
var _229=parseInt(this.sliderThumb.style.top);
_229+=GSZoomControl.SLIDER_INCREMENT;
_229=_229<GSZoomControl.SLIDER_MAX?_229:GSZoomControl.SLIDER_MAX;
this.sliderThumb.style.top=_229+"px";
this.sliderMoved(2,_229);
GSUtil.cancelEvent(e);
return false;
};
GSZoomControl.prototype.sliderClicked=function(e){
e=e?e:window.event;
var _22b,mouseY;
if(_browser.isIE){
_22b=e.offsetX;
mouseY=e.offsetY;
}else{
_22b=(window.pageXOffset+e.clientX-GSUtil.findPosX(this.sliderBar));
mouseY=(window.pageYOffset+e.clientY-GSUtil.findPosY(this.sliderBar));
}
mouseY=mouseY<GSZoomControl.SLIDER_MAX?mouseY:GSZoomControl.SLIDER_MAX;
this.sliderThumb.style.top=mouseY+"px";
this.sliderMoved(_22b,mouseY);
GSUtil.cancelEvent(e);
};
GSZoomControl.prototype.sliderMoved=function(x,y){
this.zooming=true;
var idx=Math.round(y/GSZoomControl.SLIDER_INCREMENT);
this.map.zoom(idx);
};
GSZoomControl.prototype.mapBoundsChanged=function(map,_230,_231){
var _232=this.map.scaleIdx;
this.mapZoomed(this.map,null,_232);
};
GSZoomControl.prototype.mapZoomed=function(map,_234,_235){
if(this.zooming){
this.zooming=false;
return;
}
var y=Math.round(_235*GSZoomControl.SLIDER_INCREMENT);
y=y<GSZoomControl.SLIDER_MIN?GSZoomControl.SLIDER_MIN:y>GSZoomControl.SLIDER_MAX?GSZoomControl.SLIDER_MAX:y;
this.sliderThumb.style.top=y+"px";
};
GSZoomControl.prototype.finalize=function(){
this.map.removeListener(this);
this.container.removeChild(this.control);
};
GSZoomControl.SLIDER_INCREMENT=11.5;
GSZoomControl.SLIDER_MIN=2;
GSZoomControl.SLIDER_MAX=126;
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=copy.iconOffset;
}
this.iconInfoWindowOffset=new GSPoint(0,0);
if(copy){
this.iconInfoWindowOffset=copy.iconInfoWindowOffset;
}
this.imageMap=undefined;
if(copy){
this.imageMap=copy.imageMap;
}
this.imageMapShape="poly";
if(copy){
this.imageMapShape=copy.imageMapShape;
}
this.visible=true;
this.rendered=false;
}
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);
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");
}
if(this.shadowSrc!=null){
this.shadow=GSUtil.createImage("",this.shadowSrc,this.shadowSize.width,this.shadowSize.height,0,0,0,"noprint gsicon_shadowImage",null);
}
if(_browser.isGecko&&this.imageMap!=null){
var _238="map_"+GSIcon.nextId();
this.image.setAttribute("usemap",_238);
this.htmlImageMap=GSUtil.createImageMap(_238,this.imageMapShape,this.imageMap,"#",this.alt);
}
};
GSIcon.prototype.setVisible=function(_239){
this.visible=_239;
var v=_239?"visible":"hidden";
if(this.printImage){
this.printImage.style.visibility=v;
}
if(this.shadow){
this.shadow.style.visibility=v;
}
this.image.style.visibility=v;
};
GSIcon.prototype.render=function(map,_23c){
if(this.canRender(map,_23c)){
if(!this.rendered){
map.iconContainer.appendChild(this.image);
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(_23c);
var left=(pos.x+this.iconOffset.x);
var top=(pos.y+this.iconOffset.y);
GSUtil.positionElement(this.image,left,top);
if(this.printImage){
GSUtil.positionElement(this.printImage,left,top);
}
if(this.shadow){
GSUtil.positionElement(this.shadow,left,top);
}
this.setVisible(this.visible);
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,_241){
var _242=this.iconOffset.x*map.mpx;
var _243=this.iconOffset.y*map.mpx;
return (_241.x>map.minX&&_241.x<map.maxX&&_241.y>map.minY&&_241.y<map.maxY);
};
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+"/resources/images/defaultIcon.png";
GSIcon.defaultIcon.printSrc=_globals.resourceURL+"/resources/images/defaultIcon.gif";
GSIcon.defaultIcon.shadowSrc=_globals.resourceURL+"/resources/images/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,0);
function GSPointFeature(_246){
this.id=GSUtil.getCaseInsensitiveProperty(_246,"id");
this.coordinate=GSUtil.getCaseInsensitiveProperty(_246,"coordinate");
if(this.coordinate==undefined){
var x=GSUtil.getCaseInsensitiveProperty(_246,"x");
var y=GSUtil.getCaseInsensitiveProperty(_246,"y");
this.coordinate=(x&&y)?new GSPoint(x,y):new GSPoint(0,0);
}
this.name=GSUtil.getCaseInsensitiveProperty(_246,"name");
this.suburb=GSUtil.getCaseInsensitiveProperty(_246,"suburb");
this.district=GSUtil.getCaseInsensitiveProperty(_246,"district");
this.region=GSUtil.getCaseInsensitiveProperty(_246,"region");
this.iconType=undefined;
this.infoHtml=GSUtil.getCaseInsensitiveProperty(_246,"infoHtml");
this.map=undefined;
this.onmap=false;
this.isShowingInfo=false;
this.visible=true;
this.eventListeners={};
this.icon=GSUtil.getCaseInsensitiveProperty(_246,"icon");
if(!this.icon){
this.icon=new GSIcon(GSIcon.defaultIcon);
}
this.icon.alt=this.name;
this.icon.prerender();
this.icon.setVisible(this.visible);
}
GSPointFeature.prototype.clone=function(){
var map=this.map;
var icon=this.icon;
this.map=undefined;
this.icon=undefined;
var _24b=GSUtil.clone(this,true);
_24b.icon=new GSIcon(icon);
_24b.icon.prerender();
_24b.onmap=false;
_24b.isShowingInfo=false;
this.map=map;
this.icon=icon;
return _24b;
};
GSPointFeature.prototype.setVisible=function(_24c){
this.visible=_24c;
if(this.icon){
this.icon.setVisible(_24c);
}
};
GSPointFeature.prototype.setIcon=function(icon){
var _24e=this.icon;
icon.prerender();
icon.render(this.map,this.coordinate);
};
GSPointFeature.prototype.addEventHandler=function(_24f,func){
var _251=this.icon.getEventTarget();
if(_251){
if(_24f=="click"){
this.icon.image.style.cursor="pointer";
}
var _252=GSEventManager.bind(_251,_24f,this,func);
this.addListenerToken(_24f,_252);
return _252;
}
};
GSPointFeature.prototype.addListenerToken=function(_253,_254){
if(this.eventListeners[_253]){
if((typeof this.eventListeners[_253]).toLowerCase()!="array"){
this.eventListeners[_253]=[this.eventListeners[_253]];
}
this.eventListeners[_253].push(_254);
}else{
this.eventListeners[_253]=_254;
}
};
GSPointFeature.prototype.removeEventHandler=function(_255){
GSEventManager.release(_255);
};
GSPointFeature.prototype.openMapBlowup=function(_256){
_256=_256?_256:0;
if(this.onmap){
this.isShowingInfo=true;
var map=this.map.infoWindow.openMapBlowup(this.coordinate,0,new GSPoint(-6,-8),new GSDimension(180,180));
var _258=map.createLayer(this.id);
var _259=this.clone();
_258.addFeature(_259);
}
};
GSPointFeature.prototype.showInfoWindow=function(html){
if(this.onmap){
this.isShowingInfo=true;
this.map.featureClicked(this);
this.map.showInfoWindowForFeature(this,html);
}
};
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,_25f,_260){
if(_globals.DEBUG){
_console.debug("mapResized: "+_25f+"\n"+_260);
}
this.render(map);
};
GSPointFeature.prototype.mapZoomed=function(map,_262,_263){
if(_globals.DEBUG){
_console.debug("mapZoomed: "+_262+"\n"+_263);
}
this.render(map);
};
GSPointFeature.prototype.mapBoundsChanged=function(map,_265,_266){
if(_globals.DEBUG){
_console.debug("mapBoundsChanged: "+_265+"\n"+_266);
}
this.render(map);
};
GSPointFeature.prototype.infoWindowOpened=function(){
};
GSPointFeature.prototype.infoWindowClosed=function(_267){
if(this.isShowingInfo){
this.isShowingInfo=false;
}
};
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;
};
function GSDOMParser(){
this.output;
this.aaTotalCount;
}
GSDOMParser.prototype.parse=function(_26d){
var _26e=_26d.getElementsByTagName("poi");
var _26f=_26d.documentElement.getAttribute("totalCount");
if(_26f){
this.aaTotalCount=parseInt(_26f);
}
var len=_26e.length;
for(var i=0;i<len;i++){
var el=_26e[i];
var _273={};
_273["id"]=this.getElementValue(el,"id");
_273["coordinate"]=new GSPoint(this.getElementValueAsFloat(el,"x"),this.getElementValueAsFloat(el,"y"));
_273["name"]=this.getElementValue(el,"name");
_273["suburb"]=this.getElementValue(el,"suburb");
_273["district"]=this.getElementValue(el,"district");
_273["region"]=this.getElementValue(el,"region");
var _274=this.selectSingleNode("icon",el);
if(_274){
_273["icon"]=this.parseIcon(_274,_273["id"],i);
}
var _275=this.selectSingleNode("info",el);
if(_275){
_273["infoHtml"]=this.parseInfo(_275);
}
var _276=new GSPointFeature(_273);
var _277=this.selectSingleNode("events",_275);
if(_277){
this.addFeatureEventListeners(_276,_277,this.getShowInfoFunction(_276));
}
this.output.push(_276);
}
};
GSDOMParser.prototype.parseIcon=function(el,_279,_27a){
var _27b=_browser.isSafari?"img":"image";
var _27c=this.selectSingleNode(_27b,el);
if(_27c==null){
return;
}
var _27d=this.getElementValue(_27c,"src");
var _27e=new GSDimension(this.getElementValueAsInt(_27c,"width"),this.getElementValueAsInt(_27c,"height"));
var _27f=this.selectSingleNode("printImage",el);
if(_27f!=null){
var _280=this.getElementValue(_27f,"src");
var _281=new GSDimension(this.getElementValueAsInt(_27f,"width"),this.getElementValueAsInt(_27f,"height"));
}
var _282=this.selectSingleNode("shadow",el);
if(_282!=null){
var _283=this.getElementValue(_282,"src");
var _284=new GSDimension(this.getElementValueAsInt(_282,"width"),this.getElementValueAsInt(_282,"height"));
}
var alt=this.getElementValue(_27c,"text");
var icon=new GSIcon();
icon.imageSrc=_27d;
icon.printSrc=_280;
icon.shadowSrc=_283;
icon.imageSize=_27e;
icon.printSize=_281;
icon.shadowSize=_284;
icon.alt=alt;
var _287=this.selectSingleNode("iconOffset",el);
if(_287){
var x=this.getElementValueAsInt(_287,"x");
var y=this.getElementValueAsInt(_287,"y");
icon.iconOffset=new GSPoint(x,y);
}
var _28a=this.selectSingleNode("iconInfoWindowOffset",el);
if(_28a){
var x=this.getElementValueAsInt(_28a,"x");
var y=this.getElementValueAsInt(_28a,"y");
icon.iconInfoWindowOffset=new GSPoint(x,y);
}
var _28b=this.selectSingleNode("imageMap",el);
if(_28b&&_browser.isGecko){
icon.imageMap=GSUtil.createImageMap("map_"+_279,"poly",_28b.firstChild.nodeValue.split(","),"#",this.getElementValue(_27c,"text"));
icon.image.setAttribute("usemap","map_"+_279);
}
return icon;
};
GSDOMParser.prototype.parseInfo=function(el){
var _28d=this.selectSingleNode("html",el);
if(_28d!=undefined){
var xml="";
if(_browser.isSafari){
xml=this.xmlText(_28d);
}else{
if(_browser.isIE){
xml=_28d.xml;
}else{
var _28f=new XMLSerializer();
xml=_28f.serializeToString(_28d);
}
}
xml=this.stripHtmlTags(xml);
return xml;
}else{
return undefined;
}
};
GSDOMParser.prototype.selectSingleNode=function(_290,el){
if(el!=null){
var _292=el.getElementsByTagName(_290);
return _292!=null?_292[0]:null;
}
return null;
};
GSDOMParser.prototype.hasChildNamed=function(name,el){
return this.selectSingleNode(name,el)!=null;
};
GSDOMParser.prototype.getElementValue=function(el,name){
var node=this.selectSingleNode(name,el);
if(node&&node.firstChild){
return node.firstChild.nodeValue;
}else{
return null;
}
};
GSDOMParser.prototype.getElementValueAsInt=function(el,name){
return parseInt(this.getElementValue(el,name));
};
GSDOMParser.prototype.getElementValueAsFloat=function(el,name){
return parseFloat(this.getElementValue(el,name));
};
GSDOMParser.prototype.getShowInfoFunction=function(_29c){
return function(e){
_29c.showInfoWindow();
_29c.map.featureClicked(_29c);
GSUtil.cancelEvent(e);
};
};
GSDOMParser.prototype.addFeatureEventListeners=function(_29e,_29f,func){
var _2a1=_29e.icon.image;
if(_29e.icon&&_29e.icon.imageMap){
_2a1=_29e.icon.htmlImageMap.firstChild;
}
if(_2a1!=undefined){
var _2a2=_29f.firstChild.nodeValue.split(",");
for(var i in _2a2){
if((typeof _2a2[i]).toLowerCase()=="function"){
continue;
}
switch(_2a2[i]){
case "click":
GSEventManager.addEventListener(_2a1,"click",func);
break;
case "mousedown":
GSEventManager.addEventListener(_2a1,"mousedown",func);
break;
case "mouseup":
GSEventManager.addEventListener(_2a1,"mouseup",func);
break;
case "mouseover":
GSEventManager.addEventListener(_2a1,"mouseover",func);
break;
case "mouseout":
GSEventManager.addEventListener(_2a1,"mouseout",func);
break;
}
}
}
};
var DOM_ELEMENT_NODE=1;
var DOM_ATTRIBUTE_NODE=2;
var DOM_TEXT_NODE=3;
GSDOMParser.prototype.xmlText=function(node){
var ret="";
if(node.nodeType==DOM_TEXT_NODE){
ret+=node.nodeValue;
}else{
if(node.nodeType==DOM_ELEMENT_NODE){
ret+="<"+node.nodeName;
for(var i=0;i<node.attributes.length;++i){
var a=node.attributes[i];
if(a&&a.nodeName&&a.nodeValue){
ret+=" "+a.nodeName;
ret+="=\""+a.nodeValue+"\"";
}
}
if(node.childNodes.length==0){
ret+="/>";
}else{
ret+=">";
for(var i=0;i<node.childNodes.length;++i){
ret+=arguments.callee(node.childNodes[i]);
}
ret+="</"+node.nodeName+">";
}
}
}
return ret;
};
GSDOMParser.prototype.stripHtmlTags=function(s){
return s.replace(/<html>|<\/html>/gi,"");
};
function GSIconFactory(){
}
GSIconFactory.cache={};
GSIconFactory.addIcon=function(name,icon){
this.cache[name]=icon;
};
GSIconFactory.removeIcon=function(name){
for(var i in this.cache){
if(i==name){
delete this.cache[i];
}
}
};
GSIconFactory.make=function(name){
if(this.cache[name]!=undefined){
return new GSIcon(this.cache[name]);
}
return null;
};
function GSLoader(){
this.data=[];
this.url;
this.req;
this.async=true;
this.aaTotalCount;
}
GSLoader.prototype.loaded=false;
GSLoader.prototype.onload=function(){
};
GSLoader.prototype.load=function(url,_2af){
GSAuthenticator.validateAuthentication();
_2af=_2af!=undefined?_2af:this.async;
if(url==undefined){
alert("Cannot load data");
}
this.url=url;
this.data.length=0;
var _2b0=this;
var _2b1={"method":"get","url":this.url,"async":_2af,"load":function(data){
_2b0.parseXML(data);
},"error":function(){
alert("There was a problem loading the data");
}};
this.req=new GSHttpRequest();
var _2b3=this.req.sendAndLoad(_2b1);
if(!_2af){
this.parseXML(_2b3);
}
};
GSLoader.prototype.unload=function(){
delete this.req._req.onreadystatechange;
this.req=null;
};
GSLoader.prototype.parseXML=function(_2b4){
this.loaded=true;
var _2b5=new GSDOMParser();
_2b5.output=this.data;
_2b5.parse(_2b4);
this.aaTotalCount=_2b5.aaTotalCount;
_2b5=null;
if(this.onload){
this.onload();
}
_2b4=null;
this.unload();
};
function GSRoute(){
this.points=[];
this.req;
this.async=true;
this.path=null;
this.instructions=null;
this.legDistances=null;
this.totalDistance=0;
}
GSRoute.prototype.loaded=false;
GSRoute.prototype.onload=function(){
};
GSRoute.prototype.unload=function(){
delete this.req._req.onreadystatechange;
this.req=null;
};
GSRoute.prototype.load=function(_2b6){
_2b6=_2b6!=undefined?_2b6:this.async;
var _2b7=this;
var _2b8={"method":"get","url":this.buildURL(),"async":_2b6,"load":function(data){
_2b7.parseXML(data);
},"error":function(){
alert("There was a problem retrieving the route instructions");
}};
this.req=new GSHttpRequest();
var _2ba=this.req.sendAndLoad(_2b8);
if(!_2b6){
this.parseXML(_2ba);
}
};
GSRoute.prototype.buildURL=function(){
var url=_globals.serviceName+"/route.xml?features=";
for(var i in this.points){
if((typeof this.points[i]).toLowerCase()=="function"){
continue;
}
if(i>0){
url+=",";
}
var _2bd=this.points[i].coordinate;
url+=_2bd.x+":"+_2bd.y+":"+encodeURIComponent(this.points[i].name);
}
url+=GSAuthenticator.getQueryParameters();
if(_globals.DEBUG){
_console.debug("route url: "+url);
}
return _globals.proxyURL+"?type=xml&path="+encodeURIComponent(url);
};
GSRoute.prototype.parseXML=function(_2be){
this.loaded=true;
this.legDistances=[];
var _2bf=_2be.getElementsByTagName("distance");
for(var i=0;i<_2bf.length;i++){
var _2c1=_2bf[i].firstChild.nodeValue;
this.legDistances.push(_2c1);
this.totalDistance+=parseFloat(_2c1);
}
this.totalDistance=GSUtil.roundNumber(this.totalDistance,2);
this.instructions=[];
var _2c2=_2be.getElementsByTagName("instruction");
for(var i=0;i<_2c2.length;i++){
this.instructions.push(_2c2[i].firstChild.nodeValue);
}
this.path=new GSRouteFeature(this.getPointCoordinates());
if(this.onload){
this.onload();
}
this.unload();
};
GSRoute.prototype.add=function(_2c3){
this.points.push(_2c3);
};
GSRoute.prototype.getPointCoordinates=function(){
var _2c4=[];
for(var i in this.points){
if((typeof this.points[i]).toLowerCase()=="function"){
continue;
}
_2c4.push(this.points[i].coordinate);
}
return _2c4;
};
function GSSearch(_2c6){
this.service=_globals.serverHostname+"/smartfind-client/search.php";
this.id=GSUtil.getCaseInsensitiveProperty(_2c6,"id");
if(GSUtil.getNode(this.id)){
this.bindForm(GSUtil.getNode(this.id));
}
this.mapRef=GSUtil.getCaseInsensitiveProperty(_2c6,"mapRef",undefined);
this.expressions=this.buildExpressions(GSUtil.getCaseInsensitiveProperty(_2c6,"expressions",undefined));
this.onsubmit=GSUtil.getCaseInsensitiveProperty(_2c6,"onSubmit",undefined);
this.onload=GSUtil.getCaseInsensitiveProperty(_2c6,"onload",undefined);
this.onclear=GSUtil.getCaseInsensitiveProperty(_2c6,"onclear",undefined);
function DefaultFeatureBuilder(){
DefaultFeatureBuilder.prototype.build=function(data){
var _2c8={"id":data.id,"name":data.name,"coordinate":new GSPoint(data.x,data.y),"infoHtml":data.name};
var _2c9=new GSPointFeature(_2c8);
_2c9.addEventHandler("click",function(e){
this.showInfoWindow();
GSUtil.cancelEvent(e);
});
return _2c9;
};
}
this.builder=new DefaultFeatureBuilder();
GSSearch.searchCache[this.id]=this;
}
GSSearch.searchCache={};
GSSearch.prototype.buildExpressions=function(data){
var _2cc=[];
for(var i in data){
if((typeof data[i]).toLowerCase()=="function"){
continue;
}
_2cc.push=data[i];
}
return _2cc;
};
GSSearch.prototype.bindForm=function(form){
this.form=form;
GSEventManager.bind(this.form,"submit",this,this._submit);
GSEventManager.bind(this.form,"reset",this,this._clear);
};
GSSearch.prototype.submit=function(){
this._submit();
};
GSSearch.prototype._submit=function(e){
if(e){
GSUtil.eventPreventDefault(e);
}
if(this.request){
var self=this;
self.timer=setInterval(function(){
self._submit();
clearInterval(self.timer);
},1000);
}
if(this.onsubmit){
this.onsubmit();
}
var _2d1="";
if(this.form){
_2d1=this.queryFromForm();
}else{
_2d1=this.queryFromExpressions();
}
this.request=new JSONscriptRequest(_2d1);
this.request.buildScriptTag();
this.request.addScriptTag();
};
GSSearch.prototype._onload=function(data){
if(this.isBound()){
var _2d3=this.map.createLayer(this.id);
_2d3.addFeatures(this.createFeatures(data));
}
if(this.onload){
this.onload(data);
}
this.request.removeScriptTag();
delete this.request;
};
GSSearch.prototype._onerror=function(_2d4){
if(this.onerror){
this.onerror(_2d4);
}else{
if(_globals.DEBUG){
alert(_2d4.message);
}
}
this.request.removeScriptTag();
delete this.request;
};
GSSearch.prototype.clear=function(){
this._clear();
};
GSSearch.prototype._clear=function(e){
if(this.isBound()){
this.map.removeLayer(this.id);
}
if(this.onclear){
this.onclear();
}
GSUtil.eventPreventDefault(e);
};
GSSearch.prototype.queryFromForm=function(){
var _2d6=[];
_2d6.push(this.service);
_2d6.push("?callback="+encodeURIComponent("GSSearch.searchCache[\""+this.id+"\"]._onload"));
for(var i=0;i<this.form.elements.length;i++){
var _2d8=this.form.elements[i];
var type=_2d8.tagName.toLowerCase();
switch(type){
case "input":
if(_2d8.type.toLowerCase()!="submit"&&_2d8.type.toLowerCase()!="reset"){
this.appendQueryParameter(_2d6,_2d8.name,_2d8.value,_2d8.operator);
}
break;
case "textarea":
this.appendQueryParameter(_2d6,_2d8.name,_2d8.value,_2d8.operator);
break;
case "select":
for(var j=0;j<_2d8.options.length;j++){
var _2db=_2d8.options[j];
if(_2db.selected){
this.appendQueryParameter(_2d6,_2d8.name,_2db.value);
}
}
break;
}
}
return _2d6.join("");
};
GSSearch.prototype.queryFromExpressions=function(){
var _2dc=[];
_2dc.push(this.service);
_2dc.push("?callback="+encodeURIComponent("GSSearch.searchCache[\""+this.id+"\"].onload"));
for(var i=0;i<this.expressions.length;i++){
var expr=this.expressions[i];
this.appendQueryParameter(_2dc,expr.name,expr.value,expr.operator);
}
return _2dc.join("");
};
GSSearch.prototype.appendQueryParameter=function(_2df,name,_2e1,_2e2){
var _2e3=_2e2?name+"_"+_2e2:name;
_2df.push("&"+_2e3+"="+encodeURIComponent(_2e1));
};
GSSearch.prototype.addExpression=function(name,_2e5,_2e6){
this.expressions.push={"name":name,"value":_2e5,"operator":_2e6};
};
GSSearch.prototype.removeExpression=function(name){
for(var i=0;i<this.expressions.length;i++){
var expr=this.expressions[i];
if(expr.name==name){
this.expressions.splice(i,1);
}
}
};
GSSearch.prototype.createFeatures=function(data){
var _2eb=[];
for(var i in data){
if((typeof data[i]).toLowerCase()=="function"){
continue;
}
var _2ed=this.builder.build(data[i]);
_2eb.push(_2ed);
}
return _2eb;
};
GSSearch.prototype.isBound=function(){
if(!this.map){
this.map=GSWidget.getWidgetById(this.mapRef);
}
return (this.map!=undefined);
};
GSWidget.registerWidget("gs:search",GSSearch);
function GSJsonServiceRequest(){
}
GSJsonServiceRequest.counter=0;
GSJsonServiceRequest.requests={};
GSJsonServiceRequest.send=function(url,_2ef,obj,_2f1){
var _2f2=new String(GSJsonServiceRequest.counter++);
_2ef["jsrId"]=_2f2;
var _2f3=document.createElement("script");
_2f3.type="text/javascript";
_2f3.src=url+"?"+GSUtil.joinAssociativeArray(_2ef,"&","=");
GSJsonServiceRequest.requests[_2f2]={scriptNode:_2f3,obj:obj,callback:_2f1};
GSJsonServiceRequest.getHeadNode().appendChild(_2f3);
};
GSJsonServiceRequest.handleResponse=function(_2f4,data){
var obj=GSJsonServiceRequest.requests[_2f4].obj;
var _2f7=GSJsonServiceRequest.requests[_2f4].callback;
_2f7.apply(obj,[data]);
setTimeout(function(){
var _2f8=GSJsonServiceRequest.requests[_2f4].scriptNode;
GSJsonServiceRequest.getHeadNode().removeChild(_2f8);
delete GSJsonServiceRequest.requests[_2f4];
},5000);
};
GSJsonServiceRequest.getHeadNode=function(_2f9){
return document.getElementsByTagName("head")[0];
};
function GSComplex(real,imag){
this.real=new Number(real);
this.imag=new Number(imag);
}
GSComplex.prototype.add=function(c){
return new GSComplex(this.real+c.real,this.imag+c.imag);
};
GSComplex.prototype.sub=function(c){
return new GSComplex(this.real-c.real,this.imag-c.imag);
};
GSComplex.prototype.mul=function(c){
return new GSComplex(this.real*c.real-this.imag*c.imag,this.real*c.imag+this.imag*c.real);
};
GSComplex.prototype.pow=function(_2ff){
if(_2ff==0){
return new GSComplex(1,0);
}
var c=this;
for(var i=1;i<_2ff;i++){
c=c.mul(this);
}
return c;
};
GSComplex.prototype.div=function(c){
var _303=c.real*c.real+c.imag*c.imag;
return this.mul(new GSComplex(c.real/_303,-c.imag/_303));
};
GSComplex.prototype.scale=function(_304){
return new GSComplex(this.real*_304,this.imag*_304);
};
GSComplex.prototype.equals=function(c){
return this.real.toPrecision(15)==c.real.toPrecision(15)&&this.imag.toPrecision(15)==c.imag.toPrecision(15);
};
GSComplex.prototype.toString=function(){
return this.real+"+"+this.imag+"i";
};
GSComplex.zero=new GSComplex(0,0);
function GSComponentManager(){
}
GSComponentManager.components={};
GSComponentManager.counter=0;
GSComponentManager.add=function(_306){
var id=GSComponentManager.counter++;
GSComponentManager.components[id]=_306;
_306.reference="GSComponentManager.components["+id+"]";
};
GSComponentManager.remove=function(_308){
for(var idx in GSComponentManager.components){
if(GSComponentManager.components[idx]==_308){
delete GSComponentManager.components[idx];
return;
}
}
throw new Error("Component not found: ["+_308+"]");
};
function GSGeodeticDatum(_30a,_30b,_30c,_30d,_30e){
this.semiMajor=_30a;
this.semiMinor=_30b;
this.flatteningReciprocal=_30c;
this.eccentricity1Squared=_30d;
this.eccentricity2Squared=_30e;
}
GSGeodeticDatum.nzgd2000=new GSGeodeticDatum(6378137,6356752.314,298.257223563,6.694380067*Math.pow(10,-3),6.73949682*Math.pow(10,-3));
GSGeodeticDatum.nzgd49=new GSGeodeticDatum(6378388,6356911.946,297,6.722670062*Math.pow(10,-3),6.768170238*Math.pow(10,-3));
function GSCoordinateUtil(){
}
GSCoordinateUtil.A=[null,0.6399175073,-0.1358797613,0.063294409,-0.02526853,0.0117879,-0.0055161,0.0026906,-0.001333,0.00067,-0.00034];
GSCoordinateUtil.B=[null,new GSComplex(0.7557853228,0),new GSComplex(0.249204646,0.003371507),new GSComplex(-0.001541739,0.04105856),new GSComplex(-0.10162907,0.01727609),new GSComplex(-0.26623489,-0.36249218),new GSComplex(-0.6870983,-1.1651967)];
GSCoordinateUtil.C=[null,new GSComplex(1.3231270439,0),new GSComplex(-0.577245789,-0.007809598),new GSComplex(0.508307513,-0.112208952),new GSComplex(-0.15094762,0.18200602),new GSComplex(1.01418179,1.64497696),new GSComplex(1.9660549,2.5127645)];
GSCoordinateUtil.D=[null,1.5627014243,0.5185406398,-0.03333098,-0.1052906,-0.0368594,0.007317,0.0122,0.00394,-0.0013];
GSCoordinateUtil.nzmgToWgs84=function(_30f){
var g49=GSCoordinateUtil.nzmgToGeodeticNzgd49(_30f);
var p49=GSCoordinateUtil.geodeticNzgd49ToCartesianNzgd49(g49);
var _312=GSCoordinateUtil.cartesianNzgd49ToCartesianNzgd2000(p49);
return GSCoordinateUtil.cartesianNzgd2000ToGeodeticNzgd2000(_312);
};
GSCoordinateUtil.wgs84ToNzmg=function(_313,_314){
var _315=GSCoordinateUtil.geodeticNzgd2000ToCartesianNzgd2000({latitude:_313,longitude:_314});
var p49=GSCoordinateUtil.cartesianNzgd2000ToCartesianNzgd49(_315);
var g49=GSCoordinateUtil.cartesianNzgd49ToGeodeticNzgd49(p49);
return GSCoordinateUtil.geodeticNzgd49ToNzmg(g49);
};
GSCoordinateUtil.decimalToSexagesimal=function(_318){
var sgn=_318>0?"":"-";
var d=Math.abs(_318);
var _31b=Math.floor(d);
d=(d-_31b)*60;
var _31c=Math.floor(d);
d=(d-_31c)*60;
var _31d=d.toFixed(3);
return sgn+_31b+" "+_31c+" "+_31d;
};
GSCoordinateUtil.normalizeAngle=function(_31e){
_31e=new String(_31e);
if(_31e.indexOf(".")==5&&_31e.substr(0,1)!="-"){
var _31f=3;
}else{
if(_31e.indexOf(".")==6&&_31e.substr(0,1)=="-"){
var _31f=4;
}else{
alert(_31e);
throw new Error("Illegal argument: angle must be in format DDDMM.d+ (with an optional minus prefix)");
return;
}
}
var _320=new Number(_31e.substr(0,_31f));
var _321=new Number(_31e.substr(_31f));
if(_31f==3){
return _320+_321/60;
}else{
return _320-_321/60;
}
};
GSCoordinateUtil.nzmgToGeodeticNzgd49=function(c){
var z=new GSComplex((c.y-6023150)/GSGeodeticDatum.nzgd49.semiMajor,(c.x-2510000)/GSGeodeticDatum.nzgd49.semiMajor);
var _324=[];
_324[0]=GSComplex.zero;
for(var n=1;n<=6;n++){
_324[0]=_324[0].add(GSCoordinateUtil.C[n].mul(z.pow(n)));
}
for(var i=0;i<=1;i++){
var a=GSComplex.zero;
var b=GSComplex.zero;
for(var n=2;n<=6;n++){
a=a.add(GSCoordinateUtil.B[n].mul(_324[i].pow(n)).scale(n-1));
}
for(var n=1;n<=6;n++){
b=b.add(GSCoordinateUtil.B[n].mul(_324[i].pow(n-1)).scale(n));
}
_324[i+1]=(z.add(a)).div(b);
}
var _329=0;
for(var n=1;n<=9;n++){
_329+=GSCoordinateUtil.D[n]*Math.pow(_324[2].real,n);
}
var _32a=_324[2].imag;
var _32b={};
_32b.latitude=-41+_329*100000/3600;
_32b.longitude=173+_32a*180/Math.PI;
return _32b;
};
GSCoordinateUtil.e0=2510000;
GSCoordinateUtil.n0=6023150;
GSCoordinateUtil.phi0=-41;
GSCoordinateUtil.lambda0=173;
GSCoordinateUtil.geodeticNzgd49ToNzmg=function(g49){
var phi=g49.latitude;
var _32e=g49.longitude;
var _32f=(phi-GSCoordinateUtil.phi0)*0.036;
var _330=0;
for(var n=1;n<=10;n++){
_330+=GSCoordinateUtil.A[n]*Math.pow(_32f,n);
}
deltaLambda=(_32e-GSCoordinateUtil.lambda0)*Math.PI/180;
var _332=new GSComplex(_330,deltaLambda);
var z=new GSComplex(0,0);
for(var n=1;n<=6;n++){
z=z.add(GSCoordinateUtil.B[n].mul(_332.pow(n)));
}
var x=z.real;
var y=z.imag;
var _336=y*GSGeodeticDatum.nzgd49.semiMajor+GSCoordinateUtil.e0;
var _337=x*GSGeodeticDatum.nzgd49.semiMajor+GSCoordinateUtil.n0;
return new GSPoint(_336,_337);
};
GSCoordinateUtil.geodeticNzgd49ToCartesianNzgd49=function(g49){
var _339=g49.latitude*Math.PI/180;
var _33a=g49.longitude*Math.PI/180;
var _33b=Math.pow(GSGeodeticDatum.nzgd49.semiMajor,2);
var _33c=Math.pow(GSGeodeticDatum.nzgd49.semiMinor,2);
var N=_33b/Math.sqrt(_33b*Math.pow(Math.cos(_339),2)+_33c*Math.pow(Math.sin(_339),2));
var _33e={};
_33e.x=N*Math.cos(_339)*Math.cos(_33a);
_33e.y=N*Math.cos(_339)*Math.sin(_33a);
_33e.z=_33c/_33b*N*Math.sin(_339);
return _33e;
};
GSCoordinateUtil.geodeticNzgd2000ToCartesianNzgd2000=function(_33f){
var _340=_33f.latitude*Math.PI/180;
var _341=_33f.longitude*Math.PI/180;
var _342=Math.pow(GSGeodeticDatum.nzgd2000.semiMajor,2);
var _343=Math.pow(GSGeodeticDatum.nzgd2000.semiMinor,2);
var N=_342/Math.sqrt(_342*Math.pow(Math.cos(_340),2)+_343*Math.pow(Math.sin(_340),2));
var _345={};
_345.x=N*Math.cos(_340)*Math.cos(_341);
_345.y=N*Math.cos(_340)*Math.sin(_341);
_345.z=_343/_342*N*Math.sin(_340);
return _345;
};
GSCoordinateUtil.cartesianNzgd49ToGeodeticNzgd49=function(p49){
var a=GSGeodeticDatum.nzgd49.semiMajor;
var b=GSGeodeticDatum.nzgd49.semiMinor;
var e1=GSGeodeticDatum.nzgd49.eccentricity1Squared;
var e2=GSGeodeticDatum.nzgd49.eccentricity2Squared;
var p=Math.sqrt(p49.x*p49.x+p49.y*p49.y);
var _34c=Math.atan(p49.z*a/(p*b));
var g49={};
g49.latitude=Math.atan((p49.z+e2*b*Math.pow(Math.sin(_34c),3))/(p-e1*a*Math.pow(Math.cos(_34c),3)))*180/Math.PI;
g49.longitude=Math.atan2(p49.y,p49.x)*180/Math.PI;
return g49;
};
GSCoordinateUtil.cartesianNzgd2000ToGeodeticNzgd2000=function(_34e){
var a=GSGeodeticDatum.nzgd2000.semiMajor;
var b=GSGeodeticDatum.nzgd2000.semiMinor;
var e1=GSGeodeticDatum.nzgd2000.eccentricity1Squared;
var e2=GSGeodeticDatum.nzgd2000.eccentricity2Squared;
var p=Math.sqrt(_34e.x*_34e.x+_34e.y*_34e.y);
var _354=Math.atan(_34e.z*a/(p*b));
var _355={};
_355.latitude=Math.atan((_34e.z+e2*b*Math.pow(Math.sin(_354),3))/(p-e1*a*Math.pow(Math.cos(_354),3)))*180/Math.PI;
_355.longitude=Math.atan2(_34e.y,_34e.x)*180/Math.PI;
return _355;
};
GSCoordinateUtil.cartesianNzgd49ToCartesianNzgd2000=function(c49){
var k=0.000004848137;
var t={x:59.47,y:-5.04,z:187.44};
var r={x:-0.47*k,y:0.1*k,z:-1.024*k};
var _35a=1+-4.5993*Math.pow(10,-6);
return {x:t.x+_35a*((1*c49.x)+(r.z*c49.y)+(-r.y*c49.z)),y:t.y+_35a*((-r.z*c49.x)+(1*c49.y)+(r.x*c49.z)),z:t.z+_35a*((r.y*c49.x)+(-r.x*c49.y)+(1*c49.z))};
};
GSCoordinateUtil.cartesianNzgd2000ToCartesianNzgd49=function(c49){
var k=0.000004848137;
var t={x:-59.47,y:5.04,z:-187.44};
var r={x:0.47*k,y:-0.1*k,z:1.024*k};
var _35f=1+4.5993*Math.pow(10,-6);
return {x:t.x+_35f*((1*c49.x)+(r.z*c49.y)+(-r.y*c49.z)),y:t.y+_35f*((-r.z*c49.x)+(1*c49.y)+(r.x*c49.z)),z:t.z+_35f*((r.y*c49.x)+(-r.x*c49.y)+(1*c49.z))};
};
GSHttpRequest=function(){
if(window.XMLHttpRequest){
this._req=new XMLHttpRequest();
}else{
try{
this._req=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
this._req=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
this._req=false;
}
}
}
};
GSHttpRequest.prototype={_req:null,init:function(_360){
this.method=_360["method"];
this.url=_360["url"];
this.mimetype=_360["mimetype"];
this.accept=_360["accept"];
this.content=_360["content"];
this.headers=_360["headers"];
this.contentType=_360["content-type"];
this.load=_360["load"];
this.postData=encodeURIComponent(_360["post-data"]);
this.error=_360["error"];
this.handle=_360["handle"];
this.async=_360["async"]!=undefined?_360["async"]:true;
this.username=_360["username"];
this.password=_360["password"];
this.postData=undefined;
var _361=this.buildParameterString(this.content);
if(_361&&this.method.toLowerCase()=="get"){
this.url+="?"+_361;
}else{
if(!this.postData&&this.method.toLowerCase()=="post"&&_361){
this.postData=_361;
}
}
if(this.async){
var self=this;
this._req.onreadystatechange=function(){
self.processResponse();
};
}
if(this.username&&this.password){
this._req.open(this.method,this.url,this.async,this.username,this.password);
}else{
this._req.open(this.method,this.url,this.async);
}
},send:function(){
if(this.accept){
this._req.setRequestHeader("Accept",this.accept);
}
if(this.method.toLowerCase()=="post"){
if(this.contentType){
this._req.setRequestHeader("Content-Type",this.contentType);
}else{
this._req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
}
if(this.headers){
for(var i in this.headers){
this.setRequestHeader(i,this.headers[i]);
}
}
try{
this._req.send(this.postData?this.postData:"");
if(!this.async){
return this.interpretData();
}
}
catch(e){
if(this.error){
this.error(e.message);
}else{
if(this.handle){
this.handle("error",e.message);
}
}
}
},sendAndLoad:function(_364){
this.init(_364);
return this.send();
},setRequestHeader:function(name,_366){
this._req.setRequestHeader(name,_366);
},getResponseHeader:function(name){
return this._req.getResponseHeader(name);
},processResponse:function(){
if(this._req.readyState==4){
var _368=this._req.status?this._req.status:200;
if(_368>=200&&_368<300){
var data=this.interpretData();
if(this.load){
this.load(data);
}else{
if(this.handle){
this.handle("load",data);
}
}
}else{
var data=this._req.responseText;
if(this.error){
this.error(data);
}else{
if(this.handle){
this.handle("error",data);
}
}
}
}
},interpretData:function(){
var data=undefined;
var _36b="text/plain";
var _36c=this._req.getResponseHeader("Content-Type");
if(_36c){
var _36d=_36c.indexOf(";")>0?_36c.indexOf(";"):_36c.length;
_36b=_36c.substr(0,_36d);
}
switch(_36b){
case "text/javascript":
data=eval("("+this._req.responseText+")");
break;
case "text/plain":
data=this._req.responseText;
break;
case "text/html":
data=this._req.responseText;
break;
case "text/xml":
case "application/xml":
data=this._req.responseXML;
break;
}
return data;
},getStatus:function(){
return Number(this._req.status);
},buildParameterString:function(_36e){
var _36f=undefined;
if(_36e){
var a=[];
for(var i in _36e){
var val=_36e[i]?_36e[i]:"";
a.push(i+"="+encodeURIComponent(val));
}
_36f=a.join("&");
}
return _36f;
}};

