// generic googlemap load script for pubished atwone web sites
// must be called by web site template
//
// may be replaced by specific script for tailored web site

// 01 SC 16-04-09  Changed conditional display of map scale


//<![CDATA[

// google map rendering variables ==============================================//
var geocoder = null;
var map = null;
var overlay =null;
var label = null;
var icons = new Array();
var icons = new Array();
var infoWindowJustClosed=false;
var _mPreferMetric = null;
icons["marker-ORANGE-BLANK.png"] = new GIcon(G_DEFAULT_ICON);
icons["marker-ORANGE-BLANK.png"].image = "/atwone/googlemap/marker-ORANGE-BLANK.png";

var miniIcons = new Array();
miniIcons["mini-ORANGE-BLANK.png"] = new GIcon();
miniIcons["mini-ORANGE-BLANK.png"].image = "/atwone/googlemap/mini-ORANGE-BLANK.png";
miniIcons["mini-ORANGE-BLANK.png"].shadow = "/atwone/googlemap/mm_20_shadow.png";
miniIcons["mini-ORANGE-BLANK.png"].iconSize = new GSize(12, 20);
miniIcons["mini-ORANGE-BLANK.png"].shadowSize = new GSize(22, 20);
miniIcons["mini-ORANGE-BLANK.png"].iconAnchor = new GPoint(6, 20);
miniIcons["mini-ORANGE-BLANK.png"].infoWindowAnchor = new GPoint(5, 1);
miniIcons["mini-ORANGE-BLANK.png"].infoShadowAnchor = new GPoint(8, 25);


var atwoneGoogleMapLat;
var atwoneGoogleMapLng;
var atwoneGoogleMapType;
var atwoneGoogleControlType;
var atwoneGoogleScaleType;
var atwoneGoogleOverview;
var atwoneGoogleZoom;
var atwoneGoogleMapId;
var atwoneGoogleMapServer;
var atwoneGoogleMapTypeSelected;
var atwoneGoogleMapShowSearch;
var atwoneGoogleMapKML;



cacheBuster =parseInt(Math.round(9999*Math.random()));

function showAddress(searchText) {
 geocoder.getLatLng(searchText, function(point) { if (!point) {
 alert('"'+searchText+'" not found\nPlease try again');
 } else {
 loco=point;
 map.setCenter(loco);
 var marker = new GMarker(point);
 map.addOverlay(marker);
 var htmlContent='"'+searchText+'" found<br>';
 marker.openInfoWindowHtml(htmlContent);
 }});
 }

function printMap() { 
        if (document.getElementById != null) { 
                var html = '<HTML>\n<HEAD>\n'; 
                if (document.getElementsByTagName != null) 
                { 
                        var headTags = document.getElementsByTagName("head"); 
                        if (headTags.length > 0) 
                                html += headTags[0].innerHTML; 
                } 
                html += '\n</HE>\n[an error occurred while processing this directive]\n'; 

                var printReadyElem = document.getElementById("map"); 

                if (printReadyElem != null) { 
                                html += printReadyElem.innerHTML; 
                } else { 
                        alert("Could not find the printReady function"); 
                        return; 
                } 
                html += '\n</BO>\n</HT>'; 
                var printWin = window.open("","printMap", "width=596,height=360" ); 
                printWin.document.open(); 
                printWin.document.write(html); 
                printWin.document.close(); 
                printWin.print(); 
}
} 


function get_icon(iconChoice) {
if ((typeof(iconChoice)=="undefined") || (iconChoice==null) || (iconChoice=='')) {
    iconChoice = "marker-ORANGE-BLANK.png";
  }

if (iconChoice.substr(0,4)=='mini') {
  if (!miniIcons[iconChoice]) {
       miniIcons[iconChoice] = new GIcon(miniIcons["mini-ORANGE-BLANK.png"]);
       miniIcons[iconChoice].image = "/atwone/googlemap/"+iconChoice;
     }
     return miniIcons[iconChoice];
} else {
   if (!icons[iconChoice]) {
      icons[iconChoice] = new GIcon(icons["marker-ORANGE-BLANK.png"]);
      icons[iconChoice].image = "/atwone/googlemap/"+iconChoice;
    }
    return icons[iconChoice];
  }
}


function atwoneLoadGoogleMap() {

var displayedPoints;
document.getElementById('atwoneGoogleMapLeftMenu').innerHTML='';
document.getElementById('atwoneGoogleMapTopMenu').innerHTML='';
document.getElementById('atwoneGoogleMapRightMenu').innerHTML='';
document.getElementById('atwoneGoogleMapBottomMenu').innerHTML='';


if (atwoneGoogleMapShowSearch=='Y') {
document.getElementById('atwoneGoogleMapTopMenu').innerHTML='<form name="atwoneGoogleMapForm" style="padding:0px;margin:0px;" onsubmit="showAddress(document.atwoneGoogleMapForm.q.value);return false;"><input type="text" name="q"> <input type="button" value="search map" onclick="showAddress(document.atwoneGoogleMapForm.q.value)"></form>'
}

if (atwoneGoogleMapType=='MAP') {
map = new GMap2(document.getElementById("map"),{mapTypes:[G_NORMAL_MAP]});
} else if (atwoneGoogleMapType=='SATELLITE') {
map = new GMap2(document.getElementById("map"),{mapTypes:[G_SATELLITE_MAP]});
} else if (atwoneGoogleMapType=='HYBRID') {
map = new GMap2(document.getElementById("map"),{mapTypes:[G_HYBRID_MAP]});
} else {
map = new GMap2(document.getElementById("map"),{mapTypes:[G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP]});
}
map.enableScrollWheelZoom();
map.enableDoubleClickZoom();
map.addControl(new GMapTypeControl());
pt=new GLatLng(atwoneGoogleMapLat,atwoneGoogleMapLng); 

// setup controls
if (atwoneGoogleControlType=='LARGE') {
map.addControl(new GLargeMapControl());
} else if (atwoneGoogleControlType=='SMALL') {
map.addControl(new GSmallMapControl());
} else if (atwoneGoogleControlType=='ZOOM') {
map.addControl(new GSmallZoomControl());
}

// scale control
// this segment of code commented out Dec 6 2007
// Google mad a change to API that caused this segement to
// crash maps .... means user cannot define scale !
// D Tehan 
//if (atwoneGoogleScaleType=='METRIC') {
//_mPreferMetric=true; 
//<<01>> start
if (atwoneGoogleScaleType!='NONE') {
	var scale = new GScaleControl(); 
	map.addControl(scale); 
}
//<<01>> end
//scale.fpsLbl.style.visibility="hidden"; 
//scale.fpsBar.style.visibility="hidden"; 
//} else if (atwoneGoogleScaleType=='IMPERIAL') {
//_mPreferMetric=false; 
//var scale = new GScaleControl(); 
//map.addControl(scale); 
//scale.metricLbl.style.visibility="hidden"; 
//scale.metricBar.style.visibility="hidden"; 
//} else if (atwoneGoogleScaleType=='BOTH') {
//_mPreferMetric=true; 
//map.addControl(new GScaleControl()); 
//}


// overview control
if (atwoneGoogleOverview=='Y') {
map.addControl(new GOverviewMapControl());
}

var mapTypes = map.getMapTypes();
//map.setMapType(mapTypes[atwoneGoogleMapTypeSelected]);
map.setCenter(pt,parseInt(atwoneGoogleZoom),mapTypes[atwoneGoogleMapTypeSelected]);

// load and render KML file if exists

if (atwoneGoogleMapKML!='') {
var geoXml = new GGeoXml(atwoneGoogleMapKML);
    map.addOverlay(geoXml);
}

// load and render global map markers
GDownloadUrl(atwoneGoogleMapServer+"/atwone/googlemap_markers.xml?"+cacheBuster, function(data, responseCode) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
if (markers[i].getAttribute("epoints")!='') {
addPolygon(markers[i].getAttribute("epoints"),markers[i].getAttribute("elevels"),markers[i].getAttribute("width"),markers[i].getAttribute("colour"),markers[i].getAttribute("zoom"), markers[i].getAttribute("fill"));
}
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
if (markers[i].getAttribute("text")!='') {
// display text marker
  label = new BpLabel(point,markers[i].getAttribute("text"),'googleMapTitle');
  label.setUserData({stuff: markers[i].getAttribute("zoomto")+'|'+markers[i].getAttribute("html")});
  map.addOverlay(label);
  var target = label.getEventTarget();
  GEvent.bindDom(target,'click',label,function(){
  if (this.getUserData().stuff.split('|')[0]!='') {
// zoom to a new map
   zoomToResource(this.getUserData().stuff.split('|')[0]);
 } else {
// show bubble
  this.openInfoWindowHtml(this.getUserData().stuff.split('|')[1]);
 }
  });
} else {
// dislay an icon
map.addOverlay(new GMarker(point, {title:markers[i].getAttribute("title"),icon:get_icon(markers[i].getAttribute("icon"))}));
}



if (markers[i].getAttribute("menu")!="") {
populateMenus(markers[i].getAttribute("menu"),markers[i].getAttribute("lat"),markers[i].getAttribute("lng"),markers[i].getAttribute("zoomto"),markers[i].getAttribute("title"),markers[i].getAttribute("icon"));
}
}});

// load and render local map markers
GDownloadUrl(atwoneGoogleMapServer+"/atwone/googlemap_markers_"+atwoneGoogleMapId+".xml?"+cacheBuster, function(data, responseCode) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
if (markers[i].getAttribute("epoints")!='') {
addPolygon(markers[i].getAttribute("epoints"),markers[i].getAttribute("elevels"),markers[i].getAttribute("width"),markers[i].getAttribute("colour"),markers[i].getAttribute("zoom"), markers[i].getAttribute("fill"));
}
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
if (markers[i].getAttribute("text")!='') {
// display text marker
   label = new BpLabel(point,markers[i].getAttribute("text"),'googleMapTitle');
   label.setUserData({stuff: markers[i].getAttribute("zoomto")+'|'+markers[i].getAttribute("html")});
  map.addOverlay(label);
  var target = label.getEventTarget();
  GEvent.bindDom(target,'click',label,function(){
  if (this.getUserData().stuff.split('|')[0]!='') {
// zoom to a new map
   zoomToResource(this.getUserData().stuff.split('|')[0]);
 } else {
// show bubble
  this.openInfoWindowHtml(this.getUserData().stuff.split('|')[1]);
 }
  });
} else {
// dislay an icon
map.addOverlay(new GMarker(point, {title:markers[i].getAttribute("title"),icon:get_icon(markers[i].getAttribute("icon"))}));
}

if (markers[i].getAttribute("menu")!="") {
populateMenus(markers[i].getAttribute("menu"),markers[i].getAttribute("lat"),markers[i].getAttribute("lng"),markers[i].getAttribute("zoomto"),markers[i].getAttribute("title"),markers[i].getAttribute("icon"));
}
}});


geocoder = new GClientGeocoder();

GEvent.addListener(map, "infowindowclose", function(overlay, point) {infoWindowJustClosed=true;});
GEvent.addListener(map, "click", function(overlay, point) {

if (infoWindowJustClosed) {
// stops bug of info window re-opening after closing !
infoWindowJustClosed=false;
} else {
// local markers
GDownloadUrl(atwoneGoogleMapServer+"/atwone/googlemap_markers_"+atwoneGoogleMapId+".xml?"+cacheBuster, function(data, responseCode) {
markerBuild(overlay,data);
});

// global markers
GDownloadUrl(atwoneGoogleMapServer+"/atwone/googlemap_markers.xml?"+cacheBuster, function(data, responseCode) {
markerBuild(overlay,data);
});

}

});
} 



function populateMenus(menu,lat,lng,zoomto,title,icon) {
switch (menu) {
case "LEFT" :
if (zoomto=='') {
document.getElementById('atwoneGoogleMapLeftMenu').innerHTML+='<a href="javascript:gotoPoint('+lat+','+lng+')"><img src="/atwone/googlemap/'+icon+'" align="middle" border="0"> '+title.replace(' ','&nbsp;')+'</a><br>';
} else {
document.getElementById('atwoneGoogleMapLeftMenu').innerHTML+='<a href="javascript:zoomToResource(\''+zoomto+'\')"><img src="/atwone/googlemap/'+icon+'" align="middle" border="0"> '+title.replace(' ','&nbsp;')+'</a><br>';
}
break;
case "TOP" :
if (zoomto=='') {
document.getElementById('atwoneGoogleMapTopMenu').innerHTML+='<a href="javascript:gotoPoint('+lat+','+lng+')"><img src="/atwone/googlemap/'+icon+'" align="middle" border="0"> '+title.replace(' ','&nbsp;')+'</a><br>';
} else {
document.getElementById('atwoneGoogleMapTopMenu').innerHTML+='<a href="javascript:zoomToResource(\''+zoomto+'\')"><img src="/atwone/googlemap/'+icon+'" align="middle" border="0"> '+title.replace(' ','&nbsp;')+'</a><br>';
}
break;
case "RIGHT" :
if (zoomto=='') {
document.getElementById('atwoneGoogleMapRightMenu').innerHTML+='<a href="javascript:gotoPoint('+lat+','+lng+')"><img src="/atwone/googlemap/'+icon+'" align="middle" border="0"> '+title.replace(' ','&nbsp;')+'</a><br>';
} else {
document.getElementById('atwoneGoogleMapRightMenu').innerHTML+='<a href="javascript:zoomToResource(\''+zoomto+'\')"><img src="/atwone/googlemap/'+icon+'" align="middle" border="0"> '+title.replace(' ','&nbsp;')+'</a><br>';
}
break;
case "BOTTOM" :
if (zoomto=='') {
document.getElementById('atwoneGoogleMapBottomMenu').innerHTML+='<a href="javascript:gotoPoint('+lat+','+lng+')"><img src="/atwone/googlemap/'+icon+'" align="middle" border="0"> '+title.replace(' ','&nbsp;')+'</a><br>';
} else {
document.getElementById('atwoneGoogleMapBottomMenu').innerHTML+='<a href="javascript:zoomToResource(\''+zoomto+'\')"><img src="/atwone/googlemap/'+icon+'" align="middle" border="0"> '+title.replace(' ','&nbsp;')+'</a><br>';
}
break;
}
}


function gotoPoint(lat,lng) {
if(typeof(localGotoPoint) == 'function') {
localGotoPoint(lat,lng);
} else {
tmp=map.getZoom()+3;
if (tmp>15) tmp=15;
map.setCenter(new GLatLng(lat, lng),tmp);
}
}

function markerBuild(overlay,data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
if (overlay.getPoint()=='('+markers[i].getAttribute("lat")+', '+markers[i].getAttribute("lng")+')') {
 if (markers[i].getAttribute("zoomto")!='') {
// zoom to a new map
zoomToResource(markers[i].getAttribute("zoomto"));
} else {
// display bubble
var marker = new GMarker(overlay.getPoint(),{title:markers[i].getAttribute("title"),icon:get_icon(markers[i].getAttribute("icon"))});
map.addOverlay(marker);
marker.openInfoWindowHtml("<html><head><style>td,p,li {font-family:arial;font-size:10px;}</style></head><body>"+markers[i].getAttribute("html")+"</body></html>");
}
}
}
}


function zoomToResource(reference) {

// branch to local version of function if it exists;
if(typeof(localZoomToResource) == 'function') {
localZoomToResource(reference);
} else {

// if reference has commas its a MAP otherwise its a site URL
if (reference.indexOf(',')!=-1) {
GUnload();
atwoneGoogleMapLat=reference.split(',')[0];
atwoneGoogleMapLng=reference.split(',')[1];
atwoneGoogleZoom=reference.split(',')[2];
atwoneGoogleMapType=reference.split(',')[3];
atwoneGoogleControlType=reference.split(',')[4];
atwoneGoogleScaleType=reference.split(',')[5];
atwoneGoogleOverview=reference.split(',')[6];
atwoneGoogleMapId=reference.split(',')[7];
atwoneGoogleMapTypeSelected=reference.split(',')[8];
atwoneGoogleMapKML=reference.split(',')[9];
atwoneLoadGoogleMap();
} else {
// change to new resource
switch (reference.substr(0,1)) {
case "H": //  a page;
document.location='/'+reference.substr(1,999)+'.html'
break;
case "M": //  a multimedia;
var mmWin=window.open('/'+reference.substr(1,999));
break;
case "P": //  a picture;
var picWin=window.open('/atpicture.cgi?'+reference.substr(1,999),'','scrollbars=yes,resizable=yes,toolbar=no,status=no')
break;
case "U": //  a URL;
if (reference.substr(1,4).toLowerCase()=='http') {
//open new window
var urlWin=window.open(reference.substr(1,999));
} else {
document.location='/'+ reference.substr(1,999);
}
break;
case "F": //  a form;
document.location='/'+reference.substr(1,999)+'.html'
break;
case "Z": //  a forum;
document.location='/atforum.cgi?ID='+reference.substr(1,999);
break;
case "L": //  an elobby;
document.location='/atlobby.cgi?ID='+reference.substr(1,999);
break;
case "V": //  a video;
var videoWin=window.open('/atwone/flv/'+reference.substr(1,999)+'.html','','scrollbars=yes,resizable=yes,toolbar=no,status=no')
break;
case "b": //  an audio;
var videoWin=window.open('/atwone/pod/'+reference.substr(1,999)+'.html','','scrollbars=yes,resizable=yes,toolbar=no,status=no')
break;
case "w": //  a widget;
var videoWin=window.open('/atwone/widget/'+reference.substr(1,999)+'.html','','scrollbars=yes,resizable=yes,toolbar=no,status=no')
break;
}
}
}
}

function addPolygon(encoded_points,encoded_levels,width,colour,zoom,fillType){
var encodedPoints = encoded_points;
var encodedLevels = encoded_levels;
var numlev = 18;

switch (fillType) {
case "SOLID": // polygon with solid fill;
encodedPolygon = new GPolygon.fromEncoded({
polylines: [{
points: encodedPoints,
levels: encodedLevels,
color: colour,
numLevels: numlev,
zoomFactor: zoom}],
fill: true,
color: colour,
opacity: 1.0,
outline: true
});
break;

case "TRANSLUCENT": // polygon with translucent fill;
encodedPolygon = new GPolygon.fromEncoded({
polylines: [{
points: encodedPoints,
levels: encodedLevels,
color: colour,
numLevels: numlev,
zoomFactor: zoom}],
fill: true,
color: colour,
opacity: 0.5,
outline: true
});
break;

default: // polygon with no fill;
encodedPolygon = new GPolygon.fromEncoded({
polylines: [{
points: encodedPoints,
levels: encodedLevels,
color: colour,
weight: width,
opacity: 0.9,
numLevels: numlev,
zoomFactor: zoom}],
color: colour,
outline: true
});
break;
}
map.addOverlay(encodedPolygon);

}


function getActiveMapType() {
 var mapTypes = map.getMapTypes();
 var actMap = map.getCurrentMapType();
 for (i=0;i<mapTypes.length;i++) {
 if (actMap==mapTypes[i]) return(i)
 }
}


 //]]>

// following code from www.gmaptools.com to allow implement of text labels on maps

// BpBrowser 0.11 Copyright 2006 BitPerfect http://www.gmaptools.com - All rights reserved.
function BpBrowser(){var a=['opera','msie','safari','firefox','mozilla'];var b=['x11;','macintosh','windows'];function h(c){this.OPERA=0;this.MSIE=1;this.SAFARI=2;this.FIREFOX=3;this.MOZILLA=4;this.X11=0;this.MAC=1;this.WINDOWS=2;this.type=-1;this.os=-1;this.version=0;var d=c.toLowerCase();for(var i=0;i<a.length;i++){var e=a[i];if(d.indexOf(e)!=-1){this.type=i;var f=new RegExp(e+'[ /]?([0-9]+)');if(f.exec(d)){this.version=parseFloat(RegExp.$1)}break;}}for(var i=0;i<b.length;i++){var g=b[i];if(d.indexOf(g)!=-1){this.os=i;break}}}window.BpBrowser=new h(navigator.userAgent);}BpBrowser();if(typeof(GControl)!='undefined'){function BpLogo(){GControl.apply(this,arguments);}BpLogo.prototype=new GControl();BpLogo.prototype.initialize=function(bpMap){var bpContainer=document.createElement("div");var bpImg=document.createElement('img');var bpSrc='http://www.gmaptools.com/images/bplogo.png';if(BpBrowser.type==BpBrowser.MSIE){bpImg.setAttribute('src','http://www.gmaptools.com/images/clear.gif');bpImg.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=crop; src="+bpSrc+")";}else{bpImg.setAttribute('src',bpSrc);}bpImg.setAttribute('border','0');bpImg.onclick=function(){window.parent.location.href='http://www.gmaptools.com/maplink';};try{bpImg.style.cursor='pointer';}catch(e){bpImg.style.cursor='hand';}bpContainer.appendChild(bpImg);bpMap.getContainer().appendChild(bpContainer);return bpContainer;};BpLogo.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_BOTTOM_LEFT,new GSize(4,35));};}// BpLabel 0.14 Copyright 2006 BitPerfect http://www.gmaptools.com - All rights reserved.
function BpLabel(){var _a=0;function ba(_b,_c,_d,_f,_g){this._b=_b;this._c=_c;this._d=_d||'';this._f=_f||'center';this._g=_g||false;this._h=85;this._i=G_MAP_FLOAT_SHADOW_PANE;this._a=++_a;this.isBpLabel=true;}ba.prototype=new GOverlay();var _j=ba.prototype;var _k=null;var _l=false;_j.initialize=function(_m,_g){this._m=_m;if(!_l)_l=GEvent.addListener(_m,'infowindowclose',function(){_k=null;});var _n=document.createElement('div');_n.innerHTML='<div class=\''+this._d+'\'>'+this._c+'</div>';_n.style.position='absolute';if(!this._d){var _o=_n.firstChild.style;_o.border='1px solid black';_o.backgroundColor='white';_o.filter='alpha(opacity:'+this._h+')';_o.KHTMLOpacity=this._h/100;_o.MozOpacity=this._h/100;_o.opacity=this._h/100;_o.fontWeight='bold';_o.whiteSpace='nowrap';_o.paddingRight='3px';_o.paddingLeft='3px';}if(_g||this._g)_n.style.display='none';this._n=_n;this.redraw(true);_m.getPane(this._i).appendChild(_n);this._p();if(this._q)this.setCursor(this._q);if(typeof(this._h)!='undefined')this.setOpacity(this._h);if(this.getHoverLine())this.setHoverLine(this.getHoverLine());this.setZIndex();return _n;};_j.getId=function(){return this._a;};_j._r=function(){var _m=this._m;var _s=_m.getCenter();var _t=_m.getBounds().toSpan();return new GLatLng(_s.lat()-_t.lat(),_s.lng());};_j._p=function(){var _u;var _v=!this.isVisible();if(_v){_u=this.getPoint();var offMapPoint=this._r();this.setPoint(offMapPoint);this.display(true);}this._w=this._x(this._n.firstChild);this._y=this._z(this._n.firstChild);if(_v){this.display(false);this.setPoint(_u);}};_j.getWidth=function(){return this._w;};_j.getHeight=function(){return this._y;};_j.getHtml=function(){return this._c;};_j.setHtml=function(_c){this._c=_c;if(!this._m)return;this._n.firstChild.innerHTML=this._c;if(this.isVisible()){this.hide();this.show();}this._p();this.redraw(true);};_j.getPoint=function(){return this._b;};_j.setPoint=function(_b){this._b=_b;if(typeof(this._aa)=='undefined')this.setZIndex();this.redraw(true);};_j.getOpacity=function(){return this._h;};_j.setOpacity=function(_h){if(_h<0)_h=0;if(_h>100)_h=100;this._h=_h;var _n=this._n;if(_n){var _ab=_h/100;if(typeof(_n.style.filter)=='string')_n.style.filter='alpha(opacity:'+_h+')';if(typeof(_n.style.KHTMLOpacity)=='string')_n.style.KHTMLOpacity=_ab;if(typeof(_n.style.MozOpacity)=='string')_n.style.MozOpacity=_ab;if(typeof(_n.style.opacity)=='string')_n.style.opacity=_ab;}};_j.getClassName=function(){return this._d;};_j.setClassName=function(_d){this._d=_d;this._n.firstChild.className=this._d;this._p();this.redraw(true);};_j.getUserData=function(){return this._ac;};_j.setUserData=function(_ad){this._ac=_ad;};_j.getPane=function(){return this._i;};_j.setPane=function(_i){this._i=_i;};_j.getCursor=function(){return this._q;};_j.setCursor=function(_q){this._q=_q;var _n=this._n;if(_n){try{_n.style.cursor=_q;}catch(e){_n.style.cursor=(_q=='pointer'?'hand':'pointer');}}};_j.getHoverLine=function(){return this._ae;};_j.setHoverLine=function(_af){this._ae=_af;if(!this._m)return;if(this._ae&&!this._ag){this._ah=GEvent.bindDom(this.getEventTarget(),'mouseover',this,this._ai);this._aj=GEvent.bindDom(this.getEventTarget(),'mouseout',this,this._ak);}else if(this._ag){GEvent.removeListener(this._ah);delete this._ah;GEvent.removeListener(this._aj);delete this._aj;}};_j._ai=function(){if(this._ae)this._m.addOverlay(this._ae);};_j._ak=function(){if(this._ae)this._m.removeOverlay(this._ae);};ba.getInfoWindowOpener=function(){return _k;};ba._al=function(_am){_k=_am;};var _an=['openInfoWindow','openInfoWindowHtml','openInfoWindowTabs','openInfoWindowTabsHtml','openInfoWindowXslt','showMapBlowup'];for(var i=0;i<_an.length;i++){_j[_an[i]]=function(){var _m=this._m;if(!_m)return;var _ao=new Array(this._ap());for(var i=0;i<arguments.length;i++)_ao.push(arguments[i]);_m.closeInfoWindow();ba._al(this);_m[_an[i]].apply(_m,_ao);};}_j._aq=function(){var _b=new GPoint(0,0);var _w=this.getWidth();var _y=this.getHeight();switch(this.getAnchor()){case 'n':_b.x-=Math.floor(_w/2);break;case 'ne':_b.x-=_w;break;case 'e':_b.x-=_w;_b.y-=Math.floor(_y/2);break;case 'se':_b.x-=_w;_b.y-=_y;break;case 's':_b.x-=Math.floor(_w/2);_b.y-=_y;break;case 'sw':_b.y-=_y;break;case 'w':_b.y-=Math.floor(_y/2);break;case 'center':_b.x-=Math.floor(_w/2);_b.y-=Math.floor(_y/2);}return _b;};_j.getInfoWindowOffset=function(){return this._ar;};_j.setInfoWindowOffset=function(_b){this._ar=_b;};_j._ap=function(){var _as=parseInt(this._n.style.left);var _at=parseInt(this._n.style.top);_as+=Math.round(this.getWidth()/2);_at+=Math.round(this.getHeight()/2);var _b=new GPoint(_as,_at);if(this._ar){_b.x+=this._ar.x;_b.y+=this._ar.y;}return this._m.fromDivPixelToLatLng(_b);};_j.getAnchor=function(){return this._f;};_j.setAnchor=function(_f){if(new RegExp('^(n|s)?(e|w)?$','i').test(_f)&&_f!='')this._f=_f;else this._f='center';this.redraw(true);};_j.getEventTarget=function(){if(!this._m)return;return this._n.firstChild;};_j.getMap=function(){return this._m;};_j.isMapped=function(){return(this._n&&this.getMap()&&this._n.parentNode===this.getMap().getPane(this.getPane()))?true:false;};_j.isVisible=function(){if(!this.isMapped())return false;return this._n.style.display!='none';};_j.show=function(){this.display(true);};_j.hide=function(){this.display(false);};_j.display=function(_au){if(!this._m)return;if(_au){this._n.style.display='';}else{this._n.style.display='none';}};_j.getZIndex=function(_av){if(typeof(this._aa)!='undefined')return this._aa;if(arguments.length==0)_av=this.getPoint().lat();return GOverlay.getZIndex(_av);};_j.setZIndex=function(_aw){if(arguments.length==0){this.setZIndex(this.getZIndex());delete this._aa;}else{this._aa=_aw;this.getEventTarget().parentNode.style.zIndex=_aw;}};_j.redraw=function(_ax){if(this.isMapped()){var _u=this._m.fromLatLngToDivPixel(this._b);var offset=this._aq();_u.x+=offset.x;_u.y+=offset.y;this._n.style.top=_u.y+'px';this._n.style.left=_u.x+'px';}else{var px=this.getMap().fromLatLngToDivPixel(this._r());this._n.style.top=px.y+'px';this._n.style.left=px.x+'px';this.getMap().getPane(this.getPane()).appendChild(this._n);var _ay=this._n.style.display;this._n.style.display='';this._p();this.getMap().getPane(this.getPane()).removeChild(this._n);this._n.style.display=_ay;}};_j.copy=function(){var _az=new ba(this._b,this._c,this._d,this._f);_az.setOpacity(this.getOpacity());_az.setHoverLine(this.getHoverLine());_az.setZIndex(this.getZIndex());_az.setPane(this.getPane());_az.setUserData(this.getUserData());_az.setCursor(this.getCursor());_az.setInfoWindowOffset(this.getInfoWindowOffset());return _az;};_j.remove=function(){this._n.parentNode.removeChild(this._n);delete this._m;};_j._z=function(_n){if(typeof(_n.offsetHeight)!='undefined')return _n.offsetHeight;else if(typeof(_n.style.pixelHeight)!='undefined')return _n.style.pixelHeight;return 0;};_j._x=function(_n){if(typeof(_n.offsetWidth)!='undefined')return _n.offsetWidth;else if(typeof(_n.style.pixelWidth)!='undefined')return _n.style.pixelWidth;return 0;};window.BpLabel=ba;}BpLabel();
