/* 

	Page Ticker

*/

function Ticker()
{
}

Ticker.lines 				= new Array();
Ticker.line					= 0;

// the line status
Ticker.current_text	= '';
Ticker.flip					= 0;
Ticker.current_pos	= 0;

function tickerClick()
{
	window.location = Ticker.current_url;
}

function tickerStart()
{
	Ticker.line = Math.floor(Math.random() *  1000) % Ticker.lines.length;
	tickerTick();
}

function tickerTick()
{			
	// get the line of the ticker
	var line = Ticker.lines[Ticker.line];
	var te   = $('tickText');
	if (te == null)
		return;
	
	// allocate line
	var full = line.text; 
	var text = full.substr(0, Ticker.current_pos);
	
	// speciality
	Ticker.flip++;
	if (Ticker.flip % 2 == 1)
	{
		text = text + '';
		Ticker.current_pos++;
	}
	else if (Ticker.flip % 2 == 0)
	{
		text = text;
	}
	
	// update the document text
	te.innerHTML = '<a href="' + line.page + '" class="black" onclick="tickerClick();" >' + text + '</a>';
	
	// update position
	// alert(Ticker.current_pos + "  " + text.length);
	if (Ticker.current_pos > full.length)
	{
		setTimeout('tickerTick()', 4000);
		Ticker.current_pos = 1;
		Ticker.line = (++Ticker.line % Ticker.lines.length);
	}
	else
	{
		Ticker.current_url = line.page;
		setTimeout('tickerTick()', 30);
	}
}