var Accordion = Class.create();
Accordion.prototype = {
    initialize: function(arr, blindspeed){
        this.accord = [];
        for (var i = 0, len = arr.length; i < len; ++i) {
            this.accord[i] = arr[i];
        }
        this.blindSpeed = blindspeed;
        this.previous = true;
    },
    slide: function(div, id){
        for (var i = 0, len = this.accord.length; i < len; ++i) {
            if (this.accord[i] == div) {
                changeIcon = this.changeActiveState.bind(this, div);
                new Effect.toggle(this.accord[i], 'blind', {
                    duration: this.blindSpeed,
                    afterFinish: changeIcon
                });
            }
            if (this.previous == this.accord[i]) {
                if (this.previous != div) {
                    new Effect.BlindUp(this.accord[i], {
                        duration: this.blindSpeed
                    });
                }
            }
        }
        this.previous = div;
    },
    changeActiveState: function(id){
        if (this.previous1 != 0) {
            if ($(this.previous1)) {
                $(this.previous1).up().removeClassName("active");
            }
        }
        if (this.previous1 != id) {
            if ($(id)) {
                $(id).up().addClassName("active");
            }
            this.previous1 = id;
        }
        else {
            this.previous1 = 0;
        }
    }
};

