// JavaScript Document
    var map;
    var gdir;
    var geocoder = null;
    var addressMarker;

    function initialize() {
      if (GBrowserIsCompatible()) {      
        map = new GMap2(document.getElementById("map_canvas"), { size: new GSize(880,361) });
				
//				map.removeMapType(G_HYBRID_MAP);
				
        map.setCenter(new GLatLng(52.332444,4.77126), 12);
				
				map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());

//          var latlng = new GLatLng(52.331200,4.76950);
//          map.addOverlay(new GMarker(latlng));


				
        gdir = new GDirections(map, document.getElementById("directions"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);
				


        // Create a base icon for all of our markers that specifies the
        // shadow, icon dimensions, etc.
        var baseIcon = new GIcon(G_DEFAULT_ICON);
        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        baseIcon.iconSize = new GSize(20, 34);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);

        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        function createMarker(point){
          var letteredIcon = new GIcon(baseIcon);
          letteredIcon.image = "http://www.google.com/mapfiles/marker.png";

          // Set up our GMarkerOptions object
          markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);

          GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml("<h1>TDAVIATION</h1>Schiphol Amsterdam Airport Sloterweg 327,<br />1171 VC, Badhoevedorp The Netherlands");
          });
          return marker;
        }


				
          var latlng = new GLatLng(52.331200,4.76950);
//          map.addOverlay(new GMarker(latlng));
          map.addOverlay(createMarker(latlng, 1));

//52.332444
//4.77126


//        setDirections("San Francisco", "Mountain View", "en_US");
      }
    }
    
//    function setDirections(fromAddress, toAddress, locale) {
//      gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale });
    function setDirections(fromStreet, fromCity){

			var toAddress = 'Sloterweg 327, Badhoevedorp';
			var fromAddress = fromStreet + ' ' + fromCity;
			gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": "en_UK" });

    }

    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		 var errortext = "Addresses not found.";

//	     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
//	     alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
			 var errortext = "A geocoding or directions request could not be successfully processed";   
	   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
//	     alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
			 var errortext = "The HTTP q parameter was either missing or had no value.";   	     
	   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
//	     alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
			 var errortext = "The given key is either invalid or does not match the domain for which it was given.";
	   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
//	     alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
			 var errortext = "A directions request could not be successfully parsed.";
	   else{
//			  alert("An unknown error occurred.");
	 			 var errortext = "A directions request could not be successfully parsed.";
		 }
		 
			 $("#directions").hide();
			 $("#directions").html(errortext);
			 $("#directions").addClass("gmapsError").show("slow");
	}

	function onGDirectionsLoad(){ 
      // Use this function to access information about the latest load()
      // results.

      // e.g.
      // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  // and yada yada yada...
	}
