var _tooltip=document.createElement("div");
var _handler=null;
function DynamicMap(_1,_2,_3,_4,_5){
this._map=new GMap2(_1);
this._map.enableDoubleClickZoom();
this._map.enableGoogleBar();
this._selected=null;
this._isToBeVisibleFn=null;
this.setCentre(0,0,0);
this._dataFeeds=new Array();
this._districts=new Array();
this._airQualityFeed=null;
this._dataFeedsToLoad=new Array();
this._progressControl=null;
this._overlays=new Array();
this._moveEndFunction=null;
this._map.getPane(G_MAP_FLOAT_PANE).appendChild(_tooltip);
GEvent.addListener(this._map,"dragend",_3);
GEvent.addListener(this._map,"zoomend",_5);
_handler=GEvent.addListener(this._map,"moveend",_4);
GEvent.addListener(this._map,"dragend",function(){
if(_handler===null){
_4();
}
});
GEvent.addListener(this._map,"infowindowopen",DynamicMap.infoWindowOpenFunction);
var _6=this._map;
GEvent.addListener(this._map,"infowindowclose",function(){
DynamicMap.infoWindowCloseFunction(_6,_4);
});
}
DynamicMap.prototype._showTooltip=function(_7){
_tooltip.innerHTML=_7.tooltip;
var _8=this._map.getCurrentMapType().getProjection().fromLatLngToPixel(this._map.fromDivPixelToLatLng(new GPoint(0,0),true),this._map.getZoom());
var _9=this._map.getCurrentMapType().getProjection().fromLatLngToPixel(_7.getPoint(),this._map.getZoom());
var _a=_7.getIcon().iconAnchor;
var _b=_7.getIcon().iconSize.width;
var _c=_tooltip.clientHeight;
var _d=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(_9.x-_8.x-_a.x+_b,_9.y-_8.y-_a.y-_c));
_d.apply(_tooltip);
_tooltip.style.visibility="visible";
};
DynamicMap.isSupported=function(){
try{
return GBrowserIsCompatible();
}
catch(e){
return false;
}
};
DynamicMap.prototype.useStandardControls=function(){
this._map.addControl(new GLargeMapControl());
var _e=new GControlPosition(G_ANCHOR_BOTTOM_LEFT,new GSize(255,5));
this._map.addControl(new GScaleControl(),_e);
this._map.addControl(new GOverviewMapControl(new GSize(150,150)));
};
DynamicMap.prototype.showProgressControl=function(){
this._progressControl=new ProgressControl();
this._map.addControl(this._progressControl);
};
DynamicMap.prototype.addMapEventListener=function(_f,_10){
return GEvent.addListener(this._map,_f,_10);
};
DynamicMap.prototype.setCentre=function(lat,lng,_13){
this._map.setCenter(new GLatLng(lat,lng),_13);
};
DynamicMap.prototype.setCentreForBounds=function(_14){
var _15=this._map.getBoundsZoomLevel(_14);
this._map.setCenter(_14.getCenter(),_15);
};
DynamicMap.prototype.getCentre=function(){
return this._map.getCenter();
};
DynamicMap.prototype.getZoom=function(){
return this._map.getZoom();
};
DynamicMap.prototype.getBoundsZoomLevel=function(_16){
return this._map.getBoundsZoomLevel(_16);
};
DynamicMap.prototype.setZoom=function(_17){
this._map.setZoom(_17);
};
DynamicMap.prototype.restrictToArea=function(urx,ury,blx,bly,_1c){
var map=this._map;
var _1e=new GLatLngBounds(new GLatLng(urx,ury),new GLatLng(blx,bly));
GEvent.addListener(this._map,"move",function(){
DynamicMap._checkBounds(map,_1e);
});
var mt=this._map.getMapTypes();
for(var i=0;i<mt.length;i++){
mt[i].getMinimumResolution=function(){
return _1c;
};
}
};
DynamicMap.prototype.addControl=function(_21){
this._map.addControl(_21);
};
DynamicMap.prototype.addMarkerFeed=function(_22){
this._dataFeeds.push(new MarkerDataFeed(_22.name,_22.urlFn,_22.icons,this));
};
DynamicMap.prototype.addPolylineFeed=function(_23){
this._dataFeeds.push(new PolylineFeed(_23.name,_23.urlFn,this));
};
DynamicMap.prototype.removeFeed=function(_24){
var _25=-1;
for(var idx=0;idx<this._dataFeeds.length;idx++){
var _27=this._dataFeeds[idx];
if(_27._name==_24){
_25=idx;
break;
}
}
if(_25!=-1){
this._dataFeeds.splice(_25,1);
}
};
DynamicMap.prototype.setIsToBeVisibleFn=function(fn){
this._isToBeVisibleFn=fn;
};
DynamicMap.prototype.refresh=function(_29,_2a){
if(_29){
if(_2a===undefined){
this._removeAllOverlays();
this._dataFeedsToLoad=this._dataFeedsToLoad.concat(this._dataFeeds);
if(this._airQualityFeed!=null){
this._dataFeedsToLoad.push(this._airQualityFeed);
}
}else{
for(var idx=0;idx<this._dataFeeds.length;idx++){
if(this._dataFeeds[idx]._name===_2a){
this._dataFeedsToLoad.push(this._dataFeeds[idx]);
}
}
for(var idx=0;idx<this._overlays.length;idx++){
var _2c=this._overlays[idx];
if((_2c!=null)&&(_2c.type==_2a)){
this._makeOverlayVisible(_2c,false);
this._overlays[idx]=null;
}
}
}
if(this._dataFeedsToLoad.length>0){
if(this._progressControl!=null){
this._progressControl.setText("<p><img src='images/ajax-loader.gif'/> Loading data. Please wait.</p>");
}
var _2d=this._dataFeedsToLoad.pop();
_2d._refresh();
}
}else{
for(var idx=0;idx<this._overlays.length;idx++){
var _2c=this._overlays[idx];
if(_2c!=null){
this._evaluateForDisplay(_2c);
}
}
for(var inx=0;inx<this._districts.length;inx++){
if((document.getElementById("airQualityButton").value=="on")){
this._districts[inx].polygon.show();
}else{
this._districts[inx].polygon.hide();
}
}
}
};
DynamicMap.prototype.focusOnMarker=function(id){
this._selected=id;
if(this._selected!=null){
for(var idx=0;idx<this._overlays.length;idx++){
var _31=this._overlays[idx];
if((_31!=null)&&(_31.id==this._selected)){
this._makeOverlayVisible(_31,true);
_31.invokeClick();
this._selected=null;
break;
}
}
}
};
DynamicMap._checkBounds=function(map,_33){
if(_33.contains(map.getCenter())){
return;
}
var C=map.getCenter();
var X=C.lng();
var Y=C.lat();
var _37=_33.getNorthEast().lng();
var _38=_33.getNorthEast().lat();
var _39=_33.getSouthWest().lng();
var _3a=_33.getSouthWest().lat();
if(X<_39){
X=_39;
}
if(X>_37){
X=_37;
}
if(Y<_3a){
Y=_3a;
}
if(Y>_38){
Y=_38;
}
map.setCenter(new GLatLng(Y,X));
};
DynamicMap._showBoundry=function(map,doc){
lines=doc.split("\n");
var _3d=[];
for(var i=0;i<lines.length;i++){
if(lines[i].length>1){
parts=lines[i].split(",");
var lat=parseFloat(parts[0]);
var lng=parseFloat(parts[1]);
_3d.push(new GLatLng(lat,lng));
}
}
map.addOverlay(new GPolyline(_3d,"#FFFF00",10,0.5));
};
DynamicMap.prototype.addDistrictPoly=function(_41,_42){
var _43={name:_41,polygon:_42};
this._districts.push(_43);
};
DynamicMap.prototype.findDistrictPoly=function(_44){
for(var i=0;i<this._districts.length;i++){
if(this._districts[i].name==_44){
return this._districts[i].polygon;
}
}
return null;
};
DynamicMap.prototype.getDistricts=function(){
return this._districts;
};
DynamicMap.prototype.showAreaOverlay=function(map,doc,_48,_49){
lines=doc.split("\n");
var _4a=[];
for(var i=0;i<lines.length;i++){
if(lines[i].length>1){
parts=lines[i].split(",");
var lat=parseFloat(parts[0]);
var lng=parseFloat(parts[1]);
_4a.push(new GLatLng(lat,lng));
}
}
polygon=new GPolygon(_4a,"#000000",0,0,"#FFFFFF",0);
if((document.getElementById("airQualityButton").value=="off")){
polygon.hide();
}
map.addOverlay(polygon);
_49(_48,polygon);
return polygon;
};
DynamicMap.prototype.getBounds=function(){
var _4e=this._map;
return _4e.getBounds();
};
DynamicMap.prototype.addBoundry=function(_4f){
var _50=this._map;
GDownloadUrl(_4f,function(_51,_52){
if(_52==DataFeed._HTTP_OK){
DynamicMap._showBoundry(_50,_51);
}
});
};
DynamicMap.prototype.drawDistrict=function(_53,_54){
var _55=this._map;
var _56=GEvent.callback(this,this.addDistrictPoly);
GDownloadUrl(_53,function(_57,_58){
if(_58==DataFeed._HTTP_OK){
DynamicMap.prototype.showAreaOverlay(_55,_57,_54,_56);
}
});
};
DynamicMap.prototype.addDistrict=function(_59){
this.drawDistrict(_59.url,_59.name);
};
DynamicMap.prototype.setAirQualityFeed=function(_5a){
this._airQualityFeed=new AirQualityDataFeed(_5a.name,_5a.urlFn,this);
};
DynamicMap.prototype._evaluateForDisplay=function(_5b){
var _5c=true;
if(this._isToBeVisibleFn!=null){
_5c=this._isToBeVisibleFn(_5b);
}
this._makeOverlayVisible(_5b,_5c);
};
DynamicMap.prototype._makeOverlayVisible=function(_5d,_5e){
if(!_5d._isVisible&&_5e){
this._map.addOverlay(_5d._gmarker);
_5d._isVisible=true;
}else{
if(_5d._isVisible&&!_5e){
this._map.removeOverlay(_5d._gmarker);
_5d._isVisible=false;
}
}
};
DynamicMap.prototype._addOverlay=function(_5f){
this._overlays.push(_5f);
this._evaluateForDisplay(_5f);
};
DynamicMap.prototype._removeAllOverlays=function(){
this._map.closeInfoWindow();
while(this._overlays.length!=0){
var _60=this._overlays.pop();
if(_60!=null){
this._makeOverlayVisible(_60,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(_61,_62){
if(this._map!=null){
var map=this._map;
var url=this._urlFn();
if(url==null){
this._loadNextFeed();
}else{
var _65=this._loadNextFeed;
GDownloadUrl(url,function(_66,_67){
if(_67==DataFeed._HTTP_OK){
_61(map,_66,_62);
}
_65();
});
}
}
};
DataFeed.prototype._loadNextFeed=function(){
if(map._dataFeedsToLoad.length>0){
var _68=map._dataFeedsToLoad.pop();
_68._refresh();
}else{
if(map._progressControl!=null){
map._progressControl.setText("");
}
}
};
function MarkerDataFeed(_69,_6a,_6b,map){
this._name=_69;
this._urlFn=_6a;
this._icons=_6b;
this._map=map;
}
MarkerDataFeed.prototype=new DataFeed();
MarkerDataFeed.prototype._refresh=function(){
this._refreshDataFeed(MarkerDataFeed._dataLoaded,this._icons);
};
MarkerDataFeed._dataLoaded=function(map,_6e,_6f){
var xml=GXml.parse(_6e);
var _71=xml.documentElement.getElementsByTagName("item");
var _72=new GLatLngBounds();
var _73=false;
for(var idx=0;idx<_71.length;idx++){
var _75=_71[idx];
var _76=new Array();
var _77=_75.getElementsByTagName("dataSection");
for(var _78=0;_78<_77.length;_78++){
var _79=_77[_78];
for(var _7a=0;_7a<_79.childNodes.length;_7a++){
var _7b=_79.childNodes[_7a];
if(_7b.nodeType==4){
_76.push({name:_79.getAttribute("name"),content:_7b.nodeValue});
}
}
}
var _7c=_75.getElementsByTagName("tooltip");
var _7d;
for(var _78=0;_78<_7c.length;_78++){
var _79=_7c[_78];
for(var _7a=0;_7a<_79.childNodes.length;_7a++){
var _7b=_79.childNodes[_7a];
if(_7b.nodeType==4){
_7d=_7b.nodeValue;
}
}
}
var _7e=_75.getAttribute("icon");
var _7f=new DataMarker({id:_75.getAttribute("id"),shortDescription:_75.getAttribute("shortDescription"),icon:_6f[_7e].icon,iconWidth:parseInt(_6f[_7e].iconWidth),iconHeight:parseInt(_6f[_7e].iconHeight),iconAnchorWidth:parseInt(_6f[_7e].iconAnchorWidth),iconAnchorHeight:parseInt(_6f[_7e].iconAnchorHeight),hasShadow:_6f[_7e].hasShadow,type:_75.getAttribute("type"),location:_75.getAttribute("location"),longdescription:_75.getAttribute("longdescription"),contactdetails:_75.getAttribute("contactdetails"),tooltipSize:_6f[_7e].tooltipSize,tooltip:_7d,lat:parseFloat(_75.getAttribute("lat")),lng:parseFloat(_75.getAttribute("lng")),minZoom:parseInt(_6f[_7e].minZoom),maxZoom:parseInt(_6f[_7e].maxZoom),content:_76});
map._addOverlay(_7f);
}
map.focusOnMarker(map._selected);
};
function AirQualityDataFeed(_80,_81,map){
this._name=_80;
this._urlFn=_81;
this._map=map;
}
AirQualityDataFeed.prototype=new DataFeed();
AirQualityDataFeed.prototype._refresh=function(){
this._refreshDataFeed(AirQualityDataFeed._dataLoaded);
};
AirQualityDataFeed._dataLoaded=function(map,_84){
var xml=GXml.parse(_84);
var _86=xml.documentElement.getElementsByTagName("item");
var _87=map.getDistricts();
for(var ind=0;ind<_87.length;ind++){
var _89=_87[ind];
var _8a=false;
for(var idx=0;idx<_86.length;idx++){
var _8c=_86[idx];
if(_8c.getAttribute("district")==_89.name){
var _8d=null;
if(_8c.getAttribute("severity")=="Low"){
_8d="#00FF00";
}else{
if(_8c.getAttribute("severity")=="Medium"){
_8d="#FF9900";
}else{
if(_8c.getAttribute("severity")=="High"){
_8d="#FF0000";
}
}
}
var _8e=map.findDistrictPoly(_8c.getAttribute("district"));
if(_8e!=null){
var _8f;
if(_8d!=null){
_8f={color:_8d,weight:"0.0",opacity:"0.4"};
}else{
_8f={color:"#FFFFFF",weight:"0.0",opacity:"0.0"};
}
_8e.setFillStyle(_8f);
}
_8a=true;
break;
}
}
if(!_8a){
var _8f={color:"#FFFFFF",weight:"0.0",opacity:"0.0"};
_89.polygon.setFillStyle(_8f);
}
}
};
function PolylineFeed(_90,_91,map){
this._name=_90;
this._urlFn=_91;
this._map=map;
}
PolylineFeed.prototype=new DataFeed();
PolylineFeed.prototype._refresh=function(){
this._refreshDataFeed(PolylineFeed._dataLoaded);
};
PolylineFeed._dataLoaded=function(map,_94){
var xml=GXml.parse(_94);
var _96=xml.documentElement.getElementsByTagName("polyline");
for(var idx=0;idx<_96.length;idx++){
var _98=_96[idx];
var id=_98.getAttribute("id");
var _9a=_98.getAttribute("type");
var _9b=_98.getAttribute("colour");
var _9c=parseFloat(_98.getAttribute("weight"));
var _9d=parseFloat(_98.getAttribute("opacity"));
var _9e=_98.getElementsByTagName("point");
var _9f=new Array();
for(var jdx=0;jdx<_9e.length;jdx++){
var _a1=_9e[jdx];
var lat=parseFloat(_a1.getAttribute("lat"));
var lng=parseFloat(_a1.getAttribute("lng"));
_9f.push(new GLatLng(lat,lng));
}
map._addOverlay(new Polyline(id,_9a,xml,_9f,_9b,_9c,_9d));
}
};
function GoogleOverlay(){
this.id="";
this.type="";
this.data=null;
this._isVisible=false;
}
function DataMarker(_a4){
this.id=_a4.id;
this.type=_a4.type;
this.data=_a4.content;
this.minZoom=_a4.minZoom;
this.maxZoom=_a4.maxZoom;
var _a5=new GIcon(G_DEFAULT_ICON);
_a5.image=_a4.icon;
_a5.iconSize=new GSize(_a4.iconWidth,_a4.iconHeight);
_a5.imageMap=[0,0,_a4.iconWidth,0,_a4.iconWidth,_a4.iconHeight,0,_a4.iconHeight];
_a5.iconAnchor=new GPoint(_a4.iconAnchorWidth,_a4.iconAnchorHeight);
if(_a4.hasShadow!="true"){
_a5.shadow=null;
}
var _a6=new GLatLng(_a4.lat,_a4.lng);
this._gmarker=new GMarker(_a6,{icon:_a5});
this._gmarker.id=_a4.id;
this._gmarker.type=_a4.type;
this._gmarker.shortDescription=_a4.shortDescription;
this._gmarker.tooltip="<div style=\"width: "+_a4.tooltipSize+"px\" class=\"tooltip\">";
this._gmarker.tooltip+=_a4.tooltip;
this._gmarker.tooltip+="</div>";
var _a7=this._gmarker;
var _a8=this.data;
GEvent.addListener(_a7,"click",function(){
DataMarker.onClick(_a7,_a8);
});
GEvent.addListener(_a7,"mouseover",function(){
map._showTooltip(_a7);
});
GEvent.addListener(_a7,"mouseout",function(){
_tooltip.style.visibility="hidden";
});
}
DataMarker.prototype=new GoogleOverlay();
DataMarker.prototype.invokeClick=function(){
DataMarker.onClick(this._gmarker,this.data);
};
DataMarker.onClick=function(_a9,_aa){
var _ab=new Array();
var _ac=_a9.getLatLng();
for(var idx=0;idx<_aa.length;idx++){
var _ae=_aa[idx].content;
_ae+="<div class=\"infoWindowZoomControls\">";
_ae+="<a href=\"javascript:zoom("+_ac.lat()+","+_ac.lng()+",17);\" title=\"Zoom in for closer view\">";
_ae+="<img src=\"images/zoomIn.png\" border=\"0\"></img>";
_ae+="</a>";
_ae+="<a href=\"javascript:zoomOut(9);\" title=\"Zoom out to overview\">";
_ae+="<img src=\"images/zoomOut.png\" border=\"0\"></img>";
_ae+="</a>";
_ae+="</div>";
_ab[idx]=new GInfoWindowTab(_aa[idx].name,_ae);
}
_a9.openInfoWindowTabsHtml(_ab);
};
function Polyline(id,_b0,_b1,_b2,_b3,_b4,_b5){
this.id=id;
this.type=_b0;
this.data=_b1;
this._gmarker=new GPolyline(_b2,_b3,_b4,_b5);
}
Polyline.prototype=new GoogleOverlay();
DynamicMap.infoWindowOpenFunction=function(){
GEvent.removeListener(_handler);
_handler=null;
};
DynamicMap.infoWindowCloseFunction=function(map,_b7){
_handler=GEvent.addListener(map,"moveend",_b7);
};

