// Função para colorir as linhas das tabelas ao entrar e sair
var markedRow = new Array();
function changeColorTR(theRow, thePointerColor, theNormalBgColor)
{
	var theCells = null;

	if (thePointerColor == '' || typeof(theRow.style) == 'undefined')
	{
		//return false;
	}
	if (typeof(document.getElementsByTagName) != 'undefined') 
	{
		theCells = theRow.getElementsByTagName('td');
	}
	else if (typeof(theRow.cells) != 'undefined')
	{
		 theCells = theRow.cells;
	}
	else
	{
	 return false;
	}

	var rowCellsCnt  = theCells.length;
	var currentColor = null;
	var newColor     = null;

	if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined')
	{
		currentColor = theCells[0].getAttribute('bgcolor');
		if ( currentColor == null )	{
			currentColor = "";
		}

		newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase()) ? theNormalBgColor : thePointerColor;
		for(var c = 0; c < rowCellsCnt; c++)
		{
			theCells[c].setAttribute('bgcolor', newColor, 0);
		}
	}
	else
	{
		currentColor = theCells[0].style.backgroundColor;
		newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase()) ? theNormalBgColor : thePointerColor;
 		for(var c = 0; c < rowCellsCnt; c++)
 		{
			theCells[c].style.backgroundColor = newColor;
		}
	}
	return true;
}

// Função para colorir menu
function menuChangeColorTD(tds, bgclr, txtclr)
{
	if(tds == 'all')
	{
		for(i=1; i<=7; i++)
		{
			var td = document.getElementById('TD'+i);
			td.style.backgroundColor = bgclr;
			td.style.color = txtclr;
		}
	}
	else
	{
		var td = document.getElementById(tds);
		td.style.backgroundColor = bgclr;
		td.style.color = txtclr;
	}
}


function menuHideMenuItem(menuItem)
{
	if(menuItem == 'all')
	{
		for(i=1; i<=7; i++)
		{
			document.getElementById('Menu'+i).style.display = 'none';
		}
	}
	else
	{
		document.getElementById(menuItem).style.display = 'none';
	}
}

function menuBackActivePage(activePage)
{
	//desativa todos os menus
	menuChangeColorTD('all','#FFFFFF', '#86C128'); 
	//oculte todos os menu-itens
	menuHideMenuItem('all');
	//ativa o menu corrente
	var td = document.getElementById('TD'+activePage);
	td.style.backgroundColor = '#86C128';
	td.style.color = '#FFFFFF';
	//ative o menu-item corrente
	document.getElementById('Menu'+activePage).style.display = 'block';
}

function menuActivePageCurr(activePage, activePageCurr)
{
	//desativa todos os menus
	menuChangeColorTD('all','#FFFFFF', '#86C128'); 
	//oculte todos os menu-itens
	menuHideMenuItem('all');
	
	//ativa o menu da pagina ativa
	var td = document.getElementById('TD'+activePage);
	td.style.backgroundColor = '#86C128';
	td.style.color = '#FFFFFF';
	//ative o menu-item corrente
	//document.getElementById('Menu'+activePage).style.display = 'block';
	
	//ativa o menu da pagina corrente
	var tdCurr = document.getElementById('TD'+activePageCurr);
	tdCurr.style.backgroundColor = '#86C128';
	tdCurr.style.color = '#FFFFFF';
	//ative o menu-item corrente
	document.getElementById('Menu'+activePageCurr).style.display = 'block';
}

function layerHideLayer(lay)
{
	if(lay == 'all')
	{
		for(i=1; i<=2; i++)
		{
			document.getElementById('Layer'+i).style.display = 'none';
			document.getElementById('Layer'+i).style.visibility = 'hidden';
		}
	}
	else
	{
		document.getElementById(lay).style.display = 'none';
		document.getElementById(lay).style.visibility = 'hidden';		
	}
}

function layerShowLayer(activeLay)
{
	document.getElementById('Layer'+activeLay).style.display = 'block';
	document.getElementById('Layer'+activeLay).style.visibility = 'visible';
}



/* ================================= */
/* MODIFICA A COR DO FUNDO DA CÉLULA */
/* ================================= */
function TDMouseOveR(Object)
{
	document.getElementById(Object).style.backgroundColor= "#86C128"; document.getElementById("a" + Object).style.color = "#FFFFFF";	
}

/* ================================= */
/* RETORNA O MENU AO ESTADO ORIGINAL */
/* ================================= */
function DesativaMouseOveR()
{
	document.getElementById('TD1').style.backgroundColor= "#FFFFFF"; document.getElementById('aTD1').style.color = "#649712";
	document.getElementById('TD2').style.backgroundColor= "#FFFFFF"; document.getElementById('aTD2').style.color = "#649712";
	document.getElementById('TD3').style.backgroundColor= "#FFFFFF"; document.getElementById('aTD3').style.color = "#649712";
	document.getElementById('TD4').style.backgroundColor= "#FFFFFF"; document.getElementById('aTD4').style.color = "#649712";
	document.getElementById('TD5').style.backgroundColor= "#FFFFFF"; document.getElementById('aTD5').style.color = "#649712";
	document.getElementById('TD6').style.backgroundColor= "#FFFFFF"; document.getElementById('aTD6').style.color = "#649712";
	document.getElementById('TD7').style.backgroundColor= "#FFFFFF"; document.getElementById('aTD7').style.color = "#649712";
}

/* ================================= */
/*  MOSTRA O SUBMENU ESPECIFICADO    */
/* ================================= */
function MostraSubMenu(NomeDoMenU)
{
	document.getElementById(NomeDoMenU).style.display = 'block';
}

/* ================================= */
/* ESCONDE TODOS OS SUBMENUS DA TELA */
/* ================================= */
function EscondeSubMenU()
{
	document.getElementById('Menu1').style.display = 'none';
	document.getElementById('Menu2').style.display = 'none';
	document.getElementById('Menu3').style.display = 'none';
	document.getElementById('Menu4').style.display = 'none';
	document.getElementById('Menu5').style.display = 'none';
	document.getElementById('Menu6').style.display = 'none';
	document.getElementById('Menu7').style.display = 'none';
}


function onTextEnter(fld) 
{
	fld.style.background = '#FFCC66';
	fld.style.color = '#666666';
	fld.style.fontWeight = 'bold';
}

function onTextExit(fld)
{
	fld.style.background='#FFFFFF';
	fld.style.color = '#000000';
	fld.style.fontWeight = 'normal';
}