var Featured = {
	list: new Array(),
	id: "",
	hold: false,
	direction: "forward",
	obj: new Object(),
	timeout: null,
	fadetimeout: null,
	currentIndex: 0,
	add: function(id, pic) {
		thisFeatured = {
			obj: document.getElementById(id),
			alpha: 100,
			timeout: null,
			listIndex: Featured.list.length,
			fadeOut: function(fast) {
				if (fast == true)this.alpha-=10;
				else this.alpha-=5;
				opacityString = this.alpha/100;
				filterString = "alpha(opacity = " + this.alpha + ")";
				this.obj.style.opacity = opacityString;//"0.5";
				this.obj.style.filter = filterString;//"alpha(opacity = 50)";
				Featured.hold = true;
				if (fast == true) functionCall = "Featured.list[" + this.listIndex + "].fadeOut(true)";
				else functionCall = "Featured.list[" + this.listIndex + "].fadeOut()";
				if (this.alpha > 0) this.fadetimeout =  setTimeout(functionCall,10);
				else {
					this.alpha = 100;
					this.obj.style.display = "none";
					this.obj.style.zIndex = 1;
					Featured.hold = false;
				}				
			}
		}
		preloadImages(pic);
		this.list.push(thisFeatured);
	},
	
	showNext: function(manual) {
		if ((Featured.hold == false && Featured.direction != "lock") || (manual == true && Featured.hold == false)) {
			if (manual == true) var fast = true;
			else var fast = false;
			this.list[this.currentIndex].fadeOut(fast);
			this.list[this.currentIndex].obj.style.zIndex = 10;
	
			this.currentIndex++;
			if (this.currentIndex>(this.list.length-1)) this.currentIndex = 0;
	
			this.list[this.currentIndex].obj.style.opacity = "1.0";
			this.list[this.currentIndex].obj.style.filter = "alpha(opacity = 100)";
			this.list[this.currentIndex].obj.style.display = "block";
			this.list[this.currentIndex].obj.style.zIndex = 1;
			
			var buttonTarget = document.getElementById("pausebutton");
			if (manual != true) this.timeout = setTimeout("Featured.showNext()",10000);
			else {
				Featured.direction = "forward"
				Featured.pausetoggle(buttonTarget);
			}
		}
	},
	
	showPrev: function(manual) {
		if ((Featured.hold == false && Featured.direction != "lock") || (manual == true && Featured.hold == false)) {
			if (manual == true) var fast = true;
			else var fast = false;
			this.list[this.currentIndex].fadeOut(fast);
			this.list[this.currentIndex].obj.style.zIndex = 10;
	
			if (this.currentIndex<1) this.currentIndex = (this.list.length);
			this.currentIndex--;
	
			this.list[this.currentIndex].obj.style.opacity = "1.0";
			this.list[this.currentIndex].obj.style.filter = "alpha(opacity = 100)";
			this.list[this.currentIndex].obj.style.display = "block";
			this.list[this.currentIndex].obj.style.zIndex = 1;

			var buttonTarget = document.getElementById("pausebutton");
			if (manual != true) this.timeout = setTimeout("Featured.showPrev()",10000);
			else {
				Featured.direction = "forward"
				Featured.pausetoggle(buttonTarget);
			}
		}
	},
	
	finalize: function(id) {
		this.id = id;
		this.obj = document.getElementById(id);
		this.list[0].obj.style.display = "block";
		if (Featured.direction == "forward"){
			if (EventManager) EventManager.add(window, "load", Featured.begin);
			else this.timeout = setTimeout("Featured.showNext()",15000);
		}
	},
	
	begin: function() {
		if (Featured.direction != "lock") this.timeout = setTimeout("Featured.showNext()",5000);
	},
	
	pause: function() {
		clearTimeout(this.timeout);
		if (Featured.direction != "lock") Featured.direction = "paused";
	},
	
	unpause: function() {
		if (Featured.direction != "lock") {
			this.timeout = setTimeout("Featured.showNext()",2000);
			Featured.direction = "forward";
		}
	},

	pausetoggle: function(itself) {
		if (Featured.direction == "paused" || Featured.direction == "lock") {
			Featured.direction = "paused";
			Featured.unpause();
			itself.className = 'play';
		}
		else {
			Featured.direction = "lock";
			Featured.pause();
			itself.className = 'pause';
		}
	}
}