//var tt_div = document.getElementById("Tooltip");
var tt_div;
var arr_tt_div = Array();

function tt(t,xoffset,yoffset,ttindex)
{
	if(!xoffset)
		xoffset = 0;
	if(!yoffset)
		yoffset = 0;

	if(!tt_div)
		tt_div = document.getElementById("Tooltip");

	var tt;

	if(!ttindex)
		tt = tt_div;
	else
	{
		if(!arr_tt_div[ttindex])
		{
			var newdiv = document.createElement("div");
			newdiv.setAttribute("id","autotooltip" + ttindex);
			newdiv.style.position = "center";
			newdiv.style.cssText = "position:absolute;visibility:hidden;";

			document.body.appendChild(newdiv);
			arr_tt_div[ttindex] = document.getElementById("autotooltip" + ttindex);
		}
		tt = arr_tt_div[ttindex];
	}

	var maxh = document.body.clientHeight;
	var maxw = document.body.clientWidth;


	tt.innerHTML=t;
	
	if(tt_mousey + yoffset + tt.clientHeight > maxh)
		tt.style.top=(tt_mousey-Math.abs(yoffset)-tt.clientHeight) + "px";
	else
		tt.style.top=(tt_mousey+yoffset)+"px";

	if(tt_mousex + xoffset + tt.clientWidth > maxw)
		tt.style.left=(tt_mousex-Math.abs(xoffset)-tt.clientWidth) + "px";
	else
		tt.style.left=(tt_mousex+xoffset)+"px";
	tt.style.visibility="visible";
	tt.style.zIndex = 10000;
	//alert(tt_mousex + "x" + tt_mousey);
}

var tt_mousex,tt_mousey;
var tt_IE = document.all?true:false
if (!tt_IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

function getMouseXY(e)
{
	var tempX = 0
	var tempY = 0

	if (tt_IE) { // grab the x-y pos.s if browser is tt_IE
		tempX = event.clientX + document.body.scrollLeft
		tempY = event.clientY + document.body.scrollTop
	} else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX
		tempY = e.pageY
	}  
	// catch possible negative values in NS4
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}  
	// show the position values in the form named Show
	// in the text fields named MouseX and MouseY
	/* Follow Code	
	tt_div.style.left=tempX + "px";
	tt_div.style.top=tempY + "px";
	//*/

	tt_mousex = tempX
	tt_mousey = tempY
}

function ctt(ttindex) {
	if(!ttindex)
		tt_div.style.visibility="hidden";
	else
		arr_tt_div[ttindex].style.visibility="hidden";
}
