var nextBigNews = false;
var swapOk = true;
var timerNews;
var curBigNews = 0;
var cptBigNews = 0;
var nbNews = 0;

function loadNews(idBigNews)
{
	clearTimeout(timerNews);

	if(swapOk && curBigNews != idBigNews)
	{
		swapOk = false;
		nextBigNews = false;
		$($('#smallNews'+curBigNews).children("a:first")).removeClass('hover');
		$('#bigNews'+curBigNews).fadeOut('normal', function(){$('#bigNews'+idBigNews).fadeIn('normal', function(){swapOk = true; checkBigNews(idBigNews);});});	
		$($('#smallNews'+idBigNews).children("a:first")).addClass('hover');	
		curBigNews = idBigNews;
	}
	else
	{
		nextBigNews = idBigNews;
	}
}

function checkBigNews(idNews)
{
	if(nextBigNews != false && idNews != nextBigNews)
	{
		loadNews(nextBigNews);
	}
}

function swapNews(numNews)
{
	if(numNews != 0)
		nbNews = numNews-1;
	if(cptBigNews >= nbNews)
	{
		cptBigNews = 0;
	}
	else
	{
		++cptBigNews;
	}
	
	loadNews(cptBigNews);
	timerNews = setTimeout('swapNews(0)', 5000);
}

function restoreNews()
{
	cptBigNews = 0;
	timerNews = setTimeout('swapNews(0)', 5000);
}

/*************** PS NEWS *******************/
var nextBigPSNews = false;
var swapPSOk = true;
var timerPSNews;
var curBigPSNews = 0;
var cptBigPSNews = 0;
var nbPSNews = 0;

function loadPSNews(idBigPSNews)
{
	clearTimeout(timerPSNews);

	if(swapPSOk && curBigPSNews != idBigPSNews)
	{
		swapPSOk = false;
		nextBigPSNews = false;
		$($('#smallPSNews'+curBigPSNews).children("a:first")).removeClass('hover');
		$('#bigPSNews'+curBigPSNews).fadeOut('normal', function(){$('#bigPSNews'+idBigPSNews).fadeIn('normal', function(){swapPSOk = true; checkBigPSNews(idBigPSNews);});});	
		$($('#smallPSNews'+idBigPSNews).children("a:first")).addClass('hover');	
		curBigPSNews = idBigPSNews;
	}
	else
	{
		nextBigPSNews = idBigPSNews;
	}
}

function checkBigPSNews(idPSNews)
{
	if(nextBigPSNews != false && idPSNews != nextBigPSNews)
	{
		loadPSNews(nextBigPSNews);
	}
}

function swapPSNews(numPSNews)
{
	if(numPSNews != 0)
		nbPSNews = numPSNews-1;
	if(cptBigPSNews >= nbPSNews)
	{
		cptBigPSNews = 0;
	}
	else
	{
		++cptBigPSNews;
	}
	
	loadPSNews(cptBigPSNews);
	timerPSNews = setTimeout('swapPSNews(0)', 5000);
}

function restorePSNews()
{
	cptBigPSNews = 0;
	timerPSNews = setTimeout('swapPSNews(0)', 5000);
}