// JavaScript Document
// added 07/09/2009
// by Kevin Roundtree
// for xacc-member-profile static page
// functions below were added as a custom feature for the xacc-member-profile static page
// Map Functions for member profile page

  var map = null;
  var marker = null;

  function initialize() {
    if (GBrowserIsCompatible()) {
      map = new GMap2(document.getElementById("map"));
      map.setCenter(new GLatLng(document.getElementById('lat').value, document.getElementById('lon').value), 14);
	  map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
	  
	  var latlng = new GLatLng(document.getElementById('lat').value, document.getElementById('lon').value);
	  var dirForm = '<form action="http://maps.google.com/maps" method="get" target="_blank"><p><label for="saddr">Start Address:&nbsp;</label><br /><input type="text" name="saddr" id="saddr" value=""/>&nbsp;<input type="submit" value="Go" /><input type="hidden" name="daddr" value="' + document.getElementById("address").value + '" /><input type="hidden" name="hl" value="en" /></p></form>';
	  var infoTabs = [  new GInfoWindowTab("Directions", "<table cellpadding='5' class='smalltxt11'><tr><td valign='top'>Get directions by entering<br />the starting address below.<br />"+dirForm+"</td></tr></table>")];
	  marker = createMarker(latlng, infoTabs);
	  map.addOverlay(marker);
	  marker.openInfoWindowTabsHtml(infoTabs);
	  
	}
  }
  
  function createMarker(point, infoTabs) {
	// Set up our GMarkerOptions object
	var marker = new GMarker(point);
	marker.bindInfoWindowTabsHtml(infoTabs);
	GEvent.addListener(marker, 'click', function() {marker.openInfoWindowTabsHtml(infoTabs);map.setCenter(point, 13);});
	return marker;
  }