var gmarkers = [];
var htmls = [];
var to_htmls = [];
var from_htmls = [];
var i=0;

// A function to create the marker and set up the event window
function createMarker(point,name,html) {
	var marker = new GMarker(point);

	// The info window version with the "to here" form open
	to_htmls[i] = html + '<br>Route berechnen: <b>Hierher<\/b> - <a href="javascript:fromhere(' + i + ')">Von hier<\/a>' +
   '<br>Startadresse:<form action="http://maps.google.com/maps" method="get" target="_blank">' +
   '<input type="text" SIZE=23 MAXLENGTH=50 name="saddr" id="saddr" value="" />&nbsp;' +
   '<INPUT value="Los" TYPE="SUBMIT">' +
   '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() + 
          // "(" + name + ")" + 
   '"/>';
// The info window version with the "to here" form open
from_htmls[i] = html + '<br>Route berechnen: <a href="javascript:tohere(' + i + ')">Hierher<\/a> - <b>Von hier<\/b>' +
   '<br>Zieladresse:<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
   '<input type="text" SIZE=23 MAXLENGTH=50 name="daddr" id="daddr" value="" />&nbsp;' +
   '<INPUT value="Los" TYPE="SUBMIT">' +
   '<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() +
          // "(" + name + ")" + 
   '"/>';
// The inactive version of the direction info
html = html + '<br>Route berechnen: <a href="javascript:tohere('+i+')">Hierher<\/a> - <a href="javascript:fromhere('+i+')">Von hier<\/a>';
map.addOverlay(marker);
marker.openInfoWindowHtml(html);

GEvent.addListener(marker, "click", function() {
  marker.openInfoWindowHtml(html);
});
gmarkers[i] = marker;
htmls[i] = html;
i++;
return marker;
}

// functions that open the directions forms
function tohere(i) {
gmarkers[i].openInfoWindowHtml(to_htmls[i]);
}
function fromhere(i) {
gmarkers[i].openInfoWindowHtml(from_htmls[i]);
}