﻿var current=null;

function init() {
    var linked=$$('h4'+document.location.hash)[0];
   
    if(linked!=null){
        if(!linked.hasClassName('highlight'))linked.toggleClassName('highlight');
        current=linked;
    }
    $$('body a').each(function(i){
        var hashpos = i.href.lastIndexOf("#");
        if (hashpos < 0) return;
        
        var anchor = i.href.substring(hashpos+1);
        
        if (anchor.startsWith('ctl00')) return;
        if (anchor == 'faqs'){
            i.observe('click',function(e){
                if(current==null)return;
                if(current.hasClassName('highlight'))current.toggleClassName('highlight');
                current=null;
            });
        }else{
            i.observe('click',function(e){
                var a=e.element().href.split('#')[1];
                if(current!=null)current.toggleClassName('highlight');
                current=$$('body h4#'+a)[0].toggleClassName('highlight');
            });
        }
    });
}

document.observe('dom:loaded', init);
