function TOOLTIP() {
	this.width = 200;
	this.opacity = 90;
	this.leftpos = 0;
	this.toppos = 0;
	this.cursorDistX = 10;
	this.cursorDistY = -10;
	this.text = '';
	this.title = '';
	this.obj = 0;
	this.sobj = 0;
	this.active = false;
	this.create = function() {
		if(!this.sobj) this.init();
		var t = '<TABLE cellspacing=1 class=tooltipOut><TR><TD>'+
						'<TABLE cellspacing=0 class=tooltipIn><TR><TD>'+
						'<TABLE cellspacing=0 width=' + this.width + '>';
		if (this.title) t=t+'<TR><TD class=tooltipTitle style=padding:2px;>'+this.title+'</TD></TR>';
		t=t+		'<TR><TD style=padding:2px;>'+this.text+'</TD></TR>'+
						'</TABLE></TD></TR></TABLE></TD></TR></TABLE>';
		if(document.layers) {
			this.sobj.document.write(t);
			this.sobj.document.close();
		}
		else {
			this.setOpacity();
			if(document.getElementById) document.getElementById('ToolTip').innerHTML = t;
			else document.all.ToolTip.innerHTML = t;
		}
		this.show();
	}
	this.init = function() {
		if(document.getElementById) {
			this.obj = document.getElementById('ToolTip');
			this.sobj = this.obj.style;
		}
		else if(document.all) {
			this.obj = document.all.ToolTip;
			this.sobj = this.obj.style;
		}
		else if(document.layers) {
			this.obj = document.ToolTip;
			this.sobj = this.obj;
		}
	}
	this.show = function() {
		var ext = (document.layers ? '' : 'px');
		var left = mouseX;

		if(left + this.width + this.cursorDistX > winX) left -= this.width + this.cursorDistX;
		else left += this.cursorDistX;

		if(this.leftpos)
			this.sobj.left = this.leftpos;
		else
			this.sobj.left = left + ext;
		if(this.toppos)
			this.sobj.top = this.toppos;
		else
			if(document.all) this.sobj.top = scrollHeight + 30 + mouseY + this.cursorDistY + ext; else this.sobj.top = mouseY + this.cursorDistY + ext;

		if(!this.active) {
			this.sobj.visibility = 'visible';
			this.active = true;
		}
	}
	this.hide = function() {
		if(this.sobj) this.sobj.visibility = 'hidden';
		this.active = false;
	}
	this.setOpacity = function() {
		this.sobj.filter = 'alpha(opacity=' + this.opacity + ')';
		this.sobj.mozOpacity = '.1';
		if(this.obj.filters) this.obj.filters.alpha.opacity = this.opacity;
		if(!document.all && this.sobj.setProperty) this.sobj.setProperty('-moz-opacity', this.opacity / 100, '');
	}
}
var tooltip = mouseX = mouseY = winX = 0;
if(document.layers) {
	document.write('<layer id="ToolTip"></layer>');
	document.captureEvents(Event.MOUSEMOVE);
}
else document.write('<div id="ToolTip" style="position:absolute; z-index:99"></div>');
document.onmousemove = getMouseXY;
function getMouseXY(e) {
	if(document.all) {
		mouseX = event.clientX + document.documentElement.scrollLeft;
		mouseY = event.clientY + document.documentElement.scrollTop;
	}
	else {
		mouseX = e.pageX;
		mouseY = e.pageY;
	}
	if(mouseX < 0) mouseX = 0;
	if(mouseY < 0) mouseY = 0;
		
	if (window.innerHeight && window.scrollMaxY) {	
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ 
		yScroll = document.body.scrollHeight;
	} else { 
		yScroll = document.body.offsetHeight;
	}
	if (self.innerHeight) {	
		windowHeight = self.innerHeight;
		scrollHeight = window.pageYOffset;
		yOffset = 10;
	} else if (document.documentElement && document.documentElement.clientHeight) { 
		windowHeight = document.documentElement.clientHeight;
		scrollHeight = document.documentElement.scrollTop;
		yOffset = 0;
	} else if (document.body) { 
		windowHeight = document.body.clientHeight;
		scrollHeight = document.body.scrollTop;
		yOffset = 10;
	}	

	if(document.body && document.body.offsetWidth) winX = document.body.offsetWidth - 25;
	else if(window.innerWidth) winX = window.innerWidth - 25;
	else winX = screen.width - 25;

	if(tooltip && tooltip.active) tooltip.show();
}
function toolTip(title, text, width, opacity, leftpos, toppos) {
	if(text) {
		tooltip = new TOOLTIP();
		tooltip.title = title;
		tooltip.text = text;
		if(width) tooltip.width = width;
		if(opacity) tooltip.opacity = opacity;
		if(leftpos) tooltip.leftpos = leftpos;
		if(toppos) tooltip.toppos = toppos;
		tooltip.create();
	}
	else if(tooltip) tooltip.hide();
}
