// Do NOT change ANYTHING in this script.
// It can break very easily!
//
// DECLARE GLOBAL VARIABLES
//
// Intervals
var oInt1= "";
var oInt2= "";
// Current DIV
var currDivId;
var posX;
var posY;
// Set to true if you prefer
var moveWithMouse= false;
// Used by makeVisible(), hideTT(), moveTT()
var isVisible= "";
//
// FUNCTIONS
//
function showTT( divId) { // SHOW TOOL TIP
currDivId = divId;
posX= event.clientX + document.body.scrollLeft - 10;
if( moveWithMouse) {
// Tool tip moves along with the mouse.
posY= event.clientY + document.body.scrollTop - 11 - 60;
}
else {	
// Non-moving, so fix vertical position.
// We want the tool tip box to always show a fixed number
// of pixels above the link being pointed at, regardless
// whether the cursor is pointing at the very bottom of
// a small "p", or at the top of a capital "T"
// With Internet Explorer, we can do this:
zeroToTwelve= event.offsetY - event.srcElement.offsetTop;
correction= zeroToTwelve - 8;
// But let's make sure it's Internet Explorer - 
// did we get 0 to 12?
if( (zeroToTwelve < 0) || (zeroToTwelve > 12)) {
// No - so it's not Internet Explorer, and it would be
// unreliable to make any assumption about positions etc -
// so we'll be moving the tool tip along with the cursor
// to be safe (because otherwise the tool tip box might
// end up BELOW the cursor, and then disappear on mouse
// move!)
correction= 0;
moveWithMouse= true;
}
posY= event.clientY + document.body.scrollTop - 11 - 60 - correction;
}
// Show after a second
oInt1= window.setInterval( "makeVisible()", 1000);
}
function makeVisible() {
// isVisible is used in moveTT() to decide
// if the tool tip is already visible or still
// waiting to be shown (the first second).
isVisible= currDivId;
if( !moveWithMouse) {
window.clearInterval( oInt1);
oInt2= window.setInterval( "timeOutTT()", 8000);
}
if( document.getElementById(currDivId) ) { // check the DIV exists,
// ie. is already loaded
// (it's at the bottom of the page)
document.getElementById(currDivId).style.left= posX;
document.getElementById(currDivId).style.top=  posY;
document.getElementById(currDivId).style.visibility= 'visible';
}
}
function hideTT( divId) { // HIDE TOOL TIP
// This runs "on mouse out", so clear any intervals
// and hide the tool tip.
isVisible= "";
window.clearInterval( oInt1);
window.clearInterval( oInt2);
if( document.getElementById(currDivId) ) { // check the DIV exists,
// ie. is already loaded
// (it's at the bottom of the page)
document.getElementById(divId).style.visibility= 'hidden';
}
}
function moveTT( divId) { // MOVE TOOL TIP
// This runs "on mouse move".
// Always note X - even if the tool tip is still
// waiting to be shown (ie. within the first sec.)
posX= event.clientX + document.body.scrollLeft - 10;
// Moving tool tip?
if( moveWithMouse) {
// Then also note the new Y position.
posY= event.clientY + document.body.scrollTop - 11 - 60;
// Already visible, or still waiting for the tool tip to show?
if( isVisible == divId) {
// If visible, move it along with the cursor.
currDivId = divId;
makeVisible();
}
}
}
function timeOutTT() {
// Non-moving tool tip disappers after 8 secs.
window.clearInterval( oInt2);
if( document.getElementById(currDivId) ) { // check the DIV exists,
// ie. is already loaded
// (it's at the bottom of the page)
document.getElementById(currDivId).style.visibility= 'hidden';
}
}
//
// SET EVENTS HANDLERS FOR ALL LINKS
//
if( document.links) {
for( var d=0; d<document.links.length; d++) {
// Link ID should be something like 'oc0101' or 'fp020103'
firstTwoChars= document.links[d].id.substr( 0,2);
if( (firstTwoChars == 'oc') || (firstTwoChars == 'fp') ) {
document.links[d].onmouseover = function() { showTT( "tt_" + event.srcElement.id) };
document.links[d].onmouseout  = function() { hideTT( "tt_" + event.srcElement.id) };
document.links[d].onmousemove = function() { moveTT( "tt_" + event.srcElement.id) };
}
// ENABLE THE 'ELSE' BLOCK FOR TESTING, but be sure to first define
// <div class="toolTip" id="tt_default">No tool tip</div>
// on the underlying web page.
//
//else {
//  document.links[d].onmouseover = function() { showTT( "tt_default") };
//  document.links[d].onmouseout  = function() { hideTT( "tt_default") };
//  document.links[d].onmousemove = function() { moveTT( "tt_default") };
//}
}
}
