var 

	posi;

	posi=1;

	IE =(navigator.appVersion.indexOf("MSIE") > - 1);

	

	//variaveis de abas

	

	var aAbas       = new Array();  // Lista de abas do documento atual

        var sAbaAtiva   = ""                 // Define qual é a aba ativa no momento

        var ABA_ID      = 1

        var ABA_BLOCO   = 2

        var ABA_CAMPOS  = 3



function ShowDiv (div_id) {

	var element = document.getElementById(div_id);

     

     if (element.style.display == 'none') {

     

         element.style.display = 'block';

     

     }

     else {

         element.style.display = 'none';

     }

     

     return false;

    

}



function mascaraData(DATA_INICIO, nome){ 

              var mydata = ''; 

              mydata = mydata + DATA_INICIO; 

              if (mydata.length == 2){ 

                  mydata = mydata + '/'; 

                  document.getElementById(nome).value=mydata; 

              } 

              if (mydata.length == 5){ 

                  mydata = mydata + '/'; 

                  document.getElementById(nome).value=mydata;  

              } 

            

          }

          

          

          function mascaraRG(DATA_INICIO, nome){ 

              var mydata = ''; 

              mydata = mydata + DATA_INICIO; 

              if (mydata.length == 1){ 

                  mydata = mydata + '.'; 

                  document.getElementById(nome).value=mydata; 

              } 

              if (mydata.length == 5){ 

                  mydata = mydata + '.'; 

                  document.getElementById(nome).value=mydata;  

              } 

            

          } 

function confirmar(end)

{

	



if (window.confirm("Tem certeza que deseja excluir?")){

window.location = end; 

}else

window.alert("Exclusão cancelada");

	

}

function confirmar02(idForm, action)
{
if (window.confirm("Tem certeza que deseja excluir?")){
document.getElementById(idForm).action = action;
//window.location = end; 

}else
window.alert("Exclusão cancelada");

}



function aumentaGal(id,titulo,image,contador){

	

	posi=posi+1;

	id=id.split("^");

	titulo=titulo.split("^");

	image=image.split("^");

	if (posi<=contador){

		imgMuda.innerHTML = "<img src='http://www.fckarate.com.br/newSite/IMG_UP/p_"+image[posi]+ "'  style='border-color:#ffffff; border-style:double;'>";

		titulomuda.innerHTML = titulo[posi];



	

		

	}else{

		posi=posi-1;

		window.alert('Você encerrou a listagem de galerias!');

	}

	

	

	

	

}



function diminuiGal(id,titulo,image,contador){

	

	posi=posi-1;

	id=id.split("^");

	titulo=titulo.split("^");

	image=image.split("^");

	if (posi>0){

		imgMuda.innerHTML = "<img src='http://www.fckarate.com.br/newSite/IMG_UP/p_"+image[posi]+ "' style='border-color:#ffffff; border-style:double;'>";

		titulomuda.innerHTML = titulo[posi];

		

		

	}else{

		posi=posi+1;

		window.alert('Você encerrou a listagem de galerias!');

		

	}

	

	

	

	

}





function abrirGal(val){

	val=val.split("^");

	urlgal="http://www.fckarate.com.br/newSite/galeriaFotos/galeriaFotos.php?conte="+ val[posi];

	window.open(urlgal,'Blank','width=660, height=497','location=no');

}



function sairSistema(){

	

	if (window.confirm("Deseja sair do G2E?")){

		parent.location.replace("index.php?logout=yes");

} 

	

}





function showTR(id,show,total){    

    

	contador=id*10;

	cfinal=contador-9;

	nTotal=total-1;

	total--;

	while (total>0){

		

		document.getElementById(total).style.display = !show ? "none" : IE ? "inline" : "table-row";

		total--;	

		

	}

	show=true;

	while ((contador>=cfinal) && (cfinal<=nTotal)){

		//window.alert(cfinal+"-"+nTotal);

		document.getElementById(cfinal).style.display = !show ? "block" : IE ? "inline" : "table-row";

		

		cfinal++;

		

	}

	

	

}





//funções de abas

function defineAba( sId, sBloco ){

           var aAba  = new Array( ABA_CAMPOS );

           aAba[ ABA_ID    ]  = sId;

           aAba[ ABA_BLOCO ]  = sBloco;

           aAbas.push( aAba );

        }



        function defineAbaAtiva( sId ){

           trataCliqueAba( sId );

        }



        function trataMouseAba( oAba ){

           oAba.style.cursor  = "pointer";

        }



        function trataCliqueAba( sId ){

           for ( var iAba  = 0; iAba < aAbas.length; iAba++ ){

              var aAba  = aAbas[ iAba ];



              if   ( aAba[ ABA_ID ] == sId ) ativaAba( aAba );



              else                           inativaAba( aAba );

           }

        }



        function ativaAba( aAba ){

           var sAba       = aAba[ ABA_ID ];

           var oAba       = document.getElementById( sAba );

           mudaClasse( oAba, "abaativa" ); // Esse comando chama a classe css para fazer a troca



           var sBlocoAba  = aAba[ ABA_BLOCO ];

           var oBlocoAba  = document.getElementById( sBlocoAba );

           oBlocoAba.style.display  = "block";

        }



        function inativaAba( aAba ){

           var sAba       = aAba[ ABA_ID ];

           var oAba       = document.getElementById( sAba );

           mudaClasse( oAba, "abainativa" ); // Esse comando chama a classe css para fazer a troca



           var sBlocoAba  = aAba[ ABA_BLOCO ];

           var oBlocoAba  = document.getElementById( sBlocoAba );

           oBlocoAba.style.display  = "none";

        }

        

        function mudaClasse( oObjeto, sClasse ){

           oObjeto.className  = sClasse;

        }

        

        

        function mascara_data(valor,id){ 

              var mydata = ''; 

              mydata = mydata + valor; 

              if (mydata.length == 2){ 

                  mydata = mydata + '/'; 

                  document.getElementById(id).value = mydata; 

              } 

              if (mydata.length == 5){ 

                  mydata = mydata + '/'; 

                  document.getElementById(id).value = mydata; 

              } 

            

          } 

           

          function verifica_data (valor,id) { 

		   var mydata = ''; 

              mydata = mydata + valor; 

         

            dia = (document.getElementById(id).value.substring(0,2)); 

            mes = (document.getElementById(id).value.substring(3,5)); 

            ano = (document.getElementById(id).value.substring(6,10)); 



            situacao = ""; 

            // verifica o dia valido para cada mes 

			

			if (mydata.length < 10){ 

                   situacao = "falsa"; }

			

            if ((dia < 01)||(dia < 01 || dia > 30) && (  mes == 04 || mes == 06 || mes == 09 || mes == 11 ) || dia > 31) { 

                situacao = "falsa"; 

            } 



            // verifica se o mes e valido 

            if (mes < 01 || mes > 12 ) { 

                situacao = "falsa"; 

            } 



            // verifica se e ano bissexto 

            if (mes == 2 && ( dia < 01 || dia > 29 || ( dia > 28 && (parseInt(ano / 4) != ano / 4)))) { 

                situacao = "falsa"; 

            } 

    

            if (document.getElementById(id).value == "") { 

                situacao = "falsa"; 

            } 

    

            if (situacao == "falsa") { 

                alert("Data inválida!"); 

                document.getElementById(id).focus();

				document.getElementById(id).value =""; 

            } 

          



         } 

         

    function mascara_cnpj(valor,id){ 

              var mydata = ''; 

              mydata = mydata + valor; 

              if (mydata.length == 2){ 

                  mydata = mydata + '.'; 

                  document.getElementById(id).value = mydata; 

              } 

              if (mydata.length == 6){ 

                  mydata = mydata + '.' ; 

                  document.getElementById(id).value = mydata; 

              } 

			   if (mydata.length == 10){ 

                  mydata = mydata + '/' ; 

                  document.getElementById(id).value = mydata; 

              } 

			  if (mydata.length == 15){ 

                  mydata = mydata + '-'; 

				  document.getElementById(id).value = mydata; 

                  }

		      if (mydata.length == 19){ 		  

			      alert("cnpj inválido!");

			      document.getElementById(id).value ="";

              } 

          } 

          

       function mascara_cep(valor,id){ 

              var mydata = ''; 

              mydata = mydata + valor; 

              if (mydata.length == 5){ 

                  mydata = mydata + '-'; 

                  document.getElementById(id).value = mydata; 

              } 

              

			  if (mydata.length == 10){ 

			 // document.forms[0].COMPLEMENTO_ASSOCIACAO.focus()            ; 

			 alert("CEP inválidO!");

			document.getElementById(id).value ="";

              } 

          }

          

        function mascara_cpf(valor,id){ 

              var mydata = ''; 

              mydata = mydata + valor; 

              if (mydata.length == 3){ 

                  mydata = mydata + '.'; 

                   document.getElementById(id).value = mydata; 

              } 

              if (mydata.length == 7){ 

                  mydata = mydata + '.' ; 

                   document.getElementById(id).value= mydata; 

              } 

			   if (mydata.length == 11){ 

                  mydata = mydata + '-' ; 

                   document.getElementById(id).value = mydata; 

              } 

			   if (mydata.length == 15){ 		  

			      alert("CPF inválido!");

			       document.getElementById(id).value ="";

              } 

          }

          

          

          

          

          function validaFormPessoa(){

          	if((document.getElementById('nome').value!='')&&(document.getElementById('nascimento').value!='')&&(document.getElementById('mae').value!='') ){

          		document.getElementById('pessoas').submit();

          	} else {

          		window.alert('Os campos Nome, Data de Nascimento e Nome da Mãe sao obrigatótios');

          	}

          }

          

          function validaDadosDiretoria(){

          	if((document.getElementById('pessoa').value!='')&&(document.getElementById('atividade').value!='0')){

          		

          		document.getElementById('diretoria').submit();

          	} else {

          		window.alert('Os campos Nome do Dirigente e Atividade são obrigatórios!');

          	}

          	

          }

          function resetaDirigente(){

          	if(document.getElementById('namesearch').disabled==1){

          		document.getElementById('namesearch').disabled=0;

          	}

          	

          	document.getElementById('namesearch').value='';

          	document.getElementById('pessoa').value='';

          }

          

          function verificaTempo(data, id,meses,dataExame){

          	

          	//window.alert("data exame - "+dataExame);

          	exameDiv=dataExame.split("-");

          	anoExame=exameDiv[0];

          	mesExame=exameDiv[1];

          	diaExame=exameDiv[2];

          	

          	//window.alert("data atual - "+data);

          	atualDiv=data.split("/");

          	anoAtual=atualDiv[2];

          	mesAtual=atualDiv[1];

          	diaAtual=atualDiv[0];

          	

          	atualMes=(anoAtual*12)+Number(mesAtual);

          	exameMes=(anoExame*12)+Number(mesExame)+Number(meses);

          	

          //	window.alert(meses);

          	

         // 	window.alert(atualMes+">"+exameMes);

          	

          	if(atualMes>=exameMes){

          		//window.alert("Pode Fazer");	

          		document.getElementById('btCadastrar').disabled=0;

          	} else {

          	

          	window.alert("Carência não concluida!");

          	document.getElementById('btCadastrar').disabled=1;

          	}

          	

          }

          

          

          function comboAcao(idForm, action){

						document.getElementById(idForm).action = action;

						document.getElementById(idForm).submit();

					}
					













//Cria uma variável  booleana para verificar uma instância válida do IE
var xmlhttp = false;

//Verificar se estamos usando IE
try {
    //Se a versão Javascript for maior que 5
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    //alert("Você está usando IE");
}catch (e){
    //Se não, então use o objeto active x mais antigo
    try {
        //Se estivermos usando o IE
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        //alert("Você está usando IE");
    }catch (E){
        //Ou devemos estar usando um navegador diferente do IE
        xmlhttp = false;
    }
}

//Se estivermos usando uma navegador diferente do IE, criar uma instância javascript do objeto
if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
    xmlhttp = new XMLHttpRequest();
    //alert("Você não está usando o IE");
}
/*
************************************************************
Começo da Função.
Descrição: A função abaixo se encarrega de carregar uma consulta PHP dentro de outra página em execução.
************************************************************
*/
function carregaPagina(method, servePage, objID){
    var obj = document.getElementById(objID);
    xmlhttp.open(method, servePage);
    xmlhttp.onreadystatechange = function(){
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
            obj.innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}
/*
************************************************************
Fim da Função.
************************************************************
*/

function marcaChecked(idForm, tipo){
    elementosForm = idForm.getElementsByTagName("input");
                
    i = 0;
    do {
        if (tipo == 'marcar'){
            elementosForm[i].checked = true;
        }
        if (tipo == 'desmarcar'){
            elementosForm[i].checked = false;
        }
        i++;
    }while(i < elementosForm.length);                
}
