var loop      = false;
var timer     = null;
var thisObj   = null;
var thisSpeed = null;

function scrollUp(speed, obj) {
	if(obj) { thisObj = obj; }
	
	if(thisObj.y < 0){
		var y = thisObj.y + speed;
		move(thisObj, thisObj.x, y);
		
		if(!loop) {
			loop  = true;
			timer = setInterval('scrollUp(' + speed + ')', speed);
		}
	}
}

function scrollDown(speed, obj) {
	if(obj) { thisObj = obj; }
	
	if(thisObj.y == undefined) {
		obj.y = 0;
		obj.x = 0;
	}
	
	if(thisObj.y > -thisObj.offsetHeight + thisObj.parentNode.offsetHeight) {
		var y = thisObj.y - speed;
		move(thisObj, thisObj.x, y);
		
		if(!loop) {
			loop  = true;
			timer = setInterval('scrollDown(' + speed + ')', speed);
		}
	}
}

function stopScroll(obj) {
	if(loop) {
		clearInterval(timer);
		timer = null;
		loop  = false;
	}
}

function move(obj, x, y) {
	obj.x = x;
	obj.y = y;
	
	obj.style.left = obj.x + 'px';
	obj.style.top  = obj.y + 'px';
}