window.addEvent('domready', function() {
	
	//make the accordion
var accordion = new Accordion($$('.toggler'),$$('.element'), {
 opacity: 0,
 onActive: function(toggler) { toggler.setStyle('color', '#f30'); },
 onBackground: function(toggler) { toggler.setStyle('color', '#000'); }
});

//make it open on hover
$$('.toggler').addEvent('mouseenter', function() { this.fireEvent('click'); });


	//add click event to the "add section" link
	$$('add_section').addEvent('click', function(event) {
		event.stop();
		
		// create toggler
		var toggler = new Element('h3', {
			'class': 'toggler',
			'html': 'Common descent'
		});
		
		// create content
		var content = new Element('div', {
			'class': 'element',
			'html': ''
		});
		
		// position for the new section
		var position = 0;
		
		// add the section to our myAccordion using the addSection method
		myAccordion.addSection(toggler, content, position);
	});
});
