
      var gmarkers = [];
      var htmls = [];
      var to_htmls = [];
      var from_htmls = [];
      var i=0;

      // function to create marker and set up event window
      function createMarker(point,name,html) {
        var marker = new GMarker(point);

        // info window version with "to here" form open
        to_htmls[i] = html + '<br>Directions: <b>To here</b> - <a href="javascript:fromhere(' + i + ')">From here</a>' +
           '<br>Start address:<form action="http://maps.google.com/maps" method="get" target="_blank">' +
           '<input type="text" SIZE=30 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Get Directions!" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="' +
           point.y + ',' + point.x + "(" + name + ")" + '"/>';
          
        // info window version with "from here" form open
        from_htmls[i] = html + '<br>Directions: <a href="javascript:tohere(' + i + ')">To here</a> | <b>From here</b>' +
           '<br>End address:<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
           '<input type="text" SIZE=30 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
           '<INPUT value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="saddr" value="' +
           point.y + ',' + point.x + "(" + name + ")" + '"/>';

        // inactive version of direction info
        html = html + '<br>Directions: <a href="javascript:tohere('+i+')">To here</a> - <a href="javascript:fromhere('+i+')">From here</a>';

        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml('<div style="white-space:nowrap;">'+html+'</div>');
        });
        gmarkers[i] = marker;
        htmls[i] = html;
        i++;
        return marker;
      }

      // functions that open directions forms
      function tohere(i) {
        gmarkers[i].openInfoWindowHtml('<div style="white-space:nowrap;">'+ to_htmls[i]+'</div>');
      }
      function fromhere(i) {
        gmarkers[i].openInfoWindowHtml('<div style="white-space:nowrap;">'+ from_htmls[i]+'</div>');
      }


function show_map(element, latitude, longitude, short_name, descr) {
    // check to see if browser can run Google API
	if (GBrowserIsCompatible())
	{
		// display map with controls and set initial location 
		var map = new GMap(document.getElementById(element));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GScaleControl()); 
		map.setMapType(G_HYBRID_TYPE);

		GEvent.addListener(map, 'moveend', function()
		{
			var center = map.getCenterLatitudeLng();
			var latitudeLngStr = '(' + center.y + ', ' + center.x + ')';
			document.getElementById("message").innerHTML = latitudeLngStr;
		});

		map.centerAndZoom(new GPoint(latitude, longitude), 1);

		// set up markers with info windows 
		var point = new GPoint(latitude, longitude);
		var marker = createMarker(point, short_name, descr);
		map.addOverlay(marker);
	}

    
    // display warning if the browser not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser.");
    }
}

function show_map_v2(element, longitude, latitude, map_type, short_name, descr) {
    // check to see if browser can run Google API
	if (GBrowserIsCompatible())
	{

		// display map with controls and set initial location 
		var map = new GMap2(document.getElementById(element));
		map.setCenter(new GLatLng(longitude, latitude), 16);

		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GScaleControl()); 
		map.setMapType(map_type);

		// function to create marker and set up event window
		addMarker = function(point,name,html)
		{
			var gmarkers = [];
			var htmls = [];
			var to_htmls = [];
			var from_htmls = [];
			var i=0;
			
			var marker = new GMarker(point);
			
			// info window version with "to here" form open
			to_htmls[i] = '<div id="map_name">' + name + '</div>' + '<div id="map_html">' + html + '</div>' + '<br>Directions: <b>To here</b> - <a href="javascript:fromhere(' + i + ')">From here</a>' +
			   '<br>Start address:<form action="http://maps.google.com/maps" method="get" target="_blank">' +
			   '<input type="text" SIZE=30 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
			   '<INPUT value="Get Directions!" TYPE="SUBMIT">' +
			   '<input type="hidden" name="daddr" value="' +
			   point.y + ',' + point.x + "(" + name + ")" + '"/>';
			  
			// info window version with "from here" form open
			from_htmls[i] = '<div id="map_name">' + name + '</div>' + '<div id="map_html">' + html + '</div>' + '<br>Directions: <a href="javascript:tohere(' + i + ')">To here</a> | <b>From here</b>' +
			   '<br>End address:<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
			   '<input type="text" SIZE=30 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
			   '<INPUT value="Get Directions" TYPE="SUBMIT">' +
			   '<input type="hidden" name="saddr" value="' +
			   point.y + ',' + point.x + "(" + name + ")" + '"/>';
			
			// inactive version of direction info
			html = '<div id="map_name">' + name + '</div>' + '<div id="map_html">' + html + '</div>' + '<br>Directions: <a href="javascript:tohere('+i+')">To here</a> - <a href="javascript:fromhere('+i+')">From here</a>';
			
			GEvent.addListener(marker, "click", function()
			{
				marker.openInfoWindowHtml('<div style="white-space:nowrap;">'+html+'</div>');
			});
	
			gmarkers[i] = marker;
			htmls[i] = html;
			i++;

			// functions that open directions forms
			tohere = function(i)
			{
				gmarkers[i].openInfoWindowHtml('<div style="white-space:nowrap;">'+ to_htmls[i]+'</div>');
			}
			
			fromhere = function(i)
			{
				gmarkers[i].openInfoWindowHtml('<div style="white-space:nowrap;">'+ from_htmls[i]+'</div>');
			}
		
			return marker;
		}
		
		// set up markers with info windows 
		var point = new GLatLng(longitude, latitude);
		var marker = addMarker(point, short_name, descr);
		map.addOverlay(marker);
		}

    
    // display warning if the browser not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser.");
    }
}
