function Scroller(obj, clickSize){
	var object;
	var current;
	var child;
	var childHeight;
	var parentHeight;
	var maxScroll;
	var deltaAnimation=500;
	var deltaClick=50;
	var locked=false;
	var self=this;

	this.setClickSize=function(clickSize){
		deltaClick=clickSize;
		self.clickMath();
	}
	this.setAnimationTime=function(animationTime){
		deltaAnimation=animationTime;
	}
	this.clickMath=function(){
		maxScroll=0;
		var deltaPosition=childHeight-parentHeight;
		if(deltaPosition>0){
			maxScroll=deltaPosition;
//			alert(maxScroll+"="+childHeight+"-"+parentHeight);
		}
	}
	this.init=function(obj){
		object=jQuery(obj);
		child=object.find('.scroller').children();
		parentHeight=object.find('.scroller').outerHeight(true);
		childHeight=0;
		child.children().each(function(){
			var height=jQuery(this).outerHeight(true);
			childHeight+=height;
		});
		self.clickMath();
		child.css('position','absolute');
		self.setTriggers();
		current=0;
	}

	this.setTriggers=function(){
		object.find('.controls .prev').click(function(){
			if(current>0){
				self.move('+='+deltaClick);
			}
		});
		object.find('.controls .next').click(function(){
			if(current<maxScroll){
				self.move('-='+deltaClick);
			}
		});

		r_timer=setInterval(
			function(e){
				if(child.outerHeight(true)!=childHeight)
				{
					self.clickMath();
					childHeight=child.outerHeight(true)
				}
			}, 500);
	}
	this.move=function(input){
		if(!locked){
			locked=true;
			child.animate({top: input},deltaAnimation, function(){
				locked=false;
				current=parseInt(object.find('.scroller .contentContainer').css('top'));
				current=current*(-1);
//				alert(current);
			});
		}
	}
	this.scrollToStart=function(){
		var position=object.find('.start').position();
//		alert(position.top);
		var move=position.top * -1;
		child.css('top', move);
		current=position.top;
	}
	self.init(obj);
	self.scrollToStart();
}

