var delayShowcase = 5000; // Time in ms until the next image starts to fade in
var delayChangeShowcase = 1000; // This should be the same as animateTimer
var animateTimer = 1000; // Amount of time in ms fade animations etc take
var timerShowcase;
var classShowcaseDiv = document.getElementsByTagName('a');
var imagePosition;
var imageHeight;
var imageWidth;

function getElementDetails(elementName) {
	imagePosition = $(elementName).position();
	imageHeight = $(elementName).height();
	imageWidth = $(elementName).width();
}
function setElementDetails(elementName) {
	$(elementName).css({
		"position": "absolute",
		"left": imagePosition.left+716,
		"top": imagePosition.top+176,
		"width": imageWidth,
		"height": imageHeight,
		"background": "white",
		"cursor": "pointer",
		"z-index": "1000"
	});
}
function loadShowcase(showcaseID) {
	$("#blackBox").animate({ opacity: "0.8"}, animateTimer);
	$("#showcaseLeft").animate({ opacity: "1.0"}, animateTimer);
	$("#showcaseUpperRight").animate({ opacity: "1.0"}, animateTimer);
	showcaseID++;
	if(showcaseID >= showcaseLeft.length) {
		showcaseID = 0;
	}
	timerShowcase = setTimeout("fadeShowcase(" + showcaseID + ")", delayShowcase);
}
function fadeShowcase(showcaseID) {
	$("#blackBox").animate({ opacity: "0.0"}, animateTimer);
	$("#showcaseLeft").animate({ opacity: "0.0"}, animateTimer);
	$("#showcaseUpperRight").animate({ opacity: "0.0"}, animateTimer);
	timerShowcase = setTimeout("changeShowcase(" + showcaseID + ")", delayChangeShowcase);
}
function changeShowcase(showcaseID) {
	clearTimeout(timerShowcase);
	document.getElementById("showcaseLeft").innerHTML = showcaseLeft[showcaseID];
	document.getElementById("showcaseUpperRight").innerHTML = showcaseUpperRight[showcaseID];
	getElementDetails("#showcaseLink_" + showcaseID);
	setElementDetails("#blackBox");
	loadShowcase(showcaseID);
}
function manualChangeShowcase(showcaseID) {
	clearTimeout(timerShowcase);
	$("#blackBox").animate({ opacity: "0.0"}, animateTimer);
	$("#showcaseLeft").animate({ opacity: "0.0"}, animateTimer);
	$("#showcaseUpperRight").animate({ opacity: "0.0"}, animateTimer);
	timerShowcase = setTimeout("changeShowcase(" + showcaseID + ")", delayChangeShowcase);
}
$(document).ready(function(){
	document.getElementById("showcaseLeft").innerHTML = showcaseLeft[0];
	document.getElementById("showcaseUpperRight").innerHTML = showcaseUpperRight[0];
	loadShowcase(0);
	getElementDetails("#showcaseLink_0");
	setElementDetails("#blackBox");
});