		google.load("maps", "2.x");

		var map;
		var gdir;
		var markerOptions;
    function loadMap() {
			map = new GMap2(document.getElementById("googlemap"));
			gdir = new GDirections(map, document.getElementById("googledirections"));
			//GEvent.addListener(gdir, "load", onGDirectionsLoad);
			GEvent.addListener(gdir, "error", handleErrors);


			// center map around Novagraaf
			map.setCenter(new GLatLng(52,-1.5),6);
			
			// add map controlls
      map.addControl(new GSmallMapControl());
      //map.addControl(new GMapTypeControl());

			// Put Novagraaf info
			putMarker('13 Northburgh Street, London EC1V 0JP','J.E. Evans-Jackson & Co Ltd<br>Hillgate Patent Services<br>Parchment House<br>13 Northburgh Street<br>London EC1V 0JP')			
			putMarker('42-44 Fountain Street, MANCHESTER M2 2AX', 'William A Shepherd & Son<br>Spring House, 1st Floor<br>42-44 Fountain Street<br>MANCHESTER M2 2AX');
			putMarker('54 Blossom Street, York YO24 1AP', 'Novagraaf Patents Ltd<br>The Crescent<br>54 Blossom Street<br>York YO24 1AP');
			putMarker('12 Meridian Way, Norwich NR7 0TA', 'Novagraaf Norwich Ltd<br>12 Meridian Way<br>Meridian Business Park<br>Norwich NR7 0TA');
			putMarker('2 Gayton Road, Harrow HA1 2XU', 'QED Intellectual Property Limited<br>Harrow Exchange<br>2 Gayton Road<br>Harrow HA1 2XU');
		}

		function putMarker(address, html) {
			var geocoder = new GClientGeocoder;
			geocoder.getLatLng(address, function(point) {			
				var marker = createMarker(point, html);
				map.addOverlay(marker);
			});
		}
    
		function createMarker(point,html) {
			var icon = new GIcon(G_DEFAULT_ICON);
			icon.image = "http://www.google.com/mapfiles/markerN.png";

			var marker = new GMarker(point, {icon: icon});
			GEvent.addListener(marker, "click", function(point) {
			shtml = '<form action="#" onSubmit="setDirections(this.fromaddress.value, this.toaddress.value); return false">' +
				'From: <input type="text" SIZE=24 MAXLENGTH=40 name="fromaddress" id="fromaddress" value="" class="txtfld" />' +
				'<INPUT value="Driving instructions" TYPE="image" SRC="/images/nl/search.png">' +
				'<br>(street, number, town zip)' +
				'<input type="hidden" name="toaddress" value="' + point.lat() + ',' + point.lng() + '"/>' +
				'</form>To:<br>' + html;
				marker.openInfoWindowHtml(shtml);
			});
			return marker;
		}

    function setDirections(fromAddress, toAddress) {
			map.closeInfoWindow();
      gdir.load("from: " + fromAddress + " to: " + toAddress,
      { "locale": 'en-gb' });
    }
		
		function handleErrors(){
			if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
				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.");
			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.");
			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.");

  //   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
  //     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);

			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.");
			else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
				alert("A directions request could not be successfully parsed.");
			else alert("An unknown error occurred.");

}
		
    google.setOnLoadCallback(loadMap);