function load () {	
	var map = document.getElementById("map"); //refers to html id
	
	if (GBrowserIsCompatible()) {
	
	var gmap = new GMap2(map);
		gmap.addControl( new GLargeMapControl() ); //Small for 4-way directions only, Large for slide and reset
		gmap.addControl( new GMapTypeControl()); //adds map/satelite/hybrid
		gmap.addControl( new GScaleControl()); //adds scale
		gmap.setCenter ( new GLatLng(52.92505,-2.08544),8 ); //centres map and zoom level

	function makeIcon (image) {
		var icon=new GIcon();
		icon.image= image;
		icon.shadow= "../media/shadow.png";
		icon.iconSize= new GSize(20,34);
		icon.shadowSize= new GSize(37,34);
		icon.iconAnchor= new GPoint(9,34);
		icon.infoShadowAnchor= new GPoint(9,2);
		icon.infoWindowAnchor= new GPoint(15,5);
		icon.transparent="../media/transparent.png";
		icon.imageMap=[9,0,6,1,4,2,2,4,0,8,0,12,1,14,2,16,5,19,7,23,8,26,9,30,9,34,11,34,11,30,12,26,13,24,14,21,16,18,18,16,20,12,20,8,18,4,16,2,15,1,13,0];
		return icon;
	}
		
	function formatTabOne (input) {				
			var html 	 = "<div class=\"bubble\">";
			html 		+= "<h1>" + input.job + "</h1>";			
			html		+= "<img src='" + input.image + "' style='width:64px; height:48px; float:right; margin: 3px' />"
			html 		+= "<p>" + input.information + "</p>";
			html		+= "</div>";					
			return html;			
		}
		
		function formatTabTwo (input) {				
			var html 	 = "<div class=\"bubble\">";
			html 		+= "<h1>" + input.job + "</h1>";
			html		+= "<p>"
			if(input.client != null) {
				html 	+= "<strong>Client:</strong> " + input.client + "<br />";
			}		
			if(input.type != null) {
				html 	+= "<strong>Type:</strong> " + input.type + "<br />";
			}
			if(input.value != null) {
				html 	+= "<strong>Value:</strong> " + input.value + "<br />";
			}
			if(input.duration != null) {
				html    += "<strong>Time on Site:</strong> " + input.duration + "<br />";
			}
			if(input.web != null) {
				html +="<a href='http://chris.kilobox.net/work/"+input.web+".html'>" + input.job + "</a><br />";
			}
			html 		+= "</p></div>";					
			return html;			
		}			
		
		function createMarker(input) {
		
			var marker = new GMarker(input.point, makeIcon(input.markerImage));						
			var tabs_array	= [ new GInfoWindowTab("Preview", formatTabOne(input) ),
			 					new GInfoWindowTab("Information", formatTabTwo(input) ) ];
						
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowTabsHtml(tabs_array);
			});
			
			return marker;
		}
		
		function parseJson (doc) {						
			var jsonData = eval("(" + doc + ")");					
			for (var i = 0; i < jsonData.markers.length; i++) {
				var marker = createMarker(jsonData.markers[i]);
				gmap.addOverlay(marker);
			}			
		}
		GDownloadUrl("points.json", function(data, responseCode) { 
			parseJson(data);
		});
		
	} else {
		alert("Sorry, your browser cannot handle the true power of Google Maps");
	}
}
window.onload = load;
window.onunload = GUnload;