var AdfFocusUtils={containsFocus:function(a){for(var b=AdfPage.PAGE.getActiveDomElement();null!=b;){if(b==a)return!0;b=b.parentNode}return!1},focusElement:function(a,b,d){AdfAssert.assertDomElement(a);AdfPopupScopingUtils.scope(a);AdfFocusUtils._focusElementImpl(a,b,d)},isFocusChangePending:function(){return null!=AdfFocusUtils._delayFocusTimerId},focusFirstDocumentTabStop:function(){var a=AdfPage.PAGE.getDocument().body,a=AdfFocusUtils.getFirstTabStop(a,!0);null!=a&&-999>=a.offsetTop&&(a=AdfFocusUtils.getNextTabStop(a));
null!=a&&AdfFocusUtils.focusElement(a);return a},focusFirstTabStop:function(a,b){AdfAssert.assertDomElement(a);var d=AdfFocusUtils.getFirstTabStop(a,b);null!=d&&AdfFocusUtils.focusElement(d);return d},focusLastTabStop:function(a,b){AdfAssert.assertDomElement(a);var d=AdfFocusUtils.getLastTabStop(a,b);null!=d&&AdfFocusUtils.focusElement(d);return d},focusNextTabStop:function(a,b,d,e,f){d=AdfFocusUtils.getNextTabStop(a,b,d);d||(b||(b=a.ownerDocument.documentElement),d=AdfFocusUtils.getFirstTabStop(b,
!0));d&&AdfFocusUtils.focusElement(d,e,f);return d},focusPreviousTabStop:function(a,b,d,e,f){d=AdfFocusUtils.getPreviousTabStop(a,b,d);d||(b||(b=a.ownerDocument.documentElement),d=AdfFocusUtils.getLastTabStop(b,!0));d&&AdfFocusUtils.focusElement(d,e,f);return d},getFirstTabStop:function(a,b){return AdfDomUtils.getFirstElementMatch(a,b,AdfFocusUtils.isTabStop)},getLastTabStop:function(a,b){return AdfDomUtils.getLastElementMatch(a,b,AdfFocusUtils.isTabStop)},getNextTabStop:function(a,b,d){return AdfDomUtils.getNextElementMatch(a,
b,d,AdfFocusUtils.isTabStop)},getPreviousTabStop:function(a,b){return AdfDomUtils.getPreviousElementMatch(a,b,AdfFocusUtils.isTabStop)},isTabStop:function(a){return null!=a&&-1<a.tabIndex&&AdfFocusUtils.isFocusable(a)},isFocusable:function(a,b){return AdfFocusUtils.acceptFocusableNode(a,b)==AdfDomUtils.FILTER_ACCEPT},acceptFocusableNode:function(a,b){if(null==a||1!=a.nodeType||a.disabled||-1>AdfDomUtils.getTabIndex(a))return AdfDomUtils.FILTER_REJECT;if(!AdfFocusUtils._isFocusableType(a))return AdfDomUtils.FILTER_SKIP;
AdfFocusUtils._setupContext(b);return AdfFocusUtils.isConnectedAndVisible(a,b)?AdfDomUtils.FILTER_ACCEPT:AdfDomUtils.FILTER_REJECT},_setupContext:function(a){if(a&&!a.positiveValue){var b=(new Date).getTime();a.positiveValue="y"+b;a.negativeValue="n"+b}},calculateCachedValue:function(a,b,d){if(b&&a&&d){a=AdfAgent.AGENT.getAttribute(a,d);if(a==b.positiveValue)return!0;if(a==b.negativeValue)return!1}},setCacheValue:function(a,b,d,e){b&&a&&d&&void 0!=e&&AdfAgent.AGENT.setExpandoProperty(a,d,e?b.positiveValue:
b.negativeValue)},isConnectedAndVisible:function(a,b){AdfAssert.assertDomElement(a);var d=AdfAgent.AGENT.getDomDocument().documentElement,e=AdfFocusUtils.calculateCachedValue(a,b,"_afrFoc");if(void 0!=e)return e;if(!AdfFocusUtils._isVisible(a))return AdfFocusUtils.setCacheValue(a,b,"_afrFoc",!1),!1;if(a==d)return AdfFocusUtils.setCacheValue(a,b,"_afrFoc",!0),!0;d=null==a.parentNode||1!=a.parentNode.nodeType?!1:AdfFocusUtils.isConnectedAndVisible(a.parentNode,b);AdfFocusUtils.setCacheValue(a,b,"_afrFoc",
d);return d},_isVisible:function(a,b){b||(b=AdfAgent.AGENT.getComputedStyle(a));return AdfFocusUtils._isDisplayNone(a,b)?!1:!AdfFocusUtils._isVisibilityHidden(a,b)},_isVisibilityHidden:function(a,b){b||(b=AdfAgent.AGENT.getComputedStyle(a));return b&&"hidden"==b.visibility},_isDisplayNone:function(a,b){b||(b=AdfAgent.AGENT.getComputedStyle(a));return!b||"none"!=b.display||"none"!=a.style.display&&AdfPopupScopingUtils.isScopingContainer(a)&&AdfPopupScopingUtils.isOutOfScope(a)?!1:!0},_isFocusableType:function(a){AdfAssert.assertDomElement(a);
var b=AdfDomUtils.getTabIndex(a);switch(a.nodeName.toLowerCase()){case "a":if(!a.href&&void 0==b)return!1;case "input":if("hidden"==a.type&&1!=a.isContentEditable)return!1;case "area":case "body":case "button":case "frame":case "iframe":case "isindex":case "object":case "select":case "textarea":return!0;default:return-1<=b?!0:!1}},focusElementDelayed:function(a,b){AdfAssert.assertDomElement(a);AdfAssert.assertNumber(b);var d=AdfPage.PAGE,e=AdfFocusUtils._delayFocusTimerId;e&&d.cancelTimer(e);AdfFocusUtils._delayFocusTimerId=
d.scheduleTimer(null,AdfFocusUtils._focusElementDelayedCallback,a,b)},_focusElementDelayedCallback:function(a){AdfFocusUtils._delayFocusTimerId=null;AdfFocusUtils._focusElementImpl(a)},_focusElementImpl:function(a,b,d){try{var e=AdfAgent.AGENT,f=e.getDomWindow();a.setActive&&11>e.getVersion()&&a.setActive();b&&1==b?a.focus({preventScroll:!0}):(a.focus(),f.AdfSafariMobileAgent&&e instanceof AdfSafariMobileAgent||!d||"text"==a.type&&"INPUT"==a.tagName&&a.setSelectionRange(0,a.value.length))}catch(g){AdfLogger.LOGGER.logErrorAsWarning(g,
" when calling _focusElementImpl")}},focusNextActiveDescendant:function(a,b,d){AdfAssert.assertDomElement(a);AdfAssert.assertDomElement(b);var e=AdfFocusUtils.getNextFocusableDescendant(a,b);if(!e)if(d)e=AdfFocusUtils.getFirstFocusableDescendant(a);else return e;e&&e!=b&&(b.setAttribute("tabIndex","-1"),e.setAttribute("tabIndex","0"),AdfFocusUtils.focusElement(e));return e},focusPreviousActiveDescendant:function(a,b,d){AdfAssert.assertDomElement(a);AdfAssert.assertDomElement(b);var e=AdfFocusUtils.getPreviousFocusableDescendant(a,
b);if(!e)if(d)e=AdfFocusUtils.getLastFocusableDescendant(a);else return e;e&&e!=b&&(b.setAttribute("tabIndex","-1"),e.setAttribute("tabIndex","0"),AdfFocusUtils.focusElement(e));return e},setFirstActiveDescendant:function(a,b){AdfAssert.assertDomElement(a);var d=AdfFocusUtils.getFirstFocusableDescendant(a,b);d&&d.setAttribute("tabIndex","0");return d},setupCompositeWidget:function(a){AdfAssert.assertDomElement(a);for(var b={includeVisibilityHidden:!0,includeDisplayNone:!1,includeDisabled:!0},d=AdfFocusUtils.getFirstFocusableDescendant(a,
b);d;)d.setAttribute("tabIndex","-1"),d=AdfFocusUtils.getNextFocusableDescendant(a,d,b);return AdfFocusUtils.setFirstActiveDescendant(a)},getFirstFocusableDescendant:function(a,b){AdfAssert.assertDomElement(a);return AdfDomUtils.getFirstFilteredElement(a,!1,AdfFocusUtils.isFocusableDescendant,b)},getLastFocusableDescendant:function(a,b){AdfAssert.assertDomElement(a);return AdfDomUtils.getLastFilteredElement(a,!1,AdfFocusUtils.isFocusableDescendant,b)},getNextFocusableDescendant:function(a,b,d){AdfAssert.assertDomElement(a);
AdfAssert.assertDomElement(b);return AdfDomUtils.getNextFilteredElement(b,a,!0,AdfFocusUtils.isFocusableDescendant,d)},getPreviousFocusableDescendant:function(a,b,d){AdfAssert.assertDomElement(a);AdfAssert.assertDomElement(b);return AdfDomUtils.getPreviousFilteredElement(b,a,AdfFocusUtils.isFocusableDescendant,d)},getFirstUnmarkedTabstop:function(a){AdfAssert.assertDomElement(a);return AdfDomUtils.getFirstFilteredElement(a,!1,AdfFocusUtils.isUnmarkedTabstop)},isUnmarkedTabstop:function(a){var b=AdfLogger.LOGGER;
if(null==a||1!=a.nodeType)return b.isLoggable(AdfLogger.FINE)&&b.fine("isUnmarkedTabstop: Null or not element node type"),AdfDomUtils.FILTER_REJECT;var d=AdfFocusUtils._isDisplayNone(a);if(d)return b.isLoggable(AdfLogger.FINE)&&b.fine("isUnmarkedTabstop: Node display none: "+d+", node tree: "+a.id+" "+a.nodeName),AdfDomUtils.FILTER_REJECT;if(a.attributes[AdfFocusUtils.DESCENDANT_FOCUSABLE])return b.isLoggable(AdfLogger.FINE)&&b.fine("isUnmarkedTabstop: Node is a marked tabstop: "+a.id+" "+a.nodeName),
AdfDomUtils.FILTER_REJECT;if(AdfFocusUtils.isTabStop(a))return b.isLoggable(AdfLogger.FINE)&&b.fine("isUnmarkedTabstop: Found node that is an unmarked tabstop: "+a.id+" "+a.nodeName),AdfDomUtils.FILTER_ACCEPT;b.isLoggable(AdfLogger.FINE)&&b.fine("isUnmarkedTabstop: Node not a tabstop: "+a.id+" "+a.nodeName);return AdfDomUtils.FILTER_SKIP},isFocusableDescendant:function(a,b){var d=AdfLogger.LOGGER;b=null==b?{includeVisibilityHidden:!1,includeDisplayNone:!1,includeDisabled:!1}:b;if(null==a||1!=a.nodeType)return d.isLoggable(AdfLogger.FINE)&&
d.fine("isFocusableDescendant? Skip and reject tree: Null or not element node type"),AdfDomUtils.FILTER_REJECT;var e=AdfAgent.AGENT.getComputedStyle(a);if(AdfFocusUtils._isVisibilityHidden(a,e)&&!b.includeVisibilityHidden)return d.isLoggable(AdfLogger.FINE)&&d.fine("isFocusableDescendant? Skip and reject tree, Node is visibility hidden, node: "+a.id+" "+a.nodeName),AdfDomUtils.FILTER_REJECT;if(AdfFocusUtils._isDisplayNone(a,e)&&!b.includeDisplayNone)return d.isLoggable(AdfLogger.FINE)&&d.fine("isFocusableDescendant? Skip and reject tree, Node is display none, node: "+
a.id+" "+a.nodeName),AdfDomUtils.FILTER_REJECT;e=a.attributes[AdfFocusUtils.DESCENDANT_FOCUSABLE];if(!e)return d.isLoggable(AdfLogger.FINE)&&d.fine("isFocusableDescendant? Skip, node not focusable, node: "+a.id+" "+a.nodeName),AdfDomUtils.FILTER_SKIP;if("true"==e.value)return d.isLoggable(AdfLogger.FINE)&&d.fine("isFocusableDescendant? Accept, node focusable TRUE, node: "+a.id+" "+a.nodeName),AdfDomUtils.FILTER_ACCEPT;if("false"==e.value)return d.isLoggable(AdfLogger.FINE)&&d.fine("isFocusableDescendant? Node focusable FALSE, node: "+
a.id+" "+a.nodeName),b.includeDisabled?AdfDomUtils.FILTER_ACCEPT:AdfDomUtils.FILTER_REJECT;d.isLoggable(AdfLogger.FINE)&&d.fine("isFocusableDescendant? Skip, invalid value found: "+e.name+" "+e.value);return AdfDomUtils.FILTER_SKIP},DESCENDANT_FOCUSABLE:"data-afr-fcs"};