var blnMapLoaded = false; //when they close preview window dont reload data
function loadMap(map_container, latitude, longitude, streetAddress, noAddressMsg, addressNotFoundMsg) {
      if (!blnMapLoaded && GBrowserIsCompatible()) {
        if (longitude != undefined && latitude != undefined)
        {
        	
        	//width: 500px; height: 300px
        	//alert("lat and long are given");
        	setupMap(mapContainer, latitude, longitude, 15);
        }
        else if (streetAddress != undefined)
        {
        	//alert("street address given");
        	//get co-ords and then load map
        	var geoCoder = new GClientGeocoder();
        	geoCoder.getLatLng(
			streetAddress,
			function(latlng) {
				streetLatLng = latlng;
				if (!latlng) {
		//			alert("given address not found");
					document.getElementById(map_container).innerHTML = "<p>"+addressNotFoundMsg+"</p>";
				}
				else {
		//			alert("found address");
					setupMap(map_container, latlng.lat(), latlng.lng(), 15);
				}
			}
		);
        }
        else
        {
        	//alert("neither street or co-ords given");
        	document.getElementById(map_container).innerHTML = "<p>"+noAddressMsg+"</p>";
        }
        blnMapLoaded = true;
      }
    }
function setupMap(map_container, latitude, longitude, zoomLevel) {
	document.getElementById(map_container).style.width = 500;
        document.getElementById(map_container).style.height = 300;
        
        var map = new GMap2(document.getElementById(map_container));
        map.setCenter(new GLatLng(latitude, longitude), zoomLevel);
        map.addControl(new GLargeMapControl()); //assuming the arrows and zoom
      	map.addControl(new GMapTypeControl()); //assuming the sat photos, view types
      	
      	var placeMarker = new GMarker(new GLatLng(latitude, longitude));
        map.addOverlay(placeMarker);
}