/** 
 * File Info
 * ----------------------------------
 * @filename     googlemaps.js
 * @created      xx.xx.xxxx
 * @author       Unknown, but it's based on the one used in this page: 
 *               http://www.overflowespressocafe.com/directions.html.
 * @description  This file checks if the browser is compatible with Google Maps,
 *               puts a marker for Limestone Coffee & Tea, and has a function
 *               to take an address from a user and give directions using Google.
 *
 * History
 * ---------------------------------
 * Date         Name      Note
 * 1/29         Dan       Changed GLatLng to Limstone address and added the html variable 
 *                        so I could edit the size of the font in the address window.
 */

    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
        var html = "<div style='font-size: 0.8em'>" +
            "<b>Limestone Coffee & Tea</b>" +
            "<br>15 E. Wilson St.<br>Batavia, IL 60510" +
            "</div>"; 
        map.setCenter(new GLatLng(41.8515, -88.306646), 15);
		var point = new GLatLng(41.850027, -88.306646);
		map.addOverlay(createMarker(point));
		map.openInfoWindow(point,html);
      }
    }
	
	// Creates a marker at the given point with the given number label
	function createMarker(point) {
	  var marker = new GMarker(point);
        var html = "<div style='font-size: 0.8em'>" +
            "<b>Limestone Coffee & Tea</b>" +
            "<br>15 E. Wilson St.<br>Batavia, IL 60510" +
            "</div>";
	  GEvent.addListener(marker, "click", function() {
	    marker.openInfoWindowHtml(html);
	  });
	  return marker;
	}

	function showAddress(address) {
      if (geocoder) {
        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(address);
            }
          }
        );
      }
    }