
var activeShort;
var timeout;
var n;
var speed = 5000;

function initShortNews(k)
{
	n = k;
	activeShort = 0;
}

function mouseOverNextButton()
{
	document.getElementById('next_button').src = 'images/button04.gif';
}

function mouseOutNextButton()
{
	document.getElementById('next_button').src = 'images/button02.gif';
}

function clickNextButton()
{
	var activeShortOld = activeShort;
	activeShort++;
	if (activeShort >= n) activeShort = 0;	
	switchHeadline("shortnews"+activeShortOld, "shortnews"+activeShort);
}

function mouseOverPrevButton()
{
	document.getElementById('prev_button').src = 'images/button03.gif';
}

function mouseOutPrevButton()
{
	document.getElementById('prev_button').src = 'images/button01.gif';
}

function clickPrevButton()
{
	var activeShortOld = activeShort;
	activeShort--;
	if (activeShort < 0) activeShort = n-1;
	switchHeadline("shortnews"+activeShortOld, "shortnews"+activeShort);
}

function mouseOverShortNews()
{
	clearTimeout(timeout);
	timeout = null;
}

function mouseOutShortNews()
{
	timeout = setTimeout("automaticCycle("+n+")", speed);
}

function changeOpacity(id, opacity)
{
	var obj = document.getElementById(id);
	obj.style.opacity = opacity/100;
	obj.style.filter = "alpha(opacity=" + opacity + ")"; 
}

function switchHeadline(fromID, toID)
{
	var i;
	var s = 5;
	var a = document.getElementById(fromID);
	var b = document.getElementById(toID);
	for (i=0; i<=100; i++){
		setTimeout("changeOpacity('"+fromID+"', 100-"+i+")", i*s);
		setTimeout("changeOpacity('"+toID+"', "+i+")", i*s);
	}
}

function automaticCycle()
{	
	var activeShortOld = activeShort;
	activeShort++;
	if (activeShort >= n) activeShort = 0;
	switchHeadline("shortnews"+activeShortOld, "shortnews"+activeShort);
	timeout = setTimeout("automaticCycle("+n+")", speed);
}

