(function(w){
    // Config objs
    var config = {
        endpoint: 'https://a11ystatusfb.usablenet.com/lv/aaas/forward7/28e84b2a18e193c3da5a9328a94fa66ad3bd546c3cf/feedback',
        tokenURI: 'https://a11ystatusfb.usablenet.com/lv/aaas/forward7/28e84b2a18e193c3da5a9328a94fa66ad3bd546c3cf/token',
        panelHTML: '<button id="un-s-open" aria-haspopup="dialog" lang="en">About Accessibility Status</button><div id="un-s" role="dialog" aria-hidden="true" aria-modal="true"></div><div id="un-s-overlay"></div>',
        panelContentHTML: ' <div id="un-s-header" class="un-s-component"> <button id="un-s-close" class="un-s-bold" title="Closes the Accessibility Status panel">Close</button> </div> <div id="un-s-wrapper" class="un-s-component"> <h1 id="un-s-title">Accessibility Status</h1> <p> To make sure everyone can use this website without barriers we have engaged the accessibility services of UsableNet Inc. </p> <p> This screen provides information about this website’s ongoing efforts to keep the site accessible and usable by people with disabilities. </p> <p> In addition, as part of our commitment to accessibility, you can find <span >a contact us form for accessibility support at the end of this panel and</span> an accessibility statement in the footer of every page of this website. </p> <h2>Status of verification services:</h2> <ul id="un-s-status"> <li class="un-s-bold"> Site key task verified by blind users with screen readers.<br/> <span class="ok-status">Active and ongoing</span> </li> <li class="un-s-bold"> Monitoring of pages against WCAG.<br/> <span class="ok-status">Active and ongoing</span> </li> <li class="un-s-bold"> Annual Audit and User Testing.<br/> <span class="ok-status">Active and ongoing</span> </li> </ul> <div > <h2>Contact for Accessibility Support</h2> <form onSubmit="return false;" id="un-s-feedback" name="un-s-feedback"> <fieldset id="un-s-srq" class="un-s-input-row"> <legend class="un-s-input-label un-s-bold"> <sup>*</sup>Do you use assistive technology such as a screen reader? </legend> <div id="un-s-radio-row"> <div class="un-s-radio-wrapper"> <input type="radio" id="un-s-btn-yes" name="at" aria-required="true"/> <label for="un-s-btn-yes" class="un-s-bold">Yes</label> </div> <div class="un-s-radio-wrapper"> <input type="radio" id="un-s-btn-no" name="at" aria-required="true" /> <label for="un-s-btn-no" class="un-s-bold">No</label> </div> </div> <div class="un-s-error-txt"> Please select an answer. </div> </fieldset> <div class="un-s-input-row"> <label class="un-s-input-label un-s-bold" for="un-s-i-msg"> <sup>*</sup>How can we help? </label> <textarea class="un-s-input" id="un-s-i-msg" name="content" rows="4" aria-required="true"></textarea> <div class="un-s-error-txt"> This field is required. </div> </div> <div class="un-s-input-row"> <label class="un-s-input-label un-s-bold" for="un-s-i-name"> <sup>*</sup>Name </label> <input type="text" class="un-s-input" name="name" id="un-s-i-name" autocomplete="name" aria-required="true"> <div class="un-s-error-txt"> This field is required. </div> </div> <div class="un-s-input-row"> <label class="un-s-input-label un-s-bold" for="un-s-i-email"> <sup>*</sup>Email </label> <input type="email" class="un-s-input" name="email" id="un-s-i-email" autocomplete="email" aria-required="true"> <div class="un-s-error-txt"> This field is required. </div> </div> <div class="un-s-input-row"> <button id="un-s-submit" class="un-s-bold">Submit feedback</button> </div> <input type="hidden" name="token" id="un-s-token" value=""/> </form> </div> <div id="un-s-confirmation" tabindex="-1"> <p class="un-s-d un-s-bold">Thank you for submitting.</p> <p class="un-s-l un-s-bold">Your message has been forwarded and you should expect a response shortly.</p> <p class="un-s-d un-s-bold"> UsableNet Team </p> </div> </div>',
        buttonCSS: '#un-s-open{line-height: 50px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; padding: 0 30px; background: #fff; color: #333; font-weight:bold; font-size: 14px; border-radius: 3px; border: none; box-shadow: 0px 0px 12px #00000080; letter-spacing: 0.02px; text-decoration: none; white-space:nowrap;}#un-s-open.un-s-dark{color:#FFF; background:#111111;}#un-s-open:focus, #un-s-open[aria-expanded=true]{outline: 4px solid rgba(0,125,250,0.6); outline-offset: 4px;}',
        defaultCSS: ' .un-s-sr-only{overflow: hidden !important; width: 0px !important; height: 0px !important;} .un-s-hide{display: none;} #un-s-open{position: fixed; top: -100px; left: 18px; opacity: 0; z-index: 999999; transition: opacity .5s;}#un-s-open:focus, #un-s-open[aria-expanded=true]{top: 18px; opacity: 1;}#un-s-open.un-s-out{transition: opacity .5s, top 1s;}#un-s-open.un-s-center{left: 50%; transform: translate(-50%, 0);}#un-s-open.un-s-right{left: auto; right: 18px;}#un-s{position: fixed; left: 50%; transform: translate(-50%, 0); background: #fff; z-index: 99999999; overflow: hidden; opacity: 0; top: 10px; transition: opacity .5s; width: 0; height: 0; background: #FAFAFA; overflow: hidden; box-shadow: 0px 6px 12px #00000029;}#un-s.un-s-open{opacity: 1; height: calc(100vh - 20px); width: 80vw; max-width: 650px;}#un-s .un-s-component{display: none;}#un-s.un-s-open .un-s-component{display: block;}#un-s *{font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; letter-spacing: 0.02px;}#un-s a, #un-s a:visited{color:#0066CC !important;}#un-s button:focus, #un-s input:focus, #un-s textarea:focus{border: 1px solid #0070C9; -webkit-box-shadow: 0 0 0 4px rgba(0,125,250,0.6); box-shadow: 0 0 0 4px rgba(0,125,250,0.6); outline: none;}#un-s sup{vertical-align: top; margin-right: 3px;}#un-s a:focus{outline: 4px solid rgba(0,125,250,0.6);}#un-s p{font-size: 16px; line-height: 24px; color: #666; margin: 30px 0;}#un-s-overlay{display: none; position: fixed; top: 0; left: 0; width: 0; height: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .5s; z-index: 9999999;}#un-s.un-s-open + #un-s-overlay{display: block; opacity: .55; width: 100vw; height: 100vh;}#un-s-header{padding: 30px; text-align: right;}#un-s-close{font-size: 14px; height: 44px; border-radius: 4px; border: 1px solid #989494; background: #FFF; padding: 0 16px 0 30px; background-image: url(\'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMi4xMjEiIGhlaWdodD0iMTIuMTIxIiB2aWV3Qm94PSIwIDAgMTIuMTIxIDEyLjEyMSI+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTk4Ny44NTEgLTEyMi44NTEpIj48bGluZSB5MT0iMTAiIHgyPSIxMCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoOTg4LjkxMiAxMjMuOTEyKSIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjNjY2IiBzdHJva2Utd2lkdGg9IjMiLz48bGluZSB4Mj0iMTAiIHkyPSIxMCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoOTg4LjkxMiAxMjMuOTEyKSIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjNjY2IiBzdHJva2Utd2lkdGg9IjMiLz48L2c+PC9zdmc+\'); background-position: 16px center; background-repeat: no-repeat; background-size: 11px; color: #666;}#un-s-close:hover{color: #333 !important; background-image: url(\'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMi4xMjEiIGhlaWdodD0iMTIuMTIxIiB2aWV3Qm94PSIwIDAgMTIuMTIxIDEyLjEyMSI+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTk4Ny44NTEgLTEyMi44NTEpIj48bGluZSB5MT0iMTAiIHgyPSIxMCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoOTg4LjkxMiAxMjMuOTEyKSIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMzMzIiBzdHJva2Utd2lkdGg9IjMiLz48bGluZSB4Mj0iMTAiIHkyPSIxMCIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoOTg4LjkxMiAxMjMuOTEyKSIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMzMzIiBzdHJva2Utd2lkdGg9IjMiLz48L2c+PC9zdmc+\');}#un-s-wrapper{padding: 0px 50px 50px 50px; position: relative; overflow-x: hidden; overflow-y: scroll; height: calc(100vh - 180px); box-sizing: border-box;}#un-s h1{margin: 20px 0; font-size: 20px; line-height: 25px; color: #333;}#un-s h2{color: #333; font-size: 20px;}#un-s h1#un-s-title{text-align: center; font-size: 24px; line-height: 40px; margin: 0 0 30px 0;}#un-s-badge{text-align: center;}#un-s-badge svg{width: 124px;}#un-s-badge hr{width: 50px; margin: 30px auto; border: 1px solid #989494;}ul#un-s-status, #un-s-a11y-errors ul{list-style: none; margin: 0; padding: 0}ul#un-s-status > li{padding-bottom: 12px; border: 1px solid #ddd; padding: 15px 60px; margin-bottom: 10px; background: #FFF; border-radius: 6px; font-size: 16px; color:#666; line-height: 20px; background-image: url(\'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyOCIgaGVpZ2h0PSIyOCIgdmlld0JveD0iMCAwIDI4IDI4Ij48ZGVmcz48c3R5bGU+LmF7ZmlsbDojZGRlY2RjO30uYntmaWxsOiMxMThhMGY7fTwvc3R5bGU+PC9kZWZzPjxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKC00OTYgLTgxMikiPjxwYXRoIGNsYXNzPSJhIiBkPSJNMTQsMEExNCwxNCwwLDEsMSwwLDE0LDE0LDE0LDAsMCwxLDE0LDBaIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg0OTYgODEyKSIvPjxwYXRoIGNsYXNzPSJiIiBkPSJNNjk2Ljg5MSwyMTEuNjI1bC0xMC42NjcsMTAuNjY2LTUuMzMzLTUuMzMzLDEuNi0xLjYsMy43MzMsMy43MzMsOS4wNjYtOS4wNjdaIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTc4Ljg5MSA2MDkuOTc1KSIvPjwvZz48L3N2Zz4=\'); background-position: 15px center; background-repeat: no-repeat; background-size: 30px;}#un-s .ok-status{color: green}.un-s-input-row{margin: 0 0 20px 0;}.un-s-input-label{display:block; padding: 0 0 .5rem 0; font-size: 14px; color: #333;}fieldset#un-s-srq{padding: 0; display: block; border: none;}fieldset#un-s-srq legend{float: left; width: 100%;}#un-s-radio-row{clear: both;}.un-s-radio-wrapper{position: relative; width: 70px; height: 44px; display: inline-block;}.un-s-radio-wrapper input[type="radio"]{-webkit-appearance: none; position: absolute; width: 100%; height: 100%; border: 1px solid #989494; border-radius: 4px; margin: 0; padding: 0; background-color: #fff;}.un-s-radio-wrapper + .un-s-radio-wrapper{margin-left: 10px;}.un-s-radio-wrapper input[type="radio"]:checked{border-width: 3px; border-color: #0070C9;}.un-s-radio-wrapper label{width: 100%; height: 100%; position: absolute; pointer-events: none; text-align: center; line-height: 44px; font-size: 14px; color: #333;}.un-s-input{width: 70%; border: 1px solid #989494; padding: 0 10px; font-size: 14px; height: 44px; line-height: 44px; border-radius: 4px; color: #666; box-sizing: border-box;}.un-s-i-error .un-s-input-label, .un-s-error-txt{color: #E30000 !important;}.un-s-i-error .un-s-input{border: 1px solid #E30000; background: #FFF2F4;}.un-s-error-txt{font-size: 12px; line-height: 20px; margin-top: 5px; display: none;}.un-s-i-error .un-s-error-txt{display: block;}textarea.un-s-input{resize: none; height: auto; line-height: 18px; padding: 5px 10px;}button#un-s-submit{background:#0066CC; border: none; font-size: 14px; color: #FFF; line-height: 44px; border-radius: 4px; padding: 0 15px; margin-top: 20px; box-sizing: border-box;}button#un-s-submit:hover{background:#0052A3 !important;}#un-s-confirmation{background: #FFF; padding: 20px 40px; display: none;}.un-s-success #un-s-confirmation{display: block;}.un-s-success #un-s-feedback{display: none;}#un-s-confirmation p{font-size: 18px; line-height: 26px; margin: 0;}.un-s-bold{font-weight: bold;}.un-s-d{color: #03446D !important;}.un-s-l{color: #497896 !important; margin-bottom: 30px !important;}@media all and (-ms-high-contrast: none), (-ms-high-contrast: active){ul#un-s-status > li{list-style-image: url(data:0);}.un-s-radio-wrapper input[type="radio"]{position: relative; width: 20px; height: 20px; border: 1px solid #989494;}.un-s-radio-wrapper label{width: auto; height: 20px; display: inline-block; position: relative; line-height: 20px; font-size: 14px; vertical-align: top;}}@media only screen and (max-width:485px){#un-s.un-s-open{position: fixed; left: 0; top: 0; transform: none; width: 100vw; height: 100vh; overflow: scroll}#un-s-header, #un-s-wrapper{padding-left: 15px; padding-right: 15px;}.un-s-input{width: 100%; font-size: 16px;}button#un-s-submit{width: 100%;}}@media only screen and (min-width:813px){#un-s-wrapper{padding-left: 80px; padding-right: 80px;}}#un-s-open.un-relative:focus{position:static;display:block;margin: 0 auto;text-align:center;}#un-s-open.un-relative{transition:none!important;}',
    };

    var errors = {"noInput": "The %label% field is empty; it is a required field and must be filled in.", "noAnswer": "No answer to: do you use assistive technology such as a screen reader?", "nErrors": "There are %n% errors in this form"};

    var buttonLabels = {"newtab": "(will open on a new tab)"};

    var unStatusUrl = 'https://a11ystatus.usablenet.com/lv/aaas/forward7/28e84b2a18e193c3da5a9328a94fa66ad3bd546c3cf/standalonehtml?domain=' + window.location.host;

    var panelInit = false;

    // Get the token
    var token = false;

    // Read style setup
    var thisScript = document.getElementById('UsableNetSeal');
    var color = thisScript ? thisScript.getAttribute('color') || thisScript.dataset.color : '';
    var position = thisScript ? thisScript.getAttribute('position') || thisScript.dataset.position : '';
    var additionalStyle = thisScript ? thisScript.getAttribute('css-style') || thisScript.dataset['css-style'] : '';
    var isRelative = thisScript ? thisScript.dataset['relative'] : '';

    if (thisScript) {
        thisScript.removeAttribute('css-style');
        thisScript.removeAttribute('data-css-style');
    }

    // Pointers
    var panel = document.createElement('div');
    var fform = null, toggle = null, panelEl, opener, firstEl, lastEl, lastElConf;

    // Detect mobile
    function detectMobile() {
        var isMobile = {
            Android: function() {
                return navigator.userAgent.match(/Android/i);
            },
            BlackBerry: function() {
                return navigator.userAgent.match(/BlackBerry/i);
            },
            iOS: function() {
                return navigator.userAgent.match(/iPhone|iPad|iPod/i);
            },
            Opera: function() {
                return navigator.userAgent.match(/Opera Mini/i);
            },
            Windows: function() {
                return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
            },
            any: function() {
                return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
            }
        };
        var check = isMobile.any();
        return (check instanceof Array && isMobile.any().length > 0) || ((window.innerWidth <= 800) && (window.innerHeight <= 600)) || (window.orientation !== undefined);
    }

    function openWindow() {
        return window.open(unStatusUrl);
    }

    function newTabMsg() {
        var el = document.createElement('span');
        el.innerText = buttonLabels.newtab;
        el.setAttribute('style', 'display:inline-block;height:0!important;width:0!important;overflow:hidden!important;')
        return el;
    }

    // Tab trap functions
    function enableTabTrap(){
        firstEl.addEventListener('keydown', trapFirstElement, false);
        lastEl.addEventListener('keydown', trapLastElement, false);
    }

    function disableTabTrap(){
        firstEl.removeEventListener('keydown', trapFirstElement);
        lastEl.removeEventListener('keydown', trapLastElement);
    }

    function trapFirstElement(e) {
        if(e.shiftKey && e.keyCode == 9) {
            e.preventDefault();
            lastEl.focus();
        }
    }

    function trapLastElement(e) {
        if(!e.shiftKey && e.keyCode == 9) {
            e.preventDefault();
            firstEl.focus();
        }
    }

    function lastElTrap(e){
        e.preventDefault();
        if (panelEl.getAttribute('role') === 'dialog') {
            firstEl.focus();
        } else {
            toggle.focus();
            closeStatementDialog();
        }
    }
    // End tab trap functions

    // Escape key
    function handleEscape(e) {
        var key = e.which || e.keyCode;

        if (key === 27) {
            closeStatementDialog();
        }
    }

    function removeError(e) {
        var input = e.target;
        if (input.getAttribute('name') === 'at') {
            fform.querySelector('#un-s-srq').classList.remove('un-s-i-error');
            fform.querySelectorAll('#un-s-srq input[type="radio"]').forEach(function(input){
                input.removeAttribute("aria-describedby");
                input.removeAttribute("aria-invalid");
            })
        } else {
            input.parentNode.classList.remove('un-s-i-error');
            input.removeAttribute("aria-describedby");
            input.removeAttribute("aria-invalid");
        }
    }

    // Retrieve the token to submit form
    function getToken() {
        try {
            var xhr = new XMLHttpRequest();
            xhr.withCredentials = true;
            xhr.open("GET", config.tokenURI, true);
            xhr.onreadystatechange = function () {
                if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
                    // Add token
                    var tokenValue = JSON.parse(xhr.responseText).token;
                    panel.querySelector('#un-s-token').setAttribute('value', tokenValue);
                }
            };
            xhr.send(null);
            return true;
        } catch (e) {
            return false;
        }
    }

    // Serialize form data
    function urlencodeFormData(fd){
        var s = '';
        function encode(s){ return encodeURIComponent(s).replace(/%20/g,'+'); }
        var keys = Object.keys(fd);
        for(var i = 0; i < keys.length; i += 1){
            s += (s?'&':'') + encode(keys[i])+'='+encode(fd[keys[i]]);
        }
        s += '&domain=' + window.location.host;
        return s;
    }

    function validateForm() {
        var inputs = ['#un-s-i-msg', '#un-s-i-name', '#un-s-i-email', '#un-s-token'];
        var radios = fform.querySelectorAll('input[name="at"]');
        var radioValue = null;
        var isValid = true;
        var data = {};
        var a11yErrors = [];
        var errorIndex = 0;

        for (var i = 0, length = radios.length; i < length; i++) {
            if (radios[i].checked) {
                radioValue = radios[i].value;
                break;
            }
        }

        if (!radioValue) {
            fform.querySelector('#un-s-srq').classList.add('un-s-i-error');
            isValid = false;
            a11yErrors.push(errors.noAnswer);
            fform.querySelectorAll('#un-s-srq input[type="radio"]').forEach(function(input){
                input.setAttribute("aria-describedby", "error-"+errorIndex);
                input.setAttribute("aria-invalid", "true");
            })
            errorIndex += 1;
        } else {
            fform.querySelector('#un-s-srq').classList.remove('un-s-i-error');
        }

        data.at = radioValue;

        for (var i = 0; i < inputs.length; i += 1) {
            var current = inputs[i];
            var input = fform.querySelector(current);
            var name = input.getAttribute('name');
            var id = input.getAttribute('id');
            var value = input.value;

            data[input.getAttribute('name')] = value;

            if (name === 'token') continue;

            // ..do other validations here
            if (value.trim() === '') {
                input.parentNode.classList.add('un-s-i-error')
                isValid = false;

                var inputLabel = fform.querySelector('label[for="' + id + '"]').innerText;
                a11yErrors.push(errors.noInput.replace('%label%', inputLabel.replace("*", "")));
                input.setAttribute("aria-describedby", "error-"+errorIndex++);
                input.setAttribute("aria-invalid", "true");
            }
        }

        return { isValid: isValid, data: data, a11yErrors: a11yErrors, };
    }

    function buildA11yErrors(errorsList) {
        var container = panel.querySelector('#un-s-a11y-errors');

        if (container) {
            container.parentNode.removeChild(container);
        }

        container = document.createElement('div');
        container.setAttribute('id', 'un-s-a11y-errors');
        container.setAttribute('role', 'alert');
        container.setAttribute('tabindex', '-1');
        container.classList.add('un-s-sr-only');

        var title = document.createElement('h3');
        title.innerText = errors.nErrors.replace('%n%', errorsList.length);

        container.appendChild(title);

        var listContainer = document.createElement('ul');
        for (var i = 0; i < errorsList.length; i += 1) {
            var errorEl = document.createElement('li');
            errorEl.innerText = errorsList[i];
            errorEl.setAttribute("id", "error-"+i);
            listContainer.appendChild(errorEl);
        }

        container.appendChild(listContainer);

        if (fform) {
            fform.insertBefore(container, fform.childNodes[0]);
            container.focus();
        }
    }

    function submitForm(e) {
        if (e.isTrusted || e.isTrusted === undefined) {
            var formData = validateForm();
            if (formData.isValid) {
                var xhr = new XMLHttpRequest();
                xhr.withCredentials = true;
                xhr.open('POST', config.endpoint, true);
                xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

                xhr.onreadystatechange = function () {
                    if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
                        var response = JSON.parse(xhr.responseText);
                        if (response.status === 'sent') {
                            panel.classList.add('un-s-success');

                            var confirmation = panel.querySelector('#un-s-confirmation');
                            confirmation.setAttribute('role', 'alert');
                            confirmation.focus();
                            fform.parentNode.removeChild(fform);
                        }
                    }
                };
                try {
                    xhr.send(urlencodeFormData(formData.data));
                }catch(e) {}
            } else {
                buildA11yErrors(formData.a11yErrors);
            }
        }
    }

    function prepend(node){
        if (document.body.childNodes.length) {
            document.body.insertBefore(node, document.body.childNodes[0]);
        } else {
            document.body.appendChild(node);
        }
    }

    // Init panel and bind listeners
    function initPanelContent(){
        panelInit = true;
        panelEl.innerHTML = config.panelContentHTML;
        panel.querySelector('#un-s-close').addEventListener('click', closeStatementDialog, false);
        panel.querySelector('#un-s-submit').addEventListener('click', submitForm, false);

        firstEl = panel.querySelector('#un-s-close');
        lastEl = panel.querySelector('#un-s-submit');

        // Form pointer
        fform = panel.querySelector('#un-s-feedback');
        var inputs = fform.querySelectorAll('.un-s-input, input[type="radio"]');
        for (var i = 0; i < inputs.length; i += 1) {
            inputs[i].addEventListener('change', removeError);
        }
    }

    // Run callback when elements are available
    function observe(_sel, _callback){
        var els = document.querySelectorAll(_sel);
        if(els.length) return _callback(els);
        var mo = (w.MutationObserver || w.WebKitMutationObserver);
        var observer = new mo(function(){
            if((els = document.querySelectorAll(_sel)).length){
                observer.disconnect();
                connected = false;
                _callback(els);
            }
        });
        observer.observe(document, { childList: true, subtree: true });
        var connected = true;
        // Disconnect observer after a while
        setTimeout(function(){
            if (connected) {
                observer.disconnect();
                connected = false;
            }
        }, 5000);
    }

    // Open/Close functions
    w.closeStatementDialog = function(e) {
        if (e) {
            e.preventDefault();
            e.stopPropagation();
        }

        setTimeout(function(){
            if (opener) {
                opener.focus();
            }
        }, 600);


        // Disable trap anyway
        disableTabTrap();

        // Unbind escape key
        panel.removeEventListener('keyup', handleEscape);
        document.removeEventListener('keyup', handleEscape);

        // Enable the accordion trigger
        toggle.classList.remove('un-s-hide');

        // Hide the panel
        if (panelEl) {
            panelEl.setAttribute('aria-hidden', 'true');
            panelEl.removeAttribute('role');
            panelEl.removeAttribute('aria-modal');
            panelEl.classList.remove('un-s-open');
        }

        return false;
    }

    w.openUNAccessibilityStatusPanel = function(e) {
        if (e) {
            e.preventDefault();
            e.stopPropagation();
        }

        if (detectMobile()) {
            return openWindow();
        }

        if(!panelInit){
            initPanelContent();
        }

        // Store opener to focus back on it at close
        opener = e.target;

        // Bind tab trap
        enableTabTrap();

        if (!token) {
            token = getToken();
        }

        // Bind the esc key
        panel.addEventListener('keyup', handleEscape, true);
        document.addEventListener('keyup', handleEscape, true);

        // Setup dialog attributes
        panelEl.removeAttribute('aria-hidden');
        panelEl.setAttribute('role', 'dialog');
        panelEl.setAttribute('aria-modal', 'true');
        panelEl.classList.add('un-s-open');

        // Disable the accordion trigger
        toggle.classList.add('un-s-hide');

        // Move focus inside the panel
        setTimeout(function(){
            firstEl.focus();
        }, 600);

        return false;
    }
    // End Open/Close functions

    // Enable A40 from panel
    w.sealEnableUsableNetAssistive = function(e) {
        if (typeof window.enableUsableNetAssistive === 'function') {
            return enableUsableNetAssistive();
        }
    }

    // Create button + panel container
    panel = document.createElement('div');
    panel.setAttribute('id', 'un-s-cont');

    // Inject HTML
    panel.innerHTML = config.panelHTML;

    // Panel element pointer
    panelEl = panel.querySelector('#un-s');

    // Append the style
    var style = document.createElement('style');
    style.setAttribute('type', 'text/css');
    style.innerHTML = config.defaultCSS + config.buttonCSS + additionalStyle;

    // Toggle pointer
    toggle = panel.querySelector('#un-s-open');

    if (detectMobile()) {
        var toggleLink = document.createElement('a');
        toggleLink.setAttribute('id', 'un-s-open');
        toggleLink.setAttribute('href', '#');
        toggleLink.setAttribute('target', '_blank');
        toggleLink.innerText = toggle.innerText;
        if(isRelative){
            toggleLink.classList.add('un-relative')
        }
        toggleLink.appendChild(newTabMsg());
        toggle.parentNode.replaceChild(toggleLink, toggle);
        toggle = toggleLink;

        observe('.UNAccessibilityStatus', function (els) {
            for (var i = 0; i < els.length; i += 1) {
                var el = els[i];
                el.removeAttribute('aria-haspopup');
                el.removeAttribute('role');
                el.setAttribute('href', '#');
                el.setAttribute('target', '_blank');
                el.appendChild(newTabMsg());
            }
        });
    }
    toggle.addEventListener('click', openUNAccessibilityStatusPanel, false);
    toggle.addEventListener('focusin', function(e){ toggle.classList.remove('un-s-out'); });
    toggle.addEventListener('focusout', function(e){ toggle.classList.add('un-s-out'); });

    // Setup color and position
    if (position === 'right') {
        toggle.classList.add('un-s-right')
    } else if (position === 'center') {
        toggle.classList.add('un-s-center')
    }

    if (color === 'dark') {
        toggle.classList.add('un-s-dark');
    }

    observe('body', function () {
        // Create the root element
        var shadowElement = document.createElement('div');
        shadowElement.setAttribute('id', 'un-seal');

        panelEl.removeAttribute('aria-modal');
        panelEl.removeAttribute('role');
        panelEl.setAttribute('aria-label', toggle.innerText);

        lastElConf = panel.querySelector('#un-s-overlay');
        lastElConf.setAttribute('tabindex', '0');
        lastElConf.addEventListener('focus', lastElTrap, false);

        // Add the shadow root
        if (shadowElement.attachShadow) {
            var shadow = shadowElement.attachShadow({mode: 'open'});
            shadow.appendChild(style);
            shadow.appendChild(panel);
            prepend(shadowElement);
        }
        // Fallback for IE, append as regular child
        else {
            document.getElementsByTagName('head')[0].appendChild(style);
            shadowElement.appendChild(panel);
            prepend(shadowElement);
        }
    });

})(window);