var SmallCarousel = function(args){
    var self = this;
    this.root = $(args.root);
    this.current = null;
    
    this.prev = function() {
        if(self.current.prev('li').length > 0) {
            self.current = self.current.hide().prev('li').fadeIn();    
        } else {
            self.current = self.current.hide().siblings('li:last').fadeIn();    
        }
        return false;
    }

    this.next = function() {
        if(self.current.next('li').length > 0){
            self.current = self.current.hide().next('li').fadeIn();    
        } else {
            self.current = self.current.hide().siblings('li:first').fadeIn();    
        }
        return false;
    }
    
    this._init = function() {
        self.root.addClass('js-carousel');
        self.root.find('.js-prev').click(self.prev);
        self.root.find('.js-next').click(self.next);
        self.current =  self.root.find('li:first').fadeIn();
    }
    
    this._init();
}
//container for carousels
var runningCarousels = [];

$(function(){
    $('.js-small-carousel').each(function(){
        var    args = {root:this};
        runningCarousels.push(new SmallCarousel(args));
    
    });

});

