
	var bError				= false;
	var bDebugMode			= false;
	var bShowInfoWindow	= true;

	var aGMarkers	= [];
	var aTabHTML	= [];
	var aInfoTabs	= [];

	var oPoint		= null;
	var oMap			= null;
	var oMarker		= null;
	var oGeoCoder	= new GClientGeocoder();

	var i				= 0;
	var iLatInfo	= 0;
	var iLonginfo	= 0;
	var sTabInfo	= 0;
	var iCount		= 0;
	var iPlotCount = 0;
	var iZoom		= 12;
	var iLatitude, iLongitude;

	var sDebugInfo	= "";
	var sAddress, sMiscInfo;

	function GLoad () {
		WriteDebugInfo('GLoad');

		try {
			//retrieve the details we will use when setting up the map
			sAddress		= document.getElementById("Googlemap_Address").innerHTML;
			iLongitude	= document.getElementById("Googlemap_Longitude").innerHTML;
			iLatitude	= document.getElementById("Googlemap_Latitude").innerHTML;
			sMiscInfo	= document.getElementById("Googlemap_MiscInfo").innerHTML;
			iZoom			= document.getElementById("Googlemap_ZoomLevel").innerHTML;

			//Check to see if we have a longitude value
			if ( iLongitude.length > 0 ) {
				//Ensure our longitude value is a number
				if ( !IsNumberG(iLongitude,false) ) {
					bError = true;
				}
				else {
					iLongitude = Number(iLongitude);
				}
			}
			else {
				iLongitude = 0;
			}

			//Check to see if we have a latitude value
			if ( iLatitude.length > 0 ) {
				//Ensure our latitude is a number
				if ( !IsNumberG(iLatitude,false) ) {
					bError = true;
				}
				else {
					iLatitude = Number(iLatitude);
				}
			}
			else {
				iLatitude = 0;
			}

			//ensure we have something to search on
			if ( sAddress.length == 0 && iLongitude == 0 && iLatitude == 0 ) {
				bError = true;
			}

			//Ensure our zoom level is a number
			if ( !IsNumberG(iZoom,true) ) {
				bError = true;
			}
			else {
				iZoom = Number(iZoom);
			}

			if ( document.getElementById("Googlemap_InfoWindow").innerHTML == "false" ) {
				bShowInfoWindow = false;
			}
		}
		catch(err) {
			bError = true;
		}

		//Do not continue if we have encountered errors
		if ( !bError ) {
			if ( GBrowserIsCompatible() ) {
				IntialiseMap();
			}
			else {
				alert("Sorry, the Google Maps API is not compatible with this browser");
			}
		}
		else {
			HandleProblems();
		}
	}

	function HandleProblems() {
		//Hide our map
		document.getElementById("google_map").style.display = "none";

		//Display our error message
		document.getElementById("google_debuginfo").innerHTML		= '<p><strong>Unable to display map at this time...</strong></p>';
		
		//Show our error message
		if ( document.getElementById("google_debuginfo").style.display == "none" ) {
			document.getElementById("google_debuginfo").style.display = "";
		}
	}

	function IntialiseMap () {
		WriteDebugInfo('IntialiseMap');

		//Show our status if it is currently hidden
		if ( document.getElementById("google_map").style.display == "none" ) {
			document.getElementById("google_map").style.display = "";
		}

		// establishes the map and sets the controls needed - 12 is the zoom level
		oMap = new GMap2(document.getElementById("google_map"));
		oMap.addControl(new GSmallMapControl());

		CentreMapToLocation();
	}

	function CentreMapToLocation () {
		WriteDebugInfo('CentreMapToLocation');

		//Use our coordinates as a preference if they exist otherwise use our address
		if ( iLatitude != 0 && iLongitude != 0 ) {
			iLatInfo		= iLatitude;
			iLonginfo	= iLongitude;
		}
		else {
			//retrieve location
			GetPointFromLocation();
		}

		bCheckCentreCoords();
	}

	function GetPointFromLocation() {
		oGeoCoder.getLatLng(sAddress,
			function(newpoint) {
				if (!newpoint) {
					HandleProblems();
				} else {
					SetLatandLong(newpoint);
				}
			}
		);
	}

	function bCheckCentreCoords () {
		WriteDebugInfo('bCheckCentreCoords');

		if ( iLatInfo == 0 || iLonginfo == 0 ) {
			iCount = iCount + 1;

			if ( iCount < 20 ) {
				setTimeout(bCheckCentreCoords,200);
			}
			else {
				iCount = 0
				WriteDebugInfo('Cannot obtain coordinates. Try again later.');
			}
		}
		else {
			RecentreMapToCoords();
		}
	}

	function RecentreMapToCoords () {
		//create our point using the lat and long we found earlier
		oPoint = new GLatLng(iLatInfo, iLonginfo);

		//Set up our centre point
		oMap.setCenter(oPoint, iZoom);

		// Draw marker at our centre point
		//oMarker = new GMarker(oPoint);
		//oMap.addOverlay(oMarker);

		//Now name our new marker with some info
		//aInfoTabs = [new GInfoWindowTab("Info",sMiscInfo)];
		//oMarker = createMarker(oPoint,"Marker001",aInfoTabs);

		//reset our point information
		//oPoint = null;

		//reset our coordinates for the future address
		iLatInfo		= 0;
		iLonginfo	= 0;

		setTimeout(PlotPoint,500);
	}

	function PlotPoint () {
		WriteDebugInfo('PlotPoint(' + iPlotCount + ')');

		//now that we have long and lat in our array just use that
		iLonginfo	= aLongitude[iPlotCount];
		iLatInfo		= aLattitude[iPlotCount];
		sTabInfo		= aTabInfo[iPlotCount]

		//create our point using the lat and long we found earlier
		oPoint = new GLatLng(iLatInfo, iLonginfo);

		//create the info tabs with our content (above)
		aInfoTabs = [new GInfoWindowTab("Info",sTabInfo)];

		//now combine it all together to a point on the map
		oMarker = createMarker(oPoint,iPlotCount,aInfoTabs);

		WriteDebugInfo("iPlotCount " + iPlotCount + " added to map. Coords : " + aLongitude[iPlotCount] + " by " + aLattitude[iPlotCount] + " Info " + aTabInfo[iPlotCount]);

		//reset our info tab
		aInfoTabs = [];

		// now that this plot has finished we can do the next one (if we have more)
		if ( iPlotCount < aLongitude.length-1 ) {
			//reset our coordinates for this new address
			iLatInfo		= 0;
			iLonginfo	= 0;

			iPlotCount++;

			PlotPoint();
		}
	}
	function WriteDebugInfo (sInfo) {
		if ( bDebugMode ) sDebugInfo = document.getElementById("google_debuginfo").innerHTML;
		if ( bDebugMode ) sDebugInfo = sDebugInfo + sInfo + "<br />";
		if ( bDebugMode ) document.getElementById("google_debuginfo").innerHTML = sDebugInfo;
	}

	function createMarker(oPoint,sName,aInfoTabs) {
		var Icon = new GIcon();
			 Icon.image = "js/arrow.png";
			 Icon.iconSize = new GSize(39, 34);
			 Icon.shadow = "js/arrow_shaddow.png";
			 Icon.shadowSize = new GSize(39, 34);
			 Icon.iconAnchor = new GPoint(5, 34);
			 Icon.infoWindowAnchor = new GPoint(5, 2);
			 //Icon.transparent = "mytran.png";
			 //Icon.printImage = "mymarkerie.gif";
			 //Icon.mozPrintImage = "mymarkerff.gif";
			 Icon.printShadow = "js/arrow_shaddow.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];

		var oNewMarker = new GMarker(oPoint,Icon);
		GEvent.addListener(oNewMarker, "click", function() {
			oNewMarker.openInfoWindowTabsHtml(aInfoTabs); });
		oMap.addOverlay(oNewMarker);
		aGMarkers[i] = oNewMarker;
		aTabHTML[i] = aInfoTabs;
		i++;
		return oNewMarker;
	}
	
	function SetLatandLong(sCoords) {
		WriteDebugInfo('Start SetLatandLong');

		sCoords		= sCoords + "";
		iLatInfo		= sCoords.substring(1,sCoords.indexOf(","));
		iLonginfo	= sCoords.substring(sCoords.indexOf(",")+1,sCoords.length-1);

		WriteDebugInfo('End SetLatandLong :: ' + iLatInfo + ', ' + iLonginfo);
	}

	function myclick(i) {
		aGMarkers[i].openInfoWindowTabsHtml(aTabHTML[i]);
	}

	// IsNumber - Checks to see if the value passed is a number, that is not containing non-numeric
	// characters.
	function IsNumberG(inputStr, integer) {
		var intcount=0;
		var negcount=0;
		
	  for ( var i = 0; i < inputStr.length; i++) {
		  var oneChar = inputStr.charAt(i);
		  
		  if (oneChar == ".") {
				if ( integer ) {
					return false;
				} else {
					intcount++ ;
					
					if ( intcount > 1 ) {
						return false;
					}
				}
		  }
		  else if (oneChar == "-") {
				if ( integer ) {
					return false;
				} else {
					negcount++ ;
					
					if ( negcount > 1 ) {
						return false;
					}
				}
		  }
		  else if ( (oneChar < "0" || oneChar > "9") ) {
				return false;
		  }
	  }

	  return true;
	}

	if (window.addEventListener)
	window.addEventListener("load", GLoad, false)
	else if (window.attachEvent)
	window.attachEvent("onload", GLoad)
	else if (document.getElementById)
	window.onload=GLoad