var offsetxpoint = 30; //Customize x offset of tooltip
var offsetypoint = -10; //Customize y offset of tooltip

var enabletip = false;
var disabletip = true;

var tipobj = document.getElementById("dhtmltooltip");

function ddrivetip(thetext, thecolor, thewidth) {
	if(!disabletip) {
		if (typeof thewidth!="undefined") tipobj.style.width = thewidth+"px";
		if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor = thecolor;
		tipobj.innerHTML = thetext;
		enabletip = true;
		return false;
	}
}

function positiontip(e){
	if (enabletip){
		var curX = e.pageX;
		var curY = e.pageY;

		var rightedge = window.innerWidth-e.clientX-offsetxpoint;
		var bottomedge = window.innerHeight-offsetypoint;

		var leftedge = (offsetxpoint<0)? offsetxpoint*(-1) : -1000;

		if (rightedge<tipobj.offsetWidth) tipobj.style.left = window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
		else if (curX<leftedge) tipobj.style.left="10px"
		else tipobj.style.left=curX+offsetxpoint+"px"

		if (bottomedge<tipobj.offsetHeight) tipobj.style.top = window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		else tipobj.style.top=curY+offsetypoint+"px"

		tipobj.style.visibility="visible"
	}
}

function hideddrivetip(){
	enabletip=false
	tipobj.style.visibility="hidden"
	tipobj.style.left="-1000px"
	tipobj.style.backgroundColor=''
	tipobj.style.width=''
}

function toggletip() {
	!disabletip ? disabletip = true : disabletip = false;
}

//document.onmousemove = positiontip;