$(function() {
        /* Light Box */
        $('#lbh0').click(function(e) {
            e.preventDefault();
            $('#lb0 a:first').click();
        })
        
        $('#lbh1').click(function(e) {
            e.preventDefault();
            $('#lb1 a:first').click();
        })
        
        $('#lbh2').click(function(e) {
            e.preventDefault();
            $('#lb2 a:first').click();
        })
        
        $('#lbh3').click(function(e) {
            e.preventDefault();
            $('#lb3 a:first').click();
        })
        
        $('#lbh4').click(function(e) {
            e.preventDefault();
            $('#lb4 a:first').click();
        })
        
        $('#lbh5').click(function(e) {
            e.preventDefault();
            $('#lb5 a:first').click();
        })
        
        $('#lb0 a').lightBox({fixedNavigation:true});
    	$('#lb1 a').lightBox({fixedNavigation:true});
        $('#lb2 a').lightBox({fixedNavigation:true});
        $('#lb3 a').lightBox({fixedNavigation:true});
        $('#lb4 a').lightBox({fixedNavigation:true});
        $('#lb5 a').lightBox({fixedNavigation:true});
        
        /* Twitter
        function loadTweets() {
            $.ajax({
              type: "GET",
              url: "./_twitter.php",
              cache: false,
              timeout: 5000,
              contentType: "text/html",
              dataType: "html",
              success: function(html) {
                $("#twitter p").remove();
                $("#twitter").append(html);  
              },
              error: function(xhr,er) {
                //if (er == 'timeout') {
                    $("#twitter p").remove();
                    $("#twitter").append("<p>Não foi possível conectar ao Twitter no momento.</p>");    
                //}
              }
            });
            //$('#twitter').load('./_twitter.php');
            setTimeout(function(){
                //$('#twitter p').remove();
                loadTweets();    
            },60000); 
        }
        loadTweets();
        $('#loading')
            .ajaxStart(function() {
                $(this).show();
        })
            .ajaxStop(function() {
                $(this).hide(); 
        });*/
        
        /* Contato */
        $('#contato p').toggle(
            function() {
                $('#contato').animate({
                    marginBottom: "300px"    
                });
                $('#boxcontato').slideToggle();    
            },
            function() {
                $('#contato').animate({
                    marginBottom: "0px"    
                });
                $('#boxcontato').slideToggle();
            }
        );
        
        $('#form').submit(function(e) {
            e.preventDefault();
            $('#form input, #form textarea').blur();
            $.ajax({
              type: "POST",
              url: "./_form.php",
              cache: false,
              global: false,
              dataType: "json",
              data: $("#form").serialize(),
              processData: false,
              success: function(html) {
                var obj = eval("json");
 				var sucesso = obj.sucesso;
                if (sucesso == 'true') {
                	//sucesso
                	var texto = obj.texto;
                    $('#form input[type!=submit], #form textarea').val('');
                	$('#placer').empty();
                	$('#placer').html(texto);
                	$('#placer p').fadeOut(10000);
                } else {
                	//erro
                	var erro = obj.erro;
                	$('#placer').empty();
                	$('#placer').html(erro);
                	$('#placer p').fadeOut(10000);
                }
              },
              error: function(xhr,er) {
                $('#placer').empty();
            	$('#placer').html("Erro interno.");
            	$('#placer p').fadeOut(10000);  
              }
            });
        });
    }); //fim