var theObj="";
var toolTipOverMessage="";
var toolTipDIV = false;
var toolTipDIVName = 'toolTipBox';
var toolTipOpacity = 0.9;
var toolTipPos = 'right';
function toolTip(text,me,size,tto,pos) {
	if(!toolTipDIV) {
		if(size!=undefined) {
			if(size=='auto') {
				style_size=';width:'+size+';';
			}else if(size!=0) {
				style_size=';width:'+size+'px;';
			} else {
				style_size='';
			}
		} else {
			style_size='';
		}
		if (pos != undefined) {
			toolTipPos = pos;
		}
		if(tto!=undefined && tto > 0) {
			toolTipOpacity = tto;
		}
		toolTipDIV = document.createElement('span');
		toolTipDIV.setAttribute('id', toolTipDIVName);
		toolTipDIV.setAttribute('style', 'display:none;position:absolute;z-index:10000;opacity:'+toolTipOpacity+';filter:alpha(opacity='+(toolTipOpacity*100)+');-moz-opacity:'+toolTipOpacity+';'+style_size);
		document.body.appendChild(toolTipDIV);
	}
	theObj=me;
	theObj.onmousemove=toolTip_updatePos;
	if(toolTipOverMessage=='')
		toolTipDIV.innerHTML=text;
	else
		toolTipDIV.innerHTML=toolTipOverMessage;
	ChangeCSSStyle(toolTipDIVName,'display','block');
	window.onscroll=toolTip_updatePos;
}
function toolTip_updatePos() {
	var ev=arguments[0]?arguments[0]:event;
	var x=ev.clientX;
	var y=ev.clientY;
	var left;
	var top;
	var width = parseInt(toolTipDIV.clientWidth);
	var height = parseInt(toolTipDIV.clientHeight);
	diffX=24;
	diffY=24;
	var window_width = toolTip_GetWindowWidth();
	var window_height = toolTip_GetWindowHeight();
	if ( document.captureEvents ) {
		left  = parseInt(ev.pageX-2+diffX);
		top = parseInt(ev.pageY-2+diffY);
		diferencia = diffY;
	} else if ( window.event.clientX ) {
		left  = x-2+diffX+document.documentElement.scrollLeft;
		top = y-2+diffY+document.documentElement.scrollTop;
		diferencia = document.documentElement.scrollTop;
	}
	if(window_width>0) {
		if(left+width>window_width-diffX || toolTipPos == 'left') {
			left = left-width-diffX-10;
		}
		if (left < 0) {
			left = 0;
		}
	}
	if(window_height>0) {
		if(y-diferencia+height>window_height) {
			if(height>top) {
				top = 0+diferencia;
			} else {
				top = top-height;
			}
		}
	}
	ChangeCSSStyle(toolTipDIVName,'left',left+'px');
	ChangeCSSStyle(toolTipDIVName,'top',top+'px');
	theObj.onmouseout=toolTip_hideMe;
}
function toolTip_hideMe() {
	ChangeCSSStyle(toolTipDIVName,'display','none');
}
function toolTip_GetWindowWidth() {
	var myWidth = 0
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} else if( document.documentElement && document.documentElement.clientWidth ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	} else if( document.body && document.body.clientWidth ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return parseInt(myWidth);
}
function toolTip_GetWindowHeight() {
	var myHeight = 0
	if( typeof( window.innerHeight ) == 'number' ) {
		//Non-IE
		myHeight = window.innerHeight;
	} else if( document.documentElement && document.documentElement.clientHeight ) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && document.body.clientHeight ) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return parseInt(myHeight);
}
