//*****************************************************************************
// Objetivo:              Codigo para geracao dos hint
// Autor:                 Anderson Alessandro Pavia (*)(ver comentarios)
// Data:                  31/08/2006
//
// Comentários:          (*) codigo extraído da internet: http://www.dynamicdrive.com/
//                           adaptado para o manual do desenvolvedor
//                           segue o comentario original da pagina
//
//                        ALTTXT V1.2
//                        BY: BRIAN GOSSELIN OF SCRIPTASYLUM.COM
//                        ADDED FADING EFFECT FOR IE4+ AND NS6+ ONLY AND OPTIMIZED THE CODE A BIT.
//                        SCRIPT FEATURED ON DYNAMIC DRIVE (http://www.dynamicdrive.com)
//                        Modifed by DD for doctype bug on Nov 13th, 2003
//
// Alterado Por:
// Data:
// Motivo da Alteração:
//*****************************************************************************
// Componentes Usados:    nao se aplica
// Entradas:              nenhuma
// retorno:               nenhum
//*****************************************************************************

var blnDoFade     = false; // ENABLES FADE-IN EFFECT FOR IE4+ AND NS6 ONLY
var blnCenter     = false; // CENTERS THE BOX UNER THE MOUSE, OTHERWISE DISPLAYS BOX TO THE RIGHT OF THE MOUSE
var blnCenterText = false; // CENTERS THE TEXT INSIDE THE BOX. YOU CAN'T SIMPLY DO THIS VIA STYLE BECAUSE OF NS4.
                           // OTHERWISE, TEXT IS LEFT-JUSTIFIED.






////////////////////////////// NO NEED TO EDIT BEYOND THIS POINT //////////////////////////////////////





//*****************************************************************************
// Objetivo  : Buscar referencia para ...
// Premissas : --
// Entradas  : --
// Retorno   : referencia para ...
//*****************************************************************************
function ietruebody()
{
	return (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body
}

var blnNS4 = (navigator.appName.indexOf("Netscape") >= 0 && !document.getElementById) ? true : false; // NS4
var blnIE4 = (document.all && !document.getElementById) ? true : false;                               // IE4
var blnIE5 = (document.getElementById && document.all) ? true : false;                                // IE5
var blnNS6 = (document.getElementById && navigator.appName.indexOf("Netscape") >= 0 ) ? true : false; // NS6
var blnW3C = (document.getElementById) ? true : false;                                                // W3C
var intWY, intWX, navtxt, intBoxHeight, intBoxWidth; // WY, WX, boxh, boxw
var blnIsHover = false;  // ishover
var blnIsLoaded = false; // isloaded
var intIEOP = 0;         // ieop
var intOPID = 0;         // opid

//*****************************************************************************
// Objetivo  : Recupera os limites da janela
// Premissas : --
// Entradas  : --
// Retorno   : --
//*****************************************************************************
function getwindowdims()
{
	intWY = (blnNS4 || blnNS6 || window.opera) ? window.innerHeight : (blnIE5 || blnIE4) ? document.body.clientHeight : 0;
	intWX = (blnNS4 || blnNS6 || window.opera) ? window.innerWidth  : (blnIE5 || blnIE4) ? document.body.clientWidth  : 0;
}

//*****************************************************************************
// Objetivo  : Recupera o boxwidth
// Premissas : --
// Entradas  : --
// Retorno   : --
//*****************************************************************************
function getboxwidth()
{
	if(blnNS4)           intBoxWidth = (navtxt.document.width)   ? navtxt.document.width        : navtxt.clip.width;
	if(blnIE5 || blnIE4) intBoxWidth = (navtxt.style.pixelWidth) ? navtxt.style.pixelWidth      : navtxt.offsetWidth;
	if(blnNS6)           intBoxWidth = (navtxt.style.width)      ? parseInt(navtxt.style.width) : parseInt(navtxt.offsetWidth);
}

//*****************************************************************************
// Objetivo  : Recupera o boxheight
// Premissas : --
// Entradas  : --
// Retorno   : --
//*****************************************************************************
function getboxheight()
{
	if(blnNS4)           intBoxHeight = (navtxt.document.height    )? navtxt.document.height  : navtxt.clip.height;
	if(blnIE4 || blnIE5) intBoxHeight = (navtxt.style.pixelHeight) ? navtxt.style.pixelHeight : navtxt.offsetHeight;
	if(blnNS6)           intBoxHeight = parseInt(navtxt.offsetHeight);
}

//*****************************************************************************
// Objetivo  : Move o hint
// Premissas : --
// Entradas  : intX -> posicao horizontal
//             intY -> posicao vertical
// Retorno   : --
//*****************************************************************************
function movenavtxt(intX, intY)
{
	if(blnNS4) navtxt.moveTo(intX, intY);
	if(blnW3C || blnIE4)
	{
		navtxt.style.left = intX + 'px';
		navtxt.style.top = intY + 'px';
	}
}

//*****************************************************************************
// Objetivo  : Recupera o pagescrolly
// Premissas : --
// Entradas  : --
// Retorno   : --
//*****************************************************************************
function getpagescrolly()
{
	if(blnNS4 || blnNS6) return window.pageYOffset;
	if(blnIE5 || blnIE4) return ietruebody().scrollTop;
}

//*****************************************************************************
// Objetivo  : Recupera o pagescrollx
// Premissas : --
// Entradas  : x -> posicao horizontal
//             y -> posicao vertical
// Retorno   : --
//*****************************************************************************
function getpagescrollx()
{
	if(blnNS4 || blnNS6) return window.pageXOffset;
	if(blnIE5 || blnIE4) return ietruebody().scrollLeft;
}

//*****************************************************************************
// Objetivo  : Escreve no div
// Premissas : --
// Entradas  : strText -> texto a escrever
// Retorno   : --
//*****************************************************************************
function writeindiv(strText)
{
	if(blnNS4)
	{
		navtxt.document.open();
		navtxt.document.write(strText);
		navtxt.document.close();
	}
	if(blnW3C || blnIE4) navtxt.innerHTML = strText;
}

//**** END UTILITY FUNCTIONS ****//

//*****************************************************************************
// Objetivo  : Escreve
// Premissas : --
// Entradas  : strText -> text
// Retorno   : --
//*****************************************************************************
function writetxt(strText)
{
	if(blnIsLoaded)
	{
		if(strText != 0)
		{
			blnIsHover=true;
			if(blnNS4) strText = '<div class="navtext">' + ((blnCenterText) ? '<center>' : '') + strText + ((blnCenterText) ? '</center>':'') + '</div>';
			writeindiv(strText);
			getboxheight();
			if((blnW3C || blnIE4) && blnDoFade)
			{
				intIEOP = 0;
				incropacity();
			}
		}
		else
		{
			if(blnNS4)navtxt.visibility = "hide";
			if(blnIE4 || blnW3C)
			{
				if(blnDoFade)clearTimeout(intOPID);
				navtxt.style.visibility = "hidden";
			}
			writeindiv('');
			blnIsHover = false;
		}
	}
}

//*****************************************************************************
// Objetivo  : Seta opacity
// Premissas : --
// Entradas  : --
// Retorno   : --
//*****************************************************************************
function incropacity()
{
	if(intIEOP <= 100)
	{
		intIEOP += 7;
		if(blnIE4 || blnIE5) navtxt.style.filter = "alpha(opacity=" + intIEOP + ")";
		if(blnNS6)           navtxt.style.MozOpacity = intIEOP / 100;
		intOPID = setTimeout('incropacity()', 50);
	}
}

//*****************************************************************************
// Objetivo  : Move o objeto
// Premissas : --
// Entradas  : objEVT -> objeto do evento
// Retorno   : --
//*****************************************************************************
function moveobj(objEVT)
{
	var intMX;     // mx
	var intMY;     // my
	var intXOFF;   // xoff
	var intYOFF;   // yoff
	var intMargin; // margin
	
	if(blnIsLoaded && blnIsHover)
	{
		intMargin = (blnIE4 || blnIE5) ? 1 : 23;
		if(blnNS6) if(document.height + 27 - window.innerHeight < 0) intMargin = 15;
		if(blnNS4) if(document.height - window.innerHeight < 0)      intMargin = 10;
		//intMX = (blnNS4||blnNS6)? objEVT.pageX : (blnIE5 || blnIE4) ? event.clientX : 0;
		//intMY = (blnNS4||blnNS6)? objEVT.pageY : (blnIE5 || blnIE4) ? event.clientY : 0;
		if (blnNS4)
		{
			intMX = objEVT.pageX
			intMY = objEVT.pageY
		}
		else if (blnNS6)
		{
			intMX = objEVT.clientX
			intMY = objEVT.clientY
		}
		else if (blnIE5)
		{
			intMX = event.clientX
			intMY = event.clientY
		}
		else if (blnIE4)
		{
			intMX = 0
			intMY = 0
		}

		if(blnNS4)
		{
			intMX -= getpagescrollx();
			intMY -= getpagescrolly();
		}
		intXOFF = (blnCenter) ? intMX - intBoxWidth / 2 : intMX + 5;
		intYOFF = (intMY + intBoxHeight + 30 - getpagescrolly() + intMargin >= intWY) ? -15 - intBoxHeight : 30;
		movenavtxt( Math.min(intWX - intBoxWidth - intMargin , Math.max(2, intXOFF)) + getpagescrollx(), intMY + intYOFF + getpagescrolly());
		if(blnNS4)          navtxt.visibility       = "show";
		if(blnW3C ||blnIE4) navtxt.style.visibility = "visible";
	}
}

if(blnNS4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = moveobj;

//*****************************************************************************
// Objetivo  : Carrega o hint
// Premissas : --
// Entradas  : --
// Retorno   : --
//*****************************************************************************  
function loadnavtxt()
{
	navtxt = (blnNS4) ? document.layers['navtxt'] : (blnIE4) ? document.all['navtxt'] : (blnW3C) ? document.getElementById('navtxt') : null;
	getboxwidth();
	getboxheight();
	getwindowdims();
	blnIsLoaded = true;
	if((blnW3C || blnIE4) && blnCenterText) navtxt.style.textAlign = "center";
	if(blnW3C)                              navtxt.style.padding   = '4px';
	if(blnIE4 || blnIE5 && blnDoFade)       navtxt.style.filter    = "alpha(opacity=0)";
}

window.onresize = getwindowdims;