/***********************************************
* 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
***********************************************/
/***********************************************
* 
* This version has been modified to allow use of fixed tooltips
*
*
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip" onmouseover="ddrivehold()" onmousemove="ddrivehold()" onmouseout="ddriveendmouseover()"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false

var fixed=false     //Added By Judson 1/19/07 to give an option of a fixed of following tooltip
var fixedx
var fixedy
var fixedbaseimage
var showtime = 3000  //time in milliseconds
var lastupdatetime = 0
var mouseoverfixed = false

if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody()
	{
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

function ddrivetip(thetext, thewidth, thecolor)
	{
		if (ns6||ie)
			{
				if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
				if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
				tipobj.innerHTML=thetext
				//Added by Judson 1/19/06 to distinguish that the tooltip is not fixed
				fixed=false
				enabletip=true
				return false
			}
	}

//Added by Judson 1/19/06 
//  function to put a fixed tooltip
function ddrivetipfixed(thetext, thewidth, thecolor, thefixedbaseimage, thefixedx, thefixedy)
	{
		if (ns6||ie)
			{
				if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
				if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
				fixed = true
				if (typeof thefixedbaseimage=="string") fixedbaseimage = document.images[thefixedbaseimage];
				else	alert("Incorrect Image Reference Type")
				
				if (typeof thefixedx!="undefined") fixedx = thefixedx
				if (typeof thefixedy!="undefined") fixedy = thefixedy
				tipobj.innerHTML=thetext
				enabletip=true
			
				mouseoverfixed = true;
				return false
			}
	}

//Added by Judson 1/19/06
// used to keep tooltip on when mouse is over the tooltip instead of the link
function ddrivehold()
{
	mouseoverfixed = true;
}


//Added by Judson 1/19/06
// special function to tell the script that the mouse-over has stopped
function ddriveendmouseover()
	{
		if(fixed)
		{
			mouseoverfixed = false;
			lastupdatetime = (new Date())		 // 
			self.setTimeout('timehandler()', 500)	 //			
		}
		else
			hideddrivetip();
	}


function positiontip(e)
	{
		if (enabletip)
		{
			if (fixed)	//Added by Judson 1/19/2007  - This section is different, for the fixed condition
			{		//   the original is inside the "else" section, for non-fixed
/*  Old Version - keeps the moving style that just isn't so great
				var nondefaultpos=false

				//Hacked the following lines for positioning:
				//var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
				//var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
				var curX=getImageLeft() + fixedx - offsetfromcursorX
				var curY=getImageTop() + fixedy - offsetfromcursorY
				
				//Find out how close the mouse is to the corner of the window
				var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
				var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20
				var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
				var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY
				var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000
				//if the horizontal distance isn't enough to accomodate the width of the context menu
				if (rightedge<tipobj.offsetWidth)
					{
						//move the horizontal position of the menu to the left by it's width
						tipobj.style.left=curX-tipobj.offsetWidth+"px"
						nondefaultpos=true
					}
				else if (curX<leftedge)
				tipobj.style.left="5px"
				else
					{
						//position the horizontal position of the menu where the mouse is positioned
						tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
						pointerobj.style.left=curX+offsetfromcursorX+"px"
					}
				//same concept with the vertical position
				if (bottomedge<tipobj.offsetHeight)
					{
						tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
						nondefaultpos=true
					}
				else
					{
						tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
						pointerobj.style.top=curY+offsetfromcursorY+"px"
					}
				tipobj.style.visibility="visible"
				if (!nondefaultpos)
				pointerobj.style.visibility="visible"
				else
				pointerobj.style.visibility="hidden"
				
				if(mouseoverfixed)					// Only reset disapper-timer if cursor is on the hotspot or tooltip
				{
					lastupdatetime = (new Date())		 // 
					self.setTimeout('timehandler()', 500)	 //
				}
*/

//New Version that fixes the tooltip at the exact spot you say, regardless of the size of the window

				//Hacked the following lines for positioning:
				//var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
				//var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
				var curX=getImageLeft() + fixedx
				tipobj.style.left=curX+"px"
				pointerobj.style.left="0px"

				var curY=getImageTop() + fixedy 
				tipobj.style.top=curY+"px"
				pointerobj.style.top="0px"

				tipobj.style.visibility="visible"
				pointerobj.style.visibility="hidden"

				
				if(mouseoverfixed)					// Only reset disapper-timer if cursor is on the hotspot or tooltip
				{
					lastupdatetime = (new Date())		 // 
					self.setTimeout('timehandler()', 500)	 //
				}




			}
			else		//Modified by Judson 1/19/07 - this is the original moving-tooltip section, put inside a conditional
			{		// to run only when not fixed
				var nondefaultpos=false
				var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
				var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
				//Find out how close the mouse is to the corner of the window
				var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
				var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20
				var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
				var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY
				var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000
				//if the horizontal distance isn't enough to accomodate the width of the context menu
				if (rightedge<tipobj.offsetWidth)
					{
						//move the horizontal position of the menu to the left by it's width
						tipobj.style.left=curX-tipobj.offsetWidth+"px"
						nondefaultpos=true
					}
				else if (curX<leftedge)
				tipobj.style.left="5px"
				else
					{
						//position the horizontal position of the menu where the mouse is positioned
						tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
						pointerobj.style.left=curX+offsetfromcursorX+"px"
					}
				//same concept with the vertical position
				if (bottomedge<tipobj.offsetHeight)
					{
						tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
						nondefaultpos=true
					}
				else
					{
						tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
						pointerobj.style.top=curY+offsetfromcursorY+"px"
					}
				tipobj.style.visibility="visible"
				if (!nondefaultpos)
				pointerobj.style.visibility="visible"
				else
				pointerobj.style.visibility="hidden"
			}
		
			
		
		}
	}

function hideddrivetip()
	{
		if (ns6||ie)
			{
				enabletip=false
				tipobj.style.visibility="hidden"
				pointerobj.style.visibility="hidden"
				tipobj.style.left="-1000px"
				tipobj.style.backgroundColor=''
				tipobj.style.width=''
			}
	}

//Added By Judson 1/19/2007
// Make fixed tooltips go away after specified time
function timehandler()
{
	var currtime = new Date()
	if(enabletip & (!mouseoverfixed))
	{
		if((currtime-lastupdatetime) >showtime)
		{
			if(fixed)
				hideddrivetip()
		}
		else
		{
			self.setTimeout('timehandler()', 500)  //Not time?  Run the timeout longer
		}
	}
}

//All Below Added By Judson 1/19/2007

//Calculate Corner Position of Image IE/NS compatible
function getImageLeft()
{
	if(ns6) return eval(fixedbaseimage).x
	else
	{
		xPos = eval(fixedbaseimage).offsetLeft;
		tempEl = eval(fixedbaseimage).offsetParent;
	  	while (tempEl != null) {
	  		xPos += tempEl.offsetLeft;
  			tempEl = tempEl.offsetParent;
  		}
		return xPos;
	}
}

function getImageTop()
{
	if(ns6) return eval(fixedbaseimage).y
	else
	{
		yPos = eval(fixedbaseimage).offsetTop;
		tempEl = eval(fixedbaseimage).offsetParent;
		while (tempEl != null) {
	  		yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
	  	}
		return yPos;
	}
}


// Code Ripped From: http://www.webreference.com/js/tips/991219.html
// "December 19, 1999"
// "Deriving An Image's Coordinates"
// "Tips: December 1999"
//
//Yehuda Shiran, Ph.D.
//
//Get ID:
//var holdingImage = document.images["holdspace"];
//
//Get Position:
//NS
//function docjslib_getImageXfromLeft(imgID) {
//  if (NS4) return eval(imgID).x
//  else return docjslib_getRealLeft(imgID);
//}

//function docjslib_getImageYfromTop(imgID) {
//  if (NS4) return eval(imgID).y
//  else return docjslib_getRealTop(imgID);
//}

//IE
//function docjslib_getRealLeft(imgElem) {
//	xPos = eval(imgElem).offsetLeft;
//	tempEl = eval(imgElem).offsetParent;
//  	while (tempEl != null) {
//  		xPos += tempEl.offsetLeft;
//  		tempEl = tempEl.offsetParent;
//  	}
//	return xPos;
//}

//function docjslib_getRealTop(imgElem) {
//	yPos = eval(imgElem).offsetTop;
//	tempEl = eval(imgElem).offsetParent;
//	while (tempEl != null) {
//  		yPos += tempEl.offsetTop;
//  		tempEl = tempEl.offsetParent;
//  	}
//	return yPos;
//}

// End






document.onmousemove=positiontip