var tr;

function TextRender(parent, container, direction)
{
	this.parent	= document.getElementById(parent);
	this.container = document.getElementById(container);
	this.width = this.container.clientWidth;
	this.height = this.container.clientHeight;
	this.direction = direction;
}

TextRender.prototype.TimerTick = function()
{
	if (this.direction == "up")
	{
		// If the container is above the top line
		if ((this.container.offsetTop - 10) * -1 > (this.height + 10))
		{
			this.container.style.top = this.parent.clientHeight + 10 + "px";
		}
		else
		{
			// Move the container up by 1px;
			this.container.style.top = (this.container.offsetTop - 1) + "px";			
		}
	}
	else if (this.direction == "down")
	{
		// If the container is below the bottom line
		if ((this.parent.clientHeight + 10) < (this.container.offsetTop))
		{
			this.container.style.top = (this.height + 10) * -1 + "px";
		}
		else
		{
			// Move the container down by 1px;
			this.container.style.top = (this.container.offsetTop + 1) + "px";			
		}
	}
	else if (this.direction == "left")
	{
		if ((this.container.offsetLeft + this.container.clientWidth) < this.parent.offsetLeft)
		{
			this.container.style.left = this.parent.clientWidth + 10 + "px";
		}
		else
		{
			//Move left one pixel
			this.container.style.left = this.container.offsetLeft -1 + "px";
		}
	}
	else if (this.direction == "right")
	{
		if (this.container.offsetLeft > (this.parent.offsetLeft + this.parent.clientWidth))
		{
			this.container.style.left = (this.container.clientWidth + 10) * -1 + "px";
		}
		else
		{
			//Move right one pixel
			this.container.style.left = this.container.offsetLeft +1 + "px";
		}
	}
	else
	{
		return;
	}
}