﻿function ArrowsCSA(a) {
	this.classIdName = a
}
function CarouselItem(b, a) {
	this.fadeDelay;
	this.slidetimer;
	this.scrolltimer;
	this.arrow;
	this.autoPlay = false;
	this.bgimages = [];
	this.csaID = b;
	this.s = new CarouselStage(a);
	this.selectedIndex = -1;
	this.busy = false
}
CarouselItem.prototype.play = function() {
	if (this.autoPlay) {
		return
	}
	this.autoPlay = true;
	this.scrolltimer = setInterval(this.csaID + ".goToNextFrame()", 8000)
};
CarouselItem.prototype.pause = function() {
	if (!this.autoPlay) {
		return
	}
	this.autoPlay = false;
	if (this.scrolltimer == undefined || this.scrolltimer == null) {
		return
	}
	clearInterval(this.scrolltimer);
	this.scrolltimer = null
};
CarouselItem.prototype.restart = function() {
	this.pause();
	this.play()
};
CarouselItem.prototype.goToNextFrame = function() {
	if (this.autoPlay) {
		var a = this.nextFrame();
		this.press(a, true)
	}
};
CarouselItem.prototype.nextFrame = function() {
	if (this.selectedIndex == this.bgimages.length) {
		return 1
	} else {
		if (this.selectedIndex < this.bgimages.length) {
			return ((this.selectedIndex * 1) + 1)
		} else {
			return 1
		}
	}
};
CarouselItem.prototype.prevFrame = function() {
	if (this.selectedIndex > 1) {
		return ((this.selectedIndex * 1) - 1)
	} else {
		return document.getElementById("numFrame").value
	}
};
CarouselItem.prototype.loadImg = function(b) {
	if (b != -1) {
		var a = this.s.frames[b - 1];
		if (a.imgLoaded) {
			return
		}
	}
	elem = document.getElementById(this.s.frames[b - 1].imgId);
	elem.src = this.bgimages[b - 1];
	this.s.frames[b - 1].imgLoaded = true
};
CarouselItem.prototype.updateFrame = function(c) {
	var b = this.s.frames[this.selectedIndex - 1];
	if (b == null) {
		return
	}
	if (b.spots == null) {
		return
	}
	var a = b.spots.length;
	if (!c) {
		this.clearOverlay(b)
	}
};
CarouselItem.prototype.hide = function(a) {
	if (a == null || a.style.visibility == "hidden") {
		return
	}
	a.style.visibility = "hidden"
};
CarouselItem.prototype.show = function(a) {
	if (a == null || a.style.visibility == "visible") {
		return
	}
	a.style.visibility = "visible"
};
CarouselItem.prototype.press = function(b, a) {
	if (this.busy || b == this.selectedIndex) {
		return
	}
	this.loadImg(b);
	deactive();
	this.slide(b, a);
	this.selectedIndex = b
};
CarouselItem.prototype.slide = function(b, a) {
	this.busy = true;
	if (this.slidetimer != undefined || this.slidetimer != null) {
		clearTimeout(this.slidetimer)
	} (a || b > this.selectedIndex) ? this.scrollRight(b, this.selectedIndex) : this.scrollLeft(b, this.selectedIndex)
};
CarouselItem.prototype.scrollRight = function(c, a) {
	var b = document.getElementById("stage");
	b.style.left = "0px";
	this.reposition(a, 0);
	this.reposition(c, 1);
	this.reIndex(c, a);
	this.scroll(0, -996)
};
CarouselItem.prototype.scrollLeft = function(c, a) {
	var b = document.getElementById("stage");
	b.style.left = "-996px";
	this.reposition(c, 0);
	this.reposition(a, 1);
	this.reIndex(c, a);
	this.scroll( -996, 0)
};
CarouselItem.prototype.reIndex = function(d, b) {
	var c = 2;
	var a = this.s.frames.length;
	for (a; a > 0; a--) {
		if (a != d && a != b) {
			this.reposition(a, c++)
		}
	}
};
CarouselItem.prototype.reposition = function(b, a) {
	this.s.frames[b - 1].elem.style.left = 996 * a + "px"
};
CarouselItem.prototype.scroll = function(c, a) {
	var b = document.getElementById("stage");
	next = c,
	this.slidetimer = 0,
	interval = 100,
	speed = 60,
	this.arrow = "";
	if (c < a) {
		next += interval;
		this.arrow = "lArrow"
	} else {
		if (c > a) {
			next -= interval;
			this.arrow = "rArrow"
		}
	}
	if (next > 0 || (next < a && c > a) || (next > a && c < a)) {
		next = next > 0 ? 0 : a;
		b.style.left = next + "px";
		this.busy = false
	} else {
		b.style.left = next + "px";
		this.slidetimer = setTimeout(this.classIdName + ".scroll(" + next + ", " + a + ")", speed)
	}
};
function CarouselStage(b) {
	this.frames = [b];
	for (var a = 0; a < b; a++) {
		this.frames[a] = new CarouselFrame(a + 1, true, 10)
	}
}
function CarouselFrame(b, a, c) {
	this.id = "f" + b;
	this.elem = document.getElementById(this.id);
	this.activeOverlay = -1;
	this.imgLoaded = false;
	this.imgId = "img" + b
}
function initArrowsCSA(b) {
	var a = document.getElementById("numFrame").value;
	ArrowsCSA.prototype = new CarouselItem(b, a);
	arrowsCSA = new ArrowsCSA(b);
	for (i = 0; i < a; i++) {
		arrowsCSA.bgimages[i] = document.getElementById("images" + (i + 1)).value
	}
	arrowsCSA.s.frames[0].imgLoaded = true;
	arrowsCSA.selectedIndex = 1;
	arrowsCSA.play()
}
function active() {
	if (arrowsCSA.selectedIndex == -1) {
		return
	}
	arrowsCSA.pause();
	arrowsCSA.updateFrame(true);
	document.getElementById("rArrow1").style.visibility = "visible";
	document.getElementById("lArrow1").style.visibility = "visible"
}
function deactive() {
	if (arrowsCSA.selectedIndex == -1) {
		return
	}
	var a = arrowsCSA.s.frames[arrowsCSA.selectedIndex - 1];
	if (a == null) {
		return
	}
	document.getElementById("rArrow1").style.visibility = "hidden";
	document.getElementById("lArrow1").style.visibility = "hidden";
	arrowsCSA.updateFrame(false);
	arrowsCSA.restart()
}
function prevF(a) {
	if (arrowsCSA.busy || b == arrowsCSA.selectedIndex) {
		return
	}
	var b = arrowsCSA.prevFrame();
	arrowsCSA.loadImg(b);
	deactive();
	arrowsCSA.busy = true;
	if (arrowsCSA.slidetimer != undefined || arrowsCSA.slidetimer != null) {
		clearTimeout(arrowsCSA.slidetimer)
	}
	arrowsCSA.scrollLeft(b, arrowsCSA.selectedIndex);
	arrowsCSA.selectedIndex = b
}
function nextF(a) {
	if (arrowsCSA.busy || b == arrowsCSA.selectedIndex) {
		return
	}
	var b = arrowsCSA.nextFrame();
	arrowsCSA.loadImg(b);
	deactive();
	arrowsCSA.busy = true;
	if (arrowsCSA.slidetimer != undefined || arrowsCSA.slidetimer != null) {
		clearTimeout(arrowsCSA.slidetimer)
	}
	arrowsCSA.scrollRight(b, arrowsCSA.selectedIndex);
	arrowsCSA.selectedIndex = b
}
function highlightA(a) {
	if (a.className == "arrow r-a") {
		a.className = "arrow r-h"
	}
	if (a.className == "arrow l-a") {
		a.className = "arrow l-h"
	}
}
function dehighlightA(a) {
	if (a.className == "arrow r-h") {
		a.className = "arrow r-a"
	} else {
		if (a.className == "arrow l-h") {
			a.className = "arrow l-a"
		}
	}
}
var arrowsCSA;
initArrowsCSA("arrowsCSA");
