function validaDistritoClube() {
   clubeNumero = document.formulario.clubeNumero.value;   
   distritoNumero = document.formulario.distritoNumero.value;   
   
   /* Se não for digitado nenhum distrito ou clube */
   if(!clubeNumero || !distritoNumero) {
      return false;
   }
   
   document.getElementById('clubeNome').innerHTML = 'Verificando...';
   
   var pars = "validar=true";
   pars += "&distritoNumero=" + distritoNumero;
   pars += "&clubeNumero=" + clubeNumero;

   var url = "_include/valida.php";
   
   var objetoAjax = new Ajax.Request( url, { 
      method: "post", parameters: pars, onComplete: retorna });
}

function retorna(javascript) {
   var javascript = javascript.responseText;
   javascript = javascript.replace(/\+/g," ");
   javascript = unescape(javascript);
   //document.getElementById('clubeNome').innerHTML = javascript;
   eval(javascript);
}


function validarFormulario() {
    
    clubeNumero = document.formulario.clubeNumero.value;  
    distritoNumero = document.formulario.distritoNumero.value;   
   
    if(clubeNumero=="0000" || distritoNumero=="0000") {
      return false;
   } 
    
   tipoPagamento = document.formulario.tipoPagamento.value;

   if(tipoPagamento == 1) {
      document.formulario.action = "pagamentoRotaryInternacionalOutros.php";
      document.formulario.target='blank';
      document.formulario.submit();
   }
   else if(tipoPagamento == 2) {
      document.formulario.action = "pagamentoRotaryInternacionalPercapta.php";  
      document.formulario.target='blank';      
      document.formulario.submit();
   }
	else if(tipoPagamento == 3) {
      document.formulario.action = "pagamentoDoacaoRotaria.php";
      document.formulario.target='blank';
      document.formulario.submit();
   }      
   	else if(tipoPagamento == 4) {
      document.formulario.action = "pagamentoRotaryInternacionalPublicacoes.php";
      document.formulario.target='blank';      
      document.formulario.submit();
   }
   	else if(tipoPagamento == 5) {
      document.formulario.action = "pagamentoDoacaoABTRF.php";
      document.formulario.target='blank';
      document.formulario.submit();
   } 
  	else if(tipoPagamento == '5TESTE') {
      document.formulario.action = "pagamentoDoacaoABTRFTESTE.php";
      document.formulario.target='blank';
      document.formulario.submit();
   }   
   else {
      
      alert('Favor informar o tipo de pagamento, antes de continuar!')
   }
}

function validarFormularioR2() {
    
    distritoNumero = document.formulario.distritoNumero.value;   
   
    var box = $('clubeNumero');
    var clubeNome = box.selectedIndex >= 0 ? box.options[box.selectedIndex].innerHTML : undefined;
    var clubeNumero = box.selectedIndex >= 0 ? box.options[box.selectedIndex].value : undefined;

   if(clubeNumero=='DISTRITO'){
        $('ClubeDistritoNumero').value=distritoNumero; 
        $('clubeNome').value='DISTRITO';
   }
   else{
        $('ClubeDistritoNumero').value=clubeNumero; 
        $('clubeNome').value=clubeNome;  
   }
   
   /*alert(clubeNumero+'/'+clubeNome+'/'+distritoNumero);
     return false;*/
   
    if(clubeNumero=="0000" || distritoNumero=="0000") {
      return false;
   } 

    if(document.formulario.clubeNumero.value=="" || document.formulario.distritoNumero.value=="") {
      return false;
   } 
    
   tipoPagamento = document.formulario.tipoPagamento.value;

   if(tipoPagamento == 1) {
      document.formulario.action = "pagamentoRotaryInternacionalOutros.php";
      document.formulario.target='blank';
      document.formulario.submit();
   }
   else if(tipoPagamento == '1TESTE') {
      document.formulario.action = "pagamentoRotaryInternacionalOutrosTESTE.php";
      document.formulario.target='blank';
      document.formulario.submit();
   }   
   else if(tipoPagamento == 2) {
      document.formulario.action = "pagamentoRotaryInternacionalPercapta.php";
      document.formulario.target='blank';      
      document.formulario.submit();
   }
   else if(tipoPagamento == '2TESTE') {
      document.formulario.action = "pagamentoRotaryInternacionalPercaptaTESTE.php";
      document.formulario.target='blank';      
      document.formulario.submit();
   }   
	else if(tipoPagamento == 3) {
      document.formulario.action = "pagamentoDoacaoRotaria.php";
      document.formulario.target='blank';
      document.formulario.submit();
   }    
   	else if(tipoPagamento == '3TESTE') {
      document.formulario.action = "pagamentoDoacaoRotariaTESTE.php";
      document.formulario.target='blank';
      document.formulario.submit();
   }      
   	else if(tipoPagamento == 4) {
      document.formulario.action = "pagamentoRotaryInternacionalPublicacoes.php";
      document.formulario.target='blank';      
      document.formulario.submit();
   }
  	else if(tipoPagamento == '4TESTE') {
      document.formulario.action = "pagamentoRotaryInternacionalPublicacoesTESTE.php";
      document.formulario.target='blank';      
      document.formulario.submit();
   }
   	else if(tipoPagamento == 5) {
      document.formulario.action = "pagamentoDoacaoABTRF.php";
      document.formulario.target='blank';
      document.formulario.submit();
   }
  	else if(tipoPagamento == '5TESTE') {
      document.formulario.action = "pagamentoDoacaoABTRFTESTE.php";
      document.formulario.target='blank';
      document.formulario.submit();
   }
   else {
      
      alert('Favor informar o tipo de pagamento, antes de continuar!')
   }
}


var Popup = {
  open: function(options)
  {
    this.options = {
      url: '#',
      width: 300,
      height: 300
    }
    Object.extend(this.options, options || {});
    window.open(this.options.url, '', 'width='+this.options.width+',height='+this.options.height);
  }
}

function  listaclubes(numeroDistrito){
    
    if(numeroDistrito=="0000"){
        alert("Seleção inválida!");
        return false;
    }

    $('msg').update('<img src="../imagens/loading1.gif" />Carregando....').setStyle({ background:'#FFAA00'});
    
   	var pars = "D=" + numeroDistrito;
   	     
   	var url = 'boletos/listaclubes.php'
   	url += '?' + pars;
    
   	var objetoAjax = new Ajax.Request( url, {method:'get', onComplete: function(transport){
   		
   		var notice = $('msg');
    	var saida = $('listaclubes');
    	var resposta = transport.responseText;
        /*alert(resposta);*/
         resposta = resposta.replace(/\+/g," ");
    	 resposta = unescape(resposta);
		    	
		if (resposta!=''){
		    //saida.update('');  
      		notice.update('').setStyle({ background: '#ffffff' });
   	  		saida.innerHTML=resposta;
 			}	 
    	else
      		notice.update('Falha na criação de lista de clubes').setStyle({ background: '#ff0000' });  		
   	} });
        
}

