function gpx_createMarker(map, infowindow, latlon, infotxt) {
  var marker = new google.maps.Marker({position: latlon, map: map});
  google.maps.event.addListener(marker, "click", function() {
    infowindow.setContent(infotxt);
    infowindow.open(map, marker);
  });
  return marker;
}

function gpx_createTrack(map, infowindow, latlon, infotxt) {
  var track = new google.maps.Polyline({
    geodesic: true,
    path: latlon,
    strokeColor: "#FF0000",
    strokeWeight: 4,
    strokeOpacity: 0.7,
    map: map
  });
  google.maps.event.addListener(track, "mouseover", function(event) {
    infowindow.setContent(infotxt);
    infowindow.setPosition(event.latLng);
    infowindow.open(map);
    track.setOptions({strokeColor: "#33CCFF"});
  });
  google.maps.event.addListener(track, "mouseout", function() {
    infowindow.close();
    track.setOptions({strokeColor: "#FF0000"});
  });
  return track;
}

function MapSizeControl(map, outerDiv, outerDivName, innerDiv, ctrlDiv) {
  ctrlDiv.style.padding = "5px";
  var ctrUI = document.createElement("div");
  ctrUI.style.backgroundColor = "white";
  ctrUI.style.borderStyle = "solid";
  ctrUI.style.borderWidth = "2px";
  ctrUI.style.cursor = "pointer";
  ctrUI.style.textAlign = "center";
  ctrUI.title = "Click to enlarge map";
  ctrlDiv.appendChild(ctrUI);
  var ctrText = document.createElement("div");
  ctrText.style.fontFamily = "Arial,sans-serif";
  ctrText.style.fontSize = "12px";
  ctrText.style.paddingLeft = "4px";
  ctrText.style.paddingRight = "4px";
  ctrText.innerHTML = "Enlarge map";
  ctrUI.appendChild(ctrText);
  google.maps.event.addDomListener(ctrUI, "click", function() {
    if (outerDiv.id == "fixpos") {
      outerDiv.id = outerDivName;
      innerDiv.className = "map_canvas";
      ctrUI.title = "Click to enlarge map";
      ctrText.innerHTML = "Enlarge map";
    } else {
      outerDiv.id = "fixpos";
      innerDiv.className = "map_canvas_fixpos";
      ctrUI.title = "Click to shrink map";
      ctrText.innerHTML = "Shrink map";
    }
    google.maps.event.trigger(map, "resize");
  });
}

function infoOptions() {
  return {
    alignBottom: true,
    boxClass: "infoBox",
    boxStyle: { 
      background: "yellow",
      border: "1px solid black",
      padding: "5px",
      opacity: 0.75,
      whiteSpace: "nowrap",
      fontSize: "0.833em"
    },
    closeBoxMargin: "-2px -2px -2px -2px",
    closeBoxURL: "/geo/images/close.gif",
    disableAutoPan: false,
    enableEventPropagation: false,
    infoBoxClearance: new google.maps.Size(5, 5),
    isHidden: false,
    maxWidth: 0,
    pane: "floatPane",
    pixelOffset: new google.maps.Size(0, 0),
    zIndex: null
  };
}
