//<![CDATA[

var map;
var geocoder;

var load = function() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
		geocoder = new GClientGeocoder();

		CenterMap();
//        map.setCenter(new GLatLng(61.10, -150.1), 8);
      }
};

var CenterMap = function () {

	current_url = document.location.href;

	lastPeriod = current_url.lastIndexOf(".");
	lastSlash = current_url.lastIndexOf("/");
	start = lastSlash+1;
	end = lastPeriod - start;

	citystate = current_url.substr(start, end);
	citystate = citystate.replace(/\-/,", ");

	// Initialize the Map for the USA
/*	geocoder.getLatLng(
	    "USA",
	    function(point) {
	      if (!point) { alert("USA" + " not found"); }
	      else { map.setCenter(point, 3); }
	    }
	);
*/

	geocoder.getLatLng(
			    citystate,
			    function(point) {
			      if (!point) {
			        alert(citystate + " not found");
			      } else {
			        var to_marker = new GMarker(point);
			        map.addOverlay(to_marker);

					routePoints = [];
					routePoints.push(point);
					map.setCenter(point, 8);
/*
					var bounds = new GLatLngBounds();
				    for (var i=0; i< routePoints.length; i++) {
				       bounds.extend(routePoints[i]);
				    }
				    map.setZoom(map.getBoundsZoomLevel(bounds));
				    map.setCenter(bounds.getCenter());
*/

			}
		}
	);
};

//]]>