       //
// Bubblehelp infoboxes, (C) 2002 Klaus Knopper <infobox@knopper.net>
// You can copy/modify and distribute this code under the conditions
// of the GNU GENERAL PUBLIC LICENSE Version 2.
//
var IWIDTH=250;  // Tip box width
var ns4=false;         // Are we using Netscape4?
var ie4=false;         // Are we using Internet Explorer Version 4?
var ie5=false;         // Are we using Internet Explorer Version 5 and up?
var ie6=false;         // ist es IE6
var kon=false;         // Are we using KDE Konqueror?
var x_info,y_info,winW,winH;  // Current help position and main window size
var idiv=null;   // Pointer to infodiv container
var px="px";     // position suffix with "px" in some cases  wird für ns4 auf "" gesetzt
var dummy;

// -----------------------------------------------------------------------
function fehler(msg,url,line) {
 alert("Fehler in : "+url+"\n"+"Zeile   "+line+"\n"+"Text : "+msg);
}
onerror=fehler;



function nsfix(){setTimeout("window.onresize = rebrowse", 2000);}

function rebrowse(){window.location.reload();}

function hascss(){ return gettip('infodiv')?true:false }

function infoinit(){


 ns4=((document.layers)||(navigator.userAgent.indexOf('firefox')>0))?true:false;

 ie4=(document.all)?true:false;
 ie5=((ie4)&&((navigator.userAgent.indexOf('MSIE 5')>0)||(navigator.userAgent.indexOf('MSIE 6')>0)))?true:false;
 ie6=(navigator.userAgent.indexOf('MSIE 6')>0)?true:false;

// alert(document.compatMode);
// alert("ie4="+ie4+"  ie5="+ie5+"   "+"  ie6="+ie6+"   "+navigator.userAgent);


 kon=(navigator.userAgent.indexOf('konqueror')>0)?true:false;
 x_info=0;y_info=0;winW=800;winH=600;
 idiv=null;
 document.onmousemove = mousemove;
 if(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(ns4||kon){ nsfix() }
 if(ns4) { px=""; }
}

function untip(){
  if(idiv==null) return;
 //  window.status=untip+"  ie5="+ie5+"  ie6="+ie6+" idiv="+idiv+"x_info:"+(idiv.left?idiv.left:"NAN")+", y_info:"+(idiv.top?idiv.top:"NAN")+", x_info:"+x_info+", y_info:"+y_info;

 if(idiv) idiv.visibility=ns4?"hide":"hidden";
 idiv=null;
}

function 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)?document.getElementById(name).style:0);}

// Prepare tip boxes, but don't show them yet
function maketip(name,title,text){
 if(hascss()) document.write('<div id="'+name+'" name="'+name+'" style="position:absolute; visibility:hidden; z-index:20; top:0'+px+'; left:0'+px+';"><table width='+IWIDTH+' border=0 cellpadding=2 cellspacing=0 bgcolor="#333399"><tr><td class="tiptd"><table width="100%" border=0 cellpadding=0 cellspacing=0><tr><th><span class="ptt"><b><font color="#FFFFFF">'+title+'</font></b></span></th></tr></table><table width="100%" border=0 cellpadding=2 cellspacing=0 bgcolor="#CCCCFF"><tr><td><span class="pst"><font color="#000000">'+text+'</font></span></td></tr></table></td></tr></table></div>'+"\n");
}

function tip(name){
 if(hascss()){
  if(idiv) untip();
 // alert(name);
  idiv=gettip(name);

  if(idiv != null){
   winW=(window.innerWidth)? window.innerWidth+window.pageXOffset-16:document.body.offsetWidth-20;
   winH=(window.innerHeight)?window.innerHeight+window.pageYOffset  :document.body.offsetHeight;
   if(x_info<=0||y_info<=0){ // konqueror can't get mouse position
    x_info=(winW-IWIDTH)/2+(window.pageXOffset?window.pageXOffset:0); y_info=(winH-50)/2+(window.pageYOffset?window.pageYOffset:0); // middle of window
   }
  showtip();
  }
 }
}

function showtip() {

  if(idiv == null) return;

  // window.status=idiv.left+"  "+idiv.top+ "   "+(ie6 ||ie5);
  if(ie6 || ie5){  idiv.left = (((x_info+170)<winW)?x_info+2:x_info-255); idiv.top=(((y_info+90)<winH)?y_info+12:y_info-90);  }
  else {  idiv.left = (((x_info+170)<winW)?x_info+2:x_info-255)+px; idiv.top=(((y_info+90)<winH)?y_info+12:y_info-90)+px;  }

 // window.status=dummy+"  ie5="+ie5+"  ie6="+ie6+" idiv="+idiv+"x_info:"+(idiv.left?idiv.left:"NAN")+", y_info:"+(idiv.top?idiv.top:"NAN")+", x_info:"+x_info+", y_info:"+y_info;
   idiv.visibility=(ns4?"show":"visible");
}

function mousemove(e){
 if(e)   {x_info=e.pageX?e.pageX:e.clientX?e.clientX:0; y_info=e.pageY?e.pageY:e.clientY?e.clientY:0;}
 else if(event) {x_info=event.clientX; y_info=event.clientY;}
 else {x_info=0; y_info=0;}
 if((ie4||ie5) && document.documentElement) // Workaround for scroll offset of IE
  {
    x_info+=document.documentElement.scrollLeft;
    y_info+=document.documentElement.scrollTop;
  }
  showtip();
}

// Initialize after loading the page
window.onload=infoinit;

// EOF infobox.js