////// MAP FUNCTIONS //////
var bounds = new GLatLngBounds();

var blueIcon = new GIcon();
blueIcon.image = "http://labs.google.com/ridefinder/images/mm_20_blue.png";
blueIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
blueIcon.iconSize = new GSize(12, 20);
blueIcon.shadowSize = new GSize(22, 20);
blueIcon.iconAnchor = new GPoint(6, 20);
blueIcon.infoWindowAnchor = new GPoint(5, 1);

function createMarker(point,html) {
	var marker = new GMarker(point,blueIcon);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});
	return marker;
}

function getmap(lat,lng,html) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.setCenter(new GLatLng(lat, lng), 15);
		// create the marker
		var point = new GLatLng(lat,lng);
		var marker = createMarker(point,html);
		map.addOverlay(marker);
	}
}

function getmaps(markers) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.setCenter(new GLatLng(28.805, -97.0033333), 13);
		for (var i = 0; i < markers.length; i++) {
			// obtain the attribues of each marker
			var lat = parseFloat(markers[i].lat);
			var lng = parseFloat(markers[i].lng);
			var point = new GLatLng(lat,lng);
			var html = markers[i].html;
			// create the marker
			var marker = createMarker(point,html);
			map.addOverlay(marker);
			// ==== Each time a point is found, extent the bounds and include it =====
			bounds.extend(point);
		}
		// ===== determine the zoom level from the bounds =====
		map.setZoom(map.getBoundsZoomLevel(bounds));
		// ===== determine the centre from the bounds ======
		map.setCenter(bounds.getCenter());
	}
}
////// MAP FUNCTIONS //////