var jTipN      = "wstooltip";			//Nome do Div no CSS
var jTipX      = -60; 						//Posição horizontal do ToolTip em relação do cursor/
var jTipY      =  20; 						//Posição Vertical do ToolTip em relação do cursor//


//Não é necessário editar nada abaixo desta linha//

var sWidth     = ""
var sBackColor = ""

tooltip = {
  name : jTipN,
  offsetX : jTipX,
  offsetY : jTipY,
  tip : null
}

tooltip.init = function () {
	var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";

	if (!document.getElementById) return;
	var config = document.getElementsByTagName("tooltip").item(0)
	if(config && config.getAttribute("class")) jTipN=config.getAttribute("class"); 
	if(config && config.getAttribute("width")) sWidth=config.getAttribute("width");
	if(config && config.getAttribute("backcolor")) sBackColor=config.getAttribute("backcolor");

	this.name=jTipN;

	if(!tipContainerID){ var tipContainerID = this.name;}
	var tipContainer = document.getElementById(tipContainerID);

	if(!tipContainer) {
	  tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
		tipContainer.setAttribute("id", tipContainerID);
	  document.getElementsByTagName("body").item(0).appendChild(tipContainer);
	}
	
	if (!document.getElementById) return;
	this.tip = document.getElementById (this.name);
	if (this.tip) document.onmousemove = function (evt) {tooltip.move (evt)};
	
	var a, sTitle;
	var anchors = document.getElementsByTagName ("*");
	
	for (var i = 0; i < anchors.length; i ++) {
		a = anchors[i];
		sTitle = a.getAttribute("tooltip");
		if(sTitle) {
			a.setAttribute("tiptitle", sTitle);
			a.removeAttribute("title");
			a.onmouseover = function() {tooltip.show(this.getAttribute('tiptitle'))};
			a.onmouseout = function() {tooltip.hide()};
		}
	}
}

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

tooltip.move = function (evt) {
	var x=0, y=0;
	if (document.all) {//IE
		//x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		//y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		
		x = ietruebody().scrollLeft;
		y = ietruebody().scrollTop;
		
		x += window.event.clientX;
		y += window.event.clientY;
		
	} else {//Good Browsers
		x = evt.pageX;
		y = evt.pageY;
	}

	var rightedge=document.all&&!window.opera? ietruebody().clientWidth-event.clientX-this.offsetX : window.innerWidth-evt.clientX-this.offsetX-20
	var bottomedge=document.all&&!window.opera? ietruebody().clientHeight-event.clientY-this.offsetY : window.innerHeight-evt.clientY-this.offsetY-20
	
	var leftedge=(this.offsetX<0)? this.offsetX*(-1) : -1000

	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<this.tip.offsetWidth)
		//move the horizontal position of the menu to the left by it's width
		this.tip.style.left=document.all? ietruebody().scrollLeft+event.clientX-this.tip.offsetWidth+"px" : window.pageXOffset+evt.clientX-this.tip.offsetWidth+"px"
	else if (x<leftedge)
		this.tip.style.left="5px"
	else
		//position the horizontal position of the menu where the mouse is positioned
		this.tip.style.left=x+this.offsetX+"px"

	//same concept with the vertical position
	if (bottomedge<this.tip.offsetHeight)
		this.tip.style.top=document.all? ietruebody().scrollTop+event.clientY-this.tip.offsetHeight-this.offsetY+"px" : window.pageYOffset+evt.clientY-this.tip.offsetHeight-this.offsetY+"px"
	else
		this.tip.style.top=y+this.offsetY+"px"

	//this.tip.style.left = (x + this.offsetX) + "px";
	//this.tip.style.top = (y + this.offsetY) + "px";

	//this.tip.style.visibility="visible"

}

tooltip.show = function (text) {
	if (!this.tip) return;
	this.tip.innerHTML = text;
	this.tip.style.display = "block";

	this.tip.style.visibility="visible"

	if (sWidth !="") this.tip.style.width=sWidth+"px"
	if (sBackColor !="") this.tip.style.backgroundColor=sBackColor
}

tooltip.hide = function () {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";

	this.tip.style.visibility="hidden"
	this.tip.style.left="-1000px"
	this.tip.style.backgroundColor=''
	this.tip.style.width=''
	
}

window.onload = function () {
	tooltip.init ();
}

/*
var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip
*/


