var ie = document.all;
var ns6 = document.getElementById && !document.all;
var tipobj = null;
var mouseStillIn = false;
var mouseStillInID = null;

function initTooltip(tooltip) {
	if (ie||ns6) tipobj = document.all? document.all[tooltip] : document.getElementById? document.getElementById(tooltip) : "";
}

function showTip(text, id) {
	if ((ns6||ie) && (tipobj != null)){
		mouseStillIn = true;
		if (mouseStillInID != id) { //checks to see if it never left
			var top = (findPosY(id)+(id.offsetHeight*1));
			var left = findPosX(id);
			var width = id.offsetWidth;
			
			if (typeof width != "undefined") tipobj.style.width = (width - 6)+"px"; //minus 6 for padding and border
			tipobj.innerHTML=text;
			//alert(left + " " + tipobj.style.left);
			tipobj.style.left = left + "px"; //hack for new fixed layout
			tipobj.style.top = top + "px";
			tipobj.style.visibility = "visible";
		}
	}
}

function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while(obj.id != "outer-content") {
	        curleft += obj.offsetLeft;
	        if(!obj.offsetParent) break;
			obj = obj.offsetParent;
		}
	} else if (obj.x) {
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(obj) {
  var curtop = 0;
  if(obj.offsetParent)
      while(1) {
        curtop += obj.offsetTop;
        if(!obj.offsetParent)
          break;
        obj = obj.offsetParent;
      }
  else if(obj.y)
      curtop += obj.y;
  return curtop;
}

function hideTip() {
	if (mouseStillIn == false) {
		mouseStillInID = null;
		tipobj.style.visibility="hidden";
		tipobj.style.left="-1000px";
		tipobj.style.backgroundColor='';
		tipobj.style.width='';
		//tipobj.style.height='';
	}
}

function waitForHideTip(id) {
	if ((ns6||ie) && (tipobj != null)) {
		mouseStillIn = false;
		mouseStillInID = id;
		setTimeout("hideTip()", 50);
	}
}
