//
// Bubblehelp infoboxes, (C) 2002 Klaus Knopper <infobox@knopper.net>
//
var ib_IWIDTH=250  // Tip box width
var ib_ns4         // Are we using Netscape4?
var ib_ie4         // Are we using Internet Explorer Version 4?
var ib_ie5         // Are we using Internet Explorer Version 5?
var ib_kon         // Are we using KDE Konqueror?
var ib_x,ib_y,ib_winW,ib_winH  // Current help position and main window size
var ib_idiv=null   // Pointer to infodiv container
var ib_px="px"     // position suffix with "px" in some cases

function ib_nsfix(){setTimeout("window.onresize = ib_rebrowse", 2000);} // ###

function ib_rebrowse(){window.location.reload();}

function ib_hascss(){ return ib_gettip('ib_infodiv')?true:false }

function ib_infoinit(){
 ib_ns4=(document.layers)?true:false, ib_ie4=(document.all)?true:false;
 ib_ie5=((ib_ie4)&&(navigator.userAgent.indexOf('MSIE 5')>0))?true:false;
 ib_kon=(navigator.userAgent.indexOf('konqueror')>0)?true:false;
 ib_x=0;ib_y=0;ib_winW=800;ib_winH=600;
 ib_idiv=null;
 document.onmousemove = ib_mousemove; // ###
 if(ib_ns4&&document.captureEvents) document.captureEvents(Event.MOUSEMOVE);
 // Workaround for just another netscape bug: Fix browser confusion on resize
 // obviously conqueror has a similar problem :-(
 if(ib_ns4||ib_kon){ ib_nsfix() }
 if(ib_ns4) { ib_px=""; }
}

function ib_untip(){
 if(ib_idiv) ib_idiv.visibility=ib_ns4?"hide":"hidden";
 ib_idiv=null;
}

function ib_gettip(name){
  return (document.layers&&document.layers[name])?document.layers[name]:(document.all&&document.all[name]&&document.all[name].style)?document.all[name].style:document[name]?document[name]:document.getElementById(name).style;
}

// Prepare tip boxes, but don't show them yet
function ib_maketip(name,title,text){
// if(ib_hascss())
 	document.write('<div id="'+name+'" name="'+name+'" style="position:absolute; visibility:hidden; z-index:20; top:0'+ib_px+'; left:0'+ib_px+';"><table width='+ib_IWIDTH+' border=0 cellpadding=2 cellspacing=0 style="background-color: #333399"><tr><td class="ib_tiptd"><table width="100%" border=0 cellpadding=0 cellspacing=0 class="tipboxhead"><tr><th><span class="ib_ptt"><b>'+title+'</b></span></th></tr></table><table width="100%" border=0 cellpadding=2 cellspacing=0 class="tipbox"><tr><td><span class="ib_pst"><font color="#000000">'+text+'</font></span></td></tr></table></td></tr></table></div>'+"\n");
}

function ib_tip(name){
 if(ib_hascss()){
  if(ib_idiv) ib_untip();
  ib_idiv=ib_gettip(name);
  if(ib_idiv){
   ib_winW=(window.innerWidth)? window.innerWidth+window.pageXOffset-16:document.body.offsetWidth-20;
   ib_winH=(window.innerHeight)?window.innerHeight+window.pageYOffset  :document.body.offsetHeight;
   if(ib_x<=0||ib_y<=0){ // konqueror can't get mouse position
    ib_x=(ib_winW-ib_IWIDTH)/2+(window.pageXOffset?window.pageXOffset:0); ib_y=(ib_winH-50)/2+(window.pageYOffset?window.pageYOffset:0); // middle of window
   }
   ib_showtip();
  }
 }
}

function ib_showtip(){
  //alert(ib_x);
  ib_idiv.left=(((ib_x+260)<ib_winW)?ib_x+12:ib_x-255)+ib_px;
  ib_idiv.top=(((ib_y+90)<ib_winH)?ib_y+12:ib_y-90)+ib_px;
  ib_idiv.visibility=ib_ns4?"show":"visible";
//  window.status="ib_idiv="+ib_idiv+"X:"+(ib_idiv.left?ib_idiv.left:"NAN")+", Y:"+(ib_idiv.top?ib_idiv.top:"NAN")+", x:"+ib_x+", y:"+ib_y;
}

function ib_mousemove(e){
 if(e)   {ib_x=e.pageX?e.pageX:e.clientX?e.clientX:0; ib_y=e.pageY?e.pageY:e.clientY?e.clientY:0;}
 else if(event) {ib_x=event.clientX; ib_y=event.clientY;}
 else {ib_x=0; ib_y=0;}
 if(ib_idiv) ib_showtip();
}

// Initialize after loading the page
window.onload=ib_infoinit;   // ###

// EOF infobox.js

