var geocoder = null;
var maps = new Array();
var mapObjects = new Array();

function loadMaps(){
	for(var i=0;i<maps.length;i++){
		loadMap(maps[i][0], maps[i][1], i);
	}
}

function registerMap(address, mapElemId){
	maps[maps.length] = [address, mapElemId];
}

function showAddress(address, mapElemId, mapObjectIndex) {
	if (geocoder) {
		geocoder.getLatLng(
		address,
		function(point) {
			if (!point) {
				document.getElementById(mapElemId).style.display = 'none';
			}
			else {
				mapObjects[mapObjectIndex].setCenter(point, 13);
				var marker = new GMarker(point);
				mapObjects[mapObjectIndex].addOverlay(marker);
			}
		}
		);
	}
}

function loadMap(address, mapElemId, mapObjectIndex) {
	if (GBrowserIsCompatible()) {
		mapObjects[mapObjectIndex] = new GMap2(document.getElementById(mapElemId));
		mapObjects[mapObjectIndex].addControl(new GSmallMapControl());
	
		geocoder = new GClientGeocoder();
		showAddress(address, mapElemId, mapObjectIndex);
	}
}     
