window.addEvent('domready', function() {
	
	//create our Accordion instance
	var myAccordion = new Accordion($('accordion'), 'h3.tab', 'div.element', {
		opacity: false,
		onActive: function(tab, element){
			tab.setStyle('color', '#fff');
		},
		onBackground: function(tab, element){
			tab.setStyle('color', '#EFEAE2');
		}
	});

	//add click event to the "add section" link
	$('add_section').addEvent('click', function(event) {
		event.stop();
		
		// create tab
		var tab = new Element('h3', {
			'class': 'tab',
			'html': 'Common descent'
		});
		
		// create content
		var content = new Element('div', {
			'class': 'element',
			'html': '<p></p>'
		});
		
		// position for the new section
		var position = 0;
		
		// add the section to our myAccordion using the addSection method
		myAccordion.addSection(tab, content, position);
	});
});
