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;
}

function addToMap(response)
   {
      // Retrieve the object
      place = response.Placemark[0];

      // Retrieve the latitude and longitude
      point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);

      // Center the map on this point
      map.setCenter(point, 13);

      // Create a marker
      marker = new GMarker(point);

      // Add the marker to map
      map.addOverlay(marker);

      // Add address information to marker
      marker.openInfoWindowHtml("<h2 style='background-image: none'>" + companyname + "</h2><p>Priority Central Office Condominiums<br>4405 Central Avenue Pike, Suite 103<br>Knoxville, TN 37912</p>");
   }

var dir;
var map;
var geocoder;
var address = "4405 Central Avenue Pike, Knoxville, TN, 37912";
var companyname = "ARG Financial Staffing";

function initiate() {
	if (GBrowserIsCompatible()) { 
		// Display the map, with some controls and set the initial location 
		map = new GMap2(document.getElementById("GST_gmap"));
		map.addControl(new GLargeMapControl());
		geocoder = new GClientGeocoder();
		geocoder.getLocations(address, addToMap);
	} 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("GST_gmap_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 = "1111 Northshore Dr NW, Knoxville, TN 37919";
		var dirto = address;
		dirstring = "from: " + dirfrom + " to: " + dirto;
		dir.load(dirstring, {getSteps:true});

		last_dir = dir;
}

addLoadEvent(initiate);
