var map;

// Center and zoom
var center = new GLatLng(33.760882, -118.300781);
var zoom = 8;
		
// Locations
var locations = [
	    {
			'latitude': 34.320959,
			'longitude': -119.375601,
		    'name': 'Mondos Beach'
		},
		{
			'latitude': 33.700814,
			'longitude': -118.052516,
		    'name': 'Bolsa Chica State Park'
		},
		{
			'latitude': 33.664639,
			'longitude': -118.012562,	
		    'name': 'Huntington Beach'
		},
		{
			'latitude': 33.373138,
			'longitude': -117.564987,
		    'name': 'San Onofre State Beach'
		},
        {
			'latitude': 33.336429,
			'longitude': -117.504643,
		    'name': 'Trails'
		}
	    ];


// Add a marker on the map
function addMarker(latitude, longitude, description) {
	var marker = new GMarker(new GLatLng(latitude, longitude));
	
	GEvent.addListener(marker, 'click',
	    function() {
	        marker.openInfoWindowHtml(description);
	    }
	);
	
	map.addOverlay(marker);
}
		

// Loads the map and the markers
function loadSpotMaps() {
	if (GBrowserIsCompatible()) {
		
		// Create map with controls and center it
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(center, zoom);

		// Add markers
		for (n in locations) {
			addMarker(locations[n].latitude, locations[n].longitude, locations[n].name);
		}
	}
}
