
var map = null;
function initializeMap() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map_canvas"));
	map.addControl(new GSmallMapControl());
	map.setCenter(new GLatLng(37.4419, -122.1419), 5);
  }
}

function showAddress(lat, lng) {
	console.log(lat, lng)
	// Create our "tiny" marker icon
	var mugIcon = new GIcon();
	mugIcon.image = "/mug/images/marker.png";
	mugIcon.shadow = "/mug/images/marker_shadow.png";
	mugIcon.iconSize = new GSize(31, 41);
	mugIcon.shadowSize = new GSize(47, 41);
	mugIcon.iconAnchor = new GPoint(12, 33);
	mugIcon.infoWindowAnchor = new GPoint(13, 12);

	// Set up our GMarkerOptions object
	markerOptions = { icon:mugIcon };
	
	var point = new GLatLng(lat, lng)
	map.setCenter(point, 15);

    mainMarker = new GMarker(point, markerOptions);
    map.addOverlay(mainMarker);
}			

function panTo(lat, lng) {    
	var point = new GLatLng(lat, lng);
	mainMarker.setLatLng(point); 
   	map.panTo(point);
}


function addOtherLocs(){
	
	map.setCenter(new GLatLng(0,0),0);
	var bounds = new GLatLngBounds();
	
	var mugIcon = new GIcon();
	mugIcon.image = "/mug/images/marker_d.png";
	mugIcon.shadow = "/mug/images/marker_d_shadow.png";
	mugIcon.iconSize = new GSize(25, 37);
	mugIcon.shadowSize = new GSize(33, 37);
	mugIcon.iconAnchor = new GPoint(12, 34);
	mugIcon.infoWindowAnchor = new GPoint(12, 12);

	// Set up our GMarkerOptions object
	markerOptions = {icon:mugIcon };
	marker_array = [];
	for(var i = 0; i < otherLocs.length; i++){
		var point = new GLatLng(otherLocs[i][0],otherLocs[i][1]);
		
		
    	var marker = new GMarker(point, markerOptions);
		marker_array.push(marker);
		marker.i = i;
    	map.addOverlay(marker);
		bounds.extend(point);
		
		GEvent.addListener(marker,"mouseover", function() {
			var nearby = ".nearby_"+Number(1+this.i);
			marker_array[this.i].setImage("/mug/images/marker_over.png");
			$(nearby).addClass("active");
		});
		GEvent.addListener(marker,"mouseout", function() {
			var nearby = ".nearby_"+Number(1+this.i);
			$(nearby).removeClass("active");
			marker_array[this.i].setImage("/mug/images/marker_d.png");
		});
//		console.log(point);
		
	}
	map.setZoom(map.getBoundsZoomLevel(bounds));
	map.setCenter(bounds.getCenter());
}