/***********************************************
* 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 Tooltip()
{	
	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.tooltip2_idDiv = ( typeof tooltip2idDiv == 'undefined' ) ? 'dhtmltooltip' : tooltip2idDiv;
	this.tooltip2_idImg = ( typeof tooltip2idImg == 'undefined' ) ? 'dhtmlpointer' : tooltip2idImg; 
	this.tooltip2_img	= ( typeof tooltip2img == 'undefined' ) ? 'img/tooltip.gif' : tooltip2img;

	document.write('<div id="'+this.tooltip2_idDiv+'"></div>') //write out tooltip DIV
	document.write('<img id="'+this.tooltip2_idImg+'" src="'+this.tooltip2_img+'" style="visibility: hidden;">') //write out pointer image

	this.ie=document.all
	this.ns6=document.getElementById && !document.all
	this.enabletip=false
	if (this.ie||this.ns6)
		this.tipobj=document.all? document.all[ this.tooltip2_idDiv ] : document.getElementById? document.getElementById( this.tooltip2_idDiv ) : ""

	this.pointerobj=document.all? document.all[ this.tooltip2_idImg ] : document.getElementById? document.getElementById( this.tooltip2_idImg ) : ""

	this.ietruebody = function()
	{
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

	this.ddrivetip = function(thetext, thewidth, thecolor)
	{
		if (this.ns6||this.ie)
		{
			if (typeof thewidth!="undefined") this.tipobj.style.width=thewidth+"px"
			if (typeof thecolor!="undefined" && thecolor!="") this.tipobj.style.backgroundColor=thecolor
			this.tipobj.innerHTML=thetext
			this.enabletip=true
			return false
		}
	}

	this.positiontip = function(e)
	{
		if (this.enabletip) 
		{
			var nondefaultpos=false
			var curX=(this.ns6)?e.pageX : event.clientX+this.ietruebody().scrollLeft;
			var curY=(this.ns6)?e.pageY : event.clientY+this.ietruebody().scrollTop;
			//Find out how close the mouse is to the corner of the window
			var winwidth=this.ie&&!window.opera? this.ietruebody().clientWidth : window.innerWidth-20
			var winheight=this.ie&&!window.opera? this.ietruebody().clientHeight : window.innerHeight-20
			
			var rightedge=this.ie&&!window.opera? winwidth-event.clientX-this.offsetfromcursorX : winwidth-e.clientX-this.offsetfromcursorX
			var bottomedge=this.ie&&!window.opera? winheight-event.clientY-this.offsetfromcursorY : winheight-e.clientY-this.offsetfromcursorY
			
			var leftedge=(this.offsetfromcursorX<0)? this.offsetfromcursorX*(-1) : -1000
			
			//if the horizontal distance isn't enough to accomodate the width of the context menu
			if (rightedge<this.tipobj.offsetWidth){
			//move the horizontal position of the menu to the left by it's width
			this.tipobj.style.left=curX-this.tipobj.offsetWidth+"px"
			nondefaultpos=true
			}
			else if (curX<leftedge)
			this.tipobj.style.left="5px"
			else{
			//position the horizontal position of the menu where the mouse is positioned
			this.tipobj.style.left=curX+this.offsetfromcursorX-this.offsetdivfrompointerX+"px"
			this.pointerobj.style.left=curX+this.offsetfromcursorX+"px"
			}
			
			//same concept with the vertical position
			if (bottomedge<this.tipobj.offsetHeight){
			this.tipobj.style.top=curY-this.tipobj.offsetHeight-this.offsetfromcursorY+"px"
			nondefaultpos=true
			}
			else{
			this.tipobj.style.top=curY+this.offsetfromcursorY+this.offsetdivfrompointerY+"px"
			this.pointerobj.style.top=curY+this.offsetfromcursorY+"px"
			}
			this.tipobj.style.visibility="visible"
			if (!nondefaultpos)
			this.pointerobj.style.visibility="visible"
			else
			this.pointerobj.style.visibility="hidden"
		}
	}

	this.hideddrivetip = function()
	{
		if (this.ns6||this.ie)
		{
			this.enabletip=false
			this.tipobj.style.visibility="hidden"
			this.pointerobj.style.visibility="hidden"
			this.tipobj.style.left="-1000px"
			this.tipobj.style.backgroundColor=''
			this.tipobj.style.width=''
		}
	}
}
var tooltip = new Tooltip();
Event.observe( document, "mousemove", tooltip.positiontip.bind( tooltip ) );
//document.onmousemove = Tooltip.positiontip;
