var lat;
var lng;
var ebdir = '<ul id="mlist"><li>cross the Richmond - San Rafael Bridge from the East Bay</li><li>take the Sir Francis Drake Blvd. exit and follow the road to 101</li><li>after passing beneath 101, follow the left-most lane on to 101</li><li>go south on 101</li><li>take the Marin City / Sausalito exit</li><li>turn left at the first traffic light and follow the road under 101</li><li>turn right at the second traffic light on to Bridgeway</li><li>go pass the third and fourth traffic lights</li><li>turn left at the fifth traffic light on to Harbor Drive</li><li>we are in the third building on the right past Mollie Stone&rsquo;s</li></ul>';
var nbdir = '<ul id="mlist"><li>go south on 101</li><li>take the Marin City / Sausalito exit</li><li>turn left at the first traffic light and follow the road under 101</li><li>turn right at the second traffic light on to Bridgeway</li><li>go pass the third and fourth traffic lights</li><li>turn left at the fifth traffic light on to Harbor Drive</li><li>we are in the third building on the right past Mollie Stone&rsquo;s</li></ul>';
var sfdir = '<ul id="mlist"><li>cross the Golden Gate Bridge from San Francisco</li><li>go through the Waldo Tunnel</li><li>go down to the bottom of the Waldo Grade</li><li>take the Sausalito / Marin City exit</li><li>go straight on Bridgeway past the first traffic light</li><li>go pass the second and third traffic lights</li><li>turn left at the fourth traffic light on to Harbor Drive</li><li>we are in the third building on the right past Mollie Stone&rsquo;s</li></ul>';
var gdir = '<strong>Harbor Dive & Kayak Center</strong><br />200 Harbor Drive &bull; Sausalito CA 94965<br />';
var ghdc = '';
var gpslatdeg;
var gpslngdeg;
var gpslatremainder;
var gpslatremainder2;
var gpslatremainder3;
var gpslngremainder;
var gpslngremainder2;
var gpslngremainder3;
var gpslatmin;
var gpslngmin;
var gpslatsec;
var gpslngsec;
var gpslatdir = ' N';
var gpslngdir;
var utmcoord = '<span id="coordcolor4">10 N 0544082 4191298&nbsp;UTM</span>';
var otherFormats;
var navUse = '<br /><br />Select an area from the list above to get directions.';

function onLoad(){
  var request;
  otherFormats = '';
  if (window.XMLHttpRequest){
    request = new XMLHttpRequest();
  } else if (window.ActiveXObject){
    request = new ActiveXObject("Microsoft.XMLHTTP");
  }
  request.open("GET", "ghdc.xml", false);
  request.send(null);
  var xmlDoc = request.responseXML;
  var markers = xmlDoc.documentElement.getElementsByTagName("marker");
  for (var i = 0; i < markers.length; i++) {
    lat = parseFloat(markers[i].getAttribute("lat"));
    lng = parseFloat(markers[i].getAttribute("lng"));
  }
  gpslatdeg = parseInt(lat);
  gpslngdeg = parseInt(lng);
  gpslatremainder = lat - (gpslatdeg * 1.0);
  gpslngremainder = lng - (gpslngdeg * 1.0);
  gpslatmin = gpslatremainder * 60.0;
  gpslngmin = gpslngremainder * 60.0;
  gpslatremainder2 = gpslatmin - (parseInt(gpslatmin) * 1.0);
  gpslngremainder2 = gpslngmin - (parseInt(gpslngmin) * 1.0);
  gpslatsec = gpslatremainder2 * 60.0;
  gpslngsec = gpslngremainder2 * 60.0;
  gpslatremainder3 = gpslatsec - (parseInt(gpslatsec) * 1.0);
  gpslngremainder3 = gpslngsec - (parseInt(gpslngsec) * 1.0);
  gpslatsecdec = Math.round(gpslatremainder3 * 100.0);
  gpslngsecdec = Math.round(gpslngremainder3 * 100.0);
  if (gpslngmin < 0) {
    gpslngdir = ' W';
  } else {
    gpslngdir = ' E';
  }
  otherFormats += '<br /><span id="coordcolor2">' + gpslatdeg + '&deg;&nbsp;' + gpslatmin + '&prime;' + gpslatdir;
  otherFormats += '&nbsp;' + Math.abs(gpslngdeg) + '&deg;&nbsp;' + Math.abs(gpslngmin) + '&prime;' + gpslngdir + '&nbsp;GPS</span>';
  otherFormats += '<br /><span id="coordcolor3">' + gpslatdeg + '&deg;&nbsp;' + parseInt(gpslatmin) + '&prime;&nbsp;' + parseInt(gpslatsec) + '.' + gpslatsecdec + '&Prime;' + gpslatdir;
  otherFormats += '&nbsp;' + Math.abs(gpslngdeg) + '&deg;&nbsp;' + Math.abs(parseInt(gpslngmin)) + '&prime;&nbsp;' + Math.abs(parseInt(gpslngsec)) + '.' + Math.abs(gpslngsecdec) + '&Prime;' + gpslngdir + '&nbsp;degrees minutes seconds</span>';
  otherFormats += '<br />' + utmcoord;
  ghdc = gdir + '<span id="coordcolor1">' + lat + '&nbsp;' + lng + '&nbsp;decimal</span>' + otherFormats + navUse;
  document.getElementById("maplist").innerHTML = ghdc;
}

function MM_jumpMenu(form){ //v3.0
  var fromArea = form.fromList.selectedIndex;
  switch (fromArea) {
    case 0:
      document.getElementById("maplist").innerHTML = ghdc;
      break;
    case 1:
      document.getElementById("maplist").innerHTML = sfdir;
      break;
    case 2:
      document.getElementById("maplist").innerHTML = nbdir;
      break;
    case 3:
      document.getElementById("maplist").innerHTML = ebdir;
      break;
    default:
  }
}
