// tooltip.js
<!-- // set browser version
// *** CROSS-BROWSER COMPATIBILITY ***
var bisDOM = (document.getElementById ? true : false); 
var bisIE4 = ((document.all && !bisDOM) ? true : false);
var bisNS4 = (document.layers ? true : false);
var bisDyn = (bisDOM || bisIE4 || bisNS4);
var isns4 = (document.layers)? true:false;
var isie4 = (document.all)? true:false;
var isie5 = false; // or greater than ...
var agent = navigator.userAgent; 
var vers = 0;
var ms_x = 10;
var ms_y = 10;
var sc_x = 0;
var sc_y = 0;
var win_xx = 600;
var win_yy = 400;
var x_offset = 10;
var y_offset = 5;
var mtool = null; // the layer
var tt_trackmouse = 0;
var tt_bgcolor = "bgcolor=\"#ffff44\"";
// 1em (the width of one letter) normally is 16px wide
var tt_perchar = 7; // ROUGH estimate only
var tt_width = 200;
var testtxt = '1234567890123456789012345678901234567890';
var adddbg = 0;
var theWidth = 600;
var fixedPos = 0;
var usePre = 0;
var scn_wid = screen.width;
var scn_hgt = screen.height;

if (isie4) {
 var arr = agent.split(" ");
 for (i = 0; i < arr.length; i++) {
  if (arr[i] == 'MSIE') {
   if ((i + 1) < arr.length) {
    vers = arr[i+1];
    ind = vers.indexOf(';');
    if (ind > 0) {
     vers = vers.substr(0,ind);
    }
    if (vers > 4) {
     isie5 = true;
    }
   }
   break;
  }
 }
}

// get mouse events - for current position
if ( (isns4) || (isie4) ) {
 document.onmousemove = moveMouse;
 if (isns4) document.captureEvents(Event.MOUSEMOVE);
}

// functions

function moveMouse(e) {
 scn_wid = screen.width;
 scn_hgt = screen.height;
 if (isns4) { ms_x=e.pageX; ms_y=e.pageY; }
 if (isie4) {
  ms_x = event.x;
  ms_y = event.y;
 }
 if (isie5) {
  sc_x = document.body.scrollLeft;

  if (window.pageYOffset) {
   sc_y = window.pageYOffset;
  } else if (document.documentElement && document.documentElement.scrollTop) {
   sc_y = document.documentElement.scrollTop;
  } else if (document.body) {
   sc_y = document.body.scrollTop;
  }
 }
 if (window.innerWidth) {
  theWidth = window.innerWidth;
 } else if (document.documentElement && document.documentElement.clientWidth) {
  theWidth = document.documentElement.clientWidth
 } else if (document.body) {
  theWidth = document.body.clientWidth
 }
 if (self.innerHeight) { // all except Explorer 
	win_xx = self.innerWidth; 
	win_yy = self.innerHeight; 
 } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode 
	win_xx = document.documentElement.clientWidth; 
	win_yy = document.documentElement.clientHeight; 
} else if (document.body) { // other Explorers 
	win_xx = document.body.clientWidth; 
	win_yy= document.body.clientHeight; 
} 

 if (tt_trackmouse) { moveLayer(); }

}

function set_tooltip() {
 if ( (isns4) || (isie4) ) {
  if (isns4) mtool = self.document.toolDiv;
  if (isie4) mtool = self.toolDiv.style;
 }
}

function get_max_width() {
	var cX = ms_x + x_offset + sc_x;  // horizontal
	var tX = tt_width;
	// var pY = ms_y + y_offset + sc_y;  // vertical
	if ((cX + tX) >= win_xx) {
		if (cX < win_xx) {
			tX = win_xx - cX;
		}
	}
	return tX;
}

function tabletext_ok(text) {
 var txt;
 txt = "<table width="
 //txt += '"'+tt_width+'"';
 txt += '"'+get_max_width()+'"';
 txt += " border=\"0\" cellpadding=\"0\" cellspacing=\"0\" "+tt_bgcolor+"><tr><td>";
 txt += "<table width=100% border=0 cellpadding=2 cellspacing=0><tr><td valign=top><font face=\"Verdana,Arial,Helvetica\" color=\"#000000\" size=\"1\">"+text+"</font></td></tr></table></td></tr></table>";
 return txt;
}

function tabletext(text) {
 var txt = '';
 if (usePre > 0) {
	 txt = "<table width=\""+tt_width+"\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" "+tt_bgcolor+"><tr><td>";
	 //txt += "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
	 //txt += "<td valign=top>";
	 txt += "<pre>";
	 txt += "<font face=\"fixedsys\" color=\"#000000\" size=\"1\">"+text+"</font>";
	 txt += "</pre>";
	 txt += "</td></tr></table>";
	 //txt += "</td></tr></table>";
 } else {
	 txt = tabletext_ok(text);
 }
 return txt;
}

// add text to a layer
function wrtLayer(txt) {
 if ( (isns4) || (isie4) ) {
  if (isns4) {
   var lyr = self.document.toolDiv.document;
   lyr.write(txt);
   lyr.close();
  } else if (isie4) {
   self.document.all["toolDiv"].innerHTML = txt;
  }
  moveLayer(); // set at mouse position
  objShow(mtool); // show tooltip
 }
}

// make visible
function objShow(obj) {
 if ( (isns4) || (isie4) ) {
  if (isns4) {
   obj.visibility = "show";
  } else if (isie4) {
   obj.visibility = "visible"
  }
  tt_trackmouse = 1;
 }
}

// hide object
function objHide(obj) {
 if ( (isns4) || (isie4) ) {
  if (isns4) {
   obj.visibility = "hide";
  } else if (isie4) {
   obj.visibility = "hidden";
  }
  tt_trackmouse = 0;
 }
}

function nodisp() {
 if ( (isns4) || (isie4) ) {
  objHide(mtool);
 }
}

// Move a layer
function objMove(obj,mx,my) {
 obj.left = mx;
 obj.top = my;
}


// where to popup.
function moveLayer() {
 var pX = ms_x + x_offset + sc_x;  // horizontal
 var pY = ms_y + y_offset + sc_y;  // vertical
 if (fixedPos > 0) {
	 pX = x_offset + sc_x;
	 pY = y_offset + sc_y;
 }
 objMove(mtool, pX, pY);     // move the object. 
}

function dispmsg(msg) {
 set_tooltip();
 var tt = tabletext(msg);
 wrtLayer(tt);
}

function add_last_modified_para() {
	var msg = '<p align="right"><i>This document was last modified ';
	msg += document.lastModified;
	msg += '.<i></p';
    document.writeln (msg);
}

function add_valid_401_para() {
	var msg = '<p><a href="http://validator.w3.org/check?uri=referer">'
	msg += '<img src="../images/valid-html401.gif" alt="Valid HTML 4.01 Transitional" width="88" height="31">';
	msg += '</a></p>';
    document.writeln (msg);
}

// -->
// eof - tooltip.js
