	// gmapper.js
	// Google Map generator ( marker data from external XML, custom marker set )
	//
	// Usage: 
	// Gload(mapDivID,file,centerLat,centerLng,initZoom);
	//
	// mapDivID - a string, the ID of a div to contain map
	// file - a string, the filename of an xml file
	// centerLat,centerLng - decimal values, coordinates at center of map
	// initZoom - integer 1-16, initial zoom level of map
	//
	//
	// 11-30-2006 ndalton@ausableweb.com
	
	var mapDataDir = 'http://www.record-eagle.com/elements/maps/map_data/';
	var mapMarkerDir = 'http://www.record-eagle.com/elements/maps/map_markers/';
	
	//<![CDATA[
    function Gload(mapDivID,file,centerLat,centerLng,initZoom) {
	if (GBrowserIsCompatible()) {
		
		var dataURL = mapDataDir + file;
		
	 	// define custom marker set
		var mapMarkerPrefixes = new Array('red','orange','yellow','green','blue','cyan','violet','grey','white');
		var mapMarkers = new Array();
		for (var i = 0; i < mapMarkerPrefixes.length; i++) {
			thisPrefix = mapMarkerPrefixes[i];			
			mapMarkers[thisPrefix] = new GIcon();
			mapMarkers[thisPrefix].image = mapMarkerDir + mapMarkerPrefixes[i] + "_arrow.png";
			mapMarkers[thisPrefix].iconSize = new GSize(16, 26);
			mapMarkers[thisPrefix].shadow = mapMarkerDir + "arrow_shadow.png";
			mapMarkers[thisPrefix].shadowSize = new GSize(27, 26);
			mapMarkers[thisPrefix].iconAnchor = new GPoint(8, 26);
			mapMarkers[thisPrefix].infoWindowAnchor = new GPoint(1, 1);			
			mapMarkers[thisPrefix].infoShadowAnchor = new GPoint(1, 1);
			mapMarkers[thisPrefix].transparent = mapMarkerDir + "arrow_trans.png";
			mapMarkers[thisPrefix].imageMap=[0,0,16,0,16,26,0,26,0,0];
		}
		
		// showTooltip() function
		function showTooltip(marker) {
			tooltip.innerHTML = marker.tooltip;
			var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
			var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
			var anchor=marker.getIcon().iconAnchor;
			var width=marker.getIcon().iconSize.width;
			var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width-1,- offset.y + point.y +anchor.y-1)); 
			pos.apply(tooltip);
			tooltip.style.visibility="visible";
		}
		
		// createMarker() function
		function createMarker(point,html,label,yplink,markertype) {	  	
			var marker = new GMarker(point , mapMarkers[markertype]);
			marker.tooltip = '<div class="map_tooltip">'+'<span style="font-size:12px;">'+label+'</span><br/><span style="font-size:9px;">Click for More Information</span></div>';
			GEvent.addListener(marker, "click", function() {
				<!--marker.openInfoWindowHtml(html);-->
				window.open(yplink, 'newWindow')
        	});
			GEvent.addListener(marker,"mouseover", function() {
          		showTooltip(marker);
        	});        
        	GEvent.addListener(marker,"mouseout", function() {
				tooltip.style.visibility="hidden"
        	});
        	return marker;
		}
		
		// create map and controls
		var map = new GMap2(document.getElementById(mapDivID));
		map.addControl(new GSmallMapControl());
		//map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(centerLat,centerLng),initZoom);
    
		// create tooltip div
		var tooltip = document.createElement("div");
		document.getElementById(mapDivID).appendChild(tooltip);
		tooltip.style.visibility="hidden";

		// get the xml data and createMarker() s
		GDownloadUrl(dataURL, function(data, responseCode) {
			var xml = GXml.parse(data);
			var markers = xml.documentElement.getElementsByTagName("marker");
			for (var i = 0; i < markers.length; i++) {
				var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));
				var label = markers[i].getAttribute("label");
				var markertype = markers[i].getAttribute("markertype");
				var html = GXml.value(markers[i].getElementsByTagName("infowindow")[0]);
				var yplink = GXml.value(markers[i].getElementsByTagName("yplink")[0]);
				var marker = createMarker(point,html,label,yplink,markertype);
            	map.addOverlay(marker);
			}
		});

    } else {
		// sorry pal, browser not compatible
		alert("Sorry, Google Maps is not compatible with this browser. Try the latest versions of Mozilla Firefox or Internet Explorer, and be sure to enable Javascript.");
    }
	}

    //]]>   