var bulle_visible = false;

function bulle ( msg , size , obj )  {
	
	if (bulle_visible == false) {
		
		// la bulle existe ?
		var bullo = document.getElementById('tip');
		
		// cree la bulle si elle n'existe pas
		if (!bullo) {
			
			if (!size) size = 150;
	
			bullo = document.createElement('div');
			bullo.id = 'tip';
			//bulle.className = 'tip';
			bullo.style.zIndex = 10;
	
			bullo.style.position = 'absolute';
			bullo.style.visiblity = 'hidden';
			bullo.style.overflow = 'hidden';
	
			bullo.style.width = size + 'px';
			bullo.style.margin = '5 5 5 10';
			bullo.style.padding = '5 8 5 5';
			bullo.style.color = '#000000';
			bullo.style.border = '1px solid #000';
			//bulle_bu.style.cursor = 'help';
			bullo.style.background = '#FFFFE1';
			bullo.style.fontSize = '10pt';
			bullo.style.fontfamily = 'verdana,arial';
			bullo.style.textalign = 'left';
	
			// crée l'objet
			document.body.appendChild(bullo);
	
			// active le tracking de la bulle
			document.onmousemove = bulle_move;
			//document.onmouseout  = bulle_hide;
			//bulle.onmouseout  = bulle_hide;
			
		}
		
		if ( obj ) msg = document.getElementById(msg).innerHTML;
		
		// show if there's somethign to show
		if ( msg != '' ) {
			bullo.innerHTML = msg;
			bullo.style.visibility = "visible";
			bulle_visible = true;
			//xbulle_move();
		}
	}
}


function bulle_move(e) {
	
	if (bulle_visible) {
	
		var bulle = document.getElementById("tip");
		
		if (bulle.clientHeight) bh = bulle.clientHeight;
		else if(bulle.offsetHeight) bh = bulle.offsetHeight;

		if (bulle.clientWidth) bw = bulle.clientWidth;
		else if(bulle.offsetWidth) bw = bulle.offsetWidth;

		if ( typeof( window.innerWidth ) == 'number' ) { // NON IE

			x = e.pageX;
			y = e.pageY;

			w = window.innerWidth;
			h = window.innerHeight;
			
			l = 0;
			t = 0;
			
		} else { // IE

			x = event.x;
			y = event.y;

			w = document.body.clientWidth;
			h = document.body.clientHeight;
			
			l = document.body.scrollLeft;
			t = document.body.scrollTop;
		}
		
		if (y > (h/2)) y -= (bh + 20);
		
		decal_x = 5;
		decal_y = 5;

		bulle.style.left = x - (bw/2) + 'px'; //+ decal_x + l + px; 
		bulle.style.top =  y + decal_y + t + 'px'; //- (bh/2) + px; 

	}
}

function bulle_hide() {
	
	if (bulle_visible == true) {
		
		var bullo = document.getElementById("tip");
		if (bullo) {
			bullo.style.visibility = "hidden";
			bullo.style.left = '-1000px';
			bullo.style.top = '-1000px';
			bulle_visible = false;
			//document.onmousemove = null;
		}
	}
}

function bullespan ( id ) {
	
	var txt = document.getElementById(id).innerHTML;
	//alert(txt);
	bulle( txt, 500);
}
