﻿function doImageTransition(moduleID) {
    var currentImage = jQuery("#gallery" + moduleID + " .images li.current")[0];
    var nextImage;
    if (jQuery("#gallery" + moduleID + " .images li.current + li").length > 0) {
        nextImage = jQuery("#gallery" + moduleID + " .images li.current + li")[0]
    }
    else {
        nextImage = jQuery("#gallery" + moduleID + " .images li:first")[0];
    }
    jQuery(currentImage).removeClass("current");
    jQuery(currentImage).fadeOut(1000);
    jQuery(nextImage).fadeIn(1000, function() {
        jQuery(nextImage).css("opacity", "1").css("filter", "alpha(opacity=100)").addClass("current");
    });
}

function simpleSlideshow(moduleID, slideshowInterval) {
    this.moduleID = moduleID;
    this.slideshowInterval = slideshowInterval;
}

simpleSlideshow.prototype.init = function() {

    jQuery("#gallery" + this.moduleID + " .images li").css("opacity", "1").css("filter", "alpha(opacity=100)").css("display", "none");
    jQuery("#gallery" + this.moduleID + " .images li:last").addClass("current").css("display", "list-item");
    var moduleID = this.moduleID;
    setInterval(function() {
        doImageTransition(moduleID);
    }, this.slideshowInterval * 1000);
};