var DominioSeguro = "https://anep1.websiteseguro.com/";

hiddenImgA1=new Image();
hiddenImgA1.src="imagens/ficha1a.gif";
hiddenImgA2=new Image();
hiddenImgA2.src="imagens/ficha2a.gif";
hiddenImgA3=new Image();
hiddenImgA3.src="imagens/ficha3a.gif";

hiddenImgB1=new Image();
hiddenImgB1.src="imagens/ficha1b.gif";
hiddenImgB2=new Image();
hiddenImgB2.src="imagens/ficha2b.gif";
hiddenImgB3=new Image();
hiddenImgB3.src="imagens/ficha3b.gif";

function Ficha(Pos,Lim)
{
  for (Ind=1;Ind<=Lim;Ind++)
    if (Ind==Pos)
    {
      document.getElementById("ficha"+Pos).style.visibility="visible";
      document.getElementById("ficha"+Pos).style.display="block";
      document.getElementById("img"+Pos).src=eval("hiddenImgA"+Pos+".src");
    }
    else
    {
      document.getElementById("ficha"+Ind).style.visibility="hidden";
      document.getElementById("ficha"+Ind).style.display="none";
      document.getElementById("img"+Ind).src=eval("hiddenImgB"+Ind+".src");
    }
}

function bannerRotate()
{
  if(myCount > bannerArray.length-1)
  {
    myCount=0;
  }
  document.getElementById("dv3").innerHTML=bannerArray[myCount];
  setTimeout("bannerRotate()", 5000);
  myCount++;
}

function Invisivel(Tipo)
{
  if (Tipo=="S")
  {
    document.getElementById("invisivel").style.visibility="visible";
    document.getElementById("invisivel").style.display="block";
  }
  else
  {
    document.getElementById("invisivel").style.visibility="hidden";
    document.getElementById("invisivel").style.display="none";
  }
  return true;
}

function Janela(url,lar,alt,rol)
{
  window.open(url,"","location=no,directories=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars="+rol+",width="+lar+",height="+alt);
}

function JanelaCartao(url,lar,alt,rol)
{
/*
  if (document.Carrinho.Forma[3].checked == true || document.Carrinho.Forma[4].checked == true)
  {
    if (document.Carrinho.Forma[3].checked == true)
      Cartao = document.Carrinho.Forma[3].value;
    else
      Cartao = document.Carrinho.Forma[4].value;
    if (document.Carrinho.Correio[0].checked == true)
    {
      Valor = document.Carrinho.TotalSimples.value * 100;
      Correio = document.Carrinho.Correio[0].value;
    }
    else
    {
      if (document.Carrinho.Correio[1].checked == true)
      {
        Valor = document.Carrinho.TotalExpresso1.value * 100;
        Correio = document.Carrinho.Correio[1].value;
      }
      else
      {
        Valor = document.Carrinho.TotalExpresso2.value * 100;
        Correio = document.Carrinho.Correio[2].value;
      }
    }
    Valor = parseInt(Valor);
    window.open(DominioSeguro+"redecard_janela.php?Cartao="+Cartao+"&ValorPedido="+Valor+"&Correio="+Correio,"","location=no,directories=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=yes,width=700,height=500");
  }
  else if (document.Carrinho.Forma[5].checked == true)
  {
    Cartao = document.Carrinho.Forma[5].value;
    if (document.Carrinho.Correio[0].checked == true)
    {
      Valor = document.Carrinho.TotalSimples.value * 100;
      Correio = document.Carrinho.Correio[0].value;
    }
    else
    {
      if (document.Carrinho.Correio[1].checked == true)
      {
        Valor = document.Carrinho.TotalExpresso1.value * 100;
        Correio = document.Carrinho.Correio[1].value;
      }
      else
      {
        Valor = document.Carrinho.TotalExpresso2.value * 100;
        Correio = document.Carrinho.Correio[2].value;
      }
    }
    Valor = parseInt(Valor);
    window.open(DominioSeguro+"visa_janela.php?Cartao="+Cartao+"&ValorPedido="+Valor+"&Correio="+Correio,"","location=no,directories=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=yes,width=700,height=500");
  }
  else
  {
*/
    document.Carrinho.action = DominioSeguro+"index.php?Escolha=23";
    document.Carrinho.submit();
/*
  }
*/
}

function VerificaSql(texto)
{
  if (texto.indexOf('insert',0) != -1 || texto.indexOf('update',0) != -1 || texto.indexOf('delete',0) != -1 || texto.indexOf('drop',0) != -1 || texto.indexOf('exec',0) != -1 || texto.indexOf('--',0) != -1 || texto.indexOf('@@',0) != -1 || texto.indexOf(';',0) != -1 || texto.indexOf("\'",0) != -1 || texto.indexOf("'",0) != -1 || texto.indexOf('""',0) != -1)
  {
    return true;
  }
  return false;
}

function VerificaEmail(email)
{
  var reEmail = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
  if (reEmail.test(email))
  {
    return false;
  }
  return true;
}

function ValidaPesquisa()
{
  if (document.Pesquisa.Texto.value.length < 1 || VerificaSql(document.Pesquisa.Texto.value))
  {
    window.alert("Não foi digitado nenhum texto ou foram utilizados caracteres inválidos!");
    return false;
  }
  return true;
}

function ValidaLogin()
{
  if (document.Login.Email.value.length < 1 || VerificaSql(document.Login.Email.value) || VerificaEmail(document.Login.Email.value))
  {
    window.alert("É necessário digitar um E-mail válido ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Login.Senha.value.length < 1 || VerificaSql(document.Login.Senha.value))
  {
    window.alert("É necessário digitar uma Senha ou foram utilizados caracteres inválidos!");
    return false;
  }
  return true;
}

function ValidaLogin2()
{
  if (document.Login2.Email.value.length < 1 || VerificaSql(document.Login2.Email.value) || VerificaEmail(document.Login2.Email.value))
  {
    window.alert("É necessário digitar um E-mail válido ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Login2.Senha.value.length < 1 || VerificaSql(document.Login2.Senha.value))
  {
    window.alert("É necessário digitar uma Senha ou foram utilizados caracteres inválidos!");
    return false;
  }
  return true;
}

function ValidaNews()
{
  if (document.Newsletter.Nome.value.length < 1 || VerificaSql(document.Newsletter.Nome.value))
  {
    window.alert("É necessário digitar um Nome ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Newsletter.Email.value.length < 1 || VerificaSql(document.Newsletter.Email.value) || VerificaEmail(document.Newsletter.Email.value))
  {
    window.alert("É necessário digitar um E-mail válido ou foram utilizados caracteres inválidos!");
    return false;
  }
  return true;
}

function ValidaFale()
{
  if (document.Fale.Nome.value.length < 1 || VerificaSql(document.Fale.Nome.value))
  {
    window.alert("É necessário digitar um Nome ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Fale.Email.value.length < 1 || VerificaSql(document.Fale.Email.value) || VerificaEmail(document.Fale.Email.value))
  {
    window.alert("É necessário digitar um E-mail válido ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Fale.Assunto.value.length < 1 || VerificaSql(document.Fale.Assunto.value))
  {
    window.alert("É necessário digitar um Assunto ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Fale.Mensagem.value.length < 1 || VerificaSql(document.Fale.Mensagem.value))
  {
    window.alert("É necessário digitar uma Mensagem ou foram utilizados caracteres inválidos!");
    return false;
  }
  return true;
}

function ValidaEsquema()
{
  if (document.Esquema.Nome.value.length < 1 || VerificaSql(document.Esquema.Nome.value))
  {
    window.alert("É necessário digitar um Nome ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Esquema.Email.value.length < 1 || VerificaSql(document.Esquema.Email.value) || VerificaEmail(document.Esquema.Email.value))
  {
    window.alert("É necessário digitar um E-mail válido ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Esquema.Endereco.value.length < 1 || VerificaSql(document.Esquema.Endereco.value))
  {
    window.alert("É necessário digitar um Endereço ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Esquema.Bairro.value.length < 1 || VerificaSql(document.Esquema.Bairro.value))
  {
    window.alert("É necessário digitar um Bairro ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Esquema.Cidade.value.length < 1 || VerificaSql(document.Esquema.Cidade.value))
  {
    window.alert("É necessário digitar uma Cidade ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Esquema.Cep.value.length < 1 || VerificaSql(document.Esquema.Cep.value))
  {
    window.alert("É necessário digitar um CEP ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Esquema.Telefones.value.length < 1 || VerificaSql(document.Esquema.Telefones.value))
  {
    window.alert("É necessário digitar um Telefone ou foram utilizados caracteres inválidos!");
    return false;
  }
  return true;
}

function ValidaRevenda()
{
  if (document.Revenda.Empresa.value.length < 1 || VerificaSql(document.Revenda.Empresa.value))
  {
    window.alert("É necessário digitar a Empresa ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Revenda.Cnpj.value.length < 1 || VerificaSql(document.Revenda.Cnpj.value))
  {
    window.alert("É necessário digitar o CNPJ ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Revenda.Endereco.value.length < 1 || VerificaSql(document.Revenda.Endereco.value))
  {
    window.alert("É necessário digitar o Endereço ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Revenda.Bairro.value.length < 1 || VerificaSql(document.Revenda.Bairro.value))
  {
    window.alert("É necessário digitar o Bairro ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Revenda.Cidade.value.length < 1 || VerificaSql(document.Revenda.Cidade.value))
  {
    window.alert("É necessário digitar a Cidade ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Revenda.Estado.value.length < 1)
  {
    window.alert("É necessário selecionar o Estado!");
    return false;
  }
  if (document.Revenda.Cep.value.length < 1 || VerificaSql(document.Revenda.Cep.value))
  {
    window.alert("É necessário digitar o CEP ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Revenda.Telefone.value.length < 1 || VerificaSql(document.Revenda.Telefone.value))
  {
    window.alert("É necessário digitar o Telefone ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Revenda.Responsavel.value.length < 1 || VerificaSql(document.Revenda.Responsavel.value))
  {
    window.alert("É necessário digitar o Responsavel ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Revenda.Email.value.length < 1 || VerificaSql(document.Revenda.Email.value) || VerificaEmail(document.Revenda.Email.value))
  {
    window.alert("É necessário digitar um E-mail válido ou foram utilizados caracteres inválidos!");
    return false;
  }
  return true;
}

function ValidaAssinatura()
{
  if (VerificaSql(document.Assinatura.Nome.value))
  {
    window.alert("Foram utilizados caracteres inválidos no campo Nome!");
    return false;
  }
  if (VerificaSql(document.Assinatura.Empresa.value))
  {
    window.alert("Foram utilizados caracteres inválidos no campo Empresa!");
    return false;
  }
  if (document.Assinatura.Nome.value.length < 1 && document.Assinatura.Empresa.value.length < 1)
  {
    window.alert("É necessário digitar o um Nome ou Empresa!");
    return false;
  }
  if (document.Assinatura.CpfCnpj.value.length < 1 || VerificaSql(document.Assinatura.CpfCnpj.value))
  {
    window.alert("É necessário digitar o CPF/CNPJ ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Assinatura.Endereco.value.length < 1 || VerificaSql(document.Assinatura.Endereco.value))
  {
    window.alert("É necessário digitar o Endereço ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Assinatura.Bairro.value.length < 1 || VerificaSql(document.Assinatura.Bairro.value))
  {
    window.alert("É necessário digitar o Bairro ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Assinatura.Cidade.value.length < 1 || VerificaSql(document.Assinatura.Cidade.value))
  {
    window.alert("É necessário digitar a Cidade ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Assinatura.Estado.value.length < 1)
  {
    window.alert("É necessário selecionar o Estado!");
    return false;
  }
  if (document.Assinatura.Cep.value.length < 1 || VerificaSql(document.Assinatura.Cep.value))
  {
    window.alert("É necessário digitar o CEP ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Assinatura.Telefone.value.length < 1 || VerificaSql(document.Assinaturaa.Telefone.value))
  {
    window.alert("É necessário digitar o Telefone ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Assinatura.Email.value.length < 1 || VerificaSql(document.Assinatura.Email.value) || VerificaEmail(document.Assinatura.Email.value))
  {
    window.alert("É necessário digitar um E-mail válido ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Assinatura.Revista.value.length < 1)
  {
    window.alert("É necessário selecionar uma revista!");
    return false;
  }
  return true;
}

function ValidaPesquisa2()
{
  if (document.Pesquisa2.Palavra.value.length < 1 && document.Pesquisa2.Titulo.value.length < 1 && document.Pesquisa2.Autor.value.length < 1 && document.Pesquisa2.Isbn.value.length < 1 && document.Pesquisa2.Categoria.value.length < 1 && document.Pesquisa2.Tema.value.length < 1)
  {
    window.alert("É necessário digitar ou selecionar alguma informação nos campos Palavra-chave, Título, Autor, ISBN, Categoria ou Tema!");
    return false;
  }
  else
    if (VerificaSql(document.Pesquisa2.Palavra.value) || VerificaSql(document.Pesquisa2.Titulo.value) || VerificaSql(document.Pesquisa2.Autor.value) || VerificaSql(document.Pesquisa2.Isbn.value) || VerificaSql(document.Pesquisa2.Categoria.value) || VerificaSql(document.Pesquisa2.Tema.value))
    {
      window.alert("Foram utilizados caracteres inválidos!");
      return false;
    }
  return true;
}

function ValidaLembrarSenha()
{
  if (document.LembrarSenha.Email.value.length < 1 || VerificaSql(document.LembrarSenha.Email.value) || VerificaEmail(document.LembrarSenha.Email.value))
  {
    window.alert("É necessário digitar um E-mail válido ou foram utilizados caracteres inválidos!");
    return false;
  }
  return true;
}

function ValidaCadastro()
{
  if (document.Cadastro.Nome.value.length < 1 || VerificaSql(document.Cadastro.Nome.value))
  {
    window.alert("É necessário digitar o Nome ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Cadastro.Endereco.value.length < 1 || VerificaSql(document.Cadastro.Endereco.value))
  {
    window.alert("É necessário digitar o Endereço ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Cadastro.Bairro.value.length < 1 || VerificaSql(document.Cadastro.Bairro.value))
  {
    window.alert("É necessário digitar o Bairro ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Cadastro.Cidade.value.length < 1 || VerificaSql(document.Cadastro.Cidade.value))
  {
    window.alert("É necessário digitar a Cidade ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Cadastro.Uf.value.length < 1)
  {
    window.alert("É necessário selecionar o Estado!");
    return false;
  }
  if (document.Cadastro.Cep.value.length < 1 || VerificaSql(document.Cadastro.Cep.value))
  {
    window.alert("É necessário digitar o CEP ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Cadastro.Ddd.value.length < 1 || VerificaSql(document.Cadastro.Ddd.value))
  {
    window.alert("É necessário digitar o DDD ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Cadastro.Telefone.value.length < 1 || VerificaSql(document.Cadastro.Telefone.value))
  {
    window.alert("É necessário digitar o Telefone ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Cadastro.Email.value.length < 1 || VerificaSql(document.Cadastro.Email.value) || VerificaEmail(document.Cadastro.Email.value))
  {
    window.alert("É necessário digitar um E-mail válido ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.Cadastro.Senha.value.length < 6)
  {
    window.alert("É necesário preencher o campo Senha (mínimo de 6 caracteres).");
    return false;
  }
  if (document.Cadastro.Senha.value != document.Cadastro.SenhaAux.value)
  {
    window.alert("As senhas não combinam!");
    return false;
  }
  return true;
}

function ValidaIndicaLivro()
{
  if (document.IndicaLivro.NomeA.value.length < 1 || VerificaSql(document.IndicaLivro.NomeA.value))
  {
    window.alert("É necessário digitar o seu Nome ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.IndicaLivro.EmailA.value.length < 1 || VerificaSql(document.IndicaLivro.EmailA.value) || VerificaEmail(document.IndicaLivro.EmailA.value))
  {
    window.alert("É necessário digitar seu E-mail ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.IndicaLivro.NomeB.value.length < 1 || VerificaSql(document.IndicaLivro.NomeB.value))
  {
    window.alert("É necessário digitar o Nome do Amigo ou foram utilizados caracteres inválidos!");
    return false;
  }
  if (document.IndicaLivro.EmailB.value.length < 1 || VerificaSql(document.IndicaLivro.EmailB.value) || VerificaEmail(document.IndicaLivro.EmailB.value))
  {
    window.alert("É necessário digitar o E-mail do Amigo ou foram utilizados caracteres inválidos!");
    return false;
  }
  return true;
}

function Finaliza()
{
  document.Carrinho.action = DominioSeguro+"index.php?Escolha=21";
  document.Carrinho.submit();
}

function VerificaVoto(url)
{
  var retorno = false;
  for(ind=0;ind<document.enquete.length-1;ind++)
    if (document.enquete.resposta[ind].checked)
    {
      retorno = true;
      valor   = document.enquete.resposta[ind].value;
    }
  if (retorno == true)
    Janela(url + "&resposta=" + valor,'270','330','no');
  else
    alert("Escolha uma opção!");
  return retorno;
}



