var curPos = 0;
var count = 0;
var oldid = 's1';
var newtxt = '';
var positions = new Array();
var texts = new Array();
var curBanner = 1;

var timeout = 5000;
var movetimeout = 0.5;
var movespeed = 15;

function startFlash(i, text)
{
	document.getElementById('s1').style.fontWeight = 'bold';
	count = i;
	
	document.getElementById('btext').innerHTML = text;
	
	t1 = window.setTimeout('timerTick()', timeout);
	
}

function timerTick()
{
	if(curBanner < count)
	{
		curBanner++;
		moveFlash(positions[curBanner], 's' + curBanner, texts[curBanner]);
	}
	else if(curBanner == count)
	{
		curBanner = 1;
		moveFlash(positions[curBanner], 's' + curBanner, texts[curBanner]);
	}
}

function moveFlash(i, id, text)
{
	document.getElementById('btnHolder').style.display = 'block';

	document.getElementById('btext').innerHTML = "";
	newtxt = text;
	
	if(curPos > i)
	{
		window.clearTimeout(t1);
		movedown(i, text);
	}
	else
	{
		window.clearTimeout(t1);
		moveup(i, text);
	}
		
	document.getElementById(id).style.fontWeight = 'bold';
	
	document.getElementById(oldid).style.fontWeight = 'normal';
	
	oldid = id;
}

function movedown(i){
	
	if(curPos > i)
	{
		curPos-=movespeed;
		document.getElementById('newsflash').style.backgroundPosition = 'right ' + curPos + 'px';
		movetmr = window.setTimeout('movedown('+i+')', movetimeout);
	}
	else
	{
		curPos = i;
		document.getElementById('newsflash').style.backgroundPosition = 'right ' + i + 'px';
		document.getElementById('btext').innerHTML = newtxt;
		window.clearTimeout(t1);
		t1 = window.setTimeout('timerTick()', timeout);
		window.clearTimeout(movetmr);
	}
	
}

function moveup(i){
	
	if(curPos < i)
	{
		curPos+=movespeed;
		document.getElementById('newsflash').style.backgroundPosition = 'right ' + curPos + 'px';
		movetmr = window.setTimeout('moveup('+i+')', movetimeout);
	}
	else
	{
		curPos = i;
		document.getElementById('newsflash').style.backgroundPosition = 'right ' + i + 'px';
		document.getElementById('btext').innerHTML = newtxt;
		window.clearTimeout(t1);
		t1 = window.setTimeout('timerTick()', timeout);
		window.clearTimeout(movetmr);
	}
	
}
