
google.load("maps",2);

ll1=50.635971;
ll2=7.10614;
tabs=[];
myHtml="<div id=\"gmapmarker\"><p><p><strong>GaLaBau Hans Peter Schroth</strong><br />Gimmersdorfer Str. 79<br />53343 Wachtberg - Villip<br /></p><\/p><\/div>";
counter=0;
to_htmls = [];
from_htmls = [];
markers=[];

function initGmaps(){
	var map=new google.maps.Map2(document.getElementById('googlemaps'));
	var point=new google.maps.LatLng(ll1,ll2);
	map.setCenter(point,16);
	var marker=new google.maps.Marker(point);
	
	var routes='';
	to_htmls[counter] = 	routes+'<form class="gmapDir" id="gmapDirTo" style="white-space: nowrap;" action="http://maps.google.com/maps" method="get" target="_blank">' +
        					'<span class="gmapDirHead" id="gmapDirHeadTo">Route berechnen: <strong>Hierher</strong> - <a href="javascript:fromhere(' +
					        counter +
					        ')">Von hier</a></span>' +
					        '<p class="gmapDirItem" id="gmapDirItemTo"><label for="gmapDirSaddr" class="gmapDirLabel" id="gmapDirLabelTo">Start:<br /></label>' +
					        '<input type="text" size="16" maxlength="40" name="saddr" class="gmapTextBox" id="gmapDirSaddr" value="" onfocus="this.style.backgroundColor = \'#e0e0e0\';" onblur="this.style.backgroundColor = \'#ffffff\';" />' +
					        '<span class="gmapDirBtns" id="gmapDirBtnsTo"><input value="Los!" type="submit" class="gmapDirButton" id="gmapDirButtonTo" /></span></p>' +
					        '<input type="hidden" name="daddr" value="' +
					        point.y +
					        ',' +
					        point.x +
					        '" /></form>';
	from_htmls[counter] = 	routes+'<p /><form class="gmapDir" id="gmapDirFrom" style="white-space: nowrap;" action="http://maps.google.de/maps" method="get" target="_blank">' +
							'<span class="gmapDirHead" id="gmapDirHeadFrom">Route berechnen: <a href="javascript:tohere(' +
							counter +
        					')">Hierher</a> - <strong>Von hier</strong></span>' +
        					'<p class="gmapDirItem" id="gmapDirItemFrom"><label for="gmapDirSaddr" class="gmapDirLabel" id="gmapDirLabelFrom">Ziel:<br /></label>' +
        					'<input type="text" size="16" maxlength="40" name="daddr" class="gmapTextBox" id="gmapDirSaddr" value="" onfocus="this.style.backgroundColor = \'#e0e0e0\';" onblur="this.style.backgroundColor = \'#ffffff\';" />' +
        					'<span class="gmapDirBtns" id="gmapDirBtnsFrom"><input value="Los!" type="submit" class="gmapDirButton" id="gmapDirButtonFrom" /></span></p>' +
        					'<input type="hidden" name="saddr" value="' +
        					point.y + ',' + point.x + '" /></form>';
	routes = routes + '<p /><div id="gmapDirHead" class="gmapDir" style="white-space: nowrap;">Route berechnen: <a href="javascript:tohere(' + counter + ')">Hierher</a> - <a href="javascript:fromhere(' + counter + ')">Von hier</a></div>';
	
	
	
	tabs.push(new google.maps.InfoWindowTab('Adresse',myHtml))
	tabs.push(new google.maps.InfoWindowTab('Anfahrt',routes))
	
	marker.openInfoWindowTabsHtml(tabs);

	map.addOverlay(marker);
	
	google.maps.Event.addListener(marker,'click',function(){
		marker.openInfoWindowTabsHtml(tabs);
	})
	markers[counter] = marker;
}

function tohere(idx){
    markers[idx].openInfoWindowHtml(to_htmls[idx]);
}

function fromhere(idx){
    markers[idx].openInfoWindowHtml(from_htmls[idx]);
}


google.setOnLoadCallback(initGmaps);
