var points = [];
var markers = [];
var counter = 0;
var map = null;

function GLoad() {
	if (GBrowserIsCompatible()) {
		var mapObj = document.getElementById("map");
		if (mapObj != "undefined" && mapObj != null) {
			map = new GMap2(document.getElementById("map"));
			map.setCenter(new GLatLng(52.303300, 5.147280), 15, G_NORMAL_MAP);
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			var point = new GLatLng(52.3033,5.14728);
			var marker = createMarker(point,"Rubberstraat 10, Naarden, Nederland","<div id=\"gmapmarker\"><div style=\"font-family:Verdana;font-size:11px;\"><strong>Leuwico Nederland BV<\/strong><br \/>Rubberstraat 10, Naarden, Nederland<\/div><\/div>", 0,"");
			map.addOverlay(marker);
		}
	} else {
		alert("Sorry, the Google Maps API is not compatible with this browser.");
	}
}

function createMarker(point, title, html, n, tooltip) {
	if(n >= 0) { n = -1; }
	var marker = new GMarker(point,{'title': tooltip});
	var tabFlag = isArray(html);
	if(!tabFlag) { html = [{"contentElem": html}]; }
	html[0].contentElem = html[0].contentElem + '<br /><form class="gmapDir" id="gmapDirTo" style="white-space: nowrap;" action="http://maps.google.com/maps" method="get" target="_blank">' +
	'<p style=\"margin-left:0px; padding-bottom:0px;width:265px;\" class="gmapDirItem" id="gmapDirItemTo"><label style=\"font-family:Verdana;font-size:11px;\" for="gmapDirSaddr" class="gmapDirLabel" id="gmapDirLabelTo">Start adres: (bijv. straat, plaats)<br /></label>' +
	'<input style=\"font-family:Verdana;font-size:11px;margin-left:0;\" type="text" size="30" maxlength="100" name="saddr" class="gmapTextBox" id="gmapDirSaddr" value="" onfocus="this.style.backgroundColor = \'#e0e0e0\';" onblur="this.style.backgroundColor = \'#fff\';" />' +
	'<span class="gmapDirBtns" id="gmapDirBtnsTo"><input style=\"font-family:Verdana;font-size:11px;\" value="Plan route" type="submit" class="gmapDirButton" id="gmapDirButtonTo" /></span>' +
	'<input type="hidden" name="daddr" value="' + point.y + ',' + point.x + "(" + title.replace(new RegExp(/"/g),'&quot;') + ")" + '" /></form>';
	if(!tabFlag) { html = html[0].contentElem; }if(isArray(html)) { GEvent.addListener(marker, "mouseover", function() { marker.openInfoWindowTabsHtml(html); }); }
	else { GEvent.addListener(marker, "mouseover", function() { marker.openInfoWindowHtml(html); }); }
	points[counter] = point;
	markers[counter] = marker;
	counter++;
	return marker;
}

function isArray(a) { return isObject(a) && a.constructor == Array; }
function isObject(a) { return (a && typeof a == 'object') || isFunction(a); }
function isFunction(a) { return typeof a == 'function'; }
function showInfoWindow(idx,html) {
	map.centerAtLatLng(points[idx]);
	markers[idx].openInfoWindowHtml(html);
}
function tohere(idx) { markers[idx].openInfoWindowHtml(to_htmls[idx]); }
function fromhere(idx) { markers[idx].openInfoWindowHtml(from_htmls[idx]); }

