// JavaScript Document
function load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("memberMap"));
		map.setCenter(new GLatLng(37.4419, -122.1419), 13);
	}
}

function createGoogleMap (company, street, location) {
	//alert (address);
	address = street + location;
	var map = new GMap2 (document.getElementById("memberMap"));
	
	map.addControl (new GLargeMapControl());
	map.addControl (new GMapTypeControl());
	
	var geocoder = new GClientGeocoder();
	function showAddress (address) {
		geocoder.getLatLng (address,
		function (point) {
			if (!point) {
				document.getElementById('memberMap').innerHTML = "<div align=\"center\" class=\"red\"><strong>No Map Available</strong></div>";
				document.getElementById('memberMap').style.height = "auto";
				document.getElementById('memberMap').style.border = "none";
				document.getElementById('memberMap').style.background = "inherit";
				//document.getElementById('memberMap').style.display = "none";
				//alert (address + " not found");
			}
			else {
				map.setCenter (point, 13);
				var marker = new GMarker (point);
				map.addOverlay (marker);
				mapDisplayInfo = '<strong>' + company + '</strong><br />' + street + '<br />' + location;
				marker.openInfoWindowHtml (mapDisplayInfo);
				//map.enableScrollWheelZoom();
				
				/*
				container = document.getElementById("memberMap");
				
				function mouseMove(mousePt) {
					mouseLatLng = mousePt;
					var zoom = map.getZoom();
					var oStatusDiv = document.getElementById("mouseTrack")	
					var mousePx = normalProj.fromLatLngToPixel(mousePt, zoom);
					oStatusDiv.innerHTML = 'Mouse LatLng: ' + mousePt.y.toFixed(6) + ', ' + mousePt.x.toFixed(6) ;
					//oStatusDiv.innerHTML += '<br> ';
					//oStatusDiv.innerHTML += 'Mouse Px: ' + mousePx.x + ', ' + mousePx.y;
					//oStatusDiv.innerHTML += '<br>';
					//oStatusDiv.innerHTML += 'Tile: ' + Math.floor(mousePx.x / 256) + ', ' + Math.floor(mousePx.y / 256);
				}
				
				function moveEnd() {
					updateStatusBar();
				}
				
				function zoomEnd(oldZ,zoom) {
					updateStatusBar();
				}
				
				// Mouse wheel zoom - Event handler -----
				function wheelZoom(event) {
					if (wheelZooming) {
						return;
					}
				
					wheelZooming = true;
				
					// zoomRect and rectIcon are global variables!!!
				
					zoomRect = new GMarker(mouseLatLng,{icon:rectIcon});
					map.addOverlay(zoomRect);
				
					if (event.cancelable) {
						event.preventDefault();
					}
					map.closeInfoWindow(); 
					if((event.detail || -event.wheelDelta) < 0) {
						window.setTimeout(function(){
							map.removeOverlay(zoomRect);
							map.zoomIn(mouseLatLng,true,true);
							wheelZooming = false;
						},200);
					} 
					else {
						window.setTimeout(function(){
							map.removeOverlay(zoomRect);
							map.zoomOut(mouseLatLng,true);
							wheelZooming = false;
						},200);
					}
					return false; 
				}
				// End event handler -----
				
				GEvent.addDomListener(container, "DOMMouseScroll", wheelZoom);
				GEvent.addDomListener(container, "mousewheel", wheelZoom); 
				GEvent.addListener(map, 'mousemove', mouseMove);
				GEvent.addListener(map, "moveend", moveEnd);
				GEvent.addListener(map, "zoomend", zoomEnd);
				*/
				
			}
		}
		)
	}
	showAddress (address);
	/*
	
	map.setCenter (point, 6);
	*/
}