    var map = null;
    var geocoder = null;

    function initGoogleMap() {
      if (GBrowserIsCompatible()) {
	  	// Initialise maps and geocoder
        map = new GMap2(document.getElementById("map_canvas"));
        geocoder = new GClientGeocoder();

		if (p_location != '') {
			if (showAddress(p_location,true)){
			} else {
				// No can't find it, go to default
				showDefault();
			}
            document.getElementById("map_address").value = p_location;
		} else {
			// If all else fails go to default location
			showDefault();
		}
		
        GEvent.addListener(map, "moveend", function() {
          document.getElementById("map_message").innerHTML = '';
          var center = map.getCenter();
          document.getElementById("map_message").innerHTML = 'Co-ordinates: '+center.toString();
        });
        map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
      }
    }

    function showDefault() {
		// Do we have a default lat and long
		if(d_lat != 0 && d_long != 0) {
			map.setCenter(new GLatLng(d_lat , d_long), zoom);
		// Do we have a default location
		} else if (d_location != '') {
			if (!showAddress(d_location,false)){
				// If all else fails go to Alphashare's location
				map.setCenter(new GLatLng(36.54088 , -4.62198), zoom);
			}
		} else {
			// If all else fails go to Alphashar's location
			map.setCenter(new GLatLng(36.54088 , -4.62198), zoom);
		}
	}

    function showAddress(address,display) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
			  if(display) {
              	document.getElementById("map_message").innerHTML = 'Cannot find location '+address;
			  }
			  return false;
            } else {
              map.setCenter(point, zoom);
			  // This adds an information marker
              //var marker = new GMarker(point);
              //map.addOverlay(marker);
              //marker.openInfoWindowHtml(address);
			  return true;
            }
          }
        );
      }
    }

