// --> XmlHttpRequest support



// --> Get an update to the list of markers from the server

    function getMarkersFromServer (noUpdate) {
      target = domain + "/cgi-bin/mapProperties.cgi?f=u";
      xhReq.abort();		// Abort any previously running request
      xhReq.open("get", target, true); // Server stuck in a loop.
      xhReq.send (null);
      if (noUpdate == null) {
        setTimeout ('getMarkersFromServer();', delayServerUpdate);
      }
    }



// --> Mapping support


// -- Set map center and zoom to display all markers

    function mapSetCenterZoom (map, 
		LatitudeMinimum, LongitudeMinimum, LatitudeMaximum, LongitudeMaximum, zoom) {

      sw = new google.maps.LatLng(LatitudeMinimum, LongitudeMinimum);
      ne = new google.maps.LatLng(LatitudeMaximum, LongitudeMaximum);
      bounds = new google.maps.LatLngBounds(sw, ne);
      if (zoom == 0) {zoom = map.getBoundsZoomLevel(bounds);}
      center = bounds.getCenter();
      map.setCenter(center, zoom);
    }


// --> User action handlers

    function mapShowAll () {
      latmin = 90;
      latmax = -90;
      lonmin = 360;
      lonmax = -360;
	  defLonCenter = -95.361328;
	  defLatCenter = 38.272689;
	  defLonExtent = 59.589844 /2;
	  defLatExtent = 26.050196 /2;
	  
      for (ii=0; ii<point.length; ii++) {
        latmin = Math.min(latmin, point[ii].lat);
        latmax = Math.max(latmax, point[ii].lat);
        lonmin = Math.min(lonmin, point[ii].long);
        lonmax = Math.max(lonmax, point[ii].long);
      }
	  if (latmin == 90 || latmax == -90) {
	    latmin = defLatCenter - defLatExtent;
	    latmax = defLatCenter + defLatExtent;
	  }
	  if (lonmin == 360 || lonmax == -360) {
	    lonmin = defLonCenter - defLonExtent;
	    lonmax = defLonCenter + defLonExtent;
	  }
	  if (lonmin==lonmax || latmin==latmax) {
	      zoom = 15;
	    } else {
		  zoom = 0;
	  }
      mapSetCenterZoom (map, latmin, lonmin, latmax, lonmax, zoom);
      return;
    }
    function mapShowFirst () {
      latmin = 90;
      latmax = -90;
      lonmin = 360;
      lonmax = -360;
	  defLonCenter = -95.361328;
	  defLatCenter = 38.272689;
	  defLonExtent = 59.589844 /2;
	  defLatExtent = 26.050196 /2;
	  
        latmin = Math.min(latmin, point[0].lat);
        latmax = Math.max(latmax, point[0].lat);
        lonmin = Math.min(lonmin, point[0].long);
        lonmax = Math.max(lonmax, point[0].long);
	  if (latmin == 90 || latmax == -90) {
	    latmin = defLatCenter - defLatExtent;
	    latmax = defLatCenter + defLatExtent;
	  }
	  if (lonmin == 360 || lonmax == -360) {
	    lonmin = defLonCenter - defLonExtent;
	    lonmax = defLonCenter + defLonExtent;
	  }
	  if (lonmin==lonmax || latmin==latmax) {
	      zoom = 15;
	    } else {
		  zoom = 0;
	  }
      mapSetCenterZoom (map, latmin, lonmin, latmax, lonmax, zoom);
      map.checkResize();
      return;
    }

