function generateDirections(mapDiv, dirDiv, startLocDiv, endLoc, point)
{
  // generate the map and directions
  var dirMap = new GMap2(document.getElementById(mapDiv));
  var dirPanel = document.getElementById(dirDiv);
  dirMap.setCenter(point, 13);
  dirMap.addControl(new GLargeMapControl());
  directions = new GDirections(dirMap, dirPanel);
  directions.load(document.getElementById(startLocDiv).value + " to " + endLoc);
  // generate and insert the print link
  $('print-link').innerHTML = '<a href="http://maps.google.com/maps?f=d&hl=en&z=12&pw=2&saddr=' + $(startLocDiv).value.gsub(" ","+") + '&daddr=' + endLoc.gsub(" ","+") + '" target="_blank">Print</a>';
}

// this is the modal for the large map view
var largeMapModal = new Control.Modal('large-map-link',{
	opacity: 0.5,
	width: 753,
	height: 483,
	afterOpen: function(){
	  $('flash').hide();
	  $('directions-sub').hide();
	  if (GBrowserIsCompatible()) {
		// generate the large map
		var largeMap = new GMap2(document.getElementById("large-map-container"));
		largeMap.setCenter(point, 13);
		var marker = new GMarker(point);
		largeMap.addOverlay(marker);
		largeMap.addControl(new GLargeMapControl());
		largeMap.addControl(new GMapTypeControl());
		largeMap.enableContinuousZoom();
		
		// watch for the user to enter directions
		Event.observe('dir-go-modal','click',function(){  // if they click the button
		  $('map-view-container').hide();
		  $('directions-sub').show();
		  generateDirections("map-sub", "dir-sub", "start-loc-modal", endLoc, point);
		});
		Event.observe('start-loc-modal', 'keypress', function(e){ // if they hit enter
		  if(e.keyCode == 13)
		  {
			$('map-view-container').hide();
			$('directions-sub').show();
			generateDirections("map-sub", "dir-sub", "start-loc-modal", endLoc, point);
		  }
		});
	  }
	},
	beforeClose: function(){
	  $('flash').show();
	}
});
