﻿google.load("maps","2",{"other_params":"sensor=false"});google.setOnLoadCallback(function(){Type.registerNamespace("TWorx.EpaMaps");TWorx.EpaMaps.GoogleMap=function(mapDiv){TWorx.EpaMaps.GoogleMap.initializeBase(this,[mapDiv]);this._mapDiv=jQuery(mapDiv);this._locationsArray=this._map=null};TWorx.EpaMaps.GoogleMap.prototype={initialize:function(){TWorx.EpaMaps.GoogleMap.callBaseMethod(this,"initialize");for(var i=0;i<this._locationsArray.length;i++){this._locationsArray[i]=this.createLocationMarker(this._locationsArray[i].latitude,this._locationsArray[i].longitude,this._locationsArray[i].index,this._locationsArray[i].name)}this._map=new GMap2(this.get_element());this._map.addControl(new GSmallMapControl());this._map.addControl(new GMapTypeControl());this._map.setCenter(new GLatLng(0,0),TWorx.EpaMaps.GoogleMap.defaultZoomLevel,TWorx.EpaMaps.GoogleMap.mapType)},showAllLocations:function(){this._map.clearOverlays();for(var i=0;i<this._locationsArray.length;i++){this._map.addOverlay(this._locationsArray[i])}this.displayMap();this._map.checkResize();var bounds=TWorx.EpaMaps.GoogleMap.getBounds(this._map.getCurrentMapType(),this._map.getSize(),this._locationsArray);this._map.setCenter(bounds.getCenter(),this._map.getBoundsZoomLevel(bounds)-1)},displayMap:function(){this._mapDiv.show()},createLocationMarker:function(latitude,longitude,index,name){var marker=new GMarker(new GLatLng(latitude,longitude),{icon:new GIcon(G_DEFAULT_ICON,TWorx.EpaMaps.GoogleMap.baseMarkerImagePath+"marker"+index.toString(10)+".png")});GEvent.addListener(marker,"mouseover",function(){marker.openInfoWindowHtml("<div class='Normal'>"+index.toString(10)+" - "+name+"</div>")});GEvent.addListener(marker,"mouseout",function(){marker.closeInfoWindow()});return marker},dispose:function(){TWorx.EpaMaps.GoogleMap.callBaseMethod(this,"dispose");GUnload()},get_locationsArray:function(){return this._locationsArray},set_locationsArray:function(value){this._locationsArray=value}};TWorx.EpaMaps.GoogleMap.defaultZoomLevel=13;TWorx.EpaMaps.GoogleMap.registerClass("TWorx.EpaMaps.GoogleMap",Sys.UI.Behavior);TWorx.EpaMaps.GoogleMap.getBounds=function(mapType,size,markers){var south,west,east,north;south=west=180;east=north=-180;for(var i=0;i<markers.length;i++){if(markers[i].getPoint().lat()>north){north=markers[i].getPoint().lat()}if(markers[i].getPoint().lat()<south){south=markers[i].getPoint().lat()}if(markers[i].getPoint().lng()>east){east=markers[i].getPoint().lng()}if(markers[i].getPoint().lng()<west){west=markers[i].getPoint().lng()}}var southWest=new GLatLng(south,west);var northEast=new GLatLng(north,east);var bounds=new GLatLngBounds(southWest,northEast);var zoomLevel=mapType.getBoundsZoomLevel(bounds,size);var minZoom=mapType.getMinimumResolution(markers[0]);if(zoomLevel<minZoom){zoomLevel=minZoom}return bounds};TWorx.EpaMaps.GoogleMap.mapType=G_NORMAL_MAP;TWorx.EpaMaps.GoogleMap.baseMarkerImagePath=baseMarkerImagePath;jQuery("div.map").each(function(){$create(TWorx.EpaMaps.GoogleMap,{locationsArray:eval(this.id+"_locations")},{},{},this).showAllLocations()})});
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();