window.addEvent('domready', function() {
	var starter=0;
	var obj=document.getElementById("AccordianHack");
	var myAccordion;
	if (obj!=null) {
		starter=obj.innerHTML;
		starter=starter-0;

	    //create our Accordion instance
		myAccordion = new Accordion($('sidebar'), 'h2.categorytitle', 'div.PeCatsBrands', {
        opacity: false,
        show: starter,
        onActive: function(categorytitle, PeCatsBrands) {
        categorytitle.setStyle('color', '#333333');
        },
        onBackground: function(categorytitle, PeCatsBrands) {
            categorytitle.setStyle('color', '#ababab');
        }
    });
}
	else
	{
		//create our Accordion instance
        myAccordion = new Accordion($('sidebar'), 'h2.categorytitle', 'div.PeCatsBrands', {
        opacity: false,
        start: "all-closed",
        onActive: function(categorytitle, PeCatsBrands) {
        categorytitle.setStyle('color', '#333333');
        },
        onBackground: function(categorytitle, PeCatsBrands) {
            categorytitle.setStyle('color', '#ababab');
        }
    });
	}


    //add click event to the "add section" link
    $('add_section').addEvent('click', function(event) {
        event.stop();

        // create categorytitle
        var categorytitle = new PeCatsBrands('h2', {
            'class': 'categorytitle',
            'html': 'Common descent'
        });

        // position for the new section
        var position = 0;

        // add the section to our myAccordion using the addSection method
        myAccordion.addSection(categorytitle, content, position);
    });
});