function showImgBox (img, X, Y) {
  document.getElementById('iframe_').src='show_image?img='+img+'&X='+X+'&Y='+Y;
  document.getElementById('iframe_').style.display='block';
  document.getElementById('iframe_').style.visibility='visible';
}


function manageInclude(box, botao_incluir) {
    botao = document.getElementById(botao_incluir);
    botao.disabled = (box.checked ? false : true);
}

  function verifyQtd (cod, preco, qtd, nome) {
  //alert("verifyQtd " +cod+" "+preco+" "+qtd);
    if (qtd == 0) { 
      alert ('A quantidade não pode ser Zero!');
      return false;
    } else {
      document.ped.qtd.value = qtd;
      document.ped.prod.value = cod;
      document.ped.preco.value = preco;
      document.ped.nome.value = nome;
      document.ped.botao.value = 'comprar';
      document.ped.action="trata_ped";
      document.ped.submit();
    }
    return true;
  }

  function checkLimit () {
    if (document.ped.tot_ped) {
      total = document.ped.tot_ped.value.split(",");
      if (parseInt(total[0]+total[1]) <= 1000) {
        alert ('Valor mínimo de pedido é de R$ 10,00');
      } else {
        document.getElementById('cliente').style.display = "block";
        document.getElementById('btn_confirmar').style.display = "none";
        document.getElementById('btn_pagar').style.display = "inline";
      }
    }
  }  

  function checkPagar () {
    with (document.ped) {
      if ((nome.value == '') || (email.value == '') || (ender.value == '') || 
          (bairro == '') || (cep == '') || (cidade == '') || (estado == '') || 
          (pais == '') || (cpf_cgc == '')) {
        alert ('Todos os campos do formulário são obrigatórios.');
      } else {
        if (tot_ped) {
          if (tot_ped.value <= 10000) {
            alert ('Valor mínimo de pedido é de R$ 10,00');
          } else {
            treatBotao('pagar', true)
          }
        }
      }
    }
  }  

  function checkClient () {
    if (document.ped.tot_ped) {
      if (document.ped.tot_ped.value <= 100000) {
        alert ('Valor mínimo de pedido é de R$ 10,00');
      } else {
        treatBotao('confirmar', true)
      }
    }
  }  

  function treatBotao (botao, confirmacao) {
    if (confirmacao) { 
      if (! confirm ('Confirma a Operação?')) {
        return false;
      }
    }
    document.ped.botao.value = botao;
    document.ped.action="trata_ped";
    document.ped.submit();
    return true;
  }

function GeraBoleto(tipo){
   if (tipo == 'boleto') {
      document.forms.gera_boleto.voltar.disabled = true;
      document.forms.gera_boleto.deposito.disabled = true;
      document.forms.gera_boleto.submit();
   } else if (tipo == 'deposito') {
      document.forms.gera_boleto.voltar.disabled = true;
//      document.forms.gera_boleto.boleto.disabled = true;
      document.forms.gera_boleto.action = "gera_deposito";
      document.forms.gera_boleto.submit();      
   } else {
      document.forms.gera_boleto.action = "nova_compra";
      document.forms.gera_boleto.submit();      
   }  
}
