function loadmap() {
      if (GBrowserIsCompatible()) {
	document.getElementById("map").style.width = "20em";
	document.getElementById("map").style.height = "20em";
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.setCenter(new GLatLng(51.517463,-3.189114), 16);
        var marker = createMarker(new GLatLng(51.517463,-3.189114))
        map.addOverlay(marker);
        marker.openInfoWindowHtml("<p><strong>A J Hales Pharmacy</strong><br>35 St. Isan Road<br />Heath<br>CF14 4LU</p>");
      }
}
// Creates a marker at the given point with the given number label
function createMarker(point) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml("<p><strong>A J Hales Pharmacy</strong><br>35 St. Isan Road<br />Heath<br>CF14 4LU</p>");
        });
        return marker;
}
var directionsPanel;
var directions;
function getdirections() {
        var from = document.getElementById("txtFrom").value;
        if (from != '') {
            var map = new GMap2(document.getElementById("map"));
            map.addControl(new GSmallMapControl());
            directionsPanel = document.getElementById("directions");
            directions = new GDirections(map, directionsPanel);
            GEvent.addListener(directions, "error", handleErrors);
            directions.load(from + " to CF14 4LU");
        }
}
function handleErrors(){
	   alert("Address not found, please try again");
	   loadmap();
}

window.onload = loadmap;
window.onunload = GUnload;