// DrNetStudio - 02.05.000
// Scripts Utilizados em todas as lógicas
// showmessage
// setarfocus
// windowonload
// tg_menu(frameset)
// bntdesabilitacontroles()

function showmessage(){
// Função para exibir uma mensagem de alerta.

	var controle;

	controle = eval('document.all.msg');

	if (controle == null) {
		return true;
	}

	if (document.all.msg.value != ''){
		window.alert(document.all.msg.value);
		document.all.msg.value = '';
	}
	return true;
}

function setarfocus(){
// Função para setar o foco para um campo da tela.

	var controle;

	controle = eval('document.all.focus');

	if (controle == null) {
		return true;
	}

	if (eval('document.all.' + controle.name + '.disabled;') == false){
	    if (controle.value != ''){
		    eval('document.all.' + controle.value + '.focus();');		
		    controle.value = '';
	    }
	}
	return true;
}

function navegar() {

	var controle;

	controle = eval('document.all.link');

	if (controle == null) 
		return true;
	
     if (controle.value != "")
		window.open(document.all.link.value);
	
}

function windowonload(){
	// Função para disparar eventos no evento onload da página.
	
	bntsessiontimeout()
	
	// Evita o back
	history.forward(1);

	showmessage();

	setarfocus();
	
	navegar();
	
	bntconfirm();
	
	verificartg_menu();

	return true;
}

function windowonloadback(){
	// Função para disparar eventos no evento onload da página.
	
	bntsessiontimeout()
	
	showmessage();

	setarfocus();
	
	navegar();
	
	bntconfirm();

	return true;
}

function confirmarexclusao(){

	retConfirm = window.confirm('Confirma a exclusão do registro?');
    
    if (retConfirm == false) {
		return(false); 
	}
	
	return(true);
}

function tg_menu(frameset) {
 if(parent.frbanner.tgmenu) {
  window.parent.frames[frameset].cols = parent.frbanner.tgmenu;
  parent.frbanner.tgmenu = null;
  window.document.all.imgtg_menu.src = 'Images/Toolbar/tg_menu.gif';
  window.document.all.imgtg_menu.alt = 'Retrair o painel lateral';
 }
 else {
  parent.frbanner.tgmenu = window.parent.frames[frameset].cols;
  window.parent.frames[frameset].cols = '0,*';
  window.document.all.imgtg_menu.src = 'Images/Toolbar/tg_menu_off.gif';
  window.document.all.imgtg_menu.alt = 'Expandir o painel lateral';
 }
 
 return parent.frbanner.tgmenu; 
}

function verificartg_menu() {
	if (window.document.all.imgtg_menu != null && parent.frbanner != null) {
	if(parent.frbanner.tgmenu) {
		window.document.all.imgtg_menu.src = 'Images/Toolbar/tg_menu_off.gif';
		window.document.all.imgtg_menu.alt = 'Expandir o painel lateral';
	}
	else {
		window.document.all.imgtg_menu.src = 'Images/Toolbar/tg_menu.gif';
		window.document.all.imgtg_menu.alt = 'Retrair o painel lateral';
	}				
	}
	return true;
}

function bntconfirm() {
	var controle;

	controle = eval('document.all.confirm');

	if (controle != null) {
	
		if (controle.value != '') {
		
			controle.value = window.confirm(controle.value);				
			
			document.forms[0].submit();
					
		}
	}
	
	
	
	return true;
	
}

function bntsessiontimeout()
{
	return true;
}

function bntdesabilitacontroles()
{
		
	document.Form1.style.visibility='hidden';
	document.Form1.all.pnlbntprocessando.style.width="100%";
	document.Form1.all.pnlbntprocessando.style.height="100%";
	document.Form1.all.pnlbntprocessando.style.zindex=100000000000;
	document.Form1.all.pnlbntprocessando.style.visibility='visible';
	document.Form1.all.pnlbntprocessando.style.position='absolute';
	document.Form1.all.pnlbntprocessando.style.left=0;
	document.Form1.all.pnlbntprocessando.style.top=0;
	for(i=0; i < document.Form1.all.length; i++)
	{
		switch(document.Form1.all[i].type)
		{
			case 'button':
			case 'submit':
			case 'image':				
				document.Form1.all[i].style.visibility='hidden';			
		} 
		if (document.Form1.all[i].id.substr(0,3) == "lkb")
			document.Form1.all[i].style.visibility='hidden';
	} 
	
}
