// JavaScript Document

/*-----------------------------------------------------------------------
INÍCIO ARQUIVO CADASTRE.ASP
-----------------------------------------------------------------------*/
 function ApagaCampoCadastreseEmail() {
    if (document.getElementById("email1").value != '') {
        document.getElementById("email1").value == document.getElementById("email1").value;
    }
    if (document.getElementById("email1").value == 'digite seu e-mail') {
        document.getElementById("email1").value = '';
    }
}    

function PreencheCampoCadastreseEmail() {
    if (document.getElementById("email1").value == '') {
        document.getElementById("email1").value = 'digite seu e-mail';
    }
}
    
function ApagaCampoCadastreseCep() {
    if (document.getElementById("cep1").value != '') {
        document.getElementById("cep1").value == document.getElementById("cep1").value;
    }
    if (document.getElementById("cep1").value == 'digite seu cep') {
        document.getElementById("cep1").value = '';
    }
}

function PreencheCampoCadastreseCep() {
    if (document.getElementById("cep1").value == '') {
        document.getElementById("cep1").value = 'digite seu cep';
    }
}

function EfeitoTextBoxCepOnClick() {
    document.formulariodecadastro.cep.style.border='2px solid #2c84c7';        
}
           
function EfeitoTextBoxCepOnblur() {
    document.formulariodecadastro.cep.style.border='1px solid #fa6c04';
}        
         
function EfeitoTextBoxEmailOnClick() {
    document.formulariodecadastro.email.style.border='2px solid #2c84c7';
}

function EfeitoTextBoxEmailOnBlur() {
    document.formulariodecadastro.email.style.border='1px solid #fa6c04';
}

/*-----------------------------------------------------------------------
FINAL ARQUIVO CADASTRE.ASP
-----------------------------------------------------------------------*/

/*-----------------------------------------------------------------------
INÍCIO ARQUIVO AUTENTICAÇÃO.ASP
-----------------------------------------------------------------------*/
function ApagaCampoAutenticacaoEmail() {
    if (document.getElementById("emailaut1").value != '') {
        document.getElementById("emailaut1").value == document.getElementById("emailaut1").value;
    }
    if (document.getElementById("emailaut1").value == 'digite seu e-mail') {
        document.getElementById("emailaut1").value = '';
    }
}    

function PreencheCampoAutenticacaoEmail() {
    if (document.getElementById("emailaut1").value == '') {
        document.getElementById("emailaut1").value = 'digite seu e-mail';
    }
}  
  
function ApagaCampoAutenticacaoSenha() {
    document.getElementById("senhaaut1").value = '';
}

function PreencheCampoAutenticacaoSenha() {
    if (document.getElementById("senhaaut1").value == '') {
        document.getElementById("senhaaut1").value = 'xxxxxxxxxx';
    }
}
               
function EfeitoTextBoxEmailAutenticacaoOnClick() {
    document.formautenticacao.emailaut.style.border='2px solid #2c84c7';
}

function EfeitoTextBoxEmailAutenticacaoOnBlur() {
    document.formautenticacao.emailaut.style.border='1px solid #fa6c04';
}

function EfeitoTextBoxSenhaOnClick() {
    document.formautenticacao.senhaaut.style.border='2px solid #2c84c7';        
}
           
function EfeitoTextBoxSenhaOnblur() {
    document.formautenticacao.senhaaut.style.border='1px solid #fa6c04';
}       

/*-----------------------------------------------------------------------
FINAL ARQUIVO AUTENTICAÇÃO.ASP
-----------------------------------------------------------------------*/

/*-----------------------------------------------------------------------
INÍCIO ARQUIVO REENVIARSENHA.ASP
-----------------------------------------------------------------------*/
   function ApagaCampoReEnviarSenhaEmail() {
    if (document.getElementById("emailre1").value != '') {
        document.getElementById("emailre1").value == document.getElementById("emailre1").value;
    }
    if (document.getElementById("emailre1").value == 'digite seu e-mail') {
        document.getElementById("emailre1").value = '';
    }
}

function PreencheCampoReEnviarSenhaEmail() {
    if (document.getElementById("emailre1").value == '') {
        document.getElementById("emailre1").value = 'digite seu e-mail';
    }
}

function EfeitoTextBoxEmailReEnviarSenhaOnClick() {
    document.formularioreenviarsenha.emailre.style.border='2px solid #2c84c7';
}

function EfeitoTextBoxEmailReEnviarSenhaOnBlur() {
    document.formularioreenviarsenha.emailre.style.border='1px solid #fa6c04';
}
        
/*-----------------------------------------------------------------------
FINAL ARQUIVO REENVIARSENHA.ASP
-----------------------------------------------------------------------*/

/*-----------------------------------------------------------------------
Início PULA PARA A CAIXA DE TEXTO DEFINIDA AO ALCANCAR O TAMANHO MAXIMO DE CARACTERES para o Cadastrese
-----------------------------------------------------------------------*/

function pulaemail(origem, tamanho, destino) {
	if ((origem.value.length == tamanho) && checatab) {
        destino.focus()
        destino.style.border='2px solid #2c84c7'; 
    }
    if (destino.value == 'digite seu cep') {
        destino.value = ''
        destino.style.border='1px solid #fa6c04'; 
    }
}

function pulaemailaut(origem, tamanho, destino) {
	if ((origem.value.length == tamanho) && checatab) {
        destino.focus();
        destino.style.border='2px solid #2c84c7'; 
    }
    if (destino.value == 'xxxxxxxxxx') {
        destino.value = ''
        destino.style.border='1px solid #fa6c04'; 
    }
}

/*-----------------------------------------------------------------------
Fim PULA PARA A CAIXA DE TEXTO DEFINIDA AO ALCANCAR O TAMANHO MAXIMO DE CARACTERES para o Cadastrese
-----------------------------------------------------------------------*/

function abre(pagina,janela,w,h,rolagem,maxi) {
if (maxi == '') maxi = 'no';
if (rolagem == '') rolagem = 'no';
window.open(pagina,janela,'width='+w+',height='+h+',scrollbars='+rolagem+',toolbar=no,location=no,status=no,menubar=no,resizable='+maxi+',left=200,top=5')
}


function redirectUrl(url) {
	window.location = url;
}
  
  function MouseOver(src,menu) {
    if (!src.contains(event.fromElement)) {
      src.style.border = 'solid 0px #000000';
	  src.style.cursor = 'hand';

      menu.style.visibility="visible"
	}
  }
  function MouseOut(src,menu) {
	if (!src.contains(event.toElement)) {
      src.style.border = 'solid 0px #000000';
	  src.style.cursor = 'hand';
	  src.style.cursor = 'default';

      menu.style.visibility="hidden"
	}
  }
  function MouseClique(src) {
    if(event.srcElement.tagName=='TD'){
	  src.children.tags('A')[0].click();
    }
  }
  
  
  function MouseOverSC(src) {
    if (!src.contains(event.fromElement)) {
      src.style.border = 'solid 0px #000000';
	  src.style.cursor = 'hand';
	  src.bgColor = '#000000';
	}
  }
  function MouseOutSC(src) {
	if (!src.contains(event.toElement)) {
      src.style.border = 'solid 0px #000000 ';
	  src.style.cursor = 'hand';
	  src.style.cursor = 'default';
	  src.bgColor = '#000000';
	}
  }

// ENQUETE

window.defaultStatus="Ckless Internet - (51) 3333 9932"



// RECONHECE O BROWSER
var ns4 = (document.layers) ? true : false
var ie4 = (document.all) ? true : false

// FILTRA AS TECLAS PRESSIONADAS
function filtra(obj, padrao) {
	tk    = (ie4) ? event.keyCode : event.which;
	letra = String.fromCharCode(tk);
	
	for (x = 0; x < padrao.length; x++)
		if (padrao.slice(x, x + 1) == letra) return true;
	
	return false;
}

/*-----------------------------------------------------------------------
INICIO BLOQUEIA LETRAS
-----------------------------------------------------------------------*/
function blockNumbers(e)
 {
 var key;
 var keychar;
 var reg;

 if(window.event) {
   // for IE, e.keyCode or window.event.keyCode can be used
   key = e.keyCode; 
}
 else if(e.which) {
   // netscape
   key = e.which; 
}
 else {
   // no event, so pass through
   return true;
 }

keychar = String.fromCharCode(key);
 reg = /[^\d-]/;
return !reg.test(keychar);
 }
/*-----------------------------------------------------------------------
FIM BLOQUEIA LETRAS
-----------------------------------------------------------------------*/

/*-----------------------------------------------------------------------
INICIO BLOQUEIA CARACTERES ESPECIAIS
-----------------------------------------------------------------------*/ 
function blockSpecialChars(e)
 {
 var key;
 var keychar;
 var reg;

 if(window.event) {
   // for IE, e.keyCode or window.event.keyCode can be used
   key = e.keyCode; 
}
 else if(e.which) {
   // netscape
   key = e.which; 
}
 else {
   // no event, so pass through
   return true;
 }
 
keychar = String.fromCharCode(key);
 reg = /[^a-zA-Z0-9-]/;
return !reg.test(keychar);
 }
/*-----------------------------------------------------------------------
FIM BLOQUEIA CARACTERES ESPECIAIS
-----------------------------------------------------------------------*/

// BLOQUEIA CARACTERES EXCEDENTES EM TEXTAREAS
function maximo(obj, valor) {
	if (obj.value.length >= valor) return false;
}

// ESCREVE DINAMICAMENTE DENTRO DE UM LAYER
function escreve(id, txt) {
	if (ns4) {
		var lyr = document.layers[id].document;
		lyr.write(txt);
		lyr.close();
	} else
		document.getElementById(id).innerHTML = txt;
}

// FUNCOES PARA CONTROLE DE AVANCO EM CAMPOS DE TEXTO
function semTab() {
	checatab = false;
}

function comTab() {
	checatab = true;
} 

checatab = true;

// PULA PARA A CAIXA DE TEXTO DEFINIDA AO ALCANCAR O TAMANHO MAXIMO DE CARACTERES
function pula(origem, tamanho, destino) {
	if ((origem.value.length == tamanho) && checatab)
        destino.focus();
}

// IMPEDE A EXECUCAO DE MENUS COM OS BOTOES DO MOUSE
/* function click() {
	if (event.button == 2 || event.button == 3) oncontextmenu = 'return false';
}

document.onmousedown   = click;
document.oncontextmenu = new Function('return false;'); */

/*-----------------------------------------------------------------------
Somente Números e Letras
-----------------------------------------------------------------------*/

function somente_numletras(evento, objeto) {
	var tecla=(window.event)?event.keyCode:evento.which;
	if (tecla != 8 && tecla < 8 || tecla > 16 && tecla < 19 || tecla > 90 && tecla < 96 || tecla > 105 && tecla < 192 || tecla > 192) 
	{
	return false;
	}
}

function isNaNLetters(string) {
    padraoisNL = /^([a-zA-Z0-9])*$/;
	var reg = new RegExp(padraoisNL);
	var obj = reg.test(string);
	
	if(obj)
		return true;
	else
		return false;
}

/*-----------------------------------------------------------------------
Função para Pesquisa
-----------------------------------------------------------------------*/

function pesquisa(evento, objeto) {
	var tecla=(window.event)?event.keyCode:evento.which;
	if (tecla != 8 && tecla < 8 || tecla > 90 && tecla < 96 || tecla > 105 && tecla < 192 || tecla > 192) 
	{
	return false;
	}
}

/*-----------------------------------------------------------------------
Somente Números
-----------------------------------------------------------------------*/

function somente_num(evento, objeto) {
	var tecla=(window.event)?event.keyCode:evento.which;
	if (tecla != 8 && tecla < 48 || tecla > 57 && tecla < 96 || tecla > 105) 
	{
	return false;
	}
}

function isNaN(num) {
    padraoisNaN = /^\d*$/;
	var reg = new RegExp(padraoisNaN);
	var obj = reg.test(num);
	
    /*num.replace(/\D/g,"")*/

	if(obj)
		return true;
	else
		return false;
}

/*-----------------------------------------------------------------------
Função para E-mail
-----------------------------------------------------------------------*/

function valida_email(string) {
	padraoEmail = /^([0-9a-zA-Z]+([_.-]?[0-9a-zA-Z]+)*@[0-9a-zA-Z]+[0-9,a-z,A-Z,.,-]*\.{1}[a-zA-Z]{2,4})+$/;
	var reg = new RegExp(padraoEmail);
	var obj = reg.test(string);
	
	if(obj)
		return true;
	else
		return false;		
}

/*-----------------------------------------------------------------------
Função para CEP
-----------------------------------------------------------------------*/

function valida_cep(strCEP) {
    padraoCEP = /^[1-9]{2}[0-9]{3}[0-9]{3}$/;
    var reg = new RegExp(padraoCEP);
    var obj = reg.test(strCEP);

	if(obj)
		return true;
	else
		return false;		
}

/*-----------------------------------------------------------------------
Função para Validar Login e Senha
-----------------------------------------------------------------------*/

function valida_login(evento, objeto) {
	var tecla=(window.event)?event.keyCode:evento.which;
	if (tecla != 8 && tecla < 8 || tecla > 16 && tecla < 19 || tecla > 90 && tecla < 96 || tecla > 110 && tecla < 190 || tecla > 190 && tecla < 192 || tecla > 192) 
	{
	return false;
	}
}

/*-----------------------------------------------------------------------
Validação para os campos de Atendimento Fale Conosco
-----------------------------------------------------------------------*/

function ValidaAtendimentoFale()
{
	
	error = false;
	erro = "Foram Encontrados Erros \n \n" ;
	if (document.getElementById("nome").value == "" ) {
		erro += "Nome é obrigatório \n";
		this.document.getElementById("nome").focus();
		error= true;
	}
	if (document.getElementById("cidade").value == "" ) {
		erro += "Cidade é obrigatório \n";
		this.document.getElementById("cidade").focus();
		error = true;
	}
	if (document.getElementById("estado").value == "" ) {
		erro += "Estado é obrigatório \n";
		this.document.getElementById("estado").focus();
		error = true;
	}
    
	if (document.getElementById("emailfale").value == "") {
		erro += "E-mail é obrigatório \n";
		this.document.getElementById("emailfale").focus();
		error = true;
	}
	if (document.getElementById("emailfale").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
		erro += "O E-mail está no formato incorreto \n";
		this.document.getElementById("emailfale").focus();
		error = true;
	}
	if (document.getElementById("assunto").value == "" ) {
		erro += "Assunto é obrigatório \n";
		this.document.getElementById("assunto").focus();
		error = true;
	}
	if (document.getElementById("obs").value == "" ) {
		erro += "Mensagem é obrigatório \n";
		this.document.getElementById("obs").focus();
		error = true;
	}
	if (document.getElementById("captchaTxt").value == "" ) {
		erro += "Você deve digitar os caracteres que aparecem na imagem abaixo \n";
		this.document.getElementById("captchaTxt").focus();
		error = true;
	}
	if (document.getElementById("captchaVerify").value.indexOf("incorreto") > -1)
	{
		erro += "Os caracteres digitados não conferem com os da imagem!";
		this.document.getElementById("captchaTxt").focus();
		error = true;
	}
	if (error == true ){
		alert(erro);
		return false;
	}
	else{
		document.form1.submit();
		return true;
	}
}

function carregaCaptcha(val)
{
	xmlhttp = new XMLHttpRequest();
	
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("captchaVerify").setAttribute("value",xmlhttp.ResponseText);
		}
	}
	xmlhttp.open("GET","captcha_acao.asp?captchaTxt="+val,true);
	xmlhttp.send();
}

function loadAll()
{
	carregaCaptcha("");
}


/*-----------------------------------------------------------------------
Validação para os campos de Seja Um Fornecedor
-----------------------------------------------------------------------*/

function ValidaAtendimentoSejaUmFornecedor()
{
	
	if (document.getElementById("razaosocial").value == "" ) {
		alert('O campo Razao e obrigatorio \n');
		this.document.getElementById("razaosocial").focus();
		return false;
	}
	if (document.getElementById("nomefantasia").value == "" ) {
		alert('O campo Nome Fantasia e obrigatorio \n');
		this.document.getElementById("nomefantasia").focus();
		return false;
	}
	if (document.getElementById("endereco").value == "" ) {
		alert('O campo Endereco e obrigatorio \n');
		this.document.getElementById("endereco").focus();
		return false;
	}
	if (document.getElementById("endereconumero").value == "") {
		alert('O campo Numero e obrigatorio \n');
		this.document.getElementById("endereconumero").focus();
		return false;
	}
//validar numero(verificacao se contem apenas numeros)
	if (isNaN(document.getElementById("endereconumero").value)){
		alert ("O campo Numero deve conter apenas numeros!");
		this.document.getElementById("endereconumero").focus();
	 	return false;
	}
	if (document.getElementById("complemento").value == "" ) {
		alert('O campo Complemento e obrigatorio \n');
		this.document.getElementById("complemento").focus();
		return false;
	}
	if (document.getElementById("bairro").value == "" ) {
		alert('O campo Bairro e obrigatorio \n');
		this.document.getElementById("bairro").focus();
		return false;
	}
	if (document.getElementById("cidade").value == "" ) {
		alert('O campo Cidade e obrigatorio \n');
		this.document.getElementById("cidade").focus();
		return false;
	}
	if (document.getElementById("estado").value == "" ) {
		alert('O campo Estado e obrigatorio \n');
		this.document.getElementById("estado").focus();
		return false;
	}
	if ((document.getElementById("cep").value == "") && (document.getElementById("cep").value < 8 )) {
		alert('O campo CEP e obrigatorio \n');
		this.document.getElementById("cep").focus();
		return false;
	}
	if (isNaN(document.getElementById("cep").value)){
		alert ("O campo CEP deve conter apenas numeros!");
		this.document.getElementById("cep").focus();
	 	return false;
	}	
	if (document.getElementById("contato").value == "" ) {
		alert('O campo Contato e obrigatorio \n');
		this.document.getElementById("contato").focus();
		return false;
	}
	if (document.getElementById("emailfale").value == "" ) {
		alert('O campo E-mail e obrigatorio \n');
		this.document.getElementById("emailfale").focus();
		return false;
	}
	if (document.getElementById("emailfale").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail esta no formato errado \n');
		this.document.getElementById("emailfale").focus();
		return false;
	}
	if ((document.getElementById("telefoneDDD").value == "") && (document.getElementById("telefoneDDD").value < 2 )) {
		alert('O campo Telefone DDD e obrigatorio \n');
		this.document.getElementById("telefoneDDD").focus();
		return false;
	}
	if (isNaN(document.getElementById("telefoneDDD").value)){
		alert ("O campo Telefone DDD deve conter apenas numeros!");
		this.document.getElementById("telefoneDDD").focus();
		return false;
	}	
	if ((document.getElementById("telefone").value == "") && (document.getElementById("telefone").value < 8 )) {
		alert('O campo Telefone e obrigatorio \n');
		this.document.getElementById("telefone").focus();
		return false;
	}
	if (isNaN(document.getElementById("telefone").value)){
		alert ("O campo Telefone deve conter apenas numeros!");
		this.document.getElementById("telefone").focus();
	 	return false;
	}
	if ((document.getElementById("faxDDD").value == "") && (document.getElementById("faxDDD").value < 2 )) {
		alert('O campo Fax DDD e obrigatorio \n');
		this.document.getElementById("faxDDD").focus();
		return false;
	}
	if (isNaN(document.getElementById("faxDDD").value)){
		alert ("O campo Fax DDD deve conter apenas numeros!");
		this.document.getElementById("faxDDD").focus();
		return false;
	}	
	if ((document.getElementById("fax").value == "") && (document.getElementById("fax").value < 8 )) {
		alert('O campo Fax e obrigatorio \n');
		this.document.getElementById("fax").focus();
		return false;
	}
	if (isNaN(document.getElementById("fax").value)){
		alert ("O campo Fax deve conter apenas numeros!");
		this.document.getElementById("fax").focus();
	 	return false;
	}	
	if (document.getElementById("descricao").value == "" ) {
		alert('O campo Descricao e obrigatorio \n');
		this.document.getElementById("descricao").focus();
		return false;
	}
	if (document.getElementById("preco").value == "" ) {
		alert('O campo Preco e obrigatorio \n');
		this.document.getElementById("preco").focus();
		return false;
	}
	if (isNaN(document.getElementById("preco").value)){
		alert ("O campo Preco deve conter apenas numeros!");
		this.document.getElementById("preco").focus();
	 	return false;
	}	
	if (document.getElementById("captchaTxt").value == "") {
		alert('Voce deve preencher os caracteres que aparecem na imagem \n');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	
	if (document.getElementById("captchaVerify").value.indexOf("incorreto") > -1)
	{
		alert('Os caracteres digitados nao conferem com os da imagem!');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	else{
		document.sejaumfornecedor.submit();
		return true;
	}
}

function carregaCaptcha(val)
{
	xmlhttp = new XMLHttpRequest();
	
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			document.getElementById("captchaVerify").setAttribute("value",xmlhttp.responseText);
		}
	}
	xmlhttp.open("GET","captcha_acao.asp?captchaTxt="+val,true);
	xmlhttp.send();
}

function loadAll()
{
	carregaCaptcha("");
}

<!--ÍNICIO LIMITAR CARACTERES NO CAMPO OBSERVAÇÃO-->

function TextAreaDescricao(valor)
{
    quant = 500;
    total = valor.length;
    if(total <= quant)
    {
        resto = quant - total;
        document.getElementById('cont').innerHTML = resto;
    }
    else
    {
        document.getElementById('descricao').value = valor.substr(0,quant);
    }
}
//<!--FINAL LIMITAR CARACTERES NO CAMPO OBSERVAÇÃO-->
/*-----------------------------------------------------------------------
Validação para os campos de Carrinho
-----------------------------------------------------------------------*/

function ValidaCarrinho()
{
	/*padraoQuant = /^([0]+[1-9]+[0-9]*)$/;*/
    padraoquant = /^([1-9]+[0-9]*)$/;

	quantidade = document.getElementById("quantidade").value;
    estoqueatual = document.getElementById("estoqueatual").value;
    qtdmaxcliente = document.getElementById("qtdmaxcliente").value;
	
	var ref = new RegExp(padraoquant);
	var obj = ref.test(quantidade);

	/*if (isNaN(quantidade))
	{
		alert('O campo Quantidade deve conter apenas numeros!');
		this.quantidade == 1
        this.document.getElementById("Quantidade").focus();
		return false;
	}*/

	if (quantidade == "")
	{
		alert('O campo quantidade é obrigatório \n');
        this.document.getElementById("quantidade").value = 1
		this.document.getElementById("quantidade").focus();
		return false;
	}

    if ((quantidade > 0) & (quantidade < 10) || (quantidade > 9) & (quantidade < 99))
    {
        this.document.getElementById("quantidade").value = document.getElementById("quantidade").value
        this.document.getElementById("quantidade").focus();
        return true;
    }

    /*if ((quantidade > 9) & (quantidade < 99))
    {
        this.document.getElementById("quantidade").value = document.getElementById("quantidade").value
        this.document.getElementById("quantidade").focus();
        return true;
    }*/

	if ((quantidade > estoqueatual) || (quantidade > qtdmaxcliente))
	{
		alert('Desculpe o transtorno, mas não temos a quantidade suficiente em nosso estoque!');
		this.document.getElementById("quantidade").value = 1
		this.document.getElementById("quantidade").focus();
		return false;
	}

	/*if ((quantidade = 99) & (quantidade < estoqueatual) || (quantidade = 99) & (quantidade > estoqueatual) || ((quantidade = 100) || (quantidade > 100)))
	{
		alert('Desculpe o transtorno, mas você excedeu o limite de quantidade por produto!');
		this.document.getElementById("quantidade").value = 1
		this.document.getElementById("quantidade").focus();
		return false;
	}

	if ((quantidade = 99) & (quantidade > estoqueatual))
	{
		alert('Desculpe o transtorno, mas você excedeu o limite de quantidade por produto!');
		this.document.getElementById("quantidade").value = 1
		this.document.getElementById("quantidade").focus();
		return false;
	}

	if ((quantidade = 100) || (quantidade > 100))
	{
		alert('Desculpe o transtorno, mas você excedeu o limite de quantidade por produto!');
		this.document.getElementById("quantidade").value = 1
		this.document.getElementById("quantidade").focus();
		return false;
	}*/

	if (obj);
	else 
    {
		alert("Preencha uma quantidade válida!");
        this.document.getElementById("quantidade").value = 1
		this.document.getElementById("quantidade").focus();
		return false;
	}
}

function ValidaSimulaFrete() {
    padraoquant1 = /^([1-9]+[0-9]*)$/;

    quantidade1 = document.getElementById("quantidade1").value;
    estoqueatual1 = document.getElementById("estoqueatual1").value;
    qtdmaxcliente1 = document.getElementById("qtdmaxcliente1").value;

	var ref1 = new RegExp(padraoquant1);
	var obj1 = ref1.test(quantidade1);

	if (quantidade1 == "")
	{
		alert('O campo quantidade é obrigatório \n');
        this.document.getElementById("quantidade1").value = 1
		this.document.getElementById("quantidade1").focus();
		return false;
	}

    if ((quantidade1 > 0) & (quantidade1 < 10) || (quantidade1 > 9) & (quantidade1 < 99))
    {
        this.document.getElementById("quantidade1").value = document.getElementById("quantidade1").value
        this.document.getElementById("quantidade1").focus();
        return true;
    }

	if ((quantidade1 > estoqueatual1) || (quantidade1 > qtdmaxcliente1))
	{
		alert('Desculpe o transtorno, mas não temos a quantidade suficiente em nosso estoque!');
		this.document.getElementById("quantidade1").value = 1
		this.document.getElementById("quantidade1").focus();
		return false;
	}

	/*if ((quantidade1 = 99) & (quantidade1 < estoqueatual1) || (quantidade1 = 99) & (quantidade1 > estoqueatual1) || (quantidade1 = 100) || (quantidade1 > 100))
	{
		this.document.getElementById("quantidade1").value = 1
		this.document.getElementById("quantidade1").focus();
		return false;
	}*/

	if (obj1);
	else 
    {
		alert("Preencha uma quantidade válida!");
        this.document.getElementById("quantidade1").value = 1
		this.document.getElementById("quantidade1").focus();
		return false;
	}

	if (document.getElementById("cep1").value == "")
	{
		alert('O campo CEP é obrigatório \n');
		this.document.getElementById("cep1").focus();
		return false;
	}

	if (isNaN(document.getElementById("cep1").value))
	{
		alert('O campo CEP deve conter apenas numeros!');
		this.document.getElementById("cep1").focus();
		return false;
	}

	if (document.getElementById("cep2").value == "")
	{
		alert('O campo CEP é obrigatório \n');
		this.document.getElementById("cep2").focus();
		return false;
	}

	if (isNaN(document.getElementById("cep2").value))
	{
		alert('O campo CEP deve conter apenas numeros!');
		this.document.getElementById("cep2").focus();
		return false;
	}

    else {
        return true;
    }

}

/*-----------------------------------------------------------------------
Validação para os campos de Carrinho e Autenticacao e Direita
-----------------------------------------------------------------------*/

function ValidaLogin()
{
	if (document.getElementById("email").value == "")
	{
		alert('O campo Login e obrigatorio \n');
		this.document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("email").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail esta no formato errado \n');
		this.document.getElementById("email").focus();
		return false;
	}	
	if (document.getElementById("nome3").value == "")
	{
		alert('O campo Senha e obrigatorio \n');
		this.document.getElementById("nome3").focus();
		return false;
	}
	if (document.getElementById("login").value == "")
	{
		alert('O campo Login e obrigatorio \n');
		this.document.getElementById("login").focus();
		return false;
	}	
	if (document.getElementById("senha").value == "")
	{
		alert('O campo Senha e obrigatorio \n');
		this.document.getElementById("senha").focus();
		return false;
	}	
	else{
		return true;
	}	
}

/*-----------------------------------------------------------------------
Validação para os campos de Carrinho, Autenticacao e Direita
-----------------------------------------------------------------------*/

function ValidaDuvidas()
{	
	if (document.getElementById("enviadopor").value == "")
	{
		alert('O campo Nome e obrigatorio \n');
		this.document.getElementById("enviadopor").focus();
		return false;
	}
	if (document.getElementById("email").value == "")
	{
		alert('O campo Email e obrigatorio \n');
		this.document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("email").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail esta no formato errado \n');
		this.document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("ddd").value == "")
	{
		alert('O campo Telefone DDD e obrigatorio \n');
		this.document.getElementById("ddd").focus();
		return false;
	}
	if (isNaN(document.getElementById("ddd").value))
	{
		alert('O campo Telefone DDD deve conter apenas numeros!');
		this.document.getElementById("ddd").focus();
		return false;
	}	
	if (document.getElementById("telefone").value == "")
	{
		alert('O campo Telefone e obrigatorio \n');
		this.document.getElementById("telefone").focus();
		return false;
	}
	if (isNaN(document.getElementById("telefone").value))
	{
		alert('O campo Telefone deve conter apenas numeros!');
		this.document.getElementById("telefone").focus();
		return false;
	}	
	if (document.getElementById("cidade").value == "")
	{
		alert('O campo Cidade e obrigatorio \n');
		this.document.getElementById("cidade").focus();
		return false;
	}
	if (document.getElementById("pergunta").value == "")
	{
		alert('O campo Mensagem e obrigatorio \n');
		this.document.getElementById("pergunta").focus();
		return false;
	}
	if (document.getElementById("captchaTxt").value == "") {
		alert('Voce deve preencher os caracteres que aparecem na imagem \n');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	if (document.getElementById("captchaVerify").value.indexOf("incorreto") > -1)
	{
		alert('Os caracteres digitados nao conferem com os da imagem!');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	else{
		return true;
	}	
}

/*-----------------------------------------------------------------------
Validação para os campos de Carrinho(Opine)
-----------------------------------------------------------------------*/

function ValidaOpine()
{
	if (document.getElementById("titulo").value == "")
	{
		alert('O campo Titulo e obrigatorio \n');
		this.document.getElementById("titulo").focus();
		return false;
	}
	if (document.getElementById("resenha").value == "")
	{
		alert('O campo Resenha e obrigatorio \n');
		this.document.getElementById("resenha").focus();
		return false;
	}
	if (document.getElementById("nome").value == "")
	{
		alert('O campo Nome e obrigatorio \n');
		this.document.getElementById("nome").focus();
		return false;
	}
	if (document.getElementById("email").value == "")
	{
		alert('O campo E-mail e obrigatorio \n');
		this.document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("email").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail esta no formato errado \n');
		this.document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("cidade").value == "")
	{
		alert('O campo Cidade e obrigatorio \n');
		this.document.getElementById("cidade").focus();
		return false;
	}
	if (document.getElementById("captchaTxt").value == "") {
		alert('Voce deve preencher os caracteres que aparecem na imagem \n');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	if (document.getElementById("captchaVerify").value.indexOf("incorreto") > -1)
	{
		alert('Os caracteres digitados nao conferem com os da imagem!');
		this.document.getElementById("captchaTxt").focus();
		return false;
	}
	else{
		return true;
	}	
}

//ÍNICIO CAMPO E-MAIL OBRIGATORIO
function Validar() {
    if (document.novocadastro.email.value == "") {
        alert("O preenchimento do e-mail é obrigatório.");
        document.novocadastro.email.focus();
        return false;
    }

    if (!ValidaTexto(document.novocadastro.email.value)) {

        alert("Não utilize acentuação e caracteres inválidos no campo e-mail.");

        document.novocadastro.email.focus();

        return false;

    }

    if (!ValidaEmail(document.novocadastro.email.value)) {

        alert("Você digitou um e-mail inválido.");

        document.novocadastro.email.focus();

        return false;
    }

    return true;
}

function ValidaEmail(email) {
    var achou_ponto = false;
    var achou_arroba = false;
    var achou_caracter = false;

    for (var i = 0; i < email.length; i++) {
        if (email.charAt(i) == "@") {
            if (email.charAt(i + 1) == ".")
                achou_arroba = false;
            else
                achou_arroba = true;
        }
        else if (email.charAt(i) == ".") achou_ponto = true;
        else if (email.charAt(i) != " ") achou_caracter = true;
    }

    if ((email.charAt(0) == "W" || email.charAt(0) == "w") &&
        (email.charAt(1) == "W" || email.charAt(1) == "w") &&
        (email.charAt(2) == "W" || email.charAt(2) == "w") &&
        (email.charAt(3) == ".")) {
        achou_ponto = false;
        achou_caracter = false;
    }
    if (email.charAt(email.length - 1) == ".") {
        achou_ponto = false;
    }
    return (achou_ponto && achou_arroba && achou_caracter);
}

function ValidaTexto(s) // Critica se ha caracteres estranhos
{
    var i;
    var c;

    for (i = 0; i < s.length; i++) {
        c = s.substring(i, i + 1);
        //if (!( isalpha(c) || 
        //    isdigit(c) ||
        //    ispunct(c) ) )  
        //return false;
    }
    return true;
}
    
//FINAL CAMPO E-MAIL OBRIGATORIO

//ÍNICIO CAMPO CEP OBRIGATORIO
    /*function validarprecadastro(form) {

    if (document.formulariodecadastro.cep_1.value == "") {
        alert("O campo CEP é obrigatótio!");
        formulariodecadastro.cep_1.focus();
        return false;
    }

    if (document.formulariodecadastro.email.value == "") {
        alert("O campo E-mail é obrigatótio!");
        formulariodecadastro.email.focus(); // coloque esse linha no script fazendo referência ao formulário e ao campo com foco //
        return false;
    } // a seguir a validação do e-mail pelo @

    // este campo abaixo verifica o e-mail
    else {
        if (document.formulariodecadastro.email.value.indexOf("@") == -1) {
            alert("Digite um e-mail válido.");
            formulariodecadastro.email.focus(); // coloque esse linha no script fazendo referência ao formulário e ao campo com foco //
            return false;
        }
    }
}*/
//FINAL CAMPO CEP OBRIGATORIO

/*-----------------------------------------------------------------------
INÍCIO Validação para os campos de Cadastrese
-----------------------------------------------------------------------*/
function ValidaCadastrese() {

	if (document.getElementById("email1").value == "" ) {
		alert('O campo E-mail deve ser preenchido \n');
		this.document.getElementById("email1").focus();
		return false;
	}
	if (document.getElementById("email1").value == 'digite seu e-mail' ) {
		alert('O campo E-mail deve ser preenchido \n');
		this.document.getElementById("email1").focus();
		return false;
	}
	if (document.getElementById("email1").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail está no formato errado \n');
		this.document.getElementById("email1").focus();
		return false;
	}

    padraoCEP = /^[1-9]{2}[0-9]{3}[0-9]{3}$/;
	strCEP = document.getElementById("cep1").value;
	
	var ref = new RegExp(padraoCEP);
	var obj = ref.test(strCEP);

	if (document.getElementById("cep1").value == "")
	{
		alert('O campo CEP deve ser preenchido!');
        this.document.getElementById("cep1").focus();
		return false;
	}

	if (document.getElementById("cep1").value == 'digite seu cep')
	{
		alert('O campo CEP deve ser preenchido!');
        this.document.getElementById("cep1").focus();
		return false;
	}

	if (obj)
		return true;
	else {
		alert("Preencha um CEP válido!");
        this.document.getElementById("cep1").value = ''
		this.document.getElementById("cep1").focus();
		return false;
	}	
}
/*-----------------------------------------------------------------------
FIM Validação para os campos de Cadastrese
-----------------------------------------------------------------------*/

/*-----------------------------------------------------------------------
INÍCIO Validação para os campos de Autenticação
-----------------------------------------------------------------------*/
function ValidaAutenticacao() {

	if (document.getElementById("emailaut1").value == "" ) {
		alert('O campo E-mail deve ser preenchido \n');
		this.document.getElementById("emailaut1").focus();
		return false;
	}
	if (document.getElementById("emailaut1").value == 'digite seu e-mail' ) {
		alert('O campo E-mail deve ser preenchido \n');
		this.document.getElementById("emailaut1").focus();
		return false;
	}
	if (document.getElementById("emailaut1").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail está no formato errado \n');
		this.document.getElementById("emailaut1").focus();
		return false;
	}
	if (document.getElementById("senhaaut1").value == 'xxxxxxxxxx')
	{
		alert('O campo Senha é obrigatório \n');
		this.document.getElementById("senhaaut1").focus();
		return false;
	}
	if (document.getElementById("senhaaut1").value == "")
	{
		alert('O campo Senha é obrigatório \n');
		this.document.getElementById("senhaaut1").focus();
		return false;
	}
	else{
		return true;
	}
}
/*-----------------------------------------------------------------------
FIM Validação para os campos de Autenticação
-----------------------------------------------------------------------*/

/*-----------------------------------------------------------------------
INÍCIO Validação para os campos de Reenviar Senha
-----------------------------------------------------------------------*/
function ValidaReenviarSenha() {

	if (document.getElementById("emailre1").value == "" ) {
		alert('O campo E-mail deve ser preenchido \n');
		this.document.getElementById("emailre1").focus();
		return false;
	}
	if (document.getElementById("emailre1").value == 'digite seu e-mail' ) {
		alert('O campo E-mail deve ser preenchido \n');
		this.document.getElementById("emailre1").focus();
		return false;
	}
	if (document.getElementById("emailre1").value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
	{
		alert('O campo E-mail está no formato errado \n');
		this.document.getElementById("emailre1").focus();
		return false;
	}
	else{
		return true;
	}
}
/*-----------------------------------------------------------------------
FIM Validação para os campos de Reenviar Senha
-----------------------------------------------------------------------*/

