function LoadMap(zoomLevel) {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		if (isArray(addresses)){
			var latlngbounds = new GLatLngBounds();
			
			for (var i=0;i<addresses.length;i++)
			{
                if (lat[i] == undefined || lon[i] == undefined){
                    point = showAddress(addresses[i], popup[i]);
					latlngbounds.extend(point);
                }else{
                    //window.alert('Show by Lat & Long!');
                    point = showLatLong(lat[i], lon[i], popup[i]);
					latlngbounds.extend(point);
                }
            }
			
			if (zoomLevel == undefined){
				map.setCenter(latlngbounds.getCenter(), map.getBoundsZoomLevel(latlngbounds));
			} else {
				map.setCenter(latlngbounds.getCenter(), zoomLevel);
			}
			map.addControl(new GLargeMapControl());
		}else{
			//window.alert("No address to show.");
		}

	}
}

function showAddress(address, popuptext) {
	geocoder.getLatLng( address, function(point) {
		if (!point) {
			//alert(address + " not found");
		} else {
			var marker = new GMarker(point);
			map.addOverlay(marker);
			GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(popuptext)});
			return point;
		}
	})
}

function showLatLong(lat, lon, popuptext){
    point = new GLatLng(lat, lon);
    var marker = new GMarker(point);
	map.addOverlay(marker);
    GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(popuptext)});
	return point;
}

function isArray(obj) {
//returns true is it is an array
if (obj.constructor.toString().indexOf("Array") == -1)
	return false;
else
	return true;
}

