AdfRichUIPeer.createPeerClass(AdfRichUIPeer, "AdfDhtmlTableBasePeer", false);
AdfDhtmlTableBasePeer.InitSubclass = function() {
  AdfRichUIPeer.addDomEventHandlers(this, AdfDhtmlLookAndFeel.SCROLL_EVENT_TYPE, AdfDhtmlLookAndFeel.KEY_DOWN_EVENT_TYPE, AdfDhtmlLookAndFeel.MOUSE_MOVE_EVENT_TYPE);
  AdfRichUIPeer.addComponentEventHandlers(this, AdfUIInputEvent.CLICK_EVENT_TYPE, AdfUIInputEvent.MOUSE_DOWN_EVENT_TYPE, AdfUIInputEvent.MOUSE_UP_EVENT_TYPE, AdfUIInputEvent.KEY_DOWN_EVENT_TYPE, AdfUIInputEvent.KEY_UP_EVENT_TYPE, AdfComponentEvent.FOCUS_EVENT_TYPE, AdfComponentEvent.BLUR_EVENT_TYPE, AdfUIInputEvent.DOUBLE_CLICK_EVENT_TYPE, AdfComponentEvent.CONTEXT_MENU_EVENT_TYPE, AdfValueChangeEvent.VALUE_CHANGE_TYPE);
  AdfRichUIPeer.addComponentPropertyChanges(this, "selectedRowKeys", "disclosedRowKeys", "scrollTop", "scrollLeft", "activeRowKey");
  AdfRichUIPeer.addSuppressedPPRAttributes(this, "first");
  AdfRichUIPeer.addSuppressedPPRAttributes(this, "rows");
  AdfRichUIPeer.addSuppressedPPRAttributes(this, "scrollTop");
  AdfRichUIPeer.addSuppressedPPRAttributes(this, "scrollLeft");
  AdfRichUIPeer.addSuppressedPPRAttributes(this, "scrollTopRowKey");
  AdfRichUIPeer.addSuppressedPPRAttributes(this, "activeRowKey");
  this._SEL_UPDATE_ALL_SELECT = 0;
  this._SEL_UPDATE_ALL_UNSELECT = 1;
  this._SEL_UPDATE_ALL_UPDATE = 2;
  this.AUTO_PPR_UPDATE_BLOCK = 0;
  this.AUTO_PPR_INSERT_BEFORE_BLOCK = 1;
  this.AUTO_PPR_INSERT_AFTER_BLOCK = 2;
  this.AUTO_PPR_REMOVE_BLOCK = 3;
  this._COLUMN_FOOTER_FOCUS_TYPE = 5;
  this.AUTO_PPR_FETCH_ID = -99;
  this.SCROLL_SUCCEEDED = 0;
  this.SCROLL_INDEX_NOT_FOUND = 1;
  this.SCROLL_CANCELLED = 2;
  this.MISSING_AFTER = 1;
  this.MISSING_BEFORE = 2;
  this.NO_BLOCKS = 4;
  this.VIEWPORT_SATISFIED = 0;
  this.NO_SCROLL = -1;
  this.DW_SUB_ID = "dataW";
  this._CELL_TEXT_KEY = "_afrCTK";
  this._ROW_KEY = "_afrRK";
  this._ROW_HEADER = "_afrRH";
  this._LEAF_COLUMN = "_afrLeaf";
  this._ROOT_COLUMN = "_afrRoot";
  this._FILTER_COLUMN = "_afrFilterCol";
  this._PANEL_COLLECTION_ID = "_afrPCId";
  this._SELECT_ALL = "_afrSelAll";
  this._COL_COUNT = "_afrColCount";
  this._FILTERABLE = "_afrFilterable";
  this.__SORT_INDICATOR = "afrSI";
  this._SORT_ASCENDING = "_afrSortAsc";
  this._SORT_DESCENDING = "_afrSortDesc";
  this._SORTED_TYPE = "_afrSorted";
  AdfDhtmlTableBasePeer._REMAIN_READ_ONLY = "_afrRemainReadOnly";
  this._SORTED_ASCENDING = "1";
  this._SORTED_DESCENDING = "2";
  this._SUPPORTS_HOVER = "_afrHoverable";
  this.SELECTALL_KEY_PROPERTY = "afrSelectAll";
  this._SELECTED_CLASS = "p_AFSelected";
  this._INACTIVE_CLASS = "p_AFInactive";
  this._DROP_TARGET_CLASS = "p_AFDropTarget";
  this._HIGHLIGHTED_CLASS = "p_AFHighlighted";
  this._FOCUSED_CLASS = "p_AFFocused";
  this._AUTOSCROLL_MARGIN = 40;
  this._HSCROLLER = 0;
  this._VSCROLLER = 1;
  this._SELECTION_SINGLE = "single";
  this._SELECTION_MULTIPLE = "multiple";
  this._SELECTION_MULTIPLE_NOSELECTALL = "multipleNoSelectAll";
  this._SELECTION_NONE = "none";
  this._EDIT_MODE_CLICKTOEDIT = "clickToEdit";
  this._MAXIMUM_ROW_REVEAL = 8;
  this._SELECT_PAGE_UP = 1;
  this._SELECT_PAGE_DOWN = 2;
  this._SELECT_ARROW_UP = 3;
  this._SELECT_ARROW_DOWN = 4;
  this._FOCUS_RH_ARROW_UP = 5;
  this._FOCUS_RH_ARROW_DOWN = 6;
  this._FOCUS_ROW_ARROW_UP = 7;
  this._FOCUS_ROW_ARROW_DOWN = 8;
  this._ROW_HEADER_FOCUS_TYPE = 0;
  this._COLUMN_HEADER_FOCUS_TYPE = 1;
  this._TABLE_BODY_FOCUS_TYPE = 2;
  this._SELECT_ALL_FOCUS_TYPE = 3;
  this._FILTER_CELL_FOCUS_TYPE = 4;
  this._FETCH_MORE_CANVAS_SPACE = 25;
  this._INPUT_REGEXP = /^INPUT|SELECT|OPTION|BUTTON|^A\b|TEXTAREA/;
  this._TWINKLE_ON_STYLE_CLASS = "p_AFTwinkleOn";
  this._TWINKLE_OFF_STYLE_CLASS = "p_AFTwinkleOff";
  AdfDhtmlTableBasePeer._TWINKLE_TIMER_ID_ATTR = "__afrTwinkleTimer";
  this._ICON_STYLE_EXPANDED = "af|table::disclosed-icon-style";
  this._ICON_STYLE_COLLAPSED = "af|table::undisclosed-icon-style";
  this._ICON_EXPANDED = "af|table::disclosed-icon";
  this._ICON_COLLAPSED = "af|table::undisclosed-icon";
  this._EXPANDED_NODE_KEY = "af_table.TIP_EXPANDED_NODE";
  this._COLLAPSED_NODE_KEY = "af_table.TIP_COLLAPSED_NODE";
  this._DETAIL_COLUMN_MARKER = "_afrDetCol";
  this._DETAIL_ROW_MARKER = "_afrDetRow";
  this._HAS_DETAIL_MARKER = "_hasDetail";
  this.NEEDS_REFRESH_ATTRIBUTE = "_afrNdsRfr";
  this.UNDO_FETCH_ATTRIBUTE = "_afrUndFch";
  this.NO_RESIZE_MARKER = "_noRsz";
  this._AUTO_HEIGHT_ROWS = "_afrAutoHR";
  this._MAX_ROWHEADER_MSGTYPE_EXPANDO = "_afrMRMT";
  this._CSS_HEIGHT_LIMIT = 17E6;
  this._NAVBAR_FIRST = "nb_fr";
  this._NAVBAR_PREVIOUS = "nb_pv";
  this._NAVBAR_NEXT = "nb_nx";
  this._NAVBAR_LAST = "nb_ls";
  this._NAVBAR_PAGE = "nb_pg";
  this._NAVBAR_PAGE_CNT = "nb_cnt_pg";
  this._NAVBAR_PAGE_INPUT = "nb_in_pg";
  this._NAVBAR_RANGE_TEXT = "nb_rng";
  this.RERENDER_SELF = "RERENDER_SELF";
  this.RERENDER_CELL = "RERENDER_CELL";
  this.RERENDER_ROW = "RERENDER_ROW";
  this.RERENDER_CONTAINER_CHILDREN = "RERENDER_CONTAINER_CHILDREN";
  this.RERENDER_CONTAINER = "RERENDER_CONTAINER";
  this._RERENDER_PRIORITY = {RERENDER_SELF:0, RERENDER_CELL:1, RERENDER_ROW:2, RERENDER_CONTAINER_CHILDREN:3, RERENDER_CONTAINER:4};
  this._DEFAULT_MAX_CACHED_ROWS_FOR_TOUCH = 300;
  this._MAX_CACHED_ROWS_FOR_TOUCH = "_afrMaxTouchRows";
  this._DATAWRAPPER = "dbw";
  this._SCROLLBAR_BEHAVIOR = "_afrScrollBarBehavior";
  this._SCROLLBAR_BEHAVIOR_AUTOHIDE = "autohiding-scrollbar";
  this._SCROLLBAR_AUTOHIDE_DATABODY_WRAPPER_CLASS = "af|table::data-body-wrapper-autohiding-scrollbar";
  this._SCROLLBAR_AUTOHIDE_DATABODY_H_LINES_CLASS = "af|table::data-body-H-lines-autohiding-scrollbar";
  this._SCROLLBAR_HEIGHT_TOLERANCE = 3;
  this._TABLE_H_LINES_CLASS = "af|table::data-table-H-lines";
  this._TABLE_VH_LINES_CLASS = "af|table::data-table-VH-lines";
  this._IMPLICIT_LOAD_MORE = "_afrImpldm";
  this._LOAD_MORE_TOP_DIV = "ldmrtp";
  this._LOAD_MORE_TOP_LINK = "ldmrtplnk";
  this._LOAD_MORE_BOTTOM_DIV = "ldmrbttm";
  this._LOAD_MORE_BOTTOM_LINK = "ldmrbttmlnk";
  this._LOAD_INDEX_ATTR = "data-afrldIndx";
  this._LOAD_MORE_RNG_TOP_TEXT = "ldmrrngtptxt";
  this._LOAD_MORE_RNG_BOTTOM_TEXT = "ldmrrngbttmtxt";
  this._SCROLLER_ANIMATION_CLASS = "af|table::scroll-container";
  this._HIDDEN_WIDTH_DOM_WHEN_STRETCHED_ID = "_afrHwdwsId";
};
AdfDhtmlTableBasePeer.prototype.InitDomElement = function(component, domElement) {
  var page = AdfPage.PAGE;
  var agent = AdfAgent.AGENT;
  AdfDhtmlTableBasePeer.superclass.InitDomElement.call(this, component, domElement);
  AdfRichUIPeer.addEventHandlerToDomInstance(AdfDhtmlTableBasePeer, domElement, AdfDhtmlLookAndFeel.MOUSE_MOVE_EVENT_TYPE);
  AdfRichUIPeer.addEventHandlerToDomInstance(AdfDhtmlTableBasePeer, domElement, AdfDhtmlLookAndFeel.KEY_DOWN_EVENT_TYPE);
  this._autoHeightRows = agent.getIntAttribute(domElement, AdfDhtmlTableBasePeer._AUTO_HEIGHT_ROWS, 0);
  var dataBody = this.GetDataBody(domElement);
  this._colCount = dataBody ? agent.getIntAttribute(dataBody, AdfDhtmlTableBasePeer._COL_COUNT, 0) : 0;
  this._colSelEventSelectedColIds = {};
  this._colSelEventUnselectedColIds = {};
  this._supportsFocusRowNavigation = this.SupportsFocusRowNavigation(component);
  this._contextMenuSelect = component.getContextMenuSelect();
  if (!component.getColumnResizing || component.getColumnResizing() == "enabled") {
    this._colResizeDragCallback = this.createCallback(this._handleColResizeDrag);
    this._colResizeDropCallback = this.createCallback(this._handleColResizeDrop);
  }
  if (component.getColumnStretching) {
    var columnStretching = component.getColumnStretching();
    this._columnStretching = columnStretching;
    if (columnStretching == "blank") {
      this._stretchedColumnId = "_afrBlankColumn";
    } else {
      if (columnStretching.indexOf("column:") == 0) {
        this._stretchedColumnId = columnStretching.substring(7);
      } else {
        if (columnStretching == "multiple") {
        }
      }
    }
  }
  this._editableTableReadOnlyMode = false;
  this._hoverHighlightRow = this._isRowSelectionEnabled(component) && page.getLookAndFeel().getSkinProperty("af|table-tr-hover-highlight-row") != "false";
  this._singleSortIcon = page.getLookAndFeel().getSkinProperty("af|table-tr-single-sort-icon") == "true";
  this._activeDataCount = -1;
  this._fetchId = 0;
  this._unavailableRowIndex = -1;
  this._lastColWidthOverride = -1;
  this._lastColWidth = -1;
  this._associatedId = component.getProperty("_afrMasterId");
  if (this._associatedId == null) {
    this._associatedId = component.getProperty("_afrSlaveId");
  }
  this._focusManager = {};
  this._streamingDisabled = page.isStreamingDisabled();
  this._isTouch = agent.isTouchFirstDevice();
  this._maxCachedRowsForTouch = component.getProperty(AdfDhtmlTableBasePeer._MAX_CACHED_ROWS_FOR_TOUCH) != null ? component.getProperty(AdfDhtmlTableBasePeer._MAX_CACHED_ROWS_FOR_TOUCH) : AdfDhtmlTableBasePeer._DEFAULT_MAX_CACHED_ROWS_FOR_TOUCH;
  if (agent.getOS() == AdfAgent.MAC_OS) {
    this._scrollbarBehavior = null;
  } else {
    this._scrollbarBehavior = component.getProperty(AdfDhtmlTableBasePeer._SCROLLBAR_BEHAVIOR);
  }
  this._hShiftDataBody = "0px";
  this._hShiftLoadMoreDataBody = "0px";
  this._insertDeleteAnimationInEffect = false;
  var scrollPolicy = component.getProperty("scrollPolicy");
  if (scrollPolicy == "loadMore") {
    this._isLoadMore = true;
  } else {
    if (scrollPolicy == "scrollPrefetch") {
      this._isScrollPrefetch = true;
    }
  }
  this._isImplicitLoadMore = component.getProperty(AdfDhtmlTableBasePeer._IMPLICIT_LOAD_MORE);
  if (this._isImplicitLoadMore) {
    this._isLoadMore = true;
  }
  this._disableRowMouseDownCellFocus = component.getProperty("_disableRowMouseDownCellFocus");
  this._isSyncRows = component.getProperty("_afrSyncRows");
  this._twinkledCells = [];
  this._twinkledCellAnnouncements = "";
  this._avoidSettingFocusOnColumnHeader = false;
  AdfPage.PAGE.__registerDescendantResizeNotifyComponent(component);
};
AdfDhtmlTableBasePeer.prototype.isDragAvailable = function(target) {
  AdfAssert.assertDomElement(target);
  if (target) {
    var isTargetCellEditable = this._isTargetCellEditable(target);
    var isTargetRowHeader = this._getTargetRowHeader(target) != null;
    var isTargetTextOnlyNode = this._isTargetTextOnlyNode(target);
    if (isTargetRowHeader || isTargetCellEditable || isTargetTextOnlyNode) {
      return false;
    }
  }
  return true;
};
AdfDhtmlTableBasePeer.prototype.TruncateClientId = function(component, descendantComponent, childClientId, skipArray) {
  var ids = childClientId.split(":");
  var tableIdClientId = component.getClientId();
  var iteratorIndex = AdfStrings.count(tableIdClientId, ":") + 1;
  var iteratorId = ids[iteratorIndex];
  if (iteratorId) {
    if (!isNaN(iteratorId)) {
      skipArray.push(iteratorIndex);
    }
  }
};
AdfDhtmlTableBasePeer.prototype.ComponentRemoved = function(component) {
  if (this._touchMoveManager) {
    this._touchMoveManager.unregister();
  }
  if (this._handleTouchEndCallback) {
    var agent = AdfAgent.AGENT;
    var dataBody = this.GetDataBody();
    if (dataBody) {
      agent.removeBubbleEventListener(dataBody, "touchend", this._handleTouchEndCallback);
    }
    var colHead = this.__getColumnHeader();
    if (colHead) {
      agent.removeBubbleEventListener(colHead, "touchend", this._handleTouchEndCallback);
    }
  }
  AdfPage.PAGE.__unregisterDescendantResizeNotifyComponent(component);
  AdfDhtmlTableBasePeer.superclass.ComponentRemoved.call(this, component);
};
AdfDhtmlTableBasePeer.prototype.needsChildVisibilityChanges = function(component) {
  return true;
};
AdfDhtmlTableBasePeer.prototype.ChildVisibilityChanged = function(childComponent, childDomElement, childVisible) {
  AdfPage.PAGE.addPartialTargets(this.getComponent());
  return true;
};
AdfDhtmlTableBasePeer.prototype.SupportsFocusRowNavigation = function() {
  return true;
};
AdfDhtmlTableBasePeer.prototype.AllowCellNavigation = function() {
  if (this.getDomElement().id.indexOf("_afrDropDownContent") > 0) {
    return false;
  }
  return true;
};
AdfDhtmlTableBasePeer.prototype.needsResizeNotify = function(component) {
  return true;
};
AdfDhtmlTableBasePeer.prototype.GetPanelCollectionPeer = function(domNode) {
  if (!this._pcPeer) {
    var container = this.getDomElement();
    var pcComp = null;
    var pcId = container.getAttribute(AdfDhtmlTableBasePeer._PANEL_COLLECTION_ID);
    if (pcId != null) {
      pcComp = AdfPage.PAGE.findComponent(pcId);
      if (pcComp) {
        this._pcPeer = pcComp.getPeer();
      }
    }
  }
  return this._pcPeer;
};
AdfDhtmlTableBasePeer.prototype.GetPanelCollectionComponent = function() {
  if (!this._pcComponent) {
    var container = this.getDomElement();
    var pcId = container.getAttribute(AdfDhtmlTableBasePeer._PANEL_COLLECTION_ID);
    if (pcId != null) {
      this._pcComponent = AdfPage.PAGE.findComponent(pcId);
    }
  }
  return this._pcComponent;
};
AdfDhtmlTableBasePeer.prototype._allRowsAvailableOnClient = function(blockList, numBlocks) {
  var rowsAvailable = false;
  if (numBlocks > 0) {
    var firstBlock = blockList[0];
    var lastBlock = blockList[numBlocks - 1];
    var blockRowCount = lastBlock.startRow + lastBlock.numRows;
    var rowCount = this.GetRowCount();
    rowsAvailable = rowCount > 0 && firstBlock.startRow == 0 && blockRowCount == rowCount;
  }
  return rowsAvailable;
};
AdfDhtmlTableBasePeer.prototype._updateScrollDivHeight = function(dataBody) {
  if (dataBody) {
    var blockList = dataBody.childNodes;
    var numBlocks = blockList.length;
    if (1 === numBlocks && this._allRowsAvailableOnClient(blockList, numBlocks)) {
      var newBlockHeight = blockList[0].offsetHeight;
      if (newBlockHeight > this._canvasHeight) {
        this._canvasHeight = newBlockHeight;
        this._setFakeCanvasHeight(newBlockHeight);
      }
    }
  }
};
AdfDhtmlTableBasePeer._isInsideDialog = function(component) {
  if (!component) {
    return false;
  }
  if (component instanceof AdfRichDialog) {
    return true;
  }
  return AdfDhtmlTableBasePeer._isInsideDialog(component.getParent());
};
AdfDhtmlTableBasePeer.prototype._isStretchedToContentInDialog = function(component, rootElement, dataBody) {
  if (!dataBody) {
    return;
  }
  if (this._isInsideDialog === undefined && window["AdfRichDialog"]) {
    this._isInsideDialog = AdfDhtmlTableBasePeer._isInsideDialog(component);
  }
  if (this._isInsideDialog) {
    var horizontalScrollWidth = this._getScrollWidth();
    if (horizontalScrollWidth === undefined) {
      return rootElement.clientWidth >= rootElement.scrollWidth;
    } else {
      var columnHeaderDiv = this.__getColumnHeader();
      var columnHeaderWidth;
      if (columnHeaderDiv) {
        columnHeaderWidth = columnHeaderDiv.offsetWidth;
      }
      return Math.max(columnHeaderWidth, dataBody.offsetWidth) >= horizontalScrollWidth;
    }
  }
};
AdfDhtmlTableBasePeer.prototype.ResizeNotify = function(oldWidth, oldHeight, newWidth, newHeight) {
  if (this.BusyAnimating()) {
    var peer = this;
    this.delayedResizeNotify = function() {
      peer.ResizeNotify(oldWidth, oldHeight, newWidth, newHeight);
    };
    return;
  }
  delete this._cachedFirstVisibleRowKeyAndRow;
  var agent = AdfAgent.AGENT, component = this.getComponent(), clientId = component.getClientId(), dataBody = this.GetDataBody(), hwdwsNode = agent.getElementById(AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlTableBasePeer._HIDDEN_WIDTH_DOM_WHEN_STRETCHED_ID));
  if (hwdwsNode) {
    if (oldHeight == newHeight && this._isStretchedToContentInDialog(component, this.getDomElement(), dataBody)) {
      return;
    }
    hwdwsNode.style.width = newWidth + "px";
  }
  if (this._virtInitialized) {
    var agent = AdfAgent.AGENT;
    if (!this.isHeightAutoSized()) {
      this._updateScrollDivHeight(dataBody);
      this._setScrollerHeight(newHeight, this._cachedCHHeight, this._cachedCFHeight, this._cachedNBHeight);
    } else {
      this.AdjustAutoHeight();
    }
    this._setScrollerWidth(newWidth, this._frozenWidth);
    this.SizeDataBody(dataBody, newWidth, newHeight);
    var scrollLeft = this.__getScrollLeft();
    var scrollTop = this._getScrollTop();
    if (this._currentScrollTop != scrollTop || this._currentScrollLeft != scrollLeft) {
      this.scrollToPos(this._currentScrollLeft, this._currentScrollTop);
    }
    this._stretchTheColumns();
    this._syncDataBodyHeights();
    if (!this._isPaged && !this._isLoadMore && this._rowCount == -1 && this._canvasHeight < newHeight - this._cachedCHHeight - this._cachedCFHeight) {
      this._canvasHeight = newHeight - this._cachedCHHeight - this._cachedCFHeight + AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE;
      this._setFakeCanvasHeight(this._canvasHeight);
    }
    this._fillViewPort(dataBody, dataBody.offsetHeight, false);
  } else {
    if (this._isImmediateContentDelivery(this.getComponent()) || this._isInlineDataAvailable(this.getComponent())) {
      var block = null;
      if (dataBody) {
        this._unavailableRowIndex = this._getUnavailableRowIndex(dataBody);
        var nodes = dataBody.childNodes;
        for (var i = nodes.length - 1;i >= 0;i--) {
          if ("TABLE" == nodes[i].tagName) {
            block = nodes[i];
            break;
          }
        }
      }
      this._fixOuterHeight();
      this._initColumnHeader();
      this._initColumnFooter();
      this._initNavBar();
      this._initLoadMore();
      if (block != null && block.rows.length > 0) {
        this._initVirtualization(block, true);
        this._processClickToEditRequestTimerId = AdfPage.PAGE.scheduleTimer(this, this._processClickToEditRequest, false, 10);
      } else {
        this.IsEmpty = true;
        this.getDomElement().style.overflow = "auto";
        this.AdjustAutoHeight();
        this._updatePCState();
      }
      if (this.IsEmpty) {
        var ch = this.__getColumnHeader();
        if (ch) {
          var root = this.getDomElement();
          ch.style.border = "0px";
          var chWidth = ch.offsetWidth;
          if (chWidth <= root.clientWidth) {
            root.style.overflow = "hidden";
          }
        }
        var cf = this._getColumnFooter();
        if (cf) {
          var root = this.getDomElement();
          cf.style.border = "0px";
          var cfWidth = cf.offsetWidth;
          if (cfWidth <= root.clientWidth) {
            root.style.overflow = "hidden";
          }
        }
        if (ch || cf) {
          this.AdjustAutoHeight();
        }
      }
      this._stretchTheColumns();
      this._checkLoadMore();
    } else {
      if (!this._firstBlockRequested) {
        var agent = AdfAgent.getAgent();
        var tableElement = this.getDomElement();
        var isEmpty = agent.getAttribute(tableElement, "_afrEmpty", false);
        this.IsEmpty = isEmpty;
        if (!isEmpty) {
          this._firstBlockRequested = true;
          var component = this.getComponent();
          if (this._streamingDisabled || !AdfPage.PAGE.isStreamingRequestPending(component.getClientId())) {
            this._queueFetchEvent(true, AdfTableDataFetchEvent.INITIAL_SUBTYPE, -1);
          }
          AdfDhtmlTableBasePeer.SetCursor(this.GetDataBody(), "wait");
        }
        this._initColumnHeader();
        this._initColumnFooter();
        this._initNavBar();
        this._initLoadMore();
        if (!isEmpty) {
          var statusText = AdfPage.PAGE.getLookAndFeel().getTranslatedString("af_table.LABEL_FETCHING");
          this.DisplayStatus(statusText, true);
        }
        if (isEmpty) {
          this.getDomElement().style.overflow = "auto";
          this._stretchTheColumns();
          var ch = this.__getColumnHeader();
          if (ch) {
            var root = this.getDomElement();
            ch.style.border = "0px";
            var chWidth = ch.offsetWidth;
            if (chWidth <= root.clientWidth) {
              root.style.overflow = "hidden";
            }
          }
          this._updatePCState();
        }
      } else {
        if (!this._headerless && this.IsEmpty) {
          this._stretchTheColumns();
        }
        if (this.IsEmpty && this._autoHeightRows > 0 && (!this._hasSingleScroller() || this._isPaged || this._isLoadMore)) {
          this.AdjustAutoHeight();
        }
      }
    }
  }
  if (this._hasNavBar) {
    this._resizeNavBar(newWidth, newHeight);
  }
  if (!this._anchorRowKey) {
    this._anchorRowKey = this.GetLastRowKey();
  }
};
AdfDhtmlTableBasePeer.prototype._initColumnHeader = function() {
  var agent = AdfAgent.getAgent();
  var lastFrozen = agent.getIntAttribute(this.getDomElement(), "_lastFrozen", -1);
  var firstFrozen = agent.getIntAttribute(this.getDomElement(), "_firstFrozen", -1);
  this._lastFrozen = lastFrozen;
  this._firstFrozen = firstFrozen;
  var colHeader = this.__getColumnHeader();
  if (colHeader) {
    if (this._autoHeightRows > 0 && this._hasFrozenColumn() && !this._columnHeaderUnwrapped) {
      var table = AdfDhtmlTableBasePeer.FindFirstChildByTagName(colHeader, "TABLE");
      var row = table.rows[0];
      var frozen = null;
      var unfrozen = null;
      if (this._freezeColumnsToEnd()) {
        frozen = AdfDhtmlTableBasePeer.FindFirstChildByTagName(row.cells[1], "TABLE");
        unfrozen = AdfDhtmlTableBasePeer.FindFirstChildByTagName(row.cells[0], "DIV");
      } else {
        frozen = AdfDhtmlTableBasePeer.FindFirstChildByTagName(row.cells[0], "TABLE");
        unfrozen = AdfDhtmlTableBasePeer.FindFirstChildByTagName(row.cells[1], "DIV");
      }
      frozen.parentNode.removeChild(frozen);
      unfrozen.parentNode.removeChild(unfrozen);
      colHeader.removeChild(table);
      if (!this._freezeColumnsToEnd()) {
        var frozenWidth = frozen.style.width;
        var side = "left:";
        if (AdfDhtmlTableBasePeer._isRTL()) {
          side = "right:";
        }
        unfrozen.style.cssText = "overflow:hidden;position:absolute;top:0px;" + side + frozenWidth;
      } else {
        unfrozen.style.cssText = "overflow:hidden;position:absolute;top:0px;";
      }
      if (!this._freezeColumnsToEnd()) {
        colHeader.appendChild(frozen);
        colHeader.appendChild(unfrozen);
      } else {
        colHeader.appendChild(unfrozen);
        colHeader.appendChild(frozen);
      }
      this._columnHeaderUnwrapped = true;
    }
    this._synchronizeColumnRowHeights(colHeader, "t", "d2", "t2");
    this._cachedCHHeight = colHeader.offsetHeight;
    if (AdfAgent.AGENT.getPlatform() == AdfAgent.IE_PLATFORM && AdfAgent.AGENT.getVersion() < 8) {
      var table = AdfDhtmlTableBasePeer.__getChildBySubId(colHeader, "t");
      if (table && table.rows.length) {
        table.rows[0].style.position = "absolute";
      }
      var div = AdfDhtmlTableBasePeer.__getChildBySubId(colHeader, "d2");
      if (div) {
        table = AdfDhtmlTableBasePeer.__getChildBySubId(div, "t2");
        if (table && table.rows.length) {
          table.rows[0].style.position = "absolute";
        }
        if (AdfDhtmlTableBasePeer._isRTL()) {
          table.style.right = "0px";
        }
      }
    }
  } else {
    this._headerless = true;
    this._cachedCHHeight = 0;
  }
};
AdfDhtmlTableBasePeer.prototype._hasFrozenColumn = function() {
  return this._lastFrozen >= 0 || this._firstFrozen >= 0;
};
AdfDhtmlTableBasePeer.prototype._freezeColumnsToStart = function() {
  return this._lastFrozen >= 0;
};
AdfDhtmlTableBasePeer.prototype._freezeColumnsToEnd = function() {
  return this._firstFrozen >= 0;
};
AdfDhtmlTableBasePeer.prototype._areAllColumnsFrozen = function(columnCount) {
  return this._lastFrozen >= 0 && columnCount == this._lastFrozen + 1 || this._firstFrozen == 0;
};
AdfDhtmlTableBasePeer.prototype._isColumnFrozen = function(colIndex) {
  return this._lastFrozen >= 0 && colIndex <= this._lastFrozen || this._firstFrozen >= 0 && colIndex >= this._firstFrozen;
};
AdfDhtmlTableBasePeer.prototype._hasSingleScroller = function() {
  return this._footerless && !this._freezeColumnsToEnd();
};
AdfDhtmlTableBasePeer.prototype._initColumnFooter = function() {
  var colFooter = this._getColumnFooter();
  if (colFooter) {
    this._synchronizeColumnRowHeights(colFooter, "ft", "fd2", "ft2");
    this._cachedCFHeight = colFooter.offsetHeight;
  } else {
    this._footerless = true;
    this._cachedCFHeight = 0;
  }
};
AdfDhtmlTableBasePeer.prototype._initNavBar = function() {
  var nbar = this._getNavigationBar();
  if (nbar) {
    this._hasNavBar = true;
    setTimeout(function() {
      var fe = AdfPage.PAGE.getActiveDomElement();
      var navBarPageLinkClassName = AdfPage.PAGE.getLookAndFeel().getSkinProperty("af|table::navbar-page-link");
      if (fe != null && fe.className == navBarPageLinkClassName) {
        fe.blur();
      }
    }, 0);
    this._cachedNBHeight = nbar.offsetHeight;
    var nBarContainer = AdfAgent.AGENT.getElementById(AdfRichUIPeer.CreateSubId(this.getComponent().getClientId(), "nb_cnt"));
    this._cachedNBWidth = nBarContainer.offsetWidth;
    this._isPaged = true;
    this.RegisterFirstPropertyChange();
    if (this.getComponent().getProperty("_afrSlaveId") != null || this.getComponent().getProperty("_afrMasterId") != null) {
      nbar.firstChild.style.display = "none";
      nbar.style.height = 0;
      this._cachedNBHeight = nbar.offsetHeight;
      this._cachedNBWidth = nBarContainer.offsetWidth;
    }
  } else {
    this._cachedNBHeight = 0;
    this._cachedNBWidth = 0;
  }
  this._nbarMin = false;
};
AdfDhtmlTableBasePeer.prototype._initLoadMore = function() {
  var bottomLoadMore = this._getLoadMore(false);
  var topLoadMore = this._getLoadMore(true);
  if (bottomLoadMore) {
    this._cachedFMHeight = bottomLoadMore.offsetHeight;
    this._cachedFMWidth = bottomLoadMore.offsetWidth;
    bottomLoadMore.style.display = "none";
    bottomLoadMore.style.overflow = "hidden";
    bottomLoadMore.style.zIndex = 1;
    bottomLoadMore.style.visibility = "visible";
    topLoadMore.style.display = "none";
    topLoadMore.style.overflow = "hidden";
    topLoadMore.style.zIndex = 1;
    topLoadMore.style.visibility = "visible";
    var ch = this.__getColumnHeader();
    if (ch != null) {
      ch.style.zIndex = 2;
    }
  } else {
    this._cachedFMHeight = 0;
    this._cachedFMWidth = 0;
  }
};
AdfDhtmlTableBasePeer.prototype.__fixPanelCollectionDimensions = function(detachPPR) {
  if (!this._autoHeightRows) {
    return;
  }
  var tableElement = this.getDomElement();
  var pcPeer = this.GetPanelCollectionPeer();
  var pcContainer = pcPeer.getDomElement();
  var pcElement = pcPeer.getDomElement();
  var pcComp = this.GetPanelCollectionComponent();
  var agent = AdfAgent.getAgent();
  var isWebKit = agent.getPlatform() == AdfAgent.WEBKIT_PLATFORM;
  if (pcPeer && pcComp) {
    var clientId = pcComp.getClientId();
    var topElem = agent.getElementById(AdfRichUIPeer.CreateSubId(clientId, pcPeer.__getAutoHeightTopFacetId()));
    var bottomElem = agent.getElementById(AdfRichUIPeer.CreateSubId(clientId, pcPeer.__getAutoHeightBottomFacetId()));
    var topHeight = topElem ? topElem.offsetHeight : 0;
    var bottomHeight = bottomElem ? bottomElem.offsetHeight : 0;
    if (pcPeer.isDetached()) {
      var parent = tableElement.parentNode.parentNode;
      var containerStyle = tableElement.style;
      if (!detachPPR) {
        if (pcElement.getAttribute("_afrPreDetachW") == null) {
          var tableWidth = containerStyle.width;
          var tableDataBody = this.GetDataBody();
          var tableHeight = tableDataBody.offsetHeight + this._getScrollbarHeight();
          tableHeight = tableHeight + "px";
          if ("" === tableWidth) {
            tableWidth = tableDataBody.offsetWidth + this._getScrollbarWidth();
            tableWidth = tableWidth + "px";
          }
          pcElement.setAttribute("_afrPreDetachW", tableWidth);
          pcElement.setAttribute("_afrPreDetachH", tableHeight);
        }
      }
      if (isWebKit) {
        var cStyle = agent.getComputedStyle(tableElement);
        tableElement.style.width = parent.clientWidth - parseInt(cStyle.borderLeftWidth) - parseInt(cStyle.borderRightWidth) + "px";
      } else {
        agent.setOuterWidth(tableElement, parent.clientWidth);
      }
      agent.setOuterHeight(tableElement, parent.clientHeight - topHeight - bottomHeight);
    } else {
      var oldHeight = pcElement.getAttribute("_afrPreDetachH");
      if (oldHeight != undefined) {
        tableElement.style.height = oldHeight;
        pcElement.removeAttribute("_afrPreDetachH");
      }
      var oldWidth = pcElement.getAttribute("_afrPreDetachW");
      if (oldWidth != undefined) {
        if (!detachPPR) {
          tableElement.style.width = oldWidth;
        } else {
          tableElement.style.width = "";
        }
        pcElement.removeAttribute("_afrPreDetachW");
      }
      this._sizeOuterContainer(pcContainer, tableElement.offsetHeight + topHeight + bottomHeight);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._isContainerStretched = function() {
  var container = this.getDomElement();
  var style = container.style;
  return style.position == "absolute" && style.top && style.top.length > 0 && style.bottom && style.bottom.length > 0;
};
AdfDhtmlTableBasePeer.prototype._isPCContainerStretched = function() {
  var stretched = false;
  var container = this.getDomElement();
  var pcPeer = this.GetPanelCollectionPeer();
  if (pcPeer) {
    var pcContainer = pcPeer.getDomElement();
    var style = pcContainer.style;
    stretched = style.position == "absolute" && style.top && style.top.length > 0 && style.bottom && style.bottom.length > 0;
  }
  return stretched;
};
AdfDhtmlTableBasePeer.prototype.isHeightAutoSized = function() {
  return this._autoHeightRows > 0;
};
AdfDhtmlTableBasePeer.prototype._fixOuterHeight = function() {
  var set = false;
  var autoHeightRows = this._autoHeightRows;
  if (autoHeightRows > 0) {
    var agent = AdfAgent.AGENT;
    var container = this.getDomElement();
    var style = container.style;
    if (style.height == "auto" && !this._isContainerStretched()) {
      if (agent.getPlatform() == AdfAgent.IE_PLATFORM && agent.getVersion() < 8) {
        if (container.scrollWidth <= container.offsetWidth) {
          style.height = container.clientHeight + "px";
          set = true;
        }
      }
      if (!set) {
        agent.setOuterHeight(container, container.offsetHeight);
        set = true;
      }
    }
    style.overflowX = "";
    style.overflowY = "";
  }
  return set;
};
AdfDhtmlTableBasePeer.prototype.BeginHandleDataBlocks = function() {
};
AdfDhtmlTableBasePeer.prototype.ReplaceDomElement = function(newElement, oldElement) {
  var id = newElement.id;
  if (id.indexOf(AdfDhtmlTableBasePeer.DW_SUB_ID) > 0) {
    var agent = AdfAgent.AGENT;
    var dataBody = this.GetDataBody();
    this.BeginHandleDataBlocks();
    var blocks = AdfDhtmlTableBasePeer._findFirstLevelChildrenByTagName(newElement, "TABLE");
    this._unavailableRowIndex = this._getUnavailableRowIndex(newElement);
    var empty = false;
    if (!this._virtInitialized) {
      if (!this._firstBlockRequested) {
        this._initColumnHeader();
        this._initColumnFooter();
        this._initNavBar();
        this._initLoadMore();
        this._firstBlockRequested = true;
      }
      this.CancelPendingFetch();
      if (blocks.length > 0 && blocks[0].rows.length > 0) {
        this._initVirtualization(blocks[0], false);
        agent.elementsAdded(blocks[0]);
        this._processClickToEditRequestTimerId = AdfPage.PAGE.scheduleTimer(this, this._processClickToEditRequest, false, 10);
        this.AdjustAutoHeight();
      } else {
        empty = true;
      }
    } else {
      if (blocks.length == 0) {
        empty = true;
      }
      var fetchId = agent.getIntAttribute(newElement, "_fetchId", -1);
      var pendingFetch = this._pendingFetch;
      if (pendingFetch != undefined && this._pendingId == fetchId) {
        var pendingRenderOnly = this._pendingRenderOnly;
        this.CancelPendingFetch();
        this._cleanUpDataFetchElement(oldElement);
        if (agent.getBooleanAttribute(newElement, AdfDhtmlTableBasePeer.NEEDS_REFRESH_ATTRIBUTE, false)) {
          AdfPage.PAGE.addPartialTargets(this.getComponent());
          return;
        }
        if (agent.getBooleanAttribute(newElement, AdfDhtmlTableBasePeer.UNDO_FETCH_ATTRIBUTE, false)) {
          if (pendingFetch == AdfTableDataFetchEvent.FROM_INDEX_SUBTYPE || pendingFetch == AdfTableDataFetchEvent.UP_TO_INDEX_SUBTYPE || pendingFetch == AdfTableDataFetchEvent.AFTER_KEY_SUBTYPE || pendingFetch == AdfTableDataFetchEvent.BEFORE_KEY_SUBTYPE) {
            this._undoScroll();
          } else {
            if (pendingFetch == AdfTableDataFetchEvent.EXPAND_SUBTYPE || pendingFetch == AdfTableDataFetchEvent.COLLAPSE_SUBTYPE) {
              this._restoreSavedDisclosureState();
            } else {
              if (pendingFetch == AdfTableDataFetchEvent.CLICK_EDIT_ACTIVE_ROW) {
                this._restoreActiveRowKey();
              }
            }
          }
          AdfDhtmlTableBasePeer.SetCursor(dataBody, "");
          this._hideStatus();
          this.getComponent().setProperty(AdfDhtmlTableBasePeer._REMAIN_READ_ONLY, false, false, AdfUIComponent.PROPAGATE_ALWAYS);
          return;
        }
        delete this._cachedFirstVisibleRowKeyAndRow;
        this._savedDisclosedState = undefined;
        for (var i = 0;i < blocks.length;i++) {
          newElement.removeChild(blocks[i]);
          if (!this._pruneKeyCache) {
            this._pruneKeyCache = agent.getAttribute(blocks[i], "_pruneKeyCache", null);
          }
          var adsCounter = agent.getIntAttribute(blocks[i], "_adsCounter", -1);
          var inserted = false;
          if (i == 0) {
            this._applyBufferedADSEvents(adsCounter, true);
          }
          inserted = this._handleDataCallback(blocks[i], pendingFetch, pendingRenderOnly, blocks.length - i - 1);
          if (i == blocks.length - 1) {
            this._applyBufferedADSEvents(adsCounter, false);
            this._resetActiveMessageBuffer();
            if (this._activeDataCount < adsCounter) {
              this._activeDataCount = adsCounter;
            }
          }
          if (!inserted) {
            this._addInvalidDataBlockToFetchElement(oldElement, blocks[i]);
          }
          agent.elementsAdded(blocks[i]);
        }
        this._fillViewPort(dataBody, dataBody.offsetHeight, false);
        this.FetchCompleted();
      } else {
        if (fetchId == AdfDhtmlTableBasePeer.AUTO_PPR_FETCH_ID && pendingFetch == undefined) {
          if (!this._handleAutoPPRDataFetch(newElement, blocks, dataBody, empty)) {
            return;
          }
        } else {
          this._handleIrrelaventFetchBlocks(newElement, oldElement, blocks);
        }
      }
    }
    if (empty) {
      if (this._hasRefreshAutoPPRBlock(blocks)) {
        AdfPage.PAGE.addPartialTargets(this.getComponent());
        return;
      }
      this._handleEmptyTextBlock(newElement, dataBody);
      this.AdjustAutoHeight();
    } else {
      if (this._editableTableReadOnlyMode) {
        this._disableTabStop(true);
      }
      var targetNode = this._getActiveCellNode();
      if (targetNode) {
        var targetScrollLeft = AdfAgent.AGENT.getScrollLeft(targetNode);
        if (targetScrollLeft && targetScrollLeft == this._currentScrollLeft) {
          this._setFocusOnNode(targetNode);
        }
      } else {
        this._restoreActiveCellFromDom();
      }
    }
  } else {
    if (id.indexOf("nbar") > 0) {
      var nbar = this._getNavigationBar();
      if (nbar) {
        var nbarParent = nbar.parentNode;
        nbarParent.replaceChild(newElement, nbar);
        AdfAgent.AGENT.elementsAdded(newElement);
      }
    } else {
      var labelElement = AdfDhtmlTableBasePeer._findHiddenLabel(oldElement);
      var labelText = labelElement ? labelElement.textContent : null;
      AdfDhtmlTableBasePeer.superclass.ReplaceDomElement.call(this, newElement, oldElement);
      if (labelText) {
        labelElement = AdfDhtmlTableBasePeer._findHiddenLabel(newElement);
        if (labelElement && this._matchLabelEnds(labelText, labelElement.textContent)) {
          labelElement.textContent = labelText;
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._matchLabelEnds = function(oldLabel, newLabel) {
  if (!newLabel) {
    return true;
  }
  var oldLen = oldLabel.length;
  var newLen = newLabel.length;
  var i;
  if (oldLen < newLen) {
    return false;
  }
  for (i = 0;i < newLen;i++) {
    if (oldLabel.charAt(i) != newLabel.charAt(i)) {
      break;
    }
  }
  return newLabel.substr(i) == oldLabel.substr(oldLen - (newLen - i));
};
AdfDhtmlTableBasePeer.prototype._handleAutoPPRDataFetch = function(newElement, blocks, dataBody, empty) {
  var hasRefreshAutoPPRBlock = this._hasRefreshAutoPPRBlock(blocks);
  var agent = AdfAgent.AGENT;
  if (hasRefreshAutoPPRBlock) {
    AdfPage.PAGE.addPartialTargets(this.getComponent());
    return false;
  }
  if (!empty) {
    var doFillViewPort = false;
    var activeDOM = AdfPage.PAGE.getActiveDomElement();
    var activeDOMid = activeDOM ? activeDOM.id : null;
    for (var i = 0;i < blocks.length;i++) {
      newElement.removeChild(blocks[i]);
      if (!this._pruneKeyCache) {
        this._pruneKeyCache = agent.getAttribute(blocks[i], "_pruneKeyCache", null);
      }
      var autPPRChangeType = agent.getIntAttribute(blocks[i], "_autopprBlock", -1);
      this._updateComponentDisclosureState(blocks[i]);
      this._updateComponentSelectionState(blocks[i]);
      this._updateAutoPPRActiveRowKey(blocks[i]);
      this.AutoPPRBlockReceived(blocks[i]);
      switch(autPPRChangeType) {
        case AdfDhtmlTableBasePeer.AUTO_PPR_INSERT_BEFORE_BLOCK:
        ;
        case AdfDhtmlTableBasePeer.AUTO_PPR_INSERT_AFTER_BLOCK:
          var insertToken = agent.getIntAttribute(blocks[i], "insertPath", null);
          var insertRowInfo = this.FindRowByKey(insertToken);
          if (insertRowInfo) {
            var rowCount = blocks[i].rows.length;
            var rowKey = null;
            if (rowCount > 0) {
              var row = blocks[i].rows[0];
              rowKey = row.getAttribute(AdfDhtmlTableBasePeer._ROW_KEY);
            }
            if (rowKey && !this.FindRowByKey(rowKey)) {
              var start = insertRowInfo.index;
              if (start != undefined && this.IsInsertAllowed(start)) {
                if (autPPRChangeType == AdfDhtmlTableBasePeer.AUTO_PPR_INSERT_AFTER_BLOCK) {
                  start++;
                }
                agent.elementsAdded(blocks[i]);
                var size = AdfDhtmlTableBasePeer._getBlockRowCount(blocks[i]);
                var totalInserted = AdfAgent.AGENT.getIntAttribute(blocks[i], "totalInserted", 0);
                this.InsertBlock(blocks[i], start, size, totalInserted, 0);
                this.UpdateRange(false);
              }
            }
          }
          break;
        case AdfDhtmlTableBasePeer.AUTO_PPR_REMOVE_BLOCK:
          doFillViewPort = this.HandleAutoPPRRemove(blocks[i]);
          break;
        case AdfDhtmlTableBasePeer.AUTO_PPR_UPDATE_BLOCK:
          var rowCount = blocks[i].rows.length;
          if (rowCount > 0) {
            var row = blocks[i].rows[0];
            var rowKey = row.getAttribute(AdfDhtmlTableBasePeer._ROW_KEY);
            var detailRow = rowCount > 1 && this._hasDetailStamp ? blocks[i].rows[1] : null;
            this._replaceRowByKey(rowKey, row, detailRow);
            if (activeDOMid) {
              var newActiveDOM = agent.getElementById(activeDOMid);
              if (newActiveDOM) {
                if (AdfDomUtils.isAncestor(row, newActiveDOM) || detailRow && AdfDomUtils.isAncestor(detailRow, newActiveDOM)) {
                  AdfFocusUtils.focusElement(newActiveDOM);
                }
              }
            }
          }
          break;
        default:
          break;
      }
    }
    this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UNSELECT, true);
    this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UPDATE, true);
    var scrollLeft = this._currentScrollLeft;
    if (scrollLeft != 0) {
      this._handleHorizontalScroll(scrollLeft);
    }
    if (doFillViewPort) {
      this._fillViewPort(dataBody, dataBody.offsetHeight, false);
    }
  }
  return true;
};
AdfDhtmlTableBasePeer.prototype._handleEmptyTextBlock = function(newElement, dataBody) {
  if (!this._virtInitialized) {
    var children = newElement.childNodes;
    var childCount = children.length;
    for (var i = 0;i < childCount;i++) {
      var child = children[0];
      newElement.removeChild(child);
      dataBody.appendChild(child);
    }
    this._updatePCState();
    this._hideStatus();
    this.getDomElement().style.overflow = "auto";
    this.IsEmpty = true;
    this._stretchTheColumns();
    var ch = this.__getColumnHeader();
    if (ch) {
      ch.style.border = "0px";
      var root = this.getDomElement();
      var chWidth = ch.offsetWidth;
      if (chWidth <= root.clientWidth) {
        root.style.overflow = "hidden";
      }
    }
    AdfDhtmlTableBasePeer.SetCursor(dataBody, "");
  } else {
    AdfLogger.LOGGER.severe("Empty data block received:" + id);
  }
};
AdfDhtmlTableBasePeer.prototype._handleIrrelaventFetchBlocks = function(newElement, oldElement, blocks) {
  var agent = AdfAgent.AGENT;
  this._cleanUpDataFetchElement(oldElement);
  for (var i = 0;i < blocks.length;i++) {
    newElement.removeChild(blocks[i]);
    this._addInvalidDataBlockToFetchElement(oldElement, blocks[i]);
    agent.elementsAdded(blocks[i]);
  }
};
AdfDhtmlTableBasePeer.prototype._addInvalidDataBlockToFetchElement = function(oldElement, block) {
  var rows = block.rows;
  var rowCount = rows.length;
  var invalidRows = null;
  for (var i = 0;i < rowCount;i++) {
    var row = rows[i];
    var rowKey = row.getAttribute(AdfDhtmlTableBasePeer._ROW_KEY);
    if (rowKey != null && this.FindRowByKey(rowKey) != null) {
      if (!invalidRows) {
        invalidRows = [];
      }
      invalidRows.push(row);
    }
  }
  if (invalidRows != null) {
    rowCount = invalidRows.length;
    for (i = 0;i < rowCount;i++) {
      invalidRows[i].parentNode.removeChild(invalidRows[i]);
    }
  }
  oldElement.appendChild(block);
};
AdfDhtmlTableBasePeer.prototype._cleanUpDataFetchElement = function(oldElement) {
  while (oldElement.firstChild != null) {
    var oldChild = oldElement.firstChild;
    this._unregisterNode(oldChild);
    oldElement.removeChild(oldChild);
  }
};
AdfDhtmlTableBasePeer.prototype._hasRefreshAutoPPRBlock = function(blocks) {
  var agent = AdfAgent.AGENT;
  for (var i = 0;i < blocks.length;i++) {
    if (agent.getBooleanAttribute(blocks[i], AdfDhtmlTableBasePeer.NEEDS_REFRESH_ATTRIBUTE, false)) {
      return true;
    }
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype.AutoPPRBlockReceived = function(block) {
};
AdfDhtmlTableBasePeer.prototype.HandleAutoPPRRemove = function(block) {
  var agent = AdfAgent.AGENT;
  var doFillViewPort = false;
  var token = agent.getAttribute(block, "_parentKey", null);
  if (token) {
    var rowInfo = this.FindRowByKey(token);
    if (rowInfo) {
      this.DeleteBlock(rowInfo.index, 1, 1, 0, null);
      this.UpdateRange(false);
      doFillViewPort = true;
    }
  }
  return doFillViewPort;
};
AdfDhtmlTableBasePeer.prototype.DomReplaceNotify = function(domNode) {
  if (domNode.id.indexOf(AdfDhtmlTableBasePeer.DW_SUB_ID) > 0) {
    return null;
  }
  return domNode;
};
AdfDhtmlTableBasePeer.prototype._getUnavailableRowIndex = function(elem) {
  var rowIndex = -1;
  var agent = AdfAgent.AGENT;
  if (elem) {
    var unavailableRowDiv = AdfDhtmlTableBasePeer.__getChildBySubId(elem, "unAvail");
    if (unavailableRowDiv) {
      rowIndex = agent.getIntAttribute(unavailableRowDiv, "_unavailableRowIndex", -1);
      elem.removeChild(unavailableRowDiv);
    }
  }
  return rowIndex;
};
AdfDhtmlTableBasePeer.prototype._queueExpandFetchEvent = function() {
  var event = this._queueFetchEvent(false, AdfTableDataFetchEvent.EXPAND_SUBTYPE);
  AdfDhtmlTableBasePeer.SetCursor(this.GetDataBody(), "wait");
  if (this._pruneKeyCache) {
    event.setClientTokens(this._collectClientTokens(this._pruneKeyCache));
    this._pruneKeyCache = null;
  }
};
AdfDhtmlTableBasePeer.prototype._queueCollapseFetchEvent = function() {
  this._queueFetchEvent(false, AdfTableDataFetchEvent.COLLAPSE_SUBTYPE);
  AdfDhtmlTableBasePeer.SetCursor(this.GetDataBody(), "wait");
};
AdfDhtmlTableBasePeer.prototype.BlockInserted = function(block, startRow, numRows) {
};
AdfDhtmlTableBasePeer.prototype.BlockDeleted = function() {
};
AdfDhtmlTableBasePeer.prototype.DeleteBlock = function(startRow, numRows, totalRows, remainingBlocks, deletedElems) {
  var dataBody = this.GetDataBody();
  var blocks = dataBody.childNodes;
  var oldHeight = 0, newHeight = 0;
  var removedCount = 0;
  for (var i = blocks.length - 1;i >= 0 && removedCount < numRows;i--) {
    var block = blocks[i];
    oldHeight += block.cachedHeight;
    var removeStart = Math.max(startRow, block.startRow);
    var removeEnd = Math.min(startRow + numRows - 1, block.startRow + block.numRows - 1);
    var removedInBlock = 0;
    var heightDelta = 0;
    var needsRemoving = null;
    if (removeStart == block.startRow && removeEnd == block.startRow + block.numRows - 1) {
      heightDelta = block.cachedHeight;
      needsRemoving = block;
      removedInBlock = block.numRows;
      if (deletedElems) {
        deletedElems.push(block);
        deletedElems.totalHeight += block.offsetHeight;
      }
    } else {
      for (var r = removeEnd;r >= removeStart;r--) {
        var rIndex = r - block.startRow;
        if (rIndex == 0) {
          AdfAssert.assert(block.rows != null && block.rows[0] != null, "Unable to copy cell widths when the block contains no rows!");
          var r0Cells = block.rows[0].cells;
          var r1Cells = block.rows[1].cells;
          for (var c = 0;c < r1Cells.length;c++) {
            r1Cells[c].style.width = r0Cells[c].style.width;
          }
        }
        var deletedRow = block.rows[rIndex];
        if (deletedElems) {
          deletedElems.push(deletedRow);
          deletedElems.totalHeight += deletedRow.offsetHeight;
        }
        this._unregisterNode(deletedRow);
        deletedRow.parentNode.removeChild(deletedRow);
        removedInBlock++;
      }
      if (removedInBlock > 0) {
        var height = block.offsetHeight;
        heightDelta = block.cachedHeight - height;
        block.cachedHeight = height;
        block.numRows = block.rows.length;
      }
      newHeight += block.cachedHeight;
    }
    if (removedInBlock > 0) {
      for (var b = i + 1;b < blocks.length;b++) {
        var next = blocks[b];
        next.startPos -= heightDelta;
        next.startRow -= removedInBlock;
      }
      if (needsRemoving) {
        this._unregisterNode(needsRemoving);
        dataBody.removeChild(needsRemoving);
      }
    }
    removedCount += removedInBlock;
  }
  var canvasDelta;
  if (removedCount == totalRows) {
    canvasDelta = newHeight - oldHeight;
  } else {
    canvasDelta = -this._averageRowHeight * totalRows;
  }
  this._knownRowCount -= totalRows;
  if (this._rowCount != -1) {
    this._rowCount -= totalRows;
  }
  if (this._knownRowCount > 0) {
    missing = this._isViewportSatisfied(dataBody, dataBody.offsetHeight);
    if (missing & AdfDhtmlTableBasePeer.MISSING_AFTER) {
      this._addBelow(dataBody, dataBody.offsetHeight, false);
    }
  }
  this._adjustCanvasHeight(canvasDelta, dataBody);
  if (remainingBlocks == 0) {
    this._stretchTheColumns();
    this._checkForScrollableLastBlockInViewport(dataBody);
    this.BlockDeleted();
  }
};
AdfDhtmlTableBasePeer.prototype.FetchCompleted = function() {
  this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UPDATE, true, null);
};
AdfDhtmlTableBasePeer.prototype.GetAssociatedComponent = function() {
  if (this._associatedPeer != null) {
    return this._associatedPeer.getComponent();
  } else {
    return null;
  }
};
AdfDhtmlTableBasePeer.prototype._updateInitialARK = function(block) {
  var component = this.getComponent();
  var activeRowKey = block.getAttribute("_initARK");
  if (activeRowKey) {
    this._ignoreActiveRowKeyChange = true;
    try {
      component.setProperty("_afrActiveRowKey", activeRowKey, false, AdfUIComponent.PROPAGATE_NEVER);
      component.setProperty("activeRowKey", activeRowKey, false, AdfUIComponent.PROPAGATE_NEVER);
    } finally {
      this._ignoreActiveRowKeyChange = false;
    }
  }
};
AdfDhtmlTableBasePeer.prototype._updateComponentSelectionState = function(block) {
  var component = this.getComponent();
  var selState = block.getAttribute("_selState");
  if (selState) {
    selState = selState.replace(/'/g, '"');
    var st = JSON.parse(selState);
    component.setProperty("selectedRowKeys", st, false, AdfUIComponent.PROPAGATE_NEVER);
    var service = AdfPage.PAGE._getScriptLoadingService();
    service.addCallbackScript(this, this._setFocusOnSelectedRow);
  }
};
AdfDhtmlTableBasePeer.prototype._setFocusOnSelectedRow = function() {
  var activeElement = AdfPage.PAGE.getActiveDomElement();
  if (!activeElement) {
    return;
  }
  var tableDomElement = this.getDomElement();
  var component = this.getComponent();
  var state = component.getSelectedRowKeys();
  for (var rowKey in state) {
    if (state[rowKey]) {
      var rowInfo = this.FindRowByKey(rowKey);
      if (rowInfo) {
        var row = rowInfo.tr;
        if (activeElement != tableDomElement && this.isInActiveHeirarchy() && !AdfDomUtils.isAncestorOrSelf(row, activeElement)) {
          this._setFocusOnNode(row, 0);
          return;
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._updateAutoPPRActiveRowKey = function(block) {
  var component = this.getComponent();
  var agent = AdfAgent.AGENT;
  var rowKey = agent.getAttribute(block, "_autopprActiveRow", null);
  if (rowKey != null) {
    this._ignoreActiveRowKeyChange = true;
    try {
      rowKey = rowKey.length == 0 ? null : rowKey;
      component.setProperty("_afrActiveRowKey", rowKey, false, AdfUIComponent.PROPAGATE_NEVER);
      component.setProperty("activeRowKey", rowKey, false, AdfUIComponent.PROPAGATE_NEVER);
      this._processClickToEditRequestTimerId = AdfPage.PAGE.scheduleTimer(this, this._processClickToEditRequest, false, 10);
    } finally {
      this._ignoreActiveRowKeyChange = false;
    }
  }
};
AdfDhtmlTableBasePeer.prototype._updateComponentDisclosureState = function(block) {
  var component = this.getComponent();
  var discState = block.getAttribute("_discState");
  if (discState) {
    eval("var st\x3d" + discState + ";");
    component.setProperty("disclosedRowKeys", st, false, AdfUIComponent.PROPAGATE_NEVER);
  }
};
AdfDhtmlTableBasePeer.prototype._initVirtualization = function(firstBlock, alreadyInserted) {
  try {
    this._hideStatus();
    this._virtInitialized = true;
    var agent = AdfAgent.AGENT;
    var startRow = agent.getIntAttribute(firstBlock, "_startRow", 0);
    var visibleRowIndex = agent.getIntAttribute(firstBlock, "_visibleRow", -1);
    var numRows = AdfDhtmlTableBasePeer._getBlockRowCount(firstBlock);
    var component = this.getComponent();
    var dataBody = this.GetDataBody();
    var rowCount = agent.getIntAttribute(firstBlock, "_rowCount", -1);
    var isPaged = this._isPaged;
    var isLoadMore = this._isLoadMore;
    var estRowCount = this._getEstimatedRowCount(firstBlock);
    if (estRowCount >= 0) {
      numRows = estRowCount;
      rowCount = -1;
    }
    if (this._unavailableRowIndex == 0) {
      rowCount = -1;
    } else {
      if (this._unavailableRowIndex > 0) {
        rowCount = this._unavailableRowIndex;
      }
    }
    this._rowCount = rowCount;
    this._knownRowCount = rowCount;
    var totalRows = rowCount;
    var currentScrollTop = 0;
    if (totalRows == -1) {
      totalRows = startRow + numRows;
      this._knownRowCount = startRow + numRows;
    }
    this._updateComponentSelectionState(firstBlock);
    this._updateInitialARK(firstBlock);
    var container = this.getDomElement();
    agent.setScrollLeft(container, 0);
    var clientWidth = container.clientWidth;
    var clientHeight = container.clientHeight;
    var frWidth = agent.getIntAttribute(firstBlock, "_frWidth", 0);
    this._frozenWidth = frWidth;
    var totalWidth = agent.getIntAttribute(firstBlock, "_totalWidth", -1);
    this._totalWidth = totalWidth;
    this._unfrozenWidth = totalWidth - frWidth;
    this._hasDetailStamp = agent.getAttribute(firstBlock, AdfDhtmlTableBasePeer._HAS_DETAIL_MARKER, false);
    if (!alreadyInserted) {
      var children = dataBody.childNodes;
      for (var c = children.length - 1;c >= 0;c--) {
        dataBody.removeChild(children[c]);
      }
      dataBody.appendChild(firstBlock);
      clientWidth = container.clientWidth;
      clientHeight = container.clientHeight;
    }
    var blockHeight = firstBlock.offsetHeight;
    var blockCount = AdfDhtmlTableBasePeer._getBlockRowCount(firstBlock);
    firstBlock.cachedHeight = blockHeight;
    var averageHeight = Math.round(blockHeight / blockCount);
    this._averageRowHeight = averageHeight;
    var canvasHeight;
    if (!isPaged && !isLoadMore && totalRows > numRows) {
      canvasHeight = averageHeight * totalRows;
    } else {
      if (rowCount == -1 && !isPaged && !isLoadMore && blockHeight < clientHeight - this._cachedCHHeight - this._cachedCFHeight - this._cachedNBHeight) {
        canvasHeight = clientHeight - this._cachedCHHeight - this._cachedCFHeight - this._cachedNBHeight;
      } else {
        canvasHeight = blockHeight;
      }
    }
    if (rowCount == -1 && !isPaged && !isLoadMore) {
      if (estRowCount > 0) {
        canvasHeight += averageHeight * estRowCount;
      }
      canvasHeight += AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE;
    }
    firstBlock.style.position = "relative";
    dataBody.scrollTop = 0;
    firstBlock.startRow = startRow;
    firstBlock.numRows = blockCount;
    if (!isPaged && !isLoadMore && startRow > 0) {
      firstBlock.startPos = currentScrollTop = averageHeight * startRow;
    } else {
      firstBlock.startPos = 0;
    }
    var scroller = this._createAndInitializeScroller(container, clientWidth, clientHeight, canvasHeight, frWidth, firstBlock);
    if (this._scrollbarBehavior != AdfDhtmlTableBasePeer._SCROLLBAR_BEHAVIOR_AUTOHIDE) {
      this._addScrollEventListeners(dataBody);
    }
    this._innerTableScrollCallback = this.createCallback(this._handleInnerTableScroll);
    this._registerInnerScrollCallback(firstBlock);
    if (!this._headerless) {
      var colHeader = this.__getColumnHeader();
      if (!this._hasFrozenColumn()) {
        colHeader.onscroll = this._innerTableScrollCallback;
      } else {
        if (!this._areAllColumnsFrozen(this._colCount)) {
          var second = AdfDhtmlTableBasePeer.__getChildBySubId(colHeader, "d2");
          second.onscroll = this._innerTableScrollCallback;
        }
      }
    }
    if (!this._footerless) {
      var colFooter = this._getColumnFooter();
      if (!this._hasFrozenColumn()) {
        colFooter.onscroll = this._innerTableScrollCallback;
      } else {
        if (!this._areAllColumnsFrozen(this._colCount)) {
          second = AdfDhtmlTableBasePeer.__getChildBySubId(colFooter, "fd2");
          second.onscroll = this._innerTableScrollCallback;
        }
      }
    }
    var dataBodyHeight = this.SizeDataBody(dataBody, clientWidth, clientHeight);
    dataBody.style.zIndex = 1;
    currentScrollTop = this._computeInitialScrollTop(component, firstBlock, startRow, canvasHeight, dataBodyHeight, blockHeight);
    this._initScrollLeftTop(scroller, currentScrollTop);
    if (!this.isHeightAutoSized() && visibleRowIndex > -1) {
      this.scrollToRowIndex(visibleRowIndex);
    }
    this._restoreScrollPosition();
    this._synchronizeRowHeights(firstBlock);
    if (this.isHeightAutoSized()) {
      this.AdjustAutoHeight();
      currentScrollTop = this._computeInitialScrollTop(component, firstBlock, startRow, canvasHeight, dataBody.offsetHeight, blockHeight);
      this._currentScrollTop = currentScrollTop;
      if (currentScrollTop > 0) {
        if (this._hasSingleScroller() && !isPaged) {
          scroller.scrollTop = currentScrollTop;
        } else {
          scroller[0].scrollTop = scroller[1].scrollTop = currentScrollTop;
        }
      }
      if (visibleRowIndex > -1) {
        this.scrollToRowIndex(visibleRowIndex);
      }
    }
    this._stretchTheColumns();
    this._fillViewPort(dataBody, dataBody.offsetHeight, false);
    this._syncDataBodyHeights();
    if (this._getActiveRowKey() == null) {
      this._setReadOnlyMode(true, null, false);
    }
  } finally {
    this._updatePCState();
    this.UpdateRange(true);
    this._virtInitializedComplete = true;
  }
};
AdfDhtmlTableBasePeer.prototype._computeInitialScrollTop = function(component, firstBlock, startRow, canvasHeight, dataBodyHeight, blockHeight) {
  if (this._isPaged) {
    return 0;
  }
  var currentScrollTop = 0;
  if (startRow > 0) {
    currentScrollTop = Math.min(firstBlock.startPos, canvasHeight - dataBodyHeight);
    currentScrollTop = Math.max(0, currentScrollTop);
  }
  if ("last" == component.getDisplayRow() && dataBodyHeight < canvasHeight) {
    currentScrollTop = canvasHeight - dataBodyHeight;
    firstBlock.startPos = canvasHeight - blockHeight;
  }
  return currentScrollTop;
};
AdfDhtmlTableBasePeer.prototype._handleTouchMovement = function(deltaX, deltaY) {
  var scrollPosition = this.__getScrollPos();
  if (scrollPosition) {
    scrollLeft = scrollPosition.x - deltaX;
    scrollTop = scrollPosition.y - deltaY;
    this._scrollerScrollToPos(scrollLeft, scrollTop);
  }
};
AdfDhtmlTableBasePeer.prototype._syncDataBodyHeights = function() {
  var component = this.getComponent();
  var isSlave = component.getProperty("_afrMasterId");
  var isMaster = component.getProperty("_afrSlaveId");
  if ((isSlave || isMaster) && this._hasSingleScroller()) {
    AdfPage.PAGE.scheduleTimer(this, this._syncDataBodyHeightsTimeout, component, 0);
  }
};
AdfDhtmlTableBasePeer.prototype._syncDataBodyHeightsTimeout = function(component) {
  var buddyComponent = component.getParent().findComponent(this._associatedId);
  AdfAssert.assert(buddyComponent != null, "There is no associated table");
  var buddyPeer = buddyComponent.getPeer();
  var dataBody = this.GetDataBody();
  var buddyDataBody = buddyPeer.GetDataBody();
  var scroller = this.GetScroller();
  var buddyScroller = buddyPeer.GetScroller();
  if (scroller && buddyScroller) {
    var fakeDiv = scroller.firstChild;
    var buddyFakeDiv = buddyScroller.firstChild;
    if (fakeDiv && buddyFakeDiv) {
      var hasScrollbar = (scroller.style.overflowX == "auto" || scroller.style.overflow == "auto") && scroller.offsetHeight > scroller.clientHeight;
      var buddyHasScrollbar = (buddyScroller.style.overflowX == "auto" || buddyScroller.style.overflow == "auto") && buddyScroller.offsetHeight > buddyScroller.clientHeight;
      var height = parseInt(dataBody.style.height);
      var buddyHeight = parseInt(buddyDataBody.style.height);
      if (!isNaN(height) && !isNaN(buddyHeight)) {
        if (buddyHasScrollbar && !hasScrollbar) {
          dataBody.style.height = buddyHeight + "px";
          scroller.style.height = buddyScroller.style.height;
          scroller.style.overflowX = "scroll";
          fakeDiv.style.height = buddyFakeDiv.style.height;
        } else {
          if (hasScrollbar && !buddyHasScrollbar) {
            buddyDataBody.style.height = height + "px";
            buddyScroller.style.height = scroller.style.height;
            buddyScroller.style.overflowX = "scroll";
            buddyFakeDiv.style.height = fakeDiv.style.height;
          } else {
            if (buddyScroller.style.overflowX == "auto") {
              scroller.style.overflowX = "auto";
              dataBody.style.height = buddyHeight + "px";
              scroller.style.height = buddyScroller.style.height;
              fakeDiv.style.height = buddyFakeDiv.style.height;
            } else {
              buddyScroller.style.overflowX = "auto";
              buddyDataBody.style.height = height + "px";
              buddyScroller.style.height = scroller.style.height;
              buddyFakeDiv.style.height = fakeDiv.style.height;
            }
          }
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._createAndInitializeScroller = function(container, outerWidth, outerHeight, canvasHeight, frWidth, firstBlock) {
  var agent = AdfAgent.AGENT;
  var scroller;
  if (this._hasSingleScroller() && !this._isPaged && !this._freezeColumnsToEnd()) {
    var domDocument = this.getDomDocument();
    scroller = domDocument.createElement("div");
    scroller.tabIndex = -1;
    scroller.id = container.id + "::scroller";
    var sStyle = scroller.style;
    sStyle.position = "absolute";
    if (this._isTouch && agent.getPlatform() == AdfAgent.WEBKIT_PLATFORM) {
      sStyle.setProperty("-webkit-overflow-scrolling", "touch");
      sStyle.setProperty("-webkit-transform", "translateZ(0px)");
      if (agent.getOS() == AdfAgent.MAC_OS) {
        AdfDomUtils.addCSSClassName(scroller, AdfPage.PAGE.getLookAndFeel().getStyleClass(AdfDhtmlTableBasePeer._SCROLLER_ANIMATION_CLASS));
      }
    }
    if (this._associatedId != null) {
      var component = this.getComponent();
      if (component.getProperty("_afrSlaveId") != null) {
        sStyle.overflowX = "auto";
        sStyle.overflowY = "hidden";
      } else {
        sStyle.overflow = "auto";
      }
      var buddyComponent = component.getParent().findComponent(this._associatedId);
      AdfAssert.assert(buddyComponent != null, "There is no associated table");
      this._associatedPeer = buddyComponent.getPeer();
      var buddyPeer = buddyComponent.getPeer();
      if (buddyPeer != null && buddyPeer._associatedPeer != this) {
        buddyPeer._associatedPeer = this;
      }
    } else {
      if (this._freezeColumnsToEnd()) {
        sStyle.overflowX = "auto";
        sStyle.overflowY = "hidden";
      } else {
        sStyle.overflow = "auto";
      }
    }
    sStyle.zIndex = 0;
    sStyle.width = Math.max(outerWidth - frWidth, 0) + "px";
    sStyle.top = this._cachedCHHeight + "px";
    sStyle.height = Math.max(outerHeight - this._cachedCHHeight, 0) + "px";
    if (AdfDhtmlTableBasePeer._isRTL()) {
      if (this._freezeColumnsToEnd()) {
        sStyle.right = "0px";
      } else {
        sStyle.left = "0px";
      }
    } else {
      if (this._freezeColumnsToEnd()) {
        sStyle.left = "0px";
      } else {
        sStyle.right = "0px";
      }
    }
    var fake = domDocument.createElement("div");
    var blockWidth = agent.getIntAttribute(firstBlock, "_totalWidth", -1);
    if (blockWidth == -1) {
      blockWidth = firstBlock.offsetWidth;
    }
    fake.style.width = blockWidth - frWidth + "px";
    if (agent.getPlatform() == AdfAgent.IE_PLATFORM) {
      fake.style.position = "absolute";
      if (blockWidth - frWidth == 0) {
        fake.style.width = "1px";
      }
    }
    this._canvasHeight = canvasHeight;
    if (canvasHeight > AdfDhtmlTableBasePeer._CSS_HEIGHT_LIMIT) {
      fake.style.height = AdfDhtmlTableBasePeer._CSS_HEIGHT_LIMIT + "px";
      this._canvasHeightLimited = true;
    } else {
      fake.style.height = canvasHeight + "px";
      this._canvasHeightLimited = false;
    }
    fake.style.visibility = "hidden";
    scroller.appendChild(fake);
    container.appendChild(scroller);
    agent.elementsAdded(scroller);
  } else {
    scroller = this._createAndInitializeColumnFooterScroller(container, outerWidth, outerHeight, canvasHeight, frWidth, firstBlock);
  }
  if (this._scrollbarBehavior == AdfDhtmlTableBasePeer._SCROLLBAR_BEHAVIOR_AUTOHIDE) {
    var laf = AdfPage.PAGE.getLookAndFeel();
    var dataBody = this.GetDataBody();
    var firstBlock = dataBody.firstChild;
    var tableHLinesClassName = laf.getStyleClass(AdfDhtmlTableBasePeer._TABLE_H_LINES_CLASS);
    var tableVHLinesClassName = laf.getStyleClass(AdfDhtmlTableBasePeer._TABLE_VH_LINES_CLASS);
    if (firstBlock != null && (AdfDomUtils.containsCSSClassName(firstBlock, tableHLinesClassName) || AdfDomUtils.containsCSSClassName(firstBlock, tableVHLinesClassName)) && this._scrollbarBehavior == AdfDhtmlTableBasePeer._SCROLLBAR_BEHAVIOR_AUTOHIDE) {
      AdfDomUtils.addCSSClassName(dataBody, laf.getStyleClass(AdfDhtmlTableBasePeer._SCROLLBAR_AUTOHIDE_DATABODY_H_LINES_CLASS));
    }
    var dataBodyWrapper = this.getDomDocument().createElement("div");
    dataBodyWrapper.setAttribute("id", AdfRichUIPeer.CreateSubId(container.id, AdfDhtmlTableBasePeer._DATAWRAPPER));
    var dataBodyWrapperClassName = laf.getStyleClass(AdfDhtmlTableBasePeer._SCROLLBAR_AUTOHIDE_DATABODY_WRAPPER_CLASS);
    AdfDomUtils.addCSSClassName(dataBodyWrapper, dataBodyWrapperClassName);
    var dataBodyWrapperStyle = dataBodyWrapper.style;
    this._cachedScrollerWidthAddl = container.offsetWidth - outerWidth;
    this._cachedScrollerHeightAddl = container.offsetHeight - outerHeight;
    dataBodyWrapperStyle.height = container.offsetHeight - this._cachedCHHeight - this._cachedCFHeight + "px";
    dataBodyWrapperStyle.width = container.offsetWidth + "px";
    dataBodyWrapperStyle.overflowX = "hidden";
    dataBodyWrapperStyle.overflowY = "hidden";
    dataBodyWrapperStyle.position = "relative";
    dataBodyWrapperStyle.zIndex = 1;
    this._addScrollEventListeners(dataBodyWrapper);
    container.insertBefore(dataBodyWrapper, dataBody);
    if (this._isLoadMore) {
      var bottomLoadMore = this._getLoadMore(false);
      var topLoadMore = this._getLoadMore(true);
      if (topLoadMore != null) {
        dataBodyWrapper.appendChild(topLoadMore);
      }
      dataBodyWrapper.appendChild(dataBody);
      if (bottomLoadMore != null) {
        dataBodyWrapper.appendChild(bottomLoadMore);
      }
    } else {
      dataBodyWrapper.appendChild(dataBody);
    }
    agent.elementsAdded(dataBodyWrapper);
    if (this._hasSingleScroller() && !this._isPaged) {
      vscroller = this.GetScroller();
      hscroller = this.GetScroller();
    } else {
      vscroller = this.GetScroller()[AdfDhtmlTableBasePeer._VSCROLLER];
      hscroller = this.GetScroller()[AdfDhtmlTableBasePeer._HSCROLLER];
    }
    vscroller.style.visibility = "hidden";
    hscroller.style.visibility = "hidden";
    this._scrollbarHidden = true;
    this._dataBodyWrapped = true;
  }
  return scroller;
};
AdfDhtmlTableBasePeer.prototype._initScrollLeftTop = function(scroller, currentScrollTop) {
  this._currentScrollTop = currentScrollTop;
  if (this._hasSingleScroller() && !this._isPaged) {
    if (currentScrollTop > 0) {
      scroller.scrollTop = currentScrollTop;
    }
    this._currentScrollLeft = AdfDhtmlTableBasePeer._isRTL() ? AdfAgent.AGENT.getScrollLeft(scroller) : 0;
    AdfRichUIPeer.addEventHandlerToDomInstance(AdfDhtmlTableBasePeer, scroller, AdfDhtmlLookAndFeel.SCROLL_EVENT_TYPE);
  } else {
    if (currentScrollTop > 0) {
      scroller[0].scrollTop = scroller[1].scrollTop = currentScrollTop;
    }
    this._currentScrollLeft = AdfDhtmlTableBasePeer._isRTL() ? AdfAgent.AGENT.getScrollLeft(scroller[0]) : 0;
    AdfRichUIPeer.addEventHandlerToDomInstance(AdfDhtmlTableBasePeer, scroller[0], AdfDhtmlLookAndFeel.SCROLL_EVENT_TYPE);
    AdfRichUIPeer.addEventHandlerToDomInstance(AdfDhtmlTableBasePeer, scroller[1], AdfDhtmlLookAndFeel.SCROLL_EVENT_TYPE);
  }
};
AdfDhtmlTableBasePeer.prototype._createAndInitializeColumnFooterScroller = function(container, outerWidth, outerHeight, canvasHeight, frWidth, firstBlock) {
  var scroller = [];
  var agent = AdfAgent.AGENT;
  var domDocument = this.getDomDocument();
  hscroller = domDocument.createElement("div");
  vscroller = domDocument.createElement("div");
  hscroller.id = container.id + "::hscroller";
  vscroller.id = container.id + "::vscroller";
  hscroller.tabIndex = -1;
  vscroller.tabIndex = -1;
  var hsStyle = hscroller.style;
  var vsStyle = vscroller.style;
  hsStyle.position = vsStyle.position = "absolute";
  if (this._associatedId != null) {
    var component = this.getComponent();
    if (component.getProperty("_afrSlaveId") != null) {
      vsStyle.overflowY = "hidden";
      vsStyle.overflowX = "hidden";
      hsStyle.overflowY = "hidden";
      hsStyle.overflowX = "auto";
    } else {
      vsStyle.overflowY = "auto";
      vsStyle.overflowX = "hidden";
      hsStyle.overflowY = "hidden";
      hsStyle.overflowX = "auto";
    }
    var buddyComponent = component.findComponent(this._associatedId);
    AdfAssert.assert(buddyComponent != null, "There is no associated table");
    this._associatedPeer = buddyComponent.getPeer();
    var buddyPeer = buddyComponent.getPeer();
    if (buddyPeer != null && buddyPeer._associatedPeer != this) {
      buddyPeer._associatedPeer = this;
    }
  } else {
    vsStyle.overflowY = "auto";
    vsStyle.overflowX = "hidden";
    hsStyle.overflowY = "hidden";
    hsStyle.overflowX = "auto";
    if (this._isTouch && agent.getPlatform() == AdfAgent.WEBKIT_PLATFORM) {
      vsStyle.setProperty("-webkit-overflow-scrolling", "touch");
      vsStyle.setProperty("-webkit-transform", "translateZ(0px)");
      hsStyle.setProperty("-webkit-overflow-scrolling", "touch");
      hsStyle.setProperty("-webkit-transform", "translateZ(0px)");
      if (agent.getOS() == AdfAgent.MAC_OS) {
        hsStyle.overflow = "scroll";
        var animationStyleClass = AdfPage.PAGE.getLookAndFeel().getStyleClass(AdfDhtmlTableBasePeer._SCROLLER_ANIMATION_CLASS);
        AdfDomUtils.addCSSClassName(vscroller, AdfDhtmlTableBasePeer.animationStyleClass);
        AdfDomUtils.addCSSClassName(hscroller, AdfDhtmlTableBasePeer.animationStyleClass);
      }
    }
  }
  hsStyle.zIndex = vsStyle.zIndex = 0;
  vsStyle.width = Math.max(outerWidth - frWidth, 0) + "px";
  vsStyle.top = this._cachedCHHeight + "px";
  vsStyle.height = Math.max(outerHeight - this._cachedCHHeight - this._cachedCFHeight - this._cachedNBHeight, 0) + "px";
  if (AdfDhtmlTableBasePeer._isRTL()) {
    if (this._freezeColumnsToEnd()) {
      hsStyle.right = "0px";
    } else {
      hsStyle.left = "0px";
    }
    vsStyle.left = "0px";
  } else {
    if (this._freezeColumnsToEnd()) {
      hsStyle.left = "0px";
    } else {
      hsStyle.right = "0px";
    }
    vsStyle.right = "0px";
  }
  var hfake = domDocument.createElement("div");
  var vfake = domDocument.createElement("div");
  var blockWidth = agent.getIntAttribute(firstBlock, "_totalWidth", -1);
  if (blockWidth == -1) {
    blockWidth = firstBlock.offsetWidth;
  }
  if (agent.getPlatform() == AdfAgent.IE_PLATFORM) {
    hfake.style.position = vfake.style.position = "absolute";
  }
  hfake.style.width = vfake.style.width = blockWidth - frWidth + "px";
  this._canvasHeight = canvasHeight;
  hfake.style.height = vfake.style.height = canvasHeight + "px";
  hscroller.appendChild(hfake);
  vscroller.appendChild(vfake);
  container.appendChild(vscroller);
  agent.elementsAdded(vscroller);
  hsStyle.top = this._cachedCHHeight + "px";
  hsStyle.height = Math.max(outerHeight - this._cachedCHHeight, 0) + "px";
  var scrollbarWidth = vscroller.offsetWidth - vscroller.clientWidth;
  if (AdfDhtmlTableBasePeer._isRTL()) {
    hsStyle.left = scrollbarWidth + "px";
  } else {
    hsStyle.right = scrollbarWidth + "px";
  }
  hsStyle.width = Math.max(outerWidth - frWidth - scrollbarWidth, 0) + "px";
  container.appendChild(hscroller);
  agent.elementsAdded(hscroller);
  var scrollbarHeight = hscroller.offsetHeight - hscroller.clientHeight;
  vsStyle.height = Math.max(outerHeight - this._cachedCHHeight - this._cachedCFHeight - this._cachedNBHeight - scrollbarHeight, 0) + "px";
  scroller[AdfDhtmlTableBasePeer._HSCROLLER] = hscroller;
  scroller[AdfDhtmlTableBasePeer._VSCROLLER] = vscroller;
  return scroller;
};
AdfDhtmlTableBasePeer.prototype._updatePCState = function() {
  var pcId = this.getDomElement().getAttribute(AdfDhtmlTableBasePeer._PANEL_COLLECTION_ID);
  if (pcId != null) {
    var pcPeer = this._pcPeer = AdfPage.PAGE.findComponent(pcId).getPeer();
    pcPeer.resetState();
    pcPeer.updateStandardMenuToolbarItems();
    pcPeer.updateStandardStatusbarItems();
    pcPeer.updateRowSelectionContext();
  }
};
AdfDhtmlTableBasePeer.prototype.__getVisibleLeafColumns = function() {
  if (this._visibleLeafColumns != null) {
    return this._visibleLeafColumns;
  }
  var rootElement = this.getDomElement();
  var leafColClientIdsExpando = AdfAgent.AGENT.getAttribute(rootElement, "_leafColClientIds");
  if (leafColClientIdsExpando != null) {
    leafColClientIdsExpando = leafColClientIdsExpando.replace(/'/g, '"');
  }
  var leafColClientIds = JSON.parse(leafColClientIdsExpando);
  var columns = [];
  if (leafColClientIds != null) {
    var count = leafColClientIds.length;
    for (var i = 0;i < count;i++) {
      var clientId = leafColClientIds[i];
      var columnComponent = AdfPage.PAGE.findComponent(clientId);
      columns.push(columnComponent);
    }
  }
  this._visibleLeafColumns = columns;
  return columns;
};
AdfDhtmlTableBasePeer.__getSortOrderForColumn = function(id) {
  var sortOrder = null;
  var siElem = AdfAgent.AGENT.getElementById(AdfRichUIPeer.CreateSubId(id, AdfDhtmlTableBasePeer.__SORT_INDICATOR));
  if (siElem) {
    var sortedType = siElem.getAttribute(AdfDhtmlTableBasePeer._SORTED_TYPE);
    if (sortedType == AdfDhtmlTableBasePeer._SORTED_DESCENDING) {
      sortOrder = false;
    } else {
      if (sortedType == AdfDhtmlTableBasePeer._SORTED_ASCENDING) {
        sortOrder = true;
      }
    }
  }
  return sortOrder;
};
AdfDhtmlTableBasePeer.prototype.__getColumnResizeMargin = function() {
  AdfAssert.failedInAbstractFunction();
};
AdfDhtmlTableBasePeer.prototype.HandleDomMouseMove = function(component, domEvent) {
  if (this._headerless) {
    return;
  }
  if (!this._virtInitialized) {
    return;
  }
  if (this._resizedTH) {
    var cell = this._getParentTH(domEvent);
    if (cell && (!component.getColumnResizing || component.getColumnResizing() == "enabled")) {
      AdfDhtmlTableBasePeer.SetCursor(cell, AdfAgent.AGENT.getCursor("col-resize"));
    }
    return;
  }
  var mdPos = this._mdPos;
  if (mdPos) {
    var newPos = AdfAgent.AGENT.getMousePosition(domEvent);
    if (Math.abs(newPos.x - mdPos.x) > this.__getColumnResizeMargin()) {
      this._mdPos = null;
      this._processColumnReorderAction(domEvent);
    }
    return;
  }
  if (this._reorderTH) {
    AdfDhtmlTableBasePeer.SetCursor(this._reorderTH, "move");
    return;
  }
  var headerAction = this.__getColumnHeaderMouseAction(domEvent);
  if (headerAction) {
    var th = headerAction.cell;
    if ("resize" == headerAction.type && this._getResizedCellInfo(headerAction) && (!component.getColumnResizing || component.getColumnResizing() == "enabled")) {
      AdfDhtmlTableBasePeer.SetCursor(th, AdfAgent.AGENT.getCursor("col-resize"));
    } else {
      if ("move" == headerAction.type) {
        AdfDhtmlTableBasePeer.SetCursor(th, AdfAgent.AGENT.getCursor("move"));
      } else {
        if ("default" == headerAction.type) {
          AdfDhtmlTableBasePeer.SetCursor(th, "default");
        } else {
          AdfDhtmlTableBasePeer.SetCursor(th, "");
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype.__handleColumnResizing = function(componentEvent, headerAction) {
  if (headerAction == null) {
    headerAction = this.__getColumnHeaderMouseAction(componentEvent.getNativeEvent());
    if (headerAction == null) {
      return;
    }
  }
  if (headerAction.type != "resize") {
    return;
  }
  var info = this._getResizedCellInfo(headerAction);
  if (info) {
    this._resizedTH = info.cell;
    this._resizedIndex = info.displayIndex;
    this._showColumnResizeIndicator(info.cell, info.displayIndex);
    this._resizeColDelta = 0;
    var columnHeader = this.__getColumnHeader();
    var agent = AdfAgent.AGENT;
    agent.disableUserSelect(columnHeader);
    componentEvent.cancel();
    var domEvent = componentEvent.getNativeEvent();
    AdfPage.PAGE.startDrag(domEvent, this._colResizeDragCallback, this._colResizeDropCallback);
  }
};
AdfDhtmlTableBasePeer.prototype.HandleComponentMouseDown = function(componentEvent) {
  if (componentEvent.isCanceled()) {
    return;
  }
  var domEvent = componentEvent.getNativeEvent();
  var headerAction = this.__getColumnHeaderMouseAction(domEvent);
  var actionType = headerAction ? headerAction.type : null;
  if (!this._virtInitialized && "clearAllFilter" != actionType) {
    return;
  }
  if (!this.__isOwnComponentEvent(componentEvent)) {
    return;
  }
  var agent = AdfAgent.AGENT;
  var target = agent.getEventTarget(domEvent);
  var header = this.__getColumnHeader();
  if (header && !(this.getComponent().getEditingMode() == "readOnly")) {
    AdfDomUtils.disableTabStop(header, false);
  }
  var attrs = this.GetRowKeyAndRow(target, this.getDomElement());
  if (attrs != null) {
    var rowKey = attrs[0], row = attrs[1];
    if (rowKey != null) {
      if (!this._getExpandAction(target) && (this._isClickToEdit() && (this._getActiveRowKey() != rowKey || this.getComponent().getProperty(AdfDhtmlTableBasePeer._REMAIN_READ_ONLY)))) {
        var params = {evt:domEvent, targetNode:target, isLeftButton:agent.isLeftButton(domEvent), toggleKeyDown:agent.isSelectionToggle(domEvent), shiftKeyDown:domEvent.shiftKey, rowKey:rowKey, row:row};
        this._handleRowMouseDownTimerId = AdfPage.PAGE.scheduleTimer(this, this._handleRowMouseDownForC2E, params, 10);
        this._ignoreRowClick = true;
      } else {
        this._handleRowMouseDown(domEvent, target, agent.isLeftButton(domEvent), agent.isSelectionToggle(domEvent), domEvent.shiftKey, rowKey, row);
      }
      return;
    }
  }
  if (!agent.isLeftButton(domEvent)) {
    return;
  }
  var isTargetCellFilter = this._isTargetCellFilter(target);
  if (this._isTargetCellEditable(target, isTargetCellFilter) && "clearAllFilter" != actionType) {
    if (isTargetCellFilter) {
      if (this._editableTableReadOnlyMode) {
        this._setReadOnlyMode(false, target, false);
      }
      this._setHeaderCellFocus(this._getParentTH(domEvent));
    }
    return;
  }
  if (!actionType) {
    return;
  }
  if ("selectAll" == actionType) {
    this._grabFocus();
    var selState = this.getComponent().getSelectedRowKeys();
    if (selState && selState[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY]) {
      this._selUnselectAll();
      this._queueColumnSelectionEvent();
    } else {
      this._selSelectAll();
    }
  } else {
    if ("clearAllFilter" == actionType) {
      var component = this.getComponent();
      var queryEvent = new AdfQueryEvent(component);
      queryEvent.setClearAll(true);
      component.queueEvent(queryEvent);
      component.setSelectedRowKeys(null);
    } else {
      if ("resize" == actionType) {
        this.__handleColumnResizing(componentEvent, headerAction);
      } else {
        if ("move" == actionType) {
          this._mdPos = agent.getMousePosition(domEvent);
          this._reorderTH = headerAction.cell;
          componentEvent.cancel();
        } else {
          if ("select" == actionType) {
            this._grabFocus();
            var colIndices = headerAction.colIndices;
            if (colIndices.length > 0) {
              if (!domEvent.shiftKey) {
                this._anchorColumnHeader = headerAction.cell;
              }
              this._doColumnSelections(domEvent, colIndices, headerAction.colIds);
              if (this._isMultipleColumnSelect()) {
                if (null == this._handleColumnHeaderDragCallback) {
                  this._handleColumnHeaderDragCallback = this.createCallback(this._handleColumnHeaderDrag);
                  this._handleColumnHeaderDropCallback = this.createCallback(this._handleColumnHeaderDrop);
                }
                var columnHeader = this.__getColumnHeader();
                agent.disableUserSelect(columnHeader);
                AdfPage.PAGE.startDrag(domEvent, this._handleColumnHeaderDragCallback, null);
              }
            }
          }
        }
      }
    }
  }
  if ("resize" != actionType && "sort" != actionType && headerAction.cell != null) {
    this._setHeaderCellFocus(headerAction.cell);
  }
};
AdfDhtmlTableBasePeer.prototype.HandleComponentMouseUp = function(componentEvent) {
  this._mdPos = null;
  this._reorderTH = null;
};
AdfDhtmlTableBasePeer.prototype._selectInputOnMouseUp = function(targetNode) {
  var hasSelection, selectedText;
  if (targetNode.selectionStart != null) {
    hasSelection = targetNode.selectionEnd - targetNode.selectionStart > 0;
  }
  if (AdfAgent.AGENT.getPlatform() == AdfAgent.IE_PLATFORM && AdfAgent.AGENT.getVersion() < 9) {
    selectedText = this.getDomDocument().selection.createRange().text;
  } else {
    selectedText = window.getSelection().toString();
  }
  if (!hasSelection && selectedText != "") {
    targetNode.select();
  }
};
AdfDhtmlTableBasePeer.prototype.HandleComponentDblClick = function(componentEvent) {
  if (!this._virtInitialized) {
    return;
  }
  if (!this.__isOwnComponentEvent(componentEvent)) {
    return;
  }
  if (this._isTargetCellEditable(componentEvent.getNativeEventTarget())) {
    this._ctePatternStart = undefined;
  }
};
AdfDhtmlTableBasePeer.prototype._getOnlyTextNode = function(domNode) {
  var domDoc = domNode.ownerDocument;
  var allNodes;
  var onlyTextNode = null;
  if (domDoc.evaluate && AdfAgent.AGENT.getPlatform() != AdfAgent.EDGE_PLATFORM) {
    allNodes = domDoc.evaluate(".//text()", domNode, null, XPathResult.ANY_TYPE, null);
    onlyTextNode = allNodes.iterateNext();
    if (onlyTextNode && allNodes.iterateNext()) {
      onlyTextNode = null;
    }
  } else {
    var firstChild = domNode.firstChild;
    if (firstChild && firstChild.nodeType == 3) {
      onlyTextNode = firstChild;
    }
    allNodes = domNode.getElementsByTagName("*");
    var nodeCount = allNodes.length;
    for (var i = 0;i < nodeCount;i++) {
      firstChild = allNodes[i].firstChild;
      if (firstChild && firstChild.nodeType == 3) {
        if (onlyTextNode) {
          onlyTextNode = null;
          break;
        } else {
          onlyTextNode = firstChild;
        }
      }
    }
  }
  return onlyTextNode;
};
AdfDhtmlTableBasePeer.prototype._isCellTruncated = function(domNode) {
  var cloneCell = domNode.cloneNode(true);
  var isTruncated = false;
  AdfAgent.AGENT.copyStyle(domNode, cloneCell);
  cloneCell.style.width = "";
  var children = cloneCell.getElementsByTagName("input");
  for (var i = children.length - 1;i >= 0;i--) {
    var child = children[i];
    child.id = "";
    child.name = "";
  }
  var domElement = this.getDomElement();
  var ownerDoc = domNode.ownerDocument;
  var tempTable = ownerDoc.createElement("table");
  domElement.appendChild(tempTable);
  var headerRow = tempTable.insertRow(-1);
  headerRow.appendChild(cloneCell);
  if (domNode.offsetWidth < cloneCell.offsetWidth) {
    isTruncated = true;
  }
  domElement.removeChild(tempTable);
  return isTruncated;
};
AdfDhtmlTableBasePeer.prototype.getClickLocation = function(domEvent) {
  var agent = AdfAgent.AGENT;
  var colHeader = this.__getColumnHeader();
  var headerPos;
  var eleType;
  if (colHeader) {
    headerPos = agent.getElementPosition(colHeader);
  }
  var mousePos = agent.getMousePosition(domEvent);
  if (colHeader && mousePos.y - headerPos.y <= this._cachedCHHeight) {
    eleType = "header";
  } else {
    eleType = "body";
  }
  return eleType;
};
AdfDhtmlTableBasePeer.prototype.HandleComponentContextMenu = function(componentEvent) {
  var domEvent = componentEvent.getNativeEvent();
  var agent = AdfAgent.AGENT;
  if (!componentEvent.isPositionalRequest()) {
    this._handleKeyboardContextMenu(domEvent, false);
    return;
  }
  var eleType = this.getClickLocation(domEvent);
  if (eleType === "header") {
    this._handleColumnContextMenu(domEvent);
  } else {
    var target = agent.getEventTarget(domEvent);
    if (!this._isTargetCellEditable(target)) {
      var attrs = this.GetRowKeyAndRow(target, this.getDomElement());
      if (attrs != null) {
        var rowKey = attrs[0], row = attrs[1];
        if (rowKey != null) {
          this.HandleRowContextMenu(domEvent, rowKey, row);
          return;
        }
      }
      this._handleBodyContextMenu(domEvent);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._hideColumnSortableIndicator = function(agent, th) {
  if (th && th.colSpan < 2) {
    var siId = AdfRichUIPeer.CreateSubId(th.id, AdfDhtmlTableBasePeer.__SORT_INDICATOR);
    var siElem = agent.getElementById(siId);
    if (siElem == null) {
      return;
    }
    var sortedType = siElem.getAttribute(AdfDhtmlTableBasePeer._SORTED_TYPE);
    var supportsHover = siElem.getAttribute(AdfDhtmlTableBasePeer._SUPPORTS_HOVER);
    if (sortedType == null && supportsHover) {
      siElem.style.visibility = "hidden";
    }
  }
};
AdfDhtmlTableBasePeer.prototype.HandleComponentClick = function(componentEvent) {
  if (componentEvent.isCanceled()) {
    return false;
  }
  if (!this.__isOwnComponentEvent(componentEvent)) {
    return false;
  }
  var component = this.getComponent();
  var agent = AdfAgent.AGENT;
  var domEvent = componentEvent.getNativeEvent();
  var target = agent.getEventTarget(domEvent);
  var attrs = this.GetRowKeyAndRow(target, this.getDomElement());
  if (attrs != null) {
    var rowKey = attrs[0], row = attrs[1];
    if (rowKey != null) {
      if (componentEvent.isLeftButtonPressed()) {
        var action = this._getExpandAction(target);
        if ("expand" == action) {
          component.setDisclosedRowKey(rowKey, true);
        } else {
          if ("collapse" == action) {
            component.setDisclosedRowKey(rowKey, false);
          } else {
            this._handleRowClick(target, agent.isLeftButtonClick(domEvent), agent.isSelectionToggle(domEvent), domEvent.shiftKey, rowKey, row);
          }
        }
      }
      return true;
    }
  }
  if (!this._headerless) {
    var headerAction = this.__getColumnHeaderMouseAction(domEvent);
    if (headerAction && "sort" == headerAction.type && !componentEvent.isCanceled()) {
      if (this._isClickToEdit() && this._getActiveRowKey()) {
        this._enterReadOnlyMode(componentEvent, false);
        var adfPage = AdfPage.PAGE;
        var sortParams = new Object;
        sortParams["table"] = component;
        sortParams["properties"] = [headerAction.sortProperty];
        sortParams["orders"] = [headerAction.sortOrder];
        adfPage.scheduleTimer(this, this._delayedQueueSortEvent, sortParams, 100);
      } else {
        AdfTableUtils.queueSortEvent(component, [headerAction.sortProperty], [headerAction.sortOrder]);
      }
      agent.eatEvent(domEvent);
      return false;
    }
  }
  if (this._hasNavBar) {
    this.__handleNavBarItemsClick(domEvent, target);
  }
  if (this._isLoadMore) {
    this.__handleLoadMoreItemsClick(domEvent, target);
  }
  return true;
};
AdfDhtmlTableBasePeer.prototype._delayedQueueSortEvent = function(params) {
  AdfTableUtils.queueSortEvent(params["table"], params["properties"], params["orders"]);
};
AdfDhtmlTableBasePeer.prototype.HandleComponentValueChange = function(componentEvent) {
  this._handleComponentEventForFilterCell(componentEvent);
};
AdfDhtmlTableBasePeer.prototype._handleComponentEventForFilterCell = function(componentEvent) {
  if (componentEvent.isCanceled()) {
    return;
  }
  var source = componentEvent.getSource();
  var peer = source.getPeer();
  peer.bind(source);
  var eventTarget = peer.getDomElement();
  if (this._isTargetCellFilter(eventTarget) && componentEvent.propagatesToServer()) {
    this._handleFilterCellAction();
  }
};
AdfDhtmlTableBasePeer.prototype._skipScrollRequest = function() {
  return AdfAgent.AGENT.getPlatform() == AdfAgent.WEBKIT_PLATFORM && this._scrollTopUpdating && (!this._isTouch || AdfAgent.guessOS() == "Windows") && this._currentScrollTop == this._getScrollTop();
};
AdfDhtmlTableBasePeer.prototype.HandleDomScroll = function(component, domEvent) {
  if (this._skipScrollRequest()) {
    return;
  }
  var scrollLeft = this.__getScrollLeft();
  var scrollTop;
  if (this._associatedPeer != null && AdfAgent.AGENT.getPlatform() == AdfAgent.GECKO_PLATFORM && component.getProperty("_afrSlaveId") != null) {
    scrollTop = -1;
  } else {
    scrollTop = this._getScrollTop();
  }
  this.scrollToPos(scrollLeft, scrollTop);
  this._associatedPeerScroll(-1, scrollTop);
};
AdfDhtmlTableBasePeer.prototype._associatedPeerScroll = function(scrollLeft, scrollTop, numberOfTries) {
  if (this._associatedPeer != null) {
    numberOfTries = !numberOfTries ? 1 : ++numberOfTries;
    if (!this._associatedPeer._virtInitialized) {
      if (numberOfTries < 4) {
        var self = this;
        setTimeout(function() {
          self._associatedPeerScroll(scrollLeft, scrollTop, numberOfTries);
        }, 0);
      } else {
        AdfLogger.LOGGER.severe("Tried 3 times w/ _associatedPeerScroll " + scrollLeft + " : " + scrollTop);
      }
    } else {
      this._associatedPeer.scrollToPos(scrollLeft, scrollTop);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._handleInnerTableScroll = function(evt) {
  if (!evt) {
    evt = AdfPage.PAGE.getDomWindow().event;
  }
  var div = AdfAgent.AGENT.getEventTarget(evt);
  if (this._touchMoveManager != null) {
    div = evt.target;
  }
  var scrollLeft = Math.round(AdfAgent.AGENT.getScrollLeft(div));
  this.scrollToPos(scrollLeft, -1);
};
AdfDhtmlTableBasePeer.prototype._handleDataBodyScroll = function() {
  var scrollLeft = -1;
  var dataBody;
  var first;
  if (this._skipScrollRequest()) {
    dataBody = this.GetDataBody();
    first = dataBody.firstChild;
    if (first) {
      var dataBodyLeft = AdfAgent.AGENT.getScrollLeft(dataBody);
      if (dataBodyLeft == this._currentScrollLeft) {
        return;
      }
      if (!this._hasFrozenColumn()) {
        scrollLeft = dataBodyLeft;
      }
    } else {
      return;
    }
  }
  if (this._handleDataCallbackBeingProcessed === true) {
    if (this._handleDataBodyScrollTimeout != null) {
      window.clearTimeout(this._handleDataBodyScrollTimeout);
      delete this._handleDataBodyScrollTimeout;
    }
    this._handleDataBodyScrollTimeout = window.setTimeout(this.createCallback(this._handleDataBodyScroll), 0);
    return;
  }
  if (!dataBody) {
    dataBody = this.GetDataBody();
  }
  if (!first) {
    first = dataBody.firstChild;
  }
  if (first) {
    var scrollTop = Math.round(dataBody.scrollTop + first.startPos - parseInt(this._hShiftDataBody) - parseInt(this._hShiftLoadMoreDataBody));
    if (!this._hasFrozenColumn() && -1 == scrollLeft) {
      scrollLeft = AdfAgent.AGENT.getScrollLeft(dataBody);
    }
    this.scrollToPos(scrollLeft, scrollTop);
    this._associatedPeerScroll(-1, scrollTop);
  }
};
AdfDhtmlTableBasePeer.prototype.__getScrollPos = function() {
  var scroller = this.GetScroller();
  if (scroller != null) {
    return {x:this.__getScrollLeft(), y:this._getScrollTop()};
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype.__restoreScrollerPositions = function(scrollLeft, scrollTop) {
  this._setScrollTop(scrollTop);
  this._setScrollLeft(scrollLeft);
};
AdfDhtmlTableBasePeer.prototype.scrollToPos = function(scrollLeft, scrollTop, skipUpdate, delay) {
  var component = this.getComponent();
  var vScrollState = AdfDhtmlTableBasePeer.NO_SCROLL;
  if (delay === undefined) {
    delay = true;
  }
  if (scrollTop != -1 && this._currentScrollTop != scrollTop) {
    delete this._cachedFirstVisibleRowKeyAndRow;
    if (!skipUpdate) {
      component.setProperty("scrollTop", scrollTop, true, AdfUIComponent.PROPAGATE_ALWAYS);
    }
    this._setScrollTop(scrollTop);
    vScrollState = this._handleVerticalScroll(scrollTop, delay);
    if (!this._isPaged) {
      var attrs = this.GetFirstVisibleRowKeyAndRow();
      if (attrs.rowKey != null) {
        component.setProperty("scrollTopRowKey", attrs.rowKey, true, AdfUIComponent.PROPAGATE_ALWAYS);
      }
    }
    var dataBody = this.GetDataBody();
    var blockList = dataBody.childNodes;
    for (var i = blockList.length - 1;i >= 0;i--) {
      var block = blockList[i];
      this._synchronizeRowHeights(block);
    }
  }
  if (scrollLeft != -1 && this._currentScrollLeft != scrollLeft) {
    if (!skipUpdate) {
      component.setProperty("scrollLeft", scrollLeft, true, AdfUIComponent.PROPAGATE_ALWAYS);
    }
    this._setScrollLeft(scrollLeft);
    this._handleHorizontalScrollDelayed(scrollLeft);
  }
  return vScrollState;
};
AdfDhtmlTableBasePeer.prototype._handleHorizontalScrollDelayed = function(scrollLeft) {
  var agent = AdfAgent.AGENT;
  var isIE = agent.getPlatform() == AdfAgent.IE_PLATFORM;
  var peer = this;
  if (isIE) {
    this._latestScrollLeft = scrollLeft;
    if (this._delayHScrolling) {
      return;
    } else {
      if (!window.requestAnimationFrame) {
        this._delayHScrolling = setTimeout(function() {
          peer._handleHorizontalScroll(peer._latestScrollLeft);
        }, 50);
      } else {
        this._delayHScrolling = window.requestAnimationFrame(function() {
          peer._handleHorizontalScroll(peer._latestScrollLeft);
        });
      }
    }
  } else {
    this._handleHorizontalScroll(scrollLeft);
  }
};
AdfDhtmlTableBasePeer.prototype.HandleDomKeyDown = function(component, domEvent) {
  var agent = AdfAgent.AGENT;
  var clientId = component.getClientId();
  var eventTarget = agent.getEventTarget(domEvent);
  var keyCode = domEvent.keyCode;
  switch(keyCode) {
    default:
      break;
    case AdfKeyStroke.ARROWUP_KEY:
    ;
    case AdfKeyStroke.ARROWDOWN_KEY:
    ;
    case AdfKeyStroke.ARROWRIGHT_KEY:
    ;
    case AdfKeyStroke.ARROWLEFT_KEY:
    ;
    case AdfKeyStroke.HOME_KEY:
    ;
    case AdfKeyStroke.END_KEY:
      var propagate = true;
      var isCellEditable = this._isTargetCellEditable(eventTarget);
      if (!isCellEditable) {
        if (keyCode == AdfKeyStroke.HOME_KEY || keyCode == AdfKeyStroke.END_KEY) {
          this._handleHomeEndKey(keyCode, domEvent);
        } else {
          this._handleArrow(keyCode, domEvent);
        }
        propagate = false;
      }
      if (!propagate) {
        agent.eatEvent(domEvent);
      }
      break;
    case AdfKeyStroke.ENTER_KEY:
      var th = this._getParentTH(domEvent);
      var nbarpginId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlTableBasePeer._NAVBAR_PAGE_INPUT);
      if (th && th.getAttribute("_afrFH") != null) {
        var queryEvent = new AdfQueryEvent(component);
        queryEvent.setClearAll(true);
        component.queueEvent(queryEvent);
        component.setSelectedRowKeys(null);
      } else {
        if (eventTarget.id == nbarpginId) {
          var rows = parseInt(this.GetRows());
          if (rows > 0) {
            var page = eventTarget.value;
            var targetRow = (page - 1) * rows;
            if (targetRow >= 0) {
              this._handlePageRowClick(targetRow, domEvent);
            } else {
              var laf = AdfPage.PAGE.getLookAndFeel();
              var summary = laf.getTranslatedString("af_table.MSG_NAVBAR_PAGE_INVALID");
              var detail = laf.getTranslatedString("af_table.MSG_NAVBAR_PAGE_INVALID_DETAIL");
              var message = new AdfFacesMessage(AdfFacesMessage.TYPE_ERROR, summary, detail);
              AdfPage.PAGE.clearMessages(clientId);
              if (AdfPage.PAGE.hasMessages(null)) {
                AdfPage.PAGE.clearMessages(null);
              }
              AdfPage.PAGE.addMessage(clientId, message);
              component.focus();
            }
          }
        }
      }
      break;
  }
};
AdfDhtmlTableBasePeer.prototype._handleHorizontalScroll = function(scrollLeft) {
  if (this._delayHScrolling) {
    delete this._delayHScrolling;
    if (!this.getDomElement()) {
      return;
    }
  }
  var agent = AdfAgent.AGENT;
  var dataBody = this.GetDataBody();
  if (!this._hasFrozenColumn()) {
    if (!this._headerless) {
      agent.setScrollLeft(this.__getColumnHeader(), scrollLeft);
    }
    if (!this._hasSingleScroller()) {
      agent.setScrollLeft(this._getColumnFooter(), scrollLeft);
    }
    agent.setScrollLeft(dataBody, scrollLeft);
  } else {
    if (!this._headerless) {
      AdfDhtmlTableBasePeer._scrollColumnHeader(this.__getColumnHeader(), scrollLeft);
    }
    if (!this._footerless) {
      AdfDhtmlTableBasePeer._scrollColumnFooter(this._getColumnFooter(), scrollLeft);
    }
    var blocks = dataBody.childNodes;
    for (var i = 0;i < blocks.length;i++) {
      this._positionInnerTable(blocks[i], scrollLeft);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._handleVerticalScroll = function(scrollTop, delay) {
  if (this._pendingFetch == AdfTableDataFetchEvent.EXPAND_SUBTYPE || this._pendingFetch == AdfTableDataFetchEvent.COLLAPSE_SUBTYPE) {
    return;
  }
  if (this._insertDeleteAnimationInEffect) {
    return;
  }
  var dataBody = this.GetDataBody();
  if (this._isPaged) {
    dataBody.scrollTop = scrollTop;
    return AdfDhtmlTableBasePeer.VIEWPORT_SATISFIED;
  } else {
    if (this._isLoadMore) {
      dataBody.scrollTop = scrollTop;
      this._checkLoadMore();
      return AdfDhtmlTableBasePeer.VIEWPORT_SATISFIED;
    }
  }
  var viewportHeight = dataBody.offsetHeight;
  var missing = this._fillViewPort(dataBody, viewportHeight, delay, true);
  if (this._selectionRequest != null) {
    if (missing == AdfDhtmlTableBasePeer.VIEWPORT_SATISFIED) {
      this._processSelectionRequest();
    } else {
      if (missing != AdfDhtmlTableBasePeer.MISSING_BEFORE && missing != AdfDhtmlTableBasePeer.MISSING_AFTER) {
        delete this._selectionRequest;
      }
    }
  }
  if (this._clickEditRequest != null && missing == AdfDhtmlTableBasePeer.VIEWPORT_SATISFIED) {
    this._processClickToEditActivateRequest();
  }
  return missing;
};
AdfDhtmlTableBasePeer.prototype._fillViewPort = function(dataBody, viewportHeight, delay, isScroll) {
  var missing = AdfDhtmlTableBasePeer.VIEWPORT_SATISFIED;
  if (this._isPaged) {
    this._hideStatus();
    AdfDhtmlTableBasePeer.SetCursor(dataBody, "");
    this.AdjustAutoHeight();
    return missing;
  } else {
    if (this._isLoadMore) {
      this._stretchTheColumns();
      missing = this._isViewportSatisfied(dataBody, viewportHeight);
      if (missing & AdfDhtmlTableBasePeer.MISSING_AFTER) {
        this._addBelow(dataBody, viewportHeight, delay, isScroll);
      } else {
        this._hideStatus();
        AdfDhtmlTableBasePeer.SetCursor(dataBody, "");
        this.AdjustAutoHeight();
      }
      return missing;
    }
  }
  if (this._knownRowCount > 0) {
    missing = this._isViewportSatisfied(dataBody, viewportHeight);
    if (missing == AdfDhtmlTableBasePeer.VIEWPORT_SATISFIED) {
      this._repositionBlocksForScroll(dataBody);
      this._hideStatus();
      AdfDhtmlTableBasePeer.SetCursor(dataBody, "");
      var actualCanvasHeight = this._canvasHeightLimited ? AdfDhtmlTableBasePeer._CSS_HEIGHT_LIMIT : this._canvasHeight;
      var scrollRange = actualCanvasHeight - viewportHeight;
      if (scrollRange > 0) {
        if (this._currentScrollTop < scrollRange / 2) {
          this._checkStart(dataBody);
        } else {
          this._checkEnd(dataBody);
        }
      }
      this.AdjustAutoHeight();
    } else {
      if (missing & AdfDhtmlTableBasePeer.MISSING_BEFORE) {
        this._addAbove(dataBody, viewportHeight, delay, isScroll);
      } else {
        if (missing & AdfDhtmlTableBasePeer.MISSING_AFTER) {
          if (this._isPrefetching) {
            this._repositionBlocksForScroll(dataBody);
          }
          this._addBelow(dataBody, viewportHeight, delay, isScroll);
        } else {
          this._handleLongJump(dataBody, viewportHeight, delay, isScroll);
        }
      }
    }
  }
  return missing;
};
AdfDhtmlTableBasePeer.prototype._isScrollerTop = function() {
  var scroller = null;
  if (this._hasSingleScroller() && !this._isPaged) {
    scroller = this.GetScroller();
  } else {
    scroller = this.GetScroller()[AdfDhtmlTableBasePeer._VSCROLLER];
  }
  var scrollerSpace = Math.ceil((this._averageRowHeight > 0 ? this._averageRowHeight : 1) / 2);
  var scrollerSpace = scrollerSpace > AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE ? AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE : scrollerSpace;
  return scroller.scrollTop < scrollerSpace ? true : false;
};
AdfDhtmlTableBasePeer.prototype._isScrollerBottom = function() {
  if (this.GetScroller() == null) {
    return false;
  }
  var scroller = null;
  if (this._hasSingleScroller() && !this._isPaged) {
    scroller = this.GetScroller();
  } else {
    scroller = this.GetScroller()[AdfDhtmlTableBasePeer._VSCROLLER];
  }
  if (scroller.scrollTop == 0) {
    return false;
  }
  var scrollerSpace = Math.ceil((this._averageRowHeight > 0 ? this._averageRowHeight : 1) / 2);
  var scrollerSpace = scrollerSpace > AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE ? AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE : scrollerSpace;
  if (AdfAgent.guessOS() == AdfAgent.ANDROID_OS) {
    scrollerSpace = Math.ceil(scroller.offsetHeight / 10);
  }
  var pos = scroller.scrollHeight - scroller.scrollTop;
  return pos - scroller.offsetHeight <= scrollerSpace ? true : false;
};
AdfDhtmlTableBasePeer.prototype._isScrollerRight = function() {
  if (this.GetScroller() == null) {
    return false;
  }
  var scroller = null;
  if (this._hasSingleScroller() && !this._isPaged) {
    scroller = this.GetScroller();
  } else {
    scroller = this.GetScroller()[AdfDhtmlTableBasePeer._HSCROLLER];
  }
  if (scroller.scrollLeft == 0) {
    return false;
  }
  var maxScrollLeft = scroller.scrollWidth - scroller.clientWidth;
  var scrollerSpace = Math.ceil((this._averageRowHeight > 0 ? this._averageRowHeight : 1) / 2);
  var scrollerSpace = scrollerSpace > AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE ? AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE : scrollerSpace;
  return maxScrollLeft - scroller.scrollLeft <= scrollerSpace ? true : false;
};
AdfDhtmlTableBasePeer.prototype._checkLoadMore = function() {
  if (this._isLoadMore) {
    var agent = AdfAgent.AGENT;
    var component = this.getComponent();
    var dataBody = this.GetDataBody();
    var dataBodyWidth = dataBody.style.width;
    this._loadMoreFullWidth = dataBodyWidth;
    this._loadMoreAdjWidth = this._loadMoreFullWidth;
    if (this._scrollbarBehavior == AdfDhtmlTableBasePeer._SCROLLBAR_BEHAVIOR_AUTOHIDE) {
      var container = this.getDomElement();
      var dataBodyWrapper = AdfAgent.AGENT.getElementById(AdfRichUIPeer.CreateSubId(container.id, AdfDhtmlTableBasePeer._DATAWRAPPER));
      this._loadMoreAdjWidth = dataBodyWrapper.style.width;
    }
    var blockList = dataBody.childNodes;
    var bottomLoadMore = this._getLoadMore(false);
    var topLoadMore = this._getLoadMore(true);
    var shouldDisplayBottomLoadMore = false;
    var shouldDisplayTopLoadMore = false;
    var scroller = this.GetScroller();
    if (scroller != null && !this._hasSingleScroller()) {
      scroller = scroller[AdfDhtmlTableBasePeer._VSCROLLER];
    }
    var isScrollbarVisible = this._getScrollbarWidth() > 0 ? true : false;
    var isScrollable = scroller == null ? false : scroller.scrollHeight > scroller.clientHeight ? true : false;
    if (this._isScrollerBottom() || !isScrollbarVisible && !isScrollable) {
      if (this._checkMoreHasRows(dataBody, false)) {
        shouldDisplayBottomLoadMore = true;
      }
    } else {
      if (this._isScrollerTop()) {
        if (this._checkMoreHasRows(dataBody, true)) {
          shouldDisplayTopLoadMore = true;
        }
      }
    }
    if (shouldDisplayBottomLoadMore) {
      if (this._isImplicitLoadMore && !this._implicitLoadMoreFetched) {
        this._loadMoreFetch(true);
        this._implicitLoadMoreFetched = true;
      } else {
        if (!this._isBottomLoadMoreDisplayed && !this._isImplicitLoadMore) {
          if ((isScrollbarVisible || isScrollable) && dataBody.scrollHeight + this._cachedFMHeight >= dataBody.clientHeight) {
            this._hShiftLoadMoreDataBody = -1 * this._cachedFMHeight + "px";
          } else {
            this._hShiftLoadMoreDataBody = "0px";
          }
          dataBody.style.top = parseInt(this._hShiftLoadMoreDataBody) + parseInt(this._hShiftDataBody) + "px";
          bottomLoadMore.style.top = parseInt(this._hShiftLoadMoreDataBody) + parseInt(this._hShiftDataBody) + "px";
          bottomLoadMore.style.display = "block";
          bottomLoadMore.style.width = this._loadMoreAdjWidth;
          this._isBottomLoadMoreDisplayed = true;
          if (!this._bottomLoadMoreHeight) {
            var bottomLoadMoreHeight = bottomLoadMore.offsetHeight;
            if (bottomLoadMoreHeight) {
              var textHeight = bottomLoadMore.childNodes[0].childNodes[0].offsetHeight;
              var topAdjust = Math.ceil((bottomLoadMoreHeight - textHeight) / 2);
              if (!this._isTouch) {
                bottomLoadMore.childNodes[0].style.top = topAdjust + "px";
              } else {
                var bottomLoadMoreLink = agent.getElementById(AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlTableBasePeer._LOAD_MORE_BOTTOM_LINK));
                bottomLoadMoreLink.style.paddingTop = topAdjust + "px";
                bottomLoadMoreLink.style.display = "inline-block";
              }
              this._bottomLoadMoreHeight = bottomLoadMoreHeight;
            }
          }
          if (!isScrollbarVisible && !isScrollable) {
            this._adjustCanvasHeight(this._bottomLoadMoreHeight, dataBody, false);
          }
        }
      }
      var numBlocks = blockList.length;
      var firstBlock = blockList[0];
      var lastBlock = blockList[numBlocks - 1];
      this._updateLoadMoreItemsRangeText(firstBlock.startRow, lastBlock.startRow + lastBlock.numRows, this._knownRowCount, false);
    } else {
      if (this._isImplicitLoadMore && this._implicitLoadMoreFetched) {
        this._implicitLoadMoreFetched = false;
      } else {
        if (this._isBottomLoadMoreDisplayed && !this._isImplicitLoadMore) {
          dataBody.style.top = "0px";
          bottomLoadMore.style.top = "0px";
          bottomLoadMore.style.display = "none";
          this._isBottomLoadMoreDisplayed = false;
          this._hShiftLoadMoreDataBody = "0px";
        }
      }
    }
    if (shouldDisplayTopLoadMore) {
      if (this._isImplicitLoadMore && !this._implicitLoadMoreFetched) {
        this._loadMoreFetch(false);
      } else {
        if (!this._isTopLoadMoreDisplayed && !this._isImplicitLoadMore) {
          topLoadMore.style.display = "block";
          topLoadMore.style.width = this._loadMoreAdjWidth;
          this._isTopLoadMoreDisplayed = true;
          if (!this._topLoadMoreHeight) {
            var topLoadMoreHeight = topLoadMore.offsetHeight;
            if (topLoadMoreHeight) {
              var textHeight = topLoadMore.childNodes[0].childNodes[0].offsetHeight;
              var topAdjust = Math.ceil((topLoadMoreHeight - textHeight) / 2);
              if (!this._isTouch) {
                topLoadMore.childNodes[0].style.top = topAdjust + "px";
              } else {
                var topLoadMoreLink = agent.getElementById(AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlTableBasePeer._LOAD_MORE_TOP_LINK));
                topLoadMoreLink.style.paddingTop = topAdjust + "px";
                topLoadMoreLink.style.display = "inline-block";
              }
              this._topLoadMoreHeight = topLoadMoreHeight;
            }
          }
        }
      }
      var numBlocks = blockList.length;
      var firstBlock = blockList[0];
      var lastBlock = blockList[numBlocks - 1];
      this._updateLoadMoreItemsRangeText(firstBlock.startRow, lastBlock.startRow + lastBlock.numRows, this._knownRowCount, true);
    } else {
      if (this._isImplicitLoadMore && this._implicitLoadMoreFetched) {
        this._implicitLoadMoreFetched = false;
      } else {
        if (this._isTopLoadMoreDisplayed && !this._isImplicitLoadMore) {
          topLoadMore.style.display = "none";
          this._isTopLoadMoreDisplayed = false;
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._checkMoreHasRows = function(dataBody, top) {
  var blockList = dataBody.childNodes;
  var numBlocks = blockList.length;
  var numRows = 0;
  var hasMoreRows = false;
  for (var i = 0;i < numBlocks;i++) {
    if (blockList[i].rows != null) {
      numRows += blockList[i].rows.length;
    }
  }
  if (numRows > 0) {
    if (!this._allRowsAvailableOnClient(blockList, numBlocks)) {
      var firstBlock = blockList[0];
      var lastBlock = blockList[numBlocks - 1];
      if (top && firstBlock.startRow > 0) {
        hasMoreRows = true;
      } else {
        if (!top && (lastBlock.startRow + lastBlock.numRows < this.GetKnownRowCount() || this.GetRowCount() < 0)) {
          hasMoreRows = true;
        }
      }
    }
  }
  return hasMoreRows;
};
AdfDhtmlTableBasePeer.prototype._checkScrollbarHidingAffordance = function() {
  var dataBody = this.GetDataBody();
  if (this._isScrollerBottom()) {
    if (this._getScrollWidth() > this._getScrollerOffsetWidth()) {
      var scrollerHeight = this._getScrollerOffsetHeight() - this._getScrollerClientHeight();
      this._hShiftDataBody = -1 * scrollerHeight - this._cachedCFHeight + "px";
      if (this._isBottomLoadMoreDisplayed) {
        dataBody.style.top = parseInt(this._hShiftDataBody) + parseInt(this._hShiftLoadMoreDataBody) + "px";
      } else {
        dataBody.style.top = this._hShiftDataBody;
      }
    }
  } else {
    this._hShiftDataBody = "0px";
    dataBody.style.top = "0px";
  }
};
AdfDhtmlTableBasePeer.prototype._getPrefetchMarginHeight = function() {
  return this.getComponent().getFetchSize() / 2 * this._averageRowHeight;
};
AdfDhtmlTableBasePeer.prototype._needPrefetch = function(lastBottom, viewportHeight, rowsMissing) {
  if (this._isScrollPrefetch && this._currentScrollTop > this._averageRowHeight) {
    if (this._rowCount == -1 || this._rowCount >= 0 && rowsMissing > 0) {
      if (lastBottom > viewportHeight) {
        var bottomThreshold = viewportHeight + this._getPrefetchMarginHeight();
        if (lastBottom < bottomThreshold) {
          return true;
        }
      }
    }
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype._isViewportSatisfied = function(dataBody, viewportHeight) {
  var blockList = dataBody.childNodes;
  var numBlocks = blockList.length;
  var missing = AdfDhtmlTableBasePeer.NO_BLOCKS;
  var scrollTop = this._currentScrollTop;
  var numRows = 0;
  this._isPrefetching = false;
  for (var i = 0;i < numBlocks;i++) {
    numRows += blockList[i].rows.length;
  }
  if (numRows > 0) {
    missing = AdfDhtmlTableBasePeer.VIEWPORT_SATISFIED;
    if (!this._allRowsAvailableOnClient(blockList, numBlocks)) {
      var firstBlock = blockList[0];
      var lastBlock = blockList[numBlocks - 1];
      var actualCanvasHeight = this._canvasHeightLimited ? AdfDhtmlTableBasePeer._CSS_HEIGHT_LIMIT : this._canvasHeight;
      var firstTop = firstBlock.startPos - scrollTop;
      var lastBottom = lastBlock.startPos + lastBlock.cachedHeight - scrollTop;
      if (firstTop > 0 || scrollTop == 0 && firstBlock.startRow > 0) {
        missing |= AdfDhtmlTableBasePeer.MISSING_BEFORE;
      }
      if (this._isLoadMore) {
        if (lastBottom < viewportHeight) {
          missing |= AdfDhtmlTableBasePeer.MISSING_AFTER;
        } else {
          if (this.isScrollPrefetch && this._needPrefetch(lastBottom, viewPortHeight, this.GetKnownRowCount() - lastBlock.numRows - lastBlock.startRow)) {
            missing |= AdfDhtmlTableBasePeer.MISSING_AFTER;
            this._isPrefetching = true;
          }
        }
      } else {
        if (lastBottom < viewportHeight && actualCanvasHeight >= viewportHeight || scrollTop >= actualCanvasHeight - viewportHeight && lastBlock.startRow + lastBlock.numRows < this.GetKnownRowCount()) {
          missing |= AdfDhtmlTableBasePeer.MISSING_AFTER;
        } else {
          if (this._isScrollPrefetch && this._needPrefetch(lastBottom, viewportHeight, this.GetKnownRowCount() - lastBlock.numRows - lastBlock.startRow)) {
            missing |= AdfDhtmlTableBasePeer.MISSING_AFTER;
            this._isPrefetching = true;
          }
        }
        if (missing != AdfDhtmlTableBasePeer.VIEWPORT_SATISFIED && (firstTop > viewportHeight || lastBottom < 0)) {
          missing = AdfDhtmlTableBasePeer.NO_BLOCKS;
          this._isPrefetching = false;
        }
      }
    }
  }
  return missing;
};
AdfDhtmlTableBasePeer.prototype._addAbove = function(dataBody, viewportHeight, delay, isScroll) {
  var blockList = dataBody.childNodes;
  var numBlocks = blockList.length;
  var firstBlock = blockList[0];
  if (firstBlock.startRow == 0) {
    var pos = 0;
    for (var i = 0;i < numBlocks;i++) {
      var block = blockList[i];
      var height = block.cachedHeight;
      block.startPos = pos;
      pos += height;
    }
    this._setScrollTop(0);
    this._fillViewPort(dataBody, viewportHeight, delay);
  } else {
    var index = firstBlock.startRow;
    var key = this._getBlockFirstRowKey(firstBlock);
    this._startFetch(AdfTableDataFetchEvent.BEFORE_KEY_SUBTYPE, index, key, delay, !isScroll);
  }
};
AdfDhtmlTableBasePeer.prototype._addBelow = function(dataBody, viewportHeight, delay, isScroll) {
  var blockList = dataBody.childNodes;
  var numBlocks = blockList.length;
  var lastBlock = blockList[numBlocks - 1];
  var newStart = lastBlock.startRow + lastBlock.numRows;
  var rowCount = this.GetRowCount();
  if (rowCount > 0 && newStart >= rowCount) {
    var new_scroll = this._canvasHeight - viewportHeight;
    var pos = this._canvasHeight;
    var updatedPos = false;
    for (var i = numBlocks - 1;i >= 0;i--) {
      var block = blockList[i];
      var height = block.cachedHeight;
      pos -= height;
      if (block.startPos != pos) {
        updatedPos = true;
        block.startPos = pos;
      }
    }
    if (this._currentScrollTop != new_scroll || updatedPos) {
      this._setScrollTop(new_scroll);
      this._fillViewPort(dataBody, viewportHeight, delay);
    }
  } else {
    var index = newStart - 1;
    var key = this._getBlockLastRowKey(lastBlock);
    if (this._isPrefetching && delay) {
      var actualCanvasHeight = this._canvasHeightLimited ? AdfDhtmlTableBasePeer._CSS_HEIGHT_LIMIT : this._canvasHeight;
      delay = this._currentScrollTop + viewportHeight + this._getPrefetchMarginHeight() < actualCanvasHeight;
    }
    this._startFetch(AdfTableDataFetchEvent.AFTER_KEY_SUBTYPE, index, key, delay, !isScroll);
  }
};
AdfDhtmlTableBasePeer.prototype._handleLongJump = function(dataBody, viewportHeight, delay, isScroll) {
  var where;
  var index;
  var subtype;
  var start;
  var end;
  var size = this.getComponent().getFetchSize();
  var scrollTop = this._currentScrollTop;
  var totalRows = this.GetKnownRowCount();
  var laf = AdfPage.PAGE.getLookAndFeel();
  var actualCanvasHeight = this._canvasHeightLimited ? AdfDhtmlTableBasePeer._CSS_HEIGHT_LIMIT : this._canvasHeight;
  var extra = this.GetRowCount() == -1 || this._canvasHeightLimited ? AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE : 0;
  if (scrollTop >= actualCanvasHeight - extra - viewportHeight) {
    subtype = AdfTableDataFetchEvent.UP_TO_INDEX_SUBTYPE;
    index = totalRows - 1;
    where = laf.getTranslatedString("af_table.LABEL_END");
    if (this.GetRowCount() == -1) {
      where = laf.getTranslatedString("af_table.LABEL_ROW", index + 1);
    }
    end = index;
    start = end - size + 1;
  } else {
    subtype = AdfTableDataFetchEvent.FROM_INDEX_SUBTYPE;
    if (scrollTop == 0) {
      where = laf.getTranslatedString("af_table.LABEL_START");
      index = 0;
    } else {
      index = Math.round(scrollTop / this._averageRowHeight);
      where = laf.getTranslatedString("af_table.LABEL_ROW", index + 1);
      AdfAssert.assert(index < totalRows);
    }
    start = index;
    end = index + size - 1;
  }
  var blocks = dataBody.childNodes;
  if (blocks.length > 0) {
    var first = blocks[0];
    var last = blocks[blocks.length - 1];
    var oldStart = first.startRow;
    var oldEnd = last.startRow + last.numRows;
    if (start >= oldStart && start < oldEnd) {
      this._addBelow(dataBody, viewportHeight, delay, isScroll);
      return;
    } else {
      if (end >= oldStart && end < oldEnd) {
        this._addAbove(dataBody, viewportHeight, delay, isScroll);
        return;
      }
    }
  }
  if (delay) {
    this.DisplayStatus(laf.getTranslatedString("af_table.LABEL_GOING_TO", where));
  }
  this._startFetch(subtype, index, null, delay, !isScroll);
};
AdfDhtmlTableBasePeer.prototype._deleteOffscreenBlocks = function(dataBody, viewportHeight, newlyAdded) {
  var component = this.getComponent();
  var peer = this;
  var blockList = dataBody.childNodes;
  var numBlocks = blockList.length;
  var totalRowsOnClient;
  var maxClientRows = this._isTouch ? this._maxCachedRowsForTouch : component.getMaxClientRows ? component.getMaxClientRows() : -1;
  if (numBlocks > 0) {
    var lastBlock = blockList[numBlocks - 1];
    totalRowsOnClient = lastBlock.startRow - blockList[0].startRow + lastBlock.numRows;
    if (totalRowsOnClient <= maxClientRows) {
      return;
    }
  }
  var newlyAddedTop = true;
  if (blockList[0] != newlyAdded) {
    newlyAddedTop = false;
  }
  var deleteBlocksFunction = function(i, totalRowsOnClient) {
    var block = blockList[i];
    if (block == newlyAdded) {
      return totalRowsOnClient;
    }
    var top = block.startPos - scrollTop;
    var bottom = top + block.cachedHeight;
    if (bottom < 0 || top > viewportHeight) {
      if (peer._isLoadMore) {
        var startPos = block.startPos;
        if (startPos == 0 && i + 1 < blockList.length) {
          startPos = blockList[i + 1].startPos;
        }
        for (var j = i + 1;j < blockList.length;j++) {
          blockList[j].startPos -= startPos;
        }
        var canvasDelta = -1 * block.cachedHeight;
        peer._adjustCanvasHeight(canvasDelta, dataBody);
        if (peer._currentScrollTop - startPos > 0) {
          peer._setScrollTop(peer._currentScrollTop - startPos);
        }
      }
      var blockRows = block.numRows;
      peer._unregisterNode(block);
      dataBody.removeChild(block);
      totalRowsOnClient -= blockRows;
      if (totalRowsOnClient <= maxClientRows) {
        return totalRowsOnClient;
      }
      if (bottom < 0 && i > 0) {
        return totalRowsOnClient;
      }
    }
    return totalRowsOnClient;
  };
  var scrollTop = this._currentScrollTop;
  if (newlyAddedTop) {
    for (var i = numBlocks - 1;i >= 0;i--) {
      if (totalRowsOnClient <= maxClientRows) {
        break;
      }
      totalRowsOnClient = deleteBlocksFunction(i, totalRowsOnClient);
    }
  } else {
    for (var i = 0;i < numBlocks;i++) {
      if (i > blockList.length - 1 || totalRowsOnClient <= maxClientRows) {
        break;
      }
      totalRowsOnClient = deleteBlocksFunction(i, totalRowsOnClient);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._unregisterNode = function(node) {
  AdfPage.PAGE.removeComponentsInSubtree(node);
  AdfAgent.AGENT.elementsRemoved(node);
};
AdfDhtmlTableBasePeer.prototype._repositionBlocksForScroll = function(dataBody) {
  var first = dataBody.firstChild;
  var scrollTop = this._currentScrollTop;
  if (first) {
    dataBody.scrollTop = scrollTop - first.startPos;
  }
  if ((!this._isTouch || AdfAgent.guessOS() == "Windows") && AdfAgent.AGENT.getPlatform() == AdfAgent.WEBKIT_PLATFORM) {
    this._scrollTopUpdating = true;
    setTimeout(AdfDhtmlTableBasePeer._resetScrollTopUpdating, 100, this);
  }
};
AdfDhtmlTableBasePeer._resetScrollTopUpdating = function(self) {
  self._scrollTopUpdating = false;
};
AdfDhtmlTableBasePeer.prototype._undoScroll = function() {
  var dataBody = this.GetDataBody();
  var first = dataBody.firstChild;
  if (first) {
    var oldScrollTop = first.startPos + dataBody.scrollTop;
    this._setScrollTop(oldScrollTop);
  }
};
AdfDhtmlTableBasePeer.prototype._restoreSavedDisclosureState = function() {
  this.getComponent().setProperty("disclosedRowKeys", this._savedDisclosedState, false, AdfUIComponent.PROPAGATE_NEVER);
  this._savedDisclosedState = undefined;
};
AdfDhtmlTableBasePeer.prototype._queueFetchEvent = function(renderOnly, subtype, index, key) {
  var id = this._fetchId++;
  var component = this.getComponent();
  var event = new AdfTableDataFetchEvent(component, id, subtype, index, key);
  event.setPartial(true);
  event.setRenderOnly(renderOnly);
  var canceled = false;
  if (renderOnly) {
    AdfPage.PAGE.queueEventToServer(event);
  } else {
    component.queueEvent(event);
    canceled = event.isCanceled();
  }
  if (!canceled) {
    this._pendingFetch = subtype;
    this._pendingId = id;
    this._fetchIndex = index;
    this._fetchKey = key;
    this._pendingRenderOnly = renderOnly;
  }
  return canceled ? null : event;
};
AdfDhtmlTableBasePeer.prototype._checkViewportSize = function(dataBody) {
  var blocks = dataBody.childNodes;
  if (blocks.length == 0) {
    return;
  }
  var firstBlock = blocks[0];
  if (firstBlock.numRows === undefined) {
    return;
  }
  var rowHeight = firstBlock.offsetHeight / firstBlock.numRows;
  var viewportSize = Math.round(dataBody.clientHeight / rowHeight + .5);
  var component = this.getComponent();
  if (this._isSyncRows && this.isInteger(viewportSize) && viewportSize >= 0) {
    component.setProperty("viewportSize", viewportSize, false, AdfUIComponent.PROPAGATE_ALWAYS);
  }
};
AdfDhtmlTableBasePeer.prototype._startFetch = function(subtype, index, key, delay, renderOnly) {
  if (subtype == this._pendingFetch && index == this._fetchIndex && key == this._fetchKey) {
    return;
  }
  if (delay) {
    var callback = function anonymous() {
      var c = arguments.callee;
      c._self._delayedNavigate(c._sTop, c._subtype, c._index, c._key, c._renderOnly);
    };
    callback["_sTop"] = this._currentScrollTop;
    callback["_subtype"] = subtype;
    callback["_index"] = index;
    callback["_key"] = key;
    callback["_renderOnly"] = renderOnly;
    callback["_self"] = this;
    setTimeout(callback, 300);
    this.CancelPendingFetch();
  } else {
    var event = this._queueFetchEvent(renderOnly, subtype, index, key);
    if (!event) {
      this._undoScroll();
      return;
    }
    if (!this._isPrefetching) {
      var statusText = AdfPage.PAGE.getLookAndFeel().getTranslatedString("af_table.LABEL_FETCHING");
      this.DisplayStatus(statusText);
      AdfDhtmlTableBasePeer.SetCursor(this.GetDataBody(), "wait");
    }
    if (this._pruneKeyCache) {
      event.setClientTokens(this._collectClientTokens(this._pruneKeyCache));
      this._pruneKeyCache = null;
    }
  }
};
AdfDhtmlTableBasePeer.prototype["_delayedNavigate"] = function(scrollTop, subtype, index, key, renderOnly) {
  if (this._currentScrollTop == scrollTop) {
    this._startFetch(subtype, index, key, false, renderOnly);
  }
};
AdfDhtmlTableBasePeer.prototype.CancelPendingFetch = function() {
  this._pendingFetch = undefined;
  this._fetchIndex = undefined;
  this._fetchKey = undefined;
  this._pendingId = undefined;
  this._pendingRenderOnly = undefined;
};
AdfDhtmlTableBasePeer.prototype.IsFetchPending = function() {
  return this._pendingFetch != undefined;
};
AdfDhtmlTableBasePeer.prototype.isDisclosureFetchPending = function() {
  return this._pendingFetch == AdfTableDataFetchEvent.EXPAND_SUBTYPE || this._pendingFetch == AdfTableDataFetchEvent.COLLAPSE_SUBTYPE;
};
AdfDhtmlTableBasePeer.prototype._rowIndexToBlock = function(rowIndex) {
  var dataBody = this.GetDataBody();
  var blockList = dataBody.childNodes;
  for (var i = 0;i < blockList.length;i++) {
    var block = blockList[i];
    var startRow = block.startRow;
    if (rowIndex >= startRow && rowIndex <= startRow + block.numRows) {
      return block;
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._splitBlock = function(block, splitIndex) {
  AdfAssert.assert(splitIndex >= 0);
  AdfAssert.assert(splitIndex < block.numRows);
  var nextBlock = block.cloneNode(false);
  nextBlock.numRows = block.numRows - splitIndex;
  var blockTBody = AdfDomUtils.getFirstDescendentElement(block, "TBODY");
  AdfAssert.assert(blockTBody != null, "Illegal State: data block with no tbody");
  var nextBlockTBody = blockTBody.cloneNode(false);
  var blockRows = block.rows;
  for (var rowIndex = block.numRows - 1;rowIndex >= splitIndex;rowIndex--) {
    var row = blockRows[rowIndex];
    blockTBody.removeChild(row);
    nextBlockTBody.insertBefore(row, nextBlockTBody.firstChild);
  }
  var agent = AdfAgent.AGENT;
  if (this._processColGroup()) {
    var colgroup = AdfDomUtils.getFirstDescendentElement(block, "COLGROUP");
    if (colgroup) {
      nextBlock.appendChild(colgroup.cloneNode(true));
    }
  }
  nextBlock.appendChild(nextBlockTBody);
  var nextBlockCells = nextBlock.rows[0].cells;
  var blockCells = blockRows[0].cells;
  var cellCount = nextBlockCells.length;
  for (var cellIndex = 0;cellIndex < cellCount;cellIndex++) {
    nextBlockCells[cellIndex].style.width = blockCells[cellIndex].style.width;
  }
  agent.elementsAdded(nextBlock);
  block.numRows = splitIndex;
  block.cachedHeight = block.offsetHeight;
  return nextBlock;
};
AdfDhtmlTableBasePeer.prototype._truncateBlock = function(block, deleteIndex) {
  AdfAssert.assert(deleteIndex >= 0);
  AdfAssert.assert(deleteIndex < block.numRows);
  var rows = block.rows;
  for (var rowIndex = block.numRows - 1;rowIndex >= deleteIndex;rowIndex--) {
    var tr = rows[rowIndex];
    this._unregisterNode(tr);
    block.deleteRow(rowIndex);
  }
  block.numRows = deleteIndex;
  block.cachedHeight = block.offsetHeight;
};
AdfDhtmlTableBasePeer.prototype._insertBlockDom = function(dataBody, destBlock, newBlock, startIndex, size, totalInserted) {
  var nextBlock = null;
  var beforeBlock;
  var relativeStartIndex = startIndex - destBlock.startRow;
  if (relativeStartIndex == 0) {
    beforeBlock = destBlock;
  } else {
    if (relativeStartIndex < destBlock.numRows) {
      if (size == totalInserted) {
        nextBlock = this._splitBlock(destBlock, relativeStartIndex);
      } else {
        this._truncateBlock(destBlock, relativeStartIndex);
      }
    }
    beforeBlock = destBlock.nextSibling;
  }
  dataBody.insertBefore(newBlock, beforeBlock);
  return nextBlock;
};
AdfDhtmlTableBasePeer.prototype.InsertBlock = function(newBlock, startIndex, size, totalInserted, remainingBlocks) {
  this._initNewBlock(newBlock, startIndex, size);
  var dataBody = this.GetDataBody();
  var viewportHeight = dataBody.offsetHeight;
  this._sizeBlockForFrozenColumns(newBlock, dataBody.offsetWidth);
  this._registerInnerScrollCallback(newBlock);
  this._stretchLastBlockColumn(newBlock);
  var destBlock = this._rowIndexToBlock(startIndex);
  AdfAssert.assert(destBlock);
  var nextBlock = this._insertBlockDom(dataBody, destBlock, newBlock, startIndex, size, totalInserted);
  this.SetNewBlockScrollLeft(newBlock);
  newBlock.cachedHeight = newBlock.offsetHeight;
  var before = startIndex == destBlock.startRow;
  if (before) {
    newBlock.startPos = destBlock.startPos;
  } else {
    newBlock.startPos = destBlock.startPos + destBlock.cachedHeight;
  }
  this._synchronizeRowHeights(newBlock);
  if (nextBlock) {
    dataBody.insertBefore(nextBlock, newBlock.nextSibling);
    nextBlock.cachedHeight = nextBlock.offsetHeight;
    this.SetNewBlockScrollLeft(nextBlock);
  }
  var canvasDelta;
  if (size == totalInserted) {
    var previous = newBlock;
    var current;
    while (current = previous.nextSibling) {
      current.startRow = previous.startRow + previous.numRows;
      current.startPos = previous.startPos + previous.cachedHeight;
      previous = current;
    }
    canvasDelta = newBlock.cachedHeight;
  } else {
    var lastChild = dataBody.lastChild;
    while (newBlock != lastChild) {
      this._unregisterNode(lastChild);
      dataBody.removeChild(lastChild);
      lastChild = dataBody.lastChild;
    }
    canvasDelta = this._averageRowHeight * totalInserted;
  }
  this._knownRowCount += totalInserted;
  if (this._rowCount != -1) {
    this._rowCount += totalInserted;
  }
  this._adjustCanvasHeight(canvasDelta, dataBody);
  if (remainingBlocks == 0) {
    if (!this.isHeightAutoSized()) {
      this._deleteOffscreenBlocks(dataBody, viewportHeight, newBlock);
    }
    this._stretchTheColumns();
    this._checkForScrollableLastBlockInViewport(dataBody);
    this.BlockInserted(newBlock, startIndex, size);
  }
};
AdfDhtmlTableBasePeer.prototype._initNewBlock = function(node, start, size) {
  node.style.position = "relative";
  node.startRow = start;
  node.numRows = size;
};
AdfDhtmlTableBasePeer.prototype.SetNewBlockScrollLeft = function(node) {
  var scrollLeft = this._currentScrollLeft;
  if (this._hasFrozenColumn() && scrollLeft != 0) {
    this._positionInnerTable(node, scrollLeft);
  }
};
AdfDhtmlTableBasePeer.prototype._adjustCanvasHeight = function(canvasDelta, dataBody, checkScrollbars, adjustScrollPos) {
  if (canvasDelta != 0) {
    var oldHeight = this._canvasHeight;
    if (this._isPaged || this._isLoadMore) {
      this._canvasHeight += canvasDelta;
      this._setFakeCanvasHeight(this._canvasHeight);
    } else {
      var newHeight = this._canvasHeight + canvasDelta;
      var extra = this.GetRowCount() == -1 ? AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE : 0;
      var knownCount = this.GetKnownRowCount();
      this._averageRowHeight = Math.round((newHeight - extra) / knownCount);
      this._canvasHeight = this._averageRowHeight * knownCount + extra;
      this._setFakeCanvasHeight(this._canvasHeight);
    }
    if (adjustScrollPos) {
      var relFactor = this._canvasHeight / oldHeight;
      var first = dataBody.firstChild;
      if (first) {
        var oldStart = first.startPos;
        first.startPos = Math.round(first.startPos * relFactor);
        var startChange = first.startPos - oldStart;
        var next = first.nextSibling;
        while (next) {
          next.startPos += startChange;
          next = next.nextSibling;
        }
        this._setScrollTop(Math.round(this._currentScrollTop * relFactor));
      }
    }
    this._currentScrollTop = this._getScrollTop();
  }
  if (canvasDelta != 0 || checkScrollbars) {
    var outer = this.getDomElement();
    this.SizeDataBody(dataBody, outer.clientWidth, outer.clientHeight);
  }
};
AdfDhtmlTableBasePeer.prototype._checkForScrollableLastBlockInViewport = function(dataBody) {
  var node = dataBody.lastChild;
  var startPos = node.startPos;
  var previousNode = node.previousSibling;
  if (previousNode != null && previousNode.cachedHeight != previousNode.offsetHeight) {
    startPos = previousNode.startPos + previousNode.offsetHeight;
    previousNode.cachedHeight = previousNode.offsetHeight;
    node.startPos = startPos;
  }
  if (node != null && this.GetRowCount() == node.startRow + node.numRows && startPos + node.cachedHeight > this._canvasHeight) {
    this._canvasHeight = startPos + node.cachedHeight;
    this._setFakeCanvasHeight(this._canvasHeight);
    var outer = this.getDomElement();
    this.SizeDataBody(dataBody, outer.clientWidth, outer.clientHeight);
  }
};
AdfDhtmlTableBasePeer.prototype.SizeDataBody = function(dataBody, clientWidth, clientHeight) {
  var agent = AdfAgent.AGENT;
  var scrollbarWidth = this._getScrollbarWidth();
  var scrollbarHeight = this._getScrollbarHeight();
  var dataBodyWidth = Math.max(0, clientWidth - scrollbarWidth);
  dataBody.style.width = dataBodyWidth + "px";
  var dataBodyHeight = Math.max(0, clientHeight - this._cachedCHHeight - this._cachedCFHeight - this._cachedNBHeight - scrollbarHeight);
  this._checkLoadMore();
  dataBody.style.height = dataBodyHeight + "px";
  if (!this._headerless) {
    var chStyle = this.__getColumnHeader().style;
    chStyle.width = dataBody.style.width;
    scrollbarHeight > 0 ? chStyle.borderRightWidth = "" : chStyle.borderRightWidth = "0px";
  }
  if (!this._footerless) {
    var cfStyle = this._getColumnFooter().style;
    cfStyle.width = dataBody.style.width;
    scrollbarHeight > 0 ? cfStyle.borderRightWidth = "" : cfStyle.borderRightWidth = "0px";
  }
  if (!this.IsEmpty && this._hasFrozenColumn()) {
    this._sizeRegionsForFrozenColumns(dataBody, dataBodyWidth);
  }
  this._dataBodyHeight = dataBodyHeight;
  this._checkViewportSize(dataBody);
  if (this._scrollbarBehavior == AdfDhtmlTableBasePeer._SCROLLBAR_BEHAVIOR_AUTOHIDE) {
    var container = this.getDomElement();
    var dataBodyWrapper = agent.getElementById(AdfRichUIPeer.CreateSubId(container.id, AdfDhtmlTableBasePeer._DATAWRAPPER));
    if (dataBodyWrapper) {
      var scrollerBarWidth = 0;
      var scrollerBarHeight = 0;
      if (this._hasSingleScroller() && !this._isPaged) {
        vscroller = this.GetScroller();
        hscroller = this.GetScroller();
      } else {
        vscroller = this.GetScroller()[AdfDhtmlTableBasePeer._VSCROLLER];
        hscroller = this.GetScroller()[AdfDhtmlTableBasePeer._HSCROLLER];
      }
      if (hscroller != null) {
        scrollerBarHeight = hscroller.offsetHeight - hscroller.clientHeight;
      }
      if (vscroller != null) {
        scrollerBarWidth = vscroller.offsetWidth - vscroller.clientWidth;
      }
      if (this._scrollbarHidden) {
        if (scrollerBarWidth > 0) {
          container.style.borderRight = "0px";
        } else {
          container.style.borderRight = "";
        }
        if (scrollerBarHeight > 0 && this._cachedNBHeight == 0) {
          container.style.borderBottom = "0px";
        } else {
          container.style.borderBottom = "";
        }
        if (!this.IsEmpty) {
          container.style.backgroundColor = "transparent";
        } else {
          container.style.backgroundColor = "";
        }
        scrollerBarWidth = 0;
        scrollerBarHeight = 0;
      }
      var dataBodyWrapperStyle = dataBodyWrapper.style;
      dataBodyWrapperStyle.height = container.offsetHeight - this._cachedCHHeight - this._cachedCFHeight - this._cachedNBHeight - scrollerBarHeight + "px";
      dataBodyWrapperStyle.width = container.offsetWidth - scrollerBarWidth + "px";
    }
  }
  return dataBodyHeight;
};
AdfDhtmlTableBasePeer.prototype._getScrollbarWidth = function() {
  if (this.IsEmpty) {
    return 0;
  }
  var scrollbarWidth = 0;
  var scroller = this.GetScroller();
  if (this._hasSingleScroller() && !this._isPaged) {
    if (scroller.clientWidth > 0) {
      scrollbarWidth = scroller.offsetWidth - scroller.clientWidth;
    }
  } else {
    var vScroller = scroller[AdfDhtmlTableBasePeer._VSCROLLER];
    if (vScroller.clientWidth > 0) {
      scrollbarWidth = vScroller.offsetWidth - vScroller.clientWidth;
    }
  }
  return scrollbarWidth;
};
AdfDhtmlTableBasePeer.prototype._getScrollbarHeight = function() {
  var scrollbarHeight;
  var isGecko = AdfAgent.AGENT.getPlatform() == AdfAgent.GECKO_PLATFORM;
  if (!this.IsEmpty) {
    var scroller = this.GetScroller();
    if (this._hasSingleScroller() && !this._isPaged) {
      var scrollerComputedStyleHeight = isGecko ? scroller.clientHeight : parseInt(window.getComputedStyle(scroller).height);
      scrollbarHeight = scrollerComputedStyleHeight > 3 ? scroller.offsetHeight - scrollerComputedStyleHeight : 0;
    } else {
      var hScroller = scroller[AdfDhtmlTableBasePeer._HSCROLLER];
      var hScrollerComputedStyleHeight = isGecko ? hScroller.clientHeight : parseInt(window.getComputedStyle(hScroller).height);
      scrollbarHeight = hScrollerComputedStyleHeight > 3 ? hScroller.offsetHeight - hScrollerComputedStyleHeight : 0;
    }
  } else {
    var domElement = this.getDomElement();
    var domElementComputedStyleHeight = isGecko ? domElement.clientHeight : parseInt(window.getComputedStyle(domElement).height);
    scrollbarHeight = domElement.offsetHeight - domElementComputedStyleHeight;
  }
  return scrollbarHeight < AdfDhtmlTableBasePeer._SCROLLBAR_HEIGHT_TOLERANCE ? 0 : scrollbarHeight;
};
AdfDhtmlTableBasePeer.prototype._handleDataCallback = function(node, pendingFetch, pendingRenderOnly, remainingBlocks) {
  var agent = AdfAgent.AGENT;
  var start = agent.getIntAttribute(node, "_startRow", 0);
  var size = AdfDhtmlTableBasePeer._getBlockRowCount(node);
  if (pendingFetch == AdfTableDataFetchEvent.EXPAND_SUBTYPE) {
    return this.HandleExpand(node, size, remainingBlocks);
  }
  if (pendingFetch == AdfTableDataFetchEvent.COLLAPSE_SUBTYPE) {
    return this.HandleCollapse(node, start, remainingBlocks);
  }
  if (pendingFetch == AdfTableDataFetchEvent.CLICK_EDIT_ACTIVE_ROW) {
    return this.HandleClickToEditActiveRow(node, size, remainingBlocks);
  }
  var dataBody = this.GetDataBody();
  var viewportHeight = dataBody.offsetHeight;
  var blockList = dataBody.childNodes;
  var numBlocks = blockList.length;
  var scrollTop = this._currentScrollTop;
  this._initNewBlock(node, start, size);
  if (size > 0) {
    this._sizeBlockForFrozenColumns(node, dataBody.offsetWidth);
    this._registerInnerScrollCallback(node);
    this._stretchLastBlockColumn(node);
  }
  this._handleDataCallbackBeingProcessed = true;
  try {
    if (pendingFetch == AdfTableDataFetchEvent.FROM_INDEX_SUBTYPE || pendingFetch == AdfTableDataFetchEvent.UP_TO_INDEX_SUBTYPE) {
      this.RemoveAllBlocks(dataBody);
      dataBody.appendChild(node);
      var blockHeight = node.offsetHeight;
      this._adjustRowCountFromResponse(dataBody, node, size, blockHeight);
      var margin = 0;
      var actualCanvasHeight = this._canvasHeightLimited ? AdfDhtmlTableBasePeer._CSS_HEIGHT_LIMIT : this._canvasHeight;
      if (scrollTop >= actualCanvasHeight - viewportHeight || this._canvasHeightLimited && this.GetRowCount() == node.startRow + node.numRows) {
        margin = blockHeight - viewportHeight;
      }
      node.startPos = scrollTop - margin;
      node.cachedHeight = blockHeight;
    } else {
      if (pendingFetch == AdfTableDataFetchEvent.AFTER_KEY_SUBTYPE) {
        var lastBlock = blockList[numBlocks - 1];
        if (size == 0) {
          if (this.GetRowCount() == -1) {
            var rowCount = agent.getIntAttribute(lastBlock, "_rowCount", -1);
            this._rowCount = rowCount == -1 ? this._knownRowCount : rowCount;
            if (blockList[0].startPos == 0 && lastBlock.startPos + lastBlock.cachedHeight <= this._canvasHeight) {
              this._canvasHeight = lastBlock.startPos + lastBlock.cachedHeight;
              this._setFakeCanvasHeight(this._canvasHeight);
            }
          } else {
            this._adjustRowCountFromResponse(dataBody, node);
          }
        } else {
          node.startPos = lastBlock.startPos + lastBlock.cachedHeight;
          dataBody.appendChild(node);
          node.cachedHeight = node.offsetHeight;
          var indexShift = start - lastBlock.startRow - lastBlock.numRows;
          if (indexShift != 0) {
            this.ShiftIndex(lastBlock, indexShift, false);
          }
          this._adjustRowCountFromResponse(dataBody, node);
          if (indexShift != 0 && !this.IsReceivingActiveEvents()) {
            var sibling = lastBlock;
            while (sibling) {
              var next = sibling.previousSibling;
              this._unregisterNode(sibling);
              dataBody.removeChild(sibling);
              sibling = next;
            }
          }
          var extraCount = start + size - this.GetKnownRowCount();
          if (extraCount > 0) {
            this._knownRowCount += extraCount;
            var canvasDelta = node.cachedHeight;
            if (extraCount < size) {
              canvasDelta = 0;
              var rows = node.rows;
              for (var r = size - extraCount;r < size;r++) {
                canvasDelta += rows[r].offsetHeight;
              }
            }
            this._adjustCanvasHeight(canvasDelta, dataBody);
          } else {
            this._checkForScrollableLastBlockInViewport(dataBody);
            if (this._isLoadMore && node && node.cachedHeight > 0) {
              var canvasDelta = node.cachedHeight;
              this._adjustCanvasHeight(canvasDelta, dataBody);
            }
          }
          var blockList = dataBody.childNodes;
          var numBlocks = blockList.length;
          if (this._allRowsAvailableOnClient(blockList, numBlocks)) {
            var lastBlock = blockList[numBlocks - 1];
            this._canvasHeight = lastBlock.startPos + lastBlock.cachedHeight;
            this._setFakeCanvasHeight(this._canvasHeight);
          }
        }
      } else {
        if (pendingFetch == AdfTableDataFetchEvent.BEFORE_KEY_SUBTYPE) {
          var firstBlock = blockList[0];
          dataBody.insertBefore(node, firstBlock);
          var height = node.offsetHeight;
          node.cachedHeight = height;
          if (this._isLoadMore) {
            node.startPos = 0;
            for (var i = 1;i < blockList.length;i++) {
              blockList[i].startPos += height;
            }
            var canvasDelta = node.cachedHeight;
            this._adjustCanvasHeight(canvasDelta, dataBody);
          } else {
            node.startPos = firstBlock.startPos - height;
          }
          var indexShift = start - firstBlock.startRow + size;
          if (indexShift != 0) {
            this.ShiftIndex(firstBlock, indexShift, true);
          }
          var rowCountDelta = this._adjustRowCountFromResponse(dataBody, node);
          if ((indexShift != 0 || rowCountDelta != 0) && !this.IsReceivingActiveEvents()) {
            var sibling = firstBlock;
            while (sibling) {
              var next = sibling.nextSibling;
              this._unregisterNode(sibling);
              dataBody.removeChild(sibling);
              sibling = next;
            }
          }
        }
      }
      if (!pendingRenderOnly) {
        this._deleteOffscreenBlocks(dataBody, viewportHeight, node);
      }
      if (this._isLoadMore && node && node.cachedHeight > 0) {
        this._checkLoadMore();
      }
      this._repositionBlocksForScroll(dataBody);
      this._processSelectionRequest();
      if (this._clickEditRequest != null) {
        this._processClickToEditActivateRequest();
      }
    }
  } finally {
    delete this._handleDataCallbackBeingProcessed;
  }
  if (size != 0) {
    this.SetNewBlockScrollLeft(node);
    this._synchronizeRowHeights(node);
  }
  this.UpdateRange(false);
  return true;
};
AdfDhtmlTableBasePeer.prototype._adjustRowCountFromResponse = function(dataBody, node, rowsInBlock, blockHeight) {
  var rowCountDelta = 0;
  var oldCount = this.GetRowCount();
  if (oldCount != -1) {
    var newCount = AdfAgent.AGENT.getIntAttribute(node, "_rowCount", -1);
    if (this._unavailableRowIndex == 0) {
      newCount = -1;
    } else {
      if (this._unavailableRowIndex > 0) {
        newCount = this._unavailableRowIndex;
      }
    }
    if (newCount != -1) {
      rowCountDelta = newCount - oldCount;
    }
  }
  if (rowCountDelta != 0) {
    this._knownRowCount = newCount;
    this._rowCount = newCount;
    var heghtDelta;
    if (rowsInBlock != undefined && blockHeight != undefined && rowsInBlock == newCount) {
      heghtDelta = blockHeight - this._averageRowHeight * oldCount;
    } else {
      heghtDelta = this._averageRowHeight * rowCountDelta;
    }
    this._adjustCanvasHeight(heghtDelta, dataBody, false);
  }
  return rowCountDelta;
};
AdfDhtmlTableBasePeer.prototype.HandleExpand = function(node, size, remainingBlocks) {
  return this._handleExpandCollapse(node, remainingBlocks, true);
};
AdfDhtmlTableBasePeer.prototype.HandleCollapse = function(node, start, remainingBlocks) {
  return this._handleExpandCollapse(node, remainingBlocks, false);
};
AdfDhtmlTableBasePeer.prototype._handleExpandCollapse = function(node, remainingBlocks, expanded) {
  var key = node.getAttribute("_startKey");
  var rowInfo = null;
  if (key) {
    rowInfo = this.FindRowByKey(key);
  }
  if (rowInfo) {
    var page = AdfPage.PAGE;
    var tr = rowInfo.tr;
    var block = rowInfo.block;
    this._changeDetailIcon(tr, expanded);
    var oldHeight = block.cachedHeight;
    var cellToAnimate = null;
    var animDuration;
    if (page.isAnimationEnabled() && !this.isHeightAutoSized()) {
      animDuration = parseInt(page.getLookAndFeel().getSkinProperty("af|table-tr-detail-animation-duration"));
    }
    if (expanded) {
      var colspan = tr.cells.length;
      var newRow = node.rows[0];
      if (colspan > 1) {
        newRow.cells[0].colSpan = colspan;
      }
      newRow.parentNode.removeChild(newRow);
      tr.parentNode.insertBefore(newRow, tr.nextSibling);
      AdfAgent.AGENT.elementsAdded(newRow);
      if (animDuration > 0) {
        cellToAnimate = newRow.cells[0];
      }
    } else {
      var detailRow = tr.nextSibling;
      if (AdfAgent.getAgent().getAttribute(detailRow, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false)) {
        this._unregisterNode(detailRow);
        if (animDuration > 0) {
          detailRow.style.display = "none";
          cellToAnimate = detailRow.cells[0];
        } else {
          detailRow.parentNode.removeChild(detailRow);
        }
      } else {
        AdfLogger.LOGGER.severe("Unable to locate detail row");
      }
    }
    var newHeight = block.offsetHeight;
    block.cachedHeight = newHeight;
    var delta = newHeight - oldHeight;
    var sibling = block.nextSibling;
    while (sibling) {
      sibling.startPos += delta;
      sibling = sibling.nextSibling;
    }
    var dataBody = this.GetDataBody();
    this._adjustCanvasHeight(delta, dataBody);
    if (remainingBlocks == 0) {
      this._stretchTheColumns();
      this._checkForScrollableLastBlockInViewport(dataBody);
    }
    if (cellToAnimate != null) {
      this._doDisclosureAnimation(cellToAnimate, animDuration, expanded);
    }
    return true;
  } else {
    return false;
  }
};
AdfDhtmlTableBasePeer.prototype._doDisclosureAnimation = function(cellToAnimate, animDuration, expanded) {
  var ownerDoc = cellToAnimate.ownerDocument;
  var wrapper = expanded ? ownerDoc.createElement("div") : cellToAnimate.firstChild;
  var wrapperStyle = wrapper.style;
  var finalHeight = 0;
  if (expanded) {
    wrapperStyle.overflow = "hidden";
    wrapperStyle.height = "1px";
    wrapperStyle.position = "relative";
    var style = AdfAgent.AGENT.getComputedStyle(cellToAnimate);
    var cssLengthAsInt = AdfAgent.getCSSLengthAsInt;
    finalHeight = cellToAnimate.clientHeight - cssLengthAsInt(style.paddingTop) - cssLengthAsInt(style.paddingBottom);
    var firstChild = cellToAnimate.firstChild;
    while (firstChild) {
      wrapper.appendChild(firstChild);
      firstChild = cellToAnimate.firstChild;
    }
    cellToAnimate.appendChild(wrapper);
  } else {
    cellToAnimate.parentNode.style.display = "";
  }
  AdfDhtmlElementAnimator.animate(AdfDhtmlElementAnimator.FRAME_METHOD_SLOW_FAST_SLOW, animDuration, [{element:wrapper, properties:{"height":finalHeight}}], null, !expanded ? AdfDhtmlTableBasePeer.CollapseAnimationComplete : null, !expanded ? {wrapper:cellToAnimate.parentNode, peer:this} : null);
};
AdfDhtmlTableBasePeer.CollapseAnimationComplete = function(callbackObj) {
  var wrapper = callbackObj.wrapper;
  var peer = callbackObj.peer;
  wrapper.parentNode.removeChild(wrapper);
  peer._insertDeleteAnimationInEffect = false;
  if (peer) {
    peer.SetAnimating(false);
    if (peer.delayedResizeNotify) {
      peer.delayedResizeNotify();
      peer.delayedResizeNotify = null;
    }
    peer.AdjustAutoHeight();
  }
};
AdfDhtmlTableBasePeer.prototype.SetAnimating = function(animating) {
  this._animating = animating;
};
AdfDhtmlTableBasePeer.prototype.BusyAnimating = function() {
  return this._animating;
};
AdfDhtmlTableBasePeer.prototype.HandleClickToEditActiveRow = function(node, size, remainingBlocks) {
  delete this._oldActiveRowKey;
  if (size > 0) {
    var columnStretching = this._columnStretching;
    if (columnStretching != null && columnStretching != "none") {
      this._sizeBlockForFrozenColumns(node, this.GetDataBody().offsetWidth);
      this._stretchLastBlockColumn(node);
    }
    var agent = AdfAgent.AGENT;
    var rows = node.rows;
    var newRow = rows[0];
    var detailRow = rows.length > 1 && this._hasDetailStamp ? rows[1] : null;
    var rowKey = agent.getAttribute(newRow, AdfDhtmlTableBasePeer._ROW_KEY);
    this._replaceRowByKey(rowKey, newRow, detailRow);
    if (this._hasFrozenColumn()) {
      var rowHeight = newRow.offsetHeight;
      this._syncRowHeight(newRow, rowHeight);
    }
    if (remainingBlocks == 0) {
      this._handleClickToEditActiveRowAfter();
    }
    return true;
  } else {
    if (remainingBlocks == 0) {
      this._handleClickToEditActiveRowAfter();
    }
    return false;
  }
};
AdfDhtmlTableBasePeer.prototype._copyCellWidths = function(sourceRow, targetRow) {
  AdfAssert.assert(sourceRow != null, "Unable to copy cell widths if the given source row is invalid!");
  AdfAssert.assert(targetRow != null, "Unable to copy cell widths if the target row is invalid!");
  var sourceCell = null;
  var targetCell = null;
  var sourceCells = sourceRow.cells;
  var targetCells = targetRow.cells;
  var len = sourceCells.length;
  for (var i = 0;i < len;i++) {
    sourceCell = sourceCells[i];
    targetCell = targetCells[i];
    targetCell.style.width = sourceCell.style.width;
  }
  if (this._lastFrozen >= 0) {
    var sourceTable = this._getNestedScrolledTable(sourceRow);
    var targetTable = this._getNestedScrolledTable(targetRow);
    if (this._processColGroup()) {
      var sourceTableColGrp = AdfDhtmlTableBasePeer.FindFirstChildByTagName(sourceTable, "COLGROUP");
      var targetTableColGrp = AdfDhtmlTableBasePeer.FindFirstChildByTagName(targetTable, "COLGROUP");
      if (sourceTableColGrp && targetTableColGrp) {
        sourceCells = sourceTableColGrp.childNodes;
        targetCells = targetTableColGrp.childNodes;
        len = sourceCells.length;
        for (var i = 0;i < len;i++) {
          sourceCell = sourceCells[i];
          targetCell = targetCells[i];
          if (sourceCell.tagName == "COL" && targetCell.tagName == "COL") {
            targetCell.style.width = sourceCell.style.width;
          }
        }
      }
    }
    sourceCells = sourceTable.rows[0].cells;
    targetCells = targetTable.rows[0].cells;
    len = sourceCells.length;
    for (var i = 0;i < len;i++) {
      sourceCell = sourceCells[i];
      targetCell = targetCells[i];
      targetCell.style.width = sourceCell.style.width;
    }
  }
};
AdfDhtmlTableBasePeer.prototype._replaceRowByKey = function(rowKey, newRow, detailRow) {
  var agent = AdfAgent.AGENT;
  var rowInfo = this.FindRowByKey(rowKey);
  if (rowInfo) {
    var tr = rowInfo.tr;
    var block = rowInfo.block;
    var oldHeight = block.cachedHeight;
    this._copyCellWidths(tr, newRow);
    this._unregisterNode(tr);
    tr.parentNode.replaceChild(newRow, tr);
    agent.elementsAdded(newRow);
    if (detailRow) {
      tr = newRow.nextSibling;
      if (agent.getAttribute(tr, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false)) {
        this._unregisterNode(tr);
        tr.parentNode.replaceChild(detailRow, tr);
        agent.elementsAdded(detailRow);
        detailRow.cells[0].colSpan = newRow.cells.length;
      }
    }
    var newHeight = block.offsetHeight;
    block.cachedHeight = newHeight;
    var delta = newHeight - oldHeight;
    var sibling = block.nextSibling;
    while (sibling) {
      sibling.startPos += delta;
      sibling = sibling.nextSibling;
    }
    if (this._hasFrozenColumn()) {
      cells = newRow.cells;
      var last;
      if (this._freezeColumnsToEnd()) {
        last = cells[0];
      } else {
        last = cells[cells.length - 1];
      }
      var div = AdfDhtmlTableBasePeer.FindFirstChildByTagName(last, "DIV");
      div.onscroll = this._innerTableScrollCallback;
    }
    this._adjustCanvasHeight(delta, this.GetDataBody(), true);
  }
};
AdfDhtmlTableBasePeer.prototype._handleClickToEditActiveRowAfter = function() {
  this._stretchTheColumns();
  var scrollLeft = this._currentScrollLeft;
  if (scrollLeft != 0) {
    this._handleHorizontalScroll(scrollLeft);
  }
  this._processClickToEditRequestTimerId = AdfPage.PAGE.scheduleTimer(this, this._processClickToEditRequest, true, 10);
};
AdfDhtmlTableBasePeer.prototype.SetFirst = function(first) {
  var comp = this.getComponent();
  comp.setProperty("first", first, false, AdfUIComponent.PROPAGATE_ALWAYS);
};
AdfDhtmlTableBasePeer.prototype.SetRows = function(rows) {
  var comp = this.getComponent();
  comp.setRows(rows);
};
AdfDhtmlTableBasePeer.prototype.UpdateRange = function(initialization) {
  var component = this.getComponent();
  AdfPage.PAGE.unmapDescendantComponentAbsoluteLocators(component);
  if (this._isPaged) {
    return;
  }
  var blocks = this.GetDataBody().childNodes;
  if (blocks.length == 0) {
    return;
  }
  var first = blocks[0].startRow;
  var lastBlock = blocks[blocks.length - 1];
  var rows = lastBlock.startRow + lastBlock.numRows - first;
  this.SetFirst(first);
  this.SetRows(rows);
  var attrs = this.GetFirstVisibleRowKeyAndRow();
  if (attrs.rowKey != null && !initialization) {
    component.setProperty("scrollTopRowKey", attrs.rowKey, true, AdfUIComponent.PROPAGATE_ALWAYS);
  }
};
AdfDhtmlTableBasePeer.prototype._checkStart = function(dataBody) {
  var blockList = dataBody.childNodes;
  if (blockList.length < 1) {
    return;
  }
  var first = blockList[0];
  var firstStartPos = first.startPos;
  if (firstStartPos < 0) {
    var scrollTop = this._currentScrollTop - first.startPos;
    this._setScrollTop(scrollTop);
    for (var i = 0;i < blockList.length;i++) {
      blockList[i].startPos -= firstStartPos;
    }
  }
};
AdfDhtmlTableBasePeer.prototype._checkEnd = function(dataBody) {
  var blockList = dataBody.childNodes;
  if (blockList.length < 1) {
    return;
  }
  var last = blockList[blockList.length - 1];
  var delta = last.startPos + last.cachedHeight - this._canvasHeight;
  if (this.GetRowCount() == -1 || this._canvasHeightLimited && delta < 0) {
    delta += AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE;
    if (this._canvasHeightLimited && delta < 0) {
      delta = 0;
    }
  }
  if (delta > 0) {
    var scrollTop = this._currentScrollTop - delta;
    this._setScrollTop(scrollTop);
    for (var i = 0;i < blockList.length;i++) {
      blockList[i].startPos -= delta;
    }
  }
  if (this.GetRowCount() == -1) {
    var viewportHeight = dataBody.offsetHeight;
    var end = this._canvasHeight - viewportHeight - AdfDhtmlTableBasePeer._FETCH_MORE_CANVAS_SPACE;
    if (this._currentScrollTop > end) {
      this._setScrollTop(end);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._processSelectionRequest = function() {
  var agent = AdfAgent.AGENT;
  var selectionRequest = this._selectionRequest;
  var attrs = null;
  if (selectionRequest == null) {
    return;
  } else {
    if (selectionRequest == AdfDhtmlTableBasePeer._SELECT_PAGE_UP) {
      attrs = this.GetFirstVisibleRowKeyAndRow();
    } else {
      if (selectionRequest == AdfDhtmlTableBasePeer._SELECT_PAGE_DOWN) {
        attrs = this._getLastVisibleRowKeyAndRow();
      } else {
        if (selectionRequest == AdfDhtmlTableBasePeer._SELECT_ARROW_DOWN || selectionRequest == AdfDhtmlTableBasePeer._FOCUS_RH_ARROW_DOWN || selectionRequest == AdfDhtmlTableBasePeer._FOCUS_ROW_ARROW_DOWN) {
          attrs = this._getNextRowKeyAndRow(this._lastRowKeyInView);
        } else {
          if (selectionRequest == AdfDhtmlTableBasePeer._SELECT_ARROW_UP || selectionRequest == AdfDhtmlTableBasePeer._FOCUS_RH_ARROW_UP || selectionRequest == AdfDhtmlTableBasePeer._FOCUS_ROW_ARROW_UP) {
            attrs = this._getPreviousRowKeyAndRow(this._lastRowKeyInView);
          }
        }
      }
    }
  }
  var rowKey = attrs.rowKey, row = attrs.row;
  if (rowKey != null) {
    if (selectionRequest == AdfDhtmlTableBasePeer._FOCUS_RH_ARROW_UP || selectionRequest == AdfDhtmlTableBasePeer._FOCUS_RH_ARROW_DOWN) {
      var rowHeaderCell = this.GetRowHeaderCellFromRow(row);
      this.UpdateFocusManager(AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE, rowKey, rowHeaderCell);
    } else {
      if (selectionRequest != AdfDhtmlTableBasePeer._FOCUS_ROW_ARROW_UP && selectionRequest != AdfDhtmlTableBasePeer._FOCUS_ROW_ARROW_DOWN) {
        this._selSelectRow(rowKey, row);
      }
      this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row);
    }
    this._unclipRow(row);
  }
  delete this._selectionRequest;
};
AdfDhtmlTableBasePeer.prototype.DisplayStatus = function(text, center) {
  var message = this._getStatusMessage();
  if (!message) {
    return;
  }
  message.innerHTML = text;
  var style = message.style;
  if (style.display == "none") {
    style.zIndex = 5E3;
    var dataBody = this.GetDataBody();
    style.visibility = "hidden";
    style.display = "block";
    var dataBodyHeight;
    if (this._virtInitialized) {
      dataBodyHeight = dataBody.offsetHeight;
    } else {
      dataBodyHeight = this.getDomElement().clientHeight - this._cachedCHHeight;
    }
    style.top = this._cachedCHHeight + Math.floor((dataBodyHeight - message.offsetHeight) / 2) + "px";
    var offset = "25px";
    if (center) {
      offset = Math.floor(dataBody.offsetWidth / 2 - message.offsetWidth / 2) + "px";
    }
    if (AdfDhtmlTableBasePeer._isRTL()) {
      style.left = offset;
    } else {
      style.right = offset;
    }
    style.visibility = "visible";
  }
};
AdfDhtmlTableBasePeer.prototype._hideStatus = function() {
  var message = this._getStatusMessage();
  if (!message) {
    return;
  }
  this._hideElement(message);
};
AdfDhtmlTableBasePeer.prototype._hideElement = function(element) {
  var agent = AdfAgent.AGENT;
  var scroller = this.GetScroller();
  var needsScrollPositionHack = this._hasScroller(scroller) && agent.getPlatform() == AdfAgent.IE_PLATFORM && agent.getVersion() >= 8;
  var cachedScrollPosition;
  if (needsScrollPositionHack) {
    if (AdfCollections.isArray(scroller)) {
      cachedScrollPosition = new Array;
      for (var i = 0;i < scroller.length;i++) {
        cachedScrollPosition[i] = {x:agent.getScrollLeft(scroller[i]), y:scroller[i].scrollTop};
      }
    } else {
      cachedScrollPosition = {x:agent.getScrollLeft(scroller), y:scroller.scrollTop};
    }
  }
  element.style.display = "none";
  if (needsScrollPositionHack) {
    if (AdfCollections.isArray(scroller)) {
      for (var i = 0;i < scroller.length;i++) {
        agent.setScrollLeft(scroller[i], cachedScrollPosition[i].x);
        scroller[i].scrollTop = cachedScrollPosition[i].y;
      }
    } else {
      agent.setScrollLeft(scroller, cachedScrollPosition.x);
      scroller.scrollTop = cachedScrollPosition.y;
    }
  }
};
AdfDhtmlTableBasePeer.prototype._hasScroller = function(scroller) {
  if (AdfCollections.isArray(scroller)) {
    for (var i = 0;i < scroller.length;i++) {
      if (scroller[i] != null) {
        return true;
      }
    }
    return false;
  } else {
    return scroller != null;
  }
};
AdfDhtmlTableBasePeer.prototype.GetDataBody = function(rootDomElement) {
  if (this._dataBodyWrapped) {
    var dataBodyWrapper = this.__getElemBySubId(AdfDhtmlTableBasePeer._DATAWRAPPER, rootDomElement);
    var nodes = dataBodyWrapper.childNodes;
    for (var i = 0;i < nodes.length;i++) {
      if (nodes[i].id != null && nodes[i].id.indexOf("db") > 0) {
        return nodes[i];
      }
    }
    return null;
  } else {
    return this.__getElemBySubId("db", rootDomElement);
  }
};
AdfDhtmlTableBasePeer.prototype._getStatusMessage = function() {
  return this.__getElemBySubId("sm");
};
AdfDhtmlTableBasePeer.prototype._getColumnResizeIndicator = function() {
  return this.__getElemBySubId("ri");
};
AdfDhtmlTableBasePeer.prototype.__getColumnHeader = function() {
  return this.__getElemBySubId("ch");
};
AdfDhtmlTableBasePeer.prototype._getColumnFooter = function() {
  return this.__getElemBySubId("cf");
};
AdfDhtmlTableBasePeer.prototype._getNavigationBar = function() {
  return this.__getElemBySubId("nbar");
};
AdfDhtmlTableBasePeer.prototype._getLoadMore = function(top) {
  var parent = this.getDomElement();
  if (this._dataBodyWrapped) {
    var container = this.getDomElement();
    var dataWrapper = AdfAgent.AGENT.getElementById(AdfRichUIPeer.CreateSubId(container.id, AdfDhtmlTableBasePeer._DATAWRAPPER));
    if (dataWrapper && dataWrapper.childNodes.length > 1) {
      parent = dataWrapper;
    }
  }
  var nodes = parent.childNodes;
  for (var i = 0;i < nodes.length;i++) {
    if (nodes[i].id != null && nodes[i].id.indexOf(top ? AdfDhtmlTableBasePeer._LOAD_MORE_TOP_DIV : AdfDhtmlTableBasePeer._LOAD_MORE_BOTTOM_DIV) > 0) {
      return nodes[i];
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._setFakeCanvasWidth = function(width) {
  var scroller = this.GetScroller();
  if (this._hasSingleScroller() && !this._isPaged) {
    var fakeCanvas = AdfDhtmlTableBasePeer.FindFirstChildByTagName(scroller, "DIV");
    fakeCanvas.style.width = width + "px";
  } else {
    var hfakeCanvas = AdfDhtmlTableBasePeer.FindFirstChildByTagName(scroller[0], "DIV");
    var vfakeCanvas = AdfDhtmlTableBasePeer.FindFirstChildByTagName(scroller[1], "DIV");
    vfakeCanvas.style.width = hfakeCanvas.style.width = width + "px";
  }
};
AdfDhtmlTableBasePeer.prototype._setFakeCanvasHeight = function(height) {
  var scroller = this.GetScroller();
  if (height > AdfDhtmlTableBasePeer._CSS_HEIGHT_LIMIT) {
    height = AdfDhtmlTableBasePeer._CSS_HEIGHT_LIMIT;
    this._canvasHeightLimited = true;
  } else {
    this._canvasHeightLimited = false;
  }
  if (this._hasSingleScroller() && !this._isPaged) {
    var scrollTop = scroller.scrollTop;
    var fakeCanvas = AdfDhtmlTableBasePeer.FindFirstChildByTagName(scroller, "DIV");
    fakeCanvas.style.height = height + "px";
    scroller.scrollTop = scrollTop;
  } else {
    var hfakeCanvas = AdfDhtmlTableBasePeer.FindFirstChildByTagName(scroller[0], "DIV");
    var vfakeCanvas = AdfDhtmlTableBasePeer.FindFirstChildByTagName(scroller[1], "DIV");
    vfakeCanvas.style.height = hfakeCanvas.style.height = height + "px";
  }
};
AdfDhtmlTableBasePeer.prototype.GetScroller = function() {
  if (this._hasSingleScroller() && !this._isPaged) {
    return this.__getElemBySubId("scroller");
  } else {
    var scroller = [];
    scroller[AdfDhtmlTableBasePeer._HSCROLLER] = this.__getElemBySubId("hscroller");
    scroller[AdfDhtmlTableBasePeer._VSCROLLER] = this.__getElemBySubId("vscroller");
    return scroller;
  }
};
AdfDhtmlTableBasePeer.prototype._scrollerScrollToPos = function(x, y) {
  var agent = AdfAgent.getAgent();
  var adjustForIERTL = x != null && AdfDhtmlTableBasePeer._isRTL() && agent.getPlatform() == AdfAgent.IE_PLATFORM && agent.getVersion() > 7;
  if (this._hasSingleScroller() && !this._isPaged) {
    var scroller = this.GetScroller();
    if (adjustForIERTL) {
      x = scroller.scrollWidth - scroller.clientWidth - x;
    }
    agent.scrollToPos(scroller, x, y);
  } else {
    var scroller = this.GetScroller();
    var hScroller = scroller[AdfDhtmlTableBasePeer._HSCROLLER];
    if (adjustForIERTL) {
      x = hScroller.scrollWidth - hScroller.clientWidth - x;
    }
    agent.scrollToPos(scroller[AdfDhtmlTableBasePeer._HSCROLLER], x, y);
    agent.scrollToPos(scroller[AdfDhtmlTableBasePeer._VSCROLLER], x, y);
  }
};
AdfDhtmlTableBasePeer.prototype.__getScrollerDimensions = function() {
  return {"offsetWidth":this._getScrollerOffsetWidth(), "offsetHeight":this._getScrollerOffsetHeight(), "clientWidth":this._getScrollerClientWidth(), "clientHeight":this._getScrollerClientHeight()};
};
AdfDhtmlTableBasePeer.prototype._getScrollerOffsetWidth = function() {
  var offsetWidth;
  if (this._hasSingleScroller() && !this._isPaged) {
    offsetWidth = this.GetScroller().offsetWidth;
  } else {
    var scroller = this.GetScroller();
    offsetWidth = scroller[0].offsetWidth;
  }
  return offsetWidth;
};
AdfDhtmlTableBasePeer.prototype._getScrollerOffsetHeight = function() {
  var offsetHeight;
  if (this._hasSingleScroller() && !this._isPaged) {
    offsetHeight = this.GetScroller().offsetHeight;
  } else {
    var scroller = this.GetScroller();
    offsetHeight = scroller[1].offsetHeight;
  }
  return offsetHeight;
};
AdfDhtmlTableBasePeer.prototype._getScrollerClientWidth = function() {
  var clientWidth;
  if (this._hasSingleScroller() && !this._isPaged) {
    clientWidth = this.GetScroller().clientWidth;
  } else {
    var scroller = this.GetScroller();
    clientWidth = scroller[0].clientWidth;
  }
  return clientWidth;
};
AdfDhtmlTableBasePeer.prototype._getScrollerClientHeight = function() {
  var clientHeight;
  if (this._hasSingleScroller() && !this._isPaged) {
    clientHeight = this.GetScroller().clientHeight;
  } else {
    var scroller = this.GetScroller();
    clientHeight = scroller[1].clientHeight;
  }
  return clientHeight;
};
AdfDhtmlTableBasePeer.prototype._getVerticalScrollBarWidth = function() {
  var width;
  var scroller = this.GetScroller();
  if (this._footerless && !this._isPaged) {
    width = scroller.offsetWidth - scroller.clientWidth;
  } else {
    width = scroller[1].offsetWidth - scroller[1].clientWidth;
  }
  return width;
};
AdfDhtmlTableBasePeer.prototype._setScrollerTop = function(top) {
  if (this._hasSingleScroller() && !this._isPaged) {
    this.GetScroller().style.top = top + "px";
  } else {
    var scroller = this.GetScroller();
    scroller[0].style.top = scroller[1].style.top = top + "px";
  }
};
AdfDhtmlTableBasePeer.prototype._setScrollerHeight = function(outerClientHeight, chHeight, cfHeight, nbHeight) {
  if (this._hasSingleScroller() && !this._isPaged) {
    var height = Math.max(0, outerClientHeight - chHeight - nbHeight);
    this.GetScroller().style.height = height + "px";
  } else {
    var scroller = this.GetScroller();
    height = Math.max(0, outerClientHeight - chHeight);
    scroller[0].style.height = height + "px";
    var scrollbarHeight = scroller[0].offsetHeight - scroller[0].clientHeight;
    height = Math.max(0, outerClientHeight - chHeight - cfHeight - nbHeight - scrollbarHeight);
    scroller[1].style.height = height + "px";
  }
};
AdfDhtmlTableBasePeer.prototype._setScrollerWidth = function(outerClientWidth, frozenWidth) {
  if (this._hasSingleScroller() && !this._isPaged) {
    var width = Math.max(outerClientWidth - frozenWidth, 0);
    var style = this.GetScroller().style;
    style.overflowX = "auto";
    style.width = width + "px";
  } else {
    var scroller = this.GetScroller();
    var width = Math.max(outerClientWidth - frozenWidth, 0);
    scroller[1].style.overflowX = "hidden";
    scroller[1].style.width = width + "px";
    var scrollbarWidth = 0;
    if (scroller[1].clientWidth > 0) {
      scrollbarWidth = scroller[1].offsetWidth - scroller[1].clientWidth;
    }
    width = Math.max(outerClientWidth - frozenWidth - scrollbarWidth, 0);
    var hStyle = scroller[0].style;
    hStyle.overflowX = "auto";
    hStyle.width = width + "px";
    if (!this._freezeColumnsToEnd()) {
      if (AdfDhtmlTableBasePeer._isRTL()) {
        hStyle.left = scrollbarWidth + "px";
      } else {
        hStyle.right = scrollbarWidth + "px";
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._setScrollLeft = function(scrollLeft) {
  var agent = AdfAgent.AGENT;
  this._currentScrollLeft = scrollLeft;
  if (this._hasSingleScroller() && !this._isPaged) {
    var scroller = this.GetScroller();
    if (agent.getScrollLeft(scroller) != scrollLeft) {
      agent.setScrollLeft(scroller, scrollLeft);
    }
  } else {
    scroller = this.GetScroller();
    if (agent.getScrollLeft(scroller[0]) != scrollLeft) {
      agent.setScrollLeft(scroller[0], scrollLeft);
    }
  }
};
AdfDhtmlTableBasePeer.prototype.__getScrollLeft = function() {
  var agent = AdfAgent.AGENT;
  var scrollLeft;
  if (this._hasSingleScroller() && !this._isPaged) {
    scrollLeft = agent.getScrollLeft(this.GetScroller());
  } else {
    var scroller = this.GetScroller();
    scrollLeft = agent.getScrollLeft(scroller[0]);
  }
  return Math.round(scrollLeft);
};
AdfDhtmlTableBasePeer.prototype.__getCurrentScrollLeft = function() {
  return this._currentScrollLeft;
};
AdfDhtmlTableBasePeer.prototype._setScrollTop = function(scrollTop) {
  this._currentScrollTop = scrollTop;
  if (this._hasSingleScroller() && !this._isPaged) {
    var scroller = this.GetScroller();
    if (scroller.scrollTop != scrollTop) {
      scroller.scrollTop = scrollTop;
    }
  } else {
    scroller = this.GetScroller();
    if (scroller[1].scrollTop != scrollTop) {
      scroller[1].scrollTop = scrollTop;
    }
  }
  if ((!this._isTouch || AdfAgent.guessOS() == "Windows") && AdfAgent.AGENT.getPlatform() == AdfAgent.WEBKIT_PLATFORM) {
    this._scrollTopUpdating = true;
    setTimeout(AdfDhtmlTableBasePeer._resetScrollTopUpdating, 100, this);
  }
};
AdfDhtmlTableBasePeer.prototype.__getScrollDimensions = function() {
  return {"scrollLeft":this.__getScrollLeft(), "scrollTop":this._getScrollTop(), "scrollHeight":this._getScrollHeight(), "scrollWidth":this._getScrollWidth()};
};
AdfDhtmlTableBasePeer.prototype._getScrollTop = function() {
  var scrollTop;
  if (this._hasSingleScroller() && !this._isPaged) {
    scrollTop = this.GetScroller().scrollTop;
  } else {
    var scroller = this.GetScroller();
    var agent = AdfAgent.AGENT;
    if (this._isTouch && agent.getPlatform() == AdfAgent.WEBKIT_PLATFORM && agent.getOS() == AdfAgent.MAC_OS) {
      scrollTop = scroller[0].scrollTop;
    } else {
      scrollTop = scroller[1].scrollTop;
    }
  }
  return scrollTop;
};
AdfDhtmlTableBasePeer.prototype._getScrollHeight = function() {
  if (this._hasSingleScroller() && !this._isPaged) {
    return this.GetScroller().scrollHeight;
  } else {
    var scroller = this.GetScroller();
    return scroller[1].scrollHeight;
  }
};
AdfDhtmlTableBasePeer.prototype._getScrollWidth = function() {
  var scroller = this.GetScroller();
  if (!scroller) {
    return;
  }
  if (this._hasSingleScroller() && !this._isPaged) {
    return scroller.scrollWidth;
  } else {
    return scroller[0].scrollWidth;
  }
};
AdfDhtmlTableBasePeer.prototype.__getLastFrozen = function() {
  return this._lastFrozen;
};
AdfDhtmlTableBasePeer.prototype.__getFirstFrozen = function() {
  return this._firstFrozen;
};
AdfDhtmlTableBasePeer.prototype.__getElemBySubId = function(sub, rootDomElement) {
  var top = this.getDomElement();
  if (top == null) {
    top = rootDomElement;
  }
  return AdfDhtmlTableBasePeer.__getChildBySubId(top, sub);
};
AdfDhtmlTableBasePeer.__getChildBySubId = function(parent, sub) {
  AdfAssert.assert(parent != null, "Table peer cannot get a child by sub ID if the parent is null!");
  var id = parent.id + "::" + sub;
  var nodes = parent.childNodes;
  for (var i = 0;i < nodes.length;i++) {
    if (id == nodes[i].id) {
      return nodes[i];
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype.GetRowCount = function() {
  return this._rowCount;
};
AdfDhtmlTableBasePeer.prototype.GetKnownRowCount = function() {
  return this._knownRowCount;
};
AdfDhtmlTableBasePeer.prototype.getClientStartRowIndex = function() {
  var dataBody = this.GetDataBody();
  if (dataBody && dataBody.childNodes && dataBody.childNodes.length > 0) {
    return dataBody.childNodes[0].startRow;
  }
  return -1;
};
AdfDhtmlTableBasePeer.prototype.getClientRowCount = function() {
  var rowCount = 0;
  var dataBody = this.GetDataBody();
  if (dataBody && dataBody.childNodes) {
    for (var i = 0;i < dataBody.childNodes.length;i++) {
      rowCount += dataBody.childNodes[i].numRows;
    }
  }
  return rowCount;
};
AdfDhtmlTableBasePeer.prototype.simulateSelectRows = function(rowKeyList, operation) {
  var rowInfo;
  var rowKey;
  var targetNode;
  var toggleKeyDown = operation == "toggle";
  var rowKeyArray = rowKeyList.split(",");
  for (var i = 0;i < rowKeyArray.length;i++) {
    rowKey = rowKeyArray[i];
    rowInfo = this.FindRowByKey(rowKey);
    if (rowInfo) {
      targetNode = this.FindCellByIndex(rowInfo.tr, 0);
      if (targetNode) {
        this._handleRowMouseDown(null, targetNode, true, toggleKeyDown, false, rowKey, rowInfo.tr);
        this._handleRowClick(targetNode, true, toggleKeyDown, false, rowKey, rowInfo.tr);
        toggleKeyDown = true;
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._syncRowHeight = function(row, rowHeight) {
  var table = this._getNestedScrolledTable(row);
  if (table.offsetHeight != rowHeight) {
    var agent = AdfAgent.AGENT;
    var isIE = agent.getPlatform() == AdfAgent.IE_PLATFORM;
    var isWebKit = agent.getPlatform() == AdfAgent.WEBKIT_PLATFORM;
    if (isIE || isWebKit) {
      table.style.height = "auto";
    } else {
      table.rows[0].style.height = "auto";
    }
    if (isIE || isWebKit) {
      table.style.height = rowHeight + "px";
    } else {
      table.rows[0].style.height = rowHeight + "px";
    }
  }
};
AdfDhtmlTableBasePeer.prototype._synchronizeRowHeights = function(block) {
  if (this._hasFrozenColumn()) {
    var startPos = block.startPos;
    var lastSyncRow = block._lastSyncRow;
    var dataBodyHeight = this._dataBodyHeight;
    var rows = block.rows;
    var rowCount = rows.length;
    var currentScrollTop = this._currentScrollTop;
    if (lastSyncRow != null && lastSyncRow == rowCount - 1) {
      return;
    }
    if (startPos > currentScrollTop + dataBodyHeight) {
      return;
    }
    if (this._areAllColumnsFrozen(rows[0].cells.length)) {
      return;
    }
    for (var i = 0;i < rowCount;i++) {
      if (lastSyncRow != null && lastSyncRow >= i) {
        continue;
      }
      var row = rows[i];
      var rowHeight = row.offsetHeight;
      this._syncRowHeight(row, rowHeight);
      if (startPos + row.offsetTop + rowHeight > currentScrollTop + dataBodyHeight) {
        block._lastSyncRow = i;
        return;
      }
    }
    block._lastSyncRow = rowCount - 1;
  }
};
AdfDhtmlTableBasePeer.prototype._showColumnResizeIndicator = function(resizedTH, displayIndex) {
  var indicator = this._getColumnResizeIndicator();
  if (!indicator) {
    return;
  }
  var isLTR = !AdfDhtmlTableBasePeer._isRTL();
  var s = indicator.style;
  s.display = "block";
  s.zIndex = 20;
  s.top = "0px";
  var left;
  if (isLTR) {
    left = resizedTH.offsetLeft + resizedTH.offsetWidth;
    if (this._freezeColumnsToStart() && !this._isColumnFrozen(displayIndex)) {
      left += this._frozenWidth;
    } else {
      if (this._freezeColumnsToEnd() && this._isColumnFrozen(displayIndex)) {
        left += this._getUnfrozenColumnsWidth();
      }
    }
    if (!this._hasFrozenColumn() || !this._isColumnFrozen(displayIndex)) {
      left -= this._currentScrollLeft;
    }
  } else {
    left = resizedTH.offsetLeft;
    if (this._freezeColumnsToStart() && this._isColumnFrozen(displayIndex)) {
      left += this.getDomElement().offsetWidth - resizedTH.parentNode.parentNode.offsetWidth;
    } else {
      if (this._freezeColumnsToEnd() && !this._isColumnFrozen(displayIndex)) {
        left += this._frozenWidth;
      } else {
        var domParent = resizedTH.parentNode;
        while (domParent && domParent.tagName != "TABLE") {
          domParent = domParent.parentNode;
        }
        if (domParent && domParent.tagName == "TABLE") {
          var parentTableOffsetWidth = domParent.offsetWidth;
          var parentTableOffsetLeft = domParent.offsetLeft;
          while (domParent && domParent.tagName != "DIV") {
            domParent = domParent.parentNode;
          }
          if (domParent && domParent.tagName == "DIV") {
            var headerDivOffsetWidth = domParent.offsetWidth;
            if (headerDivOffsetWidth > parentTableOffsetWidth) {
              left += parentTableOffsetLeft;
            }
          }
        }
        left -= this._getRTLScrollAdjustment();
        if (this._getScrollHeight() > this._getScrollerOffsetHeight()) {
          left += this._getVerticalScrollBarWidth();
        }
      }
    }
  }
  s.left = left + "px";
  s.height = this._cachedCHHeight + this._cachedCFHeight + this._cachedNBHeight + this._cachedFMHeight + this.GetDataBody().offsetHeight + "px";
};
AdfDhtmlTableBasePeer.prototype._getColumnHeaderFooterSizingCell = function(displayIndex, parentDiv, tableId, div2Id, table2Id) {
  if (!this._hasFrozenColumn() || this._isColumnFrozen(displayIndex)) {
    var table1 = AdfDhtmlTableBasePeer.__getChildBySubId(parentDiv, tableId);
    if (this._freezeColumnsToEnd()) {
      return table1.rows[0].cells[displayIndex - this._firstFrozen];
    } else {
      return table1.rows[0].cells[displayIndex];
    }
  } else {
    var second = AdfDhtmlTableBasePeer.__getChildBySubId(parentDiv, div2Id);
    var table2 = AdfDhtmlTableBasePeer.__getChildBySubId(second, table2Id);
    if (this._freezeColumnsToStart()) {
      return table2.rows[0].cells[displayIndex - this._lastFrozen - 1];
    } else {
      return table2.rows[0].cells[displayIndex];
    }
  }
};
AdfDhtmlTableBasePeer.prototype._getResizedCellInfo = function(headerAction) {
  var agent = AdfAgent.AGENT;
  var th = headerAction.cell;
  var isRTL = AdfDhtmlTableBasePeer._isRTL();
  var displayIndex = agent.getIntAttribute(th, "_d_index", -1);
  if (headerAction.data == "start") {
    displayIndex--;
  } else {
    displayIndex += agent.getIntAttribute(th, "colspan", 1) - 1;
  }
  var resizedTH = this._getColumnHeaderFooterSizingCell(displayIndex, this.__getColumnHeader(), "t", "d2", "t2");
  if (agent.getAttribute(resizedTH, AdfDhtmlTableBasePeer.NO_RESIZE_MARKER, false)) {
    return null;
  }
  return {cell:resizedTH, displayIndex:displayIndex};
};
AdfDhtmlTableBasePeer.prototype._getColumnHeaderLeafCell = function(displayIndex) {
  var headerDiv = this.__getColumnHeader();
  if (!headerDiv) {
    return null;
  }
  var table1 = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "t");
  var tables = new Array(table1);
  if (this._hasFrozenColumn()) {
    var second = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "d2");
    var table2 = AdfDhtmlTableBasePeer.__getChildBySubId(second, "t2");
    tables.push(table2);
  }
  var nRows = table1.rows.length;
  var agent = AdfAgent.AGENT;
  var leafExpando = AdfDhtmlTableBasePeer._LEAF_COLUMN;
  var cell = null;
  for (var i = nRows - 1;i >= 0 && !cell;i--) {
    for (var t = 0;t < tables.length;t++) {
      var table = tables[t];
      var cells = table.rows[i].cells;
      for (var c = 0;c < cells.length && !cell;c++) {
        var _cell = cells[c];
        var isLeaf = _cell.getAttribute(leafExpando);
        if (isLeaf) {
          if (agent.getIntAttribute(_cell, "_d_index", -1) == displayIndex) {
            cell = _cell;
            break;
          }
        }
      }
    }
  }
  return cell;
};
AdfDhtmlTableBasePeer.prototype._synchronizeColumnRowHeights = function(hDiv, table1Id, div2Id, table2Id) {
  if (this._hasFrozenColumn()) {
    var agent = AdfAgent.AGENT;
    var isWebKit = agent.getPlatform() == AdfAgent.WEBKIT_PLATFORM;
    var isIE8 = agent.getPlatform() == AdfAgent.IE_PLATFORM && agent.getVersion() == 8;
    var table1 = AdfDhtmlTableBasePeer.__getChildBySubId(hDiv, table1Id);
    var second = AdfDhtmlTableBasePeer.__getChildBySubId(hDiv, div2Id);
    var table2 = AdfDhtmlTableBasePeer.__getChildBySubId(second, table2Id);
    var rows1 = table1.rows;
    var rows2 = table2.rows;
    table1.style.height = table2.style.height = "auto";
    for (var r = 0;r < rows1.length;r++) {
      rows1[r].style.height = rows2[r].style.height = "auto";
    }
    for (var r = 0;r < rows1.length;r++) {
      if (isIE8) {
        var cell1 = -1;
        for (var c1 = 0;c1 < rows1[r].cells.length;c1++) {
          if (rows1[r].cells[c1].rowSpan && rows1[r].cells[c1].rowSpan == 1) {
            cell1 = c1;
            break;
          }
        }
        var cell2 = -1;
        for (var c2 = 0;c2 < rows2[r].cells.length;c2++) {
          if (rows2[r].cells[c2].rowSpan && rows2[r].cells[c2].rowSpan == 1) {
            cell2 = c2;
            break;
          }
        }
        var h1 = 0;
        var h2 = 0;
        if (cell1 > -1) {
          h1 = rows1[r].cells[cell1].offsetHeight;
        }
        if (cell2 > -1) {
          h2 = rows2[r].cells[cell2].offsetHeight;
        }
        if (h1 > h2) {
          agent.setTableRowHeight(rows2[r], h1);
        } else {
          if (h2 > h1) {
            agent.setTableRowHeight(rows1[r], h2);
          }
        }
      } else {
        var height1 = rows1[r].offsetHeight;
        var height2 = rows2[r].offsetHeight;
        if (height1 > height2) {
          agent.setTableRowHeight(rows2[r], height1);
        } else {
          if (height2 > height1) {
            agent.setTableRowHeight(rows1[r], height2);
          }
        }
      }
    }
    var height = Math.max(table1.offsetHeight, table2.offsetHeight);
    table2.style.height = table1.style.height = height + "px";
    if (isWebKit && rows2.length == 2) {
      for (var r = 0;r < rows2[0].cells.length;r++) {
        rows2[1].cells[r].rowSpan = "10";
      }
      for (var r = 0;r < rows1[0].cells.length;r++) {
        rows1[1].cells[r].rowSpan = "10";
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._getInnerTableCell = function(row, index) {
  var table = this._getNestedScrolledTable(row);
  var innerRow = table.rows[0];
  if (this._freezeColumnsToStart()) {
    return innerRow.cells[index - this._lastFrozen - 1];
  } else {
    return innerRow.cells[index];
  }
};
AdfDhtmlTableBasePeer._handleMouseWheel = function(evt) {
  if (!evt) {
    evt = AdfPage.PAGE.getDomWindow().event;
  }
  var scroller = AdfDhtmlTableBasePeer.__getChildBySubId(this.parentNode, "scroller");
  var hscroller = AdfDhtmlTableBasePeer.__getChildBySubId(this.parentNode, "hscroller");
  if (!scroller) {
    scroller = AdfDhtmlTableBasePeer.__getChildBySubId(this.parentNode, "vscroller");
  }
  if (!scroller) {
    return;
  }
  var agent = AdfAgent.AGENT;
  var scrollAmountX = null;
  var scrollAmountY = null;
  var deltaX = evt.deltaX;
  var deltaY = evt.deltaY;
  var wheelDeltaX = evt.wheelDeltaX;
  var wheelDeltaY = evt.wheelDeltaY;
  var deltaMode = evt.deltaMode;
  if (deltaX != null || deltaY != null) {
    var normalizationFactor = agent.getPlatform() == AdfAgent.IE_PLATFORM ? 40 : 1;
    var deltaModeFactor = deltaMode == 1 ? 33 : 1;
    if (deltaX != null) {
      scrollAmountX = deltaX / normalizationFactor;
    }
    if (deltaY != null) {
      scrollAmountY = deltaY * deltaModeFactor;
    }
  } else {
    if (wheelDeltaX != null) {
      scrollAmountX = -wheelDeltaX / 4;
    }
    if (wheelDeltaY != null) {
      scrollAmountY = -wheelDeltaY / 4;
    }
    if (wheelDeltaX == null && wheelDeltaY == null) {
      if (evt.wheelDelta == null) {
        scrollAmountY = evt.detail * 4;
      } else {
        scrollAmountY = -evt.wheelDelta / 4;
      }
    }
  }
  if (scrollAmountY != null && scrollAmountY != 0) {
    scroller.scrollTop += Math.round(scrollAmountY);
    var offsetHeight = scroller.offsetHeight;
    var scrollHeight = scroller.scrollHeight;
    var scrollTop = scroller.scrollTop;
    if (scrollAmountY > 0 && scrollHeight - scrollTop > offsetHeight || scrollAmountY < 0 && scrollTop > 0) {
      AdfAgent.AGENT.eatEvent(evt);
    }
  }
  if (scrollAmountX != null && scrollAmountX != 0) {
    scroller.scrollLeft += Math.round(scrollAmountX);
    if (hscroller) {
      hscroller.scrollLeft += Math.round(scrollAmountX);
    }
    AdfAgent.AGENT.eatEvent(evt);
  }
};
AdfDhtmlTableBasePeer.prototype._positionInnerTable = function(block, scrollLeft) {
  var agent = AdfAgent.AGENT;
  var rows = block.rows;
  var isRTL = AdfDhtmlTableBasePeer._isRTL();
  var freezeToEnd = this._freezeColumnsToEnd();
  for (var i = 0;i < rows.length;i++) {
    var cells = rows[i].cells;
    var last;
    if (freezeToEnd) {
      last = cells[0];
    } else {
      last = cells[cells.length - 1];
    }
    var div = AdfDhtmlTableBasePeer.FindFirstChildByTagName(last, "DIV");
    if (div) {
      agent.setScrollLeft(div, scrollLeft);
    }
  }
};
AdfDhtmlTableBasePeer._scrollColumnHeader = function(div, scrollLeft) {
  var second = AdfDhtmlTableBasePeer.__getChildBySubId(div, "d2");
  AdfAgent.AGENT.setScrollLeft(second, scrollLeft);
};
AdfDhtmlTableBasePeer._scrollColumnFooter = function(div, scrollLeft) {
  var second = AdfDhtmlTableBasePeer.__getChildBySubId(div, "fd2");
  AdfAgent.AGENT.setScrollLeft(second, scrollLeft);
};
AdfDhtmlTableBasePeer.FindFirstChildByTagName = function(parent, name) {
  AdfAssert.assert(parent != null, "Table peer cannot find first child by tag name if the parent is null!");
  var nodes = parent.childNodes;
  for (var i = 0;i < nodes.length;i++) {
    if (name == nodes[i].tagName) {
      return nodes[i];
    }
  }
  return null;
};
AdfDhtmlTableBasePeer._findFirstLevelChildrenByTagName = function(parent, name) {
  AdfAssert.assert(parent != null, "Table peer cannot find first level children by tag name if the parent is null!");
  var childNodes = [];
  var nodes = parent.childNodes;
  for (var i = 0;i < nodes.length;i++) {
    if (name == nodes[i].tagName) {
      childNodes.push(nodes[i]);
    }
  }
  return childNodes;
};
AdfDhtmlTableBasePeer.prototype.GetRowKeyAndRow = function(domElement, rootDomElement) {
  AdfAssert.assertDomElement(domElement);
  var currElement = domElement;
  var agent = AdfAgent.AGENT;
  if (currElement == null || currElement.nodeType != 1) {
    return null;
  }
  var rowKey = agent.getAttribute(currElement, AdfDhtmlTableBasePeer._ROW_KEY);
  while (rowKey == null) {
    if (currElement == null || currElement == rootDomElement) {
      return null;
    }
    currElement = currElement.parentNode;
    if (!this._isClickToEdit() && this._hasDetailStamp && agent.getNodeName(currElement) == "TR" && agent.getAttribute(currElement, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false)) {
      rowKey = agent.getAttribute(currElement.previousSibling, AdfDhtmlTableBasePeer._ROW_KEY);
      if (rowKey != null) {
        return [rowKey, currElement];
      }
    }
    if (currElement == null || currElement.nodeType != 1) {
      return null;
    }
    rowKey = agent.getAttribute(currElement, AdfDhtmlTableBasePeer._ROW_KEY);
  }
  return [rowKey, currElement];
};
AdfDhtmlTableBasePeer.prototype._hideDragColumnFooter = function(reorderIndex, colSpan) {
  var agent = AdfAgent.AGENT;
  var lastFrozen = this._lastFrozen;
  var firstFrozen = this._firstFrozen;
  var reorderColWidth = this._reorderColWidth;
  var hiddenCells = this._reorderHiddenCells;
  var footerDiv = this._getColumnFooter();
  var footerTable;
  var nestedDiv = null;
  if (this._hasFrozenColumn() && !this._isColumnFrozen(reorderIndex)) {
    nestedDiv = AdfDhtmlTableBasePeer.__getChildBySubId(footerDiv, "fd2");
    footerTable = AdfDhtmlTableBasePeer.__getChildBySubId(nestedDiv, "ft2");
  } else {
    footerTable = AdfDhtmlTableBasePeer.__getChildBySubId(footerDiv, "ft");
  }
  for (var i = 0;i < 2;i++) {
    var cells = footerTable.rows[i].cells;
    var cellIndex;
    if (this._freezeColumnsToStart() && !this._isColumnFrozen(reorderIndex)) {
      cellIndex = reorderIndex - lastFrozen - 1;
    } else {
      if (this._freezeColumnsToEnd() && this._isColumnFrozen(reorderIndex)) {
        cellIndex = reorderIndex - firstFrozen;
      } else {
        cellIndex = reorderIndex;
      }
    }
    for (var cellSpan = 0;cellSpan < colSpan;cellSpan++) {
      var cell = cells[cellIndex++];
      hiddenCells.push(cell);
      cell._afrIsFooter = true;
      cell.style.display = "none";
    }
  }
  if (this._processColGroup()) {
    this._hideReorderColGroupCols(footerTable, reorderIndex, colSpan);
  }
  this._adjustReorderColumnHeaderWidths(footerTable, nestedDiv, reorderIndex, reorderColWidth);
};
AdfDhtmlTableBasePeer.prototype._adjustReorderColumnHeaderWidths = function(headerTable, nestedDiv, colIndex, width) {
  var elemStyle = headerTable.style;
  elemStyle.width = parseInt(elemStyle.width) - width + "px";
  if (this._hasFrozenColumn()) {
    if (this._freezeColumnsToStart()) {
      if (!this._isColumnFrozen(colIndex)) {
        elemStyle = nestedDiv.style;
        elemStyle.width = parseInt(elemStyle.width) - width + "px";
      } else {
        elemStyle = headerTable.nextSibling.style;
        if (AdfDhtmlTableBasePeer._isRTL()) {
          elemStyle.right = parseInt(elemStyle.right) - width + "px";
        } else {
          elemStyle.left = parseInt(elemStyle.left) - width + "px";
        }
      }
    } else {
      if (headerTable.nextSibling) {
        elemStyle = headerTable.nextSibling.style;
      } else {
        elemStyle = headerTable.parentNode.nextSibling.style;
      }
      if (!this._isColumnFrozen(colIndex)) {
        if (AdfDhtmlTableBasePeer._isRTL()) {
          elemStyle.right = parseInt(elemStyle.right) - width + "px";
        } else {
          elemStyle.left = parseInt(elemStyle.left) - width + "px";
        }
        elemStyle = nestedDiv.style;
      }
      elemStyle.width = parseInt(elemStyle.width) - width + "px";
    }
  }
};
AdfDhtmlTableBasePeer.prototype._adjustReorderColumnFooterWidths = function(colIndex, width) {
  var footerDiv = this._getColumnFooter();
  var footerTable;
  var nestedDiv = null;
  if (this._hasFrozenColumn() && !this._isColumnFrozen(colIndex)) {
    nestedDiv = AdfDhtmlTableBasePeer.__getChildBySubId(footerDiv, "fd2");
    footerTable = AdfDhtmlTableBasePeer.__getChildBySubId(nestedDiv, "ft2");
  } else {
    footerTable = AdfDhtmlTableBasePeer.__getChildBySubId(footerDiv, "ft");
  }
  this._adjustReorderColumnHeaderWidths(footerTable, nestedDiv, colIndex, width);
};
AdfDhtmlTableBasePeer.prototype._adjustReorderInnerTableWidth = function(innerTable, width) {
  var elemStyle = innerTable.style;
  var newWidth = parseInt(elemStyle.width) - width;
  if (newWidth > 0) {
    elemStyle.width = newWidth + "px";
  }
  var innerTD = innerTable.parentNode.parentNode;
  elemStyle = innerTD.style;
  var widthStyle = elemStyle.width;
  if (widthStyle != "") {
    var newWidthValue = parseInt(widthStyle) - width;
    if (newWidthValue > 0) {
      elemStyle.width = newWidthValue + "px";
    }
  }
};
AdfDhtmlTableBasePeer.prototype._hideReorderColGroupCols = function(table, reorderIndex, colSpan, isBlock) {
  var colGroup = AdfDhtmlTableBasePeer.FindFirstChildByTagName(table, "COLGROUP");
  var firstFrozen = this._firstFrozen;
  var lastFrozen = this._lastFrozen;
  if (colGroup) {
    var hiddenCells = this._reorderHiddenCells;
    var cols = colGroup.getElementsByTagName("col");
    var startIndex = reorderIndex;
    if (this._freezeColumnsToStart() && !this._isColumnFrozen(reorderIndex)) {
      startIndex = reorderIndex - lastFrozen - 1;
    } else {
      if (this._freezeColumnsToEnd() && this._isColumnFrozen(reorderIndex)) {
        if (isBlock) {
          startIndex = reorderIndex - firstFrozen + 1;
        } else {
          startIndex = reorderIndex - firstFrozen;
        }
      }
    }
    for (i = startIndex;i < startIndex + colSpan;i++) {
      if (i < cols.length) {
        var col = cols[i];
        col._afrOriginalWidth = col.style.width;
        col.style.width = "0px";
        col.style.display = "none";
        hiddenCells.push(col);
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._adjustReorderNonFrozenCol = function(table, width) {
  var colGroup = AdfDhtmlTableBasePeer.FindFirstChildByTagName(table, "COLGROUP");
  if (colGroup) {
    var cols = colGroup.getElementsByTagName("col");
    var col = null;
    if (!this._freezeColumnsToEnd()) {
      col = cols[cols.length - 1];
    } else {
      col = cols[0];
    }
    col.style.width = parseInt(col.style.width) - width + "px";
  }
};
AdfDhtmlTableBasePeer.prototype._adjustReorderDataBodyNonFrozenCol = function(width) {
  var dataBody = this.GetDataBody();
  var blockList = dataBody.childNodes;
  var childCount = blockList.length;
  for (i = 0;i < childCount;i++) {
    this._adjustReorderNonFrozenCol(blockList[i], width);
  }
};
AdfDhtmlTableBasePeer.prototype._insertEmptyDropColGroupCol = function(table, targetIndex, targetColSpan, insertAfter, reorderColWidth, emptyDropCells, isBlock) {
  var colGroup = AdfDhtmlTableBasePeer.FindFirstChildByTagName(table, "COLGROUP");
  var firstFrozen = this._firstFrozen;
  var lastFrozen = this._lastFrozen;
  if (colGroup) {
    var cols = colGroup.getElementsByTagName("col");
    var cellIndex = targetIndex;
    if (this._freezeColumnsToStart() && !this._isColumnFrozen(targetIndex)) {
      cellIndex = targetIndex - lastFrozen - 1;
    } else {
      if (this._freezeColumnsToEnd() && this._isColumnFrozen(targetIndex)) {
        if (isBlock) {
          cellIndex = targetIndex - firstFrozen + 1;
        } else {
          cellIndex = targetIndex - firstFrozen;
        }
      }
    }
    if (insertAfter) {
      cellIndex += targetColSpan - 1;
    }
    var headerCell = cols[cellIndex];
    var emptyCell = colGroup.ownerDocument.createElement("col");
    insertAfter ? headerCell.nextSibling ? colGroup.insertBefore(emptyCell, headerCell.nextSibling) : colGroup.appendChild(emptyCell) : colGroup.insertBefore(emptyCell, headerCell);
    emptyCell.style.width = reorderColWidth + "px";
    emptyDropCells.push(emptyCell);
    colGroup.span++;
  }
};
AdfDhtmlTableBasePeer.prototype._forceRelayoutDataBody = function() {
  var dataBody = this.GetDataBody();
  var blockList = dataBody.childNodes;
  var childCount = blockList.length;
  var scrollLeft = this._currentScrollLeft;
  for (i = 0;i < childCount;i++) {
    var firstRow = blockList[i].rows[0];
    var firstRowStyle = firstRow.style;
    firstRowStyle.display = "block";
    var offsetWidth = firstRow.offsetWidth;
    firstRowStyle.display = "";
    if (this._hasFrozenColumn()) {
      innerTable = this._getNestedScrolledTable(firstRow);
      AdfAgent.AGENT.setScrollLeft(innerTable.parentNode, scrollLeft);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._processColumnReorderAction = function(domEvent) {
  var agent = AdfAgent.AGENT;
  var reorderTH = this._reorderTH;
  if (reorderTH) {
    this._columnReorderTracker = this._createReorderTracker();
    this._positionColumnReorderTracker(domEvent);
    this._insertEmptyDropColumn(domEvent);
    if (!this._colReorderDragCallback) {
      this._colReorderDragCallback = this.createCallback(this._handleColReorderDrag);
      this._colReorderDropCallback = this.createCallback(this._handleColReorderDrop);
      this._colReorderAbortCallback = this.createCallback(this._handleColReorderAbort);
    }
    agent.disableUserSelect(this.__getColumnHeader());
    AdfPage.PAGE.startDrag(domEvent, this._colReorderDragCallback, this._colReorderDropCallback, this._colReorderAbortCallback);
    agent.setCursor(reorderTH, "move", true);
    agent.setCursor(this.getDomElement(), "move", true);
    agent.eatEvent(domEvent);
  }
};
AdfDhtmlTableBasePeer.prototype._positionColumnReorderTracker = function(evt) {
  var tracker = this._columnReorderTracker, trackerStyle = tracker.style;
  var outerDiv = this.getDomElement();
  var agent = AdfAgent.AGENT;
  var mousePos = agent.getMousePosition(evt), divPos = agent.getElementPosition(outerDiv);
  var left = Math.max(mousePos.x - divPos.x + (AdfDhtmlTableBasePeer._isRTL() ? -tracker.offsetWidth + 8 : -8), 0), top = Math.max(mousePos.y - divPos.y - 8, 0);
  trackerStyle.left = left + "px";
  trackerStyle.top = top + "px";
};
AdfDhtmlTableBasePeer.prototype._autoScrollColumnsIfNecessary = function(evt) {
  var outerDiv = this.getDomElement();
  if (this._getScrollWidth() <= this._getScrollerOffsetWidth()) {
    return;
  }
  var agent = AdfAgent.getAgent();
  var mousePos = agent.getMousePosition(evt), divPos = agent.getElementPosition(outerDiv);
  var outerDivMouseX = Math.max(mousePos.x - divPos.x, 0);
  var headerTable, headerDiv = this.__getColumnHeader(), div2;
  var table1 = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "t"), table2;
  if (this._hasFrozenColumn()) {
    div2 = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "d2");
    table2 = AdfDhtmlTableBasePeer.__getChildBySubId(div2, "t2");
    headerTable = table2;
  } else {
    headerTable = table1;
  }
  var extraX = 0, scrollLeft = AdfDhtmlTableBasePeer._isRTL() ? this._getRTLScrollAdjustment() : this._currentScrollLeft;
  var shouldScrollLeft = false, shouldScrollRight = false;
  if (!div2 || outerDivMouseX > table1.offsetWidth) {
    if (div2) {
      extraX = table1.offsetWidth;
    }
    if (outerDivMouseX - extraX < AdfDhtmlTableBasePeer._AUTOSCROLL_MARGIN && scrollLeft > 0) {
      shouldScrollLeft = true;
    } else {
      if (outerDivMouseX - extraX > this._getScrollerClientWidth() - AdfDhtmlTableBasePeer._AUTOSCROLL_MARGIN) {
        shouldScrollRight = true;
      }
    }
  }
  if (shouldScrollLeft || shouldScrollRight) {
    extraX -= scrollLeft;
    var nRows = table1.rows.length;
    var rootExpando = AdfDhtmlTableBasePeer._ROOT_COLUMN, rhExpando = AdfDhtmlTableBasePeer._ROW_HEADER;
    for (var i = nRows - 1;i >= 0;i--) {
      var cells = headerTable.rows[i].cells, cellCount = cells.length;
      for (var c = 0;c < cellCount;c++) {
        var cell = cells[c];
        if (cell.getAttribute(rootExpando) && cell.getAttribute(rhExpando) == null) {
          var cellLeft = cell.offsetLeft + extraX;
          var cellRight = cellLeft + cell.offsetWidth;
          if (outerDivMouseX >= cellLeft && outerDivMouseX <= cellRight) {
            if (shouldScrollLeft) {
              scrollLeft = Math.max(scrollLeft - cell.offsetWidth, 0);
            } else {
              scrollLeft = Math.min(scrollLeft + cell.offsetWidth, this._getScrollWidth() - this._getScrollerClientWidth());
            }
            this._scrollerScrollToPos(scrollLeft, null);
            break;
          }
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._handleColReorderDrag = function(event, deltaX, deltaY) {
  this._autoScrollColumnsIfNecessary(event);
  this._positionColumnReorderTracker(event);
  this._insertEmptyDropColumn(event);
};
AdfDhtmlTableBasePeer.prototype._handleColReorderDrop = function(event, deltaX, deltaY) {
  var animDuration = null;
  if (this._targetReorderTH != null) {
    animDuration = this._getColReorderAnimationDuration();
    this._reorderId = this._reorderTH.id;
    if (animDuration > 0) {
      this._reorderColumnComponentsWithAnimation(animDuration);
    } else {
      this._reorderColumnComponentsWithoutAnimation();
    }
  }
  if (animDuration == 0) {
    if (this._columnReorderTracker != null) {
      var outerDiv = this.getDomElement();
      outerDiv.removeChild(this._columnReorderTracker);
      this._columnReorderTracker = null;
    }
    this._cleanUpAfterColumnReorder();
  }
  AdfAgent.AGENT.enableUserSelect(this.__getColumnHeader());
};
AdfDhtmlTableBasePeer.prototype._getColReorderAnimationDuration = function() {
  var animDuration = this._colReorderAnimationDuration;
  if (animDuration == undefined) {
    var page = AdfPage.PAGE;
    if (page.isAnimationEnabled()) {
      animDuration = parseInt(page.getLookAndFeel().getSkinProperty("af|table-tr-column-reorder-animation-duration"), 10);
    } else {
      animDuration = 0;
    }
    this._colScrollAnimationDuration = animDuration;
  }
  return animDuration;
};
AdfDhtmlTableBasePeer.prototype._reorderColumnComponentsWithoutAnimation = function() {
  var showColsEvent = this._queueColumnReorderEvent();
  if (!showColsEvent.isCanceled()) {
    var laf = AdfPage.PAGE.getLookAndFeel();
    var statusText = laf.getTranslatedString("af_table.LABEL_REORDERING_COLUMN");
    this.DisplayStatus(statusText, true);
  } else {
    this._handleColReorderAbort();
  }
};
AdfDhtmlTableBasePeer.prototype._queueColumnReorderEvent = function() {
  var component = this.getComponent();
  var showColsEvent = new AdfTableShowColumnsEvent(component, this._reorderId, "reorderColumn");
  showColsEvent.setTargetColumnId(this._targetReorderTH.id);
  showColsEvent.setAfterTarget(this._insertColumnAfter);
  showColsEvent.queue();
  return showColsEvent;
};
AdfDhtmlTableBasePeer.prototype._cleanUpAfterColumnReorder = function() {
  AdfAgent.AGENT.setCursor(this.getDomElement(), "");
  this._reorderTH = null;
  this._targetReorderTH = null;
  delete this._reorderId;
  delete this._reorderHiddenCells;
  delete this._insertColumnAfter;
  delete this._previousInsertColIndex;
  delete this._emptyDropCells;
  delete this._reorderEmptyCellWidth;
};
AdfDhtmlTableBasePeer.prototype._reorderColumnComponentsWithAnimation = function(animDuration) {
  var firstHeaderCell = this._emptyDropCells[0];
  var targetLeft = firstHeaderCell.offsetLeft;
  targetLeft += this._reorderDropColumnExtraX;
  AdfDhtmlElementAnimator.animate(AdfDhtmlElementAnimator.FRAME_METHOD_SLOW_FAST_SLOW, animDuration, [{element:this._columnReorderTracker, properties:{"top":0, "left":targetLeft}}], null, AdfDhtmlTableBasePeer._columnReorderAnimationComplete, this);
};
AdfDhtmlTableBasePeer.prototype._createReorderTracker = function() {
  var agent = AdfAgent.AGENT;
  var reorderTH = this._reorderTH;
  var reorderIndex = agent.getIntAttribute(reorderTH, "_d_index", -1);
  var colSpan = reorderTH.colSpan;
  var outerDiv = this.getDomElement();
  var dropColDiv = outerDiv.ownerDocument.createElement("div");
  var columnDivStyle = dropColDiv.style;
  outerDiv.appendChild(dropColDiv);
  columnDivStyle.overflow = "hidden";
  columnDivStyle.position = "absolute";
  columnDivStyle.zIndex = 1E3;
  agent.setOpacity(dropColDiv, 85);
  this._reorderHiddenCells = [];
  var colTable = this._createReorderColumnLayerHeader(dropColDiv, reorderIndex, colSpan);
  this._createReorderColumnLayerBody(dropColDiv, colTable, reorderIndex, colSpan);
  if (!this._footerless) {
    this._hideDragColumnFooter(reorderIndex, colSpan);
  }
  return dropColDiv;
};
AdfDhtmlTableBasePeer.prototype._createReorderColumnLayerHeader = function(dropColDiv, reorderIndex, colSpan) {
  var agent = AdfAgent.AGENT;
  var lastFrozen = this._lastFrozen;
  var firstFrozen = this._firstFrozen;
  var headerDiv = this.__getColumnHeader();
  var headerTable;
  var nestedDiv = null;
  if (this._hasFrozenColumn() && !this._isColumnFrozen(reorderIndex)) {
    nestedDiv = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "d2");
    headerTable = AdfDhtmlTableBasePeer.__getChildBySubId(nestedDiv, "t2");
  } else {
    headerTable = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "t");
  }
  var colTable = dropColDiv.ownerDocument.createElement("table");
  colTable.className = headerTable.className;
  colTable.cellSpacing = 0;
  colTableStyle = colTable.style;
  colTableStyle.tableLayout = "fixed";
  colTableStyle.position = "relative";
  dropColDiv.appendChild(colTable);
  var nRows = headerTable.rows.length;
  var reorderColWidth = 0;
  var hiddenCells = this._reorderHiddenCells;
  for (var i = 0;i < nRows;i++) {
    var cells = headerTable.rows[i].cells;
    var cellCount = cells.length;
    var cell = null;
    var cellSpan = 0;
    var headerRow;
    for (var j = 0;j < cellCount;j++) {
      var headerCell = cells[j];
      var headerCellFound = false;
      if (i > 0) {
        var headerIndex = agent.getIntAttribute(headerCell, "_d_index", -1);
        if (headerIndex > reorderIndex) {
          break;
        }
        headerCellFound = headerIndex == reorderIndex;
      } else {
        if (this._freezeColumnsToStart() && !this._isColumnFrozen(reorderIndex)) {
          headerCellFound = j == reorderIndex - lastFrozen - 1;
        } else {
          if (this._freezeColumnsToEnd() && this._isColumnFrozen(reorderIndex)) {
            headerCellFound = j == reorderIndex - firstFrozen;
          } else {
            headerCellFound = j == reorderIndex;
          }
        }
      }
      if (headerCellFound) {
        do {
          if (cell == null) {
            cell = headerCell;
            headerRow = colTable.insertRow(i);
            if (i == 0) {
              if (agent.getPlatform() == AdfAgent.IE_PLATFORM && agent.getVersion() < 8) {
                headerRow.style.position = "absolute";
              }
            }
          } else {
            cell = cells[++j];
          }
          cellSpan += cell.colSpan;
          var cellClone = this._cloneWithSelectedOption(cell, true);
          agent.removeIdsFromDomSubTree(cellClone);
          headerRow.appendChild(cellClone);
          headerRow.style.height = "auto";
          if (i != 0) {
            cellClone.rowSpan = 1;
            agent.setOuterHeight(cellClone, cell.offsetHeight);
          } else {
            reorderColWidth += cell.offsetWidth;
          }
          hiddenCells.push(cell);
        } while (cellSpan < colSpan);
        break;
      }
    }
  }
  for (var i = hiddenCells.length - 1;i >= 0;i--) {
    hiddenCells[i].style.display = "none";
  }
  if (this._processColGroup()) {
    this._hideReorderColGroupCols(headerTable, reorderIndex, colSpan);
  }
  this._reorderColWidth = reorderColWidth;
  dropColDiv.style.width = colTableStyle.width = reorderColWidth + "px";
  this._adjustReorderColumnHeaderWidths(headerTable, nestedDiv, reorderIndex, reorderColWidth);
  agent.setOuterHeight(colTable, headerTable.offsetHeight);
  return colTable;
};
AdfDhtmlTableBasePeer.prototype._createReorderColumnLayerBody = function(dropColDiv, colTable, reorderIndex, colSpan) {
  var agent = AdfAgent.AGENT;
  var platForm = agent.getPlatform();
  var isGecko = platForm == AdfAgent.GECKO_PLATFORM;
  var lastFrozen = this._lastFrozen;
  var firstFrozen = this._firstFrozen;
  var reorderColWidth = this._reorderColWidth;
  var colTable2 = this._cloneWithSelectedOption(colTable, false);
  dropColDiv.appendChild(colTable2);
  var hiddenCells = this._reorderHiddenCells;
  var dataBody = this.GetDataBody();
  var blockList = dataBody.childNodes;
  var childCount = blockList.length;
  var currentScrollTop = this._currentScrollTop;
  var startPos;
  for (var i = 0;i < childCount;i++) {
    var block = blockList[i];
    var rows = block.rows;
    var rowCount = rows.length;
    var rowIndex = 0;
    if (i == 0) {
      colTable2.className = block.className;
      startPos = block.startPos;
    }
    for (var r = 0;r < rowCount;r++) {
      var row = rows[r];
      var rowTopDelta = row.offsetTop - (currentScrollTop - startPos);
      if (rowTopDelta > dataBody.offsetHeight) {
        break;
      }
      var cells;
      var cellIndex;
      var innerTable = null;
      if (this._freezeColumnsToStart() && !this._isColumnFrozen(reorderIndex)) {
        innerTable = this._getNestedScrolledTable(row);
        cells = innerTable.rows[0].cells;
        cellIndex = reorderIndex - lastFrozen - 1;
      } else {
        if (this._freezeColumnsToEnd()) {
          if (!this._isColumnFrozen(reorderIndex)) {
            innerTable = this._getNestedScrolledTable(row);
            cells = innerTable.rows[0].cells;
            cellIndex = reorderIndex;
          } else {
            cellIndex = reorderIndex - firstFrozen + 1;
            cells = row.cells;
          }
        } else {
          cellIndex = reorderIndex;
          cells = row.cells;
        }
      }
      if (!(this._hasDetailStamp && agent.getAttribute(row, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false))) {
        var dataRow = colTable2.insertRow(rowIndex);
        rowIndex++;
        for (var cellSpan = 0;cellSpan < colSpan;cellSpan++) {
          var cell = cells[cellIndex++];
          cellClone = this._cloneWithSelectedOption(cell, true);
          agent.removeIdsFromDomSubTree(cellClone);
          dataRow.appendChild(cellClone);
          hiddenCells.push(cell);
          cell.style.display = "none";
          if (isGecko) {
            cellClone.style.height = row.offsetHeight + "px";
          } else {
            agent.setOuterHeight(cellClone, row.offsetHeight);
          }
          if (innerTable != null) {
            this._adjustReorderInnerTableWidth(innerTable, reorderColWidth);
            if (this._processColGroup()) {
              this._hideReorderColGroupCols(innerTable, reorderIndex, colSpan);
            }
          }
        }
      }
    }
    startPos += block.offsetHeight;
    if (this._processColGroup()) {
      if (!this._hasFrozenColumn() || this._isColumnFrozen(reorderIndex)) {
        this._hideReorderColGroupCols(block, reorderIndex, colSpan, true);
      }
      if (this._hasFrozenColumn() && !this._isColumnFrozen(reorderIndex)) {
        this._adjustReorderNonFrozenCol(block, reorderColWidth);
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._cloneWithSelectedOption = function(originalNode, deepFlag) {
  if (originalNode == null) {
    return null;
  }
  var clonedNode = originalNode.cloneNode(deepFlag);
  if (originalNode.nodeType == 1) {
    if (deepFlag) {
      var originalSelects = originalNode.getElementsByTagName("SELECT");
      var clonedSelects = clonedNode.getElementsByTagName("SELECT");
      var originalSelectsLength = originalSelects.length;
      var clonedSelectsLength = clonedSelects.length;
      AdfAssert.assert(originalSelectsLength == clonedSelectsLength, "Unexpected clone--different amounts of selects!");
      for (var i = 0;i < originalSelectsLength;i++) {
        clonedSelects[i].selectedIndex = originalSelects[i].selectedIndex;
      }
    }
    if (originalNode.tagName == "SELECT") {
      clonedNode.selectedIndex = originalNode.selectedIndex;
    }
  }
  return clonedNode;
};
AdfDhtmlTableBasePeer.prototype._insertEmptyDropColumn = function(evt) {
  var isRTL = AdfDhtmlTableBasePeer._isRTL();
  var outerDiv = this.getDomElement();
  var agent = AdfAgent.AGENT;
  var mousePos = agent.getMousePosition(evt);
  var divPos = agent.getElementPosition(outerDiv);
  var outerDivMouseX = Math.max(mousePos.x - divPos.x, 0);
  var headerDiv = this.__getColumnHeader();
  var div2;
  var table1 = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "t");
  var table2;
  if (this._hasFrozenColumn()) {
    div2 = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "d2");
    table2 = AdfDhtmlTableBasePeer.__getChildBySubId(div2, "t2");
  }
  var headerTable;
  var extraX = 0;
  if (!isRTL) {
    if (!this._freezeColumnsToEnd()) {
      if (outerDivMouseX <= table1.offsetWidth) {
        headerTable = table1;
      } else {
        if (div2) {
          extraX = table1.offsetWidth;
          extraX -= this._currentScrollLeft;
          headerTable = table2;
        } else {
          headerTable = table1;
        }
      }
    } else {
      if (outerDivMouseX >= table2.offsetWidth) {
        extraX = table2.offsetWidth;
        extraX -= this._currentScrollLeft;
        headerTable = table1;
      } else {
        headerTable = table2;
      }
    }
  } else {
    var outerWidth = outerDiv.offsetWidth;
    var table1Width = table1.offsetWidth;
    var table1Left = outerWidth - table1Width;
    if (div2 && outerDivMouseX <= table1Left) {
      headerTable = table2;
      if (outerWidth > table1Width + table2.offsetWidth) {
        extraX = outerWidth - (table1Width + table2.offsetWidth);
      } else {
        extraX = -this._getRTLScrollAdjustment();
        if (this._getScrollHeight() > this._getScrollerOffsetHeight()) {
          extraX += this._getScrollerOffsetWidth() - this._getScrollerClientWidth();
        }
      }
    } else {
      if (outerDiv.offsetWidth > table1.offsetWidth) {
        extraX = table1Left;
      }
      headerTable = table1;
    }
  }
  var insertColumnAfter;
  var targetReorderTH = null;
  if (!headerTable) {
    return;
  }
  if (!this._hasFrozenColumn()) {
    extraX -= isRTL ? this._getRTLScrollAdjustment() : this._currentScrollLeft;
  }
  var nRows = table1.rows.length;
  var rootExpando = AdfDhtmlTableBasePeer._ROOT_COLUMN, rhExpando = AdfDhtmlTableBasePeer._ROW_HEADER;
  for (var i = nRows - 1;i >= 0;i--) {
    var cells = headerTable.rows[i].cells, cellCount = cells.length;
    for (var c = 0;c < cellCount;c++) {
      var cell = cells[c];
      if (cell.getAttribute(rootExpando) && cell.getAttribute(rhExpando) == null) {
        if (cell.style.display == "none") {
          continue;
        }
        var cellLeft = cell.offsetLeft + extraX;
        var cellRight = cellLeft + cell.offsetWidth;
        if (!isRTL) {
          if (outerDivMouseX >= cellLeft && outerDivMouseX <= cellRight - cell.offsetWidth / 2) {
            targetReorderTH = cell;
            insertColumnAfter = false;
            break;
          } else {
            if (outerDivMouseX >= cellLeft && outerDivMouseX <= cellRight) {
              targetReorderTH = cell;
              insertColumnAfter = cell.id.indexOf("_afrBlankColumn") == -1;
              break;
            }
          }
        } else {
          if (outerDivMouseX >= cellLeft && outerDivMouseX <= cellRight - cell.offsetWidth / 2) {
            targetReorderTH = cell;
            insertColumnAfter = cell.id.indexOf("_afrBlankColumn") == -1;
            break;
          } else {
            if (outerDivMouseX >= cellLeft && outerDivMouseX <= cellRight) {
              targetReorderTH = cell;
              insertColumnAfter = false;
              break;
            }
          }
        }
      }
    }
  }
  if (targetReorderTH == null && this._previousInsertColIndex == null) {
    for (var i = nRows - 1;i >= 0;i--) {
      var cells = headerTable.rows[i].cells;
      var cellCount = cells.length;
      var lastCell;
      if (cellCount > 0) {
        lastCell = cells[cellCount - 1];
      }
      if (lastCell && lastCell.getAttribute(rootExpando) && lastCell.getAttribute(rhExpando) == null) {
        if (lastCell == this._reorderTH && lastCell.previousSibling) {
          targetReorderTH = lastCell.previousSibling;
        } else {
          targetReorderTH = lastCell;
        }
        insertColumnAfter = true;
        break;
      }
    }
  }
  if (targetReorderTH != null) {
    var targetIndex = agent.getIntAttribute(targetReorderTH, "_d_index", -1);
    var targetColSpan = targetReorderTH.colSpan;
    var insertColIndex = insertColumnAfter ? targetIndex + targetColSpan : targetIndex;
    if (insertColIndex != this._previousInsertColIndex) {
      this._removeEmptyDropColumn(table2, div2);
      this._targetReorderTH = targetReorderTH;
      this._insertColumnAfter = insertColumnAfter;
      this._previousInsertColIndex = insertColIndex;
      this._reorderDropColumnExtraX = extraX;
      this._targetHeaderTable = headerTable;
      this._insertEmptyDropColumnHeader(targetReorderTH, targetIndex, targetColSpan, table2, div2);
      if (div2 != null && isRTL) {
        agent.setScrollLeft(div2, this._currentScrollLeft);
      }
      this._insertEmptyDropColumnBody(targetIndex, targetColSpan);
      if (!this._footerless) {
        this._insertEmptyDropColumnFooter(targetIndex, targetColSpan);
      }
      if (this._processColGroup()) {
        this._forceRelayoutDataBody();
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._removeEmptyDropColumn = function(innerTable, innerDiv) {
  var emptyDropCells = this._emptyDropCells;
  if (emptyDropCells) {
    var agent = AdfAgent.AGENT;
    var isWebKit = agent.getPlatform() == AdfAgent.WEBKIT_PLATFORM;
    var targetIndex = agent.getIntAttribute(this._targetReorderTH, "_d_index", -1);
    var reorderColWidth = this._reorderColWidth;
    for (var i = emptyDropCells.length - 1;i >= 0;i--) {
      var emptyDropCell = emptyDropCells[i];
      var tagName = emptyDropCell.tagName;
      if (isWebKit && tagName == "COL") {
        var colGroup = emptyDropCell.parentNode;
        colGroup.span--;
      } else {
        if (tagName == "TD" && (this._hasFrozenColumn() && !this._isColumnFrozen(targetIndex)) && !emptyDropCell._afrIsFooter) {
          var row = emptyDropCell.parentNode;
          var cellTable = row.parentNode.parentNode;
          this._adjustReorderInnerTableWidth(cellTable, reorderColWidth);
        }
      }
      emptyDropCell.parentNode.removeChild(emptyDropCell);
    }
    this._adjustReorderColumnHeaderWidths(this._targetHeaderTable, innerDiv, targetIndex, reorderColWidth);
    if (this._processColGroup() && (this._hasFrozenColumn() && !this._isColumnFrozen(targetIndex))) {
      this._adjustReorderDataBodyNonFrozenCol(reorderColWidth);
    }
    if (!this._footerless) {
      this._adjustReorderColumnFooterWidths(targetIndex, reorderColWidth);
    }
  }
  this._emptyDropCells = [];
};
AdfDhtmlTableBasePeer.prototype._insertEmptyDropColumnHeader = function(targetReorderTH, targetIndex, targetColSpan, innerTable, innerDiv) {
  var agent = AdfAgent.AGENT;
  var insertAfter = this._insertColumnAfter;
  var reorderColWidth = this._reorderColWidth;
  var emptyDropCells = this._emptyDropCells;
  var lastFrozen = this._lastFrozen;
  var firstFrozen = this._firstFrozen;
  var headerTable = this._targetHeaderTable;
  var reorderEmptyCellWidth = this._reorderEmptyCellWidth;
  var ownerDoc = targetReorderTH.ownerDocument;
  var isFilterable = this._isFilterable();
  var insertedRows = isFilterable ? 3 : 2;
  for (var i = 0;i < insertedRows;i++) {
    var row = headerTable.rows[i];
    var cells = row.cells;
    if (i < insertedRows - 1) {
      var cellIndex = targetIndex;
      if (this._hasFrozenColumn()) {
        if (this._freezeColumnsToStart() && !this._isColumnFrozen(targetIndex)) {
          cellIndex = targetIndex - lastFrozen - 1;
        } else {
          if (this._freezeColumnsToEnd() && this._isColumnFrozen(targetIndex)) {
            cellIndex = targetIndex - firstFrozen;
          }
        }
      }
      if (insertAfter) {
        cellIndex += targetColSpan - 1;
      }
      headerCell = cells[cellIndex];
    } else {
      headerCell = targetReorderTH;
    }
    var emptyCell = ownerDoc.createElement("th");
    insertAfter ? headerCell.nextSibling ? row.insertBefore(emptyCell, headerCell.nextSibling) : row.appendChild(emptyCell) : row.insertBefore(emptyCell, headerCell);
    if (i == 0) {
      emptyCell.style.cssText = headerCell.style.cssText;
    } else {
      emptyCell.className = AdfDhtmlTableBasePeer._DROP_TARGET_CLASS + " " + headerCell.className;
      if (i == insertedRows - 1) {
        emptyCell.rowSpan = headerTable.rows.length - (isFilterable ? 2 : 1);
      }
      emptyCell.innerHTML = "\x26nbsp;";
    }
    if (reorderEmptyCellWidth) {
      emptyCell.style.width = reorderEmptyCellWidth;
    } else {
      agent.setOuterWidth(emptyCell, reorderColWidth);
      reorderEmptyCellWidth = this._reorderEmptyCellWidth = parseInt(emptyCell.style.width) + "px";
    }
    emptyDropCells.push(emptyCell);
  }
  this._adjustReorderColumnHeaderWidths(headerTable, innerDiv, targetIndex, -reorderColWidth);
  if (this._processColGroup()) {
    this._insertEmptyDropColGroupCol(headerTable, targetIndex, targetColSpan, insertAfter, reorderColWidth, emptyDropCells);
  }
};
AdfDhtmlTableBasePeer.prototype._insertEmptyDropColumnBody = function(targetIndex, targetColSpan) {
  var agent = AdfAgent.AGENT;
  var platform = agent.getPlatform();
  var isIE = platform == AdfAgent.IE_PLATFORM;
  var isRTL = AdfDhtmlTableBasePeer._isRTL();
  var lastFrozen = this._lastFrozen;
  var firstFrozen = this._firstFrozen;
  var insertAfter = this._insertColumnAfter;
  var reorderColWidth = this._reorderColWidth;
  var emptyDropCells = this._emptyDropCells;
  var reorderEmptyCellWidth = this._reorderEmptyCellWidth;
  var scrollLeft = this._currentScrollLeft;
  var dataBody = this.GetDataBody();
  var blockList = dataBody.childNodes;
  var childCount = blockList.length;
  var ownerDoc = dataBody.ownerDocument;
  var selClassName = AdfDhtmlTableBasePeer._DROP_TARGET_CLASS;
  var currentScrollTop = this._currentScrollTop;
  var cellIndex = insertAfter ? targetIndex + targetColSpan - 1 : targetIndex;
  var startPos;
  for (var i = 0;i < childCount;i++) {
    var block = blockList[i];
    var rows = block.rows;
    var rowCount = rows.length;
    if (i == 0) {
      startPos = block.startPos;
    }
    var blockOffsetTop = currentScrollTop - startPos;
    for (var r = 0;r < rowCount;r++) {
      var row = rows[r];
      var rowTopDelta = row.offsetTop - blockOffsetTop;
      if (rowTopDelta > dataBody.offsetHeight) {
        break;
      }
      if (!(this._hasDetailStamp && agent.getAttribute(row, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false))) {
        var cell;
        var innerTable = null;
        if (this._freezeColumnsToStart() && !this._isColumnFrozen(targetIndex)) {
          innerTable = this._getNestedScrolledTable(row);
          row = innerTable.rows[0];
          cell = row.cells[cellIndex - lastFrozen - 1];
        } else {
          if (this._freezeColumnsToEnd()) {
            if (!this._isColumnFrozen(targetIndex)) {
              innerTable = this._getNestedScrolledTable(row);
              row = innerTable.rows[0];
              cell = row.cells[cellIndex];
            } else {
              cell = row.cells[cellIndex - firstFrozen + 1];
            }
          } else {
            cell = row.cells[cellIndex];
          }
        }
        var emptyCell = ownerDoc.createElement("td");
        emptyCell.className = selClassName + " " + cell.className;
        insertAfter ? cell.nextSibling ? row.insertBefore(emptyCell, cell.nextSibling) : row.appendChild(emptyCell) : row.insertBefore(emptyCell, cell);
        emptyCell.style.width = reorderEmptyCellWidth;
        emptyCell.noWrap = true;
        emptyCell.innerHTML = "\x26nbsp;";
        emptyDropCells.push(emptyCell);
        if (innerTable != null) {
          this._adjustReorderInnerTableWidth(innerTable, -reorderColWidth);
          if (this._processColGroup()) {
            this._insertEmptyDropColGroupCol(innerTable, targetIndex, targetColSpan, insertAfter, reorderColWidth, emptyDropCells);
          } else {
            if (isIE) {
              var innerDiv = innerTable.parentNode;
              if (isRTL || agent.getScrollLeft(innerDiv) != scrollLeft) {
                agent.setScrollLeft(innerDiv, scrollLeft);
              }
            }
          }
        }
      }
    }
    startPos += block.offsetHeight;
    if (this._processColGroup()) {
      if (!this._hasFrozenColumn() || this._isColumnFrozen(targetIndex)) {
        this._insertEmptyDropColGroupCol(block, targetIndex, targetColSpan, insertAfter, reorderColWidth, emptyDropCells, true);
      }
      if (this._hasFrozenColumn() && !this._isColumnFrozen(targetIndex)) {
        this._adjustReorderNonFrozenCol(block, -reorderColWidth);
      }
    }
  }
  if (isRTL && !this._hasFrozenColumn()) {
    agent.setScrollLeft(dataBody, scrollLeft);
  }
};
AdfDhtmlTableBasePeer.prototype._insertEmptyDropColumnFooter = function(targetIndex, targetColSpan) {
  var agent = AdfAgent.AGENT;
  var isWebKit = agent.getPlatform() == AdfAgent.WEBKIT_PLATFORM;
  var lastFrozen = this._lastFrozen;
  var firstFrozen = this._firstFrozen;
  var insertAfter = this._insertColumnAfter;
  var reorderColWidth = this._reorderColWidth;
  var emptyDropCells = this._emptyDropCells;
  var reorderEmptyCellWidth = this._reorderEmptyCellWidth;
  var footerDiv = this._getColumnFooter();
  var footerTable;
  var nestedDiv = null;
  var cellIndex = insertAfter ? targetIndex + targetColSpan - 1 : targetIndex;
  if (this._hasFrozenColumn() && !this._isColumnFrozen(targetIndex)) {
    nestedDiv = AdfDhtmlTableBasePeer.__getChildBySubId(footerDiv, "fd2");
    footerTable = AdfDhtmlTableBasePeer.__getChildBySubId(nestedDiv, "ft2");
    if (this._freezeColumnsToStart()) {
      cellIndex -= lastFrozen + 1;
    }
    if (agent.getScrollLeft(nestedDiv) != this._currentScrollLeft) {
      agent.setScrollLeft(nestedDiv, this._currentScrollLeft);
    }
  } else {
    footerTable = AdfDhtmlTableBasePeer.__getChildBySubId(footerDiv, "ft");
    if (this._freezeColumnsToEnd() && this._isColumnFrozen(targetIndex)) {
      cellIndex -= firstFrozen;
    }
  }
  var ownerDoc = footerDiv.ownerDocument;
  var emptyCell;
  for (var i = 0;i < 2;i++) {
    var row = footerTable.rows[i];
    var cells = row.cells;
    emptyCell = ownerDoc.createElement(i == 0 ? "th" : "td");
    cell = row.cells[cellIndex];
    insertAfter ? cell.nextSibling ? row.insertBefore(emptyCell, cell.nextSibling) : row.appendChild(emptyCell) : row.insertBefore(emptyCell, cell);
    emptyCell.style.width = reorderEmptyCellWidth;
    if (i == 0) {
      emptyCell.style.cssText = cell.style.cssText;
    } else {
      emptyCell.className = cell.className;
      emptyCell.innerHTML = "\x26nbsp;";
      emptyCell._afrIsFooter = true;
      if (isWebKit) {
        emptyCell.rowSpan = "10";
      }
    }
    emptyDropCells.push(emptyCell);
  }
  this._adjustReorderColumnHeaderWidths(footerTable, nestedDiv, targetIndex, -reorderColWidth);
  if (this._processColGroup()) {
    this._insertEmptyDropColGroupCol(footerTable, targetIndex, targetColSpan, insertAfter, reorderColWidth, emptyDropCells);
  }
};
AdfDhtmlTableBasePeer._columnReorderAnimationComplete = function(peer) {
  peer._reorderColumnComponentsWithoutAnimation();
  peer._cleanUpAfterColumnReorder();
};
AdfDhtmlTableBasePeer.prototype._handleColReorderAbort = function() {
  var agent = AdfAgent.AGENT;
  var isWebKit = AdfAgent.AGENT.getPlatform() == AdfAgent.WEBKIT_PLATFORM;
  var headerDiv = this.__getColumnHeader();
  var table1 = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "t");
  var div2;
  var table2;
  if (this._hasFrozenColumn()) {
    div2 = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "d2");
    table2 = AdfDhtmlTableBasePeer.__getChildBySubId(div2, "t2");
  }
  this._removeEmptyDropColumn(table2, div2);
  var reorderIndex = agent.getIntAttribute(this._reorderTH, "_d_index", -1);
  var hiddenCells = this._reorderHiddenCells;
  var reorderColWidth = this._reorderColWidth;
  var cellCount = hiddenCells.length;
  var row, previousRow;
  for (var i = 0;i < cellCount;i++) {
    var cell = hiddenCells[i];
    cell.style.display = "";
    if (cell._afrOriginalWidth) {
      cell.style.width = cell._afrOriginalWidth;
    }
    if (cell.tagName == "TD" && !cell._afrIsFooter) {
      row = cell.parentNode;
      if (this._hasFrozenColumn() && !this._isColumnFrozen(reorderIndex) && row != previousRow) {
        this._adjustReorderInnerTableWidth(row.parentNode.parentNode, -reorderColWidth);
      }
      previousRow = row;
    }
  }
  if (this._processColGroup() && (this._hasFrozenColumn() && !this._isColumnFrozen(reorderIndex))) {
    this._adjustReorderDataBodyNonFrozenCol(-reorderColWidth);
  }
  this._adjustReorderColumnHeaderWidths((this._hasFrozenColumn() && !this._isColumnFrozen(reorderIndex) ? table2 : table1, div2, reorderIndex, -reorderColWidth));
  if (!this._footerless) {
    this._adjustReorderColumnFooterWidths(reorderIndex, -reorderColWidth);
  }
  if (this._columnReorderTracker != null) {
    var outerDiv = this.getDomElement();
    outerDiv.removeChild(this._columnReorderTracker);
    this._columnReorderTracker = null;
  }
  this._cleanUpAfterColumnReorder();
  agent.enableUserSelect(this.__getColumnHeader());
};
AdfDhtmlTableBasePeer.prototype.GetFocusManager = function() {
  return this._focusManager;
};
AdfDhtmlTableBasePeer.prototype.GetFocusedRowKey = function() {
  return this._focusManager.currency;
};
AdfDhtmlTableBasePeer.prototype.GetLastRowKey = function() {
  var lastRowKey = this._focusManager.currency;
  if (lastRowKey == null && this._isRowSelectionEnabled()) {
    var component = this.getComponent();
    var state = component.getSelectedRowKeys();
    for (var rowKey in state) {
      if (state[rowKey] == AdfUITable._SELECT_ALL) {
        continue;
      }
      if (state[rowKey]) {
        lastRowKey = rowKey;
      }
    }
  }
  return lastRowKey;
};
AdfDhtmlTableBasePeer.prototype.suppressSelectionEventDelivery = function(freeze) {
  this._suppressSelectionEventDelivery = freeze;
};
AdfDhtmlTableBasePeer.prototype.canDeliverSelectionEvent = function() {
  return !this._suppressSelectionEventDelivery;
};
AdfDhtmlTableBasePeer.prototype._getTargetRowHeader = function(node) {
  var rh = null;
  var rootDomElement = this.getDomElement();
  while (node && node != rootDomElement) {
    var agent = AdfAgent.getAgent();
    if (agent.getNodeName(node) == "TD") {
      if (node.getAttribute(AdfDhtmlTableBasePeer._ROW_HEADER) != null) {
        rh = node;
      }
      break;
    }
    node = node.parentNode;
  }
  return rh;
};
AdfDhtmlTableBasePeer.prototype.__getSelectedColumns = function() {
  var leafColumns = this.__getVisibleLeafColumns();
  var selectedColumns = [], colCount = leafColumns.length;
  for (var i = 0;i < colCount;i++) {
    var col = leafColumns[i];
    if (col && col.getSelected()) {
      selectedColumns.push(col);
    }
  }
  return selectedColumns;
};
AdfDhtmlTableBasePeer.prototype.GetRowHeaderCellFromRow = function(row) {
  AdfAssert.assert(row != null, "Unable to get row header cell from a non-valid row!");
  var agent = AdfAgent.getAgent();
  var rh = null, cell, cells = row.cells, cellCount = cells.length;
  for (var i = 0;i < cellCount;i++) {
    cell = cells[i];
    if (cell.getAttribute(AdfDhtmlTableBasePeer._ROW_HEADER) != null) {
      rh = cell;
      break;
    }
  }
  return rh;
};
AdfDhtmlTableBasePeer.prototype._isTargetCellEditable = function(node, isFilter) {
  var agent = AdfAgent.getAgent();
  var nodeName;
  var rootElement = this.getDomElement();
  var inputRegExp = AdfDhtmlTableBasePeer._INPUT_REGEXP;
  while (null != node && node != rootElement && (nodeName = agent.getNodeName(node)) != "TD" && nodeName != "TH" && nodeName != "TR") {
    if (node.nodeType == 3) {
      node = node.parentNode;
      continue;
    }
    var tabIndex = node.getAttribute("tabIndex", 2);
    if (tabIndex != null && tabIndex >= 0 && tabIndex != 32768 && tabIndex != 65535) {
      return true;
    } else {
      if (nodeName.match(inputRegExp)) {
        if (isFilter || tabIndex != -1) {
          return true;
        }
      }
    }
    node = node.parentNode;
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype._isTargetTextOnlyNode = function(domNode) {
  if (domNode.tagName == "SPAN" && domNode.getAttribute(AdfDhtmlTableBasePeer._CELL_TEXT_KEY) == "on") {
    return true;
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype._isTargetNavigable = function(node) {
  return node && node.tagName == "A" && node.href && node.href.length > 0 && node.getAttribute("href") != "#";
};
AdfDhtmlTableBasePeer.prototype._handleRowMouseDownForC2E = function(params) {
  this._handleRowMouseDown(params.evt, params.targetNode, params.isLeftButton, params.toggleKeyDown, params.shiftKeyDown, params.rowKey, params.row);
  if (this._handleRowMouseDownTimerId) {
    delete this._handleRowMouseDownTimerId;
  }
  return;
};
AdfDhtmlTableBasePeer.prototype._handleRowMouseDown = function(evt, targetNode, isLeftButton, toggleKeyDown, shiftKeyDown, rowKey, row) {
  if (!this._isClickToEdit() && this._editableTableReadOnlyMode || this._isClickToEdit() && rowKey && this._getActiveRowKey() == rowKey) {
    this._setReadOnlyMode(false, targetNode, false);
  }
  if (this._getExpandAction(targetNode)) {
    return;
  }
  var agent = AdfAgent.AGENT;
  var rowHeaderCell = this._getTargetRowHeader(targetNode);
  var isRowHeader = null != rowHeaderCell;
  var isTargetCellEditable = this._isTargetCellEditable(targetNode);
  var params = this._getCellAndIndexForNode(targetNode, row);
  var cellIndex = params.cellIndex;
  if (!isTargetCellEditable && !this._isClickToEdit() && !this._contextMenuSelect) {
    this._grabFocus();
  }
  if (isRowHeader) {
    this.UpdateFocusManager(AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE, rowKey, rowHeaderCell);
  } else {
    if (isLeftButton || this._contextMenuSelect) {
      this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row, params.cell);
    }
  }
  if (this._isClickToEdit() && (this._getActiveRowKey() != rowKey || this.getComponent().getProperty(AdfDhtmlTableBasePeer._REMAIN_READ_ONLY))) {
    this._ctePatternStart = undefined;
    if (this._getActiveRowKey() != rowKey) {
      this._setActiveRowKey(rowKey);
    }
    this._saveClickToEditRequest(targetNode, row);
    if (rowKey) {
      this._setReadOnlyMode(false, targetNode, false);
    }
  } else {
    if (isTargetCellEditable) {
      if (this._ctePatternStart != cellIndex) {
        this._ctePatternStart = undefined;
      }
    }
  }
  if (!this._isRowSelectionEnabled()) {
    return;
  }
  var isRowSelected = this._selIsSelected(rowKey);
  if (isLeftButton || this._contextMenuSelect && !isLeftButton) {
    if (!isRowSelected) {
      this._doRowSelection(targetNode, toggleKeyDown, shiftKeyDown, rowKey, row);
      this._ignoreRowClick = true;
      if (!isTargetCellEditable && evt != null) {
        agent.eatEvent(evt);
      }
    }
    if (!isTargetCellEditable && isLeftButton || this._contextMenuSelect && !isLeftButton) {
      targetNode = params.cell;
      if (!this._isInDetailStampRow(targetNode)) {
        var isIOSAgent = agent.getDomWindow().AdfSafariMobileAgent && agent instanceof AdfSafariMobileAgent && agent.getOS() != AdfAgent.ANDROID_OS;
        if (!isIOSAgent && !this._disableRowMouseDownCellFocus && !this._setFocusOnEditableElementInNode(agent, targetNode)) {
          if (agent.getPlatform() != AdfAgent.IE_PLATFORM || this._isClickToEdit()) {
            this._setFocusOnNode(targetNode);
          }
        }
      }
      if (isRowHeader && this._isMultipleRowSelect() && evt != null) {
        agent.disableUserSelect(this.GetDataBody());
        this._doRowHeaderDrag(evt, rowKey);
        agent.eatEvent(evt);
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._isInDetailStampRow = function(node) {
  if (!this._hasDetailStamp) {
    return false;
  }
  var outer = this.getDomElement();
  var agent = AdfAgent.AGENT;
  while (node && node != outer) {
    if (agent.getNodeName(node) == "TR" && agent.getAttribute(node, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false)) {
      return true;
    }
    node = node.parentNode;
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype._setFocusOnNode = function(targetNode, delayed) {
  var tabIndex = targetNode.tabIndex;
  targetNode.tabIndex = 0;
  if (delayed) {
    AdfFocusUtils.focusElementDelayed(targetNode, 1);
  } else {
    AdfFocusUtils.focusElement(targetNode);
  }
  targetNode.tabIndex = tabIndex;
};
AdfDhtmlTableBasePeer.prototype._handleDataBodySelectStart = function(evt) {
  if (!evt) {
    evt = AdfPage.PAGE.getDomWindow().event;
  }
  var agent = AdfAgent.AGENT;
  var target = agent.getEventTarget(evt);
  if (this._isRowSelectionEnabled() && !this._isTargetCellEditable(target)) {
    agent.preventDefault(evt);
  }
};
AdfDhtmlTableBasePeer.prototype._doRowHeaderDrag = function(evt, rowKey) {
  this._startDragRowHeaderKey = rowKey;
  if (this._handleRowHeaderDragCallback == null) {
    this._handleRowHeaderDragCallback = this.createCallback(this._handleRowHeaderDrag);
    this._endRowHeaderDragCallback = this.createCallback(this._endRowHeaderDrag);
  }
  AdfPage.PAGE.startDrag(evt, this._handleRowHeaderDragCallback, this._endRowHeaderDragCallback);
};
AdfDhtmlTableBasePeer.prototype._handleRowHeaderDrag = function(event, deltaX, deltaY) {
  var agent = AdfAgent.getAgent();
  var eventTarget = agent.getEventTarget(event);
  var rowHeaderCell = this._getTargetRowHeader(eventTarget);
  if (rowHeaderCell != null) {
    var parentRow = eventTarget.parentNode;
    while (parentRow && agent.getNodeName(parentRow) != "TR") {
      parentRow = parentRow.parentNode;
    }
    if (parentRow) {
      var rowKey = parentRow.getAttribute(AdfDhtmlTableBasePeer._ROW_KEY);
      if (rowKey != null) {
        this._selectRowRange(this._startDragRowHeaderKey, rowKey);
        this._startDragRowHeaderKey = rowKey;
        this._autoScrollRows(event);
      }
    }
  } else {
    var outer = this.getDomElement();
    var parentRow = eventTarget.parentNode;
    while (parentRow && parentRow != outer) {
      if (agent.getNodeName(parentRow) == "TR" && agent.getAttribute(parentRow, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false)) {
        this._autoScrollRows(event);
        break;
      }
      parentRow = parentRow.parentNode;
    }
  }
};
AdfDhtmlTableBasePeer.prototype._autoScrollRows = function(evt) {
  var agent = AdfAgent.AGENT;
  var dataBody = this.GetDataBody();
  if (this._getScrollHeight() <= this._getScrollerOffsetHeight()) {
    return;
  }
  var mousePos = agent.getMousePosition(evt);
  var divPos = agent.getElementPosition(dataBody);
  var divMouseY = Math.max(mousePos.y - divPos.y, 0);
  var scrollUp = divMouseY < AdfDhtmlTableBasePeer._AUTOSCROLL_MARGIN;
  var scrollDown = divMouseY > dataBody.offsetHeight - AdfDhtmlTableBasePeer._AUTOSCROLL_MARGIN;
  if (scrollUp || scrollDown) {
    var scrollToPos = this._currentScrollTop + (scrollDown ? this._averageRowHeight : -this._averageRowHeight);
    if (scrollToPos >= 0 && scrollToPos < this._getScrollHeight()) {
      this._scrollerScrollToPos(null, scrollToPos);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._endRowHeaderDrag = function(event, deltaX, deltaY) {
  this._startDragRowHeaderKey = null;
  AdfAgent.AGENT.enableUserSelect(this.GetDataBody());
};
AdfDhtmlTableBasePeer.prototype._handleRowClick = function(targetNode, isLeftButtonClick, toggleKeyDown, shiftKeyDown, rowKey, row) {
  var agent = AdfAgent.getAgent();
  var rowHeaderCell = this._getTargetRowHeader(targetNode);
  var isRowHeader = null != rowHeaderCell;
  if (this._ignoreRowClick) {
    this._ignoreRowClick = false;
    return;
  }
  if (this._isRowSelectionEnabled()) {
    if (isRowHeader) {
      this.UpdateFocusManager(AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE, rowKey, rowHeaderCell);
    } else {
      this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row);
    }
    if (isLeftButtonClick || this._contextMenuSelect && !isLeftButtonClick) {
      this._doRowSelection(targetNode, toggleKeyDown, shiftKeyDown, rowKey, row);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._doRowSelection = function(targetNode, toggleKeyDown, shiftKeyDown, rowKey, row) {
  var isMultiSelect = this._isMultipleRowSelect();
  var agent = AdfAgent.AGENT;
  if (isMultiSelect && toggleKeyDown) {
    this._unSelectAllColumns();
    this._anchorRowKey = rowKey;
    if (this._selIsSelected(rowKey)) {
      if (!agent.disableSelectionToggleOnEditableCell() || !this._isTargetCellEditable(targetNode)) {
        this._selUnselectRow(rowKey, row);
      }
    } else {
      this._selSelectRow(rowKey, row);
    }
  } else {
    if (isMultiSelect && shiftKeyDown) {
      var anchorRowKey = this._anchorRowKey;
      if (!anchorRowKey) {
        anchorRowKey = this._anchorRowKey = rowKey;
      } else {
        if (!this.FindRowByKey(anchorRowKey)) {
          var component = this.getComponent();
          var evt = new AdfSelectionEvent(component, component.getSelectedRowKeys(), null);
          evt.setSelectionRange(anchorRowKey, rowKey);
          evt.queue();
          return;
        }
      }
      this.suppressSelectionEventDelivery(true);
      this._selUnselectAll();
      this._queueColumnSelectionEvent();
      this.suppressSelectionEventDelivery(false);
      this._selectRowRange(anchorRowKey, rowKey);
    } else {
      this._anchorRowKey = rowKey;
      if (!this._selIsOnlySelection(rowKey)) {
        this.suppressSelectionEventDelivery(true);
        this._selUnselectAll();
        this.suppressSelectionEventDelivery(false);
        this._selSelectRow(rowKey, row);
        this._queueColumnSelectionEvent();
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._selUnselectAll = function() {
  this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UNSELECT, true);
  this._unSelectAllColumns();
  this._updateTableSelectionState(new Object);
};
AdfDhtmlTableBasePeer.prototype._selSelectRow = function(rowKey, row, skipUpdate) {
  this._selHighlightRow(row);
  if (!skipUpdate) {
    var component = this.getComponent();
    var state = {};
    var oldState = component.getSelectedRowKeys();
    var isSelectAll = oldState ? oldState[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY] : false;
    if (isSelectAll) {
      AdfCollections.copyInto(state, oldState);
      var index = state[rowKey];
      delete state[rowKey];
      this._adjustSelectedRowKeyIndex(state, index);
    } else {
      state[rowKey] = 1;
      this._mergeSelectedRowKeys(oldState, state, state);
    }
    this._updateTableSelectionState(state);
  }
};
AdfDhtmlTableBasePeer.prototype._selUnselectRow = function(rowKey, row) {
  this._selUnhighlightRow(row);
  var state = {};
  var oldState = this.getComponent().getSelectedRowKeys();
  var isSelectAll = oldState[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY];
  if (isSelectAll) {
    state[rowKey] = 1;
    this._mergeSelectedRowKeys(oldState, state, state);
  } else {
    AdfCollections.copyInto(state, oldState);
    var index = state[rowKey];
    delete state[rowKey];
    this._adjustSelectedRowKeyIndex(state, index);
  }
  this._updateTableSelectionState(state);
};
AdfDhtmlTableBasePeer.prototype._mergeSelectedRowKeys = function(originalRows, newRows, mergedRows, inState1Size) {
  if (!originalRows || !newRows) {
    var outTarget = originalRows ? originalRows : newRows;
    if (outTarget) {
      AdfCollections.copyInto(mergedRows, outTarget);
    }
  } else {
    var originalSize = 0;
    for (var key in originalRows) {
      if (!(key in newRows)) {
        originalSize++;
      }
    }
    for (var key1 in newRows) {
      mergedRows[key1] = newRows[key1] + originalSize;
    }
    AdfCollections.copyInto(mergedRows, originalRows);
  }
  return mergedRows;
};
AdfDhtmlTableBasePeer.prototype._adjustSelectedRowKeyIndex = function(state, index) {
  if (state && index) {
    for (var k in state) {
      if (state[k] > index) {
        state[k] = state[k] - 1;
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._selectRowRange = function(rowKeyStart, rowKeyEnd) {
  var dataBody = this.GetDataBody();
  if (dataBody == null) {
    return;
  }
  var agent = AdfAgent.getAgent();
  var component = this.getComponent();
  var state = {};
  var positionIndex = 1;
  var oldState = component.getSelectedRowKeys();
  var isSelectAll = oldState[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY];
  var inSelectionRange = false, leaveRange = false;
  var dataTables = dataBody.childNodes, tableCount = dataTables.length;
  var forward = true;
  if (component.getRowIndex(rowKeyStart) > component.getRowIndex(rowKeyEnd)) {
    forward = false;
  }
  for (var i = 0;i < tableCount && !leaveRange;++i) {
    var tableIndex = forward ? i : tableCount - i - 1;
    var table = dataTables[tableIndex];
    var rows = dataTables[tableIndex].rows, rowCount = rows.length;
    for (var j = 0;j < rowCount;++j) {
      var rowIndex = forward ? j : rowCount - j - 1;
      var row = rows[rowIndex];
      var rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
      if (rowKey != null) {
        if (rowKey == rowKeyStart || rowKey == rowKeyEnd) {
          if (inSelectionRange || rowKeyStart == rowKeyEnd) {
            leaveRange = true;
          }
          inSelectionRange = true;
        }
        if (inSelectionRange) {
          this._selSelectRow(rowKey, row, true);
          if (isSelectAll) {
            var oldIndex = state[rowKey];
            delete state[rowKey];
            this._adjustSelectedRowKeyIndex(state, oldIndex);
          } else {
            state[rowKey + ""] = positionIndex;
            positionIndex++;
          }
        }
        if (leaveRange) {
          break;
        }
      }
    }
  }
  this._mergeSelectedRowKeys(oldState, state, state);
  this._updateTableSelectionState(state);
};
AdfDhtmlTableBasePeer.prototype._selIsSelected = function(rowKey) {
  var state = this.getComponent().getSelectedRowKeys();
  var isSelectAll = state[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY];
  return isSelectAll ? !state[rowKey] : state[rowKey];
};
AdfDhtmlTableBasePeer.prototype._selIsOnlySelection = function(rowKey) {
  var state = this.getComponent().getSelectedRowKeys();
  if (state[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY] != null) {
    return false;
  }
  var onlySelected = state[rowKey];
  if (onlySelected) {
    for (var key in state) {
      if (key != rowKey) {
        onlySelected = false;
        break;
      }
    }
  }
  return onlySelected;
};
AdfDhtmlTableBasePeer.prototype._selHighlightRow = function(row) {
  AdfAssert.assertDomNode(row);
  AdfDomUtils.addCSSClassName(row, AdfDhtmlTableBasePeer._SELECTED_CLASS);
  if (row.getAttribute("role") == "row") {
    row.setAttribute("aria-selected", "true");
  }
  AdfDomUtils.removeCSSClassName(row, AdfDhtmlTableBasePeer._HIGHLIGHTED_CLASS);
  if (!this.isInActiveHeirarchy()) {
    AdfDomUtils.addCSSClassName(row, AdfDhtmlTableBasePeer._INACTIVE_CLASS);
  } else {
    AdfDomUtils.removeCSSClassName(row, AdfDhtmlTableBasePeer._INACTIVE_CLASS);
  }
};
AdfDhtmlTableBasePeer.prototype._selUnhighlightRow = function(row) {
  AdfAssert.assertDomNode(row);
  AdfDomUtils.removeCSSClassName(row, AdfDhtmlTableBasePeer._INACTIVE_CLASS);
  AdfDomUtils.removeCSSClassName(row, AdfDhtmlTableBasePeer._SELECTED_CLASS);
  if (row.getAttribute("role") == "row") {
    row.removeAttribute("aria-selected");
  }
};
AdfDhtmlTableBasePeer.prototype._isColumnSelectionEnabled = function() {
  var colSelection = this.getComponent().getColumnSelection ? this.getComponent().getColumnSelection() : null;
  return colSelection && colSelection != AdfDhtmlTableBasePeer._SELECTION_NONE;
};
AdfDhtmlTableBasePeer.prototype._isMultipleColumnSelect = function() {
  var colSelection = this.getComponent().getColumnSelection ? this.getComponent().getColumnSelection() : null;
  return colSelection && colSelection == AdfDhtmlTableBasePeer._SELECTION_MULTIPLE;
};
AdfDhtmlTableBasePeer.prototype._isRowSelectionEnabled = function(component) {
  if (!component) {
    component = this.getComponent();
  }
  var rowSelection = component.getRowSelection();
  return rowSelection && rowSelection.toLowerCase() != AdfDhtmlTableBasePeer._SELECTION_NONE;
};
AdfDhtmlTableBasePeer.prototype._isMultipleRowSelect = function() {
  var rowSelection = this.getComponent().getRowSelection();
  return rowSelection && rowSelection.toLowerCase().indexOf(AdfDhtmlTableBasePeer._SELECTION_MULTIPLE) != -1;
};
AdfDhtmlTableBasePeer.prototype._isMultipleRowSelectNoSelectAll = function() {
  var rowSelection = this.getComponent().getRowSelection();
  return rowSelection && rowSelection.indexOf(AdfDhtmlTableBasePeer._SELECTION_MULTIPLE_NOSELECTALL) != -1;
};
AdfDhtmlTableBasePeer.prototype._selUpdateAll = function(selType, clearHighlightedRowKey, rowKeys) {
  if (rowKeys == null) {
    rowKeys = this.getComponent().getSelectedRowKeys();
  }
  var isSelectAll = false;
  if (rowKeys != null) {
    isSelectAll = rowKeys[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY] ? true : false;
  }
  if (isSelectAll) {
    this._selectAllSelectionUpdate(selType, clearHighlightedRowKey, rowKeys);
  } else {
    this._normalSelectionUpdate(selType, clearHighlightedRowKey, rowKeys);
  }
};
AdfDhtmlTableBasePeer.prototype._normalSelectionUpdate = function(selType, clearHighlightedRowKey, selState) {
  var dataBody = this.GetDataBody();
  if (dataBody == null) {
    return;
  }
  if (true == clearHighlightedRowKey) {
    this._highlightedRowKey = null;
  }
  if (!selState || AdfCollections.isEmpty(selState)) {
    return;
  }
  var dataTables = dataBody.childNodes, tableCount = dataTables.length;
  var agent = AdfAgent.getAgent();
  for (var i = 0;i < tableCount;++i) {
    var table = dataTables[i];
    var rows = table.rows;
    if (!rows) {
      continue;
    }
    var rowCount = rows.length;
    for (var j = 0;j < rowCount;++j) {
      var row = rows[j];
      var rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
      if (rowKey == null) {
        continue;
      }
      if (false == clearHighlightedRowKey && this._highlightedRowKey == rowKey) {
        continue;
      }
      switch(selType) {
        default:
          break;
        case AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_SELECT:
          this._selHighlightRow(row);
          break;
        case AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UNSELECT:
          this._selUnhighlightRow(row);
          break;
        case AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UPDATE:
          if (selState[rowKey]) {
            this._selHighlightRow(row);
          } else {
            this._selUnhighlightRow(row);
          }
          break;
      }
    }
  }
  this._updateColumnSelection(selType != 1);
};
AdfDhtmlTableBasePeer.prototype._selectAllSelectionUpdate = function(selType, clearHighlightedRowKey, selState) {
  var dataBody = this.GetDataBody();
  if (dataBody == null) {
    return;
  }
  if (true == clearHighlightedRowKey) {
    this._highlightedRowKey = null;
  }
  if (!selState || AdfCollections.isEmpty(selState)) {
    return;
  }
  var dataTables = dataBody.childNodes, tableCount = dataTables.length;
  var agent = AdfAgent.getAgent();
  for (var i = 0;i < tableCount;++i) {
    var table = dataTables[i];
    var rows = table.rows;
    if (!rows) {
      continue;
    }
    var rowCount = rows.length;
    for (var j = 0;j < rowCount;++j) {
      var row = rows[j];
      var rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
      if (rowKey == null) {
        continue;
      }
      if (false == clearHighlightedRowKey && this._highlightedRowKey == rowKey) {
        continue;
      }
      switch(selType) {
        default:
          break;
        case AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_SELECT:
          this._selHighlightRow(row);
          break;
        case AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UNSELECT:
          this._selUnhighlightRow(row);
          break;
        case AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UPDATE:
          if (selState[rowKey]) {
            this._selUnhighlightRow(row);
          } else {
            this._selHighlightRow(row);
          }
          break;
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._selSelectAll = function() {
  var dataBody = this.GetDataBody();
  if (dataBody == null) {
    return;
  }
  if (!this._isMultipleRowSelect()) {
    return;
  }
  this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UNSELECT, true);
  var state = new Object;
  state[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY] = true;
  this._updateTableSelectionState(state);
  var dataTables = dataBody.childNodes, tableCount = dataTables.length;
  var agent = AdfAgent.getAgent();
  for (var i = 0;i < tableCount;++i) {
    var table = dataTables[i];
    var rows = dataTables[i].rows, rowCount = rows.length;
    for (var j = 0;j < rowCount;++j) {
      var row = rows[j];
      var rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
      if (rowKey != null) {
        this._selHighlightRow(row);
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._unhiglightAnyExistingHighlightedRow = function() {
  var highlightedRowKey = this._highlightedRowKey;
  if (highlightedRowKey) {
    this._highlightedRowKey = null;
    if (!this._selIsSelected(highlightedRowKey)) {
      this._selUnhighlightRow(this._highlightedRow);
      this._highlightedRow = null;
    }
  }
};
AdfDhtmlTableBasePeer.prototype._updateTableSelectionState = function(state) {
  this._ignoreSelSet = true;
  AdfLogger.LOGGER.finer("Update Table selection state to:", state);
  this.getComponent().setSelectedRowKeys(state);
  this._ignoreSelSet = false;
};
AdfDhtmlTableBasePeer.prototype.ComponentSelectedRowKeysChanged = function(component, domElement, newValue, oldValue) {
  if (!this._ignoreSelSet) {
    this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UNSELECT, true, oldValue);
    this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UPDATE, true, newValue);
  } else {
    var buddyComponent = this.GetAssociatedComponent();
    if (buddyComponent != null) {
      buddyComponent.setSelectedRowKeys(newValue);
    }
  }
  if (this._pcPeer) {
    this._pcPeer.updateRowSelectionContext();
  }
};
AdfDhtmlTableBasePeer.prototype._resolveColumns = function(colIndices, colIds, th) {
  var index = AdfAgent.AGENT.getIntAttribute(th, "_d_index", -1);
  if (index >= 0) {
    var colSpan = th.colSpan;
    if (colSpan != null && (colSpan = parseInt(colSpan)) > 1) {
      var endIndex = index + colSpan;
      while (index < endIndex) {
        colIds.push(this._getColumnHeaderLeafCell(index).id);
        colIndices.push(index++);
      }
    } else {
      colIndices.push(index);
      colIds.push(th.id);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._handleColumnHeaderDrag = function(domEvent, deltaX, deltaY) {
  var headerAction = this.__getColumnHeaderMouseAction(domEvent);
  if (headerAction != null && "select" == headerAction.type) {
    var colIndices = headerAction.colIndices;
    if (colIndices.length > 0) {
      this._selectColumnRange(this._activeColIndices, this._activeColIds, colIndices, headerAction.colIds);
      this._queueColumnSelectionEvent();
    }
  }
  this._autoScrollColumnsIfNecessary(domEvent);
  if (this._pcPeer) {
    this._pcPeer.updateStandardMenuToolbarItems();
  }
};
AdfDhtmlTableBasePeer.prototype._handleColumnHeaderDrop = function(domEvent, deltaX, deltaY) {
  var columnHeader = this.__getColumnHeader();
  AdfAgent.AGENT.enableUserSelect(columnHeader);
  this._queueColumnSelectionEvent();
};
AdfDhtmlTableBasePeer.prototype._doColumnSelections = function(event, indices, ids) {
  var page = AdfPage.PAGE;
  var isMultiSelect = this._isMultipleColumnSelect();
  var domWindow = AdfAgent.AGENT.getDomWindow();
  if (isMultiSelect && !(domWindow.AdfSafariMobileAgent && AdfAgent.AGENT instanceof AdfSafariMobileAgent) && AdfAgent.AGENT.isSelectionToggle(event)) {
    var rowKeys = this.getComponent().getSelectedRowKeys();
    if (!AdfCollections.isEmpty(rowKeys)) {
      this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UNSELECT, true);
      this._updateTableSelectionState(new Object);
    }
    this._activeColIndices = indices;
    this._activeColIds = ids;
    for (var i = 0;i < indices.length;i++) {
      var col = page.findComponent(ids[i]);
      if (col.getSelected()) {
        this._unSelectColumn(indices[i], col, false);
      } else {
        this._selectColumn(indices[i], col, false);
      }
    }
    this._queueColumnSelectionEvent();
  } else {
    if (event.shiftKey && this._isMultipleColumnSelect()) {
      if (this._activeColIndices && this._activeColIndices.length >= 0) {
        this._clearColumnSelectionEventChangedSets();
        this._selUnselectAll();
        this._selectColumnRange(this._activeColIndices, this._activeColIds, indices, ids);
        this._queueColumnSelectionEvent();
      }
    } else {
      this._activeColIndices = indices;
      this._activeColIds = ids;
      this._clearColumnSelectionEventChangedSets();
      this._selUnselectAll();
      for (var i = 0;i < indices.length;i++) {
        var col = page.findComponent(ids[i]);
        this._selectColumn(indices[i], col, false);
      }
      this._queueColumnSelectionEvent();
    }
  }
  if (this._pcPeer) {
    this._pcPeer.updateStandardMenuToolbarItems();
  }
};
AdfDhtmlTableBasePeer.prototype._selectColumn = function(index, col, queueEvent) {
  if (!col.getSelected()) {
    col.setProperty(AdfRichColumn.SELECTED, true, true, AdfUIComponent.PROPAGATE_NEVER);
    this._highlightColumn(index);
    if (this._isClickToEdit() && this._getActiveRowKey()) {
      this._setActiveRowKey(null);
    }
    this._colSelEventSelectedColIds[col.getClientId()] = true;
    if (queueEvent) {
      this._queueColumnSelectionEvent();
    }
  }
};
AdfDhtmlTableBasePeer.prototype._unSelectColumn = function(index, col, queueEvent) {
  if (col.getSelected()) {
    col.setProperty(AdfRichColumn.SELECTED, false, true, AdfUIComponent.PROPAGATE_NEVER);
    this._unHighlightColumn(index);
    this._colSelEventUnselectedColIds[col.getClientId()] = true;
    if (queueEvent) {
      this._queueColumnSelectionEvent();
    }
  }
};
AdfDhtmlTableBasePeer.prototype._unSelectAllColumns = function() {
  if (this._isColumnSelectionEnabled()) {
    var page = AdfPage.PAGE;
    var colCount = this._colCount;
    var headerCell;
    this._clearColumnSelectionEventRemovedSet();
    for (var c = 0;c < colCount;c++) {
      headerCell = this._getColumnHeaderLeafCell(c);
      if (headerCell) {
        this._unSelectColumn(c, page.findComponent(headerCell.id), false);
      }
    }
  }
  if (this._pcPeer) {
    this._pcPeer.updateStandardMenuToolbarItems();
  }
};
AdfDhtmlTableBasePeer.prototype._updateColumnSelection = function(isSelect) {
  if (this._headerless) {
    return;
  }
  var page = AdfPage.PAGE;
  var colCount = this._colCount;
  for (var c = 0;c < colCount;c++) {
    var leaf = this._getColumnHeaderLeafCell(c);
    if (!leaf) {
      continue;
    }
    var colId = leaf.id;
    var col = page.findComponent(colId);
    if (col.getSelected()) {
      if (isSelect) {
        this._highlightColumn(c);
      } else {
        this._unHighlightColumn(c);
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._selectColumnRange = function(indicesStart, idsStart, indicesEnd, idsEnd) {
  var page = AdfPage.PAGE;
  for (var c = 0;c < indicesStart.length;c++) {
    this._selectColumn(indicesStart[c], page.findComponent(idsStart[c]));
  }
  var incIndex = indicesEnd[0] > indicesStart[0] ? 1 : -1;
  var iIndex = indicesStart[0], thId = idsStart[0];
  while (iIndex != indicesEnd[0]) {
    this._selectColumn(iIndex, page.findComponent(thId));
    iIndex += incIndex;
    thId = this._getColumnHeaderLeafCell(iIndex).id;
  }
  for (var c = 0;c < indicesEnd.length;c++) {
    this._selectColumn(indicesEnd[c], page.findComponent(idsEnd[c]));
  }
};
AdfDhtmlTableBasePeer.prototype._highlightColumn = function(index) {
  var headerCell = this._getColumnHeaderLeafCell(index);
  this._highlightCell(headerCell, true);
  var dataTables = this.GetDataBody().childNodes;
  var tableCount = dataTables.length;
  var isTableActive = null;
  var agent = AdfAgent.getAgent();
  for (var i = 0;i < tableCount;++i) {
    var rows = dataTables[i].rows;
    var rowCount = rows.length;
    for (var j = 0;j < rowCount;++j) {
      if (!agent.getAttribute(rows[j], AdfDhtmlTableBasePeer._ROW_KEY, null)) {
        continue;
      }
      if (isTableActive == null) {
        isTableActive = this.isInActiveHeirarchy();
      }
      if (this._hasFrozenColumn() && !this._isColumnFrozen(index)) {
        this._highlightCell(this._getInnerTableCell(rows[j], index), isTableActive);
      } else {
        if (!this._hasFrozenColumn() || this._freezeColumnsToStart()) {
          this._highlightCell(rows[j].cells[index], isTableActive);
        } else {
          this._highlightCell(rows[j].cells[index - this._firstFrozen + 1], isTableActive);
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._unHighlightColumn = function(index) {
  var headerCell = this._getColumnHeaderLeafCell(index);
  this._unHighlightCell(headerCell, true);
  var dataTables = this.GetDataBody().childNodes, tableCount = dataTables.length;
  var agent = AdfAgent.getAgent();
  for (var i = 0;i < tableCount;++i) {
    var table = dataTables[i];
    var rows = dataTables[i].rows, rowCount = rows.length;
    for (var j = 0;j < rowCount;++j) {
      if (!agent.getAttribute(rows[j], AdfDhtmlTableBasePeer._ROW_KEY, null)) {
        continue;
      }
      if (this._hasFrozenColumn() && !this._isColumnFrozen(index)) {
        this._unHighlightCell(this._getInnerTableCell(rows[j], index));
      } else {
        if (!this._hasFrozenColumn() || this._freezeColumnsToStart()) {
          this._unHighlightCell(rows[j].cells[index]);
        } else {
          this._unHighlightCell(rows[j].cells[index - this._firstFrozen + 1]);
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._highlightCell = function(cell, isTableActive) {
  AdfDomUtils.addCSSClassName(cell, AdfDhtmlTableBasePeer._SELECTED_CLASS);
};
AdfDhtmlTableBasePeer.prototype._unHighlightCell = function(cell) {
  AdfDomUtils.removeCSSClassName(cell, AdfDhtmlTableBasePeer._SELECTED_CLASS);
  AdfDomUtils.removeCSSClassName(cell, AdfDhtmlTableBasePeer._INACTIVE_CLASS);
};
AdfDhtmlTableBasePeer.prototype._getParentTH = function(domEvent) {
  var agent = AdfAgent.AGENT;
  var target = agent.getEventTarget(domEvent);
  var th = null, rootElem = this.getDomElement();
  while (!th && target && target != rootElem && target.nodeType == 1) {
    if (target.getAttribute("_d_index")) {
      th = target;
    } else {
      target = target.parentNode;
    }
  }
  return th;
};
AdfDhtmlTableBasePeer.prototype._getColumnHeaderCellForEvent = function(domEvent) {
  var th = null;
  var colHeader = this.__getColumnHeader();
  var agent = AdfAgent.AGENT;
  var headerPos = agent.getElementPosition(colHeader);
  var mousePos = agent.getMousePosition(domEvent);
  if (mousePos.y - headerPos.y <= this._cachedCHHeight) {
    th = this._getParentTH(domEvent);
  }
  return th;
};
AdfDhtmlTableBasePeer.prototype.__getColumnHeaderMouseAction = function(domEvent) {
  var action = null;
  if (!this._headerless) {
    var agent = AdfAgent.AGENT;
    var th = null;
    var colHeader = this.__getColumnHeader();
    var headerPos = agent.getElementPosition(colHeader);
    var mousePos = agent.getMousePosition(domEvent);
    if (mousePos.y - headerPos.y <= this._cachedCHHeight) {
      th = this._getParentTH(domEvent);
    }
    if (th) {
      action = new Object;
      action.cell = th;
      if (th.getAttribute("_afrFH") != null) {
        action.type = "clearAllFilter";
        return action;
      }
      if (!this._virtInitialized) {
        return null;
      }
      var resizeData = null;
      var displayIndex = agent.getIntAttribute(th, "_d_index", -1);
      var isRTL = AdfDhtmlTableBasePeer._isRTL();
      if (displayIndex != -1 && this.getComponent().getColumnResizing() == "enabled") {
        var thPos = agent.getElementPosition(th);
        var mouseX = mousePos.x - thPos.x;
        var width = th.offsetWidth;
        var isLastColResizeAllowed = !(this._lastColWidthOverride != -1 && displayIndex == this._colCount - 1);
        if (mouseX <= this.__getColumnResizeMargin()) {
          if (isRTL) {
            if (isLastColResizeAllowed) {
              resizeData = "end";
            }
          } else {
            if (displayIndex > 0) {
              resizeData = "start";
            }
          }
        } else {
          if (width - mouseX <= this.__getColumnResizeMargin()) {
            if (isRTL) {
              if (displayIndex > 0) {
                resizeData = "start";
              }
            } else {
              if (isLastColResizeAllowed) {
                resizeData = "end";
              }
            }
          }
        }
      }
      if (resizeData) {
        action.type = "resize";
        action.data = resizeData;
      } else {
        this._getColHeaderMouseSelAction(domEvent, action, th);
      }
    }
  }
  return action;
};
AdfDhtmlTableBasePeer.prototype._getColHeaderMouseSelAction = function(domEvent, action, th) {
  var agent = AdfAgent.AGENT;
  var target = agent.getEventTarget(domEvent);
  var isColSelectionOn = this._isColumnSelectionEnabled();
  var sortAscending = target.parentNode.getAttribute(AdfDhtmlTableBasePeer._SORT_ASCENDING);
  if (!sortAscending) {
    sortAscending = target.parentNode.parentNode.getAttribute(AdfDhtmlTableBasePeer._SORT_ASCENDING);
  }
  var sortDescending = target.parentNode.getAttribute(AdfDhtmlTableBasePeer._SORT_DESCENDING);
  if (!sortDescending) {
    sortDescending = target.parentNode.parentNode.getAttribute(AdfDhtmlTableBasePeer._SORT_DESCENDING);
  }
  if (sortAscending || sortDescending) {
    if (domEvent.type == "click") {
      var siElem = agent.getElementById(AdfRichUIPeer.CreateSubId(th.id, AdfDhtmlTableBasePeer.__SORT_INDICATOR));
      var sortedType = siElem.getAttribute(AdfDhtmlTableBasePeer._SORTED_TYPE);
      if (sortAscending) {
        if (sortedType == AdfDhtmlTableBasePeer._SORTED_ASCENDING) {
          if (!this._singleSortIcon) {
            return;
          }
          action.sortOrder = false;
        } else {
          action.sortOrder = true;
        }
      } else {
        if (sortDescending) {
          if (sortedType == AdfDhtmlTableBasePeer._SORTED_DESCENDING) {
            if (!this._singleSortIcon) {
              return;
            }
            action.sortOrder = true;
          } else {
            action.sortOrder = false;
          }
        }
      }
      action.type = "sort";
      action.sortProperty = AdfPage.PAGE.findComponent(th.id).getSortProperty();
    }
  } else {
    if (th.getAttribute(AdfDhtmlTableBasePeer._SELECT_ALL) != null) {
      action.type = "selectAll";
    } else {
      if (th.id.indexOf("_afrBlankColumn") == -1) {
        if (!isColSelectionOn && this.getComponent().getDisableColumnReordering() && th.getAttribute(AdfDhtmlTableBasePeer._ROW_HEADER) == null) {
          action.type = "default";
        } else {
          if (!isColSelectionOn && th.getAttribute(AdfDhtmlTableBasePeer._ROW_HEADER) == null && th.getAttribute(AdfDhtmlTableBasePeer._ROOT_COLUMN) != null) {
            var siElem = agent.getElementById(AdfRichUIPeer.CreateSubId(th.id, AdfDhtmlTableBasePeer.__SORT_INDICATOR));
            if (siElem != null) {
              if (domEvent.type == "click") {
                var sortedType = siElem.getAttribute(AdfDhtmlTableBasePeer._SORTED_TYPE);
                action.sortOrder = sortedType == AdfDhtmlTableBasePeer._SORTED_ASCENDING ? false : true;
                action.type = "sort";
                action.sortProperty = AdfPage.PAGE.findComponent(th.id).getSortProperty();
              } else {
                action.type = domEvent.type == "mousemove" ? "default" : "move";
              }
            } else {
              action.type = "move";
            }
          } else {
            if (th.getAttribute(AdfDhtmlTableBasePeer._ROW_HEADER) == null) {
              if (!(isColSelectionOn && agent.isSelectionToggle(domEvent)) && this._shouldEnableColumnReorder(domEvent, th)) {
                if (!this.getComponent().getDisableColumnReordering()) {
                  action.type = "move";
                }
              } else {
                if (th.id && isColSelectionOn) {
                  action.type = "select";
                  this._resolveColumns(action.colIndices = [], action.colIds = [], th);
                } else {
                  action.type = "default";
                }
              }
            } else {
              action.type = "default";
            }
          }
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._shouldEnableColumnReorder = function(domEvent, th) {
  var page = AdfPage.PAGE;
  var index = -1;
  var enableColumnDragDrop = false;
  var indices = null, colIds = null;
  var columns = this._flattenedColumns;
  var isLeaf = th.getAttribute(AdfDhtmlTableBasePeer._LEAF_COLUMN) != null, isRoot = th.getAttribute(AdfDhtmlTableBasePeer._ROOT_COLUMN) != null;
  if (isLeaf && isRoot) {
    if (th.id && th.id.length > 0 && page.findComponent(th.id).getSelected()) {
      colIds = [th.id];
    }
  } else {
    if (isRoot) {
      this._resolveColumns(indices = [], colIds = [], th);
      if (colIds.length == 0) {
        colIds = null;
      } else {
        for (i = colIds.length - 1;i >= 0;--i) {
          if (!page.findComponent(colIds[i]).getSelected()) {
            colIds = null;
            break;
          }
        }
      }
    }
  }
  if (colIds) {
    enableColumnDragDrop = true;
    columns = this.__getVisibleLeafColumns();
    for (i = columns.length - 1;i >= 0;--i) {
      var column = columns[i];
      if (column && column.getSelected()) {
        var columnFound = false;
        for (j = colIds.length - 1;j >= 0;--j) {
          if (column.getClientId() == colIds[j]) {
            columnFound = true;
            break;
          }
        }
        if (!columnFound) {
          enableColumnDragDrop = false;
          break;
        }
      }
    }
  }
  return enableColumnDragDrop;
};
AdfDhtmlTableBasePeer.prototype._handleColResizeDrag = function(domEvent, deltaX, deltaY) {
  var indicator = this._getColumnResizeIndicator();
  var s = indicator.style;
  var left = parseInt(s.left);
  var th = this._resizedTH;
  var width = parseInt(th.style.width);
  var delta = this._resizeColDelta + (AdfDhtmlTableBasePeer._isRTL() ? -deltaX : deltaX);
  var largestMinimumWidth = this._getLargestMinimumWidth();
  this._resizeColDelta = delta;
  if (width + delta >= largestMinimumWidth) {
    s.left = left + deltaX + "px";
  }
};
AdfDhtmlTableBasePeer.prototype._getLargestMinimumWidth = function() {
  var displayIndex = this._resizedIndex;
  var leafColumns = this.__getVisibleLeafColumns();
  var resizedColumnComponent = leafColumns[displayIndex];
  var largestMinimumWidth = this._largestMinimumWidth;
  if (largestMinimumWidth == null) {
    largestMinimumWidth = 0;
    var selectedColumns = this.__getSelectedColumns();
    if (AdfCollections.indexOf(selectedColumns, resizedColumnComponent) == -1) {
      largestMinimumWidth = resizedColumnComponent.getMinimumWidth();
    } else {
      var columnCount = selectedColumns.length;
      for (var c = 0;c < columnCount;c++) {
        var columnMinimumWidth = selectedColumns[c].getMinimumWidth();
        largestMinimumWidth = Math.max(largestMinimumWidth, columnMinimumWidth);
      }
    }
    this._largestMinimumWidth = largestMinimumWidth;
  }
  return this._largestMinimumWidth;
};
AdfDhtmlTableBasePeer.prototype._handleColResizeDrop = function(domEvent, deltaX, deltaY) {
  var indicator = this._getColumnResizeIndicator();
  this._hideElement(indicator);
  if (this.isHeightAutoSized() && this._autoHeightRows <= 2) {
    this._restoreHorizontalScrollBarForIE8(17);
  }
  var delta = this._resizeColDelta;
  var th = this._resizedTH;
  var newWidth = parseInt(delta) + parseInt(th.style.width);
  var largestMinimumWidth = this._getLargestMinimumWidth();
  newWidth = Math.max(newWidth, largestMinimumWidth);
  if (this._hasFrozenColumn()) {
    if (this._isColumnFrozen(this._resizedIndex)) {
      var maxWidth = Math.max(this.GetDataBody().clientWidth - 10, largestMinimumWidth);
      if (th.offsetLeft + newWidth >= maxWidth) {
        newWidth = maxWidth - th.offsetLeft;
      }
    }
  }
  AdfAssert.assert(!isNaN(newWidth), "Illegal width for column resize drop.  delta \x3d " + delta + ", th.style.width \x3d " + th.style.width);
  this._doColResizesFromUser(newWidth, null);
};
AdfDhtmlTableBasePeer.prototype._restoreHorizontalScrollBarForIE8 = function(minHeightIncr) {
  var scroller = this.GetScroller();
  var agent = AdfAgent.getAgent();
  var isIE = agent.getPlatform() == AdfAgent.IE_PLATFORM;
  if (scroller != null && isIE && this.GetRowCount() < 2) {
    var container = this.getDomElement();
    var scrollbarHeight = this._getScrollbarHeight();
    var dataBody = this.GetDataBody();
    var bodyHeight = !this.IsEmpty ? this._computeAutoHeight() : dataBody.offsetHeight;
    var elementToPurgeMinHeight = null;
    var minHeightToAssign = 0;
    var version = agent.getVersion();
    if (version > 7 && version < 9) {
      elementToPurgeMinHeight = scroller;
      if (!this._hasSingleScroller() || this._isPaged) {
        elementToPurgeMinHeight = scroller[AdfDhtmlTableBasePeer._HSCROLLER];
      }
      if (this._averageRowHeight != null) {
        minHeightToAssign = this._averageRowHeight;
        elementToPurgeMinHeight.style.minHeight = (minHeightIncr ? minHeightIncr : 8) + minHeightToAssign + "px";
      }
      if (elementToPurgeMinHeight != null) {
        var newSbh = this._getScrollbarHeight();
        if (scrollbarHeight != newSbh) {
          newHeight = bodyHeight + this._cachedCHHeight + this._cachedCFHeight + newSbh;
          this._sizeOuterContainer(container, newHeight);
          this._setScrollerHeight(newHeight, this._cachedCHHeight, this._cachedCFHeight, this._cachedNBHeight);
        }
        elementToPurgeMinHeight.style.minHeight = minHeightToAssign + "px";
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._doColResizesFromUser = function(newWidth, oldWidth) {
  this._largestMinimumWidth = null;
  this._resizedTH = null;
  var displayIndex = this._resizedIndex;
  var leafColumns = this.__getVisibleLeafColumns();
  var leafColumnCount = leafColumns.length;
  var resizedColumnComponent = leafColumns[displayIndex];
  var dataBody = this.GetDataBody();
  var selectedColumns = this.__getSelectedColumns();
  var resizedColumnIsInSelection = false;
  if (oldWidth == null) {
    resizedColumnIsInSelection = AdfCollections.indexOf(selectedColumns, resizedColumnComponent) != -1;
    var resizeCount = 1;
    if (resizedColumnIsInSelection) {
      resizeCount = selectedColumns.length;
    }
  }
  var firstRow;
  if (!this.IsEmpty) {
    var block = dataBody.childNodes[0];
    firstRow = block.rows[0];
    AdfAssert.assert(firstRow != null, "this.IsEmpty was " + this.IsEmpty + " but there were no rows!");
  }
  var flexibleColumnsToTheLeft = [];
  var flexibleColumnsToTheRight = [];
  var resizedColumnsInfo = [];
  var column;
  var resizedColumnTally = 0;
  var actualWidth;
  var actualWidthOfResizedColumns = 0;
  var c;
  var columnStretching = this._columnStretching;
  var totalActualWidth = 0;
  for (c = 0;c < leafColumnCount;c++) {
    column = leafColumns[c];
    var flex = this._getColumnFlex(column, null, columnStretching, leafColumnCount, c);
    actualWidth = this._getColumnActualWidth(c, firstRow);
    totalActualWidth += actualWidth;
    if (resizedColumnIsInSelection && AdfCollections.indexOf(selectedColumns, column) != -1 || !resizedColumnIsInSelection && c == displayIndex) {
      if (oldWidth != null) {
        flex = this._getColumnFlex(null, oldWidth, columnStretching, leafColumnCount, c);
      }
      resizedColumnTally++;
      actualWidthOfResizedColumns += actualWidth;
      resizedColumnsInfo.push({"component":column, "displayIndex":c, "flex":flex, "minimumWidth":column.getMinimumWidth(), "actualWidth":actualWidth});
      continue;
    }
    if (flex != null) {
      var flexibleInfo = {"component":column, "displayIndex":c, "flex":flex, "minimumWidth":column.getMinimumWidth(), "actualWidth":actualWidth}
    }
  }
  if (columnStretching != "none" && columnStretching != "blank") {
    return this._userDragStretchedColumns(newWidth, oldWidth, firstRow, resizedColumnsInfo, leafColumns, columnStretching);
  }
  var uberDelta = resizedColumnTally * newWidth - actualWidthOfResizedColumns;
  var columnInfo;
  var absoluteUberDelta = Math.abs(uberDelta);
  var numberOfColumnsToTheRight = flexibleColumnsToTheRight.length;
  var spacePerColumn = Math.floor(absoluteUberDelta / numberOfColumnsToTheRight);
  var excessSpace = absoluteUberDelta - numberOfColumnsToTheRight * spacePerColumn;
  var columnsAtTheirLimit = 0;
  do {
    for (var r = 0;r < numberOfColumnsToTheRight;r++) {
      columnInfo = flexibleColumnsToTheRight[r];
      if (true != columnInfo["atMinimum"]) {
        var minimumWidth = columnInfo["minimumWidth"];
        actualWidth = columnInfo["actualWidth"];
        var spaceForThisColumn = spacePerColumn;
        if (excessSpace > 0) {
          spaceForThisColumn += excessSpace;
          excessSpace = 0;
        }
        if (uberDelta < 0) {
          spaceForThisColumn *= -1;
        }
        var uncappedWidth = actualWidth - spaceForThisColumn;
        var oldDesiredWidth = columnInfo["desiredWidth"];
        if (oldDesiredWidth != null) {
          uncappedWidth += oldDesiredWidth - actualWidth;
        }
        var desiredWidth = Math.max(minimumWidth, uncappedWidth);
        if (desiredWidth != uncappedWidth) {
          columnInfo["atMinimum"] = true;
          columnsAtTheirLimit++;
        }
        excessSpace += desiredWidth - uncappedWidth;
        columnInfo["desiredWidth"] = desiredWidth;
      }
    }
    spacePerColumn = 0;
  } while (excessSpace != 0 && columnsAtTheirLimit < numberOfColumnsToTheRight);
  var flexibleColumns = flexibleColumnsToTheLeft.concat(flexibleColumnsToTheRight);
  var resizedColumnsCount = resizedColumnsInfo.length;
  for (c = 0;c < resizedColumnsCount;c++) {
    column = resizedColumnsInfo[c];
    if (column["flex"] == null) {
      delta = newWidth - column["actualWidth"];
      this._doResizeColumn(column["displayIndex"], null, newWidth, delta, true);
    } else {
      column["desiredWidth"] = newWidth;
      flexibleColumns.push(column);
    }
  }
  var flexibleColumnCount = flexibleColumns.length;
  var desiredFlexiblePixels = 0;
  for (c = 0;c < flexibleColumnCount;c++) {
    column = flexibleColumns[c];
    desiredWidth = column["desiredWidth"];
    actualWidth = column["actualWidth"];
    if (desiredWidth == null) {
      desiredWidth = actualWidth;
      column["desiredWidth"] = desiredWidth;
    }
    column["delta"] = desiredWidth - actualWidth;
    desiredFlexiblePixels += desiredWidth;
  }
  var stretchDetails = [];
  for (c = 0;c < flexibleColumnCount;c++) {
    column = flexibleColumns[c];
    desiredWidth = column["desiredWidth"];
    delta = column["delta"];
    displayIndex = column["displayIndex"];
    this._doResizeColumn(displayIndex, null, desiredWidth, delta, false);
    var newFlex = Math.round(1E4 * desiredWidth / desiredFlexiblePixels) + "%";
    var component = column["component"];
    this._ignoreSetColWidth = true;
    component.setProperty(AdfRichColumn.WIDTH, newFlex, true);
    delete this._ignoreSetColWidth;
    stretchDetails.push({"displayIndex":displayIndex, "width":desiredWidth});
  }
  this._currentColumnStretchDetails = stretchDetails;
  this._stretchTheColumns();
  var columnHeader = this.__getColumnHeader();
  AdfAgent.AGENT.enableUserSelect(columnHeader);
};
AdfDhtmlTableBasePeer.prototype._userDragStretchedColumns = function(newWidth, oldWidth, firstRow, resizedColumnsInfo, leafColumns, columnStretchingType) {
  var alteredColumns = [];
  var resizedColumnTally = resizedColumnsInfo.length;
  var resizedColumnMin = 0;
  var maxOldWidth = 0;
  var column;
  var x;
  var needCalculateOldWidth = false;
  if (oldWidth == null || isNaN(oldWidth)) {
    oldWidth = 0;
    needCalculateOldWidth = true;
  }
  for (x = 0;x < resizedColumnTally;x++) {
    column = resizedColumnsInfo[x];
    column["desiredWidth"] = column["minimumWidth"];
    alteredColumns[column["displayIndex"]] = column;
    resizedColumnMin += column["minimumWidth"];
    maxOldWidth = Math.max(maxOldWidth, column["actualWidth"]);
    if (needCalculateOldWidth) {
      oldWidth += column["actualWidth"];
    }
  }
  var minimumWidths = 0;
  var actualWidth = 0;
  var index, newIndex;
  var i;
  var rightDrag = false;
  var stretchMax;
  var affectedColumns = [];
  var widthDelta;
  if (newWidth > maxOldWidth) {
    rightDrag = true;
    index = resizedColumnsInfo[resizedColumnTally - 1]["displayIndex"] + 1;
    var rightMostColStretched = index == leafColumns.length;
    if (rightMostColStretched) {
      index--;
    }
    for (i = index;i < leafColumns.length;i++) {
      affectedColumns.push(this._createStretchColumnData(i, leafColumns[i], firstRow));
      newIndex = affectedColumns.length - 1;
      minimumWidths += affectedColumns[newIndex]["minimumWidth"];
      actualWidth += affectedColumns[newIndex]["actualWidth"];
    }
  } else {
    index = resizedColumnsInfo[0]["displayIndex"] - 1;
    for (i = index;i >= 0;i--) {
      affectedColumns.push(this._createStretchColumnData(i, leafColumns[i], firstRow));
      newIndex = affectedColumns.length - 1;
      minimumWidths += affectedColumns[newIndex]["minimumWidth"];
      actualWidth += affectedColumns[newIndex]["actualWidth"];
    }
  }
  stretchMax = actualWidth - minimumWidths;
  if (this._nothingFlexible) {
    var databody = this.GetDataBody();
    var blockList = databody.childNodes;
    if (blockList && blockList[0]) {
      var deltaDbTable = databody.offsetWidth - this._totalWidth;
      if (deltaDbTable > 0) {
        stretchMax += deltaDbTable;
      }
    }
  }
  widthDelta = newWidth - maxOldWidth;
  if (widthDelta >= 0 && widthDelta > stretchMax) {
    newWidth = stretchMax + resizedColumnMin;
    widthDelta = stretchMax;
    if (newWidth <= 0) {
      return;
    }
  }
  resizedColumnsInfo.sort(AdfDhtmlTableBasePeer.__columnSortComparator);
  var spaceRemaining = oldWidth - resizedColumnMin + widthDelta;
  while (spaceRemaining != 0) {
    var bucket = [];
    var currentDesiredWidth = resizedColumnsInfo[0]["desiredWidth"];
    for (i = 0;i < resizedColumnTally;i++) {
      var columnSizeDelta = 0;
      column = resizedColumnsInfo[i];
      if (!resizedColumnsInfo[i + 1]) {
        currentDesiredWidth = Math.abs(spaceRemaining);
        columnSizeDelta = Math.abs(spaceRemaining);
      } else {
        columnSizeDelta = column["desiredWidth"];
      }
      if (columnSizeDelta <= currentDesiredWidth) {
        bucket.push(column);
      } else {
        break;
      }
    }
    var addToColumn = Math.floor(spaceRemaining / bucket.length);
    if (addToColumn > currentDesiredWidth && bucket.length < resizedColumnTally) {
      addToColumn = resizedColumnsInfo[bucket.length]["desiredWidth"] - bucket[bucket.length - 1]["desiredWidth"];
    }
    for (i = 0;i < bucket.length;i++) {
      bucket[i]["desiredWidth"] += addToColumn;
      spaceRemaining -= addToColumn;
    }
    if (spaceRemaining / bucket.length < 1) {
      resizedColumnsInfo[resizedColumnTally - 1]["desiredWidth"] += spaceRemaining;
      spaceRemaining = 0;
    }
  }
  for (i = 0;i < resizedColumnTally;i++) {
    if (this._shouldResizeCol(column["displayIndex"])) {
      column = resizedColumnsInfo[i];
      column["flex"] = Math.abs(column["desiredWidth"]);
      this._doResizeColumn(column["displayIndex"], null, column["flex"], column["flex"] - column["actualWidth"], true);
    }
  }
  if (!rightDrag) {
    var rightColDisplayIndex = resizedColumnsInfo[resizedColumnTally - 1]["displayIndex"] + 1;
    if (!leafColumns[rightColDisplayIndex]) {
      rightColDisplayIndex++;
    }
    if (this._shouldResizeCol(rightColDisplayIndex)) {
      if (rightColDisplayIndex < leafColumns.length) {
        var newDelta = Math.abs(widthDelta);
        affectedColumns[rightColDisplayIndex] = {"component":leafColumns[rightColDisplayIndex], "displayIndex":i, "minimumWidth":leafColumns[rightColDisplayIndex].getMinimumWidth(), "actualWidth":this._getColumnActualWidth(rightColDisplayIndex, firstRow)};
        affectedColumns[rightColDisplayIndex]["actualWidth"] += newDelta;
        this._doResizeColumn(rightColDisplayIndex, null, affectedColumns[rightColDisplayIndex]["actualWidth"], newDelta, true);
        if (newWidth >= resizedColumnMin) {
          widthDelta = 0;
        }
      }
    }
  }
  var columnData;
  var columnDelta;
  if (rightDrag && !rightMostColStretched) {
    var remainingWidthDelta = widthDelta;
    var resizeShouldBeOrHasBeenSkipped = false;
    for (i = 0;i < affectedColumns.length;i++) {
      if (!resizeShouldBeOrHasBeenSkipped) {
        resizeShouldBeOrHasBeenSkipped = !this._shouldResizeCol(affectedColumns[i]["displayIndex"]);
      }
      if (!resizeShouldBeOrHasBeenSkipped) {
        columnData = affectedColumns[i];
        if (columnData.component) {
          columnDelta = columnData["actualWidth"] - columnData["minimumWidth"];
          if (remainingWidthDelta >= columnDelta) {
            columnData["newWidth"] = columnData["minimumWidth"];
            columnData["flex"] = columnData["newWidth"];
            alteredColumns[columnData["displayIndex"]] = columnData;
            this._doResizeColumn(columnData["displayIndex"], null, columnData["newWidth"], -columnDelta, true);
            remainingWidthDelta -= columnDelta;
          } else {
            columnData["newWidth"] = columnData["actualWidth"] - remainingWidthDelta;
            columnData["flex"] = columnData["newWidth"];
            alteredColumns[columnData["displayIndex"]] = columnData;
            this._doResizeColumn(columnData["displayIndex"], null, columnData["newWidth"], -remainingWidthDelta, true);
            break;
          }
        }
      }
    }
  }
  var stretchDetails = [];
  var flex;
  for (i = 0;i < leafColumns.length;i++) {
    if (!alteredColumns[i]) {
      flex = this._getColumnFlex(leafColumns[i], null, columnStretchingType, leafColumns.length, i);
      if (flex) {
        stretchDetails.push({"displayIndex":i, "width":this._getColumnActualWidth(i, firstRow)});
      }
    }
  }
  this._currentColumnStretchDetails = stretchDetails;
  this._stretchTheColumns();
  var columnHeader = this.__getColumnHeader();
  AdfAgent.AGENT.enableUserSelect(columnHeader);
};
AdfDhtmlTableBasePeer.prototype._shouldResizeCol = function(index) {
  if (this._columnStretching != "multiple") {
    return true;
  }
  return !this._isLastFlexColumn(index);
};
AdfDhtmlTableBasePeer.prototype._isLastFlexColumn = function(index) {
  var leafColumns = this.__getVisibleLeafColumns();
  var leafColumnCount = leafColumns.length;
  var columnStretching = this._columnStretching;
  var foundFlexIndex = -1;
  AdfAssert.assert(columnStretching == "multiple", "This fuction must not be called when columnStretching is: " + columnStretching);
  var found = false;
  for (var i = 0;i < leafColumnCount;i++) {
    var f = this._getColumnFlex(leafColumns[i], null, columnStretching, leafColumnCount, i);
    if (f != null) {
      if (found) {
        return false;
      }
      found = true;
      foundFlexIndex = i;
    }
  }
  return found && index == foundFlexIndex;
};
AdfDhtmlTableBasePeer.prototype._createStretchColumnData = function(index, column, firstRow) {
  var columnData = null;
  if (column) {
    columnData = {"component":column, "displayIndex":index, "minimumWidth":column.getMinimumWidth(), "actualWidth":this._getColumnActualWidth(index, firstRow)};
  } else {
    var detailStampWidth = this._getColumnActualWidth(index, firstRow);
    columnData = {"component":null, "displayIndex":index, "minimumWidth":detailStampWidth, "actualWidth":detailStampWidth};
  }
  return columnData;
};
AdfDhtmlTableBasePeer.__columnSortComparator = function(x, y) {
  return x["minimumWidth"] - y["minimumWidth"];
};
AdfDhtmlTableBasePeer.prototype.__getPixelWidthFromPercent = function(percentWidth) {
  var width = parseInt(percentWidth);
  if (!isNaN(width)) {
    var dataBody = this.GetDataBody();
    width = dataBody.offsetWidth * width / 100;
    return width.toFixed(0);
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype.resizeColumn = function(colComponent, value, oldWidth) {
  if (this._ignoreSetColWidth) {
    return;
  }
  var isPercent = value.toString().indexOf("%") > 0;
  var clientId = colComponent.getClientId();
  var colHeader = this.__getColumnHeader();
  var agent = AdfAgent.AGENT;
  var cells = colHeader.getElementsByTagName("th"), cellCount = cells.length;
  var th, displayIndex;
  for (var i = 0;i < cellCount;++i) {
    if (cells[i].id == clientId) {
      th = cells[i];
      displayIndex = agent.getIntAttribute(th, "_d_index", 0);
      this._resizedIndex = displayIndex;
      break;
    }
  }
  if (th) {
    var newWidth = 100;
    if (value != null) {
      newWidth = value;
      if (isPercent) {
        newWidth = this.__getPixelWidthFromPercent(value);
      }
    }
    if (isNaN(newWidth) || newWidth <= 0 || newWidth > 3200) {
      newWidth = 100;
    }
    var selectedColumns = this.__getSelectedColumns();
    var resizedColumnIsInSelection = AdfCollections.indexOf(selectedColumns, colComponent) != -1;
    if (resizedColumnIsInSelection) {
      var resizeCount = selectedColumns.length;
      for (var c = 0;c < resizeCount;c++) {
        newWidth = Math.max(newWidth, selectedColumns[c].getMinimumWidth());
      }
    } else {
      newWidth = Math.max(newWidth, colComponent.getMinimumWidth());
    }
    this._doColResizesFromUser(newWidth, oldWidth);
  }
};
AdfDhtmlTableBasePeer.prototype._doResizeColumn = function(displayIndex, th, newWidth, delta, persist) {
  var newHeaderHeight = false;
  var newFooterHeight = false;
  var newFrozenWidth = false;
  var newUnfrozenWidth = false;
  if (this._hasFrozenColumn()) {
    if (this._totalWidth !== undefined) {
      this._totalWidth += delta;
    } else {
      this._totalWidth = delta;
    }
    if (this._isColumnFrozen(displayIndex)) {
      this._frozenWidth += delta;
      newFrozenWidth = true;
    } else {
      this._unfrozenWidth += delta;
      newUnfrozenWidth = true;
    }
  }
  var dataBody = this.GetDataBody();
  if ((newFrozenWidth || newUnfrozenWidth) && !this.IsEmpty) {
    this._sizeRegionsForFrozenColumns(dataBody, dataBody.offsetWidth);
  }
  if (!this._headerless) {
    var colHeader = this.__getColumnHeader();
    if (!th) {
      th = this._getColumnHeaderFooterSizingCell(displayIndex, colHeader, "t", "d2", "t2");
    }
    this._resizeColumnHeaderFooterColumn(th, delta, colHeader, displayIndex, "t", "d2", "t2");
    if (this.IsEmpty) {
      if (this._columnStretching != "multiple") {
        this._incrementWidth(colHeader, delta);
      }
      this._synchronizeColumnRowHeights(colHeader, "t", "d2", "t2");
    } else {
      this._synchronizeColumnRowHeights(colHeader, "t", "d2", "t2");
      var height = colHeader.offsetHeight;
      if (height != this._cachedCHHeight) {
        this._cachedCHHeight = height;
        newHeaderHeight = true;
      }
    }
  }
  if (!this._footerless) {
    var colFooter = this._getColumnFooter();
    th = this._getColumnHeaderFooterSizingCell(displayIndex, colFooter, "ft", "fd2", "ft2");
    this._resizeColumnHeaderFooterColumn(th, delta, colFooter, displayIndex, "ft", "fd2", "ft2");
    if (this.IsEmpty) {
      this._incrementWidth(colFooter, delta);
      this._synchronizeColumnRowHeights(colFooter, "ft", "fd2", "ft2");
    } else {
      this._synchronizeColumnRowHeights(colFooter, "ft", "fd2", "ft2");
      var height = colFooter.offsetHeight;
      if (height != this._cachedCFHeight) {
        this._cachedCFHeight = height;
        newFooterHeight = true;
      }
    }
  }
  if (this.IsEmpty) {
    return;
  }
  var resizeInfo = this._resizeDataBodyColumn(dataBody, displayIndex, delta);
  if (newHeaderHeight || newFooterHeight || newFrozenWidth) {
    var container = this.getDomElement();
    this._setScrollerTop(this._cachedCHHeight);
    this._setScrollerHeight(container.clientHeight, this._cachedCHHeight, this._cachedCFHeight, this._cachedNBHeight);
    this._setScrollerWidth(container.clientWidth, this._frozenWidth);
  }
  var fakeWidth;
  var firstBlock = dataBody.firstChild;
  if (!this._hasFrozenColumn()) {
    fakeWidth = parseInt(firstBlock.getBoundingClientRect().width);
  } else {
    fakeWidth = !this._areAllColumnsFrozen() ? parseInt(this._getNestedScrolledTable(firstBlock.rows[0]).clientWidth) : 0;
  }
  this._setFakeCanvasWidth(fakeWidth);
  var relFactor = resizeInfo.relFactor;
  var sizeDiff = resizeInfo.delta;
  var canvasDelta = sizeDiff != undefined ? sizeDiff : Math.round((relFactor - 1) * this._averageRowHeight * this.GetKnownRowCount());
  this._adjustCanvasHeight(canvasDelta, dataBody, true, true);
  if (persist) {
    var column = this.__getVisibleLeafColumns()[displayIndex];
    this._ignoreSetColWidth = true;
    column.setProperty(AdfRichColumn.WIDTH, newWidth, true);
    delete this._ignoreSetColWidth;
  }
  var scrollLeft = this.__getScrollLeft();
  if (this._currentScrollLeft != scrollLeft) {
    this._currentScrollLeft = scrollLeft;
    this._handleHorizontalScroll(scrollLeft);
  }
  if (!this._virtInitialized) {
    this._fillViewPort(dataBody, dataBody.offsetHeight, false);
  }
};
AdfDhtmlTableBasePeer.prototype._resizeColumnHeaderFooterColumn = function(th, delta, colHeader, displayIndex, tableId, div2Id, table2Id) {
  var newWidth = this._incrementWidth(th, delta);
  var table1 = AdfDhtmlTableBasePeer.__getChildBySubId(colHeader, tableId);
  if (this._hasFrozenColumn()) {
    var second = AdfDhtmlTableBasePeer.__getChildBySubId(colHeader, div2Id);
    var table2 = AdfDhtmlTableBasePeer.__getChildBySubId(second, table2Id);
    if (this._freezeColumnsToStart()) {
      if (this._isColumnFrozen(displayIndex)) {
        this._incrementWidth(table1, delta);
        var tableWidth = table1.style.width;
        var secondStyle = second.style;
        if (AdfDhtmlTableBasePeer._isRTL()) {
          secondStyle.right = tableWidth;
        } else {
          secondStyle.left = tableWidth;
        }
      } else {
        this._incrementWidth(table2, delta);
      }
    } else {
      if (!this._isColumnFrozen(displayIndex)) {
        this._incrementWidth(table2, delta);
        var tableWidth = table2.style.width;
        if (AdfDhtmlTableBasePeer._isRTL()) {
          table1.style.right = tableWidth;
        } else {
          table1.style.left = tableWidth;
        }
      } else {
        this._incrementWidth(table1, delta);
      }
    }
  } else {
    this._incrementWidth(table1, delta);
  }
  return newWidth;
};
AdfDhtmlTableBasePeer.prototype._resizeDataBodyColumn = function(dataBody, displayIndex, delta) {
  var oldHeight = 0, newHeight = 0;
  var blockList = dataBody.childNodes;
  for (var i = blockList.length - 1;i >= 0;i--) {
    var block = blockList[i];
    oldHeight += block.cachedHeight;
    this._resizeBlockColumn(block, displayIndex, delta);
    block._lastSyncRow = null;
    this._synchronizeRowHeights(block);
    var height = block.offsetHeight;
    newHeight += height;
    if (height != block.cachedHeight) {
      var hDelta = height - block.cachedHeight;
      for (var b = i + 1;b < blockList.length;b++) {
        blockList[b].startPos += hDelta;
      }
    }
    block.cachedHeight = height;
  }
  var allLocal = blockList.length == 1 && blockList[0].startRow == 0 && blockList[0].numRows == this.GetKnownRowCount();
  var diff = allLocal ? newHeight - oldHeight : undefined;
  return {relFactor:newHeight / oldHeight, delta:diff};
};
AdfDhtmlTableBasePeer.prototype._resizeBlockColumn = function(block, displayIndex, delta) {
  if (!this._hasFrozenColumn() || this._isColumnFrozen(displayIndex)) {
    if (block.rows) {
      if (this._freezeColumnsToEnd()) {
        this._incrementWidth(block.rows[0].cells[displayIndex - this._firstFrozen + 1], delta);
      } else {
        this._incrementWidth(block.rows[0].cells[displayIndex], delta);
      }
    }
  } else {
    var rows = block.rows;
    for (var r = 0;r < rows.length;r++) {
      var td;
      var table = this._getNestedScrolledTable(rows[r]);
      this._incrementWidth(table, delta);
      if (this._freezeColumnsToStart()) {
        td = table.rows[0].cells[displayIndex - this._lastFrozen - 1];
      } else {
        td = table.rows[0].cells[displayIndex];
      }
      this._incrementWidth(td, delta);
    }
  }
  if (!this._hasFrozenColumn()) {
    this._incrementWidth(block, delta);
  }
};
AdfDhtmlTableBasePeer.prototype._incrementWidth = function(element, delta) {
  AdfAssert.assertDomNode(element);
  var newWidth = parseInt(element.style.width) + delta;
  if (!isNaN(newWidth)) {
    element.style.width = newWidth + "px";
  }
  if (this._processColGroup()) {
    if (element.tagName == "TH" || element.tagName == "TD") {
      var colGrpCol = this._findColGroupColumn(element);
      if (colGrpCol) {
        newWidth = parseInt(colGrpCol.style.width) + delta;
        colGrpCol.style.width = newWidth + "px";
      }
    }
  }
  return newWidth;
};
AdfDhtmlTableBasePeer.prototype._findColGroupColumn = function(element, delta) {
  AdfAssert.assertDomNode(element);
  AdfAssert.assert(element.tagName == "TH" || element.tagName == "TD", "Invalid COLGROUP tag name");
  var parentRow = element.parentNode;
  while (parentRow && parentRow.tagName != "TR") {
    parentRow = parentRow.parentNode;
  }
  if (parentRow) {
    var cells = parentRow.cells;
    var cellCount = cells.length;
    for (var index = 0;index < cellCount;index++) {
      if (cells[index] == element) {
        break;
      }
    }
    if (index < cellCount) {
      var parentTable = parentRow.parentNode;
      while (parentTable && parentTable.tagName != "TABLE") {
        parentTable = parentTable.parentNode;
      }
      if (parentTable) {
        var colGroup = AdfDhtmlTableBasePeer.FindFirstChildByTagName(parentTable, "COLGROUP");
        if (colGroup) {
          var childNodes = colGroup.childNodes;
          ++index;
          for (var c = 0;c < childNodes.length;c++) {
            if (childNodes[c].tagName == "COL") {
              --index;
            }
            if (index == 0) {
              return childNodes[c];
            }
          }
        }
      }
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.SetCursor = function(elem, cur) {
  if (elem) {
    if (elem.style.cursor != cur) {
      elem.style.cursor = cur;
    }
  }
};
AdfDhtmlTableBasePeer.prototype._handleColumnContextMenu = function(domEvent, alignElement) {
  if (!this._pcPeer) {
    return;
  }
  var th = alignElement ? alignElement : this._getParentTH(domEvent);
  if (th && th.getAttribute(AdfDhtmlTableBasePeer._LEAF_COLUMN) != null) {
    var col = AdfPage.PAGE.findComponent(th.id);
    if (!col.getSelected() && this._isColumnSelectionEnabled()) {
      this._selUnselectAll();
      var index = AdfAgent.AGENT.getIntAttribute(th, "_d_index", -1);
      this._selectColumn(index, col, true);
    }
    this._pcPeer.showColumnContextMenu(domEvent, alignElement);
  }
};
AdfDhtmlTableBasePeer.prototype._handleBodyContextMenu = function(domEvent) {
  var component = this.getComponent();
  var menuId = component.getBodyContextMenuId ? component.getBodyContextMenuId() : null;
  if (menuId) {
    component.setSelectedRowKeys(new Object);
    var popup = component.findComponent(menuId);
    var menuFindContainer = component;
    if (popup == null) {
      popup = AdfPage.PAGE.findComponent(menuId);
      menuFindContainer = null;
    }
    this.showContextMenu(domEvent, menuId, menuFindContainer);
    var agent = AdfAgent.AGENT;
    agent.eatEvent(domEvent);
  }
};
AdfDhtmlTableBasePeer.prototype.GetRowContextMenuId = function(rowKey) {
  return this.getComponent().getContextMenuId();
};
AdfDhtmlTableBasePeer.prototype._getRowContextMenuAndContainer = function(rowKey) {
  var menuId = this.GetRowContextMenuId(rowKey);
  var popup;
  var menuFindContainer;
  if (menuId) {
    var component = this.getComponent();
    popup = AdfPage.PAGE.findComponent(menuId);
    menuFindContainer = null;
    if (popup == null) {
      popup = component.findComponent(menuId);
      menuFindContainer = component;
    }
    if (popup == null) {
      AdfLogger.LOGGER.severe("Could not find context menu ", menuId, " from component ", component);
    }
  }
  return {popup:popup, menuId:menuId, menuFindContainer:menuFindContainer};
};
AdfDhtmlTableBasePeer.prototype.HandleRowContextMenu = function(domEvent, rowKey, row, alignElement, alignHint) {
  var params = this._getRowContextMenuAndContainer(rowKey);
  var popup = params.popup;
  var menuFindContainer = params.menuFindContainer;
  var menuId = params.menuId;
  if (popup) {
    if (!this._contextMenuSelect) {
      if (!this._isMultipleRowSelect()) {
        this._unhiglightAnyExistingHighlightedRow();
      }
      this._selHighlightRow(row);
      this._highlightedRowKey = rowKey;
      this._highlightedRow = row;
    } else {
      if (AdfAgent.AGENT.getCapabilities()[AdfAgent.CAP_TOUCH_SCREEN] != AdfAgent.CAP_TOUCH_SCREEN_NONE && !this._selIsSelected(rowKey)) {
        this.suppressSelectionEventDelivery(true);
        this._selUnselectAll();
        this.suppressSelectionEventDelivery(false);
        this._selSelectRow(rowKey, row);
      }
    }
    var component = this.getComponent();
    var clientId = component.getClientId();
    AdfObject.ensureClassInitialization(AdfDhtmlCommandMenuItemPeer);
    popup[AdfMenuUtils.AFR_TARGETROWCURRENCY] = rowKey;
    popup[AdfMenuUtils.AFR_TARGETCOMPONENTID] = clientId;
    var params = {component:this.getComponent(), rowKey:rowKey};
    AdfPage.PAGE.scheduleTimer(null, AdfDhtmlTableBasePeer._setHighlightedRowKey, params, 10);
    AdfDhtmlTableBasePeer._setHighlightedRowKey(params);
    if (!this._contextMenuClosedCallback) {
      this._contextMenuClosedCallback = this.createCallback(this._contextMenuClosed);
    }
    if (!this._contextMenuOpenedCallback) {
      this._contextMenuOpenedCallback = this.createCallback(this._contextMenuOpened);
    }
    if (!popup._afrTableListenerSet) {
      popup.addEventListener(AdfPopupOpenedEvent.POPUP_OPENED_EVENT_TYPE, this._contextMenuOpenedCallback);
      popup.addEventListener(AdfPopupClosedEvent.POPUP_CLOSED_EVENT_TYPE, this._contextMenuClosedCallback);
      popup._afrTableListenerSet = true;
    }
    if (popup.isPopupVisible()) {
      popup.hide();
      this._ignoreContextMenuClose = true;
    }
    this.showContextMenu(domEvent, menuId, menuFindContainer, alignElement, alignHint, clientId);
    var agent = AdfAgent.AGENT;
    agent.eatEvent(domEvent);
  }
};
AdfDhtmlTableBasePeer.prototype.ContextMenuOpened = function(componentEvent, popup) {
};
AdfDhtmlTableBasePeer.prototype.ContextMenuClosed = function(componentEvent, popup) {
};
AdfDhtmlTableBasePeer.prototype._contextMenuOpened = function(componentEvent) {
  this._rowContextMenuVisible = true;
  var popup = componentEvent.getSource();
  if (!this._contextMenuSelect) {
    var params = this._getRowContextMenuAndContainer(this._highlightedRowKey);
    var contextPopup = params.popup;
    if (contextPopup != null && popup.getClientId() == contextPopup.getClientId()) {
      if (!this._isMultipleRowSelect()) {
        this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UNSELECT, false);
      }
    }
  }
  this.ContextMenuOpened(componentEvent, popup);
};
AdfDhtmlTableBasePeer.prototype._contextMenuClosed = function(componentEvent) {
  if (this._ignoreContextMenuClose) {
    delete this._ignoreContextMenuClose;
    return;
  }
  delete this._rowContextMenuVisible;
  var popup = componentEvent.getSource();
  if (!this._contextMenuSelect) {
    var params = this._getRowContextMenuAndContainer(this._highlightedRowKey);
    var contextPopup = params.popup;
    if (contextPopup != null && popup.getClientId() == contextPopup.getClientId()) {
      this._grabFocus();
      this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UPDATE, false);
      this._unhiglightAnyExistingHighlightedRow();
    }
  }
  delete popup[AdfMenuUtils.AFR_TARGETROWCURRENCY];
  delete popup[AdfMenuUtils.AFR_TARGETCOMPONENTID];
  AdfPage.PAGE.scheduleTimer(null, AdfDhtmlTableBasePeer._clearHighlightedRowKey, this.getComponent(), 10);
  this.ContextMenuClosed(componentEvent, popup);
};
AdfDhtmlTableBasePeer._clearHighlightedRowKey = function(component) {
  component.setProperty("_highlightedRowKey", null, false, AdfUIComponent.PROPAGATE_ALWAYS);
};
AdfDhtmlTableBasePeer._setHighlightedRowKey = function(params) {
  var component = params.component;
  var rowKey = params.rowKey;
  component.setProperty("_highlightedRowKey", rowKey, false, AdfUIComponent.PROPAGATE_ALWAYS);
};
AdfDhtmlTableBasePeer.prototype.ProcessPushData = function(payload, changeCount) {
  if (!this._virtInitialized && !this.IsEmpty) {
    return;
  }
  if (this._activeDataCount >= changeCount) {
    AdfPage.PAGE.addPartialTargets(this.getComponent());
    return;
  }
  this._activeDataCount = changeCount;
  if (!this._payloadEvaluator) {
    this._payloadEvaluator = function anonymous(payload) {
      return payload;
    };
  }
  var envelope = this._payloadEvaluator(payload);
  for (var i = 0;i < envelope.length;i++) {
    var message = envelope[i];
    if (this.IsFetchPending()) {
      message["id"] = changeCount;
      this._getActiveMessageBuffer().push(message);
    } else {
      this._processActiveMessage(message);
    }
  }
  if (!this.IsFetchPending()) {
    this._resetTwinkledCellStyling();
  }
  var dataBody = this.GetDataBody();
  this._fillViewPort(dataBody, dataBody.offsetHeight, false);
  envelope = null;
  return true;
};
AdfDhtmlTableBasePeer.prototype._processActiveMessage = function(message) {
  var rerender;
  var result;
  var type = message["type"];
  switch(type) {
    case "update":
      result = this.UpdateActiveRow(message);
      break;
    case "remove":
      result = this.RemoveActiveRow(message);
      break;
    case "insertBefore":
    ;
    case "insertAfter":
    ;
    case "insertInside":
      result = this.InsertActiveRow(message, type);
      break;
    default:
      AdfAssert.assert(false, "Unknown ADS type:" + type);
      rerender = AdfDhtmlTableBasePeer.RERENDER_CONTAINER;
      break;
  }
  if (result) {
    rerender = result["rerender"];
    this._announceActiveDataUpdate(type, result["updates"]);
  }
  if (rerender) {
    AdfPage.PAGE.addPartialTargets(this.getComponent());
  }
};
AdfDhtmlTableBasePeer.prototype.IsValidAnnouncement = function(table, agent, type) {
  var ariaLive = agent.getAttribute(table, "aria-live") || "";
  ariaLive = ariaLive.toLowerCase();
  if ("" !== ariaLive) {
    return false;
  }
  var ariaRelevant = agent.getAttribute(table, "aria-relevant") || "";
  ariaRelevant = ariaRelevant.toLowerCase().trim();
  var relevances = ariaRelevant.split(" ");
  if (relevances.indexOf("all") > -1) {
    return true;
  }
  var supported = false;
  switch(type) {
    case "update":
      if ("" === ariaRelevant || relevances.indexOf("text") > -1) {
        supported = true;
      }
      break;
    case "remove":
      if (relevances.indexOf("removals") > -1) {
        supported = true;
      }
      break;
    case "insertBefore":
    ;
    case "insertAfter":
    ;
    case "insertInside":
      if ("" === ariaRelevant || relevances.indexOf("additions") > -1) {
        supported = true;
      }
      break;
    default:
      break;
  }
  return supported;
};
AdfDhtmlTableBasePeer.prototype._announceActiveDataUpdate = function(type, updates) {
  if (!updates || updates === "") {
    return;
  }
  var table = this.getDomElement();
  var agent = AdfAgent.AGENT;
  if (!table) {
    return;
  }
  if (!this.IsValidAnnouncement(table, agent, type)) {
    return;
  }
  var laf = AdfPage.PAGE.getLookAndFeel();
  var component = this.getComponent();
  var name = component.getAccessibleName();
  if (name == null) {
    name = "";
    AdfLogger.LOGGER.fine("No shortDesc exists for the component with clientId: ", component.getClientId());
  }
  var key = this.GetActiveDataAnnouncementKey(type);
  var msg = laf.getTranslatedString(key);
  msg = TrFastMessageFormatUtils["format"](msg, name, updates);
  this._twinkledCellAnnouncements = this._twinkledCellAnnouncements + " " + msg;
};
AdfDhtmlTableBasePeer.prototype.GetActiveDataAnnouncementKey = function(type) {
  return AdfDhtmlTableBasePeer.msgMap[type] || "AFActiveDataTableRowInsert";
};
AdfDhtmlTableBasePeer.prototype.RegisterADSAccessibility = function() {
};
AdfDhtmlTableBasePeer.prototype._getActiveMessageBuffer = function() {
  if (!this._activeMessageBuffer) {
    this._activeMessageBuffer = new Array;
  }
  return this._activeMessageBuffer;
};
AdfDhtmlTableBasePeer.prototype._resetActiveMessageBuffer = function() {
  this._activeMessageBuffer = null;
};
AdfDhtmlTableBasePeer.prototype._applyBufferedADSEvents = function(adsCounter, oldEvents) {
  if (adsCounter == -1) {
    return;
  }
  var list = this._activeMessageBuffer;
  if (list) {
    for (var i = 0;i < list.length;i++) {
      var message = list[i];
      var id = message["id"];
      var apply = oldEvents ? id <= adsCounter : id > adsCounter;
      if (apply) {
        this._processActiveMessage(message);
      }
    }
  }
  this._resetTwinkledCellStyling();
};
AdfDhtmlTableBasePeer.prototype.IsInsertAllowed = function(insertIndex) {
  var allowed = true;
  var blocks = this.GetDataBody().childNodes;
  var first = blocks[0];
  var last = blocks[blocks.length - 1];
  if (this._pendingFetch == AdfTableDataFetchEvent.AFTER_KEY_SUBTYPE) {
    if (insertIndex == last.startRow + last.numRows) {
      allowed = false;
    }
  } else {
    if (this._pendingFetch == AdfTableDataFetchEvent.BEFORE_KEY_SUBTYPE) {
      if (insertIndex == first.startRow) {
        allowed = false;
      }
    } else {
      if (this._pendingFetch == undefined) {
        var isAppend = insertIndex == last.startRow + last.numRows;
        if (!isAppend && (insertIndex < first.startRow || insertIndex >= last.startRow + last.numRows)) {
          allowed = false;
        }
      }
    }
  }
  return allowed;
};
AdfDhtmlTableBasePeer.prototype._findADSInsertLocation = function(anchorKey, insertType, blocks) {
  var before = insertType == "insertBefore";
  var insertAt = -1;
  var rowInfo;
  if (before) {
    if (!anchorKey) {
      var last = blocks[blocks.length - 1];
      var count = this.GetRowCount();
      if (count != -1 && last.startRow + last.numRows == count) {
        insertAt = count;
      }
    } else {
      rowInfo = this.FindRowByKey(anchorKey);
      if (rowInfo) {
        insertAt = rowInfo.index;
      }
    }
  } else {
    if (!anchorKey) {
      if (blocks[0].startRow == 0) {
        insertAt = 0;
      }
    } else {
      rowInfo = this.FindRowByKey(anchorKey);
      if (rowInfo) {
        insertAt = rowInfo.index + 1;
      }
    }
  }
  return insertAt;
};
AdfDhtmlTableBasePeer.prototype.InsertClonedRow = function(templateRow, insertAt, insertRowKey) {
  var tr = templateRow.cloneNode(true);
  this._cleanClonedRow(tr, insertRowKey);
  tr.setAttribute(AdfDhtmlTableBasePeer._ROW_KEY, insertRowKey);
  AdfDomUtils.removeCSSClassName(tr, AdfDhtmlTableBasePeer._SELECTED_CLASS);
  AdfDomUtils.removeCSSClassName(tr, AdfDhtmlTableBasePeer._HIGHLIGHTED_CLASS);
  AdfDomUtils.removeCSSClassName(tr, AdfDhtmlTableBasePeer._FOCUSED_CLASS);
  var templateTable = templateRow.parentNode.parentNode;
  var table = templateTable.cloneNode(false);
  var tbody = this.getDomDocument().createElement("TBODY");
  tbody.appendChild(tr);
  table.appendChild(tbody);
  this.InsertBlock(table, insertAt, 1, 1, 0);
  return tr;
};
AdfDhtmlTableBasePeer.prototype.InsertClonedComponents = function(rootDomNode, newRowKey) {
  var components = AdfAgent.AGENT.getDescendantComponentsForNode(rootDomNode);
  if (components) {
    var componentCount = components.length;
    for (var i = 0;i < componentCount;i++) {
      var baseComponent = components[i];
      var oldClientId = baseComponent.getClientId();
      var newClientId = this._fixClonedClientId(oldClientId, newRowKey);
      var clonedComponent = baseComponent.clone(newClientId);
      clonedComponent.AddNotify();
    }
  }
};
AdfDhtmlTableBasePeer.prototype.InsertActiveRow = function(message, insertType) {
  var rerender;
  var blocks = null;
  if (!this.IsEmpty) {
    blocks = this.GetDataBody().childNodes;
  }
  if (blocks && blocks.length > 0) {
    var insertAt = this._findADSInsertLocation(message["iKey"], insertType, blocks);
    if (insertAt != -1 && this.IsInsertAllowed(insertAt)) {
      var insertRowKey = message["rKey"];
      var templateRow = this.GetTemplateRow(blocks);
      this.InsertClonedRow(templateRow, insertAt, insertRowKey);
      this.InsertClonedComponents(templateRow, insertRowKey);
      var result = this.UpdateActiveRow(message);
      renderer = result["rerender"];
    } else {
      rerender = AdfDhtmlTableBasePeer.RERENDER_CONTAINER_CHILDREN;
    }
  } else {
    rerender = AdfDhtmlTableBasePeer.RERENDER_CONTAINER_CHILDREN;
  }
  var update = this.GetActiveRowText(message["rKey"], insertType);
  return {"rerender":rerender, "updates":update};
};
AdfDhtmlTableBasePeer.prototype.GetTemplateRow = function(blocks) {
  var templateBlock = blocks[0];
  var templateRows = templateBlock.rows;
  AdfAssert.assert(templateRows && templateRows[0], "Unable to insert active row when the block contains no rows to clone!");
  return templateRows[0];
};
AdfDhtmlTableBasePeer.prototype.RemoveActiveRow = function(message) {
  var update = "";
  if (!this.IsEmpty) {
    var rowInfo = this.FindRowByKey(message["rKey"]);
    if (rowInfo) {
      var removedRow = rowInfo.tr;
      update = this.GetActiveRowText(message["rKey"], "remove");
      AdfAgent.AGENT.elementsRemoved(removedRow);
      this.DeleteBlock(rowInfo.index, 1, 1, 0, null);
      AdfPage.PAGE.removeComponentsInSubtree(removedRow);
    }
  }
  return {"rerender":"", "updates":update};
};
AdfDhtmlTableBasePeer.prototype.MaxOfRerender = function(rerender1, rerender2) {
  if (rerender1 === rerender2) {
    return rerender1;
  }
  var priorityMap = AdfDhtmlTableBasePeer._RERENDER_PRIORITY;
  var priority1 = priorityMap[rerender1];
  var priority2 = priorityMap[rerender2];
  if (!priority1) {
    return rerender2;
  }
  if (!priority2) {
    return rerender1;
  }
  if (priority1 >= priority2) {
    return rerender1;
  } else {
    return rerender2;
  }
};
AdfDhtmlTableBasePeer.prototype.UpdateActiveRow = function(message) {
  var rerender = "";
  var type = message["type"];
  if (!this.IsEmpty) {
    var changes = message["updates"];
    var updates = "";
    for (var i = 0;i < changes.length;i++) {
      var data = changes[i];
      var properties = data["properties"];
      var formattedProperties = data["formattedProperties"];
      var adsCallback = data["callback"];
      var clientId = data["cliId"];
      var result = this._applyActiveDataUpdate(clientId, adsCallback, properties, formattedProperties, type);
      var newRerender = result["result"];
      rerender = this.MaxOfRerender(rerender, newRerender);
      updates = updates + " " + result["update"];
      updates = updates.trim();
    }
  }
  return {"rerender":rerender, "updates":updates};
};
AdfDhtmlTableBasePeer.prototype._cleanClonedRow = function(tr, rowKey) {
  for (var i = 0;i < this._colCount;i++) {
    var td = this.FindCellByIndex(tr, i);
    this._fixElementIds(td, rowKey);
  }
  AdfAgent.AGENT.elementsAdded(tr);
};
AdfDhtmlTableBasePeer.prototype._fixElementIds = function(element, rowKey) {
  element.id = this._fixClonedClientId(element.id, rowKey);
  var child = element.firstChild;
  while (child) {
    if (child.nodeType == 1) {
      this._fixElementIds(child, rowKey);
    }
    child = child.nextSibling;
  }
};
AdfDhtmlTableBasePeer.prototype._fixClonedClientId = function(baseClientId, rowKey) {
  var newClientId = "";
  if (baseClientId) {
    var ids = baseClientId.split(":");
    for (var i = 0;i < ids.length - 2;i++) {
      newClientId += ids[i];
      newClientId += ":";
    }
    newClientId += rowKey + ":";
    newClientId += ids[ids.length - 1];
  }
  return newClientId;
};
AdfDhtmlTableBasePeer.prototype.IsNodeStampCell = function(cell) {
  return false;
};
AdfDhtmlTableBasePeer.prototype._applyActiveDataUpdate = function(clientId, adsCallback, properties, formattedProperties, type) {
  var changedElement = AdfAgent.AGENT.getElementById(clientId);
  if (!changedElement) {
    return {"result":false, "update":""};
  }
  var td = this._findCellContainingChild(changedElement);
  if (!td) {
    return {"result":false, "update":""};
  }
  var oldValue = td.textContent;
  this._markAsActive(td, clientId);
  var cellFunc = function anonymous(clientId, properties, formattedProperties) {
    var c = AdfPage.PAGE.findComponent(clientId);
    if (c) {
      fp = formattedProperties;
      for (p in fp) {
        c.setProperty(p, fp[p], !1, AdfUIComponent.PROPAGATE_LOCALLY);
      }
    } else {
      return "RERENDER_CELL";
    }
  };
  var result = cellFunc(clientId, properties, formattedProperties);
  var update = this.GetUpdatedActiveValues(td, type, oldValue);
  return {"result":result, "update":update};
};
AdfDhtmlTableBasePeer.prototype.GetUpdatedActiveValues = function(td, type, oldValue) {
  var text = "";
  if (type !== "update") {
    return text;
  }
  var table = this.getDomElement();
  var agent = AdfAgent.AGENT;
  if (!table) {
    return text;
  }
  if (!this.IsValidAnnouncement(table, agent, type)) {
    return text;
  }
  text = this.GetRowHeaderText(td, table);
  text.trim();
  if ("" === text) {
    return text;
  }
  var colHeader = this.GetColHeaderText(td);
  var content = td.textContent;
  var laf = AdfPage.PAGE.getLookAndFeel();
  var msg = laf.getTranslatedString("AFActiveDataTableRowUpdateInfo");
  msg = TrFastMessageFormatUtils["format"](msg, text, colHeader, content);
  return msg;
};
AdfDhtmlTableBasePeer.prototype.GetActiveRowText = function(rowKey, type) {
  var text = "";
  var table = this.getDomElement();
  var agent = AdfAgent.AGENT;
  if (!table) {
    return text;
  }
  if (!this.IsValidAnnouncement(table, agent, type)) {
    return text;
  }
  text = this.GetRowText(rowKey, table, agent);
  return text;
};
AdfDhtmlTableBasePeer.prototype.GetRowText = function(rowKey, table, agent) {
  var text = "";
  try {
    var rowInfo = this.FindRowByKey(rowKey);
    var tr = rowInfo["tr"];
    var cells = tr.cells;
    if (this.IsWholeRowRead(table, agent)) {
      var length = cells.length;
      for (var i = 0;i < length;i++) {
        text = text + cells[i].textContent + " ";
      }
    } else {
      text = cells[0].textContent;
    }
    text = text.trim();
    return text;
  } catch (err) {
    AdfLogger.LOGGER.fine("Exception while trying to get the announcement text for the active data row insert/delete" + err);
    return text;
  }
};
AdfDhtmlTableBasePeer.prototype.IsWholeRowRead = function(table, agent) {
  var readwholeRow = agent.getAttribute(table, "data-aria-read-whole-row") || "";
  readwholeRow = readwholeRow.toLowerCase().trim();
  if ("true" === readwholeRow) {
    return true;
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype.GetRowHeaderText = function(td, table) {
  try {
    var rowElement = this.GetRowKeyAndRow(td, table);
    var row = rowElement[1];
    var cell = cells = row.cells[0];
    return cell.textContent;
  } catch (err) {
    AdfLogger.LOGGER.fine("Exception while trying to get the header text of active row:" + err);
    return "";
  }
};
AdfDhtmlTableBasePeer.prototype.GetColHeaderText = function(td) {
  try {
    if (!this._headerless) {
      var colindex = this._getCellIndex(td);
      var column = this._getColumnHeaderLeafCell(colindex);
      return column.textContent;
    } else {
      return "";
    }
  } catch (err) {
    AdfLogger.LOGGER.fine("Exception while trying to get the column header text of active row:" + err);
    return "";
  }
};
AdfDhtmlTableBasePeer.prototype._markAsActive = function(td, childClientId) {
  if (td) {
    AdfDomUtils.addCSSClassName(td, AdfDhtmlTableBasePeer._TWINKLE_ON_STYLE_CLASS);
    AdfDomUtils.removeCSSClassName(td, AdfDhtmlTableBasePeer._TWINKLE_OFF_STYLE_CLASS);
    this._twinkledCells.push(childClientId);
  }
};
AdfDhtmlTableBasePeer.prototype._resetTwinkledCellStyling = function() {
  AdfPage.PAGE.announceToAssistiveTechnology(this._twinkledCellAnnouncements);
  window.setTimeout(AdfDhtmlTableBasePeer._cleanUpAdsNodes, 1E3, this);
};
AdfDhtmlTableBasePeer._cleanUpAdsNodes = function(self) {
  if (self.getDomElement()) {
    var size = self._twinkledCells.length;
    for (var i = 0;i < size;i++) {
      var childClientId = self._twinkledCells[i];
      var changedElement = AdfAgent.AGENT.getElementById(childClientId);
      if (changedElement) {
        var td = self._findCellContainingChild(changedElement);
        if (td) {
          AdfDomUtils.removeCSSClassName(td, AdfDhtmlTableBasePeer._TWINKLE_ON_STYLE_CLASS);
          AdfDomUtils.addCSSClassName(td, AdfDhtmlTableBasePeer._TWINKLE_OFF_STYLE_CLASS);
        }
      }
    }
  }
  delete self._twinkledCells;
  delete self._twinkledCellAnnouncements;
  self._twinkledCells = [];
  self._twinkledCellAnnouncements = "";
};
AdfDhtmlTableBasePeer.prototype.FindRowByKey = function(key) {
  var rowInfo = null;
  var dataBody = this.GetDataBody();
  var blocks = dataBody.childNodes;
  for (var i = 0;i < blocks.length && !rowInfo;i++) {
    var block = blocks[i];
    var rows = block.rows;
    if (rows) {
      for (var r = 0, rowCount = 0;r < rows.length && !rowInfo;r++) {
        var tr = rows[r];
        var rowKey = tr.getAttribute(AdfDhtmlTableBasePeer._ROW_KEY);
        if (rowKey) {
          if (key == rowKey) {
            rowInfo = {tr:tr, index:block.startRow + rowCount, block:block};
            break;
          }
          ++rowCount;
        }
      }
    }
  }
  return rowInfo;
};
AdfDhtmlTableBasePeer.prototype.FindCellByIndex = function(row, index) {
  AdfAssert.assert(row != null, "Unable to find cell by index if the given row is invalid!");
  var cell = null;
  var table = null;
  if (this._freezeColumnsToStart() && !this._isColumnFrozen(index)) {
    table = this._getNestedScrolledTable(row);
    cell = table.rows[0].cells[index - this._lastFrozen - 1];
  } else {
    if (this._freezeColumnsToEnd()) {
      if (this._isColumnFrozen(index)) {
        if (this._firstFrozen > 0) {
          cell = row.cells[index - this._firstFrozen + 1];
        } else {
          cell = row.cells[index];
        }
      } else {
        table = this._getNestedScrolledTable(row);
        cell = table.rows[0].cells[index];
      }
    } else {
      cell = row.cells[index];
    }
  }
  return cell;
};
AdfDhtmlTableBasePeer.prototype._findCellContainingChild = function(childNode) {
  var agent = AdfAgent.AGENT;
  var currNode = childNode;
  while (currNode && agent.getNodeName(currNode) !== "TD") {
    currNode = currNode.parentNode;
  }
  return currNode;
};
AdfDhtmlTableBasePeer.prototype._getColumnFlex = function(column, width, columnStretching, leafColumnCount, iterationIndex) {
  if (!column) {
    return null;
  }
  if (columnStretching == "multiple") {
    var assignedWidth = width;
    if (assignedWidth == null) {
      assignedWidth = "" + column.getWidth();
    }
    var lastIndex = assignedWidth.length - 1;
    if (("" + assignedWidth).charAt(lastIndex) != "%") {
      return null;
    }
    return Math.abs(parseInt(assignedWidth.substring(0, lastIndex)));
  } else {
    if (columnStretching == "last") {
      var columnVisibleIndex = column.getDisplayIndex();
      if (columnVisibleIndex == -1) {
        columnVisibleIndex = iterationIndex;
      }
      if (columnVisibleIndex == leafColumnCount - 1 && !column.getRowHeader()) {
        return 1;
      }
    } else {
      var stretchedColumnId = this._stretchedColumnId;
      if (stretchedColumnId != null) {
        var clientId = column.getClientId();
        var id = clientId.substring(1 + clientId.lastIndexOf(":"));
        if (id == stretchedColumnId) {
          var columnVisibleIndex = column.getDisplayIndex();
          if (columnVisibleIndex == -1) {
            columnVisibleIndex = iterationIndex;
          }
          if (!column.getRowHeader() && (!this._isColumnFrozen(columnVisibleIndex) || this._freezeColumnsToEnd() && columnVisibleIndex == leafColumnCount - 1)) {
            return 1;
          }
        }
      }
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._getColumnActualWidth = function(columnDisplayIndex, firstRow) {
  var defaultColumnWidth = 100;
  var ret = defaultColumnWidth;
  var logError = false;
  var stretchedTD;
  if (this.IsEmpty) {
    stretchedTD = this._getColumnHeaderFooterSizingCell(columnDisplayIndex, this.__getColumnHeader(), "t", "d2", "t2");
  } else {
    stretchedTD = this.FindCellByIndex(firstRow, columnDisplayIndex);
  }
  try {
    var computedWidth = AdfAgent.AGENT.getComputedStyle(stretchedTD).width;
    ret = parseInt(computedWidth);
    if (isNaN(ret) || ret < 0) {
      ret = parseInt(stretchedTD.style.width);
      if (isNaN(ret) || ret < 0) {
        ret = defaultColumnWidth;
        logError = true;
      }
    }
  } catch (e) {
    ret = defaultColumnWidth;
    logError = true;
  }
  if (logError) {
    AdfLogger.LOGGER.warning("INVALID COLUMN WIDTH FOR COLUMN DISPLAY INDEX: " + columnDisplayIndex);
    logError = false;
  }
  return ret;
};
AdfDhtmlTableBasePeer.prototype._stretchTheColumns = function() {
  var columnStretching = this._columnStretching;
  if (columnStretching == null || columnStretching == "none") {
    return;
  }
  if (this._nothingFlexible || this.IsEmpty && this._headerless) {
    return;
  }
  this._stretchingTheColumns = true;
  try {
    this._doColumnStretching(columnStretching);
  } finally {
    delete this._stretchingTheColumns;
  }
};
AdfDhtmlTableBasePeer.prototype._doColumnStretching = function(columnStretching, iterationCount) {
  var flex;
  var columnCount;
  var flexValues;
  var minimumWidths;
  var percentageWidths;
  var agent = AdfAgent.AGENT;
  var totalPercentageWidth = 0;
  var columns = this.__getVisibleLeafColumns();
  columnCount = columns.length;
  flexValues = new Array(columnCount);
  minimumWidths = new Array(columnCount);
  percentageWidths = new Array(columnCount);
  var nothingFlexible = true;
  for (var i = 0;i < columnCount;i++) {
    var column = columns[i];
    flex = this._getColumnFlex(column, null, columnStretching, columnCount, i);
    if (flex != null) {
      nothingFlexible = false;
      flexValues[i] = flex;
      var columnWidth = "" + column.getWidth();
      if (columnWidth.lastIndexOf("%") == columnWidth.length - 1) {
        percentageWidths[i] = columnWidth.substring(0, columnWidth.length - 1);
        totalPercentageWidth += Math.abs(parseInt(percentageWidths[i]));
      }
      minimumWidths[i] = isNaN(columnWidth) ? column.getMinimumWidth() : columnWidth;
    }
  }
  if (nothingFlexible) {
    this._nothingFlexible = true;
    return;
  }
  if (columnStretching == "multiple") {
    for (x = 0;x < percentageWidths.length;x++) {
      percentageWidths[x] = percentageWidths[x] / totalPercentageWidth;
    }
  }
  var colCount = this._colCount;
  var dataBody = this.GetDataBody();
  var block = dataBody.childNodes[0];
  var stretched = false;
  var firstRow;
  if (!this.IsEmpty) {
    firstRow = block.rows[0];
    AdfAssert.assert(firstRow != null, "this.IsEmpty was " + this.IsEmpty + " but there were no rows!");
  }
  var maxWidth;
  var delta = 0;
  if (!this._hasFrozenColumn() || this._areAllColumnsFrozen(colCount)) {
    maxWidth = dataBody.offsetWidth;
    var blockWidth;
    if (this.IsEmpty) {
      var columnHeaderChild = this.__getColumnHeader().firstChild;
      blockWidth = columnHeaderChild.offsetWidth;
    } else {
      blockWidth = block.offsetWidth;
    }
    delta = maxWidth - blockWidth;
  } else {
    var innerNonFrozenContent;
    if (this.IsEmpty) {
      var columnHeaderDiv = this.__getColumnHeader();
      var frozenTable = AdfDhtmlTableBasePeer.__getChildBySubId(columnHeaderDiv, "t");
      var nonFrozenColumnHeaderDiv = AdfDhtmlTableBasePeer.__getChildBySubId(columnHeaderDiv, "d2");
      var nonFrozenColumnHeaderTable = AdfDhtmlTableBasePeer.__getChildBySubId(nonFrozenColumnHeaderDiv, "t2");
      maxWidth = columnHeaderDiv.parentNode.offsetWidth;
      delta = maxWidth - frozenTable.offsetWidth - nonFrozenColumnHeaderTable.offsetWidth - 2;
    } else {
      innerNonFrozenContent = this._getNestedScrolledTable(firstRow);
      if (this._freezeColumnsToEnd()) {
        var columnHeaderDiv = this.__getColumnHeader();
        var frozenTable = AdfDhtmlTableBasePeer.__getChildBySubId(columnHeaderDiv, "t");
        var nonFrozenColumnHeaderDiv = AdfDhtmlTableBasePeer.__getChildBySubId(columnHeaderDiv, "d2");
        var nonFrozenColumnHeaderTable = AdfDhtmlTableBasePeer.__getChildBySubId(nonFrozenColumnHeaderDiv, "t2");
        maxWidth = columnHeaderDiv.parentNode.offsetWidth;
        var scrollbarWidth = this._getScrollbarWidth();
        delta = maxWidth - frozenTable.offsetWidth - nonFrozenColumnHeaderTable.offsetWidth - scrollbarWidth - 2;
      } else {
        maxWidth = innerNonFrozenContent.parentNode.offsetWidth;
        delta = maxWidth - innerNonFrozenContent.offsetWidth;
      }
    }
  }
  if (delta != 0 || !this._virtInitializedComplete) {
    var flexDataItems = [];
    var currentFlexibleConsumption = 0;
    for (var c = 0;c < columnCount;c++) {
      flex = flexValues[c];
      if (flex != null) {
        var consumedWidth = this._getColumnActualWidth(c, firstRow);
        currentFlexibleConsumption += consumedWidth;
        flexDataItems.push({"displayIndex":c, "flex":flex, "minimumWidth":minimumWidths[c], "width":consumedWidth});
      }
    }
    var spaceForFlexibleColumns = currentFlexibleConsumption + delta;
    var flexibleCount = flexDataItems.length;
    var d;
    var flexDataItem;
    var calculatedWidth;
    var allSpaceConsumed = false;
    var atMinimumCount = 0;
    while (!allSpaceConsumed && atMinimumCount < flexibleCount) {
      var currentSpaceAllocation = spaceForFlexibleColumns;
      var flexTotal = 0;
      for (d = 0;d < flexibleCount;d++) {
        flexDataItem = flexDataItems[d];
        if (flexDataItem["atMinimum"]) {
          calculatedWidth = flexDataItem["minimumWidth"];
          currentSpaceAllocation -= calculatedWidth;
        } else {
          flexTotal += flexDataItem["flex"];
        }
      }
      var spaceToRation = currentSpaceAllocation;
      var roundOff = 0;
      for (d = 0;d < flexibleCount;d++) {
        flexDataItem = flexDataItems[d];
        if (!flexDataItem["atMinimum"]) {
          var preciseWidth = flexDataItem["flex"] / flexTotal * spaceToRation;
          calculatedWidth = Math.floor(preciseWidth);
          minimumWidth = flexDataItem["minimumWidth"];
          if (calculatedWidth < minimumWidth) {
            calculatedWidth = minimumWidth;
            flexDataItem["atMinimum"] = true;
            atMinimumCount++;
          } else {
            roundOff += preciseWidth - calculatedWidth;
          }
          flexDataItem["calculatedWidth"] = calculatedWidth;
          currentSpaceAllocation -= calculatedWidth;
        }
      }
      roundOff = Math.round(roundOff);
      if (currentSpaceAllocation == roundOff) {
        if (roundOff > 0) {
          flexDataItem["calculatedWidth"] += roundOff;
        }
        allSpaceConsumed = true;
      }
    }
    var stretchDetails = [];
    for (d = 0;d < flexibleCount;d++) {
      flexDataItem = flexDataItems[d];
      var displayIndex = flexDataItem["displayIndex"];
      calculatedWidth = flexDataItem["calculatedWidth"];
      stretchDetails.push({"displayIndex":displayIndex, "width":calculatedWidth});
      var columnDelta = calculatedWidth - flexDataItem["width"];
      if (columnDelta != 0 || !this._virtInitializedComplete) {
        stretched = true;
        this._doResizeColumn(displayIndex, null, calculatedWidth, columnDelta, false);
      }
    }
    if (!this.IsEmpty && (agent.getPlatform() == AdfAgent.GECKO_PLATFORM || agent.getPlatform() == AdfAgent.WEBKIT_PLATFORM)) {
      this.alignColGroupWidths();
    }
    this._currentColumnStretchDetails = stretchDetails;
  }
  if (stretched) {
    if (!iterationCount) {
      iterationCount = 0;
    }
    if (iterationCount < 5) {
      this._doColumnStretching(columnStretching, ++iterationCount);
    }
  }
};
AdfDhtmlTableBasePeer.prototype.alignColGroupWidths = function() {
  if (!this._headerless) {
    var colHeader = this.__getColumnHeader();
    var colHeaderTable = AdfDhtmlTableBasePeer.FindFirstChildByTagName(colHeader, "TABLE");
    if (colHeaderTable) {
      var colHeaderColGroup = AdfDhtmlTableBasePeer.FindFirstChildByTagName(colHeaderTable, "COLGROUP");
      if (colHeaderColGroup) {
        var colHeaderColGroupChildNodes = colHeaderColGroup.children
      }
    }
  }
  var dataBody = this.GetDataBody();
  var nodes = dataBody.childNodes;
  for (var i = 0;i < nodes.length;i++) {
    var dataBodyTable = nodes[i];
    if (dataBodyTable && colHeaderTable) {
      var dataBodyTableColGroup = AdfDhtmlTableBasePeer.FindFirstChildByTagName(dataBodyTable, "COLGROUP");
      if (dataBodyTableColGroup && colHeaderColGroup) {
        var dataBodyColGroupChildNodes = dataBodyTableColGroup.children;
        if (dataBodyColGroupChildNodes.length == colHeaderColGroupChildNodes.length) {
          for (var c = 0;c < dataBodyColGroupChildNodes.length;c++) {
            var dataBodyTableColGroupWidth = parseInt(dataBodyColGroupChildNodes[c].style.width);
            var colHeaderColGroupWitdh = parseInt(colHeaderColGroupChildNodes[c].style.width);
            if (dataBodyTableColGroupWidth > colHeaderColGroupWitdh) {
              colHeaderColGroupChildNodes[c].style.width = dataBodyTableColGroupWidth + "px";
            }
            if (colHeaderColGroupWitdh > dataBodyTableColGroupWidth) {
              dataBodyColGroupChildNodes[c].style.width = colHeaderColGroupWitdh + "px";
            }
          }
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._stretchLastBlockColumn = function(block) {
  var td;
  var width;
  if (this._lastColWidthOverride != -1) {
    var last = this._colCount - 1;
    AdfAssert.assert(block.rows != null, "Unable to stretch the columns in the last fetched block because it contains no rows!");
    td = this.FindCellByIndex(block.rows[0], last);
    width = parseInt(td.style.width);
    this._resizeBlockColumn(block, last, this._lastColWidthOverride - width);
  } else {
    if (this._currentColumnStretchDetails != null) {
      AdfAssert.assert(block.rows != null, "Unable to stretch the columns in the last fetched block because it contains no rows!");
      var stretchDetails = this._currentColumnStretchDetails;
      var colCount = stretchDetails.length;
      for (var c = 0;c < colCount;c++) {
        var colDetails = stretchDetails[c];
        var displayIndex = colDetails["displayIndex"];
        td = this.FindCellByIndex(block.rows[0], displayIndex);
        width = parseInt(td.style.width);
        this._resizeBlockColumn(block, displayIndex, colDetails["width"] - width);
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._collectClientTokens = function(cacheType) {
  var tokens = "";
  var blockList = this.GetDataBody().childNodes;
  var listSep = "_";
  var levelSep = ",";
  for (var i = 0;i < blockList.length;i++) {
    var rows = blockList[i].rows;
    for (var r = 0;r < rows.length;r++) {
      var token = rows[r].getAttribute(AdfDhtmlTableBasePeer._ROW_KEY);
      if (cacheType == "flat") {
        tokens += token;
        tokens += listSep;
      } else {
        var keys = token.split(levelSep);
        var levels = keys.length;
        tokens += keys[levels - 1];
        tokens += listSep;
        for (var l = 0;l < levels - 1;l++) {
          var parent = keys[l];
          var exp = new RegExp("(^|_)" + parent + "(_|$)");
          if (!tokens.match(exp)) {
            tokens += parent;
            tokens += listSep;
          }
        }
      }
    }
  }
  return tokens;
};
AdfDhtmlTableBasePeer.prototype._grabFocus = function() {
  if (!this.isInActiveHeirarchy()) {
    AdfFocusUtils.focusElement(this.getDomElement());
  } else {
    var activeDom = AdfPage.PAGE.getActiveDomElement();
    if (activeDom && this.getDomElement() != activeDom && activeDom.blur) {
      activeDom.blur();
      AdfFocusUtils.focusElement(this.getDomElement());
    }
  }
};
AdfDhtmlTableBasePeer.prototype.HandleComponentFocus = function(componentEvent) {
  if (!this._virtInitialized) {
    return;
  }
  if (componentEvent.getNativeEventTarget != undefined) {
    var target = componentEvent.getNativeEventTarget();
    if (target && (this._getNavigationBar() && this._getNavigationBar().contains(target) || this.__getElemBySubId("hscroller") && this.__getElemBySubId("hscroller").contains(target))) {
      this._avoidSettingFocusOnColumnHeader = true;
    } else {
      this._avoidSettingFocusOnColumnHeader = false;
    }
    if (target != this.getDomElement() && this._isTargetCellEditable(target)) {
      var clientId = this.getComponent().getClientId();
      var source = componentEvent.getSource();
      if (source && source.getClientId() != clientId && source.getParent() && source.getParent().getClientId() != clientId) {
        return;
      }
      this._unclipInputElem(target);
      if (undefined != target.value && (target.nodeName == "TEXTAREA" || target.type == "text" || target.type == "select-one")) {
        target._afrOldValue = target.value;
      }
      if (target.nodeName == "INPUT" && target.type == "text") {
        AdfPage.PAGE.scheduleTimer(this, this._selectInputOnMouseUp, target, 0);
      }
    }
  }
  if (this._blurTimeout != null) {
    clearTimeout(this._blurTimeout);
    delete this._blurTimeout;
  }
  if (componentEvent.getEventPhase() != AdfBaseEvent.BUBBLING_PHASE && this._focusTimeout == null) {
    if (this._focusTimeoutCallback == null) {
      this._focusTimeoutCallback = this.createCallback(this._doFocusTimeout);
    }
    this._focusTimeout = setTimeout(this._focusTimeoutCallback, 10);
  }
};
AdfDhtmlTableBasePeer.prototype.HandleComponentBlur = function(componentEvent) {
  if (this._blurTimeoutCallback == null) {
    this._blurTimeoutCallback = this.createCallback(this._doBlurTimeout);
  }
  this._blurTimeout = setTimeout(this._blurTimeoutCallback, 10);
};
AdfDhtmlTableBasePeer.prototype.HandleHeaderlessFocus = function() {
  var rowKey = null;
  var row = null;
  var activeCell = null;
  rowKey = this.GetLastRowKey();
  if (rowKey) {
    var rowInfo = this.FindRowByKey(rowKey);
    if (rowInfo) {
      row = rowInfo.tr;
    } else {
      rowKey = null;
    }
  }
  if (rowKey == null) {
    var attrs = this.GetFirstVisibleRowKeyAndRow();
    if (attrs) {
      rowKey = attrs.rowKey;
      row = attrs.row;
      if (this._isRowSelectionEnabled()) {
        if (rowKey != null) {
          this._selSelectRow(rowKey, row);
          this._unclipRow(row);
        }
      }
    }
  }
  if (row) {
    activeCell = this.FindCellByIndex(row, 0);
  }
  this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row, activeCell);
};
AdfDhtmlTableBasePeer.prototype._doFocusTimeout = function() {
  if (this.getComponent()) {
    if (!this._rowContextMenuVisible) {
      this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UPDATE, false, null);
      var fm = this._focusManager;
      if (fm.domElement) {
        this._updateFocusCellStyle(true);
      } else {
        if (fm.objectType != AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE && fm.objectType != AdfDhtmlTableBasePeer._FILTER_CELL_FOCUS_TYPE) {
          if (!this._avoidSettingFocusOnColumnHeader && !this._setFirstColumnHeaderFocus(false, true, true)) {
            this.HandleHeaderlessFocus();
          }
          this._avoidSettingFocusOnColumnHeader = false;
        }
      }
    }
  }
  delete this._focusTimeout;
};
AdfDhtmlTableBasePeer.prototype._doBlurTimeout = function() {
  if (this.getComponent()) {
    if (!this._rowContextMenuVisible) {
      this._selUpdateAll(AdfDhtmlTableBasePeer._SEL_UPDATE_ALL_UPDATE, false, null);
      if (!this.isInActiveHeirarchy()) {
        if (this._focusManager.domElement) {
          this._updateFocusCellStyle(false);
        }
      }
    }
  }
  delete this._blurTimeout;
};
AdfDhtmlTableBasePeer.prototype._handleKeyboardSort = function(sortType) {
  var fm = this._focusManager;
  var objType = fm.objectType;
  if (objType == AdfDhtmlTableBasePeer._COLUMN_HEADER_FOCUS_TYPE) {
    var th = fm.domElement;
    var id = th.id;
    var siElem = AdfAgent.AGENT.getElementById(AdfRichUIPeer.CreateSubId(id, AdfDhtmlTableBasePeer.__SORT_INDICATOR));
    if (siElem) {
      var sortedType = siElem.getAttribute(AdfDhtmlTableBasePeer._SORTED_TYPE);
      var col = AdfPage.PAGE.findComponent(id);
      var sortProperty = col.getSortProperty();
      var sortOrder = AdfDhtmlTableBasePeer.__getSortOrderForColumn(id);
      if (sortedType == sortType) {
        return;
      }
      if (sortType == AdfDhtmlTableBasePeer._SORTED_DESCENDING) {
        sortOrder = false;
      } else {
        sortOrder = true;
      }
      this.getComponent().setProperty("currentlySelectedHeaderId", th.id);
      AdfTableUtils.queueSortEvent(this.getComponent(), sortProperty, sortOrder);
    }
  }
};
AdfDhtmlTableBasePeer.prototype.HandleComponentKeyUp = function(componentEvent) {
  if (componentEvent.isCanceled()) {
    return;
  }
  var agent = AdfAgent.AGENT;
  agent.enableUserSelect(agent.getDomDocument().body);
};
AdfDhtmlTableBasePeer.prototype._disableTabStop = function(disable) {
  AdfDomUtils.disableTabStop(this.GetDataBody(), disable);
  var header = this.__getColumnHeader();
  if (header) {
    AdfDomUtils.disableTabStop(header, disable);
  }
};
AdfDhtmlTableBasePeer.prototype._enterReadOnlyMode = function(componentEvent, undoChange) {
  var domEvent = componentEvent.getNativeEvent();
  var agent = AdfAgent.AGENT;
  var eventTarget = agent.getEventTarget(domEvent);
  var propagate = false;
  var isDialog = AdfDhtmlDialogManager.getInstance();
  if (this._reorderTH || this._resizedTH) {
    propagate = true;
  } else {
    if (!this._rowContextMenuVisible) {
      if (this._isTargetCellEditable(eventTarget)) {
        if (undefined != eventTarget._afrOldValue && eventTarget.value != eventTarget._afrOldValue && undoChange) {
          eventTarget.value = eventTarget._afrOldValue;
        }
      }
      var focusedRowKey = this.GetFocusedRowKey();
      if (focusedRowKey && focusedRowKey == this._getActiveRowKey() && this._isClickToEdit()) {
        var attrs = this.GetRowKeyAndRow(eventTarget, this.getDomElement());
        if (attrs != null) {
          var rowKey = attrs[0];
          if (rowKey != null) {
            var params = this._getCellAndIndexForNode(eventTarget, attrs[1]);
            this._lastCTEIndex = params.cellIndex;
            if (params.cell) {
              this._setActiveDescendant(params.cell, false);
            }
          }
        }
        this._setActiveRowKey(null);
        this._disableTabStop(true);
        this._editableTableReadOnlyMode = true;
        this._grabFocus();
        agent.eatEvent(domEvent);
      } else {
        if (!this._isClickToEdit()) {
          this._setReadOnlyMode(true, eventTarget, true);
          agent.eatEvent(domEvent);
        } else {
          if (!this._isTargetCellEditable(eventTarget)) {
            this._selUnselectAll();
            this._queueColumnSelectionEvent();
          }
        }
      }
    }
  }
  return propagate;
};
AdfDhtmlTableBasePeer.prototype.HandleComponentKeyDown = function(componentEvent) {
  if (componentEvent.isCanceled() || !this.__isOwnComponentEvent(componentEvent)) {
    return;
  }
  var domEvent = componentEvent.getNativeEvent();
  var agent = AdfAgent.AGENT;
  var eventTarget = agent.getEventTarget(domEvent);
  var keyCode = domEvent.keyCode;
  var propagate = false;
  var virtInitialized = this._virtInitialized;
  switch(keyCode) {
    default:
      propagate = true;
      break;
    case AdfKeyStroke.ESC_KEY:
      var isDialog = AdfDhtmlDialogManager.getInstance().getActiveDialog();
      var isAncestorOfDailog = isDialog ? AdfDhtmlPopupWindow.isAncestorOrSelf(isDialog._rootElement, componentEvent.GetSourceDomElement()) : false;
      if (isAncestorOfDailog && !this._isTargetCellEditable(eventTarget)) {
        propagate = true;
      } else {
        propagate = this._enterReadOnlyMode(componentEvent, true);
      }
      break;
    case AdfKeyStroke.M_KEY:
      if (domEvent.ctrlKey && domEvent.altKey && virtInitialized) {
        this._handleKeyboardContextMenu(domEvent, true);
      } else {
        propagate = true;
      }
      break;
    case AdfKeyStroke.A_KEY:
      if (domEvent.ctrlKey && !domEvent.altKey && virtInitialized) {
        this._grabFocus();
        var isMultiSelect = this._isMultipleRowSelect();
        var isNoSelectAll = this._isMultipleRowSelectNoSelectAll();
        if (isMultiSelect && !isNoSelectAll && !this.getComponent().getSelectedRowKeys()[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY]) {
          this._selSelectAll();
        }
      } else {
        propagate = true;
      }
      break;
    case AdfKeyStroke.END_KEY:
      if (!(propagate = this._isTargetCellEditable(eventTarget)) && domEvent.ctrlKey && domEvent.shiftKey && virtInitialized) {
        this._handleCtrlShiftEnd(domEvent);
      }
      break;
    case AdfKeyStroke.PAGEUP_KEY:
      if (!(propagate = this._isTargetCellEditable(eventTarget))) {
        this._handlePageUp(domEvent.altKey, domEvent.ctrlKey, domEvent.shiftKey);
      }
      break;
    case AdfKeyStroke.PAGEDOWN_KEY:
      if (!(propagate = this._isTargetCellEditable(eventTarget))) {
        this._handlePageDown(domEvent.altKey, domEvent.ctrlKey, domEvent.shiftKey);
      }
      break;
    case AdfKeyStroke.SPACE_KEY:
    ;
    case 192:
      var macCtrlSpace = agent.getOS() == AdfAgent.MAC_OS && keyCode == 192 && domEvent.ctrlKey;
      if (!(propagate = this._isTargetCellEditable(eventTarget))) {
        if (macCtrlSpace || keyCode == AdfKeyStroke.SPACE_KEY) {
          this._handleSpaceKey(keyCode, domEvent);
        }
      }
      break;
    case AdfKeyStroke.ENTER_KEY:
      if (!(propagate = eventTarget.tagName == "TEXTAREA" || eventTarget.tagName == "A")) {
        propagate = this._handleEnterKey(eventTarget, domEvent);
      }
      break;
    case AdfKeyStroke.HOME_KEY:
      if (!(propagate = this._isTargetCellEditable(eventTarget)) && domEvent.ctrlKey && virtInitialized) {
        this._scrollerScrollToPos(null, 0);
      }
      break;
    case AdfKeyStroke.F2_KEY:
      if (this._editableTableReadOnlyMode) {
        this._exitReadOnlyMode(domEvent);
      } else {
        this._enterReadOnlyMode(componentEvent, false);
      }
      break;
    case AdfKeyStroke.TAB_KEY:
      if (this._isTargetCellEditable(eventTarget)) {
        propagate = this._handleTabKey(eventTarget, domEvent);
      } else {
        if (AdfPage.PAGE.getActiveDomElement() == this.getDomElement() && !domEvent.shiftKey) {
          var activeKey = this._getActiveRowKey();
          var focusKey = this.GetFocusedRowKey();
          if (activeKey != null) {
            if (activeKey == 0 && focusKey == null && this._isClickToEdit()) {
              propagate = true;
            } else {
              var rowInfo = this.FindRowByKey(activeKey);
              if (rowInfo != null) {
                if (this._setFocusOnEditableElementInNode(agent, rowInfo.tr) == null) {
                  propagate = true;
                } else {
                  if (focusKey == null) {
                    this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, activeKey, rowInfo.tr);
                  }
                }
              }
            }
          } else {
            propagate = true;
          }
        } else {
          propagate = true;
        }
      }
      break;
  }
  if (!propagate) {
    componentEvent.stopBubbling();
    agent.eatEvent(domEvent);
  }
};
AdfDhtmlTableBasePeer.prototype._handleKeyboardContextMenu = function(domEvent, alwaysShow) {
  var agent = AdfAgent.AGENT;
  var fm = this._focusManager;
  var objType = fm.objectType;
  if (objType == AdfDhtmlTableBasePeer._COLUMN_HEADER_FOCUS_TYPE) {
    this._handleColumnContextMenu(domEvent, fm.domElement);
  } else {
    var target = agent.getEventTarget(domEvent);
    if (alwaysShow || !this._isTargetCellEditable(target)) {
      var alignElement = this.ResolveContextMenuAlignElement(fm.domElement);
      var alignHint = this.GetKeyboardContextMenuAlignHint();
      this.HandleRowContextMenu(domEvent, fm.currency, fm.domElement, alignElement, alignHint);
    }
  }
};
AdfDhtmlTableBasePeer.prototype.GetKeyboardContextMenuAlignHint = function() {
  return null;
};
AdfDhtmlTableBasePeer.prototype.ResolveContextMenuAlignElement = function(row) {
  return row;
};
AdfDhtmlTableBasePeer.prototype._handleCtrlShiftEnd = function(domEvent) {
  var fm = this._focusManager, objType = fm.objectType, rowKey = fm.currency;
  if (objType == AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE || objType == AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE) {
    var dataBody = this.GetDataBody();
    if (dataBody && dataBody.childNodes.length > 0) {
      var row = dataBody.childNodes[0].rows[0];
      var firstRowKey = row.getAttribute(AdfDhtmlTableBasePeer._ROW_KEY);
      if (firstRowKey == rowKey) {
        this._grabFocus();
        if (!this.getComponent().getSelectedRowKeys()[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY]) {
          this._selSelectAll();
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._exitReadOnlyMode = function(domEvent) {
  var agent = AdfAgent.AGENT;
  var eventTarget = agent.getEventTarget(domEvent);
  if (this._isClickToEdit()) {
    var focusedRowKey = this.GetFocusedRowKey();
    var activeRowKey = this._getActiveRowKey();
    if (!activeRowKey || focusedRowKey && (activeRowKey != focusedRowKey || this.getComponent().getProperty(AdfDhtmlTableBasePeer._REMAIN_READ_ONLY))) {
      var rowKey = focusedRowKey ? focusedRowKey : this._getFirstRowKey();
      if (rowKey) {
        this._setActiveRowKey(rowKey);
        if (this._editableTableReadOnlyMode) {
          var cellIndex = this._lastCTEIndex;
          this._setReadOnlyMode(false, eventTarget, false);
          if (cellIndex != undefined) {
            this._clickEditRequest = {cellIndex:cellIndex};
          }
        }
      }
      return;
    }
  } else {
    if (!this._isClickToEdit() && this._editableTableReadOnlyMode) {
      this._setReadOnlyMode(false, eventTarget, true);
    }
  }
  if (this._isTargetCellEditable(eventTarget)) {
    var attrs = this.GetRowKeyAndRow(eventTarget, this.getDomElement());
    if (attrs != null) {
      var row = attrs[1];
      var params = this._getCellAndIndexForNode(eventTarget, row);
      var cell = params.cell;
      this._setInputElementCursorAtEndInNode(agent, cell);
    }
  }
};
AdfDhtmlTableBasePeer._restoreSelectedItemOnArrowNav = function(params) {
  var index = params.index;
  var elem = params.elem;
  elem.selectedIndex = index;
};
AdfDhtmlTableBasePeer.prototype._handleArrowKeyNavLeftRight = function(keyCode, row, eventTarget, cellIndex) {
  var focusedItem = null;
  var agent = AdfAgent.AGENT;
  if (keyCode == AdfKeyStroke.ARROWRIGHT_KEY) {
    var columns = this.__getVisibleLeafColumns();
    var colCount = columns.length;
    var newIndex = cellIndex + 1;
    while (newIndex < colCount) {
      var cellRight = this.FindCellByIndex(row, newIndex);
      focusedItem = this._setFocusOnEditableElementInNode(agent, cellRight);
      if (focusedItem != null) {
        this._dismissTargetPopupsOnArrowNav(eventTarget);
        break;
      }
      newIndex++;
    }
  } else {
    var newIndex = cellIndex - 1;
    while (newIndex >= 0) {
      var cellLeft = this.FindCellByIndex(row, newIndex);
      focusedItem = this._setFocusOnEditableElementInNode(agent, cellLeft);
      if (focusedItem != null) {
        this._dismissTargetPopupsOnArrowNav(eventTarget);
        break;
      }
      newIndex--;
    }
  }
  if (focusedItem != null && agent.getPlatform() == AdfAgent.GECKO_PLATFORM && focusedItem.nodeName == "SELECT" && focusedItem.type == "select-one") {
    var params = {index:focusedItem.selectedIndex, elem:focusedItem};
    AdfPage.PAGE.scheduleTimer(null, AdfDhtmlTableBasePeer._restoreSelectedItemOnArrowNav, params, 0);
  }
};
AdfDhtmlTableBasePeer.prototype._handleArrowKeyNav = function(keyCode, eventTarget, event) {
  var attrs = this.GetRowKeyAndRow(eventTarget, this.getDomElement());
  if (attrs != null) {
    var rowKey = attrs[0];
    if (rowKey != null) {
      var row = attrs[1];
      var params = this._getCellAndIndexForNode(eventTarget, row);
      var cell = params.cell;
      var cellIndex = params.cellIndex;
      this._ctePatternStart = undefined;
      if (keyCode == AdfKeyStroke.ARROWUP_KEY || keyCode == AdfKeyStroke.ARROWDOWN_KEY) {
        if (this._isClickToEdit()) {
          this._clickToEditActivateRow(rowKey, keyCode == AdfKeyStroke.ARROWDOWN_KEY, cellIndex);
        } else {
          this._setFocusOnEditableRowCell(rowKey, keyCode == AdfKeyStroke.ARROWDOWN_KEY, cellIndex);
        }
      } else {
        this._handleArrowKeyNavLeftRight(keyCode, row, eventTarget, cellIndex);
      }
    }
    return false;
  } else {
    return true;
  }
};
AdfDhtmlTableBasePeer.prototype._dismissTargetPopupsOnArrowNav = function(domElement) {
  var dismissComponent = AdfRichUIPeer.getFirstAncestorComponent(domElement);
  if (dismissComponent != this.getComponent()) {
    dismissComponent.getPeer().cancelAllPopups(dismissComponent);
  }
};
AdfDhtmlTableBasePeer.prototype._handleArrow = function(keyCode, event) {
  switch(this._focusManager.objectType) {
    default:
      break;
    case AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE:
      this._handleRowHeaderArrow(keyCode, event);
      break;
    case AdfDhtmlTableBasePeer._FILTER_CELL_FOCUS_TYPE:
      this._handleFilterCellArrow(keyCode, event);
      break;
    case AdfDhtmlTableBasePeer._COLUMN_HEADER_FOCUS_TYPE:
      this._handleColumnHeaderArrow(keyCode, event);
      break;
    case AdfDhtmlTableBasePeer._COLUMN_FOOTER_FOCUS_TYPE:
      this._handleColumnFooterArrow(keyCode, event);
      break;
    case AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE:
      if (keyCode == AdfKeyStroke.ARROWUP_KEY || keyCode == AdfKeyStroke.ARROWDOWN_KEY) {
        this._handleTableBodyArrowUpDown(keyCode == AdfKeyStroke.ARROWUP_KEY, event.ctrlKey, event.shiftKey);
      } else {
        if (keyCode == AdfKeyStroke.ARROWLEFT_KEY || keyCode == AdfKeyStroke.ARROWRIGHT_KEY) {
          this.HandleTableBodyArrowLeftRight(keyCode == AdfKeyStroke.ARROWLEFT_KEY, event.ctrlKey, event.shiftKey);
        }
      }
      break;
    case AdfDhtmlTableBasePeer._SELECT_ALL_FOCUS_TYPE:
      this._handleSelectAllArrow(keyCode, event);
      break;
  }
};
AdfDhtmlTableBasePeer.prototype._handleRowHeaderArrow = function(keyCode, event) {
  if (keyCode == AdfKeyStroke.ARROWDOWN_KEY || keyCode == AdfKeyStroke.ARROWUP_KEY) {
    var agent = AdfAgent.AGENT;
    var isKeyUp = keyCode == AdfKeyStroke.ARROWUP_KEY;
    var fm = this._focusManager, rowKey = fm.currency;
    delete this._lastRowKeyInView;
    var attrs = isKeyUp ? this._getPreviousRowKeyAndRow(rowKey) : this._getNextRowKeyAndRow(rowKey);
    if (attrs.isAtTop) {
      this._setFirstColumnHeaderFocus(false);
      return;
    } else {
      if (attrs.isAtButtom) {
        var activeIndex = this._getActiveCellIndex();
        this._setIndexedColumnFooterFocus(false, false, activeIndex == -1 ? 0 : activeIndex);
        return;
      }
    }
    var lastRowKeyInView = attrs.lastRowKeyInView;
    rowKey = attrs.rowKey;
    if (rowKey != null) {
      var row = attrs.row;
      var rowHeaderCell = this.GetRowHeaderCellFromRow(row);
      this.UpdateFocusManager(AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE, rowKey, rowHeaderCell);
      this._unclipRow(row);
    } else {
      if (lastRowKeyInView != null) {
        var scroller = this.GetScroller();
        var scrollToPos = this._currentScrollTop + (isKeyUp ? -this._averageRowHeight : this._averageRowHeight);
        if (scrollToPos > 0 && scrollToPos < this._getScrollHeight()) {
          this._lastRowKeyInView = lastRowKeyInView;
          this._selectionRequest = isKeyUp ? AdfDhtmlTableBasePeer._FOCUS_RH_ARROW_UP : AdfDhtmlTableBasePeer._FOCUS_RH_ARROW_DOWN;
          this._scrollerScrollToPos(null, scrollToPos);
        }
      } else {
        attrs = isKeyUp ? this._getLastVisibleRowKeyAndRow() : this.GetFirstVisibleRowKeyAndRow();
        if (attrs.rowKey != null) {
          var rowHeaderCell = this.GetRowHeaderCellFromRow(attrs.row);
          this.UpdateFocusManager(AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE, attrs.rowKey, rowHeaderCell);
          this._unclipRow(attrs.row);
        }
      }
    }
  } else {
    if (keyCode == AdfKeyStroke.ARROWRIGHT_KEY) {
      if (this._focusManager.currency != null) {
        var fm = this._focusManager, rowKey = fm.currency, row = fm.domElement.parentNode;
        if (this._isRowSelectionEnabled()) {
          this._selUnselectAll();
          this._selSelectRow(rowKey, row);
        }
        var nextCell = this._findNextCell(this._getActiveCellNode(), false);
        this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row, nextCell);
      }
    } else {
      if (keyCode == AdfKeyStroke.ARROWLEFT_KEY) {
        if (this._focusManager.currency != null) {
          this._changeActiveCell(true);
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._handleFilterCellArrow = function(keyCode, event) {
  switch(keyCode) {
    default:
      break;
    case AdfKeyStroke.ARROWRIGHT_KEY:
      var focusElem = this._getNextColumnHeaderFocusElement(this._focusManager.domElement);
      if (focusElem) {
        this._unclipColumnElement(focusElem);
        this._setHeaderCellFocus(focusElem);
      }
      break;
    case AdfKeyStroke.ARROWLEFT_KEY:
      var focusElem = this._getPrevColumnHeaderFocusElement(this._focusManager.domElement);
      if (focusElem) {
        this._unclipColumnElement(focusElem);
        this._setHeaderCellFocus(focusElem);
      }
      break;
    case AdfKeyStroke.ARROWDOWN_KEY:
      var domElement = this._focusManager.domElement;
      if (domElement) {
        var index = this._getCellIndex(domElement);
        if (index >= 0) {
          this._setIndexedColumnHeaderFocus(false, false, index);
        }
      }
      break;
  }
};
AdfDhtmlTableBasePeer.prototype._handleColumnHeaderArrow = function(keyCode, event) {
  var isCtrl = event.ctrlKey;
  var isShift = event.shiftKey;
  var virtInitialized = this._virtInitialized;
  switch(keyCode) {
    default:
      break;
    case AdfKeyStroke.ARROWRIGHT_KEY:
      var focusElem = this._getNextColumnHeaderFocusElement(this._focusManager.domElement);
      if (focusElem) {
        this._unclipColumnElement(focusElem);
        if (!this.getComponent().getDisableColumnReordering() && isCtrl && isShift) {
          this._reorderColumnThroughKeyboard(false);
        } else {
          this._setHeaderCellFocus(focusElem);
          if (isShift && this._isMultipleColumnSelect()) {
            this._shiftSelectColumnsThroughKeyboard(focusElem);
          }
        }
      }
      break;
    case AdfKeyStroke.ARROWLEFT_KEY:
      var focusElem = this._getPrevColumnHeaderFocusElement(this._focusManager.domElement);
      if (focusElem) {
        this._unclipColumnElement(focusElem);
        if (!this.getComponent().getDisableColumnReordering() && isCtrl && isShift) {
          this._reorderColumnThroughKeyboard(true);
        } else {
          var focusType = this._setHeaderCellFocus(focusElem);
          if (focusType != AdfDhtmlTableBasePeer._SELECT_ALL_FOCUS_TYPE) {
            if (isShift && this._isMultipleColumnSelect()) {
              this._shiftSelectColumnsThroughKeyboard(focusElem);
            }
          }
        }
      }
      break;
    case AdfKeyStroke.ARROWUP_KEY:
    ;
    case AdfKeyStroke.ARROWDOWN_KEY:
      var domElement = this._focusManager.domElement;
      if (domElement) {
        if (isCtrl && isShift) {
          if (virtInitialized) {
            this._handleKeyboardSort(AdfKeyStroke.ARROWUP_KEY == keyCode ? AdfDhtmlTableBasePeer._SORTED_ASCENDING : AdfDhtmlTableBasePeer._SORTED_DESCENDING);
          }
        } else {
          if (domElement.colSpan > 1) {
            var focusElem = AdfKeyStroke.ARROWUP_KEY == keyCode ? this._resolveImmediateParentColumn(domElement) : this._resolveImmediateChildColumn(domElement);
            if (focusElem) {
              this._unclipColumnElement(focusElem);
              this._setHeaderCellFocus(focusElem);
            }
          } else {
            if (AdfKeyStroke.ARROWDOWN_KEY == keyCode) {
              attrs = this.GetFirstVisibleRowKeyAndRow();
              rowKey = attrs.rowKey;
              var row = attrs.row;
              var isMultiSelect = this._isMultipleRowSelect();
              if (this._isRowSelectionEnabled()) {
                if (rowKey != null) {
                  if (!isMultiSelect) {
                    this._selUnselectAll();
                  }
                  this._selSelectRow(rowKey, row);
                  this._unclipRow(row);
                }
              }
              this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row);
            } else {
              this._setIndexedFilterCellFocus(this._getCellIndex(domElement));
            }
          }
        }
      }
      break;
  }
};
AdfDhtmlTableBasePeer.prototype._shiftSelectColumnsThroughKeyboard = function(th) {
  if (this._anchorColumnHeader) {
    var activeColIndices = [], activeColIds = [], colIndices = [], colIds = [];
    this._resolveColumns(activeColIndices, activeColIds, this._anchorColumnHeader);
    this._resolveColumns(colIndices, colIds, th);
    this._selUnselectAll();
    this._selectColumnRange(activeColIndices, activeColIds, colIndices, colIds);
  }
};
AdfDhtmlTableBasePeer.prototype._reorderColumnThroughKeyboard = function(isLeftArrow) {
  var currentCol = this._focusManager.domElement;
  if (currentCol && currentCol.getAttribute(AdfDhtmlTableBasePeer._ROOT_COLUMN) != null) {
    var targetReorderTH = null;
    if (isLeftArrow) {
      targetReorderTH = this._getSiblingDomNode(currentCol, false);
      if (targetReorderTH == null) {
        var displayIndex = AdfAgent.AGENT.getIntAttribute(currentCol, "_d_index", -1);
        if (this._hasFrozenColumn() && !this._isColumnFrozen(displayIndex)) {
          var table = AdfDhtmlTableBasePeer.__getChildBySubId(this.__getColumnHeader(), "t");
          var hrRowIndex = this._isFilterable() ? 2 : 1;
          if (table && table.rows && table.rows[hrRowIndex].cells.length > 0) {
            var cells = table.rows[hrRowIndex].cells;
            targetReorderTH = cells[cells.length - 1];
          }
        }
      }
      if (targetReorderTH.getAttribute(AdfDhtmlTableBasePeer._ROW_HEADER) != null) {
        targetReorderTH = null;
      }
    } else {
      targetReorderTH = this._getSiblingDomNode(currentCol, true);
      if (targetReorderTH == null) {
        var displayIndex = AdfAgent.AGENT.getIntAttribute(currentCol, "_d_index", -1);
        if (this._isColumnFrozen(displayIndex)) {
          var second = AdfDhtmlTableBasePeer.__getChildBySubId(this.__getColumnHeader(), "d2");
          var table = AdfDhtmlTableBasePeer.__getChildBySubId(second, "t2");
          var hrRowIndex = this._isFilterable() ? 2 : 1;
          if (table && table.rows && table.rows[hrRowIndex].cells.length > 0) {
            targetReorderTH = table.rows[hrRowIndex].cells[0];
          }
        }
      }
    }
    if (targetReorderTH) {
      this._reorderTH = currentCol;
      this._targetReorderTH = targetReorderTH;
      if (isLeftArrow) {
        this._insertColumnAfter = AdfDhtmlTableBasePeer._isRTL() ? true : false;
      } else {
        this._insertColumnAfter = AdfDhtmlTableBasePeer._isRTL() ? false : true;
      }
      this._reorderId = this._reorderTH.id;
      this._reorderColumnComponentsWithoutAnimation();
      this._reorderTH = this._targetReorderTH = null;
      delete this._insertColumnAfter;
    }
  }
};
AdfDhtmlTableBasePeer.prototype._isFilterCell = function(cell) {
  return cell.getAttribute(AdfDhtmlTableBasePeer._FILTER_COLUMN) != null;
};
AdfDhtmlTableBasePeer.prototype._getNextColumnHeaderFocusElement = function(domElement) {
  var agent = AdfAgent.AGENT;
  if (domElement) {
    if (domElement.colSpan > 1) {
      return this._resolveImmediateChildColumn(domElement);
    }
    var nextSibling = this._getSiblingDomNode(domElement, true);
    var parentCol = this._resolveImmediateParentColumn(domElement), siblingParent = parentCol;
    while (!nextSibling && siblingParent) {
      if ((nextSibling = this._getSiblingDomNode(parentCol, true)) != null) {
        siblingParent = this._resolveImmediateParentColumn(nextSibling);
      } else {
        siblingParent = null;
      }
    }
    if (nextSibling) {
      var nextSiblingParent = nextSibling ? this._resolveImmediateParentColumn(nextSibling) : null;
      if (nextSiblingParent != parentCol) {
        var parentCol = this._resolveImmediateParentColumn(nextSibling);
        if (parentCol && !this._isTargetCellFilter(parentCol)) {
          return parentCol;
        }
      }
      return nextSibling;
    }
    var displayIndex = agent.getIntAttribute(domElement, "_d_index", -1);
    if (this._hasFrozenColumn() && this._isColumnFrozen(displayIndex)) {
      var headerDiv = this.__getColumnHeader();
      var second = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "d2");
      var table = AdfDhtmlTableBasePeer.__getChildBySubId(second, "t2");
      var hrRowIndex = this._isFilterCell(domElement) ? 1 : this._isFilterable() ? 2 : 1;
      if (table && table.rows && table.rows[hrRowIndex].cells.length > 0) {
        return table.rows[hrRowIndex].cells[0];
      }
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._getPrevColumnHeaderFocusElement = function(domElement) {
  var agent = AdfAgent.AGENT;
  if (domElement && domElement.getAttribute("_afrFH") == null) {
    var isFilter = this._isFilterCell(domElement);
    var previousSibling = this._getSiblingDomNode(domElement, false);
    var parentCol = this._resolveImmediateParentColumn(domElement);
    var previousSiblingParent = previousSibling ? this._resolveImmediateParentColumn(previousSibling) : null;
    var siblingParent = parentCol;
    while (!previousSibling && siblingParent) {
      if ((previousSibling = this._getSiblingDomNode(parentCol, false)) != null) {
        siblingParent = this._resolveImmediateParentColumn(previousSibling);
      } else {
        siblingParent = null;
      }
    }
    if (parentCol != null && parentCol != previousSiblingParent && !this._isTargetCellFilter(parentCol)) {
      return parentCol;
    } else {
      if (previousSibling != null) {
        return this._resolveBotttomMostChildColumn(previousSibling);
      }
    }
    var displayIndex = agent.getIntAttribute(domElement, "_d_index", -1);
    if (this._hasFrozenColumn() && !this._isColumnFrozen(displayIndex)) {
      var headerDiv = this.__getColumnHeader();
      var table = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "t");
      if (table && table.rows) {
        var hrRowIndex = isFilter ? 1 : this._isFilterable() ? 2 : 1;
        var cells = table.rows[hrRowIndex].cells, cellCount = cells.length;
        if (cellCount > 0) {
          return this._resolveBotttomMostChildColumn(cells[cellCount - 1]);
        }
      }
    } else {
      if (this._hasFrozenColumn()) {
        this._setFirstColumnHeaderFocus(true, false, isFilter);
      }
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._getSiblingDomNode = function(domElement, next) {
  var sibling = next ? domElement.nextSibling : domElement.previousSibling;
  while (sibling && sibling.nodeType != 1) {
    sibling = next ? sibling.nextSibling : sibling.previousSibling;
  }
  return sibling;
};
AdfDhtmlTableBasePeer.prototype._resolveBotttomMostChildColumn = function(th) {
  var child = th;
  if (th.colSpan > 1) {
    var parent = th;
    AdfAssert.assert(parent != null, "Table peer cannot resolve the bottom-most child column if the parent is null!");
    child = this._resolveImmediateChildColumn(th);
    child = this._resolveRightMostSiblingInGroup(parent, child);
    var newChild = child;
    while (newChild != null) {
      parent = newChild;
      if ((newChild = this._resolveImmediateChildColumn(newChild)) != null) {
        newChild = this._resolveRightMostSiblingInGroup(parent, newChild);
        child = newChild;
      }
    }
  }
  return child;
};
AdfDhtmlTableBasePeer.prototype._resolveRightMostSiblingInGroup = function(parent, child) {
  AdfAssert.assert(parent != null, "Table peer cannot resolve the right-most sibling in a group if the parent is null!");
  if (parent.colSpan > 1) {
    var newChild = child, siblingOffset = parent.colSpan;
    while (newChild && siblingOffset > newChild.colSpan) {
      siblingOffset -= newChild.colSpan;
      if ((newChild = this._getSiblingDomNode(newChild, true)) != null) {
        child = newChild;
      }
    }
  }
  return child;
};
AdfDhtmlTableBasePeer.prototype.__getParentColumn = function(column) {
  AdfAssert.assertPrototype(column, AdfRichColumn);
  if (!this._headerless) {
    var parentTH = this._resolveImmediateParentColumn(column.getPeer().getDomElement());
    if (parentTH) {
      return AdfPage.PAGE.findComponent(parentTH.id);
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._resolveImmediateParentColumn = function(th) {
  var trNode = th.parentNode, tableNode = trNode.parentNode.parentNode;
  var prevRowIndex, topTH = null, rows = tableNode.rows, rowCount = rows.length;
  var agent = AdfAgent.AGENT;
  var displayIndex = agent.getIntAttribute(th, "_d_index", -1);
  for (var i = 0;i < rowCount;i++) {
    if (rows[i] == trNode) {
      prevRowIndex = i - 1;
      break;
    }
  }
  if (prevRowIndex >= 0) {
    for (var i = prevRowIndex, found = false;i >= 0 && !found;i--) {
      var row = rows[i];
      var cells = row.cells, cellCount = cells.length;
      for (var j = cellCount - 1;j >= 0;j--) {
        var cell = cells[j];
        var parentIndex = agent.getIntAttribute(cell, "_d_index", -1);
        if (cell.colSpan >= 1 && (parentIndex <= displayIndex && parentIndex + cell.colSpan >= displayIndex)) {
          topTH = cell;
          found = true;
          break;
        }
      }
    }
  }
  return topTH;
};
AdfDhtmlTableBasePeer.prototype._resolveImmediateChildColumn = function(th) {
  var agent = AdfAgent.AGENT;
  var displayIndex = agent.getIntAttribute(th, "_d_index", -1);
  var trNode = th.parentNode, tableNode = trNode.parentNode.parentNode;
  var nextRowIndex, topTH = null, rows = tableNode.rows, rowCount = rows.length;
  for (var i = rowCount - 1;i >= 0;i--) {
    if (rows[i] == trNode) {
      nextRowIndex = i + 1;
      break;
    }
  }
  if (nextRowIndex < rowCount) {
    for (var i = nextRowIndex, found = false;i < rowCount && !found;i++) {
      var row = rows[i];
      var cells = row.cells, cellCount = cells.length;
      for (var j = 0;j < cellCount;j++) {
        var cell = cells[j];
        if (displayIndex == agent.getIntAttribute(cell, "_d_index", -1)) {
          topTH = cell;
          found = true;
          break;
        }
      }
    }
  }
  return topTH;
};
AdfDhtmlTableBasePeer.prototype._unclipColumnElement = function(elem) {
  var agent = AdfAgent.AGENT;
  if (this.IsEmpty) {
    var domElement = this.getDomElement();
    var frozenWidth = 0;
    if (this._hasFrozenColumn()) {
      frozenWidth = AdfDhtmlTableBasePeer.__getChildBySubId(this.__getColumnHeader(), "t").offsetWidth;
    }
    if (elem.offsetLeft + elem.offsetWidth + frozenWidth > domElement.clientWidth + domElement.offsetLeft) {
      agent.setScrollLeft(domElement, elem.offsetWidth + elem.offsetLeft + frozenWidth - domElement.clientWidth);
    }
    if (domElement.offsetLeft > elem.offsetLeft + frozenWidth) {
      agent.setScrollLeft(domElement, elem.offsetLeft + frozenWidth);
    }
  } else {
    var dataBody = this.GetDataBody();
    var rightClipped = elem.offsetLeft + elem.offsetWidth > dataBody.clientWidth + this.__getScrollLeft() - this._frozenWidth;
    if (rightClipped) {
      var scrollPos = elem.offsetWidth + elem.offsetLeft - dataBody.clientWidth + this._frozenWidth;
      this._scrollerScrollToPos(scrollPos, null);
      return;
    }
    var leftClipped = this.__getScrollLeft() > elem.offsetLeft;
    if (leftClipped) {
      this._scrollerScrollToPos(elem.offsetLeft, null);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._handleSelectAllArrow = function(keyCode, event) {
  switch(keyCode) {
    default:
      break;
    case AdfKeyStroke.ARROWUP_KEY:
      if (this._isFilterable()) {
        this._setFirstColumnHeaderFocus(false, true, true);
      }
      break;
    case AdfKeyStroke.ARROWDOWN_KEY:
      var dataBody = this.GetDataBody();
      var dataTables = dataBody.childNodes, tableCount = dataTables.length;
      if (tableCount > 0) {
        var row = dataTables[0].rows[0];
        if (row) {
          var rowKey = row.getAttribute(AdfDhtmlTableBasePeer._ROW_KEY);
          var rowHeaderCell = this.GetRowHeaderCellFromRow(row);
          this.UpdateFocusManager(AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE, rowKey, rowHeaderCell);
          this._unclipRow(row);
        }
      }
      break;
    case AdfKeyStroke.ARROWRIGHT_KEY:
      var headerDiv = this.__getColumnHeader();
      var table = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "t");
      AdfAssert.assertDomNode(table);
      var hrRowIndex = this._isFilterable() ? 2 : 1;
      if (table.rows && table.rows[hrRowIndex].cells.length > 1) {
        this._setHeaderCellFocus(table.rows[hrRowIndex].cells[1]);
      } else {
        var second = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "d2");
        var table = AdfDhtmlTableBasePeer.__getChildBySubId(second, "t2");
        if (table.rows && table.rows[hrRowIndex].cells.length > 1) {
          this._setHeaderCellFocus(table.rows[hrRowIndex].cells[0]);
        }
      }
      break;
  }
};
AdfDhtmlTableBasePeer.prototype._setFirstColumnHeaderFocus = function(selectAllOnly, skipUnclip, includeFilter) {
  if (!this._headerless) {
    var headerDiv = this.__getColumnHeader();
    if (headerDiv == null) {
      return false;
    }
    var table = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "t");
    var hrRowIndex = includeFilter ? 1 : this._isFilterable() ? 2 : 1;
    var cell = table.rows[hrRowIndex].cells[0];
    var isSelectAll = cell.getAttribute(AdfDhtmlTableBasePeer._SELECT_ALL) != null;
    if (isSelectAll || !selectAllOnly) {
      this._setHeaderCellFocus(cell);
      if (!skipUnclip && !isSelectAll) {
        this._unclipColumnElement(cell);
      }
      return true;
    }
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype._setIndexedFilterCellFocus = function(index) {
  if (index >= 0 && this._isFilterable()) {
    var headerDiv = this.__getColumnHeader();
    if (!this._headerless && headerDiv) {
      var table = AdfDhtmlTableBasePeer.__getChildBySubId(headerDiv, "t");
      var cell = table.rows[1].cells[0];
      for (var i = 0;i < index && cell;i++) {
        cell = this._getNextColumnHeaderFocusElement(cell);
      }
      if (cell) {
        this._setHeaderCellFocus(cell);
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._setIndexedColumnHeaderFocus = function(selectAllOnly, skipUnclip, index) {
  if (index == 0) {
    return this._setFirstColumnHeaderFocus(selectAllOnly, skipUnclip);
  }
  if (!this._headerless) {
    var cellId = this._getColumnHeaderId(index);
    if (cellId) {
      var cell;
      if (cell = AdfAgent.AGENT.getElementById(cellId)) {
        this.UpdateFocusManager(AdfDhtmlTableBasePeer._COLUMN_HEADER_FOCUS_TYPE, null, cell);
        if (!skipUnclip) {
          this._unclipColumnElement(cell);
        }
        return true;
      }
    }
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype._handleTableBodyArrowUpDown = function(arrowUp, ctrlKey, shiftKey) {
  var isRowSelectionEnabled = this._isRowSelectionEnabled();
  var supportsFocusRowNavigation = this._supportsFocusRowNavigation;
  var scrollToPos = this._currentScrollTop + (arrowUp ? -this._averageRowHeight : this._averageRowHeight);
  if (!isRowSelectionEnabled && !supportsFocusRowNavigation) {
    if (scrollToPos >= 0 && scrollToPos < this._getScrollHeight()) {
      this._scrollerScrollToPos(null, scrollToPos);
    }
    return;
  }
  var lastRowKey = this.GetLastRowKey();
  delete this._lastRowKeyInView;
  var attrs = arrowUp ? this._getPreviousRowKeyAndRow(lastRowKey) : this._getNextRowKeyAndRow(lastRowKey);
  if (attrs.isAtTop) {
    var activeIndex = this._getActiveCellIndex();
    this._setIndexedColumnHeaderFocus(false, false, activeIndex == -1 ? 0 : activeIndex);
    return;
  } else {
    if (attrs.isAtButtom) {
      var activeIndex = this._getActiveCellIndex();
      this._setIndexedColumnFooterFocus(false, false, activeIndex == -1 ? 0 : activeIndex);
      return;
    }
  }
  var isMultiSelect = this._isMultipleRowSelect();
  var lastRowKeyInView = attrs.lastRowKeyInView;
  var rowKey = attrs.rowKey;
  if (rowKey != null) {
    var row = attrs.row;
    if (isRowSelectionEnabled) {
      if (shiftKey && isMultiSelect) {
        if (this._selIsSelected(rowKey) != null && this._selIsSelected(lastRowKeyInView) != null) {
          var attrs1 = arrowUp ? this._getNextRowKeyAndRow(rowKey) : this._getPreviousRowKeyAndRow(rowKey);
          this._selUnselectRow(lastRowKeyInView, attrs1.row);
        } else {
          if (this._selIsSelected(rowKey)) {
            this._selUnselectRow(rowKey, row);
          } else {
            this._selSelectRow(rowKey, row);
          }
        }
      } else {
        if (!ctrlKey || !isMultiSelect || !supportsFocusRowNavigation) {
          var component = this.getComponent();
          if (component.getSelectionEventDelay() == "enabled") {
            var delay = 300;
            var page = AdfPage.PAGE;
            var rowInfo = this.FindRowByKey(lastRowKey);
            if (rowInfo && rowInfo.tr) {
              this._selUnhighlightRow(rowInfo.tr);
            }
            this._selHighlightRow(row);
            if (this._selectRowTimer) {
              page.cancelTimer(this._selectRowTimer);
              delete this._selectRowTimer;
            }
            this._selectRowTimer = page.scheduleTimer(this, this._selectRowForTimer, [rowKey, row], delay);
          } else {
            this._selUnselectAll();
            this._selSelectRow(rowKey, row);
          }
        }
      }
    }
    this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row);
    this._unclipRow(row);
    delete this._selectionRequest;
  } else {
    if (lastRowKeyInView != null) {
      if (scrollToPos > 0 && scrollToPos < this._getScrollHeight()) {
        this._lastRowKeyInView = lastRowKeyInView;
        if (ctrlKey && isMultiSelect && supportsFocusRowNavigation || !isRowSelectionEnabled && supportsFocusRowNavigation) {
          this._selectionRequest = arrowUp ? AdfDhtmlTableBasePeer._FOCUS_ROW_ARROW_UP : AdfDhtmlTableBasePeer._FOCUS_ROW_ARROW_DOWN;
        } else {
          this._selectionRequest = arrowUp ? AdfDhtmlTableBasePeer._SELECT_ARROW_UP : AdfDhtmlTableBasePeer._SELECT_ARROW_DOWN;
        }
        if (!shiftKey && !ctrlKey || !isMultiSelect) {
          var lastRow = false;
          if (!arrowUp) {
            var rowCount = this.GetRowCount();
            if (rowCount >= 0) {
              var dataBody = this.GetDataBody();
              var blockList = dataBody.childNodes;
              var numBlocks = blockList.length;
              var lastBlock = blockList[numBlocks - 1];
              var currCount = lastBlock.startRow + lastBlock.numRows;
              lastRow = currCount == rowCount;
            }
          }
          if (!lastRow) {
            this._selUnselectAll();
          }
        }
        this._scrollerScrollToPos(null, scrollToPos);
      }
    } else {
      attrs = arrowUp ? this._getLastVisibleRowKeyAndRow() : this.GetFirstVisibleRowKeyAndRow();
      rowKey = attrs.rowKey;
      if (rowKey != null) {
        var row = attrs.row;
        if (isRowSelectionEnabled) {
          this._selSelectRow(rowKey, row);
        }
        this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row);
        this._unclipRow(row);
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._selectRowForTimer = function(params) {
  var rowKey = params[0];
  var row = params[1];
  this._selUnselectAll();
  this._selSelectRow(rowKey, row);
};
AdfDhtmlTableBasePeer.prototype.HandleTableBodyArrowLeftRight = function(arrowLeft, ctrlKey, shiftKey) {
  var scrollToPos = this.__getScrollLeft() + (arrowLeft ? -20 : 20);
  var changeActive = true;
  if (ctrlKey) {
    if (!this._hasDetailStamp) {
      scrollToPos = Math.max(0, scrollToPos);
      if (scrollToPos < this._getScrollWidth()) {
        this._scrollerScrollToPos(scrollToPos, null);
      }
    }
    changeActive = false;
  } else {
    if (arrowLeft) {
      var fm = this._focusManager, rowKey = fm.currency;
      if (rowKey) {
        var rowInfo = this.FindRowByKey(rowKey);
        if (rowInfo) {
          var rowHeaderCell = this.GetRowHeaderCellFromRow(rowInfo.tr);
          if (rowHeaderCell) {
            var leftNode = this._findNextCell(this._getActiveCellNode(), true);
            if (leftNode == null || leftNode == rowHeaderCell) {
              this.UpdateFocusManager(AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE, rowKey, rowHeaderCell);
              changeActive = false;
            }
          }
        }
      }
    }
  }
  if (this._hasDetailStamp && ctrlKey) {
    var activeRowKey = this.GetFocusedRowKey();
    if (activeRowKey != null) {
      var component = this.getComponent();
      component.setDisclosedRowKey(activeRowKey, !arrowLeft);
    }
  }
  if (changeActive) {
    this._changeActiveCell(arrowLeft);
  }
};
AdfDhtmlTableBasePeer.prototype._handleHomeEndKey = function(keyCode, event) {
  if (event.ctrlKey) {
    return;
  }
  switch(this._focusManager.objectType) {
    default:
      break;
    case AdfDhtmlTableBasePeer._FILTER_CELL_FOCUS_TYPE:
    ;
    case AdfDhtmlTableBasePeer._SELECT_ALL_FOCUS_TYPE:
    ;
    case AdfDhtmlTableBasePeer._COLUMN_HEADER_FOCUS_TYPE:
      var focusElem = null;
      var nextElem;
      if (!event.ctrlKey && !event.shiftKey) {
        if (keyCode == AdfKeyStroke.HOME_KEY) {
          nextElem = this._getPrevColumnHeaderFocusElement(this._focusManager.domElement);
        } else {
          nextElem = this._getNextColumnHeaderFocusElement(this._focusManager.domElement);
        }
        while (nextElem) {
          focusElem = nextElem;
          if (keyCode == AdfKeyStroke.HOME_KEY) {
            nextElem = this._getPrevColumnHeaderFocusElement(focusElem);
          } else {
            nextElem = this._getNextColumnHeaderFocusElement(focusElem);
          }
        }
        if (focusElem) {
          this._unclipColumnElement(focusElem);
          this._setHeaderCellFocus(focusElem);
        }
      }
      break;
    case AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE:
    ;
    case AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE:
      var fm = this._focusManager, rowKey = fm.currency;
      if (rowKey) {
        var rowInfo = this.FindRowByKey(rowKey);
        if (rowInfo && rowInfo.tr.cells.length) {
          var cell = keyCode == AdfKeyStroke.HOME_KEY ? rowInfo.tr.cells[0] : this._findLastCell(rowInfo.tr);
          if (cell) {
            if (cell.getAttribute(AdfDhtmlTableBasePeer._ROW_HEADER) != null) {
              this.UpdateFocusManager(AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE, rowKey, cell);
            } else {
              this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, rowInfo.tr, cell);
            }
          }
        }
      }
      break;
  }
};
AdfDhtmlTableBasePeer.prototype._hScrollPage = function(scrollRight) {
  var hScroller = this.IsEmpty ? this.getDomElement() : this._hasSingleScroller() && !this._isPaged ? this.GetScroller() : this.GetScroller()[AdfDhtmlTableBasePeer._HSCROLLER];
  if (hScroller && hScroller.scrollWidth > hScroller.offsetWidth) {
    var newScrollPos = AdfAgent.AGENT.getScrollLeft(hScroller) - (scrollRight ? -1 : 1) * (hScroller.clientWidth - hScroller.clientWidth / 10);
    newScrollPos = scrollRight ? Math.max(newScrollPos, 0) : Math.min(newScrollPos, hScroller.scrollWidth);
    AdfAgent.AGENT.scrollToPos(hScroller, newScrollPos);
  }
};
AdfDhtmlTableBasePeer.prototype._handlePageUp = function(altKey, ctrlKey, shiftKey) {
  if (altKey) {
    this._hScrollPage(true);
  } else {
    if (this._virtInitialized) {
      var dataBody = this.GetDataBody();
      var scrollToPos = this._currentScrollTop - dataBody.offsetHeight;
      var canScroll = scrollToPos > 0 - dataBody.offsetHeight;
      scrollToPos = scrollToPos < 0 ? 0 : scrollToPos;
      var component = this.getComponent();
      var selState = component.getSelectedRowKeys();
      var hasSelection = false;
      for (var rowKey in selState) {
        hasSelection = true;
        break;
      }
      if (!hasSelection || ctrlKey) {
        if (canScroll) {
          this._scrollerScrollToPos(null, scrollToPos);
        }
        return;
      }
      var firstRowKey;
      var attrs = this.GetFirstVisibleRowKeyAndRow();
      if ((firstRowKey = attrs.rowKey) != null) {
        var firstRow = attrs.row;
        var isFirstRowSelected = selState[firstRowKey] != null && selState[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY] == null;
        this._selUnselectAll();
        if (canScroll && isFirstRowSelected) {
          this._selectionRequest = AdfDhtmlTableBasePeer._SELECT_PAGE_UP;
          var rowTop = firstRow.offsetTop + firstRow.parentNode.parentNode.startPos;
          scrollToPos = rowTop - dataBody.offsetHeight;
          this._scrollerScrollToPos(null, scrollToPos);
        } else {
          this._selSelectRow(firstRowKey, firstRow);
          this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, firstRowKey, firstRow);
          this._unclipRow(firstRow);
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._handlePageDown = function(altKey, ctrlKey, shiftKey) {
  if (altKey) {
    this._hScrollPage(false);
  } else {
    if (this._virtInitialized) {
      var dataBody = this.GetDataBody();
      var component = this.getComponent();
      var selState = component.getSelectedRowKeys();
      var hasSelection = false;
      for (var rowKey in selState) {
        hasSelection = true;
        break;
      }
      if (!hasSelection || ctrlKey) {
        var scrollToPos = this._currentScrollTop + dataBody.offsetHeight;
        if (scrollToPos < this._getScrollHeight()) {
          this._scrollerScrollToPos(null, scrollToPos);
        }
        return;
      }
      var lastRowKey;
      var attrs = this._getLastVisibleRowKeyAndRow();
      if ((lastRowKey = attrs.rowKey) != null) {
        var lastRow = attrs.row;
        var isLastRowSelected = selState[lastRowKey] != null && selState[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY] == null;
        this._selUnselectAll();
        if (isLastRowSelected) {
          this._selectionRequest = AdfDhtmlTableBasePeer._SELECT_PAGE_DOWN;
          var topAdjustment = this._currentScrollTop - lastRow.parentNode.parentNode.startPos;
          var rowBottom = lastRow.offsetTop + lastRow.offsetHeight - topAdjustment;
          this._scrollerScrollToPos(null, this._currentScrollTop + rowBottom);
        } else {
          this._selSelectRow(lastRowKey, lastRow);
          this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, lastRowKey, lastRow);
          this._unclipRow(lastRow);
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._getLastVisibleRowKeyAndRow = function() {
  var agent = AdfAgent.AGENT;
  var dataBody = this.GetDataBody();
  var dataTables = dataBody.childNodes;
  var tableCount = dataTables.length;
  var attrs = {};
  for (var i = tableCount - 1;i >= 0 && !attrs.rowKey;--i) {
    var table = dataTables[i], tableTop = table.startPos;
    var rows = dataTables[i].rows, rowCount = rows.length;
    for (var j = rowCount - 1;j >= 0;--j) {
      var row = rows[j];
      var rowTop = row.offsetTop - (this._currentScrollTop - tableTop);
      if (rowTop + AdfDhtmlTableBasePeer._MAXIMUM_ROW_REVEAL < dataBody.offsetHeight) {
        var rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
        attrs.rowKey = rowKey;
        attrs.row = row;
        break;
      }
    }
  }
  return attrs;
};
AdfDhtmlTableBasePeer.prototype.GetFirstVisibleRowKeyAndRow = function(margin) {
  var attrs = this._cachedFirstVisibleRowKeyAndRow;
  if (attrs) {
    return attrs;
  }
  var agent = AdfAgent.AGENT;
  var dataBody = this.GetDataBody();
  var dataTables = dataBody.childNodes;
  var tableCount = dataTables.length;
  attrs = {};
  margin = margin == undefined ? AdfDhtmlTableBasePeer._MAXIMUM_ROW_REVEAL : margin;
  for (var i = 0;i < tableCount && !attrs.rowKey;++i) {
    var table = dataTables[i];
    var tableTop = table.startPos;
    var rows = table.rows;
    var rowCount = 0;
    if (rows != null) {
      rowCount = rows.length;
    }
    for (var j = 0;j < rowCount;++j) {
      var row = rows[j];
      var rowBottom = row.offsetTop + row.offsetHeight + tableTop;
      if (rowBottom - margin > this._currentScrollTop) {
        var rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
        attrs.rowKey = rowKey;
        attrs.row = row;
        break;
      }
    }
  }
  this._cachedFirstVisibleRowKeyAndRow = attrs;
  return attrs;
};
AdfDhtmlTableBasePeer.prototype.scrollToRowIndex = function(index, callback) {
  var scrollTop = index * this._averageRowHeight;
  var comp = this.getComponent();
  var attrs = this.GetFirstVisibleRowKeyAndRow();
  var firstVisibleIndex = attrs.rowKey ? comp.getRowIndex(attrs.rowKey) : null;
  var vScrollState;
  if (this._currentScrollTop != scrollTop) {
    vScrollState = this.scrollToPos(-1, scrollTop, true, false);
  }
  if (firstVisibleIndex == index || vScrollState == AdfDhtmlTableBasePeer.VIEWPORT_SATISFIED) {
    this._callCallbackWithStatus(callback, this.SCROLL_SUCCEEDED);
  } else {
    var oldCallback = this._postEvalCallback;
    this._callCallbackWithStatus(oldCallback, this.SCROLL_CANCELLED);
    this._postEvalCallback = callback;
    if (!oldCallback) {
      AdfPage.PAGE.addEventListener(AdfDomReplacedEvent.EVENT_TYPE, this._domReplacedListener, this);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._callCallbackWithStatus = function(callback, status) {
  if (callback) {
    AdfAssert.assertFunction(callback);
    var state = new Object;
    state.status = status;
    callback(state);
  }
};
AdfDhtmlTableBasePeer.prototype._domReplacedListener = function(event) {
  var component = this.getComponent();
  AdfAssert.assertPrototype(component, AdfUIComponent);
  var clientId = component.getClientId();
  if (event.containsClientId(clientId)) {
    AdfPage.PAGE.removeEventListener(AdfDomReplacedEvent.EVENT_TYPE, this._domReplacedListener, this);
    var callback = this._postEvalCallback;
    this._postEvalCallback = null;
    this._callCallbackWithStatus(callback, this.SCROLL_SUCCEEDED);
  }
};
AdfDhtmlTableBasePeer.prototype._getNextRowKeyAndRow = function(selectedRowKey) {
  var agent = AdfAgent.AGENT;
  var dataBody = this.GetDataBody();
  var dataTables = dataBody.childNodes;
  var tableCount = dataTables.length;
  var attrs = {};
  for (var i = 0;i < tableCount && !attrs.rowKey;++i) {
    var table = dataTables[i];
    var rows = table.rows, rowCount = rows.length;
    for (var j = 0;j < rowCount;++j) {
      var row = rows[j];
      var rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
      if (selectedRowKey == null) {
        attrs.rowKey = rowKey;
        attrs.row = row;
        break;
      } else {
        if (rowKey == selectedRowKey) {
          attrs.lastRowKeyInView = rowKey;
          if (j + 1 < rowCount) {
            row = rows[j + 1];
            if (this._hasDetailStamp && AdfAgent.AGENT.getAttribute(row, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false)) {
              if (j + 2 < rowCount) {
                row = rows[j + 2];
              } else {
                if (i + 1 < tableCount && dataTables[i + 1].rows.length > 0) {
                  row = dataTables[i + 1].rows[0];
                } else {
                  return attrs;
                }
              }
            }
            rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
            attrs.rowKey = rowKey;
            attrs.row = row;
          } else {
            if (i + 1 < tableCount) {
              rows = dataTables[i + 1].rows;
              if (rows.length > 0) {
                row = rows[0];
                rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
                attrs.rowKey = rowKey;
                attrs.row = row;
              }
            } else {
              var lastBlock = dataTables[tableCount - 1];
              var currCount = lastBlock.startRow + lastBlock.numRows;
              if (currCount == this.GetRowCount() || this._isPaged) {
                attrs.isAtButtom = true;
              }
            }
          }
          break;
        }
      }
    }
  }
  return attrs;
};
AdfDhtmlTableBasePeer.prototype._getPreviousRowKeyAndRow = function(selectedRowKey) {
  var agent = AdfAgent.AGENT;
  var dataBody = this.GetDataBody();
  var dataTables = dataBody.childNodes;
  var tableCount = dataTables.length;
  var attrs = {};
  for (var i = tableCount - 1;i >= 0 && !attrs.rowKey;--i) {
    var table = dataTables[i], tableTop = table.startPos;
    var rows = dataTables[i].rows, rowCount = rows.length;
    for (var j = rowCount - 1;j >= 0;--j) {
      var row = rows[j];
      var rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
      if (selectedRowKey == null) {
        attrs.rowKey = rowKey;
        attrs.row = row;
        break;
      } else {
        if (rowKey == selectedRowKey) {
          attrs.lastRowKeyInView = rowKey;
          if (j - 1 >= 0) {
            row = rows[j - 1];
            if (this._hasDetailStamp && AdfAgent.AGENT.getAttribute(row, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false)) {
              if (j - 2 >= 0) {
                row = rows[j - 2];
              } else {
                if (i - 1 >= 0 && dataTables[i - 1].rows.length > 0) {
                  row = dataTables[i - 1].rows[dataTables[i - 1].rows.length - 1];
                } else {
                  return attrs;
                }
              }
            }
            rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
            attrs.rowKey = rowKey;
            attrs.row = row;
          } else {
            if (i - 1 >= 0) {
              rows = dataTables[i - 1].rows;
              if (rows.length > 0) {
                row = rows[rows.length - 1];
                rowKey = agent.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
                attrs.rowKey = rowKey;
                attrs.row = row;
              }
            } else {
              if (agent.getIntAttribute(table, "_startRow", -1) == 0) {
                attrs.isAtTop = true;
              }
            }
          }
          break;
        }
      }
    }
  }
  return attrs;
};
AdfDhtmlTableBasePeer.prototype._handleSpaceKey = function(keyCode, event) {
  var agent = AdfAgent.AGENT;
  var fm = this._focusManager;
  switch(fm.objectType) {
    default:
      break;
    case AdfDhtmlTableBasePeer._SELECT_ALL_FOCUS_TYPE:
      this._grabFocus();
      if (!this.getComponent().getSelectedRowKeys()[AdfDhtmlTableBasePeer.SELECTALL_KEY_PROPERTY]) {
        this._selSelectAll();
      }
      break;
    case AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE:
      var attrs = this.GetRowKeyAndRow(fm.domElement, this.getDomElement());
      if (attrs != null) {
        this._grabFocus();
        this._doRowSelection(agent.getEventTarget(event), agent.isSelectionToggle(event), event.shiftKey, attrs[0], attrs[1]);
      }
      break;
    case AdfDhtmlTableBasePeer._COLUMN_HEADER_FOCUS_TYPE:
      if (this._isColumnSelectionEnabled()) {
        var colIndices = [], colIds = [], th = fm.domElement;
        this._anchorColumnHeader = th;
        this._resolveColumns(colIndices, colIds, th);
        this._doColumnSelections(event, colIndices, colIds);
      }
      break;
    case AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE:
      if (this._supportsFocusRowNavigation) {
        var focusedRowKey = this._focusManager.currency;
        if (focusedRowKey != null) {
          if (!this._selIsSelected(focusedRowKey)) {
            this._selSelectRow(focusedRowKey, this._focusManager.domElement);
          } else {
            if (event.ctrlKey) {
              this._selUnselectRow(focusedRowKey, this._focusManager.domElement);
            }
          }
        }
      }
      break;
  }
};
AdfDhtmlTableBasePeer.prototype._handleEnterKey = function(eventTarget, domEvent) {
  var agent = AdfAgent.AGENT;
  var fm = this._focusManager;
  var stopBubbling = false;
  if (this._isTargetCellFilter(eventTarget)) {
    if (this._editableTableReadOnlyMode) {
      this._setReadOnlyMode(false, eventTarget, true);
    }
    if (agent.getPlatform() == AdfAgent.GECKO_PLATFORM && this._currentScrollLeft > 0) {
      AdfFocusUtils.focusElement(this.getDomElement());
    }
    var comp = AdfPage.PAGE.findComponent(agent.getAttribute(eventTarget, "name"));
    if (comp) {
      var peer = comp.getPeer();
      peer.bind(comp);
      if (peer instanceof AdfDhtmlInputBasePeer) {
        peer.RunValidation(comp, eventTarget, false);
      }
    }
    this._handleFilterCellAction();
    stopBubbling = true;
  } else {
    if (this._isTargetCellEditable(eventTarget)) {
      var attrs = this.GetRowKeyAndRow(eventTarget, this.getDomElement());
      if (attrs != null) {
        var rowKey = attrs[0];
        if (rowKey != null) {
          var row = attrs[1];
          var params = this._getCellAndIndexForNode(eventTarget, row);
          var cell = params.cell;
          if (this._ctePatternStart != params.cellIndex) {
            delete this._ctePatternStart;
          }
          var cellIndex = params.cellIndex;
          if (cellIndex > -1) {
            if (this._isClickToEdit()) {
              stopBubbling = this._clickToEditActivateRow(rowKey, !domEvent.shiftKey, cellIndex);
            } else {
              stopBubbling = this._setFocusOnEditableRowCell(rowKey, !domEvent.shiftKey, cellIndex);
            }
          }
        }
      }
    } else {
      if (this._focusManager.objectType == AdfDhtmlTableBasePeer._COLUMN_HEADER_FOCUS_TYPE) {
        var th = fm.domElement;
        if (th) {
          var siElem = agent.getElementById(AdfRichUIPeer.CreateSubId(th.id, AdfDhtmlTableBasePeer.__SORT_INDICATOR));
          if (siElem != null) {
            var col = AdfPage.PAGE.findComponent(th.id);
            var sortProperty = col.getSortProperty(), sortOrder = AdfDhtmlTableBasePeer.__getSortOrderForColumn(th.id);
            if (sortOrder == null) {
              sortOrder = true;
            } else {
              sortOrder = !sortOrder;
            }
            this.getComponent().setProperty("currentlySelectedHeaderId", th.id);
            AdfTableUtils.queueSortEvent(this.getComponent(), sortProperty, sortOrder);
          }
        }
      } else {
        if (this._isClickToEdit() && this.GetFocusedRowKey() != null) {
          if (this._editableTableReadOnlyMode || this.GetFocusedRowKey() != this._getActiveRowKey() || this._getActiveRowKey() == null) {
            this._setActiveRowKey(this.GetFocusedRowKey());
            this._setReadOnlyMode(false, eventTarget, false);
            cellIndex = this._getActiveCellIndex();
            if (cellIndex == -1) {
              cellIndex = this._lastCTEIndex;
            }
            if (cellIndex != undefined) {
              this._clickEditRequest = {cellIndex:cellIndex};
            }
          } else {
            stopBubbling = this._clickToEditActivateRow(this.GetFocusedRowKey(), !domEvent.shiftKey, this._lastCTEIndex);
          }
        } else {
          if (!this._isClickToEdit() && this._editableTableReadOnlyMode) {
            this._setReadOnlyMode(false, eventTarget, true);
          } else {
            return true;
          }
        }
      }
    }
  }
  return !stopBubbling;
};
AdfDhtmlTableBasePeer.prototype._setFocusOnEditableRowCell = function(curRowKey, isNext, cellIndex) {
  var attrs = isNext ? this._getNextRowKeyAndRow(curRowKey) : this._getPreviousRowKeyAndRow(curRowKey);
  var rowKey = attrs.rowKey;
  if (rowKey != null) {
    var agent = AdfAgent.AGENT;
    var row = attrs.row;
    var cell = this.FindCellByIndex(row, cellIndex);
    var focusWasSet = true;
    if (this._setFocusOnEditableElementInNode(agent, cell) == null) {
      if (this._setFocusOnEditableElementInNode(agent, row) == null) {
        focusWasSet = false;
      }
    }
    if (focusWasSet && this._isRowSelectionEnabled() && !this._selIsSelected(rowKey)) {
      this._selUnselectAll();
      this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row);
      this._selSelectRow(rowKey, row);
    }
  }
  return rowKey != null;
};
AdfDhtmlTableBasePeer.prototype._indexOfDomElement = function(domArr, elem) {
  var domCount = domArr.length;
  for (var i = 0;i < domCount;i++) {
    if (domArr[i] == elem) {
      return i;
    }
  }
  return -1;
};
AdfDhtmlTableBasePeer.prototype._getFirstInputElementInNode = function(agent, node, getAny) {
  var domDoc = agent.getDomDocument();
  var inputElems;
  var firstInputElem = null;
  var isVisible;
  if (domDoc.evaluate) {
    inputElems = domDoc.evaluate('.//input[not(@type\x3d"hidden")]|.//select|.//textarea|.//button|.//a|.//*[@tabindex\x3e\x3d0]', node, null, XPathResult.ANY_TYPE, null);
    var elem = inputElems.iterateNext();
    while (elem) {
      isVisible = this._isElementVisible(elem);
      if ((getAny || isVisible && !elem.disabled && elem.tabIndex != -1) && (elem.nodeName != "A" || elem.href)) {
        firstInputElem = elem;
        break;
      }
      elem = inputElems.iterateNext();
    }
  } else {
    inputElems = node.getElementsByTagName("*");
    var elemCount = inputElems.length;
    var inputRegExp = AdfDhtmlTableBasePeer._INPUT_REGEXP;
    for (var i = 0;i < elemCount;i++) {
      var elem = inputElems[i];
      var tabIndex = elem.getAttribute("tabIndex", 2);
      if (tabIndex != null && tabIndex >= 0 && tabIndex != 32768 && tabIndex != 65535 || elem.tagName.match(inputRegExp)) {
        isVisible = this._isElementVisible(elem);
        if ((getAny || isVisible && !elem.disabled && tabIndex != -1) && (elem.nodeName != "A" || elem.href)) {
          firstInputElem = elem;
          break;
        }
      }
    }
  }
  return firstInputElem;
};
AdfDhtmlTableBasePeer.prototype._isElementVisible = function(elem) {
  return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects && elem.getClientRects().length);
};
AdfDhtmlTableBasePeer.prototype._setFocusOnEditableElementInNode = function(agent, node) {
  var firstInputElem = this._getFirstInputElementInNode(agent, node);
  if (firstInputElem) {
    var isInput = firstInputElem.nodeName == "INPUT";
    if (agent.getPlatform() != AdfAgent.GECKO_PLATFORM || !(isInput && firstInputElem.type == "file")) {
      var previousElem = AdfPage.PAGE.getActiveDomElement();
      if (previousElem && previousElem.blur) {
        previousElem.blur();
      }
      var isInPopup = false;
      var zOrderManager = AdfPage.PAGE.getZOrderManager();
      if (zOrderManager) {
        if (zOrderManager.containsElement(this.getDomElement())) {
          isInPopup = true;
        }
      }
      if (agent.getPlatform() == AdfAgent.IE_PLATFORM && isInPopup && !this._isClickToEdit()) {
        AdfFocusUtils.focusElementDelayed(firstInputElem, 1);
      } else {
        AdfFocusUtils.focusElement(firstInputElem);
      }
      if (isInput && typeof firstInputElem.select != undefined) {
        firstInputElem.select();
      }
      return firstInputElem;
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._setInputElementCursorAtEndInNode = function(agent, node) {
  var firstInputElem = this._getFirstInputElementInNode(agent, node);
  if (firstInputElem && (firstInputElem.nodeName == "INPUT" && firstInputElem.type == "text" || firstInputElem.nodeName == "TEXTAREA")) {
    var textLength = firstInputElem.value.length;
    if (firstInputElem.selectionStart != null) {
      firstInputElem.setSelectionRange(textLength, textLength);
      firstInputElem.blur();
      firstInputElem.focus();
      var evt = firstInputElem.ownerDocument.createEvent("KeyboardEvent");
      if (evt.initKeyEvent != undefined) {
        evt.initKeyEvent("keypress", true, true, null, false, false, false, false, 27, 0);
      } else {
        evt.initUIEvent("keypress", true, true, window, 1);
      }
      firstInputElem.dispatchEvent(evt);
    } else {
      var r = firstInputElem.createTextRange();
      r.collapse(false);
      r.select();
    }
    return firstInputElem;
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._unclipRow = function(row) {
  AdfAssert.assert(row != null, "Unable to unclipRow without a valid row being passed in!");
  var dataBody = this.GetDataBody();
  var selectedRowTop = row.offsetTop + row.parentNode.parentNode.startPos;
  var topClipped = selectedRowTop < this._currentScrollTop;
  if (topClipped) {
    this._scrollerScrollToPos(null, selectedRowTop);
    return;
  }
  var selectedRowBottom = row.offsetTop + row.offsetHeight - (this._currentScrollTop - row.parentNode.parentNode.startPos);
  var bottomClipped = selectedRowBottom > dataBody.offsetHeight;
  if (bottomClipped) {
    this._scrollerScrollToPos(null, this._currentScrollTop + (selectedRowBottom - dataBody.offsetHeight));
  }
};
AdfDhtmlTableBasePeer.prototype.UpdateFocusManager = function(objectType, currency, domElement, activeCell) {
  var fm = this._focusManager;
  if (fm.domElement != null) {
    this._updateFocusCellStyle(false);
  }
  fm.objectType = objectType;
  fm.currency = currency;
  fm.domElement = domElement;
  this._updateFocusCellStyle(true);
  if (!this._disableRowMouseDownCellFocus) {
    if (activeCell) {
      this._setActiveDescendant(activeCell, true);
    } else {
      if (fm.domElement) {
        if (fm.domElement.nodeName == "TR") {
          this._moveActiveCellToRow(fm.domElement);
        } else {
          this._setActiveDescendant(fm.domElement, true);
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._getLabelText = function(node) {
  var labelText = "";
  var childNodes = node.childNodes;
  var childCount = childNodes ? childNodes.length : 0;
  for (var i = 0;i < childCount;i++) {
    var child = childNodes[i];
    if (child.nodeType == 1) {
      var childText;
      if (child.nodeName == "LABEL") {
        childText = child.textContent;
      } else {
        childText = this._getLabelText(child);
      }
      if (childText) {
        labelText += (labelText ? " " : "") + childText;
      }
    }
  }
  return labelText;
};
AdfDhtmlTableBasePeer.prototype._getSortColumnHeaderLabel = function(node) {
  var siElem = AdfAgent.AGENT.getElementById(AdfRichUIPeer.CreateSubId(node.id, AdfDhtmlTableBasePeer.__SORT_INDICATOR));
  if (siElem && siElem.rows[0]) {
    var sortCells = siElem.rows[0].cells;
    if (sortCells && sortCells.length > 0) {
      var aElem;
      if (siElem.getAttribute(AdfDhtmlTableBasePeer._SORTED_TYPE) == AdfDhtmlTableBasePeer._SORTED_ASCENDING) {
        aElem = AdfDomUtils.getFirstDescendentElement(sortCells[1], "A");
      }
      if (!aElem) {
        aElem = AdfDomUtils.getFirstDescendentElement(sortCells[0], "A");
      }
      if (aElem) {
        return node.textContent + " " + aElem.title;
      }
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._setActiveDescendant = function(node, addRowLabel) {
  var gridNode = this.getDomElement();
  if (gridNode) {
    var currActiveNode = this._getActiveCellNode();
    if (currActiveNode) {
      if (currActiveNode.getAttribute("role") == "columnheader" && currActiveNode.getAttribute(AdfDhtmlTableBasePeer._SELECT_ALL) == null) {
        currActiveNode.removeAttribute("aria-label");
      } else {
        var oldLabelledBy = currActiveNode.getAttribute("aria-labelledby");
        if (oldLabelledBy) {
          var ids = oldLabelledBy.split(" ");
          var rhNode;
          for (var i = 0;i < ids.length;i++) {
            if (ids[i].indexOf(":_ariaRHId") > 0) {
              if (rhNode = this.getDomDocument().getElementById(ids[i])) {
                rhNode.removeAttribute("id");
              }
            }
          }
        }
        currActiveNode.removeAttribute("aria-labelledby");
      }
      if (currActiveNode.id && currActiveNode.id.indexOf(":_ariaActiveId") > 0) {
        currActiveNode.removeAttribute("id");
      }
    }
    if (!node.id) {
      this._ariaIdSuffix = this._ariaIdSuffix == 1 ? 0 : 1;
      node.id = this.getDomElement().id + ":_ariaActiveId" + this._ariaIdSuffix;
    }
    var role = node.getAttribute("role");
    if (this._isFilterCell(node)) {
      if (!node.getAttribute("aria-label")) {
        node.setAttribute("aria-label", this._getLabelText(node));
      }
    } else {
      if (role == "columnheader") {
        var labelText = this._getSortColumnHeaderLabel(node);
        if (labelText) {
          node.setAttribute("aria-label", labelText);
        }
      } else {
        if (role != "presentation") {
          var labelledBy = "";
          var colHeaderIds;
          var cellIndex;
          if (role != "rowheader") {
            var attrs = this.GetRowKeyAndRow(node, this.getDomElement());
            if (attrs != null) {
              labelledBy = this._getRowHeaderIds(attrs[1]);
            }
          }
          cellIndex = this._getCellIndex(node);
          colHeaderIds = this._getLayeredColumnHeaderIds(cellIndex);
          if (colHeaderIds) {
            if (labelledBy) {
              labelledBy = labelledBy + " ";
            }
            labelledBy = labelledBy + colHeaderIds;
          }
          if (labelledBy) {
            labelledBy = labelledBy + " " + node.id;
            node.setAttribute("aria-labelledby", labelledBy);
          }
        }
      }
    }
    gridNode.setAttribute("aria-activedescendant", node.id);
    if (this._editableTableReadOnlyMode || this._getFirstInputElementInNode(AdfAgent.AGENT, node) == null) {
      var isInPopup = false;
      var zOrderManager = AdfPage.PAGE.getZOrderManager();
      if (zOrderManager) {
        if (zOrderManager.containsElement(this.getDomElement())) {
          isInPopup = true;
        }
      }
      if (!this.AllowCellNavigation() || AdfAgent.AGENT.getPlatform() == AdfAgent.IE_PLATFORM && !this._isClickToEdit() && isInPopup) {
        var attrs = this.GetRowKeyAndRow(node, this.getDomElement());
        if (attrs) {
          this._setFocusOnNode(attrs[1], true);
        }
      } else {
        this._setFocusOnNode(node, true);
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._findNextCell = function(activeNode, goLeft) {
  var nextCell = null;
  if (activeNode) {
    var attrs = this.GetRowKeyAndRow(activeNode, this.getDomElement());
    if (attrs != null) {
      var row = attrs[1];
      if (row != null) {
        var params = this._getCellAndIndexForNode(activeNode, row);
        if (params && params.cellIndex != -1) {
          if (!goLeft) {
            nextCell = this.FindCellByIndex(row, params.cellIndex + 1);
          } else {
            if (params.cellIndex > 0) {
              nextCell = this.FindCellByIndex(row, params.cellIndex - 1);
            }
          }
        }
      }
    }
  }
  return nextCell;
};
AdfDhtmlTableBasePeer.prototype._findLastCell = function(row) {
  var lastCell = null;
  if (row != null) {
    var index = 0;
    var nextCell;
    while (nextCell = this.FindCellByIndex(row, index)) {
      lastCell = nextCell;
      ++index;
    }
  }
  return lastCell;
};
AdfDhtmlTableBasePeer.prototype._getCellIndex = function(cellNode) {
  var cellIndex = -1;
  var gridNode = this.getDomElement();
  if (gridNode && cellNode) {
    var role = cellNode.getAttribute("role");
    if (this._isFilterCell(cellNode)) {
      cellIndex = AdfAgent.AGENT.getIntAttribute(cellNode, "_d_index", -1);
    } else {
      if (role == "columnheader") {
        var leafColClientIdsExpando = AdfAgent.AGENT.getAttribute(gridNode, "_leafColClientIds");
        if (leafColClientIdsExpando != null) {
          leafColClientIdsExpando = leafColClientIdsExpando.replace(/'/g, '"');
        }
        var leafColClientIds = JSON.parse(leafColClientIdsExpando);
        if (leafColClientIds != null) {
          var count = leafColClientIds.length;
          for (var i = 0;i < count;i++) {
            if (leafColClientIds[i] == cellNode.id) {
              cellIndex = i;
              break;
            }
          }
        }
      } else {
        var attrs = this.GetRowKeyAndRow(cellNode, this.getDomElement());
        if (attrs != null) {
          var rowKey = attrs[0];
          if (rowKey != null) {
            var params = this._getCellAndIndexForNode(cellNode, attrs[1]);
            if (params) {
              cellIndex = params.cellIndex;
            }
          }
        }
        if (!this._footerless && cellIndex == -1) {
          cellIndex = AdfAgent.AGENT.getIntAttribute(cellNode, "_d_index", -1);
        }
      }
    }
  }
  return cellIndex;
};
AdfDhtmlTableBasePeer.prototype._getActiveCellNode = function() {
  var cellNode;
  var gridNode = this.getDomElement();
  if (gridNode) {
    var activeId = gridNode.getAttribute("aria-activedescendant");
    if (activeId && activeId.length > 0) {
      cellNode = this.getDomDocument().getElementById(activeId);
    }
    while (cellNode && cellNode.nodeName != "TD" && cellNode.nodeName != "TH") {
      cellNode = cellNode.parentNode;
    }
  }
  return cellNode;
};
AdfDhtmlTableBasePeer.prototype._getActiveCellIndex = function() {
  return this._getCellIndex(this._getActiveCellNode());
};
AdfDhtmlTableBasePeer.prototype._changeActiveCell = function(goLeft) {
  var newNode;
  newNode = this._findNextCell(this._getActiveCellNode(), goLeft);
  if (newNode) {
    this._setActiveDescendant(newNode, false);
  } else {
    if (this._associatedPeer != null) {
      if (goLeft) {
        if (this.getComponent().getProperty("_afrMasterId") != null) {
          var activeCellNode = this._getActiveCellNode();
          var rowKey = activeCellNode.parentNode.getAttribute(AdfDhtmlTableBasePeer._ROW_KEY);
          this._associatedPeer.handleNavFromAssociatedPeer(rowKey);
        }
      } else {
        if (this.getComponent().getProperty("_afrSlaveId") != null) {
          var activeCellNode = this._getActiveCellNode();
          var rowKey = activeCellNode.parentNode.getAttribute(AdfDhtmlTableBasePeer._ROW_KEY);
          this._associatedPeer.handleNavToAssociatedPeer(rowKey);
        }
      }
    }
  }
  return newNode;
};
AdfDhtmlTableBasePeer.prototype._setHeaderCellFocus = function(cell) {
  var focusType;
  if (cell.getAttribute(AdfDhtmlTableBasePeer._FILTER_COLUMN)) {
    focusType = AdfDhtmlTableBasePeer._FILTER_CELL_FOCUS_TYPE;
  } else {
    if (cell.getAttribute(AdfDhtmlTableBasePeer._SELECT_ALL)) {
      focusType = AdfDhtmlTableBasePeer._SELECT_ALL_FOCUS_TYPE;
    } else {
      if (cell.getAttribute("role") == "columnheader") {
        focusType = AdfDhtmlTableBasePeer._COLUMN_HEADER_FOCUS_TYPE;
      }
    }
  }
  if (focusType) {
    this.UpdateFocusManager(focusType, null, cell);
  }
  return focusType;
};
AdfDhtmlTableBasePeer.prototype._restoreActiveCellFromDom = function() {
  var rootElem = this.getDomElement();
  var elem = document.activeElement;
  if (elem && AdfDomUtils.isAncestor(rootElem, elem)) {
    if (elem.nodeName == "TH") {
      this._setHeaderCellFocus(elem);
    } else {
      if (elem.nodeName == "TD") {
        var attrs = this.GetRowKeyAndRow(elem, rootElem);
        if (attrs) {
          if (elem.getAttribute(AdfDhtmlTableBasePeer._ROW_HEADER)) {
            this.UpdateFocusManager(AdfDhtmlTableBasePeer._ROW_HEADER_FOCUS_TYPE, attrs[0], elem);
          } else {
            this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, attrs[0], attrs[1], elem);
          }
        }
      } else {
        var cell = this._getTargetCell(elem);
        if (cell && this._isFilterCell(cell)) {
          this._setReadOnlyMode(false, elem, false);
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype.handleNavFromAssociatedPeer = function(rowKey) {
  var rowInfo = this.FindRowByKey(rowKey);
  if (rowInfo && rowInfo.tr) {
    var newNode = this._findLastCell(rowInfo.tr);
    this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, rowInfo.tr, newNode);
  }
};
AdfDhtmlTableBasePeer.prototype.handleNavToAssociatedPeer = function(rowKey) {
  var rowInfo = this.FindRowByKey(rowKey);
  if (rowInfo && rowInfo.tr) {
    var newNode = this.FindCellByIndex(rowInfo.tr, 0);
    this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, rowInfo.tr, newNode);
  }
};
AdfDhtmlTableBasePeer.prototype._getColumnHeaderId = function(index) {
  var colHeaderId;
  if (!this._headerless) {
    var gridNode = this.getDomElement();
    if (gridNode) {
      var leafColClientIdsExpando = AdfAgent.AGENT.getAttribute(gridNode, "_leafColClientIds");
      if (leafColClientIdsExpando != null) {
        leafColClientIdsExpando = leafColClientIdsExpando.replace(/'/g, '"');
      }
      var leafColClientIds = JSON.parse(leafColClientIdsExpando);
      if (leafColClientIds != null && leafColClientIds.length > index) {
        colHeaderId = leafColClientIds[index];
      }
    }
  }
  return colHeaderId;
};
AdfDhtmlTableBasePeer.prototype._getLayeredColumnHeaderIds = function(index) {
  var leafHeaderId = this._getColumnHeaderId(index);
  var allHeaderIds = leafHeaderId;
  if (leafHeaderId != null) {
    var domElement = AdfAgent.AGENT.getElementById(leafHeaderId);
    while (domElement) {
      if ((domElement = this._resolveImmediateParentColumn(domElement)) && domElement.id) {
        allHeaderIds = domElement.id + " " + allHeaderIds;
      }
    }
  }
  return allHeaderIds;
};
AdfDhtmlTableBasePeer.prototype._getRowHeaderIds = function(row) {
  var rowHeaderIds = "";
  var tableId = this.getDomElement().id;
  if (row) {
    var cell, i = 0;
    while (cell = this.FindCellByIndex(row, i++)) {
      if (cell.getAttribute("role") == "rowheader") {
        var inputElem;
        var headerId;
        if ((inputElem = this._getFirstInputElementInNode(AdfAgent.AGENT, cell, true)) && inputElem.id) {
          headerId = inputElem.id;
        } else {
          if (!cell.id) {
            cell.id = tableId + ":_ariaRHId" + i;
          }
          headerId = cell.id;
        }
        rowHeaderIds = rowHeaderIds + " " + headerId;
      }
    }
  }
  return rowHeaderIds;
};
AdfDhtmlTableBasePeer.prototype._moveActiveCellToRow = function(row) {
  var cellIndex = this._getActiveCellIndex();
  if (cellIndex == -1) {
    cellIndex = 0;
  }
  var newNode = this.FindCellByIndex(row, cellIndex);
  if (newNode) {
    this._setActiveDescendant(newNode, true);
  }
};
AdfDhtmlTableBasePeer.prototype._getTargetCell = function(node) {
  var rootNode = this.getDomElement();
  while (node && (node.nodeName != "TD" && node.nodeName != "TH")) {
    if (node == rootNode) {
      return null;
    }
    node = node.parentNode;
  }
  return node;
};
AdfDhtmlTableBasePeer.prototype._setReadOnlyMode = function(readOnly, eventTarget, changeFocus) {
  this._disableTabStop(readOnly);
  this._editableTableReadOnlyMode = readOnly;
  if (!changeFocus) {
    return;
  }
  if (readOnly) {
    var params;
    var attrs = this.GetRowKeyAndRow(eventTarget, this.getDomElement());
    if (attrs != null) {
      var rowKey = attrs[0];
      if (rowKey != null) {
        params = this._getCellAndIndexForNode(eventTarget, attrs[1]);
        if (this._isClickToEdit()) {
          this._lastCTEIndex = params.cellIndex;
        }
        if (params.cell) {
          this._setActiveDescendant(params.cell, false);
        }
      }
    }
    var targetCell = this._getTargetCell(eventTarget);
    if (targetCell && this._isFilterCell(targetCell)) {
      this._setHeaderCellFocus(targetCell);
    } else {
      if (this._isClickToEdit()) {
        this._setActiveRowKey(null);
        this._grabFocus();
      } else {
        if (!params || !params.cell) {
          this._grabFocus();
        }
      }
    }
  } else {
    var activeNode = this._getActiveCellNode();
    if (activeNode) {
      this._setFocusOnEditableElementInNode(AdfAgent.AGENT, activeNode);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._updateFocusCellStyle = function(hasFocus) {
  var fm = this._focusManager;
  if (hasFocus && fm.domElement) {
    AdfDomUtils.addCSSClassName(fm.domElement, AdfDhtmlTableBasePeer._FOCUSED_CLASS);
  } else {
    if (!hasFocus && fm.domElement) {
      AdfDomUtils.removeCSSClassName(fm.domElement, AdfDhtmlTableBasePeer._FOCUSED_CLASS);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._isFilterable = function() {
  return this.getDomElement().getAttribute(AdfDhtmlTableBasePeer._FILTERABLE) != null;
};
AdfDhtmlTableBasePeer.prototype._isTargetCellFilter = function(node) {
  var currElement = node, rootElement = this.getDomElement();
  var agent = AdfAgent.AGENT;
  var filterAttr = agent.getAttribute(currElement, AdfDhtmlTableBasePeer._FILTER_COLUMN);
  while (filterAttr == null) {
    if (currElement == null || currElement == rootElement) {
      return false;
    }
    currElement = currElement.parentNode;
    if (currElement == null || currElement.nodeType != 1) {
      break;
    }
    filterAttr = agent.getAttribute(currElement, AdfDhtmlTableBasePeer._FILTER_COLUMN);
  }
  return filterAttr != null;
};
AdfDhtmlTableBasePeer.prototype._handleFilterCellAction = function() {
  var component = this.getComponent();
  component.queueEvent(new AdfQueryEvent(component));
  component.setSelectedRowKeys(null);
};
AdfDhtmlTableBasePeer.prototype.getRowKeyForEvent = function(inputEvent) {
  var target = inputEvent.getNativeEventTarget();
  if (this._getTargetRowHeader(target) == null) {
    var domElement = this.getDomElement();
    var attrs = this.GetRowKeyAndRow(target, domElement);
    if (attrs != null) {
      return attrs[0];
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype.applyDragReadyStateForRowKeys = function(component, inputEvent, rowKeys) {
  AdfAssert.assertArray(rowKeys);
  var elements = this._getDomNodesForDrag(rowKeys);
  for (var i = 0, size = elements.length;i < size;++i) {
    AdfDomUtils.addCSSClassName(elements[i], AdfRichUIPeer.DRAG_READY_STYLECLASS);
  }
  return elements;
};
AdfDhtmlTableBasePeer.prototype.ClearDragReadyState = function(dragReadyObj) {
  AdfAssert.assertArray(dragReadyObj);
  for (var i = 0, size = dragReadyObj.length;i < size;++i) {
    AdfDomUtils.removeCSSClassName(dragReadyObj[i], AdfRichUIPeer.DRAG_READY_STYLECLASS);
  }
};
AdfDhtmlTableBasePeer.prototype.applyDragSourceStateForRowKeys = function(component, inputEvent, rowKeys) {
  AdfAssert.assertArray(rowKeys);
  var elements = this._getDomNodesForDrag(rowKeys);
  for (var i = 0, size = elements.length;i < size;++i) {
    AdfDomUtils.addCSSClassName(elements[i], AdfRichUIPeer.DRAG_SOURCE_STYLECLASS);
  }
  return elements;
};
AdfDhtmlTableBasePeer.prototype.ClearDragSourceState = function(dragSourceObj) {
  AdfAssert.assertArray(dragSourceObj);
  for (var i = 0, size = dragSourceObj.length;i < size;++i) {
    AdfDomUtils.removeCSSClassName(dragSourceObj[i], AdfRichUIPeer.DRAG_SOURCE_STYLECLASS);
  }
};
AdfDhtmlTableBasePeer.prototype.getDragOffsetForRowKeys = function(inputEvent, rowKeys) {
  var target = inputEvent.getNativeEventTarget();
  var domElement = this.getDomElement();
  var attrs = this.GetRowKeyAndRow(target, domElement);
  var xOffset = 0, yOffset = 0;
  var agent = AdfAgent.AGENT;
  if (attrs != null) {
    var rowKey = attrs[0];
    var row = attrs[1];
    for (var i = 0;i < rowKeys.length;i++) {
      if (rowKeys[i] == rowKey) {
        var elemPos = agent.getElementPosition(row);
        var mousePos = agent.getMousePosition(inputEvent.getNativeEvent());
        xOffset = mousePos.x - elemPos.x;
        yOffset += mousePos.y - elemPos.y;
        if (this._hasFrozenColumn()) {
          xOffset -= AdfDhtmlTableBasePeer.__getChildBySubId(this.__getColumnHeader(), "t").offsetWidth;
        }
        break;
      } else {
        var rowInfo = this.FindRowByKey(rowKeys[i]);
        AdfAssert.assert(rowInfo != null);
        yOffset += rowInfo.tr.offsetHeight;
      }
    }
  }
  return {x:xOffset, y:yOffset};
};
AdfDhtmlTableBasePeer.prototype.getDragNodeForRowKeys = function(rowKeys) {
  AdfAssert.assertArray(rowKeys);
  var dragNode = this.getDomDocument().createElement("table");
  var elements = this._getDomNodesForDrag(rowKeys);
  for (var i = 0, size = elements.length;i < size;++i) {
    var dragCell = elements[i];
    var cloneCell = this._cloneCellForDrag(dragCell);
    var dragRow = dragNode.insertRow(-1);
    dragRow.appendChild(cloneCell);
  }
  return dragNode;
};
AdfDhtmlTableBasePeer.prototype._getDomNodesForDrag = function(rowKeys) {
  var elements = [];
  var lastFrozen = this._lastFrozen;
  var dataBody = this.GetDataBody();
  for (var i = 0;i < rowKeys.length;++i) {
    var rowInfo = this.FindRowByKey(rowKeys[i]);
    if (rowInfo) {
      var domNode = rowInfo.tr;
      var tableTop = domNode.parentNode.parentNode.startPos;
      var rowBottom = domNode.offsetTop + domNode.offsetHeight + tableTop;
      if (rowBottom - AdfDhtmlTableBasePeer._MAXIMUM_ROW_REVEAL > this._currentScrollTop) {
        var rowTop = domNode.offsetTop - (this._currentScrollTop - tableTop);
        if (rowTop + AdfDhtmlTableBasePeer._MAXIMUM_ROW_REVEAL < dataBody.offsetHeight) {
          var dragCell = domNode.cells[0];
          if (this._freezeColumnsToStart()) {
            dragCell = this._getInnerTableCell(domNode, lastFrozen + 1);
          } else {
            if (this._freezeColumnsToEnd()) {
              dragCell = this._getInnerTableCell(domNode, 0);
            }
          }
          if (dragCell == null) {
            dragCell = domNode.cells[0];
          }
          elements.push(dragCell);
        }
      }
    }
  }
  return elements;
};
AdfDhtmlTableBasePeer.prototype._cloneCellForDrag = function(dragCell) {
  var cloneCell = dragCell.cloneNode(true);
  var agent = AdfAgent.AGENT;
  agent.copyStyle(dragCell, cloneCell);
  var cloneCellStyle = cloneCell.style;
  cloneCellStyle.width = "";
  cloneCellStyle.borderRight = cloneCellStyle.borderBottom = "0px";
  agent.setOpacity(cloneCell, 50);
  return cloneCell;
};
AdfDhtmlTableBasePeer.prototype.getRowKeyAndOrientationFromHints = function(pageX, pageY, hints) {
  AdfAssert.assertNumber(pageX);
  AdfAssert.assertNumber(pageY);
  AdfAssert.assert(hints != null);
  var hintRowKey = hints[AdfStampedDropTarget.HINT_LAST_ROWKEY];
  var hintRowKeyBounds = hints[AdfStampedDropTarget.HINT_LAST_ROWKEY_BOUNDS];
  var hintDropOrientation = hints[AdfStampedDropTarget.HINT_LAST_DROP_ORIENTATION];
  if (hintRowKey && hintRowKeyBounds) {
    AdfAssert.assertString(hintRowKey);
    AdfAssert.assertObject(hintRowKeyBounds);
    if (pageX >= hintRowKeyBounds.left && pageY >= hintRowKeyBounds.top && pageX <= hintRowKeyBounds.right && pageY <= hintRowKeyBounds.bottom) {
      hints[AdfStampedDropTarget.ROW_KEY] = hintRowKey;
      hints[AdfStampedDropTarget.DROP_ORIENTATION] = hintDropOrientation;
      return;
    }
  }
  this._getRowKeyAndOrientationForPosition(pageX, pageY, hints);
};
AdfDhtmlTableBasePeer.prototype._getRowKeyAndOrientationForPosition = function(pageX, pageY, hints) {
  AdfAssert.assertNumber(pageX);
  AdfAssert.assertNumber(pageY);
  var dataBody = this.GetDataBody();
  var ignoreList = {"colgroup":true};
  var eventTarget = AdfDomUtils.getElementAtPoint(dataBody, pageX, pageY, null, ignoreList);
  if (eventTarget) {
    var attrs = this.GetRowKeyAndRow(eventTarget, this.getDomElement());
    if (attrs != null) {
      hints[AdfStampedDropTarget.ROW_KEY] = attrs[0];
      hints[AdfStampedDropTarget.DROP_ORIENTATION] = AdfDropEvent.DROP_ORIENTATION_ON;
      return;
    }
  }
  if (this.IsEmpty) {
    hints[AdfStampedDropTarget.ROW_KEY] = null;
    hints[AdfStampedDropTarget.DROP_ORIENTATION] = AdfDropEvent.DROP_ORIENTATION_AFTER;
    return;
  } else {
    if (AdfAgent.AGENT.pointInElementBounds(dataBody, pageX, pageY)) {
      hints[AdfStampedDropTarget.ROW_KEY] = this._getLastRowKey();
      hints[AdfStampedDropTarget.DROP_ORIENTATION] = AdfDropEvent.DROP_ORIENTATION_AFTER;
      return;
    }
  }
  hints[AdfStampedDropTarget.ROW_KEY] = null;
  hints[AdfStampedDropTarget.DROP_ORIENTATION] = AdfDropEvent.DROP_ORIENTATION_ON;
};
AdfDhtmlTableBasePeer.prototype.showDragFeedback = function(dndContext, rowKey, userAction, lastValidRowKey, pageX, pageY, dragExit) {
  AdfAssert.assertPrototype(dndContext, AdfDnDContext);
  AdfAssert.assertStringOrNull(rowKey);
  AdfAssert.assertNumber(userAction);
  AdfAssert.assertStringOrNull(lastValidRowKey);
  if (userAction == AdfDnDContext.ACTION_NONE) {
    AdfDomUtils.removeCSSClassName(this.GetDataBody(), AdfDhtmlTableBasePeer._DROP_TARGET_CLASS);
    rowKey = null;
  }
  if (lastValidRowKey != rowKey) {
    if (lastValidRowKey) {
      var rowInfo = this.FindRowByKey(lastValidRowKey);
      if (rowInfo) {
        AdfDomUtils.removeCSSClassName(rowInfo.tr, AdfDhtmlTableBasePeer._DROP_TARGET_CLASS);
      }
    }
    if (rowKey) {
      var rowInfo = this.FindRowByKey(rowKey);
      if (rowInfo) {
        AdfDomUtils.addCSSClassName(rowInfo.tr, AdfDhtmlTableBasePeer._DROP_TARGET_CLASS);
        AdfDomUtils.removeCSSClassName(this.GetDataBody(), AdfDhtmlTableBasePeer._DROP_TARGET_CLASS);
      }
    }
  }
  if (rowKey == null && userAction != AdfDnDContext.ACTION_NONE) {
    AdfDomUtils.addCSSClassName(this.GetDataBody(), AdfDhtmlTableBasePeer._DROP_TARGET_CLASS);
  }
};
AdfDhtmlTableBasePeer.prototype.getRowKeyBounds = function(rowKey) {
  if (!rowKey) {
    return null;
  }
  var rowInfo = this.FindRowByKey(rowKey);
  if (rowInfo) {
    return AdfAgent.AGENT.getElementPageBounds(rowInfo.tr);
  } else {
    return null;
  }
};
AdfDhtmlTableBasePeer.prototype.ShiftIndex = function(fromBlock, delta, down) {
  var block = fromBlock;
  while (block) {
    block.startRow += delta;
    block = down ? block.nextSibling : block.previousSibling;
  }
};
AdfDhtmlTableBasePeer.prototype.IsReceivingActiveEvents = function() {
  return this._activeDataCount != -1;
};
AdfDhtmlTableBasePeer.prototype.RemoveAllBlocks = function(dataBody) {
  var blockList = dataBody.childNodes;
  for (var i = blockList.length - 1;i >= 0;i--) {
    this._unregisterNode(blockList[i]);
    dataBody.removeChild(blockList[i]);
  }
};
AdfDhtmlTableBasePeer.prototype._getFirstRowKey = function() {
  var dataBody = this.GetDataBody();
  var blocks = dataBody.childNodes;
  if (blocks.length > 0) {
    return this._getBlockFirstRowKey(blocks[0]);
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._getLastRowKey = function() {
  var dataBody = this.GetDataBody();
  var blocks = dataBody.childNodes;
  var blockCount = blocks.length;
  if (blockCount > 0) {
    return this._getBlockLastRowKey(blocks[blockCount - 1]);
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._getBlockFirstRowKey = function(block) {
  AdfAssert.assert(block.rows != null && block.rows.length > 0, "Unable to get row key by index when the block contains no rows!");
  return AdfAgent.AGENT.getAttribute(block.rows[0], AdfDhtmlTableBasePeer._ROW_KEY);
};
AdfDhtmlTableBasePeer.prototype._getBlockLastRowKey = function(block) {
  AdfAssert.assert(block.rows != null && block.rows.length > 0, "Unable to get row key by index when the block contains no rows!");
  var agent = AdfAgent.AGENT;
  var tr = block.rows[block.rows.length - 1];
  var rowKey = agent.getAttribute(tr, AdfDhtmlTableBasePeer._ROW_KEY);
  if (rowKey == null && tr.previousSibling) {
    rowKey = agent.getAttribute(tr.previousSibling, AdfDhtmlTableBasePeer._ROW_KEY);
  }
  return rowKey;
};
AdfDhtmlTableBasePeer.prototype._isImmediateContentDelivery = function(component) {
  var delivery = component.getContentDelivery();
  return delivery == "immediate";
};
AdfDhtmlTableBasePeer.prototype._isInlineDataAvailable = function(component) {
  var available = component.getProperty("_afrDataInline");
  return available;
};
AdfDhtmlTableBasePeer.prototype._sizeRegionsForFrozenColumns = function(dataBody, dataBodyWidth) {
  if (!this._hasFrozenColumn() || this._areAllColumnsFrozen(this._colCount)) {
    return;
  }
  var block = dataBody.firstChild;
  while (block) {
    this._sizeBlockForFrozenColumns(block, dataBodyWidth);
    block = block.nextSibling;
  }
  var colHeader = this.__getColumnHeader();
  var unfrozenWidth = this._unfrozenWidth;
  if (colHeader != null) {
    var unfrozenDiv = AdfDhtmlTableBasePeer.__getChildBySubId(colHeader, "d2");
    if (this._freezeColumnsToEnd()) {
      var colHeaderTable = AdfDhtmlTableBasePeer.__getChildBySubId(colHeader, "t");
      if (colHeaderTable) {
        unfrozenWidth = this._unfrozenWidth;
        if (dataBodyWidth < this._totalWidth) {
          unfrozenWidth = Math.max(dataBodyWidth - this._frozenWidth, 0);
        }
        unfrozenDiv.style.width = unfrozenWidth + "px";
        var unfrozenTable = AdfDhtmlTableBasePeer.__getChildBySubId(unfrozenDiv, "t2");
        unfrozenTable.style.width = unfrozenWidth + "px";
        if (AdfDhtmlTableBasePeer._isRTL()) {
          colHeaderTable.style.right = unfrozenDiv.style.width;
        } else {
          colHeaderTable.style.left = unfrozenDiv.style.width;
        }
      }
    } else {
      unfrozenDiv.style.width = Math.max(dataBodyWidth - this._frozenWidth, 0) + "px";
    }
  }
  var colFooter = this._getColumnFooter();
  if (colFooter != null) {
    unfrozenDiv = AdfDhtmlTableBasePeer.__getChildBySubId(colFooter, "fd2");
    if (this._freezeColumnsToEnd()) {
      var colFootTable = AdfDhtmlTableBasePeer.__getChildBySubId(colFooter, "ft");
      if (colFootTable) {
        unfrozenWidth = this._unfrozenWidth;
        if (dataBodyWidth < this._totalWidth) {
          unfrozenWidth = dataBodyWidth - this._frozenWidth;
        }
        unfrozenDiv.style.width = unfrozenWidth + "px";
        if (AdfDhtmlTableBasePeer._isRTL()) {
          colFootTable.style.right = unfrozenDiv.style.width;
        } else {
          colFootTable.style.left = unfrozenDiv.style.width;
        }
      }
    } else {
      unfrozenDiv.style.width = Math.max(dataBodyWidth - this._frozenWidth, 0) + "px";
    }
  }
};
AdfDhtmlTableBasePeer.prototype._getUnfrozenColumnsWidth = function() {
  var width = 0;
  var colHeader = this.__getColumnHeader();
  var colHeaderTable = AdfDhtmlTableBasePeer.__getChildBySubId(colHeader, "d2");
  if (colHeaderTable) {
    width = colHeaderTable.offsetWidth;
  }
  return width;
};
AdfDhtmlTableBasePeer.prototype._sizeBlockForFrozenColumns = function(block, dataBodyWidth) {
  if (!this._hasFrozenColumn()) {
    return;
  }
  AdfAssert.assert(block.rows != null && block.rows[0] != null, "Unable to _sizeBlockForFrozenColumns when block contains no rows!");
  var cells = block.rows[0].cells;
  if (this._areAllColumnsFrozen(cells.length)) {
    return;
  }
  var colGrp;
  if (this._freezeColumnsToEnd()) {
    var unfrozenWidth = Math.max(dataBodyWidth - this._frozenWidth, 0);
    var frozenWidth = this._frozenWidth;
    if (this._totalWidth > 0 && dataBodyWidth >= this._totalWidth) {
      unfrozenWidth = this._unfrozenWidth;
    }
    if (this._frozenWidth > 0 && dataBodyWidth < this._frozenWidth) {
      frozenWidth = dataBodyWidth;
    }
    var first = cells[0];
    var totalWidth = unfrozenWidth + frozenWidth;
    first.style.width = unfrozenWidth + "px";
    block.style.width = totalWidth + "px";
    if (this._processColGroup()) {
      colGrp = AdfDhtmlTableBasePeer.FindFirstChildByTagName(block, "COLGROUP");
      if (colGrp) {
        var firstCol = colGrp.childNodes[0];
        while (firstCol && firstCol.tagName != "COL") {
          firstCol = firstCol.nextSibling;
        }
        if (firstCol) {
          firstCol.style.width = first.style.width;
          first.firstChild.style.width = first.style.width;
        }
      }
    }
  } else {
    var last = cells[cells.length - 1];
    last.style.width = Math.max(dataBodyWidth - this._frozenWidth, 0) + "px";
    block.style.width = dataBodyWidth + "px";
    if (this._processColGroup()) {
      colGrp = AdfDhtmlTableBasePeer.FindFirstChildByTagName(block, "COLGROUP");
      if (colGrp) {
        var lastCol = colGrp.childNodes[colGrp.childNodes.length - 1];
        while (lastCol && lastCol.tagName != "COL") {
          lastCol = lastCol.previousSibling;
        }
        if (lastCol) {
          lastCol.style.width = last.style.width;
          last.firstChild.style.width = last.style.width;
        }
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._registerInnerScrollCallback = function(block) {
  if (!this._hasFrozenColumn()) {
    return;
  }
  AdfAssert.assert(block.rows != null && block.rows[0] != null, "Unable to register inner scroll callback when the block contains no rows!");
  var cells = block.rows[0].cells;
  var len = cells.length;
  if (this._areAllColumnsFrozen(len)) {
    return;
  }
  for (var r = 0;r < block.rows.length;r++) {
    cells = block.rows[r].cells;
    var last;
    if (this._freezeColumnsToEnd()) {
      last = cells[0];
    } else {
      last = cells[len - 1];
    }
    var div = AdfDhtmlTableBasePeer.FindFirstChildByTagName(last, "DIV");
    div.onscroll = this._innerTableScrollCallback;
  }
};
AdfDhtmlTableBasePeer.prototype._getNestedScrolledTable = function(row) {
  AdfAssert.assert(row != null, "Unable to get the nested scrolled table without a valid row passed in!");
  var cells = row.cells;
  var last;
  if (this._freezeColumnsToEnd()) {
    last = cells[0];
  } else {
    last = cells[cells.length - 1];
  }
  var div = AdfDhtmlTableBasePeer.FindFirstChildByTagName(last, "DIV");
  var table = AdfDhtmlTableBasePeer.FindFirstChildByTagName(div, "TABLE");
  return table;
};
AdfDhtmlTableBasePeer._isRTL = function() {
  return AdfPage.PAGE.getLocaleContext().isRightToLeft();
};
AdfDhtmlTableBasePeer.prototype._getExpandAction = function(target) {
  var laf = AdfPage.PAGE.getLookAndFeel();
  var styleExpanded = laf.getStyleClass(AdfDhtmlTableBasePeer._ICON_STYLE_EXPANDED);
  var parentClassName = target.parentNode.className;
  if (styleExpanded == target.className || styleExpanded == parentClassName) {
    return "collapse";
  }
  var styleCollapsed = laf.getStyleClass(AdfDhtmlTableBasePeer._ICON_STYLE_COLLAPSED);
  if (styleCollapsed == target.className || styleCollapsed == parentClassName) {
    return "expand";
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype.ComponentScrollTopChanged = function(component, domElement, newValue, oldValue) {
  this.scrollToPos(-1, newValue, true);
  return false;
};
AdfDhtmlTableBasePeer.prototype.ComponentScrollLeftChanged = function(component, domElement, newValue, oldValue) {
  this.scrollToPos(newValue, -1, true);
  return false;
};
AdfDhtmlTableBasePeer.prototype.ComponentDisclosedRowKeysChanged = function(component, domElement, newValue, oldValue) {
  this._savedDisclosedState = oldValue;
  var collapseItems = AdfCollections.removeAll(oldValue, newValue);
  var expandItems = AdfCollections.removeAll(newValue, oldValue);
  var someCollapsed = false;
  var someExpanded = false;
  if (collapseItems != null && !AdfCollections.isEmpty(collapseItems)) {
    this.HandleComponentCollapseEvent(collapseItems);
    someCollapsed = true;
  }
  if (expandItems != null && !AdfCollections.isEmpty(expandItems)) {
    this.HandleComponentExpandEvent(collapseItems);
    someExpanded = true;
  }
  AdfAssert.assert(!(someCollapsed && someExpanded));
};
AdfDhtmlTableBasePeer.prototype.HandleComponentCollapseEvent = function(collapsedItems) {
  this._queueCollapseFetchEvent();
};
AdfDhtmlTableBasePeer.prototype.HandleComponentExpandEvent = function(collapsedItems) {
  this._queueExpandFetchEvent();
};
AdfDhtmlTableBasePeer.prototype._changeDetailIcon = function(tr, expanded) {
  var agent = AdfAgent.AGENT;
  var detailCell = null;
  var cells = tr.cells;
  for (var i = 0;i < cells.length;i++) {
    if (agent.getAttribute(cells[i], AdfDhtmlTableBasePeer._DETAIL_COLUMN_MARKER, false)) {
      detailCell = cells[i];
      break;
    }
  }
  if (detailCell) {
    var link = AdfDhtmlTableBasePeer.FindFirstChildByTagName(detailCell, "A");
    if (link) {
      var fullStyle = expanded ? AdfDhtmlTableBasePeer._ICON_STYLE_EXPANDED : AdfDhtmlTableBasePeer._ICON_STYLE_COLLAPSED;
      var laf = AdfPage.PAGE.getLookAndFeel();
      var abbr = laf.getStyleClass(fullStyle);
      link.className = abbr;
      var title = expanded ? laf.getTranslatedString(AdfDhtmlTableBasePeer._EXPANDED_NODE_KEY) : laf.getTranslatedString(AdfDhtmlTableBasePeer._COLLAPSED_NODE_KEY);
      link.title = title;
    }
    var imageElem = this._getDisclosureIcon(link);
    if (imageElem) {
      var iconKey = expanded ? AdfDhtmlTableBasePeer._ICON_EXPANDED : AdfDhtmlTableBasePeer._ICON_COLLAPSED;
      AdfDomUtils.swapIcon(imageElem, iconKey);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._getDisclosureIcon = function(element) {
  var agent = AdfAgent.getAgent();
  if (element.firstChild != null) {
    var imgChild = element.firstChild;
    var nodeName = agent.getNodeName(imgChild).toLowerCase();
    if (nodeName == "img" || nodeName == "span" || nodeName == "#text") {
      return imgChild;
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._getEstimatedRowCount = function(block) {
  var agent = AdfAgent.getAgent();
  return agent.getIntAttribute(block, "_estRowCount", -1);
};
AdfDhtmlTableBasePeer._getBlockRowCount = function(block) {
  var count = 0;
  var agent = AdfAgent.getAgent();
  if (agent.getAttribute(block, AdfDhtmlTableBasePeer._HAS_DETAIL_MARKER, false)) {
    var rows = block.rows;
    for (var r = 0;r < rows.length;r++) {
      if (!agent.getAttribute(rows[r], AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false)) {
        count++;
      }
    }
  } else {
    return block.rows.length;
  }
  return count;
};
AdfDhtmlTableBasePeer.prototype.__isOwnComponentEvent = function(componentEvent) {
  var source = componentEvent.getSource();
  var self = this.getComponent();
  var isOwn = false;
  var checkTree = AdfPage.PAGE.getDomWindow().AdfUITree != null;
  while (!isOwn && source) {
    if (source == self) {
      isOwn = true;
    } else {
      if (source instanceof AdfUITable || checkTree && source instanceof AdfUITree || source instanceof AdfUIPopup) {
        break;
      }
      source = source.getParent();
    }
  }
  return isOwn;
};
AdfDhtmlTableBasePeer.prototype._isClickToEdit = function() {
  var editingMode = this.getComponent().getEditingMode();
  return editingMode == AdfDhtmlTableBasePeer._EDIT_MODE_CLICKTOEDIT;
};
AdfDhtmlTableBasePeer.prototype._getActiveRowKey = function() {
  return this.getComponent().getProperty("_afrActiveRowKey");
};
AdfDhtmlTableBasePeer.prototype.ComponentActiveRowKeyChanged = function(component, domElement, newValue, oldValue) {
  this._setActiveRowKey(newValue);
  return false;
};
AdfDhtmlTableBasePeer.prototype._setActiveRowKey = function(rowKey) {
  if (AdfTableDataFetchEvent.CLICK_EDIT_ACTIVE_ROW == this._pendingFetch) {
    return;
  }
  if (this._ignoreActiveRowKeyChange) {
    return;
  }
  var eventObj = null;
  this._ignoreActiveRowKeyChange = true;
  try {
    var component = this.getComponent();
    var oldActiveRowKey = component.getProperty("_afrActiveRowKey");
    component.setProperty("_afrActiveRowKey", rowKey, false, AdfUIComponent.PROPAGATE_ALWAYS);
    component.setProperty("activeRowKey", rowKey, false, AdfUIComponent.PROPAGATE_ALWAYS);
    if (component.getProperty(AdfDhtmlTableBasePeer._REMAIN_READ_ONLY)) {
      delete oldActiveRowKey;
    }
    component.setProperty(AdfDhtmlTableBasePeer._REMAIN_READ_ONLY, null, false, AdfUIComponent.PROPAGATE_ALWAYS);
    if (this._remainReadOnly) {
      component.setProperty(AdfDhtmlTableBasePeer._REMAIN_READ_ONLY, true, false, AdfUIComponent.PROPAGATE_ALWAYS);
    } else {
      component.setProperty(AdfDhtmlTableBasePeer._REMAIN_READ_ONLY, false, false, AdfUIComponent.PROPAGATE_ALWAYS);
    }
    if (!this._isPaged && component.getProperty("scrollTopRowKey") == null) {
      var attrs = this.GetFirstVisibleRowKeyAndRow();
      if (attrs.rowKey != null) {
        component.setProperty("scrollTopRowKey", attrs.rowKey, true, AdfUIComponent.PROPAGATE_ALWAYS);
      }
    }
    delete this._remainReadOnly;
    eventObj = this._queueFetchEvent(false, AdfTableDataFetchEvent.CLICK_EDIT_ACTIVE_ROW, -1, rowKey);
    if (oldActiveRowKey && eventObj) {
      eventObj.setOldClientKey(oldActiveRowKey);
      this._oldActiveRowKey = oldActiveRowKey;
    } else {
      if (!eventObj) {
        component.setProperty("_afrActiveRowKey", oldActiveRowKey, false, AdfUIComponent.PROPAGATE_ALWAYS);
        component.setProperty("activeRowKey", oldActiveRowKey, false, AdfUIComponent.PROPAGATE_ALWAYS);
      }
    }
  } finally {
    this._ignoreActiveRowKeyChange = false;
  }
  return eventObj;
};
AdfDhtmlTableBasePeer.prototype._restoreActiveRowKey = function() {
  this._ignoreActiveRowKeyChange = true;
  try {
    var component = this.getComponent();
    component.setProperty("_afrActiveRowKey", this._oldActiveRowKey, false, AdfUIComponent.PROPAGATE_NEVER);
    component.setProperty("activeRowKey", this._oldActiveRowKey, false, AdfUIComponent.PROPAGATE_NEVER);
    delete this._oldActiveRowKey;
  } finally {
    this._ignoreActiveRowKeyChange = false;
  }
};
AdfDhtmlTableBasePeer.prototype._getCellAndIndexForNode = function(node, tr) {
  var agent = AdfAgent.AGENT;
  var row = null;
  var rootElement = this.getDomElement();
  var innerTR = null;
  var cellIndex = -1;
  var cell = null;
  while (null != node && node != rootElement && cellIndex == -1) {
    if (agent.getNodeName(node) == "TD") {
      var parentNode = node.parentNode;
      if (parentNode == tr) {
        if (this._freezeColumnsToEnd()) {
          cellIndex = this._firstFrozen + this._indexOfDomElement(tr.cells, node) - 1;
        } else {
          cellIndex = this._indexOfDomElement(tr.cells, node);
        }
        cell = node;
        break;
      } else {
        if (this._hasFrozenColumn()) {
          if (innerTR == null) {
            innerTR = this._getNestedScrolledTable(tr).rows[0];
          }
          if (parentNode == innerTR) {
            if (this._freezeColumnsToStart()) {
              cellIndex = this._lastFrozen + this._indexOfDomElement(innerTR.cells, node) + 1;
            } else {
              if (this._freezeColumnsToEnd()) {
                cellIndex = this._indexOfDomElement(innerTR.cells, node);
              }
            }
            cell = node;
            break;
          }
        }
      }
      node = parentNode;
    } else {
      node = node.parentNode;
    }
  }
  return {cellIndex:cellIndex, cell:cell};
};
AdfDhtmlTableBasePeer.prototype._saveClickToEditRequest = function(targetNode, tr) {
  var params = this._getCellAndIndexForNode(targetNode, tr);
  var clickEditRequest = {};
  clickEditRequest.cellIndex = params.cellIndex;
  this._clickEditRequest = clickEditRequest;
};
AdfDhtmlTableBasePeer.prototype._processClickToEditRequest = function(selectRow) {
  var agent = AdfAgent.AGENT;
  var clickEditRequest = this._clickEditRequest;
  if (!clickEditRequest || clickEditRequest.cellIndex === -1) {
    return;
  }
  if (this._ignoreRowClick) {
    this._ignoreRowClick = false;
  }
  var rowKey = this._getActiveRowKey();
  this._lastCTEIndex = clickEditRequest ? clickEditRequest.cellIndex : undefined;
  if (!rowKey) {
    return;
  }
  var rowInfo = this.FindRowByKey(rowKey);
  if (!rowInfo) {
    return;
  }
  var row = rowInfo.tr;
  AdfAssert.assertDomElement(row);
  if (!clickEditRequest || clickEditRequest.activateCellType) {
    this._grabFocus();
    if (clickEditRequest && clickEditRequest.activateCellType == "last") {
      var cellIndex = this.__getVisibleLeafColumns().length - 1;
      while (cellIndex >= 0) {
        var elems = AdfDomUtils.getInputElementsInNode(this.FindCellByIndex(row, cellIndex));
        if (elems.length > 0) {
          AdfFocusUtils.focusElement(elems[elems.length - 1]);
          break;
        }
        cellIndex--;
      }
    } else {
      this._setFocusOnEditableElementInNode(agent, row);
    }
  } else {
    var cell = this.FindCellByIndex(row, clickEditRequest.cellIndex);
    AdfAssert.assertDomElement(cell);
    if (agent.getPlatform() == AdfAgent.IE_PLATFORM) {
      var focusElement = this._getFirstInputElementInNode(agent, cell);
      if (!focusElement) {
        focusElement = this._getFirstInputElementInNode(agent, row);
      }
      if (focusElement) {
        this._grabFocus();
      }
    } else {
      this._grabFocus();
    }
    if (this._setFocusOnEditableElementInNode(agent, cell) == null) {
      if (this._setFocusOnEditableElementInNode(agent, row) == null) {
        this._setFocusOnNode(cell);
      }
    }
  }
  if (selectRow && this._isRowSelectionEnabled() && !this._selIsSelected(rowKey)) {
    this._selUnselectAll();
    this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row);
    this._selSelectRow(rowKey, row);
  }
  if (this._clickEditRequest) {
    delete this._clickEditRequest;
  }
  if (this._processClickToEditRequestTimerId) {
    delete this._processClickToEditRequestTimerId;
  }
};
AdfDhtmlTableBasePeer.prototype._handleTabKey = function(target, domEvent) {
  var attrs = this.GetRowKeyAndRow(target, this.getDomElement());
  var shiftDown = domEvent.shiftKey;
  var propagate = true;
  if (attrs != null) {
    var row = attrs[1];
    if (row != null) {
      var params = this._getCellAndIndexForNode(target, row);
      var cell = params.cell;
      if (cell) {
        var cellIndex = params.cellIndex;
        if (!this._ctePatternStart && this._ctePatternStart != 0) {
          this._ctePatternStart = cellIndex;
        }
        if (this._isClickToEdit() && this._getActiveRowKey() != null) {
          var elems = AdfDomUtils.getInputElementsInNode(cell);
          var elemCount = elems.length;
          if (elemCount > 0) {
            if (!shiftDown && AdfDomUtils.isAncestorOrSelf(elems[elemCount - 1], target)) {
              if (this._hasDetailStamp) {
                var detailRow = row.nextSibling;
                if (detailRow && AdfAgent.AGENT.getAttribute(detailRow, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false)) {
                  elems = AdfDomUtils.getInputElementsInNode(detailRow);
                  if (elems.length > 0) {
                    return true;
                  }
                }
              }
              var columns = this.__getVisibleLeafColumns();
              var colCount = columns.length;
              var isLastEditable = cellIndex >= colCount - 1;
              if (!isLastEditable) {
                cellIndex++;
                while (cellIndex < colCount) {
                  elems = AdfDomUtils.getInputElementsInNode(this.FindCellByIndex(row, cellIndex));
                  if (elems.length > 0) {
                    break;
                  }
                  cellIndex++;
                }
                isLastEditable = cellIndex == colCount;
              }
              if (isLastEditable) {
                var editComponent = AdfRichUIPeer.getFirstAncestorComponent(target);
                if (editComponent) {
                  var editComponentPeer = editComponent.getPeer();
                  if (editComponentPeer.RunValidation) {
                    editComponentPeer.RunValidation(editComponent, target);
                  }
                }
                this._clickToEditActivateRow(attrs[0], true);
                propagate = !this._clickEditRequest;
              }
            } else {
              if (shiftDown && AdfDomUtils.isAncestorOrSelf(elems[0], target)) {
                var isFirstEditable = params.cellIndex == 0;
                if (!isFirstEditable) {
                  var cellIndex = params.cellIndex - 1;
                  while (cellIndex >= 0) {
                    elems = AdfDomUtils.getInputElementsInNode(this.FindCellByIndex(row, cellIndex));
                    if (elems.length > 0) {
                      break;
                    }
                    cellIndex--;
                  }
                  isFirstEditable = cellIndex == -1;
                }
                if (isFirstEditable) {
                  this._clickToEditActivateRow(attrs[0], false);
                  propagate = !this._clickEditRequest;
                }
              }
            }
          }
        } else {
          var columns = this.__getVisibleLeafColumns();
          var colCount = columns.length;
          var isNextCellEditable = shiftDown ? cellIndex == 0 && row.previousElementSibling && AdfFocusUtils.isTabStop(row.previousElementSibling) : cellIndex >= colCount - 1 && row.nextElementSibling && AdfFocusUtils.isTabStop(row.nextElementSibling);
          if (isNextCellEditable) {
            var destinationCell = shiftDown ? row.previousElementSibling.lastElementChild : row.nextElementSibling.firstElementChild;
            var attrs = this.GetRowKeyAndRow(destinationCell, this.getDomElement());
            this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, attrs[0], destinationCell);
          } else {
            var destinationCell = shiftDown ? cell.previousElementSibling : cell.nextElementSibling;
            if (destinationCell && AdfFocusUtils.isTabStop(destinationCell)) {
              this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, attrs[0], attrs[1], destinationCell);
            }
          }
        }
      }
    }
  } else {
    if (!shiftDown && this._hasDetailStamp && this._isClickToEdit()) {
      return this._handleTabKeyInCTEDetailRegion(target);
    }
  }
  return propagate;
};
AdfDhtmlTableBasePeer.prototype._handleTabKeyInCTEDetailRegion = function(target) {
  var outer = this.getDomElement();
  var parentRow = target.parentNode;
  var agent = AdfAgent.AGENT;
  var propagate = true;
  while (parentRow && parentRow != outer) {
    if (agent.getNodeName(parentRow) == "TR" && agent.getAttribute(parentRow, AdfDhtmlTableBasePeer._DETAIL_ROW_MARKER, false)) {
      elems = AdfDomUtils.getInputElementsInNode(parentRow);
      if (elems.length > 0 && elems[elems.length - 1] == target) {
        var rowKey = agent.getAttribute(parentRow.previousSibling, AdfDhtmlTableBasePeer._ROW_KEY);
        this._clickToEditActivateRow(rowKey, true);
        propagate = false;
      }
      break;
    }
    parentRow = parentRow.parentNode;
  }
  return propagate;
};
AdfDhtmlTableBasePeer.prototype._clickToEditActivateRow = function(curRowKey, isNext, cellIndex) {
  delete this._lastRowKeyInView;
  var attrs = isNext ? this._getNextRowKeyAndRow(curRowKey) : this._getPreviousRowKeyAndRow(curRowKey);
  if (!attrs.isAtTop) {
    var rowKey = attrs.rowKey;
    var lastRowKeyInView = attrs.lastRowKeyInView;
    if (rowKey != null) {
      this._setActiveRowKey(rowKey);
      this._selUnselectAll();
      var row = attrs.row;
      this._selSelectRow(rowKey, row);
      this._unclipRow(attrs.row);
      if (cellIndex != undefined) {
        this._clickEditRequest = {cellIndex:cellIndex};
      } else {
        this._clickEditRequest = {activateCellType:!isNext ? "last" : "first"};
      }
      var elem = AdfPage.PAGE.getActiveDomElement();
      var component = this.getComponent();
      var newActiveRowKey = component.getProperty("activeRowKey");
      if (curRowKey != newActiveRowKey && elem && elem.blur) {
        elem.blur();
      }
    } else {
      if (lastRowKeyInView != null) {
        var scroller = this.GetScroller();
        if (!this._hasSingleScroller() || this._isPaged) {
          scroller = scroller[AdfDhtmlTableBasePeer._VSCROLLER];
        }
        var scrollToPos = this._currentScrollTop + (isNext ? this._averageRowHeight : -this._averageRowHeight);
        if (scrollToPos > 0 && scrollToPos < this._getScrollHeight()) {
          this._lastRowKeyInView = lastRowKeyInView;
          if (this._getScrollerClientHeight() + scrollToPos < this._getScrollHeight()) {
            AdfAgent.AGENT.scrollToPos(scroller, null, scrollToPos);
            this._clickEditRequest = {activateRowType:isNext ? "next" : "previous"};
          }
        }
      }
    }
  }
  return attrs.rowKey != null;
};
AdfDhtmlTableBasePeer.prototype._processClickToEditActivateRequest = function() {
  var clickEditRequest = this._clickEditRequest;
  if (clickEditRequest && clickEditRequest.activateRowType) {
    var activateNextRow = clickEditRequest.activateRowType == "next";
    attrs = activateNextRow ? this._getNextRowKeyAndRow(this._lastRowKeyInView) : this._getPreviousRowKeyAndRow(this._lastRowKeyInView);
    clickEditRequest.activateCellType = activateNextRow ? "first" : "last";
    if (attrs.rowKey) {
      this._setActiveRowKey(attrs.rowKey);
    }
    delete this._lastRowKeyInView;
  }
};
AdfDhtmlTableBasePeer.prototype._restoreScrollPosition = function() {
  var component = this.getComponent();
  var scrollLeft = component.getScrollLeft();
  if (scrollLeft >= 0) {
    this.scrollToPos(scrollLeft, -1, true);
  }
};
AdfDhtmlTableBasePeer.prototype._unclipInputElem = function(elem) {
  var agent = AdfAgent.AGENT;
  var scroller = this.GetScroller();
  if (!scroller) {
    return;
  }
  var colIndex = this._getCellIndex(elem);
  if (this._hasFrozenColumn() && this._isColumnFrozen(colIndex)) {
    return;
  }
  if (!this._hasSingleScroller() || this._isPaged) {
    scroller = scroller[AdfDhtmlTableBasePeer._HSCROLLER];
  }
  var elemleft = agent.getElementLeft(elem);
  var scollerLeft = agent.getElementLeft(scroller);
  var rightClipped;
  if (AdfDhtmlTableBasePeer._isRTL()) {
    rightClipped = elemleft + elem.offsetWidth < scroller.scrollWidth - (this.__getScrollLeft() + scroller.clientWidth);
  } else {
    rightClipped = elemleft + elem.offsetWidth > scollerLeft + scroller.clientWidth;
  }
  if (rightClipped) {
    var scrollPos = this._currentScrollLeft + (elem.offsetWidth + elemleft - (scollerLeft + scroller.clientWidth));
    agent.scrollToPos(scroller, scrollPos, null);
    return;
  }
};
AdfDhtmlTableBasePeer.prototype.scrollColumnIntoView = function(columnId, column) {
  AdfAssert.assert(columnId != null || column != null);
  var agent = AdfAgent.AGENT;
  if (!column) {
    column = agent.getElementById(columnId);
    if (!column) {
      return;
    }
  }
  var displayIndex = agent.getIntAttribute(column, "_d_index", -1);
  if (this._isColumnFrozen(displayIndex)) {
    return;
  }
  var scroller = this.GetScroller();
  if (!this._hasSingleScroller() || this._isPaged) {
    scroller = scroller[AdfDhtmlTableBasePeer._HSCROLLER];
  }
  var scrollToPos = column.offsetLeft;
  if (scrollToPos == this._currentScrollLeft) {
    return;
  }
  var animDuration = this._colScrollAnimationDuration;
  if (animDuration == undefined) {
    var page = AdfPage.PAGE;
    if (page.isAnimationEnabled()) {
      animDuration = parseInt(page.getLookAndFeel().getSkinProperty("af|table-tr-column-scroll-animation-duration"));
    } else {
      animDuration = 0;
    }
    this._colScrollAnimationDuration = animDuration;
  }
  if (animDuration > 0) {
    AdfDhtmlElementAnimator.animate(AdfDhtmlElementAnimator.FRAME_METHOD_SLOW_FAST_SLOW, animDuration, [{element:scroller, properties:{"scrollLeft":scrollToPos}}], null, null, null);
  } else {
    agent.scrollToPos(scroller, scrollToPos, null);
  }
};
AdfDhtmlTableBasePeer.prototype.getRowIndex = function(rowKey) {
  AdfAssert.assertString(rowKey);
  AdfAssert.assert(rowKey != null, "Row Key cannot be null");
  var index = -1;
  var rowInfo = this.FindRowByKey(rowKey);
  if (rowInfo) {
    index = rowInfo.index;
  }
  return index;
};
AdfDhtmlTableBasePeer.prototype.getRowKey = function(index) {
  AdfAssert.assertNumber(index);
  AdfAssert.assert(index >= 0, "index must be greater than or equal to 0");
  var rowKey = null;
  var dataBody = this.GetDataBody();
  var blockList = dataBody.childNodes;
  var numBlocks = blockList.length;
  for (var i = 0;i < numBlocks;i++) {
    var block = blockList[i];
    var startRow = block.startRow;
    if (index >= startRow && index < startRow + block.numRows) {
      var rows = block.rows;
      var rowOffset = index - startRow;
      for (var j = 0, rowCount = 0;j < rows.length;j++) {
        var row = rows[j];
        rowKey = AdfAgent.AGENT.getAttribute(row, AdfDhtmlTableBasePeer._ROW_KEY);
        if (rowKey) {
          if (rowCount == rowOffset) {
            break;
          }
          ++rowCount;
        }
      }
    }
  }
  return rowKey;
};
AdfDhtmlTableBasePeer.prototype._clearColumnSelectionEventAddedSet = function() {
  this._colSelEventSelectedColIds = {};
};
AdfDhtmlTableBasePeer.prototype._clearColumnSelectionEventRemovedSet = function() {
  this._colSelEventUnselectedColIds = {};
};
AdfDhtmlTableBasePeer.prototype._clearColumnSelectionEventChangedSets = function() {
  this._colSelEventSelectedColIds = {};
  this._colSelEventUnselectedColIds = {};
};
AdfDhtmlTableBasePeer.prototype._hasColumnSelectionEventChangedSets = function() {
  return !AdfCollections.isEmpty(this._colSelEventSelectedColIds) || !AdfCollections.isEmpty(this._colSelEventUnselectedColIds);
};
AdfDhtmlTableBasePeer.prototype._queueColumnSelectionEvent = function() {
  if (this._hasColumnSelectionEventChangedSets()) {
    var component = this.getComponent();
    AdfTableUtils.queueColumnSelectionEvent(component, this._colSelEventSelectedColIds, this._colSelEventUnselectedColIds);
    this._clearColumnSelectionEventChangedSets();
  }
};
AdfDhtmlTableBasePeer.prototype.ConvertClientIdToLocator = function(component, childComponent, descComponentClientId, replaceArray) {
  var header = this.__getColumnHeader();
  if (header) {
    var childNode = childComponent.getPeer().getDomElement();
    if (childNode && AdfDomUtils.isAncestor(header, childNode)) {
      return;
    }
  }
  var clientId = component.getClientId();
  var clientIdDepth = AdfStrings.count(clientId, ":");
  AdfAssert.assert(descComponentClientId.indexOf(clientId) >= 0);
  var subComponentId = descComponentClientId.substring(clientId.length + 1);
  var endIndex = subComponentId.indexOf(":");
  if (endIndex > 0) {
    var rowKey = subComponentId.substring(0, endIndex);
    var rowInfo = this.FindRowByKey(rowKey);
    replaceArray.push([clientIdDepth + 1, rowInfo ? rowInfo.index : null]);
  }
};
AdfDhtmlTableBasePeer.prototype.convertLocatorToClientId = function(component, rowIndex) {
  var clientId = component.getClientId();
  var rowKey = this.getRowKey(rowIndex);
  return rowKey ? clientId + ":" + rowKey : null;
};
AdfDhtmlTableBasePeer.prototype._computeAutoHeight = function() {
  var agent = AdfAgent.AGENT;
  var autoHeight = 0;
  var autoHeightRows = this._autoHeightRows;
  if (autoHeightRows > 0) {
    var isGecko = agent.getPlatform() == AdfAgent.GECKO_PLATFORM;
    var isIE = agent.getPlatform() == AdfAgent.IE_PLATFORM;
    var attrs = this.GetFirstVisibleRowKeyAndRow();
    var firstVisibleRow = attrs.row;
    if (firstVisibleRow) {
      var dataBody = this.GetDataBody();
      var dataTables = dataBody.childNodes;
      var tableCount = dataTables.length;
      var visibleRows = 0;
      var tableIndex = 0;
      for (var i = 0;i < tableCount && visibleRows < autoHeightRows;i++) {
        tableIndex = i;
        var table = dataTables[i];
        var rows = table.rows;
        var rowCount = 0;
        if (rows != null) {
          rowCount = rows.length;
        }
        if (isIE && this.getComponent().getProperty("scrollPolicy") == "page") {
          autoHeight = table.offsetHeight;
        } else {
          for (var j = 0;j < rowCount && visibleRows < autoHeightRows;j++) {
            if (firstVisibleRow === rows[j] || visibleRows > 0) {
              visibleRows++;
              var height;
              if (isGecko) {
                var currentStyle = agent.getComputedStyle(rows[j]);
                height = parseFloat(currentStyle.height);
              } else {
                if (isIE) {
                  height = rows[j].getBoundingClientRect().height;
                } else {
                  height = rows[j].offsetHeight;
                }
              }
              autoHeight += height;
            }
          }
        }
      }
    }
    if (visibleRows != autoHeightRows && visibleRows > 0) {
      var beforeVisible = false;
      for (var i = tableIndex;i >= 0;i--) {
        var table = dataTables[i];
        var rows = table.rows;
        var rowCount = 0;
        if (rows != null) {
          rowCount = rows.length;
        }
        for (var j = rowCount - 1;j >= 0 && visibleRows < autoHeightRows;j--) {
          if (firstVisibleRow === rows[j]) {
            beforeVisible = true;
            continue;
          }
          if (beforeVisible) {
            visibleRows++;
            var height;
            if (isGecko) {
              var currentStyle = agent.getComputedStyle(rows[j]);
              height = parseFloat(currentStyle.height);
            } else {
              height = rows[j].offsetHeight;
            }
            autoHeight += height;
          }
        }
      }
    }
  }
  return isGecko ? Math.round(autoHeight) : autoHeight;
};
AdfDhtmlTableBasePeer.prototype._setOuterHeightForBodyHeight = function(bodyHeight) {
  var container = this.getDomElement();
  var scrollbarHeight = this._getScrollbarHeight();
  var newHeight = bodyHeight + this._cachedCHHeight + this._cachedCFHeight + this._cachedNBHeight + scrollbarHeight;
  this._sizeOuterContainer(container, newHeight);
  if (!this.IsEmpty) {
    var agent = AdfAgent.getAgent();
    var isIE = agent.getPlatform() == AdfAgent.IE_PLATFORM;
    this._restoreHorizontalScrollBarForIE8();
    this._setScrollerHeight(newHeight, this._cachedCHHeight, this._cachedCFHeight, this._cachedNBHeight);
    scrollbarHeight = this._getScrollbarHeight();
    this._setScrollerWidth(container.clientWidth, this._frozenWidth);
    if (isIE && agent.getVersion() < 8) {
      this._setFakeCanvasHeight(this._canvasHeight);
    }
    var newSbh = this._getScrollbarHeight();
    if (scrollbarHeight != newSbh) {
      newHeight = bodyHeight + this._cachedCHHeight + this._cachedCFHeight + newSbh;
      this._sizeOuterContainer(container, newHeight);
      this._setScrollerHeight(newHeight, this._cachedCHHeight, this._cachedCFHeight, this._cachedNBHeight);
    }
    this.SizeDataBody(this.GetDataBody(), container.clientWidth, container.clientHeight);
  }
};
AdfDhtmlTableBasePeer.prototype._sizeOuterContainer = function(container, newHeight) {
  var agent = AdfAgent.AGENT;
  if (agent.getBoxSizing(container) == "border-box") {
    var cssLengthAsInt = AdfAgent.getCSSLengthAsInt;
    var currentStyle = agent.getComputedStyle(container);
    newHeight = newHeight + cssLengthAsInt(currentStyle.paddingTop) + cssLengthAsInt(currentStyle.paddingBottom) + cssLengthAsInt(currentStyle.marginTop) + cssLengthAsInt(currentStyle.marginBottom) + cssLengthAsInt(currentStyle.borderTopWidth) + cssLengthAsInt(currentStyle.borderBottomWidth);
  }
  container.style.height = newHeight + "px";
  if (container.style.minHeight && parseFloat(container.style.minHeight) > newHeight) {
    container.style.minHeight = newHeight + "px";
  }
};
AdfDhtmlTableBasePeer.prototype.AdjustAutoHeight = function() {
  var pcPeer = this.GetPanelCollectionPeer();
  var dataBody = this.GetDataBody();
  var container = this.getDomElement();
  var clientHeight = container.clientHeight;
  if (pcPeer && pcPeer.isDetached()) {
    this.__fixPanelCollectionDimensions(true);
    this.SizeDataBody(dataBody, container.clientWidth, clientHeight);
    if (!this.IsEmpty) {
      this._setScrollerHeight(clientHeight, this._cachedCHHeight, this._cachedCFHeight, this._cachedNBHeight);
    }
  } else {
    if (this.isHeightAutoSized() && !this.BusyAnimating()) {
      var attrs = this.GetFirstVisibleRowKeyAndRow();
      var bodyHeight;
      if (!this.IsEmpty) {
        bodyHeight = this._computeAutoHeight();
        if (bodyHeight === 0 && !attrs.rowKey) {
          bodyHeight = dataBody.offsetHeight;
        }
      } else {
        bodyHeight = dataBody.offsetHeight;
      }
      var agent = AdfAgent.AGENT;
      var isIE8 = agent.getPlatform() == AdfAgent.IE_PLATFORM && agent.getVersion() < 9 && agent.getVersion() > 7;
      if (this.IsEmpty || bodyHeight != dataBody.offsetHeight || isIE8 && this.GetRowCount() < 2) {
        this._setOuterHeightForBodyHeight(bodyHeight);
        var newClientHeight = container.clientHeight;
        if (pcPeer) {
          this.__fixPanelCollectionDimensions(false);
        }
        if (clientHeight != newClientHeight) {
          var adfPage = AdfPage.PAGE;
          adfPage.scheduleTimer(adfPage, adfPage.doResizeNotify, null, 0, {"isSynchronized":true});
        }
      }
      this._checkAutoHeightScrollbar(dataBody);
      if (!this._stretchingTheColumns && !this._desendentResizeQueued) {
        this._doStretch();
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype._queueDescendantResize = function() {
  if (this._desendentResizeQueued) {
    return;
  }
  this._desendentResizeQueued = true;
  try {
    AdfPage.PAGE.__queueDescendantResizeNotifySource(this.getComponent());
    AdfPage.PAGE.__doDescendantResizeNotify();
  } finally {
    delete this._desendentResizeQueued;
  }
};
AdfDhtmlTableBasePeer.prototype._doStretch = function(p) {
  var oldWidth = this._totalWidth;
  this._stretchTheColumns();
  var newWidth = this._totalWidth;
  if (newWidth != oldWidth) {
    this._queueDescendantResize();
  }
  return -1;
};
AdfDhtmlTableBasePeer.prototype._checkAutoHeightScrollbar = function(dataBody) {
  var blockList = dataBody.childNodes;
  var autoHeightRows = this._autoHeightRows;
  var numBlocks = blockList.length;
  var totalRowCount = this._getRowCountWithDisclosedDetailStampRow(dataBody);
  if (this._allRowsAvailableOnClient(blockList, numBlocks) && totalRowCount <= autoHeightRows) {
    var scrollerHeight = this._getScrollerClientHeight();
    if (scrollerHeight != this._canvasHeight) {
      this._canvasHeight = scrollerHeight;
      this._setFakeCanvasHeight(scrollerHeight);
      var container = this.getDomElement();
      this._setScrollerWidth(container.clientWidth, this._frozenWidth);
      this.SizeDataBody(dataBody, container.clientWidth, container.clientHeight);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._getRowCountWithDisclosedDetailStampRow = function(dataBody) {
  var rowCount = 0;
  if (this._hasDetailStamp) {
    var blockList = dataBody.childNodes;
    var numBlocks = blockList.length;
    for (var b = 0;b < numBlocks;b++) {
      var rows = null;
      if (null != blockList[b]) {
        rows = blockList[b].rows;
      }
      if (null != rows) {
        rowCount += rows.length;
      }
    }
  } else {
    rowCount = this.GetRowCount();
  }
  return rowCount;
};
AdfDhtmlTableBasePeer._maxMessageType = function(clientId) {
  AdfAssert.assertString(clientId);
  var messages = AdfPage.PAGE.getMessages(clientId);
  var messageType = AdfFacesMessage.TYPE_INFO;
  for (var i = 0;i < messages.length;i++) {
    messageType = Math.max(messageType, AdfFacesMessage.getTypeFromMessage(messages[i]));
  }
  return messageType;
};
AdfDhtmlTableBasePeer.prototype._getRTLScrollAdjustment = function() {
  var agent = AdfAgent.getAgent();
  var platform = agent.getPlatform();
  if (platform == AdfAgent.IE_PLATFORM && agent.getVersion() > 7 || platform == AdfAgent.WEBKIT_PLATFORM) {
    var scroller = this.GetScroller();
    if (!this._footerless || this._isPaged) {
      scroller = scroller[AdfDhtmlTableBasePeer._HSCROLLER];
    }
    return scroller.scrollWidth - scroller.clientWidth - this._currentScrollLeft;
  } else {
    return this._currentScrollLeft;
  }
};
AdfDhtmlTableBasePeer.prototype.DescendantMessageChanged = function() {
  var domElement = this.getDomElement();
  var agent = AdfAgent.AGENT;
  var component = this.getComponent();
  var clientId = component.getClientId();
  var rowKeysWithMessages = this._rowKeysWithMessages;
  if (!rowKeysWithMessages) {
    this._rowKeysWithMessages = rowKeysWithMessages = new Array;
  }
  var clientIdsWithMessages = AdfPage.PAGE.getClientIdsWithMessages(clientId);
  var newExistingBitSet = {};
  var rowHeaderCache = {};
  for (var i = 0;i < clientIdsWithMessages.length;i++) {
    var clientIdWithMessages = clientIdsWithMessages[i];
    var maxMessageType = AdfDhtmlTableBasePeer._maxMessageType(clientIdWithMessages);
    var target = agent.getElementById(clientIdWithMessages);
    if (!target) {
      continue;
    }
    var attrs = this.GetRowKeyAndRow(target, domElement);
    if (!attrs) {
      continue;
    }
    var rowKey = attrs[0];
    var row = attrs[1];
    var rowHeaderDom = this.GetRowHeaderCellFromRow(row);
    if (!rowHeaderDom) {
      continue;
    }
    var n = AdfCollections.indexOf(rowKeysWithMessages, rowKey);
    if (n == -1) {
      n = rowKeysWithMessages.push(rowKey) - 1;
    }
    newExistingBitSet[n] = Math.max(maxMessageType, !newExistingBitSet[n] ? -1 : newExistingBitSet[n]);
    rowHeaderCache[n] = rowHeaderDom;
  }
  for (var i = rowKeysWithMessages.length - 1;i > -1;i--) {
    var rowKey = rowKeysWithMessages[i];
    if (!newExistingBitSet[i]) {
      var rowInfo = this.FindRowByKey(rowKey);
      if (!rowInfo) {
        AdfCollections.removeArrayKey(rowKeysWithMessages, i);
        continue;
      }
      var rowHeaderDom = this.GetRowHeaderCellFromRow(rowInfo.tr);
      if (!rowHeaderDom) {
        continue;
      }
      var lastMessageType = agent.getExpandoProperty(rowHeaderDom, AdfDhtmlTableBasePeer._MAX_ROWHEADER_MSGTYPE_EXPANDO, -1);
      AdfMessageUtils.removeCSSClassName(rowHeaderDom, lastMessageType);
      agent.setExpandoProperty(rowHeaderDom, AdfDhtmlTableBasePeer._MAX_ROWHEADER_MSGTYPE_EXPANDO, -1);
      AdfCollections.removeArrayKey(rowKeysWithMessages, i);
    } else {
      var rowHeaderDom = rowHeaderCache[i];
      var lastMessageType = agent.getExpandoProperty(rowHeaderDom, AdfDhtmlTableBasePeer._MAX_ROWHEADER_MSGTYPE_EXPANDO, -1);
      var messageType = newExistingBitSet[i];
      if (lastMessageType != messageType) {
        if (lastMessageType > -1) {
          AdfMessageUtils.removeCSSClassName(rowHeaderDom, lastMessageType);
        }
        agent.setExpandoProperty(rowHeaderDom, AdfDhtmlTableBasePeer._MAX_ROWHEADER_MSGTYPE_EXPANDO, messageType);
        AdfMessageUtils.addCSSClassName(rowHeaderDom, messageType);
      }
    }
  }
};
AdfDhtmlTableBasePeer.prototype.ApplyTooltipTitle = function(target) {
  var onlyTextNode = this._getOnlyTextNode(target);
  if (onlyTextNode && this._isCellTruncated(target)) {
    target.setAttribute("title", onlyTextNode.nodeValue);
  }
};
AdfDhtmlTableBasePeer.prototype._getParentMatchingId = function(domElem, id) {
  var target = domElem;
  var elem = null;
  var rootElem = this.getDomElement();
  while (!elem && target && target != rootElem.parent && target.nodeType == 1) {
    if (target.id && target.id.indexOf(id) >= 0) {
      elem = target;
      break;
    } else {
      target = target.parentNode;
    }
  }
  return elem;
};
AdfDhtmlTableBasePeer.prototype._resizeNavBar = function(newWidth, newHeight) {
  var shouldResize = false;
  if (newWidth < this._cachedNBWidth && !this._nbarMin) {
    this._nbarMin = true;
    shouldResize = true;
  } else {
    if (newWidth >= this._cachedNBWidth && this._nbarMin) {
      this._nbarMin = false;
      shouldResize = true;
    }
  }
  if (shouldResize) {
    var agent = AdfAgent.AGENT;
    var component = this.getComponent();
    var clientId = component.getClientId();
    var nbarrngtxtId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlTableBasePeer._NAVBAR_RANGE_TEXT);
    var nbarrngtxt = agent.getElementById(nbarrngtxtId);
    var nbarpgcntId = AdfRichUIPeer.CreateSubId(clientId, AdfDhtmlTableBasePeer._NAVBAR_PAGE_CNT);
    var nbarpgcnt = agent.getElementById(nbarpgcntId);
    if (this._nbarMin) {
      nbarpgcnt.style.display = "none";
      nbarrngtxt.style.display = "none";
    } else {
      nbarpgcnt.style.display = "";
      nbarrngtxt.style.display = "";
    }
  }
};
AdfDhtmlTableBasePeer.prototype.__handleNavBarItemsClick = function(domEvent, target) {
  var isClicked = false;
  if (this._isNavBarLink(target, AdfDhtmlTableBasePeer._NAVBAR_PREVIOUS)) {
    if (!(this._isLinkDisabled(target) > -1)) {
      this._handlePrevClick(domEvent);
      isClicked = true;
    }
  } else {
    if (this._isNavBarLink(target, AdfDhtmlTableBasePeer._NAVBAR_NEXT)) {
      if (!(this._isLinkDisabled(target) > -1)) {
        this._handleNextClick(domEvent);
        isClicked = true;
      }
    } else {
      if (this._isNavBarLink(target, AdfDhtmlTableBasePeer._NAVBAR_FIRST)) {
        if (!(this._isLinkDisabled(target) > -1)) {
          this._handleFirstClick(domEvent);
          isClicked = true;
        }
      } else {
        var navbarPageRow = this._getNavBarPageRow(target, AdfDhtmlTableBasePeer._NAVBAR_LAST);
        if (navbarPageRow != null) {
          if (!(this._isLinkDisabled(target) > -1)) {
            this._handlePageRowClick(navbarPageRow, domEvent);
            isClicked = true;
          }
        } else {
          navbarPageRow = this._getNavBarPageRow(target, AdfDhtmlTableBasePeer._NAVBAR_PAGE);
          if (navbarPageRow != null) {
            this._handlePageRowClick(navbarPageRow, domEvent);
            isClicked = true;
          }
        }
      }
    }
  }
  if (isClicked) {
    AdfDomUtils.addCSSClassName(target, "p_AFActivated");
  }
};
AdfDhtmlTableBasePeer.prototype._isLinkDisabled = function(element) {
  var className = element.className;
  var indexOfDisableStr = className.indexOf("p_AFDisabled");
  return indexOfDisableStr;
};
AdfDhtmlTableBasePeer.prototype.__handleLoadMoreItemsClick = function(domEvent, target) {
  var component = this.getComponent();
  var targetId = target.id;
  if (targetId == AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlTableBasePeer._LOAD_MORE_BOTTOM_LINK)) {
    this._loadMoreFetch(true);
  } else {
    if (targetId == AdfRichUIPeer.CreateSubId(component.getClientId(), AdfDhtmlTableBasePeer._LOAD_MORE_TOP_LINK)) {
      this._loadMoreFetch(false);
    }
  }
};
AdfDhtmlTableBasePeer.prototype._loadMoreFetch = function(bottom) {
  var databody = this.GetDataBody();
  var blockList = databody.childNodes;
  var numBlocks = blockList.length;
  if (bottom) {
    var lastBlock = blockList[numBlocks - 1];
    var newStart = lastBlock.startRow + lastBlock.numRows;
    var rowCount = this.GetRowCount();
    if (rowCount > 0 && newStart < rowCount || rowCount < 0) {
      var index = newStart - 1;
      var key = this._getBlockLastRowKey(lastBlock);
      this._startFetch(AdfTableDataFetchEvent.AFTER_KEY_SUBTYPE, index, key, null, false);
    }
  } else {
    var firstBlock = blockList[0];
    var index = firstBlock.startRow;
    var key = this._getBlockFirstRowKey(firstBlock);
    this._startFetch(AdfTableDataFetchEvent.BEFORE_KEY_SUBTYPE, index, key, null, false);
  }
};
AdfDhtmlTableBasePeer.prototype._updateLoadMoreItemsRangeText = function(start, end, rowCount, top) {
  if (this._isImplicitLoadMore) {
    return;
  }
  var laf = AdfPage.PAGE.getLookAndFeel();
  var component = this.getComponent();
  var loadMoreDiv = this._getLoadMore(top);
  var loadMoreRngId = AdfRichUIPeer.CreateSubId(component.getClientId(), top ? AdfDhtmlTableBasePeer._LOAD_MORE_RNG_TOP_TEXT : AdfDhtmlTableBasePeer._LOAD_MORE_RNG_BOTTOM_TEXT);
  start = parseInt(start) + 1;
  var nodes = loadMoreDiv.childNodes[0].childNodes;
  for (var i = 0;i < nodes.length;i++) {
    if (nodes[i].id != null && nodes[i].id.indexOf(loadMoreRngId) != -1) {
      var rngText = null;
      if (this.GetRowCount() > 0 && rowCount > 0) {
        rngText = laf.getTranslatedString("af_table.LABEL_ITEM_RANGE_KNOWN_COUNT", new String(start), new String(end), new String(rowCount));
      } else {
        rngText = laf.getTranslatedString("af_table.LABEL_ITEM_RANGE_UNKNOWN_COUNT", new String(start), new String(end));
      }
      nodes[i].childNodes[0].nodeValue = rngText;
      break;
    }
  }
};
AdfDhtmlTableBasePeer.prototype.GetFirst = function() {
  return this.getComponent().getFirst();
};
AdfDhtmlTableBasePeer.prototype.RegisterFirstPropertyChange = function() {
  AdfRichUIPeer.addComponentPropertyChanges(AdfDhtmlTablePeer, "first");
};
AdfDhtmlTableBasePeer.prototype.GetRows = function() {
  return this.getComponent().getRows();
};
AdfDhtmlTableBasePeer.prototype.ComponentFirstChanged = function(component, domElement, newValue, oldValue) {
  this.QueueRangeChangeEvent(oldValue, newValue);
  if (this._isPaged) {
    AdfPage.PAGE.addPartialTargets(component);
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype.ComponentRowsChanged = function(component, domElement, newValue, oldValue) {
  AdfRangeChangeEvent.queue(component, parseInt(0).toString(), parseInt(oldValue).toString(), parseInt(0).toString(), parseInt(newValue).toString());
  if (this._isPaged) {
    AdfPage.PAGE.addPartialTargets(component);
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype.QueueRangeChangeEvent = function(oldValue, newValue) {
  var component = this.getComponent();
  var rows = parseInt(this.GetRows());
  var oldStart = parseInt(oldValue);
  var oldEnd = oldStart + rows - 1;
  var newStart = parseInt(newValue);
  var newEnd = newStart + rows - 1;
  AdfRangeChangeEvent.queue(component, oldStart.toString(), oldEnd.toString(), newStart.toString(), newEnd.toString());
};
AdfDhtmlTableBasePeer.prototype._isNavBarLink = function(target, suffixId) {
  var linkId = AdfRichUIPeer.CreateSubId(this.getComponent().getClientId(), suffixId);
  return null != this._getParentMatchingId(target, linkId);
};
AdfDhtmlTableBasePeer.prototype._getNavBarPageRow = function(target, suffixId) {
  var linkId = AdfRichUIPeer.CreateSubId(this.getComponent().getClientId(), suffixId);
  var elem = this._getParentMatchingId(target, linkId);
  if (elem != null) {
    return elem.id.substring(linkId.length);
  }
};
AdfDhtmlTableBasePeer.prototype._handlePrevClick = function(domEvent) {
  var first = parseInt(this.GetFirst());
  var rows = parseInt(this.GetRows());
  first -= rows;
  first = Math.max(first, 0);
  this.QueueRangeChangeEvent(this.GetFirst(), first);
  AdfPage.PAGE.addPartialTargets(this.getComponent());
  AdfAgent.AGENT.eatEvent(domEvent);
};
AdfDhtmlTableBasePeer.prototype._handleFirstClick = function(domEvent) {
  this.QueueRangeChangeEvent(this.GetFirst(), 0);
  AdfPage.PAGE.addPartialTargets(this.getComponent());
  AdfAgent.AGENT.eatEvent(domEvent);
};
AdfDhtmlTableBasePeer.prototype._handleNextClick = function(domEvent) {
  var first = parseInt(this.GetFirst());
  var rows = parseInt(this.GetRows());
  first += rows;
  this.QueueRangeChangeEvent(this.GetFirst(), first);
  AdfPage.PAGE.addPartialTargets(this.getComponent());
  AdfAgent.AGENT.eatEvent(domEvent);
};
AdfDhtmlTableBasePeer.prototype._handlePageRowClick = function(row, domEvent) {
  this.QueueRangeChangeEvent(this.GetFirst(), row);
  AdfPage.PAGE.addPartialTargets(this.getComponent());
  AdfAgent.AGENT.eatEvent(domEvent);
};
AdfDhtmlTableBasePeer.prototype.setBusy = function(component, isBusy) {
  if (AdfAgent.AGENT.supportsTransientStyleClasses()) {
    AdfDhtmlTableBasePeer.superclass.setBusy.call(this, component, isBusy);
  }
};
AdfDhtmlTableBasePeer.prototype.setSelectedRowKeysWithoutEvent = function(keys) {
  this.suppressSelectionEventDelivery(true);
  this.getComponent().setSelectedRowKeys(keys);
  this.suppressSelectionEventDelivery(false);
};
AdfDhtmlTableBasePeer.prototype._addScrollEventListeners = function(dataBody) {
  var agent = AdfAgent.AGENT;
  var platform = agent.getPlatform();
  if (platform == AdfAgent.IE_PLATFORM && agent.getVersion() > 8 || platform == AdfAgent.GECKO_PLATFORM && agent.getVersion() >= 17) {
    dataBody.addEventListener("wheel", AdfDhtmlTableBasePeer._handleMouseWheel, true);
  } else {
    dataBody.onmousewheel = AdfDhtmlTableBasePeer._handleMouseWheel;
  }
  if (platform != AdfAgent.IE_PLATFORM) {
    dataBody.addEventListener("DOMMouseScroll", AdfDhtmlTableBasePeer._handleMouseWheel, true);
  }
  dataBody.onscroll = this.createCallback(this._handleDataBodyScroll);
  if (AdfAgent.guessOS() == AdfAgent.ANDROID_OS) {
    var agentName = navigator.userAgent.toLowerCase();
    if (agentName.indexOf("chrome") > -1) {
      this._touchMoveManager = agent.createTouchMoveManager(dataBody, this.createCallback(this._handleTouchMovement), 1);
    }
  }
  if (this._isIOS13OrLater()) {
    this._touchMoveManager = agent.createTouchMoveManager(dataBody, this.createCallback(this._handleTouchMovement), 1);
  }
  this._handleTouchEndCallback = this.createCallback(this._handleTouchEnd);
  agent.addBubbleEventListener(dataBody, "touchend", this._handleTouchEndCallback);
  var colHead = this.__getColumnHeader();
  if (colHead) {
    agent.addBubbleEventListener(colHead, "touchend", this._handleTouchEndCallback);
  }
};
AdfDhtmlTableBasePeer.prototype._handleTouchEnd = function(event) {
  event._insideADFTable = 1;
};
AdfDhtmlTableBasePeer.prototype._isIOS13OrLater = function() {
  return AdfAgent.AGENT.getTypeName() == "AdfSafariMobileAgent" && parseFloat(AdfAgent.AGENT.getVersion()) >= 13 && AdfAgent.AGENT.getOS() == "Mac" || "AdfSafariAgent" && parseFloat(AdfAgent.AGENT.getVersion()) >= 13 && AdfAgent.AGENT.getOS() == "Mac" && this._isTouch;
};
AdfDhtmlTableBasePeer.prototype._processColGroup = function() {
  return true;
};
AdfDhtmlTableBasePeer._findHiddenLabel = function(componentElement) {
  if (componentElement.id) {
    var contentId = AdfRichUIPeer.CreateSubId(componentElement.id, AdfDhtmlEditableValuePeer._CONTENT_ID);
    var contentNode = AdfAgent.AGENT.getElementById(contentId);
    if (contentNode) {
      var sibling = contentNode.nextElementSibling;
      if (sibling && sibling.nodeName == "LABEL" && sibling.htmlFor == contentId) {
        return sibling;
      }
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.msgMap = {"update":"AFActiveDataTableRowUpdate", "remove":"AFActiveDataTableRowDelete"};
AdfDhtmlTableBasePeer.prototype.preventSwitchToEditableMode = function() {
  this._remainReadOnly = true;
};
AdfDhtmlTableBasePeer.prototype.isInteger = function(value) {
  return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
};
AdfDhtmlTableBasePeer.prototype._getNextColumnFooterFocusElement = function(domElement) {
  var agent = AdfAgent.AGENT;
  if (domElement) {
    var nextSibling = this._getSiblingDomNode(domElement, true);
    var parentCol = this._resolveImmediateParentColumn(domElement), siblingParent = parentCol;
    while (!nextSibling && siblingParent) {
      if ((nextSibling = this._getSiblingDomNode(parentCol, true)) != null) {
        siblingParent = this._resolveImmediateParentColumn(nextSibling);
      } else {
        siblingParent = null;
      }
    }
    if (nextSibling) {
      var nextSiblingParent = nextSibling ? this._resolveImmediateParentColumn(nextSibling) : null;
      if (nextSiblingParent != parentCol) {
        var parentCol = this._resolveImmediateParentColumn(nextSibling);
        if (parentCol) {
          return parentCol;
        }
      }
      return nextSibling;
    }
    var displayIndex = agent.getIntAttribute(domElement, "_d_index", -1);
    if (this._hasFrozenColumn() && this._isColumnFrozen(displayIndex)) {
      var footerDiv = this._getColumnFooter();
      var nestedDiv = AdfDhtmlTableBasePeer.__getChildBySubId(footerDiv, "fd2");
      var table = AdfDhtmlTableBasePeer.__getChildBySubId(nestedDiv, "ft2");
      return table.rows[1].cells[0];
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._getPrevColumnFooterFocusElement = function(domElement) {
  if (domElement) {
    var agent = AdfAgent.AGENT;
    var parentCol = this._resolveImmediateParentColumn(domElement);
    if (parentCol && parentCol.nodeName == "TH") {
      return null;
    }
    var previousSibling = this._getSiblingDomNode(domElement, false);
    var previousSiblingParent = previousSibling ? this._resolveImmediateParentColumn(previousSibling) : null;
    var siblingParent = parentCol;
    while (!previousSibling && siblingParent) {
      if ((previousSibling = this._getSiblingDomNode(parentCol, false)) != null) {
        siblingParent = this._resolveImmediateParentColumn(previousSibling);
      } else {
        siblingParent = null;
      }
    }
    if (parentCol != null && parentCol != previousSiblingParent && !this._isTargetCellFilter(parentCol)) {
      return parentCol;
    } else {
      if (previousSibling != null) {
        return this._resolveBotttomMostChildColumn(previousSibling);
      }
    }
    var displayIndex = agent.getIntAttribute(domElement, "_d_index", -1);
    if (this._hasFrozenColumn()) {
      var footerDiv = this._getColumnFooter();
      var table = AdfDhtmlTableBasePeer.__getChildBySubId(footerDiv, "ft");
      if (table && table.rows) {
        var cells = table.rows[1].cells, cellCount = cells.length;
        if (cellCount > 0) {
          return this._resolveBotttomMostChildColumn(cells[cellCount - 1]);
        }
      }
    }
  }
  return null;
};
AdfDhtmlTableBasePeer.prototype._setIndexedColumnFooterFocus = function(selectAllOnly, skipUnclip, index) {
  if (!this._footerless) {
    return this._setFirstColumnFooterFocus(selectAllOnly, skipUnclip, index);
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype._setFirstColumnFooterFocus = function(selectAllOnly, skipUnclip, index) {
  if (!this._footerless) {
    var footerDiv = this._getColumnFooter();
    if (footerDiv == null) {
      return false;
    }
    var table = AdfDhtmlTableBasePeer.__getChildBySubId(footerDiv, "ft");
    var cell = table.rows[1].cells[index];
    if (this._hasFrozenColumn() && !cell) {
      var nestedDiv = AdfDhtmlTableBasePeer.__getChildBySubId(footerDiv, "fd2");
      table = AdfDhtmlTableBasePeer.__getChildBySubId(nestedDiv, "ft2");
      cell = table.rows[1].cells[index - 1];
    }
    var isSelectAll = cell.getAttribute(AdfDhtmlTableBasePeer._SELECT_ALL) != null;
    if (isSelectAll || !selectAllOnly) {
      this._setFooterCellFocus(cell);
      if (!skipUnclip && !isSelectAll) {
        this._unclipColumnElement(cell);
      }
      return true;
    }
  }
  return false;
};
AdfDhtmlTableBasePeer.prototype._setFooterCellFocus = function(cell) {
  var focusType = AdfDhtmlTableBasePeer._COLUMN_FOOTER_FOCUS_TYPE;
  this.UpdateFocusManager(focusType, null, cell);
  return focusType;
};
AdfDhtmlTableBasePeer.prototype._handleColumnFooterArrow = function(keyCode, event) {
  switch(keyCode) {
    default:
      break;
    case AdfKeyStroke.ARROWRIGHT_KEY:
      var focusElem = this._getNextColumnFooterFocusElement(this._focusManager.domElement);
      if (focusElem) {
        this._unclipColumnElement(focusElem);
        this._setFooterCellFocus(focusElem);
      }
      break;
    case AdfKeyStroke.ARROWLEFT_KEY:
      var focusElem = this._getPrevColumnFooterFocusElement(this._focusManager.domElement);
      if (focusElem) {
        this._unclipColumnElement(focusElem);
        this._setFooterCellFocus(focusElem);
      }
      break;
    case AdfKeyStroke.ARROWDOWN_KEY:
      break;
    case AdfKeyStroke.ARROWUP_KEY:
      var domElement = this._focusManager.domElement;
      if (domElement) {
        attrs = this._getLastVisibleRowKeyAndRow();
        rowKey = attrs.rowKey;
        var row = attrs.row;
        var isMultiSelect = this._isMultipleRowSelect();
        if (this._isRowSelectionEnabled()) {
          if (rowKey != null) {
            if (!isMultiSelect) {
              this._selUnselectAll();
            }
            this._selSelectRow(rowKey, row);
            this._unclipRow(row);
          }
        }
        this.UpdateFocusManager(AdfDhtmlTableBasePeer._TABLE_BODY_FOCUS_TYPE, rowKey, row);
      }
      break;
  }
};
