function AdfAutoSuggestBehaviorImpl(isSmartListEnabled, minChars, maxSuggestedItems, isLOVComponent) {
  this.Init(isSmartListEnabled, minChars, maxSuggestedItems, isLOVComponent);
}
AdfAutoSuggestBehaviorImpl.InitClass = function() {
  this._POPUP_PANEL_ID = "_afrAutoSuggest";
  this._ITEM_VALUE_ATTR = "data-afr-value";
  this._ITEM_LABEL_ATTR = "data-afr-label";
  this._SUGGEST_ITEMS_ID = "_afrautosuggestpopup";
  this._SUGGEST_ITEM_ID = "su";
  this._SMART_ITEM_ID = "sm";
  this._POPUP_CONTAINER_DIV_ID = "_afrautosuggestcontainer";
  this._MORE_LINK_ID = "_afrautosuggestmorelink";
  this._BUSY_DIV_ID = "_afrautosuggestbusydiv";
  this._POPUP_CONTAINER_STYLE = "AFAutoSuggestItemsContainer";
  this._SUGGESTED_ITEM_STYLE = "AFAutoSuggestItem";
  this._MORE_LINK_STYLE = "AFAutoSuggestMoreLink";
  this.SUGGEST_BUSY_STYLE = "AFAutoSuggestBusyStyle";
};
AdfObject.createSubclass(AdfAutoSuggestBehaviorImpl, AdfAutoSuggestBehavior);
AdfAutoSuggestBehaviorImpl.prototype.Init = function(isSmartListEnabled, minChars, maxSuggestedItems, isLOVComponent) {
  AdfAutoSuggestBehaviorImpl.superclass.Init.call(this);
  this._isSmartListEnabled = isSmartListEnabled;
  this._minChars = minChars;
  this._maxSuggestedItems = maxSuggestedItems;
  this._isLOVComponent = isLOVComponent;
};
AdfAutoSuggestBehaviorImpl.prototype.initialize = function(component) {
  AdfPage.PAGE.scheduleTimer(this, this._initialize, component, 0);
};
AdfAutoSuggestBehaviorImpl.prototype._initialize = function(component) {
  if (AdfPage.PAGE.isAttachmentMode()) {
    return;
  }
  component.addEventListener(AdfUIInputEvent.KEY_UP_EVENT_TYPE, this._fireKeyUp, this);
  component.addEventListener(AdfUIInputEvent.KEY_DOWN_EVENT_TYPE, this._fireKeyDown, this);
  component.addEventListener(AdfUIInputEvent.CLICK_EVENT_TYPE, this._fireClick, this);
  component.addEventListener(AdfUIInputEvent.MOUSE_DOWN_EVENT_TYPE, this._fireMouseDown, this);
  component.addEventListener(AdfUIInputEvent.BLUR_EVENT_TYPE, this._fireBlur, this);
  component.addEventListener(AdfUIInputEvent.FOCUS_EVENT_TYPE, this._fireFocus, this);
  this._autoCompleteDisabled = false;
  this._requestId = 0;
  this._itemsCache = {};
  this._clickedInSuggestitems = false;
  var clientId = component.getClientId();
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
  contentNode.setAttribute("role", "combobox");
  contentNode.setAttribute("aria-autocomplete", "list");
  contentNode.setAttribute("aria-owns", AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._SUGGEST_ITEMS_ID));
  contentNode.setAttribute("aria-expanded", "false");
};
AdfAutoSuggestBehaviorImpl.isPopupVisible = function(component, peer) {
  return peer.isPopupVisible(component, AdfAutoSuggestBehaviorImpl._POPUP_PANEL_ID);
};
AdfAutoSuggestBehaviorImpl.showAutoSuggestPopup = function(clientId, submittedValue, suggestedItems, isSmartList, maxSuggestedItems, isLOVComponent, requestId) {
  var page = AdfPage.PAGE;
  var component = page.findComponent(clientId);
  if (component) {
    if (isSmartList && isSmartList == true) {
      component._smartList = suggestedItems;
    } else {
      var oldRequestId = component._requestId;
      if (requestId == oldRequestId) {
        var autoSuggestBehavior = component.getBehaviors(AdfAutoSuggestBehavior);
        if (autoSuggestBehavior) {
          autoSuggestBehavior._cacheSuggestedItems(submittedValue, suggestedItems);
          autoSuggestBehavior._showPopup(component, submittedValue, clientId, suggestedItems, false, maxSuggestedItems, isLOVComponent);
        }
      }
    }
  }
};
AdfAutoSuggestBehaviorImpl.prototype.getSuggestedItems = function(component) {
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
  var submittedValue = contentNode.value;
  if (submittedValue.trim().length == 0) {
    return;
  }
  var selectItems = [];
  var filteredSmartList = this._filterSmartList(component._smartList, submittedValue);
  AdfAutoSuggestBehaviorImpl._convertToSelectItems(filteredSmartList, selectItems);
  var suggestedItems = this._getSuggestedItemsFromCache(submittedValue);
  AdfAutoSuggestBehaviorImpl._convertToSelectItems(suggestedItems, selectItems);
  return selectItems;
};
AdfAutoSuggestBehaviorImpl._addBusyDiv = function(ownerDoc, ulElement, clientId, laf) {
  var div = ownerDoc.createElement("div");
  var divClientId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._BUSY_DIV_ID);
  div.setAttribute("id", divClientId);
  var busyStyle = laf.getStyleClass(AdfAutoSuggestBehaviorImpl.SUGGEST_BUSY_STYLE);
  AdfDomUtils.addCSSClassName(div, busyStyle);
  liElement = ownerDoc.createElement("li");
  liElement.appendChild(div);
  AdfAgent.AGENT.elementsAdded(div);
  ulElement.appendChild(liElement);
};
AdfAutoSuggestBehaviorImpl._addMoreLink = function(ownerDoc, ulElement, clientId, isSmartList, maxSuggestedItems, submittedValue, laf) {
  if (!isSmartList && maxSuggestedItems && maxSuggestedItems >= 0) {
    AdfAutoSuggestBehaviorImpl._addSeparator(ownerDoc, ulElement);
    var link = ownerDoc.createElement("a");
    link.setAttribute("href", "#");
    var domWindow = AdfPage.PAGE.getDomWindow();
    var agent = AdfAgent.AGENT;
    if (domWindow.AdfSafariMobileAgent && agent instanceof AdfSafariMobileAgent) {
      link.addEventListener("click", function(event) {
        void 0;
        event.preventDefault();
      });
    } else {
      link.addEventListener("click", function(event) {
        event.preventDefault();
      });
    }
    var moreLinkId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._MORE_LINK_ID);
    link.setAttribute("id", moreLinkId);
    link.setAttribute(AdfAutoSuggestBehaviorImpl._ITEM_VALUE_ATTR, submittedValue);
    link.setAttribute("role", "option");
    var moreTextNode = ownerDoc.createTextNode(laf.getTranslatedString("AFAutoSuggestMoreLinkLabel"));
    link.appendChild(moreTextNode);
    AdfDomUtils.addCSSClassName(link, AdfAutoSuggestBehaviorImpl._MORE_LINK_STYLE);
    liElement = ownerDoc.createElement("li");
    liElement.appendChild(link);
    agent.elementsAdded(link);
    ulElement.appendChild(liElement);
  }
};
AdfAutoSuggestBehaviorImpl._addSuggestItems = function(ownerDoc, ulElement, clientId, suggestedItems, isSmartList, laf) {
  var domWindow = AdfPage.PAGE.getDomWindow();
  var agent = AdfAgent.AGENT;
  var isSafariMobileAgent = domWindow.AdfSafariMobileAgent && agent instanceof AdfSafariMobileAgent;
  var suggestedItemStyle = laf.getStyleClass(AdfAutoSuggestBehaviorImpl._SUGGESTED_ITEM_STYLE);
  var index = 0;
  var suggestItemId = AdfRichUIPeer.createSubId(clientId, isSmartList ? AdfAutoSuggestBehaviorImpl._SMART_ITEM_ID : AdfAutoSuggestBehaviorImpl._SUGGEST_ITEM_ID);
  for (var key in suggestedItems) {
    var liElement = ownerDoc.createElement("li");
    liElement.setAttribute("role", "option");
    liElement.setAttribute("id", suggestItemId + index++);
    liElement.setAttribute(AdfAutoSuggestBehaviorImpl._ITEM_VALUE_ATTR, suggestedItems[key]);
    if (isSafariMobileAgent) {
      liElement.addEventListener("click", function(event) {
        event.preventDefault();
      });
    }
    var label = key;
    liElement.setAttribute(AdfAutoSuggestBehaviorImpl._ITEM_LABEL_ATTR, label);
    var labelNode = ownerDoc.createTextNode(label);
    liElement.appendChild(labelNode);
    AdfDomUtils.addCSSClassName(liElement, suggestedItemStyle);
    ulElement.appendChild(liElement);
    agent.elementsAdded(liElement);
  }
};
AdfAutoSuggestBehaviorImpl._addSeparator = function(ownerDoc, ulElement) {
  var liElement = ownerDoc.createElement("li");
  var separator = ownerDoc.createElement("hr");
  liElement.appendChild(separator);
  ulElement.appendChild(liElement);
};
AdfAutoSuggestBehaviorImpl._adjustForScrollBars = function(ulElement) {
  var agent = AdfAgent.AGENT;
  var computedStyle = agent.getComputedStyle(ulElement);
  var maxHeightInt = parseInt(computedStyle.maxHeight, 10);
  var scrollHeightInt = ulElement.scrollHeight;
  var isRtl = AdfPage.PAGE.getLocaleContext().isRightToLeft();
  var childElements = AdfDomUtils.getChildElements(ulElement);
  for (var i = 0;i < childElements.length;i++) {
    var childElement = childElements[i];
    if (scrollHeightInt > maxHeightInt) {
      if (isRtl) {
        childElement.style.paddingLeft = "20px";
      } else {
        childElement.style.paddingRight = "20px";
      }
    } else {
      if (isRtl) {
        childElement.style.paddingLeft = "";
      } else {
        childElement.style.paddingRight = "";
      }
    }
  }
};
AdfAutoSuggestBehaviorImpl._convertToSelectItems = function(suggestedItems, selectItems) {
  for (var item in suggestedItems) {
    if (suggestedItems.hasOwnProperty(item)) {
      var selectItem = new AdfSelectItem(suggestedItems[item], item);
      selectItems.push(selectItem);
    }
  }
};
AdfAutoSuggestBehaviorImpl._createPopupContent = function(component, clientId, ownerDoc, agent) {
  var popupClientId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._SUGGEST_ITEMS_ID);
  var popupContainerId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._POPUP_CONTAINER_DIV_ID);
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
  var outerDiv = agent.getElementById(popupContainerId);
  var laf = AdfPage.PAGE.getLookAndFeel();
  var popupContainerStyle = laf.getStyleClass(AdfAutoSuggestBehaviorImpl._POPUP_CONTAINER_STYLE);
  if (!outerDiv) {
    outerDiv = ownerDoc.createElement("div");
    outerDiv.setAttribute("id", popupContainerId);
    var outerDivStyle = outerDiv.style;
    outerDivStyle.display = "none";
  } else {
    outerDiv.innerHTML = "";
  }
  var ulElement = ownerDoc.createElement("ul");
  ulElement.setAttribute("id", popupClientId);
  ulElement.setAttribute("role", "listbox");
  AdfDomUtils.addCSSClassName(ulElement, popupContainerStyle);
  outerDiv.appendChild(ulElement);
  contentNode.parentNode.appendChild(outerDiv);
  agent.elementsAdded(outerDiv);
  return ulElement;
};
AdfAutoSuggestBehaviorImpl._isSuggestItemOrMoreLink = function(element) {
  return element.getAttribute("role") == "option";
};
AdfAutoSuggestBehaviorImpl._updateSelectedStyle = function(element, selected) {
  var styleManagementFunction = AdfDomUtils.addCSSClassName;
  if (!selected) {
    styleManagementFunction = AdfDomUtils.removeCSSClassName;
  }
  styleManagementFunction(element, AdfRichUIPeer.SELECTED_STYLECLASS);
};
AdfAutoSuggestBehaviorImpl.prototype._fireFocus = function(componentEvent) {
  var component = componentEvent.getSource();
  if (!this._autoCompleteDisabled) {
    if (component && component instanceof AdfUIEditableValue) {
      var peer = component.getPeer();
      peer.bind(component);
      if (peer.disableBrowserAutoComplete) {
        peer.disableBrowserAutoComplete(component);
      }
    }
    this._autoCompleteDisabled = true;
  }
  if (this._isSmartListEnabled && !component._smartList) {
    AdfCustomEvent.queue(component, "_autoSuggest", {smartList:true}, true, true);
  }
};
AdfAutoSuggestBehaviorImpl.prototype._fireMouseDown = function(componentEvent) {
  var component = componentEvent.getSource();
  var peer = component.getPeer();
  peer.bind(component);
  if (component && component instanceof AdfUIEditableValue) {
    var target = componentEvent.getNativeEventTarget();
    var value = target.getAttribute && target.getAttribute(AdfAutoSuggestBehaviorImpl._ITEM_VALUE_ATTR);
    var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
    var clientId = component.getClientId();
    var moreLinkId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._MORE_LINK_ID);
    if (target.id == moreLinkId) {
      peer.preventNextValueSubmission();
      this._clickedInSuggestitems = true;
    } else {
      if (value && value.length > 0) {
        var label = target.getAttribute(AdfAutoSuggestBehaviorImpl._ITEM_LABEL_ATTR);
        if (label && label.length > 0) {
          component.setProperty("_afrAutoSuggestLabel", label, false, AdfUIComponent.PROPAGATE_ALWAYS);
        }
        contentNode.value = value;
        var oldVal = component.getValue();
        if (oldVal == null) {
          oldVal = AdfDhtmlInputBasePeer.getLastValue(contentNode);
        }
        peer.RunValidation(component, componentEvent.getNativeEventTarget());
        if (value == oldVal) {
          AdfValueChangeEvent.queue(component, oldVal, component.getValue(), component.getAutoSubmit());
        }
        this._clickedInSuggestitems = true;
      } else {
        var popupContentId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._SUGGEST_ITEMS_ID);
        var divClientId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._BUSY_DIV_ID);
        while (target) {
          if (target.id == popupContentId) {
            this._clickedInSuggestitems = true;
            if (AdfAgent.AGENT.getPlatform() == AdfAgent.IE_PLATFORM) {
              peer.preventNextValueSubmission();
            }
            break;
          } else {
            if (target == contentNode || target.id == divClientId) {
              break;
            }
          }
          target = target.parentNode;
        }
      }
    }
  }
};
AdfAutoSuggestBehaviorImpl.prototype._fireBlur = function(componentEvent) {
  this._cancelSuggestTimer();
  var component = componentEvent.getSource();
  var peer = component.getPeer();
  peer.bind(component);
  AdfPage.PAGE.scheduleTimer(this, this._clearCache, null, 100);
  this._cancelSmartListTimer();
  var dts = AdfPage.PAGE.getDataTransferService();
  var dtsState = dts.getDTSState();
  if (dtsState == AdfDataTransferService.STATE_BUSY) {
    component._requestId = this._requestId++;
  }
};
AdfAutoSuggestBehaviorImpl.prototype._fireClick = function(componentEvent) {
  var component = componentEvent.getSource();
  if (component && component instanceof AdfUIEditableValue) {
    var peer = component.getPeer();
    peer.bind(component);
    var node = componentEvent.getNativeEventTarget();
    if (AdfAutoSuggestBehaviorImpl.isPopupVisible(component, peer)) {
      var value = node.getAttribute(AdfAutoSuggestBehaviorImpl._ITEM_VALUE_ATTR);
      var clientId = component.getClientId();
      var moreLinkId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._MORE_LINK_ID);
      if (node.id == moreLinkId) {
        if (value && value.length > 0) {
          if (this._isLOVComponent) {
            AdfLaunchPopupEvent.queue(component, true);
          }
        }
        component.focus();
        return;
      }
      if (value && value.length > 0) {
        this._cancelSmartListTimer();
        peer.hidePopup(component, AdfAutoSuggestBehaviorImpl._POPUP_PANEL_ID);
        component.focus();
      }
    }
  }
};
AdfAutoSuggestBehaviorImpl.prototype._fireKeyUp = function(componentEvent) {
  var agent = AdfAgent.AGENT;
  var keyCode = agent.getKeyCode(componentEvent.getNativeEvent());
  if (keyCode == AdfKeyStroke.ARROWLEFT_KEY || keyCode == AdfKeyStroke.ARROWRIGHT_KEY) {
    return;
  }
  var isSmartListDisplayed = this._smartListTimerId !== undefined;
  this._cancelSmartListTimer();
  var component = componentEvent.getSource();
  if (component && component instanceof AdfUIEditableValue) {
    var peer = component.getPeer();
    peer.bind(component);
    var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
    if (contentNode) {
      var contentValue = contentNode.value;
      if (contentValue.replace(/\s*/, "").length > 0) {
        if (keyCode == AdfKeyStroke.BACKSPACE_KEY || this._nodeLength != undefined && contentValue.length != this._nodeLength || this._lastValue && this._lastValue != contentValue) {
          var page = AdfPage.PAGE;
          if (this._timerId) {
            page.rescheduleTimer(this._timerId, 500);
          } else {
            this._timerId = page.scheduleTimer(this, this._autoSuggest, component, 500, {"isSynchronized":true});
          }
        }
      } else {
        if (contentValue.length == 0 && AdfAutoSuggestBehaviorImpl.isPopupVisible(component, peer)) {
          peer.hidePopup(component, AdfAutoSuggestBehaviorImpl._POPUP_PANEL_ID);
        }
      }
      delete this._nodeLength;
      delete this._lastValue;
      var clientId = component.getClientId();
      switch(keyCode) {
        case AdfKeyStroke.ENTER_KEY:
          if (AdfAutoSuggestBehaviorImpl.isPopupVisible(component, peer)) {
            var moreLinkId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._MORE_LINK_ID);
            var selectedItemId = this._getCurrentSelectedItemId(contentNode);
            if (selectedItemId && selectedItemId == moreLinkId) {
              if (this._isLOVComponent) {
                AdfLaunchPopupEvent.queue(component, true);
              }
            } else {
              var selectedItem;
              if (selectedItemId) {
                selectedItem = agent.getElementById(selectedItemId);
              }
              if (selectedItem) {
                var label = selectedItem.getAttribute(AdfAutoSuggestBehaviorImpl._ITEM_LABEL_ATTR);
                if (label && label.length > 0) {
                  component.setProperty("_afrAutoSuggestLabel", label, false, AdfUIComponent.PROPAGATE_ALWAYS);
                }
              }
              var oldVal = component.getValue();
              if (oldVal == null) {
                oldVal = AdfDhtmlInputBasePeer.getLastValue(contentNode);
              }
              peer.RunValidation(component, componentEvent.getNativeEventTarget());
              if (selectedItem) {
                var value = selectedItem.getAttribute(AdfAutoSuggestBehaviorImpl._ITEM_VALUE_ATTR);
                if (value == oldVal) {
                  AdfValueChangeEvent.queue(component, oldVal, component.getValue(), component.getAutoSubmit());
                }
              }
            }
            peer.hidePopup(component, AdfAutoSuggestBehaviorImpl._POPUP_PANEL_ID);
            componentEvent.cancel();
            componentEvent.stopBubbling();
          }
          break;
        case AdfKeyStroke.ARROWDOWN_KEY:
        ;
        case AdfKeyStroke.ARROWUP_KEY:
          if (AdfAutoSuggestBehaviorImpl.isPopupVisible(component, peer)) {
            var suggestItemsContainerId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._SUGGEST_ITEMS_ID);
            var suggestItemsContainer = agent.getElementById(suggestItemsContainerId);
            if (isSmartListDisplayed) {
              var busyDivId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._BUSY_DIV_ID);
              var busyDiv = agent.getElementById(busyDivId);
              if (busyDiv) {
                var busyDivItem = busyDiv.parentElement;
                var separatorItem = AdfDomUtils.getPreviousElement(busyDivItem);
                suggestItemsContainer.removeChild(busyDivItem);
                agent.elementsRemoved(busyDiv);
                suggestItemsContainer.removeChild(separatorItem);
              }
            }
            this._selectNewItem(contentNode, suggestItemsContainer, keyCode == AdfKeyStroke.ARROWDOWN_KEY);
          }
          break;
      }
    }
  }
};
AdfAutoSuggestBehaviorImpl.prototype._fireKeyDown = function(event) {
  var component = event.getSource();
  if (component && component instanceof AdfUIEditableValue) {
    var peer = component.getPeer();
    peer.bind(component);
    var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
    if (AdfAgent.AGENT.getKeyCode(event.getNativeEvent()) == AdfKeyStroke.ENTER_KEY && AdfAutoSuggestBehaviorImpl.isPopupVisible(component, peer)) {
      var clientId = component.getClientId();
      var selectedItemId = this._getCurrentSelectedItemId(contentNode);
      var moreLinkId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._MORE_LINK_ID);
      if (selectedItemId && selectedItemId == moreLinkId) {
        peer.preventNextValueSubmission();
      }
    }
    this._nodeLength = contentNode.value.length;
    this._lastValue = contentNode.value;
  }
};
AdfAutoSuggestBehaviorImpl.prototype._firePopupClosed = function(component) {
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
  contentNode.setAttribute("aria-expanded", "false");
  contentNode.removeAttribute("aria-activedescendant");
};
AdfAutoSuggestBehaviorImpl.prototype._firePopupOpening = function(component) {
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
  contentNode.setAttribute("aria-expanded", "true");
};
AdfAutoSuggestBehaviorImpl.prototype._getCurrentSelectedItemId = function(contentNode) {
  return contentNode.getAttribute("aria-activedescendant");
};
AdfAutoSuggestBehaviorImpl.prototype._autoSuggest = function(component) {
  this._timerId = null;
  var peer = component.getPeer();
  peer.bind(component);
  if (AdfAutoSuggestBehaviorImpl.isPopupVisible(component, peer)) {
    peer.hidePopup(component, AdfAutoSuggestBehaviorImpl._POPUP_PANEL_ID);
  }
  var targetNode = AdfDhtmlEditableValuePeer.getContentNode(component);
  var value = targetNode.value;
  var suggestedItems = this._getSuggestedItemsFromCache(value);
  if (suggestedItems) {
    this._showPopup(component, value, component.getClientId(), suggestedItems, false, this._maxSuggestedItems, this._isLOVComponent);
  } else {
    if (value) {
      var hasSmartItems = false;
      if (component._smartList) {
        var filteredSmartList = this._filterSmartList(component._smartList, value);
        hasSmartItems = !AdfCollections.isEmpty(filteredSmartList);
        if (hasSmartItems) {
          this._showPopup(component, value, component.getClientId(), filteredSmartList, true, this._maxSuggestedItems, this._isLOVComponent);
        }
      }
      if (value.length < this._minChars) {
        return;
      }
      if (!hasSmartItems) {
        this._queueAutoSuggestEvent([component, value, targetNode, this._maxSuggestedItems]);
      } else {
        this._smartListTimerId = AdfPage.PAGE.scheduleTimer(this, this._queueAutoSuggestEvent, [component, value, targetNode, this._maxSuggestedItems], 2E3, {"isSynchronized":true});
      }
    }
  }
};
AdfAutoSuggestBehaviorImpl.prototype._cancelSuggestTimer = function() {
  var timerId = this._timerId;
  if (timerId) {
    AdfPage.PAGE.cancelTimer(timerId);
    delete this._timerId;
  }
};
AdfAutoSuggestBehaviorImpl.prototype._cancelSmartListTimer = function() {
  var smartListtimerId = this._smartListTimerId;
  if (smartListtimerId) {
    AdfPage.PAGE.cancelTimer(smartListtimerId);
    delete this._smartListTimerId;
  }
};
AdfAutoSuggestBehaviorImpl.prototype._queueAutoSuggestEvent = function(params) {
  delete this._smartListTimerId;
  var laf = AdfPage.PAGE.getLookAndFeel();
  if (params[1]) {
    var component = params[0];
    var peer = component.getPeer();
    peer.bind(component);
    if (!AdfAutoSuggestBehaviorImpl.isPopupVisible(component, peer)) {
      var clientId = component.getClientId();
      var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
      var ownerDoc = contentNode.ownerDocument;
      var agent = AdfAgent.AGENT;
      var ulElement = AdfAutoSuggestBehaviorImpl._createPopupContent(component, clientId, ownerDoc, agent);
      AdfAutoSuggestBehaviorImpl._addBusyDiv(ownerDoc, ulElement, clientId, laf);
      this._showDropdown(component, peer, clientId, ulElement);
    }
    var requestId = this._requestId++;
    component._requestId = requestId;
    AdfCustomEvent.queue(params[0], "_autoSuggest", {"submittedValue":params[1], "emptyText":laf.getTranslatedString("AFAutoSuggestEmptyText"), "maxSuggestedItems":params[3], "requestId":requestId}, true, true);
  }
};
AdfAutoSuggestBehaviorImpl.prototype._filterSmartList = function(smartList, submittedValue) {
  var filteredSmartList = {};
  for (var key in smartList) {
    if (key.indexOf(submittedValue) == 0) {
      filteredSmartList[key] = smartList[key];
    }
  }
  return filteredSmartList;
};
AdfAutoSuggestBehaviorImpl.prototype._selectNewItem = function(contentNode, suggestItemsContainer, isFindNextItem) {
  var oldItem, newItem;
  var selectedItemId = this._getCurrentSelectedItemId(contentNode);
  if (selectedItemId) {
    oldItem = AdfAgent.AGENT.getElementById(selectedItemId);
    newItem = isFindNextItem ? AdfDomUtils.getNextElementMatch(oldItem, suggestItemsContainer, true, AdfAutoSuggestBehaviorImpl._isSuggestItemOrMoreLink) : AdfDomUtils.getPreviousElementMatch(oldItem, suggestItemsContainer, AdfAutoSuggestBehaviorImpl._isSuggestItemOrMoreLink);
  } else {
    if (isFindNextItem) {
      newItem = AdfDomUtils.getFirstElementMatch(suggestItemsContainer, true, AdfAutoSuggestBehaviorImpl._isSuggestItemOrMoreLink);
    }
  }
  if (!newItem) {
    return;
  }
  if (oldItem) {
    AdfAutoSuggestBehaviorImpl._updateSelectedStyle(oldItem, false);
  }
  AdfAutoSuggestBehaviorImpl._updateSelectedStyle(newItem, true);
  contentNode.setAttribute("aria-activedescendant", newItem.id);
  newItem.scrollIntoView();
  var value = newItem.getAttribute(AdfAutoSuggestBehaviorImpl._ITEM_VALUE_ATTR);
  if (value) {
    contentNode.value = value;
  }
};
AdfAutoSuggestBehaviorImpl.prototype._showPopup = function(component, submittedValue, clientId, suggestedItems, isSmartList, maxSuggestedItems, isLOVComponent) {
  var peer = component.getPeer();
  peer.bind(component);
  var popupClientId = AdfRichUIPeer.createSubId(clientId, AdfAutoSuggestBehaviorImpl._SUGGEST_ITEMS_ID);
  var contentNode = AdfDhtmlEditableValuePeer.getContentNode(component);
  var ownerDoc = contentNode.ownerDocument;
  var agent = AdfAgent.AGENT;
  var laf = AdfPage.PAGE.getLookAndFeel();
  var ulElement;
  var isMoreLinkNeeded = !suggestedItems.hasOwnProperty(laf.getTranslatedString("AFAutoSuggestEmptyText"));
  if (AdfAutoSuggestBehaviorImpl.isPopupVisible(component, peer)) {
    ulElement = agent.getElementById(popupClientId);
    var busyDiv = ulElement.lastChild;
    busyDiv = ulElement.lastChild;
    if (busyDiv) {
      agent.elementsRemoved(busyDiv);
      ulElement.removeChild(busyDiv);
    }
    AdfAutoSuggestBehaviorImpl._addSuggestItems(ownerDoc, ulElement, clientId, suggestedItems, isSmartList, laf);
    if (isMoreLinkNeeded && isLOVComponent) {
      AdfAutoSuggestBehaviorImpl._addMoreLink(ownerDoc, ulElement, clientId, isSmartList, maxSuggestedItems, submittedValue, laf);
    }
  } else {
    ulElement = AdfAutoSuggestBehaviorImpl._createPopupContent(component, clientId, ownerDoc, agent);
    AdfAutoSuggestBehaviorImpl._addSuggestItems(ownerDoc, ulElement, clientId, suggestedItems, isSmartList, laf);
    if (isSmartList == true && contentNode.value.length >= this._minChars) {
      AdfAutoSuggestBehaviorImpl._addSeparator(ownerDoc, ulElement);
      AdfAutoSuggestBehaviorImpl._addBusyDiv(ownerDoc, ulElement, clientId, laf);
    }
    if (isMoreLinkNeeded && isLOVComponent) {
      AdfAutoSuggestBehaviorImpl._addMoreLink(ownerDoc, ulElement, clientId, isSmartList, maxSuggestedItems, submittedValue, laf);
    }
    this._showDropdown(component, peer, clientId, ulElement);
  }
  AdfAutoSuggestBehaviorImpl._adjustForScrollBars(ulElement);
};
AdfAutoSuggestBehaviorImpl.prototype._showDropdown = function(component, peer, clientId, ulElement) {
  AdfObject.ensureClassInitialization(AdfRichPopup);
  var hints = {};
  hints[AdfDhtmlPopupHints.TYPE] = AdfDhtmlPopupHints.TYPE_MENU;
  hints[AdfDhtmlPopupHints.AUTODISMISS] = AdfDhtmlPopupHints.AUTODISMISS_MENU;
  hints[AdfDhtmlPopupHints.FOCUS] = false;
  hints[AdfDhtmlPopupHints.CLOSE_ON_ESCAPE] = true;
  hints[AdfDhtmlPopupHints.CLOSE_HANDLER] = this.createCallback(this._firePopupClosed);
  hints[AdfDhtmlPopupHints.CLOSE_HANDLER_PARAM] = component;
  hints[AdfDhtmlPopupHints.OPENED_HANDLER] = this.createCallback(this._firePopupOpening);
  hints[AdfDhtmlPopupHints.OPENED_HANDLER_PARAM] = component;
  hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_AFTER_START;
  hints[AdfRichPopup.HINT_LAUNCH_ID] = clientId;
  hints[AdfRichPopup.HINT_ALIGN_ID] = AdfRichUIPeer.createSubId(clientId, "content");
  peer.showPopup(component, ulElement, hints, AdfAutoSuggestBehaviorImpl._POPUP_PANEL_ID);
};
AdfAutoSuggestBehaviorImpl.prototype._cacheSuggestedItems = function(submittedValue, suggestedItems) {
  this._itemsCache[submittedValue] = suggestedItems;
};
AdfAutoSuggestBehaviorImpl.prototype._getSuggestedItemsFromCache = function(submittedValue) {
  return this._itemsCache[submittedValue];
};
AdfAutoSuggestBehaviorImpl.prototype._clearSuggestedItemsCache = function() {
  this._itemsCache = {};
};
AdfAutoSuggestBehaviorImpl.prototype._clearCache = function() {
  if (!this._clickedInSuggestitems) {
    this._clearSuggestedItemsCache();
  }
  this._clickedInSuggestitems = false;
};
