jQuery(function($){

    /*  Image gallery
    */
    var $galleries = $('div').filter('[id^=image_gallery_]');
    if ( $galleries.length > 0 ) {
        $galleries.each(function(){
            var $images = $(this).find('.images').find('.image > a');
            if ( $images.length > 0 ) {
                var getImageText = function(title, currentArray, currentIndex, currentOpts) {
                    return $images.eq(currentIndex).next().html();
                }
                $images.fancybox({
                    'titlePosition': 'inside',
                    'titleFormat' : getImageText
                });
            }
            
            $(this).find('.prev-next').find('span').height( $(this).find('.images').outerHeight() );
        });
    }
});

