// JavaScript Document

var map = null;
var geocoder = null;

function start_google_map(address, popup) {
	initialize();
	showAddress(address, popup);
}

function initialize() {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map_canvas"));
	map.setCenter(new GLatLng(-27.464337, 153.027878), 15);
	geocoder = new GClientGeocoder();
	map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
  }
}

function showAddress(address, popup) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        //alert(address + " not found");
      } else {
        map.setCenter(point, 15);
        var marker = new GMarker(point);
        map.addOverlay(marker);
        //marker.openInfoWindowHtml(popup);
      }
    }
  );
}
function addAddress(address, popup) {
  map.clearOverlays();
  if (geocoder) {
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) {
		  //alert(address + " not found");
		} else {
		  var marker = new GMarker(point);
		  map.addOverlay(marker);
		  marker.openInfoWindowHtml(popup);
		}
	  }
	);
  }
}
