$(function(){
    function animateCaption(obj, show) {
        var caption = $(obj).find('.caption');
        if (caption.find('p').text().length > 0) {
            caption.dequeue().animate({top: show
                ? caption.parent().height() - caption.height()
                : caption.parent().height()
            }, 300);
        }
    }
    $('.plgallery .tiles .thumb, .mod-favourites .thumb').hover(
        function(){ animateCaption(this, true); },
        function(){ animateCaption(this, false); }
    );
    if($('a.colorbox').length > 0) {
        $('a.colorbox').colorbox({maxWidth:'90%',maxHeight:'90%'});

    }
    if($('.plgallery a[rel="plgallery"]').length > 0) {
        $('a.colorbox').colorbox();
        $('.plgallery a[rel="plgallery"]').colorbox({maxWidth:'90%',maxHeight:'90%'});
    }
});
