$.easing.bouncy = function (x, t, b, c, d) { 
	var s = 1.70158;
	if ((t/=d/2) < 1) 
		return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
} 
	 
$.tools.tooltip.addEffect("bouncy",
	function(done) { 
		this.getTip().animate({top: '+=15'}, 500, 'bouncy', done).show(); 
	},
	function(done) { 
		this.getTip().animate({top: '-=15'}, 500, 'bouncy', function()  { 
			$(this).hide(); 
			done.call(); 
		}); 
	} 
);
	

$(document).ready(function() {

	$.get('modules/twitter.php',function(data) {
		var separ = data.indexOf('_',0);
		var nom = data.substr(0,separ);
		var tweet = data.substring(separ+1,data.length);
		
		if( nom == 'Alessandro' ) {
			$('#user-tweet').children('h4').html('<img src="graphix/fennec-small.png" alt="Alessandro Stigliani" /> Alessandro');
		}
		else {
			$('#user-tweet').children('h4').html('<img src="graphix/hibou-small.png" alt="Yassine Khial" style="margin-left: 16px" /> Yassine');
		}
		
		$('#twitter').children('p').html(tweet);
	});

	$("#tout-tweets").tooltip({
		tip: '#voir',
		effect: 'bouncy'
	});
	
	$(".suiv").click(function() {
		$this = $(this).parent().parent();
		$this.fadeOut(function() {
			$('.news').eq($this.index()+1).fadeIn();
		});
	});
	
	$(".prec").click(function() {
		$this = $(this).parent().parent();
		$this.fadeOut(function() {
			$('.news').eq($this.index()-1).fadeIn();
		});
	});
	
});
