var map = "";
var mapdiv = "";
var baseIcon = "";

function createMarker(point, index) {
	// Create a lettered icon for this point using our icon class
	var letter = String.fromCharCode("A".charCodeAt(0) + index);
	var icon = new GIcon(baseIcon);
	icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, "click", function() {
				info = document.getElementById('gmacInfo').innerHTML;
				info = info + document.getElementById('gmacLink').innerHTML;
				marker.openInfoWindowHtml(info);
	
	//GEvent.addListener(marker, "click", function() {
	//	info = 'Company Name<br/>Address Line One<br/>Address Line Two<br/>Address Line Three<br/>City, State 00000'; //document.getElementById('officeInfo' + (index + 1)).innerHTML;
	//	marker.openInfoWindowHtml(info);
	});
	return marker;
}

function wheelZoom(event) { 
// Prevent from scrolling the page when zooming the map 
	if(window.event) { event.returnValue = false; } // IE 
	if(event.cancelable) { event.preventDefault(); } // DOM-Standard 
	if((event.detail || -event.wheelDelta) < 0) {
		map.zoomIn();
	} else {
		map.zoomOut();
	}
}

function loadOfficeMap(lat, lng) {
	if (GBrowserIsCompatible()) {
		mapdiv = document.getElementById("officeMap");
		map = new GMap2(document.getElementById("officeMap"));
		
		//map.addControl(new GLargeMapControl());
		//map.addControl(new GMapTypeControl());

		GEvent.addDomListener(mapdiv, "DOMMouseScroll", wheelZoom); // Firefox
		GEvent.addDomListener(mapdiv, "mousewheel", wheelZoom); // IE
		
		baseIcon = new GIcon();
		baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		baseIcon.iconSize = new GSize(20, 34);
		baseIcon.shadowSize = new GSize(37, 34);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);
		baseIcon.infoShadowAnchor = new GPoint(18, 25);
		
		map.setCenter(new GLatLng(lat, lng), 11);
		
		var point = new GLatLng(lat, lng);
		map.addOverlay(createMarker(point, 0));
		map.getContainer().style.overflow="hidden";
		
	}
}
