function AdfSafariMobileAgent(version, domWindow) {
  this.Init(version, domWindow)
}
AdfObject.createSubclass(AdfSafariMobileAgent, AdfSafariAgent);
AdfSafariMobileAgent.prototype.Init = function(version, domWindow) {
  AdfSafariMobileAgent.superclass.Init.call(this, version, domWindow);
  this._isWithinTouchEventsSequence = true
};
AdfSafariMobileAgent.prototype.GetTouchCapability = function() {
  if(this.getOS() != AdfAgent.ANDROID_OS) {
    return AdfAgent.CAP_TOUCH_SCREEN_MULTIPLE
  }
  return AdfSafariMobileAgent.superclass.GetTouchCapability.call(this)
};
AdfSafariMobileAgent.prototype.createTouchMoveManager = function(element, handlerCallback, touchCount) {
  return new AdfSafariTouchMoveManager(element, handlerCallback, touchCount)
};
AdfSafariMobileAgent.prototype.getBrowserViewportScrollTop = function() {
  var domWindow = this.getDomWindow();
  return domWindow.pageYOffset
};
AdfSafariMobileAgent.prototype.getBrowserViewportScrollLeft = function() {
  var domWindow = this.getDomWindow();
  return domWindow.pageXOffset
};
AdfSafariMobileAgent.prototype.isInlineDialogRepositioningOnScroll = function() {
  return false
};
AdfSafariMobileAgent.prototype.isSelectionToggle = function(evt) {
  return true
};
AdfSafariMobileAgent.prototype.getMousePosition = function(evt) {
  var type = evt.type;
  if(AdfCollections.indexOf(AdfAgent._REDISTRIBUTE_TOUCH_EVENTS, type) > -1) {
    var touch = AdfComponentTouchEvent.__getFirstTouch(evt);
    var scrolltop = this.getBrowserViewportScrollTop();
    var scrollleft = this.getBrowserViewportScrollLeft();
    return{"x":touch.clientX + scrollleft, "y":touch.clientY + scrolltop}
  }
  return AdfSafariMobileAgent.superclass.getMousePosition.call(this, evt)
};
AdfSafariMobileAgent.prototype.getComponentEvent = function(component, nativeEvent, prevComponent) {
  var nativeType = nativeEvent.type;
  var type = AdfSafariMobileAgent.superclass.mapNativeToComponentEventType.call(this, nativeEvent.type);
  if(type) {
    switch(type) {
      case AdfComponentTouchEvent.TOUCH_START_EVENT_TYPE:
        this._isWithinTouchEventsSequence = true;
        break
    }
    return new AdfComponentTouchEvent(component, type, nativeEvent)
  }
  if(!this._isWithinTouchEventsSequence) {
    return null
  }else {
    return AdfSafariMobileAgent.superclass.getComponentEvent.call(this, component, nativeEvent, prevComponent)
  }
};
AdfSafariMobileAgent.prototype.preventDefault = function(evt) {
  AdfSafariMobileAgent.superclass.preventDefault.call(this, evt);
  var nativeType = evt.type;
  if(nativeType == "touchstart" || nativeType == "touchend") {
    this._isWithinTouchEventsSequence = false
  }
};
AdfSafariMobileAgent.prototype.getEventTarget = function(event) {
  var result = null;
  var type = event.type;
  if(event._afrClonedEvent) {
    result = AdfSafariMobileAgent.superclass.getEventTarget.call(this, event)
  }else {
    if(AdfCollections.indexOf(AdfAgent._REDISTRIBUTE_TOUCH_EVENTS, type) > -1) {
      var touch = AdfComponentTouchEvent.__getFirstTouch(event);
      if(touch) {
        result = touch.target
      }
    }
  }
  if(!result) {
    result = AdfSafariMobileAgent.superclass.getEventTarget.call(this, event)
  }
  return result != null ? AdfDomUtils.getElement(result) : null
};
AdfSafariMobileAgent.prototype.isDragPrepEvent = function(componentEvent) {
  return componentEvent.getType() == AdfComponentTouchEvent.TOUCH_START_EVENT_TYPE && componentEvent.getTouchCount() == 1
};
AdfSafariMobileAgent.prototype.createContextMenuEventGenerator = function() {
  return new AdfSafariTouchContextMenuManager
};
AdfSafariMobileAgent.prototype.createDraggableNode = function(domNode) {
  var doc = domNode.ownerDocument;
  var dragContent = doc.createElement("DIV");
  AdfDomUtils.addCSSClassName(dragContent, AdfAgent.DRAG_GHOST_STYLECLASS);
  this.CopyDragSize(domNode, dragContent);
  return dragContent
};
AdfSafariMobileAgent.prototype.isLeftButton = function(evt) {
  return AdfSafariMobileAgent.superclass.isLeftButton.call(this, evt) || AdfSafariMobileAgent._NATIVE_TO_COMPONENT_MAPPINGS[evt.type] != null
};
AdfSafariMobileAgent.prototype.showTooltip = function(componentEvent) {
  var type = componentEvent.getType();
  if(type == AdfComponentTouchEvent.TOUCH_START_EVENT_TYPE && !componentEvent.isCanceled() && componentEvent.getTouchCount() == 1) {
    AdfSafariMobileAgent._hideTooltip()
  }else {
    if(type == AdfComponentEvent.CONTEXT_MENU_EVENT_TYPE) {
      var page = AdfPage.PAGE;
      var key = AdfSafariMobileAgent._TOOLTIP_PROPERTY_KEY;
      var state = page.getPageProperty(key);
      if(!state) {
        state = {};
        state["popup"] = new AdfDhtmlTooltip;
        page.setPageProperty(key, state)
      }
      state["timer"] = page.scheduleTimer(page, AdfSafariMobileAgent._showTooltip, componentEvent, 1)
    }
  }
};
AdfSafariMobileAgent.prototype.isDefaultPrevented = function(evt) {
  var touchEventsSequencePrevented = !this._isWithinTouchEventsSequence;
  return touchEventsSequencePrevented || AdfSafariMobileAgent.superclass.isDefaultPrevented.call(this, evt)
};
AdfSafariMobileAgent.prototype.disableSelectionToggleOnEditableCell = function() {
  return true
};
AdfSafariMobileAgent.prototype.addBubbleEventListener = function(nodeOrWindow, eventType, listener) {
  if(nodeOrWindow === AdfPage.PAGE.getDomDocument()) {
    this._saveEventListener(eventType, listener, false)
  }
  AdfSafariMobileAgent.superclass.addBubbleEventListener.call(this, nodeOrWindow, eventType, listener)
};
AdfSafariMobileAgent.prototype.addEventCaptures = function(node, listener) {
  if(node === AdfPage.PAGE.getDomDocument()) {
    for(var i = 0;i < AdfAgent._REDISTRIBUTE_TOUCH_EVENTS.length;i++) {
      this._saveEventListener(AdfAgent._REDISTRIBUTE_TOUCH_EVENTS[i], listener, true)
    }
  }
  AdfSafariMobileAgent.superclass.addEventCaptures.call(this, node, listener)
};
AdfSafariMobileAgent.prototype.addEventBubbles = function(node, listener) {
  if(node === AdfPage.PAGE.getDomDocument()) {
    for(var i = 0;i < AdfAgent._REDISTRIBUTE_TOUCH_EVENTS.length;i++) {
      this._saveEventListener(AdfAgent._REDISTRIBUTE_TOUCH_EVENTS[i], listener, false)
    }
  }
  AdfSafariMobileAgent.superclass.addEventBubbles.call(this, node, listener)
};
AdfSafariMobileAgent.prototype.cloneEvent = function(event, newTarget) {
  var newEvent = AdfSafariAgent.superclass.cloneEvent.call(this, event, newTarget);
  newEvent._afrClonedEvent = true;
  return newEvent
};
AdfSafariMobileAgent.prototype.isTouchFirstDevice = function() {
  return true
};
AdfSafariMobileAgent.prototype._getTouchEventListeners = function() {
  return this._touchEventListeners
};
AdfSafariMobileAgent.prototype._saveEventListener = function(eventType, listener, capture) {
  if(!this._touchEventListeners) {
    this._touchEventListeners = new Array
  }
  for(var i = 0;i < this._touchEventListeners.length;i++) {
    if(this._touchEventListeners[i].eventType === eventType && this._touchEventListeners[i].listener === listener && this._touchEventListeners[i].capture === capture) {
      return
    }
  }
  if(eventType == "touchstart" || eventType == "touchmove" || eventType == "touchend" || eventType == "touchcancel") {
    this._touchEventListeners.push({eventType:eventType, listener:listener, capture:capture})
  }
};
AdfSafariMobileAgent._showTooltip = function(componentEvent) {
  var page = AdfPage.PAGE;
  var key = AdfSafariMobileAgent._TOOLTIP_PROPERTY_KEY;
  var state = page.getPageProperty(key);
  if(!state) {
    return
  }
  var tooltipPopup = state["popup"];
  var nativeTarget = componentEvent.getNativeEventTarget();
  var title = AdfSafariMobileAgent._getTitle(nativeTarget);
  if(title) {
    var positionManager = page.getPositionManager();
    var alignmentHint = AdfRichPopup.ALIGN_AFTER_START;
    var height = tooltipPopup.getHeight();
    var width = tooltipPopup.getWidth();
    var pos = positionManager.calculatePlacementPosition(height, width, alignmentHint, nativeTarget, null);
    if(pos["y"] > 0 && pos["x"] > 0) {
      AdfAgent.AGENT.setTextContent(tooltipPopup.getElement(), title);
      tooltipPopup.show(pos["y"], pos["x"]);
      state["timer"] = page.scheduleTimer(page, AdfSafariMobileAgent._hideTooltip, null, AdfSafariMobileAgent._TOOLTIP_HIDE_TIMEOUT)
    }else {
      state["timer"] = null;
      AdfAgent.AGENT.setTextContent(tooltipPopup.getElement(), "")
    }
  }else {
    state["timer"] = null;
    AdfAgent.AGENT.setTextContent(tooltipPopup.getElement(), "")
  }
};
AdfSafariMobileAgent._hideTooltip = function() {
  var page = AdfPage.PAGE;
  var state = page.getPageProperty(AdfSafariMobileAgent._TOOLTIP_PROPERTY_KEY);
  if(!state) {
    return
  }
  var timer = state["timer"];
  state["timer"] = null;
  if(timer) {
    page.cancelTimer(timer)
  }
  var tooltipPopup = state["popup"];
  tooltipPopup.hide()
};
AdfSafariMobileAgent._getTitle = function(node) {
  var i = 0;
  var MAX_PARENTS = 20;
  while(node != null && i++ < MAX_PARENTS) {
    if(node.nodeType == 1) {
      var title = node.getAttribute("title");
      if(title && title.length > 0) {
        return title
      }
    }
    node = node.parentNode
  }
  return null
};
AdfSafariMobileAgent._TOOLTIP_HIDE_TIMEOUT = 3E3;
AdfSafariMobileAgent._TOOLTIP_PROPERTY_KEY = "oracle$adfinternal$tooltip";
