var tableTop_start;
var skip_waiting;

function redirect(url){
	location = url;
}

function closeWin(){
	window.close();
}

function openWin(url,name,param){
	newWin = window.open (url,name,param);
}				

function ltrim ( s ){
	return s.replace( /^\s*/, "" )
}
function rtrim ( s ){
	return s.replace( /\s*$/, "" );
}
function trim ( s ){
	return rtrim(ltrim(s));
}

function changeItemStyle(me, bgColor, fgColor, level)
{
	if (bgColor)
		me.style.backgroundColor = bgColor;
	if (fgColor)
		me.style.color = fgColor;
}

function scrollOneNews()
{	
	var tableTop = document.getElementById("newsTbl").offsetTop;
	if ( tableTop%60 != 0 )
	{
		document.getElementById("newsTbl").style.top = tableTop-1;
		setTimeout( "scrollOneNews()", 40 );
	}
}

function scrollNews()
{
	tableTop_start = document.getElementById("newsTbl").offsetTop;
	setTimeout ( "start_scrolling()", 6000 );
}

function start_scrolling()
{
	if ( document.getElementById("newsTbl") )
	{
		table = document.getElementById("newsTbl");
		numNews = table.rows.length;
		
		table.style.top = table.offsetTop-1;
		if ( table.offsetTop - tableTop_start < numNews*(-60) )
			document.getElementById("newsTbl").style.top = tableTop_start + 60;
		
		if ((((tableTop_start - table.offsetTop)/60)|0)==numNews)
			skip_waiting = true;
		else
			skip_waiting = false;
		
		if (skip_waiting==true)
		{
			start_scrolling();
		}
		else
		{
			scrollOneNews();
			setTimeout ( "start_scrolling()", 6000 );
		}
	}
}

