/*******************************************************************************
 * Google Maps with Directions
 ******************************************************************************/


function GmapLoad() {
	if (GBrowserIsCompatible()) {

		// Karte
        var map = new GMap2(document.getElementById("gmap_canvas"));
		map.setCenter(new GLatLng(50.778752,6.107433), 13, G_NORMAL_MAP);
		var customUI = map.getDefaultUI();
		map.setUI(customUI);

		// Marker
		marker = new GMarker(new GLatLng(50.7698296,6.1030349));
		map.addOverlay(marker);

 		// Infofenster mit Routenberechnung
		marker.openRouteInfoWindow = getRouteInfoWindow;
		// Hier die Adresse des Markers eintragen
		marker.openRouteInfoWindow_targetName = "Oppenhoffallee 41, 52066 Aachen";
		// Hier HTML eintragen, das oben im InfoFenster erscheinen soll.
		marker.openRouteInfoWindow_html = '<p class="p_fliesstext" style="border-bottom:1px solid #999;">WAHLE DESIGN<br />Oppenhoffallee 41, 52066 Aachen<br />Tel. +49. 241. 441 07 22</p>';
		//marker.openInfoWindowHtml(marker.openRouteInfoWindow_html);
		marker.openRouteInfoWindow();

    }
  }



function getRouteInfoWindow(sAction) {
	// this ist marker	
	var LatLong = this.getLatLng();

	var aDisplay = ["block", "none", "none"];
	if (sAction == "to") aDisplay = ["none", "block", "none"];
	else if (sAction == "from") aDisplay = ["none", "none", "block"];

	var sTargetName = this.openRouteInfoWindow_targetName;
	var sHtml = this.openRouteInfoWindow_html;
	
   	// Info Window: Route
	sHtml +=	'<div style="display:'+aDisplay[0]+';">' +
				'<p class="p_fliesstext">Route berechnen: <a href="javascript:ShowRoute(\'to\');">Hierher</a> - <a href="javascript:ShowRoute(\'from\');">Von hier</a></p>' +
				'</div>';

	// Info Window: Hierher
	sHtml += 	'<div style="display:'+aDisplay[1]+';">' +
  				'<p class="p_fliesstext">Route berechnen: <b>Hierher</b> - <a href="javascript:ShowRoute(\'from\');">Von hier</a>' +
				'<br /><strong>Startadresse:</strong></p><form action="http://maps.google.com/maps" method="get" target="_blank">' +
				'<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br />' +
				'<input value="Route berechnen" TYPE="SUBMIT">';
    if (sTargetName != "")
			sHtml += '<input type="hidden" name="daddr" value="'+sTargetName+'" />';
	else	sHtml += '<input type="hidden" name="daddr" value="'+LatLong.lat()+','+LatLong.lng()+'" />';
	sHtml +=  '</form></div>';
          	            
        // Info Window: von hier
	sHtml += 	'<div style="display:'+aDisplay[2]+';">' +
				'<p class="p_fliesstext">Route berechnen: <a href="javascript:ShowRoute(\'to\');">Hierher</a> - <b>Von hier</b>' +
				'<br /><strong>Zieladresse:</strong></p><form action="http://maps.google.com/maps" method="get" target="_blank">' +
				'<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br />' +
				'<input value="Route berechnen" TYPE="SUBMIT">';
    if (sTargetName != "")
			sHtml += '<input type="hidden" name="saddr" value="'+sTargetName+'" />';
    else	sHtml += '<input type="hidden" name="saddr" value="'+LatLong.lat()+','+LatLong.lng()+'" />';
	sHtml +=  '</form></div>';

	this.closeInfoWindow();	
	this.openInfoWindow(sHtml);
	}




function ShowRoute(sAction) {
	marker.openRouteInfoWindow(sAction);
	}









