//'-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
//' Loja Exemplo Locaweb 
//' Versão: 6.5
//' Data: 12/09/06
//' Arquivo: funcoes_js.js
//' Versão do arquivo: 0.0
//' Data da ultima atualização: 13/10/08
//'
//'-----------------------------------------------------------------------------
//' Licença Código Livre: http://comercio.locaweb.com.br/gpl/gpl.txt
//'-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

//# FUNCOES CEP

//###################################################################################
function disable_form() {
	document.frm.cep.disabled		= true;
	document.frm.cep.value			= '';

}
//###################################################################################
function mostraiframe(linha) {
var linha = document.getElementById(linha);
  if (linha.style.display=='none') {
   linha.style.display='';
  } else {
   linha.style.display='none';
  }
}
//###################################################################################
function alteraiframe(linha,acao) {
var linha = document.getElementById(linha);
  if (acao=='exibe') {
   linha.style.display='';
  } else {
   linha.style.display='none';
  }
}
//###################################################################################
function enable_form() {
	document.frm.cep.disabled		= false;
}


//###################################################################################
function pesquisar_cep(pais,cep,pesofrete) {

    var tempIFrame=document.createElement('iframe');
	tempIFrame.setAttribute('id','iframe_cep');
	tempIFrame.setAttribute('name','iframe_cep');

	tempIFrame.style.border			= '0px';
	tempIFrame.style.width			= '0px';
	tempIFrame.style.height			= '0px';

	tempIFrame.setAttribute('src','cep_frete.asp?pais='+pais+'&cep='+cep+'&pesofrete='+pesofrete);
	IFrameObj = document.body.appendChild(tempIFrame);
}

//###################################################################################
function valida_pesquisar_cep() {

    // pais
    var DROPpais = document.frm.paises;
    var pais = DROPpais.options[DROPpais.selectedIndex].value;

    // cep
    var format_cep = document.frm.cep.value.replace("-", "");
	
    if (pais == 'BR') {
        if (format_cep.length == 8){
            executar_pesquisar_cep();
        } else {
            alert(ValPesqCepALERTcepinvalido);
            document.frm.cep.focus();
        }
    } else {
        executar_pesquisar_cep();
    }

}

//###################################################################################
function executar_pesquisar_cep() {
	// pais
    var DROPpais = document.frm.paises;
    var pais = DROPpais.options[DROPpais.selectedIndex].value;
    document.frmEditContact.pais_frete.value = pais;

    // cep
    var cep = document.frm.cep.value.replace("-", "");

    //peso
    var peso = document.frm.pesofrete.value;
    
    pesquisar_cep(pais,cep,peso);
}

//###################################################################################
function send_frete(string) {

 var vfrete = string.split('#');
 
 SndFrtALERTopcaofreteTMP = SndFrtALERTopcaofrete.replace("varOpcaoFrete", ""+vfrete[0])+"";
 SndFrtALERTopcaofreteTMP = SndFrtALERTopcaofreteTMP.replace("varValorFrete", ""+vfrete[1])+"";
 
 var conf_frete = confirm(SndFrtALERTopcaofreteTMP)
 
 if (conf_frete==true) {
   document.frmEditContact.opcao_frete.value = vfrete[0];
   document.frmEditContact.frete.value = vfrete[2];
   document.frmEditContact.cep_frete.value = vfrete[3];
   document.frmEditContact.submit();
 }
}

//###################################################################################
function handleResponse(informacoes) {

    /////////////////////
    var tbl = document.getElementById('freteTable'); 
    var lastRow = tbl.rows.length; 
    if (lastRow > 0) tbl.deleteRow(lastRow - 1);

    if (informacoes != 0) {
	
        var verify_informacoes = informacoes.indexOf("#");

        if (verify_informacoes>=0) {
		
            var CEP = document.frm.cep.value;
            var textoCEP = document.frm.textocep.value;
        
            var x=document.getElementById('freteTable').insertRow(0);
            var y=x.insertCell(0);
            y.innerHTML="<table id='"+ CEP +"' border='0' width='100%' cellpadding='0' cellspacing='2'></table>";

            /////////////////////

            var array_informacoes = informacoes.split("#");

            var x=document.getElementById(CEP).insertRow(0);
            var y=x.insertCell(0);
            x.height="25"
            x.bgColor="#FEE247"
            y.innerHTML='<b>&nbsp;&nbsp;&nbsp;' + textoCEP + " " + CEP + ':</b>' ;

            var part_num=0;
            var count = 0;
            var mod = 0;
            var color;

            while (part_num < array_informacoes.length) {
                
                if (mod==0) {
                    mod = 1;
                    color = '#FFFFFF';
                } else {
                    mod = 0;
                    color = '#F5F5F5';
                }
                
                var array_frete = array_informacoes[part_num].split(":");
                
                if (array_frete[2] != "ok") {
                    // Insere o option na tabela
                    var nRows=document.getElementById(CEP).rows.length
                    var x=document.getElementById(CEP).insertRow(nRows)
                    var y=x.insertCell(0)
                    y.innerHTML= array_frete[0] + ": " + array_frete[2] 
                    count+=1;
                } else {
                    
                    if (array_frete[1] != "vazio") {
                        //Trata o valor do frete conforme a moeda utilizada
                        var verify_vlrFRETE = array_frete[1].indexOf("|");
                        if (verify_vlrFRETE>=0) {
                            var vlrFRETE = array_frete[1].split("|");
                            var vlrFRETE_REAL = vlrFRETE[0];
                            var vlrFRETE_VIS = vlrFRETE[1];
                        } else {
                            var vlrFRETE_REAL = array_frete[1];
                            var vlrFRETE_VIS = array_frete[1];
                        }
                        // Insere o option na tabela
		                var x=document.getElementById(CEP).insertRow(1)
		                var y=x.insertCell(0)
                        x.height="10"
                        x.bgColor=color
                        y.innerHTML="<input type='radio' name='opcao' value='"+ array_frete[0] + "#" + vlrFRETE_VIS + "#" + vlrFRETE_REAL + "#" + CEP + "' onclick='send_frete(this.value);'>" + array_frete[0] + " ( " + vlrFRETE_VIS + " )"
   		                count+=1;
                    }
                
                }
                part_num+=1;
            }
            
            if (count == 0) {
                var x=document.getElementById('freteTable').insertRow(0)
                var y=x.insertCell(0)
                y.innerHTML=HndRespALERTsemfrete
            }
            
            enable_form();
        
        } else {
            
            var vfrete = informacoes.split(":");

            if (vfrete[2] != "ok") {
                
                var CEP = document.frm.cep.value;
                var textoCEP = document.frm.textocep.value;
            
                var x=document.getElementById('freteTable').insertRow(0);
                var y=x.insertCell(0);
                y.innerHTML="<table id='"+ CEP +"' border='0' width='100%' cellpadding='0' cellspacing='2'></table>";

                var x=document.getElementById(CEP).insertRow(0);
                var y=x.insertCell(0);
                x.height="25"
                x.bgColor="#FEE247"
                y.innerHTML='<b>&nbsp;&nbsp;&nbsp;' + textoCEP + " " + CEP + ':</b>' ;
                
                // Insere o option na tabela
                var x=document.getElementById(CEP).insertRow(1)
                var y=x.insertCell(0)
                y.innerHTML= vfrete[0] + ": " + vfrete[2] 
                count+=1;
            
            } else {

                //Trata o valor do frete conforme a moeda utilizada
                var verify_vlrFRETE = vfrete[1].indexOf("|");
                
                if (verify_vlrFRETE>=0) {
                    var vlrFRETE = vfrete[1].split("|");
                    var vlrFRETE_REAL = vlrFRETE[0];
                    var vlrFRETE_VIS = vlrFRETE[1];
                } else {
                    var vlrFRETE_REAL = vfrete[1];
                    var vlrFRETE_VIS = vfrete[1];
                }
                
                document.frmEditContact.opcao_frete.value = vfrete[0];
                document.frmEditContact.frete.value = vlrFRETE_REAL;
                document.frmEditContact.cep_frete.value = document.frm.cep.value;
                document.frmEditContact.submit();
	        
            }
        }
    
    } else {
        disable_form();
        document.frm.cep.disabled = false;
        var x=document.getElementById('freteTable').insertRow(0)
		var y=x.insertCell(0)
		y.innerHTML=HndRespALERTsemfrete
    }

}

//###################################################################################
/*VERIFICA*/
function cadastro_cep_verificar(cep){
	if (!alterado_cep)	{
		alterado_cep = true;
		document.all.cep.focus();
		document.all.numero.value = '';
		document.all.complemento.value = '';
	}
}

//###################################################################################
function check_meiopag(opcaopag){
	var fr = document.OpcaoPag;
	for(a=0;a<fr.elements.length;a++){
		if(fr.elements[a].value == opcaopag){
			fr.elements[a].checked = true;
		}
	}
}



//# FUNCOES LOJA

//###################################################################################
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
    var keyCode = (isNN) ? e.which : e.keyCode; 
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
    if(input.value.length >= len && !containsElement(filter,keyCode)) {
        input.value = input.value.slice(0, len);
        input.form[(getIndex(input)+1) % input.form.length].focus();
}

function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
        if(arr[index] == ele)
            found = true;
        else
            index++;
        return found;
    }

function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
        if (input.form[i] == input)index = i;
        else i++;
        return index;
    }
return true;
}

//###################################################################################
function remover_produto(nome) {
	eval("document.carrinho."+nome+".value = 0");  // estamos zerando o carrinho.
	document.carrinho.submit ();
}

//###################################################################################
function atualizar_carrinho() {
	var resposta, Form;
	Form = document.carrinho;
	resposta = true;
	if (Form.tipofrete.value == "SEDEX" && (Form.cep1.value.length != 0 || Form.cep2.value.length != 0)) {
		resposta = valida_cep();
	}
	if (resposta == true)
		document.carrinho.submit ();
}

//###################################################################################
function calcular_frete() {
	var resposta;
	resposta = valida_cep();
	if (resposta == true)
		document.carrinho.submit ();
}

//###################################################################################
function mostra_calculo_frete() {
	var Form;
	Form = document.pagamento;
	janela = window.open('calculo_frete.asp?valor=' + Form.subtotal.value + '&frete=' + Form.taxa_envio.value + '&cepdestino=' + Form.cep.value + '&peso=' + Form.peso.value + '&tipo_sedex=' + Form.tipo_sedex.value,'promocao','width=600,height=250,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes')
	if (janela != null) {
		janela.location.href ='calculo_frete.asp?valor=' + Form.subtotal.value + '&frete=' + Form.taxa_envio.value + '&cepdestino=' + Form.cep.value + '&peso=' + Form.peso.value + '&tipo_sedex=' + Form.tipo_sedex.value
	}
}

//###################################################################################
function metodo_pagamento(nome) { 
	var carteira, i, sel, num_pag, temp, metodo_pag, ssl, acao;
	var Form;
	Form = document.carrinho;
	num_pag = document.pagamento.num_pagamentos.value;
	
	if (document.pagamento.tipo.value == false) {
		alert(MtdPagALERTselpag);
		return false;
	} 

	if (document.pagamento.taxa_envio.value == 0 && !document.carrinho.frete_teste) {
		alert(MtdPagALERTcalcfrete);
		return false;
	} else { 
		if (num_pag == "1") {
			temp = document.pagamento.tipo.value;
			acao = document.pagamento.URL_Autentica.value + "?acao=login" + "&forma_pagamento=" + metodo_pag;
			eval("document.pagamento.action='" + acao + "'");
			document.pagamento.submit();
		} else {
			for (i=0; i<num_pag; i++) {
				if (document.pagamento.tipo.value == true) {
					sel = i;
				break;
				}
			}
			temp = document.pagamento.tipo.value;
		}
		// VISA1
		// VISA - VisaNet, 1 - com SSL

		metodo_pag = temp.substring(0,temp.length-1);

		if (metodo_pag == "AMEX" || metodo_pag == "AMEXPOS"|| metodo_pag == "REDECARD" || metodo_pag == "RCARDPOS"|| metodo_pag == "VISA" || metodo_pag == "VISAPOS") metodo_pag = "CARTAO"; 
			ssl = temp.substring(temp.length-1,temp.length);
	
		if (ssl == "0") {
			acao = document.pagamento.URL_Autentica.value + "?acao=login" + "&forma_pagamento=" + metodo_pag;
		} else {
			acao = document.pagamento.URL_Autentica_seguro.value + "?acao=login" + "&forma_pagamento=" + metodo_pag;
		}

		if (metodo_pag == "CARTAO") {
			acao = acao + "&cartao=" + temp.substring(0,temp.length-1);
		}

		eval("document.pagamento.action='" + acao + "'");

		document.pagamento.submit();
	}
}

//###################################################################################
function valida_busca() {

	Form = document.busca;
	
    if (Form.produto.value.length == 0) {
		alert(VldBuscaALERTcampobusca);
		Form.produto.focus();
		return false;
	}

    if (Form.produto.value.length < 3) {
		alert(VldBuscaALERTminbusca);
		Form.produto.focus();
		return false;
	}

    if (!Form.codigo_categoria) {
        alert(VldBuscaALERTexistecatbusca);
        return false;
    }
	
    if (Form.codigo_categoria.value == '') {
		alert(VldBuscaALERTcatbusca);
		Form.codigo_categoria.focus();
		return false;
	}
}


//###################################################################################
function valida_cep() {

	Form = document.carrinho;
	if (Form.cep1.value.length == 0) {
		alert(VldCepALERTcampocep);
		Form.cep1.focus();
		return false;
	}
	if (Form.cep2.value.length == 0) {
		alert(VldCepALERTcampocep);
		Form.cep2.focus();
		return false;
	}
	s = limpa_string(Form.cep1.value);
	if (s.length != 5) {
		alert(VldCepALERTcaractcep);
		Form.cep1.focus();
		return false;
	}
	s = limpa_string(Form.cep2.value);
	if (s.length != 3) {
		alert(VldCepALERTcaractcep);
		Form.cep2.focus();
		return false;
	}
	return true;
}

//###################################################################################
function limpa_string(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	for (var i=0; i<S.length; i++){
		digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0){temp=temp+digito}
	}
	return temp
}

//###################################################################################
function mostra_cep() {
	Form = document.carrinho;
	if ( (Form.cep1.value.length == 5) && (checatab) ) { 
		Form.cep2.focus();
		checatab=false;
	} 
}

//###################################################################################
function semtab() { checatab=false; }
function comtab() { checatab=true; } 
checatab=true;
        
//###################################################################################
function menu_goto( menuform ) {
	selecteditem = menuform.local_frete_Exporta.selectedIndex ;
	local_frete_Exporta = menuform.local_frete_Exporta.options[ selecteditem ].value ;
	if (local_frete_Exporta.length != 0) {
		location.href = local_frete_Exporta ;
	}
}

//###################################################################################
function valida_cadastro(formname,tipoverif,cep_frete) {

	var Form;
	Form = formname;

	if (cep_frete == 'SEM FRETE') {
        if (tipoverif == 'CadPedido') {
            if ((valida_endereco(Form,'CadPedido') == false) || (valida_password(Form) == false)) {
                return false;
            }
        } else if (tipoverif == 'CadUsuario') {
            if (valida_endereco(Form,'CadUsuario') == false) {
                return false;
            }
        }
	} else {
        if ((valida_endereco(Form,'CadPedido') == false) || (valida_password(Form) == false) || (verifica_cep(cep_frete) == false)) {
            return false;
        }
    }

}

//###################################################################################
function valida_password(Form) {

	if (Form.tipo_login.value == "user_new") {
		if (Form.senha1.value.length == 0 || Form.senha2.value.length == 0) {
			alert(VldPwdALERTcamposenha);
			Form.senha1.focus();
			return false;
		}
		if (Form.senha1.value != Form.senha2.value) {
			alert(VldPwdALERTsenhadif);
			Form.senha1.focus();
			return false;
		}
	}

}

//###################################################################################
function valida_trocapassword(Form) {

	if (Form.senha_atual.value.length == 0) {
		alert(VldTrocaPwdALERTcamposenhaatual);
		Form.senha_atual.focus();
		return false;
	}
	if (Form.nova_senha.value.length == 0 || Form.confirma_senha.value.length == 0) {
		alert(VldTrocaPwdALERTcamposenha);
		Form.nova_senha.focus();
		return false;
	}
	if (Form.nova_senha.value != Form.confirma_senha.value) {
		alert(VldTrocaPwdALERTsenhadif);
		Form.nova_senha.focus();
		return false;
	}

}

//###################################################################################
function valida_faleconosco(Form) {

	if (Form.nome.value.length == 0) {
		alert(VldFaleConALERTcmpnome);
		Form.nome.focus();
		return false;
	}

    if (Form.email.value.length == 0) {
        alert(VldFaleConALERTcmpemail);
        Form.email.focus();
        return false;
    }

    if (Form.email.value.indexOf('@', 0) == -1 || Form.email.value.indexOf('.', 0) == -1) {
        alert(VldFaleConALERTcmpemailinc); 
        Form.email.focus();
        return false;
    }

    if (Form.assunto.value.length == 0) {
		alert(VldFaleConALERTcmpassunto);
		Form.assunto.focus();
		return false;
	}

    if (Form.comentarios.value.length == 0) {
		alert(VldFaleConALERTcmpcomentario);
		Form.comentarios.focus();
		return false;
	}

    return true;

}

//###################################################################################
function valida_newsletter(Form) {

	if (Form.nome.value.length == 0) {
		alert(VldNewsALERTcmpnome);
		Form.nome.focus();
		return false;
	}

    if (Form.email.value.length == 0) {
        alert(VldNewsALERTcmpemail);
        Form.email.focus();
        return false;
    }

    if (Form.email.value.indexOf('@', 0) == -1 || Form.email.value.indexOf('.', 0) == -1) {
        alert(VldNewsALERTcmpemailinc); 
        Form.email.focus();
        return false;
    }

    return true;

}

//###################################################################################
function valida_endereco(Form,tipoverif) {

	var s;

	if ((Form.tipcliente[0].checked==false) && (Form.tipcliente[1].checked==false)) {
		alert(VldEndALERTcmpfisjur);
        return false;
	}

    //Dados Cobrança
    if (valida_dadosCobranca(Form) == false) {
        return false;
    }

    //Confirma o tipo de verificação
	if (tipoverif == 'CadPedido') {
        // Dados Entrega
        if (Form.cobranca_diferente.checked==true) {
            if (valida_dadosEntrega(Form) == false) {
                return false;
            }
        }
    } else if (tipoverif == 'CadUsuario') {
        // Dados Entrega
        if (valida_dadosEntrega(Form) == false) {
            return false;
        }
    }

}

//###################################################################################
function valida_dadosCobranca(Form) {

    var s;

	if (Form.tipcliente[1].checked==true) {

		if (Form.razaosocial_cobranca.value.length == 0) {
			alert(VldEndALERTcmprazaosocial);
			Form.razaosocial_cobranca.focus();
			return false;
		}

        if (Form.pais_cobranca.options[Form.pais_cobranca.selectedIndex].value == "BR") {
            
            var cnpj_cob = Form.cnpj_cobranca_b1.value + Form.cnpj_cobranca_b2.value + Form.cnpj_cobranca_b3.value + Form.cnpj_cobranca_b4.value + Form.cnpj_cobranca_b5.value;

            if (cnpj_cob.length == 0) {
                alert(VldEndALERTcmpcnpj);
                Form.cnpj_cobranca_b1.focus();
                return false;
            }
             
            s = limpa_string(cnpj_cob);
            if (s.length == 14) {
                if (valida_CNPJ(cnpj_cob) == false ) {
                    alert(VldEndALERTcmpcnpjinc);
                    Form.cnpj_cobranca_b1.focus();
                    return false;
                }
            }else{
                alert(VldEndALERTcmpcnpjinc);
                Form.cnpj_cobranca_b1.focus();
                return false;
            }

            Form.cnpj_cobranca.value = cnpj_cob;

        }

	}

	if (Form.nome_cobranca.value.length == 0) {
		alert(VldEndALERTcmpnome);
        Form.nome_cobranca.focus();
        return false;
	}

    if (Form.pais_cobranca.options[Form.pais_cobranca.selectedIndex].value == "BR") {
        
        var cpf_cob = Form.cpf_cobranca_b1.value + Form.cpf_cobranca_b2.value + Form.cpf_cobranca_b3.value + Form.cpf_cobranca_b4.value;
        
        if (cpf_cob.length == 0) {
            alert(VldEndALERTcmpcpf);
            Form.cpf_cobranca_b1.focus();
            return false;
        }

        s = limpa_string(cpf_cob);
        if (s.length == 11) {
            if (valida_CPF(cpf_cob) == false ) {
                alert(VldEndALERTcmpcpfinc);
                Form.cpf_cobranca_b1.focus();
                return false;
            }
        }else{
            alert(VldEndALERTcmpcpfinc);
            Form.cpf_cobranca_b1.focus();
            return false;
        }

        Form.cpf_cobranca.value = cpf_cob;

        if (Form.rg_cobranca.value.length == 0) {
            alert(VldEndALERTcmprg);
            Form.rg_cobranca.focus();
            return false;
        }
    
    }
	
    if (Form.logradouro_cobranca.value.length == 0) {
		alert(VldEndALERTcmpend);
		Form.logradouro_cobranca.focus();
		return false;
	}
     
	if (Form.numero_cobranca.value.length == 0) {
		alert(VldEndALERTcmpnum);
		Form.numero_cobranca.focus();
		return false;
	}
     
    if (Form.pais_cobranca.options[Form.pais_cobranca.selectedIndex].value == "BR") {

        var cep_cob = Form.cep_cobranca_b1[0].value + Form.cep_cobranca_b2.value;

        if (cep_cob.length == 0) {
            alert(VldEndALERTcmpcep);
            Form.cep_cobranca_b1[0].focus();
            return false;
        }
         
        s = limpa_string(cep_cob);
        if (s.length != 8) {
            alert(VldEndALERTcmptamcep);
            Form.cep_cobranca_b1[0].focus();
            return false;
        }

        Form.cep_cobranca.value = cep_cob;
     
	} else {
        Form.cep_cobranca.value = Form.cep_cobranca_b1[1].value;
    }

    if (Form.cidade_cobranca.value.length == 0) {
		alert(VldEndALERTcmpcidade);
		Form.cidade_cobranca.focus();
		return false;
	}

	if (Form.pais_cobranca.options[Form.pais_cobranca.selectedIndex].value == "BR") {
        if (Form.ddd_cobranca.value.length == 0) {
            alert(VldEndALERTcmpddd);
            Form.ddd_cobranca.focus();
            return false;
        }
    }

	if (Form.telefone_cobranca.value.length == 0) {
		alert(VldEndALERTcmptel);
		Form.telefone_cobranca.focus();
		return false;
	}

    Form.data_nascimento_cobranca.value = Form.data_nascimento_cobranca_b1.value + Form.data_nascimento_cobranca_b2.value + Form.data_nascimento_cobranca_b3.value;

}

//###################################################################################
function valida_dadosEntrega(Form) {
    
	var s;

    if (Form.tipcliente[1].checked==true) {

        if (Form.razaosocial_entrega.value.length == 0) {
            alert(VldEndALERTcmprazaosocial);
            Form.razaosocial_entrega.focus();
            return false;
        }

        if (Form.pais_entrega.options[Form.pais_entrega.selectedIndex].value == "BR") {
            
            var cnpj_ent = Form.cnpj_entrega_b1.value + Form.cnpj_entrega_b2.value + Form.cnpj_entrega_b3.value + Form.cnpj_entrega_b4.value + Form.cnpj_entrega_b5.value;

            if (cnpj_ent.length == 0) {
                alert(VldEndALERTcmpcnpj);
                Form.cnpj_entrega_b1.focus();
                return false;
            }
             
            s = limpa_string(cnpj_ent);
            if (s.length == 14) {
                if (valida_CNPJ(cnpj_ent) == false ) {
                    alert(VldEndALERTcmpcnpjinc);
                    Form.cnpj_entrega_b1.focus();
                    return false;
                }
            }else{
                alert(VldEndALERTcmpcnpjinc);
                Form.cnpj_entrega_b1.focus();
                return false;
            }

            Form.cnpj_entrega.value = cnpj_ent;

        }

    }

    if (Form.nome_entrega.value.length == 0) {
        alert(VldEndALERTcmpnome);
        Form.nome_entrega.focus();
        return false;
    }

    if (Form.pais_entrega.options[Form.pais_entrega.selectedIndex].value == "BR") {

        var cpf_ent = Form.cpf_entrega_b1.value + Form.cpf_entrega_b2.value + Form.cpf_entrega_b3.value + Form.cpf_entrega_b4.value;

        if (cpf_ent.length == 0) {
            alert(VldEndALERTcmpcpf);
            Form.cpf_entrega_b1.focus();
            return false;
        }

        s = limpa_string(cpf_ent);
        if (s.length == 11) {
            if (valida_CPF(cpf_ent) == false ) {
                alert(VldEndALERTcmpcpfinc);
                Form.cpf_entrega_b1.focus();
                return false;
            }
        }else{
            alert(VldEndALERTcmpcpfinc);
            Form.cpf_entrega_b1.focus();
            return false;
        }

        Form.cpf_entrega.value = cpf_ent;

        if (Form.rg_entrega.value.length == 0) {
            alert(VldEndALERTcmprg);
            Form.rg_entrega.focus();
            return false;
        }

    }

    if (Form.logradouro_entrega.value.length == 0) {
        alert(VldEndALERTcmpend);
        Form.logradouro_entrega.focus();
        return false;
    }

    if (Form.numero_entrega.value.length == 0) {
        alert(VldEndALERTcmpnum);
        Form.numero_entrega.focus();
        return false;
    }

    if (Form.pais_entrega.options[Form.pais_entrega.selectedIndex].value == "BR") {

        var cep_ent = Form.cep_entrega_b1[0].value + Form.cep_entrega_b2.value;

        if (cep_ent.length == 0) {
            alert(VldEndALERTcmpcep);
            Form.cep_entrega_b1[0].focus();
            return false;
        }

        s = limpa_string(cep_ent);
        if (s.length != 8) {
            alert(VldEndALERTcmptamcep);
            Form.cep_entrega_b1[0].focus();
            return false;
        }
        
        Form.cep_entrega.value = cep_ent;

    } else {
        Form.cep_entrega.value = Form.cep_entrega_b1[1].value;
    }

    if (Form.cidade_entrega.value.length == 0) {
        alert(VldEndALERTcmpcidade);
        Form.cidade_entrega.focus();
        return false;
    }

    if (Form.telefone_entrega.value.length == 0) {
        alert(VldEndALERTcmptel);
        Form.telefone_entrega.focus();
        return false;
    }

    if (Form.pais_entrega.options[Form.pais_entrega.selectedIndex].value == "BR") {
        if (Form.ddd_entrega.value.length == 0) {
            alert(VldEndALERTcmpddd);
            Form.ddd_entrega.focus();
            return false;
        }
    }

    if (Form.email_entrega.value.length == 0) {
        alert(VldEndALERTcmpemail);
        Form.email_entrega.focus();
        return false;
    }

    if (Form.email_entrega.value.indexOf('@', 0) == -1 || Form.email_entrega.value.indexOf('.', 0) == -1) {
        alert(VldEndALERTcmpemailinc); 
        Form.email_entrega.focus();
        return false;
    }

    Form.data_nascimento_entrega.value = Form.data_nascimento_entrega_b1.value + Form.data_nascimento_entrega_b2.value + Form.data_nascimento_entrega_b3.value;

}

//###################################################################################
function valida_visa() {
	if (valida_endereco() == true) {
		document.Endereco.submit();
	}
	else return;
}

//###################################################################################
function valida_CPF(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
        if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}

//###################################################################################
function valida_CNPJ(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);
	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
        if (d1 == 0) return false;
        d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}

	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
        return true;
}

//###################################################################################
function valida_numeros(s)
{
	var i; 
	var dif = 0;
	for (i = 0; i < s.length; i++)
	{
		var c = s.charAt(i);
		if (!((c >= "0") && (c <= "9")))
		{
			dif = 1;
		}
	}
	if (dif == 1)
	{
		return false;
	}
	return true;
}

//###################################################################################
function copia_entrega(){
	var n='';
	var v='';
	var s='';
	var i=0;
	var form=document.Endereco;
	var x=form.length-1;
	if(form.cobranca_igual.checked){
		for(var y = 0; y <= x; y++){
			n=form.elements[y].name;			
			if(n.substring(0,2)=='b_'){
				s=n.substring(2,n.length);
				if(form.elements[s].type == "select-one"){					
					i=form.elements[s].selectedIndex;
					form.elements[n].selectedIndex=i;
				}
				else{
					
					v=form.elements[s].value;
					form.elements[n].value=v;
				}
			}
		}
	}
}

//###################################################################################
function mostraDados(pri) {
  var element = document.getElementById(pri);

  if (element.style.display=='none') {
   element.style.display='';
  } else {
   element.style.display='none'
  }

}

//###################################################################################
function reenvio_pwd() {
   var fr = document.autent;

   if (fr.esquecisenha.checked == true) {
      fr.senha.disabled = true;
      fr.senha.value = '';
      fr.enviar.value = RnvPwdALERTreenvsenha;
   } else {
      fr.senha.disabled = false;
      fr.enviar.value = RnvPwdALERTautentusuario;
   }
}

//###################################################################################
function check_login() {
   var fr = document.autent;

   if (fr.user_id.value.length == 0) {
      alert(CkLoginALERTcmpemail);
      fr.user_id.focus();
      return false;
   }

   if (fr.user_id.value.indexOf('@', 0) == -1 || fr.user_id.value.indexOf('.', 0) == -1) {
      alert(CkLoginALERTcmpemailinc); 
      fr.user_id.focus();
      return false;
   }

   if (fr.esquecisenha.checked == false) {
      if (fr.senha.value.length == 0) {
         alert(CkLoginALERTcmpsenha);
         fr.senha.focus();
         return false;
      }
   }
   return true;
}

//###################################################################################
function check_newlogin() {
   var fr = document.new_user;

   if (fr.user_id.value.length == 0) {
      alert(CkNwLoginALERTcmpemail);
      fr.user_id.focus();
      return false;
   }

   if (fr.user_id.value.indexOf('@', 0) == -1 || fr.user_id.value.indexOf('.', 0) == -1) {
      alert(CkNwLoginALERTcmpemailinc); 
      fr.user_id.focus();
      return false;
   }
   return true;
}

//###################################################################################
function alteraTipCad() {
    
    var tipCadTextCob = document.getElementById('tipCadTextJuridico_cobranca');
    var tipCadInputCob = document.getElementById('tipCadInputJuridico_cobranca');
    var tipCadTextEnt = document.getElementById('tipCadTextJuridico_entrega');
    var tipCadInputEnt = document.getElementById('tipCadInputJuridico_entrega');
    var tipCadTextCob2 = document.getElementById('tipCadTextJuridico2_cobranca');
    var tipCadInputCob2 = document.getElementById('tipCadInputJuridico2_cobranca');
    var tipCadTextEnt2 = document.getElementById('tipCadTextJuridico2_entrega');
    var tipCadInputEnt2 = document.getElementById('tipCadInputJuridico2_entrega');
    
    if (document.Endereco.tipcliente[0].checked == true) {
        tipCadTextCob.style.display='none';
        tipCadInputCob.style.display='none';
        tipCadTextEnt.style.display='none';
        tipCadInputEnt.style.display='none';
        tipCadTextCob2.style.display='none';
        tipCadInputCob2.style.display='none';
        tipCadTextEnt2.style.display='none';
        tipCadInputEnt2.style.display='none';
        document.getElementsByName('razaosocial_cobranca')[0].value ='';
        document.getElementsByName('cnpj_cobranca_b1')[0].value ='';
        document.getElementsByName('cnpj_cobranca_b2')[0].value ='';
        document.getElementsByName('cnpj_cobranca_b3')[0].value ='';
        document.getElementsByName('cnpj_cobranca_b4')[0].value ='';
        document.getElementsByName('cnpj_cobranca_b5')[0].value ='';
        document.getElementsByName('inscricaoestadual_cobranca')[0].value ='';
        document.getElementsByName('razaosocial_entrega')[0].value ='';
        document.getElementsByName('cnpj_entrega_b1')[0].value ='';
        document.getElementsByName('cnpj_entrega_b2')[0].value ='';
        document.getElementsByName('cnpj_entrega_b3')[0].value ='';
        document.getElementsByName('cnpj_entrega_b4')[0].value ='';
        document.getElementsByName('cnpj_entrega_b5')[0].value ='';
        document.getElementsByName('inscricaoestadual_entrega')[0].value ='';
    } else {
        tipCadTextCob.style.display='';
        tipCadInputCob.style.display='';
        tipCadTextEnt.style.display='';
        tipCadInputEnt.style.display='';
        tipCadTextCob2.style.display='';
        tipCadInputCob2.style.display='';
        tipCadTextEnt2.style.display='';
        tipCadInputEnt2.style.display='';
    } 

}

//###################################################################################
function checkTipCad(tipoEnd) {
    
    var verificacao;
    
    if (document.getElementsByName('razaosocial_'+tipoEnd)[0].value != '') {
        verificacao = true;
    } else {
        verificacao = false;
    }

    var tipCadText = document.getElementById('tipCadTextJuridico_'+tipoEnd);
    var tipCadInput = document.getElementById('tipCadInputJuridico_'+tipoEnd);
    var tipCadText2 = document.getElementById('tipCadTextJuridico2_'+tipoEnd);
    var tipCadInput2 = document.getElementById('tipCadInputJuridico2_'+tipoEnd);
    
    if (verificacao == false) {
        tipCadText.style.display='none';
        tipCadInput.style.display='none';
        tipCadText2.style.display='none';
        tipCadInput2.style.display='none';
        document.getElementsByName('razaosocial_'+tipoEnd)[0].value ='';
        document.getElementsByName('cnpj_'+tipoEnd+'_b1')[0].value ='';
        document.getElementsByName('cnpj_'+tipoEnd+'_b2')[0].value ='';
        document.getElementsByName('cnpj_'+tipoEnd+'_b3')[0].value ='';
        document.getElementsByName('cnpj_'+tipoEnd+'_b4')[0].value ='';
        document.getElementsByName('cnpj_'+tipoEnd+'_b5')[0].value ='';
        document.getElementsByName('inscricaoestadual_'+tipoEnd)[0].value ='';
    } else {
        tipCadText.style.display='';
        tipCadInput.style.display='';
        tipCadText2.style.display='';
        tipCadInput2.style.display='';
    } 

}

//###################################################################################
function verifica_cep(cep_frete){
    if (document.Endereco.tipo_acesso.value != "conta"){
        if (document.Endereco.cobranca_diferente.checked == true){
            if (cep_frete != document.Endereco.cep_entrega.value) {
                resposta = confirm(VrfCepALERTcepentdif);
                if (resposta == false) {
                    return false;
                } else {
                    document.Endereco.mode.value='changeItem';
                    document.Endereco.cep_frete.value=document.Endereco.cep_entrega.value;
                    document.Endereco.submit();
                    return false;
                }
            }
        } else {
            if (cep_frete != document.Endereco.cep_cobranca.value) {
                resposta = confirm(VrfCepALERTcepentcobdif);
                if (resposta == false) {
                    return false;
                } else {
                    document.Endereco.mode.value='changeItem';
                    document.Endereco.cep_frete.value=document.Endereco.cep_cobranca.value;
                    document.Endereco.submit();
                    return false;
                }
            }
        }
    }
}

//###################################################################################
function pagamento() {
	vpos=window.open('','vpos','toolbar=yes,menubar=yes,resizable=yes,status=no,scrollbars=yes,width=600,height=400');
	document.pagamento.submit();
}

//###################################################################################
function JanelaNova(URLBoleto) {
	window.open(URLBoleto,'NOME','width=680,height=400,menubar,scrollbars,resizable');
}

//###################################################################################
function Start(VarForm,x,y) {
	vpos = window.open('','vpos','toolbar=no,menubar=no,resizable=yes,status=no,scrollbars=yes,width='+ x +',height='+ y +'');
	document.abnfinanc.submit();
}

//###################################################################################
function submit_bradesco(metodo_pag) {
	Form = document.Confirmacao;

	if (metodo_pag == "cc") {
		eval("Form.action='inicia_transacao.asp?metodo_pag=CC'");
	} else if (metodo_pag == "transfer") {
		eval("Form.action='inicia_transacao.asp?metodo_pag=TRANSFER'");                
	} else if (metodo_pag == "financiamento") {
		eval("Form.action='inicia_transacao.asp?metodo_pag=FINANCIAMENTO'");                
	}
	document.Confirmacao.submit();
}

//###################################################################################
// formata data
function formata_data(formato, keypress, objeto) {
    campo = eval (objeto);

    if (formato=='DATA'){ 
        separador = '/'; 
        conjunto1 = 2; 
        conjunto2 = 5;
    }

    if (campo.value.length == conjunto1){ 
        campo.value = campo.value + separador; 
    }

    if (campo.value.length == conjunto2){ 
        campo.value = campo.value + separador; 
    } 

}

//###################################################################################
function PopUp(theURL,winName,features) 
{
window.open(theURL,winName,features); 
}

//###################################################################################
function check_opcaopag() 
	{
	var fr = document.OpcaoPag;
	var check = false;
	for(a=0;a<fr.elements.length;a++){
		if(fr.elements[a].name == 'tipo'){
			if (fr.elements[a].checked == true) {
				check = true;
				break;
			}
		}
	}
	if (check == false) {
	alert(CkOpPagALERTselpag);
	} else {
	fr.submit();
	}
}

//###################################################################################
function valida_VisaMoset(Form) {

	if (Form.ccn.value.length == 0) {
		alert(VldMosetALERTcmpnumcartao);
		Form.ccn.focus();
		return false;
	}

    if (Form.email.value.length == 0) {
        alert(VldMosetALERTcmpemail);
        Form.email.focus();
        return false;
    }

    if (Form.email.value.indexOf('@', 0) == -1 || Form.email.value.indexOf('.', 0) == -1) {
        alert(VldMosetALERTcmpemailinc); 
        Form.email.focus();
        return false;
    }

    if (Form.assunto.value.length == 0) {
		alert(VldMosetALERTcmpassunto);
		Form.assunto.focus();
		return false;
	}

    if (Form.comentarios.value.length == 0) {
		alert(VldMosetALERTcmpcomentario);
		Form.comentarios.focus();
		return false;
	}

    return true;

}

//###################################################################################
function fncLimpaValue(objTexto, sString)

	{

	if (sString == objTexto.value) {

		objTexto.value = '';
	}

}

//###################################################################################
function fncPreencheValue(objTexto, sString)

	{

	if (objTexto.value == '') {

		objTexto.value = sString;

	}

}
//###################################################################################
function atualiza_carrinho(tip) {
    var fr = document.frmEditContact;
    var qte_elements = 0;
    var liberado = true;
    var qte_escolhida, qte_atual, qte_maxima;
    var qte_diferenca;

    for (a=0;a<fr.elements.length;a++) {

        if(fr.elements[a].name == 'quantidade_produto') {
            qte_elements = qte_elements + 1;
        }
        
    }

    qte_elements = (qte_elements - 1);

    if (qte_elements>=1) {

        for (i=0;i<=qte_elements;i++) {
            
            qte_escolhida = fr.quantidade_produto[i].value;
            qte_atual = fr.quantidade_atual[i].value;
            qte_maxima = fr.quantidade_maxima[i].value

            qte_diferenca = qte_escolhida - qte_atual;
            var qte_tratada = String(qte_diferenca);
            
            if (qte_tratada.indexOf('-') == -1) {

                qte_tratada = Number(qte_tratada);

                if ((qte_tratada > qte_maxima) && (qte_maxima != 0)) {
                    alert(AtzCarALERTqtdestoque);
                    fr.quantidade_produto[i].focus();
                    liberado = false;
                    break;
                }

                if ((qte_escolhida > qte_maxima) && (qte_maxima == 0) && (qte_tratada != 0)) {
                    alert(AtzCarALERTqtdestoque);
                    fr.quantidade_produto[i].focus();
                    liberado = false;
                    break;
                }

            }

        }
    
    } else {
        qte_escolhida = fr.quantidade_produto.value;
        qte_atual = fr.quantidade_atual.value;
        qte_maxima = fr.quantidade_maxima.value

        qte_diferenca = qte_escolhida - qte_atual;
        var qte_tratada = String(qte_diferenca);
        
        if (qte_tratada.indexOf('-') == -1) {

            qte_tratada = Number(qte_tratada);

            if ((qte_tratada > qte_maxima) && (qte_maxima != 0)) {
                alert(AtzCarALERTqtdestoque);
                fr.quantidade_produto.focus();
                liberado = false;
            }

            if ((qte_escolhida > qte_maxima) && (qte_maxima == 0) && (qte_tratada != 0)) {
                alert(AtzCarALERTqtdestoque);
                fr.quantidade_produto.focus();
                liberado = false;
            }

        }
    }

    if (liberado == true) {
        if (tip == 'frete') {
            valida_pesquisar_cep();
        } else {
            fr.submit();
        }
    }
}

//###################################################################################
function valida_indique() {

    Form = document.indique;
	
    if (Form.Nome_AmigoIndicador.value.length == 0) {
        alert(VldIndALERTcmpnome);
        Form.Nome_AmigoIndicador.focus();
        return false;
    }

    if (Form.Email_AmigoIndicador.value.length == 0) {
		alert(VldIndALERTcmpemail);
		Form.Email_AmigoIndicador.focus();
		return false;
	}

    if (Form.Email_AmigoIndicador.value.indexOf('@', 0) == -1 || Form.Email_AmigoIndicador.value.indexOf('.', 0) == -1) {
        alert(VldIndALERTcmpemailinc); 
        Form.Email_AmigoIndicador.focus();
        return false;
    }

    if (Form.Nome_AmigoIndicado.value.length == 0) {
        alert(VldIndALERTcmpnome);
        Form.Nome_AmigoIndicado.focus();
        return false;
    }

    if (Form.Email_AmigoIndicado.value.length == 0) {
		alert(VldIndALERTcmpemail);
		Form.Email_AmigoIndicado.focus();
		return false;
	}
    
    if (Form.Email_AmigoIndicado.value.indexOf('@', 0) == -1 || Form.Email_AmigoIndicado.value.indexOf('.', 0) == -1) {
        alert(VldIndALERTcmpemailinc); 
        Form.Email_AmigoIndicado.focus();
        return false;
    }

    if (Form.comentario.value.length == 0) {
		alert(VldIndALERTcmpcomentario);
		Form.comentario.focus();
		return false;
	}

    return true;

}

//###################################################################################
function travaCepFrete(paises,cep) {

    cep.value = '';
    if (paises == 'BR') {
        cep.maxLength = "8";
	} else {
        cep.maxLength = "100";
    }

}
//###################################################################################
function ajustaCepFrete(paises,cep) {

    if (paises == 'BR') {
        cep.value = cep.value.replace(/[^\d]*/gi,"");
    }

}
//###################################################################################
function ajustaEstadoCadastro(Form,tipo) {

    var pais = document.getElementsByName('pais'+tipo)[0].options[document.getElementsByName('pais'+tipo)[0].selectedIndex].value;

    if (pais == 'BR') {
        document.getElementsByName('display_estado'+tipo)[0].style.display = '';
        document.getElementsByName('estado'+tipo)[0].disabled = false;
        document.getElementsByName('display_estado'+tipo)[1].style.display = 'none';
        document.getElementsByName('estado'+tipo)[1].disabled = true;
    } else {
        document.getElementsByName('display_estado'+tipo)[0].style.display = 'none';
        document.getElementsByName('estado'+tipo)[0].disabled = true;
        document.getElementsByName('display_estado'+tipo)[1].style.display = '';
        document.getElementsByName('estado'+tipo)[1].disabled = false;
    }

}
//###################################################################################
function ajustaCepCadastro(Form,tipo) {

    var pais = document.getElementsByName('pais'+tipo)[0].options[document.getElementsByName('pais'+tipo)[0].selectedIndex].value;

    if (pais == 'BR') {
        document.getElementsByName('display_cep'+tipo)[0].style.display = '';
        document.getElementsByName('cep'+tipo+'_b1')[0].disabled = false;
        document.getElementsByName('cep'+tipo+'_b2')[0].disabled = false;
        
        document.getElementsByName('display_cep'+tipo)[1].style.display = 'none';
        document.getElementsByName('cep'+tipo+'_b1')[1].disabled = true;
    } else {
        document.getElementsByName('display_cep'+tipo)[0].style.display = 'none';
        document.getElementsByName('cep'+tipo+'_b1')[0].disabled = true;
        document.getElementsByName('cep'+tipo+'_b2')[0].disabled = true;
        
        document.getElementsByName('display_cep'+tipo)[1].style.display = '';
        document.getElementsByName('cep'+tipo+'_b1')[1].disabled = false;
    }

}
//###################################################################################
function valida_dadosAdicionais()
{
	var liberado = true;

	for(a=0;a<document.frmEditContact.elements.length;a++){
        
		// Verifica a forma de pagamento utilizada
		if (document.frmEditContact.elements[a].name == 'forma_pagamento') {
			
			// Verifica se é Paggo para registrar os dados do celular
			if (document.frmEditContact.forma_pagamento.value == 'Paggo')
			{
				// Verifica se o ddd foi preenchido
				if (document.frmEditContact.ddd_celular.value.length == 0) {
					alert(VldDadosAdicALERTcmpddd);
					document.frmEditContact.ddd_celular.focus();
					liberado = false;
					break;
				}

				// Verifica se o celular foi preenchido
				if (document.frmEditContact.numero_celular.value.length == 0) {
					alert(VldDadosAdicALERTcmpcelular);
					document.frmEditContact.numero_celular.focus();
					liberado = false;
					break;
				}

				if (liberado) {
					document.Confirmacao.dados_cartao.value = document.frmEditContact.ddd_celular.value + document.frmEditContact.numero_celular.value;
				}
			}

			// Verifica se é Paggo para registrar os dados do celular
			if ((document.frmEditContact.forma_pagamento.value == 'Visa') && (document.frmEditContact.modulo_pagamento.value == 'VISAMOSET'))
			{
				
				var s;

				// Verifica se o cartão foi preenchido corretamente
				s = limpa_string(document.frmEditContact.ccn.value);
				if (s.length != 16) {
					alert(VldCartaoALERTcmptamnumcartao);
					document.frmEditContact.ccn.focus();
					liberado = false;
					break;
				}
				
				// Verifica se o cartão foi preenchido corretamente
				if (document.frmEditContact.ccn.value.length == 0) {
					alert(VldCartaoALERTcmpnumcartao);
					document.frmEditContact.ccn.focus();
					liberado = false;
					break;
				}

				// Verifica se a data de validade do cartão foi preenchida
				if (document.frmEditContact.expMM.value.length == 0) {
					alert(VldCartaoALERTcmpdataval);
					document.frmEditContact.expMM.focus();
					liberado = false;
					break;
				}

				if (document.frmEditContact.expAA.value.length == 0) {
					alert(VldCartaoALERTcmpdataval);
					document.frmEditContact.expAA.focus();
					liberado = false;
					break;
				}

				// Verifica se o cod de seguranca do cartão foi preenchido corretamente
				if (document.frmEditContact.cvv2.value.length == 0) {
					alert(VldCartaoALERTcmpcodseg);
					document.frmEditContact.cvv2.focus();
					liberado = false;
					break;
				}

				if (liberado) {
					document.Confirmacao.dados_cartao.value = document.frmEditContact.ccn.value + '|' + document.frmEditContact.cvv2.value + '|' + document.frmEditContact.expAA.value + document.frmEditContact.expMM.value;
				}
			}

		}

		// Registra os dados de parcelamento
		if (document.frmEditContact.elements[a].name == 'parcelas') {
            document.Confirmacao.dados_adicionais.value = document.frmEditContact.parcelas.value;
        }

		//posta os dados adicionais para ABN
		if(document.frmEditContact.elements[a].name == 'abn_formapgto'){
            document.Confirmacao.dados_adicionais.value = document.frmEditContact.abn_formapgto.value + '|' + document.frmEditContact.abn_garantia.value + '|' + document.frmEditContact.abn_entrada.value + '|' + document.frmEditContact.abn_vencto.value;
        }
    }
	
	if (liberado)
	{
		document.Confirmacao.submit();
	}
}
