$(document).ready(function(){

    /*$(function () {
        var img = new Image();
        $(img).load(function () {
            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
            $(this).hide();
            $('#loader').hide().append(this);
            $(this).fadeIn();
        }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', '/tswalu/images/main-images/default-header.jpg');
    });*/

    $(function () {
        $('.gallery_module_fader').each(function() {

            $('#' + $(this).attr('id')).innerFade({
                speed: 'slow',
                timeout: 3000,
                type: 'random',
                containerheight: '142px',
                prevLink: '#' + $(this).attr('id') + '.picture-slides-previous-image',
                nextLink: '#' + $(this).attr('id') + '.picture-slides-next-image'
            });

        });
    });

    $(function () {

            $('.gallery_fader').innerFade({
                speed: 'slow',
                timeout: 5000,
                type: 'sequence',
                containerheight: '338px',
                pauseLink: '.gallery_index',
                prevLink: '.picture-slides-previous-image',
                nextLink: '.picture-slides-next-image'
            });
    });

    $('.gallery_index').click(function() {
        indexes = $('ul.picture-slides-thumbnails')
        index = indexes.find('li').index(this);
        
        $('.gallery_fader').innerFadeTo(index);
    });

    // Home Page Image Fader
        $(function () {
                $('#header-images-fader').innerFade({
                	 speed: 'slow',
                         timeout: 4000,
                         type: 'random',
                         containerheight: '386px',
               		 callback_index_update: $(function(){ $('.picture-slides-image-link').hide(); })
                 });
        });

});

