    //<![CDATA[
	var map;
	var om;
	
	
    function loadMap() {
      if (GBrowserIsCompatible()) {
		  
		 om = new OverlayMessage(document.getElementById('loading'));      
		 om.Set('<b>Loading...</b>');  
			  
		  map = new GMap2(document.getElementById("map"));
		  map.addControl(new GLargeMapControl());
		  map.addControl(new GMapTypeControl());
		  map.setCenter(new GLatLng(47.666775, -117.325745), 11);
	  }
    }
	
    if (GBrowserIsCompatible()) { 
      // A function to create the marker and set up the event window
      // Dont try to unroll this function. It has to be here for the function closure
      // Each instance of the function preserves the contends of a different instance
      // of the "marker" and "html" variables which will be needed later when the event triggers.    

	  	  // display the loading message


      // remove the loading message when the page has finished loading
      function clearmessage() {
        om.Clear();
      }
	  
      function createMarker(point,html) {
        var marker = new GMarker(point);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        gmarkers[i] = marker;
        return marker;
      }

	var geocoder = new GClientGeocoder();
	geocoder.setCache(null);
	
	var bounds = new GLatLngBounds();

    function convertToLatLng() { 
      if (points.length >= addresses.length) { 
        showPoints(); 
      } else { 
        geocode(addresses[points.length]); 
      } 
    } 

    function geocodeSingle(address) { 
	//alert("in geocoder");
      if (geocoder) { 
        geocoder.getLatLng( 
          address, 
          function(point) { 
		    if (!point) {
				alert(address + " was not found");
			} else {
            	points.push(point); 
            	window.setTimeout(convertToLatLng, 1200); 
			}
          } 
        ); 
      } 
    }

    function geocode(address) { 
	//alert("in geocoder");
      if (geocoder) { 
        geocoder.getLatLng( 
          address, 
          function(point) { 
            	window.setTimeout(convertToLatLng, 1500); 
            	points.push(point); 
          } 
        ); 
      } 
    } 

    function showPoints() { 
	//alert("in show points");
	  var valid_pts = 0;
	  var invalid_pts = 0;
      for (i in points) { 
        var lat_lng = points[i]; 
        if (lat_lng) { 
			var html_text = htmls[i];
			var marker = createMarker(lat_lng,html_text)
              map.addOverlay(marker);
			  bounds.extend(lat_lng);
			  valid_pts = valid_pts + 1;
        } else {
			invalid_pts = invalid_pts + 1;
		}
      } 
	  
	  if (valid_pts > 0){
		  
		  //clear 'loading' message
		  clearmessage();
		  
		  // ===== determine the zoom level from the bounds =====
		  map.setZoom(map.getBoundsZoomLevel(bounds));
	
		  // ===== determine the centre from the bounds ======
		  var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
		  var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
		  map.setCenter(new GLatLng(clat,clng));
		  
	  } 
	  
	  if (invalid_pts > 0){
		  alert("At least one address was invalid and could not be plotted.");  
	  }
    } 



    } else { // display a warning if the browser was not compatible
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }



    // This Javascript is based on code provided by the
    // Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/   
    // http://www.econym.demon.co.uk/googlemaps/
	
    //]]>