	$(function() {   
    
    // Validação do formulário
    $("#contato").validate({
        invalidHandler: function(e, validator) {
            var errors = validator.numberOfInvalids();
            if (errors) {
                $("div#form_error").show();
            } else {
                $("div#form_error").hide();
            }
        },
        errorPlacement: function(error,element) {
            return true;
        }
    }); 

    $("#formTrabalheConosco").validate({
        invalidHandler: function(e, validator) {
            var errors = validator.numberOfInvalids();
            if (errors) {
                $("div#form_error").show();
            } else {
                $("div#form_error").hide();
            }
        },
        errorPlacement: function(error,element) {
            return true;
        }
    }); 

        // Chamada do DataTable    
    $('#tableSorter').dataTable({ 
        "bPaginate" : false,
        "bInfo" : false,
         "aaSorting": [[ 1, "asc" ]]
    });

    $('#tableSorter_filter input').val("");

	    $('#animacao').cycle({
	        fx:     'fade',
	        timeout: 12000,
	        pager:  '#nav',
			slideExpr: 'img'
	    });    

    //Clientes - Filtro por Unidades
    $("#unidades li a#industria").click(function(){
        if($(this).hasClass("desativo")) {
            $(this).removeClass("desativo");
            $("tbody tr.industria").fadeIn();
        } else {
            $(this).addClass("desativo");
            $("tbody tr.industria").fadeOut();
        }
    });

    $("#unidades li a#comercio").click(function(){
        if($(this).hasClass("desativo")) {
            $(this).removeClass("desativo");
            $("tbody tr.comercio").fadeIn();
        } else {
            $(this).addClass("desativo");
            $("tbody tr.comercio").fadeOut();
        }
    });

    $("#unidades li a#servico").click(function(){
        if($(this).hasClass("desativo")) {
            $(this).removeClass("desativo");
            $("tbody tr.servico").fadeIn();
        } else {
            $(this).addClass("desativo");
            $("tbody tr.servico").fadeOut();
        }
    });

    $(".video").click(function() {
        $.fancybox({
            'padding'       : 0,
            'autoScale'     : false,
            'transitionIn'  : 'none',
            'transitionOut' : 'none',
            'title'         : this.title,
            'width'     : 680,
            'height'        : 495,
            'href'          : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type'          : 'swf',
            'swf'           : {
                 'wmode'        : 'transparent',
                'allowfullscreen'   : 'true'
            }
        });
        return false;
    });

    //When page loads...
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function() {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });

    jQuery(function(){
        $(".tweet").tweet({
            username: "RuiCadete_",
            join_text: "auto",
            avatar_size: 0,
            count: 1,
            auto_join_text_default: "we said,", 
            auto_join_text_ed: "we",
            auto_join_text_ing: "we were",
            auto_join_text_reply: "we replied to",
            auto_join_text_url: "we were checking out",
            loading_text: "loading tweets..."
        });
    });

});
