var scrollerwidth = 160;
var scrollerheight = 210;
var scrollerbg = '';
var scrollerspeed = 1.3;
var sizeup = 0;

var tickerElm = null;
var msg = '';
var theTop = 0;
var resumescrollerspeed = scrollerspeed;

var speedswitch = 0;

function marquee()
{
	tickerElm.style.top = scrollerheight + "px";
	tickerElm.innerHTML = msg;
	sizeup = tickerElm.offsetHeight - 150;
	slide();
}

function slide()
{
	if (parseInt(tickerElm.style.top) >= (sizeup + 120) * (-1))
	{
		if (parseInt(tickerElm.style.top) >= 0)
		{
			if (speedswitch != 1)
			{
				scrollerspeed = 1.3;
				speedswitch = 1;
			}
		}
		else
		{
			if (speedswitch != 0)
			{
				scrollerspeed = 2.2;
				speedswitch = 0;
			}
		}
		theTop = parseInt(tickerElm.style.top) - scrollerspeed;
		tickerElm.style.top = theTop + "px";
		window.setTimeout(slide,100);
	}
	else 
	{
		scrollerspeed = 1.3;
		tickerElm.style.top = scrollerheight + "px";
		slide();
	}
}

$(function(){
	$('#newspanel').mouseover(function(){
		scrollerspeed = 0;
	}).mouseout(function(){
		scrollerspeed = resumescrollerspeed;
	});
	
	tickerElm = $('#newspanel div:first').get(0);
	msg = $('#newspanel div:first').html();
	marquee();
});
