/**
 * (c) Copyright 2008 Speedtrap.org.
 *
 */

var objMap = null;
var objMarker = null;

function addMarker( objMarkerPoint )
{
	// Center the map at the new location
	objMap.setCenter( objMarkerPoint, 15 );

	// Re-create the marker object
	var objMarker = new GMarker( objMarkerPoint );

	// Add the new marker to the map
	objMap.addOverlay( objMarker );
}


window.addEvent( 'domready', function()
{
	// If we have long/lat coordinates, show the map and pluck down a marker
	strLong = $( 'longitude_value' ).get( 'html' );
	strLat = $( 'latitude_value' ).get( 'html' );

	if( strLong.length > 2 && strLat.length > 2 )
	{
		if( GBrowserIsCompatible())
		{
			// Create the map on the page
			objMap = new GMap2( document.getElementById( 'map_canvas' ) );
			objMap.addControl( new GSmallMapControl());
			objMap.addControl( new GMapTypeControl());
		}

		// Create our new marker object
		addMarker( new GLatLng( strLat, strLong, true ));
	}
});
