function ini(){
	//controla o tempo de sessao. 300=5min
	initTimer(300, 1,"opcao('acoes/PADRAO/SAIR/logout.php','SESSÃO EXPIRADA','load','Deslogando...','principal')", "relogio");
}

function carregar_camada_inicial(tipo,variaveis) {
document.getElementById('topo').innerHTML="<img src='imagens/principal/topo.jpg'>";
	if(tipo=='E'){
		document.getElementById('principal').innerHTML=opcao('acoes/PADRAO/loginEasy.php',variaveis,'load','Carregando sistema...','principal');
	}else{
		document.getElementById('principal').innerHTML=opcao('acoes/PADRAO/login.php','','load','Carregando tela de Login...','principal');
	}
document.getElementById('rodape').innerHTML='<img src=imagens/principal/rodape.jpg>';


}

function carregar_menu() {
	opcao('topo.php','','load','','topo');
//document.getElementById('topo').innerHTML="<img src='imagens/principal/topo.jpg'>";
//document.getElementById('principal').innerHTML='<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>';
document.getElementById('rodape').innerHTML='<img src=imagens/principal/rodape.jpg>';
//opcao('topo.php','','load','','topo');



}

function erro_endereco(tipo,msg,div){
	if(div==''){
		div='erro';	
	}
		if(tipo=='ok'){
		document.getElementById(div).innerHTML="<div class='tabela_ok'><img width='50' heigth='50' src=../admin/imagens/geral/ok_green.gif><span class='central'>"+msg+"</span></div>";
	}
	
	if(tipo=='alerta'){
		document.getElementById(div).innerHTML="<div class='tabela_alerta'><img width='50' heigth='50'  src=../admin/imagens/geral/attention.gif><span class='central'>"+msg+"</span></div>";
	}
	
	if(tipo=='fatal'){
		document.getElementById(div).innerHTML="<div class='tabela_fatal'><img width='50' heigth='50'  src=../admin/imagens/geral/cross.gif><span class='central'>"+msg+"</span></div>";
	}
		if(tipo==''){
		document.getElementById(div).innerHTML="";
	}
}

function somente_numero(campo){
    var digits="0123456789"
    var campo_temp 
    for (var i=0;i<campo.value.length;i++){
      campo_temp=campo.value.substring(i,i+1)    
      if (digits.indexOf(campo_temp)==-1){
            campo.value = campo.value.substring(0,i);
            break;
       }
    }
}

// valida email
function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){ 
         return true; 
                }
    }else{
        return false;
        }
}

//trim completo
	function trim(str) {
		return str.replace(/^\s+|\s+$/g,"");
	}
 
//left trim
	function ltrim(str) {
		return str.replace(/^\s+/,"");
	}
 
//right trim
	function rtrim(str) {
		return str.replace(/\s+$/,"");
	}
	

//verifica se o campo está preenchido ou não, se for vazio, altera a classe do objeto.
	function requerido(obj){
		var diverro='';
		if(document.getElementById('respopup')){
			 diverro='respopup';
		}else{
			 diverro='erro';
		}	

		with (obj){
			if (value==null||value==""){
				var classe=obj.className;
				obj.className="requerido";
				erro('alerta','Preencha o(s) campo(s) obrigatorio(s)!',diverro);
				return false;
			}else{
				obj.className=classe;
				return true;
			}
		}	
	}

	
function contaTexto(field, countfield, maxlimit) {
	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
	}else {
		countfield.value = maxlimit - field.value.length;
	}
}	

function setFoco(nomecampo){
	document.getElementById(nomecampo).focus();	
}

//verifica se o campo informado possui o minimo de caracteres preenchidos, remove espaços para evitar espertinhos
function verifica(nomecampo,tamanho){	
	var valor='';
	valor=document.getElementById(nomecampo).value;
	valor = String(valor).replace(/ /g,''); 
	if(valor.length >= tamanho){
		return true;
	}else{
		return false;	
	}	
}

//retorna o valor de um campo informado
function getVal(obj){
	return document.getElementById(obj).value;	
}

//seta o valor de um campo
function setVal(obj,valor){
	return document.getElementById(obj).value=valor;		
}

function exibeAjuda(campo,msg) {
	var descricao = document.getElementById('ajuda'+campo)
		descricao.style.display = 'block'
		descricao.innerHTML = msg
}

function ocultaAjuda(campo) {
	var descricao = document.getElementById('ajuda'+campo)
		descricao.style.display = 'none'

}


/*
function bloqueiaMenu(TPU_CO_TIPO){

	var x=document.getElementsByTagName("li");
	    for(var i=0;i<x.length;i++){//percorre todos os elementod do menu
	   		x[i].disabled=true;//bloqueia todos os itens
	  		if(x[i].id=='li_'+TPU_CO_TIPO){//libera os permitidos para o tipo de usuario
	  			x[i].disabled=false;
	  			}
	   		if(x[i].id=='li_'){//libera os permitidos para todos os usuarios(TPU_CO_TIPO is NULL)
	  			x[i].disabled=false;
	   		}
	  	}
	var y=document.getElementsByName("linkmenu");
	    for(var j=0;j<y.length;j++){//percorre todos os elementod do menu
	   		y[j].disabled=true;//bloqueia todos os itens
	  			   		
	   		if(y[j].id=='h_'+TPU_CO_TIPO){//libera os permitidos para o tipo de usuario
	  			y[j].disabled=false;
	  			}
	  			
	   		if(y[j].id=='h_'){//libera os permitidos para todos os usuarios(TPU_CO_TIPO is NULL)
	  			y[j].disabled=false;
	  			y[j].heigth=0;
	   		}
	  	}  	
}
*/	
