var offsets = new Object();
offsets.offsetxpoint=-60;
offsets.offsetypoint=20;
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
var tipobjInd = 0;
var tipobj=[];

function initHelp(){
	if(ie||ns6){
		tipobj[0]=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
		tipobj[1]=document.all? document.all["helptip"] : document.getElementById? document.getElementById("helptip") : ""
	}
}



function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

// needs to be an object


function ddrivetip(thetext, thecolor, thewidth,offsetxpointNEW,offsetypointNEW,instance){
	tipobjInd = instance;
	if(offsetxpointNEW){offsets.offsetxpoint=offsetxpointNEW;}
	if(offsetypointNEW){offsets.offsetypoint=offsetypointNEW;}
	if (ns6||ie){
		if (typeof thewidth!="undefined" && thewidth) tipobj[instance].style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="") tipobj[instance].style.backgroundColor=thecolor
		if(tipobjInd == 0){
			tipobj[instance].innerHTML=thetext			
		}else{
			tipobj[instance].childNodes[1].innerHTML=thetext
		}
		enabletip=true
		return false
	}
}

function positiontip(e){
	instance = tipobjInd;
	if (enabletip){
		var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsets.offsetxpoint : window.innerWidth-e.clientX-offsets.offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsets.offsetypoint : window.innerHeight-e.clientY-offsets.offsetypoint-20

		var leftedge=(offsets.offsetxpoint<0)? offsets.offsetxpoint*(-1) : -1000
		if(rightedge<tipobj[instance].offsetWidth){
			tipobj[instance].style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj[instance].offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj[instance].offsetWidth+"px"
		}else if(curX<leftedge){
			tipobj[instance].style.left="5px"
		}else{
			tipobj[instance].style.left=curX+offsets.offsetxpoint+"px"
		}
//		if (bottomedge<tipobj[instance].offsetHeight){
//			tipobj[instance].style.top=ie? ietruebody().scrollTop+event.clientY-tipobj[instance].offsetHeight-offsets.offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj[instance].offsetHeight-offsets.offsetypoint+"px"
//		}else{
			tipobj[instance].style.top=curY+offsets.offsetypoint+"px"
			tipobj[instance].style.visibility="visible"
//		}
	}
}
function hideddrivetip(instance){
	if (ns6||ie){
		tipobjInd = instance;
		enabletip=false
		tipobj[instance].style.visibility="hidden"
		tipobj[instance].style.left="-1000px"
		tipobj[instance].style.backgroundColor=''
		tipobj[instance].style.width=''
	}
}

document.onmousemove=positiontip
