function AdfOverflowSupport(overflowId, peer, type, position, orientation, useRovingTabIndex) {
  this.Init(overflowId, peer, type, position, orientation, useRovingTabIndex);
}
AdfObject.createSubclass(AdfOverflowSupport);
AdfOverflowSupport.InitClass = function() {
  this._POPUP_ID_START = "_afrOfwSrt";
  this._POPUP_ID_END = "_afrOfwEnd";
  this._DEPRESSED_STYLE_CLASS = "p_AFDepressed";
};
AdfOverflowSupport.prototype.Init = function(overflowId, peer, type, position, orientation, useRovingTabIndex) {
  AdfOverflowSupport.superclass.Init.call(this);
  this._peer = peer;
  this._type = type || "end";
  this._position = position || "after";
  this._orientation = orientation || "horizontal";
  this._useRovingTabIndex = useRovingTabIndex;
  this._element = AdfAgent.AGENT.getElementById(overflowId);
  if (this._supportsStartOverflow()) {
    this._startContainer = this._getElement(overflowId, "soc");
    this._startIndicator = this._getElement(overflowId, "soi");
    if (this._startIndicator) {
      this._initStartButtonEventHandling();
    }
  }
  if (this._supportsEndOverflow()) {
    this._endContainer = this._getElement(overflowId, "eoc");
    this._endIndicator = this._getElement(overflowId, "eoi");
    if (this._endIndicator != null) {
      this._initEndButtonEventHandling();
    }
  }
  if (this._supportsDroplist()) {
    var dlcId = AdfRichUIPeer.CreateSubId(overflowId, "dlc");
    this._droplistContainer = AdfAgent.AGENT.getElementById(dlcId);
  }
  this._steps = [];
  this._firstVisibleStep = 0;
  this._lastVisibleStep = -1;
  this._handlingResize = false;
};
AdfOverflowSupport.needsOverflow = function(overflowId) {
  var element = AdfAgent.AGENT.getElementById(overflowId);
  var contentWidth = Math.max(element.firstChild.offsetWidth, element.scrollWidth);
  if (contentWidth > element.offsetWidth) {
    return true;
  }
  var contentHeight = Math.max(element.firstChild.offsetHeight, element.scrollHeight);
  if (contentHeight > element.offsetHeight) {
    return true;
  }
  return false;
};
AdfOverflowSupport.getOverflowChildComponents = function(baseComponent, children) {
  if (!children) {
    children = new Array;
  }
  var agent = AdfAgent.AGENT;
  var clientId = baseComponent.getClientId();
  var parentEocId = AdfRichUIPeer.createSubId(clientId, "eoc");
  var parentSocId = AdfRichUIPeer.createSubId(clientId, "soc");
  var endOverflowContainer = agent.getElementById(parentEocId);
  if (endOverflowContainer) {
    agent.getDescendantComponentsForNode(endOverflowContainer, children);
  }
  var startOverflowContainer = agent.getElementById(parentSocId);
  if (startOverflowContainer) {
    agent.getDescendantComponentsForNode(startOverflowContainer, children);
  }
  return children;
};
AdfOverflowSupport.prototype.removeOverflowSupport = function(ignoreOverflowComponentCleanup) {
  if (!ignoreOverflowComponentCleanup) {
    if (this._startContainer) {
      AdfPage.PAGE.removeComponentsInSubtree(this._startContainer);
    }
    if (this._endContainer) {
      AdfPage.PAGE.removeComponentsInSubtree(this._endContainer);
    }
  }
  delete this._peer;
  delete this._element;
  if (this._supportsStartOverflow()) {
    delete this._startContainer;
    if (this._startIndicator) {
      this._removeStartButtonCallbacks();
      delete this._startIndicator;
      delete this._startHints;
    }
    if (this._startContainerParent) {
      delete this._startContainerParent;
    }
  }
  if (this._supportsEndOverflow()) {
    this._removeEndButtonCallbacks();
    delete this._endIndicator;
    delete this._endContainer;
    delete this._endHints;
    if (this._endContainerParent) {
      delete this._endContainerParent;
    }
  }
  if (this._supportsDroplist()) {
    delete this._droplistContainer;
  }
  this._removeSteps();
};
AdfOverflowSupport.prototype.createStep = function() {
  var step = {elements:[], overflowElements:[], swapElements:[]};
  this._steps.push(step);
  this._lastVisibleStep++;
};
AdfOverflowSupport.prototype.addElement = function(element) {
  var stepIndex = this._steps.length - 1;
  this._steps[stepIndex].elements.push(element);
};
AdfOverflowSupport.prototype.addOverflowElement = function(element) {
  this._steps[this._steps.length - 1].overflowElements.push(element);
};
AdfOverflowSupport.prototype.createSwapPosition = function(element) {
  var stepIndex = this._steps.length - 1;
  var ownerDocument = element.ownerDocument;
  var overflowPosition = ownerDocument.createElement("a");
  overflowPosition.style.display = "none";
  var elementPosition = ownerDocument.createElement("a");
  elementPosition.style.display = "none";
  element.parentNode.insertBefore(elementPosition, element);
  this._steps[stepIndex].swapElements.push([element, elementPosition, overflowPosition]);
  return overflowPosition;
};
AdfOverflowSupport.prototype.addDropListElements = function(elementArray) {
  var droplistContainer = this._droplistContainer;
  for (var i = 0;i < elementArray.length;i++) {
    var child = elementArray[i];
    droplistContainer.appendChild(child);
  }
};
AdfOverflowSupport.prototype.handleResize = function() {
  if (this._handlingResize) {
    return;
  }
  this._handlingResize = true;
  this._handleResize();
  this._handlingResize = false;
};
AdfOverflowSupport.prototype._handleResize = function() {
  var availableWidth = this._getAvailableWidth();
  var availableHeight = this._getAvailableHeight();
  if (this._supportsBothOverflow()) {
    this._handleResizeTypeBoth(availableWidth, availableHeight);
    return;
  }
  var hasAvailableSpace;
  var totalSteps = this._steps.length;
  var visibleSteps = this._numberOfVisibleSteps();
  if (visibleSteps == totalSteps) {
    this._hideOverflowButtons();
    hasAvailableSpace = this._hasAvailableSpace(availableWidth, availableHeight);
    if (hasAvailableSpace) {
      return;
    }
  }
  this._showOverflowButtons(true);
  availableWidth = this._getAvailableWidth();
  availableHeight = this._getAvailableHeight();
  if (this._orientation == "horizontal" && availableWidth <= 50 || this._orientation == "vertical" && availableHeight <= 50) {
    this._hideAllSteps();
    hasAvailableSpace = this._hasAvailableSpace(availableWidth, availableHeight);
  } else {
    if (hasAvailableSpace == null) {
      hasAvailableSpace = this._hasAvailableSpace(availableWidth, availableHeight);
    }
    var lowerRange = hasAvailableSpace ? visibleSteps : 0;
    var upperRange = hasAvailableSpace ? totalSteps : visibleSteps;
    hasAvailableSpace = this._binarySearchAdjustSteps(hasAvailableSpace, availableWidth, availableHeight, lowerRange, upperRange);
    availableWidth = this._getAvailableWidth();
    availableHeight = this._getAvailableHeight();
  }
  hasAvailableSpace = this._showSteps(availableWidth, availableHeight, hasAvailableSpace);
  availableWidth = this._getAvailableWidth();
  availableHeight = this._getAvailableHeight();
  if (this._numberOfVisibleSteps() == totalSteps) {
    if (hasAvailableSpace) {
      this._hideOverflowButtons();
      this._closeOverflowPopups();
      return;
    } else {
      this._hideOverflowButtons();
      hasAvailableSpace = this._hasAvailableSpace(availableWidth, availableHeight);
      if (hasAvailableSpace) {
        this._closeOverflowPopups();
        return;
      }
      this._showOverflowButtons(true);
    }
  }
  this._hideSteps(availableWidth, availableHeight, hasAvailableSpace);
  if (this._useRovingTabIndex) {
    this._resetActiveDescendant();
  }
};
AdfOverflowSupport.prototype.removeAllItemsFromOverflow = function() {
  this._hideOverflowButtons();
  this._showAllSteps();
  this._closeOverflowPopups();
};
AdfOverflowSupport.prototype.focusNextChild = function(popupContainer) {
  if (this._canMoveFocus(popupContainer)) {
    var nextItem = AdfFocusUtils.focusNextActiveDescendant(popupContainer, this._activeDescendant, true);
    AdfAssert.assertDomElement(nextItem);
    this._activeDescendant = nextItem;
  }
};
AdfOverflowSupport.prototype.focusPreviousChild = function(popupContainer) {
  if (this._canMoveFocus(popupContainer)) {
    var prevItem = AdfFocusUtils.focusPreviousActiveDescendant(popupContainer, this._activeDescendant, true);
    AdfAssert.assertDomElement(prevItem);
    this._activeDescendant = prevItem;
  }
};
AdfOverflowSupport.prototype._canMoveFocus = function(popupContainer) {
  AdfAssert.assert(this._useRovingTabIndex);
  AdfAssert.assertDomElement(popupContainer);
  AdfAssert.assertDomElement(this._activeDescendant);
  AdfAssert.assert(this._activeDescendant.getAttribute("tabindex") == "0", "The overflow popup's active descendant should have tabindex 0");
  if (!this._activeDescendant) {
    AdfLogger.LOGGER.warning("Overflow has lost its assigned activeDescendant!");
    this.resetActiveDescendant();
  }
  return this._activeDescendant != null;
};
AdfOverflowSupport.prototype.updateActiveDescendant = function(newActiveDescendant) {
  AdfAssert.assertDomElement(newActiveDescendant);
  if (this._activeDescendant != newActiveDescendant) {
    if (this._activeDescendant) {
      this._activeDescendant.setAttribute("tabIndex", "-1");
    }
    newActiveDescendant.setAttribute("tabIndex", "0");
    this._activeDescendant = newActiveDescendant;
  }
};
AdfOverflowSupport.prototype.isInOverflow = function(domElement) {
  if (this._supportsEndOverflow()) {
    if (AdfDomUtils.isAncestor(this._endContainer, domElement)) {
      return "end";
    }
  }
  if (this._supportsStartOverflow()) {
    if (AdfDomUtils.isAncestor(this._startContainer, domElement)) {
      return "start";
    }
  }
};
AdfOverflowSupport.prototype.showOverflowPopup = function(location) {
  var peer = this._peer;
  var component = this._peer.getComponent();
  var popupId = location == "start" ? AdfOverflowSupport._POPUP_ID_START : AdfOverflowSupport._POPUP_ID_END;
  if (peer.isPopupVisible(component, popupId)) {
    return;
  }
  if (location == "start") {
    this._initializeStartContainerCallback();
    this._overflowButtonPressed(AdfOverflowSupport._POPUP_ID_START, this._startContainer, this._startHints);
  } else {
    this._initializeEndContainerCallback();
    if (this._supportsDroplist()) {
      this._overflowButtonPressed(AdfOverflowSupport._POPUP_ID_END, this._droplistContainer, this._endHints);
    } else {
      this._overflowButtonPressed(AdfOverflowSupport._POPUP_ID_END, this._endContainer, this._endHints);
    }
  }
};
AdfOverflowSupport.prototype._closeOverflowPopups = function() {
  var peer = this._peer;
  var component = peer.getComponent();
  if (peer.isPopupVisible(component, AdfOverflowSupport._POPUP_ID_START)) {
    peer.hidePopup(component, AdfOverflowSupport._POPUP_ID_START);
  }
  if (peer.isPopupVisible(component, AdfOverflowSupport._POPUP_ID_END)) {
    peer.hidePopup(component, AdfOverflowSupport._POPUP_ID_END);
  }
};
AdfOverflowSupport.prototype._supportsStartOverflow = function() {
  return this._type == "start" || this._type == "both" || this._type == "droplist";
};
AdfOverflowSupport.prototype._supportsEndOverflow = function() {
  return this._type == "end" || this._type == "both" || this._type == "droplist";
};
AdfOverflowSupport.prototype._supportsBothOverflow = function() {
  return this._type == "both" || this._type == "droplist";
};
AdfOverflowSupport.prototype._supportsDroplist = function() {
  return this._type == "droplist";
};
AdfOverflowSupport.prototype._getElement = function(overflowId, subString) {
  var id = AdfRichUIPeer.CreateSubId(overflowId, subString);
  return AdfAgent.AGENT.getElementById(id);
};
AdfOverflowSupport.prototype._initStartButtonEventHandling = function() {
  var agent = AdfAgent.AGENT;
  var startIndicator = this._startIndicator;
  var startHints = this._createOverflowPopupHints();
  startHints[AdfDhtmlPopupHints.ALIGN_ELEMENT] = startIndicator;
  startHints[AdfRichPopup.HINT_ALIGN] = this._position == "before" ? AdfRichPopup["ALIGN_BEFORE_START"] : AdfRichPopup["ALIGN_AFTER_START"];
  this._startHints = startHints;
  this._startShowCall = this.createCallback(this._startOverflowButtonPressed);
  var startShowCall = this._startShowCall;
  agent.addBubbleEventListener(startIndicator, "mousedown", startShowCall);
  agent.addBubbleEventListener(startIndicator, "keydown", startShowCall);
  this._startButtonMouseUpCall = this.createCallback(this._startOverflowButtonMouseUp);
  agent.addBubbleEventListener(startIndicator, "mouseup", this._startButtonMouseUpCall);
  this._startButtonMouseOutCall = this.createCallback(this._startOverflowButtonMouseOut);
  agent.addBubbleEventListener(startIndicator, "mouseout", this._startButtonMouseOutCall);
};
AdfOverflowSupport.prototype._initEndButtonEventHandling = function() {
  var agent = AdfAgent.AGENT;
  var endIndicator = this._endIndicator;
  var endHints = this._createOverflowPopupHints();
  endHints[AdfDhtmlPopupHints.ALIGN_ELEMENT] = this._endIndicator;
  endHints[AdfRichPopup.HINT_ALIGN] = this._position == "before" ? AdfRichPopup["ALIGN_BEFORE_END"] : AdfRichPopup["ALIGN_AFTER_END"];
  this._endHints = endHints;
  this._endShowCall = this.createCallback(this._endOverflowButtonPressed);
  var endShowCall = this._endShowCall;
  agent.addBubbleEventListener(endIndicator, "mousedown", endShowCall);
  agent.addBubbleEventListener(endIndicator, "keydown", endShowCall);
  this._endButtonMouseUpCall = this.createCallback(this._endOverflowButtonMouseUp);
  agent.addBubbleEventListener(endIndicator, "mouseup", this._endButtonMouseUpCall);
  this._endButtonMouseOutCall = this.createCallback(this._endOverflowButtonMouseOut);
  agent.addBubbleEventListener(endIndicator, "mouseout", this._endButtonMouseOutCall);
};
AdfOverflowSupport.prototype._createOverflowPopupHints = function() {
  var hints = new Object;
  hints[AdfDhtmlPopupHints.AUTODISMISS] = AdfDhtmlPopupHints.AUTODISMISS_ALWAYS;
  hints[AdfDhtmlPopupHints.FOCUS] = true;
  hints[AdfDhtmlPopupHints.TYPE] = AdfDhtmlPopupHints.TYPE_MENU;
  hints[AdfDhtmlPopupHints.CLOSE_ON_ESCAPE] = true;
  return hints;
};
AdfOverflowSupport.prototype._startOverflowButtonPressed = function(event) {
  var agent = AdfAgent.AGENT;
  var eventType = event.type;
  var keyCode = event.keyCode;
  if (eventType == "keydown" && (keyCode != AdfKeyStroke.ENTER_KEY && keyCode != AdfKeyStroke.ARROWDOWN_KEY && keyCode != AdfKeyStroke.SPACE_KEY)) {
    return;
  } else {
    if (eventType == "mousedown" && event.button && event.button != AdfUIInputEvent.LEFT_BUTTON_FLAG) {
      agent.eatEvent(event);
      return;
    }
  }
  this._initializeStartContainerCallback();
  this._overflowButtonPressed(AdfOverflowSupport._POPUP_ID_START, this._startContainer, this._startHints);
  if (eventType == "mousedown") {
    var targetElement = agent.getEventTarget(event);
    this._setDepressedStyle(targetElement, true);
  }
  agent.eatEvent(event);
};
AdfOverflowSupport.prototype._initializeStartContainerCallback = function() {
  if (this._hideStartContainerCallback == null) {
    this._hideStartContainerCallback = this.createCallback(this._hideStartContainer);
    AdfObject.ensureClassInitialization(AdfDhtmlPopupWindow);
    this._startHints[AdfDhtmlPopupHints.CLOSE_HANDLER] = this._hideStartContainerCallback;
    this._startContainerParent = this._startContainer.parentNode;
  }
};
AdfOverflowSupport.prototype._startOverflowButtonMouseUp = function(event) {
  var targetElement = AdfAgent.AGENT.getEventTarget(event);
  this._setDepressedStyle(targetElement, false);
};
AdfOverflowSupport.prototype._startOverflowButtonMouseOut = function(event) {
  var targetElement = AdfAgent.AGENT.getEventTarget(event);
  this._setDepressedStyle(targetElement, false);
};
AdfOverflowSupport.prototype._endOverflowButtonPressed = function(event) {
  var agent = AdfAgent.AGENT;
  var eventType = event.type;
  var keyCode = event.keyCode;
  if (eventType == "keydown" && (keyCode != AdfKeyStroke.ENTER_KEY && keyCode != AdfKeyStroke.ARROWDOWN_KEY && keyCode != AdfKeyStroke.SPACE_KEY)) {
    return;
  } else {
    if (eventType == "mousedown" && event.button && event.button != AdfUIInputEvent.LEFT_BUTTON_FLAG) {
      agent.eatEvent(event);
      return;
    }
  }
  this._initializeEndContainerCallback();
  if (this._supportsDroplist()) {
    this._overflowButtonPressed(AdfOverflowSupport._POPUP_ID_END, this._droplistContainer, this._endHints);
  } else {
    this._overflowButtonPressed(AdfOverflowSupport._POPUP_ID_END, this._endContainer, this._endHints);
  }
  if (eventType == "mousedown") {
    var targetElement = agent.getEventTarget(event);
    this._setDepressedStyle(targetElement, true);
  }
  agent.eatEvent(event);
};
AdfOverflowSupport.prototype._initializeEndContainerCallback = function() {
  if (this._hideEndContainerCallback == null) {
    this._hideEndContainerCallback = this.createCallback(this._hideEndContainer);
    AdfObject.ensureClassInitialization(AdfDhtmlPopupWindow);
    this._endHints[AdfDhtmlPopupHints.CLOSE_HANDLER] = this._hideEndContainerCallback;
    this._endContainerParent = this._endContainer.parentNode;
  }
};
AdfOverflowSupport.prototype._endOverflowButtonMouseUp = function(event) {
  var targetElement = AdfAgent.AGENT.getEventTarget(event);
  this._setDepressedStyle(targetElement, false);
};
AdfOverflowSupport.prototype._endOverflowButtonMouseOut = function(event) {
  var targetElement = AdfAgent.AGENT.getEventTarget(event);
  this._setDepressedStyle(targetElement, false);
};
AdfOverflowSupport.prototype._setDepressedStyle = function(targetElement, depressed) {
  var className = AdfOverflowSupport._DEPRESSED_STYLE_CLASS;
  if (depressed) {
    AdfDomUtils.addCSSClassName(targetElement, className);
  } else {
    AdfDomUtils.removeCSSClassName(targetElement, className);
  }
};
AdfOverflowSupport.prototype._overflowButtonPressed = function(popupId, popupContainer, popupHints) {
  var peer = this._peer;
  var component = this._peer.getComponent();
  if (peer.isPopupVisible(component, popupId)) {
    this._peer.hidePopup(component, popupId);
  } else {
    if (this._useRovingTabIndex) {
      this._resetActiveDescendant(popupContainer);
    }
    this._peer.showPopup(component, popupContainer, popupHints, popupId);
  }
};
AdfOverflowSupport.prototype._hideStartContainer = function() {
  if (this._startContainer) {
    this._startContainerParent.appendChild(this._startContainer);
  }
};
AdfOverflowSupport.prototype._hideEndContainer = function() {
  if (this._supportsDroplist() && this._droplistContainer) {
    var droplistContainerParent = this._droplistContainer.parentNode;
    droplistContainerParent.appendChild(this._droplistContainer);
  } else {
    if (this._endContainer) {
      this._endContainerParent.appendChild(this._endContainer);
    }
  }
};
AdfOverflowSupport.prototype._handleResizeTypeBoth = function(availableWidth, availableHeight) {
  this._hideOverflowButtons();
  this._setActiveStep();
  var hasAvailableSpace = this._hasAvailableSpace(availableWidth, availableHeight);
  hasAvailableSpace = this._showSteps(availableWidth, availableHeight, hasAvailableSpace);
  this._showOverflowButtons();
  availableWidth = this._getAvailableWidth();
  availableHeight = this._getAvailableHeight();
  hasAvailableSpace = this._hasAvailableSpace(availableWidth, availableHeight);
  while (this._hideSteps(availableWidth, availableHeight, hasAvailableSpace)) {
    this._showOverflowButtons();
    hasAvailableSpace = this._hasAvailableSpace(availableWidth, availableHeight);
  }
  if (this._numberOfVisibleSteps() == this._steps.length) {
    this._closeOverflowPopups();
  }
};
AdfOverflowSupport.prototype._setActiveStep = function() {
  var steps = this._steps;
  for (var i = 0;i < steps.length;i++) {
    var step = steps[i];
    for (var j = 0;j < step.overflowElements.length;j++) {
      var overflowElement = step.overflowElements[j];
      if (AdfDomUtils.containsCSSClassName(overflowElement.firstChild, "p_AFSelected")) {
        this._activeStep = i;
        return;
      }
    }
    for (var k = 0;k < step.elements.length;k++) {
      var element = step.elements[k];
      if (AdfDomUtils.containsCSSClassName(element, "p_AFSelected")) {
        this._activeStep = i;
        return;
      }
    }
  }
};
AdfOverflowSupport.prototype._binarySearchAdjustSteps = function(hasAvailableSpace, availableWidth, availableHeight, lowerRange, upperRange) {
  var rangeToDivide = upperRange - lowerRange;
  if (rangeToDivide <= 2) {
    return hasAvailableSpace;
  }
  var divider = Math.ceil(rangeToDivide / 2);
  for (var x = 0;x < divider;x++) {
    if (hasAvailableSpace) {
      this._showOneStep();
      availableWidth = this._getAvailableWidth();
      availableHeight = this._getAvailableHeight();
    } else {
      this._hideOneStep();
    }
  }
  hasAvailableSpace = this._hasAvailableSpace(availableWidth, availableHeight);
  if (hasAvailableSpace) {
    lowerRange = lowerRange + divider;
  } else {
    upperRange = upperRange - divider;
  }
  return this._binarySearchAdjustSteps(hasAvailableSpace, availableWidth, availableHeight, lowerRange, upperRange);
};
AdfOverflowSupport.prototype._showSteps = function(availableWidth, availableHeight, hasAvailableSpace) {
  while (this._numberOfVisibleSteps() < this._steps.length && (hasAvailableSpace || this._isActiveStepInOverflow())) {
    switch(this._type) {
      case "end":
        this._showEndStep();
        break;
      case "start":
        this._showStartStep();
        break;
      case "both":
      ;
      case "droplist":
        var startOffset = this._activeStep - this._firstVisibleStep;
        var endOffset = this._numberOfVisibleSteps() - startOffset - 1;
        var lastStep = this._steps.length - 1;
        if (startOffset < endOffset && this._firstVisibleStep != 0 || this._lastVisibleStep == lastStep) {
          this._showStartStep();
        } else {
          this._showEndStep();
        }
      ;
    }
    availableWidth = this._getAvailableWidth();
    availableHeight = this._getAvailableHeight();
    hasAvailableSpace = this._hasAvailableSpace(availableWidth, availableHeight);
  }
  return hasAvailableSpace;
};
AdfOverflowSupport.prototype._showAllSteps = function() {
  while (this._numberOfVisibleSteps() < this._steps.length) {
    switch(this._type) {
      case "end":
        this._showEndStep();
        break;
      case "start":
        this._showStartStep();
        break;
      case "both":
      ;
      case "droplist":
        if (this._firstVisibleStep != 0) {
          this._showStartStep();
        } else {
          this._showEndStep();
        }
      ;
    }
  }
};
AdfOverflowSupport.prototype._hideAllSteps = function() {
  while (this._numberOfVisibleSteps() > 0) {
    switch(this._type) {
      case "end":
        this._hideEndStep();
        break;
      case "start":
      ;
      case "both":
      ;
      case "droplist":
        this._hideStartStep();
        break;
    }
  }
};
AdfOverflowSupport.prototype._hideSteps = function(availableWidth, availableHeight, hasAvailableSpace) {
  var wasStepHidden = false;
  while (!hasAvailableSpace && this._numberOfVisibleSteps() > 0) {
    switch(this._type) {
      case "end":
        this._hideEndStep();
        break;
      case "start":
        this._hideStartStep();
        break;
      case "both":
      ;
      case "droplist":
        var startOffset = this._activeStep - this._firstVisibleStep;
        var endOffset = this._numberOfVisibleSteps() - startOffset - 1;
        if (startOffset >= endOffset || this._firstVisibleStep == -1) {
          this._hideStartStep();
        } else {
          this._hideEndStep();
        }
      ;
    }
    wasStepHidden = true;
    hasAvailableSpace = this._hasAvailableSpace(availableWidth, availableHeight);
  }
  return wasStepHidden;
};
AdfOverflowSupport.prototype._isActiveStepInOverflow = function() {
  if (this._supportsBothOverflow()) {
    return this._activeStep < this._firstVisibleStep || this._activeStep > this._lastVisibleStep;
  } else {
    return false;
  }
};
AdfOverflowSupport.prototype._getAvailableWidth = function() {
  return this._element.offsetWidth + 3;
};
AdfOverflowSupport.prototype._getAvailableHeight = function() {
  return this._element.offsetHeight + 5;
};
AdfOverflowSupport.prototype._hasAvailableSpace = function(availableWidth, availableHeight) {
  var contentWidth = Math.max(this._element.firstChild.offsetWidth, this._element.scrollWidth);
  var agent = AdfAgent.getAgent();
  if (AdfPage.PAGE.getLocaleContext().isRightToLeft() && (agent.getPlatform() == AdfAgent.IE_PLATFORM && agent.getVersion() < 8)) {
    contentWidth = this._element.scrollWidth;
  }
  var contentHeight = Math.max(this._element.firstChild.offsetHeight, this._element.scrollHeight);
  var hasAvailableWidth = contentWidth <= availableWidth;
  var hasAvailableHeight = contentHeight <= availableHeight;
  return hasAvailableWidth && hasAvailableHeight;
};
AdfOverflowSupport.prototype._showOneStep = function() {
  if (this._type == "end") {
    this._showEndStep();
  } else {
    if (this._type == "start") {
      this._showStartStep();
    }
  }
};
AdfOverflowSupport.prototype._showStartStep = function() {
  var step = this._steps[this._firstVisibleStep - 1];
  this._showStep(step, true);
  this._firstVisibleStep--;
};
AdfOverflowSupport.prototype._showEndStep = function() {
  var step = this._steps[this._lastVisibleStep + 1];
  this._showStep(step);
  this._lastVisibleStep++;
};
AdfOverflowSupport.prototype._hideOneStep = function() {
  if (this._type == "end") {
    this._hideEndStep();
  } else {
    if (this._type == "start") {
      this._hideStartStep();
    }
  }
};
AdfOverflowSupport.prototype._hideStartStep = function() {
  var step = this._steps[this._firstVisibleStep];
  this._hideStep(step, true);
  this._firstVisibleStep++;
};
AdfOverflowSupport.prototype._hideEndStep = function() {
  var step = this._steps[this._lastVisibleStep];
  this._hideStep(step);
  this._lastVisibleStep--;
};
AdfOverflowSupport.prototype._showStep = function(step, isStart) {
  this._showElements(step.elements);
  this._hideOverflowElements(step.overflowElements, isStart);
  this._swapElements(step.swapElements, true);
};
AdfOverflowSupport.prototype._hideStep = function(step, isStart) {
  this._hideElements(step.elements);
  this._showOverflowElements(step.overflowElements, isStart);
  this._swapElements(step.swapElements);
};
AdfOverflowSupport.prototype._hideElements = function(elements) {
  var elementsLength = elements.length;
  for (var i = 0;i < elementsLength;i++) {
    var element = elements[i];
    element._display = element.style.display;
    element.style.display = "none";
  }
};
AdfOverflowSupport.prototype._showElements = function(elements) {
  var elementsLength = elements.length;
  for (var i = 0;i < elementsLength;i++) {
    var element = elements[i];
    element.style.display = element._display || "";
  }
};
AdfOverflowSupport.prototype._hideOverflowElements = function(elements, isStart) {
  var elementsLength = elements.length;
  for (var i = 0;i < elementsLength;i++) {
    var element = elements[i];
    element.parentNode.removeChild(element);
  }
};
AdfOverflowSupport.prototype._showOverflowElements = function(elements, isStart) {
  var elementsLength = elements.length;
  var container = isStart ? this._startContainer : this._endContainer;
  for (var i = 0;i < elementsLength;i++) {
    var element = elements[i];
    if (this._position == "before" || isStart && this._orientation == "vertical") {
      container.appendChild(element);
    } else {
      container.insertBefore(element, container.firstChild);
    }
  }
};
AdfOverflowSupport.prototype._swapElements = function(elements, show) {
  var elementsLength = elements.length;
  for (var i = 0;i < elementsLength;i++) {
    var swapElements = elements[i];
    var element = swapElements[0];
    var position = swapElements[show ? 1 : 2];
    position.parentNode.insertBefore(element, position);
  }
};
AdfOverflowSupport.prototype._removeStartButtonCallbacks = function() {
  var agent = AdfAgent.AGENT;
  var startIndicator = this._startIndicator;
  agent.removeBubbleEventListener(startIndicator, "mousedown", this._startShowCall);
  agent.removeBubbleEventListener(startIndicator, "keydown", this._startShowCall);
  agent.removeBubbleEventListener(startIndicator, "mouseup", this._startButtonMouseUpCall);
  agent.removeBubbleEventListener(startIndicator, "mouseout", this._startButtonMouseOutCall);
};
AdfOverflowSupport.prototype._removeEndButtonCallbacks = function() {
  var agent = AdfAgent.AGENT;
  var endIndicator = this._endIndicator;
  agent.removeBubbleEventListener(endIndicator, "mousedown", this._endShowCall);
  agent.removeBubbleEventListener(endIndicator, "keydown", this._endShowCall);
  agent.removeBubbleEventListener(endIndicator, "mouseup", this._endButtonMouseUpCall);
  agent.removeBubbleEventListener(endIndicator, "mouseout", this._endButtonMouseOutCall);
};
AdfOverflowSupport.prototype._removeSteps = function() {
  var steps = this._steps;
  while (steps.length > 0) {
    var step = steps.pop();
    AdfCollections.clear(step.elements);
    AdfCollections.clear(step.overflowElements);
    var swapElements = step.swapElements;
    while (swapElements.length > 0) {
      var positions = swapElements.pop();
      AdfCollections.clear(positions);
    }
  }
};
AdfOverflowSupport.prototype._numberOfVisibleSteps = function() {
  var numberOfSteps = this._steps.length;
  var invisibleStartSteps = this._firstVisibleStep;
  var lastStep = numberOfSteps - 1;
  var invisibleEndSteps = lastStep - this._lastVisibleStep;
  return numberOfSteps - invisibleStartSteps - invisibleEndSteps;
};
AdfOverflowSupport.prototype._hideOverflowButtons = function() {
  switch(this._type) {
    case "end":
      AdfDomUtils.removeCSSClassName(this._element, "p_AFEndOverflow");
      break;
    case "start":
      AdfDomUtils.removeCSSClassName(this._element, "p_AFStartOverflow");
      break;
    case "both":
      AdfDomUtils.removeCSSClassName(this._element, "p_AFEndOverflow");
      AdfDomUtils.removeCSSClassName(this._element, "p_AFStartOverflow");
      break;
    case "droplist":
      AdfDomUtils.removeCSSClassName(this._element, "p_AFOverflowDroplist");
  }
};
AdfOverflowSupport.prototype._showOverflowButtons = function(force) {
  if (force) {
    switch(this._type) {
      case "end":
        AdfDomUtils.addCSSClassName(this._element, "p_AFEndOverflow");
        break;
      case "start":
        AdfDomUtils.addCSSClassName(this._element, "p_AFStartOverflow");
        break;
      case "both":
        AdfDomUtils.addCSSClassName(this._element, "p_AFEndOverflow");
        AdfDomUtils.addCSSClassName(this._element, "p_AFStartOverflow");
        break;
      case "droplist":
        AdfDomUtils.addCSSClassName(this._element, "p_AFOverflowDroplist");
    }
    return;
  }
  if (this._firstVisibleStep > 0 && this._startContainer.childNodes.length > 0) {
    if (this._supportsDroplist()) {
      AdfDomUtils.addCSSClassName(this._element, "p_AFOverflowDroplist");
    } else {
      AdfDomUtils.addCSSClassName(this._element, "p_AFStartOverflow");
    }
  }
  var lastStep = this._steps.length - 1;
  if (this._lastVisibleStep < lastStep && this._endContainer.childNodes.length > 0) {
    if (this._supportsDroplist()) {
      AdfDomUtils.addCSSClassName(this._element, "p_AFOverflowDroplist");
    } else {
      AdfDomUtils.addCSSClassName(this._element, "p_AFEndOverflow");
    }
  }
};
AdfOverflowSupport.prototype._resetActiveDescendant = function(popupContainer) {
  if (!popupContainer) {
    switch(this._type) {
      case "end":
        popupContainer = this._endContainer;
        break;
      case "start":
        popupContainer = this._startContainer;
        break;
      case "droplist":
        popupContainer = this._droplistContainer;
        break;
      case "both":
        AdfLogger.LOGGER.warning("Roving tab index not yet supported for overflow type 'both'!");
        return;
    }
  }
  if (this._activeDescendant) {
    this._activeDescendant.setAttribute("tabIndex", "-1");
  }
  var context = {includeVisibilityHidden:true, includeDisplayNone:true};
  this._activeDescendant = AdfFocusUtils.setFirstActiveDescendant(popupContainer, context);
};
