var YOOaccordion = new Class({
    initialize: function (togglers, elements, options) {
        this.setOptions({
            openAll: false,
            allowMultipleOpen: false,
            transition: Fx.Transitions.linear,
            duration: 400
        },
        options);
        this.togglers = togglers;
        this.elements = elements;
        this.elementFx = [];
        this.elementVisible = [];
        this.togglers.each(function (tog, i) {
            tog.addEvent('click', function () {
                this.toggleSection(i)
            }.bind(this))
        },
        this);
        this.elements.each(function (el, i) {
            this.elementFx[i] = new Fx.Slide(el, this.options);
            if (! (this.options.allowMultipleOpen && this.options.openAll)) this.hide(i)
        },
        this);
        if (! (this.options.allowMultipleOpen && this.options.openAll))(function () {
            
        }).delay(1, this)
    },
    toggleSection: function (iToToggle) {
        if (!this.options.allowMultipleOpen) {
            this.elements.each(function (el, i) {
                if (this.elementVisible[i] && i != iToToggle) this.slideOut(i)
            },
            this)
        }
        this.toggle(iToToggle)
    },
    toggle: function (i) {
        this.elementVisible[i] = !this.elementVisible[i];
        this.elementFx[i].toggle()
    },
    slideIn: function (i) {
        this.elementVisible[i] = true;
        this.elementFx[i].slideIn()
    },
    slideOut: function (i) {
        this.elementVisible[i] = false;
        this.elementFx[i].slideOut()
    },
    show: function (i) {
        this.elementVisible[i] = true;
        this.elementFx[i].show()
    },
    hide: function (i) {
        this.elementVisible[i] = false;
        this.elementFx[i].hide()
    }
});
YOOaccordion.implement(new Options);
