//<![CDATA[
			   
//functie die de printerknop toont en verbergt
function PrinterKnop() { //v9.0
  var i,p,v,obj,args=PrinterKnop.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


   if (GBrowserIsCompatible()) {
      var side_bar_html = "";
      var gmarkers = [];
      var htmls = [];
      var i = 0;
      // arrays to hold variants of the info window html with get direction forms open
            var icon = new GIcon();
			icon.image 					= "http://www.hamiltonhill.com/2008/img/google.png";
			icon.iconSize 				= new GSize(61, 14);
			icon.iconAnchor = new GPoint(0, 14);
			icon.infoWindowAnchor = new GPoint(57, 12);

      // A function to create the marker and set up the event window
      function createMarker(point,name,html) {
        var marker = new GMarker(point,icon);

       // Hieronder wordt de inhoud van de tekstballon bepaald
        html = '<span style="color: #000000"> <b>Hamilton Hill B.V.</b><br />Dreef 34<br />2012 HS Haarlem</span>';

        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
       // Opvragen marker
       	gmarkers[i] = marker;
   	 	htmls[i] = html;
        
 		side_bar_html += '<a href="javascript:myclick(' + i + ')">' + name + '</a><br>';
 		i++;
 		return marker;
	       }

      // ===== opvragen route =====
      function getDirections() {
        var saddr = document.getElementById("saddr").value
        var daddr = document.getElementById("daddr").value
        gdir.load("from: "+saddr+" to: "+daddr);
	    PrinterKnop('printbutton','','show');
      }

      // functions that open the directions forms
      function tohere(i) {
        gmarkers[i].openInfoWindowHtml(to_htmls[i]);
      }
      function fromhere(i) {

        gmarkers[i].openInfoWindowHtml(from_htmls[i]);
		
      }


      // create the map
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GSmallMapControl());

      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(52.371068,4.628897), 16);
	  map.setMapType(G_HYBRID_MAP); 
	  

      // === create a GDirections Object ===
      var gdir=new GDirections(map, document.getElementById("directions"));
	  

      // === Array for decoding the failure codes ===
      var reasons=[];
      reasons[G_GEO_SUCCESS]            = "Success";

      reasons[G_GEO_MISSING_ADDRESS]    = "Geen adres: Er is geen adres ingevoerd.";
      reasons[G_GEO_UNKNOWN_ADDRESS]    = "Onbekend adres:  Het adres kon niet gevonden worden";
      reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
      reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
      reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
      reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
      reasons[G_GEO_BAD_REQUEST]        = "A directions request could not be successfully parsed.";
      reasons[G_GEO_MISSING_QUERY]      = "No query was specified in the input.";
      reasons[G_GEO_UNKNOWN_DIRECTIONS] = "De routeberekening kan om technische redenen niet worden uitgevoerd";

      // === Errors in de route zoeken ===
      GEvent.addListener(gdir, "error", function() {
        var code = gdir.getStatus().code;
        var reason="Code "+code;	
		
        if (reasons[code]) {
          reason = reasons[code]
        } 
		PrinterKnop('printbutton','','hide');
        alert("De route werd niet berekend. "+reason);
		
      });

      

      // Read the data from example.xml
      var request = GXmlHttp.create();
      request.open("GET", "xml/googleadres.xml", true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {
          var xmlDoc = GXml.parse(request.responseText);
          // obtain the array of markers and loop through it
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");
          
          for (var i = 0; i < markers.length; i++) {
            // obtain the attribues of each marker
            var lat = parseFloat(markers[i].getAttribute("lat"));
            var lng = parseFloat(markers[i].getAttribute("lng"));
            var point = new GLatLng(lat,lng);
            var html = markers[i].getAttribute("html");
            var label = markers[i].getAttribute("label");
            // create the marker
            var marker = createMarker(point,label,html);
            map.addOverlay(marker);
          }
        }
      }
      request.send(null);
	  

    }

    else {
      alert("Sorry, Googlemaps kan niet door uw browser worden getoond.");
    }

//]]>
