
	//Função simples que atualiza o mês a partir do combo na tela de Relacionamento NIF
	function atualiza_dia_cre_deb(){
		if(document.getElementById('indica_bkp').checked == false){
			document.getElementById('data_inicial_credito').value = document.getElementById('ajuda_menos_7_dias_atual').value;
			document.getElementById('data_final_credito').value = document.getElementById('ajuda_dia_atual').value;

			document.getElementById('data_inicial_debito').value = document.getElementById('ajuda_menos_7_dias_atual').value;
			document.getElementById('data_final_debito').value = document.getElementById('ajuda_dia_atual').value;
		} else {
			var mes = document.getElementById('tabela').value.substr(8,2);
			var ano = document.getElementById('tabela').value.substr(3,4);
			var aux = document.getElementById('tabela').value.substr(10,4);

			variavel = new Date();
			dia_atual = variavel.getDate();
			mes_atual = variavel.getMonth() + 1;
			ano_atual = variavel.getFullYear();

			if(mes == '' && ano == ''){
				dia = 31;
				mes = '01';
				ano = '2005';
			}
			if(mes == '') mes = '01';
			if(ano == '') ano = '2007';

			if(mes == '01' || mes == '03' || mes == '05' || mes == '07' || mes == '08' || mes == '10' || mes == '12') dia = 31;
			else if(mes == '04' || mes == '06' || mes == '09' || mes == '11') dia = 30;
			else if((mes == '02') && (ano % 4 == 0)) dia = 29;
			else dia = 28;

			if(aux == ''){
				document.getElementById('data_inicial_credito').value = "01/"+mes+"/"+ano;
				document.getElementById('data_final_credito').value = "07/"+mes+"/"+ano;

				document.getElementById('data_inicial_debito').value = "01/"+mes+"/"+ano;
				document.getElementById('data_final_debito').value = "07/"+mes+"/"+ano
			} else if(aux == '_tri'){
				if(mes == '01') {
					data1 = "01/01/"+ano;
					data2 = "31/03/"+ano;
				}
				if(mes == '02') {
					data1 = "01/04/"+ano;
					data2 = "30/06/"+ano;
				}
				if(mes == '03') {
					data1 = "01/07/"+ano;
					data2 = "30/09/"+ano;
				}
				if(mes == '04') {
					data1 = "01/10/"+ano;
					data2 = "31/12/"+ano;
				}

				document.getElementById('data_inicial_credito').value = data1;
				document.getElementById('data_inicial_debito').value = data1;

				document.getElementById('data_final_credito').value = data2;
				document.getElementById('data_final_debito').value = data2;
			}
		}
	}

	//Função simples que atualiza o mês a partir do combo na tela de Despesas e Receitas
	function atualiza_dia_rec_des_com(){

		if(document.getElementById('indica_bkp').checked == false){
			document.getElementById('data_inicial_receita').value = document.getElementById('ajuda_menos_7_dias_atual').value;
			document.getElementById('data_final_receita').value = document.getElementById('ajuda_dia_atual').value;

			document.getElementById('data_inicial_despesa').value = document.getElementById('ajuda_menos_7_dias_atual').value;
			document.getElementById('data_final_despesa').value = document.getElementById('ajuda_dia_atual').value;

			document.getElementById('data_inicial_compra').value = document.getElementById('ajuda_menos_7_dias_atual').value;
			document.getElementById('data_final_compra').value = document.getElementById('ajuda_dia_atual').value;
		} else {
			var mes = document.getElementById('tabela').value.substr(8,2);
			var ano = document.getElementById('tabela').value.substr(3,4);
			var aux = document.getElementById('tabela').value.substr(10,4);

			variavel = new Date();
			dia_atual = variavel.getDate();
			mes_atual = variavel.getMonth() + 1;
			ano_atual = variavel.getFullYear();

			if(mes == '' && ano == ''){
				dia = 31;
				mes = '01';
				ano = '2005';
			}
			if(mes == '') mes = '01';
			if(ano == '') ano = '2007';

			if(mes == '01' || mes == '03' || mes == '05' || mes == '07' || mes == '08' || mes == '10' || mes == '12') dia = 31;
			else if(mes == '04' || mes == '06' || mes == '09' || mes == '11') dia = 30;
			else if((mes == '02') && (ano % 4 == 0)) dia = 29;
			else dia = 28;

			if(aux == ''){
				document.getElementById('data_inicial_receita').value = "01/"+mes+"/"+ano;
				document.getElementById('data_final_receita').value = "07/"+mes+"/"+ano;

				document.getElementById('data_inicial_despesa').value = "01/"+mes+"/"+ano;
				document.getElementById('data_final_despesa').value = "07/"+mes+"/"+ano

				document.getElementById('data_inicial_compra').value = "01/"+mes+"/"+ano;
				document.getElementById('data_final_compra').value = "07/"+mes+"/"+ano
			} else if(aux == '_tri'){
				if(mes == '01') {
					data1 = "01/01/"+ano;
					data2 = "31/03/"+ano;
				}
				if(mes == '02') {
					data1 = "01/04/"+ano;
					data2 = "30/06/"+ano;
				}
				if(mes == '03') {
					data1 = "01/07/"+ano;
					data2 = "30/09/"+ano;
				}
				if(mes == '04') {
					data1 = "01/10/"+ano;
					data2 = "31/12/"+ano;
				}

				document.getElementById('data_inicial_receita').value = data1;

				document.getElementById('data_final_receita').value = dia_atual+"/"+mes_atual+"/"+ano_atual;
				document.getElementById('data_final_despesa').value = dia_atual+"/"+mes_atual+"/"+ano_atual;
				document.getElementById('data_final_compra').value = dia_atual+"/"+mes_atual+"/"+ano_atual;
			}
		}
	}

	//Função para formatar a data que o usuário vai digitando
	function destrava_periodo() {
		if(document.getElementById('indica_bkp').checked == true){
			document.getElementById('tabela').disabled = false;
		} else {
			document.getElementById('tabela').disabled = true;
		}
	}

	//Função para calcular a porcentagem e a diferença do rateio - (na opção Livre)
	function verifica_valor_rateio(){
	   var sv = 0, aux= 0, p = 0, d = 0, v = 0;
       var vt = document.getElementById('valort').value; vt = parseFloat(vt);
	    for (var i = 0; i < document.forms[0].elements.length; i++) {
			var x = document.forms[0].elements[i];
			if((x.name.substr(0,11) == "valor_novo_") ){
				var v = x.value; v = parseFloat(v);
                var v1 = x.value; v1 = parseFloat(v1);				            
			}
			p = (100 * v1) / vt; 
            sv = sv + v;		
                     
            for (var j = i; j < document.forms[0].elements.length; j++) {
			var y = document.forms[0].elements[j];
			if((y.name.substr(0,12) == "porcentagem_") ){
				y.value = p;
				               				            
			   }
			break; 
            }            
            v = 0;           
        }   
        d = vt - sv;       
        d = (Math.round(d*100))/100; 
        document.getElementById('diferenca').value = d;
        
        if(document.getElementById('diferenca').value == 0 || document.getElementById('diferenca').value == 0.00){
				document.getElementById('salva').disabled = false;			    
            }
        if(document.getElementById('diferenca').value != 0 || document.getElementById('diferenca').value != 0.00){
				document.getElementById('salva').disabled = true;				
			}
			
       }
		
          
   
//-----------------------------------------------------
//Funcao: MascaraMoeda
//Sinopse: Mascara de preenchimento de moeda
//Parametro:
//   objTextBox : Objeto (TextBox)
//   SeparadorMilesimo : Caracter separador de milésimos
//   SeparadorDecimal : Caracter separador de decimais
//   e : Evento
//Retorno: Booleano
//-----------------------------------------------------
function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;
// 13=enter, 8=backspace as demais retornam 0(zero)
// whichCode==0 faz com que seja possivel usar todas as teclas como del, setas, etc
    if ((whichCode == 13) || (whichCode == 0) || (whichCode == 8) )
    return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
        
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida
    len = objTextBox.value.length;
    for(i = 0; i < len; i++)
        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
    aux = '';
    for(; i < len; i++)
        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) objTextBox.value = '';
    if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
    if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
    if (len > 2) {
        aux2 = '';
        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += SeparadorMilesimo;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }
        objTextBox.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--)
        objTextBox.value += aux2.charAt(i);
        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }
    return false;
}
//</script>
//Exemplo de utilização:
//<form>
//Valor R$: <input type="text" name="valor"  onKeyPress="return(MascaraMoeda(this,'.',',',event))">
//</form>



 //Função para verificar se o usuário digitou o valor acima de X saldo  - (devl e complementacao)
	function verifica_valores(){
	   var valor_em_especie = 0;
		var j = 1;
		
        if(document.getElementById('tipodec').value == 0){
        //devolucao
        for (var i = 0; i<document.forms[0].elements.length; i++) {
			var x = document.forms[0].elements[i];
			var y = document.forms[0].elements[j];
			if((x.name.substr(0,12) == "saldo_total_") && (y.name.substr(0,11) == "valor_novo_") ){
				var sal_esp = x.value; sal_esp = parseFloat(sal_esp);
				var val_esp = y.value; val_esp = parseFloat(val_esp);
	            if(val_esp <= sal_esp){
					valor_em_especie = sal_esp - val_esp;
				    
                } else {
					y.value = x.value;
					sal_esp = val_esp;
                    valor_em_especie = sal_esp - val_esp;
					alert("Valor digitado maior que o Saldo, o valor digitado foi alterado para R$ "+x.value+".");
				}
			}
			j++;
        }
        
        }else{
        //complementacao               
        for (var i = 0; i<document.forms[0].elements.length; i++) {
			var x = document.forms[0].elements[i];
			var y = document.forms[0].elements[j];
			if((x.name.substr(0,12) == "saldo_total_") && (y.name.substr(0,11) == "valor_novo_") ){
				var sal_esp = x.value; sal_esp = parseFloat(sal_esp);
				var val_esp = y.value; val_esp = parseFloat(val_esp);
	            if(val_esp <= sal_esp){
					valor_em_especie = sal_esp + val_esp;
				  
                } else {
					y.value = x.value;
					val_esp = sal_esp;
                    valor_em_especie = sal_esp + val_esp;
					alert("Valor digitado maior que o Saldo, o valor digitado foi alterado para R$ "+x.value+".");
				}
			}
			j++;
        }
        
        }
               
        aux_valor = valor_em_especie ;
        aux_valor = (Math.round(aux_valor*100))/100;
        document.getElementById('valor3').value = aux_valor;
        
        
    }





 //Função para somar cheque fornecedor e troca
    function soma_cheque_fornecedor(){
        var valor_em_especie = 0;
		var valor_em_especie2 = 0;
		for (var i = 0; i<document.forms[0].elements.length; i++) {
			var x = document.forms[0].elements[i];
			if((x.name.substr(0,23) == "dado_cheque_fornecedor_") && (x.checked == true) ){
				var sal_esp = x.value; sal_esp = parseFloat(sal_esp);
				valor_em_especie = valor_em_especie + sal_esp;
			}
			if((x.name.substr(0,18) == "dado_cheque_troca_") && (x.checked == true) ){
				var sal_esp2 = x.value; sal_esp2 = parseFloat(sal_esp2);
				valor_em_especie2 = valor_em_especie2 + sal_esp2;
			}
                   
        }
        
        valor_em_especie = (Math.round(valor_em_especie*100))/100;
        document.getElementById('total_selecionado_troca').value = valor_em_especie;
        valor_em_especie2 = (Math.round(valor_em_especie2*100))/100;
        document.getElementById('total_em_cheque').value = valor_em_especie2;
    }

    //Função para verificar se o usuário digitou o valor acima de X saldo 
	function verifica_valor(){
	   var valor_em_especie = 0;
		var j = 1;
		for (var i = 0; i<document.forms[0].elements.length; i++) {
			var x = document.forms[0].elements[i];
			var y = document.forms[0].elements[j];
			if((x.name.substr(0,12) == "saldo_total_") && (y.name.substr(0,11) == "valor_novo_") ){
				var sal_esp = x.value; sal_esp = parseFloat(sal_esp);
				var val_esp = y.value; val_esp = parseFloat(val_esp);
				if( (isNaN(val_esp)) || (val_esp < 0) ){
					val_esp = 0;
					y.value = "0.00";
					alert("Valor digitado menor que zero, o valor digitado foi alterado para R$ 0.00");
				}

				if(val_esp <= sal_esp){
					valor_em_especie = valor_em_especie + val_esp;
				} else {
					valor_em_especie = valor_em_especie + sal_esp;
					y.value = x.value;
					alert("Valor digitado maior que o Saldo, o valor digitado foi alterado para R$ "+x.value+".");
				}
			}
			j++;
        }
                       
        document.getElementById('total_dinheiro_somado').value = valor_em_especie;
        valor_em_especie = (Math.round(valor_em_especie*100))/100;
        tot_sel_tro = document.getElementById('total_selecionado_troca').value;
        tot_sel_tro = parseFloat(tot_sel_tro);
        tot_em_che = document.getElementById('total_em_cheque').value;
        tot_em_che = parseFloat(tot_em_che);
        aux_valor = tot_sel_tro - tot_em_che - valor_em_especie;
        aux_valor = (Math.round(aux_valor*100))/100;
        document.getElementById('diferenca_analisada').value = aux_valor;
        
        if(document.getElementById('diferenca_analisada').value == 0 && (document.getElementById('total_em_cheque').value != 0 || document.getElementById('total_selecionado_troca').value != 0 || document.getElementById('total_dinheiro_somado').value != 0 )){
				document.getElementById('troca').disabled = false;
			    alert("Diferença igual a zero ! Agora é possivel efetuar troca !"); 
            }
        if(document.getElementById('diferenca_analisada').value != 0 ){
				document.getElementById('troca').disabled = true;				
			}
    }



	//Função para formatar a data que o usuário vai digitando
	function formatar_dd_mm_yyyy(id, tammax, teclapres) {
		if(window.event) { // Internet Explorer
			var tecla = teclapres.keyCode;
		} else if(teclapres.which) { // Nestcape / firefox
			var tecla = teclapres.which;
		}

		vr = document.getElementById(id).value;
		vr = vr.toString().replace( "/", "" );
		tam = vr.length;

		if ((tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105) ){
			if (tam == 2) {
				document.getElementById(id).value = vr + "/";
			}
			if (tam == 4) document.getElementById(id).value = vr.substr(0, 2) + '/' + vr.substr(2, 2) + '/';
		}
	}

	//Função simples que atualiza o mês a partir do combo
	function atualiza_dia_periodo_lf(){
		var mes = document.getElementById('tabela').value.substr(8,2);
		var ano = document.getElementById('tabela').value.substr(3,4);
		var aux = document.getElementById('tabela').value.substr(10,4);

		if(mes == '' && ano == ''){
			dia = 31;
			mes = '01';
			ano = '2005';
		}
		if(mes == '') mes = '01';
		if(ano == '') ano = '2007';

		if(mes == '01' || mes == '03' || mes == '05' || mes == '07' || mes == '08' || mes == '10' || mes == '12') dia = 31;
		else if(mes == '04' || mes == '06' || mes == '09' || mes == '11') dia = 30;
		else if((mes == '02') && (ano % 4 == 0)) dia = 29;
		else dia = 28;

		if(aux == ''){
			document.getElementById('data_1').value = "01/"+mes+"/"+ano;
			document.getElementById('data_2').value = dia+"/"+mes+"/"+ano;
		} else if(aux == '_tri'){
			if(mes == '01') {
				data1 = "01/01/"+ano;
				data2 = "31/03/"+ano;
			}
			if(mes == '02') {
				data1 = "01/04/"+ano;
				data2 = "30/06/"+ano;
			}
			if(mes == '03') {
				data1 = "01/07/"+ano;
				data2 = "30/09/"+ano;
			}
			if(mes == '04') {
				data1 = "01/10/"+ano;
				data2 = "31/12/"+ano;
			}

			document.getElementById('data_1').value = data1;
			document.getElementById('data_2').value = data2;
		}
	}

	//Função para verificar se o usuário digitou o valor acima de 65.000 registros
	function valida_maxima_quantidade(){
		val_max = document.getElementById('qtde_registros').value;
		val_max = parseFloat(val_max);

		if(isNaN(val_max)){
			val_max = 50;
		}

		if(val_max > 30000) {
			val_max = 30000;
			alert ("A quantidade máxima que você pode escolher é 30.000 mil registros, a quantidade digitada foi alterada para o valor máximo!");
		}
		document.getElementById('qtde_registros').value = val_max;
	}

	//Função para somar os valores das abas em Financeiro Marketing, Financeiro ...
	function valores_somados_abas(){
		val_cre_cc = document.getElementById('valor_credito_cc_digitado').value;
		val_cre_cc = parseFloat(val_cre_cc);
		val_esp = document.getElementById('valor_especie_digitado').value;
		val_esp = parseFloat(val_esp);
		val_che = document.getElementById('valor_cheques_digitado').value;
		val_che = parseFloat(val_che);
		val_bor = document.getElementById('valor_bordero_digitado').value;
		val_bor = parseFloat(val_bor);
		val_out_uni = document.getElementById('valor_outra_unidade_digitado').value;
		val_out_uni = parseFloat(val_out_uni);
		aux_valor = val_cre_cc + val_esp + val_che + val_bor + val_out_uni;
		aux_valor = (Math.round(aux_valor*100))/100;
		document.getElementById('valor_total_digitado').value = aux_valor;
	}

	//Função para verificar a diferença em Financeiro Marketing, Financeiro ...
	function soma_diferenca(){
		val_a_pag = document.getElementById('a_pagar').value;
		val_a_pag = parseFloat(val_a_pag);
		val_tot = document.getElementById('valor_total_digitado').value;
		val_tot = parseFloat(val_tot);
		diferenca_valor = val_a_pag - val_tot;
		diferenca_valor=(Math.round(diferenca_valor*100))/100;
		document.getElementById('valor_diferenca').value = diferenca_valor;
	}

	//Função para as telas de Financeiro Marketing, Financeiro ...
	function soma_abas(){
		valor_em_especie = 0;
		valor_cheque_proprio = 0;
		valor_cheque_eletronico = 0;
		valor_cheque_bordero = 0;
		valor_unidade = 0;
		var j = 1;
		for (var i = 0; i<document.forms[0].elements.length; i++) {
			var x = document.forms[0].elements[i];
			var y = document.forms[0].elements[j];
			if((x.name.substr(0,12) == "saldo_total_") && (y.name.substr(0,11) == "valor_novo_") ){
				sal_esp = x.value; sal_esp = parseFloat(sal_esp);
				val_esp = y.value; val_esp = parseFloat(val_esp);
				if(isNaN(val_esp)){
					val_esp = 0;
					y.value = "0.00";
					alert("Valor digitado menor que zero, o valor digitado foi alterado para R$ 0.00");
				}

				if(val_esp <= sal_esp){
					valor_em_especie = valor_em_especie + val_esp;
				} else {
					valor_em_especie = valor_em_especie + sal_esp;
					y.value = x.value;
					alert("Valor digitado maior que o Saldo, o valor digitado foi alterado para R$ "+x.value+".");
				}
			}
			j++;
			if(x.name.substr(0,21) == "valor_cheque_proprio_"){
				val_che_pro = x.value; val_che_pro = parseFloat(val_che_pro);
				valor_cheque_proprio = valor_cheque_proprio + val_che_pro;
			}
			if(x.name.substr(0,21) == "valor_cheque_bordero_"){
				val_che_bor = x.value; val_che_bor = parseFloat(val_che_bor);
				valor_cheque_bordero = valor_cheque_bordero + val_che_bor;
			}
			if(x.name.substr(0,14) == "valor_unidade_"){
				val_uni = x.value; val_uni = parseFloat(val_uni);
				valor_unidade = valor_unidade + val_uni;
			}
			if(x.name.substr(0,24) == "valor_cheque_eletronico_"){
				val_che_ele = x.value; val_che_ele = parseFloat(val_che_ele);
				valor_cheque_eletronico = valor_cheque_eletronico + val_che_ele;
			}
		}
		valor_em_especie=(Math.round(valor_em_especie*100))/100;
		valor_cheque_proprio=(Math.round(valor_cheque_proprio*100))/100;
		valor_cheque_bordero=(Math.round(valor_cheque_bordero*100))/100;
		valor_unidade=(Math.round(valor_unidade*100))/100;
		valor_cheque_eletronico=(Math.round(valor_cheque_eletronico*100))/100;

		valores = valor_em_especie + valor_cheque_proprio + valor_cheque_bordero + valor_unidade + valor_cheque_eletronico;
		valores=(Math.round(valores*100))/100;
		v_final = document.getElementById('a_pagar').value;
		v_final = parseFloat(v_final);
		if(valores == v_final){
			alert("Valor total do lançamento digitado corretamente, click no botão 'Salvar e Sair' ");
		} else if(valores > v_final){
			alert("Soma dos valores digitados é maior do que o valor do lançamento, favor verificar os valores novamente!");
		}
		valores=(Math.round(valores*100))/100;
		document.forms[0].valor_especie_digitado.value = valor_em_especie;
		document.forms[0].valor_credito_cc_digitado.value = valor_cheque_proprio + valor_cheque_eletronico;
		document.forms[0].valor_bordero_digitado.value = valor_cheque_bordero;
		document.forms[0].valor_outra_unidade_digitado.value = valor_unidade;
	}

	//Função para setar zero em lugares que estão vazios ou onde forão digitados letras
	function seta_zero_real(){
		val_qua = parseFloat(document.getElementById('quantidade').value);

		if(isNaN(val_qua)){
			document.getElementById('quantidade').value = "0.00";
			alert("Valor digitado menor que zero, o valor digitado foi alterado para R$ 0.00");
		}
	}

	//Mostrar cores na tela
	function drawCell(red, green, blue) {
		document.write('<TD BGCOLOR="#' + red + green + blue + '">')
		document.write('<A HREF="javascript:display(\'' + (red + green + blue) + '\')">')
		document.write('<IMG SRC="place.gif" BORDER=0 HEIGHT=14 WIDTH=14>')
		document.write('</A>')
		document.write('</TD>')
	}

    //Mostrar cores na tela
	function drawRow(red, blue) {
		document.write('<TR>')
		for (var i = 0; i < 4; ++i) {
			drawCell(red, hex[i], blue)
		}
		document.write('</TR>')
	}

    //Mostrar cores na tela
	function drawTable(blue) {
		document.write('<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>')
		for (var i = 0; i < 4; ++i) {
			drawRow(hex[i], blue)
		}
		document.write('</TABLE>')
	}

    //Mostrar cores na tela
	function drawCube() {
		document.write('<TABLE CELLPADDING=5 CELLSPACING=0 BORDER=0><TR>')
		for (var i = 0; i < 5; ++i) {
			document.write('<TD BGCOLOR="#FFFFFF">')
			drawTable(hex[i])
			document.write('</TD>')
		}
		document.write('<TD width=\'5%\'></TD>')
/*
		for (var i = 3; i < 6; ++i) {
			document.write('<TD BGCOLOR="#FFFFFF">')
			drawTable(hex[i])
			document.write('</TD>')
   		}
		document.write('</TR></TABLE>')
*/
	}

	//Função para travar o teclado
	function teclado_travado() {
		event.returnValue = false;
	}	

	//Função simples para validar a data digitada
	function ValidaData(data){
		exp = /\d{2}\/\d{2}\/\d{4}/

		var dd1 = data.value.substr(0,2);
		var mm1 = data.value.substr(3,2);
		var yyyy1 = data.value.substr(6,4);

		var dd = data.value.substr(0,2);
		var mm = data.value.substr(3,2);
		var yyyy = data.value.substr(6,4);

		dd = parseFloat(dd);
		mm = parseFloat(mm);
		yyyy = parseFloat(yyyy);

		variavel = new Date();
		dia = variavel.getDate();
		mes = variavel.getMonth() + 1;
		ano = variavel.getFullYear();
		//ano = 2007;

		if (data.value != ''){
			if (exp.test(data.value)){
				if (yyyy >= 1900 && yyyy < 2038){
					if(mm == 01 || mm == 03 || mm == 05 || mm == 07 || mm == 08 || mm == 10 || mm == 12){
						if(dd > 00 && dd <= 31){
							dia = parseFloat(dd1); mes = parseFloat(mm1);
						} else {
							dia = 31; mes = parseFloat(mm1);
							alert('ATENÇÃO!!\n\nPara este mês o ultimo dia corrente é dia 31, foi atribuido o dia 31 para este mês!');
						}
						if(dia < 10) dia = "0" + dia;
						if(mes < 10) mes = "0" + mes;
						data_atual = dia + "/" + mes + "/" + yyyy1;
					} else if(mm == 04 || mm == 06 || mm == 09 || mm == 11){
						if(dd > 00 && dd <= 30){
							dia = parseFloat(dd1); mes = parseFloat(mm1);
						} else {
							dia = 30; mes = parseFloat(mm1);
							alert('ATENÇÃO!!\n\nPara este mês o ultimo dia corrente é dia 30, foi atribuido o dia 30 para este mês!');
						}
						if(dia < 10) dia = "0" + dia;
						if(mes < 10) mes = "0" + mes;
						data_atual = dia + "/" + mes + "/" + yyyy1;
					} else if(mm == 02){
						if((yyyy % 4) == 0){
							if(dd > 00 && dd <= 29){
								dia = parseFloat(dd1); mes = parseFloat(mm1);
							} else {
								dia = 29; mes = parseFloat(mm1);
								alert('ATENÇÃO!!\n\nPara este mês deste ano o ultimo dia corrente é dia 29, foi atribuido o dia 29 para este mês!');
							}
						} else {
							if(dd > 00 && dd <= 28){
								dia = parseFloat(dd1); mes = parseFloat(mm1);
							} else {
								dia = 28; mes = parseFloat(mm1);
								alert('ATENÇÃO!!\n\nPara este mês deste ano o ultimo dia corrente é dia 28, foi atribuido o dia 28 para este mês!');
							}
						}
						if(dia < 10) dia = "0" + dia;
						if(mes < 10) mes = "0" + mes;
						data_atual = dia + "/" + mes + "/" + yyyy1;
					} else {
						if(dia < 10) dia = "0" + dia;
						if(mes < 10) mes = "0" + mes;
						data_atual = dia + "/" + mes + "/" + ano;
						alert('ATENÇÃO\r\nNão existe este mês, favor digitar um mês entre 1 e 12.\nFoi atribuido a este campo a data atual: '+ data_atual);
					}
				} else {
					if(dia < 10) dia = "0" + dia;
					if(mes < 10) mes = "0" + mes;
					data_atual = dia + "/" + mes + "/" + ano;
					alert('ATENÇÃO\r\nA Data digitada está invalida, favor digitar uma data entre 01/01/1900 e 31/12/2037.\nFoi atribuido a este campo a data atual: '+ data_atual);
				}
			} else {
				if(dia < 10) dia = "0" + dia;
				if(mes < 10) mes = "0" + mes;
				data_atual = dia + "/" + mes + "/" + ano;
				alert('ATENÇÃO\r\nA Data digitada está invalida, favor digitar uma data entre 01/01/1900 e 31/12/2037.\nFoi atribuido a este campo a data atual: '+ data_atual);
			}
			data.value = data_atual;
		} else {
			if(dia < 10) dia = "0" + dia;
			if(mes < 10) mes = "0" + mes;
			data_atual = dia + "/" + mes + "/" + ano;
			data.value = data_atual;
			alert('ATENÇÃO!!\n\nNão é possivel deixar este campo vazio, foi atribuido a este campo a seguinte data: '+ data_atual);
		}
	}

	//Função simples que valida o telefone digitado
	function ValidaTelefone(tel){
		exp = /\d{3}\-\d{8}/
		if (tel.value != ''){
			if(!exp.test(tel.value))
			alert('Numero de Telefone Invalido, formato correto: DDD-Telefone!'  );
		}
	}

	//Função simples que valida a hora digitada
	function ValidaHora(hora){
		exp = /\d{2}\:\d{2}\:\d{2}/
		if (hora.value != ''){
			if(!exp.test(hora.value))
			alert('Hora Digitada Inválida!');
		}
	}

	//Função que valida o CPF digitado
	function ValidarCPF(Objcpf){
		var cpf = Objcpf.value;
		exp = /\.|\-/g
		cpf = cpf.toString().replace( exp, "" );
		var digitoDigitado = eval(cpf.charAt(9)+cpf.charAt(10));
		var soma1=0, soma2=0;
		var vlr =11;

		for(i=0;i<9;i++){
			soma1+=eval(cpf.charAt(i)*(vlr-1));
			soma2+=eval(cpf.charAt(i)*vlr);
			vlr--;
		}
		soma1 = (((soma1*10)%11)==10 ? 0:((soma1*10)%11));
		soma2=(((soma2+(2*soma1))*10)%11);

		if (Objcpf.value != ''){
			var digitoGerado=(soma1*10)+soma2;
			if(digitoGerado != digitoDigitado || cpf == '00000000000' || cpf == '11111111111' || cpf == '22222222222' || cpf == '33333333333' || cpf == '44444444444' || cpf == '55555555555' || cpf == '66666666666' || cpf == '77777777777' || cpf == '88888888888' || cpf == '99999999999')
			alert('O CPF digitado está inválido, favor digitar um CPF válido!\nQualquer dúvida entrar em contato com CPD-Desenvolvimento');
		}
	}

	//Função que valida o CNPJ digitado
	function ValidarCNPJ(ObjCnpj){
		var cnpj = ObjCnpj.value;
		var valida = new Array(6,5,4,3,2,9,8,7,6,5,4,3,2);
		var dig1= new Number;
		var dig2= new Number;

		exp = /\.|\-|\//g
		cnpj = cnpj.toString().replace( exp, "" );
		var digito = new Number(eval(cnpj.charAt(12)+cnpj.charAt(13)));

		for(i = 0; i<valida.length; i++){
			dig1 += (i>0? (cnpj.charAt(i-1)*valida[i]):0);
			dig2 += cnpj.charAt(i)*valida[i];
		}
		dig1 = (((dig1%11)<2)? 0:(11-(dig1%11)));
		dig2 = (((dig2%11)<2)? 0:(11-(dig2%11)));

		if (ObjCnpj.value != ''){
			if(((dig1*10)+dig2) != digito || cnpj == '00000000000000')
			alert('O CNPJ está invalido!');
		}
	}
	
	//Função que valida o CNPJ2 digitado
	function validaCNPJ2(val){

		var cnpj = val;
		var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;

		digitos_iguais = 1;

		for (var i=0; i < cnpj.length - 1; i++)
			if (cnpj.charAt(i) != cnpj.charAt(i + 1)) {
				digitos_iguais = 0;
				break;
			}

		if (!digitos_iguais) {
			tamanho = cnpj.length - 2
			numeros = cnpj.substring(0,tamanho);
			digitos = cnpj.substring(tamanho);
			soma = 0;
			pos = tamanho - 7;

			for (var i=tamanho; i >= 1; i--) {
				soma += numeros.charAt(tamanho - i) * pos--;
				if (pos < 2) {
					pos = 9;
				}
			}
			resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
			if(resultado != digitos.charAt(0)) {
				return false;
			}

			tamanho = tamanho + 1;
			numeros = cnpj.substring(0,tamanho);
			soma = 0;
			pos = tamanho - 7;

			for (i = tamanho; i >= 1; i--) {
				soma += numeros.charAt(tamanho - i) * pos--;
				if (pos < 2) {
					pos = 9;
				}
			}
			resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
			if (resultado != digitos.charAt(1)) {
				return false;
			}
			return true;
		} else {
			return false;
		}
	}

	//Função que valida o CPF2 digitado
	function validaCPF2(val){
	    var i;
    	var soma = soma2 = 0;
	    var cpf = val;
    	if (!(cpf.match(/^[0-9]{3,3}[.]{0,1}[0-9]{3,3}[.]{0,1}[0-9]{3,3}[-]{0,1}[0-9]{2,2}$/))) {
        	return false;
    	}
    	cpf = retiraCaracter(retiraCaracter(cpf, '.'), '-');
    	for(i=0;i<10;i++) {
        	if (i<9) {
            	soma += cpf.charAt(i) * (10 - i);
	        }
    	    soma2 += cpf.charAt(i) * (11 - i);
	    }
    	if(((soma % 11) < 2 ? 0 : 11 - (soma  % 11 )) != cpf.charAt(9)) {
        	return false;
	    }
    	return (((soma2 % 11 ) < 2 ? 0 : 11 - (soma2 % 11 )) != cpf.charAt(10)) ? false : true;
	}

	//Função que retira caracter
	function retiraCaracter(string, caracter) {
		var i = 0;
		var final = '';
		while (i < string.length) {
			if (string.charAt(i) == caracter) {
				final += string.substr(0, i);
				string = string.substr(i+1, string.length - (i+1));
				i = 0;
			} else {
				i++;
			}
		}
		return final + string;
	}

	//Função simples que valida o CEP digitado
	function ValidaCep(cep){
		exp = /\d{5}\-\d{3}/
		if (cep.value != ''){
			if(!exp.test(cep.value))
			alert('Numero do Cep digitado está inválido, formato correto: 00000-000!');
		}
	}

	//Função simples que esconde um dv
	function dvHide(dvID) {
		if (document.getElementById && document.getElementById(dvID) && document.getElementById(dvID).style) {
			document.getElementById(dvID).style.visibility="hidden";
		}
	}

	//Função simples que mostra um dv
	function dvShow(dvID) {
		if (document.getElementById && document.getElementById(dvID) && document.getElementById(dvID).style) {
			document.getElementById(dvID).style.visibility="visible";
		}
	}

	//Função simples que mostra um popup tamanho pequeno
	function PopupAlert(strFile, strName) {
		var Uwidth  = window.screen.width;
		var Uheight = window.screen.height;
		var Pleft = (Uwidth/2)-175;
		var Ptop  = (Uheight/2)-100;
		window.open(strFile, strName, "width=400,height=200,left="+Pleft+",top="+Ptop+",location=no,menubar=no,directories=no,toolbar=no,status=no,personalbar=no,resizable=no,scrollbars=no,titlebar=Portal OBA");
	}

	//Função simples que mostra um popup tamanho pequeno
	function PopupAlert_atual(strFile, strName) {
		var Uwidth  = window.screen.width;
		var Uheight = window.screen.height;
		var Pleft = (Uwidth/2)-175;
		var Ptop  = (Uheight/2)-100;
		window.open(strFile, strName, "width=400,height=200,left="+Pleft+",top="+Ptop+",location=no,menubar=no,directories=no,toolbar=no,status=no,personalbar=no,resizable=no,scrollbars=no,titlebar=Portal OBA");
		atualizar_principal();
	}

	//Função simples que atualiza a pagina
	function atualizar_principal() {
		window.close();
		window.opener.reload();
		window.opener.focus();
	}

	//Função simples que mostra um popup tamanho médio
	function PopupA4(strFile, strName) {
		var h = 500;
		var w = 650;
		var Uwidth  = window.screen.width;
		var Uheight = window.screen.height;
		var Pleft = (Uwidth/2)-(w/2);
		var Ptop  = (Uheight/2)-(h/2);
		window.open(strFile, strName, "width="+w+",height="+h+",left="+Pleft+",top="+Ptop+",location=no,menubar=yes,directories=no,toolbar=no,status=no,personalbar=no,resizable=no,scrollbars=yes,titlebar=Portal Oba");
	}

	//Função simples que mostra um popup tamanho paisagem
	function PopupA4Paisagem(strFile, strName) {
		var h = 718;
		var w = 1058;
		var Uwidth  = window.screen.width;
		var Uheight = window.screen.height;
		var Pleft = (Uwidth/2)-(w/2);
		var Ptop  = (Uheight/2)-(h/2);
		window.open(strFile, strName, "width="+w+",height="+h+",left="+Pleft+",top="+Ptop+",location=no,menubar=no,directories=no,toolbar=no,status=no,personalbar=no,resizable=no,scrollbars=yes,titlebar=Portal Oba");
	}

	//Função simples que mostra um popup tamanho médio
	function PopupST(strFile, strName) {
		var h = 500;
		var w = 650;
		var Uwidth  = window.screen.width;
		var Uheight = window.screen.height;
		var Pleft = (Uwidth/2)-(w/2);
		var Ptop  = (Uheight/2)-(h/2);
		window.open(strFile, strName, "width="+w+",height="+h+",left="+Pleft+",top="+Ptop+",location=no,menubar=no,directories=no,toolbar=no,status=no,personalbar=no,resizable=no,scrollbars=yes,titlebar=Portal Oba");
	}

	//Função que trava a tela
	function TravaTela() {
		dvShow('dvCarrega');
		dvShow('dvBloqWin');
	}

	//Função que coloca o sistema em manutenção
	function Sistema_Manutencao() {
		dvShow('dvBloqWin');
	}

	//Função que libera a tela
	function LiberaTela() {
		dvHide('dvCarrega');
		dvHide('dvBloqWin');
	}

	//Função que sai do sistema e vai para a tela de login
	function ExitPortal() {
		if (confirm("Deseja realmente sair do sistema?")) {
			
			document.location.href="modulos.php?mod=0";			
		} else {
			window.location.href=window.location.href;
		}
	}

	//Função que valida o e-mail digitado
	function valida_email(email) {
		var camp = email.value;
		var i, arroba, cont, ret;
		i=0;
		if(email.value != ''){
			if (email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi)){
				while(i<camp.length){
					if(camp.charAt(i)=="@"){
						cont = 1;
					}
					i++
				}
				if(cont!=1){
					alert("Email digitado incorreto, favor digitar novamente!")
				}
			} else {
				alert("Email digitado incorreto, favor digitar novamente!")
			}
		}
	}

	function PrintDialog(){
		var NS = (navigator.appName == "Netscape");
		var VERSION = parseInt(navigator.appVersion);
		if(NS){
			window.print();
		}else{
			var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
			document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
			WebBrowser1.ExecWB(6, 2);
			WebBrowser1.outerHTML = "";
		}
	}

/*
	Função que formata os dados de um campo
	variáveis:
		e recebe o evento da janela
		src recebe o campo onde será aplicado a formatação
		mask recebe o valor da formatação
	Autor Eduardo Ferreira de Carvalho <edufc@redeoba.com.br>
	Versão 1.0 13/06/2007
*/
	function MM_formtDados(e,src,mask){
		if(window.event) { _TXT = e.keyCode; } //IE
		else if(e.which) { _TXT = e.which; }   //Mozilla

		if(_TXT > 47 && _TXT < 58){
			var i = src.value.length;
			var saida = mask.substring(0,1);
			var texto = mask.substring(i);
			if(texto.substring(0,1) != saida){
				src.value += texto.substring(0,1);
			}
			return true;
		} else {
			if (_TXT != 8) {
				return false;
			} else {
				return true;
			}
		}
	}


/*
	Função que formata valores numéricos
	variáveis:
		id recebe o evento da janela
		tammax recebe o tamanho do campo onde será aplicado a formatação
		teclapres recebe o valor da tecla pressionada
	Autor Eduardo Ferreira de Carvalho <edufc@redeoba.com.br>
	Versão 1.0 13/06/2007
*/
	function FormataValor(id,tammax,teclapres) {

		if(window.event) { // Internet Explorer
			var tecla = teclapres.keyCode; }
		else if(teclapres.which) { // Nestcape / firefox
			var tecla = teclapres.which;
		}

		vr = document.getElementById(id).value;
		vr = vr.toString().replace( "/", "" );
		vr = vr.toString().replace( "/", "" );
		vr = vr.toString().replace( ",", "" );
		vr = vr.toString().replace( ".", "" );
		vr = vr.toString().replace( ".", "" );
		vr = vr.toString().replace( ".", "" );
		vr = vr.toString().replace( ".", "" );
		tam = vr.length;

		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 <= 1)					document.getElementById(id).value = vr;
			if((tam > 1) && (tam <= 5))		document.getElementById(id).value = vr.substr( 0, tam - 1 ) + ',' + vr.substr( tam - 1, tam );
			if((tam >= 6) && (tam <= 8))	document.getElementById(id).value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam );
			if((tam >= 9) && (tam <= 11))	document.getElementById(id).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))	document.getElementById(id).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))	document.getElementById(id).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 );
		}
	}


/*
	Função que faz com que um campo apenas aceite números
	variáveis:
		e recebe o evento da janela
	Autor Eduardo Ferreira de Carvalho <edufc@redeoba.com.br>
	Versão 1.0 13/06/2007
*/
	function Numero(e){
		navegador = /msie/i.test(navigator.userAgent);
		if (navegador)
			var tecla = event.keyCode;
		else
			var tecla = e.which;

		if( (tecla > 47 && tecla < 58) || (tecla == 0) ) // numeros de 0 a 9
			return true;
		else {
			if (tecla != 8) // backspace
				return false;
			else
				return true;
		}
	}

/*
	Função que faz com que um campo apenas aceite números, backspace e delete
	Autor Luis Antonio Ferreira da Silva <luis.silva@redeoba.com.br>
	Versão 1.0 13/12/2007
*/
	function somente_numeros(e){
		navegador = /msie/i.test(navigator.userAgent);
		if (navegador)
			var tecla = event.keyCode;
		else
			var tecla = e.which;

		if((tecla > 47 && tecla < 58) || (tecla == 8) || (tecla == 0)){ // numeros de 0 a 9
			return true;
		} else {
			alert ("ATENÇÃO por favor, digite apenas números!");
			return false;
		}
	}

/*
	Função que faz com que um campo apenas aceite os numeros 1 e/ou 0
	Autor Luis Antonio Ferreira da Silva <luis.silva@redeoba.com.br>
	Versão 1.0 12/12/2007
*/
	function numero_zero_um(id, teclapres){
		if(window.event) { // Internet Explorer
			var tecla = teclapres.keyCode;
		} else if(teclapres.which) { // Nestcape / firefox
			var tecla = teclapres.which;
		}
		if (tecla == 48){
			document.getElementById(id).value = 0;
		} else if (tecla == 49 ){
			document.getElementById(id).value = 1;
		} else {
			document.getElementById(id).value = 0;
			vr = document.getElementById(id).value;
			vr = vr.toString().replace("0", " " );
			document.getElementById(id).value = vr;
		}
	}

/*
	Função formata os valores digitados com maskara 0.00, apenas 7 digitos
	Autor Luis Antonio Ferreira da Silva <luis.silva@redeoba.com.br>
	Versão 1.0 12/12/2007
*/
	function FormataValor_MySQL(id, tammax, teclapres) {
		if(window.event) { // Internet Explorer
			var tecla = teclapres.keyCode;
		} else if(teclapres.which) { // Nestcape / firefox
			var tecla = teclapres.which;
		}

		vr = document.getElementById(id).value;
		vr = vr.toString().replace( "/", "" );
		vr = vr.toString().replace( ",", "" );
		vr = vr.toString().replace( ".", "" );
		tam = vr.length;

		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 == 1 || tam == 2) document.getElementById(id).value = '.' + vr;
			if (tam == 3) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(1, tam);
			if (tam == 4) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(2, tam);
			if (tam == 5) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(3, tam);
			if (tam == 6) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(4, tam);
			if (tam == 7) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(5, tam);
		}
	}

/*
	Função formata os valores digitados com maskara 0.000,00
	Autor Luis Antonio Ferreira da Silva <luis.silva@redeoba.com.br>
	Versão 1.0 12/12/2007
*/
	function FormataValor_real(id, tammax, teclapres) {
		if(window.event) { // Internet Explorer
			var tecla = teclapres.keyCode;
		} else if(teclapres.which) { // Nestcape / firefox
			var tecla = teclapres.which;
		}

		vr = document.getElementById(id).value;
		vr = vr.toString().replace( "/", "" );
		vr = vr.toString().replace( ",", "" );
		vr = vr.toString().replace( ".", "" );
		tam = vr.length;

		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 == 1 || tam == 2) document.getElementById(id).value = ',' + vr;
			if (tam == 3) document.getElementById(id).value = vr.substr(0, tam - 2) + ',' + vr.substr(1, tam);
			if (tam == 4) document.getElementById(id).value = vr.substr(0, tam - 2) + ',' + vr.substr(2, tam);
			if (tam == 5) document.getElementById(id).value = vr.substr(0, tam - 2) + ',' + vr.substr(3, tam);
			if (tam == 6) document.getElementById(id).value = vr.substr(0, 1) + '.' + vr.substr(1, 3) + ',' + vr.substr(4, 2);
			if (tam == 7) document.getElementById(id).value = vr.substr(0, 2) + '.' + vr.substr(2, 3) + ',' + vr.substr(5, 2);
		}
	}

/*
	Função formata os valores digitados com maskara 0.00, apenas três digitos
	Autor Luis Antonio Ferreira da Silva <luis.silva@redeoba.com.br>
	Versão 1.0 12/12/2007
*/
	function Valor_3_digitos(id, tammax, teclapres) {
		if(window.event) { // Internet Explorer
			var tecla = teclapres.keyCode;
		} else if(teclapres.which) { // Nestcape / firefox
			var tecla = teclapres.which;
		}

		vr = document.getElementById(id).value;
		vr = vr.toString().replace( "/", "" );
		vr = vr.toString().replace( ",", "" );
		vr = vr.toString().replace( ".", "" );
		tam = vr.length;

		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 == 1 || tam == 2) document.getElementById(id).value = '.' + vr;
			if (tam == 3) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(1, tam);
		}
	}

/*
	Função formata os valores digitados com maskara 0.00, apenas 8 digitos
	Autor Luis Antonio Ferreira da Silva <luis.silva@redeoba.com.br>
	Versão 1.0 12/12/2007
*/
	function Formata_Valor_Simples(id, tammax, teclapres) {
		if(window.event) { // Internet Explorer
			var tecla = teclapres.keyCode;
		} else if(teclapres.which) { // Nestcape / firefox
			var tecla = teclapres.which;
		}

		vr = document.getElementById(id).value;
		vr = vr.toString().replace( "/", "" );
		vr = vr.toString().replace( ",", "" );
		vr = vr.toString().replace( ".", "" );
		tam = vr.length;

		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 == 1 || tam == 2) document.getElementById(id).value = '.' + vr;
			if (tam == 3) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(1, tam);
			if (tam == 4) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(2, tam);
			if (tam == 5) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(3, tam);
			if (tam == 6) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(4, tam);
			if (tam == 7) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(5, tam);
			if (tam == 8) document.getElementById(id).value = vr.substr(0, tam - 2) + '.' + vr.substr(6, tam);
		}
	}

/*
	Função que cria abas (cliente / fornecedores/ unidades adm / pessoas)
	Autor: Claudemir Trevisan <claudemir@redeoba.com.br>
	Versão 1.2 30/08/2007
*/
	//abas clientes
	function stAba_cli(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}

	function AlternarAbas_cli(menu,conteudo){
		var arAbas_cli = new Array();
		arAbas_cli[0] = new stAba_cli('td_dados_basicos','div_dados_basicos');
		arAbas_cli[1] = new stAba_cli('td_dados_complementares','div_dados_complementares');
		arAbas_cli[2] = new stAba_cli('td_dados_socio_economicos','div_dados_socio_economicos');
		arAbas_cli[3] = new stAba_cli('td_relacionamentos','div_relacionamentos');

		for (i=0;i<arAbas_cli.length;i++){
			m = document.getElementById(arAbas_cli[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbas_cli[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	//abas Baixa de lançamentos Financeiro
	function stAba_bai_fin(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}

	function AlternarAbas_bai_fin(menu,conteudo){
		var arAbas_bai_fin = new Array();
		arAbas_bai_fin[0] = new stAba_bai_fin('td_em_especie','div_em_especie');
		arAbas_bai_fin[1] = new stAba_bai_fin('td_cheques_proprios','div_cheques_proprios');
		arAbas_bai_fin[2] = new stAba_bai_fin('td_bordero','div_bordero');
		arAbas_bai_fin[3] = new stAba_bai_fin('td_outra_unidade','div_outra_unidade');
		arAbas_bai_fin[4] = new stAba_bai_fin('td_cheque_eletronico','div_cheque_eletronico');

		for (i=0;i<arAbas_bai_fin.length;i++){
			m = document.getElementById(arAbas_bai_fin[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbas_bai_fin[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	//abas Promoções Web
	function stAba_pro_web(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}

	function AlternarAbas_pro_web(menu,conteudo){
		var arAbas_pro_web = new Array();
		arAbas_pro_web[0] = new stAba_pro_web('td_saude_a_z','div_saude_a_z');
		arAbas_pro_web[1] = new stAba_pro_web('td_calendario_vegetal','div_calendario_vegetal');
		arAbas_pro_web[2] = new stAba_pro_web('td_cadastro','div_cadastro');
		arAbas_pro_web[3] = new stAba_pro_web('td_texto','div_texto');
		arAbas_pro_web[4] = new stAba_pro_web('td_exportar','div_exportar');

		for (i=0;i<arAbas_pro_web.length;i++){
			m = document.getElementById(arAbas_pro_web[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbas_pro_web[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	//abas Classificação LF
	function stAba_cla_lf(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}

	function AlternarAbas_cla_lf(menu,conteudo){
		var arAbas_cla_lf = new Array();
		arAbas_cla_lf[0] = new stAba_cla_lf('td_geral','div_geral');
		arAbas_cla_lf[1] = new stAba_cla_lf('td_funcionalidades','div_funcionalidades');
		arAbas_cla_lf[2] = new stAba_cla_lf('td_fornecedores','div_fornecedores');
		arAbas_cla_lf[3] = new stAba_cla_lf('td_configuracoes','div_configuracoes');

		for (i=0;i<arAbas_cla_lf.length;i++){
			m = document.getElementById(arAbas_cla_lf[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbas_cla_lf[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	//abas Classificação LF 3
	function stAba_cla_lf_novo(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}

	function AlternarAbas_cla_lf_novo(menu,conteudo){
		var arAbas_cla_lf_novo = new Array();
		arAbas_cla_lf_novo[0] = new stAba_cla_lf_novo('td_geral','div_geral');
		arAbas_cla_lf_novo[1] = new stAba_cla_lf_novo('td_fornecedores','div_fornecedores');
		arAbas_cla_lf_novo[2] = new stAba_cla_lf_novo('td_configuracoes','div_configuracoes');

		for (i=0;i<arAbas_cla_lf_novo.length;i++){
			m = document.getElementById(arAbas_cla_lf_novo[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbas_cla_lf_novo[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	//abas produtos
	function stAba_pro(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}

	function AlternarAbas_pro(menu,conteudo){
		var arAbas_pro = new Array();
		arAbas_pro[0] = new stAba_pro('td_volumes_movimentacao','div_volumes_movimentacao');
		arAbas_pro[1] = new stAba_pro('td_dados_empresa','div_dados_empresa');
		arAbas_pro[2] = new stAba_pro('td_classificacao','div_classificacao');
		arAbas_pro[3] = new stAba_pro('td_internet','div_internet');

		for (i=0;i<arAbas_pro.length;i++){
			m = document.getElementById(arAbas_pro[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbas_pro[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	//abas fornecedores
	function stAba_for(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}

	function AlternarAbas_for(menu,conteudo,valor){
		var arAbas_for = new Array();

		arAbas_for[0] = new stAba_for('td_dados_basicos','div_dados_basicos');
		arAbas_for[1] = new stAba_for('td_dados_financeiros','div_dados_financeiros');
		arAbas_for[2] = new stAba_for('td_relacionamentos','div_relacionamentos');
		arAbas_for[3] = new stAba_for('td_produtos_homologados','div_produtos_homologados');
		arAbas_for[4] = new stAba_for('td_setores','div_setores');
		arAbas_for[5] = new stAba_for('td_unidades_administrativas','div_unidades_administrativas');
		arAbas_for[6] = new stAba_for('td_dados_da_roca','div_dados_da_roca');

		if(valor == 0)
			var tam_abas = arAbas_for.length - 1;
		else
			var tam_abas = arAbas_for.length;

		for (i=0;i<tam_abas;i++){
			m = document.getElementById(arAbas_for[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbas_for[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	//abas unidades administrativas
	function stAba_uni(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}

	function AlternarAbas_uni(menu,conteudo,valor){
		var arAbas_uni = new Array();

		if(valor == 0){
			arAbas_uni[0] = new stAba_uni('td_dados_basicos','div_dados_basicos');
			arAbas_uni[1] = new stAba_uni('td_dados_complementares','div_dados_complementares');
			arAbas_uni[2] = new stAba_uni('td_relacionamentos','div_relacionamentos');
			arAbas_uni[3] = new stAba_uni('td_caixa','div_caixa');
			arAbas_uni[4] = new stAba_uni('td_depositos','div_depositos');
			arAbas_uni[5] = new stAba_uni('td_setores','div_setores');
		}

		if(valor == 1){
			arAbas_uni[0] = new stAba_uni('td_dados_basicos','div_dados_basicos');
			arAbas_uni[1] = new stAba_uni('td_dados_complementares','div_dados_complementares');
			arAbas_uni[2] = new stAba_uni('td_relacionamentos','div_relacionamentos');
			arAbas_uni[3] = new stAba_uni('td_caixa','div_caixa');
			arAbas_uni[4] = new stAba_uni('td_percentual_de_cobranca','div_percentual_de_cobranca');
		}

		if(valor == 2){
			arAbas_uni[0] = new stAba_uni('td_dados_basicos','div_dados_basicos');
			arAbas_uni[1] = new stAba_uni('td_dados_complementares','div_dados_complementares');
			arAbas_uni[2] = new stAba_uni('td_relacionamentos','div_relacionamentos');
			arAbas_uni[3] = new stAba_uni('td_caixa','div_caixa');
			arAbas_uni[4] = new stAba_uni('td_financeiro','div_financeiro');
		}

		if(valor == 3){
			arAbas_uni[0] = new stAba_uni('td_dados_basicos','div_dados_basicos');
			arAbas_uni[1] = new stAba_uni('td_dados_complementares','div_dados_complementares');
			arAbas_uni[2] = new stAba_uni('td_relacionamentos','div_relacionamentos');
			arAbas_uni[3] = new stAba_uni('td_caixa','div_caixa');
		}

		for (i=0;i<arAbas_uni.length;i++){
			m = document.getElementById(arAbas_uni[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbas_uni[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	//abas pessoas
	function stAba_pes(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}

	function AlternarAbas_pes(menu,conteudo,valor){
		var arAbas_pes = new Array();

		if(valor == 0){
			arAbas_pes[0] = new stAba_pes('td_dados_basicos','div_dados_basicos');
			arAbas_pes[1] = new stAba_pes('td_formacao','div_formacao');
			arAbas_pes[2] = new stAba_pes('td_experiencia','div_experiencia');
			arAbas_pes[3] = new stAba_pes('td_dados_candidato','div_dados_candidato');
			arAbas_pes[4] = new stAba_pes('td_parecer_psicologico','div_parecer_psicologico');
			arAbas_pes[5] = new stAba_pes('td_ocorrencias','div_ocorrencias');
		}

		if(valor == 1){
			arAbas_pes[0] = new stAba_pes('td_dados_basicos','div_dados_basicos');
			arAbas_pes[1] = new stAba_pes('td_funcoes','div_funcoes');
			arAbas_pes[2] = new stAba_pes('td_formacao','div_formacao');
			arAbas_pes[3] = new stAba_pes('td_experiencia','div_experiencia');
			arAbas_pes[4] = new stAba_pes('td_parecer_psicologico','div_parecer_psicologico');
			arAbas_pes[5] = new stAba_pes('td_avaliacao_30_dias','div_avaliacao_30_dias');
			arAbas_pes[6] = new stAba_pes('td_avaliacao_80_dias','div_avaliacao_80_dias');
			arAbas_pes[7] = new stAba_pes('td_ocorrencias','div_ocorrencias');
			arAbas_pes[8] = new stAba_pes('td_desligamento','div_desligamento');
			arAbas_pes[9] = new stAba_pes('td_dados_complementares','div_dados_complementares');
		}

		if(valor == 2){
			arAbas_pes[0] = new stAba_pes('td_dados_basicos','div_dados_basicos');
			arAbas_pes[1] = new stAba_pes('td_funcoes','div_funcoes');
			arAbas_pes[2] = new stAba_pes('td_formacao','div_formacao');
			arAbas_pes[3] = new stAba_pes('td_experiencia','div_experiencia');
			arAbas_pes[4] = new stAba_pes('td_parecer_psicologico','div_parecer_psicologico');
			arAbas_pes[5] = new stAba_pes('td_ocorrencias','div_ocorrencias');
		}

		if(valor == 3){
			arAbas_pes[0] = new stAba_pes('td_dados_basicos','div_dados_basicos');
			arAbas_pes[1] = new stAba_pes('td_formacao','div_formacao');
			arAbas_pes[2] = new stAba_pes('td_experiencia','div_experiencia');
			arAbas_pes[3] = new stAba_pes('td_parecer_psicologico','div_parecer_psicologico');
			arAbas_pes[4] = new stAba_pes('td_ocorrencias','div_ocorrencias');
		}

		for (i=0;i<arAbas_pes.length;i++){
			m = document.getElementById(arAbas_pes[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbas_pes[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	function toggleFieldset(){
		var oNode, aElms, i=0;

		switch (typeof arguments[0]){
			case "string": oNode=document.getElementById(arguments[0]); break;
			case "object": oNode=arguments[0]; break;
			default: return;
		}

		if (aElms=oNode.childNodes){
			while (oFld = aElms.item(i++)){
				oFld.disabled = (oFld.nodeType==1 && /^(input|select|button|textarea)$/i.test(oFld.nodeName) && oFld.disabled==false) ? true : false ;
			}
		}
	}

	//abas classificação lançamento financeiro
	function stAba_classlf(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}	

	function AlternarAbas_classlf(menu,conteudo,vlr){
		var arAbas_classlf = new Array();

		if(vlr == 1){
			arAbas_classlf[0] = new stAba_classlf('td_geral','div_geral');
			arAbas_classlf[1] = new stAba_classlf('td_fornec','div_fornec');
			arAbas_classlf[2] = new stAba_classlf('td_funcional','div_funcional');
			arAbas_classlf[3] = new stAba_classlf('td_config','div_config');
		} else {
			arAbas_classlf[0] = new stAba_classlf('td_geral','div_geral');
			arAbas_classlf[1] = new stAba_classlf('td_fornec','div_fornec');
			arAbas_classlf[2] = new stAba_classlf('td_config','div_config');
		}

		for (i=0;i<arAbas_classlf.length;i++){
			m = document.getElementById(arAbas_classlf[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbas_classlf[i].conteudo)
			c.style.display = 'none';
		}

		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	var version4 = (navigator.appVersion.charAt(0) == '4');
	var popupHandle;
	function closePopup() {
		if(popupHandle != null && !popupHandle.closed) popupHandle.close();
	}
	function displayPopup(position,url,name,height,width,evnt) {
		// position=1 POPUP: makes screen display up and/or left, down and/or right
		// depending on where cursor falls and size of window to open
		// position=2 CENTER: makes screen fall in center
		var properties = 'toolbar = 0, location = 0, height = ' + height;
		properties = properties + ', width=' + width;
		var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt;
		if(navigator.appName == 'Microsoft Internet Explorer') {
			screenY = document.body.offsetHeight;
			screenX = window.screen.availWidth;
		} else {
			screenY = window.outerHeight
			screenX = window.outerWidth
		}
		if(position == 1)	{ // if POPUP not CENTER
			cursorX = evnt.screenX;
			cursorY = evnt.screenY;
			padAmtX = 10;
			padAmtY = 10;
			if((cursorY + height + padAmtY) > screenY){
				// make sizes a negative number to move left/up
				padAmtY = (-30) + (height * -1);
				// if up or to left, make 30 as padding amount
			}
			if((cursorX + width + padAmtX) > screenX){
				padAmtX = (-30) + (width * -1);
				// if up or to left, make 30 as padding amount
			}
			if(navigator.appName == 'Microsoft Internet Explorer') {
				leftprop = cursorX + padAmtX;
				topprop = cursorY + padAmtY;
			} else {
				leftprop = (cursorX - pageXOffset + padAmtX);
				topprop = (cursorY - pageYOffset + padAmtY);
			}
		} else {
			leftvar = (screenX - width) / 2;
			rightvar = (screenY - height) / 2;
			if(navigator.appName == 'Microsoft Internet Explorer') {
				leftprop = leftvar;
				topprop = rightvar;
			} else {
				leftprop = (leftvar - pageXOffset);
				topprop = (rightvar - pageYOffset);
			}
		}
		if(evnt != null) {
			properties = properties + ', left = ' + leftprop;
			properties = properties + ', top = ' + topprop;
		}
		closePopup();
		popupHandle = open(url,name,properties);
	}

	//abas entidades
	function stAbaEnt(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}

	var arAbasEnt = new Array();
	arAbasEnt[0] = new stAbaEnt('td_dadosbasicos','div_dadosbasicos');	

	function AlternarAbasEnt(menu,conteudo){
		for (i=0;i<arAbasEnt.length;i++){
			m = document.getElementById(arAbasEnt[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbasEnt[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}

	
	//função que mascara o CPF
	function maskCPF(CPF){
	    return CPF.substring(0,3)+"."+CPF.substring(3,6)+"."+CPF.substring(6,9)+"-"+CPF.substring(9,11);
	}

	//função que mascara o CNPJ
	function maskCNPJ(CNPJ){
    	return CNPJ.substring(0,2)+"."+CNPJ.substring(2,5)+"."+CNPJ.substring(5,8)+"/"+CNPJ.substring(8,12)+"-"+CNPJ.substring(12,14);
	}

	//abas movimento diário
	function stAbaMovDiario(menu,conteudo){
		this.menu = menu;
		this.conteudo = conteudo;
	}		

	function AlternarAbasMovDiario(menu,conteudo,vlr){
		if(vlr == 1){
			var arAbasMovDiario = new Array();
			arAbasMovDiario[0] = new stAbaMovDiario('td_rsetor','div_rsetor');
			arAbasMovDiario[1] = new stAbaMovDiario('td_geral','div_geral');
			arAbasMovDiario[2] = new stAbaMovDiario('td_turnopdv','div_turnopdv');
			arAbasMovDiario[3] = new stAbaMovDiario('td_turno','div_turno');
			arAbasMovDiario[4] = new stAbaMovDiario('td_tpag','div_tpag');
			arAbasMovDiario[5] = new stAbaMovDiario('td_conciliaFL','div_conciliaFL');
		} else {
			var arAbasMovDiario = new Array();
			arAbasMovDiario[0] = new stAbaMovDiario('td_rsetor','div_rsetor');
			arAbasMovDiario[1] = new stAbaMovDiario('td_geral','div_geral');
			arAbasMovDiario[2] = new stAbaMovDiario('td_turnopdv','div_turnopdv');
			arAbasMovDiario[3] = new stAbaMovDiario('td_turno','div_turno');
			arAbasMovDiario[4] = new stAbaMovDiario('td_tpag','div_tpag');
		}

		for (i=0;i<arAbasMovDiario.length;i++){
			m = document.getElementById(arAbasMovDiario[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbasMovDiario[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}
	
	function stAbaFretes(menu,conteudo)
	{
		this.menu = menu;
		this.conteudo = conteudo;
	}	

	function AlternarAbasFretes(menu,conteudo,vlr)
	{
		if((vlr == '116') || (vlr == '95') || (vlr == '224'))
		{	
			var arAbasFretes = new Array();			
			arAbasFretes[0] = new stAbaFretes('td_transacoesabertas','div_transacoesabertas');
			arAbasFretes[1] = new stAbaFretes('td_historicotransacoes','div_historicotransacoes');			
			arAbasFretes[2] = new stAbaFretes('td_pendencias','div_pendencias');
		}
		else if(vlr == '45')
		{
			var arAbasFretes = new Array();
			arAbasFretes[0] = new stAbaFretes('td_fretesabertos','div_fretesabertos');
			arAbasFretes[1] = new stAbaFretes('td_historico','div_historico');			
		}
		else if(vlr == '01')
		{
			var arAbasFretes = new Array();			
			arAbasFretes[0] = new stAbaFretes('td_transacoesabertas','div_transacoesabertas');
			arAbasFretes[1] = new stAbaFretes('td_historicotransacoes','div_historicotransacoes');
			arAbasFretes[2] = new stAbaFretes('td_fornecedoresnmostrados','div_fornecedoresnmostrados');			
			arAbasFretes[3] = new stAbaFretes('td_pendencias','div_pendencias');
		}
		else if(vlr == '02')
		{
			var arAbasFretes = new Array();			
			arAbasFretes[0] = new stAbaFretes('td_transacoesabertas','div_transacoesabertas');
			arAbasFretes[1] = new stAbaFretes('td_historicotransacoes','div_historicotransacoes');			
			arAbasFretes[2] = new stAbaFretes('td_transacoesnmostradas','div_transacoesnmostradas');
			arAbasFretes[3] = new stAbaFretes('td_pendencias','div_pendencias');
		}
		else if(vlr == '03')
		{
			var arAbasFretes = new Array();			
			arAbasFretes[0] = new stAbaFretes('td_transacoesabertas','div_transacoesabertas');
			arAbasFretes[1] = new stAbaFretes('td_historicotransacoes','div_historicotransacoes');
			arAbasFretes[2] = new stAbaFretes('td_fornecedoresnmostrados','div_fornecedoresnmostrados');
			arAbasFretes[3] = new stAbaFretes('td_transacoesnmostradas','div_transacoesnmostradas');
			arAbasFretes[4] = new stAbaFretes('td_pendencias','div_pendencias');
		}			
		else
		{
		   alert('erro nas abas');
		}
		
		for (i=0;i<arAbasFretes.length;i++)
		{
			m = document.getElementById(arAbasFretes[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbasFretes[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}


	function stAbaNF(menu,conteudo)
	{
		this.menu = menu;
		this.conteudo = conteudo;
	}

	function AlternarAbasNF(menu,conteudo)
	{
		var arAbasNF = new Array();
		arAbasNF[0] = new stAbaNF('td_nota1','div_nota1');
		arAbasNF[1] = new stAbaNF('td_nota2','div_nota2');	
		for (i=0;i<arAbasNF.length;i++)
		{
			m = document.getElementById(arAbasNF[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbasNF[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}
	
	function stAbaContabil(menu,conteudo)
	{
		this.menu = menu;
		this.conteudo = conteudo;
	}		

	function AlternarAbasContabil(menu,conteudo)
	{
		var arAbasContabil = new Array();
		arAbasContabil[0] = new stAbaContabil('td_info','div_info');
		arAbasContabil[1] = new stAbaContabil('td_dados','div_dados');
		
		for (i=0;i<arAbasContabil.length;i++)
		{
			m = document.getElementById(arAbasContabil[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbasContabil[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}
	
	function stAbaFatura(menu,conteudo)
	{
		this.menu = menu;
		this.conteudo = conteudo;
	}		

	function AlternarAbasFatura(menu,conteudo)
	{
		var arAbasFatura = new Array();
		arAbasFatura[0] = new stAbaFatura('td_novafatura','div_novafatura');
		arAbasFatura[1] = new stAbaFatura('td_fatura','div_fatura');
		arAbasFatura[2] = new stAbaFatura('td_faturapagas','div_faturapagas');
		
		for (i=0;i<arAbasFatura.length;i++)
		{
			m = document.getElementById(arAbasFatura[i].menu);
			m.className = 'menu';
			c = document.getElementById(arAbasFatura[i].conteudo)
			c.style.display = 'none';
		}
		m = document.getElementById(menu)
		m.className = 'menu-sel';
		c = document.getElementById(conteudo)
		c.style.display = '';
	}


