var offsetxpoint=-5
var offsetypoint=22
var enabletip=false

var tooltip = tooltipDIV


function s(thetext, thecolor, thewidth){
		if (typeof thewidth!="undefined"){
			tooltip.style.width=thewidth+"px"
		}
		if (typeof thecolor!="undefined" && thecolor!=""){
			tooltip.style.backgroundColor=thecolor
		}
		tooltip.innerHTML = thetext
		enabletip=true
		return false
}


function positiontip(e){
	if (enabletip){
		var curX = event.x + document.body.scrollLeft;
		var curY = event.y + document.body.scrollTop;
		var rightedge = document.body.clientWidth-event.clientX-offsetxpoint
		var bottomedge = document.body.clientHeight-event.clientY-offsetypoint
		var leftedge = (offsetxpoint<0)? offsetxpoint*(-1) : -1000
		
		if (rightedge<tooltip.offsetWidth)
			tooltip.style.left = document.body.clientWidth - tooltip.offsetWidth + document.body.scrollLeft +"px"
		else if (curX<leftedge)
			tooltip.style.left = "0px"
		else
			tooltip.style.left = curX + offsetxpoint + "px"
		
		if (bottomedge<tooltip.offsetHeight)
			tooltip.style.top = document.body.scrollTop+event.clientY-tooltip.offsetHeight-offsetypoint+"px"
		else
			tooltip.style.top = curY + offsetypoint + "px"
			
		tooltip.style.visibility="visible"
	}
}

function h(){
		enabletip=false
		tooltip.style.visibility="hidden"
		tooltip.style.left="-1000px"
		tooltip.style.backgroundColor=''
		tooltip.style.width=''
}

document.onmousemove=positiontip

