var CurrentShowcase =	1;
var showcaseData =		new Array();
var showcaseTimer =		null;

function InitShowcase() {
	CurrentShowcase = 1;
	ToggleShowcase(CurrentShowcase);
	
}

function ToggleShowcase(n) {
	
	var x;
	var obj;
	
	// reset the timeout so a click and a timeout iteration don't collide
	if(n != null && showcaseTimer != null) {
		clearTimeout(showcaseTimer);
	}
	
	if(n == null || n == 0) { n = CurrentShowcase + 1; }
	else if(n == -1) { n = CurrentShowcase - 1; }
	
	if(n > showcaseData.length) { n = 1; }
	if(n < 1) { n = showcaseData.length; }
	
	// image link
	obj = document.getElementById('showcase_image_link');
	obj.href = showcaseData[n - 1].link;
	
	// image
	obj = document.getElementById('showcase_image');
	obj.src = showcaseData[n - 1].image;
	
	// title
	obj = document.getElementById('showcase_title');
	obj.innerHTML = showcaseData[n - 1].title;
	
	// description
	obj = document.getElementById('showcase_description');
	obj.innerHTML = showcaseData[n - 1].description;
	
	// toggle active link
	for(x = 1; x <= showcaseData.length; x++) {
		
		obj = document.getElementById('showcase_link_' + x);
		if(x == n) {
			obj.className = "active";
		}
		else {
			obj.className = "";
		}
	}
	
	CurrentShowcase = n;
	
	showcaseTimer = setTimeout("ToggleShowcase()",8000);
	
}
