function loadFragmentInToElement(fragment_url, element_id, modo, parametros) {
    if(element_id=="_top"){
        element_id="mainframe";
    }
    var xmlhttp;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	}else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	try{
        var element = document.getElementById(element_id);
        element.innerHTML = "<div style='position:absolute;top:0;left:0;'><img src=imagens/ajax-loader.gif></div>";
    }catch(e){
        var element = parent.document.getElementById(element_id);
    }
    fragment_url = fragment_url
    try{
        xmlhttp.open(modo, fragment_url);
    }catch(e){
        xmlhttp.open(modo, "principal/acessa_url_externa.asp");
        xmlhttp.open(modo, "../principal/acessa_url_externa.asp");
        parametros= parametros +"&URL="+fragment_url;
    }
    if(modo == "POST"){
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		xmlhttp.setRequestHeader("Pragma", "no-cache");
    }else{
        
    }
   
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            element.innerHTML = xmlhttp.responseText;
        }
    }
    
    if(modo == "GET"){
		xmlhttp.send();
	}else{
		xmlhttp.send(parametros);
	}
    
}



function loadMenuInToElement(fragment_url, element_id, modo, parametros) {

    var xmlhttp;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	}else if (window.ActiveXObject) {
	
	    
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
    var element = document.getElementById(element_id);
    //element.innerHTML = "<div style='position:absolute;top:0;left:0;'><img src=imagens/ajax-loader.gif></div>";
    fragment_url = fragment_url
    try{
        xmlhttp.open(modo, fragment_url);
    }catch(e){
        xmlhttp.open(modo, "principal/acessa_url_externa.asp?URL="+fragment_url);
    }
    
    if(modo == "POST"){
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
		xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
		xmlhttp.setRequestHeader("Pragma", "no-cache");
    }else{
        
    }
    
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            element.innerHTML = xmlhttp.responseText;
        }
    }
    if(modo == "GET"){
		xmlhttp.send();
	}else{
		xmlhttp.send(parametros);
	}
    
}



function menu(meuLayer,minhaImg,imgMais,imgMenos) {
    if (document.getElementById(meuLayer).style.display=="none") {
        document.getElementById(meuLayer).style.display="";
        document.getElementById(minhaImg).src=imgMenos;
    }
    else {
      document.getElementById(meuLayer).style.display="none";
        document.getElementById(minhaImg).src=imgMais;
    }
}
function smenu(meuLayer,minhaImg,imgMais,imgMenos) {
    if (document.getElementById(meuLayer).style.display=="none") {
	    document.getElementById(meuLayer).style.display="";
	    document.getElementById(minhaImg).src=imgMenos;
    }
    else {
      document.getElementById(meuLayer).style.display="none";
	    document.getElementById(minhaImg).src=imgMais;
    }
}

function loadPaginaAgenda(){
	var parametros;
	/*parametros = 'CO_LOGIN_RES=' + document.getElementById('CO_LOGIN_RES_1').value;
	alert('');
	loadFragmentInToElement('agenda_ajax.asp','Responsavel','POST',parametros);
	parametros = 'CO_GRUPO=' + document.getElementById('CO_GRUPO_1').value;
	loadFragmentInToElement('agenda_ajax.asp', 'GrupoManutencao','POST',parametros);		*/
}


function submeter_efv(acao,formato,parametros,form, referencia) {
    switch (acao) {
            case 0: //Atualizar
	          if (formato=="LS"){
		          if (!verAlgunMarcado(form.chkItem))  return(false);
		          if (!verTodosMarcados(form.chkItem)) return(false);
		        }
		        if(referencia=="frame"){
		            form.action = "../principal/exibir_formulario.asp?TRAMITA=<%=TRAMITA%>&ACAO=Buscar&CO_VISAO=<%=CO_VISAO%>&CO_FORMULARIO=<%=CO_FORMULARIO%>&VOLTA=../principal/exibir_formulario_visao.asp?CO_VISAO=<%=CO_VISAO%>"; 
		        }else{
		            loadFragmentInToElement('principal/exibir_formulario.asp','mainFrame','POST','ACAO=Buscar&'+parametros);
		        }
		        break;
	        case 1: //Excluir
	            if (formato=="LS"){
		          if (!verAlgunMarcado(form.chkItem))  return(false);
		          if (!confirm('Deseja excluir os itens selecionados')) return(false);
		        }
		        if(referencia=="frame"){
		            form.action = "../adm_formulario_resposta/excluir.asp?VOLTA=<%=Server.URLEncode('../principal/exibir_formulario_visao.asp?TRAMITA=" & TRAMITA & "&CO_VISAO=" & CO_VISAO & "&DE_PASTA=" & DE_PASTA & "&IC_NAVEGA=CARREGA')%>";
		        }else{
		            loadFragmentInToElement('adm_formulario_resposta/excluir.asp','mainFrame','POST',"IC_NAVEGA=CARREGA&"+parametros+"&VOLTA=../principal/exibir_formulario_visao.asp...."+parametros.replace("&","..."));
		        }
		        break;
	        case 2: //Recarrega
	            if(referencia=="frame"){
		            form.action = "exibir_formulario_visao.asp?IC_NAVEGA=CARREGA";
		        }else{
		            loadFragmentInToElement('principal/exibir_formulario_visao.asp','mainFrame','POST','IC_NAVEGA=CARREGA&'+parametros);
		        }
		        break;
	        case 3: //Mover para pasta
	            if (formato=="LS"){
  		            if (!verAlgunMarcado(form.chkItem))  return(false);
		        }
		        if(referencia=="frame"){
		            form.action = "exibir_formulario_visao.asp?ACAO=Arquivar&IC_NAVEGA=CARREGA";
		        }else{
		            loadFragmentInToElement('exibir_formulario_visao.asp','mainFrame','POST','ACAO=Arquivar&IC_NAVEGA=CARREGA&'+parametros);
		        }
		        break;
	        case 4: //Pastas
	            if(referencia=="frame"){
		            // form.action = "../adm_formulario_pasta/listar.asp?CO_FORMULARIO=<%=CO_FORMULARIO%>&VOLTA=<%=Server.URLEncode("../principal/exibir_formulario_visao.asp?TRAMITA=" & TRAMITA & "&CO_VISAO=" & CO_VISAO)%>";
		        }else{
		            loadFragmentInToElement('adm_formulario_pasta/listar.asp','mainFrame','POST','ACAO=Buscar&'+parametros);
		        }
		        break;
	        case 5: //Visões
	            if(referencia=="frame"){
		            //form.action = "../adm_formulario_visao/listar.asp?CO_FORMULARIO=<%=CO_FORMULARIO%>&VOLTA=<%=Server.URLEncode("../principal/exibir_formulario_visao.asp?TRAMITA=" & TRAMITA & "&CO_VISAO=" & CO_VISAO)%>";
		        }else{
		            loadFragmentInToElement('adm_formulario_visao/listar.asp','mainFrame','POST','ACAO=Buscar&'+parametros);
		        }
		        break;
	        case 6: //
	            //
	            break;
	        case 7: //Cadastrar
	            if(referencia=="frame"){
		            form.action = "../principal/exibir_formulario.asp?ACAO=Incluir&IC_NAVEGA=CARREGA&"+parametros+"&VOLTA=../principal/exibir_formulario_visao.asp...CO_VISAO=...CO_VISAO...";
		        }else{
		            loadFragmentInToElement('principal/exibir_formulario.asp','mainFrame','POST','ACAO=Incluir&IC_NAVEGA=CARREGA&'+parametros);
		        }
		        break;
	        case 8: //Anterior
	            if(referencia=="frame"){
		            form.action = "exibir_formulario_visao.asp?IC_NAVEGA=CO_ANTERIOR";
		        }else{
		            loadFragmentInToElement('principal/exibir_formulario_visao.asp','mainFrame','POST','IC_NAVEGA=CO_ANTERIOR&'+parametros);	
		        }
		        break; 
	        case 9: //Próximo
	            if(referencia=="frame"){
		            form.action = "../principal/exibir_formulario_visao.asp?IC_NAVEGA=CO_PROXIMO";
		        }else{
		            loadFragmentInToElement('principal/exibir_formulario_visao.asp','mainFrame','POST','IC_NAVEGA=CO_PROXIMO&'+parametros);	
		        }
		        break;
	        case 10: //Primeiro
	            if(referencia=="frame"){
		            form.action = "exibir_formulario_visao.asp?IC_NAVEGA=CO_PRIMEIRO";
		        }else{
		            loadFragmentInToElement('principal/exibir_formulario_visao.asp','mainFrame','POST','IC_NAVEGA=CO_PRIMEIRO&'+parametros);	
		        }
		        break;
	        case 11: //Último
	            if(referencia=="frame"){
		            form.action = "exibir_formulario_visao.asp?IC_NAVEGA=CO_ULTIMO";
		        }else{
		            loadFragmentInToElement('principal/exibir_formulario_visao.asp','mainFrame','POST','IC_NAVEGA=CO_ULTIMO&'+parametros);
		        }
		        break;
	        case 12: //Imprimir
	            //form.target = "_new"
	            if (form.LAY_OUT.value == "CON"){
	                if(referencia=="frame"){
		                form.action = "../adm_formulario_visao/imprimir_con.asp";
		            }else{
		                window.open('adm_formulario_visao/imprimir_con.asp?'+parametros, 'nova_janela', '');
		            }
	                
  	            }else{
  	                if(referencia=="frame"){
		                form.action = "../adm_formulario_visao/imprimir_for.asp"; 
		            }else{
		                window.open('adm_formulario_visao/imprimir_for.asp?'+parametros, 'nova_janela', '');
		            } 	                
  		        }
	            break;
	        case 13: //Encaminhar
	          if (formato=="LS"){
		          if (!verAlgunMarcado(form.chkItem))  return(false);
		          if (!verTodosMarcados(form.chkItem)) return(false);
		        }
		        form.action = "../principal/exibir_formulario.asp?TRAMITA=<%=TRAMITA%>&ACAO=Encaminhar&CO_VISAO=<%=CO_VISAO%>&CO_FORMULARIO=<%=CO_FORMULARIO%>&VOLTA=../principal/exibir_formulario_visao.asp?CO_VISAO=<%=CO_VISAO%>";
		        break;
	        case 14: //Consultar
	          if (formato=="LS"){
		          if (!verAlgunMarcado(form.chkItem))  return(false);
		          if (!verTodosMarcados(form.chkItem)) return(false);
		        }
		        form.action = "../principal/exibir_formulario.asp?TRAMITA=<%=TRAMITA%>&ACAO=Buscar&CO_VISAO=<%=CO_VISAO%>&CO_FORMULARIO=<%=CO_FORMULARIO%>&VOLTA=../principal/exibir_formulario_visao.asp?CO_VISAO=<%=CO_VISAO%>";
		        break; 
	        case 15: //Anexos
	          if (formato=="LS"){
		          if (!verAlgunMarcado(form.chkItem))  return(false);
		          if (!verTodosMarcados(form.chkItem)) return(false);
	          }
		        form.action = "../adm_tramita_anexo/listar.asp";
		        break;
	        case 16: //Informar página
	            if(referencia=="frame"){
		            form.action = "exibir_formulario_visao.asp?IC_NAVEGA=CO_ATUAL";
		        }else{
		            loadFragmentInToElement('principal/exibir_formulario_visao.asp','mainFrame','POST','IC_NAVEGA=CO_ATUAL&'+parametros);
		        }            
		        break;
	        case 17: //Visualizar
	          if (formato=="LS"){
		          if (!verAlgunMarcado(form.chkItem))  return(false);
		          if (!verTodosMarcados(form.chkItem)) return(false);
		        }
		        if(referencia=="frame"){
		            form.action = "../principal/exibir_formulario.asp?VISUALIZA=SIM&ACAO=Buscar&"+parametros+"&VOLTA=../principal/exibir_formulario_visao.asp....CO_VISAO=...CO_VISAO...";
		        }else{
		            loadFragmentInToElement('principal/exibir_formulario.asp','mainFrame','POST','VISUALIZA=SIM&ACAO=Buscar&'+parametros);	
		        }
		        break;
	        case 18: //Exportar
	            if(referencia=="frame"){
	                form.target = "_new";
 		            form.action = "../adm_formulario_visao/exportar_dados.asp";
 		        }else{
 		            window.open('adm_formulario_visao/exportar_dados.asp?'+parametros, 'nova_janela', '');
 		        }
		        break; 
	}
	if(referencia=="frame"){
	    form.target = "mainFrame";
	    form.submit();
	}
	return(true);
}

function parametrosAjax(form){
	var aux = "";
	for(var i=0;i<form.length;i++){
		switch(form[i].type){
			case "text":
				aux = aux + "&" + form[i].name + "=" + encodeMyHtml(form[i].value);
				break;
			case "hidden":
				aux = aux + "&" + form[i].name + "=" + encodeMyHtml(form[i].value);
				break;
			case "password":
				aux = aux + "&" + form[i].name + "=" + encodeMyHtml(form[i].value);
				break;
			case "textarea":						
				aux = aux + "&" + form[i].name + "=" + encodeMyHtml(form[i].value);
				break;
			case "select-one":	
				aux = aux + "&" + form[i].name + "=" + encodeMyHtml(form[i].value);
				break;
			case "select-multiple":	
				var element = form[i];
				for(var x=0;x<element.length;x++){
					if(element[x].selected){						
						aux = aux + "&" + element.name + "=" + encodeMyHtml(element[x].value);
					}
				}
				break;
			case "radio":
				if(form[i].checked){						
					aux = aux + "&" + form[i].name + "=" + encodeMyHtml(form[i].value);
				}
				break;
			case "checkbox":						
				if(form[i].checked){						
					aux = aux + "&" + form[i].name + "=" + encodeMyHtml(form[i].value);
				}
				break;
		}
	}
	return aux.substr(1,aux.length -1);
}

  function recarregaAdmUsuario(rotina, parametros){
    loadFragmentInToElement('adm_usuario/'+ rotina + '.asp','mainFrame','POST','ACAO=Recarga&'+parametros);	
  	//document.form.action = 'adm_usuario/'+rotina + '.asp?ACAO=Recarga';
	//document.form.submit();
 }
 
 function ehInteiro(oObj) {
	var codigo;
	if (document.all)
  	codigo = event.keyCode;
  else
    codigo = oObj.which;
	if((codigo < 48 || codigo > 57) && codigo != 8 && codigo != 0)
	{
	  if (document.all)
  		event.keyCode = 0;
  	else
  	  oObj.preventDefault();
		return false;
	}
}

function verAlgunMarcado(objCheck) {
  var existe = false;
  if (objCheck == null) {
    alert('Não há itens cadastrados');
    //alert("<%=oDic.Traduz("Não há itens cadastrados")%>");
    return false;
  }
  if (objCheck.length == null) {
    existe = objCheck.checked;
  }
  else {
    for (var i=0;i<objCheck.length;i++) {
      if (objCheck[i].checked) {
        existe=true;
        break;
      }
    }
  }
  if (!existe) {
    alert('É necessário selecionar um item');
    //alert("<%=oDic.Traduz("É necessário selecionar um item")%>");
    return false;
  }
  return true;
}


function verTodosMarcados(objCheck) {
  var countMarcados = 0;
  if (objCheck == null) {
    alert('Não há itens cadastrados');
    //alert("<%=oDic.Traduz("Não há itens cadastrados")%>");
    return false;
  }
  if (objCheck.length != null) {
    for (var i=0;i<objCheck.length;i++) {
      if (objCheck[i].checked) {
        countMarcados = countMarcados + 1;
      }
    }
  }
  if (countMarcados>1) {
    //alert("<%=oDic.Traduz("Selecione apenas um item")%>");
    alert('Selecione apenas um item');
    return false;
  }
  return true;
}

function desabilitaBotoes(form) {
    if (document.all) {
      for (var i=0; i < form.length; i++) {
        if (form(i).type == "button" || form(i).type == "submit")
          form(i).disabled = true;
      }
    }
  }
  
  
  function confirma_ef(form,acao,referencia,parametros,cpathvoltar) {
    if (acao=="Voltar"){
        if(referencia=="frame"){
            form.action = cpathvoltar;
        }else{
            if(cpathvoltar==""){
              cpathvoltar = "principal/exibir_formulario_visao.asp";
            } 
            loadFragmentInToElement(cpathvoltar,'mainFrame','POST',parametros);	
        }
        if(referencia=="frame"){
            form.submit();
        }
    }else{
        if(referencia=="frame"){
            form.action = 'exibir_formulario.asp?ACAO=Salvar&'+parametros;
        }else{
            loadFragmentInToElement('principal/exibir_formulario.asp','mainFrame','POST','ACAO=Salvar&'+parametros);	
        }
        if(referencia=="frame"){
            form.submit();
        }
    }
  }
  
  
  function paginacao_efv(texto){
	alert(texto);
  }
  
  
   function exibeArquivo(cArq, codigo,caminho) {
  	window.open(caminho+"adm_upload/formularios/" + codigo + "/" + cArq, null,
        "scrollbars=yes,RESIZABLE=yes,toolbar=no,left=160,top=110,width=450,height=415");
  }
  
  function imprimir(form,parametros,caminhoReferencia){
    var cAction;
    cAction = form.action;
    form.target = "new";
    form.action = caminhoReferencia+"principal/exibir_formulario.asp"+parametros;
    form.submit();
    form.target = "mainFrame";
    form.action = cAction; 
  }
  
  function goUrl(src,target){
    if(target=="Principal"){
        target="mainFrame"
    }else if(target=="Cabeçalhos"){
        target="topFrame"
    }else if(target=="Menu"){
        target="leftFrame"
    }else{
        target="Nova Janela"
    }
    if(target=="Nova Janela"){
        window.open(src,'','');
    }else{
        loadFragmentInToElement(src,target,'GET','');
    }
  }
  
  
  
  function subItemMenuLateral(elemento,elementoiten,nMenu,indice,nTamanhoPortal,nTamanhocabecalho,nLayout,nAltura,bSeparacao){
        
        if (nAltura > 18){
            if(bSeparacao){
                topo = document.getElementById('ITENS'+elemento).offsetTop + ((nAltura+1)*indice);
            }else{
                topo = document.getElementById('ITENS'+elemento).offsetTop + (nAltura*indice);
            }
        }else{
            if(bSeparacao){
                topo = document.getElementById('ITENS'+elemento).offsetTop + (19*indice);
            }else{
                topo = document.getElementById('ITENS'+elemento).offsetTop + (18*indice);
            }
        }
        
        lateral = (document.getElementById('MENUAREAPRINCIPAL').offsetWidth) + document.getElementById('ITENS'+elemento).offsetWidth + ((screen.width-nTamanhoPortal)/2)-14;
        document.getElementById('SUBITENS'+elemento+elementoiten).style.left = lateral ;
        document.getElementById('SUBITENS'+elemento+elementoiten).style.top = topo;
        document.getElementById('SUBITENS'+elemento+elementoiten).style.display = "";
        
        form = document.getElementById('FORMAREAS');
        for(var i=0;i<form.length;i++){
		    if(form[i].type=="hidden"){
		       elementocomp = 'SUBITENS'+elemento+elementoiten
			   if(form[i].value!=elementocomp&&form[i].name.substring(0,12)=='NOMESUBITENS'){
				    document.getElementById(form[i].value).style.display = "none";
			   }
		    }
	    }
  }
  
  
  
  function subItemMenu(elemento,indice,nTamanhoPortal,nTamanhocabecalho){
        var Browser; 
        Browser=navigator.appName; 
        
        document.getElementById('SUB'+elemento).style.display = "";
        //lateral = document.getElementById('SETA'+elemento).offsetLeft + 15;
        
        
        if (Browser == "Microsoft Internet Explorer") { 
            lateral = getAbsLeft(document.getElementById('SETA'+elemento)) - ((screen.width-nTamanhoPortal)/2) + 24;
            topo = document.getElementById(elemento).offsetTop + nTamanhocabecalho + (18*(indice+1));
        } else { 
            lateral = getAbsLeft(document.getElementById('SETA'+elemento)) - ((screen.width-nTamanhoPortal)/2) + 10;
            topo = document.getElementById(elemento).offsetTop + nTamanhocabecalho + (18*(indice+1));
        } 
        
        document.getElementById('SUB'+elemento).style.left = lateral;
        document.getElementById('SUB'+elemento).style.top = topo;
        
        form = document.getElementById('FORMAREAS');
        for(var i=0;i<form.length;i++){
		    if(form[i].type=="hidden"){
				if(form[i].value!=elemento&&form[i].name.substring(0,9)!='NOMEITENS'){
				    //alert(form[i].value + ' - ' + elemento + ' - ' + form[i].name.substring(0,9));
				    document.getElementById('SUB'+form[i].value).style.display = "none";
			    }
		    }
	    }
  }
  
  
  function itemMenu(elemento){
        document.getElementById('ITENS'+elemento).style.display = "";
        lateral = getAbsLeft(document.getElementById(elemento));
        document.getElementById('ITENS'+elemento).style.left = lateral;
        form = document.getElementById('FORMAREAS');
        for(var i=0;i<form.length;i++){
		    if(form[i].type=="hidden"){
		        //alert(form[i].name.substring(0,9));
				if(form[i].value!=elemento&&form[i].name.substring(0,9)=='NOMEITENS'){
				    document.getElementById('ITENS'+form[i].value).style.display = "none";
			    }
			    if(form[i].value!=elemento&&form[i].name.substring(0,12)=='NOMESUBITENS'){
				    document.getElementById('SUB'+form[i].value).style.display = "none";
			    }
		    }
	    }
  }
  
  
  function itemMenuLateral(elemento){
            parent.frames['mainFrame'].document.getElementById("menuH").innerHTML ="";
            parent.frames['mainFrame'].document.getElementById("menuH2").innerHTML = "";
            parent.frames['mainFrame'].document.getElementById("menuH").innerHTML = document.getElementById('ITENS'+elemento).innerHTML;
            topo = document.getElementById(elemento).offsetTop;
            parent.frames['mainFrame'].document.getElementById("menuH").style.top = topo;
  }
  
  
  
  /*function itemMenuLateral(elemento, nMenu, nTamanhoPortal,nTamanhocabecalho,sImagem,nLayout ){
            parent.frames['mainFrame'].document.getElementById("menuH").innerHTML = document.getElementById('ITENS'+elemento).innerHTML
            elemento = parent.frames['mainFrame'].document.getElementById("menuH");
            topo = (elemento.offsetTop) + parent.frames['mainFrame'].getElementById('ALTURAIMAGEMSC').offsetTop;
            
            parent.frames['mainFrame'].document.getElementById("menuH").style.display = "";
            lateral = (document.getElementById('MENUAREAPRINCIPAL').offsetWidth ) + ((screen.width-nTamanhoPortal)/2) - 11;
            parent.frames['mainFrame'].document.getElementById("menuH").style.left = lateral ;
            parent.frames['mainFrame'].document.getElementById("menuH").style.top = topo;
            form = document.getElementById('FORMAREAS');
            for(var i=0;i<form.length;i++){
		        if(form[i].type=="hidden"){
			       elementocomp = 'ITENS'+elemento
			       if(form[i].value!=elementocomp&&form[i].name.substring(0,9)=='NOMEITENS'){
				        document.getElementById(form[i].value).style.display = "none";
			       }
			        if(form[i].name.substring(0,12)=='NOMESUBITENS'){
				        document.getElementById(form[i].value).style.display = "none";
			        }
		        }
	        }
	        
  }*/
  
  
  function limparMenu(){
        var nTamanhoForm = 0;
        try{
            document.getElementById('FORMAREAS')
            form = document.getElementById('FORMAREAS');
            nTamanhoForm = form.length
        }catch(e){}  
        if(nTamanhoForm>0){
            for(var i=0;i<form.length;i++){
                if(form[i].name.substring(0,12)=='NOMESUBITENS'){
				    document.getElementById('SUB'+form[i].value).style.display = "none";
			    }
                if(form[i].name.substring(0,9)=='NOMEITENS'){
				    document.getElementById('ITENS'+form[i].value).style.display = "none";
			    }
            }
        }
  }
  
  function limparMenuLateral(){
        var nTamanhoForm = 0;
        try{
            form = document.getElementById('FORMAREAS');
            nTamanhoForm = form.elements.length
        }catch(e){}  
        if(nTamanhoForm>0){
            for(var i=0;i<form.elements.length;i++){
                if(form[i].name.substring(0,12)=='NOMESUBITENS'){
				    document.getElementById(form[i].value).style.display = "none";
			    }
                if(form[i].name.substring(0,9)=='NOMEITENS'){
				    document.getElementById(form[i].value).style.display = "none";
			    }
            }
        }
  }
  
     
  function getAbsLeft(el){
    var l=el.offsetLeft;
    while((el=el.parentNode) && el!=document)
        l+=el.offsetLeft;
    return l;
  }
  
  function getAbsTop(el){
    var t=el.offsetTop;
    while((el=el.parentNode) && el!=document)
        t+=el.offsetTop;
    return t;
  }

function confirmaNovaSenha(form,referencia,parametros){
    if (referencia=="ajax"){
        loadFragmentInToElement('adm_senha/altera.asp','mainFrame','POST','ACAO=Salvar&'+parametros);
    }else{
        form.submit();
    }    
}

function janelaupload_ef(cID,titulo, caminho, referencia) {
    if (referencia=="ajax"){
  	    window.open("popup/upload.asp?ID=" + cID + "&TITULO=" + titulo + "&DESTINO=" + caminho + "\\",
            null, "SCROLLBARS=no, RESIZABLE=no, TOOLBAR=no, STATUS=no, MENUBAR=no, WIDTH=440, HEIGHT=50, TOP=" +
            (window.screen.Height/2 - 50) + ", LEFT=" + (window.screen.Width/2 - 200));
    }else{
        window.open("../popup/upload.asp?ID=" + cID + "&TITULO=" + titulo + "&DESTINO=" + caminho + "\\",
            null, "SCROLLBARS=no, RESIZABLE=no, TOOLBAR=no, STATUS=no, MENUBAR=no, WIDTH=440, HEIGHT=50, TOP=" +
            (window.screen.Height/2 - 50) + ", LEFT=" + (window.screen.Width/2 - 200));
    }
}

function validaEmail(objeto) {
var email = objeto.value;
var s = new String(email);
var retorno = true;
if (email == "") return true;
	if ((s.indexOf("{")>=0) || (s.indexOf("}")>=0) || (s.indexOf("(")>=0) || (s.indexOf(")")>=0) || (s.indexOf("<")>=0) || (s.indexOf(">")>=0) || (s.indexOf("[")>=0) || (s.indexOf("]")>=0) || (s.indexOf("|")>=0) || (s.indexOf("\"")>=0) || (s.indexOf("/")>=0))
		  retorno = false;
	if ((s.indexOf("&")>=0) || (s.indexOf("*")>=0) || (s.indexOf("$")>=0) || (s.indexOf("%")>=0) || (s.indexOf("?")>=0) || (s.indexOf("!")>=0) || (s.indexOf("^")>=0) || (s.indexOf("~")>=0) || (s.indexOf("`")>=0) || (s.indexOf("'")>=0) )
		 retorno = false;
	if ((s.indexOf(",")>=0) || (s.indexOf(";")>=0) || (s.indexOf(":")>=0) || (s.indexOf("=")>=0) || (s.indexOf("#")>=0) )
		  retorno = false;
	if ( (s.indexOf("@") < 0) || (s.indexOf("@") != s.lastIndexOf("@")) )
		  retorno = false;
	if (s.lastIndexOf(".") < s.indexOf("@"))
		  retorno = false;
	if (s.substr(0,1) == '@')
		  retorno = false;
	if (!retorno){
		  objeto.focus();
		 objeto.select();
		 alert("E-mail inválido!");
		}
	if (!retorno) objeto.value = "";
	return retorno;
}


function encodeMyHtml(texto) {
     encodedHtml = escape(texto);
     encodedHtml = encodedHtml.replace(/\//g,"%2F");
     encodedHtml = encodedHtml.replace(/\?/g,"%3F");
     encodedHtml = encodedHtml.replace(/=/g,"%3D");
     encodedHtml = encodedHtml.replace(/&/g,"%26");
     encodedHtml = encodedHtml.replace(/@/g,"%40");
     return encodedHtml;
}


function alteraImagem(elemento,imagem){
    alert(elemento);
    alert(imagem);
    elemento.style.backgroundImage='adm_upload/imagens/'+imagem+'.jpg';
}

function enviarEmail(parametros){
    if(parametros==''){
       alert('Não existe conteúdo para envio!');
       //window.open("enviaremail.asp", null,"scrollbars=yes,RESIZABLE=yes,toolbar=no,left=160,top=110,width=450,height=415");
    }else{
       window.open("popup/enviaremail.asp?"+parametros, null,"scrollbars=no,RESIZABLE=no,toolbar=no,left=300,top=270,width=350,height=150");
    }
}





