function onGDirectionsLoad() {
	return true;
}

function getRoute() {
//	alert(dir.GRoute.getNumSteps());
}

function createMarker(point,html) {
	var marker = new GMarker(point);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});
	return marker;
}

var dir;
var map;

function initiate() {
	if (GBrowserIsCompatible()) { 
		// Display the map, with some controls and set the initial location 
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.setCenter(new GLatLng(35.868743,-83.809204),8);

		
		// Set up three markers with info windows 

		var point = new GLatLng(35.868743,-83.809204);
		var marker = createMarker(point,'<div style="width:240px">Brookhaven Retreat</div>');
		map.addOverlay(marker);


	} else {
		alert("Sorry, the Google Maps API is not compatible with this browser");
	}
}

var last_dir = null;

function getDirections() {
	if (last_dir != null) {
		last_dir.clear();
	}

		dir = new GDirections(map, document.getElementById("directions"));

		GEvent.addListener(dir, "load", onGDirectionsLoad); 
		var fromstreet = document.getElementById("fromstreet").value;
		var fromcity = document.getElementById("fromcity").value;
		var fromstate = document.getElementById("fromstate").value;
		var fromzip = document.getElementById("fromzip").value;
		var dirfrom = fromstreet + ", " + fromcity + ", " + fromstate + ", " + fromzip;
		var dirto = "1016 IC King Rd, Seymour, TN, 37865";
		dirstring = "from: " + dirfrom + " to: " + dirto;
		dir.load(dirstring, {getSteps:true});

		last_dir = dir;
}