var timerID;

function Wait(item,seconds,callback)
{
	this.item 			= item;
	this.callback		= callback;
	this.seconds		= seconds;

	var self			= this;
	this.timer			= window.setTimeout(function(){self.Execute();},seconds);

	this.Execute = function Execute()
	{
		if(this != arguments.callee._oScope)
		{
			return arguments.callee.apply(arguments.callee._oScope, arguments);
		};

		eval(this.callback+"(this.item)");
		this.timer			= window.setTimeout(function(){self.Execute();},seconds);
	};

	this.Stop = function Stop()
	{
		clearTimeout(this.timer);
	};

	//setting reference
	this.Execute._oScope = this;
}

function scrollStart(obj, modifier, interval) {
	if (!interval)
	{
		interval = 1;
	}

	if (timerID)
	{
		scrollStop();
	}

	var vars=new Array(obj, modifier);
	timerID  = new Wait(vars, interval, "doScroll");
}

function doScroll(vars)
{

	var obj = vars[0];
	var modifier = vars[1];

	obj.scrollTop = obj.scrollTop + modifier;

	if (obj.scrollTop == 0)
	{
		obj.scrollTop = obj.scrollHeight;
	}
	else
	{
		if (obj.scrollTop == (obj.scrollHeight-300))
		{
			obj.scrollTop = 0;
		}
	}

}

function scrollStop() {

	timerID.Stop();
}
