// JavaScript Document

function startRouteInteraktiv() {
	var modus = 0;
	var gmark0, gmark1;
	var directions;
	map.clearOverlays();
	var listener = GEvent.addListener(map, "click", function(overlay, point) {
		if (modus == 0) {
			//set marker one
			map.clearOverlays();
			gmark0 = new GMarker(point);
			//gmark1.openInfoWindow(modus);
			map.addOverlay(gmark0);
			//gmark0.openInfoWindow("Start " + modus);
		}
	
		if (modus == 1) {
			//set marker two
			gmark1 = new GMarker(point);
			map.addOverlay(gmark1);
			//gmark1.openInfoWindow("Finish " + modus);
	
			//find way from marker one to marker two
			var start = "Start@" + gmark0.getPoint().lat() +", " + gmark0.getPoint().lng();
			var finish = "Finish@" + gmark1.getPoint().lat() +", " + gmark1.getPoint().lng();
			directions = new GDirections(map, document.getElementById("directions"));
			directions.loadFromWaypoints([start, finish]);
			//access polygon through directions.getPolyline();
			//see http://www.google.com/apis/maps/documentation/reference.html#GDirections
			GEvent.removeListener(listener);
		} 
		modus = (modus + 1 )%2;
        });
}
