window.addEvent('domready', function() {
	
	//create our Accordion instance
	var myAccordion = new Accordion($('accordion'), 'h5.toggler', 'div.element', {
		opacity: false,
		onActive: function(toggler, element){
				toggler.addClass('open');
        element.style.display = '';
		},
		onBackground: function(toggler, element){
				toggler.removeClass('open');
        element.style.display = 'none';
		}
	});
  if ($('add_section')) {
    //add click event to the "add section" link
    $('add_section').addEvent('click', function(event) {
      event.stop();
      
      // create toggler
      var toggler = new Element('h5', {
        'class': 'toggler',
        'html': '1'
      });
      
      // create content
      var content = new Element('div', {
        'class': 'element',
        'html': '1a'
      });
      
      // position for the new section
      var position = 0;
      
      // add the section to our myAccordion using the addSection method
      myAccordion.addSection(toggler, content, position);
    });
  }
});
