// var ol_textfontclass="casual"
var toggle = true

// xGetElementsByAttribute r2, Copyright 2002-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xGetElementsByAttribute(sTag, sAtt, sRE, fn) {
    var a, list, found = new Array(), re = new RegExp(sRE, 'i');
    list = xGetElementsByTagName(sTag);
    for (var i = 0; i < list.length;++ i) {
        a = list[i].getAttribute(sAtt);
        if (! a) {
            a = list[i][sAtt];
        }
        if (typeof (a) == 'string' && a.search(re) != - 1) {
            found[found.length] = list[i];
            if (fn) fn(list[i]);
        }
    }
    return found;
}

clarify = function () {
    var clarification = xGetElementsByAttribute('span', 'name', 'clarify')
    var paragraphs = xGetElementsByAttribute('span', 'name', 'paragraph')
    if (toggle) {
        // highlight clarifications
        for (var i = 0; i < clarification.length; i++) {
            clarification[i].className = 'highlight';
        }
        for (var i = 0; i < paragraphs.length; i++) {
            paragraphs[i].className = 'show'
        }
    } else {
        // nohighlight clarifications
        for (var i = 0; i < clarification.length; i++) {
            clarification[i].className = 'nohighlight';
        }
        for (var i = 0; i < paragraphs.length; i++) {
            paragraphs[i].className = 'hide'
        }
    }
    toggle = ! toggle
}

// publisher = a global constant defined in the calling document
loaded = function () {
    
    xGetElementById("immediacy") .innerHTML = "{ " + ximmediacy() + " }"
    
    xAddEventListener('topbar', 'click', function () {
        document.location = publisher
    },
    false)
    
    xAddEventListener('topbar', 'mouseover', function () {
        xGetElementById("topbar") .className = "topbar light"
    },
    false)

    xAddEventListener('topbar', 'mouseout', function () {
        xGetElementById("topbar") .className = "topbar dark"
    },
    false)

}

// <!-- execute when the page is loaded -->
xAddEventListener(window, 'load', loaded, false)