/*
* Função utilizada para o redimensionamento automático do conteúdo.
* Cassyus
* 25/04/2008
*/
var menu = null;
var corpo = null;
var logAtualizacao = null;
var imgAcaoCorpo = null;
var div_displaytagTable = null;
var areaFormulario = null;
var alturaCabecalho = new Number(90);
var alturaTitulo = new Number(150);
var alturaAreaFormulario = new Number(0);

function setFunctions() {
	try {
		menu = document.getElementById("menu");
		if ($("index")) {
			menu.style.visibility = "visible";
		} else {
			menu.onmouseover = menuActive;
			menu.onmouseout = menuDeactive;
		}
	} catch(e) {}
	try {
		corpo = document.getElementById("corpo");
	} catch(e) {}
	try {
		logAtualizacao = document.getElementById("logAtualizacao");
	} catch(e) {}
	try {
		areaFormulario = document.getElementById("areaFormulario");
	} catch(e) {}
	try {
		imgAcaoCorpo = document.getElementById("imgAcaoCorpo");
		imgAcaoCorpo.onmouseover = expandMenu;
	} catch(e) {}
	try {
		document.getElementById("processAJAX").style.display = "none";
	} catch(e) {}
	try {
		div_displaytagTable = document.getElementById("div_displaytagTable");
	} catch(e) {}
}

var areaUtilFormulario;
var altura = (document.documentElement.clientHeight || window.innerHeight || document.body.clientHeight);
areaUtilFormulario = altura - alturaCabecalho - alturaTitulo + 2 - 10;

function setViewport(e) {
	setFunctions();
	try {
		var evt = (e || event);
	} catch(e) {}
	document.body.style.height = altura + "px";
	try {
		menu.style.height = (altura - alturaCabecalho) + "px";
	} catch(e) {}
	try {
		corpo.style.height = (altura - alturaCabecalho - 40) + "px";
	} catch(e) {}
	try {
		document.getElementById("tabela").style.height = altura + "px";
	} catch(e) {}
	setFirstElementFocus();
}

function setFirstElementFocus() {
	var elementos = document.getElementsByTagName("*");
	for (i = 0; i < elementos.length; i++){
		if ((elementos[i].tagName.toUpperCase() == "INPUT") || 
			(elementos[i].tagName.toUpperCase() == "SELECT") || 
			(elementos[i].tagName.toUpperCase() == "TEXTAREA") || 
			(elementos[i].tagName.toUpperCase() == "BUTTON")){
			if ((elementos[i].type != "hidden") && !(elementos[i].readOnly) && !(elementos[i].disabled)) {
				try{
					elementos[i].focus();
				}catch(e){}
				return;
			}
		}
	}
}

window.onresize = setViewport;
window.onload = setViewport;

