

var coord, tabset, marker;
var g_map = null;
var geocoder = null;


function load( dom_id, lat, lon, map_html, controls ) {
  if (GBrowserIsCompatible()) {
	coord = new GLatLng( lat, lon );
	tabset = [ new GInfoWindowTab("General", map_html) ];
	
	//alert(map_html);
	g_map = new GMap2(document.getElementById( dom_id ));
	
	if( isNull(controls) || controls == true ){
		g_map.addControl( new GSmallMapControl() );
		g_map.addControl( new GMapTypeControl(true) );
	}
	
	g_map.setCenter(coord, 13);
	
	//Create Marker & Listener
	marker = new GMarker( coord );
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowTabsHtml( tabset );
	});
	
	g_map.addOverlay( marker );
	marker.openInfoWindowTabsHtml( tabset );
	
	geocoder = new GClientGeocoder();
  }
}


function showAddress(address) {
  if (geocoder) {
	  
	geocoder.getLatLng(
		address,
		function(point) {
		  if (!point) {
			alert(address + " not found");
		  } else {
			g_map.setCenter(point, 13);
			
			//Create Marker & Listener
			//marker = new GMarker( point );
			marker.setLatLng( point );
			
			//g_map.addOverlay(marker);
			marker.openInfoWindowHtml( tabset );
		  }
		}
	);
	
  }	
}

