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

var currentDiv = 6;

function flick_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 flick_startFade()
{
	
	for(var x = 9; x >= 1; x -= 1)
	{
		setTimeout('flick_fadeMe(' + x + ',"div' + currentDiv +'")',10*x);
	}
}

function flick_fadeMe(value,div)
{	
	var fade = 10 - value;
	document.getElementById(div).style.opacity = '0.' + fade;
	document.getElementById(div).style.filter = 'alpha(opacity='+ (fade * 10) +')';
	
	if(fade == 1)
	{
		flick_switchLayer();
		document.getElementById(div).style.opacity = 1;
		document.getElementById(div).style.filter = 'alpha(opacity=100)';
	}
}

function runFlick()
{
	var checkVal = 9 / 10;
	
	if(document.getElementById("tabblock"))
	{
		flick_startFade();
		
		var theTimer = setTimeout('runFlick()',4000);
	}
}

window.onload = runFlick;
