(function($){
    $.fn.extend({ 
        //plugin name - animatemenu
        animateCarousel: function(options) {
 
            //Settings list and the default values
            var defaults = {
                animatePadding: 60,
                defaultPadding: 10,
                evenColor: '#ccc',
                oddColor: '#eee'
            };
             
            var options = $.extend(defaults, options);
         
            return this.each(function() {
                var o =options;
                 
                //Assign current element to variable, in this case is UL element
                var obj = $(this);              

				// width slide
				var slideWidth = 300;
				// speed
				var slideSpeed = 1000;	
				// count slides
				var slideCount = obj.find(".sidebar_carousel_slider").children().length;
								
				// total width
				var slidesWidth = slideCount * slideWidth;
				// end of slides
				var slideEnd = slidesWidth;
				//set start to zero
				var n = 0;

			
				obj.find('.sidebar_carousel_prev').click(function() {
					n = n - slideWidth;
					if(n == -slideWidth) n = slideEnd - slideWidth;
					obj.find(".sidebar_carousel").scrollTo( { top: 0, left: n }, slideSpeed );
					var slideItem = n / slideWidth;
					return false;
				});	
				
				obj.find('.sidebar_carousel_next').click(function() {
					n = n + slideWidth;
					if(n == slideEnd) n = 0;
					obj.find(".sidebar_carousel").scrollTo( { top: 0, left: n }, slideSpeed );
					var slideItem = n / slideWidth;
					return false;
				});					
                 
            });
        }
	
    });
})(jQuery);
