(function($) {
	$.fn.productScroll = function(o) {
		$(this).each(function() {
			var itemWidth = 187;
			var itemsVisible = 4;
			var itemsVisibleWidth = itemWidth * itemsVisible;

			var list = $(this).find('ul');
			var buttons = $(this).find('.ScrollButton');

			var listWidth = itemWidth * list.find('>li').length;

			buttons.click(function() {
				var dir = $(this).is('.ScrollLeftButton') ? +1 : -1;
				var left = parseInt(list.css('left').replace('px', ''));
				var rem = Math.abs(left) % itemWidth;

				var inc = itemWidth * itemsVisible * dir + rem;
				
				var min = 0;
				var max = listWidth - itemsVisibleWidth;

				if (dir == 1 && left + inc > 0) inc = -left;
				if (dir == -1 && left + inc < -max) inc = -(max + left);

				list.stop();

				list.animate({
					left: '+=' + inc
				}, {            
					'duration': 1000, 
					'step': function(now, fx) {
						
					},
					'complete': function() {

					}                                
				});
			});

		});
	}
})(jQuery);
