var debug_alerts = false;

/*jshint esversion:6 */
/*jshint strict:true */
var hhpEqualbrowsifyOptions = {
    "ajaxurl": "https:\/\/app.equalbrowse.com\/ajax",
    "nonce": "0000000000",
    "pluginURL": "https:\/\/app.equalbrowse.com\/",
    "onlineDictionary": "1",
    "language": "auto",
    "profileEpilepsy": "1",
    "profileVisuallyImpaired": "1",
    "profileCognitiveDisability": "1",
    "profileAdhdFriendly": "1",
    "profileBlindUsers": "1",
    "contentScaling": "1",
    "readableFont": "1",
    "dyslexiaFont": "1",
    "highlightTitles": "1",
    "highlightLinks": "1",
    "textMagnifier": "1",
    "fontSizing": "1",
    "lineHeight": "1",
    "letterSpacing": "1",
    "alignCenter": "1",
    "alignLeft": "1",
    "alignRight": "1",
    "darkContrast": "1",
    "lightContrast": "1",
    "monochrome": "1",
    "highSaturation": "1",
    "highContrast": "1",
    "lowSaturation": "1",
    "textColors": "1",
    "titleColors": "1",
    "backgroundColors": "1",
    "muteSounds": "1",
    "hideImages": "1",
    "virtualKeyboard": "1",
    "readingGuide": "1",
    "usefulLinks": "1",
    "stopAnimations": "1",
    "readingMask": "1",
    "highlightHover": "1",
    "highlightFocus": "1",
    "bigBlackCursor": "1",
    "bigWhiteCursor": "1",
    "textToSpeech": "1",
    "keyboardNavigation": "1",
    "showOpenButton": "1",
    "buttonPosition": "right-center",
    "buttonCaption": "",
    "buttonIcon": "_equalbrowsify\/equalbrowsify.svg",
    "buttonIconPosition": "before",
    "buttonSize": "16",
    "buttonMargin": "8",
    "buttonPadding": "8",
    "buttonBorderRadius": "23",
    "buttonColor": "rgba(255, 255, 255, 1)",
    "buttonColorHover": "rgba(33, 150, 243, 1)",
    "buttonBgcolor": "rgba(33, 150, 243, 1)",
    "buttonBgcolorHover": "rgba(255, 255, 255, 1)",
    "buttonEntranceTimeout": "0",
    "buttonEntranceAnimation": "fade",
    "buttonHoverAnimation": "none",
    "popupOverlayColor": "#0253ee",
    "popupBackgroundColor": "#ffffff",
    "popupKeyColor": "rgba(33, 150, 243, 1)",
    "popupBorderRadius": "0",
    "popupAnimation": "fade",
    "popupScroll": "",
    "closeAnywhere": "",
    "popupDraggable": "1",
    "hotKeyOpenInterface": "Alt+9",
    "LEARN_MORE_IN_WIKIPEDIA": "Learn more in Wikipedia",
    "DEFAULT": "Default",
    "HOME": "Home",
    "HIDE_ACCESSIBILITY_INTERFACE": "Hide Accessibility Interface? \n\nPlease note: If you choose to hide the accessibility interface, you won't be able to see it anymore, unless you clear clear cookies for this site. Are you sure that you wish to hide the interface?",
    "highlightTitlesStyle": "solid",
    "highlightTitlesColor": "#639af9",
    "highlightTitlesWidth": "2",
    "highlightTitlesOffset": "2",
    "highlightLinksStyle": "solid",
    "highlightLinksColor": "#639af9",
    "highlightLinksWidth": "2",
    "highlightLinksOffset": "2",
    "textMagnifierBgColor": "#333333",
    "textMagnifierColor": "#ffffff",
    "textMagnifierFontSize": "36",
    "readingGuideWidth": "500",
    "readingGuideHeight": "12",
    "readingGuideBackgroundColor": "#0274e6",
    "readingGuideBorderColor": "#000000",
    "readingGuideBorderWidth": "2",
    "readingGuideBorderRadius": "10",
    "readingMaskHeight": "100",
    "readingMaskColor": "rgba(0, 0, 0, 0.7)",
    "highlightHoverStyle": "solid",
    "highlightHoverColor": "#639af9",
    "highlightHoverWidth": "2",
    "highlightHoverOffset": "2",
    "highlightFocusStyle": "solid",
    "highlightFocusColor": "#639af9",
    "highlightFocusWidth": "2",
    "highlightFocusOffset": "2",
    "virtualKeyboardLayout": "english",
    "textToSpeechAjaxUrl": "https:\/\/app.equalbrowse.com\/ajax",
    "textToSpeechNonce": "0000000000",
    "hotKeyMenu": "M",
    "hotKeyHeadings": "H",
    "hotKeyForms": "F",
    "hotKeyButtons": "B",
    "hotKeyGraphics": "G"
};
(function() {
    'use strict';

    var options = {
        'base_url': 'https://app.equalbrowse.com/',
        'version': '1.2.1',
        'default_active_features': ['hhp-equalbrowsify-action-highlight-focus']
    };

    var scriptQueueCount = 0;
    var scriptQueueCallbacks = [];

    var readerViewAvailable = false;
    var readerArticleConstraint = false;

    var mainContent;

    var getHtml = function(url, callback, fail) {
        var xhrobj = new XMLHttpRequest();
        xhrobj.onreadystatechange = function () {
            if (this.readyState == 4) {
                if (this.status == 200) {
                    callback(xhrobj.responseText);
                } else {
                    if (typeof fail != 'undefined') {
                        fail();
                    }
                }
            }
        };
        xhrobj.open('GET', url);
        xhrobj.send(null);
    };

    var processTemplate = function(html, vars) {
        var r = html;
        for (var i in vars) {
            r = r.replace(new RegExp('{' + i + '}', 'g'), vars[i]);
        }
        return r;
    };

    var injectCss = function(url, id, disabled) {
        var link = document.createElement('link');
        link.href = url;
        link.type = "text/css";
        link.rel = "stylesheet";
        if (id) {
            link.id = id;
        }
        if (disabled) {
            link.disabled = true;
        }
        document.getElementsByTagName('head')[0].appendChild(link);
    };

    var injectJs = function(url, callback, callbackAll) {
        if (typeof callbackAll != 'undefined') {
            scriptQueueCallbacks.push(callbackAll);
        }
        scriptQueueCount++;
        var script = document.createElement('script');
        script.onload = function() {
            scriptQueueCount--;
            if (typeof callback != 'undefined' && callback !== null) {
                callback();
            }
            if (scriptQueueCount === 0) {
                if (scriptQueueCallbacks.length) {
                    // These callback functions are called only after the JS injection queue is empty
                    for (var i in scriptQueueCallbacks) {
                        scriptQueueCallbacks[i]();
                    }
                }
            }
        };
        script.src = url;
        document.getElementsByTagName('head')[0].appendChild(script);
    };

    var appendHtml = function(element, html) {
        var div = document.createElement('div');
        div.innerHTML = html.trim();
        var children = div.children;
        while (children.length > 0) {
            element.appendChild(children[0]);
        }
    };

    var switchReaderView = function(status) {
        var i, j, clickEvent, origTtsStatus, ttsBtn;

        var textmode = document.getElementById('equalbrowse-text-only');
        var children = document.body.children;

        // do not hide these:
        var protectedElements = ['#equalbrowse-text-only', '#hhp-equalbrowsify-popup-box', '.hhp-equalbrowsify-trigger-button-box']; 

        var docBody = document.getElementsByTagName('body')[0];

        if (status) {
            // Hide everything
            childrenLoop:
            for (i = 0; i < children.length; i++) {
                if (typeof children[i] == 'undefined') {
                    continue;
                }
                for (j = 0; j < protectedElements.length; j++) {
                    if (children[i].matches(protectedElements[j])) {
                        continue childrenLoop;
                    }
                }
                children[i].classList.add('equalbrowse-read-mode-hide');
            }

            // Add body classes. Preserve highlight focus if enabled
            var origClass = docBody.getAttribute('class');
            var readerClass = 'light sans-serif loaded';
            if (origClass.match(/hhp-equalbrowsify-highlight-focus/)) {
                readerClass += ' hhp-equalbrowsify-highlight-focus';
            }
            docBody.dataset.origClass = origClass;
            docBody.setAttribute('class', readerClass);

            // Store previous TTS status
            ttsBtn = document.getElementById('hhp-equalbrowsify-action-text-to-speech');
            origTtsStatus = ttsBtn.classList.contains('hhp-active') ? 1 : 0;
            docBody.dataset.origTtsStatus = origTtsStatus;

            // Activate TTS if not active
            if (!origTtsStatus) {
                clickEvent = new Event("click", {'bubbles': true});
                ttsBtn.dispatchEvent(clickEvent);
            }

            // Enable reader CSS
            document.getElementById('reader-mode-css').disabled = false;

            if (textmode) {
                textmode.style.display = 'block';
            }
        } else {
            // Show everything
            for (i = 0; i <= children.length; i++) {
                if (typeof children[i] == 'undefined') {
                    continue;
                }
                children[i].classList.remove('equalbrowse-read-mode-hide');
            }

            // Disable reader CSS
            document.getElementById('reader-mode-css').disabled = true;

            // Reset body classes
            if (typeof docBody.dataset.origClass != 'undefined') {
                docBody.setAttribute('class', docBody.dataset.origClass);
                delete docBody.dataset.origClass;
            }

            // Restore previous TTS status
            origTtsStatus = docBody.dataset.origTtsStatus;
            if (parseInt(origTtsStatus) === 0) {
                clickEvent = new Event("click", {'bubbles': true});
                ttsBtn = document.getElementById('hhp-equalbrowsify-action-text-to-speech');
                ttsBtn.dispatchEvent(clickEvent);
            }

            if (textmode) {
                textmode.style.display = 'none';
            }
        }
    };

    var toggleReaderView = function(e) {
        // Disable
        var tgt = document.getElementById('hhp-equalbrowsify-action-reader-view');
        if (!tgt) {
            return;
        }
        if (!tgt.classList.contains('hhp-active')) {
            switchReaderView(false);
            return;
        }

        // Enable
        var textmode = document.getElementById('equalbrowse-text-only');
        if (!document.getElementById('equalbrowse-text-only')) {
            var articleElms = document.querySelectorAll('article');
            var documentClone;
            if (readerArticleConstraint && articleElms.length > 0) {
                // create empty document
                documentClone = document.implementation.createHTMLDocument();
                // clone <article> elements into new document
                articleElms.forEach(function(articleElm) {
                    var articleElmClone = articleElm.cloneNode(true);
                    documentClone.body.appendChild(articleElmClone);
                });
                documentClone.querySelectorAll('.cff-timeline-feed').forEach(function(elm) {
                    // We don't want these
                    elm.parentNode.removeChild(elm);
                });
            } else {
                // Generate full document clone first
                documentClone = document.cloneNode(true);

                // Remove the widget itself from the cloned document
                var widgetClone = documentClone.getElementById('hhp-equalbrowsify-popup-box');
                if (widgetClone) {
                    widgetClone.parentNode.removeChild(widgetClone);
                }
            }

            // Get text-only content
            var article = new Readability(documentClone).parse();

            // Add new div with text-only content
            var textOnlyDiv = document.createElement('div');
            textOnlyDiv.id = 'equalbrowse-text-only';
            textOnlyDiv.style.display = 'none';

            var readerContent = '<div class="container">' +
                '<div class="header reader-header reader-show-element">' +
                '<a class="domain reader-domain" href="' + window.location.href + '">' +
                window.location.hostname +
                '</a>' +
                '<div class="domain-border"></div>' +
                '<h1 class="reader-title">' + article.title + '</h1>' +
                '</div>' +
                '<hr>' +
                '<div class="content">' +
                '<div class="moz-reader-content reader-show-element">' + article.content + '</div>' +
                '</div>' +
                '</div>';
            textOnlyDiv.innerHTML = readerContent;
            document.body.append(textOnlyDiv);

            // Add links drop-down
            var links = document.getElementById('hhp-equalbrowsify-useful-links');
            if (links) {
                var linksClone = links.cloneNode(true);
                linksClone.id = 'hhp-equalbrowsify-useful-links-reader-view'; // change id to prevent conflicts

                var linksDiv = document.createElement('div');
                linksDiv.className = 'hhp-equalbrowsify-links-dropdown-div';
                
                var linksBtn = document.createElement('button');
                linksBtn.setAttribute('type', 'button');
                linksBtn.setAttribute('id', 'hhp-equalbrowsify-links-go');
                linksBtn.innerHTML = 'Go &raquo;';
                linksBtn.addEventListener('click', function(e) {
                    window.location.href = document.getElementById('hhp-equalbrowsify-useful-links-reader-view').value;
                });

                linksDiv.append(linksClone);
                linksDiv.append(linksBtn);

                document.querySelector('#equalbrowse-text-only .content').prepend(linksDiv);
            }

        }
        switchReaderView(true);
    };

    var queryVisible = function(selector) {
        return Array.prototype.slice.call(
            document.querySelectorAll(selector)
        ).filter(
            function (item,index) {
                return item.style.display != "none";
            }
        );
    };

    var scrollTo = function(element, offset) {
        if (typeof offset == 'undefined') {
            offset = -250;
        }
        if (!element.getBoundingClientRect) {
            return false;
        }
        var pos = element.getBoundingClientRect().top + offset;
        window.scroll({
            top: pos, 
            left: 0, 
            behavior: 'smooth'
        });
    };

    document.addEventListener('DOMContentLoaded', function(event) {

        if (document.cookie.split(';').some((item) => item.includes('hhp-equalbrowsify-hide=1'))) {
            return;
        }

        // Set defaults
        var prefix = 'hhpEqualbrowsify';
        var key;
        for (var i in options.default_active_features) {
            key = prefix + options.default_active_features[i];
            if (localStorage.getItem(key) === null || localStorage.getItem('equalbrowse-last-version') !== options.version) {
                localStorage.setItem(key, true);
            }
        }
        localStorage.setItem('equalbrowse-last-version', options.version);

        // Inject CSS
        injectCss('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');
        injectCss(options.base_url + 'css/equalbrowsify.min.css?v=' + options.version);
        injectCss(
            options.base_url +
                'panel/css/60d5877ce6/accessibility.css?v=' +
                options.version
        );
        injectCss(options.base_url + 'reader.css?v=' + options.version, 'reader-mode-css', true);

        // Inject HTML
        getHtml(options.base_url + 'panel/html/60d5877ce6/v' + options.version, function(html) {
            /*
            var data = {
                'hostname': window.location.hostname,
                'today': new Date().toLocaleDateString(undefined, {year:'numeric', month: 'long', day: 'numeric'})
            };
            */
            appendHtml(document.body, html);

            // Inject JS
            var scripts = [
                'micromodal.min.js',
                'hotkeys.min.js',
                'simple-keyboard.min.js',
                'simple-keyboard-layouts/index.min.js',
                'readability/Readability.js',
                'readability/Readability-readerable.js',
                'detect-main-content.js'
            ];
            for (var i in scripts) {
                injectJs(options.base_url + 'js/' + scripts[i] + '?v=' + options.version);
            }
            injectJs(options.base_url + 'js/equalbrowsify.js?v=' + options.version, null, function() {
                var equalbrowsifyReadyEvent = new Event('equalbrowsifyReady');
                document.dispatchEvent(equalbrowsifyReadyEvent);

                var readerView = document.querySelector('#hhp-equalbrowsify-action-reader-view');
                var textMagnifier = document.querySelector('#hhp-equalbrowsify-action-text-magnifier');
                if (document.querySelectorAll("article").length == 1) {
                    readerViewAvailable = true;
                    readerArticleConstraint = true; // there is exactly one <article> tag
                }
                if (document.querySelector("meta[property='og:type'][content='article']") !== null) {
                    readerViewAvailable = true;
                }
                if (isProbablyReaderable(
                    document,
                    {
                        minContentLength: 250,
                        minScore: 250                    }
                )) {
                    readerViewAvailable = true;
                }
                if (readerViewAvailable) {
                    // Show button
                    readerView.classList.add('visible');
                    textMagnifier.classList.add('halfwidth');

                    // Listen for Reader View change
                    readerView.addEventListener('EqualbrowsifyToggleBoxChanged', toggleReaderView);

                    // Check if it is already active
                    if (readerView.classList.contains('hhp-active')) {
                        toggleReaderView();
                    }
                }

                // Fix for Firefox not supporting CSS zoom
                // Listen for content scaling change
                var contentScaling = document.querySelector( '#hhp-equalbrowsify-action-content-scaling .hhp-equalbrowsify-value' );
                contentScaling.addEventListener('EqualbrowsifyInputSpinnerChanged', function() {
                    if (navigator.userAgent.toLowerCase().indexOf('firefox') > 0) {
                        var transform = window.getComputedStyle(document.body, null).getPropertyValue('-moz-transform');
                        var scale = 1;
                        if (transform !== 'none') {
                            scale = parseFloat(transform.split('(')[1].split(')')[0]);
                        }
                        var popup = document.querySelector('#hhp-equalbrowsify-popup');
                        if (popup !== null) {
                            var prevScale = 1;
                            if (popup.dataset.prevScale) {
                                prevScale = popup.dataset.prevScale;
                            }
                            if (popup.dataset.start && popup.dataset.start == 'right') {
                                popup.style.right = parseInt(document.body.offsetWidth * (scale - 1)) + 'px';
                            } else {
                                var t = parseInt(popup.style.top);
                                var l = parseInt(popup.style.left);
                                t = t / scale * prevScale;
                                l = l / scale * prevScale;
                                popup.style.top = parseInt(t) + 'px';
                                popup.style.left = parseInt(l) + 'px';
                            }
                            popup.dataset.prevScale = scale;
                        }
                    }
                });

                // Filter link navigator
                var links = document.getElementById('hhp-equalbrowsify-useful-links');
                var link_filters = (["\/^View on Facebook$\/i","\/^Share.*\/i","\/.*powered by.*\/i","\/Listable\/","\/Pixelgrade\/"]);
                var flags, pattern, regex, i, j;
                var remove_these = [];
                if (links) {
                    linksLoop:
                    for (i = 0; i < links.options.length; i++) {
                        for (j in link_filters) {
                            flags = link_filters[j].replace(/.*\/([gimy]*)$/, '$1');
                            pattern = link_filters[j].replace(new RegExp('^/(.*?)/' + flags + '$'), '$1');
                            regex = new RegExp(pattern, flags);
                            if (links.options[i].text.match(regex)) {
                                remove_these.push(links.options[i]);
                                continue linksLoop;
                            }
                        }

                        // Make sure link is visible
                        if (queryVisible('a[href="' + links.options[i].value + '"]').length == 0) {
                            remove_these.push(links.options[i]);
                        }
                    }
                }
                for (i in remove_these) {
                    remove_these[i].parentNode.removeChild(remove_these[i]);
                }

                var paletteChangedHandler = function(e) {
                    var colorButtons = document.querySelectorAll(
                        '.hhp-equalbrowsify-color-box .hhp-equalbrowsify-color'
                    );
                    for (var i = 0; i < colorButtons.length; i++) {
                        if (colorButtons[i].classList.contains('hhp-active')) {
                            colorButtons[i].style.setProperty(
                                'background-color',
                                'var(--equalbrowsify-bg)',
                                'important'
                            );
                            colorButtons[i].style.setProperty(
                                '--equalbrowsify-palette-color',
                                colorButtons[i].dataset.color
                            );
                        } else {
                            colorButtons[i].style.setProperty(
                                'background-color',
                                colorButtons[i].dataset.color,
                                'important'
                            );
                        }
                    }
                };
                document
                    .querySelector('.hhp-equalbrowsify-palette-box')
                    .addEventListener(
                        'EqualbrowsifyPaletteChanged',
                        paletteChangedHandler
                    );
                paletteChangedHandler();

                // Handle tab menu
                var tabMenuOpener = document.createElement('div');
                tabMenuOpener.setAttribute('tabindex', '1');
                tabMenuOpener.setAttribute('id', 'hhp-equalbrowsify-tab-menu-opener');
                document.body.prepend(tabMenuOpener);

                var showNextTabOption = function(event) {
                    if (document.getElementById('hhp-equalbrowsify-tab-nav').style.display != 'block') {
                        // Show first option
                        document.getElementById('hhp-equalbrowsify-tab-nav').style.display = 'block';
                        var firstOption = document.querySelector('.hhp-equalbrowsify-tab-nav-option');
                        firstOption.style.display = 'block';
                        firstOption.focus();
                        event.preventDefault();
                    } else {
                        // Show next option
                        var opts = document.querySelectorAll('.hhp-equalbrowsify-tab-nav-option');
                        var currentOption = null;
                        var nextOption = null;
                        for (var i = 0; i < opts.length; i++) {
                            if (opts[i].style.display == 'block') {
                                currentOption = opts[i];
                                if (i + 1 < opts.length) {
                                    nextOption = opts[i + 1];
                                }
                                break;
                            }
                        }
                        currentOption.style.display = 'none';
                        if (nextOption !== null) {
                            nextOption.style.display = 'block';
                            nextOption.focus();
                            event.preventDefault();
                        } else {
                            document.getElementById('hhp-equalbrowsify-tab-nav').style.display = 'none';
                        }
                    }

                };

                var showPrevTabOption = function(event) {
                    var opts = document.querySelectorAll('.hhp-equalbrowsify-tab-nav-option');
                    if (document.getElementById('hhp-equalbrowsify-tab-nav').style.display != 'block') {
                        // Show last option
                        document.getElementById('hhp-equalbrowsify-tab-nav').style.display = 'block';
                        var lastOption = opts[opts.length - 1];
                        lastOption.style.display = 'block';
                        lastOption.focus();
                        event.preventDefault();
                    } else {
                        // Show previous option
                        var opts = document.querySelectorAll('.hhp-equalbrowsify-tab-nav-option');
                        var currentOption = null;
                        var prevOption = null;
                        for (var i = 0; i < opts.length; i++) {
                            if (opts[i].style.display == 'block') {
                                currentOption = opts[i];
                                if (i > 0) {
                                    prevOption = opts[i - 1];
                                }
                                break;
                            }
                        }
                        currentOption.style.display = 'none';
                        if (prevOption !==  null) {
                            prevOption.style.display = 'block';
                            prevOption.focus();
                            event.preventDefault();
                        } else {
                            document.getElementById('hhp-equalbrowsify-tab-nav').style.display = 'none';
                        }
                    }
                };

                var tabNavActivateOption = function(optionName) {
                    if (optionName == 'hhp-equalbrowsify-tab-nav-option-open') {
                        var button = document.querySelector('[data-equalbrowsify-trigger]');
                        if (button === null) {
                            button = document.querySelector('.equalbrowsify-trigger');
                        }
                        if (button === null) {
                            button = document.createElement('button');
                            button.style.width = 0;
                            button.style.height = 0;
                            button.setAttribute('class', 'equalbrowsify-trigger');
                            button.setAttribute('type', 'button');
                            document.getElementsByTagName('body')[0].appendChild(button);
                        }
                        if (button !== null) {
                            // Simulate click on accessibility button
                            var clickEvent = new Event("click", {'bubbles': true});
                            var res = button.dispatchEvent(clickEvent);
                        }
                    } else if (optionName == 'hhp-equalbrowsify-tab-nav-option-visual') {
                        // Toggle blindness mode unless it is already active
                        var slider = document.querySelector('#hhp-equalbrowsify-accessibility-profile-blind-users');
                        if (slider !== null && !slider.classList.contains('hhp-active')) {
                            // Simulate click
                            var clickEvent = new Event("click", {'bubbles': true});
                            var res = slider.dispatchEvent(clickEvent);
                        }
                    } else if (optionName == 'hhp-equalbrowsify-tab-nav-option-skip') {
                        // Detect main content block and skip to it
                        if (!mainContent) {
                            mainContent = detectMainContent();
                        }
                        if (mainContent) {
                            scrollTo(mainContent);
                        }
                    }

                    // Hide tab navigation
                    document.getElementById(optionName).style.display = '';
                    document.getElementById('hhp-equalbrowsify-tab-nav').style.display = 'none';
                }
                document.body.addEventListener('keydown', function(event) {
                    var code = event.keyCode || event.which;
                    var shiftKey = event.shiftKey;

                    // Enter
                    if (code === 13) {
                        var opts = document.querySelectorAll('.hhp-equalbrowsify-tab-nav-option');
                        var currentOption = null;
                        for (var i = 0; i < opts.length; i++) {
                            if (opts[i].style.display == 'block') {
                                currentOption = opts[i];
                                setTimeout(function() {
                                    tabNavActivateOption(currentOption.id);
                                }, 100);
                                break;
                            }
                        }
                    }

                    // Tab
                    if (code === 9) {
                        if (shiftKey) {
                            if (document.activeElement === tabMenuOpener ||
                                document.activeElement.classList.contains('hhp-equalbrowsify-tab-nav-option')
                            ) {
                                showPrevTabOption(event);
                            }
                        } else {
                            if (document.activeElement === tabMenuOpener ||
                                document.activeElement.classList.contains('hhp-equalbrowsify-tab-nav-option')
                            ) {
                                showNextTabOption(event);
                            }
                        }
                    }
                });
            });
        });
    });

}());
