if (typeof Avid  == "undefined")  Avid = Class.create();
Avid.BannerSlider = Class.create();
Avid.BannerSlider.prototype = {
    initialize: function(elem) {
        this.container = $(elem);
        this.slides = $$('#' + elem + ' .banner-slides li');
        this.buttons = $$('#' + elem + ' .banner-buttons li');
        this.duration = 1;
        this.slides.each(function(slide) {
            Event.observe(slide,'click',this.hyperlink.bindAsEventListener(this));
        }.bind(this));
        this.slideIndex = 0;
        new Effect.Appear(this.slides[this.slideIndex], {duration:this.duration, from:0, to:1.0});
        instance = this;
        this.interval = setInterval(function(){ instance.next() }, 6000)
    },
    goto: function(index) {
        if (this.slideIndex == index) {
            return false;
        }
        new Effect.Fade(this.slides[this.slideIndex], {duration:this.duration, from:1.0, to:0});
        this.slideIndex = index;
        new Effect.Appear(this.slides[this.slideIndex], {duration:this.duration, from:0, to:1.0});
        this.buttons.each(function(button) {
            button.removeClassName('current');
        });
        this.buttons[this.slideIndex].addClassName('current');
    },
    next: function() {
        if (this.slideIndex == this.slides.length-1) {
            index = 0
        } else {
            index = this.slideIndex + 1;
        }
        this.goto(index);
    },
    previous: function() {
        if (this.currentIndex == 0) {
            index = this.slides.length-1
        } else {
            index = this.slideIndex - 1;
        }
        this.goto(index);
    },
    hyperlink: function() {
        console.log(event.target);
    }
}
