var locations = new Array();
var map = null;
var geocoder = null;	

locations[0] = "Redwood City, CA"
locations[1] = "Sacramento, CA"
locations[2] = "Jacksonville, FL"
locations[3] = "Atlanta, GA"
locations[4] = "Chicago, IL"
locations[5] = "Kansas City, KS "
locations[6] = "Boston, MA"
locations[7] = "Northampton, MA"
locations[8] = "Minneapolis, MN"
locations[9] = "Rochester, MN"
locations[10] = "Jackson, MS"
locations[11] = "St. Louis, MO"
locations[12] = "Omaha, NE"
locations[13] = "Concord, NH"
locations[14] = "Albuquerque, NM"
locations[15] = "Buffalo, NY"
locations[16] = "Columbus, OH"
locations[17] = "Cincinnati, OH"
locations[18] = "Oklahoma City, OK"
locations[19] = "Pittsburgh, PA"
locations[20] = "San Antonio, TX"
locations[21] = "Logan, UT"
locations[22] = "Seattle, WA"

    function load() {
	  var iter = null;
      if (GBrowserIsCompatible()) {
       	geoload(39.095962936305476, -95.712890625);
		document.getElementById("Locat").innerHTML = listLocations();
      }
    }
	
	function listLocations() {
		var LocList = null;
		var iter = null;
		LocList = "<table width=\"700\" border=\"0\" align=\"left\" cellpadding=\"5\" style=\"margin-left:25px;\">";
		LocList = LocList + "<tr><td width=\"237\" valign=\"top\"><ul>";
		for (iter in locations) {
				if (iter==12) {// this is one greater than half the list
					LocList = LocList + "</ul></td><td width=\"247\" valign=\"top\"><ul>";
				}	
				LocList = LocList + "<li>" + getPoint(locations[iter]) + "</li>";	
				//showAddress(locations[iter]); 
		}
		LocList = LocList + "</ul></table>";
		return LocList;
	}
			
    function geoload(LT,LG) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(LT,LG), 4);
        geocoder = new GClientGeocoder();
      }
    }

    function showAddress(address) {
      this.lost = false;
      if (geocoder) {
	  geocoder.getLatLng(address, function(point) {
            if (!point) { 
				this.lost = true; 
				//getPoint(address);
				//alert(address + " Not found!");
			} else {
                var marker = new GMarker(point);
                map.addOverlay(marker);			
			    GEvent.addListener(marker, "click", function() {
            	  marker.openInfoWindowHtml(address);
         	    });
			  //alert(address);
       		}
        });
      }
	  if (this.lost) {alert("some locations were lost.");}
    }
	
	function getPoint(address) {
		var r = "no";
		this.r = r;
		if (geocoder) {
			geocoder.getLatLng(address, function(point) {
					var pr="NA";												  
					if (!point) {
						pr="not found";
					} else {
						pr=address;
						var marker = new GMarker(point);
		                map.addOverlay(marker);	
					    GEvent.addListener(marker, "click", function() {
						marker.openInfoWindowHtml(address);
         	    		});
					}
					return pr
			});
			//this.r = address
		}
		return address
	}
// JavaScript Document
