PathControl = function () {}
PathControl.prototype = new GControl();
PathControl.prototype.initialize = function(map) {
  var container = $(document.createElement('div'));
  container.setStyle({
    width: '32px',
    height: '32px',
    background: 'url(' + this.image() + ') no-repeat'
  });

  this.map = map;
  var me = this;
  GEvent.addDomListener(container, "click", function () {me.clunk()});

  map.getContainer().appendChild(container);
  return container;
}
PathControl.prototype.nextPathMarker = function () {
  var markers = this.map.path().concat(this.map.orphans());
  var i = 0;
  if (this.map.activeMarker) {
    for (i; i < markers.length; i++) {
      if (markers[i] == this.map.activeMarker) { 
        i += 1;
        break; 
      }
    }
  }

  if (i >= markers.length) { i = 0; }
  var iStart = i;

  for (i; i < markers.length; i++) {
    if (!markers[i].kink()) { return markers[i]; }
  }

  for (i = 0; i < iStart; i++) {
    if (!markers[i].kink()) { return markers[i]; }
  }
}


PathFirstControl = function () {}
PathFirstControl.prototype = new PathControl();
PathFirstControl.prototype.image = function () { 
  return '/images/blueprints/mapblg/ctrl_marker_first.png';
}
PathFirstControl.prototype.clunk = function () {
  this.map.activeMarker = null;
  var mkr = this.nextPathMarker();
  mkr.openInfoWindow(mkr.infWin);
}
PathFirstControl.prototype.getDefaultPosition = function () {
  return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(36, 10));
}

PathNextControl = function () {}
PathNextControl.prototype = new PathControl();
PathNextControl.prototype.image = function () { 
  return '/images/blueprints/mapblg/ctrl_marker_next.png';
}
PathNextControl.prototype.clunk = function () {
  var mkr = this.nextPathMarker();
  mkr.openInfoWindow(mkr.infWin);
}
PathNextControl.prototype.getDefaultPosition = function () {
  return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(4, 10));
}
