window.addEvent('load', function(){
    
    //initialization of togglers effects
    var stretchers = $$('div.accordion');
    stretchers.setStyles({'height': '0', 'overflow': 'hidden'});
    var togglers = $$('h2.toggler');
    togglers.each(function(toggler, i){
        toggler.color = toggler.getStyle('background-color');
        toggler.$tmp.first = toggler.getFirst();
        toggler.$tmp.fx = new Fx.Style(toggler, 'background-color', {'wait': false, 'transition': Fx.Transitions.Quart.easeOut});
    });
    
    //the accordion
    
    var myAccordion = new Accordion(togglers, stretchers, {
        
        'opacity': false,
        
        'start': false,
        
        'transition': Fx.Transitions.Quad.easeOut,
        
        onActive: function(toggler){
            //toggler.$tmp.fx.start('#009DE0');
            //toggler.$tmp.first.setStyle('color', '#009DE0');
        },
    
        onBackground: function(toggler){
            toggler.$tmp.fx.stop();
            //toggler.setStyle('background-color', toggler.color).$tmp.first.setStyle('color', 'green');
        }
    });
    
    //open the accordion section relative to the url
    
    var found = 0;
    $$('h2.toggler a').each(function(link, i){
        if (window.location.hash.test(link.hash)) found = i;
    });
    myAccordion.display(found);
    
});

