$( function() {
  
  //APAGA VALUE DO INPUT
  $("#topo #busca input").focus( 
  function() {
    if ($(this).val()==$(this).attr("defaultValue")) {
     $(this).val('');
    }
  });
  
  $("#topo #busca input").blur(
  function() {
    if ($(this).val()=='') {
     $(this).val($(this).attr("defaultValue"));
    }
  });

  //VALIDACAO
  $('#contato form').validate({
  
      // define regras para os campos
      rules: {
          nome: {
              required : true,
              minlength: 5
          },
          email: {
              required: true,
              email   : true
          },   
          opcao: {
              required: true
          }
      },
      // define messages para cada campo
      messages: {
          nome: null,
          email: null
      }
  });
  
  //ABRE E FECHA TEXTO
  $(".esconder").hide();
  $("#associados .info-associado a.abre-descricao").toggle(
    function(){
      $(this).next("div").slideDown("slow");
    },
    function(){
      $(this).next("div").slideUp("slow");
    }
  );

  //LIGHTBOX
  $('#principal #ultimas-noticias a#foto-ultimas-noticias').lightBox(); 
  $('#fotos .foto a').lightBox(); 
  $('#noticias a#foto-ultimas-noticias').lightBox(); 
  $('#institucional a#foto-ultimas-noticias').lightBox();
  
  /*-- COMBO SELECT PERSONALIZADO --*/
  $(".lista-oculta").hide();
  $(".select-em-lista").click(function(){
    
    if ($(".lista-oculta").css('display') == 'block'){
      $(".lista-oculta").hide();
    }else{
      $(".lista-oculta").show();
    }
  });

  $(".lista-oculta a").click(
    function () {
      $(".lista-oculta").hide();
      $(".select-em-lista p").text($(this).text());
      return false;
    }
  );
  
  $(".lista-oculta").mouseleave(function(){
    $(this).hide();
  });
  
  /* RESERVAS - LISTA DE RESERVAS */
  $('#lista-opcoes-associados li a').click(function(){
    $('#opcao').val($(this).attr("title"));  
  });

});