Cramer = {}
Cramer.Behavior = (function () {
    function init() {

        if (arguments.callee.done) return;
        arguments.callee.done = true;
        if (_timer) clearInterval(_timer);

        //YOUR INIT CODE GOES HERE

        Cufon.replace(getElementsByClass('sifr-orange'))(getElementsByClass('sifr-black'));

        if ($("homepage-flash")) {
            addClass($("container"), "home");
        };
        var expandos = getElementsByClass("expandable");
        for (var i = 0; i < expandos.length; i++) {
            expandos[i].onclick = windowShade;
        };
        if ($("search")) {
            $("search-box").onfocus = $("search-box").onclick = function () {
                addClass($("search"), "focused")
                if ($("search-box").value == "Site Search") {
                    $("search-box").value = "";
                }
            };
            $("search-box").onblur = function () {
                removeClass($("search"), "focused")
                if ($("search-box").value == "") {
                    $("search-box").value = "Site Search";
                }
            };
        };
        if ($("language-selector")) {
            $("language-selector").onclick = language.down;
        };
        if ($("main-content") && $("secondary-content")) {
            adjustColumns();
        };
        if ($("case-study-detail-top") || $("knowledge-center-top")) {
            var morelinks = getElementsByClass("more")
            for (var i = 0; i < morelinks.length; i++) {
                morelinks[i].onclick = handleMoreLinks;
            };
        };
        if ($("bio-top")) {
            var morelinks = getElementsByClass("more")
            for (var i = 0; i < morelinks.length; i++) {
                morelinks[i].onclick = handleMoreLinks;
            };
        };

        if ($("advance-search-tabs")) {
            var tabs = $("advance-search-tabs").getElementsByTagName("li");
            for (var i = 0; i < tabs.length; i++) {
                if (hasClass(tabs[i], "on") && i > 0) {
                    addClass(tabs[i - 1], "sibling");
                };
                // i hate you ie6.
                if (hasClass(tabs[i], "on") && hasClass(tabs[i], "last")) {
                    addClass(tabs[i], "on-last");
                };
            };
        };
        if ($("redirect")) {
            setTimeout("window.location = '/'", 120000);
        }
        // keep secondary nav expanded
        if ($("secondary-navigation")) {
            var secondaryNavItems = $("secondary-navigation").getElementsByTagName("li");
            for (var i = 0; i < secondaryNavItems.length; i++) {
                if (hasClass(secondaryNavItems[i], "on") && hasClass(secondaryNavItems[i], "expandable")) {
                    addClass(secondaryNavItems[i], "open");
                };
            };
        };
        var links = document.getElementsByTagName("a");
        for (var i = 0; i < links.length; i++) {
            if (links[i].getAttribute("href") && links[i].getAttribute("rel") == "external") {
                links[i].target = "_blank";
            };
        };
        var popups = getElementsByClass('popup');
        for (var i = 0; i < popups.length; i++) {
            if (popups[i].href) {
                addEvent(popups[i], 'click', attorneyEmail);
                addEvent(popups[i], 'click', function () {
                    var mailto = this.href;
                    var email = mailto.split(':');
                    var emailAddress = email[1];
                    showEmailAgreement(emailAddress);
                    return false;
                }
	    );
            };
        };

        var textInputs = getElementsByClass("text");
        for (var i = 0; i < textInputs.length; i++) {
            var theInput = textInputs[i];
            /* Add event handlers */
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            /* Save the current value */
            if (theInput.value != '') {
                var theParentId = theInput.parentNode.id;

                if (typeof (initialKnowledgeValues) !== 'undefined') {
                    if (typeof (initialKnowledgeValues[theParentId]) !== 'undefined') {
                        theInput.defaultText = initialKnowledgeValues[theParentId];
                    }
                    else {
                        theInput.defaultText = theInput.value;
                    }
                }

                if (typeof (initialExperienceValues) !== 'undefined') {
                    if (typeof (initialExperienceValues[theParentId]) !== 'undefined') {
                        theInput.defaultText = initialExperienceValues[theParentId];
                    }
                    else {
                        theInput.defaultText = theInput.value;
                    }
                }

                if (typeof (initialValues) !== 'undefined') {
                    if (typeof (initialValues[theParentId]) !== 'undefined') {
                        theInput.defaultText = initialValues[theParentId];
                    }
                    else {
                        theInput.defaultText = theInput.value;
                    }
                }



            }
        };

        var dls = document.getElementsByTagName("dl");
        for (var i = 0; i < dls.length; i++) {
            if (hasClass(dls[i], "texture")) {
                var dtHeight = dls[i].getElementsByTagName("dt")[0].offsetHeight;
                var ddHeight = dls[i].getElementsByTagName("dd")[0].offsetHeight;
                if (dtHeight > ddHeight) {
                    dls[i].getElementsByTagName("dd")[0].style.height = dtHeight + "px";
                };
            };
        };
        var ths = document.getElementsByTagName("th");
        for (var i = 0; i < ths.length; i++) {
            textNode = ths[i].childNodes[0];
            if (typeof textNode != 'undefined') {
                theClassName = textNode.nodeValue;
                addClass(ths[i], theClassName.toLowerCase());
            };
        };

        var querystring = window.location.search.substring(1);
        if (querystring != "") {
            var printPair = querystring.split('=');
            if ((printPair[0] == "print") && (printPair[1] == "true")) {
                window.print();
            }
        }

        if ($("resume")) {
            var errorState = getElementsByClass("error", $("resume"));
            if (errorState.length > 0) {
                var formItemDiv = errorState[0].parentNode;
                addClass(formItemDiv, "error")
            }
        };

        addEvent(window, "resize", function () { adjustColumns(); });

        // Omniture Tracking Events
        // Site Search
        if ($("site-search-results")) {
            setTimeout('siteSearch()', 500);
        };
        // Experience Search
        if ($("experience-center-search-results")) {
            setTimeout('experienceCenterSearch()', 500);
        };
        // Knowledge Center Search
        if ($("knowledge-center-search-results")) {
            setTimeout('knowledgeCenterSearch()', 500);
        };
        // Career Search
        if ($("career-search-results")) {
            setTimeout('careerSearch()', 500);
        };
        // Professional Search
        if ($("professional-search-results")) {
            setTimeout('professionalSearch()', 500);
        };
        // Contact Us Registration
        if ($("contact-us-confirmation")) {
            setTimeout('contactUsRegistration()', 500);
        };
        // Mail Order Registration
        if ($("mail-order-confirmation")) {
            setTimeout('mailOrderRegistration()', 500);
        };
        // Event Registration
        if ($("btn-register")) {
            var registerButton = $("btn-register").getElementsByTagName("a");
            if (registerButton.length > 0) {
                addEvent(registerButton[0], 'click', EventRegistration);
            }
        };
        // Event Registration
        if ($("downloads")) {
            var downloadLinks = $("downloads").getElementsByTagName("a");
            if (downloadLinks.length > 0) {
                for (var i = 0; i < downloadLinks.length; i++) {
                    addEvent(downloadLinks[i], 'click', fileDownloaded);
                };
            };
        };
        // Job Application Registration
        if ($("job-application-confirmation")) {
            setTimeout('jobApplicationSubmission()', 500);
        };
        //outgoing links

        // Page Emailed
        if ($("utility").getElementsByTagName("a").length > 0) {
            var emailPageIcons = getElementsByClass('email', $("utility"));
            if (emailPageIcons.length > 0) {
                for (var i = 0; i < emailPageIcons.length; i++) {
                    var emailPageIcon = emailPageIcons[i].getElementsByTagName("a")[0];
                    addEvent(emailPageIcon, 'click', pageEmailed);
                };
            };
        };
        // Page Printed
        var printIcons = getElementsByClass('icon-print');
        if (printIcons.length > 0) {

            for (var i = 0; i < printIcons.length; i++) {
                var printIcon = printIcons[i].getElementsByTagName("a")[0];
                addEvent(printIcon, 'click', pagePrinted);
            };
        };
        var pdfIcons = getElementsByClass('icon-pdf');
        if (pdfIcons.length > 0) {
            for (var i = 0; i < pdfIcons.length; i++) {
                var pdfIcon = pdfIcons[i].getElementsByTagName("a")[0];
                if (pdfIcon != null) {
                    addEvent(pdfIcon, 'click', pdfDownloaded);
                }
            };
        };
        var pdfPrintIcons = getElementsByClass('pdf', $("utility"));
        if (pdfPrintIcons.length > 0) {
            for (var i = 0; i < pdfPrintIcons.length; i++) {

                var pdfPrintIcon = pdfPrintIcons[i].getElementsByTagName("a")[0];
                if (pdfPrintIcon != null) {
                    addEvent(pdfPrintIcon, 'click', pdfDownloaded);
                }
            };
        };
        if ($("offices-landing")) {
            var printIcons = getElementsByClass('icon-print');
            if (printIcons.length > 0) {
                for (var i = 0; i < printIcons.length; i++) {
                    var printIcon = printIcons[i].getElementsByTagName("a")[0];
                    if (printIcon.length > 0) {
                        addEvent(printIcon, 'click', pagePrinted);
                    }
                };
            };
        }
        // vCard Download
        if ($("pro-bono") || $("professional-search-results") || $("professionals-panel") || $("management-landing")) {
            var vcardIcons = getElementsByClass('icon-vcard');
            if (vcardIcons.length > 0) {
                for (var i = 0; i < vcardIcons.length; i++) {
                    addEvent(vcardIcons[i], 'click', vCardDownloaded);
                };
            }
        }
        else {
            var vcardIcons = getElementsByClass('icon-vcard');
            if (vcardIcons.length > 0) {
                for (var i = 0; i < vcardIcons.length; i++) {
                    var vcardIcon = vcardIcons[i].getElementsByTagName("a")[0];
                    addEvent(vcardIcon, 'click', vCardDownloaded);
                };
            };
        };

        // RSS Subscription
        if ($("rss-nav")) {
            rssNavItems = $("rss-nav").getElementsByTagName("a");
            for (var i = 0; i < rssNavItems.length; i++) {
                addEvent(rssNavItems[i], 'click', rssSubscription);
            }
        };
        if ($("industries-and-services-nav")) {
            industriesAndServicesNavItems = $("industries-and-services-nav").getElementsByTagName("a");
            for (var i = 0; i < industriesAndServicesNavItems.length; i++) {
                addEvent(industriesAndServicesNavItems[i], 'click', rssSubscription);
            }
        };
        //bug fix for background image flickers in Internet Explorer 
        //IE6 submit button hovers
        /*@cc_on@*/
        /*@if (@_win32)
        document.execCommand("BackgroundImageCache", false, true);

        // hovers for IE6
        var inputElements = document.getElementsByTagName("input")
        for (var i = 0; i < inputElements.length; i++) {
            if (inputElements[i].getAttribute("type") == "submit") {
                inputElements[i].onmouseover = inputElements[i].onfocus = function () {
                    addClass(this, "hover");
                }
                inputElements[i].onmouseout = inputElements[i].onblur = function () {
                    removeClass(this, "hover");
                }
            }
        };

        // more hovers for IE6
        if ($("main-navigation")) {
            var menus = ($("main-navigation")).getElementsByTagName("li")
            for (var i = 0; i < menus.length; i++) {
                menus[i].onmouseover = function () {
                    addClass(this, "hover");
                };
                menus[i].onmouseout = function () {
                    removeClass(this, "hover");
                };
            };

            // add an iframe behind the dropdown menus in IE6
            var dropdowns = getElementsByClass('dropdown');
            for (var i = 0; i < dropdowns.length; i++) {
                theiFrame = document.createElement('iframe');
                theiFrame.style.filter = 'alpha(opacity=0)';
                dropdowns[i].appendChild(theiFrame);
            };
        };

        // alpha image loader for bio images
        if ($("bio-image")) {
            var bioImageContainer = $("bio-image");
            var bioImage = $("bio-image").getElementsByTagName("img")[0];
            var bioImageSrc = bioImage.src;
            bioImageContainer.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + bioImageSrc + "', sizingMethod='crop')";
            bioImageContainer.style.background = "#fff"
            bioImage.style.visibility = "hidden";
        }

        /*@end@*/

    };

    if (document.addEventListener) {
        document.addEventListener("DOMContentLoaded", init, false);
    };
    /*@cc_on@*/
    /*@if (@_win32)
    (function () {
        try {
            document.documentElement.doScroll('left');
        } catch (e) {
            setTimeout(arguments.callee, 50);
            return;
        }
        // no errors, fire
        init();
    })();
    /*@end@*/
    if (/WebKit/i.test(navigator.userAgent)) { // sniff
        var _timer = setInterval(function () {
            if (/loaded|complete/.test(document.readyState)) {
                init(); // call the onload handler
            }
        }, 10);
    };

    window.onload = init;

    function $() {
        var elements = [];
        for (var i = 0; i < arguments.length; i++) {
            var element = arguments[i];
            if (typeof element == 'string')
                element = document.getElementById(element);
            if (arguments.length == 1)
                return element;
            elements.push(element);
        };
        return elements;
    };
    function insertAfter(parent, node, referenceNode) {
        parent.insertBefore(node, referenceNode.nextSibling);
    };
    function preloadImages() {
        var pics = [];
        for (var i = 0; i < arguments.length; i++) {
            pics[i] = new Image();
            pics[i].src = arguments[i];
        };
    };
    function findPos(obj) {
        var curleft = curtop = 0;
        if (obj.offsetParent) {
            curleft = obj.offsetLeft;
            curtop = obj.offsetTop;
            while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft;
                curtop += obj.offsetTop;
            };
        };
        return [curleft, curtop];
    };
    function getElementsByClass(theclass, node) {
        var classElements = [];
        var i;
        if (node == null) {
            node = document
        };
        if (node.getElementsByClassName) {
            var tempCollection = node.getElementsByClassName(theclass);
            for (i = 0; i < tempCollection.length; i++) {
                classElements.push(tempCollection[i])
            };
        }
        else {
            var els = node.getElementsByTagName("*");
            var elsLen = els.length;
            var pattern = new RegExp("(^|\\s)" + theclass + "(\\s|$)");
            for (i = 0; i < elsLen; i++) {
                if (pattern.test(els[i].className)) {
                    classElements.push(els[i]);
                };
            };
        };
        return classElements;
    };
    function ajax(options) {
        options = {
            type: options.type || "POST",
            url: options.url || "",
            timeout: options.timeout || 5000,
            onComplete: options.onComplete || function () { },
            onError: options.onError || function () { },
            onSuccess: options.onSuccess || function () { },
            data: options.data || ""
        };
        if (typeof XMLHttpRequest == "undefined")
            XMLHttpRequest = function () {
                return new ActiveXObject(
            	navigator.userAgent.indexOf("MSIE 5") >= 0 ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP"
        );
            };
        var xml = new XMLHttpRequest();
        xml.open(options.type, options.url, true);
        var requestDone = false;
        setTimeout(function () {
            requestDone = true;
        }, options.timeout);
        xml.onreadystatechange = function () {
            if (xml.readyState == 4 && !requestDone) {
                if (httpSuccess(xml)) {
                    options.onSuccess(httpData(xml, options.data));
                } else {
                    options.onError();
                };
                options.onComplete();
                xml = null;
            };
        };
        xml.send(null);
        function httpSuccess(r) {
            try {
                return !r.status && location.protocol == "file:" ||
                (r.status >= 200 && r.status < 300) ||
                r.status == 304 ||
                navigator.userAgent.indexOf("Safari") >= 0 && typeof r.status == "undefined";
            } catch (e) { }
            return false;
        };
        function httpData(r, type) {
            switch (type) {
                case "xml":
                    data = r.responseXML;
                    break;
                case "script":
                    data = eval(r.responseText);
                    break;
                case "text":
                    data = r.responseText;
                    break;
                default:
                    data = r.responseText;
                    break;
            };
            return data;
        };
    };
    function getFirstChild(element) {
        element = element.firstChild;
        return element && element.nodeType != 1 ? nextSibling(element) : element;
    };
    function getPreviousSibling(element) {
        do {
            element = element.previousSibling;
        } while (element && element.nodeType != 1);
        return element;
    };
    function getNextSibling(element) {
        do {
            element = element.nextSibling;
        } while (element && element.nodeType != 1);
        return element;
    };
    function getLastChild(element) {
        element = elem.lastChild;
        return element && element.nodeType != 1 ? prevSibling(element) : element;
    };

    function addEvent(element, type, handler) {
        if (!handler.$$guid) handler.$$guid = addEvent.guid++;
        if (!element.events) element.events = {};
        var handlers = element.events[type];
        if (!handlers) {
            handlers = element.events[type] = {};
            if (element["on" + type]) {
                handlers[0] = element["on" + type];
            }
        }
        handlers[handler.$$guid] = handler;
        element["on" + type] = handleEvent;
    };
    addEvent.guid = 1;
    function removeEvent(element, type, handler) {
        if (element.events && element.events[type]) {
            delete element.events[type][handler.$$guid];
        };
    };
    function handleEvent(event) {
        var returnValue = true;
        event = event || fixEvent(window.event);
        var handlers = this.events[event.type];
        for (var i in handlers) {
            this.$$handleEvent = handlers[i];
            if (this.$$handleEvent(event) === false) {
                returnValue = false;
            };
        };
        return returnValue;
    };
    function fixEvent(event) {
        event.preventDefault = fixEvent.preventDefault;
        event.stopPropagation = fixEvent.stopPropagation;
        return event;
    };
    fixEvent.preventDefault = function () {
        this.returnValue = false;
    };
    fixEvent.stopPropagation = function () {
        this.cancelBubble = true;
    };
    function addClass(element, className) {
        if (!hasClass(element, className)) {
            element.className += (element.className ? " " : "") + className;
        };
    };
    function hasClass(element, className) {
        var regexp = new RegExp("(^|\\s)" + className + "(\\s|$)");
        return regexp.test(element.className);
    };
    function removeClass(element, className) {
        var regexp = new RegExp("(^|\\s)" + className + "(\\s|$)", "g");
        element.className = element.className.replace(regexp, "$2").trim();
    };
    function toggleClass(element, className) {
        if (hasClass(element, className)) {
            removeClass(element, className);
        } else {
            addClass(element, className);
        };
    };
    function getText(e) {
        var t = "";
        e = e.childNodes || e;
        for (var j = 0; j < e.length; j++) {
            t += e[j].nodeType != 1 ?
            e[j].nodeValue : text(e[j].childNodes);
        }
        return t;
    };
    if (!Array.prototype.push) {
        function array_push() {
            for (var i = 0; i < arguments.length; i++) {
                this[this.length] = arguments[i]
            };
            return this.length;
        }
        Array.prototype.push = array_push;
    };
    if (!Array.prototype.inArray) {
        Array.prototype.inArray = function (value) {
            var i;
            for (i = 0; i < this.length; i++) {
                if (this[i] === value) {
                    return true;
                }
            }
            return false;
        }
    };
    String.prototype.trim = function () {
        return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
    };

    var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]+\]|[^[\]]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g;

    var cache = null;
    var done = 0;

    if (document.addEventListener && !document.querySelectorAll) {
        cache = {};
        function invalidate() { cache = {}; }
        document.addEventListener("DOMAttrModified", invalidate, false);
        document.addEventListener("DOMNodeInserted", invalidate, false);
        document.addEventListener("DOMNodeRemoved", invalidate, false);
    }

    var Sizzle = function (selector, context, results, seed) {
        var doCache = !results;
        results = results || [];
        context = context || document;

        if (context.nodeType !== 1 && context.nodeType !== 9)
            return [];

        if (!selector || typeof selector !== "string") {
            return results;
        }

        if (cache && context === document && cache[selector]) {
            results.push.apply(results, cache[selector]);
            return results;
        }

        var parts = [], m, set, checkSet, check, mode, extra;

        // Reset the position of the chunker regexp (start from head)
        chunker.lastIndex = 0;

        while ((m = chunker.exec(selector)) !== null) {
            parts.push(m[1]);

            if (m[2]) {
                extra = RegExp.rightContext;
                break;
            }
        }

        var ret = seed ?
		{ expr: parts.pop(), set: makeArray(seed)} :
		Sizzle.find(parts.pop(), context);
        set = Sizzle.filter(ret.expr, ret.set);

        if (parts.length > 0) {
            checkSet = makeArray(set);
        }

        while (parts.length) {
            var cur = parts.pop(), pop = cur;

            if (!Expr.relative[cur]) {
                cur = "";
            } else {
                pop = parts.pop();
            }

            if (pop == null) {
                pop = context;
            }

            var later = "", match;

            // Position selectors must be done after the filter
            if (typeof pop === "string") {
                while ((match = Expr.match.POS.exec(pop))) {
                    later += match[0];
                    pop = pop.replace(Expr.match.POS, "");
                }
            }

            Expr.relative[cur](checkSet, pop);

            if (later) {
                Sizzle.filter(later, checkSet, true);
            }
        }

        if (!checkSet) {
            checkSet = set;
        }

        if (!checkSet) {
            throw "Syntax error, unrecognized expression: " + (cur || selector);
        }
        if (checkSet instanceof Array) {
            if (context.nodeType === 1) {
                for (var i = 0; checkSet[i] != null; i++) {
                    if (checkSet[i] && checkSet[i].nodeType === 1 && contains(context, checkSet[i])) {
                        results.push(set[i]);
                    }
                }
            } else {
                for (var i = 0; checkSet[i] != null; i++) {
                    if (checkSet[i] && checkSet[i].nodeType === 1) {
                        results.push(set[i]);
                    }
                }
            }
        } else {
            makeArray(checkSet, results);
        }

        if (extra) {
            arguments.callee(extra, context, results);
        }

        if (cache && doCache) {
            cache[selector] = results.slice(0);
        }

        return results;
    };

    Sizzle.matches = function (expr, set) {
        return Sizzle(expr, null, null, set);
    };

    Sizzle.find = function (expr, context) {
        var set, match;

        if (!expr) {
            return [];
        }

        var later = "", match;

        // Pseudo-selectors could contain other selectors (like :not)
        while ((match = Expr.match.PSEUDO.exec(expr))) {
            var left = RegExp.leftContext;

            if (left.substr(left.length - 1) !== "\\") {
                later += match[0];
                expr = expr.replace(Expr.match.PSEUDO, "");
            } else {
                // TODO: Need a better solution, fails: .class\:foo:realfoo(#id)
                break;
            }
        }

        for (var i = 0, l = Expr.order.length; i < l; i++) {
            var type = Expr.order[i];

            if ((match = Expr.match[type].exec(expr))) {
                var left = RegExp.leftContext;

                if (left.substr(left.length - 1) !== "\\") {
                    match[1] = (match[1] || "").replace(/\\/g, "");
                    set = Expr.find[type](match, context);

                    if (set != null) {
                        expr = expr.replace(Expr.match[type], "");
                        break;
                    }
                }
            }
        }

        if (!set) {
            set = context.getElementsByTagName("*");
        }

        expr += later;

        return { set: set, expr: expr };
    };

    Sizzle.filter = function (expr, set, inplace) {
        var old = expr, result = [], curLoop = set, match;

        while (expr && set.length) {
            for (var type in Expr.filter) {
                if ((match = Expr.match[type].exec(expr)) != null) {
                    var anyFound = false, filter = Expr.filter[type], goodArray = null;
                    match[1] = (match[1] || "").replace(/\\/g, "");

                    if (curLoop == result) {
                        result = [];
                    }

                    if (Expr.preFilter[type]) {
                        match = Expr.preFilter[type](match, curLoop);

                        if (match[0] === true) {
                            goodArray = [];
                            var last = null, elem;
                            for (var i = 0; (elem = curLoop[i]) !== undefined; i++) {
                                if (elem && last !== elem) {
                                    goodArray.push(elem);
                                    last = elem;
                                }
                            }
                        }

                    }

                    var goodPos = 0, found, item;

                    for (var i = 0; (item = curLoop[i]) !== undefined; i++) {
                        if (item) {
                            if (goodArray && item != goodArray[goodPos]) {
                                goodPos++;
                            }

                            found = filter(item, match, goodPos, goodArray);
                            if (inplace && found != null) {
                                curLoop[i] = found ? curLoop[i] : false;
                            } else if (found) {
                                result.push(item);
                                anyFound = true;
                            }
                        }
                    }

                    if (found !== undefined) {
                        if (!inplace) {
                            curLoop = result;
                        }

                        expr = expr.replace(Expr.match[type], "");

                        if (!anyFound) {
                            return [];
                        }

                        break;
                    }
                }
            }


            expr = expr.replace(/\s*,\s*/, "");

            // Improper expression
            if (expr == old) {
                throw "Syntax error, unrecognized expression: " + expr;
            }

            old = expr;
        }

        return curLoop;
    };

    var Expr = Sizzle.selectors = {
        order: ["ID", "NAME", "TAG"],
        match: {
            ID: /#((?:[\w\u0128-\uFFFF_-]|\\.)+)/,
            CLASS: /\.((?:[\w\u0128-\uFFFF_-]|\\.)+)/,
            NAME: /\[name=((?:[\w\u0128-\uFFFF_-]|\\.)+)\]/,
            ATTR: /\[((?:[\w\u0128-\uFFFF_-]|\\.)+)\s*(?:(\S{0,1}=)\s*(['"]*)(.*?)\3|)\]/,
            TAG: /^((?:[\w\u0128-\uFFFF\*_-]|\\.)+)/,
            CHILD: /:(only|nth|last|first)-child\(?(even|odd|[\dn+-]*)\)?/,
            POS: /:(nth|eq|gt|lt|first|last|even|odd)\(?(\d*)\)?/,
            PSEUDO: /:((?:[\w\u0128-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
        },
        attrMap: {
            "class": "className"
        },
        relative: {
            "+": function (checkSet, part) {
                for (var i = 0, l = checkSet.length; i < l; i++) {
                    var elem = checkSet[i];
                    if (elem) {
                        var cur = elem.previousSibling;
                        while (cur && cur.nodeType !== 1) {
                            cur = cur.previousSibling;
                        }
                        checkSet[i] = cur || false;
                    }
                }

                Sizzle.filter(part, checkSet, true);
            },
            ">": function (checkSet, part) {
                if (typeof part === "string" && !/\W/.test(part)) {
                    part = part.toUpperCase();

                    for (var i = 0, l = checkSet.length; i < l; i++) {
                        var elem = checkSet[i];
                        if (elem) {
                            var parent = elem.parentNode;
                            checkSet[i] = parent.nodeName === part ? parent : false;
                        }
                    }
                } else {
                    for (var i = 0, l = checkSet.length; i < l; i++) {
                        var elem = checkSet[i];
                        if (elem) {
                            checkSet[i] = elem.parentNode;
                            if (typeof part !== "string") {
                                checkSet[i] = checkSet[i] == part;
                            }
                        }
                    }

                    if (typeof part === "string") {
                        Sizzle.filter(part, checkSet, true);
                    }
                }
            },
            "": function (checkSet, part) {
                var doneName = "done" + (done++), checkFn = dirCheck;

                if (!part.match(/\W/)) {
                    var nodeCheck = part = part.toUpperCase();
                    checkFn = dirNodeCheck;
                }

                checkFn("parentNode", part, doneName, checkSet, nodeCheck);
            },
            "~": function (checkSet, part) {
                var doneName = "done" + (done++), checkFn = dirCheck;

                if (!part.match(/\W/)) {
                    var nodeCheck = part = part.toUpperCase();
                    checkFn = dirNodeCheck;
                }

                checkFn("previousSibling", part, doneName, checkSet, nodeCheck);
            }
        },
        find: {
            ID: function (match, context) {
                if (context.getElementById) {
                    var m = context.getElementById(match[1]);
                    return m ? [m] : [];
                }
            },
            NAME: function (match, context) {
                return context.getElementsByName(match[1]);
            },
            TAG: function (match, context) {
                return context.getElementsByTagName(match[1]);
            }
        },
        preFilter: {
            CLASS: function (match) {
                return new RegExp("(?:^|\\s)" + match[1] + "(?:\\s|$)");
            },
            ID: function (match) {
                return match[1];
            },
            TAG: function (match) {
                return match[1].toUpperCase();
            },
            CHILD: function (match) {
                if (match[1] == "nth") {
                    // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
                    var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
					match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" ||
					!/\D/.test(match[2]) && "0n+" + match[2] || match[2]);

                    // calculate the numbers (first)n+(last) including if they are negative
                    match[2] = (test[1] + (test[2] || 1)) - 0;
                    match[3] = test[3] - 0;
                }

                // TODO: Move to normal caching system
                match[0] = typeof get_length == "undefined" ? "done" + (done++) : "nodeCache";

                return match;
            },
            ATTR: function (match) {
                var name = match[1];

                if (Expr.attrMap[name]) {
                    match[1] = Expr.attrMap[name];
                }

                return match;
            },
            PSEUDO: function (match) {
                if (match[1] === "not") {
                    match[3] = match[3].split(/\s*,\s*/);
                }

                return match;
            },
            POS: function (match) {
                match.unshift(true);
                return match;
            }
        },
        filters: {
            enabled: function (elem) {
                return elem.disabled === false && elem.type !== "hidden";
            },
            disabled: function (elem) {
                return elem.disabled === true;
            },
            checked: function (elem) {
                return elem.checked === true;
            },
            selected: function (elem) {
                // Accessing this property makes selected-by-default
                // options in Safari work properly
                elem.parentNode.selectedIndex;
                return elem.selected === true;
            },
            parent: function (elem) {
                return !!elem.firstChild;
            },
            empty: function (elem) {
                return !elem.firstChild;
            },
            has: function (elem, i, match) {
                return !!Sizzle(match[3], elem).length;
            },
            header: function (elem) {
                return /h\d/i.test(elem.nodeName);
            },
            text: function (elem) {
                return "text" === elem.type;
            },
            radio: function (elem) {
                return "radio" === elem.type;
            },
            checkbox: function (elem) {
                return "checkbox" === elem.type;
            },
            file: function (elem) {
                return "file" === elem.type;
            },
            password: function (elem) {
                return "password" === elem.type;
            },
            submit: function (elem) {
                return "submit" === elem.type;
            },
            image: function (elem) {
                return "image" === elem.type;
            },
            reset: function (elem) {
                return "reset" === elem.type;
            },
            button: function (elem) {
                return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON";
            },
            input: function (elem) {
                return /input|select|textarea|button/i.test(elem.nodeName);
            }
        },
        setFilters: {
            first: function (elem, i) {
                return i === 0;
            },
            last: function (elem, i, match, array) {
                return i === array.length - 1;
            },
            even: function (elem, i) {
                return i % 2 === 0;
            },
            odd: function (elem, i) {
                return i % 2 === 1;
            },
            lt: function (elem, i, match) {
                return i < match[3] - 0;
            },
            gt: function (elem, i, match) {
                return i > match[3] - 0;
            },
            nth: function (elem, i, match) {
                return match[3] - 0 == i;
            },
            eq: function (elem, i, match) {
                return match[3] - 0 == i;
            }
        },
        filter: {
            CHILD: function (elem, match) {
                var type = match[1], parent = elem.parentNode;

                var doneName = match[0];

                if (!parent[doneName]) {
                    var count = 1;

                    for (var node = parent.firstChild; node; node = node.nextSibling) {
                        if (node.nodeType == 1) {
                            node.nodeIndex = count++;
                        }
                    }

                    parent[doneName] = count - 1;
                }

                if (type == "first") {
                    return elem.nodeIndex == 1;
                } else if (type == "last") {
                    return elem.nodeIndex == parent[doneName];
                } else if (type == "only") {
                    return parent[doneName] == 1;
                } else if (type == "nth") {
                    var add = false, first = match[2], last = match[3];

                    if (first == 1 && last == 0) {
                        return true;
                    }

                    if (first == 0) {
                        if (elem.nodeIndex == last) {
                            add = true;
                        }
                    } else if ((elem.nodeIndex - last) % first == 0 && (elem.nodeIndex - last) / first >= 0) {
                        add = true;
                    }

                    return add;
                }
            },
            PSEUDO: function (elem, match, i, array) {
                var name = match[1], filter = Expr.filters[name];

                if (filter) {
                    return filter(elem, i, match, array)
                } else if (name === "contains") {
                    return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0;
                } else if (name === "not") {
                    var not = match[3];

                    for (var i = 0, l = not.length; i < l; i++) {
                        if (Sizzle.filter(not[i], [elem]).length > 0) {
                            return false;
                        }
                    }

                    return true;
                }
            },
            ID: function (elem, match) {
                return elem.nodeType === 1 && elem.getAttribute("id") === match;
            },
            TAG: function (elem, match) {
                return (match === "*" && elem.nodeType === 1) || elem.nodeName === match;
            },
            CLASS: function (elem, match) {
                return match.test(elem.className);
            },
            ATTR: function (elem, match) {
                var result = elem[match[1]], value = result + "", type = match[2], check = match[4];
                return result == null ?
				false :
				type === "=" ?
				value === check :
				type === "*=" || type === "~=" ?
				value.indexOf(check) >= 0 :
				!match[4] ?
				result :
				type === "!=" ?
				value != check :
				type === "^=" ?
				value.indexOf(check) === 0 :
				type === "$=" ?
				value.substr(value.length - check.length) === check :
				type === "|=" ?
				value === check || value.substr(0, check.length + 1) === check + "-" :
				false;
            },
            POS: function (elem, match, i, array) {
                var name = match[2], filter = Expr.setFilters[name];

                if (filter) {
                    return filter(elem, i, match, array);
                }
            }
        }
    };

    function makeArray(array, results) {
        array = Array.prototype.slice.call(array);

        if (results) {
            results.push.apply(results, array);
            return results;
        }

        return array;
    }

    // TODO: Need a proper check here
    if (document.all && !window.opera) {
        function makeArray(array, results) {
            if (array instanceof Array) {
                return Array.prototype.slice.call(array);
            }

            var ret = results || [];

            for (var i = 0; array[i]; i++) {
                ret.push(array[i]);
            }

            return ret;
        }

        Expr.find.ID = function (match, context) {
            if (context.getElementById) {
                var m = context.getElementById(match[1]);
                return m ? m.id === match[1] || m.getAttributeNode && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
            }
        };

        Expr.filter.ID = function (elem, match) {
            var node = elem.getAttributeNode && elem.getAttributeNode("id");
            return elem.nodeType === 1 && node && node.nodeValue === match;
        };
    }

    if (document.querySelectorAll) (function () {
        var oldSizzle = Sizzle;

        window.Sizzle = Sizzle = function (query, context, extra) {
            context = context || document;

            if (context.nodeType === 9) {
                try {
                    return makeArray(context.querySelectorAll(query));
                } catch (e) { }
            }

            return oldSizzle(query, context, extra);
        };

        Sizzle.find = oldSizzle.find;
        Sizzle.filter = oldSizzle.filter;
        Sizzle.selectors = oldSizzle.selectors;
    })();

    if (document.getElementsByClassName) {
        Expr.order.splice(1, 0, "CLASS");
        Expr.find.CLASS = function (match, context) {
            return context.getElementsByClassName(match[1]);
        };
    }

    function dirNodeCheck(dir, cur, doneName, checkSet, nodeCheck) {
        for (var i = 0, l = checkSet.length; i < l; i++) {
            var elem = checkSet[i];
            if (elem) {
                elem = elem[dir]
                var match = false;

                while (elem && elem.nodeType) {
                    var done = elem[doneName];
                    if (done) {
                        match = checkSet[done];
                        break;
                    }

                    if (elem.nodeType === 1)
                        elem[doneName] = i;

                    if (elem.nodeName === cur) {
                        match = elem;
                        break;
                    }

                    elem = elem[dir];
                }

                checkSet[i] = match;
            }
        }
    }


    function dirCheck(dir, cur, doneName, checkSet, nodeCheck) {
        for (var i = 0, l = checkSet.length; i < l; i++) {
            var elem = checkSet[i];
            if (elem) {
                elem = elem[dir]
                var match = false;

                while (elem && elem.nodeType) {
                    if (elem[doneName]) {
                        match = checkSet[elem[doneName]];
                        break;
                    }

                    if (elem.nodeType === 1) {
                        elem[doneName] = i;

                        if (Sizzle.filter(cur, [elem]).length > 0) {
                            match = elem;
                            break;
                        }
                    }

                    elem = elem[dir];
                }

                checkSet[i] = match;
            }
        }
    }

    function clearDefaultText(e) {
        var target = window.event ? window.event.srcElement : e ? e.target : null;
        if (!target) return;

        if (target.value == target.defaultText) {
            target.value = '';
        }
    }

    function replaceDefaultText(e) {
        var target = window.event ? window.event.srcElement : e ? e.target : null;
        if (!target) return;

        if (target.value == '' && target.defaultText) {
            target.value = target.defaultText;
        }
    }


    if (document.compareDocumentPosition) {
        function contains(a, b) {
            return a.compareDocumentPosition(b) & 16;
        }
    } else {
        function contains(a, b) {
            return a !== b && a.contains(b);
        }
    }

    // EXPOSE
    $$ = Sizzle;

    //PRIVATE SITE SPECIFIC FUNCTIONS GO HERE

    var language = {
        up: function () {
            //removeClass($("language"),"open");
            jqry("#languageSelectionList").hide();
            this.onclick = language.down;
        },
        down: function () {
            //addClass($("language"),"open");
            jqry("#languageSelectionList").show();
            this.onclick = language.up;
        }
    };

    function getDimensions() {
        var dimensions = [];
        dimensions[0] = (typeof (window.innerHeight) == 'number') ? docHeight = window.innerHeight : docHeight = document.documentElement.clientHeight;
        dimensions[1] = (typeof (window.innerWidth) == 'number') ? docWidth = window.innerWidth : docWidth = document.documentElement.clientWidth;
        return dimensions;
    };

    function windowShade(e) {
        e = e ? e : (window.event) ? window.event : "";
        var actor = (e.target) ? e.target : e.srcElement;
        if (actor.nodeName.toLowerCase() == "a") {
            return true
            e.cancelBubble = true;
            if (e.stopPropagation) e.stopPropagation();
        } else {
            toggleClass(this, "open");
            if (hasClass(this, "open")) {
                var theHeight = this.offsetHeight;
                this.setAttribute("data-height", theHeight);
                var dataHeight = this.getAttribute("data-height");
                var totalDataHeight = parseInt(dataHeight);
                var secondaryContentHeight = $("secondary-content").offsetHeight;
                var newHeight = $("secondary-content").style.height = (secondaryContentHeight + totalDataHeight) + "px";
            }
            else {
                if (this.getAttribute("data-height")) {
                    var dataHeight = this.getAttribute("data-height");
                    var totalDataHeight = parseInt(dataHeight) + 120;
                    var secondaryContentHeight = $("secondary-content").offsetHeight;
                    var newHeight = $("secondary-content").style.height = (secondaryContentHeight - totalDataHeight) + "px";
                }
            }
            e.cancelBubble = true;
            if (e.stopPropagation) { e.stopPropagation(); }

        }
    };

    function showEmailAgreement(email) {
        var popupWindow = window.open("/Site%20Tools/Email%20Disclaimer.aspx?device=popup&email=" + email, "popupWindow", "width=452,height=495,status=no,menubar=no,scrollbars=no");
        return false;
    };

    function adjustColumns() {
        var dimensions = getDimensions();
        var container = $("container").offsetHeight;
        var secondaryContent = $("secondary-content").offsetHeight;

        if (secondaryContent < dimensions[0]) {
            var secondaryContent = $("secondary-content").style.height = (dimensions[0] - 84) + "px";
        };

        if (($("container").offsetHeight) > ($("secondary-content").offsetHeight)) {
            if ($("flash-video-player")) {
                $("secondary-content").style.height = (container + 500) + "px";
            } else {
                $("secondary-content").style.height = (container + 200) + "px";
            };
        };
    };

    function handleMoreLinks() {
        var theUL = this.parentNode;
        var nextSibling = theUL.nextSibling;
        while (nextSibling != null && nextSibling.nodeType === 3) {
            nextSibling = nextSibling.nextSibling;
        }
        addClass(theUL, "hidden");
        removeClass(nextSibling, "hidden");
        return false;
    };

    return {
        //PUBLIC METHODS AND ATTRIBUTES GO HERE
        // IN THE RETURNED OBJECT
        //Methods look like this
        //method1 : function(){ alert(method1")},
        //called Cramer.Behavior.method1();
        //Attrributes look like this
        //attribute1 : value,
        //accessed as Cramer.Behavior.attribute1
        getElementsByClass: function (theClass, context) { return getElementsByClass(theClass, context) }
    };
})();
