//Codes pour affichage infobulle custom

/*
	affichage d'une infobulle custom
	Argument(s): event, this, position d'affichage (right, left)
	Retourne: rien
	
	code HTML pour l'appel:
	
	<div onmouseover="javascript: showInfo(event, this, 'left');" onmouseout="javascript: hideInfo(this);">
	   <!--contenu et style à votre goût-->                      
   </div>
   <div style="display:none; position:absolute; z-index:99; background-color:#fafafa; border:solid 1px #000000; padding:5px">
      <!--contenu de l'infobulle et reste du style à votre goût-->
   </div>	
*/
   
var getThisTag;
var c = 0;
var st;
var stIsOn = false;
var ut;
var utIsOn = false;

function showInfo(e, getThis, pos)
{
   var cursor = getPosition(e);
   
   if (utIsOn)
   {
      clearTimeout(st);
      clearTimeout(ut);
      unsetOpacity();
      showInfo(e, getThis, pos);
   }
   else
   {  
      if (navigator.appName == "Microsoft Internet Explorer")
      {
         getThisTag = getThis.nextSibling;
      }         
      else
      {
         getThisTag = getThis.nextSibling.nextSibling;
      }   
      getThisTag.style.opacity = c;
      getThisTag.style.filter = 'alpha(opacity='+ c +')';
      getThisTag.style.display = 'block';
      if (pos == "right")
      {
         getThisTag.style.left = 5 + cursor.x + 'px';
         getThisTag.style.top = cursor.y + 'px';
      }
      else if (pos == "left")
      {
         var divWidth = getThisTag.clientWidth;
         getThisTag.style.left = cursor.x - divWidth - 5 + 'px';
         getThisTag.style.top = cursor.y + 'px';
      }
      stIsOn = true;
      setOpacity();
   }
}

function hideInfo(getThis)
{
   if (stIsOn)
   {
      clearTimeout(st);
      clearTimeout(ut);
      stIsOn = false;
      hideInfo(getThis);
   }
   else
   {
      if (navigator.appName == "Microsoft Internet Explorer")
      {
         getThisTag = getThis.nextSibling;
      }         
      else
      {
         getThisTag = getThis.nextSibling.nextSibling;
      }
      getThisTag.style.opacity = 1;
      getThisTag.style.filter = 'alpha(opacity=100)';
      utIsOn = true;
      ut = setTimeout("unsetOpacity()",1000);
   }
}

function setOpacity()
{   
   if (stIsOn)
   {
      if (c <= 10)
      {
         getThisTag.style.opacity = c/10;
         getThisTag.style.filter = 'alpha(opacity=' + c*10 + ')';
         c = c + 1;
         st = setTimeout("setOpacity()",10);
      }
      else
      {
         stIsOn = false;
         c = 0;
         return;
      }
   }
   else
   {
      stIsOn = false;
      c = 0;
      return;
   }
}

function unsetOpacity()
{ 
   c = 0; 
   getThisTag.style.opacity = c;
   getThisTag.style.filter = 'alpha(opacity='+ c +')';
   getThisTag.style.display = 'none';
   utIsOn = false;
}

function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}
