var gmarker;

function directions() {
	GEvent.trigger(gmarker, 'click');
}

function load() {
	if ( GBrowserIsCompatible() ) {
		var map = new GMap2(document.getElementById('map-single'));
		map.enableDoubleClickZoom();
		map.enableScrollWheelZoom();

		// calculate center point
		var point = new GLatLng(coordinate_x, coordinate_y);

		// zoom and pan controls
		map.addControl(new GSmallMapControl());

		// map/satellite/hybrid mode
		map.addControl(new GMapTypeControl());

		// now hide them so they're only visible on mouseover
		map.hideControls();

		GEvent.addListener(map, 'mouseover', function(){
		map.showControls();
		});

		GEvent.addListener(map, 'mouseout', function(){
		map.hideControls();
		});

		// set the center of the map and the zoom level
		map.setCenter(point, 13);

		// add the point to the map
		var marker_point = new GMarker(point);

		gmarker = marker_point;

		map.addOverlay(marker_point);

		GEvent.addListener(marker_point, 'click', function() {
			var html = '<strong>Get to Dearborn Ultimate!<\/strong><br \/><br \/>' +
			'<form action="http://maps.google.com/maps" method="get" target="_blank"><label>Start Address:<\/label> ' +
			'<input type="text" name="saddr" id="saddr" />' +
			'<div style="text-align:center;margin-top: 1em;"><input value="Get Directions!" type="submit"><\/div>' +
			'<input type="hidden" name="f" value="d" />' +
			'<input type="hidden" name="hl" value="en" />' +
			'<input type="hidden" name="daddr" value="'+coordinate_x+','+coordinate_y+'(Dearborn Ultimate)" />' +
			'<input type="hidden" name="sll" value="'+coordinate_x+','+coordinate_y+'" />' +
			'<input type="hidden" name="ie" value="UTF8" />' +
			'<\/form>';
			marker_point.openInfoWindowHtml(html);
		});
	} else {
		$('#map').html('<strong>Your browser is unable to display the map.<\/strong>');
	}
}
