<!--

/*

<script language = "javascript">
function favoritos() {
  window.external.AddFavorite('http://www.toformando.com','ToFormando.com - Sua Formatura em um clique!');
}
</script>

<a href="javascript:favoritos()">adicionar a favoritos</a>

  */
  
  

		/* Verifica se o conteudo de um campo Auto Complete mudou, colocando
		seu status em vermelho, ou seja, indicando que o que foi digitado nao
		eh valido
		nomeID = nome do campo que guarda o ID selecionado
	 	nomeID_Dependentes = string com os campos ID separados por # e que sao dependentes do campo nomeID
	 	*/
		function VerificaMudancaCampo(nomeID, nomeID_Dependentes) {
			var nomeTemp = nomeID + '_NomeTemp';
			var nomeCampo = nomeID + '_Nome';
			var nomeFlag = nomeID + '_Flag';

			// se houve mudança do campo, coloca como não selecionado
		  if (document.getElementById(nomeTemp).value != document.getElementById(nomeCampo).value) {
				document.getElementById(nomeFlag).className = 'nao_selecionou';
				document.getElementById(nomeID).value = '';

				// percorre os campos dependentes colocando limpando-os
				if ((nomeID_Dependentes != '') && (nomeID_Dependentes != null)) {
					var array_dependentes = nomeID_Dependentes.split('#');
					var cont_dep;
					for (cont_dep=0; cont_dep<array_dependentes.length; cont_dep++) {
						var nomeCampoID = array_dependentes[cont_dep];
						var nomeTemp = nomeCampoID + '_NomeTemp';
						var nomeCampo = nomeCampoID + '_Nome';
						var nomeFlag = nomeCampoID + '_Flag';

						document.getElementById(nomeFlag).className = 'nao_selecionou';
						document.getElementById(nomeCampo).value = '';
						document.getElementById(nomeCampoID).value = '';
						document.getElementById(nomeTemp).value = '';
					}
				}

			}
			// se nao houve mudança e ja foi selecionado algum registro, coloca como selecionado
			else if (document.getElementById(nomeID).value != '') {
				document.getElementById(nomeFlag).className = 'selecionou';
			}
			// nenhum registro selecionado
			else {
				document.getElementById(nomeFlag).className = 'nao_selecionou';
			}

			return (true);
	  }

  
  

 

 /**
  * dados: conteúdo
  */


		function getPosicaoElemento(elemID){
		    var offsetTrail = document.getElementById(elemID);
		    var offsetLeft = 0;
		    var offsetTop = 0;
		    while (offsetTrail) {
		        offsetLeft += offsetTrail.offsetLeft;
		        offsetTop += offsetTrail.offsetTop;
		        offsetTrail = offsetTrail.offsetParent;
		    }
		    if (navigator.userAgent.indexOf("Mac") != -1 &&
		        typeof document.body.leftMargin != "undefined") {
		        offsetLeft += document.body.leftMargin;
		        offsetTop += document.body.topMargin;
		    }
		    return {left:offsetLeft, top:offsetTop};
		}



    function post(frm) {
      document.getElementById(frm + "_chk").value = 0;
      document.getElementById(frm).submit();
    }

    function mask(targ, type, rev) {

      var patt = new Array();

      patt['cep'] = '#####-###';
      patt['cnpj'] = '##.###.###/####-##';
      patt['cpf'] = '###.###.###-##';
      patt['data'] = '##/##/####';
      patt['mesAno'] = '##/####';
      patt['hora'] = '##:##:##';
      patt['tel'] = '####-####';
      patt['valor'] = '####-####';

      ele = document.getElementById(targ);
      val = ele.value;
      pos = ele.value.length - 1;

      msk = patt[type];

      if(rev) {
        pos = val.length - pos;
      }
      if(msk.charAt(pos) != '#' && val.charAt(pos) != msk.charAt(pos)) {
        ele.value = val.substring(0, pos) + msk.charAt(pos) + val.charAt(pos);
      }
    }
    
    function FormataValor(arg){
	    var campo = document.getElementById(arg);
	    var strVal;

	    strVal = campo.value;
	 
/*
	 		var comp = "";
	    strVal = strVal.substring(0, strVal.indexOf(",")) + strVal.substring(strVal.indexOf(",") + 1 , strVal.length);
	    if(strVal.length > 2)
	    	strVal = comp + strVal.substring(0, strVal.length - 2) + "," + strVal.substring(strVal.length - 2, strVal.length );
	    campo.value = strVal;
*/
	    
// comecei a mexer aqui
			if ( isNaN(strVal.substring( (strVal.length-1), strVal.length) ) ) {
					strVal = strVal.substring(0, strVal.length-1);
			}	
			else {
				
				if ( (strVal.length == 3) && (strVal.substring(1,2) == ",") )  {
					strVal = "0," + strVal.substring(0,1) + strVal.substring(2,3);
				}

		    //if(strVal.length == 0) strVal = "0,0";
		    if(strVal.length == 1) strVal = "0,0" + strVal;

				//retira a vírgula
		    strVal = strVal.substring(0, strVal.indexOf(",")) + strVal.substring(strVal.indexOf(",") + 1 , strVal.length);

				if ((strVal.substring(0,1) == "0") && (strVal.length == 4))
				strVal = strVal.substring(1, strVal.length);


				if(strVal.length > 2)
		    strVal = strVal.substring(0, strVal.length - 2) + "," + strVal.substring(strVal.length - 2, strVal.length );



			}
			
			campo.value = strVal;

  	}
  	
  	
    
    function goOvr(rowID, rowNum) {
      ele = document.getElementById(rowID + '_' + rowNum);

      ele.className = 'row_h';
      window.status = ele.getElementsByTagName('a')[0].href;
    }

    function goOut(rowID, rowNum) {
      ele = document.getElementById(rowID + '_' + rowNum);

      ele.className = 'row_' + rowNum % 2;
      window.status = '';
    }

    function goClk(rowID, rowNum) {
      ele = document.getElementById(rowID + '_' + rowNum);

      location.href = ele.getElementsByTagName('a')[0].href;
    }

    function AbreJanela(url,nome,propriedades) {
      window.open(url,nome,propriedades);
			return true;
    }
    
    
  //essa aki tava no message!
  function checaOkMessage() {
    var frm = document.frmMessage;

    if (frm.txtAssunto.value == "") {
      alert('Digite um assunto para a mensagem.');
      return false;
    }
    else if (frm.txtTexto.value == "") {
      alert('Texto da mensagem não pode ser vazio.');
      return false;
    }
    return true;
  }


  //esse aki tava no enquete!
  function checaOkEnquete() {
        var frm = document.frmEnqCad;

    if (frm.txtPergunta.value == "") {
      alert('Digite uma pergunta.');
      return false;
    }
    else if (frm.txtReA.value == "") {
      alert('Resposta A não preenchida.');
      return false;
    }
    else if (frm.txtReB.value == "") {
      alert('Resposta B não preenchida.');
      return false;
    }
     else if (frm.txtReC.value == "") {
      alert('Resposta C não preenchida.');
      return false;
    }
    else if (frm.txtReD.value == "") {
      alert('Resposta D não preenchida.');
      return false;
    }
        else if (frm.txtDta.value == "") {
      alert('Data não preenchida.');
      return false;
    }
    else if (isDate(frm.txtDta.value) == 'f') {
      return false;
    }
    return true;
  }

  //Gerencia o botal voltar no cadastro da comissão
  function ComissaoVoltar(frm, endereco) {
      document.getElementById(frm + "_chk").value = 0;
    document.getElementById(frm).action = endereco;
    document.getElementById(frm).submit();
    }


  //esse gigante aki tava no mensalidades.php
  function checaOkGera() {

    var frm = document.frmGera;

    if (frm.mes.value == "") {
      alert('Preencha o mês.');
      return false;
    }
    else if (frm.ano.value == "") {
      alert('Preencha o ano.');
      return false;
    }
    else if ((frm.mes.value < "01") || (frm.mes.value > "12")) {
      alert('Mês inválido.');
      return false;
    }
    else if ((frm.ano.value < "2000") || (frm.ano.value > "2100")) {
      alert('Ano inválido.');
      return false;
    }

    if (frm.mes.value.length == 1) {
      frm.mes.value = "0" + frm.mes.value;
    }
    data = "01/" + frm.mes.value + "/" + frm.ano.value;
    if (isDate(data) == 'f') {
      return false;
    }
  }

  function checaOkList() {

    var frm = document.frmList;

    if ((frm.mes.value != "") && (frm.ano.value != "")){
      var data = "01/" + frm.mes.value + "/" + frm.ano.value;
      if (isDate(data) == 'f') {
        return false;
      }
    }
    return true;
  }

   function checaOkAltera() {

    var frm = document.frmRead;

    if (frm.dtaVenc.value == "") {
      alert('Preencha a data de vencimento do boleto.');
      return false;
    }
    else if (frm.valbol.value == "") {
      alert('Preencha o valor do boleto corretamente.');
      return false;
    }
    else if (isDate(frm.dtaVenc.value) == 'f') {
      return false;
    }
    return confAltera();
  }

  function checaOkPaga() {

    var frm = document.frmRead;

    if (frm.dtaPagto.value == "") {
      alert('Preencha a data de pagamento do boleto.');
      return false;
    }
    else if (frm.valpago.value == "") {
      alert('Preencha o valor pago corretamente.');
      return false;
    }
    else if (isDate(frm.dtaPagto.value) == 'f') {
      return false;
    }
    return confPaga();
  }

  function confPaga() {
      if(confirm("Confirma pagamento?"))
        return(true);
      else
        return(false);
  }

  function confAltera() {
      if(confirm("Confirma alteração?"))
        return(true);
      else
        return(false);
  }



  //Função para confirmar a exclusão dos registros
  function confDelete(frm, endereco, mensagem) {
    if(confirm(mensagem)) {
      document.getElementById(frm).action = endereco;
      document.getElementById(frm).submit();
      return(true);
    }
    else {
        return(false);
    }
  }

	//Função para confirmar a exclusão dos registros - MAIS SIMPLES - JOAQUIM
  function confDeleteSimples(mensagem) {
    if(confirm(mensagem)) {
      return(true);
    }
    else {
      return(false);
    }
  }
  
  //Função para confirmar a exclusão dos registros sem mensagem
  function confDeleteSemMensagem(frm, endereco) {
    document.getElementById(frm).action = endereco;
    document.getElementById(frm).submit();
    return(true);
  }


  //Função para marcar todos os checkboxes com base no chk_exc_all - JOAQUIM
	function checkAll(form){
		var state;  //gurada o estado do checkbox principal
		var cont = 0;   //contador
		var msg_cod;

		state = form.elements["chk_exc_all"].checked;

		while(form.elements["hid_msg_" + cont] != null){
			msg_cod = form.elements["hid_msg_" + cont].value;
			form.elements["chk_exc_" + msg_cod].checked = state;
			cont++;
		}
		return true;
	}
	
  //Função para marcar todos os checkboxes com base no chk_exc_all - JOAQUIM
	function checkAll_generic(form, radical){
		var state;  //gurada o estado do checkbox principal
		var cont = 0;   //contador
		var cod;

		state = form.elements["chk_exc_all"].checked;

		while(form.elements["hid_" + radical + "_" + cont] != null){
			cod = form.elements["hid_" + radical + "_" + cont].value;
			form.elements["chk_exc_" + cod].checked = state;
			cont++;
		}
		return true;
	}
	
	//calcula o valor a ser pago com base nos valores de mensalidades, juros e multa
	function calculaValor(form, linha){
		
		var pago = form.elements["apg_sit_" + linha].checked;

		if(!pago){
			var base = form.elements["apg_val_total_" + linha].value;
			var multa = form.elements["apg_val_multa_" + linha].value;
			var juros = form.elements["apg_val_juros_" + linha].value;

			base = parseFloat(base.replace(",", "."));
			multa = parseFloat(multa.replace(",", "."));
			juros = parseFloat(juros.replace(",", "."));

	    var total = base + multa + juros;
	    total = String(total.toFixed(2));
	    total = total.replace(".", ",");

			return total;
		}
		else
			return form.elements["apg_val_pago_" + linha].value;
	}	

	//funcao para controlar a exibição de textos descrtivos no arquivo curiosidades.php
	function exibe_texto(param){

		var textos = new Array(5);

		textos[0] = "<br /><br />";
		textos[1] = "<b>Saiba usar os pronomes de tratamento adequadamente e evite gafes!<br/><br /></b>";
		textos[2] = "<b>Voc&ecirc; n&atilde;o precisa ser estilista para se vestir adequadamente em todas as ocasi&otilde;es. Confira!</b>";
		textos[3] = "<b>Qual ser&aacute; a pedra que est&aacute; em sintonia com a profiss&atilde;o que voc&ecirc; escolheu?</b>";
		textos[4] = "<b>Saiba qual copo usar para cada tipo de bebida. Por incr&iacute;vel que pare&ccedil;a, tudo faz sentido!</b>";
		textos[5] = "<b>Todas as informações necessárias para voc&ecirc; organizar um churrasco bastante lucrativo!</b>";

		var celula = document.getElementById("txt_curiosidades");
		celula.innerHTML = textos[param];
		return true;
	}	
	
	
	//Função para converter um valor inteiro (100.15) em moeda nacional (100,5)
	function float2moeda(num){

   x = 0;

   if(num<0) {
      num = Math.abs(num);
      x = 1;
   }

   if(isNaN(num)) num = "0";
      cents = Math.floor((num*100+0.5)%100);

   num = Math.floor((num*100+0.5)/100).toString();

   if(cents < 10) cents = "0" + cents;
      for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
         num = num.substring(0,num.length-(4*i+3))+'.'
               +num.substring(num.length-(4*i+3));

   ret = num + ',' + cents;

   if (x == 1) ret = ' - ' + ret;return ret;

	}
	
	
	
//-->
