$(document).ready(function() {
    var onMouseOutOpacity = 0.67;
    $('#galerry_thumbs ul.galerry_thumbs li').css('opacity', onMouseOutOpacity)
    .hover(
        function () {
            $(this).not('.selected').fadeTo('fast', 1.0);
        },

        function () {
            $(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
        }
    );

    var gallery = $('#gallery').galleriffic('#galerry_thumbs', {
        delay:                  5000,
        numThumbs:              4,
        preloadAhead:           10,
        enableTopPager:         false,
        enableBottomPager:      false,
        enablePrevPager:        true,
        enableNextPager:        true,
        imageContainerSel:      '#slideshow',
        loadingContainerSel:    '#loading',
        renderSSControls:       false,
        enableHistory:          true,
        autoStart:              false,

        onChange:   function(prevIndex, nextIndex) {
            $('#galerry_thumbs ul.galerry_thumbs').children()
            .eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
            .eq(nextIndex).fadeTo('fast', 1.0);
        },

        onTransitionOut: function(callback) {
            $('#slideshow, #caption').fadeOut('fast', callback);
        },

        onTransitionIn: function() {
            $('#slideshow, #caption').fadeIn('fast');
        },

        onPageTransitionOut: function(callback) {
            $('#galerry_thumbs ul.galerry_thumbs').fadeOut('fast', callback);
        },

        onPageTransitionIn: function() {
            $('#galerry_thumbs ul.galerry_thumbs').fadeIn('fast');
        }
    });
});