<!--

/*

<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>

  */

 

 /**
  * dados: conteúdo
  */

    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'] = '####-####';

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

    	//elimina data com caracter
    	if ( isNaN(val.substring( (val.length-1), val.length) ) ) {
					ele.value = val.substring(0, val.length-1);
					return false;
			}


      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);
    }
    
  //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 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;
        }
        
        function max(txarea, limite){
                var tam = txarea.value.length;
                var index = "lim_" + txarea.name;
                var campo = document.getElementById(index);
                var aux;

                aux = limite - tam;
                campo.value = aux;

   if (tam > limite){
            aux = txarea.value;
            txarea.value = aux.substring(0,limite);
            campo.value = 0;

    }

  }
  
        function conta(txarea){
    tam = txarea.value.length;
    var index = "tam_" + txarea.name;
                var campo = document.getElementById(index);
                campo.value = tam;
  }
  
  
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function enq() {
	reposta = "";
	
	for (i=0;i<4;i++) {
		if (document.frm_enq.enq_vot[i].checked) {
			resposta = document.frm_enq.resposta[i].value;
		}
	}
	if (id_resp == "")
	{
        alert("Escolha uma opção antes de votar!");
	}
	else
	{
		window.open('{$conf.addr}/popUp_enquete.php?id={$enq.enq_cod}&voto=' + resposta, 'Enquetes','left=20,width=400,top=20,height=350,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,fullscreen=no,maximize=no');
	}
}

var mymessage = "©Compugraphic LTDA";
function rtclickcheck(keyp){
  if (navigator.appName == "Netscape" && keyp.which == 3) {
    alert(mymessage);
    return false;
  }
  if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {
    alert(mymessage);
    return false;
  }

}

function add_mensalidade(valor, vencimento, url){
	
	if((valor.length == 0) || (vencimento.length == 0))
	  alert("<Valor< e <Data de vencimento> da mensalidade devem estar preenchidos!");

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

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

 	//cria uma nova linha ao fim da tabela
 	nova_linha = tabela.insertRow(-1);
 	
 	//monta o id da nova linha
 	nova_linha.id = "mens_" + nova_linha_id.value;
 	
	//cria 4 novasuma nova célula na linha recém-criada
	nova_celula1 = nova_linha.insertCell(0);
	nova_celula1.innerHTML = "<input type = 'text' name = 'pgt_val_" + nova_linha_id.value + "' value = '" + valor + "' />";

	nova_celula2 = nova_linha.insertCell(1);
	nova_celula2.innerHTML = "<input type = 'text' name = 'pgt_venc_" + nova_linha_id.value + "' value = '" + vencimento + "' />";

	nova_celula3 = nova_linha.insertCell(2);
	nova_celula3.innerHTML = "<input type = 'checkbox' name = 'pgt_sit_" + nova_linha_id.value + "' />";

	nova_celula3.align = "center";
	nova_celula4 = nova_linha.insertCell(3);
	

	nova_celula4.innerHTML = "	<img src = '" + url + "/common/img/delete.gif' onclick = 'javascript: del_mensalidade(" + nova_linha_id.value  + ");'> <input type = 'hidden' name = 'pgt_" + 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;

	//limpa os campos valor e data de vencimento do formulário
	document.frm_cad.mens_venc.value = "";
	document.frm_cad.mens_val.value = "";

	return true;

}	

function del_mensalidade(linha){

	var tabela = document.getElementById("mensalidades");
 	var id_linha = document.getElementById("mens_" + linha);
 	
	linha_nova = id_linha.rowIndex;
 	
	tabela.deleteRow(linha_nova);
	
	return true;

}

function atualiza_ids(){

	var linha;

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

	for(i = 1; i < tabela.rows.length; i++){
		linha = tabela.rows[i];
		var id_antigo = linha.substring(5, linha.length - 1);
		linha.id = "mens" + i;
	}

	return true;

}	

function preenche_solenidades(){

	var locais = document.getElementById("locais");

	//montagem do endereço
	var endereco_fonte = document.getElementById("loc_end_" + locais.value);
	var endereco_destino = document.getElementById("sol_end");
	endereco_destino.value = endereco_fonte.value;
	
	//montagem do nome do lugar
	var nome_fonte = document.getElementById("loc_nom_" + locais.value);
	var nome_destino = document.getElementById("sol_loc");
	nome_destino.value = nome_fonte.value;
	
	return 1;

}	

function setParam(id) {
	var valor;
	var encartes;
	var nencartes;
	encartes = 'encartes'+id;
	nencartes ='nencartes'+id;
	if(document.getElementById(encartes).value == "outro") {
		document.getElementById(nencartes).style.display = "inline";
		valor = document.getElementById(nencartes).value;
  }
	else {
		valor = document.getElementById(encartes).value;
		document.getElementById(nencartes).style.display = "none";
  }
	document.getElementById(nencartes).value = valor;
}

function versaoImpressao() {
	document.impressao.imp.value = "true";
	document.impressao.submit();
}
document.onmousedown = rtclickcheck



function alteraSituacaoConvite (){

			if ((document.frm_cad.cad_sit[0].selected)) {

						if ( (document.frm_cad.cad_txt.checked) && (document.frm_cad.cad_fot.checked) ) {
  	  				document.frm_cad.cad_sit[1].selected=true;
						}
			}

}


//-->

