

if (GBrowserIsCompatible()) 
{
    var map = new GMap2(document.getElementById("map"));

    map.addControl(new GSmallMapControl());

    map.autoReshape = true;
    
    map.setCenter(new GLatLng(51.63847621195153,-1.021728515625), 6);
    
	// 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, text) 
	{
		var endemolIcon = new GIcon(baseIcon);
		endemolIcon.image = "/static/images/gm_icon.png";
		
		// Set up our GMarkerOptions object
		markerOptions = { icon:endemolIcon };
		var marker = new GMarker(point, markerOptions);
		
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(text);
		});
		return marker;
	}                

	// Create a boundary object so we know how to show all points
    var latlngbounds = new GLatLngBounds();
    
    $(offices).each(function() {
    	var point = new GLatLng(this.lat, this.lng);
        map.addOverlay(createMarker(point, this.html));
        latlngbounds.extend( point );
    });

    // Centre and zoom the map so that all points are shown 
    map.setCenter( latlngbounds.getCenter( ), (map.getBoundsZoomLevel( latlngbounds ) - 4) );
    
    
}
    

