var actus = new Array();
var currentActu = 0;

function updateActu()
{
	// We loop through each news
	if (currentActu > (actus.length - 1))
		currentActu = 0;

	$('#news p a.actu').fadeOut('normal', function() {  
		// '<strong>' + actus[currentActu].date + ':</strong>&nbsp;&nbsp;' +
		$(this).html(actus[currentActu].title);
		$(this).attr('href', actus[currentActu].link);
		$(this).attr('title', actus[currentActu].title);
		currentActu++;
		$(this).fadeIn();
	});
	setTimeout("updateActu();", 5000);
}

// get RSS news from Warpdesign.fr blog
function getWarpdesignRSS()
{
	$.ajax({
		url: '/warpRSS.php',
		dataType: "json",
		success: function(data)
		{
			actus = data;
			updateActu();
		},
		error: function()
		{
			$('#news p a.actu').html('Twitter (encore) inaccessible...');
		}
	});
}

function getWarpdesignTwitter()
{
	$.ajax({
		url: '/warpTwitter.php',
		dataType: "json",
		success: function(data)
		{
			if (data[0] == 'success')
			{
				actus = data;
				updateActu();
			}
			else
				$('#news p a.actu').html('Twitter (encore) inaccessible...');
		},
		error: function()
		{
			$('#news p a.actu').html('Twitter (encore) inaccessible...');
		}
	});
}

$(document).ready(function()
{
	getWarpdesignTwitter();
	//getWarpdesignRSS();
});