var stretchers = $$('div.accordion');
var togglers = $$('h3.toggler');

stretchers.setStyles({'height': '0', 'overflow': 'hidden'});
	
//initialization of togglers effects

window.addEvent('load', function(){ 
	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, {
	//'alwaysHide': 'false',
	'display': '-1',
	'opacity': false,
	'start': false,
	'transition': Fx.Transitions.Quad.easeOut,
	
	onActive: function(toggler){
		toggler.$tmp.fx.start('#fff'); // Finishing Color Background
		toggler.$tmp.first.setStyle('color', '#000000'); // Finishing Color Text
	},

	onBackground: function(toggler){
		toggler.$tmp.fx.stop();
		toggler.setStyle('background-color', toggler.color).$tmp.first.setStyle('color', '#000000'); // Standard Text Color
	}

});
		
//open the accordion section relative to the url
		
var found = 0;
$$('h3.toggler a').each(function(link, i){
	if (window.location.hash.test(link.hash)) found = i;
});

myAccordion.display(found);
		
//the draggable ball
		
var ball = $('header').getElement('h1');
var ballfx = new Fx.Styles(ball, {duration: 1000, 'transition': Fx.Transitions.Elastic.easeOut});
	new Drag.Base(ball, {
		onComplete: function(){
			ballfx.start({'top': 13, 'left': 358});
		}
	});
});