
// ***** code for the tool tip info *****

var Words = new Array();

function addWord(word, definition)
{
	if(getDefinition(word) == undefined) {
		var entry = new Array(word, unescape(definition));
		Words.push(entry);
	}
}

function getDefinition(word)
{
	var def = undefined;

	if(Words != undefined) {
		for(i=0; i<Words.length; i++) {
			entry = Words[i];
			key = entry[0];
			if(key == word) {
				def = entry[1];
		    }
		}
	}
	
	return def;
}

var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;

var toolTipSTYLE = null;
var yCoordinate = 0;
var bubbleLength = 0;


function initToolTips()
{
  if(ns4||ns6||ie4)
  {
    if(ns4) toolTipSTYLE = document.toolTipLayer;
    else if(ns6||ie4) toolTipSTYLE = document.getElementById("toolTipLayer").style;
    else if(ie4) toolTipSTYLE = document.getElementById("toolTipLayer").style;
    if(ns4){
        document.captureEvents(Event.MOUSEMOVE | Event.CLICK);
    }
    else
    {
      toolTipSTYLE.visibility = "visible";
      toolTipSTYLE.display = "none";
    }
    document.onmousemove = moveToMouseLoc;
    document.onclick = moveToMouseLoc;
    
  }
}

function toolTip(msg, baseHref)
{
    var locationTop = 0;
    var content= '';
    var basehref= baseHref;

    if (ns4||ns6){
        if (yCoordinate < ((bubbleLength * 12) + 65)){
            locationTop = 1;
        }

    }
    else{
        if (event.clientY < ((bubbleLength * 12) + 65)){
            locationTop = 1;
        }
    }

	 if (locationTop == 1) {
        content = '<table border="0" cellspacing="0" width="247" cellpadding="0">' +
        '<tr><td valign="bottom" width="247" colspan="6">' +
                '<table border="0" cellspacing="0" width="247" cellpadding="0">' +
                '<tr><td valign="bottom"><IMG SRC="' + basehref + 'Util/images/bubble_top_inv_left.gif" WIDTH="19" HEIGHT="7"><br /></td>' +
                '<td valign="bottom"><IMG SRC="' + basehref + 'Util/images/bubble_top_inv.gif" WIDTH="25" HEIGHT="25"><br /></td>' +
                '<td valign="bottom"><IMG SRC="' + basehref + 'Util/images/bubble_top_inv_right.gif" WIDTH="203" HEIGHT="7"><br /></td></tr></table>' +
        '</td></tr>' +
        '<tr><td width="1" bgcolor="#666666"><IMG SRC="' + basehref + 'Util/images/dark_grey_pixel.gif" width="1" height="1"><br /></td>' +
        '<td width="2" bgcolor="#FFFFFF">&nbsp;</td>' +
        '<td width="240" bgcolor="#FFFFFF" style="PADDING-LEFT: 2px; FONT-SIZE: 11px; FONT-FAMILY: Arial; COLOR: #000000;">'+ msg + '&nbsp;</td>' +
        '<td width="2" bgcolor="#FFFFFF">&nbsp;</td>' +
        '<td width="1" bgcolor="#666666"><IMG SRC="' + basehref + 'Util/images/dark_grey_pixel.gif" width="1" height="1"><br /></td>' +
        '<td width="1" bgcolor="#E0E0E0"><IMG SRC="' + basehref + 'Util/images/light_grey_pixel.gif" width="1" height="1"><br /></td></tr>' +
        '<tr><td width="247" colspan="6"><IMG SRC="' + basehref + 'Util/images/bubble_bottom_inv.gif" WIDTH="247" HEIGHT="5"><br /></td></tr>'+
        '</table>';
    }
    else{
        content = '<table border="0" cellspacing="0" width="247" cellpadding="0">' +
        '<tr><td width="247" colspan="6"><IMG SRC="' + basehref + 'Util/images/bubble_top.gif" WIDTH="247" HEIGHT="5"><br /></td></tr>'+
        '<tr><td width="1" bgcolor="#666666"><IMG SRC="' + basehref + 'Util/images/dark_grey_pixel.gif" width="1" height="1"><br /></td>' +
        '<td width="2" bgcolor="#FFFFFF">&nbsp;</td>' +
        '<td width="240" bgcolor="#FFFFFF" style="PADDING-LEFT: 2px; FONT-SIZE: 11px; FONT-FAMILY: Arial; COLOR: #000000;">' + msg + '&nbsp;</td>' +
        '<td width="2" bgcolor="#FFFFFF">&nbsp;</td>' +
        '<td width="1" bgcolor="#666666"><IMG SRC="' + basehref + 'Util/images/dark_grey_pixel.gif" width="1" height="1"><br /></td>' +
        '<td width="1" bgcolor="#E0E0E0"><IMG SRC="' + basehref + 'Util/images/light_grey_pixel.gif" width="1" height="1"><br /></td></tr>' +
        '<tr><td valign="top" width="247" colspan="6">' +
            '<table border="0" cellspacing="0" width="247" cellpadding="0">' +
                '<tr><td valign="top"><IMG SRC="' + basehref + 'Util/images/bubble_bottom_left.gif" WIDTH="19" HEIGHT="7"><br /></td>' +
                '<td valign="top"><IMG SRC="' + basehref + 'Util/images/bubble_bottom.gif" WIDTH="25" HEIGHT="25"><br /></td>' +
                '<td valign="top"><IMG SRC="' + basehref + 'Util/images/bubble_bottom_right.gif" WIDTH="203" HEIGHT="7"><br /></td></tr></table>' +
        '</td></tr>' +
        '</table>';
    }
    
    if(ns4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
    if(ns6)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display='block'
    }
    if(ie4)
    {
      document.all("toolTipLayer").innerHTML=content;
      toolTipSTYLE.display='block'
    }
}

function hideToolTip(){
    if(ns4) toolTipSTYLE.visibility = "hidden";
    else toolTipSTYLE.display = "none";
}

function moveToMouseLoc(e){
    
    if (ns4||ns6){
        yCoordinate = e.pageY - window.pageYOffset;
       
        if (yCoordinate < ((bubbleLength * 12) + 65)) {
            x = e.pageX;
            y = e.pageY + 30;
        }
        else{
            x = e.pageX;
            y = e.pageY - (bubbleLength * 12) - 50;
        }
    }
    else {
        if (event.clientY < ((bubbleLength * 12) + 65)) {
            x = event.clientX + document.body.scrollLeft;
            y = event.clientY + document.body.scrollTop + 15;
        }
        else{
            x = event.clientX + document.body.scrollLeft;
            y = event.clientY + document.body.scrollTop - (bubbleLength * 12) - 50;
        }
    }
    
    if (ns6) {
        document.getElementById("toolTipLayer").style.left = x + "px";
        document.getElementById("toolTipLayer").style.top =  y + "px";
    }
    else if (toolTipSTYLE) {
             toolTipSTYLE.left = x;
             toolTipSTYLE.top = y;
    }

    return true;
}

function bubbleToolTip(word, defLength, baseHref) {
    bubbleLength = defLength /45;
    basehref = baseHref;
    toolTip("<b>" + word + "</b><br />" + getDefinition(word), basehref);
}


