﻿PT.Sites.Castelijnmode.Slideshow = function (targetImage, array, speed) {
    var me = this;

    this.slideShowSpeed = speed;
    this.crossFadeDuration = 2;
    this.targetImage = targetImage;
    this.array = array;
    this.currentIndex = 0;
    this.timeout = undefined;

    PT.Sites.General.RegisterEvent(window, "load", function () { me.runSlideShow(); });
}

PT.Sites.Castelijnmode.Slideshow.prototype.runSlideShow = function () {
    var me = this;

    if (this.array.length > 0) {
        var slideshowimg = get$(this.targetImage);

        if (document.all) {
            slideshowimg.style.filter = "blendTrans(duration=" + this.crossFadeDuration + ")";
            slideshowimg.filters.blendTrans.Apply();
        }

        slideshowimg.src = this.array[this.currentIndex];

        if (document.all) {
            slideshowimg.filters.blendTrans.Play();
        }

        this.currentIndex = (this.currentIndex + 1) % this.array.length;

        this.timeout = setTimeout(function () { me.runSlideShow(); }, this.slideShowSpeed);
    }
}

if (typeof Picl != "undefined") { PT.Instances.Slideshow = new PT.Sites.Castelijnmode.Slideshow('faderimglinks.1', Picl, 4000); };
if (typeof Picr != "undefined") { PT.Instances.Slideshow = new PT.Sites.Castelijnmode.Slideshow('faderimgrechts.1', Picr, 4500); };
