﻿// Functions used for showing google maps

function loadGoogleMap() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());  
        map.setCenter(new GLatLng(_latitude, _longitude), 13);
		var point = new GLatLng(_latitude, _longitude);
		map.addOverlay(createMarker(point,_location_html));
		map.openInfoWindow(map.getCenter(),_location_html);
      }
    }
	
	// Creates a marker at the given point with the given number label
	function createMarker(point, address) {
	  var marker = new GMarker(point);
	  GEvent.addListener(marker, "click", function() {
	    marker.openInfoWindowHtml(address);
	  });
	  return marker;
	}


	function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              map.addOverlay(createMarker(point,address));
              marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }


