function gotoURL(end){
  controleUnload = "true";
  registraEstatistica('Home/BuscaRapida');
  document.location = end;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
}

function addFav(){
    var url      = "http://www.rolo4x4.com.br";
    var title    = "Rolo4x4 - Classificados Off Road";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

function RedRect(id){
	window.open('dadosRedirect.asp?id='+id,'_blank');
}

//VALIDAÇÃO DA DATA
function VerificaData(digData){
        var bissexto = 0;
        var data = digData;
        var tam = data.length;
        if (tam == 10){
         var dia = data.substr(0,2)
         var mes = data.substr(3,2)
         var ano = data.substr(6,4)
         if ((ano > 1900)||(ano < 2100)){
          switch (mes){
           case '01':
           case '03':
           case '05':
           case '07':
           case '08':
           case '10':
           case '12':
            if(dia <= 31){
             return true;
            }
            break
           case '04':
           case '06':
           case '09':
           case '11':
            if  (dia <= 30){
             return true;
            }
            break
           case '02':
            /* Validando ano Bissexto / fevereiro / dia */
            if ((ano % 4 == 0) || (ano % 100 == 0) || (ano % 400 == 0)){
             bissexto = 1;
            }
            if ((bissexto == 1) && (dia <= 29)){
             return true;
            }
            if ((bissexto != 1) && (dia <= 28)){
             return true;
            }
            break
          }
        }
      }
      alert("Data de Nascimento inválida!");
      return false;
}

function geralPop(url,janela,larg,alt,scroll,pos1,pos2){
  window.open(url,janela,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scroll+',resizable=no,copyhistory=no,top="+pos1+",left="+pos2+",screenY="+pos1+",screenX="+pos2+",width="+larg+",height="+alt);
}

//Limpar Caracteres
function Limpar(valor, validos) {
// retira caracteres invalidos da string
var result = "";
var aux;
for (var i=0; i < valor.length; i++) {
aux = validos.indexOf(valor.substring(i, i+1));
if (aux>=0) {
result += aux;
}
}
return result;
}

function hidestatus(){
  window.status="O|||O - Rolo4x4"
  return true
}

function upperCase(x){
var y=document.getElementById(x).value
document.getElementById(x).value=y.toUpperCase()
}

function setOrder(str,cate,tipo,tpa){
  window.location = "dadosClassificados.asp?idOrdem="+str+"&cat="+cate+"&tip="+tipo+"&tpa="+tpa;
}

function setOrderBusca(str,cate,tipo,tpa,busc){
  window.location = "dadosBusca.asp?idOrdem="+str+"&cat="+cate+"&tip="+tipo+"&tpa="+tpa+"&busca="+busc;
}

function BoolDel(obj){
if( confirm('Deseja mesmo deletar o Anúncio?') )
obj.submit();
else
return false;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
 }

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
  if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
  obj.visibility=v; }
}

//Função: PopUP Imagem
function doLoad() {

    if (document.all) {
        var wp = this.width+10
        var wh = this.height+29
    } else {
        var wp = this.width
        var wh = this.height
    }

    var s1 = "<HTML><TITLE>Rolo4x4 - Fotos</TITLE>" +
    "<BODY topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>"
    var s2 = "<IMG SRC='"+this.src+"'></BODY></HTML>"

    popup.document.write(s1+s2)
    popup.resizeTo(wp,wh)
    popup.document.close()
}

function doError() {
alert("Arquivo " + this.src + " não encontrado")
}

var i

function LoadImage(src) {

    if (document.all) {
        popup = window.open("carregando.htm","","height=150,width=250")
    } else {
        popup = window.open("carregando.htm","","height=200,width=200,resizable")
    }

i = new Image
i.onload = doLoad;
i.onerror = doError;
i.src = src
}

//Formata número tipo moeda usando o evento onKeyDown
function Formata(campo,tammax,teclapres,decimal){
  var tecla = teclapres.keyCode;
  vr = Limpar(campo.value,"0123456789");
  tam = vr.length;
  dec=decimal
  if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }
   if (tecla == 8 )
    { tam = tam - 1 ; }
    if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
    {
    if ( tam <= dec )
     { campo.value = vr ; }
    if ( (tam > dec) && (tam <= 5) ){
     campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
    if ( (tam >= 6) && (tam <= 8) ){
     campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ;
    }
    if ( (tam >= 9) && (tam <= 11) ){
     campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
    if ( (tam >= 12) && (tam <= 14) ){
     campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
    if ( (tam >= 15) && (tam <= 17) ){
     campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;}
    }
}

//Formata conforme mascara
//OnKeyPress="formatar(this,'#####-###')"
//OnKeyPress="formatar(this,'###.###.###-##')"
//OnKeyPress="formatar(this,'##/##/####')"
function formatar(src, mask) {
  var i = src.value.length;
  var saida = mask.substring(0,1);
  var texto = mask.substring(i)
  if (texto.substring(0,1) != saida){
    src.value += texto.substring(0,1);
  }
}


//Validação se realmenteo o que foi digitado é apenas numero
  function isNumber(inString){
    var tempChar;
     if (inString.length==0)
      return (false);
      refString="1234567890";
      for (count=0; count < inString.length; count++)  {
      tempChar = inString.substring (count, count+1);
      if (refString.indexOf (tempChar, 0) == -1)
       return (false);
    }
    return (true);
  }

//Validação se realmenteo o que foi digitado é apenas numero
  function isNumberVirgula(inString){
    var tempChar;
     if (inString.length==0)
      return (false);
      refString="1234567890.,-";
      for (count=0; count < inString.length; count++)  {
      tempChar = inString.substring (count, count+1);
      if (refString.indexOf (tempChar, 0) == -1)
       return (false);
    }
    return (true);
  }

//Validação de alpha numerico
function isAlphaNum( chr ) {
// Return immediately if an invalid value was passed in
    if (chr+"" == "undefined" || chr+"" == "null" || chr+"" == "")
     return false;
     var isValid = true;
     // convert to a string for performing string comparisons.
     chr += "";
     // Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
     if (!(((chr >= "0") && (chr <= "9")) ||
           ((chr >= "a") && (chr <= "z")) ||
           ((chr >= "A") && (chr <= "Z"))
          ))
         isValid = false;
        return isValid;
     }  // end isAlphaNum

//---------------------------------------------------------------------------
// Funcao    :isEmail( str )
// tratamento:Checa se a sintaxe do email, mas nao checa a autenticidade.
//---------------------------------------------------------------------------
function isEmail( str ) {
        // Return immediately if an invalid value was passed in
        if (str+"" == "undefined" || str+"" == "null" || str+"" == "")
            return false;

        var isValid = true;
        var ok = 0;
        // convert to a string for performing string comparisons.
        str += "";
        if ( str.charAt(0) == "@" || str.charAt(0) == ".") // descarta quando '.@' estiverem na inicio ou fim da str.
            return false;
        if ( str.charAt(str.length-1) == "@" || str.charAt(str.length-1) == ".")
            return false;

        // Loop through length of string and test for any alpha numeric
        // characters
        for (i = 0; i < str.length; i++)
        {
            if (!(// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
                    isAlphaNum(str.charAt(i))  ||
                    (str.charAt(i) == ".")     ||
                    (str.charAt(i) == "_")     ||
                    (str.charAt(i) == "-")     ||
                    (str.charAt(i) == "@")
               ))
                    {
                    isValid = false;
                    break;
                    }
                // se ele achou mais de um @
                if (
                       (str.charAt(i) == "@") &&
                        (ok == 1)
                    )
                        isValid = false;
                if ( str.charAt(i) == "@" )
                    ok = 1;
        } // END for

        if ( ok == 0 )
                isValid = false;
        return isValid;
}  // end isEmail

//Validação de email
function CheckEmail(email){
      email =  email + "";
      var atPos = email.indexOf("@");
      var tmp   = email.substring(atPos,email.length-2)
      var ptPos = tmp.indexOf(".");
      var cond = true
    if(email == "")
     return true;
     else
        {
         if((atPos  == -1) || (ptPos == -1) || !isEmail(email))
          cond = false
        }
   return cond
}

//Validação de nulo
function isNull (inString){
    if(inString == null) {
     return;
    }
    if(inString.length == 0) {
     return;
    }
}

//Validação do fomulario de Login
function validaLogin(){
  if(formLogin.login.value == ""){
   alert("Informe seu email!");
   return false;
  }
  if(formLogin.senha.value == ""){
   alert("Informe sua senha!");
   return false;
  }
MM_showHideLayers('aguarde','','show');
return true;
MM_showHideLayers('aguarde','','hide');
}

function CPFValido(st) {
   var ok = false;
        st = st;

// descarta a possibilidade de por um cpf de teste
   for (i=0;i<(st.length-1);i++){
     prev=st.charAt(i)
     next=st.charAt(i+1)
     if( prev != next)
      ok=true;
     }

    if ( ok != true )
     return (false)

        l = st.length;
        st2 = "";
        for (i = 0; i < l; i++) {
                caracter = st.charAt(i,i+1)
                if ((caracter >= '0') && (caracter <= '9'))
                        st2 = st2 + caracter;
        }
   if ((st2.length > 11) || (st2.length < 10))
        return (false);
        if (st2.length==10)
                st2 = '0' + st2;
        digito1 = st2.charAt(9,10)
        digito2 = st2.charAt(10,11)

        digito1 = parseInt(digito1,10)
        digito2 = parseInt(digito2,10)

        sum = 0; mul = 10;
        for (i = 0; i < 9 ; i++) {
        digit = st2.substring(i,i+1);
                tproduct = parseInt(digit ,10)*mul;
      sum += tproduct;
                mul--;
   }
        dig1 = ( sum % 11 )
        if ( dig1==0 || dig1==1 )
                dig1=0;
        else
                dig1 = 11 - dig1

        if (dig1!=digito1)
                return (false);

        sum = 0; mul = 11;
        for (i = 0; i < 10 ; i++) {
        digit = st2.substring(i,i+1);
                tproduct = parseInt(digit ,10)*mul;
      sum += tproduct;
                mul--;
        }
        dig2 = (sum % 11)

        if ( dig2==0 || dig2==1 )
                dig2=0;
        else
                dig2 = 11 - dig2;

        if (dig2 != digito2)
         return (false);
         return (true)
}

// Valida cnpj
function CNPJValido(s){
  var i;
  s = 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);
  }

//Validação do fomulario de Cadastro
function validaBoletim(){
  if(frm.strNome.value == ""){
   alert("Informe seu nome!");
   return false;
  }

  if(!CheckEmail(frm.strEmail.value) || frm.strEmail.value == ""){
   alert("Email Invalido!");
   return false;
  }
MM_showHideLayers('aguarde','','show');
return true;
MM_showHideLayers('aguarde','','hide');
}

//Validação do fomulario de Cadastro
function validaCadastro(){
  if(frmCadastroUser.nome.value == ""){
   alert("Nome Inválido!");
   return false;
  }
  if(frmCadastroUser.sobrenome.value == ""){
   alert("Sobrenome Inválido!");
   return false;
  }
  if(frmCadastroUser.dtNasc.value == ""){
   alert("Data de Nascimento Inválido!");
   return false;
  }
  if(frmCadastroUser.sexo.value == ""){
   alert("Selecione o sexo!");
   return false;
  }
  if(frmCadastroUser.endereco.value == ""){
   alert("Endereço Inválido!");
   return false;
  }
  if(frmCadastroUser.numero.value == "" || !isNumber(frmCadastroUser.numero.value) ){
   alert("Número do Endereço Inválido!");
   return false;
  }
  if(frmCadastroUser.bairro.value == ""){
   alert("Bairro Inválido!");
   return false;
  }
  if(frmCadastroUser.cep.value == "" || !isNumber(frmCadastroUser.cep.value) || frmCadastroUser.cep.value.length < 8){
   alert("CEP Inválido!");
   return false;
  }
  if(frmCadastroUser.estados.value == ""){
   alert("Estado Inválido!");
   return false;
  }
  if(!(CPFValido(frmCadastroUser.cpf_cnpj.value)) || !isNumber(frmCadastroUser.cpf_cnpj.value)){
   alert("CPF inválido");
   return false;
  }
  if(frmCadastroUser.ddd1.value == "" || frmCadastroUser.ddd1.value.length < 2 || frmCadastroUser.telefone.value.length < 8 || frmCadastroUser.telefone.value == "" || !isNumber(frmCadastroUser.ddd1.value) || !isNumber(frmCadastroUser.telefone.value)){
   alert("Telefone Inválido!");
   return false;
  }
  if(!CheckEmail(frmCadastroUser.email.value) || frmCadastroUser.email.value == ""){
   alert("Email Invalido!");
   return false;
  }
  if(frmCadastroUser.senha.value == "" || frmCadastroUser.conf_senha.value == ""){
   alert("Senha  Invalido!");
   return false;
  }
  if(frmCadastroUser.senha.value != frmCadastroUser.conf_senha.value){
   alert("A senha digitada não confere com o que foi digitado na confirmação da senha!");
   return false;
  }
MM_showHideLayers('aguarde','','show');
return true;
MM_showHideLayers('aguarde','','hide');
}

//Validação do fomulario de Alteracao de Cadastro
function validaAlteraCadastro(){
  if(frm.endereco.value == ""){
   alert("Informe seu endereço!");
   return false;
  }
  if(frm.numero.value == "" || !isNumber(frm.ddd1.value) ){
   alert("Informe o número!");
   return false;
  }
  if(frm.bairro.value == ""){
   alert("Informe seu bairro!");
   return false;
  }
  if(frm.cidade.value == ""){
   alert("Informe seu cidade!");
   return false;
  }
  if(frm.cep.value == "" || !isNumber(frm.ddd1.value) || frm.cep.value.length < 8){
   alert("Informe seu CEP!");
   return false;
  }
  if(frm.uf.value == ""){
   alert("Selecionar o estado!");
   return false;
  }
  if(frm.ddd1.value == "" || frm.ddd1.value.length < 2 || frm.telefone.value.length < 8 || frm.telefone.value == "" || !isNumber(frm.ddd1.value) || !isNumber(frm.telefone.value)){
   alert("Telefone Inválido!");
   return false;
  }
  if(!CheckEmail(frm.email.value) || frm.email.value == ""){
   alert("Email Invalido!");
   return false;
  }
MM_showHideLayers('aguarde','','show');
return true;
MM_showHideLayers('aguarde','','hide');
}

//Validação do fomulario Esqueceu Senha
function validaEsqueceuSenha(){
  if(frmValSenha.cpf_cnpj.value.length < 12) {
   if(!(CPFValido(frmValSenha.cpf_cnpj.value)) || !isNumber(frmValSenha.cpf_cnpj.value)){
    alert("CPF inválido");
    return false;
   }
  }else{
        if(!CNPJValido(frmValSenha.cpf_cnpj.value) || !isNumber(frmValSenha.cpf_cnpj.value)){
         alert("CNPJ INVALIDO!");
         return false;
        }
  }
  MM_showHideLayers('aguarde','','show');
  return true;
  MM_showHideLayers('aguarde','','hide');
}

//Validação do fomulario Esqueceu Senha
function alterarSenha(){
  if(frm.senha1.value == "" || frm.senha2.value == "") {
   alert("A Nova Senha e a Confirmação de Senha não podem estar em branco!");
   return false;
  }
  if(frm.senha1.value != frm.senha2.value){
   alert("A senha digirada não é igual a senha de confirmação!");
   return false;
  }
MM_showHideLayers('aguarde','','show');
return true;
MM_showHideLayers('aguarde','','hide');
}

//Oculta Div Cadastro de anuncio
function exibeTexto(vlr){
    if (vlr == 0){
     document.getElementById("assessorios").style.display = 'block';
     document.getElementById("auto").style.display = 'none';
     document.getElementById("motos").style.display = 'none';
    }
    if (vlr == 1){
     document.getElementById("assessorios").style.display = 'none';
     document.getElementById("auto").style.display = 'block';
     document.getElementById("motos").style.display = 'none';
    }
    if (vlr == 2){
     document.getElementById("assessorios").style.display = 'none';
     document.getElementById("auto").style.display = 'none';
     document.getElementById("motos").style.display = 'block';
    }

}

//Validação do fomulario cadastro de anuncio
function validaCadAnuncio(){
var cont=0;
for (i=0;i < document.formCadastro.tipo.length;i++)
if (document.formCadastro.tipo[i].checked==true)
cont++;
if(cont==0){
alert('Selecione o tipo do anúncio!');
return false;
}

var cont=0;
for (i=0;i < document.formCadastro.categoria.length;i++)
if (document.formCadastro.categoria[i].checked==true)
cont++;
if(cont==0){
alert('Selecione uma categoria para o anúncio!');
return false;
}

var cont=0;
for (i=0;i < document.formCadastro.itemCategoria.length;i++)
if (document.formCadastro.itemCategoria[i].checked==true)
cont++;
if(cont==0){
alert('Selecione um item da categoria do anúncio!');
return false;
}

if(document.formCadastro.titulo.value == ""){
 alert('Informe o título do anúncio!');
 return false;
}

if(document.formCadastro.valor.value == "" && !isNumberVirgula(document.formCadastro.valor.value)){
 alert('Informe o valor do que esta anúnciando!');
 return false;
}else{
    if(!isNumberVirgula(document.formCadastro.valor.value)){
     alert('Valor do anúncio inválido!');
     return false;
    }
}

if(document.formCadastro.descricao.value == ""){
 alert('Informe a descrição do anúncio!');
 return false;
}

MM_showHideLayers('aguarde','','show');
return true;
MM_showHideLayers('aguarde','','hide');
}

//Validação do fomulario alteração de anuncio
function validaAlteAnuncio(){
if(document.frm.titulo.value == ""){
 alert('Informe o título do anúncio!');
 return false;
}
if(document.frm.valor.value == ""){
 alert('Informe o valor do que esta anúnciando!');
 return false;
}else{
if(!isNumberVirgula(document.frm.valor.value)){
 alert('Valor do anúncio inválido!');
 return false;
}
}
if(document.frm.descricao.value == ""){
 alert('Informe a descrição do anúncio!');
 return false;
}
MM_showHideLayers('aguarde','','show');
return true;
MM_showHideLayers('aguarde','','hide');
}

//Validação do formulario de cadastramento de news
function validaCadNews(){
  var cont=0;
  for (i=0;i < document.frm.tipo.length;i++)
   if (document.frm.tipo[i].checked==true)
   cont++;
   if(cont==0){
    alert('Selecione o tipo do anúncio!');
    return false;
   }
   var cont=0;
   for (i=0;i < document.frm.categoria.length;i++)
    if (document.frm.categoria[i].checked==true)
     cont++;
    if(cont==0){
     alert('Selecione uma categoria para o anúncio!');
     return false;
   }
   var cont=0;
    for (i=0;i < document.frm.itemCategoria.length;i++)
     if (document.frm.itemCategoria[i].checked==true)
     cont++;
     if(cont==0){
      alert('Selecione um item da categoria do anúncio!');
      return false;
     }
    if(document.frm.valor.value == "0"){
     alert('Selecione um valor!');
     return false;
    }
MM_showHideLayers('aguarde','','show');
return true;
MM_showHideLayers('aguarde','','hide');
}

function funcProposta(str,str1){
  window.open('dadosPropostaAnuncio.asp?id='+str+"&cl="+str1,'_blank','width=610,height=440,status=no,scrollbars=no,resizable=no,top=0,left=0');
}

function funcAmigoEventos(str){
  window.open('dadosEnviaEventoAmigo.asp?ev='+str,'_blank','width=430,height=350,status=no,scrollbars=no,resizable=no,top=0,left=0');
}

function funcEnvEventos(str){
  window.open('dadosEnviaEvento.asp?ev='+str,'_blank','width=430,height=330,status=no,scrollbars=no,resizable=no,top=0,left=0');
}

function validaEvento(){

  if(formEventos.strDataInicial.value == ""){
   alert("Data inicial Inválida!");
   formEventos.strDataInicial.focus();
   return false;
  }

  if(formEventos.strDataFinal.value == ""){
   alert("Data final Inválida!");
   formEventos.strDataFinal.focus();
   return false;
  }

  if(formEventos.strTitulo.value == ""){
   alert("Título do evento Inválida!");
   formEventos.strTitulo.focus();
   return false;
  }

  if(formEventos.strDescricao.value == ""){
   alert("Descrição do evento Inválido!");
   formEventos.strDescricao.focus();
   return false;
  }

  if(formEventos.strDataEvento.value == ""){
   alert("Data do evento Inválido!");
   formEventos.strDataEvento.focus();
   return false;
  }

  if(formEventos.estados.value == ""){
   alert("Selecione o estado!");
   formEventos.estados.focus();
   return false;
  }

  if(formEventos.cidades.value == ""){
   alert("Selecione uma cidade!");
   formEventos.cidades.focus();
   return false;
  }

  if(!CheckEmail(formEventos.strEmail.value) || formEventos.strEmail.value == ""){
   alert("Email Invalido!");
   formEventos.strEmail.focus();
   return false;
  }

  if(formEventos.strTelefone.value == ""){
   alert("Telefone de contato Invalido!");
   formEventos.strTelefone.focus();
   return false;
  }

  MM_showHideLayers('aguarde','','show');
  return true;
  MM_showHideLayers('aguarde','','hide');
}

function validaEncontro(){

  if(formEncontros.strTitulo.value == ""){
   alert("Título do encontro Inválida!");
   formEncontros.strTitulo.focus();
   return false;
  }

  if(formEncontros.strDescricao.value == ""){
   alert("Descrição do encontro Inválido!");
   formEncontros.strDescricao.focus();
   return false;
  }

  if(formEncontros.strSemana.value == ""){
   alert("Dia da semana do encontro Inválido!");
   formEncontros.strSemana.focus();
   return false;
  }

  if(formEncontros.strHorario.value == ""){
   alert("Hora do encontro Inválido!");
   formEncontros.strHorario.focus();
   return false;
  }

  if(!CheckEmail(formEncontros.strEmail.value) || formEncontros.strEmail.value == ""){
   alert("Email Invalido!");
   formEncontros.strEmail.focus();
   return false;
  }

  if(formEncontros.estados.value == ""){
   alert("Selecione o estado!");
   formEncontros.estados.focus();
   return false;
  }

  if(formEncontros.cidades.value == ""){
   alert("Selecione uma cidade!");
   formEncontros.cidades.focus();
   return false;
  }

  if(formEncontros.strTelefone.value == ""){
   alert("Telefone de contato Invalido!");
   formEncontros.strTelefone.focus();
   return false;
  }

  MM_showHideLayers('aguarde','','show');
  return true;
  MM_showHideLayers('aguarde','','hide');
}

function validaProposta(){
  if(frmProsposta.txtNome.value == ""){
   alert("Nome Inválido!");
   return false;
  }
  if(!CheckEmail(frmProsposta.txtEmail.value) || frmProsposta.txtEmail.value == ""){
   alert("Email Invalido!");
   return false;
  }
  if(frmProsposta.txtTelDDD1.value == "" || !isNumber(frmProsposta.txtTelDDD1.value) || frmProsposta.txtTel1.value == "" || !isNumber(frmProsposta.txtTel1.value) || frmProsposta.txtTelDDD1.value.length < 2 || frmProsposta.txtTel1.value.length < 8){
   alert("Telefone Invalido!");
   return false;
  }
  if(frmProsposta.txtProposta.value == ""){
   alert("Proposta Inválida!");
   return false;
  }
  MM_showHideLayers('aguarde','','show');
  return true;
  MM_showHideLayers('aguarde','','hide');
}


function validaIndiqueProposta(){
  if(frmIndique4x4.txtNome.value == ""){
   alert("Nome Inválido!");
   return false;
  }
  if(!CheckEmail(frmIndique4x4.txtEmail.value) || frmIndique4x4.txtEmail.value == ""){
   alert("Email Invalido!");
   return false;
  }
  if(frmIndique4x4.txtNomeAmigo.value == ""){
   alert("Nome do Amigo Inválido!");
   return false;
  }
  if(!CheckEmail(frmIndique4x4.txtEmailAmigo.value) || frmIndique4x4.txtEmailAmigo.value == ""){
   alert("Email do Amigo Invalido!");
   return false;
  }
  if(frmIndique4x4.txtMensagem.value == ""){
   alert("Digite uma mensagem!");
   return false;
  }
  MM_showHideLayers('aguarde','','show');
  return true;
  MM_showHideLayers('aguarde','','hide');
}

function validaContato(){
   if (document.fale_com.nome.value == '') {
           alert("Preencha o campo nome!");
           document.fale_com.nome.focus();
           return false;
   }
   if (document.fale_com.email.value == '') {
           alert("Preencha o campo email!");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.email.value.indexOf("@")== -1)
   {
           alert("Preencha corretamente o campo email");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.email.value.indexOf(".")== -1)
   {
           alert("Preencha corretamente o campo email");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.email.value.length < 6)
   {
           alert("Preencha corretamente o campo email");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.cidade.value == '') {
           alert("Preencha o campo cidade!");
           document.fale_com.cidade.focus();
           return false;
   }
   if (document.fale_com.Estado.value == '') {
           alert("Preencha o campo estado!");
           document.fale_com.Estado.focus();
           return false;
   }
   if (document.fale_com.msg.value == '') {
           alert("Preencha o campo mensagem!");
           document.fale_com.msg.focus();
           return false;
   }
MM_showHideLayers('aguarde','','show');
return true;
MM_showHideLayers('aguarde','','hide');
}

function validaContatoAgenda4x4(){
   if (document.fale_com.nome.value == ''){
           alert("Preencha o campo nome!");
           document.fale_com.nome.focus();
           return false;
   }
   if (document.fale_com.email.value == ''){
           alert("Preencha o campo email!");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.email.value.indexOf("@")== -1){
           alert("Preencha corretamente o campo email!");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.email.value.indexOf(".")== -1){
           alert("Preencha corretamente o campo email!");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.email.value.length < 6){
           alert("Preencha corretamente o campo email!");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.msg.value.length < 6){
           alert("Preencha sua Dúvida!");
           document.fale_com.msg.focus();
           return false;
   }
   return true;
}

function validaContatoAmigoAgenda4x4(){
   if (document.fale_com.seuNome.value == ''){
           alert("Preencha o campo seu nome!");
           document.fale_com.seuNome.focus();
           return false;
   }
   if (document.fale_com.nomeAmigo.value == ''){
           alert("Preencha o campo nome do amigo!");
           document.fale_com.nomeAmigo.focus();
           return false;
   }
   if (document.fale_com.email.value == ''){
           alert("Preencha o campo email!");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.email.value.indexOf("@")== -1){
           alert("Preencha corretamente o campo email");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.email.value.indexOf(".")== -1){
           alert("Preencha corretamente o campo email");
           document.fale_com.email.focus();
           return false;
   }
   if (document.fale_com.email.value.length < 6){
           alert("Preencha corretamente o campo email");
           document.fale_com.email.focus();
           return false;
   }
   return true;
}

function mostraCombo(blnMostra){
   if (blnMostra){
     document.getElementById("aviso").style.display = 'none';
   }else{
     document.getElementById("aviso").style.display = 'block';
   }
}
function skyMostraCombo(blnMostra){
   if (blnMostra){
     document.getElementById("skybanner").style.display = 'none';
   }else{
     document.getElementById("skybanner").style.display = 'block';
   }
}
//Validação do fomulario de Pedido
function validaPedido(){
  if(frm.nome.value == ""){
   alert("Informe seu nome!");
   return false;
  }
  if(frm.sobrenome.value == ""){
   alert("Informe seu sobrenome!");
   return false;
  }
  if(frm.endereco.value == ""){
   alert("Informe seu endereço!");
   return false;
  }
  if(frm.numero.value == "" || !isNumber(frm.ddd1.value) ){
   alert("Informe o número!");
   return false;
  }
  if(frm.bairro.value == ""){
   alert("Informe seu bairro!");
   return false;
  }
  if(frm.cidade.value == ""){
   alert("Informe seu cidade!");
   return false;
  }
  if(frm.cep.value == "" || !isNumber(frm.cep.value) || frm.cep.value.length < 8){
   alert("Informe seu CEP!");
   return false;
  }
  if(frm.uf.value == ""){
   alert("Selecionar o estado!");
   return false;
  }
  if(frm.cpf_cnpj.value.length < 12) {
   if(!(CPFValido(frm.cpf_cnpj.value)) || !isNumber(frm.cpf_cnpj.value)){
    alert("CPF inválido");
    return false;
   }
  }else{
        if(!CNPJValido(frm.cpf_cnpj.value) || !isNumber(frm.cpf_cnpj.value)){
         alert("CNPJ INVALIDO!");
         return false;
        }
       }
  if(frm.ddd1.value == "" || frm.ddd1.value.length < 2 || frm.telefone.value.length < 8 || frm.telefone.value == "" || !isNumber(frm.ddd1.value) || !isNumber(frm.telefone.value)){
   alert("Telefone Inválido!");
   return false;
  }
  if(!CheckEmail(frm.email.value) || frm.email.value == ""){
   alert("Email Invalido!");
   return false;
  }
  if(!isNumber(frm.qtdPequena.value) || !isNumber(frm.qtdMedia.value) || !isNumber(frm.qtdGrande.value) || !isNumber(frm.qtdExtraGrande.value)){
   alert("Quantidade de camisetas Inválida!");
   return false;
  }else{
     if(frm.qtdPequena.value == "0" && frm.qtdMedia.value == "0" && frm.qtdGrande.value == "0" && frm.qtdExtraGrande.value == "0"){
      alert("Quantidade de camisetas Inválida!");
      return false;
     }
  }
MM_showHideLayers('aguarde','','show');
return true;
MM_showHideLayers('aguarde','','hide');
}

function validaFormNews(){
  if(frmNews.strNome.value == ""){
   alert("Nome Invalido!");
   return false;
  }
  if(!CheckEmail(frmNews.strEmail.value) || frmNews.strEmail.value == ""){
   alert("Email Invalido!");
   return false;
  }
return true;
}

function detect(){
  if (screen.width >= 1024 || screen.height >= 768){
    document.getElementById("tabela_extra").style.display = "block";
  //tabela_extra_gama.style.display = 'block';
  }
}

function showdiv(ativar,id1,id2){
    var A=document.getElementById(id1);
    var B=document.getElementById(id2);
        if(ativar=='sim'){
         document.getElementById("B").style.display = "block";
         document.getElementById("A").style.display = "none";
        }else{
              document.getElementById("A").style.display = "block";
              document.getElementById("B").style.display = "none";
            }
}

function registraEstatistica(objetoAcessado){
    var pageTracker = _gat._getTracker("UA-1881717-1");
        pageTracker._trackPageview(objetoAcessado+".htm");

    var pageTracker = _gat._getTracker("UA-9419694-2");
        pageTracker._trackPageview();
}

function registraEstatisticaBanner(objetoAcessado){
    var pageTracker = _gat._getTracker("UA-5638906-2");
        pageTracker._trackPageview(objetoAcessado+".htm");
}

function registraEstatisticaClickBanner(objetoAcessado){
    var pageTrackerEvent = _gat._getTracker("UA-9419694-2");
        pageTrackerEvent._trackEvent('BannerParceiro',objetoAcessado);
}

//Verifica o total de caracteres digitado na proposta
function contaChar(obj){
    var total = 1000;
    var tam = 0;
    if (obj != null)
        tam = obj.value.length;
    str="";
    str=str+tam;
    var restante = document.getElementById('Restante');
    restante.innerHTML = total - str;
    if (tam > total){
        restante.innerHTML = 0;
    }
}

function checkLengthTextArea(cp,len){
    if (cp.value.length >= len){
        cp.value = cp.value.substring(0,len-1);
    }
}

function NewLetter(frm2){
    email  = eval(frm2["email"])? frm2["email"]: "";
    if(!CheckEmail(email.value) || frm2.email.value == ""){
     alert("EMAIL INVALIDO!",email);
    return;
    }
    frm2.submit();
}

function popUp(url){
   sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=350,height=250');
   self.name = "mainWin";
}

function Busca(frm3){
  inString = frm3.busca.value;
  refString = "! @ # $ % ¨& * ( ) _ - = + < > : ; / ? | \ ' ^ ~ { } ] [ ç ";
  if (inString == ""){
   alert("DIGITE UMA PALAVRA CHAVE !!");
   return;
  } 

  for (i=0;i<inString.length;i++){
    var letra = inString.substr(i,1);
     busca = (letra + "").toUpperCase();
     if (refString.indexOf(busca) > 0 ){
      alert(busca+" -> CARACTER INVÁLIDO !!");
      return;
     }
  }

  frm3.submit();

}

function CheckEmail(email){
      email =  email + ""; 
      var atPos = email.indexOf("@");
      var tmp   = email.substring(atPos,email.length-2)
      var ptPos = tmp.indexOf(".");
      var cond = true   
    if(email == "")
     return true;
     else
        {  
         if((atPos  == -1) || (ptPos == -1) || !isEmail(email))
          cond = false
        }
   return cond
}


function isAlphaNum( chr ) {
// Return immediately if an invalid value was passed in
    if (chr+"" == "undefined" || chr+"" == "null" || chr+"" == "")  
     return false;
     var isValid = true;
     // convert to a string for performing string comparisons.
     chr += "";  
     // Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
     if (!(((chr >= "0") && (chr <= "9")) || 
           ((chr >= "a") && (chr <= "z")) ||
           ((chr >= "A") && (chr <= "Z"))
          ))
         isValid = false;
        return isValid;
}// end isAlphaNum

//---------------------------------------------------------------------------
// Funcao    :isEmail( str )
// tratamento:Checa se a sintaxe do email, mas nao checa a autenticidade.
//---------------------------------------------------------------------------
function isEmail( str ) {
        // Return immediately if an invalid value was passed in
        if (str+"" == "undefined" || str+"" == "null" || str+"" == "")  
            return false;
    
        var isValid = true;
        var ok = 0;     
        // convert to a string for performing string comparisons.
        str += "";  
        if ( str.charAt(0) == "@" || str.charAt(0) == ".") // descarta quando '.@' estiverem na inicio ou fim da str.
            return false;
        if ( str.charAt(str.length-1) == "@" || str.charAt(str.length-1) == ".")
            return false;

        // Loop through length of string and test for any alpha numeric 
        // characters
        for (i = 0; i < str.length; i++)
        {
            if (!(// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
                    isAlphaNum(str.charAt(i))  ||
                    (str.charAt(i) == ".")     ||
                    (str.charAt(i) == "_")     ||
                    (str.charAt(i) == "-")     ||
                    (str.charAt(i) == "@") 
               ))
                    {
                    isValid = false;
                    break;
                    }
                // se ele achou mais de um @
                if ( 
                       (str.charAt(i) == "@") &&
                        (ok == 1)
                    ) 
                        isValid = false;
                if ( str.charAt(i) == "@" ) 
                    ok = 1;
        } // END for  

        if ( ok == 0 ) 
                isValid = false;
        return isValid;
}  // end isEmail

function FormEncontros(encont){

    email  = eval(encont["email"])? encont["email"]: "";

    if(encont.nome_encontro.value == ""){
     alert("NOME DO ENCONTRO INVÁLIDO!!!");
     return; 
    }

    if(encont.local.value == ""){
     alert("LOCAL DO ENCONTRO INVÁLIDO!!!");
     return;
    }

    if(encont.bairro.value == ""){
     alert("DIGITE O BAIRRO!!!");
     return;
    }

    if(encont.cidade.value == ""){
     alert("DIGITE A CIDADE!!!");
     return;
    }

    if(encont.estado[encont.estado.selectedIndex].value == ""){
     alert("SELECIONE O ESTADO!!!");
     return;
    }

    if(encont.hinicio1.value == "" || !isNumber(encont.hinicio1.value) || encont.hinicio2.value == "" || !isNumber(encont.hinicio2.value)){
     alert("HORA/MINUTOS DE INICO INVALIDO!!!");
     return;
    }

    if(encont.hterm1.value == "" || !isNumber(encont.hterm1.value) || encont.hterm2.value == "" || !isNumber(encont.hterm2.value)){
     alert("HORA/MINUTOS DE FIM INVALIDO!!!");
     return;
    }

    if(encont.freq[encont.freq.selectedIndex].value == ""){
     alert("SELECIONE A FREQUENCIA DO ENCONTRO!!!");
     return;
    }

    if(encont.ddd.value == "" || !isNumber(encont.ddd.value)){
     alert("DDD INVÁLIDO!!!");
     return; 
    }

    if(encont.fone.value == "" || !isNumber(encont.fone.value)){
     alert("FONE INVÁLIDO!!!");
     return; 
    }

    if( !CheckEmail(email.value) || encont.email.value == ""){
     alert("EMAIL INVALIDO!",email);
     return;
    }

   encont.submit();
}

function Votacao(frmv){

    email  = eval(frmv["email"])? frmv["email"]: "";

    if(frmv.nome.value == ""){
     alert("DIGITE SEU NOME!!!");
     return; 
    }

    if(frmv.rg.value == "" || !isNumber(frmv.rg.value)){
     alert("RG INVÁLIDO!!!");
     return; 
    }

    if(frmv.ddd.value == "" || !isNumber(frmv.ddd.value)){
     alert("DDD INVÁLIDO!!!");
     return; 
    }

    if(frmv.fone.value == "" || !isNumber(frmv.fone.value)){
     alert("FONE INVÁLIDO!!!");
     return; 
    }

    if( !CheckEmail(email.value) || frmv.email.value == ""){
     alert("EMAIL INVALIDO!",email);
     return;
    }

    if (frmv.opcao.value == "2"){
     if(frmv.oficina[frmv.oficina.selectedIndex].value == ""){
      alert("ESCOLHA UMA OFICINA !!!");
      return;
     }
    }else {
     if(frmv.loja[frmv.loja.selectedIndex].value == ""){
      alert("ESCOLHA UMA LOJA !!!");
      return;
     }
    }

    if(frmv.comentario.value == ""){
     alert("DIGITE UM COMENTÁRIO PARA O SEU VOTO!!!");
     return; 
    }
   frmv.submit();
}