	
	var AlphenPoint = new GLatLng(52.1339482, 4.6306306);
	
	var PointSelected = "Maatschapslaan 15, Alphen aan den Rijn, Netherlands";
	var directions = null;

    function mapload() {
      if (GBrowserIsCompatible()) {
	  
        var map = new GMap2($('map'));
        map.setCenter(AlphenPoint, 15);
		//map.addControl(new ToonzalenControl());
		map.addControl(new RouteControl());
		map.addControl(new GSmallMapControl());
		map.addOverlay(createMarker(AlphenPoint,"<strong>PriMatras.NL</strong><br />Maatschapslaan 15<br />Alphen aan den Rijn"));

      } else {
		alert("Your browser is incompatible with Google Maps!");
	  }
    }
	
	function ToonzalenControl() {
	}
	ToonzalenControl.prototype = new GControl();
	
	ToonzalenControl.prototype.initialize = function(map) {
	  var container = document.createElement("div");
	
	  var alphenDiv = document.createElement("div");
	  this.setButtonStyle_(alphenDiv);
	  container.appendChild(alphenDiv);
	  alphenDiv.appendChild(document.createTextNode("Alphen a/d Rijn"));
	  GEvent.addDomListener(alphenDiv, "click", function() {
		PointSelected = "Maatschapslaan 15, Alphen aan den Rijn, Netherlands";
		map.panTo(AlphenPoint);
	  });
	
	  map.getContainer().appendChild(container);
	  return container;
	}
	
	ToonzalenControl.prototype.getDefaultPosition = function() {
	  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
	}
	
	ToonzalenControl.prototype.setButtonStyle_ = function(button) {
	  button.style.textDecoration = "underline";
	  button.style.color = "#0000cc";
	  button.style.backgroundColor = "white";
	  button.style.font = "small Arial";
	  button.style.border = "1px solid black";
	  button.style.padding = "2px";
	  button.style.marginBottom = "3px";
	  button.style.textAlign = "center";
	  button.style.width = "8em";
	  button.style.cursor = "pointer";
	}
	
	function RouteControl() {
	}
	RouteControl.prototype = new GControl();
	
	RouteControl.prototype.initialize = function(map) {
	  var container = document.createElement("div");
	
	  var invoer = document.createElement("input");
	  this.setInputStyle_(invoer);
	  container.appendChild(invoer);
	  invoer.value = "<uw adres>";
	  GEvent.addDomListener(invoer, "click", function() {
		if(invoer.value == "<uw adres>"){invoer.value="";}
	  });
	  
	  var button = document.createElement("input");
	  button.type="button";
	  button.name="route";
	  button.value="Route";
	  container.appendChild(button);
	  GEvent.addDomListener(button, "click", function() {
			directionsPanel = document.getElementById("route");
			
			if(directions != null){
				directions.clear();
			}
			directions = new GDirections(map, directionsPanel);
			GEvent.addListener(directions, "error", function() {
  				alert("Uw adres kon niet worden gevonden.\n\nVoer uw adres op de volgende wijze in:\nstraat huisnummer, plaats");
				invoer.value="";
			});
 			directions.load("from: "+invoer.value+", to: "+PointSelected , { "locale": "nl" });
	  });
	
	  map.getContainer().appendChild(container);
	  return container;
	}
	
	RouteControl.prototype.getDefaultPosition = function() {
	  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(50, 5));
	}
	
	RouteControl.prototype.setInputStyle_ = function(inputbox) {
	  inputbox.style.textDecoration = "none";
	  inputbox.style.color = "#0000cc";
	  inputbox.style.backgroundColor = "white";
	  inputbox.style.font = "small Arial";
	  inputbox.style.textAlign = "left";
	  inputbox.style.width = "13em";
	}
	
	function createMarker(point, text) {
  		var marker = new GMarker(point);
  		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(text);
  		});
 	 return marker;
	}

