$(function() {
  
   $(".ampliar").lightBox();
  
  /* CONTROLA O TAMANHO DA TELA SEM MENU */
  $("#tudo").css("height",$(window).height()-60);
  
  $(window).resize(function(){
    $("#tudo").css("height",$(window).height()-60);
  });
  
  /* FORM FALE CONOSCO */
  $("#formContato input, #formContato textarea, #formInteresse input, #formInteresse textarea, #formPalestra input[type=text]").focus( 
  function() {
    if ($(this).val()==$(this).attr("defaultValue")) {
     $(this).val('');
    }
  });
  
  $("#formContato input, #formContato textarea, #formInteresse input, #formInteresse textarea, #formPalestra input[type=text]").blur(
  function() {
    if ($(this).val()=='') {
     $(this).val($(this).attr("defaultValue"));
    }
  });


  $("#formContato a.btnenviar").click(
    function () {
      $("#formContato").submit();
      return false;
    }
  );
  
  $("#formInteresse a.btnenviar").click(
    function () {
      $("#formInteresse").submit();
      return false;
     }
  );
  
  $("#formPalestra a.btnenviar").click(
    function () {
      $("#formPalestra").submit();
      return false;
     }
  );
  
  
  $("div#faq div.item a").toggle(
    function() {
      $(this).next("p").show();
    },
    function() {
      $(this).next("p").hide();
    }
  )

  /*-- VALIDACAO CONTATO -----------------------*/
  $('#formContato').validate({
      // define regras para os campos
      rules: {
          nome: {
              required : true,
              minlength: 5
          },
          email: {
              required: true,
              email   : true
          },
          telefone: {
              required : true,
              minlength: 8
          }
      },
      // define messages para cada campo
      messages: {
          nome : null,
          email: null,
          telefone: null
      },
      invalidHandler: function(form, validator) {
          var errors = validator.numberOfInvalids();
          if (errors) {
            var msg = errors == 1
              ? 'Existe 1 campo obrigatório não preenchido ou inválido, verifique.'
              : 'Existem ' + errors + ' campos obrigatórios não preenchidos ou inválidos, verifique.';
              alert(msg);
          }
        }
  });
  
  /*-- VALIDACAO PALESTRA -----------------------*/
  $('#formPalestra').validate({
      // define regras para os campos
      rules: {
          nome: {
              required : true,
              minlength: 5
          },
          email: {
              required: true,
              email   : true
          },
          telefone: {
              required : true,
              minlength: 8
          }
      },
      // define messages para cada campo
      messages: {
          nome : null,
          email: null,
          telefone: null
      },
      invalidHandler: function(form, validator) {
          var errors = validator.numberOfInvalids();
          if (errors) {
            var msg = errors == 1
              ? 'Existe 1 campo obrigatório não preenchido ou inválido, verifique.'
              : 'Existem ' + errors + ' campos obrigatórios não preenchidos ou inválidos, verifique.';
              alert(msg);
          }
        }
  });
  
  /*-- VALIDACAO INTERESSE -----------------------*/
  $('#formInteresse').validate({
      // define regras para os campos
      rules: {
          nome: {
              required : true,
              minlength: 5
          },
          email: {
              required: true,
              email   : true
          },
          telefone: {
              required : true,
              minlength: 10
          },
          curso: {
              required : true,
              minlength: 6
          }
         
      },
      // define messages para cada campo
      messages: {
          nome : null,
          email: null,
          telefone: null,
          curso: null
      },
      invalidHandler: function(form, validator) {
          var errors = validator.numberOfInvalids();
          if (errors) {
            var msg = errors == 1
              ? 'Existe 1 campo obrigatório não preenchido ou inválido, verifique.'
              : 'Existem ' + errors + ' campos obrigatórios não preenchidos ou inválidos, verifique.';
              alert(msg);
          }
        }
  });
  
});

/* EMENTAS DISCIPLINAS */
  function ementa(td) {
    var tr = document.getElementById(td);
    if (tr.style.display=="block") {
      tr.style.display = "none";
    } else {
      tr.style.display = "block";
    }
  } 