var _tooltip=document.createElement("div");
var overviewMap=new GOverviewMapControl(new GSize(150,150));
var largeMapControl=new GLargeMapControl();
var scaleControl=new GScaleControl();
var mapTypeControl=new GMapTypeControl();
var textualZoomControl;
function DynamicMap(_1,_2,_3,_4,_5){
this._map=new GMap2(_1);
this._map.addControl(largeMapControl);
this._map.addControl(scaleControl);
this._map.addControl(overviewMap);
textualZoomControl=new TextualZoomControl(_2,_3,_4,_5);
this._map.addControl(textualZoomControl);
this._map.addControl(mapTypeControl);
this._map.enableDoubleClickZoom();
this._isToBeVisibleFn=null;
this.setCentre(0,0,0);
this._markerMngr=new MarkerManager(this._map);
this._dataFeeds=new Array();
this._overlays=new Array();
this._map.getPane(G_MAP_FLOAT_PANE).appendChild(_tooltip);
}
DynamicMap.prototype._showTooltip=function(_6){
_tooltip.innerHTML=_6.tooltip;
var _7=this._map.getCurrentMapType().getProjection().fromLatLngToPixel(this._map.fromDivPixelToLatLng(new GPoint(0,0),true),this._map.getZoom());
var _8=this._map.getCurrentMapType().getProjection().fromLatLngToPixel(_6.getPoint(),this._map.getZoom());
var _9=_6.getIcon().iconAnchor;
var _a=_6.getIcon().iconSize.width;
var _b=_tooltip.clientHeight;
var _c=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(_8.x-_7.x-_9.x+_a,_8.y-_7.y-_9.y-_b));
_c.apply(_tooltip);
_tooltip.style.visibility="visible";
};
DynamicMap.isSupported=function(){
return GBrowserIsCompatible();
};
DynamicMap.prototype.addMapEventListener=function(_d,_e){
GEvent.addListener(this._map,_d,_e);
};
DynamicMap.prototype.setCentre=function(_f,lng,_11){
this._map.setCenter(new GLatLng(_f,lng),_11);
};
DynamicMap.prototype.addMarkerFeed=function(_12){
this._dataFeeds.push(new MarkerDataFeed(_12.name,_12.urlFn,this));
};
DynamicMap.prototype.addPolylineFeed=function(_13){
this._dataFeeds.push(new PolylineFeed(_13.name,_13.urlFn,this));
};
DynamicMap.prototype.removeFeed=function(_14){
var _15=-1;
for(var idx=0;idx<this._dataFeeds.length;idx++){
var _17=this._dataFeeds[idx];
if(_17._name==_14){
_15=idx;
break;
}
}
if(_15!=-1){
this._dataFeeds.splice(_15,1);
}
};
DynamicMap.prototype.setIsToBeVisibleFn=function(fn){
this._isToBeVisibleFn=fn;
};
DynamicMap.prototype.refresh=function(_19){
this._map.closeInfoWindow();
if(_19){
this._removeAllOverlayss();
for(var idx=0;idx<this._dataFeeds.length;idx++){
var _1b=this._dataFeeds[idx];
_1b._refresh();
}
}else{
for(var idx=0;idx<this._overlays.length;idx++){
var _1c=this._overlays[idx];
this._evaluateForDisplay(_1c);
}
}
};
DynamicMap.prototype.focusOnMarker=function(id,_1e){
for(var idx=0;idx<this._overlays.length;idx++){
var _20=this._overlays[idx];
if((_20.id==id)&&(_20.type==_1e)){
this._makeOverlayVisible(_20,true);
_20.invokeClick();
break;
}
}
};
DynamicMap.prototype._evaluateForDisplay=function(_21){
var _22=true;
if(this._isToBeVisibleFn!=null){
_22=this._isToBeVisibleFn(_21);
}
this._makeOverlayVisible(_21,_22);
};
DynamicMap.prototype._makeOverlayVisible=function(_23,_24){
if(!_23._isVisible&&_24){
if(_23.minZoom!=null){
this._markerMngr.addMarker(_23._gmarker,_23.minZoom,_23.maxZoom);
}else{
this._map.addOverlay(_23._gmarker);
}
_23._isVisible=true;
}else{
if(_23._isVisible&&!_24){
if(_23.minZoom!=null){
this._markerMngr.removeMarker(_23._gmarker);
}
this._map.removeOverlay(_23._gmarker);
_23._isVisible=false;
}
}
};
DynamicMap.prototype._addOverlay=function(_25){
this._overlays.push(_25);
this._evaluateForDisplay(_25);
};
DynamicMap.prototype._addYouAreHereOverlay=function(_26){
this._map.addOverlay(_26);
};
DynamicMap.prototype._removeAllOverlayss=function(){
this._map.closeInfoWindow();
while(this._overlays.length!=0){
var _27=this._overlays.pop();
this._makeOverlayVisible(_27,false);
}
};
function DataFeed(){
this._name="";
this._urlFn="";
this._map=null;
}
DataFeed._HTTP_OK=200;
DataFeed.prototype._refresh=function(){
this._refreshDataFeed(function(){
alert("OVERRIDE THIS METHOD");
});
};
DataFeed.prototype._refreshDataFeed=function(_28){
if(this._map!=null){
var map=this._map;
var url=this._urlFn();
if(url!=null){
GDownloadUrl(url,function(_2b,_2c){
if(_2c==DataFeed._HTTP_OK){
_28(map,_2b);
}
});
}
}
};
function MarkerDataFeed(_2d,_2e,map){
this._name=_2d;
this._urlFn=_2e;
this._map=map;
}
MarkerDataFeed.prototype=new DataFeed();
MarkerDataFeed.prototype._refresh=function(){
this._refreshDataFeed(MarkerDataFeed._dataLoaded);
};
MarkerDataFeed._dataLoaded=function(map,_31){
var xml=GXml.parse(_31);
var _33=xml.documentElement.getElementsByTagName("item");
for(var idx=0;idx<_33.length;idx++){
var _35=_33[idx];
var id=_35.getAttribute("id");
var _37=_35.getAttribute("icon");
var _38=_35.getAttribute("type");
var _39=_35.getAttribute("tooltip");
var lat=parseFloat(_35.getAttribute("lat"));
var lng=parseFloat(_35.getAttribute("lng"));
var _3c=null;
var _3d=null;
var _3e=_35.getAttribute("minZoom");
if(_3e!=null){
_3c=parseInt(_3e);
}
_3e=_35.getAttribute("maxZoom");
if(_3e!=null){
_3d=parseInt(_3e);
}
var _31="";
for(var _3f=0;_3f<_35.childNodes.length;_3f++){
var _40=_35.childNodes[_3f];
if(_40.nodeType==4){
_31=_40.nodeValue;
}
}
var _41=new DataMarker(id,_38,_37,lat,lng,_31,_3c,_3d);
_41._gmarker.tooltip="<div class=\"tooltip\">"+_39+"</div>";
GEvent.addListener(_41._gmarker,"mouseover",function(){
map._showTooltip(this);
});
GEvent.addListener(_41._gmarker,"mouseout",function(){
_tooltip.style.visibility="hidden";
});
map._addOverlay(_41);
}
};
function PolylineFeed(_42,_43,map){
this._name=_42;
this._urlFn=_43;
this._map=map;
}
PolylineFeed.prototype=new DataFeed();
PolylineFeed.prototype._refresh=function(){
this._refreshDataFeed(PolylineFeed._dataLoaded);
};
PolylineFeed._dataLoaded=function(map,_46){
var xml=GXml.parse(_46);
var _48=xml.documentElement.getElementsByTagName("polyline");
for(var idx=0;idx<_48.length;idx++){
var _4a=_48[idx];
var id=_4a.getAttribute("id");
var _4c=_4a.getAttribute("type");
var _4d=_4a.getAttribute("colour");
var _4e=parseFloat(_4a.getAttribute("weight"));
var _4f=parseFloat(_4a.getAttribute("opacity"));
var _50=_4a.getElementsByTagName("point");
var _51=new Array();
for(var jdx=0;jdx<_50.length;jdx++){
var _53=_50[jdx];
var lat=parseFloat(_53.getAttribute("lat"));
var lng=parseFloat(_53.getAttribute("lng"));
_51.push(new GLatLng(lat,lng));
}
map._addOverlay(new Polyline(id,_4c,xml,_51,_4d,_4e,_4f));
}
};
function GoogleOverlay(){
this.id="";
this.type="";
this.data=null;
this._isVisible=false;
}
function DataMarker(id,_57,_58,lat,lng,_5b,_5c,_5d){
this.id=id;
this.type=_57;
this.data=_5b;
this.minZoom=_5c;
this.maxZoom=_5d;
var _5e=new GIcon(G_DEFAULT_ICON);
_5e.image=_58;
var _5f=new GLatLng(lat,lng);
this._gmarker=new GMarker(_5f,_5e);
this._gmarker.id=id;
var _60=this._gmarker;
GEvent.addListener(_60,"click",function(){
DataMarker.onClick(_60,_5b);
});
}
DataMarker.prototype=new GoogleOverlay();
DataMarker.prototype.invokeClick=function(){
DataMarker.onClick(this._gmarker,this.data);
};
DataMarker.onClick=function(_61,_62){
_61.openInfoWindowHtml(_62);
};
function Polyline(id,_64,_65,_66,_67,_68,_69){
this.id=id;
this.type=_64;
this.data=_65;
this._gmarker=new GPolyline(_66,_67,_68,_69);
}
Polyline.prototype=new GoogleOverlay();
function TextualZoomControl(_6a,lat,lng,_6d){
this._area=_6a;
this._lat=lat;
this._lng=lng;
this._zoom=_6d;
}
TextualZoomControl.prototype=new GControl();
TextualZoomControl.prototype.initialize=function(map){
var _6f=document.createElement("div");
var _70=document.createElement("div");
this.setButtonStyle_(_70);
_6f.appendChild(_70);
_70.appendChild(document.createTextNode("View "+this._area));
var _71=new GLatLng(this._lat,this._lng);
var _72=this._zoom;
GEvent.addDomListener(_70,"click",function(){
map.setCenter(_71,_72);
});
map.getContainer().appendChild(_6f);
return _6f;
};
TextualZoomControl.prototype.getDefaultPosition=function(){
return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(47,7));
};
TextualZoomControl.prototype.setButtonStyle_=function(_73){
_73.style.color="black";
_73.style.backgroundColor="white";
_73.style.font="small Arial";
_73.style.border="1px solid black";
_73.style.padding="0px";
_73.style.marginBottom="0px";
_73.style.textAlign="center";
_73.style.width="10em";
_73.style.cursor="pointer";
};
DynamicMap.prototype.removeOverviewMap=function(_74){
this._map.removeControl(overviewMap);
};
DynamicMap.prototype.disableInfoWindow=function(){
this._map.disableInfoWindow();
};
DynamicMap.prototype.removeLargeMapControl=function(){
this._map.removeControl(largeMapControl);
};
DynamicMap.prototype.removeScaleControl=function(){
this._map.removeControl(scaleControl);
};
DynamicMap.prototype.removeMapTypeControl=function(){
this._map.removeControl(mapTypeControl);
};
DynamicMap.prototype.removeTextualZoomControl=function(){
this._map.removeControl(textualZoomControl);
};

