
	// exhalebrighton.com maps API key = ABQIAAAA5cLqDL1Bj35Fd6Pg7SoJZxRrpbWTFSAblmqA_Ci-PrwNRs8RKxRBpJjXAJ3tfYGauhnXshwg7mjPug
	
	google.load("maps", "2");
	
	jQuery(document).unload(function() {
		google.maps.Unload();
	});
	
	var map;
	
	jQuery(document).ready(function() {
		
		// create the map.
		function GMload() {
			if (GBrowserIsCompatible()) {
				
				// open street map tiles
				var copyOSM = new GCopyrightCollection("<a href=\"http://www.openstreetmap.org/\">OpenStreetMap</a>");
				copyOSM.addCopyright(new GCopyright(1, new GLatLngBounds(new GLatLng(-90,-180), new GLatLng(90,180)), 0, " "));				
				var tilesMapnik = new GTileLayer(copyOSM, 1, 17, {tileUrlTemplate: 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png'});
				var mapMapnik = new GMapType([tilesMapnik],G_NORMAL_MAP.getProjection(),"Map (alt.)");
				map = new GMap2(document.getElementById("map"),{ mapTypes: [mapMapnik, G_SATELLITE_MAP] });
				
				var mLat = 50.82689;
				var mLong = -0.14071;
				map.setUIToDefault();
				map.disableScrollWheelZoom();
				map.setCenter(new GLatLng(mLat, mLong), 15);

				$('ul.ttable .vcard').each(function(){
					
					var $this = $(this);
					var $geoElem = $this.find('abbr.geo');
					var venueName = $geoElem.text();
					var latlon = $geoElem.attr('title').split(";");
					if(latlon){
						var lat = parseFloat(latlon[0]);
						var lon = parseFloat(latlon[1]);
					}else{
						return false;
					}
					
					var address = "";
					$this.find('.adr span').each(function(){
						address += '<p>' + $(this).text() + '</p>';
					});
					
					var point = new GLatLng(lat, lon);
					var marker = new GMarker(point,{title: venueName });
					map.addOverlay(marker);
					
					// reveal the venue name on click
					GEvent.addListener(marker, "click", function() {
						map.closeInfoWindow();
						map.panTo(marker.getLatLng());
						var h = '<div class="adrPopup">';
						h += '<h3 class="venuename">' + venueName + '</h3>';
						h += address;		
						h += '</div>';				
						marker.openInfoWindowHtml(h);
					});
					
				});
		
			}
		}
		
		// add the hover & reveal to the yoga venues
		$('ul.ttable')
			.hover(
				function(){
				    $(this).addClass("active");
				},
				function(){
				    $(this).removeClass("active");
				}
			).click(function(){
					map.closeInfoWindow();
					var latlon = $(this).find('.geo').eq(0).attr('title').split(";");
					if(latlon){
						var lat = parseFloat(latlon[0]);
						var lon = parseFloat(latlon[1]);
					}
					var point = new GLatLng(lat, lon);
					map.panTo(point);
			});
		
		GMload();
	    
	})

