
function menuFindPosX(obj)
{
   var curleft = 0;
   if (obj.offsetParent) 
   {
      while (obj.offsetParent) 
      {
         curleft += obj.offsetLeft
         obj = obj.offsetParent;
      }
   }
   else if(obj.x)
   {   
      curleft += obj.x;
   }
   return curleft;
}

function menuFindPosY(obj) 
{
   var curtop = 0;
   if (obj.offsetParent) 
   {
      while (obj.offsetParent) 
      {
         curtop += obj.offsetTop
         obj = obj.offsetParent;
      }
   }
   else if(obj.y)
   {
      curtop += obj.y;
   }
   return curtop;
}         


function pause(millis) 
{
   var date = new Date();
   var curDate = null;

   do { curDate = new Date(); } 
   while(curDate-date < millis) 
} 


// Affiche un élément de menu
function showMenu(menuId, parentId, posX, posY, fade)
{
   it = document.getElementById(menuId);
   
   if(it.style.visibility == 'visible') return;                
   
   if ((it.style.top == '' || it.style.top == 0) 
   && (it.style.left == '' || it.style.left == 0))
   {
      // need to fixate default size (MSIE problem)
      it.style.width = it.offsetWidth + 'px';
      it.style.height = it.offsetHeight + 'px';
      
      img = document.getElementById(parentId); 
      
      // if tooltip is too wide, shift left to be within parent 
      if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
      if (posX < 0 ) posX = -10; 
      
      x = menuFindPosX(img) + posX;
      
      y = menuFindPosY(img) + posY;
      
      it.style.top = y + 'px';
      it.style.left = x + 'px';
   }
   
  
   
   /* Si il faut afficher en fondu, */
   if(fade)
   {
      it.style['opacity'] = 0.0;
      it.style.visibility = 'visible';
      for(i=1; i<10 ; i++)
      {
         setTimeout('setOpacity(\''+menuId+'\','+i*10+')', i*30);
         
      } 
   }
   else
   {
      it.style.visibility = 'visible';
   }
   
 //  alert(it.style.left + ' - '+ it.style.top);
}

// Masque un élément de menu
function hideMenu(menuId)
{
it = document.getElementById(menuId);


it.style.visibility = 'hidden';
}
         