function parcelaAbril (revista)
{
	if (revista != 'veja'){
		form_consulta.qtdeParcelaBLT.remove(1);
		form_consulta.qtdeParcelaBLT.remove(2);
		form_consulta.qtdeParcelaBLT.remove(3);
		form_consulta.qtdeParcelaBLT.remove(1);
		form_consulta.qtdeParcelaBLT.remove(1);
		form_consulta.qtdeParcelaBLT.clearAttributes
		myEle=document.createElement("option");
		theText=document.createTextNode("1x 499,00");
		myEle.appendChild(theText);
		myEle.setAttribute("value","1x 499,00");
		document.form_consulta.qtdeParcelaBLT.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("2x 249,50");
		myEle.appendChild(theText);
		myEle.setAttribute("value","2x 249,50");
		document.form_consulta.qtdeParcelaBLT.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("3x 166,37");
		myEle.appendChild(theText);
		myEle.setAttribute("value","3x 166,37");
		form_consulta.qtdeParcelaBLT.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("6x 83,17");
		myEle.appendChild(theText);
		myEle.setAttribute("value","6x 83,17");
		form_consulta.qtdeParcelaBLT.appendChild(myEle);
		
		// card
		form_consulta.qtdeParcelaCRD.remove(1);
		form_consulta.qtdeParcelaCRD.remove(2);
		form_consulta.qtdeParcelaCRD.remove(3);
		form_consulta.qtdeParcelaCRD.remove(1);
		form_consulta.qtdeParcelaCRD.remove(1);
		form_consulta.qtdeParcelaCRD.clearAttributes
		myEle=document.createElement("option");
		theText=document.createTextNode("1 x 499,00");
		myEle.appendChild(theText);
		myEle.setAttribute("value","1 x 499,00");
		form_consulta.qtdeParcelaCRD.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("2x 249,50");
		myEle.appendChild(theText);
		myEle.setAttribute("value","2x 249,50");
		form_consulta.qtdeParcelaCRD.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("3x 166,37");
		myEle.appendChild(theText);
		myEle.setAttribute("value","3x 166,37");
		form_consulta.qtdeParcelaCRD.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("6x 83,17");
		myEle.appendChild(theText);
		myEle.setAttribute("value","6x 83,17");
		form_consulta.qtdeParcelaCRD.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("11x 45,37");
		myEle.appendChild(theText);
		myEle.setAttribute("value","11x 45,37");
		form_consulta.qtdeParcelaCRD.appendChild(myEle);
		
	}
	else{
		form_consulta.qtdeParcelaBLT.remove(1);
		form_consulta.qtdeParcelaBLT.remove(2);
		form_consulta.qtdeParcelaBLT.remove(3);
		form_consulta.qtdeParcelaBLT.remove(1);
		form_consulta.qtdeParcelaBLT.remove(1);
		form_consulta.qtdeParcelaBLT.clearAttributes
		myEle=document.createElement("option");
		theText=document.createTextNode("1x 550,00");
		myEle.appendChild(theText);
		myEle.setAttribute("value","1x 550,00");
		form_consulta.qtdeParcelaBLT.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("2x 275,00");
		myEle.appendChild(theText);
		myEle.setAttribute("value","2x 275,00");
		form_consulta.qtdeParcelaBLT.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("3x 183,34");
		myEle.appendChild(theText);
		myEle.setAttribute("value","3x 183,34");
		form_consulta.qtdeParcelaBLT.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("6x 91,67");
		myEle.appendChild(theText);
		myEle.setAttribute("value","6x 91,67");
		form_consulta.qtdeParcelaBLT.appendChild(myEle);
				
		// card
		form_consulta.qtdeParcelaCRD.remove(1);
		form_consulta.qtdeParcelaCRD.remove(2);
		form_consulta.qtdeParcelaCRD.remove(3);
		form_consulta.qtdeParcelaCRD.remove(1);
		form_consulta.qtdeParcelaCRD.remove(1);
		form_consulta.qtdeParcelaCRD.clearAttributes
		myEle=document.createElement("option");
		theText=document.createTextNode("1x 550,00");
		myEle.appendChild(theText);
		myEle.setAttribute("value","1x 550,00");
		form_consulta.qtdeParcelaCRD.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("2x 275,50");
		myEle.appendChild(theText);
		myEle.setAttribute("value","2x 275,50");
		form_consulta.qtdeParcelaCRD.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("3x 183,34");
		myEle.appendChild(theText);
		myEle.setAttribute("value","3x 183,34");
		form_consulta.qtdeParcelaCRD.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("6x 91,67");
		myEle.appendChild(theText);
		myEle.setAttribute("value","6x 91,67");
		form_consulta.qtdeParcelaCRD.appendChild(myEle);
		
		myEle=document.createElement("option");
		theText=document.createTextNode("11x 50,00");
		myEle.appendChild(theText);
		myEle.setAttribute("value","11x 50,00");
		form_consulta.qtdeParcelaCRD.appendChild(myEle);
	}
}


function isValidCreditCardNumber(cardNumber, cardType){
    var isValid = false;
    var ccCheckRegExp = /[^\d ]/;
    isValid = !ccCheckRegExp.test(cardNumber);
    if (isValid){
        var cardNumbersOnly = cardNumber.replace(/ /g,"");
        var cardNumberLength = cardNumbersOnly.length;
        var lengthIsValid = false;
        var prefixIsValid = false;
        var prefixRegExp;
    switch(cardType){
        case "mastercard":
            lengthIsValid = (cardNumberLength == 16);
            prefixRegExp = /^5[1-5]/;
        break;
        case "visa":
            lengthIsValid = (cardNumberLength == 16 || cardNumberLength == 13);
            prefixRegExp = /^4/;
        break;
        case "amex":
            lengthIsValid = (cardNumberLength == 15);
            prefixRegExp = /^3(4|7)/;
        break;
        default:
            prefixRegExp = /^$/;
            alert("Tipo de Cartão não encontrado");
    }
    prefixIsValid = prefixRegExp.test(cardNumbersOnly);
    isValid = prefixIsValid && lengthIsValid;
    }
    if (isValid){
        var numberProduct;
        var numberProductDigitIndex;
        var checkSumTotal = 0;
        for (digitCounter = cardNumberLength - 1; digitCounter >= 0; digitCounter--){
            checkSumTotal += parseInt (cardNumbersOnly.charAt(digitCounter));
            digitCounter--;
            numberProduct = String((cardNumbersOnly.charAt(digitCounter) * 2));
            for (var productDigitCounter = 0; productDigitCounter < numberProduct.length; productDigitCounter++){
                checkSumTotal += parseInt(numberProduct.charAt(productDigitCounter));
            }
        }
        isValid = (checkSumTotal % 10 == 0);
    }
    return isValid;
}
function campo_numerico (){
if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;
}
function verify() 
{ 
 if (xmlDoc.readyState != 4) 
 {return false;} 
}
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
var xmlDoc2 = new ActiveXObject("Microsoft.XMLDOM"); 
function loadXML(cep) 
{ 
 xmlDoc.async="false"; 
 xmlDoc.onreadystatechange=verify; 
 xmlDoc.load('base.asp?cep='+cep); 
 xmlObj=xmlDoc.documentElement; 
 form_consulta.endEntrega.value = xmlObj.childNodes(0).getAttribute("rua");
 form_consulta.bairroEntrega.value = xmlObj.childNodes(0).getAttribute("bairro");
 form_consulta.cidadeEntrega.value = xmlObj.childNodes(0).getAttribute("cidade");
 form_consulta.ufEntrega.value = xmlObj.childNodes(0).getAttribute("uf");
}
function loadXML2(cep) 
{ 
 xmlDoc.async="false"; 
 xmlDoc.onreadystatechange=verify; 
 xmlDoc.load('base.asp?cep='+cep); 
 xmlObj=xmlDoc.documentElement; 
 form_consulta.endCobranca.value = xmlObj.childNodes(0).getAttribute("rua");
 form_consulta.bairroCobranca.value = xmlObj.childNodes(0).getAttribute("bairro");
 form_consulta.cidadeCobranca.value = xmlObj.childNodes(0).getAttribute("cidade");
 form_consulta.ufCobranca.value = xmlObj.childNodes(0).getAttribute("uf");
}
function CopyEnd() 
{ 
 form_consulta.endCobranca.value = form_consulta.endEntrega.value;
 form_consulta.bairroCobranca.value = form_consulta.bairroEntrega.value;
 form_consulta.cidadeCobranca.value = form_consulta.cidadeEntrega.value;
 form_consulta.ufCobranca.value = form_consulta.ufEntrega.value;
 form_consulta.numCobranca.value = form_consulta.numEntrega.value;
 form_consulta.cepCobranca.value = form_consulta.cepEntrega.value;
 form_consulta.complCobranca.value = form_consulta.complEntrega.value;
 form_consulta.tp_endCobranca.value = form_consulta.tp_endEntrega.value;
}

function MostraForm()
{ 
	if (document.form_consulta.rad[0].checked){
		document.getElementById("formPF").style.display="";
		document.getElementById("formPJ").style.display="none";
		document.getElementById("escolha").style.display="none";
	}
	if (document.form_consulta.rad[1].checked){
		document.getElementById("formPF").style.display="none";
		document.getElementById("formPJ").style.display="";
		document.getElementById("escolha").style.display="none";
	}
}
function Cartao()
{ 
	if (document.form_consulta.tpPagamento[1].checked){
		document.getElementById("cartao").style.display="none";
		document.getElementById("boleto").style.display="";
	}
	if (document.form_consulta.tpPagamento[0].checked){
		document.getElementById("cartao").style.display="";
		document.getElementById("boleto").style.display="none";
	}

}

function cnpj_cpf(campo,documento,f,formi)
{
	form = formi;
	for (Count = 0; Count < 2; Count++){
	if (form.rad[Count].checked)
	break;
}
if (Count == 0)
{
	mascara_cpf (campo,documento,f);
}
else{
mascara_cnpj (campo,documento,f);
}
}
function mascara_cnpj (campo,documento,f){
var mydata = '';
mydata = mydata + documento;
if (mydata.length == 2){
mydata = mydata + '.';
ct_campo = eval("document."+f+"."+campo+".value = mydata");
ct_campo;
}
if (mydata.length == 6){
mydata = mydata + '.';
ct_campo = eval("document."+f+"."+campo+".value = mydata");
ct_campo;
}
if (mydata.length == 10){
mydata = mydata + '/';
ct_campo1 = eval("document."+f+"."+campo+".value = mydata");
ct_campo1;
}
if (mydata.length == 15){
mydata = mydata + '-';
ct_campo1 = eval("document."+f+"."+campo+".value = mydata");
ct_campo1;
}
if (mydata.length == 18){
valida_cnpj(f,campo);
}
}
function mascara_cpf (campo,documento,f){
var mydata = '';
mydata = mydata + documento;
if (mydata.length == 3){
mydata = mydata + '.';
ct_campo = eval("document."+f+"."+campo+".value = mydata");
ct_campo;
}
if (mydata.length == 7){
mydata = mydata + '.';
ct_campo = eval("document."+f+"."+campo+".value = mydata");
ct_campo;
}
if (mydata.length == 11){
mydata = mydata + '-';
ct_campo1 = eval("document."+f+"."+campo+".value = mydata");
ct_campo1;
}
if (mydata.length == 14){
valida_cpf(f,campo);
}
}
function valida_cnpj(f,campo){
pri = eval("document."+f+"."+campo+".value.substring(0,2)");
seg = eval("document."+f+"."+campo+".value.substring(3,6)");
ter = eval("document."+f+"."+campo+".value.substring(7,10)");
qua = eval("document."+f+"."+campo+".value.substring(11,15)");
qui = eval("document."+f+"."+campo+".value.substring(16,18)");
var i;
var numero;
var situacao = '';
numero = (pri+seg+ter+qua+qui);
s = numero;
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){
var result = "falso";
}
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(0) != d1){
var result = "falso";
}
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){
var result = "falso";
}
if (result == "falso") {
alert("CNPJ inválido!");
aux1 = eval("document."+f+"."+campo+".focus");
aux2 = eval("document."+f+"."+campo+".value = ''");
}
}
function valida_cpf(f,campo){
pri = eval("document."+f+"."+campo+".value.substring(0,3)");
seg = eval("document."+f+"."+campo+".value.substring(4,7)");
ter = eval("document."+f+"."+campo+".value.substring(8,11)");
qua = eval("document."+f+"."+campo+".value.substring(12,14)");
var i;
var numero;
numero = (pri+seg+ter+qua);
s = numero;
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){
var result = "falso";
}
d1 = 11 - (d1 % 11);
if (d1 > 9) d1 = 0;
if (dv.charAt(0) != d1){
var result = "falso";
}
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){
var result = "falso";
}
if (result == "falso") {
alert("CPF inválido!");
aux1 = eval("document."+f+"."+campo+".focus");
aux2 = eval("document."+f+"."+campo+".value = ''");
}
}




function valida()
{
	
	if(document.form_consulta.promocao.value == 'epoca2')
		{
			if(document.form_consulta.revista[0].checked == false && document.form_consulta.revista[1].checked == false && document.form_consulta.revista[2].checked == false)
			{
				alert("Escolha uma revista da promoção")
				return false;
			}
		}
	if(document.form_consulta.rad[0].checked == false && document.form_consulta.rad[1].checked == false)
		{
			alert("Escolha o tipo de cadastro (Física / Jurídica)")
			return false;
		}
	// valida PJ
	if(document.form_consulta.rad[1].checked == true)
		{
			if(document.form_consulta.nome_compPJ.value == 0)
			{
				alert("O nome não pode estar em branco")
				document.form_consulta.nome_compPJ.focus();
				return false;
			}
			if(document.form_consulta.responsavel.value == 0)
			{
				alert("O nome do responsável não pode ser em branco")
				document.form_consulta.responsavel.focus();
				return false;
			}
			if(document.form_consulta.cnpj.value == 0)
			{
				alert("O CNPJ não pode estar em branco")
				document.form_consulta.cnpj.focus();
				return false;
			}
			if(document.form_consulta.emailPJ.value == 0)
			{
				alert("O email não pode estar em branco")
				document.form_consulta.emailPJ.focus();
				return false;
			}
			if(document.form_consulta.emailPJ.value != 0)
			{
				var Email = document.form_consulta.emailPJ.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi); 
				if (Email)
					{ 
						//return true
					} 
				else
					{ 
						alert('Email inválido.')
						document.form_consulta.emailPJ.focus(); 
						return false 
					} 
			}
			if(document.form_consulta.dddComPJ.value == 0)
			{
				alert("Por favor preencha DDD do telefone")
				document.form_consulta.dddComPJ.focus();
				return false;
			}
			if(document.form_consulta.foneComPJ.value == 0)
			{
				alert("Por favor preencha o telefone")
				document.form_consulta.foneComPJ.focus();
				return false;
			}

		}
	
	// valida PF
	if(document.form_consulta.rad[0].checked == true)
		{
			if(document.form_consulta.nome_comp.value == 0)
			{
				alert("O nome não pode ser em branco")
				document.form_consulta.nome_comp.focus();
				return false;
			}
			if(document.form_consulta.cpf.value == 0)
			{
				alert("O CPF não pode estar em branco")
				document.form_consulta.cpf.focus();
				return false;
			}
			if(document.form_consulta.sexo.value == 0)
			{
				alert("Por favor escolha um sexo")
				document.form_consulta.sexo.focus();
				return false;
			}
			if(document.form_consulta.ddn.value == 0)
			{
				alert("Por favor preencha o dia de nascimento")
				document.form_consulta.ddn.focus();
				return false;
			}
			if(document.form_consulta.mmn.value == 0)
			{
				alert("Por favor preencha o mês de nascimento")
				document.form_consulta.mmn.focus();
				return false;
			}
			if(document.form_consulta.aan.value == 0)
			{
				alert("Por favor preencha o ano de nascimento")
				document.form_consulta.aan.focus();
				return false;
			}
			if(document.form_consulta.email.value == 0)
			{
				alert("O email não pode estar em branco")
				document.form_consulta.email.focus();
				return false;
			}
			if(document.form_consulta.email.value != 0)
			{
				var Email = document.form_consulta.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi); 
				if (Email)
					{ 
						//return true
					} 
				else
					{ 
						alert('Email inválido.')
						document.form_consulta.email.focus(); 
						return false 
					} 
			}
			if(document.form_consulta.dddRes.value == 0)
			{
				alert("Por favor preencha DDD do telefone residencial")
				document.form_consulta.dddRes.focus();
				return false;
			}
			if(document.form_consulta.foneRes.value == 0)
			{
				alert("Por favor preencha o telefone residencial")
				document.form_consulta.foneRes.focus();
				return false;
			}

		}
	//valida dados entrega
	if(document.form_consulta.tp_endEntrega.value == 0)
		{
			alert("Escolha uim tipo de endereço para entrega")
			document.form_consulta.tp_endEntrega.focus();
			return false;
		}
	if(document.form_consulta.cepEntrega.value == 0)
		{
			alert("Por favor, informe o CEP para entrega")
			document.form_consulta.cepEntrega.focus();
			return false;
		}
	if(document.form_consulta.endEntrega.value == 0)
		{
			alert("Por favor, informe o endereço de entrega")
			document.form_consulta.endEntrega.focus();
			return false;
		}
	if(document.form_consulta.numEntrega.value == 0)
		{
			alert("Por favor, informe o número do endereço para entrega")
			document.form_consulta.numEntrega.focus();
			return false;
		}
	if(document.form_consulta.cidadeEntrega.value == 0)
		{
			alert("Por favor, informe a cidade do endereço de entrega")
			document.form_consulta.cidadeEntrega.focus();
			return false;
		}
	if(document.form_consulta.ufEntrega.value == 0)
		{
			alert("Por favor, informe o estado do endereço de entrega")
			document.form_consulta.ufEntrega.focus();
			return false;
		}
	
	// valida dados cobranca
	if(document.form_consulta.tp_endCobranca.value == 0)
		{
			alert("Escolha uim tipo de endereço para Cobranca")
			document.form_consulta.tp_endCobranca.focus();
			return false;
		}
	if(document.form_consulta.cepCobranca.value == 0)
		{
			alert("Por favor, informe o CEP para Cobranca")
			document.form_consulta.cepCobranca.focus();
			return false;
		}
	if(document.form_consulta.endCobranca.value == 0)
		{
			alert("Por favor, informe o endereço de Cobranca")
			document.form_consulta.endCobranca.focus();
			return false;
		}
	if(document.form_consulta.numCobranca.value == 0)
		{
			alert("Por favor, informe o número do endereço para Cobranca")
			document.form_consulta.numCobranca.focus();
			return false;
		}
	if(document.form_consulta.cidadeCobranca.value == 0)
		{
			alert("Por favor, informe a cidade do endereço de Cobranca")
			document.form_consulta.cidadeCobranca.focus();
			return false;
		}
	if(document.form_consulta.ufCobranca.value == 0)
		{
			alert("Por favor, informe o estado do endereço de Cobranca")
			document.form_consulta.ufCobranca.focus();
			return false;
		}
	
	// dados cobranca
	// valida boleto ou cartao
	if(document.form_consulta.tpPagamento[0].checked == false && document.form_consulta.tpPagamento[1].checked == false)
	{
			alert("Por favor, selecione uma forma de pagamento")
			return false;
	}
	
	// valida dados cartao
	if(document.form_consulta.tpPagamento[0].checked == true)
	{
		if(document.form_consulta.qtdeParcelaCRD.value == 0)
		{
			alert("Por favor, selecione a quantidade de parcelas")
			document.form_consulta.qtdeParcelaCRD.focus();
			return false;
		}
		if(document.form_consulta.TipoCard[0].checked == false && document.form_consulta.TipoCard[1].checked == false && document.form_consulta.TipoCard[2].checked == false)
		{
			alert("Por favor, escolha um tipo de cartão")
			return false;
		}		
		if(document.form_consulta.nomeTitCard.value == 0)
		{
			alert("Por favor, informe o nome do titular do cartão")
			document.form_consulta.nomeTitCard.focus();
			return false;
		}
		if(document.form_consulta.numerocartao.value == 0)
		{
			alert("Por favor, informe o número do cartão")
			document.form_consulta.numerocartao.focus();
			return false;
		}
		if(document.form_consulta.mesValCard.value == 0)
		{
			alert("Por favor, informe o mês de validade do cartão")
			document.form_consulta.mesValCard.focus();
			return false;
		}
		if(document.form_consulta.anoValCard.value == 0)
		{
			alert("Por favor, informe o ano de validade do cartão")
			document.form_consulta.anoValCard.focus();
			return false;
		}
	}
	if(document.form_consulta.tpPagamento[1].checked == true)
	{
		if(document.form_consulta.qtdeParcelaBLT.value == 0)
		{
			alert("Por favor, selecione a quantidade de parcelas")
			document.form_consulta.qtdeParcelaBLT.focus();
			return false;
		}
	}
	else
		return true	
} 



