<!--
function padNumber(txt,maxLen){var s;s=txt;while(s.length<maxLen){s='0'+s;}
return s;}
function fmtFloat(vlr){var v,p,d;v=String(vlr);p=v.indexOf('.');if(p>-1){d=v.substring(p+1);while(d.length<2){d+='0';}
return(v.substring(0,p)+','+d.substring(0,2));}else{return v+',00';}}
function fmtMoney(vlr,symbol){if(symbol){return'R$ '+fmtFloat(vlr);}else{return fmtFloat(vlr);}}
function fmtMoneyStrToFloat(vlr){var p;p=vlr.indexOf(',');if(p>-1){return(vlr.substring(0,p)+'.'+vlr.substring(p+1,2));}else{return vlr;}}
function numeroDocumentoBloqueto(){var myDate=new Date();var ano,mes,dia,hh,mm,ss;dia=padNumber(String(myDate.getUTCDate()),2);mes=padNumber(String(myDate.getMonth()),2);ano=padNumber(String(myDate.getYear()),4);hh=padNumber(String(myDate.getUTCHours()),2);mm=padNumber(String(myDate.getUTCMinutes()),2);ss=padNumber(String(myDate.getUTCSeconds()),2);return(dia+mes+ano+hh+mm+ss);}
function recalcula(){var itn_sub=0;var sel_ope="";var sub_total=0;var vlr_total=0;for(var i=0;i<document.frmBlq.operacao.length;i++){if(document.frmBlq.operacao[i].checked){sel_ope=document.frmBlq.operacao[i].value;}}
itn_sub=0;if(document.frmBlq.prod_01.checked){if(sel_ope=="REG"){itn_sub=894;}else if(sel_ope=="RNV"){itn_sub=173;}}
document.getElementById('sub_01').childNodes[0].nodeValue=fmtFloat(itn_sub);sub_total+=itn_sub;itn_sub=0;if(document.frmBlq.prod_02.checked){if(sel_ope=="REG"){itn_sub=289;}else if(sel_ope=="RNV"){itn_sub=88;}}
document.getElementById('sub_02').childNodes[0].nodeValue=fmtFloat(itn_sub);sub_total+=itn_sub;itn_sub=0;if(document.frmBlq.prod_04.checked){if(sel_ope=="REG"){itn_sub=125;}else if(sel_ope=="RNV"){itn_sub=52;}}
document.getElementById('sub_04').childNodes[0].nodeValue=fmtFloat(itn_sub);sub_total+=itn_sub;itn_sub=0;if(document.frmBlq.prod_05.checked){if(sel_ope=="REG"){itn_sub=900;}else if(sel_ope=="RNV"){itn_sub=200;}}
document.getElementById('sub_05').childNodes[0].nodeValue=fmtFloat(itn_sub);sub_total+=itn_sub;itn_sub=0;if(document.frmBlq.prod_06.checked){if(sel_ope=="REG"){itn_sub=894;}else if(sel_ope=="RNV"){itn_sub=173;}}
document.getElementById('sub_06').childNodes[0].nodeValue=fmtFloat(itn_sub);sub_total+=itn_sub;itn_sub=0;if(document.frmBlq.prod_07.checked){if(sel_ope=="REG"){itn_sub=289;}else if(sel_ope=="RNV"){itn_sub=88;}}
document.getElementById('sub_07').childNodes[0].nodeValue=fmtFloat(itn_sub);sub_total+=itn_sub;itn_sub=0;if(document.frmBlq.prod_08.checked){if(sel_ope=="REG"){itn_sub=894;}else if(sel_ope=="RNV"){itn_sub=173;}}
document.getElementById('sub_08').childNodes[0].nodeValue=fmtFloat(itn_sub);sub_total+=itn_sub;itn_sub=0;if(document.frmBlq.prod_09.checked){if(sel_ope=="REG"){itn_sub=289;}else if(sel_ope=="RNV"){itn_sub=88;}}
document.getElementById('sub_09').childNodes[0].nodeValue=fmtFloat(itn_sub);sub_total+=itn_sub;itn_sub=0;if(document.frmBlq.prod_10.checked){if(sel_ope=="REG"){itn_sub=894;}else if(sel_ope=="RNV"){itn_sub=173;}}
document.getElementById('sub_10').childNodes[0].nodeValue=fmtFloat(itn_sub);sub_total+=itn_sub;itn_sub=0;if(document.frmBlq.prod_11.checked){if(sel_ope=="REG"){itn_sub=289;}else if(sel_ope=="RNV"){itn_sub=88;}}
document.getElementById('sub_11').childNodes[0].nodeValue=fmtFloat(itn_sub);sub_total+=itn_sub;vlr_total=sub_total;document.getElementById('valorTotal').childNodes[0].nodeValue=fmtFloat(vlr_total);}
function isNumber(txt){var result=true;var validChars='0123456789';for(var i=0;i<txt.length;i++){if(validChars.indexOf(txt.charAt(i))==-1){result=false;break;}}
return result;}
function isRepeated(txt){var result=true;var char_ref;char_ref=txt.charAt(0);for(var i=0;i<txt.length;i++){if(txt.charAt(i)!=char_ref){result=false;break;}}
return result;}
function isCPFCNPJ(campo,pType){var campo_filtrado="";var valor_1=" ";var valor_2=" ";var ch="";var valido=false;for(i=0;i<campo.length;i++){ch=campo.substring(i,i+1);if(ch>="0"&&ch<="9"){campo_filtrado=campo_filtrado.toString()+ch.toString();valor_1=valor_2;valor_2=ch;}
if((valor_1!=" ")&&(!valido))valido=!(valor_1==valor_2);}
if(!valido)campo_filtrado="12345678912";if(campo_filtrado.length<11){for(i=1;i<=(11-campo_filtrado.length);i++){campo_filtrado="0"+campo_filtrado;}}
if(pType<=1){if((campo_filtrado.substring(9,11)==checkCPF(campo_filtrado.substring(0,9)))&&(campo_filtrado.substring(11,12)=="")){return true;}}
if((pType==2)||(pType==0)){if(campo_filtrado.length>=14){if(campo_filtrado.substring(12,14)==checkCNPJ(campo_filtrado.substring(0,12))){return true;}}}
return false;}
function checkCNPJ(vCNPJ){var mControle="";var aTabCNPJ=new Array(5,4,3,2,9,8,7,6,5,4,3,2);for(i=1;i<=2;i++){mSoma=0;for(j=0;j<vCNPJ.length;j++)
mSoma=mSoma+(vCNPJ.substring(j,j+1)*aTabCNPJ[j]);if(i==2)mSoma=mSoma+(2*mDigito);mDigito=(mSoma*10)%11;if(mDigito==10)mDigito=0;mControle1=mControle;mControle=mDigito;aTabCNPJ=new Array(6,5,4,3,2,9,8,7,6,5,4,3);}
return((mControle1*10)+mControle);}
function checkCPF(vCPF){var mControle=""
var mContIni=2,mContFim=10,mDigito=0;for(j=1;j<=2;j++){mSoma=0;for(i=mContIni;i<=mContFim;i++)
mSoma=mSoma+(vCPF.substring((i-j-1),(i-j))*(mContFim+1+j-i));if(j==2)mSoma=mSoma+(2*mDigito);mDigito=(mSoma*10)%11;if(mDigito==10)mDigito=0;mControle1=mControle;mControle=mDigito;mContIni=3;mContFim=11;}
return((mControle1*10)+mControle);}
function check_cnpj_cpf(txt){if(txt==""){alert("O CNPJ ou CPF do sacado deve ser informado.");return false;}else if(txt.indexOf(" ")>=0){alert('O CNPJ ou CPF informado é inválido.');return false;}else if((txt.length!=11)&&(txt.length!=14)){alert('O CNPJ ou CPF informado é inválido. Informe um número com 11 ou 14 dígitos.');return false;}else if(!isNumber(txt)){alert('O CNPJ ou CPF "'+txt+'" informado é inválido. Informe apenas números.');return false;}else if(isRepeated(txt)){alert('O CNPJ ou CPF "'+txt+'" informado é inválido.');return false;}else{if(txt.length==11){if(isCPFCNPJ(txt,1)){return true;}else{alert('O CPF informado é inválido. Informe um CPF válido.');return false;}}else if(txt.length==14){if(isCPFCNPJ(txt,2)){return true;}else{alert('O CNPJ informado é inválido. Informe um CNPJ válido.');return false;}}}}
function cnpj_cpf_banido(txt){if(txt=="47696010182"){return true;}else{return false;}}
function check_nome(txt,caption){if(txt==""){alert("O "+caption+" deve ser informado.");return false;}else if(txt.split(" ").length<1){alert('Informe o '+caption+' completo.');return false;}else if(txt.indexOf("  ")>0){alert('Informe o '+caption+' completo com apenas um espaço entre as palavras.');return false;}else if(isRepeated(txt)){alert('O '+caption+' informado é inválido.');return false;}else if(txt.indexOf("asdf")>0){alert('O '+caption+' informado contém uma sequência inválida de caracteres.');return false;}else{return true;}}
function check_bairro(txt,caption){if(txt==""){alert("O "+caption+" deve ser informado.");return false;}else if(txt.length<3){alert('O '+caption+' informado é inválido.');return false;}else if(txt.indexOf("  ")>0){alert('Informe o '+caption+' completo com apenas um espaço entre as palavras.');return false;}else if(isRepeated(txt)){alert('O '+caption+' informado é inválido.');return false;}else if(txt.indexOf("asdf")>0){alert('O '+caption+' informado contém uma sequência inválida de caracteres.');return false;}else{return true;}}
function check_cep(txt,caption){if(txt==""){alert("O "+caption+" deve ser informado.");return false;}else if(txt.length!=8){alert('O '+caption+' é inválido. Informe um número com 8 dígitos.');return false;}else if(!isNumber(txt)){alert('O '+caption+' "'+txt+'" é inválido. Informe apenas números.');return false;}else if(txt.indexOf(" ")>=0){alert('O '+caption+' "'+txt+'" é inválido. Não informe espaços.');return false;}else if(isRepeated(txt)){alert(caption+' é inválido.');return false;}else{return true;}}
function check_fone(txt,caption,minLen,maxLen){if(txt==""){alert("O "+caption+" deve ser informado.");return false;}else if((txt.length<minLen)||(txt.length>maxLen)){alert('O '+caption+' é inválido. Informe um número contendo '+minLen+' a '+maxLen+' dígitos.');return false;}else if(!isNumber(txt)){alert('O '+caption+' "'+txt+'" é inválido. Informe apenas números.');return false;}else if(txt.indexOf(" ")>=0){alert('O '+caption+' "'+txt+'" é inválido. Não informe espaços.');return false;}else if(isRepeated(txt)){alert('O '+caption+' "'+txt+'" é inválido.');return false;}else{return true;}}
function check_email(txt,caption){if(txt==""){alert("O "+caption+" deve ser informado.");return false;}else if(txt.length<=5){alert('O '+caption+' é inválido.');return false;}else if(txt.indexOf("@")<0){alert('O '+caption+' é inválido.');return false;}else if(txt.indexOf(".")<0){alert('O '+caption+' é inválido.');return false;}else if(txt.indexOf(" ")>0){alert('O '+caption+' é inválido.');return false;}else if(txt.indexOf("asdf")>0){alert('O '+caption+' informado contém uma sequência inválida de caracteres.');return false;}else{return true;}}
function email_banido(txt){if(txt=="reydavi_6@hotmail.com"){return true;}else if(txt=="cleitonferreira@gmail.com.br"){return true;}else if(txt=="cleitonferreira@gmail.com"){return true;}else if(txt=="cleitoferreira@gmail.com.br"){return true;}else if(txt=="cleitoferreira@gmail.com"){return true;}else{return false;}}
function montaBloqueto(){var msg_prod_01='';var msg_prod_02='';var msg_prod_04='';var msg_prod_05='';var msg_prod_06='';var msg_prod_07='';var msg_prod_08='';var msg_prod_09='';var msg_prod_10='';var msg_prod_11='';var msg_conf;var tmp_frm;var sel_ope="";tmp_frm=document.forms["frmBlq"];for(var i=0;i<document.frmBlq.operacao.length;i++){if(document.frmBlq.operacao[i].checked){sel_ope=document.frmBlq.operacao[i].value;}}
if(!(document.frmBlq.prod_01.checked)&&(!document.frmBlq.prod_02.checked)&&(!document.frmBlq.prod_04.checked)&&(!document.frmBlq.prod_05.checked)&&(!document.frmBlq.prod_06.checked)&&(!document.frmBlq.prod_07.checked)&&(!document.frmBlq.prod_08.checked)&&(!document.frmBlq.prod_09.checked)&&(!document.frmBlq.prod_10.checked)&&(!document.frmBlq.prod_11.checked)){alert("Marque ao menos um produto.");document.frmBlq.prod_01.focus();document.frmBlq.prod_01.blur();document.frmBlq.prod_01.select();return false;}else if(!check_email(tmp_frm.elements["EnderecoEmail"].value,"email do sacado")){tmp_frm.elements["EnderecoEmail"].focus();tmp_frm.elements["EnderecoEmail"].blur();tmp_frm.elements["EnderecoEmail"].select();return false;}else if(email_banido(tmp_frm.elements["EnderecoEmail"].value)){return false;}else if(!check_nome(tmp_frm.elements["NomeSacado"].value,'nome do sacado')){tmp_frm.elements["NomeSacado"].focus();tmp_frm.elements["NomeSacado"].blur();tmp_frm.elements["NomeSacado"].select();return false;}else if(!check_cnpj_cpf(tmp_frm.elements["CNPJCPFSacado"].value)){tmp_frm.elements["CNPJCPFSacado"].focus();tmp_frm.elements["CNPJCPFSacado"].blur();tmp_frm.elements["CNPJCPFSacado"].select();return false;}else if(cnpj_cpf_banido(tmp_frm.elements["CNPJCPFSacado"].value)){return false;}else if(!check_nome(tmp_frm.elements["EnderecoSacado"].value,'endereço do sacado')){tmp_frm.elements["EnderecoSacado"].focus();tmp_frm.elements["EnderecoSacado"].blur();tmp_frm.elements["EnderecoSacado"].select();return false;}else if(!check_bairro(tmp_frm.elements["BairroSacado"].value,'bairro do sacado')){tmp_frm.elements["BairroSacado"].focus();tmp_frm.elements["BairroSacado"].blur();tmp_frm.elements["BairroSacado"].select();return false;}else if(!check_bairro(tmp_frm.elements["CidadeSacado"].value,'município do sacado')){tmp_frm.elements["CidadeSacado"].focus();tmp_frm.elements["CidadeSacado"].blur();tmp_frm.elements["CidadeSacado"].select();return false;}else if(!check_cep(tmp_frm.elements["CepSacado"].value,'CEP do sacado')){tmp_frm.elements["CepSacado"].focus();tmp_frm.elements["CepSacado"].blur();tmp_frm.elements["CepSacado"].select();return false;}else if(!check_fone(tmp_frm.elements["DDD"].value,'DDD do telefone do sacado',2,3)){tmp_frm.elements["DDD"].focus();tmp_frm.elements["DDD"].blur();tmp_frm.elements["DDD"].select();return false;}else if(!check_fone(tmp_frm.elements["Telefone"].value,'número do telefone do sacado',7,9)){tmp_frm.elements["Telefone"].focus();tmp_frm.elements["Telefone"].blur();tmp_frm.elements["Telefone"].select();return false;}else{tmp_frm.elements["NumeroDocumento"].value=numeroDocumentoBloqueto();tmp_frm.elements["ValorDocumento"].value=document.getElementById('valorTotal').childNodes[0].nodeValue;tmp_frm.elements["EstadoSacado"].value=tmp_frm.elements["Estado"].options[tmp_frm.elements["Estado"].selectedIndex].value;msg_prod='Referente a:';if(document.frmBlq.prod_01.checked){msg_prod_01='e-Suite::Financeiro CORPORATIVO';if(sel_ope=="REG"){msg_prod_01+=' (licenciamento)';}else if(sel_ope=="RNV"){msg_prod_01+=' (renovação)';}
msg_prod_01+=' = R$ '+document.getElementById('sub_01').childNodes[0].nodeValue;msg_prod+='<br>'+msg_prod_01;}
if(document.frmBlq.prod_02.checked){msg_prod_02='e-Suite::Financeiro COMERCIAL';if(sel_ope=="REG"){msg_prod_02+=' (licenciamento)';}else if(sel_ope=="RNV"){msg_prod_02+=' (renovação)';}
msg_prod_02+=' = R$ '+document.getElementById('sub_02').childNodes[0].nodeValue;msg_prod+='<br>'+msg_prod_02;}
if(document.frmBlq.prod_04.checked){msg_prod_04='Softcheque 5.x (ou +) ';if(sel_ope=="REG"){msg_prod_04+=' (licenciamento)';}else if(sel_ope=="RNV"){msg_prod_04+=' (renovação)';}
msg_prod_04+=' = R$ '+document.getElementById('sub_04').childNodes[0].nodeValue;msg_prod+='<br>'+msg_prod_04;}
if(document.frmBlq.prod_05.checked){msg_prod_05='e-Suite::NF-e CORPORATIVO';if(sel_ope=="REG"){msg_prod_05+=' (licenciamento)';}else if(sel_ope=="RNV"){msg_prod_05+=' (renovação)';}
msg_prod_05+=' = R$ '+document.getElementById('sub_05').childNodes[0].nodeValue;msg_prod+='<br>'+msg_prod_05;}
if(document.frmBlq.prod_06.checked){msg_prod_06='e-Suite::Estoque CORPORATIVO';if(sel_ope=="REG"){msg_prod_06+=' (licenciamento)';}else if(sel_ope=="RNV"){msg_prod_06+=' (renovação)';}
msg_prod_06+=' = R$ '+document.getElementById('sub_06').childNodes[0].nodeValue;msg_prod+='<br>'+msg_prod_06;}
if(document.frmBlq.prod_07.checked){msg_prod_07='e-Suite::Estoque COMERCIAL';if(sel_ope=="REG"){msg_prod_07+=' (licenciamento)';}else if(sel_ope=="RNV"){msg_prod_07+=' (renovação)';}
msg_prod_07+=' = R$ '+document.getElementById('sub_07').childNodes[0].nodeValue;msg_prod+='<br>'+msg_prod_07;}
if(document.frmBlq.prod_08.checked){msg_prod_08='e-Suite::RepCom CORPORATIVO';if(sel_ope=="REG"){msg_prod_08+=' (licenciamento)';}else if(sel_ope=="RNV"){msg_prod_08+=' (renovação)';}
msg_prod_08+=' = R$ '+document.getElementById('sub_08').childNodes[0].nodeValue;msg_prod+='<br>'+msg_prod_08;}
if(document.frmBlq.prod_09.checked){msg_prod_09='e-Suite::RepCom COMERCIAL';if(sel_ope=="REG"){msg_prod_09+=' (licenciamento)';}else if(sel_ope=="RNV"){msg_prod_09+=' (renovação)';}
msg_prod_09+=' = R$ '+document.getElementById('sub_09').childNodes[0].nodeValue;msg_prod+='<br>'+msg_prod_09;}
if(document.frmBlq.prod_10.checked){msg_prod_10='e-Suite::Compras CORPORATIVO';if(sel_ope=="REG"){msg_prod_10+=' (licenciamento)';}else if(sel_ope=="RNV"){msg_prod_10+=' (renovação)';}
msg_prod_10+=' = R$ '+document.getElementById('sub_10').childNodes[0].nodeValue;msg_prod+='<br>'+msg_prod_10;}
if(document.frmBlq.prod_11.checked){msg_prod_11='e-Suite::Compras COMERCIAL';if(sel_ope=="REG"){msg_prod_11+=' (licenciamento)';}else if(sel_ope=="RNV"){msg_prod_11+=' (renovação)';}
msg_prod_11+=' = R$ '+document.getElementById('sub_11').childNodes[0].nodeValue;msg_prod+='<br>'+msg_prod_11;}
tmp_frm.elements["Demonstrativo"].value=msg_prod;msg_conf='Confira os dados do seu pedido\n';msg_conf+='\n';msg_conf+='DADOS DOS PRODUTOS ======================================\n';if(document.frmBlq.prod_01.checked){msg_conf+=msg_prod_01+'\n';}
if(document.frmBlq.prod_02.checked){msg_conf+=msg_prod_02+'\n';}
if(document.frmBlq.prod_04.checked){msg_conf+=msg_prod_04+'\n';}
if(document.frmBlq.prod_05.checked){msg_conf+=msg_prod_05+'\n';}
if(document.frmBlq.prod_06.checked){msg_conf+=msg_prod_06+'\n';}
if(document.frmBlq.prod_07.checked){msg_conf+=msg_prod_07+'\n';}
if(document.frmBlq.prod_08.checked){msg_conf+=msg_prod_08+'\n';}
if(document.frmBlq.prod_09.checked){msg_conf+=msg_prod_09+'\n';}
if(document.frmBlq.prod_10.checked){msg_conf+=msg_prod_10+'\n';}
msg_conf+='\n';msg_conf+='Valor total: '+tmp_frm.elements["ValorDocumento"].value+'\n';msg_conf+='\n';msg_conf+='DADOS DO COMPRADOR (SACADO) =============================\n';msg_conf+='E-mail: '+tmp_frm.elements["EnderecoEmail"].value+'\n';msg_conf+='Nome: '+tmp_frm.elements["NomeSacado"].value+'\n';msg_conf+='CNPJ / CPF: '+tmp_frm.elements["CNPJCPFSacado"].value+'\n';msg_conf+='Endereço: '+tmp_frm.elements["EnderecoSacado"].value+'\n';msg_conf+='Bairro: '+tmp_frm.elements["BairroSacado"].value+'\n';msg_conf+='Cidade: '+tmp_frm.elements["CidadeSacado"].value+'\n';msg_conf+='UF: '+tmp_frm.elements["EstadoSacado"].value+'\n';msg_conf+='CEP: '+tmp_frm.elements["CepSacado"].value+'\n';msg_conf+='Telefone: '+tmp_frm.elements["DDD"].value+' '+tmp_frm.elements["Telefone"].value+'\n';msg_conf+='\n';msg_conf+='Se todas as informações estiverem corretas, clique o botão "Ok" para ';msg_conf+='emitir o boleto bancário, ou clique em "Cancelar" para ajustar os dados.';if(confirm(msg_conf)){return true;}else{document.frmBlq.prod_01.focus();document.frmBlq.prod_01.blur();document.frmBlq.prod_01.select();return false;}}}