﻿PT.Sites.Standaardwinkelcentrum.Slideshow = function(targetImage, array, speed) {
	var me = this;

	this.slideShowSpeed = speed;
	this.crossFadeDuration = 2;
	this.targetImage = targetImage;
	this.array = array;
	this.currentIndex = 1;
	this.timeout = undefined;

	PT.Sites.General.RegisterEvent(window, "load", function() {
	if (me.array.length > 1) {
		setTimeout(function() {me.runSlideShow();},(me.slideShowSpeed/3));
	}});
}

PT.Sites.Standaardwinkelcentrum.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 Pic != "undefined") { PT.Instances.Slideshow = new PT.Sites.Standaardwinkelcentrum.Slideshow('alg_foto.1', Pic, 4000); };
