window.current_question = window.location.hash;

function highlight_question() {
    $$('.faq-question').invoke('removeClassName', 'notice_msg');
    if (window.current_question) {
        var target = $(window.current_question.substr(1));
        if (target) { target.addClassName('notice_msg'); }
        return target;
    }
}

function pollFragment() {
    if (window.location.hash == current_question) { return; }
    current_question = window.location.hash;
    highlight_question();
}
document.observe('dom:loaded', function(e) {
    $$('a[type="application/pdf"]').invoke('addClassName', 'pdf-link');
    $$('a[href^="mailto:"]').invoke('addClassName', 'email-link');

    // if it's the popup, hide the standard navigation frame
    if (window.name == 'faq') {
        $('header').hide();
        $('footer').hide();
        $$('.navlinks').invoke('hide');
    }

    var question = highlight_question();
    // ensure that we get the question on the page, even after removing the navigation frame
    // (which will cause the scroll to caused by the #fragment to be off)
    if (question) { question.scrollTo(); }

    var fragment_poll = setInterval(pollFragment, 100);
});

