var bubulle_aff = "";

function checkbubulle(id)
{
	$('#'+id).slideUp('fast');
	
	if(bubulle_aff != '' && bubulle_aff != id) {$('#'+bubulle_aff).slideUp('fast');}
	bubulle_aff = "";
}

$(document).ready(function()
{
	$('.bubulle2').mouseover(function()
	{
		var id = "bubulle_"+$(this).attr('id');
		
		if(id != bubulle_aff)
		{
			if(bubulle_aff != "")
			{
				//alert(bubulle_aff);
				$('#'+bubulle_aff).slideUp('fast');
			}
			
			bubulle_aff = id;
			$('#'+id).css("display", "block");
			
			$(this).mousemove(function(e)
			{
				var long = $('#'+id).width();
				var long2 = long/2;
				
				$('#'+id).css("top", (e.pageY-60)+"px");
				$('#'+id).css("left", (e.pageX-long2)+"px");
			});
			
			setTimeout(function() {checkbubulle(id);}, 2500);
		}
	});
});


//était dans le global.js, provoquait des erreurs dans les thickbox
//Aucune idée si encore utile

//bubulles
$(function () {
     $('.bubbleInfo').each(function () {
         var distance = -30;
         var time = 250;
         var hideDelay = 500;

         var hideDelayTimer = null;

         var beingShown = false;
         var shown = false;
         var trigger = $('.trigger', this);
         var info = $('.popup', this).css('opacity', 0);


         $([trigger.get(0), info.get(0)]).mouseover(function () {
             if (hideDelayTimer) clearTimeout(hideDelayTimer);
             if (beingShown || shown) {
                 // don't trigger the animation again
                 return;
             } else {
                 // reset position of info box
                 beingShown = true;

                 info.css({
                     top: -90,
                     left: -33,
                     display: 'block'
                 }).animate({
                     top: '-=' + distance + 'px',
                     opacity: 1
                 }, time, 'swing', function() {
                     beingShown = false;
                     shown = true;
                 });
             }

             return false;
         }).mouseout(function () {
             if (hideDelayTimer) clearTimeout(hideDelayTimer);
             hideDelayTimer = setTimeout(function () {
                 hideDelayTimer = null;
                 info.animate({
                     top: '-=' + distance + 'px',
                     opacity: 0
                 }, time, 'swing', function () {
                     shown = false;
                     info.css('display', 'none');
                 });

             }, hideDelay);

             return false;
         });
     });
 });
