var rootsite = "http://www.erotischcentrumweimar.nl/";
var adres = "Weimarstraat 106, 2562 HB Den Haag";
var map = null;
var geocoder = null;
var loadgooglemaps = function() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.setMapType(G_PHYSICAL_MAP);
		geocoder = new GClientGeocoder();
		map.setUIToDefault();
		geocoder.getLatLng(adres, function(point) {
			if (point) {
				set_naar(point);
				map.setCenter(point, 13);
				map.addOverlay(createmarker(point, getsitemarker()));
				if(typeof loadRoute == 'function') { 
					loadRoute(); 
				}
			}
		});
	}
}
var print_page = function() {
	window.print();
	return false;
}
var popuproute = function(adres){
	if(adres == ""){
		alert("Vul aub eerst een geldig adres in.");
	} else {
		var winl = (screen.width-700)/2;
		var wint = (screen.height-700)/2;
		var winpops=window.open(rootsite + "pages/routepopup/"+adres+"/","","width=700,height=700,top="+wint+",left="+winl+",scrollbars");
	}
}

var set_naar = function(point) {
	naar = point;
}
var getsitemarker = function () {
	var icon = new GIcon();
	icon.image = rootsite+"img/marker.png";
	icon.iconSize = new GSize(30, 45);
	icon.iconAnchor = new GPoint(10, 30);
	icon.infoWindowAnchor = new GPoint(5, 1);
	return icon;
}
var createmarker = function (point, icon) {
	return new GMarker(point, icon);
}
var wijsdeweg = function (van) {
	geocoder.getLatLng(van, function(point) {if (point) {wijsdeweg_vanpoint(point);}});
}
var wijsdeweg_vanpoint = function (point) {
	directions = new GDirections(map, document.getElementById('stappen'));
	GEvent.addListener(directions, "error", directionerrors);
	GEvent.addListener(directions, "load", directionload);
	map.clearOverlays();
	directions.loadFromWaypoints(new Array(point, naar));
}
var directionerrors = function(){
	if (directions.getStatus().code == G_GEO_UNKNOWN_ADDRESS) alert("Het adres dat u heeft opgegeven bestaat niet of wordt niet door ons systeem herkend.");
}
var directionload = function() {
	directions.getMarker(0).getIcon().image = rootsite+"/img/home_marker.png"; 
	directions.getMarker(0).getIcon().iconSize = new GSize(30, 45);
	directions.getMarker(1).getIcon().image = rootsite+"/img/marker.png"; 
	directions.getMarker(1).getIcon().iconSize = new GSize(30, 45);
}
