function setOpacity(obj, opacity) 
{
    opacity = (opacity == 100)?99.999:opacity;
    
    // IE/Win
    obj.style.filter = "alpha(opacity:"+opacity+")";
    
    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacity/100;
    
    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity/100;
    
    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity/100;
}

function attachToEvent(obj, name, func) 
{
	name = name.toLowerCase();
	if(typeof(obj.addEventListener) != "undefined")
	{
		if(name.length > 2 && name.indexOf("on") == 0) 
		{
		    name = name.substring(2, name.length);
		    obj.addEventListener(name, func, false);
		}
		
	} 
	else if ( typeof(obj.attachEvent) != "undefined" )
	{
		obj.attachEvent(name, func);
	} 
	else 
	{
		if(eval("obj." + name) != null)
		{
		// Save whatever defined in the event
		var oldOnEvents = eval("obj." + name);
		eval("obj." + name) = function(e) 
			{
			    try
			    {
					func(e);
					eval(oldOnEvents);
				} 
			    catch(e){}
			};
		} 
		else 
		{
		    eval("obj." + name) = func;
		}
	}
}



        var oTT = new Object();
	oTT._topDivZIndex = 10000;
	oTT._oBody = null;
	oTT._oIF = null;
	oTT._oTTMsg = null;
	oTT._oTTTxt = null;
	oTT._oTTDiv = null;
	oTT._mousePos = new Object();
	
	oTT._init = function()
	{
		oTT._oBody = document.getElementsByTagName("body").item(0);
		
		oTT._oIF = document.createElement("iframe");
		oTT._oIF.src = "javascript:false;";
		oTT._oIF.style.border = 0;
		oTT._oIF.style.display = "none";
		oTT._oIF.style.position = "absolute";
		oTT._oIF.style.filter = "alpha(Opacity=0)";
		oTT._oIF.width = "0px";
		oTT._oIF.height = "0px";
		
		oTT._oTTDiv = document.createElement("div");
		oTT._oTTDiv.style.display = "none";
		oTT._oTTDiv.style.position = "absolute";
		oTT._oTTDiv.width = "auto";
		oTT._oTTDiv.height = "auto";
		oTT._oTTDiv.id = "dTT";
		
		oTT._oTTMsg = document.createElement("div");
		oTT._oTTTxt = document.createTextNode("");
		oTT._oTTMsg.appendChild(oTT._oTTTxt);
		oTT._oTTMsg.id = "dTTMsg1";
		oTT._oTTMsg.width = "auto";
		oTT._oTTMsg.height = "auto";
		
		browserID = getBrowser();
	    if ( browserID == "msie" && window.ActiveXObject ) 
		{
	        oTT._oBody.appendChild(oTT._oIF);
		} 
		oTT._oTTDiv.appendChild(oTT._oTTMsg);
		oTT._oBody.appendChild(oTT._oTTDiv);
		

		attachToEvent(document, 'onmousemove', oTT._mousemove);
	}
	
	oTT._mousemove = function(e)
	{
		if(typeof(e) == 'undefined')e = event;

		oTT._mousePos.Y = (document.all) ? e.clientY : e.pageY;
		oTT._mousePos.X = (document.all) ? e.clientX : e.pageX;
				
		if(oTT._oTTDiv.style.display == "block")
		{
		    oTT._fixTipPosition();
		}
	}
	

	oTT._fixTipPosition = function()
	{
	   
		if(oTT._mousePos.Y > Math.round(oTT._oBody.clientHeight / 2))
		{
		    oTT._oTTDiv.style.top =  - 8 + oTT._mousePos.Y - oTT._oTTDiv.offsetHeight + oTT._oBody.scrollTop + "px";
		    oTT._oIF.style.top = oTT._oTTDiv.style.top;
		} 
		else 
		{
		    oTT._oTTDiv.style.top = 8 + oTT._mousePos.Y + oTT._oBody.scrollTop + "px";
		    oTT._oIF.style.top = oTT._oTTDiv.style.top;
		}
		
		if(oTT._mousePos.X > Math.round(oTT._oBody.clientWidth / 2))
		{
		    oTT._oTTDiv.style.left = - 8 + oTT._mousePos.X - oTT._oTTDiv.offsetWidth + oTT._oBody.scrollLeft + "px";
		    oTT._oIF.style.left = oTT._oTTDiv.style.left;
		} 
		else 
		{
		    oTT._oTTDiv.style.left = 8 + oTT._mousePos.X  + oTT._oBody.scrollLeft + "px";
		    oTT._oIF.style.left = oTT._oTTDiv.style.left;
		}
		oTT._oIF.width = oTT._oTTDiv.offsetWidth;
		oTT._oIF.height = oTT._oTTDiv.offsetHeight;
	}
	
	
	
	// Will show the div and the helper iframe.
	oTT.showToolTip = function(toolTipMessage)
	{
		//var divContent = document.createTextNode(toolTipMessage);
		//oTT._oTTMsg.replaceChild( divContent, oTT._oTTTxt );
		oTT._oTTMsg.innerHTML = toolTipMessage;
		oTT._mousePos;
		oTT._oIF.style.display = "block";
		oTT._oTTDiv.style.display = "block";
		setOpacity(oTT._oTTDiv, 84);
		oTT._fixTipPosition();
	}
	
	// Will hide the div and the helper iframe.
	oTT.hideToolTip = function(){
	    oTT._oIF.style.display = "none"
		oTT._oTTDiv.style.display = "none";
	}
	
	// Attach to the onload event
	attachToEvent(window, 'onload', oTT._init);

