
<!--

/* =======================================================================
  Script ID   : tTips.js ( tool tips )

  Desc        : Include file containing tool tip variables and functions.

  Included by : footer.html, miaList.html

  Functions Defined in this File
  NAME                DESCRIPTION
  -------------   ------------------------------------------------------------

  trackMouse      maintain mouse X/Y coordinates and 
                   call tTipSetCSSpos if tipOn (true, hovering over <a> tag )

  tTipGetTable    get HTML table code with image + text assigned.

  tTipHide        set tipcss visibility property to hidden and tipOn = false.

  tTipInit        initialize tool tip global vars.

  tTipItem        constructor for tool tip item object

  tTipSetCSS      set tipcss properties for current tTip

  tTipSetCSSpos   set tipcss properties (top,left) to keep tool tip inside window.

  tTipShow        assign HTML table code to tipDiv object
                   if NOT tipFollowMouse then call tTipSetCSSpos
                   if     tipFollowMouse then set tipcss visibility property.
  -------------   ------------------------------------------------------------

 ========================================================================== */


/** Tool Tip Item constructor
  *
  * @param  tName    : name (handle) for tool tip item.
  *         type     : string
  *
  * @param  tDOMid   : identifier for DIV tag container for CSS attributes + position.
  *         type     : string
  *
  * @param  tImgSrc  : image file specification (absolute path).
  *         type     : string
  *
  * @param  tImgWidth: width of image in pixels.
  *         type     : string-integer
  *
  * @return Object reference.
  *
  */
function tTipItem( tName, tDOMid, tImgSrc, tImgWidth )
{
               this.name  = tName      ; // tip name (handle)
              this.DOMid  = tDOMid     ; // document DIV ID value
       if (document.images) {
              this.image  = new Image();
          this.image.src  = tImgSrc    ;  // Image source filename
        this.image.width  = tImgWidth  ;  // image width
       }

    /* mouse and display distance ------------------------------ */
        this.followMouse  = true       ;  // DEF:true
               this.off   = new Object();
              this.off.X  = 20         ;  // display-dist from mouse DEF:20
              this.off.Y  =  1         ;  // display-dist from mouse DEF: 1

    /* message ------------------------------------------------ */
        this.msg              = new Object();
        this.msg.text         = ''          ; // tip message string
        this.msg.font         = new Object();
        this.msg.font.family  = 'Georgia, Helvitica, Arial' ; // DEF
        this.msg.font.size    = "8pt";
        this.msg.font.color   = "#000000"  ; // black

   /* tip window & border ------------------------------------ */
           this.bg             = new Object();
           this.bg.color       = "#FFFFFF"  ; // white
           this.border         = new Object();
           this.border.color   = "#000080"  ; // dark blue
           this.border.width   =  0         ; // NO BORDER
           this.border.style   = "solid"    ; // ridge
           this.border.padding =  0         ;

} // end of tTipItem #1 tName, tDOMid, tImgSrc, tImgWidth

var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

// resize fix for ns4
var origWidth, origHeight;
if (ns4) {
 origWidth = window.innerWidth; origHeight = window.innerHeight;
 window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

var tipFollowMouse= true;
var          offX= 20; // how far away from mouse to show tip
var          offY= 1;

////////////////////////////////////////////////////////////
//  tTipInit	- initialization for tooltip.
//		Global variables for tooltip.
//		Set styles for all but ns4.
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;

function tTipInit()
{
  if ( nodyn ) return; // DHTML not supported
  tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
  tipcss  = (ns4)? document.tipDiv : tooltip.style ;
  if ( tooltip && tipFollowMouse ) {
    if (ns4) document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = trackMouse; // store ref to function
  }
} // tTipInit

window.onload = tTipInit;

/** Set Tool Tip CSS Properties
  *
  * @param  tTip     : tool tip item ( single element from tTips array ).
  *         type     : Object of type tTipItem
  *
  */
function tTipSetCSS( tTip )
{
  if ( ! tooltip )         return ;
  if ( ! document.tipDiv ) return ;
  if ( ! tipcss ) tipcss = (ns4)? document.tipDiv : tooltip.style ;

  if ( ie4 || ie5 || ns5 ) {	// ns4 would lose all this on rewrites
    tipcss.width            = tTip.image.width + "px"     ;
    tipcss.fontFamily       = tTip.msg.font.family        ;
    tipcss.fontSize         = tTip.msg.font.size          ;
    tipcss.color            = tTip.msg.font.color         ;
    tipcss.backgroundColor  = tTip.bg.color               ;
    tipcss.borderColor      = tTip.border.color           ;
    tipcss.borderWidth      = tTip.border.width   + "px"  ;
    tipcss.padding          = tTip.border.padding + "px"  ;
    tipcss.borderStyle      = tTip.border.style           ;
  }
}  // end of tTipSetCSS( tTip )


/** Get Tool Tip Table with Image + Message
  *
  * @param  tTip     : tool tip item ( single element from tTips array ).
  *         type     : Object of type tTipItem
  *
  * @return tool tip table
  *
  */
function tTipGetTable( tTip )
{
  if ( ! tTip || tTip == undefined ) return ;

  /* Start new table with image in 1st row */
  var tipTable = '<table width="' +  tTip.image.width + '"'   +
    ' cellspacing=0 cellpadding=0 >'             +
    ' <tr> '                                     +
    '   <td align=center width=100% >'           +
    '     <img src="' + tTip.image.src + '"'     +
    '          border=0 > '                      +
    '   </td> '                                  +
    ' </tr> ' ;

  /* Add row for message */
  if ( tTip.msg.text.length > 0 ) {
    tipTable +=  ' <tr> '                                       +
    '   <td valign=top > '                                      +
    '       <span style="'                                      +
    '             font-family:' + tTip.msg.font.family + ' ;  ' +
    '             font-size  :' + tTip.msg.font.size   + ' ;  ' +
    '             color      :' + tTip.msg.font.color  + ';" >' +
                  tTip.msg.text + '</span>' ;
  }

  /* End Table */
  tipTable += '</td></tr></table>';

  return tipTable ;

} // end of tTipGetTable( tTip )


/////////////////////////////////////////////////
//  tTipShow function
//			Assembles content for tooltip and writes
//			it to tipDiv
/////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function tTipShow(evt,num)
{
	if (! tooltip ) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;

	if (ns4) {
        var tip = '<table bgcolor='     + tTips[num].border.color    +
                  ' width='             + tTips[num].image.width     +
                  ' cellspacing=0 '                                  +
                  ' cellpadding='       + tTips[num].border.width    +
                  ' border=0 > '                         +
                  ' <tr><td> '                           +
                  ' <table '                             +
                  '    bgcolor="'       + tTips[num].bg.color + '"'  +
                  '    width=100%    '                   +
                  '    cellspacing=0 '                   +
                  '    cellpadding='    + tTips[num].border.padding  +
                  '    border=0 >  '                     +
                  '  <tr><td> '                          +
                     tTipGetTable( tTips[num] )          +
                  ' </td></tr></table></td></tr></table>';

        tooltip.write(tip);
        tooltip.close();

	} else if (ie4 || ie5 || ns5 ) {
        tTipSetCSS( tTips[num] ); // set global tipcss
        tooltip.innerHTML = tTipGetTable( tTips[num] );
	}
	if (!tipFollowMouse) tTipSetCSSpos(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);

}  // end of tTipShow


var mouseX, mouseY;
function trackMouse(evt) {
	mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
	mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	if (tipOn) tTipSetCSSpos(evt);
}

/////////////////////////////////////////////////////////////
//  tTipSetCSSpos function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position,
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
function tTipSetCSSpos(evt)
{
  if (!tipFollowMouse) {
    mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
    mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
  }
  // tooltip width and height
  var tpWd = (ns4)? tooltip.width  : (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
  var tpHt = (ns4)? tooltip.height : (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
  // document area in view (subtract scrollbar width for ns)
  var winWd = (ns4||ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
  var winHt = (ns4||ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
  // check mouse position against tip and window dimensions
  // and position the tooltip
  if ((mouseX+offX+tpWd)>winWd)
       tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-(tpWd+offX)+"px";
  else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";

  if ((mouseY+offY+tpHt)>winHt)
       tipcss.top = (ns4)? winHt-(tpHt+offY): winHt-(tpHt+offY)+"px";
  else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
  if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);

} //  end of tTipSetCSSpos


function tTipHide()
{
  if (!tooltip) return;
  t2=setTimeout("tipcss.visibility='hidden'",100);
  tipOn = false;
}

// end hide -->

