var ToolTipTimer = null;

if (!document.layers && !document.all && !document.getElementById) event = "none";

    if (!document.layers&&!document.all&&!document.getElementById)
    event="test"

    function showtip(current,e,text)
    {
       if (document.all||document.getElementById)
        {
           if (current.type=='select-one')
           {
              showSelectTip(e, text);
           }
           else
           {
                thetitle=text.split('<br>')
                if (thetitle.length>1)
                {
                    thetitles=''
                    for (i=0;i<thetitle.length;i++)
                    thetitles+=thetitle[i]
                    current.title=thetitles
                }
                else
                {
                  current.title=text
                }
           }
        }
        else if (document.layers)
        {
            document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+text+'</layer>')
            document.tooltip.document.close()
            document.tooltip.left=e.pageX+5
            document.tooltip.top=e.pageY+5
            document.tooltip.visibility="show"
        }
    }


    function hidetip()
    {
    hideSelectTip()
        if (document.layers)
        document.tooltip.visibility="hidden"
    }


function showSelectTip(e, sTxt, sFont, sSize, sColor, sBGColor,sBorderColor) {
  var ToolTip;
  // set defaults for parameters left blank
  if (sFont == null || sFont == '') sFont = 'Verdana,Geneva,Arial,Helvetica,sans-serif';
  if (sSize == null || sSize == '') sSize = '8pt';
  if (sColor == null || sColor == '') sColor = '#000000';
  if (sBGColor == null || sBGColor == '') sBGColor = '#FFFFE7';
  if (sBorderColor == null || sBorderColor == '') sBorderColor = '#000000';

  if (document.getElementById) { // NS6/IE5+
    ToolTip = document.getElementById('ToolTip');
    var TTStyle = ToolTip.style;
    ToolTip.innerHTML = '<nobr>' + sTxt + '</nobr>';
    TTStyle.font = sSize + ' ' + sFont;
    TTStyle.padding = '1 2 1 2'; // top right bottom left
    TTStyle.border = '1px solid ' + sBorderColor;
    TTStyle.color = sColor;
    TTStyle.backgroundColor = sBGColor;
    document.onmousemove = delaySelectToolTip;
    delaySelectToolTip(e);
  } else if (document.layers) { // NS4
    ToolTip = document.layers.ToolTip;
    var TTDoc = ToolTip.document;
    TTDoc.open();
    TTDoc.write('<body><div id="innerToolTip" style="position:absolute;font-family:' + sFont + ';font-size:' + sSize + ';color:' + sColor + ';border:solid;border-width:1px;border-color:' + sBorderColor +        ';layer-background-color:' + sBGColor + ';"><nobr>' + sTxt +'</nobr></div></body>');
    TTDoc.close();
    ToolTip.clip.width = TTDoc.layers.innerToolTip.clip.width;
    ToolTip.clip.height = TTDoc.layers.innerToolTip.clip.height;
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = delaySelectToolTip;
    delaySelectToolTip(e);
  } else if (document.all) { // IE4
    ToolTip = document.all.ToolTip;
    ToolTip.innerHTML = '<div id="innerToolTip" style="position:absolute;font-family:' + sFont + ';font-size:' + sSize + ';color:' + sColor + ';border:solid;border-width:1px;border-color:' + sBorderColor +        ';background-color:' + sBGColor + ';padding:2px;"><nobr>' + sTxt+ '</nobr></div>';    document.onmousemove = delaySelectToolTip;
    delaySelectToolTip(e);
  }
} // showToolTip()

function delaySelectToolTip(e) {
  if (ToolTipTimer) clearTimeout(ToolTipTimer);
  var nX = 0;
  var nY = 0;
  if (document.getElementById) { // NS6/IE5+
    // e && e.pageX/Y is NS6, otherwise IE5+
    nX = (e && e.pageX ? e.pageX : window.event.clientX + document.body.scrollLeft);
    nY = (e && e.pageY ? e.pageY : window.event.clientY + document.body.scrollTop);
  } else if (document.layers) { // NS4
    nX = e.pageX;
    nY = e.pageY;
  } else if (document.all) { // IE4
    nX = window.event.clientX + document.body.scrollLeft;
    nY = window.event.clientY + document.body.scrollTop;
  }
  ToolTipTimer = setTimeout("displaySelectToolTip(" + nX + ", " + nY + ")",300);
} // delaySelectToolTip()

function displaySelectToolTip(nX, nY) {
  var ToolTip;
  if (document.getElementById) { // NS6/IE5+
    document.onmousemove = null;
    ToolTip = document.getElementById('ToolTip');
    var TTStyle = ToolTip.style;
    // window.innerWidth/Height is NS6, otherwise IE5+
    var nRightMargin = (window.innerWidth ? window.innerWidth +
window.pageXOffset : document.body.clientWidth +document.body.scrollLeft);
    if ((nX + ToolTip.offsetWidth) > nRightMargin)  // tooltip runs off right
      nX -= ToolTip.offsetWidth + 10;
    var nBottomMargin = (window.innerHeight ? (window.innerHeight + window.pageYOffset - 38) : (document.body.clientHeight + document.body.scrollTop - 20));
    if ((nY + ToolTip.offsetHeight) > nBottomMargin) // tooltip runs off bottom
      nY -= ToolTip.offsetHeight + 30;
    TTStyle.left = nX;
    TTStyle.top = nY + 20;
    TTStyle.visibility = 'visible';
  } else if (document.layers) { // NS4
    document.releaseEvents(Event.MOUSEMOVE);
    document.onmousemove = null;
    ToolTip = document.layers.ToolTip;
    var TTClip = ToolTip.clip;
    var nRightMargin = window.innerWidth + window.pageXOffset;
    if ((nX + TTClip.width) > (nRightMargin - 10)) // tooltip runs off right
      nX = nRightMargin - TTClip.width - 20;
    if ((nY + TTClip.height) > (window.innerHeight + window.pageYOffset - 38)) // tooltip runs off bottom
      nY -= TTClip.height + 22;
    ToolTip.left = nX;
    ToolTip.top = nY + 20;
    ToolTip.visibility = 'visible';
  } else if (document.all) { // IE4
    document.onmousemove = null;
    ToolTip = document.all.ToolTip;
    var TTStyle = ToolTip.style;
    var InnerToolTip = ToolTip.all.innerToolTip;
    var nRightMargin = document.body.clientWidth + document.body.scrollLeft;
    if ((nX + InnerToolTip.clientWidth) > nRightMargin) // tooltip runsoff right
      nX = nRightMargin - InnerToolTip.clientWidth - 6;
    if ((nY + InnerToolTip.clientHeight) > (document.body.clientHeight + document.body.scrollTop - 20)) // tooltip runs off bottom
      nY -= InnerToolTip.clientHeight + 30;
    TTStyle.pixelLeft = nX;
    TTStyle.pixelTop = nY + 20;
    TTStyle.visibility = 'visible';
  }
} // displaySelectToolTip()

function hideSelectTip()
{
  if (ToolTipTimer) clearTimeout(ToolTipTimer);

  if (document.getElementById)
  { // NS6/IE5+
    document.onmousemove = null;
    var TTStyle = document.getElementById('ToolTip').style;
    TTStyle.visibility = 'hidden';
    TTStyle.left = 0; // move layer to top left corner, otherwise when innerHTML
    TTStyle.top = 0;  // is set again, it may cause a horizontalscrollbar
  }
  else if (document.layers)
  { // NS4
    document.releaseEvents(Event.MOUSEMOVE);
    document.onmousemove = null;
    document.layers.ToolTip.visibility = 'hidden';
  } else if (document.all) { // IE4
    document.onmousemove = null;
    var TTStyle = document.all.ToolTip.style;
    TTStyle.visibility = 'hidden';
    TTStyle.pixelLeft = 0; // move layer to top left corner, otherwise when innerHTML
    TTStyle.pixelTop = 0;  // is set again, it may cause a horizontal scrollbar
  }
} // hideToolTip()

