function selectRadio(radioArray, index) 
{ 
  radioArray[index].click(); 
} 
//** funcoes para controle dos combos de data **// 
//**                   inicio                 **// 
var _a; 
var _b; 
var _c; 
var _d; 
var _e; 
var _f; 
function resetDates(c, semdata) 
{ 
  resetDatesPartida(c, semdata); 
} 

function resetDatesPartida(c, semdata) 
{ 
  f = c.form; 
  if(semdata) 
  { 
    _a = f.dsDiaPartida.selectedIndex; 
    _b = f.dsMesPartida.selectedIndex; 

    f.dsDiaPartida.selectedIndex = 100; 
    f.dsMesPartida.selectedIndex = 100; 
  } 
  else 
  { 
    f.dsDiaPartida.selectedIndex = _a; 
    f.dsMesPartida.selectedIndex = _b; 
  } 
} 
//** funcoes para validacao do formulario para envio **// 
//**                      inicio                     **// 
function validaAeroportos(f) { 
  try{
      if(f.aeroOrigem.value == VDIGITE_CIDADE) {
        return DFchangeClassFocus(VSEL_AEROPORTO_ORIG, f.aeroOrigem);
      }
      if(f.aeroDestino.value == VDIGITE_CIDADE) {
        return DFchangeClassFocus(VSEL_AEROPORTO_DEST, f.aeroDestino);
      }
      if(f.aeroOrigem.value == f.aeroDestino.value) {
        return DFchangeClassFocus(VSEL_DEST_DIF_ORIG, f.aeroDestino);
      }

  } catch(e) {} 
  return true;
}
//** funcoes para validacao do formulario para envio **// 
//**                      inicio                     **// 
function validaAeroportosWebCheckinHome(f) { 
  try{
      if(f.aeroOrigem2.value == VDIGITE_CIDADE) {
        return DFchangeClassFocus(VSEL_AEROPORTO_ORIG, f.aeroOrigem2);
      }
      if(f.aeroDestino2.value == VDIGITE_CIDADE) {
        return DFchangeClassFocus(VSEL_AEROPORTO_DEST, f.aeroDestino2);
      }
      if(f.aeroOrigem2.value == f.aeroDestino2.value) {
        return DFchangeClassFocus(VSEL_DEST_DIF_ORIG, f.aeroDestino2);
      }

  } catch(e) {} 
  return true;
} 

/** 
 * Função para verificar se é um valor numérico 
 * 
 * Histórico 
 * 18/02/2006 - Fabio Oliveira Silva - EDS 
 * 
 */ 
function isNumber(wNumero) { 
    var numeric = true; 
    for (var i = 0; i<wNumero.length; i++) { 
        if ("0123456789".indexOf(wNumero.charAt(i)) == -1) { 
            numeric = false; 
            break; 
        } 
    } 
    return numeric; 
} 
/** 
 * Função para validar o número do eticket fornecido, verificando se os três 
 * números do etkt foram fornecidos e se são numeros 
 * 
 * Histórico 
 * 18/02/2006 - Fabio Oliveira Silva - EDS 
 * 
 */ 

function validaEtkt(f) { 
    var cdIataEmpAer = f.cdIataEmpAer.value; 
    var cdFormulario = f.cdFormulario.value; 
    var cdSerie = f.cdSerie.value; 

    if ( cdIataEmpAer == null || cdIataEmpAer == "" || 
         cdIataEmpAer.length != 3 || !isNumber(cdIataEmpAer) ) { 
        return DFchangeClassFocus(VPREENCHE_ETKT, f.cdIataEmpAer); 
    } 
    if (cdFormulario == null || cdFormulario == "" || 
        cdFormulario.length != 4 || !isNumber(cdFormulario)) { 
        return DFchangeClassFocus(VPREENCHE_ETKT, f.cdFormulario); 
    } 
    if (cdSerie == null || cdSerie == "" || 
        cdSerie.length != 6 || !isNumber(cdSerie)) { 
        return DFchangeClassFocus(VPREENCHE_ETKT, f.cdSerie); 
    } 
    return true; 
} 
/** 
 * Função para validar a data fornecida. 
 * 
 * Histórico 
 * 21/09/2004 - Diogo Montanaro Pedroso 
 * O ano passou a ser tratado com 4 dígitos e os dados referentes a datas 
 * foram convertidos para numéricos para o tratamento da data funcionar no Netscape 6.2. 
 * 
 */ 
function isDataValida(dd, mm, yyyy) { 
  var data = new Date(yyyy, mm, dd); 
  if((data.getDate() == Number(dd)) && (data.getMonth() == Number(mm)) && (data.getFullYear() == Number(yyyy))) { 
    return true; 
  } 
  else { 
    return false; 
  } 
} 
/** 
 * Função para validar datas para a pesquisa de vôos. 
 * 
 * Histórico 
 * 21/09/2004 - Diogo Montanaro Pedroso 
 * O ano passou a ser tratado com 4 dígitos. 
 * 
 */ 
function validaDatasPesquisa(f) 
{ 
  // Validacoes de data 
  var dataHoje      = new Date(); 
  var dataPartida   = new Date(f.dsAnoPartida.value, valSel(f.dsMesPartida, true), valSel(f.dsDiaPartida, true)); 
  // Testa se a data de Partida eh valida 
  if(!isDataValida(valSel(f.dsDiaPartida, true), valSel(f.dsMesPartida, true) - 1, f.dsAnoPartida.value)) { 
    return DFchangeClassFocus(VDATA_INVALIDA, f.dsDiaPartida); 
  } 
  // verifica se a ida e hoje 
  if(dataPartida.getTime() != dataHoje.getTime()) { 
    // Acertando datas para pesquisas no ano seguinte 
    if(dataPartida.getTime() < dataHoje.getTime()) { 
      dataPartida.setFullYear(dataPartida.getFullYear() + 1); 
      f.dsAnoPartida.value = (f.dsAnoPartida.value * 1) + 1; 
    } 
    // Testa se a data de Partida eh valida 
    if(!isDataValida(valSel(f.dsDiaPartida, true), valSel(f.dsMesPartida, true) - 1, f.dsAnoPartida.value)) { 
      return DFchangeClassFocus(VDATA_INVALIDA, f.dsDiaPartida); 
    } 
  } 
  
  return true; 
} 
function validaDiaMes(f) { 
    var diaEscolhido = f.dsDiaPartida.value; 
    var mesEscolhido = f.dsMesPartida.value - 1; 
    var dataHoje = new Date(); 
    var teste = dataHoje.getMonth();
    if ( mesEscolhido == dataHoje.getMonth() ) { 
        if ( diaEscolhido < dataHoje.getDate() ) { 
            return DFchangeClassFocus(VDATA_INVALIDA, f.dsDiaPartida); 
        } 
    } 
    else if ( diaEscolhido > dataHoje.getDate() ){ 
        return DFchangeClassFocus(VDATA_INVALIDA, f.dsDiaPartida); 
    } 
} 
/** 
 * Função para verificar se algum botão radio, de uma 
 * lista de radios, foi selecionado. 
 * 
 * Parâmetros: 
 * _radio: objeto radio a ser consultado 
 * 
 * retorno: 
 * false - nenhum botão de radio foi selecionado 
 * true - achou algum botão de radio selecionado 
 * 
 */ 
function _hasChecked(_radio) { 
        var i = 0; 
        if (_radio.length) { 
                for (i = 0; i < _radio.length; i++) { 
                        if (_radio[i].checked) { 
                                return true; 
                        } 
                } 
        } 
        else { 
                if (_radio.checked) { 
                        return true; 
                } 
        } 
        return false; 
} 
//**                        fim                      **// 
//** funcoes para validacao do formulario para envio **// 

/**
 * Nao permite inserir caracteres não numéricos
 * DCI_19926
 * 27/07/2007
 */
function filtraCaracteresNaoNumericos() {
    var cpf =  document.getElementById("cdCPF").value;
    var exp = /[a-zA-Z.;_,<>/?:!@#$%^&()-+={}|\?]/;
    cpf = cpf.replace(exp,"");
    document.getElementById("cdCPF").value = cpf;
}

    /**
    * Aplica máscara ao campo de CPF
    */
    function aplicarMascaraCPF() {
    
        if  ( (event.keyCode != 46) && (event.keyCode != 8) ){ 
            var cpf = document.consultaEticketForm.cdCPF;
            wCpf = cpf.value;
            wCpf = wCpf.replace(".","");
            wCpf = wCpf.replace(".","");
            wCpf = wCpf.replace(".","");
            wCpf = wCpf.replace("-","");
            wCpf = wCpf.replace("-","");
            wCpf = wCpf.replace("-","");        
            
            if (wCpf.length == 11) {
               return false;
            }
            
            if (wCpf.length == 3) {
                cpf.value = wCpf.substr(0,3) + '.';
            }
            if (wCpf.length == 6) { 
                cpf.value = wCpf.substr(0,3) + '.' + wCpf.substr(3,3) + '.' + wCpf.substr(7);
            }
            if (wCpf.length == 9) {
                cpf.value = wCpf.substr(0,3) + '.' + wCpf.substr(3,3) + '.' + wCpf.substr(6,3) + '-' + wCpf.substr(9);
            }
            if (wCpf.length > 11 ) {
                    cpf.value = wCpf.substr(0,3) + '.' + wCpf.substr(3,3) + '.' + wCpf.substr(6,3) + '-' + wCpf.substr(9);
            }
            
            return true;
      }
    }
    
    function validaCPF(f){
        var cpf = f.cdCPF.value;
        if ( cpf == null 
            || cpf == '' 
            || (cpf.length > 0 && cpf.length < 11 ) ){
            return DFchangeClassFocus(VERRO_DIGITOS_CPF, f.cdCPF);
        } else {
            return true;
        }
    }

    function verificaCPF(f) {
      var cpf = f.cdCPF.value;
      var form = f;  
      var nonNumbers = /\D/; 

      var newCpf = cpf.substring(0,3);
      newCpf = newCpf + "" + cpf.substring(4,7);
      newCpf = newCpf + "" + cpf.substring(8,11);
      newCpf = newCpf + "" + cpf.substring(12,14);
      cpf = newCpf;

      if (cpf.length > 0 && cpf.length < 11 ){ 
              return DFchangeClassFocus(VERRO_DIGITOS_CPF, form.cdCPF);
      }
      
      if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
  
              return DFchangeClassFocus(VPREENCHE_CPF, form.cdCPF);
      } 
      
      var a = []; 
      var b = new Number; 
      var c = 11; 
      
      for (i=0; i<11; i++){ 
              a[i] = cpf.charAt(i); 
              if (i < 9){ 
                      b += (a[i] * --c); 
              } 
      } 
      if ((x = b % 11) < 2) { 
              a[9] = 0 
      } else { 
              a[9] = 11-x 
      } 
      b = 0; 
      c = 11; 
      for (y=0; y<10; y++){ 
              b += (a[y] * c--); 
      } 
      if ((x = b % 11) < 2) { 
              a[10] = 0; 
      } else { 
              a[10] = 11-x; 
      } 
      
      if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){ 
         return DFchangeClassFocus(VERRO_DIGITOS_CPF, form.cdCPF);
      }
      
      return true;
    }
