		//params : elementId, startId, timeOut, image1, image2...
function animateImage(){
	
	if (arguments.length < 4)
		return;
	
	if (arguments[1] < (arguments.length - 4))
		arguments[1]++;
	else
		arguments[1] = 0;
	
	var images = '';
	images += "'" + arguments[3] +  "'";
	for (var i = 4; i < arguments.length; i++)
		images += ",'" + arguments[i] + "'";
	
	$('#' + arguments[0]).css('background-image', 'url(' + tpl_url + '/images/' + arguments[arguments[1] + 3] + ')');
	window.setTimeout('animateImage(\'' + arguments[0] + '\',\'' + arguments[1] + '\',\'' + arguments[2] + '\',' + images + ')', arguments[2]);

}

function animateMovement(id, css, number, timeOut){
	$('#' + id).animate(eval('({' + css +  ' : \'-=' + number + '\'})'), timeOut, function(){
		$('#' + id).animate(eval('({' + css +  ' : \'+=' + number + '\'})'), timeOut, function(){
			animateMovement(id,css, number,timeOut);
		});
	});
}

function makeStartableStopable(id, initTop, timeOut, css, movement, timeOut2){
	var obj =  $('#' + id);
	var top = 0 ;
	
	obj.hover(function(eventObject){
		top = obj.offset().top;
		obj.stop();
	}, function(eventObject){
		if (top > initTop)
			obj.animate({top : '-=' + (top - initTop)}, timeOut, function(){ obj.delay(timeOut); animateMovement(id, css, movement, timeOut2);});
		else
			obj.animate({top : '+=' + (initTop - top)}, timeOut, function(){ obj.delay(timeOut);  animateMovement(id, css, movement, timeOut2);});
	});
	
	
}

function startAfter(){
	animateImage('tofu-news', 0,400, 'tofu0.png', 'tofu1.png');
	makeStartableStopable('tofu-news', 0, 1000, 'top', 100, 4000);
	animateMovement('tofu-news', 'top', 100, 4000);	
}

$(window).load(function(){
	
	//Animation tofu : 
	animateImage('tofu-shoutbox', 0,400, 'tofu0.png', 'tofu1.png');
	makeStartableStopable('tofu-shoutbox', 0, 1000, 'top', 100, 4000);
	animateMovement('tofu-shoutbox', 'top', 100, 4000);	
	
	window.setTimeout('startAfter()', 3000);
	
	
});
