var centerLatitude = 35.290271;
var centerLongitude = -91.357756;

var startZoom = 13; 
var map;

var iconPath = 'http://ncepr.org/darren/augusta/images/'
var baseIconImage = 'page_white_link.png';

var baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.image = iconPath + baseIconImage;
baseIcon.iconSize = new GSize(16, 16);
baseIcon.infoWindowAnchor = new GPoint(8, 8);
baseIcon.imageMap = [0,0, 16,0, 16,16, 0,16];
//This makes the shadows invisible until I can Photoshop some appropriate ones.
baseIcon.shadowSize = new GSize(1, 1); 

function addMarker(latitude, longitude, name, description, URL, iconImage, type) {
	
	if(iconImage) {
		var iconURL = iconPath + iconImage;
		var icon = new GIcon(baseIcon,iconURL);
	} else {
		var icon = new GIcon(baseIcon);
	}
	
	if(type == 'exhibit') {
		icon.iconSize = new GSize(40, 40);
		icon.infoWindowAnchor = new GPoint(20, 20);
		icon.imageMap = [0,0, 40,0, 40,40, 0,40];
	}
	
	var info = '<div class="mapItemTitle">' 
		+ name 
		+ '</div> <div class="mapItemDescription">' 
		+ description 
		+ '</a></div>'; 
	
	if(URL) {	
		info = info + '<div><a href="' 
		+ URL 
		+'">View</a></div>'; 
		}
	
	var marker = new GMarker(new GLatLng(latitude, longitude),icon);
	
	GEvent.addListener(marker, 'click', 
		function() {
			marker.openInfoWindowHtml(info);
		}
	);
	
	map.addOverlay(marker);
}

function init()
{
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		var location = new GLatLng(centerLatitude, centerLongitude);
		map.setCenter(location, startZoom);
		
		for(id in markers) {
			addMarker(markers[id].latitude, markers[id].longitude, markers[id].name, markers[id].description, markers[id].URL, markers[id].iconImage,markers[id].type);
		};
	}; 
}

window.onload = init;
window.onunload = GUnload;

