// JavaScript Document
function ProductScroller()
{
	this._li = 0;
	this._products = 1;
	this._prev = '#prev';
	this._next = '#next';
	this._scroller = '#scroller';
}
ProductScroller.prototype.setScroller = function()
{
	var obj = this;
	$(obj._scroller).scrollTo(obj._li);
	
	$(obj._prev).click(function(){
		obj._li -= obj._products;
		if (obj._li < obj._products)
		{
			$(this).attr('disabled', true);
		}
		if (obj._li < 0)
		{
			obj._li = 0;
		}
		$(obj._next).attr('disabled', false);
		obj.scrollNow();
	})
	.attr('disabled', true);
	
	$(obj._next).click(function(){
		obj._li += obj._products;
		var num = $(obj._scroller + '>ul>li').length;
		if (obj._li > num - obj._products - 1)
		{
			$(this).attr('disabled', true);
		}
		if (obj._li > num)
		{
			obj._li = Math.floor(num / obj._products) * obj._products;
		}
		$(obj._prev).attr('disabled', false);
		obj.scrollNow();
	})
	.attr('disabled', false);
}
ProductScroller.prototype.scrollNow = function()
{
	var obj = this;
	$(obj._scroller).stop().scrollTo('li:eq(' + obj._li + ')', 800);
}