var map;

function mapOpen(mapdiv, addresst, pntLat, pntLong) {
	//$('#'+mapdiv).show("slow");
	//$('#mapTitle').html(unescape(addresst));
	load(pntLat, pntLong, unescape(addresst));
}

function mapClose(mapdiv) {
	//$('#'+mapdiv).hide("slow");
	GUnload();
}

function load(pntLat, pntLong, addresst) {
    if (GBrowserIsCompatible()) {
		// Create our "tiny" marker icon
		var tinyIcon = new GIcon();
		tinyIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		tinyIcon.iconSize = new GSize(12, 20);
		tinyIcon.shadowSize = new GSize(22, 20);
		tinyIcon.iconAnchor = new GPoint(6, 20);
		tinyIcon.infoWindowAnchor = new GPoint(5, 1);
		
		// Set up our GMarkerOptions object literal
		markerOptions = { icon:tinyIcon };
	
	    map = new GMap2(document.getElementById("mapViewPort"))
		map.setMapType(G_HYBRID_MAP);
		map.addControl(new GSmallMapControl());
	       map.addControl(new GMapTypeControl());
		if (pntLat == 0 || pntLong == 0) {
			var geocoder = new GClientGeocoder();
			function showAddress(address) {
			  geocoder.getLatLng(address,
			    function(point) {
			      if (!point) {
			        alert(address + " not found");
			      } else {
			        map.setCenter(point, 17);
			        map.addOverlay(new GMarker(point, markerOptions));
			      }
			    }
			  );
			}
			showAddress(addresst);			
		} else {
			map.setCenter(new GLatLng(pntLat, pntLong), 17);
			map.addOverlay(new GMarker(new GLatLng(pntLat, pntLong), markerOptions));
		}				
     }
}

function loadAddress(addresst) {
    if (GBrowserIsCompatible()) {
		// Create our "tiny" marker icon
		var tinyIcon = new GIcon();
		tinyIcon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		tinyIcon.iconSize = new GSize(12, 20);
		tinyIcon.shadowSize = new GSize(22, 20);
		tinyIcon.iconAnchor = new GPoint(6, 20);
		tinyIcon.infoWindowAnchor = new GPoint(5, 1);
		
		// Set up our GMarkerOptions object literal
		markerOptions = { icon:tinyIcon };
	
	    var map = new GMap2(document.getElementById("mapViewPort"))
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		var geocoder = new GClientGeocoder();
		function showAddress(address) {
			geocoder.getLatLng(address,
			function(point) {
				if (!point) {
					alert(address + " not found");
				} else {
					map.setCenter(point, 17);
					map.addOverlay(new GMarker(point, markerOptions));
				}
			});
		}
		showAddress(addresst);			
     }
}
