var Slidebox = function(container, childWidth, childCountPerPage){
	this.container = container;
	this.childWidth = childWidth;
	this.childCountPerPage = childCountPerPage;

	this.ClassNameForChildren = 'child';
	this.isScrolling = false;
	this.offsetLeft = 0;

	this.container.children('li').addClass(this.ClassNameForChildren);
}
Slidebox.prototype = {
	slide : function(){
		if(this.isScrolling) return;
		this.isScrolling = true;

		this._appendClones();
		this._slideContainer();
	},
	_appendClones : function(){
		var self = this;
		var slidingItems = this.container.children('li.%s:lt(%d)'.replace('%s', this.ClassNameForChildren).replace('%d', this.childCountPerPage));
		slidingItems.each(function(){
			$(this).clone().appendTo(self.container);
			$(this).removeClass(this.ClassNameForChildren);
		});
	},
	_slideContainer : function(){
		var self = this;
		this.offsetLeft += this.childWidth * this.childCountPerPage;
		this.container.animate(
			{left : (-1 * this.offsetLeft) + 'px'},
			{
				duration : 'slow',
				complete : function(){
//					self._extendWidth(self.offsetLeft);
					self.isScrolling = false;
				}
			}
		);
	}
/*
	,
	_extendWidth : function(x){
		var width = this.container.css('width').replace(/px$/, '');
		var newWidth = new Number(width) + x;
		this.container.css('width', newWidth + 'px');
	}
*/
}
