(function(window) {
    
    FeaturedSlider = function(el, bL, bR) {
        
        /* private variables */
        var that,
            element,
            buttonLeft,
            buttonRight,
            show,
            max,
            itemWidth;
            
        this.initialize(el, bL, bR);
    }
    
    var p = FeaturedSlider.prototype;
    
    p.initialize = function(el, bL, bR) {
        that = this;
        element = el;
        buttonLeft = bL;
        buttonRight = bR;
        show = 3;
        this.index = 0;
        max = element.children("li").length;
        itemWidth = element.children("li").outerWidth(true);
        
        element.width(itemWidth * max);        
        buttonLeft.click(this.indexDown);
        buttonRight.click(this.indexUp);
    }
    
    p.move = function() {
        element.animate({marginLeft: - (that.index * itemWidth)});
    }
   
    p.indexDown = function() {
        that.index = (that.index > 0) ? that.index - 1 : max - show;
        that.move();
    }
    
    p.indexUp = function() {
        that.index = (that.index < max - show) ? that.index + 1 : 0;
        that.move();
    }
    
    window.FeaturedSlider = FeaturedSlider;
}(window));
