/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function ietruebody() {
   return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}
function getHTMLobj(Id){
   return document.all ? document.all[Id] : document.getElementById ? document.getElementById(Id) : ""
}

var tooltipobj
function TooltipCollection(){
   tooltipobj = this;

   this.ie = document.all
   this.ns6 = document.getElementById && !document.all
   this.iebody = ietruebody()

   this.offsetfromcursorX = 12 //Customize x offset of tooltip
   this.offsetfromcursorY = 10 //Customize y offset of tooltip

   this.offsetdivfrompointerX = 10 //Customize x offset of tooltip DIV relative to pointer image
   this.offsetdivfrompointerY = 14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

   this.tooltipid = "dhtmltooltip"
   this.pointerid = "dhtmlpointer"
   document.writeln('<div id="' + this.tooltipid + '" style="font-family: Verdana; font-size: 9pt; '
                       + 'position: absolute; left: -300px; width: 150px; '
                       + 'border: 1px solid black; background-color: lightyellow; padding: 2px; '
                       + 'z-index: 100; visibility: hidden; '
                       + 'filter: progid:DXImageTransform.Microsoft.Shadow(color=gray, direction=135);"></div>')
   document.writeln('<div id="' + this.pointerid + '" src="img/arrow2.gif" style="'
                       + 'position: absolute; left: -300px; '
                       + 'z-index: 101; visibility: hidden;"></div>')
   this.tipobj = getHTMLobj(this.tooltipid)
   this.pointerobj = getHTMLobj(this.pointerid)
   this.enabletip = false

document.onmousemove = function positiontip(e){
   if (tooltipobj.enabletip) {
      var nondefaultpos = false
      var curX = (tooltipobj.ns6) ? e.pageX : event.clientX + tooltipobj.iebody.scrollLeft;
      var curY = (tooltipobj.ns6) ? e.pageY : event.clientY + tooltipobj.iebody.scrollTop;
//Find out how close the mouse is to the corner of the window
      var winwidth = tooltipobj.ie && !window.opera ? tooltipobj.iebody.clientWidth : window.innerWidth - 20
      var winheight = tooltipobj.ie && !window.opera ? tooltipobj.iebody.clientHeight : window.innerHeight - 20

      var rightedge = tooltipobj.ie && !window.opera ? winwidth - event.clientX - tooltipobj.offsetfromcursorX : winwidth - e.clientX - tooltipobj.offsetfromcursorX
      var bottomedge = tooltipobj.ie && !window.opera ? winheight - event.clientY - tooltipobj.offsetfromcursorY : winheight - e.clientY - tooltipobj.offsetfromcursorY

      var leftedge = (tooltipobj.offsetfromcursorX < 0) ? tooltipobj.offsetfromcursorX * (-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
      if (rightedge < tooltipobj.tipobj.offsetWidth) {
//move the horizontal position of the menu to the left by it's width
         tooltipobj.tipobj.style.left = curX - tooltipobj.tipobj.offsetWidth + "px"
         nondefaultpos = true
      } else
         if (curX < leftedge)
            tooltipobj.tipobj.style.left = "5px"
         else {
//position the horizontal position of the menu where the mouse is positioned
            tooltipobj.tipobj.style.left = curX + tooltipobj.offsetfromcursorX - tooltipobj.offsetdivfrompointerX + "px"
            tooltipobj.pointerobj.style.left = curX + tooltipobj.offsetfromcursorX + "px"
         }

//same concept with the vertical position
      if (bottomedge < tooltipobj.tipobj.offsetHeight) {
         tooltipobj.tipobj.style.top = curY - tooltipobj.tipobj.offsetHeight - tooltipobj.offsetfromcursorY + "px"
         nondefaultpos = true
      } else {
         tooltipobj.tipobj.style.top = curY + tooltipobj.offsetfromcursorY + tooltipobj.offsetdivfrompointerY + "px"
         tooltipobj.pointerobj.style.top = curY + tooltipobj.offsetfromcursorY + "px"
      }

      tooltipobj.tipobj.style.visibility = "visible"
      if (!nondefaultpos)
         tooltipobj.pointerobj.style.visibility = "visible"
      else
         tooltipobj.pointerobj.style.visibility = "hidden"
   }
}
}

function ddrivetip(thetext, thewidth, thecolor) {
   if (tooltipobj.ns6||tooltipobj.ie) {
      if (typeof thewidth != "undefined") tooltipobj.tipobj.style.width = thewidth + "px"
      if (typeof thecolor != "undefined" && thecolor != "") tooltipobj.tipobj.style.backgroundColor = thecolor
      tooltipobj.tipobj.innerHTML = thetext
      tooltipobj.enabletip = true
      return false
   }
}

function hideddrivetip() {
   if (tooltipobj.ns6||tooltipobj.ie) {
      tooltipobj.enabletip = false
      tooltipobj.tipobj.style.visibility = "hidden"
      tooltipobj.pointerobj.style.visibility = "hidden"
      tooltipobj.tipobj.style.left = "-1000px"
      tooltipobj.tipobj.style.backgroundColor = ''
      tooltipobj.tipobj.style.width = ''
   }
}


