/************************************************************
	
	Arquivo: js_moveMenuLateral.js
	Data: 03/11/2006
	Descrição:
		Funções para abrir/fechar o menu lateral das áreas
	
************************************************************/


//Variáveis globais do menu
var NS6 = (document.getElementById&&!document.all)
var IE = (document.all)
var NS = (navigator.appName=="Netscape" && navigator.appVersion.charAt(0)=="4")
var objMenu = document.getElementById("divPrincipalMenuLateral").style;
var objEspacamento = document.getElementById("auxEspacamentoMenu").style;
var objPosicionamentoMenu = document.getElementById("divPosMenu").style;
var moving = setTimeout('null',1);
var slideSpeed = 15;
var posMenuFechado = -239;
var posMenuAberto = 1;
var topoMenu = 190;
//variáveis de posicionamento inicial do menu de acordo com o browse
var posLeftMenu_IE = -40+'px';
var posTopMenu_IE = -190+'px';
var posLeftMenu_NS = -50+'px';
var posTopMenu_NS = -195+'px';

//define a posição final e inicial de acordo com o browser
if(IE){
	posMenuFechado = -239;
	posMenuAberto = 1;
}
if(NS || NS6){
	posMenuFechado = -229;
	posMenuAberto = 0;
}

//função para abrir o menu
function abreMenu(){
	objEspacamento.display = 'none';
	if((NS6 || NS) && parseInt(objMenu.left) < posMenuAberto || IE && objMenu.pixelLeft < posMenuAberto){
		clearTimeout(moving);
		moving = setTimeout('abreMenu()', slideSpeed);
		moveMenu(10);
	}
	else{
		clearTimeout(moving);
		moving = setTimeout('null',1)
	}
}

//função para fechar o menu
function fechaMenu(){
	if((NS6 || NS) && (parseInt(objMenu.left)-10) == (posMenuFechado) || IE && (objMenu.pixelLeft-10) == (posMenuFechado)) objEspacamento.display = '';
	
	if((NS6 || NS) && parseInt(objMenu.left) > (posMenuFechado) || IE && objMenu.pixelLeft > (posMenuFechado)){
		clearTimeout(moving);
		moving = setTimeout('fechaMenu()',slideSpeed);
		moveMenu(-10);
	}
	else{
		clearTimeout(moving);
		moving = setTimeout('null',1)
	}
}

//movimenta o menu para abrir/fechar
function moveMenu(num){
	if(IE) objMenu.pixelLeft += num;
	if(NS6) objMenu.left = parseInt(objMenu.left) + num + "px";
	if(NS) objMenu.left = parseInt(objMenu.left) + num;
}

//função para "esconder" os elementos tipo: SELECT
function escondeSelect(opc){
for(b=0;b<document.forms.length;b++){
	for(a=0;a<document.forms[b].elements.length;a++){ 
		if(document.forms[b].elements[a].tagName.toUpperCase() == 'SELECT'){
			if(!opc) 
				document.forms[b].elements[a].style.visibility = 'visible';
			if(opc)
				document.forms[b].elements[a].style.visibility = 'hidden';
		}
	}
}
}

//função de posicionamento inicial do meun
function initMenu(){
	if(IE){
		objPosicionamentoMenu.left = posLeftMenu_IE;
		objPosicionamentoMenu.top = posTopMenu_IE;
	}
	if(NS || NS6){
		objPosicionamentoMenu.left = posLeftMenu_NS;
		objPosicionamentoMenu.top = posTopMenu_NS;
	}
}

//chama a inicialização do menu
initMenu();