function JavaScroller(holderObj, movingObj, upObj, downObj) {

	this.holderObj = holderObj;
	
	this.movingObj = movingObj;
	
	this.downObj = downObj;
	
	this.upObj = upObj;
	
	this.movingOffset = 0;
		
	this.movingSpeed = 1;

	this.rotationCount = 1;
	

	this.init = function () {

		this.CachedStopMoveHandler = this.stopMove.bindAsEventListener(this);
	
		this.CachedMoveUpHandler = this.moveUp.bindAsEventListener(this);
	
		this.CachedMoveDownHandler = this.moveDown.bindAsEventListener(this);
		
		Event.observe(this.upObj, 'mouseover', this.CachedMoveUpHandler);
		
		Event.observe(this.downObj, 'mouseover', this.CachedMoveDownHandler);
	
	}


	this.moveUp = function (event) {
	
		Event.observe(this.upObj, 'mouseout', this.CachedStopMoveHandler);

		this.movingOffset = -1;
		
		this.move();

		Event.stop(event);

	}


	this.moveDown = function (event) {
	
		Event.observe(this.downObj, 'mouseout', this.CachedStopMoveHandler);

		this.movingOffset = 1;
				
		this.move();

		Event.stop(event);

	}

	this.stopMove = function () {
			
		Event.stopObserving(this.upObj, 'mouseup', this.CachedStopMoveHandler);

		clearTimeout(this.timerHandle);

		this.movingSpeed = 1;
		
		this.rotationCount = 1;
		
		return true;
	};

	this.move = function () {

		var self = this;

		var process = function() {
		
			self.rotationCount++;
			
			if (self.rotationCount > 60) {
				self.movingSpeed++;
				self.rotationCount = 1;
			}

			/* DOWN  */
			if (self.movingOffset > 0 && (self.movingObj.offsetTop <= 0)) {
				self.movingObj.style.top = (self.movingObj.offsetTop + (self.movingOffset * self.movingSpeed)) + 'px';
				//$('dirk').value = self.movingObj.offsetTop + " + " + self.movingObj.offsetHeight + " >= " + self.holderObj.offsetTop + " + " + self.holderObj.offsetHeight
			}
			
			/* UP */
			if (self.movingOffset < 0 && ((self.movingObj.offsetTop + self.movingObj.offsetHeight) >= (self.holderObj.offsetHeight))) {
				self.movingObj.style.top = (self.movingObj.offsetTop + (self.movingOffset * self.movingSpeed)) + 'px';			
				//$('dirk').value = self.movingObj.offsetTop + " >= " + self.holderObj.offsetTop;
			}
		
			self.move();
		}

		self.timerHandle = setTimeout(process, 5);

	}


	this.findPos = function(obj) {

		var curleft = curtop = 0;

		if (obj.offsetParent) {

			curleft = obj.offsetLeft

			curtop = obj.offsetTop

			while (obj = obj.offsetParent) {

				curleft += obj.offsetLeft

				curtop += obj.offsetTop

			}
		}

		return [curleft,curtop];

	}


	this.alignResultsBox = function(leftOffset, topOffset) {

		this.hideAppendObj.style.left = (this.findPos(this.textBoxObj)[0] + leftOffset) - this.findPos(this.hideAppendObj.offsetParent)[0];

		this.hideAppendObj.style.top = (this.findPos(this.textBoxObj)[1] + this.textBoxObj.offsetHeight + leftOffset) - this.findPos(this.hideAppendObj.offsetParent)[1];

	}

	this.init();

}
