function initCallback(carousel) {      
    carousel.clip.hover(function() {
      carousel.stopAuto();
       }, function() {
      carousel.startAuto();
    });

      $('.next').bind('click', function() {
          carousel.next();
          return false;
      });

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

function itemVisibleInCallback (o, li, i, s) {
    if (i == 1) {
        $('.prev').hide();
    } else {
        $('.prev').show();
    }
}


$(document).ready(function() {
    $("#thumbs").jcarousel({
        initCallback:initCallback,
        itemVisibleInCallback:itemVisibleInCallback,
        //auto:1,
        scroll:1,
        wrap: 'last',
        easing:'easeOutBack',
        buttonNextHTML: null,
        buttonPrevHTML: null,
        animation: 1000
    });
    
    $('.lista li').hover(function() {
        var html = $(this).find('.img-desc').html();
        var pos = $(this).offset();
        $(this).find('a').stop().animate({marginTop: -141}, 500, 'easeInOutSine', function() {
            $('#img-pop').html(html).css({top:(pos.top+100), left:(pos.left-50)}).show();
        });
    }, function() {
        $(this).find('a').stop().animate({marginTop: 0}, 500, 'easeInOutSine');
        $('#img-pop').hide();
    });
    
    var num_desc = $('#proj h3').length;
    $('.desc').eq(0).show();
    $('#proj li').slice(3, num_desc).hide();
    
    $('#veja-todos a').bind('click', function(event) {
        $('#proj li').slice(3, num_desc).show('slow');
        $('#veja-todos').hide();
        return false;
    });
    
    $('#proj h3').toggle(function(event) {
        var index = $('#proj h3').index(this);
        $('#proj .desc').eq(index).fadeIn('slow');
    }, function () {
        var index = $('#proj h3').index(this);
        $('#proj .desc').eq(index).slideUp('slow');
    });
    
    
    function planos (link, div) {
        $(link).hover(function(event) {
            var pos = $(this).offset()
            $(div).css({top:(pos.top+100), left:(pos.left+30)}).fadeIn('slow');
        },
        function(event) {
            $(div).fadeOut('slow');
        });
        
        $(link).bind('click', function(event) {
            return false;
        });
    }
    
    // planos('li.prata', '.plan1');
    // planos('li.ouro', '.plan2');
    // planos('li.vip', '.plan3');
    
});
