/* Short set of functions to fade through a series of layered divs. */

var currentDiv = 6;

function switchLayer()
{
	var theDiv = document.getElementById('div' + currentDiv);
	
	theDiv.style.display = 'none';
	
	if((currentDiv - 1) < 0)
	{
		var main = document.getElementById("tabblock");
		var collect = main.getElementsByTagName("DIV");
		
		for(var x = 0; x < collect.length; x++)
		{
			collect[x].style.display = 'block';
		}
		
		currentDiv = 6;
	}
	else
	{
		currentDiv -= 1;
	}
}

function startFade()
{
	
	for(var x = 9; x >= 1; x -= 1)
	{
		setTimeout('fadeMe(' + x/10 + ',"div' + currentDiv +'")',100*x);
	}
}

function fadeMe(value,div)
{	
	document.getElementById(div).style.opacity = 1 - value;
	
	if(document.getElementById(div).style.opacity == 0.1)
	{
		switchLayer();
		document.getElementById(div).style.opacity = 1;
	}
}

function runFlick()
{
	if(document.getElementById("tabblock"))
	{
		startFade();
		
		var theTimer = setTimeout('runFlick()',2000);
	}
}