function load () {
	
	var map = document.getElementById("map");
	
	if (GBrowserIsCompatible()) {

		var gmap = new GMap2(map);
		gmap.addControl( new GSmallMapControl() );
		gmap.addControl( new GMapTypeControl()) ;
		gmap.addControl( new GOverviewMapControl(new GSize(100,100)) );		
		gmap.setCenter ( new GLatLng(54.15, -2.1333333), 9 );
		
		function makeIcon (image) {
			var icon = new GIcon();
			icon.image = image;
			icon.shadow = "images/shadow.png";
			icon.iconSize = new GSize(160, 32);
			icon.shadowSize = new GSize(59, 32);
			icon.iconAnchor = new GPoint(8, 16);
			icon.infoShadowAnchor = new GPoint(0, 0);
			icon.infoWindowAnchor = new GPoint(8, 1);	
			return icon;
		}
		
		function formatTabOne (input) {				
			var html 	 = "<div class=\"bubble\">";
			html 		+= "<h1>" + input.destination + "</h1>";			
			html 		+= "<p class=\"googlebubble\">" + input.information + "</p>";
			html		+= "</div>";					
			return html;			
		}
		
		function formatTabTwo (input) {
			var html 	 = "<div class=\"bubble\">";
			html 		+= "<h1>" + input.destination + "</h1>";
			html		+= "<p class=\"googlebubble\">"
			if(input.hours != null) {
				html 	+= "<strong>Hours:</strong> " + input.hours + "<br />";
			}		
			if(input.telephone != null) {
				html 	+= "<strong>Telephone:</strong> " + input.telephone + "<br />";
			}
			if(input.email != null) {
				html 	+= "<strong>Email:</strong> " + input.email + "<br />";
			}
			if(input.tv != null) {
				html 	+= "<strong>TV Station:</strong> " + input.tv + "<br />";
			}
			html 		+= "</p></div>";					
			return html;			
		}
					
	    function createMarker(input) {
		
			var marker = new GMarker(input.point, makeIcon(input.markerImage) );						
			var tabs_array	= [ new GInfoWindowTab("Address", formatTabOne(input) ),
			 					new GInfoWindowTab("Contact", 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("point05.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;