/*
 * AET
 *
 * Copyright (C) 2013 Cognifide Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
* based on  https://github.com/yargalot/AccessSniff/blob/master/libs/dist/HTMLCS.min.js
* changed scope of variable to window
* added HTMLCS.getMessagesJSON()
*/

function Runner() {
    this.run = function(standard) {
        var _this = this;
        HTMLCS.process(standard, document, function() {
            var messages = HTMLCS.getMessages();
            messages.forEach(function(message) {
                message.elementString = message.element.outerHTML, _this.output(message);
            }), console.log("done");
        });
    }, this.output = function(msg) {
        var typeName = "UNKNOWN";
        switch (msg.type) {
          case HTMLCS.ERROR:
            typeName = "ERROR";
            break;

          case HTMLCS.WARNING:
            typeName = "WARNING";
            break;

          case HTMLCS.NOTICE:
            typeName = "NOTICE";
        }
        var message = typeName + "|" + msg.code + "|" + msg.msg + "|" + msg.elementString + "|" + msg.element.className + "|" + msg.element.id;
        console.log(message);
    };
}

window.HTMLCS_Section508_Sniffs_A = {
    register: function() {
        return [ "img", "input", "area", "object", "applet", "bgsound", "audio" ];
    },
    process: function(element, top) {
        if (element === top) this.addNullAltTextResults(top), this.addMediaAlternativesResults(top); else {
            var nodeName = element.nodeName.toLowerCase();
            ("object" === nodeName || "bgsound" === nodeName || "audio" === nodeName) && HTMLCS.addMessage(HTMLCS.NOTICE, element, "For multimedia containing audio only, ensure an alternative is available, such as a full text transcript.", "Audio");
        }
    },
    testNullAltText: function(top) {
        var errors = {
            img: {
                generalAlt: [],
                missingAlt: [],
                ignored: [],
                nullAltWithTitle: [],
                emptyAltInLink: []
            },
            inputImage: {
                generalAlt: [],
                missingAlt: []
            },
            area: {
                generalAlt: [],
                missingAlt: []
            }
        };
        elements = top.querySelectorAll('img, area, input[type="image"]');
        for (var el = 0; el < elements.length; el++) {
            var element = elements[el], nodeName = element.nodeName.toLowerCase(), linkOnlyChild = !1, missingAlt = !1, nullAlt = !1;
            if ("a" === element.parentNode.nodeName.toLowerCase()) {
                var prevNode = this._getPreviousSiblingElement(element, null), nextNode = this._getNextSiblingElement(element, null);
                if (null === prevNode && null === nextNode) {
                    var textContent = element.parentNode.textContent;
                    if (void 0 !== element.parentNode.textContent) var textContent = element.parentNode.textContent; else var textContent = element.parentNode.innerText;
                    HTMLCS.util.isStringEmpty(textContent) === !0 && (linkOnlyChild = !0);
                }
            }
            switch (element.hasAttribute("alt") === !1 ? missingAlt = !0 : element.getAttribute("alt") && HTMLCS.util.isStringEmpty(element.getAttribute("alt")) !== !0 || (nullAlt = !0), 
            nodeName) {
              case "img":
                linkOnlyChild !== !0 || missingAlt !== !0 && nullAlt !== !0 ? missingAlt === !0 ? errors.img.missingAlt.push(element) : nullAlt === !0 ? element.hasAttribute("title") === !0 && HTMLCS.util.isStringEmpty(element.getAttribute("title")) === !1 ? errors.img.nullAltWithTitle.push(element) : errors.img.ignored.push(element) : errors.img.generalAlt.push(element) : errors.img.emptyAltInLink.push(element.parentNode);
                break;

              case "input":
                missingAlt === !0 || nullAlt === !0 ? errors.inputImage.missingAlt.push(element) : errors.inputImage.generalAlt.push(element);
                break;

              case "area":
                missingAlt === !0 || nullAlt === !0 ? errors.area.missingAlt.push(element) : errors.inputImage.generalAlt.push(element);
            }
        }
        return errors;
    },
    addNullAltTextResults: function(top) {
        for (var errors = this.testNullAltText(top), i = 0; i < errors.img.emptyAltInLink.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.img.emptyAltInLink[i], "Img element is the only content of the link, but is missing alt text. The alt text should describe the purpose of the link.", "Img.EmptyAltInLink");
        for (var i = 0; i < errors.img.nullAltWithTitle.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.img.nullAltWithTitle[i], "Img element with empty alt text must have absent or empty title attribute.", "Img.NullAltWithTitle");
        for (var i = 0; i < errors.img.ignored.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, errors.img.ignored[i], "Img element is marked so that it is ignored by Assistive Technology.", "Img.Ignored");
        for (var i = 0; i < errors.img.missingAlt.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.img.missingAlt[i], "Img element missing an alt attribute. Use the alt attribute to specify a short text alternative.", "Img.MissingAlt");
        for (var i = 0; i < errors.img.generalAlt.length; i++) HTMLCS.addMessage(HTMLCS.NOTICE, errors.img.generalAlt[i], "Ensure that the img element's alt text serves the same purpose and presents the same information as the image.", "Img.GeneralAlt");
        for (var i = 0; i < errors.inputImage.missingAlt.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.inputImage.missingAlt[i], "Image submit button missing an alt attribute. Specify a text alternative that describes the button's function, using the alt attribute.", "InputImage.MissingAlt");
        for (var i = 0; i < errors.inputImage.generalAlt.length; i++) HTMLCS.addMessage(HTMLCS.NOTICE, errors.inputImage.generalAlt[i], "Ensure that the image submit button's alt text identifies the purpose of the button.", "InputImage.GeneralAlt");
        for (var i = 0; i < errors.area.missingAlt.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.area.missingAlt[i], "Area element in an image map missing an alt attribute. Each area element must have a text alternative that describes the function of the image map area.", "Area.MissingAlt");
        for (var i = 0; i < errors.area.generalAlt.length; i++) HTMLCS.addMessage(HTMLCS.NOTICE, errors.area.generalAlt[i], "Ensure that the area element's text alternative serves the same purpose as the part of image map image it references.", "Area.GeneralAlt");
    },
    testMediaTextAlternatives: function(top) {
        for (var errors = {
            object: {
                missingBody: [],
                generalAlt: []
            },
            applet: {
                missingBody: [],
                missingAlt: [],
                generalAlt: []
            }
        }, elements = top.querySelectorAll("object"), el = 0; el < elements.length; el++) {
            var element = elements[el], childObject = (element.nodeName.toLowerCase(), element.querySelector("object"));
            if (null === childObject) {
                var textAlt = HTMLCS.util.getElementTextContent(element, !0);
                "" === textAlt ? errors.object.missingBody.push(element) : errors.object.generalAlt.push(element);
            }
        }
        for (var elements = top.querySelectorAll("applet"), el = 0; el < elements.length; el++) {
            var childObject = element.querySelector("object"), hasError = !1;
            if (null === childObject) {
                var textAlt = HTMLCS.util.getElementTextContent(element, !0);
                HTMLCS.util.isStringEmpty(textAlt) === !0 && (errors.applet.missingBody.push(element), 
                hasError = !0);
            }
            var altAttr = element.getAttribute("alt") || "";
            HTMLCS.util.isStringEmpty(altAttr) === !0 && (errors.applet.missingAlt.push(element), 
            hasError = !0), hasError === !1 && errors.applet.generalAlt.push(element);
        }
        return errors;
    },
    addMediaAlternativesResults: function(top) {
        for (var errors = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1.testMediaTextAlternatives(top), i = 0; i < errors.object.missingBody.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.object.missingBody[i], "Object elements must contain a text alternative after all other alternatives are exhausted.", "Object.MissingBody");
        for (var i = 0; i < errors.object.generalAlt.length; i++) HTMLCS.addMessage(HTMLCS.NOTICE, errors.object.generalAlt[i], "Check that short (and if appropriate, long) text alternatives are available for non-text content that serve the same purpose and present the same information.", "Object.GeneralAlt");
        for (var i = 0; i < errors.applet.missingBody.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.applet.missingBody[i], "Applet elements must contain a text alternative in the element's body, for browsers without support for the applet element.", "Applet.MissingBody");
        for (var i = 0; i < errors.applet.missingAlt.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.applet.missingAlt[i], "Applet elements must contain an alt attribute, to provide a text alternative to browsers supporting the element but are unable to load the applet.", "Applet.MissingAlt");
        for (var i = 0; i < errors.applet.generalAlt.length; i++) HTMLCS.addMessage(HTMLCS.NOTICE, errors.applet.generalAlt[i], "Check that short (and if appropriate, long) text alternatives are available for non-text content that serve the same purpose and present the same information.", "Applet.GeneralAlt");
    }
}, window.HTMLCS_Section508_Sniffs_B = {
    register: function() {
        return [ "object", "applet", "embed", "video" ];
    },
    process: function(element) {
        element.nodeName.toLowerCase();
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "For multimedia containing video, ensure a synchronised audio description or text alternative for the video portion is provided.", "Video"), 
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "For multimedia containing synchronised audio and video, ensure synchronised captions are provided for the audio portion.", "Captions");
    }
}, window.HTMLCS_Section508_Sniffs_C = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Ensure that any information conveyed using colour alone is also available without colour, such as through context or markup.", "Colour");
    }
}, window.HTMLCS_Section508_Sniffs_D = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        if (element === top) {
            HTMLCS.addMessage(HTMLCS.NOTICE, top, "Ensure that content is ordered in a meaningful sequence when linearised, such as when style sheets are disabled.", "Linearised"), 
            this.testPresentationMarkup(top), this.testHeadingOrder(top);
            var hasScript = top.querySelectorAll('script, link[rel="stylesheet"]');
            hasScript.length > 0 && HTMLCS.addMessage(HTMLCS.NOTICE, top, 'If content is hidden and made visible using scripting (such as "click to expand" sections), ensure this content is readable when scripts and style sheets are disabled.', "HiddenText");
        }
    },
    testPresentationMarkup: function(top) {
        for (var tags = top.querySelectorAll("b, i, u, s, strike, tt, big, small, center, font"), i = 0; i < tags.length; i++) {
            var msgCode = "PresMarkup." + tags[i].nodeName.substr(0, 1).toUpperCase() + tags[i].nodeName.substr(1).toLowerCase();
            HTMLCS.addMessage(HTMLCS.WARNING, tags[i], "Semantic markup should be used to mark emphasised or special text so that it can be programmatically determined.", msgCode);
        }
        for (var tags = top.querySelectorAll("*[align]"), i = 0; i < tags.length; i++) {
            var msgCode = "PresMarkup.AlignAttr";
            HTMLCS.addMessage(HTMLCS.WARNING, tags[i], "Semantic markup should be used to mark emphasised or special text so that it can be programmatically determined.", msgCode);
        }
    },
    testHeadingOrder: function(top) {
        for (var lastHeading = 0, headings = top.querySelectorAll("h1, h2, h3, h4, h5, h6"), i = 0; i < headings.length; i++) {
            var headingNum = parseInt(headings[i].nodeName.substr(1, 1));
            if (headingNum - lastHeading > 1) {
                var exampleMsg = "should be an h" + (lastHeading + 1) + " to be properly nested";
                0 === lastHeading && (exampleMsg = "appears to be the primary document heading, so should be an h1 element"), 
                HTMLCS.addMessage(HTMLCS.ERROR, headings[i], "The heading structure is not logically nested. This h" + headingNum + " element " + exampleMsg + ".", "HeadingOrder");
            }
            lastHeading = headingNum;
        }
    }
}, window.HTMLCS_Section508_Sniffs_G = {
    register: function() {
        return [ "table" ];
    },
    process: function(element) {
        HTMLCS.util.isLayoutTable(element) === !0 && HTMLCS.addMessage(HTMLCS.NOTICE, element, "This table has no headers. If this is a data table, ensure row and column headers are identified using th elements.", "TableHeaders");
    }
}, window.HTMLCS_Section508_Sniffs_H = {
    register: function() {
        return [ "table" ];
    },
    process: function(table) {
        for (var headersAttr = HTMLCS.util.testTableHeaders(table), i = 0; i < headersAttr.wrongHeaders.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, headersAttr.wrongHeaders[i].element, 'Incorrect headers attribute on this td element. Expected "' + headersAttr.wrongHeaders[i].expected + '" but found "' + headersAttr.wrongHeaders[i].actual + '"', "IncorrectHeadersAttr");
        headersAttr.required === !0 && headersAttr.allowScope === !1 && (headersAttr.used === !1 ? HTMLCS.addMessage(HTMLCS.ERROR, table, "The relationship between td elements and their associated th elements is not defined. As this table has multiple levels of th elements, you must use the headers attribute on td elements.", "MissingHeadersAttrs") : (headersAttr.missingThId.length > 0 && HTMLCS.addMessage(HTMLCS.ERROR, table, "Not all th elements in this table contain an id attribute. These cells should contain ids so that they may be referenced by td elements' headers attributes.", "MissingHeaderIds"), 
        headersAttr.missingTd.length > 0 && HTMLCS.addMessage(HTMLCS.ERROR, table, "Not all td elements in this table contain a headers attribute. Each headers attribute should list the ids of all th elements associated with that cell.", "IncompleteHeadersAttrs")));
    }
}, window.HTMLCS_Section508_Sniffs_I = {
    register: function() {
        return [ "frame", "iframe", "object" ];
    },
    process: function(element, top) {
        var nodeName = element.nodeName.toLowerCase(), hasTitle = element.hasAttribute("title"), titleEmpty = !0;
        hasTitle === !0 && (titleEmpty = HTMLCS.util.isStringEmpty(element.getAttribute("title"))), 
        titleEmpty === !0 && HTMLCS.addMessage(HTMLCS.ERROR, top, "This " + nodeName + " element is missing title text. Frames should be titled with text that facilitates frame identification and navigation.", "Frames");
    }
}, window.HTMLCS_Section508_Sniffs_J = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that no component of the content flickers at a rate of greater than 2 and less than 55 times per second.", "Flicker");
    }
}, window.HTMLCS_Section508_Sniffs_K = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "If this page cannot be made compliant, a text-only page with equivalent information or functionality should be provided. The alternative page needs to be updated in line with this page's content.", "AltVersion");
    }
}, window.HTMLCS_Section508_Sniffs_L = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        element === top && (this.addProcessLinksMessages(top), this.testKeyboard(top));
    },
    addProcessLinksMessages: function(top) {
        for (var errors = this.processLinks(top), i = 0; i < errors.emptyNoId.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.emptyNoId[i], "Anchor element found with no link content and no name and/or ID attribute.", "EmptyAnchorNoId");
        for (var i = 0; i < errors.placeholder.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, errors.placeholder[i], "Anchor element found with link content, but no href, ID, or name attribute has been supplied.", "PlaceholderAnchor");
        for (var i = 0; i < errors.noContent.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.noContent[i], "Anchor element found with a valid href attribute, but no link content has been supplied.", "NoContentAnchor");
    },
    processLinks: function(top) {
        for (var errors = {
            empty: [],
            emptyWithName: [],
            emptyNoId: [],
            noHref: [],
            placeholder: [],
            noContent: []
        }, elements = top.querySelectorAll("a"), el = 0; el < elements.length; el++) {
            var element = elements[el], nameFound = !1, hrefFound = !1, content = HTMLCS.util.getElementTextContent(element);
            element.hasAttribute("title") === !0 && /^\s*$/.test(element.getAttribute("title")) === !1 ? nameFound = !0 : /^\s*$/.test(content) === !1 && (nameFound = !0), 
            element.hasAttribute("href") === !0 && /^\s*$/.test(element.getAttribute("href")) === !1 && (hrefFound = !0), 
            hrefFound === !1 ? /^\s*$/.test(content) === !0 ? element.hasAttribute("id") === !0 ? errors.empty.push(element) : element.hasAttribute("name") === !0 ? errors.emptyWithName.push(element) : errors.emptyNoId.push(element) : element.hasAttribute("id") === !0 || element.hasAttribute("name") === !0 ? errors.noHref.push(element) : errors.placeholder.push(element) : /^\s*$/.test(content) === !0 && 0 === element.querySelectorAll("img").length && errors.noContent.push(element);
        }
        return errors;
    },
    testKeyboard: function(top) {
        for (var dblClickEls = top.querySelectorAll("*[ondblclick]"), i = 0; i < dblClickEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, dblClickEls[i], "Ensure the functionality provided by double-clicking on this element is available through the keyboard.", "DblClick");
        for (var mouseOverEls = top.querySelectorAll("*[onmouseover]"), i = 0; i < mouseOverEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, mouseOverEls[i], "Ensure the functionality provided by mousing over this element is available through the keyboard; for instance, using the focus event.", "MouseOver");
        for (var mouseOutEls = top.querySelectorAll("*[onmouseout]"), i = 0; i < mouseOutEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, mouseOutEls[i], "Ensure the functionality provided by mousing out of this element is available through the keyboard; for instance, using the blur event.", "MouseOut");
        for (var mouseMoveEls = top.querySelectorAll("*[onmousemove]"), i = 0; i < mouseMoveEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, mouseMoveEls[i], "Ensure the functionality provided by moving the mouse on this element is available through the keyboard.", "MouseMove");
        for (var mouseDownEls = top.querySelectorAll("*[onmousedown]"), i = 0; i < mouseDownEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, mouseDownEls[i], "Ensure the functionality provided by mousing down on this element is available through the keyboard; for instance, using the keydown event.", "MouseDown");
        for (var mouseUpEls = top.querySelectorAll("*[onmouseup]"), i = 0; i < mouseUpEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, mouseUpEls[i], "Ensure the functionality provided by mousing up on this element is available through the keyboard; for instance, using the keyup event.", "MouseUp");
    }
}, window.HTMLCS_Section508_Sniffs_M = {
    register: function() {
        return [ "object", "applet", "bgsound", "embed", "audio", "video" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If external media requires a plugin or application to view, ensure a link is provided to a plugin or application that complies with Section 508 accessibility requirements for applications.", "PluginLink");
    }
}, window.HTMLCS_Section508_Sniffs_N = {
    register: function() {
        return [ "form" ];
    },
    process: function(element) {
        var nodeName = element.nodeName.toLowerCase();
        "form" === nodeName && (HTMLCS.addMessage(HTMLCS.NOTICE, element, "If an input error is automatically detected in this form, check that the item(s) in error are identified and the error(s) are described to the user in text.", "Errors"), 
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that descriptive labels or instructions (including for required fields) are provided for user input in this form.", "Labels"), 
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Ensure that this form can be navigated using the keyboard and other accessibility tools.", "KeyboardNav"));
    }
}, window.HTMLCS_Section508_Sniffs_O = {
    register: function() {
        return [ "_top", "a", "area" ];
    },
    process: function(element, top) {
        if (element === top) HTMLCS.addMessage(HTMLCS.NOTICE, top, "Ensure that any common navigation elements can be bypassed; for instance, by use of skip links, header elements, or ARIA landmark roles.", "SkipLinks"); else if (element.hasAttribute("href") === !0) {
            var href = element.getAttribute("href");
            if (href = HTMLCS.util.trim(href), href.length > 1 && "#" === href.charAt(0)) {
                var id = href.substr(1);
                try {
                    var doc = top;
                    doc.ownerDocument && (doc = doc.ownerDocument);
                    var target = doc.getElementById(id);
                    null === target && (target = doc.querySelector('a[name="' + id + '"]')), (null === target || HTMLCS.util.contains(top, target) === !1) && (HTMLCS.isFullDoc(top) === !0 || "body" === top.nodeName.toLowerCase() ? HTMLCS.addMessage(HTMLCS.ERROR, element, 'This link points to a named anchor "' + id + '" within the document, but no anchor exists with that name.', "NoSuchID") : HTMLCS.addMessage(HTMLCS.WARNING, element, 'This link points to a named anchor "' + id + '" within the document, but no anchor exists with that name in the fragment tested.', "NoSuchIDFragment"));
                } catch (ex) {}
            }
        }
    }
}, window.HTMLCS_Section508_Sniffs_P = {
    register: function() {
        return [ "_top", "meta" ];
    },
    process: function(element, top) {
        element === top ? HTMLCS.addMessage(HTMLCS.NOTICE, top, "If a timed response is required on this page, alert the user and provide sufficient time to allow them to indicate that more time is required.", "TimeLimit") : element.hasAttribute("http-equiv") === !0 && "refresh" === String(element.getAttribute("http-equiv")).toLowerCase() && /^[1-9]\d*/.test(element.getAttribute("content").toLowerCase()) === !0 && (/url=/.test(element.getAttribute("content").toLowerCase()) === !0 ? HTMLCS.addMessage(HTMLCS.ERROR, element, "Meta refresh tag used to redirect to another page, with a time limit that is not zero. Users cannot control this time limit.", "MetaRedirect") : HTMLCS.addMessage(HTMLCS.ERROR, element, "Meta refresh tag used to refresh the current page. Users cannot control the time limit for this refresh.", "MetaRefresh"));
    }
};

window.HTMLCS_Section508 = {
    name: "Section508",
    description: "U.S. Section 508 Standard",
    sniffs: [ "A", "B", "C", "D", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P" ],
    getMsgInfo: function(code) {
        var msgCodeParts = code.split(".", 3), paragraph = msgCodeParts[1].toLowerCase(), retval = [ [ "Section", "1194.22 (" + paragraph + ")" ] ];
        return retval;
    }
}, window.HTMLCS_WCAG2A = {
    name: "WCAG2A",
    description: "Web Content Accessibility Guidelines (WCAG) 2.0 A",
    sniffs: [ {
        standard: "WCAG2AAA",
        include: [ "Principle1.Guideline1_1.1_1_1", "Principle1.Guideline1_2.1_2_1", "Principle1.Guideline1_2.1_2_2", "Principle1.Guideline1_2.1_2_3", "Principle1.Guideline1_3.1_3_1", "Principle1.Guideline1_3.1_3_1_A", "Principle1.Guideline1_3.1_3_2", "Principle1.Guideline1_3.1_3_3", "Principle1.Guideline1_4.1_4_1", "Principle1.Guideline1_4.1_4_2", "Principle2.Guideline2_1.2_1_1", "Principle2.Guideline2_1.2_1_2", "Principle2.Guideline2_2.2_2_1", "Principle2.Guideline2_2.2_2_2", "Principle2.Guideline2_3.2_3_1", "Principle2.Guideline2_4.2_4_1", "Principle2.Guideline2_4.2_4_2", "Principle2.Guideline2_4.2_4_3", "Principle2.Guideline2_4.2_4_4", "Principle3.Guideline3_1.3_1_1", "Principle3.Guideline3_2.3_2_1", "Principle3.Guideline3_2.3_2_2", "Principle3.Guideline3_3.3_3_1", "Principle3.Guideline3_3.3_3_2", "Principle4.Guideline4_1.4_1_1", "Principle4.Guideline4_1.4_1_2" ]
    } ],
    getMsgInfo: function(code) {
        return HTMLCS_WCAG2AAA.getMsgInfo(code);
    }
}, window.HTMLCS_WCAG2AA = {
    name: "WCAG2AA",
    description: "Web Content Accessibility Guidelines (WCAG) 2.0 AA",
    sniffs: [ {
        standard: "WCAG2AAA",
        include: [ "Principle1.Guideline1_1.1_1_1", "Principle1.Guideline1_2.1_2_1", "Principle1.Guideline1_2.1_2_2", "Principle1.Guideline1_2.1_2_4", "Principle1.Guideline1_2.1_2_5", "Principle1.Guideline1_3.1_3_1", "Principle1.Guideline1_3.1_3_1_A", "Principle1.Guideline1_3.1_3_2", "Principle1.Guideline1_3.1_3_3", "Principle1.Guideline1_4.1_4_1", "Principle1.Guideline1_4.1_4_2", "Principle1.Guideline1_4.1_4_3", "Principle1.Guideline1_4.1_4_3_F24", "Principle1.Guideline1_4.1_4_3_Contrast", "Principle1.Guideline1_4.1_4_4", "Principle1.Guideline1_4.1_4_5", "Principle2.Guideline2_1.2_1_1", "Principle2.Guideline2_1.2_1_2", "Principle2.Guideline2_2.2_2_1", "Principle2.Guideline2_2.2_2_2", "Principle2.Guideline2_3.2_3_1", "Principle2.Guideline2_4.2_4_1", "Principle2.Guideline2_4.2_4_2", "Principle2.Guideline2_4.2_4_3", "Principle2.Guideline2_4.2_4_4", "Principle2.Guideline2_4.2_4_5", "Principle2.Guideline2_4.2_4_6", "Principle2.Guideline2_4.2_4_7", "Principle3.Guideline3_1.3_1_1", "Principle3.Guideline3_1.3_1_2", "Principle3.Guideline3_2.3_2_1", "Principle3.Guideline3_2.3_2_2", "Principle3.Guideline3_2.3_2_3", "Principle3.Guideline3_2.3_2_4", "Principle3.Guideline3_3.3_3_1", "Principle3.Guideline3_3.3_3_2", "Principle3.Guideline3_3.3_3_3", "Principle3.Guideline3_3.3_3_4", "Principle4.Guideline4_1.4_1_1", "Principle4.Guideline4_1.4_1_2" ]
    } ],
    getMsgInfo: function(code) {
        return HTMLCS_WCAG2AAA.getMsgInfo(code);
    }
};

window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = {
    register: function() {
        return [ "_top", "img" ];
    },
    process: function(element, top) {
        if (element === top) this.addNullAltTextResults(top), this.addMediaAlternativesResults(top); else {
            var nodeName = element.nodeName.toLowerCase();
            switch (nodeName) {
              case "img":
                this.testLinkStutter(element), this.testLongdesc(element);
            }
        }
    },
    addNullAltTextResults: function(top) {
        for (var errors = this.testNullAltText(top), i = 0; i < errors.img.emptyAltInLink.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.img.emptyAltInLink[i], "Img element is the only content of the link, but is missing alt text. The alt text should describe the purpose of the link.", "H30.2");
        for (var i = 0; i < errors.img.nullAltWithTitle.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.img.nullAltWithTitle[i], "Img element with empty alt text must have absent or empty title attribute.", "H67.1");
        for (var i = 0; i < errors.img.ignored.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, errors.img.ignored[i], "Img element is marked so that it is ignored by Assistive Technology.", "H67.2");
        for (var i = 0; i < errors.img.missingAlt.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.img.missingAlt[i], "Img element missing an alt attribute. Use the alt attribute to specify a short text alternative.", "H37");
        for (var i = 0; i < errors.img.generalAlt.length; i++) HTMLCS.addMessage(HTMLCS.NOTICE, errors.img.generalAlt[i], "Ensure that the img element's alt text serves the same purpose and presents the same information as the image.", "G94.Image");
        for (var i = 0; i < errors.inputImage.missingAlt.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.inputImage.missingAlt[i], "Image submit button missing an alt attribute. Specify a text alternative that describes the button's function, using the alt attribute.", "H36");
        for (var i = 0; i < errors.inputImage.generalAlt.length; i++) HTMLCS.addMessage(HTMLCS.NOTICE, errors.inputImage.generalAlt[i], "Ensure that the image submit button's alt text identifies the purpose of the button.", "G94.Button");
        for (var i = 0; i < errors.area.missingAlt.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.area.missingAlt[i], "Area element in an image map missing an alt attribute. Each area element must have a text alternative that describes the function of the image map area.", "H24");
        for (var i = 0; i < errors.area.generalAlt.length; i++) HTMLCS.addMessage(HTMLCS.NOTICE, errors.area.generalAlt[i], "Ensure that the area element's text alternative serves the same purpose as the part of image map image it references.", "H24.2");
    },
    testNullAltText: function(top) {
        var errors = {
            img: {
                generalAlt: [],
                missingAlt: [],
                ignored: [],
                nullAltWithTitle: [],
                emptyAltInLink: []
            },
            inputImage: {
                generalAlt: [],
                missingAlt: []
            },
            area: {
                generalAlt: [],
                missingAlt: []
            }
        };
        elements = top.querySelectorAll('img, area, input[type="image"]');
        for (var el = 0; el < elements.length; el++) {
            var element = elements[el], nodeName = element.nodeName.toLowerCase(), linkOnlyChild = !1, missingAlt = !1, nullAlt = !1;
            if ("a" === element.parentNode.nodeName.toLowerCase()) {
                var prevNode = this._getPreviousSiblingElement(element, null), nextNode = this._getNextSiblingElement(element, null);
                if (null === prevNode && null === nextNode) {
                    var textContent = element.parentNode.textContent;
                    if (void 0 !== element.parentNode.textContent) var textContent = element.parentNode.textContent; else var textContent = element.parentNode.innerText;
                    HTMLCS.util.isStringEmpty(textContent) === !0 && (linkOnlyChild = !0);
                }
            }
            switch (element.hasAttribute("alt") === !1 ? missingAlt = !0 : element.getAttribute("alt") && HTMLCS.util.isStringEmpty(element.getAttribute("alt")) !== !0 || (nullAlt = !0), 
            nodeName) {
              case "img":
                linkOnlyChild !== !0 || missingAlt !== !0 && nullAlt !== !0 ? missingAlt === !0 ? errors.img.missingAlt.push(element) : nullAlt === !0 ? element.hasAttribute("title") === !0 && HTMLCS.util.isStringEmpty(element.getAttribute("title")) === !1 ? errors.img.nullAltWithTitle.push(element) : errors.img.ignored.push(element) : errors.img.generalAlt.push(element) : errors.img.emptyAltInLink.push(element.parentNode);
                break;

              case "input":
                missingAlt === !0 || nullAlt === !0 ? errors.inputImage.missingAlt.push(element) : errors.inputImage.generalAlt.push(element);
                break;

              case "area":
                missingAlt === !0 || nullAlt === !0 ? errors.area.missingAlt.push(element) : errors.inputImage.generalAlt.push(element);
            }
        }
        return errors;
    },
    testLongdesc: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this image cannot be fully described in a short text alternative, ensure a long text alternative is also available, such as in the body text or through a link.", "G73,G74");
    },
    testLinkStutter: function(element) {
        if ("a" === element.parentNode.nodeName.toLowerCase()) {
            var anchor = element.parentNode, nodes = {
                anchor: {
                    href: anchor.getAttribute("href"),
                    text: HTMLCS.util.getElementTextContent(anchor, !1),
                    alt: this._getLinkAltText(anchor)
                }
            };
            if (null === nodes.anchor.alt && (nodes.anchor.alt = ""), null !== nodes.anchor.alt && "" !== nodes.anchor.alt && HTMLCS.util.trim(nodes.anchor.alt).toLowerCase() === HTMLCS.util.trim(nodes.anchor.text).toLowerCase() && HTMLCS.addMessage(HTMLCS.ERROR, element, "Img element inside a link must not use alt text that duplicates the text content of the link.", "H2.EG5"), 
            "" === nodes.anchor.text) {
                var prevLink = this._getPreviousSiblingElement(anchor, "a", !0), nextLink = this._getNextSiblingElement(anchor, "a", !0);
                null !== prevLink && (nodes.previous = {
                    href: prevLink.getAttribute("href"),
                    text: HTMLCS.util.getElementTextContent(prevLink, !1),
                    alt: this._getLinkAltText(prevLink)
                }, null === nodes.previous.alt && (nodes.previous.alt = "")), null !== nextLink && (nodes.next = {
                    href: nextLink.getAttribute("href"),
                    text: HTMLCS.util.getElementTextContent(nextLink, !1),
                    alt: this._getLinkAltText(nextLink)
                }, null === nodes.next.alt && (nodes.next.alt = "")), nodes.next && "" !== nodes.next.href && null !== nodes.next.href && nodes.anchor.href === nodes.next.href && ("" !== nodes.next.text && "" === nodes.anchor.alt ? HTMLCS.addMessage(HTMLCS.ERROR, element, "Img element inside a link has empty or missing alt text when a link beside it contains link text. Consider combining the links.", "H2.EG4") : nodes.next.text.toLowerCase() === nodes.anchor.alt.toLowerCase() && HTMLCS.addMessage(HTMLCS.ERROR, element, "Img element inside a link must not use alt text that duplicates the content of a text link beside it.", "H2.EG3")), 
                nodes.previous && "" !== nodes.previous.href && null !== nodes.previous.href && nodes.anchor.href === nodes.previous.href && ("" !== nodes.previous.text && "" === nodes.anchor.alt ? HTMLCS.addMessage(HTMLCS.ERROR, element, "Img element inside a link has empty or missing alt text when a link beside it contains link text. Consider combining the links.", "H2.EG4") : nodes.previous.text.toLowerCase() === nodes.anchor.alt.toLowerCase() && HTMLCS.addMessage(HTMLCS.ERROR, element, "Img element inside a link must not use alt text that duplicates the content of a text link beside it.", "H2.EG3"));
            }
        }
    },
    addMediaAlternativesResults: function(top) {
        for (var errors = this.testMediaTextAlternatives(top), i = 0; i < errors.object.missingBody.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.object.missingBody[i], "Object elements must contain a text alternative after all other alternatives are exhausted.", "H53");
        for (var i = 0; i < errors.object.generalAlt.length; i++) HTMLCS.addMessage(HTMLCS.NOTICE, errors.object.generalAlt[i], "Check that short (and if appropriate, long) text alternatives are available for non-text content that serve the same purpose and present the same information.", "G94,G92.Object");
        for (var i = 0; i < errors.applet.missingBody.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.applet.missingBody[i], "Applet elements must contain a text alternative in the element's body, for browsers without support for the applet element.", "H35.3");
        for (var i = 0; i < errors.applet.missingAlt.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.applet.missingAlt[i], "Applet elements must contain an alt attribute, to provide a text alternative to browsers supporting the element but are unable to load the applet.", "H35.2");
        for (var i = 0; i < errors.applet.generalAlt.length; i++) HTMLCS.addMessage(HTMLCS.NOTICE, errors.applet.generalAlt[i], "Check that short (and if appropriate, long) text alternatives are available for non-text content that serve the same purpose and present the same information.", "G94,G92.Applet");
    },
    testMediaTextAlternatives: function(top) {
        for (var errors = {
            object: {
                missingBody: [],
                generalAlt: []
            },
            applet: {
                missingBody: [],
                missingAlt: [],
                generalAlt: []
            }
        }, elements = top.querySelectorAll("object"), el = 0; el < elements.length; el++) {
            var element = elements[el], childObject = (element.nodeName.toLowerCase(), element.querySelector("object"));
            if (null === childObject) {
                var textAlt = HTMLCS.util.getElementTextContent(element, !0);
                "" === textAlt ? errors.object.missingBody.push(element) : errors.object.generalAlt.push(element);
            }
        }
        for (var elements = top.querySelectorAll("applet"), el = 0; el < elements.length; el++) {
            var childObject = element.querySelector("object"), hasError = !1;
            if (null === childObject) {
                var textAlt = HTMLCS.util.getElementTextContent(element, !0);
                HTMLCS.util.isStringEmpty(textAlt) === !0 && (errors.applet.missingBody.push(element), 
                hasError = !0);
            }
            var altAttr = element.getAttribute("alt") || "";
            HTMLCS.util.isStringEmpty(altAttr) === !0 && (errors.applet.missingAlt.push(element), 
            hasError = !0), hasError === !1 && errors.applet.generalAlt.push(element);
        }
        return errors;
    },
    _getLinkAltText: function(anchor) {
        for (var anchor = anchor.cloneNode(!0), nodes = [], i = 0; i < anchor.childNodes.length; i++) nodes.push(anchor.childNodes[i]);
        for (var alt = null; nodes.length > 0; ) {
            var node = nodes.shift();
            if (1 === node.nodeType && "img" === node.nodeName.toLowerCase() && node.hasAttribute("alt") === !0) {
                alt = node.getAttribute("alt"), alt = alt ? alt.replace(/^\s+|\s+$/g, "") : "";
                break;
            }
        }
        return alt;
    },
    _getPreviousSiblingElement: function(element, tagName, immediate) {
        void 0 === tagName && (tagName = null), void 0 === immediate && (immediate = !1);
        for (var prevNode = element.previousSibling; null !== prevNode; ) {
            if (3 === prevNode.nodeType) {
                if (HTMLCS.util.isStringEmpty(prevNode.nodeValue) === !1 && immediate === !0) {
                    prevNode = null;
                    break;
                }
            } else if (1 === prevNode.nodeType) {
                if (null === tagName || prevNode.nodeName.toLowerCase() === tagName) break;
                if (immediate === !0) {
                    prevNode = null;
                    break;
                }
                break;
            }
            prevNode = prevNode.previousSibling;
        }
        return prevNode;
    },
    _getNextSiblingElement: function(element, tagName, immediate) {
        void 0 === tagName && (tagName = null), void 0 === immediate && (immediate = !1);
        for (var nextNode = element.nextSibling; null !== nextNode; ) {
            if (3 === nextNode.nodeType) {
                if (HTMLCS.util.isStringEmpty(nextNode.nodeValue) === !1 && immediate === !0) {
                    nextNode = null;
                    break;
                }
            } else if (1 === nextNode.nodeType) {
                if (null === tagName || nextNode.nodeName.toLowerCase() === tagName) break;
                if (immediate === !0) {
                    nextNode = null;
                    break;
                }
                break;
            }
            nextNode = nextNode.nextSibling;
        }
        return nextNode;
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_1 = {
    register: function() {
        return [ "object", "embed", "applet", "bgsound", "audio", "video" ];
    },
    process: function(element) {
        var nodeName = element.nodeName.toLowerCase();
        "video" !== nodeName && HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this embedded object contains pre-recorded audio only, and is not provided as an alternative for text content, check that an alternative text version is available.", "G158"), 
        "bgsound" !== nodeName && "audio" !== nodeName && HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this embedded object contains pre-recorded video only, and is not provided as an alternative for text content, check that an alternative text version is available, or an audio track is provided that presents equivalent information.", "G159,G166");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_2 = {
    register: function() {
        return [ "object", "embed", "applet", "video" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this embedded object contains pre-recorded synchronised media and is not provided as an alternative for text content, check that captions are provided for audio content.", "G87,G93");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_3 = {
    register: function() {
        return [ "object", "embed", "applet", "video" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this embedded object contains pre-recorded synchronised media and is not provided as an alternative for text content, check that an audio description of its video, and/or an alternative text version of the content is provided.", "G69,G78,G173,G8");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_4 = {
    register: function() {
        return [ "object", "embed", "applet", "video" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this embedded object contains synchronised media, check that captions are provided for live audio content.", "G9,G87,G93");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_5 = {
    register: function() {
        return [ "object", "embed", "applet", "video" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this embedded object contains pre-recorded synchronised media, check that an audio description is provided for its video content.", "G78,G173,G8");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_6 = {
    register: function() {
        return [ "object", "embed", "applet", "video" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this embedded object contains pre-recorded synchronised media, check that a sign language interpretation is provided for its audio.", "G54,G81");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_7 = {
    register: function() {
        return [ "object", "embed", "applet", "video" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this embedded object contains synchronised media, and where pauses in foreground audio is not sufficient to allow audio descriptions to convey the sense of pre-recorded video, check that an extended audio description is provided, either through scripting or an alternate version.", "G8");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_8 = {
    register: function() {
        return [ "object", "embed", "applet", "video" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this embedded object contains pre-recorded synchronised media or video-only content, check that an alternative text version of the content is provided.", "G69,G159");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_9 = {
    register: function() {
        return [ "object", "embed", "applet", "bgsound", "audio" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this embedded object contains live audio-only content, check that an alternative text version of the content is provided.", "G150,G151,G157");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = {
    _labelNames: null,
    register: function() {
        return [ "_top", "p", "div", "input", "select", "textarea", "button", "table", "fieldset", "form", "h1", "h2", "h3", "h4", "h5", "h6" ];
    },
    process: function(element, top) {
        var nodeName = element.nodeName.toLowerCase();
        if (element === top) this.testPresentationMarkup(top), this.testEmptyDupeLabelForAttrs(top); else switch (nodeName) {
          case "input":
          case "textarea":
          case "button":
            this.testLabelsOnInputs(element, top);
            break;

          case "form":
            this.testRequiredFieldsets(element);
            break;

          case "select":
            this.testLabelsOnInputs(element, top), this.testOptgroup(element);
            break;

          case "p":
          case "div":
            this.testNonSemanticHeading(element), this.testListsWithBreaks(element), this.testUnstructuredNavLinks(element);
            break;

          case "table":
            this.testGeneralTable(element), this.testTableHeaders(element), this.testTableCaptionSummary(element);
            break;

          case "fieldset":
            this.testFieldsetLegend(element);
            break;

          case "h1":
          case "h2":
          case "h3":
          case "h4":
          case "h5":
          case "h6":
            this.testEmptyHeading(element);
        }
    },
    testEmptyDupeLabelForAttrs: function(top) {
        this._labelNames = {};
        for (var labels = top.getElementsByTagName("label"), i = 0; i < labels.length; i++) if (null !== labels[i].getAttribute("for") || "" !== labels[i].getAttribute("for")) {
            var labelFor = labels[i].getAttribute("for");
            if (this._labelNames[labelFor] && null !== this._labelNames[labelFor]) this._labelNames[labelFor] = null; else {
                if (this._labelNames[labelFor] = labels[i], top.ownerDocument) var refNode = top.ownerDocument.getElementById(labelFor); else var refNode = top.getElementById(labelFor);
                if (null === refNode) {
                    var level = HTMLCS.ERROR, msg = 'This label\'s "for" attribute contains an ID that does not exist in the document.', code = "H44.NonExistent";
                    if (HTMLCS.isFullDoc(top) === !0 || "body" === top.nodeName.toLowerCase()) {
                        level = HTMLCS.WARNING, msg = 'This label\'s "for" attribute contains an ID that does not exist in the document fragment.';
                        var code = "H44.NonExistentFragment";
                    }
                    HTMLCS.addMessage(level, labels[i], msg, code);
                } else {
                    var nodeName = refNode.nodeName.toLowerCase();
                    "input" !== nodeName && "select" !== nodeName && "textarea" !== nodeName && HTMLCS.addMessage(HTMLCS.WARNING, labels[i], 'This label\'s "for" attribute contains an ID for an element that is not a form control. Ensure that you have entered the correct ID for the intended element.', "H44.NotFormControl");
                }
            }
        }
    },
    testLabelsOnInputs: function(element, top, muteErrors) {
        var nodeName = element.nodeName.toLowerCase(), inputType = nodeName;
        "input" === inputType && (inputType = element.hasAttribute("type") === !0 ? element.getAttribute("type") : "text");
        var hasLabel = !1, addToLabelList = function(found) {
            hasLabel || (hasLabel = {}), hasLabel[found] = !0;
        }, needsLabel = !1, inputType = inputType.toLowerCase();
        "select" === inputType || "textarea" === inputType ? needsLabel = !0 : /^(radio|checkbox|text|file|password)$/.test(inputType) === !0 && (needsLabel = !0), 
        null !== element.getAttribute("hidden") && (needsLabel = !1);
        var explicitLabel = element.ownerDocument.querySelector('label[for="' + element.id + '"]');
        explicitLabel && addToLabelList("explicit");
        var implicitLabel = element.parentNode;
        implicitLabel && "label" === implicitLabel.nodeName.toLowerCase() && addToLabelList("implicit");
        var title = element.getAttribute("title");
        null !== title && (/^\s*$/.test(title) === !0 && needsLabel === !0 ? HTMLCS.addMessage(HTMLCS.WARNING, element, 'This form control has a "title" attribute that is empty or contains only spaces. It will be ignored for labelling test purposes.', "H65") : addToLabelList("title"));
        var ariaLabel = element.getAttribute("aria-label");
        null !== ariaLabel && (/^\s*$/.test(ariaLabel) === !0 && needsLabel === !0 ? HTMLCS.addMessage(HTMLCS.WARNING, element, 'This form control has an "aria-label" attribute that is empty or contains only spaces. It will be ignored for labelling test purposes.', "ARIA6") : addToLabelList("aria-label"));
        var ariaLabelledBy = element.getAttribute("aria-labelledby");
        if (ariaLabelledBy && /^\s*$/.test(ariaLabelledBy) === !1) {
            var labelledByIds = ariaLabelledBy.split(/\s+/), ok = !0;
            for (x in labelledByIds) {
                var labelledByElement = element.ownerDocument.querySelector("#" + labelledByIds[x]);
                labelledByElement || (HTMLCS.addMessage(HTMLCS.WARNING, element, 'This form control contains an aria-labelledby attribute, however it includes an ID "' + labelledByIds[x] + '" that does not exist on an element. The aria-labelledby attribute will be ignored for labelling test purposes.', "ARIA16,ARIA9"), 
                ok = !1);
            }
            ok === !0 && addToLabelList("aria-labelledby");
        }
        return muteErrors !== !0 && (hasLabel !== !1 && needsLabel === !1 ? "hidden" === inputType ? HTMLCS.addMessage(HTMLCS.WARNING, element, "This hidden form field is labelled in some way. There should be no need to label a hidden form field.", "F68.Hidden") : null !== element.getAttribute("hidden") && HTMLCS.addMessage(HTMLCS.WARNING, element, 'This form field is intended to be hidden (using the "hidden" attribute), but is also labelled in some way. There should be no need to label a hidden form field.', "F68.HiddenAttr") : hasLabel === !1 && needsLabel === !0 && HTMLCS.addMessage(HTMLCS.ERROR, element, 'This form field should be labelled in some way. Use the label element (either with a "for" attribute or wrapped around the form field), or "title", "aria-label" or "aria-labelledby" attributes as appropriate.', "F68")), 
        hasLabel;
    },
    testPresentationMarkup: function(top) {
        for (var tags = top.querySelectorAll("b, i, u, s, strike, tt, big, small, center, font"), i = 0; i < tags.length; i++) {
            var msgCode = "H49." + tags[i].nodeName.substr(0, 1).toUpperCase() + tags[i].nodeName.substr(1).toLowerCase();
            HTMLCS.addMessage(HTMLCS.WARNING, tags[i], "Semantic markup should be used to mark emphasised or special text so that it can be programmatically determined.", msgCode);
        }
        for (var tags = top.querySelectorAll("*[align]"), i = 0; i < tags.length; i++) {
            var msgCode = "H49.AlignAttr";
            HTMLCS.addMessage(HTMLCS.WARNING, tags[i], "Semantic markup should be used to mark emphasised or special text so that it can be programmatically determined.", msgCode);
        }
    },
    testNonSemanticHeading: function(element) {
        var tag = element.nodeName.toLowerCase();
        if ("p" === tag || "div" === tag) {
            var children = element.childNodes;
            if (1 === children.length && 1 === children[0].nodeType) {
                var childTag = children[0].nodeName.toLowerCase();
                /^(strong|em|b|i|u)$/.test(childTag) === !0 && HTMLCS.addMessage(HTMLCS.WARNING, element, "Heading markup should be used if this content is intended as a heading.", "H42");
            }
        }
    },
    testTableHeaders: function(table) {
        for (var headersAttr = HTMLCS.util.testTableHeaders(table), scopeAttr = this._testTableScopeAttrs(table), i = 0; i < scopeAttr.invalid.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, scopeAttr.invalid[i], "Table cell has an invalid scope attribute. Valid values are row, col, rowgroup, or colgroup.", "H63.3");
        for (var i = 0; i < scopeAttr.obsoleteTd.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, scopeAttr.obsoleteTd[i], "Scope attributes on td elements that act as headings for other elements are obsolete in HTML5. Use a th element instead.", "H63.2");
        headersAttr.allowScope === !0 ? 0 === scopeAttr.missing.length && headersAttr.required === !1 : scopeAttr.used === !0 && (HTMLCS.addMessage(HTMLCS.WARNING, table, "Scope attributes on th elements are ambiguous in a table with multiple levels of headings. Use the headers attribute on td elements instead.", "H43.ScopeAmbiguous"), 
        scopeAttr = null);
        for (var i = 0; i < headersAttr.wrongHeaders.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, headersAttr.wrongHeaders[i].element, 'Incorrect headers attribute on this td element. Expected "' + headersAttr.wrongHeaders[i].expected + '" but found "' + headersAttr.wrongHeaders[i].actual + '"', "H43.IncorrectAttr");
        headersAttr.required === !0 && headersAttr.allowScope === !1 && (headersAttr.used === !1 ? HTMLCS.addMessage(HTMLCS.ERROR, table, "The relationship between td elements and their associated th elements is not defined. As this table has multiple levels of th elements, you must use the headers attribute on td elements.", "H43.HeadersRequired") : (headersAttr.missingThId.length > 0 && HTMLCS.addMessage(HTMLCS.ERROR, table, "Not all th elements in this table contain an id attribute. These cells should contain ids so that they may be referenced by td elements' headers attributes.", "H43.MissingHeaderIds"), 
        headersAttr.missingTd.length > 0 && HTMLCS.addMessage(HTMLCS.ERROR, table, "Not all td elements in this table contain a headers attribute. Each headers attribute should list the ids of all th elements associated with that cell.", "H43.MissingHeadersAttrs"))), 
        headersAttr.required === !0 && headersAttr.allowScope === !0 && headersAttr.correct === !1 && scopeAttr.correct === !1 && (scopeAttr.used === !1 && headersAttr.used === !1 ? HTMLCS.addMessage(HTMLCS.ERROR, table, "The relationship between td elements and their associated th elements is not defined. Use either the scope attribute on th elements, or the headers attribute on td elements.", "H43,H63") : scopeAttr.used === !1 && (headersAttr.missingThId.length > 0 || headersAttr.missingTd.length > 0) ? (headersAttr.missingThId.length > 0 && HTMLCS.addMessage(HTMLCS.ERROR, table, "Not all th elements in this table contain an id attribute. These cells should contain ids so that they may be referenced by td elements' headers attributes.", "H43.MissingHeaderIds"), 
        headersAttr.missingTd.length > 0 && HTMLCS.addMessage(HTMLCS.ERROR, table, "Not all td elements in this table contain a headers attribute. Each headers attribute should list the ids of all th elements associated with that cell.", "H43.MissingHeadersAttrs")) : scopeAttr.missing.length > 0 && headersAttr.used === !1 ? HTMLCS.addMessage(HTMLCS.ERROR, table, "Not all th elements in this table have a scope attribute. These cells should contain a scope attribute to identify their association with td elements.", "H63.1") : scopeAttr.missing.length > 0 && (headersAttr.missingThId.length > 0 || headersAttr.missingTd.length > 0) && HTMLCS.addMessage(HTMLCS.ERROR, table, "The relationship between td elements and their associated th elements is not defined. Use either the scope attribute on th elements, or the headers attribute on td elements.", "H43,H63"));
    },
    _testTableScopeAttrs: function(table) {
        var elements = {
            th: table.getElementsByTagName("th"),
            td: table.getElementsByTagName("td")
        }, retval = {
            used: !1,
            correct: !0,
            missing: [],
            invalid: [],
            obsoleteTd: []
        };
        for (var tagType in elements) for (var i = 0; i < elements[tagType].length; i++) {
            element = elements[tagType][i];
            var scope = "";
            element.hasAttribute("scope") === !0 && (retval.used = !0, element.getAttribute("scope") && (scope = element.getAttribute("scope"))), 
            "th" === element.nodeName.toLowerCase() ? /^\s*$/.test(scope) === !0 ? (retval.correct = !1, 
            retval.missing.push(element)) : /^(row|col|rowgroup|colgroup)$/.test(scope) === !1 && (retval.correct = !1, 
            retval.invalid.push(element)) : "" !== scope && (retval.obsoleteTd.push(element), 
            /^(row|col|rowgroup|colgroup)$/.test(scope) === !1 && (retval.correct = !1, retval.invalid.push(element)));
        }
        return retval;
    },
    testTableCaptionSummary: function(table) {
        var summary = table.getAttribute("summary") || "", captionEl = table.getElementsByTagName("caption"), caption = "";
        captionEl.length > 0 && (caption = captionEl[0].innerHTML.replace(/^\s*(.*?)\s*$/g, "$1")), 
        summary = summary.replace(/^\s*(.*?)\s*$/g, "$1"), "" !== summary ? HTMLCS.util.isLayoutTable(table) === !0 ? HTMLCS.addMessage(HTMLCS.ERROR, table, "This table appears to be used for layout, but contains a summary attribute. Layout tables must not contain summary attributes, or if supplied, must be empty.", "H73.3.LayoutTable") : (caption === summary && HTMLCS.addMessage(HTMLCS.ERROR, table, "If this table is a data table, and both a summary attribute and a caption element are present, the summary should not duplicate the caption.", "H39,H73.4"), 
        HTMLCS.addMessage(HTMLCS.NOTICE, table, "If this table is a data table, check that the summary attribute describes the table's organization or explains how to use the table.", "H73.3.Check")) : HTMLCS.util.isLayoutTable(table) === !1 && HTMLCS.addMessage(HTMLCS.WARNING, table, "If this table is a data table, consider using the summary attribute of the table element to give an overview of this table.", "H73.3.NoSummary"), 
        "" !== caption ? HTMLCS.util.isLayoutTable(table) === !0 ? HTMLCS.addMessage(HTMLCS.ERROR, table, "This table appears to be used for layout, but contains a caption element. Layout tables must not contain captions.", "H39.3.LayoutTable") : HTMLCS.addMessage(HTMLCS.NOTICE, table, "If this table is a data table, check that the caption element accurately describes this table.", "H39.3.Check") : HTMLCS.util.isLayoutTable(table) === !1 && HTMLCS.addMessage(HTMLCS.WARNING, table, "If this table is a data table, consider using a caption element to the table element to identify this table.", "H39.3.NoCaption");
    },
    testFieldsetLegend: function(fieldset) {
        var legend = fieldset.querySelector("legend");
        (null === legend || legend.parentNode !== fieldset) && HTMLCS.addMessage(HTMLCS.ERROR, fieldset, "Fieldset does not contain a legend element. All fieldsets should contain a legend element that describes a description of the field group.", "H71.NoLegend");
    },
    testOptgroup: function(select) {
        var optgroup = select.querySelector("optgroup");
        null === optgroup && HTMLCS.addMessage(HTMLCS.WARNING, select, "If this selection list contains groups of related options, they should be grouped with optgroup.", "H85.2");
    },
    testRequiredFieldsets: function(form) {
        for (var optionInputs = form.querySelectorAll("input[type=radio], input[type=checkbox]"), usedNames = {}, i = 0; i < optionInputs.length; i++) {
            var option = optionInputs[i];
            if (option.hasAttribute("name") === !0) {
                for (var optionName = option.getAttribute("name"), fieldset = option.parentNode; "fieldset" !== fieldset.nodeName.toLowerCase() && null !== fieldset && fieldset !== form; ) fieldset = fieldset.parentNode;
                "fieldset" !== fieldset.nodeName.toLowerCase() && (fieldset = null);
            }
            if (void 0 === usedNames[optionName]) usedNames[optionName] = fieldset; else if (null === fieldset || fieldset !== usedNames[optionName]) {
                HTMLCS.addMessage(HTMLCS.WARNING, form, "If these radio buttons or check boxes require a further group-level description, they should be contained within a fieldset element.", "H71.SameName");
                break;
            }
        }
    },
    testListsWithBreaks: function(element) {
        var firstBreak = element.querySelector("br"), items = [];
        if (null !== firstBreak) {
            for (var nodes = [], i = 0; i < element.childNodes.length; i++) nodes.push(element.childNodes[i]);
            for (var thisItem = []; nodes.length > 0; ) {
                var subel = nodes.shift();
                if (1 === subel.nodeType) if ("br" === subel.nodeName.toLowerCase()) items.push(thisItem.join(" ").replace(/^\s*(.*?)\s*$/g, "$1")), 
                thisItem = []; else for (var i = subel.childNodes.length - 1; i >= 0; --i) nodes.unshift(subel.childNodes[i]); else 3 === subel.nodeType && thisItem.push(subel.nodeValue);
            }
            thisItem.length > 0 && items.push(thisItem.join(" ").replace(/^\s*(.*?)\s*$/g, "$1"));
            for (var i = 0; i < items.length; i++) {
                if (/^[\-*]\s+/.test(items[0]) === !0) {
                    HTMLCS.addMessage(HTMLCS.WARNING, element, "Content appears to have the visual appearance of a bulleted list. It may be appropriate to mark this content up using a ul element.", "H48.1");
                    break;
                }
                if (/^\d+[:\/\-.]?\s+/.test(items[0]) === !0) {
                    HTMLCS.addMessage(HTMLCS.WARNING, element, "Content appears to have the visual appearance of a numbered list. It may be appropriate to mark this content up using an ol element.", "H48.2");
                    break;
                }
            }
        }
    },
    testHeadingOrder: function(top, level) {
        for (var lastHeading = 0, headings = top.querySelectorAll("h1, h2, h3, h4, h5, h6"), i = 0; i < headings.length; i++) {
            var headingNum = parseInt(headings[i].nodeName.substr(1, 1));
            if (headingNum - lastHeading > 1) {
                var exampleMsg = "should be an h" + (lastHeading + 1) + " to be properly nested";
                0 === lastHeading && (exampleMsg = "appears to be the primary document heading, so should be an h1 element"), 
                HTMLCS.addMessage(level, headings[i], "The heading structure is not logically nested. This h" + headingNum + " element " + exampleMsg + ".", "G141");
            }
            lastHeading = headingNum;
        }
    },
    testEmptyHeading: function(element) {
        var text = element.textContent;
        void 0 === text && (text = element.innerText), /^\s*$/.test(text) === !0 && HTMLCS.addMessage(HTMLCS.ERROR, element, "Heading tag found with no content. Text that is not intended as a heading should not be marked up with heading tags.", "H42.2");
    },
    testUnstructuredNavLinks: function(element) {
        for (var linksLength = (element.nodeName.toLowerCase(), 0), childNodes = element.childNodes, i = 0; i < childNodes.length && !(1 === childNodes[i].nodeType && "a" === childNodes[i].nodeName.toLowerCase() && (linksLength++, 
        linksLength > 1)); i++) ;
        if (linksLength > 1) {
            for (var parent = element.parentNode; null !== parent && "ul" !== parent.nodeName.toLowerCase() && "ol" !== parent.nodeName.toLowerCase(); ) parent = parent.parentNode;
            null === parent && HTMLCS.addMessage(HTMLCS.WARNING, element, "If this element contains a navigation section, it is recommended that it be marked up as a list.", "H48");
        }
    },
    testGeneralTable: function(table) {
        HTMLCS.util.isLayoutTable(table) === !0 ? HTMLCS.addMessage(HTMLCS.NOTICE, table, "This table appears to be a layout table. If it is meant to instead be a data table, ensure header cells are identified using th elements.", "LayoutTable") : HTMLCS.addMessage(HTMLCS.NOTICE, table, "This table appears to be a data table. If it is meant to instead be a layout table, ensure there are no th elements, and no summary or caption.", "DataTable");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1_A = {
    _labelNames: null,
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        var sniff = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1;
        element === top && sniff.testHeadingOrder(top, HTMLCS.WARNING);
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1_AAA = {
    _labelNames: null,
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        var sniff = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1;
        element === top && sniff.testHeadingOrder(top, HTMLCS.ERROR);
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_2 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that the content is ordered in a meaningful sequence when linearised, such as when style sheets are disabled.", "G57");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_3 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Where instructions are provided for understanding the content, do not rely on sensory characteristics alone (such as shape, size or location) to describe objects.", "G96");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_1 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that any information conveyed using colour alone is also available in text, or through other visual cues.", "G14,G182");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_2 = {
    register: function() {
        return [ "object", "embed", "applet", "bgsound", "audio", "video" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "If this element contains audio that plays automatically for longer than 3 seconds, check that there is the ability to pause, stop or mute the audio.", "F23");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        if (element === top) for (var failures = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast.testContrastRatio(top, 4.5, 3), i = 0; i < failures.length; i++) {
            for (var element = failures[i].element, decimals = 2, value = Math.round(failures[i].value * Math.pow(10, decimals)) / Math.pow(10, decimals), required = failures[i].required, recommend = failures[i].recommendation, hasBgImg = failures[i].hasBgImage || !1, isAbsolute = (failures[i].bgColour || !1, 
            failures[i].isAbsolute || !1); required === value; ) decimals++, value = Math.round(failures[i].value * Math.pow(10, decimals)) / Math.pow(10, decimals);
            if (4.5 === required) var code = "G18"; else if (3 === required) var code = "G145";
            var recommendText = [];
            recommend && (recommend.fore.from !== recommend.fore.to && recommendText.push("text colour to " + recommend.fore.to), 
            recommend.back.from !== recommend.back.to && recommendText.push("background to " + recommend.back.to)), 
            recommendText.length > 0 && (recommendText = " Recommendation: change " + recommendText.join(", ") + "."), 
            isAbsolute === !0 ? (code += ".Abs", HTMLCS.addMessage(HTMLCS.WARNING, element, "This element is absolutely positioned and the background color can not be determined. Ensure the contrast ratio between the text and all covered parts of the background are at least " + required + ":1.", code)) : hasBgImg === !0 ? (code += ".BgImage", 
            HTMLCS.addMessage(HTMLCS.WARNING, element, "This element's text is placed on a background image. Ensure the contrast ratio between the text and all covered parts of the image are at least " + required + ":1.", code)) : (code += ".Fail", 
            HTMLCS.addMessage(HTMLCS.ERROR, element, "This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least " + required + ":1, but text in this element has a contrast ratio of " + value + ":1." + recommendText, code));
        }
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = {
    testContrastRatio: function(top, minContrast, minLargeContrast) {
        var failures = (new Date(), []);
        if (top.ownerDocument) var toProcess = [ top ]; else var toProcess = [ top.getElementsByTagName("body")[0] ];
        for (;toProcess.length > 0; ) {
            var node = toProcess.shift();
            if (1 === node.nodeType && HTMLCS.util.isHidden(node) === !1 && HTMLCS.util.isDisabled(node) === !1) {
                for (var processNode = !1, i = 0; i < node.childNodes.length; i++) 1 === node.childNodes[i].nodeType ? toProcess.push(node.childNodes[i]) : 3 === node.childNodes[i].nodeType && "" !== HTMLCS.util.trim(node.childNodes[i].nodeValue) && (processNode = !0);
                if (processNode === !0) {
                    var style = HTMLCS.util.style(node);
                    if (style) {
                        var bgColour = style.backgroundColor, foreColour = style.color, hasBgImg = !1, isAbsolute = !1;
                        "none" !== style.backgroundImage && (hasBgImg = !0), "absolute" == style.position && (isAbsolute = !0);
                        var parent = node.parentNode, fontSize = .75 * parseInt(style.fontSize, 10), minLargeSize = 18;
                        if ("bold" === style.fontWeight || parseInt(style.fontWeight, 10) >= 600) var minLargeSize = 14;
                        var reqRatio = minContrast;
                        for (fontSize >= minLargeSize && (reqRatio = minLargeContrast); ("transparent" === bgColour || "rgba(0, 0, 0, 0)" === bgColour) && parent && parent.ownerDocument; ) {
                            var parentStyle = HTMLCS.util.style(parent), bgColour = parentStyle.backgroundColor;
                            "none" !== parentStyle.backgroundImage && (hasBgImg = !0), "absolute" == parentStyle.position && (isAbsolute = !0), 
                            parent = parent.parentNode;
                        }
                        if (hasBgImg === !0) {
                            failures.push({
                                element: node,
                                colour: style.color,
                                bgColour: void 0,
                                value: void 0,
                                required: reqRatio,
                                hasBgImage: !0
                            });
                            continue;
                        }
                        if (isAbsolute === !0) failures.push({
                            element: node,
                            colour: foreColour,
                            bgColour: void 0,
                            value: void 0,
                            required: reqRatio,
                            isAbsolute: !0
                        }); else if ("transparent" === bgColour || "rgba(0, 0, 0, 0)" === bgColour) continue;
                        var contrastRatio = HTMLCS.util.contrastRatio(bgColour, style.color);
                        if (reqRatio > contrastRatio) {
                            var recommendation = this.recommendColour(bgColour, style.color, reqRatio);
                            failures.push({
                                element: node,
                                colour: style.color,
                                bgColour: bgColour,
                                value: contrastRatio,
                                required: reqRatio,
                                recommendation: recommendation
                            });
                        }
                    }
                }
            }
        }
        return failures;
    },
    recommendColour: function(back, fore, target) {
        var fore = HTMLCS.util.RGBtoColourStr(HTMLCS.util.colourStrToRGB(fore)), back = HTMLCS.util.RGBtoColourStr(HTMLCS.util.colourStrToRGB(back)), cr = HTMLCS.util.contrastRatio(fore, back), foreDiff = Math.abs(HTMLCS.util.relativeLum(fore) - .5), backDiff = Math.abs(HTMLCS.util.relativeLum(back) - .5), recommendation = null;
        if (target > cr) {
            var multiplier = 1.0025;
            if (backDiff >= foreDiff) {
                var change = "back", newCol = back;
                if (HTMLCS.util.relativeLum(back) < .5) var multiplier = 1 / multiplier;
            } else {
                var change = "fore", newCol = fore;
                if (HTMLCS.util.relativeLum(fore) < .5) var multiplier = 1 / multiplier;
            }
            for (var hsv = HTMLCS.util.sRGBtoHSV(newCol), chroma = hsv.saturation * hsv.value, newFore = fore, newBack = back, changed = !1, i = 0; target > cr; ) {
                if ("#fff" === newCol || "#000" === newCol) if (changed === !0) if ("fore" === change) for (var oldBack = newBack, j = 1; newBack === oldBack; ) {
                    var newBack = this.multiplyColour(newBack, Math.pow(1 / multiplier, j));
                    j++;
                } else for (var oldFore = newFore, j = 1; newFore === oldFore; ) {
                    var newFore = this.multiplyColour(newFore, Math.pow(1 / multiplier, j));
                    j++;
                } else {
                    if (newFore = fore, newBack = back, multiplier = 1 / multiplier, "fore" === change) {
                        change = "back";
                        var hsv = back;
                    } else {
                        change = "fore";
                        var hsv = fore;
                    }
                    hsv = HTMLCS.util.sRGBtoHSV(hsv), chroma = hsv.saturation * hsv.value, changed = !0;
                }
                i++;
                var newCol = HTMLCS.util.HSVtosRGB(hsv), newCol = this.multiplyColour(newCol, Math.pow(multiplier, i));
                if ("fore" === change) var newFore = newCol; else var newBack = newCol;
                var cr = HTMLCS.util.contrastRatio(newFore, newBack);
            }
            recommendation = {
                fore: {
                    from: fore,
                    to: newFore
                },
                back: {
                    from: back,
                    to: newBack
                }
            };
        }
        return recommendation;
    },
    multiplyColour: function(colour, multiplier) {
        var hsvColour = HTMLCS.util.sRGBtoHSV(colour), chroma = hsvColour.saturation * hsvColour.value;
        0 === hsvColour.value && (hsvColour.value = 1 / 255), hsvColour.value = hsvColour.value * multiplier, 
        hsvColour.saturation = 0 === hsvColour.value ? 0 : chroma / hsvColour.value, hsvColour.value = Math.min(1, hsvColour.value), 
        hsvColour.saturation = Math.min(1, hsvColour.saturation);
        var newColour = HTMLCS.util.RGBtoColourStr(HTMLCS.util.HSVtosRGB(hsvColour));
        return newColour;
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_F24 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        for (var elements = top.querySelectorAll("*"), i = 0; i < elements.length; i++) this.testColourComboFail(elements[i]);
    },
    testColourComboFail: function(element) {
        var hasFg = element.hasAttribute("color");
        hasFg = hasFg || element.hasAttribute("link"), hasFg = hasFg || element.hasAttribute("vlink"), 
        hasFg = hasFg || element.hasAttribute("alink");
        var hasBg = element.hasAttribute("bgcolor");
        if (element.style) {
            var fgStyle = element.style.color, bgStyle = element.style.background;
            "" !== fgStyle && "auto" !== fgStyle && (hasFg = !0), "" !== bgStyle && "auto" !== bgStyle && (hasBg = !0);
        }
        hasBg !== hasFg && (hasBg === !0 ? HTMLCS.addMessage(HTMLCS.WARNING, element, "Check that this element has an inherited foreground colour to complement the corresponding inline background colour or image.", "F24.BGColour") : HTMLCS.addMessage(HTMLCS.WARNING, element, "Check that this element has an inherited background colour or image to complement the corresponding inline foreground colour.", "F24.FGColour"));
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_4 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that text can be resized without assistive technology up to 200 percent without loss of content or functionality.", "G142");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_5 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        var imgObj = top.querySelector("img");
        null !== imgObj && HTMLCS.addMessage(HTMLCS.NOTICE, top, "If the technologies being used can achieve the visual presentation, check that text is used to convey information rather than images of text, except when the image of text is essential to the information being conveyed, or can be visually customised to the user's requirements.", "G140,C22,C30.AALevel");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_6 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        if (element === top) for (var failures = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast.testContrastRatio(top, 7, 4.5), i = 0; i < failures.length; i++) {
            for (var element = failures[i].element, decimals = 2, value = Math.round(failures[i].value * Math.pow(10, decimals)) / Math.pow(10, decimals), required = failures[i].required, recommend = failures[i].recommendation, hasBgImg = failures[i].hasBgImage || !1; required === value; ) decimals++, 
            value = Math.round(failures[i].value * Math.pow(10, decimals)) / Math.pow(10, decimals);
            if (4.5 === required) var code = "G18"; else if (7 === required) var code = "G17";
            var recommendText = [];
            recommend && (recommend.fore.from !== recommend.fore.to && recommendText.push("text colour to " + recommend.fore.to), 
            recommend.back.from !== recommend.back.to && recommendText.push("background to " + recommend.back.to)), 
            recommendText.length > 0 && (recommendText = " Recommendation: change " + recommendText.join(", ") + "."), 
            hasBgImg === !0 ? (code += ".BgImage", HTMLCS.addMessage(HTMLCS.WARNING, element, "This element's text is placed on a background image. Ensure the contrast ratio between the text and all covered parts of the image are at least " + required + ":1.", code)) : (code += ".Fail", 
            HTMLCS.addMessage(HTMLCS.ERROR, element, "This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least " + required + ":1, but text in this element has a contrast ratio of " + value + ":1." + recommendText, code));
        }
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_7 = {
    register: function() {
        return [ "object", "embed", "applet", "bgsound", "audio" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "For pre-recorded audio-only content in this element that is primarily speech (such as narration), any background sounds should be muteable, or be at least 20 dB (or about 4 times) quieter than the speech.", "G56");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_8 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that a mechanism is available for the user to select foreground and background colours for blocks of text, either through the Web page or the browser.", "G148,G156,G175"), 
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that a mechanism exists to reduce the width of a block of text to no more than 80 characters (or 40 in Chinese, Japanese or Korean script).", "H87,C20"), 
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that blocks of text are not fully justified - that is, to both left and right edges - or a mechanism exists to remove full justification.", "C19,G172,G169"), 
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that line spacing in blocks of text are at least 150% in paragraphs, and paragraph spacing is at least 1.5 times the line spacing, or that a mechanism is available to achieve this.", "G188,C21"), 
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that text can be resized without assistive technology up to 200 percent without requiring the user to scroll horizontally on a full-screen window.", "H87,G146,C26");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_9 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        var imgObj = top.querySelector("img");
        null !== imgObj && HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that images of text are only used for pure decoration or where a particular presentation of text is essential to the information being conveyed.", "G140,C22,C30.NoException");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_1_2_1_1 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        if (element === top) {
            for (var dblClickEls = top.querySelectorAll("*[ondblclick]"), i = 0; i < dblClickEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, dblClickEls[i], "Ensure the functionality provided by double-clicking on this element is available through the keyboard.", "SCR20.DblClick");
            for (var mouseOverEls = top.querySelectorAll("*[onmouseover]"), i = 0; i < mouseOverEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, mouseOverEls[i], "Ensure the functionality provided by mousing over this element is available through the keyboard; for instance, using the focus event.", "SCR20.MouseOver");
            for (var mouseOutEls = top.querySelectorAll("*[onmouseout]"), i = 0; i < mouseOutEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, mouseOutEls[i], "Ensure the functionality provided by mousing out of this element is available through the keyboard; for instance, using the blur event.", "SCR20.MouseOut");
            for (var mouseMoveEls = top.querySelectorAll("*[onmousemove]"), i = 0; i < mouseMoveEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, mouseMoveEls[i], "Ensure the functionality provided by moving the mouse on this element is available through the keyboard.", "SCR20.MouseMove");
            for (var mouseDownEls = top.querySelectorAll("*[onmousedown]"), i = 0; i < mouseDownEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, mouseDownEls[i], "Ensure the functionality provided by mousing down on this element is available through the keyboard; for instance, using the keydown event.", "SCR20.MouseDown");
            for (var mouseUpEls = top.querySelectorAll("*[onmouseup]"), i = 0; i < mouseUpEls.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, mouseUpEls[i], "Ensure the functionality provided by mousing up on this element is available through the keyboard; for instance, using the keyup event.", "SCR20.MouseUp");
        }
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_1_2_1_2 = {
    register: function() {
        return [ "object", "applet", "embed" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.WARNING, element, "Check that this applet or plugin provides the ability to move the focus away from itself when using the keyboard.", "F10");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_1 = {
    register: function() {
        return [ "meta" ];
    },
    process: function(element) {
        element.hasAttribute("http-equiv") === !0 && "refresh" === String(element.getAttribute("http-equiv")).toLowerCase() && /^[1-9]\d*/.test(element.getAttribute("content").toLowerCase()) === !0 && (/url=/.test(element.getAttribute("content").toLowerCase()) === !0 ? HTMLCS.addMessage(HTMLCS.ERROR, element, "Meta refresh tag used to redirect to another page, with a time limit that is not zero. Users cannot control this time limit.", "F40.2") : HTMLCS.addMessage(HTMLCS.ERROR, element, "Meta refresh tag used to refresh the current page. Users cannot control the time limit for this refresh.", "F41.2"));
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_2 = {
    register: function() {
        return [ "_top", "blink" ];
    },
    process: function(element, top) {
        if (element === top) {
            HTMLCS.addMessage(HTMLCS.NOTICE, element, "If any part of the content moves, scrolls or blinks for more than 5 seconds, or auto-updates, check that there is a mechanism available to pause, stop, or hide the content.", "SCR33,SCR22,G187,G152,G186,G191");
            for (var elements = top.querySelectorAll("*"), i = 0; i < elements.length; i++) {
                var computedStyle = HTMLCS.util.style(elements[i]);
                computedStyle && /blink/.test(computedStyle["text-decoration"]) === !0 && HTMLCS.addMessage(HTMLCS.WARNING, elements[i], "Ensure there is a mechanism available to stop this blinking element in less than five seconds.", "F4");
            }
        } else "blink" === element.nodeName.toLowerCase() && HTMLCS.addMessage(HTMLCS.ERROR, element, "Blink elements cannot satisfy the requirement that blinking information can be stopped within five seconds.", "F47");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_3 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that timing is not an essential part of the event or activity presented by the content, except for non-interactive synchronized media and real-time events.", "G5");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_4 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that all interruptions (including updates to content) can be postponed or suppressed by the user, except interruptions involving an emergency.", "SCR14");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_5 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this Web page is part of a set of Web pages with an inactivity time limit, check that an authenticated user can continue the activity without loss of data after re-authenticating.", "G105,G181");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_3_2_3_1 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that no component of the content flashes more than three times in any 1-second period, or that the size of any flashing area is sufficiently small.", "G19,G176");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_3_2_3_2 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that no component of the content flashes more than three times in any 1-second period.", "G19");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_1 = {
    register: function() {
        return [ "iframe", "a", "area", "_top" ];
    },
    process: function(element, top) {
        if (element === top) this.testGenericBypassMsg(top); else {
            var nodeName = element.nodeName.toLowerCase();
            switch (nodeName) {
              case "iframe":
                this.testIframeTitle(element);
                break;

              case "a":
              case "area":
                this.testSameDocFragmentLinks(element, top);
            }
        }
    },
    testIframeTitle: function(element) {
        var nodeName = element.nodeName.toLowerCase();
        if ("iframe" === nodeName) {
            var hasTitle = !1;
            element.hasAttribute("title") === !0 && element.getAttribute("title") && /^\s+$/.test(element.getAttribute("title")) === !1 && (hasTitle = !0), 
            hasTitle === !1 ? HTMLCS.addMessage(HTMLCS.ERROR, element, "Iframe element requires a non-empty title attribute that identifies the frame.", "H64.1") : HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that the title attribute of this element contains text that identifies the frame.", "H64.2");
        }
    },
    testGenericBypassMsg: function(top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Ensure that any common navigation elements can be bypassed; for instance, by use of skip links, header elements, or ARIA landmark roles.", "G1,G123,G124,H69");
    },
    testSameDocFragmentLinks: function(element, top) {
        if (element.hasAttribute("href") === !0) {
            var href = element.getAttribute("href");
            if (href = HTMLCS.util.trim(href), href.length > 1 && "#" === href.charAt(0)) {
                var id = href.substr(1);
                try {
                    var doc = top;
                    doc.ownerDocument && (doc = doc.ownerDocument);
                    var target = doc.getElementById(id);
                    null === target && (target = doc.querySelector('a[name="' + id + '"]')), (null === target || HTMLCS.util.contains(top, target) === !1) && (HTMLCS.isFullDoc(top) === !0 || "body" === top.nodeName.toLowerCase() ? HTMLCS.addMessage(HTMLCS.ERROR, element, 'This link points to a named anchor "' + id + '" within the document, but no anchor exists with that name.', "G1,G123,G124.NoSuchID") : HTMLCS.addMessage(HTMLCS.WARNING, element, 'This link points to a named anchor "' + id + '" within the document, but no anchor exists with that name in the fragment tested.', "G1,G123,G124.NoSuchIDFragment"));
                } catch (ex) {}
            }
        }
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_2 = {
    register: function() {
        return [ "html" ];
    },
    process: function(element) {
        for (var children = element.childNodes, head = null, i = 0; i < children.length; i++) if ("head" === children[i].nodeName.toLowerCase()) {
            head = children[i];
            break;
        }
        if (null === head) HTMLCS.addMessage(HTMLCS.ERROR, element, "There is no head section in which to place a descriptive title element.", "H25.1.NoHeadEl"); else {
            for (var children = head.childNodes, title = null, i = 0; i < children.length; i++) if ("title" === children[i].nodeName.toLowerCase()) {
                title = children[i];
                break;
            }
            null === title ? HTMLCS.addMessage(HTMLCS.ERROR, head, "A title should be provided for the document, using a non-empty title element in the head section.", "H25.1.NoTitleEl") : /^\s*$/.test(title.innerHTML) === !0 ? HTMLCS.addMessage(HTMLCS.ERROR, title, "The title element in the head section should be non-empty.", "H25.1.EmptyTitle") : HTMLCS.addMessage(HTMLCS.NOTICE, title, "Check that the title element describes the document.", "H25.2");
        }
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_3 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        if (element === top) {
            var tabIndexExists = top.querySelector("*[tabindex]");
            tabIndexExists && HTMLCS.addMessage(HTMLCS.NOTICE, element, "If tabindex is used, check that the tab order specified by the tabindex attributes follows relationships in the content.", "H4.2");
        }
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_4 = {
    register: function() {
        return [ "a" ];
    },
    process: function(element) {
        element.hasAttribute("title") === !0 ? HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that the link text combined with programmatically determined link context, or its title attribute, identifies the purpose of the link.", "H77,H78,H79,H80,H81,H33") : HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that the link text combined with programmatically determined link context identifies the purpose of the link.", "H77,H78,H79,H80,H81");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_5 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this Web page is not part of a linear process, check that there is more than one way of locating this Web page within a set of Web pages.", "G125,G64,G63,G161,G126,G185");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_6 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that headings and labels describe topic or purpose.", "G130,G131");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_7 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        var inputField = top.querySelector("input, textarea, button, select, a");
        null !== inputField && HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that there is at least one mode of operation where the keyboard focus indicator can be visually located on user interface controls.", "G149,G165,G195,C15,SCR31");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_8 = {
    register: function() {
        return [ "link" ];
    },
    process: function(element) {
        var linkParentName = element.parentNode.nodeName.toLowerCase();
        "head" !== linkParentName && HTMLCS.addMessage(HTMLCS.ERROR, element, "Link elements can only be located in the head section of the document.", "H59.1"), 
        element.hasAttribute("rel") !== !1 && element.getAttribute("rel") && /^\s*$/.test(element.getAttribute("rel")) !== !0 || HTMLCS.addMessage(HTMLCS.ERROR, element, "Link element is missing a non-empty rel attribute identifying the link type.", "H59.2a"), 
        element.hasAttribute("href") !== !1 && element.getAttribute("href") && /^\s*$/.test(element.getAttribute("href")) !== !0 || HTMLCS.addMessage(HTMLCS.ERROR, element, "Link element is missing a non-empty href attribute pointing to the resource being linked.", "H59.2b");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_9 = {
    register: function() {
        return [ "a" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that text of the link describes the purpose of the link.", "H30");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_1 = {
    register: function() {
        return [ "html" ];
    },
    process: function(element, top) {
        if (element.hasAttribute("lang") === !1 && element.hasAttribute("xml:lang") === !1) HTMLCS.addMessage(HTMLCS.ERROR, element, "The html element should have a lang or xml:lang attribute which describes the language of the document.", "H57.2"); else {
            if (element.hasAttribute("lang") === !0) {
                var lang = element.getAttribute("lang");
                this.isValidLanguageTag(lang) === !1 && HTMLCS.addMessage(HTMLCS.ERROR, top, "The language specified in the lang attribute of the document element does not appear to be well-formed.", "H57.3.Lang");
            }
            if (element.hasAttribute("xml:lang") === !0) {
                var lang = element.getAttribute("xml:lang");
                this.isValidLanguageTag(lang) === !1 && HTMLCS.addMessage(HTMLCS.ERROR, top, "The language specified in the xml:lang attribute of the document element does not appear to be well-formed.", "H57.3.XmlLang");
            }
        }
    },
    isValidLanguageTag: function(langTag) {
        var regexStr = "^([ix](-[a-z0-9]{1,8})+)$|";
        regexStr += "^[a-z]{2,8}", regexStr += "(-[a-z]{3}){0,3}", regexStr += "(-[a-z]{4})?", 
        regexStr += "(-[a-z]{2}|-[0-9]{3})?", regexStr += "(-[0-9][a-z0-9]{3}|-[a-z0-9]{5,8})*", 
        regexStr += "(-[a-wy-z0-9](-[a-z0-9]{2,8})+)*", regexStr += "(-x(-[a-z0-9]{1,8})+)?$";
        var regex = new RegExp(regexStr, "i"), valid = !0;
        return regex.test(langTag) === !1 && (valid = !1), valid;
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_2 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Ensure that any change in language is marked using the lang and/or xml:lang attribute on an element, as appropriate.", "H58");
        for (var sc3_1_1 = HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_1, langEls = top.querySelectorAll("*[lang]"), i = 0; i <= langEls.length; i++) {
            if (i === langEls.length) var langEl = top; else var langEl = langEls[i];
            if (!langEl.documentElement && "html" !== langEl.nodeName.toLowerCase()) {
                if (langEl.hasAttribute("lang") === !0) {
                    var lang = langEl.getAttribute("lang");
                    sc3_1_1.isValidLanguageTag(lang) === !1 && HTMLCS.addMessage(HTMLCS.ERROR, langEl, "The language specified in the lang attribute of this element does not appear to be well-formed.", "H58.1.Lang");
                }
                if (langEl.hasAttribute("xml:lang") === !0) {
                    var lang = langEl.getAttribute("xml:lang");
                    sc3_1_1.isValidLanguageTag(lang) === !1 && HTMLCS.addMessage(HTMLCS.ERROR, langEl, "The language specified in the xml:lang attribute of this element does not appear to be well-formed.", "H58.1.XmlLang");
                }
            }
        }
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_3 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that there is a mechanism available for identifying specific definitions of words or phrases used in an unusual or restricted way, including idioms and jargon.", "H40,H54,H60,G62,G70");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_4 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that a mechanism for identifying the expanded form or meaning of abbreviations is available.", "G102,G55,G62,H28,G97");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_5 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Where the content requires reading ability more advanced than the lower secondary education level, supplemental content or an alternative version should be provided.", "G86,G103,G79,G153,G160");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_6 = {
    register: function() {
        return [ "ruby" ];
    },
    process: function(element) {
        var rb = element.querySelectorAll("rb"), rt = element.querySelectorAll("rt");
        0 === rt.length && (0 === rb.length ? HTMLCS.addMessage(HTMLCS.ERROR, element, "Ruby element does not contain an rt element containing pronunciation information for its body text.", "H62.1.HTML5") : HTMLCS.addMessage(HTMLCS.ERROR, element, "Ruby element does not contain an rt element containing pronunciation information for the text inside the rb element.", "H62.1.XHTML11"));
        var rp = element.querySelectorAll("rp");
        0 === rp.length && HTMLCS.addMessage(HTMLCS.ERROR, element, "Ruby element does not contain rp elements, which provide extra punctuation to browsers not supporting ruby text.", "H62.2");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_1 = {
    register: function() {
        return [ "input", "textarea", "button", "select" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that a change of context does not occur when this input field receives focus.", "G107");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_2 = {
    register: function() {
        return [ "form" ];
    },
    process: function(element) {
        var nodeName = element.nodeName.toLowerCase();
        "form" === nodeName && this.checkFormSubmitButton(element);
    },
    checkFormSubmitButton: function(form) {
        var submitButton = form.querySelector("input[type=submit], input[type=image], button[type=submit]");
        null === submitButton && HTMLCS.addMessage(HTMLCS.ERROR, form, 'Form does not contain a submit button (input type="submit", input type="image", or button type="submit").', "H32.2");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_3 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that navigational mechanisms that are repeated on multiple Web pages occur in the same relative order each time they are repeated, unless a change is initiated by the user.", "G61");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_4 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that components that have the same functionality within this Web page are identified consistently in the set of Web pages to which it belongs.", "G197");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_5 = {
    register: function() {
        return [ "a" ];
    },
    process: function(element) {
        var nodeName = element.nodeName.toLowerCase();
        "a" === nodeName && this.checkNewWindowTarget(element);
    },
    checkNewWindowTarget: function(link) {
        var hasTarget = link.hasAttribute("target");
        if (hasTarget === !0) {
            var target = link.getAttribute("target") || "";
            "_blank" === target && /new window/i.test(link.innerHTML) === !1 && HTMLCS.addMessage(HTMLCS.WARNING, link, "Check that this link's link text contains information indicating that the link will open in a new window.", "H83.3");
        }
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_1 = {
    register: function() {
        return [ "form" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If an input error is automatically detected in this form, check that the item(s) in error are identified and the error(s) are described to the user in text.", "G83,G84,G85");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_2 = {
    register: function() {
        return [ "form" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that descriptive labels or instructions (including for required fields) are provided for user input in this form.", "G131,G89,G184,H90");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_3 = {
    register: function() {
        return [ "form" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that this form provides suggested corrections to errors in user input, unless it would jeopardize the security or purpose of the content.", "G177");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_4 = {
    register: function() {
        return [ "form" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "If this form would bind a user to a financial or legal commitment, modify/delete user-controllable data, or submit test responses, ensure that submissions are either reversible, checked for input errors, and/or confirmed by the user.", "G98,G99,G155,G164,G168.LegalForms");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_5 = {
    register: function() {
        return [ "form" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that context-sensitive help is available for this form, at a Web-page and/or control level.", "G71,G184,G193");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_6 = {
    register: function() {
        return [ "form" ];
    },
    process: function(element) {
        HTMLCS.addMessage(HTMLCS.NOTICE, element, "Check that submissions to this form are either reversible, checked for input errors, and/or confirmed by the user.", "G98,G99,G155,G164,G168.AllForms");
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_1 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        if (element === top) for (var elsWithIds = top.querySelectorAll("*[id]"), usedIds = {}, i = 0; i < elsWithIds.length; i++) {
            var id = elsWithIds[i].getAttribute("id");
            void 0 !== usedIds[id] ? HTMLCS.addMessage(HTMLCS.ERROR, elsWithIds[i], 'Duplicate id attribute value "' + id + '" found on the web page.', "F77") : usedIds[id] = !0;
        }
    }
}, window.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = {
    register: function() {
        return [ "_top" ];
    },
    process: function(element, top) {
        if (element === top) {
            for (var messages = this.processFormControls(top), i = 0; i < messages.errors.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, messages.errors[i].element, messages.errors[i].msg, "H91." + messages.errors[i].subcode);
            for (var i = 0; i < messages.warnings.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, messages.warnings[i].element, messages.warnings[i].msg, "H91." + messages.warnings[i].subcode);
            this.addProcessLinksMessages(top);
        }
    },
    addProcessLinksMessages: function(top) {
        for (var errors = this.processLinks(top), i = 0; i < errors.empty.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, errors.empty[i], "Anchor element found with an ID but without a href or link text. Consider moving its ID to a parent or nearby element.", "H91.A.Empty");
        for (var i = 0; i < errors.emptyWithName.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, errors.emptyWithName[i], "Anchor element found with a name attribute but without a href or link text. Consider moving the name attribute to become an ID of a parent or nearby element.", "H91.A.EmptyWithName");
        for (var i = 0; i < errors.emptyNoId.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.emptyNoId[i], "Anchor element found with no link content and no name and/or ID attribute.", "H91.A.EmptyNoId");
        for (var i = 0; i < errors.noHref.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, errors.noHref[i], "Anchor elements should not be used for defining in-page link targets. If not using the ID for other purposes (such as CSS or scripting), consider moving it to a parent element.", "H91.A.NoHref");
        for (var i = 0; i < errors.placeholder.length; i++) HTMLCS.addMessage(HTMLCS.WARNING, errors.placeholder[i], "Anchor element found with link content, but no href, ID or name attribute has been supplied.", "H91.A.Placeholder");
        for (var i = 0; i < errors.noContent.length; i++) HTMLCS.addMessage(HTMLCS.ERROR, errors.noContent[i], "Anchor element found with a valid href attribute, but no link content has been supplied.", "H91.A.NoContent");
    },
    processLinks: function(top) {
        for (var errors = {
            empty: [],
            emptyWithName: [],
            emptyNoId: [],
            noHref: [],
            placeholder: [],
            noContent: []
        }, elements = top.querySelectorAll("a"), el = 0; el < elements.length; el++) {
            var element = elements[el], nameFound = !1, hrefFound = !1, content = HTMLCS.util.getElementTextContent(element);
            element.hasAttribute("title") === !0 && /^\s*$/.test(element.getAttribute("title")) === !1 ? nameFound = !0 : /^\s*$/.test(content) === !1 && (nameFound = !0), 
            element.hasAttribute("href") === !0 && /^\s*$/.test(element.getAttribute("href")) === !1 && (hrefFound = !0), 
            hrefFound === !1 ? /^\s*$/.test(content) === !0 ? element.hasAttribute("id") === !0 ? errors.empty.push(element) : element.hasAttribute("name") === !0 ? errors.emptyWithName.push(element) : errors.emptyNoId.push(element) : element.hasAttribute("id") === !0 || element.hasAttribute("name") === !0 ? errors.noHref.push(element) : errors.placeholder.push(element) : nameFound === !1 && 0 === element.querySelectorAll("img").length && errors.noContent.push(element);
        }
        return errors;
    },
    processFormControls: function(top) {
        for (var elements = top.querySelectorAll("button, fieldset, input, select, textarea"), errors = [], warnings = [], requiredNames = {
            button: [ "@title", "_content" ],
            fieldset: [ "legend" ],
            input_button: [ "@value" ],
            input_text: [ "label", "@title" ],
            input_file: [ "label", "@title" ],
            input_password: [ "label", "@title" ],
            input_checkbox: [ "label", "@title" ],
            input_radio: [ "label", "@title" ],
            input_image: [ "@alt", "@title" ],
            select: [ "label", "@title" ],
            textarea: [ "label", "@title" ]
        }, requiredValues = {
            select: "option_selected"
        }, el = 0; el < elements.length; el++) {
            var element = elements[el], nodeName = element.nodeName.toLowerCase(), msgSubCode = element.nodeName.substr(0, 1).toUpperCase() + element.nodeName.substr(1).toLowerCase();
            if ("input" === nodeName) {
                nodeName += element.hasAttribute("type") === !1 ? "_text" : "_" + element.getAttribute("type").toLowerCase(), 
                ("input_submit" === nodeName || "input_reset" === nodeName) && (nodeName = "input_button");
                var msgSubCode = "Input" + nodeName.substr(6, 1).toUpperCase() + nodeName.substr(7).toLowerCase();
            }
            var requiredName = requiredNames[nodeName], requiredValue = requiredValues[nodeName];
            if (requiredName) {
                for (var i = 0; i < requiredNames[nodeName].length; i++) {
                    var requiredName = requiredNames[nodeName][i];
                    if ("_content" === requiredName) {
                        var content = HTMLCS.util.getElementTextContent(element);
                        if (/^\s*$/.test(content) === !1) break;
                    } else if ("label" === requiredName) {
                        var hasLabel = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1.testLabelsOnInputs(element, top, !0);
                        if (hasLabel !== !1) {
                            found = !0;
                            break;
                        }
                    } else if ("@" === requiredName.charAt(0)) {
                        if (requiredName = requiredName.substr(1, requiredName.length), element.hasAttribute(requiredName) === !0 && /^\s*$/.test(element.getAttribute(requiredName)) === !1) break;
                    } else {
                        var subEl = element.querySelector(requiredName);
                        if (null !== subEl) {
                            var content = HTMLCS.util.getElementTextContent(subEl);
                            if (/^\s*$/.test(content) === !1) break;
                        }
                    }
                }
                if (i === requiredNames[nodeName].length) {
                    var msgNodeType = nodeName + " element";
                    "input_" === nodeName.substr(0, 6) && (msgNodeType = nodeName.substr(6) + " input element");
                    for (var builtAttrs = requiredNames[nodeName].slice(0, requiredNames[nodeName].length), a = 0; a < builtAttrs.length; a++) builtAttrs[a] = "_content" === builtAttrs[a] ? "element content" : "@" === builtAttrs[a].charAt(0) ? builtAttrs[a].substr(1) + " attribute" : builtAttrs[a] + " element";
                    var msg = "This " + msgNodeType + " does not have a name available to an accessibility API. Valid names are: " + builtAttrs.join(", ") + ".";
                    errors.push({
                        element: element,
                        msg: msg,
                        subcode: msgSubCode + ".Name"
                    });
                }
            }
            var requiredValue = requiredValues[nodeName], valueFound = !1;
            if (void 0 === requiredValue) valueFound = !0; else if ("_content" === requiredValue) {
                var content = HTMLCS.util.getElementTextContent(element);
                /^\s*$/.test(content) === !1 && (valueFound = !0);
            } else if ("option_selected" === requiredValue) if (element.hasAttribute("multiple") === !1) {
                var selected = element.querySelector("option[selected]");
                null !== selected && (valueFound = !0);
            } else valueFound = !0; else "@" === requiredValue.charAt(0) && (requiredValue = requiredValue.substr(1, requiredValue.length), 
            element.hasAttribute(requiredValue) === !0 && (valueFound = !0));
            if (valueFound === !1) {
                var msgNodeType = nodeName + " element";
                "input_" === nodeName.substr(0, 6) && (msgNodeType = nodeName.substr(6) + " input element");
                var msg = "This " + msgNodeType + " does not have a value available to an accessibility API.", builtAttr = "", warning = !1;
                "_content" === requiredValue ? builtAttr = " Add one by adding content to the element." : "option_selected" === requiredValue ? (warning = !0, 
                msg = "This " + msgNodeType + " does not have an initially selected option. Depending on your HTML version, the value exposed to an accessibility API may be undefined.") : builtAttr = "@" === requiredValue.charAt(0) ? ' A value is exposed using the "' + requiredValue + '" attribute.' : ' A value is exposed using the "' + requiredValue + '" element.', 
                msg += builtAttr, warning === !1 ? errors.push({
                    element: element,
                    msg: msg,
                    subcode: msgSubCode + ".Value"
                }) : warnings.push({
                    element: element,
                    msg: msg,
                    subcode: msgSubCode + ".Value"
                });
            }
        }
        return {
            errors: errors,
            warnings: warnings
        };
    }
};

window.HTMLCS_WCAG2AAA = {
    name: "WCAG2AAA",
    description: "Web Content Accessibility Guidelines (WCAG) 2.0 AAA",
    sniffs: [ "Principle1.Guideline1_1.1_1_1", "Principle1.Guideline1_2.1_2_1", "Principle1.Guideline1_2.1_2_2", "Principle1.Guideline1_2.1_2_4", "Principle1.Guideline1_2.1_2_5", "Principle1.Guideline1_2.1_2_6", "Principle1.Guideline1_2.1_2_7", "Principle1.Guideline1_2.1_2_8", "Principle1.Guideline1_2.1_2_9", "Principle1.Guideline1_3.1_3_1", "Principle1.Guideline1_3.1_3_1_AAA", "Principle1.Guideline1_3.1_3_2", "Principle1.Guideline1_3.1_3_3", "Principle1.Guideline1_4.1_4_1", "Principle1.Guideline1_4.1_4_2", "Principle1.Guideline1_4.1_4_3_F24", "Principle1.Guideline1_4.1_4_3_Contrast", "Principle1.Guideline1_4.1_4_6", "Principle1.Guideline1_4.1_4_7", "Principle1.Guideline1_4.1_4_8", "Principle1.Guideline1_4.1_4_9", "Principle2.Guideline2_1.2_1_1", "Principle2.Guideline2_1.2_1_2", "Principle2.Guideline2_2.2_2_2", "Principle2.Guideline2_2.2_2_3", "Principle2.Guideline2_2.2_2_4", "Principle2.Guideline2_2.2_2_5", "Principle2.Guideline2_3.2_3_2", "Principle2.Guideline2_4.2_4_1", "Principle2.Guideline2_4.2_4_2", "Principle2.Guideline2_4.2_4_3", "Principle2.Guideline2_4.2_4_5", "Principle2.Guideline2_4.2_4_6", "Principle2.Guideline2_4.2_4_7", "Principle2.Guideline2_4.2_4_8", "Principle2.Guideline2_4.2_4_9", "Principle3.Guideline3_1.3_1_1", "Principle3.Guideline3_1.3_1_2", "Principle3.Guideline3_1.3_1_3", "Principle3.Guideline3_1.3_1_4", "Principle3.Guideline3_1.3_1_5", "Principle3.Guideline3_1.3_1_6", "Principle3.Guideline3_2.3_2_1", "Principle3.Guideline3_2.3_2_2", "Principle3.Guideline3_2.3_2_3", "Principle3.Guideline3_2.3_2_4", "Principle3.Guideline3_2.3_2_5", "Principle3.Guideline3_3.3_3_1", "Principle3.Guideline3_3.3_3_2", "Principle3.Guideline3_3.3_3_3", "Principle3.Guideline3_3.3_3_5", "Principle3.Guideline3_3.3_3_6", "Principle4.Guideline4_1.4_1_1", "Principle4.Guideline4_1.4_1_2" ],
    getMsgInfo: function(code) {
        for (var principles = {
            Principle1: {
                name: "Perceivable",
                link: "http://www.w3.org/TR/WCAG20/#perceivable"
            },
            Principle2: {
                name: "Operable",
                link: "http://www.w3.org/TR/WCAG20/#operable"
            },
            Principle3: {
                name: "Understandable",
                link: "http://www.w3.org/TR/WCAG20/#understandable"
            },
            Principle4: {
                name: "Robust",
                link: "http://www.w3.org/TR/WCAG20/#robust"
            }
        }, msgCodeParts = code.split(".", 5), principle = msgCodeParts[1], techniques = msgCodeParts[4].split(","), techniquesStr = [], i = 0; i < techniques.length; i++) techniques[i] = techniques[i].split("."), 
        techniquesStr.push('<a href="http://www.w3.org/TR/WCAG20-TECHS/' + techniques[i][0] + '" target="_blank">' + techniques[i][0] + "</a>");
        var principleStr = [ '<a href="', principles[principle].link, '" target="_blank">', principles[principle].name, "</a>" ].join(""), retval = [ [ "Principle", principleStr ], [ "Techniques", techniquesStr.join(" ") ] ];
        return retval;
    }
};

window.HTMLCS = new function() {
    var _standards = {}, _sniffs = [], _tags = {}, _standard = null, _currentSniff = null, _messages = [], _msgOverrides = {};
    this.ERROR = 1, this.WARNING = 2, this.NOTICE = 3, this.process = function(standard, content, callback, failCallback) {
        return _standards = {}, _sniffs = [], _tags = {}, _standard = null, content ? void (_standards[_getStandardPath(standard)] ? HTMLCS.run(callback, content) : this.loadStandard(standard, function() {
            HTMLCS.run(callback, content);
        }, failCallback)) : !1;
    }, this.loadStandard = function(standard, callback, failCallback) {
        return standard ? void _includeStandard(standard, function() {
            _standard = standard, callback.call(this);
        }, failCallback) : !1;
    }, this.run = function(callback, content) {
        var element = null, loadingFrame = !1;
        if ("string" == typeof content) {
            loadingFrame = !0;
            var elementFrame = document.createElement("iframe");
            elementFrame.style.display = "none", elementFrame = document.body.insertBefore(elementFrame, null), 
            elementFrame.contentDocument ? element = elementFrame.contentDocument : element.contentWindow && (element = elementFrame.contentWindow.document), 
            elementFrame.load = function() {
                if (this.onreadystatechange = null, this.onload = null, HTMLCS.isFullDoc(content) === !1) {
                    element = element.getElementsByTagName("body")[0];
                    var div = element.getElementsByTagName("div")[0];
                    div && "__HTMLCS-source-wrap" === div.id && (div.id = "", element = div);
                }
                var elements = _getAllTags(element);
                elements.unshift(element), _run(elements, element, callback);
            }, elementFrame.onreadystatechange = function() {
                /^(complete|loaded)$/.test(this.readyState) === !0 && (this.onreadystatechange = null, 
                this.load());
            }, elementFrame.onload = elementFrame.load, element.write(HTMLCS.isFullDoc(content) === !1 && -1 === content.indexOf("<body") ? '<div id="__HTMLCS-source-wrap">' + content + "</div>" : content), 
            element.close();
        } else element = content;
        if (!element) return void callback.call(this);
        callback = callback || function() {}, _messages = [];
        var elements = _getAllTags(element);
        elements.unshift(element), loadingFrame === !1 && _run(elements, element, callback);
    }, this.isFullDoc = function(content) {
        var fullDoc = !1;
        return "string" == typeof content ? -1 !== content.toLowerCase().indexOf("<html") ? fullDoc = !0 : -1 !== content.toLowerCase().indexOf("<head") && -1 !== content.toLowerCase().indexOf("<body") && (fullDoc = !0) : ("html" === content.nodeName.toLowerCase() || content.documentElement) && (fullDoc = !0), 
        fullDoc;
    }, this.addMessage = function(type, element, msg, code, data) {
        code = _getMessageCode(code), _messages.push({
            type: type,
            element: element,
            msg: _msgOverrides[code] || msg,
            code: code,
            data: data
        });
    }, this.getMessages = function() {
        return _messages.concat([]);
    }, this.getMessagesJSON = function() {
        var messages = _messages.concat([]);
        var simplerMessages = [];
        messages.forEach(function(message, index, array) {
            simplerMessages.push({
                code: message.code,
                message: message.msg,
                type: message.type,
                elementString: message.element.outerHTML
            });
        });
        return JSON.stringify(simplerMessages);
    };
    var _run = function(elements, topElement, callback) {
        for (var topMsgs = []; elements.length > 0; ) {
            var element = elements.shift();
            if (element === topElement) var tagName = "_top"; else var tagName = element.tagName.toLowerCase();
            for (var i = 0; i < topMsgs.length; ) element === topMsgs[i].element ? (_messages.push(topMsgs[i]), 
            topMsgs.splice(i, 1)) : i++;
            _tags[tagName] && _tags[tagName].length > 0 && (_processSniffs(element, _tags[tagName].concat([]), topElement), 
            "_top" === tagName && (topMsgs = _messages, _messages = []));
        }
        callback instanceof Function == !0 && callback.call(this);
    }, _processSniffs = function(element, sniffs, topElement, callback) {
        for (;sniffs.length > 0; ) {
            var sniff = sniffs.shift();
            _currentSniff = sniff, sniff.useCallback === !0 ? sniff.process(element, topElement, function() {
                _processSniffs(element, sniffs, topElement), sniffs = [];
            }) : sniff.process(element, topElement);
        }
        callback instanceof Function == !0 && callback.call(this);
    }, _includeStandard = function(standard, callback, failCallback, options) {
        0 !== standard.indexOf("http") && (standard = _getStandardPath(standard));
        var parts = standard.split("/"), ruleSet = window["HTMLCS_" + parts[parts.length - 2]];
        ruleSet ? _registerStandard(standard, callback, failCallback, options) : _includeScript(standard, function() {
            _registerStandard(standard, callback, failCallback, options);
        }, failCallback);
    }, _registerStandard = function(standard, callback, failCallback, options) {
        var parts = standard.split("/"), oldRuleSet = window["HTMLCS_" + parts[parts.length - 2]], ruleSet = {};
        for (var x in oldRuleSet) oldRuleSet.hasOwnProperty(x) === !0 && (ruleSet[x] = oldRuleSet[x]);
        if (!ruleSet) return !1;
        if (_standards[standard] = ruleSet, options) if (options.include && options.include.length > 0) ruleSet.sniffs = options.include; else if (options.exclude) for (var i = 0; i < options.exclude.length; i++) {
            var index = ruleSet.sniffs.find(options.exclude[i]);
            index >= 0 && ruleSet.sniffs.splice(index, 1);
        }
        var sniffs = ruleSet.sniffs.slice(0, ruleSet.sniffs.length);
        _registerSniffs(standard, sniffs, callback, failCallback);
    }, _registerSniffs = function(standard, sniffs, callback, failCallback) {
        if (0 === sniffs.length) return void callback.call(this);
        var sniff = sniffs.shift();
        _loadSniffFile(standard, sniff, function() {
            _registerSniffs(standard, sniffs, callback, failCallback);
        }, failCallback);
    }, _loadSniffFile = function(standard, sniff, callback, failCallback) {
        if ("string" == typeof sniff) {
            var sniffObj = _getSniff(standard, sniff), cb = function() {
                _registerSniff(standard, sniff), callback.call(this);
            };
            sniffObj ? cb() : _includeScript(_getSniffPath(standard, sniff), cb, failCallback);
        } else _includeStandard(sniff.standard, function() {
            if (sniff.messages) for (var msg in sniff.messages) _msgOverrides[msg] = sniff.messages[msg];
            callback.call(this);
        }, failCallback, {
            exclude: sniff.exclude,
            include: sniff.include
        });
    }, _registerSniff = function(standard, sniff) {
        var sniffObj = _getSniff(standard, sniff);
        if (!sniffObj) return !1;
        if (sniffObj.register) var watchedTags = sniffObj.register();
        if (watchedTags && watchedTags.length > 0) for (var i = 0; i < watchedTags.length; i++) _tags[watchedTags[i]] || (_tags[watchedTags[i]] = []), 
        _tags[watchedTags[i]].push(sniffObj);
        _sniffs.push(sniffObj);
    }, _getSniffPath = function(standard, sniff) {
        var parts = standard.split("/");
        parts.pop();
        var path = parts.join("/") + "/Sniffs/" + sniff.replace(/\./g, "/") + ".js";
        return path;
    }, _getStandardPath = function(standard) {
        for (var scripts = document.getElementsByTagName("script"), path = null, i = 0; i < scripts.length; i++) if (scripts[i].src && scripts[i].src.match(/HTMLCS\.js/)) {
            path = scripts[i].src.replace(/HTMLCS\.js/, "");
            break;
        }
        return path + "Standards/" + standard + "/ruleset.js";
    }, _getSniff = function(standard, sniff) {
        var name = "HTMLCS_";
        return name += _standards[standard].name + "_Sniffs_", name += sniff.split(".").join("_"), 
        window[name] ? (window[name]._name = sniff, window[name]) : null;
    }, _getMessageCode = function(code) {
        return code = _standard + "." + _currentSniff._name + "." + code;
    }, _includeScript = function(src, callback, failCallback) {
        var script = document.createElement("script");
        script.onload = function() {
            script.onload = null, script.onreadystatechange = null, callback.call(this);
        }, script.onerror = function() {
            script.onload = null, script.onreadystatechange = null, failCallback && failCallback.call(this);
        }, script.onreadystatechange = function() {
            /^(complete|loaded)$/.test(this.readyState) === !0 && (script.onreadystatechange = null, 
            script.onload());
        }, script.src = src, document.head ? document.head.appendChild(script) : document.getElementsByTagName("head")[0].appendChild(script);
    }, _getAllTags = function(element) {
        element = element || document;
        for (var elements = element.getElementsByTagName("*"), elArray = [], i = 0; i < elements.length; i++) elArray.push(elements[i]);
        return elArray;
    };
    this.util = new function() {
        this.trim = function(string) {
            return string.replace(/^\s*(.*)\s*$/g, "$1");
        }, this.isStringEmpty = function(string) {
            if ("string" != typeof string) return !0;
            var empty = !0;
            return -1 !== string.indexOf(String.fromCharCode(160)) ? empty = !1 : /^\s*$/.test(string) === !1 && (empty = !1), 
            empty;
        }, this.getElementWindow = function(element) {
            if (element.ownerDocument) var doc = element.ownerDocument; else var doc = element;
            var window = null;
            return window = doc.defaultView ? doc.defaultView : doc.parentWindow;
        }, this.style = function(element) {
            var computedStyle = null, window = this.getElementWindow(element);
            return element.currentStyle ? computedStyle = element.currentStyle : window.getComputedStyle && (computedStyle = window.getComputedStyle(element, null)), 
            computedStyle;
        }, this.isHidden = function(element) {
            var hidden = !1, style = this.style(element);
            return null !== style && (("hidden" === style.visibility || "none" === style.display) && (hidden = !0), 
            parseInt(style.left, 10) + parseInt(style.width, 10) < 0 && (hidden = !0), parseInt(style.top, 10) + parseInt(style.height, 10) < 0 && (hidden = !0)), 
            hidden;
        }, this.isDisabled = function(element) {
            var disabled = !1;
            return (element.disabled === !0 || "true" === element.getAttribute("aria-disabled")) && (disabled = !0), 
            disabled;
        }, this.isInDocument = function(element) {
            for (var parent = element.parentNode; parent && parent.ownerDocument; ) parent = parent.parentNode;
            return null === parent ? !1 : !0;
        }, this.contains = function(parent, child) {
            var contained = !1;
            return parent !== child && (parent.ownerDocument ? parent.contains && parent.contains(child) === !0 ? contained = !0 : parent.compareDocumentPosition && (16 & parent.compareDocumentPosition(child)) > 0 && (contained = !0) : child.ownerDocument && child.ownerDocument === parent && (contained = !0)), 
            contained;
        }, this.isLayoutTable = function(table) {
            var th = table.querySelector("th");
            return null === th ? !0 : !1;
        }, this.contrastRatio = function(colour1, colour2) {
            var ratio = (.05 + this.relativeLum(colour1)) / (.05 + this.relativeLum(colour2));
            return 1 > ratio && (ratio = 1 / ratio), ratio;
        }, this.relativeLum = function(colour) {
            if (colour.charAt) var colour = this.colourStrToRGB(colour);
            var transformed = {};
            for (var x in colour) transformed[x] = colour[x] <= .03928 ? colour[x] / 12.92 : Math.pow((colour[x] + .055) / 1.055, 2.4);
            var lum = .2126 * transformed.red + .7152 * transformed.green + .0722 * transformed.blue;
            return lum;
        }, this.colourStrToRGB = function(colour) {
            if (colour = colour.toLowerCase(), "rgb" === colour.substring(0, 3)) {
                var matches = /^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)([^)]*)\)$/.exec(colour);
                colour = {
                    red: matches[1] / 255,
                    green: matches[2] / 255,
                    blue: matches[3] / 255
                };
            } else "#" === colour.charAt(0) && (colour = colour.substr(1)), 3 === colour.length && (colour = colour.replace(/^(.)(.)(.)$/, "$1$1$2$2$3$3")), 
            colour = {
                red: parseInt(colour.substr(0, 2), 16) / 255,
                green: parseInt(colour.substr(2, 2), 16) / 255,
                blue: parseInt(colour.substr(4, 2), 16) / 255
            };
            return colour;
        }, this.RGBtoColourStr = function(colour) {
            return colourStr = "#", colour.red = Math.round(255 * colour.red), colour.green = Math.round(255 * colour.green), 
            colour.blue = Math.round(255 * colour.blue), colour.red % 17 === 0 && colour.green % 17 === 0 && colour.blue % 17 === 0 ? (colourStr += (colour.red / 17).toString(16), 
            colourStr += (colour.green / 17).toString(16), colourStr += (colour.blue / 17).toString(16)) : (colour.red < 16 && (colourStr += "0"), 
            colourStr += colour.red.toString(16), colour.green < 16 && (colourStr += "0"), colourStr += colour.green.toString(16), 
            colour.blue < 16 && (colourStr += "0"), colourStr += colour.blue.toString(16)), 
            colourStr;
        }, this.sRGBtoHSV = function(colour) {
            colour.charAt && (colour = this.colourStrToRGB(colour));
            var hsvColour = {
                hue: 0,
                saturation: 0,
                value: 0
            }, maxColour = Math.max(colour.red, colour.green, colour.blue), minColour = Math.min(colour.red, colour.green, colour.blue), chroma = maxColour - minColour;
            return 0 === chroma ? hsvColour.value = colour.red : (hsvColour.value = maxColour, 
            hsvColour.hue = maxColour === colour.red ? (colour.green - colour.blue) / chroma : maxColour === colour.green ? 2 + (colour.blue - colour.red) / chroma : 4 + (colour.red - colour.green) / chroma, 
            hsvColour.hue = 60 * hsvColour.hue, hsvColour.hue >= 360 && (hsvColour.hue -= 360), 
            hsvColour.saturation = chroma / hsvColour.value), hsvColour;
        }, this.HSVtosRGB = function(hsvColour) {
            var colour = {
                red: 0,
                green: 0,
                blue: 0
            };
            if (0 === hsvColour.saturation) colour.red = hsvColour.value, colour.green = hsvColour.value, 
            colour.blue = hsvColour.value; else {
                var chroma = hsvColour.value * hsvColour.saturation, minColour = hsvColour.value - chroma, interHue = hsvColour.hue / 60, interHueMod = interHue - 2 * Math.floor(interHue / 2), interCol = chroma * (1 - Math.abs(interHueMod - 1));
                switch (Math.floor(interHue)) {
                  case 0:
                    colour.red = chroma, colour.green = interCol;
                    break;

                  case 1:
                    colour.green = chroma, colour.red = interCol;
                    break;

                  case 2:
                    colour.green = chroma, colour.blue = interCol;
                    break;

                  case 3:
                    colour.blue = chroma, colour.green = interCol;
                    break;

                  case 4:
                    colour.blue = chroma, colour.red = interCol;
                    break;

                  case 5:
                    colour.red = chroma, colour.blue = interCol;
                }
                colour.red = colour.red + minColour, colour.green = colour.green + minColour, colour.blue = colour.blue + minColour;
            }
            return colour;
        }, this.getElementTextContent = function(element, includeAlt) {
            void 0 === includeAlt && (includeAlt = !0);
            for (var element = element.cloneNode(!0), nodes = [], i = 0; i < element.childNodes.length; i++) nodes.push(element.childNodes[i]);
            for (var text = []; nodes.length > 0; ) {
                var node = nodes.shift();
                if (1 === node.nodeType) if ("img" === node.nodeName.toLowerCase()) includeAlt === !0 && node.hasAttribute("alt") === !0 && text.push(node.getAttribute("alt")); else for (var i = 0; i < node.childNodes.length; i++) nodes.push(node.childNodes[i]); else 3 === node.nodeType && text.push(node.nodeValue);
            }
            return text = text.join("").replace(/^\s+|\s+$/g, "");
        }, this.testTableHeaders = function(element) {
            for (var retval = {
                required: !0,
                used: !1,
                correct: !0,
                allowScope: !0,
                missingThId: [],
                missingTd: [],
                wrongHeaders: []
            }, rows = element.getElementsByTagName("tr"), skipCells = [], headerIds = {
                rows: [],
                cols: []
            }, multiHeaders = {
                rows: 0,
                cols: 0
            }, rownum = 0; rownum < rows.length; rownum++) for (var row = rows[rownum], colnum = 0, item = 0; item < row.childNodes.length; item++) {
                var cell = row.childNodes[item];
                if (1 === cell.nodeType) {
                    if (skipCells[rownum]) for (;skipCells[rownum][0] === colnum; ) skipCells[rownum].shift(), 
                    colnum++;
                    var nodeName = cell.nodeName.toLowerCase(), rowspan = Number(cell.getAttribute("rowspan")) || 1, colspan = Number(cell.getAttribute("colspan")) || 1;
                    if (rowspan > 1) for (var i = rownum + 1; rownum + rowspan > i; i++) {
                        skipCells[i] || (skipCells[i] = []);
                        for (var j = colnum; colnum + colspan > j; j++) skipCells[i].push(j);
                    }
                    if ("th" === nodeName) {
                        var id = cell.getAttribute("id") || "";
                        "" === id && (retval.correct = !1, retval.missingThId.push(cell)), rowspan > 1 && colspan > 1 ? retval.allowScope = !1 : retval.allowScope === !0 && (void 0 === headerIds.cols[colnum] && (headerIds.cols[colnum] = 0), 
                        void 0 === headerIds.rows[rownum] && (headerIds.rows[rownum] = 0), headerIds.rows[rownum] += colspan, 
                        headerIds.cols[colnum] += rowspan);
                    } else "td" === nodeName && cell.hasAttribute("headers") === !0 && /^\s*$/.test(cell.getAttribute("headers")) === !1 && (retval.used = !0);
                    colnum += colspan;
                }
            }
            for (var i = 0; i < headerIds.rows.length; i++) headerIds.rows[i] > 1 && multiHeaders.rows++;
            for (var i = 0; i < headerIds.cols.length; i++) headerIds.cols[i] > 1 && multiHeaders.cols++;
            multiHeaders.rows > 1 || multiHeaders.cols > 1 ? retval.allowScope = !1 : retval.allowScope !== !0 || 0 !== multiHeaders.rows && 0 !== multiHeaders.cols || (retval.required = !1);
            for (var cells = HTMLCS.util.getCellHeaders(element), i = 0; i < cells.length; i++) {
                var cell = cells[i].cell, expected = cells[i].headers;
                if (cell.hasAttribute("headers") === !1) retval.correct = !1, retval.missingTd.push(cell); else {
                    var actual = (cell.getAttribute("headers") || "").split(/\s+/);
                    if (0 === actual.length) retval.correct = !1, retval.missingTd.push(cell); else if (actual = " " + actual.sort().join(" ") + " ", 
                    actual = actual.replace(/\s+/g, " ").replace(/(\w+\s)\1+/g, "$1").replace(/^\s*(.*?)\s*$/g, "$1"), 
                    expected !== actual) {
                        retval.correct = !1;
                        var val = {
                            element: cell,
                            expected: expected,
                            actual: cell.getAttribute("headers") || ""
                        };
                        retval.wrongHeaders.push(val);
                    }
                }
            }
            return retval;
        }, this.getCellHeaders = function(table) {
            if ("object" != typeof table) return null;
            if ("table" !== table.nodeName.toLowerCase()) return null;
            for (var rows = table.getElementsByTagName("tr"), skipCells = [], headingIds = {
                rows: {},
                cols: {}
            }, cells = [], targetNodeNames = [ "th", "td" ], k = 0; k < targetNodeNames.length; k++) for (var targetNode = targetNodeNames[k], rownum = 0; rownum < rows.length; rownum++) for (var row = rows[rownum], colnum = 0, item = 0; item < row.childNodes.length; item++) {
                var thisCell = row.childNodes[item];
                if (1 === thisCell.nodeType) {
                    if (skipCells[rownum]) for (;skipCells[rownum][0] === colnum; ) skipCells[rownum].shift(), 
                    colnum++;
                    var nodeName = thisCell.nodeName.toLowerCase(), rowspan = Number(thisCell.getAttribute("rowspan")) || 1, colspan = Number(thisCell.getAttribute("colspan")) || 1;
                    if (rowspan > 1) for (var i = rownum + 1; rownum + rowspan > i; i++) {
                        skipCells[i] || (skipCells[i] = []);
                        for (var j = colnum; colnum + colspan > j; j++) skipCells[i].push(j);
                    }
                    if (nodeName === targetNode) if ("th" === nodeName) {
                        for (var id = thisCell.getAttribute("id") || "", i = rownum; rownum + rowspan > i; i++) headingIds.rows[i] = headingIds.rows[i] || {
                            first: colnum,
                            ids: []
                        }, headingIds.rows[i].ids.push(id);
                        for (var i = colnum; colnum + colspan > i; i++) headingIds.cols[i] = headingIds.cols[i] || {
                            first: rownum,
                            ids: []
                        }, headingIds.cols[i].ids.push(id);
                    } else if ("td" === nodeName) {
                        for (var exp = [], i = rownum; rownum + rowspan > i; i++) for (var j = colnum; colnum + colspan > j; j++) headingIds.rows[i] && j >= headingIds.rows[i].first && (exp = exp.concat(headingIds.rows[i].ids)), 
                        headingIds.cols[j] && i >= headingIds.cols[j].first && (exp = exp.concat(headingIds.cols[j].ids));
                        exp.length > 0 && (exp = " " + exp.sort().join(" ") + " ", exp = exp.replace(/\s+/g, " ").replace(/(\w+\s)\1+/g, "$1").replace(/^\s*(.*?)\s*$/g, "$1"), 
                        cells.push({
                            cell: thisCell,
                            headers: exp
                        }));
                    }
                    colnum += colspan;
                }
            }
            return cells;
        };
    }();
}();
HTMLCS.process(arguments[0], window.document);
return HTMLCS.getMessagesJSON();