function ietruebody(){ // retourne le bon corps...
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
	}
function BoxeDefilante(bullename) { 

	this.xOffset=6;
	this.yOffset=5;
	
	this.affiche = false; // La variable i nous dit si le bloc est visible ou non
	this.w3c=document.getElementById && !document.all;
	this.ie=document.all;
	
	if (this.ie||this.w3c) {
		this.laBulle=document.getElementById(bullename);
	}
	
	
	BoxeDefilante.prototype.showTooltip = function()
	{
		if (this.w3c||this.ie){
			this.laBulle.style.visibility = "visible"; // Si il est cachée (la verif n'est qu'une securité) on le rend visible.
			this.affiche =true;
		}
	};
	
	BoxeDefilante.prototype.hideTooltip = function()
	{
		if (this.w3c||this.ie){
		this.affiche = false;
		this.laBulle.style.visibility="hidden"; // avoid the IE6 cache optimisation with hidden blocks
		}
	};
	
}

var bullename;	
function loadSelection(id,bn,root)
{	
	bullename =bn;
	new Ajax.Updater(
			bullename,
			root+'/ajax.php',
			{
				method: 'post',
				parameters: {page: "boxe_defilante", product_id:id},
				onLoading: function(){  
				      $(bullename).innerHTML = '<img src="template/images/ajax-loader.gif">'; 
				}
			}
		);
}

document.onmousemove = deplacer;
function deplacer(e) {
		if($(bullename) != null)
		{
			w3c=document.getElementById && !document.all;	
			ie=document.all;
			xOffset=6;
			yOffset=5;
			var curX = (w3c) ? e.pageX : event.x + ietruebody().scrollLeft;
			var curY = (w3c) ? e.pageY : event.y + ietruebody().scrollTop;
			
			var winwidth = ie && !window.opera ? ietruebody().clientWidth : window.innerWidth - 20;
			var winheight = ie && !window.opera ? ietruebody().clientHeight : window.innerHeight - 20;
			
			var rightedge = ie && !window.opera ? winwidth - event.clientX - xOffset : winwidth - e.clientX - xOffset;
			var bottomedge = ie && !window.opera ? winheight - event.clientY - yOffset : winheight - e.clientY - yOffset;
			
			var leftedge = (xOffset < 0) ? xOffset*(-1) : -1000;
			
			// modifier la largeur de l'objet s'il est trop grand...
			if($(bullename).offsetWidth > winwidth / 3){
				$(bullename).style.width = winwidth / 3;
			}
	
			// si la largeur horizontale n'est pas assez grande pour l'info bulle
			if(rightedge < $(bullename).offsetWidth){
				// bouge la position horizontale de sa largeur à gauche
				$(bullename).style.left = curX - $(bullename).offsetWidth + "px";
			} else {
				if(curX < leftedge){
					$(bullename).style.left = "5px";
				} else{
					// la position horizontale de la souris
					$(bullename).style.left = curX + xOffset + "px";
				}
			}
			
			// même chose avec la verticale
			if(bottomedge < $(bullename).offsetHeight){
				$(bullename).style.top = curY - $(bullename).offsetHeight - yOffset + "px";
			} else {
				$(bullename).style.top = curY + yOffset + "px";
			}
		}
	};
	
