var showcaseIndex = 0;
var casestudyIndex = 0;
var showcaseLastBoxId = null;
var casestudyLastBoxId = null;
var showcaseTimeOut = 5; // showcase timeout in seconds
var casestudyTimeOut = 5; // casestudy timeout in seconds

var index = 0;
var timeOut = 5;

function start()
{
	if (typeof showcaseBoxArray != "undefined"){
		showcaseDisplay(showcaseBoxArray[showcaseIndex]);
	}
	if (typeof casestudyBoxArray != "undefined"){
		casestudyDisplay(casestudyBoxArray[casestudyIndex]);
	}
    //window.setInterval("showcaseNext()", showcaseTimeOut*1000);
    //window.setInterval("casestudyNext()", casestudyTimeOut*1000);
    window.setInterval("nextFeature()", timeOut*1000);
}

function nextFeature()
{
    if (index == 0) { casestudyNext(); } else { showcaseNext(); }
    index = ++index % 2;
}

function showcaseNext()
{
    if (showcaseIndex == showcaseBoxArray.length - 1) { showcaseIndex = 0; } else { showcaseIndex++; }
    showcaseDisplay(showcaseBoxArray[showcaseIndex]);
}

function casestudyNext()
{
    if (casestudyIndex == casestudyBoxArray.length - 1) { casestudyIndex = 0; } else { casestudyIndex++; }
    casestudyDisplay(casestudyBoxArray[casestudyIndex]);
}

function showcaseDisplay(boxId)
{
    if (showcaseLastBoxId != null) { toggleBox(showcaseLastBoxId, false); }
    showcaseLastBoxId = boxId;
    return toggleBox(boxId, true);
}

function casestudyDisplay(boxId)
{
    if (casestudyLastBoxId != null) { toggleBox(casestudyLastBoxId, false); }
    casestudyLastBoxId = boxId;
    return toggleBox(boxId, true);
}

function toggleBox(boxId, state)
{
    var obj = document.layers ? (document.layers[boxId] ? document.layers[boxId] : null) : (document.getElementById ? (document.getElementById(boxId) ? document.getElementById(boxId).style : null) : (document.all[boxId] ? document.all[boxId].style : null));
    if (obj != null) { obj.visibility = document.layers ? (state ? "show" : "hide") : (state ? "visible" : "hidden"); }
    return false;
}

//if (document.getElementById || document.all) { window.onload = start; }

