var map = null;
var geocoder = null; 

function initializeMap(sWidth, sHeight) {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map-canvas"),{size:new GSize(sWidth,sHeight)});
    geocoder = new GClientGeocoder();
	var mapControl = new GMapTypeControl();
	map.addControl(mapControl);
	map.addControl(new GSmallMapControl());
	splitMapArray(address, info);
  }
}

function splitMapArray(address, info) {
	for (var i=0; i<address.length; i++) {
		var geoAddress = address[i];
		var geoInfo = info[i];
		addMapLocation(geoAddress, geoInfo);
	}
}

function addMapLocation(geoAddress, geoInfo) {
	geocoder.getLatLng(geoAddress,
	function(point) {
		if (!point) {
			alert(geoAddress + " not found");
		} else {	
			map.setCenter(point, 14);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			marker.openInfoWindowHtml(geoInfo, {maxWidth:230, maxHeight:25});
            GEvent.addListener(marker, "click", function(){marker.openInfoWindowHtml(geoInfo, {maxWidth:230, maxHeight:25});}); 				
		  }
		}
	);	
}

function getDirections(sFrom, sTo){
	var directionsPanel;
	var directions;

  	directionsPanel = document.getElementById("directions-canvas");
  	//map.setCenter(new GLatLng(49.496675,-102.65625), 3);
  	directions = new GDirections(map, directionsPanel);
  	directions.load("from: " + sFrom + " to: " + sTo);
}

