/**
	*	Google Map Code for Baltimore DON
 	*	Goes below closing body tag (only way I have found to integrate it with jquery thickbox)
 */
			var map;
			
				if (GBrowserIsCompatible()) {
				
					var gmarkers = [];
					var gicons = [];
			
					gicons["red"] = new GIcon(G_DEFAULT_ICON,"../../../../assets/images/maps/gmap-custom-markers/marker_red.png");
					//gicons["green"] = new GIcon(G_DEFAULT_ICON,"../../../../assets/images/maps/gmap-custom-markers/marker_green.png");
					//gicons["blue"] = new GIcon(G_DEFAULT_ICON,"../../../../assets/images/maps/gmap-custom-markers/marker_blue.png");
					//gicons["orange"] = new GIcon(G_DEFAULT_ICON,"../../../../assets/images/maps/gmap-custom-markers/marker_orange.png");
					//gicons["purple"] = new GIcon(G_DEFAULT_ICON,"../../../../assets/images/maps/gmap-custom-markers/marker_purple.png");
					//gicons["yellow"] = new GIcon(G_DEFAULT_ICON,"../../../../assets/images/maps/gmap-custom-markers/marker_yellow.png");
					//gicons["cyan"] = new GIcon(G_DEFAULT_ICON,"../../../../assets/images/maps/gmap-custom-markers/marker_cyan.png");
					//gicons["pink"] = new GIcon(G_DEFAULT_ICON,"../../../../assets/images/maps/gmap-custom-markers/marker_pink.png");
					//gicons["grey"] = new GIcon(G_DEFAULT_ICON,"../../../../assets/images/maps/gmap-custom-markers/marker_grey.png");
					//gicons["black"] = new GIcon(G_DEFAULT_ICON,"../../../../assets/images/maps/gmap-custom-markers/marker_black.png");
			
			function onResize(){
				var mapDiv = document.getElementById("map");
				var listDiv = document.getElementById("marker_list");
			  };
			
			
				// function to create the marker and set up the event window
				 function createMarker(point,name,html,category) {
					var marker = new GMarker(point,gicons[category]);
					// === Store the category and name info as a marker properties ===
					marker.mycategory = category;                                 
					marker.myname = name;
					GEvent.addListener(marker, "click", function() {
					  marker.openInfoWindowHtml(html);
					  tb_init('a.thickbox'); // this required for thickbox to work from within the GMap info window
					});		
					
					gmarkers.push(marker);
					return marker;
				  }
			
				// == shows all markers of a particular category, and ensures the checkbox is checked ==
				  function show(category) {
					for (var i=0; i<gmarkers.length; i++) {
					  if (gmarkers[i].mycategory == category) {
						gmarkers[i].show();
					  }
					}
					// == check the checkbox ==
					document.getElementById(category+"box").checked = true;
				  }
			
				  // == hides all markers of a particular category, and ensures the checkbox is cleared ==
				  function hide(category) {
					for (var i=0; i<gmarkers.length; i++) {
					  if (gmarkers[i].mycategory == category) {
						gmarkers[i].hide();
					  }
					}
					// == clear the checkbox ==
					document.getElementById(category+"box").checked = false;
					// == close the info window, in case its open on a marker that we just hid
					map.closeInfoWindow();
				  }
			
				  // == a checkbox has been clicked ==
				  function boxclick(box,category) {
					if (box.checked) {
					  show(category);
					} else {
					  hide(category);
					}
					// == rebuild the side bar
					makeSidebar();
				  }
			
				  function myclick(i) {
					GEvent.trigger(gmarkers[i],"click");
				  }
				  
				  // == rebuilds the sidebar to match the markers currently displayed ==
				  function makeSidebar() {
					var html = "";
					html += '<ol>';
					for (var i=0; i<gmarkers.length; i++) {
					  if (!gmarkers[i].isHidden()) {
						html += '<li><a href="javascript:myclick(' + i + ')"><img src="../../../../assets/images/maps/gmap-custom-markers/s_marker_'+ gmarkers[i].mycategory +'.gif" alt="'+gmarkers[i].myname+'" /> '+gmarkers[i].myname+'</a></li>';
					  }
					}
					html += '</ol>';
					document.getElementById("marker_list").innerHTML = html;
				  }
				  
				var panelDefaultUrls = ["/maps?ie=UTF8&hl=en", "/maps/ms?ie=UTF8&hl=en&msa=10","", "",""];
				
				 
				 // Display the map, with some controls and set the initial location 
					onResize();
					map = new GMap2(document.getElementById("map"));
					map.addControl(new GLargeMapControl()); //map.addControl(new GSmallMapControl());
					map.addControl(new GMapTypeControl());
					map.addMapType(G_PHYSICAL_MAP);
					map.removeMapType(G_HYBRID_MAP);
					map.addControl(new GScaleControl());
					map.setCenter(new GLatLng(39.2757,-76.6257), 12, G_NORMAL_MAP); //41.7625 -87.8629 -- 53.465522,-2.291103
				
				
			
				 // Read the data
				  GDownloadUrl("mapdata.baltimore.xml", function(doc) {
					var xmlDoc = GXml.parse(doc);
					var markers = xmlDoc.documentElement.getElementsByTagName("marker");
					
					  
					for (var i = 0; i < markers.length; i++) {
					  // obtain the attribues of each marker
					  
					  // custom add rel attribute
					  var region = markers[i].getAttribute("region");
					  
					  var lat = parseFloat(markers[i].getAttribute("lat"));
					  var lng = parseFloat(markers[i].getAttribute("lng"));
					  var point = new GLatLng(lat,lng);
					  var image = markers[i].getAttribute("image");
					  var site = markers[i].getAttribute("site");
					  var name = markers[i].getAttribute("name");
					  var location = markers[i].getAttribute("location");
					  var description = GXml.value(markers[i].getElementsByTagName("description")[i]);
					  var category = markers[i].getAttribute("icon");
					  var html = [];
					  html = html+'<div class="map-flyout"><h3>'+name+'</h3><strong>Site Number:</strong> '+site+'<br /><strong>Location:</strong> '+location+'<br /><div align="center" class="photoholder"><a class="thickbox" rel="'+region+'" title="'+name+': '+location+': " href="'+site+'.jpg"><img src="'+site+'.jpg" alt="'+site+'" width="200" height="133" /></a></div><form id="form1" name="form1" method="get" target="_blank" action="http://maps.google.com/maps">Search for nearby businesses and more: <br /><input class="textfield" type="text" name="q"> <input class="button" type="submit" value="Search"><input type="hidden" name="f" value="l"/><input type="hidden" name="near" value="' + point.lat() + ',' + point.lng() +'"/></form></div>'
					  // create the marker
					  var marker = createMarker(point,name,html,category);
					  map.addOverlay(marker);
					  
					}
					// == show or hide the categories initially ==
			
					show("red");
					//show("green");
					//show("blue");
					//show("orange");
					//show("purple");
					//show("yellow");
					//show("cyan");
					//show("pink");
					//show("grey");
					//show("black");
				   
					// == create the initial sidebar ==
					makeSidebar();
				  });   
				  
				}
			
				// display a warning if the browser was not compatible
				else {
				  alert("Sorry, the Google Maps API is not compatible with this browser");
				}
			  
				// This Javascript is based on code provided by the Blackpool Community Church Javascript Team http://www.commchurch.freeserve.co.uk http://www.econym.demon.co.uk/googlemaps/
				
				//]]>
			

