function BannerSec(url) {
	
	window.location.href = url;	
	
}

// ActionScript Document
/*::	ADC Versão WEB
	::	Data de Criação: 20/12/2006
	@desc Funcoes Auxiliares comuns à todas as páginas
	@autora	Silvana Gonçalves - silvana.goncalves@ac.gov.br
	@versão	1.0
*/
//-----------------------------------------------------------------------------------
//Variável Globais
var ha0 = true;
var ha1 = true;
var ha2 = true;
var ha3 = true;
var ha4 = true;
var ha5 = true;
//Função criada como solução para o fato de a função DesabilitaAbasTela não funcionar no Firefox.
//De acordo com um variável global, realiza ou não a ação de trocar a aba.
function ChecaHab(tipo)
{
	if (tipo==0){	if(ha0==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);	}	}
	if (tipo==1){	if(ha1==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);	}	}
	if (tipo==2){	if(ha2==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);	}	}
	if (tipo==3){	if(ha3==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);	}	}
	if (tipo==4){	if(ha4==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);	}	}
	if (tipo==5){	if(ha5==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);	}	}
}
//-----------------------------------------------------------------------------------
function ChecaHabilita(tipo)
{
	if (tipo==0){	if(ha0==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);top.MudaCodAba(tipo);top.EscondeBotao();	}	}
	if (tipo==1){	if(ha1==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);top.MudaCodAba(tipo);top.EscondeBotao();	}	}	
	if (tipo==2){	if(ha2==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);top.MudaCodAba(tipo);top.EscondeBotao();	}	}
	if (tipo==3){	if(ha3==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);top.MudaCodAba(tipo);top.EscondeBotao();	}	}
	if (tipo==4){	if(ha4==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);top.MudaCodAba(tipo);top.EscondeBotao();	}	}
	if (tipo==5){	if(ha5==false){	top.alternaAba(tipo);top.TrocaAbas(tipo);top.MudaCodAba(tipo);top.EscondeBotao();	}	}
}
//-----------------------------------------------------------------------------------
function CriticaEspaco(campo)
{
	//verifica se so tem espaço 
	Resultado = campo;
	var i;
	var teste = "";
	//faz a busca na string...
	for (  i = 0; i < Resultado.length; i++ ) {
    	if (Resultado.charCodeAt(i) == '32'){	teste = "espaco";	}
		else
		{
        	teste = "sem";
        	break;
    	}//fim do if...
	}//fim do for...
	//faz o teste da existencia de espaço sem letra
	if ( teste == "espaco" ){	return false	}//fim do if...
	else{	return true	}
}
//Formata campo para o padrão numérico, mas sem estar digitando, ou seja, próprio para campos que são automaticamente calculados.
function FormataCampo(campo)
{	
	var valor = gE(campo).value.split(".");
	if (valor[1] != null)
	{	gE(campo).value = valor[0]+","+valor[1];	}
	var aux = gE(campo).value.split(",");
	var tam = aux[0].length; 
	if (tam < 4 || tam > 18){	return false	}
	if (tam >= 4 && tam <= 6)
	{	
		var aux2 = aux[0].substr(0,tam-3)+"."+aux[0].substr(tam-3,tam);
	}
	if (tam >= 7 && tam <= 9)
	{	
		var aux2 = aux[0].substr(0,tam-6)+"."+aux[0].substr(tam-6,3)+"."+aux[0].substr(tam-3,tam);
	}
	if (tam >= 10 && tam <= 12)
	{	
		var aux2 = aux[0].substr(0,tam-9)+"."+aux[0].substr(tam-9,3)+"."+aux[0].substr(tam-6,3)+"."+aux[0].substr(tam-3,tam);
	}
	if (tam >= 13 && tam <= 15)
	{	
		var aux2 = aux[0].substr(0,tam-12)+"."+aux[0].substr(tam-12,3)+"."+aux[0].substr(tam-9,3)+"."+aux[0].substr(tam-6,3)+"."+aux[0].substr(tam-3,tam);
	}
	if (tam >= 16 && tam <= 18)
	{	
		var aux2 = aux[0].substr(0,tam-15)+"."+aux[0].substr(tam-15,3)+"."+aux[0].substr(tam-12,3)+"."+aux[0].substr(tam-9,3)+"."+aux[0].substr(tam-6,3)+"."+aux[0].substr(tam-3,tam);
	}
	gE(campo).value = aux2+","+valor[1];
}
//---------------------------------------------------------------------------------------
function getKeyCode(e) { /* event */ return (e.which) ? e.which : (window.event && event.keyCode) ? event.keyCode : false; }
function FormataValorReal(campo,tammax,e) {
	if( !e ) {
    //if the browser did not pass the event information to the
    //function, we will have to obtain it from the event register
    
        if( window.event ) {
    //Internet Explorer
            e = window.event;
        } else {
    //total failure, we have no way of referencing the event
            return;
        }
    }
	var tecla = getKeyCode(e);

/*	if (!ValidarValorNumerico( e )){
		return false;	
	}
*/
	vr = campo.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }

	if ( ( tecla >= 48 && tecla <= 57 ) || (tecla >= 96 && tecla <= 105) || tecla == 8 ){
  	//if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		campo.value = "0," + vr ; } 
		/*else {
				if (vr.substring(0,1) == "0"){
					vr = vr.substring(1,vr.length+1);
					alert("val:"+vr)
				}
			} */
			
		if (vr.substring(0,1) == "0"){
			vr = vr.substring(1,vr.length+1);
			tam = tam - 1;
			
		}
	 	if ( (tam > 2) && (tam <= 5) ){
	 		campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 12) && (tam <= 14) ){
	 		campo.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
	} else if (tecla == 17 || tecla == 18 || tecla == 9) {
		return true;
	} else return false
	
}

//Formata número tipo moeda usando o evento onKeyDown
function FormataValor(campo,tammax,teclapres,decimal) 
{
	var tecla = teclapres.keyCode;
	vr = Limpar(campo.value,"0123456789");
	tam = vr.length;
	dec=decimal;
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
	if (tecla == 8 ){ tam = tam - 1 ; }
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
	{
		if ( tam <= dec ){ campo.value = vr ; }
		if ( (tam > dec) && (tam <= 5) ){	campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 6) && (tam <= 8) ){	campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam );	}
		if ( (tam >= 9) && (tam <= 11) ){	campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 12) && (tam <= 14) ){	campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
		if ( (tam >= 15) && (tam <= 17) ){	campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;}
	}
}
//-------------------------------------------------------------------------------------------------------------------
// Retira Caracteres Invalidos da String
function Limpar(valor, validos) 
{
	var result = "";
	var aux;
	for (var i=0; i < valor.length; i++) 
	{
		aux = validos.indexOf(valor.substring(i, i+1));
		if (aux>=0){	result += aux;	}
	}
	return result;
}
//---------------------------------------------------------------------------------------
//Função para abertura de telas auxiliares.
function MaxLength(obj, limit) 
{
	if (obj.value.length >= limit){	obj.value = obj.value.substring(0, limit-1);	}
}
//---------------------------------------------------------------------------------------
//Função que utiliza uma Expressão regular para substituir qualquer ocorrência de um caractere por outro caractere.
//Atenção para os parâmetros que deverão ser passados:
//campo --> é o valor do campo do formulário, ou a variável.
//cout --> é o caracter ou string que se quer substituir, atente para o fato de que este caracter deverá ser reconhecido pela Expressão Regular.
//cin --> é o caracter ou string que substituirá o que foi especificado anteriormente.
function SubstituiCaracteres(campo,cout,cin)
{
	var aux = new RegExp(cout,"gi");
	var aux2 = campo.replace(aux,cin);
	return aux2;
}
//-----------------------------------------------------------------------------------
//Função permite digitação de números
function BloqueiaCaracteres(evnt)
{
	if (navigator.appName.indexOf('Microsoft') != -1){	clientNavigator = "IE";	}
	else{	clientNavigator = "Other";	}
	
	if (clientNavigator == "IE") {	
		
		if ( (evnt.keyCode < 48 || evnt.keyCode > 57) && (evnt.keyCode < 96 || evnt.keyCode > 105) )  {	
		
			if (( evnt.keyCode == 8 ) || ( evnt.keyCode == 13 )) {
				
				return true;
				
			} else {
		
				return false;
			
			}
			
		}	
			
	} else {
		
		if ( (evnt.charCode < 48 || evnt.charCode > 57) && evnt.keyCode == 0) {
			
			if ( evnt.keyCode == 8 ) {
				
				return true;
				
			} else {
		
				return false;
			
			}
			
		}	
	
	}
}
//-----------------------------------------------------------------------------------
//Função permite digitação de números
function BloqueiaCaracteres2(evnt)
{
	if (navigator.appName.indexOf('Microsoft') != -1){	
		clientNavigator = "IE";	
	}else{	
		clientNavigator = "Other";	
	}
	if (clientNavigator == "IE"){	
		if ((evnt.keyCode < 48 || evnt.keyCode > 57) && evnt.keyCode != 44  ) {	
			return false	
		}
	}else{	
		if ((evnt.charCode < 48 || evnt.charCode > 57) && evnt.keyCode == 0){	
			return false	
		}	
	}
}
//-----------------------------------------------------------------------------------
//Função para abertura de telas auxiliares.
function MM_openBrWindow(theURL,winName,features) 
{ //v2.0
	window.open(theURL,winName,features);
}
//---------------------------------------------------------------------------------------
//Função que será chamada no campo textarea, eventos Onblur, OnKeyPress, OnKeyUp e OnKeyDown
//Passados como parâmetros o campo textarea e a referência a um span que deve ser colocado na tela para mostrar a contagem 
//dos caracteres.   
function max(txarea,cont,qtd)
{
	total = qtd;
	tam = txarea.value.length;
	str="";
	str=str+tam;
	if (tam > total)
	{
		aux = txarea.value;
		txarea.value = aux.substring(0,total);
	}
	contador(txarea,cont);                   
}
//----------------------------------------------------------------------------------
//Função que insere o contador de caracteres na tela, geralmente utilizado em campos textarea.
//var  total = 500;
function contador(txarea,cont)
{
	var aux = total;
	if (eval(txarea.value.length) <= total)
	{
		var tam = aux - eval(txarea.value.length);
		aux--
		var msg = "Restam <strong><font color=\"red\">" + tam + "</font></strong> caracteres.";
		cont.innerHTML = msg;
	} 
}   
//----------------------------------------------------------------------------------
//Retira os caracteres especiais do campo e atribui a ele a string sem esses caracteres.
function TiraCaracteresEspeciais(campo)
{
	campo.value = TrimJS(campo.value); // Retira os espaços em branco
	campo.value = SubstituiCaracteres(campo.value,"\"",""); // Retira as aspas duplas
	campo.value = SubstituiCaracteres(campo.value,"\\n"," "); // Retira os enters
	campo.value = SubstituiCaracteres(campo.value,"'",""); // Retira as aspas simples
	campo.value = SubstituiCaracteres(campo.value,"&",""); // Retira o & largamente utilizado nas operações de SQL.
}
//----------------------------------------------------------------------------------
function TrimJS(String0)
{
	Resultado = String0;
	//Retira os espaços do inicio
    //Enquanto o primeiro caracter for igual a "Espaço"
    //1 caracter do inicio &eacute; removido
    var i;
	i = 0;
	if (Resultado.charCodeAt(2-1) == '32'){
    }
    while (Resultado.charCodeAt(0) == '32'){
    	Resultado = String0.substring(i,String0.length);
        i++;}
        //Pega a string já formatada e agora retira os espaços do final
        //mesmo esquema, enquanto o ultimo caracter for um espaço,
        //ele retira 1 caracter do final...
        while(Resultado.charCodeAt(Resultado.length-1) == "32"){
		Resultado = Resultado.substring(0,Resultado.length-1);
	}
	String0 = "";
	return Resultado;
}



//---------------------------------------------------------------------------------------
/*
* @name: isEmpty(prm)
* @version: 0.2
* @param: prm
* @return: boolean
* @author: Jorge Oliveira
* @description: Verifica se o prm está vazio.
*/
function isEmpty(prm)
{
	return (prm == null || prm == "");
}
//---------------------------------------------------------------------------------------
/*
* @name: clearValElem(idObj1[, idObj2, idObj3, idObj4, ...])
* @version: 0.2
* @param: idObj(String, Array of String)
* @return: boolean
* @author: Jorge Oliveira
* @description: Esta funçao faz a limpeza do objeto ou de múltiplos objetos informados.
* O idObj pode ser uma string, array de strings,
* ou a funçao recebe vários parâmetros e executa
* a mesma açao em todos.
* No primeiro caso, ele age especificamente para
* cada um dos casos: select, textarea, input(text,hidden,radio,checkbox)
* e div. No segundo caso, ele percorre o array informado
* e chama esta mesma funçao repassando cada posiçao do array
* de cada vez para executar a tarefa específica.
*/
function LimpaElementos(idObj)
{
	var obj,arrIdObj;
 	if(arguments.length == 1)  //de acordo com a quantidade de parâmetros, estes sao jogados para um Array
	{
  		if ( isEmpty(idObj)){	return false;	} //Critica se está vazio. Segurança. A funçao está no código.
	} 
	else if(arguments.length > 1) 
	{
 		arrIdObj = new Array();
  		// Percorre o Array de Argumentos e joga para o Array de Objetos arrIdObj
  		for(i=0; i<arguments.length; i++){	arrIdObj.push(arguments[i]);	} 
  		idObj = arrIdObj;
  		arrIdObj = null;
 	} 
 	if ((idObj instanceof Array))//Verifica se o prm é uma instância do objeto Array
	{
  		// Percorre o Array de Objetos e chama a si mesma de forma recursiva passando somente um parâmetro.
  		for(var i=0;i<idObj.length;i++){	LimpaElementos(idObj[i]);		} 
  		return true;//Retorna para nao executar o restante da funçao.
 	}
 	if ( typeof(idObj) == "string" ) // Sendo somente um parâmetro, verifica se é String para entao carregar o elemento.
	{
  		obj = gE(idObj);
 	} 
	else if ( typeof(idObj) == "object" )// Se for objeto o parâmetro, ele já carrega o elemento .
	{	obj = idObj;	} 
 	//Com o elemento carregado, verifica-se o tipo da tagName ou nodeName
 	//Sendo SELECT, o obj.selectIndex é definido para 0, para setar a seleçao na primeira opçao do select.
 	if (obj.nodeName == "SELECT") 
	{	
		obj.selectedIndex = 0;
 	} 
	else if (obj.nodeName == "INPUT") //Agora, uma observaçao: se for INPUT, devemos verificar o tipo de INPUT
	{
 		var tipoObj = obj.type.toLowerCase();
 		
  		if ( (tipoObj == "text") || ( tipoObj == "hidden" ) ) 
		{
  			obj.value = "";
  		} 
		else if ( (tipoObj == "radio") || tipoObj == "checkbox" )
		{	obj.checked = false;	} 
 	} 
	else if ( (obj.nodeName == "DIV") || (obj.nodeName == "TEXTAREA") )
	{	
 		obj.innerHTML = "";
 	} 
}
//---------------------------------------------------------------------------------------
/*
* @name: HabDesabilitaBotoes(val, idObj1[, idObj2, idObj3, idObj4, ...])
* @version: 1.0
* @param: val(true ou false) --> Valor que diz se habilita ou não.
* @param: idObj(String, Array of String) --> Id do botão.
* @return: boolean
* @author: Silvana Goncalves
* @description: Esta funçao faz o tratamento do botão ou de múltiplos botões informados.
* O idObj pode ser uma string, array de strings, ou a funçao recebe vários parâmetros e executa
* a mesma açao em todos.
* No primeiro caso, ele age especificamente um botão.
* No segundo caso, ele percorre o array informado e chama a mesma funçao repassando cada posiçao do array.
*/
function HabDesabilitaBotoes(val,idObj)
{
	var obj,arrIdObj;
	if (idObj instanceof Array)//Verifica se o prm é uma instância do objeto Array
	{
  		// Percorre o Array de Objetos e chama a si mesma de forma recursiva passando somente um parâmetro.
  		for(var i=0;i<idObj.length;i++){	HabDesabilitaBotoes(val,idObj[i]);		} 
  		return true; 	//Retorna para nao executar o restante da funçao.
 	}
 	
	if ( typeof(idObj) == "string" ) 
	{
  		obj = gE(idObj);	// Sendo somente um parâmetro, verifica se é String para entao carregar o elemento.
 	} 
	else if ( typeof(idObj) == "object" )
	{	obj = idObj;	} 	// Se for objeto o parâmetro, ele já carrega o elemento.
	obj.disabled = val; 	//Desabilita efetivamente o botão.
	if(val == true){obj.style.color = '#9A9A9A';}//Modifica as cor do botão para ficar mais especificamente visível no firefox.
	else{obj.style.color = '#000000';} 
} 
//---------------------------------------------------------------------------------------
/*
* @name: Atualiza_iFrame(ifrm, url)
* @version: 1.0
* @param: ifrm(String) --> Id do iFrame na tela que o mesmo é carregado.
* @param: url(String) --> Endereço fisíco do iFrame.
* @return: boolean
* @author: Silvana Goncalves
* @description: Esta funçao atualiza o iFrame da tela de acordo com o padrão W3C.
*/
function Atualiza_iFrame(ifrm,url)
{		
	gE(ifrm).setAttribute('src',url);
}
//---------------------------------------------------------------------------------------
/*
* @name: PreencheCombo(retorno, combo)
* @version: 1.0
* @param: retorno(String) --> Retorno do Banco de dados, com os dados para carregar o combo.
* @param: combo(String) --> Id do combo que será preenchido.
* @author: Adaptado por Silvana Goncalves
* @description: Esta funçao carrega um ComboBox com o retorno de uma query SQL.
*/
function PreencheComboSimples(retorno,ComboaPreencher) 
{
	var combo = ComboaPreencher;
	for (var a = combo.options.length - 1; a >= 0; a--)
	{
		combo.options[a] = null;
	}
	combo.selectedIndex = -1;
	var Line = retorno.split("|");
	for (iLine = 0; iLine < Line.length; iLine++)
	{
		var arrLine = Line[iLine].split(";");
		if (arrLine[0] != '') 
		{
			var i = combo.length;
			combo.length = i + 1;
			combo.options[i].value = arrLine[0];
			combo.options[i].text =  arrLine[1];
		} //fim do if...
	} //fim do for...
}
//-----------------------------------------------------------------------------------
/*
* @name: LimpaCombo(combo)
* @version: 1.0
* @param: combo(String) --> Id do combo que será limpo.
* @author: Adaptado por Silvana Goncalves
* @description: Esta funçao limpa um ComboBox a fim de não deixar sujeira para as próximas consultas.
*/
function LimpaCombo(ComboaLimpar) 
{
	var combo = ComboaLimpar;
	for (var a = combo.options.length - 1; a >= 0; a--)
	{
		combo.options[a] = null;
	}
	combo.selectedIndex = -1;
}
//-----------------------------------------------------------------------------------
//Habilita Ajax
function openAjax()
{
	var ajax;
	try{	ajax = new XMLHttpRequest(); // XMLHttpRequest para browsers decentes, como: Firefox, Safari, dentre outros.	
	}catch(ee){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP"); // Para o IE da MS
		}catch(e){
			try{
				ajax = new ActiveXObject("Microsoft.XMLHTTP"); // Para o IE da MS
			}catch(E){
				ajax = false;
			}
		}
	}
	return ajax;
}
//-----------------------------------------------------------------------------------

var arFilaAJX = new Array();
var iArFilaAJX = 0;

/*Funcao execAJAX reduzida para criar a fila*/
function execAJAX(url,acao) {
			
			arFilaAJX[iArFilaAJX] = arguments;
			//Se não há conexões pendentes, executa
			if( (iArFilaAJX+1)==arFilaAJX.length)execAJAXUnico()
	
/*			alert("iArFilaAJX: "+ iArFilaAJX)
			alert(arFilaAJX.length)*/
} 

function execAJAXUnico(){
			posAr 	= arFilaAJX[iArFilaAJX]
			url 	= posAr[0]
			acao	= posAr[1]
			
			var ajax = openAjax(); // Inicia o Ajax.
			ajax.open("GET", url, true); // Envia a página que realizará a consulta propriamente dita
			/* verifica se o terceiro argumento [2] existe e é uma funçao. */
			if ( (posAr.length > 2) && (posAr[2]) && (typeof(posAr[2]) == 'function') ){
				var func = posAr[2];
				
				if (posAr[3]){
					var obj = posAr[3];
				}
			}
			


			ajax.onreadystatechange = function() {
				if(ajax.readyState == 1) { // Quando estiver carregando, exibe uma camada: Carregando...
					gE('divCarreg').style.visibility = "visible";
				}
				if(ajax.readyState == 4) { // Quando estiver tudo pronto.
					
					if(ajax.status == 200) {
						var resultado = ajax.responseText; // Coloca o resultado (da busca) retornado pelo Ajax nessa variável (var resultado).
						resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
						resultado = unescape(resultado); // Resolve o problema dos acentos
						gE('divCarreg').style.visibility = "hidden"; //Oculta o "Carregando..."
						if (func){
							if (obj){
								eval('func(resultado,obj)')
							} else {
								eval('func(resultado)');
							}
							
						} else {
							
							retornaAJAX(resultado,acao); // Manda o resultado para uma funç?o de retorno.
						}
						
						//Roda o próximo
						iArFilaAJX++
						if(iArFilaAJX<arFilaAJX.length)setTimeout("execAJAXUnico()",20);

					} else {
						
						gE('divCarreg').innerHTML = "Erro no AJAX.";
						alert("Ocorreu um erro no AJAX ("+ ajax.statusText + ")"); //Caso ocorram erros, exibe um aviso.
						gE('divCarreg').style.visibility = "hidden"; //Oculta o "Carregando..."
					}
				}
			} 
			ajax.send(null); // submete
}




function execAJAXRot(url,acao,rotulo)
{
	if (rotulo == "" || rotulo == undefined ){	rotulo = "Carregando...";	}
	var ajax = openAjax(); // Inicia o Ajax.
	ajax.open("GET", url, true); // Envia a página que realizará a consulta propriamente dita
	ajax.onreadystatechange = function() 
	{
		if(ajax.readyState == 1) 
		{ // Quando estiver carregando, exibe uma camada: Carregando...
			gE('divCarreg').innerHTML = rotulo;
			gE('divCarreg').style.visibility = "visible";
		}
		if(ajax.readyState == 4) 
		{ // Quando estiver tudo pronto.
			if(ajax.status == 200) 
			{
				var resultado = ajax.responseText; // Coloca o resultado (da busca) retornado pelo Ajax nessa variável (var resultado).
				resultado = resultado.replace(/\+/g," "); // Resolve o problema dos acentos (saiba mais aqui: http://www.plugsites.net/leandro/?p=4)
				resultado = unescape(resultado); // Resolve o problema dos acentos
				gE('divCarreg').style.visibility = "hidden"; //Oculta o "Carregando..."
				retornaAJAX(resultado,acao); // Manda o resultado para uma função de retorno.
			} else {
				gE('divCarreg').innerHTML = "ERRO... <span onclick=\"gE(\'divCarreg\').style.visibility = \'hidden\';\"> [X]</span>";
				alert("Ocorreu um erro ao carregar os dados. Código: AJX("+ ajax.statusText + ")"); //Caso ocorram erros, exibe um aviso.
				setTimeout("gE('divCarreg').style.visibility = 'hidden'",2500)
			}
		}
	} 
	ajax.send(null); // submete
}
//-----------------------------------------------------------------------------------
// Esta funcao pega o elemento pelo ID
function gE(tI) 
{ 
  	if (document.getElementById) { return document.getElementById(tI); }
  	else if (document.all) { return document.all[tI]; } else return false;
}


function PreencheCombo(retorno,ComboaPreencher)
{
    var combo = ComboaPreencher;

	combo.length = 0

	var Line = retorno.split("||");
    for (iLine = 0; iLine < Line.length; iLine++)
    {
        var arrLine = Line[iLine].split(";;");
        if (arrLine[0] != '')
        {
            var i = combo.length;
            combo.length = i + 1;
            combo.options[iLine].value = arrLine[0];
            combo.options[iLine].text =  arrLine[1].toUpperCase();
        } //fim do if...
    } //fim do for...
}

function CompValArray(pArray, pVal){
	
	   for (var i = 0;i<pArray.length;i++){
		  if (pArray[i] == pVal) {
			  return true;
		  }
	   }
	   return false;
}

function RemoveValArray(pArray, pVal){
	var tmp;
	  for (var i = 0;i<pArray.length;i++){
		  if (pArray[i] == pVal) {
			  tmp = pArray.splice(i,1);
			  return true;
		  }
	   }
	   return false;
}


function fecharJanelaModulo(){
	
	document.location.href = '../../../menu/aes.asp'	
	
}

var glEncontrada = 0;
function replaceChars(entry,out,add) {
	//out = ","; // replace this
	//add = " "; // with this
        
	temp = "" + entry; // temporary holder
	
	while (temp.indexOf(out)>-1) {
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
                glEncontrada = 1;
                
	}
	 return temp;
} // fim da funcao ...

function GrifaLinha(pLinha, cor) {
	
	if ( !cor ) {

		if (pLinha!=ultimaLinhaSelecionada) {
			
			pLinha.style.backgroundColor='#FFFF99';
			pLinha.style.fontWeight='bold';
			
		}
		
	} else {
		
		if (pLinha!=ultimaLinhaSelecionada) {
			
			pLinha.style.backgroundColor=cor;
			pLinha.style.fontWeight='bold';
			
		}

	}
	
}

function DesgrifaLinha(pLinha, cor) {
	
	if (!cor) {
		
		if(pLinha!=ultimaLinhaSelecionada){pLinha.style.backgroundColor='#FFFFFF'; pLinha.style.fontWeight='normal';
}
		
	} else {
		
		if(pLinha!=ultimaLinhaSelecionada){pLinha.style.backgroundColor=''; pLinha.style.fontWeight='normal';
}
		
	}
	
}

var ultimaLinhaSelecionada=null;

function selecionaLinha(pLinha)	{

	
	if(pLinha!=ultimaLinhaSelecionada) {
	
		pLinha.style.backgroundColor='#CCCCCC';	
		
		if(ultimaLinhaSelecionada!=null) {
		
			ultimaLinhaSelecionada.style.backgroundColor='#FFFFFF';
					
		}
					
		ultimaLinhaSelecionada=pLinha;
		
	}

//Fim da função para colorir a linha selecionada.
}

function FormataData()
{
	campo = window.document.activeElement;
	tecla = event.keyCode;
	var texto = campo.value;
	
	if(texto.length==0)
	{
		if( (tecla > 51) && (tecla <= 57) )
			texto = texto + '0';
	}
	if(texto.length==1)
	{				
		if( (tecla > 49) &&  (eval(texto.substr(0,1)) > 2) )
			return false;
	}
	if(texto.length==2)
	{
		texto = texto + '/';
	}
	if(texto.length==3)
	{
		if( (tecla > 49) && (tecla <= 57) )
			texto = texto + '0';
	}
	if(texto.length==4)
	{
		if( (tecla > 50) &&  (eval(texto.substr(3,1)) > 0) )
			return false;		
	}
	if(texto.length==5)
	{
		texto = texto + '/';				
	}
	if(texto.length==6)
	{
		
		if( tecla == 48 || tecla > 50)
			{	
			texto = texto + '20';
//			return false;
			}
			
//		if( (tecla > 52) && (tecla <= 57) )
//			texto = texto + '19';
	}
	if(texto.length==7)		
	{
//				alert(texto.substr(6,1));
//				alert(texto);
		if (texto.substr(6,1) == '1')
			{
			if( tecla == 48 || tecla < 57)  // tecla = 0 ou menor que 9
				return false;
			}
	}
	if(texto.length==8)
	{
//		alert(texto.substr(6,1));
	
//		if (texto.substr(6,1)<>2)
//			{
//			if(tecla < 54 )
//				{
//				return false;
//				}
//			}
	}
	if(texto.length==9)
	{
	}	
	if(texto.length==10)
	{
		return false;
	}
	
	campo.value = texto;

	if( (tecla >= 48) && (tecla <= 57) )
		return true
	else
		return false;
}

function LimparElementos(obj){

	var ind = 0;
	
	if ( (arguments.length > 0) && arguments[1] ) {
	
		ind = arguments[1];
	
	}
	
	while (obj.childNodes.length > ind){
		//remove o primeiro no dos resultados antigos
		obj.removeChild(obj.childNodes[obj.childNodes.length-1]);

	}
	
	
		
}

function Enter(evt, func) {
	
	if ( evt.keyCode == 13 ) {
		
		eval('func()');
		
	}
	
}

function openUrl(url) {

	window.location.href = url;	
	
}
//-----------------------------------------------------------------------------------
//Cria a layer que vai exibir o status da operação, Layer Pequenininha localizada no canto superior direito da tela.
/*document.write("<div id=\"divCarreg\"  " + 
			   "style=\"position:absolute;right:5px;top:5px;width:87px; " + 
			   "height:23px;z-index:1; " + 
			   "font-family: Arial, Helvetica, sans-serif;font-size: 12px; " + 
			   "font-weight: bold;color: #FFFFFF;background-color: #CC3300; " + 
			   "visibility: hidden;text-align:center;vertical-align:middle; " + 
			   "\" >Carregando...</div>")*/
			   var wL = screen.width/2 - 60;
			   var hL = screen.height/2 - 80;

/*
document.write("<div id=\"divCarreg\"  " + 
			   "style=\"position:absolute;right:"+wL+"px;top:"+hL+"px; " + 
			   "padding:7px;z-index:1; " + 
			   "font-family: Arial, Helvetica, sans-serif;font-size: 12px; " + 
			   "font-weight: bold;color: #333333;background-color: #F5F5F5; " + 
			   "visibility: visible;text-align:center;vertical-align:middle;border: #000000 0px solid; " + 
			   "\" ><img src='img/ajax-loader.gif' align='absmiddle' />&nbsp;&nbsp;Carregando...</div>")
*/