<!--

	//Latitude and Longitude corrections for London
	var latCorrection = 0.00044;
	var lngCorrection = -0.0016;

	// FUNCTIONS --------------------------------------------------------

	// Creates a marker and associated info window from OSGB36 coordinates.
	function createOSMarker(easting, northing, icon, html) {
	  // Convert Eastings and Northings to Latitude and Longitude
	  geo = NEtoLL(easting, northing);
  	  // The above conversion function has a small fixed error, which the lines below adjust for
  	  lat = geo.latitude + latCorrection;
  	  lon = geo.longitude + lngCorrection;
	  // Create a marker at the location specified, using the specified icon
	  var point = new GLatLng(lat, lon);	
	  var marker = new GMarker(point, icon);
	  // Add marker properties to the object for later use
	  marker.x = lon;
	  marker.y = lat;
	  marker.html = html;
	  // Show this marker's associated HTML in the info window when it is clicked.
	  GEvent.addListener(marker, 'click', function() {
		marker.openInfoWindowHtml(html);
	  });
	  return marker;
	}
	
	// Creates a marker and associated info window from OSGB36 coordinates.
	function createOSTabMarker(easting, northing, icon, infoTabs) {
	  // Convert Eastings and Northings to Latitude and Longitude
	  geo = NEtoLL(easting, northing);
  	  // The above conversion function has a small fixed error, which the lines below adjust for
  	  lat = geo.latitude + latCorrection;
  	  lon = geo.longitude + lngCorrection;
	  // Create a marker at the location specified, using the specified icon
	  var point = new GLatLng(lat, lon);	
	  var marker = new GMarker(point, icon);
	  // Add marker properties to the object for later use
	  marker.x = lon;
	  marker.y = lat;
	  marker.html = infoTabs[1];
	  // Show this marker's associated HTML in the info window when it is clicked.
	  GEvent.addListener(marker, 'click', function() {
		marker.openInfoWindowTabsHtml(infoTabs);
	  });
	  return marker;
	}
	
	
	// Creates a marker and associated info window from WGS84 coordinates.
	function createGeoMarker(lon, lat, icon, html) {
	  // Create a marker at the location specified, using the specified icon
	  var point = new GLatLng(lat, lon);	
	  var marker = new GMarker(point, icon);
	  // Add marker properties to the object for later use
	  marker.x = lon;
	  marker.y = lat;
	  marker.html = html;
	  // Show this marker's associated HTML in the info window when it is clicked.
	  GEvent.addListener(marker, 'click', function() {
		marker.openInfoWindowHtml(html);
	  });
	  return marker;
	}
	
	// Scrolls and zooms map to a specific marker and opens it's info window
	function openMarker(marker, zoom){
		map.setCenter(new GLatLng(parseFloat(marker.y), parseFloat(marker.x)), parseFloat(zoom), G_NORMAL_MAP);
		marker.openInfoWindowHtml(marker.html);
	}
	
	// Scrolls and zooms map to a specific marker (based on an 'id' variable) and opens it's info window
	function openMarker2(marker, index, zoom){
				var i
				for (i in marker)
				{
					if(marker[i].id == index) {
						map.setCenter(new GLatLng(parseFloat(marker[i].y), parseFloat(marker[i].x)), parseFloat(zoom), G_NORMAL_MAP);
						marker[i].openInfoWindowHtml(marker[i].html);
					}
				}
	}


	// Toggles a single overlay on or off when a checkbox is checked or unchecked
	function toggleOverlay(checkBox, overlay){
		if (document.getElementById(checkBox).checked==false) {
			map.removeOverlay(overlay);
			} else {
			map.addOverlay(overlay);
		} 
	}
	
	// Toggles an array of overlays on or off when a checkbox is checked or unchecked
	function toggleOverlays(checkBox, overlays){
		if (document.getElementById(checkBox).checked==false) {
				for (var i = 0; i < overlays.length; i++) {
					map.removeOverlay(overlays[i]);
				}
			} else {
				for (var i = 0; i < overlays.length; i++) {
					map.addOverlay(overlays[i]);
				}
		} 
	}
	
	// Toggles an array of markers on or off when a checkbox is checked or unchecked
	function toggleMarkers(checkBox, markerArray){
		if (document.getElementById(checkBox).checked==false) {
			for (var i = 0; i < markerArray.length; i++) {
				map.removeOverlay(markerArray[i]);
			}
		} else {
			for (var i = 0; i < markerArray.length; i++) {
				if (markerArray[i] != 'NULL'){
					map.addOverlay(markerArray[i]);
				}
			}
		} 
	}


	var deg2rad = Math.PI / 180;
	var rad2deg = 180.0 / Math.PI;
	var pi = Math.PI;
	
	function NEtoLL(east, north) 
	{
	  // converts NGR easting and nothing to lat, lon.
	  // input metres, output radians
	  var nX = Number(north);
	  var eX = Number(east);
	  a = 6377563.396;       // OSI semi-major
	  b = 6356256.91;        // OSI semi-minor
	  e0 = 400000;           // easting of false origin
	  n0 = -100000;          // northing of false origin
	  f0 = 0.9996012717;     // OSI scale factor on central meridian
	  e2 = 0.0066705397616;  // OSI eccentricity squared
	  lam0 = -0.034906585039886591;  // OSI false east
	  phi0 = 0.85521133347722145;    // OSI false north
	  var af0 = a * f0;
	  var bf0 = b * f0;
	  var n = (af0 - bf0) / (af0 + bf0);
	  var Et = east - e0;
	  var phid = InitialLat(north, n0, af0, phi0, n, bf0);
	  var nu = af0 / (Math.sqrt(1 - (e2 * (Math.sin(phid) * Math.sin(phid)))));
	  var rho = (nu * (1 - e2)) / (1 - (e2 * (Math.sin(phid)) * (Math.sin(phid))));
	  var eta2 = (nu / rho) - 1;
	  var tlat2 = Math.tan(phid) * Math.tan(phid);
	  var tlat4 = Math.pow(Math.tan(phid), 4);
	  var tlat6 = Math.pow(Math.tan(phid), 6);
	  var clatm1 = Math.pow(Math.cos(phid), -1);
	  var VII = Math.tan(phid) / (2 * rho * nu);
	  var VIII = (Math.tan(phid) / (24 * rho * (nu * nu * nu))) * (5 + (3 * tlat2) + eta2 - (9 * eta2 * tlat2));
	  var IX = ((Math.tan(phid)) / (720 * rho * Math.pow(nu, 5))) * (61 + (90 * tlat2) + (45 * tlat4 ));
	  var phip = (phid - ((Et * Et) * VII) + (Math.pow(Et, 4) * VIII) - (Math.pow(Et, 6) * IX)); 
	  var X = Math.pow(Math.cos(phid), -1) / nu;
	  var XI = (clatm1 / (6 * (nu * nu * nu))) * ((nu / rho) + (2 * (tlat2)));
	  var XII = (clatm1 / (120 * Math.pow(nu, 5))) * (5 + (28 * tlat2) + (24 * tlat4));
	  var XIIA = clatm1 / (5040 * Math.pow(nu, 7)) * (61 + (662 * tlat2) + (1320 * tlat4) + (720 * tlat6));
	  var lambdap = (lam0 + (Et * X) - ((Et * Et * Et) * XI) + (Math.pow(Et, 5) * XII) - (Math.pow(Et, 7) * XIIA));
	  var geo = { latitude: phip * rad2deg, longitude: lambdap * rad2deg };
	  return(geo);
	}  
	
	function Marc(bf0, n, phi0, phi)
	{
	  var Marc = bf0 * (((1 + n + ((5 / 4) * (n * n)) + ((5 / 4) * (n * n * n))) * (phi - phi0))
		- (((3 * n) + (3 * (n * n)) + ((21 / 8) * (n * n * n))) * (Math.sin(phi - phi0)) * (Math.cos(phi + phi0)))
		+ ((((15 / 8) * (n * n)) + ((15 / 8) * (n * n * n))) * (Math.sin(2 * (phi - phi0))) * (Math.cos(2 * (phi + phi0))))
		- (((35 / 24) * (n * n * n)) * (Math.sin(3 * (phi - phi0))) * (Math.cos(3 * (phi + phi0)))));
	  return(Marc);
	}
	
	function InitialLat(north, n0, af0, phi0, n, bf0)
	{
	  var phi1 = ((north - n0) / af0) + phi0;
	  var M = Marc(bf0, n, phi0, phi1);
	  var phi2 = ((north - n0 - M) / af0) + phi1;
	  var ind = 0;
	  while ((Math.abs(north - n0 - M) > 0.00001) && (ind < 20))  // max 20 iterations in case of error
	  {  
		ind = ind + 1;
		phi2 = ((north - n0 - M) / af0) + phi1;
		M = Marc(bf0, n, phi0, phi2);
		phi1 = phi2;
	  }
	  return(phi2);  
	}
	
	function conv_ngr_to_ings(ngr)
	{
	  var myRegExp = /^[A-Z][A-Z][0-9]/;
	  if (myRegExp.test(ngr))
		grid = "British";
		
	  myRegExp = /^ [A-Z][0-9]/;
	  if (myRegExp.test(ngr))
		grid = "Irish";
		
	  myRegExp = /^W[AV][0-9]/;
	  if (myRegExp.test(ngr))
		grid = "Channel Islands";
	
	  if (grid == "Channel Islands") 
	  {
		var eci = "5" + ngr.substring(2,7);
		if (ngr.charAt(1) == "V")
		  var nci = "54" + ngr.substring(7,12);
		else
		  var nci = "55" + ngr.substring(7,12);
		east = Number(eci);
		north = Number(nci);
	  }
	  if ((grid == "British") || (grid == "Irish"))
	  {
		north = Number(ngr.substring(7));
		east = Number(ngr.substring(2,7));
	
		var t1 = ngr.charCodeAt(0) - 65;
		if (t1 < 0)   // 
		  t1 = 18;    // S for Irish 83-65
		if (t1 > 8)
		  t1 = t1 -1;
		var t2 = Math.floor(t1 / 5);
		north = north + 500000 * (3 - t2);
		east = east + 500000 * (t1 - 5 * t2 - 2);
	
		t1 = ngr.charCodeAt(1) - 65;
		if (t1 > 8)
		  t1 = t1 - 1;
		t2 = Math.floor(t1 / 5);
		north = north + 100000 * ( 4 - t2);
		east = east + 100000 * ( t1 - 5 * t2);
	  }
	}

//-->