/*
*	Developed by Hutz! Media! <hutzmedia.com>
*	Under Contract For: JAFTech <jaftech.com>
*
*	August 31, 2010
*/

// <class name="slideshow">
SlideShowClass = function() {
	// settings
	this.fps = 20;
	this.fadeTime = 1000;
	this.waitTime = 5000;
	
	// variables (do not edit)
	this.p = 0;
	this.images = [];
};
SlideShowClass.prototype = {
	"init": function(a) {
		var self = this;
		self.p = 0;
		self.images = a;
		setTimeout(function(){self.next(self);}, self.waitTime);
	},
	"next": function(self) {
		var lObj = document.getElementById(self.images[self.p]);
		lObj.style.zIndex = 49;
		
		self.p++;
		if (self.p >= self.images.length) {
			self.p = 0;
		}
		
		var nObj = document.getElementById(self.images[self.p]);
		self.setOpacity(nObj, 0);
		nObj.style.display = "block";
		nObj.style.zIndex = 50;
		
		self.step(self, nObj, 0, 100, 0);
	
	},
	"step": function(self, obj, from, to, current) {
		var step = (to - from) / (self.fps * (self.fadeTime / 1000));
		current += step;
		if (from < to) {
			current = Math.min(current, to);
		} else {
			current = Math.max(current, to);
		}
		
		self.setOpacity(obj, current);
		
		if (current == to) {
			setTimeout(function(){self.next(self);}, self.waitTime);
		} else {
			setTimeout(function(){self.step(self, obj, from, to, current);}, 1000 / self.fps);
		}
		
	},
	"setOpacity": function(obj, opacity) {
		obj.style.opacity = opacity / 100;
		obj.style.filter = "alpha(opacity=" + opacity + ")";
	}
};

var Slideshow = new SlideShowClass();
// </class>
