window.addEvent('load', function(){

    var notonload;
    var dontscroll;
    
    $('accordion').addEvent('click', function(){
        notonload = 1;
    });
    
    var accordion = new Accordion('h3.atStart', 'div.atStart', {
		display: 999,
        opacity: true,
        duration: 2000,
		alwaysHide: true,
        onActive: function(toggler, element){
            activeelement = toggler;
        },
        
    
		
        onComplete: function(){
            if (notonload && dontscroll != 1) {
                var scroll = new Fx.Scroll(window, {
                    wait: true,
                    duration: 2000,
                    transition: Fx.Transitions.Quad.easeInOut
                }).toElement(activeelement);
            }
            else {
                dontscroll = 0;
                var scroll = new Fx.Scroll(window, {
                    wait: true,
                    duration: 3000,
                    transition: Fx.Transitions.Quad.easeInOut
                }).toElement('top');
            }    
        }
    }, $('accordion'));
    
    Accordion.implement({
        showAll: function(){
            var obj = {};
            this.elements.each(function(el, i){
                obj[i] = {};
                this.fireEvent('onActive', [this.togglers[i], el]);
                for (var fx in this.effects) 
                    obj[i][fx] = el[this.effects[fx]];
            }, this);
            return this.start(obj);
        },
        hideAll: function(){
            var obj = {};
            this.elements.each(function(el, i){
                obj[i] = {};
                this.fireEvent('onBackground', [this.togglers[i], el]);
                for (var fx in this.effects) 
                    obj[i][fx] = 0;
            }, this);
            return this.start(obj);
        }
    });
    
    
    
    $$('a.close').addEvent('click', function(event){
        accordion.hideAll();
        dontscroll = 1;
    });
    
});




