$(document).ready(function(){  var ok = false;  $('body').ready(function(){      for(var i = 0; i<3;i++){        $(".effect-rastreamento:eq("+i+")").each(function(){        $(this).stop().animate({left:'0px'},300,function(){          $(this).find('img').fadeIn();        });      });             }        var abreAbas = setTimeout(function(){      $(".effect-rastreamento:eq(0)").addClass('select');      for(var i = 1; i<3;i++){          $(".effect-rastreamento:eq("+i+")").each(function(){          $(this).stop().animate({left:'-218px'},300,function(){            $(this).find('img').fadeOut();          });        });               }      ok = true;    },1500)  });    $(".effect-rastreamento").click(function(){        if(!ok) return;        if($(this).hasClass('select')) return;        var effect_number = $(this).attr('name');          $(".effect-rastreamento.select").stop().animate({left:'-218px'},function(){      $(this).find('img').fadeOut();    }).removeClass('select');            $(this).addClass('select');    $('.load-r').addClass('loader-rastreamentos');        $('.content-banner-rastreamento').hide();        $('.content-banner-rastreamento').load(site+'/carrega_rastreamento',{data:effect_number},function(data){      $('.load-r').removeClass('loader-rastreamentos');        $(this).fadeIn();    })      });    $("#menu-banner-rastreamento li").hover(function(){    if(!ok) return;    if($(this).find('div').hasClass('select')) return;    $(this).find('div').stop().animate({left:'0px'},300,function(){      $(this).find('img').fadeIn();    });  },function(){    if(!ok) return;    if($(this).find('div').hasClass('select')) return;    $(this).find('div').stop().animate({left:'-218px'},function(){      $(this).find('img').fadeOut();    });  });    $('#cnpj-rastreamento').mask('99.999.999/9999-99');    $('#cep-rastreamento1').keypress(function(){    if($(this).val().length == 5){      $('#cep-rastreamento2').focus();    }  });    $('#form-rastreamento').validate({    rules: {      'nome': { required:true },      'email': { required:true, email:true },      'empresa': { required:true },      'telefone': { required:true },      'cnpj': { required:true ,cnpj:true },      'endereco': { required:true },      'bairro': { required:true },      'cidade': { required:true },      'estado': { required:true },      'cep1': { required:true },      'cep2': { required:true },      'postal': { required:true }    },    messages: {      nome: {required:__('nome')},      email:{required:__('email'), email:__('email_invalido')},      empresa:{required:__('empresa')},      telefone:{required:__('telefone')},      cnpj:{required:__('cnpj'), cnpj:__('cnpj')},      endereco:{required:__('endereco')},      bairro:{required:__('bairro')},      cidade:{required:__('cidade')},      estado:{required:__('estado')},      cep1:{required:__('cep')},      cep2:{required:__('cep')},      postal:{required:__('cep')}          },    submitHandler: function(form) {      $(form).ajaxSubmit(options);    },    errorLabelContainer: $("#erro-rastreamento")  });    var options = {      beforeSubmit:  showRequest,      success:       showResponse   };  function showRequest(formData, jqForm, options) {     $(".msg-form-rastreamento").html('<span class="mensagem-neutral">Aguarde...</span>');  }  function showResponse(data,jqForm) {    if($.trim(data)=='true'){      $(".msg-form-rastreamento").html('Enviado com sucesso');      try{        $("#form-rastreamento")[0].reset();      }catch(e){            }      setTimeout(function(){$(".msg-form-rastreamento").html("Preencha o formulário abaixo e receba usuário e senha para demonstração:");},2000);    }else{      $("#msg-rastreamento").html('<span class="mensagem-erro">Erro ao enviar</span>');      setTimeout(function(){$("#msg-rastreamento").html("Preencha o formulário abaixo e receba usuário e senha para demonstração:");},2000);    }  }    /**   * Cnpj.:   * Metodo para validar cnpj   */  jQuery.validator.addMethod("cnpj", function(cnpj, element) {   cnpj = jQuery.trim(cnpj);   cnpj = cnpj.replace('/','');   cnpj = cnpj.replace('.','');   cnpj = cnpj.replace('.','');   cnpj = cnpj.replace('-','');     var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;    digitos_iguais = 1;    if (cnpj.length < 14 && cnpj.length < 15){      return false;    }    for (i = 0; i < cnpj.length - 1; i++){      if (cnpj.charAt(i) != cnpj.charAt(i + 1)){         digitos_iguais = 0;         break;      }    }    if (!digitos_iguais){      tamanho = cnpj.length - 2      numeros = cnpj.substring(0,tamanho);      digitos = cnpj.substring(tamanho);      soma = 0;      pos = tamanho - 7;      for (i = tamanho; i >= 1; i--){         soma += numeros.charAt(tamanho - i) * pos--;         if (pos < 2){            pos = 9;         }      }      resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;      if (resultado != digitos.charAt(0)){         return false;      }      tamanho = tamanho + 1;      numeros = cnpj.substring(0,tamanho);      soma = 0;      pos = tamanho - 7;      for (i = tamanho; i >= 1; i--){         soma += numeros.charAt(tamanho - i) * pos--;         if (pos < 2){            pos = 9;         }      }      resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;      if (resultado != digitos.charAt(1)){         return false;      }      return true;    }else{      return false;    }  }, "Informe um CNPJ válido.");});
