﻿PT.Sites.Linders.Slideshow = function(targetImage, array, speed) {
	var me = this;
	
	this.slideShowSpeed = speed;
	this.crossFadeDuration = 3;
	this.targetImage = targetImage;
	this.array = array;
	this.currentIndex = 0;
	this.timeout = undefined;
	
	PT.Sites.General.RegisterEvent(window, "load", function() {me.runSlideShow();} );
}

PT.Sites.Linders.Slideshow.prototype.runSlideShow = function() {
	var me = this;
	
	if (this.array.length>0) {
		var slideshowimg = $(this.targetImage).getElementsByTagName('img')[0];
		
		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.Linders.Slideshow('maindivslider', Pic, 6000);};