/* Detect if the browser is IE or not. If it is not IE, we assume that the browser is NS. */
var IEbbl = document.all?true:false;

var IEbblBody = ietruebody();

function displayBubble(bblId,e)
{
  var musX = getMouseX(e);
  var musY = getMouseY(e);

  /* Absolute bottom position (including scroll value) of browser-window (viewport) */
  var wndwHeight = getWinHeight();
  document.getElementById(bblId).style.display = 'inline';

  var bblWidth = document.getElementById(bblId).offsetWidth;
  var bblHeight = document.getElementById(bblId).offsetHeight + 30;

  /////////////////////////////////////////// display div in center //////////////////////////////////////////////////////

  // First, determine how much the visitor has scrolled
  var scrolledX, scrolledY;
  if( self.pageYoffset ) {
    scrolledX = self.pageXoffset;
    scrolledY = self.pageYoffset;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    scrolledX = document.documentElement.scrollLeft;
    scrolledY = document.documentElement.scrollTop;
  } else if( document.body ) {
    scrolledX = document.body.scrollLeft;
    scrolledY = document.body.scrollTop;
  }

  // Next, determine the coordinates of the center of browser's window

  var centerX, centerY;
  if( self.innerHeight ) {
    centerX = self.innerWidth;
    centerY = self.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) {
    centerX = document.documentElement.clientWidth;
    centerY = document.documentElement.clientHeight;
  } else if( document.body ) {
    centerX = document.body.clientWidth;
    centerY = document.body.clientHeight;
  }
  
  // Xwidth is the width of the div, Yheight is the height of the
  // div passed as arguments to the function:
  var leftoffset = scrolledX + (centerX - bblWidth) / 2;
  var topoffset = scrolledY + (centerY - bblHeight) / 2;
  // the initial width and height of the div can be set in the
  // style sheet with display:none; divid is passed as an argument to // the function
  var o=document.getElementById(bblId);
  var r=o.style;
  r.position='absolute';
  r.top = topoffset + 'px';
  r.left = leftoffset + 'px';
//  r.display = "block";
}

function hideBubble(bblId)
{
  document.getElementById(bblId).style.display = 'none';
}

function getMouseX(e)
{
  var tempX = 0;

  if (IEbbl)
  {
    /* Get the x pos.s if browser is IE */
    tempX = event.clientX + IEbblBody.scrollLeft;
  }
  else
  {
    /* Get the x pos.s if browser is NS */
    tempX = e.pageX;
  }

  /* catch possible negative values in NS4 */
  if (tempX < 0)
  {
    tempX = 0;
  }

  return tempX;
}

function getMouseY(e)
{
  var tempY = 0;

  if (IEbbl)
  {
    /* Get the y pos.s if browser is IE */
    tempY = event.clientY + IEbblBody.scrollTop;
  }
  else
  {
    /* Get the y pos.s if browser is NS */
    tempY = e.pageY;
  }

  /* catch possible negative values in NS4 */
  if (tempY < 0)
  {
    tempY = 0;
  }

  return tempY;
}

/* Gives absolute bottom position (Including scroll value) of bottom edge of browser visible window (viewport) */
function getWinHeight()
{
  /* Default value for old browser if(parseInt(navigator.appVersion)<3) */
  /*	var winW = 630, winH = 460;	*/

  /* We can also use if(navigator.appName.indexOf("Microsoft")!=-1) for the following */
  if(IEbbl && !window.opera)	/* For IE */
  {
    // 		var winW = IEbblBody.offsetWidth + IEbblBody.scrollLeft;
    // 		var winH = (IEbblBody.offsetHeight - 1222) + IEbblBody.scrollTop;
    // 		var winW = IEbblBody.clientWidth + IEbblBody.scrollLeft;
    var winH = IEbblBody.clientHeight + IEbblBody.scrollTop;
  }
  else	/* For Netscape if(navigator.appName=="Netscape") */
  {
    // 		var winW = window.innerWidth + window.pageXOffset;
    var winH = window.innerHeight + window.pageYOffset;
  }

  return winH;
}

function ietruebody()
{
  return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}