var IWIDTH=250  // Tip box width
var browser		// browser
var x,y,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
var id_name     //  name of current
var div_width 
var div_height 


function nsfix(){setTimeout("window.onresize = rebrowse", 2000);}

function rebrowse(){window.location.reload();}

function hascss(){ return gettip('infodiv')?true:false }

function infoinit(){
 browser = getBrowser();
 x=0;y=0;winW=800;winH=600;
 idiv=null;
 document.onmousemove = mousemove;
 if((browser == 'nc4')&&document.captureEvents) document.captureEvents(Event.MOUSEMOVE);
 // Workaround for just another netscape bug: Fix browser confusion on resize
 // obviously conqueror has a similar problem :-(
 if( (browser == 'nc4')||(browser=='kq2')){ nsfix() }
 if (browser == 'nc4') { px=""; }
}

function untip(){
 if(idiv) {
 	if(browser == 'nc4')
		idiv.visibility = "hide";
	else
		idiv.visibility = "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
// html structure
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");
 if(hascss())
 	document.write('<div id="'+name+'" name="'+name+'" class="tooltip_container" style="position:absolute; visibility:hidden; z-index:999; top:0'+px+'; left:0'+px+'; width:200px;"><span class="tooltip_title">'+title+'</span><span class="tooltip_text">'+text+'</span></div>'+"\n");
}

function tip(name){
 id_name = name;
 if(hascss()){
  if(idiv) untip();
  idiv=gettip(name);
  if(idiv){
   winW=(window.innerWidth)? window.innerWidth+window.pageXOffset-16:document.body.offsetWidth-20;
   winH=(window.innerHeight)?window.innerHeight+window.pageYOffset  :document.body.offsetHeight;
   if(x<=0||y<=0){ // konqueror can't get mouse position
    x=(winW-IWIDTH)/2+(window.pageXOffset?window.pageXOffset:0); y=(winH-50)/2+(window.pageYOffset?window.pageYOffset:0); // middle of window
   }
   
   showtip();
  }
 }
}

function showtip(){
  // take into account distance to bottom or right of window
	idiv.left=(((x+div_width)<winW)?x+12:x-div_width)+px; idiv.top=(((y+div_height)<winH)?y-div_height:y-div_height)+px;

	if(browser == 'nc4')
		idiv.visibility = "show";
	else
		idiv.visibility = "visible";
}

function mousemove(e){
 if(e)   {x=e.pageX?e.pageX:e.clientX?e.clientX:0; y=e.pageY?e.pageY:e.clientY?e.clientY:0;}
 else if(event) {x=event.clientX; y=event.clientY;}
 else {x=0; y=0;}

if( ((browser=='ie4')||(browser=='ie5') || (browser=='ie5.5')) && document.documentElement) // Workaround for scroll offset of IE
{
//    x+=document.body.scrollLeft;
//    y+=document.body.scrollTop;
x+=document.documentElement.scrollLeft;
y+=document.documentElement.scrollTop;
}

if( ((browser=='ie6'))) // Workaround for scroll offset of IE6
{
//    x+=document.body.scrollLeft; ????
//    y+=document.body.scrollTop;  ????
x+=document.documentElement.scrollLeft;
y+=document.documentElement.scrollTop;
}

if( ((browser=='ie7'))) // Workaround for scroll offset of IE7
{
x+=document.documentElement.scrollLeft;
y+=document.documentElement.scrollTop;
}

div_width = document.getElementById(id_name).offsetWidth;
div_height = document.getElementById(id_name).offsetHeight;

if(idiv) showtip();

}

function getBrowser(){
	if(document.ids)browser='nc4';
	else if( document.all && !document.getElementById )browser='ie4';
	else if( window.opera && !document.createElement )browser='op5';
	else if( window.opera && window.getComputedStyle )  {
			  if(document.createRange)browser='op8';
				else if(window.navigate)browser='op7.5';
								 else browser='op7.2';                   }
	else if( window.opera && document.compatMode )browser='op7';
	else if( window.opera && document.releaseEvents )browser='op6';
	else if( document.contains && !window.opera )browser='kq3';
	else if(window.pkcs11&&window.XML)browser='f15';
	else if( window.getSelection && window.atob )browser='nn7';
	else if( window.getSelection && !document.compatMode )browser='nn6';
	else if( window.clipboardData && document.compatMode )
	  browser=window.XMLHttpRequest? 'ie7' : 'ie6';
	else if( window.clipboardData ){browser='ie5';
		 if( !document.createDocumentFragment ) browser+='.5';
		 if( document.doctype && !window.print ) browser+='m';}
	else if( document.getElementById && !document.all ) browser='op4';
	else if( document.images && !document.all ) browser='nn3';
	else if(document.clientWidth&&!window.RegExp)browser='kq2';
	else browser='???';
	return browser;
}
