/*

File: custom.js

For: Pixelation
Author: Luke Smith - HisHandiwork.biz
Created: 03/09/11



--- TABLE OF CONTENTS ---


1. IMAGE ZOOM
2. SHOW MENU SEARCH
3. PORTFOLIO 4 SLIDING CAPTIONS
4. JMENU
5. PAGE JUMP
6. FANCYBOX
7. LATEST TWEETS
8. TIPSY FOR REPLACING THE "TITLE" ATTRIBUTE VALUES 
9. JCAROUSEL
10. PIKA CHOOSE


*/

/* 1 *** IMAGE ZOOM */
jQuery(document).ready(function() {
    $("a.zoom img, .separator a").mouseover(function(){
        $(this).stop(true,true);
        $(this).fadeTo(300, 0.6);
    });
	
    $("a.zoom img, .separator a").mouseout(function(){
        $(this).fadeTo(400, 1.0);
    });                
});


// Verifica o tamanho da palavra procurada
jQuery(document).ready(function() {
    $('#btn_buscar').click(function() {
        if($('#busca').val().length < 3) {
            alert('A busca deve conter 3 ou mais caracteres.');
        } else {
            $('#form_busca').submit();
        }
    }); 
});

/* 2 *** SHOW MENU SEARCH
$(document).ready(function() {
	$(".menu-search, .search-close").click(function () {
		$("#searchform").toggle("slow");
	});
}); */

$(document).ready(function () {

    $('.menu-search, .search-close').click(function () {

        var $search = $('#searchform');

        if ($search.is(':visible')) {

            $search.fadeOut(1000);

        } else {

            $search.fadeIn(1000);

        }

    });

});



/* 3 *** PORTFOLIO 4 SLIDING CAPTIONS */
$(document).ready(function() {

    $('.boxgrid.captionfull').hover(function(){
        $(".cover", this).stop().animate({
            top:'-0px'
        },{
            queue:false,
            duration:200
        });
    }, function() {
        $(".cover", this).stop().animate({
            top:'-145px'
        },{
            queue:false,
            duration:700
        });
    });

});



/* 4 *** JMENU */
jQuery(document).ready(function() {
    $('#menu').jmenu({
        animation:'slide',
        duration:300
    });
});



/* 5 *** PAGE JUMP */
$('.jump').click(function() {
    var elementClicked = $(this).attr("href");
    var destination = $(elementClicked).offset().top;
    $("html:not(:animated),body:not(:animated)").animate({
        scrollTop: destination-20
        }, 1000 );
    return false;
});



/*** FANCYBOX */
jQuery(document).ready(function() {

    //display image
    $("a.zoom").fancybox({
        // Define the callback to accept an array of links selected by jQuery as
        // its first parameter, and an index as the second parameter
        'onComplete' : function(links, index) {
            var self = $(links[index]);
            var href = self.siblings('span').find('a').attr('href');
            var tmp = $('#fancybox-title-inside').html();
            tmp += ' - <a style="color: #fff;" href="' + href + '">Ir para artigos</a>';
            $('#fancybox-title-inside').html(tmp);
        }
    });
});



/* 8 *** TIPSY FOR REPLACING THE "TITLE" ATTRIBUTE VALUES */
jQuery(document).ready(function(){
	
    $('a.tipsy').tipsy({
	
        delayIn: 0,      // delay before showing tooltip (ms)
        delayOut: 0,     // delay before hiding tooltip (ms)
        fade: true,     // fade tooltips in/out?
        fallback: '',    // fallback text to use when no tooltip text
        gravity: 's',    // gravity
        html: false,     // is tooltip content HTML?
        live: false,     // use live event support?
        offset: 15,       // pixel offset of tooltip from element
        opacity: 0.8,    // opacity of tooltip
        title: 'title',  // attribute/callback containing tooltip text
        trigger: 'hover' // how tooltip is triggered - hover | focus | manual
	
    });
	
});



/* 9 *** JCAROUSEL */
jQuery(document).ready(function() {
    jQuery('.imageCarousel').jcarousel({
        auto: 3,
        scroll: 1,
        wrap: 'last',
        animation: 700,
        initCallback: mycarousel_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

function mycarousel_initCallback(carousel) {
    jQuery('.carousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('.carousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};
