// Google Map Interface for Oak Meadow and Strawberry Meadow CC 2008

	function gup( name ) {
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp( regexS );
		var results = regex.exec( window.location.href );
		if( results == null ) {
    		return "";
  		} else {
			return results[1];
		}
	}

	function initialize() {
		if (GBrowserIsCompatible()) {
		var map = "";

 		// Creates map
		function makeMap(mwide, mhigh, cenlat, cenlng, mzoom) {
			map = new GMap2(document.getElementById("map_canvas"),
                { size: new GSize(mwide,mhigh) } );
			map.setCenter(new GLatLng(cenlat,cenlng), mzoom);
			// Adds map control
			map.addControl(new GLargeMapControl());
			var mapControl = new GMapTypeControl();
			map.addControl(mapControl);
		}
		
		// Creates a base icon for all markers
		// and specifies shadow, icon dimensions, etc.
		var baseIcon = new GIcon(G_DEFAULT_ICON);
		baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		baseIcon.iconSize = new GSize(20, 34);
		baseIcon.shadowSize = new GSize(37, 34);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);

		// Creates a marker with a letter corresponding to the given index.
		function createMarker(point, index, info) {
  		// Creates a lettered icon for this point using our icon class
  			var letteredIcon = new GIcon(baseIcon);
  			letteredIcon.image = "http://www.google.com/mapfiles/marker" + index + ".png";

  		// Set up our GMarkerOptions object
  			markerOptions = { icon:letteredIcon };
  			var marker = new GMarker(point, markerOptions);
		
			GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(info);
			});

  			return marker;
		}
		
		function makeMarker(mlat, mlng, info, letr) {
			var position = new GLatLng(mlat,mlng);
			var marker = createMarker(position, letr, info);
			map.addOverlay(marker);
			marker.openInfoWindowHtml(info);
		}
		var venue = gup('loc');
		if(!venue) { venue = "omc";}
		for(i=0; i<centres.length; i++) {
			if(centres[i][0] == venue) {
				var centLat = centres[i][1];
				var centLng = centres[i][2];
				makeMap(mapWide, mapHigh, centLat, centLng, mapZoom);
				for(m=0; m<centres[i][3].length; m++){
				markerLat = centres[i][3][m][0];
				markerLng = centres[i][3][m][1];
				markerInfo = centres[i][3][m][2];
				markerLetter = centres[i][3][m][3];
				makeMarker(markerLat, markerLng, markerInfo, markerLetter);
				}
			}
		}
		}
	}


addLoadListener(initialize);
