/// *****************************
/// *       RadTicker           *
/// *****************************


function RadTicker(id)
{
	this.ID = id;
	this.Container = '';
	this.CurrentChar = 0;
	this.CurrentLine = 0;
	this.Lines = new Array();
	this.Links = new Array();
	this.NewCharDelay = 50;
	this.NewLineDelay = 70;
	this.LineLoop = true;
	this.TimeoutID = 0;
	this.OnEnd = function () {};
	
	// Efficiency changes GJB 14/06/04
	this.ContainerElement = null;
}

RadTicker.prototype.Start = function()
{
	this.CurrentLine = Math.floor(Math.random()*this.Lines.length);
	this.PrintNextChar(true);	
}

RadTicker.prototype.PrintNextChar = function(clearLine)
{
	var overflowFlag = false;
	
	
	// Changed to get the actual element from document only once, and only if needed - GJB 14/06/04
	var con = this.ContainerElement;

	if(con == null) {
		con = document.getElementById(this.Container);
		this.ContainerElement = con;
	}
	
	if (clearLine)
	{
		if (this.StatusBar)
			window.status = '';
		else
			con.innerHTML = '';

		if (this.Lines.length == this.Links.length)
			g_CurrentLink = this.Links[this.CurrentLine];
	}
	
	this.CurrentChar = this.CurrentChar + 1;
	
	if (this.CurrentChar > this.Lines[this.CurrentLine].length)
	{
		if (this.OnEnd)
		{
			this.OnEnd();
		}
		
		this.CurrentLine = this.CurrentLine + 1;
		this.CurrentChar = 0;
		if (this.CurrentLine > this.Lines.length - 1)
		{
			overflowFlag = true;
			this.CurrentLine = 0;
		}
		
		if (overflowFlag && this.LineLoop == false)
			return;
			
		eval(this.ID + " = " + "this;");
		window.setTimeout( this.ID + ".PrintNextChar(true)", this.NewLineDelay);
		return;
	}
	
	if (this.StatusBar)
		window.status += this.Lines[this.CurrentLine].charAt(this.CurrentChar-1);
	else
		con.innerHTML += this.Lines[this.CurrentLine].charAt(this.CurrentChar-1);
	
	eval(this.ID + " = " + "this;");
	window.setTimeout( this.ID + ".PrintNextChar(false)", this.NewCharDelay);
}
