<!--
/*
		// função para alinhar o menu
		function RetornaMargem() {
			var tabela = document.getElementById("tabela_regua");
			alert(tabela.offsetParent);
			if (navigator.appVersion.indexOf("MSIE")!=-1){
			  //caso o browser seja internetExplorer
			  var tabela = document.getElementById("tabela_regua");
			  return tabela.offsetLeft;
			}
			else if(navigator.userAgent.indexOf("Firefox")!=-1){
				//caso o browser seja Firefox
				var celula = document.getElementById("celula_regua");
				return celula.offsetLeft;
			}

			var tamanho_tela = screen.width;

			var margem = 0;

			// Resolução de 600
			if (tamanho_tela <= 799) margem = 0;
			// Resolução de 800
			else if ( (tamanho_tela >= 800) && (tamanho_tela <= 959) ) margem = 46;
			// Resolução de 960
			else if ( (tamanho_tela >= 960) && (tamanho_tela <= 1023) ) margem = 127;
			// Resolução de 1024
			else if ( (tamanho_tela >= 1024) && (tamanho_tela <= 1087) ) margem = 160;
			// Resolução de 1088
			else if ( (tamanho_tela >= 1088) && (tamanho_tela <= 1151) ) margem = 191;
			// Resolução de 1152
			else if ( (tamanho_tela >= 1152) && (tamanho_tela <= 1279) ) margem = 223;
			// Resolução de 1280
			else if ( (tamanho_tela >= 1280) && (tamanho_tela <= 1599) ) margem = 287;
			// Resolução de 1600
			else if (tamanho_tela >= 1600) margem = 350;
			// Não achou a resolução
			else margem = 0;

			return (margem);
		}
		*/

    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['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;
	}


  function add_opcao(url) {

	 	var tabela = document.getElementById("opcoes");

		//obtém o número de linhas da tabela
		nova_linha_id = document.getElementById("opt_flag");

	 	//cria uma nova linha ao fim da tabela
	 	nova_linha = tabela.insertRow(-1);

	 	//monta o id da nova linha
	 	nova_linha.id = "opt_" + nova_linha_id.value;

		//cria 4 novasuma nova célula na linha recém-criada
		nova_celula1 = nova_linha.insertCell();
		nova_celula1.innerHTML = "Opção &nbsp;&nbsp;" + ": <input class='long' type = 'text' name = 'opt_txt_" + nova_linha_id.value + "' />";

		nova_celula4 = nova_linha.insertCell();
		nova_celula4.innerHTML = "	<img src = '" + url + "/common/img/delete.gif' onclick = 'javascript: del_opcao(" + nova_linha_id.value  + ");'> <input type = 'hidden' name = 'opt_" + nova_linha_id.value + "' value = '1' />";
		nova_celula4.align = "center";

	 	//atualiza o valor do flag
	 	nova_linha_id.value = parseInt(nova_linha_id.value) + 1;

		return true;

	}

	function del_opcao(linha){

		var tabela = document.getElementById("opcoes");
		var id_linha = document.getElementById("opt_" + linha);

		linha_nova = id_linha.rowIndex;

		tabela.deleteRow(linha_nova);

		return true;

	}


		
	
//-->

