  // FUNCOES EM JAVASCRIPT

  // Indentificação do Navegador:
  var ie5 = (document.getElementById && document.all);  // se for internet explorer ira retornar verdadeiro
  var ffox = (!document.all && document.getElementById); // se for se for firefox ira retornar verdadeiro

  var novalinha = "\r\r"
  var informe_suporte="\r\rPOR FAVOR INFORME AO SUPORTE TECNICO."
  var nome_combo_div='';
  function confirma() {

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

  }
  
  function show_destaque(Posicao,Direcao)
  {
  	carregar_ajax('show_destaque.php?Posicao='+Posicao+'&Direcao='+Direcao, 'POST', false, 'DIV_show_destaque');
  }


  // Funcao Generica Para formatar Valor no Imput
  function Formatar_Valor(campo,fld, milSep, decSep, e, casas, tamanho)
  {
      var sep = 0;
      var cTecla = '';
      var i = j = 0;
      var len = len2 = 0;
      var strCheck = '-0123456789';
      var aux = aux2 = '';
      var nCodTecla = (window.Event) ? e.which : e.keyCode;
      var zeros = 0;
      var tudozero=1;

      // Se for um enter, pula para o proximo campo
      //Skip_Campo(campo,e,nome_form);

      if ((nCodTecla==8) || (nCodTecla==0) || (nCodTecla == 13)) {
         return true;
      }

      // Verifica se é um Valor ou Numero
      cTecla = String.fromCharCode(nCodTecla);

      // Não é um Número ou Valor Válido

      if (strCheck.indexOf(cTecla) == -1) return false;

      len = fld.value.length;



      for(i = 0; i < len; i++) {
         if ((fld.value.substr(i, 1)!=0) && (fld.value.substr(i, 1)!=',') && (fld.value.substr(i, 1)!='.')) {
            tudozero++;
         }
      }

      if ((len>=tamanho) && (tudozero==len)) return false;

      for(i = 0; i < len; i++)

      if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;

      aux = '';

      for(; i < len; i++)
      if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);

      aux += cTecla;
      len = aux.length;

      for(z = 1; z < (casas-len); z++) zeros=zeros+'0';

      for(c = 0; c <= casas; c++) {
          if (len!=casas) {
              if (len == c) fld.value = '0'+ decSep + zeros + aux;
          } else {
              if (len == casas) fld.value = '0'+ decSep + aux;
          }
      }

      if (len > casas) {
          aux2 = '';
          for (j = 0, i = len - (casas+1); i >= 0; i--) {
              if (j == 3) {
                 aux2 += milSep;
                 j = 0;
              }
              aux2 += aux.charAt(i);
              j++;
          }
          fld.value = '';
          len2 = aux2.length;
          for (i = len2 - 1; i >= 0; i--)
              fld.value += aux2.charAt(i);
           fld.value += decSep + aux.substr(len-casas, len);
      }
      return false;
  }

  function IncluirLivroReceitas(D010_Id)
  {
	  document.getElementById('fme_geral').src='incluir_livro.php?D010_Id='+D010_Id;
  }
  
  function AbreFormularioEnviar()
  {
	 FecharTodasOpcoes();
	 document.getElementById('DIV_enviar').style.display='inline';
  }
  
  function FechaFormularioEnviar()
  {
	 document.getElementById('DIV_enviar').style.display='none';
  }
  
  function AbreFormularioCompartilhar()
  {
	 FecharTodasOpcoes();
	 document.getElementById('DIV_compartilhar').style.display='inline';
  }

  function FechaFormularioCompartilhar()
  {
	 document.getElementById('DIV_compartilhar').style.display='none';
  }
  
  function FecharTodasOpcoes()
  {
	 FechaFormularioEnviar();
	 FechaFormularioCompartilhar();
  }
  
  function MostraResultados(D018_Id)
  {
  	carregar_ajax('mostra_resultados_enquete.php?D018_Id='+D018_Id, 'POST', false, 'DIV_resultado_enquete');
  	document.getElementById('DIV_resultado_enquete').style.display='inline';
  }
  
  function FecharResultados()
  {
  	document.getElementById('DIV_resultado_enquete').style.display='none';
  }

