var ns6 = (document.getElementById)? true:false;
var ie5 = false;
var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;

if (ie4)
{
  if (navigator.userAgent.indexOf('MSIE 4')<=0)
  {
    ie5 = true;
  }
  if (ns6)
  {
    ns6 = false;
  }
}

var frame = self;  // Frame where bubble will be visible
var bLayer = null; // Bubble layer
var bDelayid = 0;  // Bubble delay id
var mx = 0; // Mouse position variables
var my = 0; // var for save position parametres
var sballign;
var spx;
var spy;
var VISIBLE=false;

// Capture events ( for mouse position )
if ( (ns4) || (ie4) || (ns6))
{
  document.onmousemove = mouseMove
  if (ns4) document.captureEvents(Event.MOUSEMOVE)
}

function bubble(type,alig)
{
  if (!type) return;
  if (alig==1)
  {
    px=-3;
    py=-30;
  }
  else if (alig==-1)
  {
    px=-80;
    py=20;
  }
  else if (alig<-1)
  {
    px=-400;
    py=20;
  }
  else
  {
    px=-3;
    py=20;
  }

  openDelay=0;
  ballign="";
  bBackground="#FFFFC5";
  btext=type;

  if (openDelay != 0)
  {
    var bpar = "bubble("+type+")";
    bDelayid = setTimeout(bpar, openDelay);
  }
  else
  {
    sballign = ballign; // Save positions param.
    spx = px;
    spy = py;

    // Special for frame support, bLayer must be set
    if ( (ns4) || (ie4) || (ns6) )
    {
      if (ns4) bLayer = frame.document.bDiv
      if (ie4) bLayer = frame.bDiv.style
      if (ns6) bLayer = frame.document.getElementById("bDiv");
    }

htmlcode="<TABLE BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR=#000000><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="+bBackground+"><TR><TD VALIGN=TOP class=alt>"+btext+"</TD></TR></TABLE></TD></TR></TABLE>\n";

    if (ns4)
    {
      var lyr = frame.document.bDiv.document
      lyr.write(htmlcode)
      lyr.close()
    }
    else if (ie4)
    {
      frame.document.all["bDiv"].innerHTML = htmlcode
    }
    else if (ns6)
    {
      range = frame.document.createRange();
      range.setStartBefore(bLayer);
      domfrag = range.createContextualFragment(htmlcode);
      while (bLayer.hasChildNodes())
      {
        bLayer.removeChild(bLayer.lastChild);
      }
      bLayer.appendChild(domfrag);
    }
    // end Write HTML code to bubble
    // Set possition of the bubble
    setPosition();
    // Show bubble
    if (ns4) bLayer.visibility = "show";
    else if (ie4) bLayer.visibility = "visible";
    else if (ns6) bLayer.style.visibility = "visible";
    VISIBLE=true;
  } // end if else
  return true;
}

function bubbleClose()
{
  if ( bLayer != null)
  if      (ns4) bLayer.visibility = "hide";
  else if (ie4) bLayer.visibility = "hidden";
  else if (ns6) bLayer.style.visibility = "hidden";
  if (bDelayid > 0) clearTimeout(bDelayid);
  bDelayid = 0;
  VISIBLE=false;
  bLayer=null;
}

function setPosition()
{
  var xL, yL;

  if ( sballign == "ABSOLUTE")
  {
    xL = spx;
    yL = spy;
  }
  else
  {
    xL = mx + spx; // x position
    yL = my + spy; // y position
  }

  if ( (ns4) || (ie4) )
  {
    bLayer.left = xL;
    bLayer.top = yL;
  }
  else if (ns6)
  {
    bLayer.style.left = xL + "px";
    bLayer.style.top = yL+ "px";
  }
}

function mouseMove(e)
{
  if (VISIBLE) return;
  if ( (ns4) || (ns6) ) {mx=e.pageX; my=e.pageY;}
  if (ie5){ 
    if (document.documentElement && document.documentElement.scrollTop)
      {mx=event.x+frame.document.documentElement.scrollLeft; my=event.y+frame.document.documentElement.scrollTop; }
    else if(frame.document.body) {
      mx=event.x+frame.document.body.scrollLeft; my=event.y+frame.document.body.scrollTop;
    }  
  }    
  else if (ie4) {mx=event.x; my=event.y;}
  if (bLayer != null) setPosition(); // move bubble with mouse on link
}