$(document).ready(function(){
	LastfmUpdate();
	$('#lastfm a').live('click', function(){
		window.open($(this).attr('href'));
		return false;
	});
});
function LastfmUpdate() {
	lastfm_old_data = $('#lastfm').html();
	$('#lastfm').slideUp('normal', function(){
		$(this).html('<img src="public/images/ajax-loader.gif" alt="Chargement..." /><br />Chargement du dernier<br />titre écouté en cours...').slideDown();
	});
	$.ajax({
		type: 'GET',
		url: 'modules/live/lastfm.php',
		timeout: 2000,
		success: function(data) {
			$('#lastfm').slideUp('normal', function(){
				if(data != '') {
					$(this).html(data).slideDown();
				}
				window.setTimeout(LastfmUpdate, 120000);
			});
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) {
			$('#lastfm').slideUp('normal', function(){
				if(lastfm_old_data != '') $(this).html(lastfm_old_data).slideDown();
				window.setTimeout(LastfmUpdate, 2000);
			});
		}
	});
}