//<![CDATA[

/*
Example:
// Create a base icon for all of our markers that specifies the
// shadow, icon dimensions, etc.
var icon = new GIcon();
icon.iconSize = new GSize(120, 60);
icon.iconAnchor = new GPoint(0, 60);
icon.infoWindowAnchor = new GPoint(0, 0);
icon.image = "http://www.emotion.nl/images/google_logo.png";

var html = 'Gerhard is ok, ole!';
			
map = load('Vlijtseweg 89-91, Apeldoorn', icon, html, showAddresInfo);

*/

var _icon = '';
var _html = '';
var _map = '';
function createMarker(point, icon, html) {
  // Set up our GMarkerOptions object
  markerOptions = { icon:icon };
  var marker = new GMarker(point, markerOptions);

  if (html)
  	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});

  return marker;
}

function placeMarker(latlng) {
	if (!latlng) {
 		
	} else {
 		_map.setCenter(latlng, 13);
		if (_icon != null) _map.addOverlay(createMarker(latlng, _icon, _html));

		if (typeof(_callback_function) == 'function') {
			eval(_callback_function)(map, _html);
		}
	}
}
function load(address, icon, html, callback_function) {
	_icon = icon;
	_html = html;
	_callback_function = callback_function;

  if (GBrowserIsCompatible()) {

	// We need a geocoder for searching
	geocoder = new GClientGeocoder();

	_map = new GMap2(document.getElementById("map"));
	_map.setUIToDefault();


	geocoder.getLatLng(
	    	address,
			placeMarker
	  	);
   }

   return _map;
}

	

//]]>
