$(function() {
  //ABRE E FECHA TEXTO
  $("#lista-representantes a").toggle(
    function(){
      $(this).next("div").slideDown("slow").end().addClass('selecionado');
    },
    function(){
      $(this).next("div").slideUp("slow").end().removeClass('selecionado');
    }
  );

  $("#lista-representantes div").hide();
  $("#lista-representantes a:first").click();
  
  //APAGA VALUE DO INPUT
  $("form input[type='text'],form textarea").focus( 
  function() {
    if ($(this).val()==$(this).attr("defaultValue")) {
     $(this).val('');
    }
  });
  
  $("form input[type='text'],form textarea").blur(
  function() {
    if ($(this).val()=='') {
     $(this).val($(this).attr("defaultValue"));
    }
  });
  
  //Função troca banner
  $('#troca-banner').show();
  $('#troca-banner').cycle({
    fx:'fade',
    timeout:6000,
    speed:1000,
    pager:'.numeros',
    prev: '#banner-anterior',
    next: '#banner-proximo'
  });
  
  //COMPONETES
  $("#conteudo-lateral-componentes a").mouseover(
    function () {
      var elemento = '#conteudo-componentes a.'+$(this).attr("class");
      $(elemento).css('background-position','bottom center');
      
      $(this).css('text-decoration','underline');
      $(this).css('color','#BE242C');      
    }
  ).mouseout(
    function(){
      var elemento = '#conteudo-componentes a.'+$(this).attr("class");
      $(elemento).css('background-position','top center');
      
      $(this).css('text-decoration','none');
      $(this).css('color','#909090');      
    }
  );
  
  $("#conteudo-componentes a").mouseover(
    function () {
      var elemento = '#conteudo-lateral-componentes a.'+$(this).attr("class");
      $(elemento).css('text-decoration','underline');
      $(elemento).css('color','#BE242C');

      $(this).css('background-position','bottom center');
    }
  ).mouseout(
    function(){
      var elemento = '#conteudo-lateral-componentes a.'+$(this).attr("class");
      $(elemento).css('text-decoration','none');
      $(elemento).css('color','#909090');

      $(this).css('background-position','top center');
    }
  );  
  
  //MASCARA PARA O FORMULARIO
  $("form #telefone").mask("(99) 9999-9999").val('Telefone');
  
  //VALIDACAO
  $('form').validate({
  
      // define regras para os campos
      rules: {
          nome: {
              required : true,
              minlength: 5
          },
          email: {
              required: true,
              email   : true
          }     
      },
      // define messages para cada campo
      messages: {
          nome: null,
          email: null
      }
  });
  
});