


window.addEvent('load', function(){
	
	var stretchers = $$('div.accordion');
	var togglers = $$('h3.toggler');
	
	

	stretchers.setStyles({'height': '0', 'overflow': 'hidden'});
	
	//initialization of togglers effects
	
	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': true,
		
		'opacity': false,
		
		'start': true,
		
		'transition': Fx.Transitions.Quad.easeOut,
		
		onActive: function(toggler){
			toggler.$tmp.fx.start('#FFFFFF');
			toggler.$tmp.first.setStyle('color', '#333');
		},
	
		onBackground: function(toggler){
			toggler.$tmp.fx.stop();
			toggler.$tmp.first.setStyle('color', '#828282');
		}
	});
	
	//open the accordion section relative to the url
	
	var found = -1;
	$$('div.accordion').each(function(item, i){
		item.getElements('a').each(function(link, j){
			if (window.location.href.indexOf(link)>-1) {
				found = i;
				link.setStyle('color', '#e97918');
			}
		});
	});
	if (found != -1) {
		myAccordion.display(found);
	}else{
		$$('div.menu_contenedor a').each(function(link, i){
			if (window.location.href.indexOf(link)>-1) {
				link.setStyle('color', '#e97918');
			}
		});
	}
	
});
