// Fonctions exécutées au chargement de la page
$(function() {
	initInfobulles();
});

// Charge les infobulles
function initInfobulles() { 
	// Pour chaque élément avec un attribut title, on gère le survol souris
	$('*[title]').bind('mouseover', function() { 	
		var texte = $(this).attr('title'); // Récupère l'attribut
		var position = $(this).offset();
		$(this).attr('title', ''); // Enlève le title pour éviter les infobulles système (noir sur fond jaune)
		var infobulle = $('<div></div>')
			.addClass('infobulle')
			.html(texte)
			.appendTo('body')
			.css('left', position.left + $(this).outerWidth())
			.css('top', position.top)
			.hide();
			var width = infobulle.outerWidth();
			var newWidth = Math.round(width/2); 
			infobulle
				.css('width', newWidth)
				.fadeIn('normal')
				.animate({width: width}, 'normal');

		$(this).bind('mouseout', function() {
			infobulle.fadeOut('fast', function() { 
				$(this).remove(); 
			});
			$(this).attr('title', texte);
		});
	});
}

function cacheMontre( div ) { 
   var element = document.getElementById(div);
   if ( element.style.display=="block") element.style.display="none"; 
   else element.style.display="block";
}


function cacheMontre2( div ) { 
   var element = document.getElementById(div);
   if ( element.style.display=="block") element.style.display="none"; 
   else element.style.display="block";
}

