var sliderGallery = {

    init: function () {
        this.slideTime = 6000;
        this.timer = null;
        this.showSlideId = null;

        $('#gallery a').css({opacity: 0.0});
        $('#gallery a:first').css({opacity: 1.0});
        t = setTimeout('sliderGallery.swapImage()',this.slideTime);

    },

    swapImage: function () {
        var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));
        if (this.showSlideId==null) {
            var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));
            next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
            current.animate({opacity: 0.0}, 1000).removeClass('show');
        }
        else {
            var next = $("#"+this.showSlideId);
            if (next.attr("id")!=current.attr("id")) {
                current.animate({opacity: 0.0}, 1000).removeClass('show');
                next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
            }
        };
        this.timer = setTimeout('sliderGallery.swapImage()',this.slideTime);
    },

    onEventSwap: function (slId) {
        this.showSlideId = slId;
        this.timer = setTimeout('sliderGallery.swapImage()',100);
    }

}

$(document).ready(function() {
    sliderGallery.init();
});

