// BubbleScript

var BubbleScript_mx=0; // absolute mouse x-position
var BubbleScript_my=0; // absolute mouse y-position
var BubbleScript_isBubbleEnabled=false;
var BubbleScript_isNetscape=false;
var BubbleScript_CloseTimer;
var BubbleScript_DivID;
var BubbleScript_DontClose = false; 

BubbleScript_Init();

// watch mouse
function BubbleScript_WatchMouse(e)
{
   if (BubbleScript_isNetscape)
   {
      BubbleScript_mx = e.pageX;
      BubbleScript_my = e.pageY; 
   }
   else
   {
      BubbleScript_mx = window.event.x + document.body.scrollLeft;
      BubbleScript_my = window.event.y + document.body.scrollTop; 
   }
}

// show bubble
function BubbleScript_ShowBubble(id, text, xoffset, yoffset)
{  
   BubbleScript_DontClose = false;
   clearInterval(BubbleScript_CloseTimer);

   if (BubbleScript_isNetscape)
   {  
      document.getElementById(id).style.left = BubbleScript_mx - xoffset; 
      document.getElementById(id).style.top  = BubbleScript_my - yoffset;
      document.getElementById(id).innerHTML = text;
      document.getElementById(id).style.visibility = "visible"; 
   }
   else
   {        
      document.getElementById(id).style.left = BubbleScript_mx - xoffset; 
      document.getElementById(id).style.top  = BubbleScript_my - yoffset;
      document.getElementById(id).innerHTML  = text;
      document.getElementById(id).style.visibility = "visible";
   }
}

function BubbleScript_EnterBubble()
{ 
   BubbleScript_DontClose = true;
}

function BubbleScript_ExitBubble()
{ 
   BubbleScript_DontClose = false;  
}

// hide bubble
function BubbleScript_FinishHideBubble()
{ 
   if(!BubbleScript_DontClose)
   {
      clearInterval(BubbleScript_CloseTimer);
   
      if (BubbleScript_isNetscape)
      { 
         document.getElementById(BubbleScript_DivID).style.visibility="hidden";
         document.getElementById(BubbleScript_DivID).innerHTML = ""; 
      }
      else
      {
         document.getElementById(BubbleScript_DivID).style.visibility = "hidden";
      }
   }    
}

function BubbleScript_HideBubble(id, msecs)
{ 
   if (BubbleScript_CloseTimer)
   { 
      clearInterval(BubbleScript_CloseTimer);
   }

   if (msecs > 0)
   {    
       BubbleScript_DivID = id;
       BubbleScript_CloseTimer = setInterval('BubbleScript_FinishHideBubble()', msecs);        
   }
   else
   { 
      if (BubbleScript_isNetscape)
      { 
         document.getElementById(id).style.visibility="hidden";
         document.getElementById(id).innerHTML = ""; 
      }
      else
      {
         document.getElementById(id).style.visibility = "hidden";
      }
    }
}

// init mouse tracking
function BubbleScript_Init()
{ 
   if (navigator.appName =="Netscape") 
   { 
      BubbleScript_isNetscape = true;
   } 
      
   BrowserVar = parseFloat(navigator.appVersion); 
   
   // no mouse tracing in old browser versions
   if (BrowserVar < 4)
   {
      return;
   }
   
   BubbleScript_isBubbleEnabled = true;

   if (BubbleScript_isNetscape)
   {
      document.captureEvents(Event.MOUSEMOVE);
   }

   document.onmousemove = BubbleScript_WatchMouse;
}