// common layout functions
function toggle( par_id )
{
	if (document.getElementById)
	{
		target = document.getElementById( par_id );
		if (target.style.display == "none")	{ target.style.display = ""; target.innerHTML.display = ""; }
		else	{ target.style.display = "none"; target.innerHTML.display = "none"; }
	}
}
function show_tab(scenario)
{
    var tab;
    var i = 1;
	while (tab = document.getElementById('tab' + i))
	{
        if (i == scenario)	{ tab.style.display = 'block'; }
        else				{ tab.style.display = 'none'; }
        i++;
    }
	var content;
    i = 1;
	while (content = document.getElementById('content' + i))
	{
		if (i == scenario)	{ content.style.display = 'block'; }
        else				{ content.style.display = 'none'; }
        i++;
    }
}
function detect_tab(url)
{
	if (! url)	{ url = window.location + ''; }		// URL as string
	var regexp = /#(.+)$/
	var prepostanchor = url.split('#');
	var tab;
	if( prepostanchor.length > 1 )	{ tab = prepostanchor.pop(); }
	if( (tab !=2) && (tab !=3) && (tab !=4) && (tab !=5) && (tab !=6) )	{ return 1;}	// bogus tab; set default
	return tab;
}




// recursive function call that performs the fade
function DoFade(colorId, targetId)
{
//alert('colorId: ' + colorId);
//alert('targetId: ' + targetId);
//exit;
	var FadeInterval = 600;
	var FadeSteps = new Array();
		FadeSteps[1] = "ff";
		FadeSteps[2] = "ee";
		FadeSteps[3] = "dd";
		FadeSteps[4] = "cc";
		FadeSteps[5] = "bb";
		FadeSteps[6] = "aa";
		FadeSteps[7] = "99";
	if (colorId >= 1)
	{
		document.getElementById(targetId).style.backgroundColor = "#ffff" + FadeSteps[colorId];
        if (colorId==1) { document.getElementById(targetId).style.backgroundColor = "transparent"; }	// if last color, set to transparent
        colorId--;
        setTimeout("DoFade("+colorId+",'"+targetId+"')", FadeInterval);		// wait, and fade another shade
	}
}
