
var g_defaultPanel = 'Default';
var g_currentPanel = 'Default';
var g_bIsIE = (typeof(document.all) != 'undefined');
var g_nSwappingRes = -1;

function testPrint(pMessage)
{
/*
	var txtTest = document.getElementById('txtTest');
	if( txtTest != null )
	{
		txtTest.value = pMessage;
	}
*/
}

function switchToNavPanel(pPanelToShow)
{
	if( pPanelToShow == 'Default' )
		pPanelToShow = g_defaultPanel;

	if( g_currentPanel == pPanelToShow )
		return;
	if( g_nSwappingRes >= 0 )
	{
		clearTimeout(g_nSwappingRes);
		g_nSwappingRes = -1;
	}

	g_currentPanel = pPanelToShow;
	g_nSwappingRes = setInterval('stepSwapTo();', 100);
}

function stepSwapTo()
{
	var vSwapTo   = document.getElementById('navPanel_' + g_currentPanel);

	if( vSwapTo != null )
	{
		//half the opacity of the divs that aren't the current
		var vDiv = document.getElementById('navPanels');
		var nHighestAlpha = 0.0;
		var nActiveAlpha = 0.0;
		
		if( vDiv != null )
		{
			for( var nIndex = 0; nIndex < vDiv.childNodes.length; nIndex++ )
			{
				var currentCheck = vDiv.childNodes[nIndex];
				if( currentCheck.id != undefined )
				{
					if( currentCheck.tagName.toLowerCase() == 'div' )
					{
						var navTab = document.getElementById(currentCheck.id.replace('navPanel', 'navTab'));
						
						if( currentCheck.id != 'navPanel_' + g_currentPanel )
						{
							nHighestAlpha = Math.max(stepDownOpacity(currentCheck), nHighestAlpha);
							if( navTab!= null ) 
								navTab.style.backgroundColor = 'transparent';
						}
						else
						{
							nActiveAlpha = stepUpOpacity(currentCheck);
							if( navTab!= null ) 
								navTab.style.backgroundColor = '#330066';
						}	
					}
				}
			}
		}

		if( ( nActiveAlpha >= 1.0 ) && ( nHighestAlpha <= 0.05 ) )
		{
			clearInterval(g_nSwappingRes);
			g_nSwappingRes = -1;
		}
	}
	else
	{
		clearInterval(g_nSwappingRes);
		g_nSwappingRes = -1;
	}
}

function stepDownOpacity(pDiv)
{
	var szAlpha = ( g_bIsIE ? pDiv.filters[0].opacity : pDiv.style.MozOpacity );

	if( szAlpha == '' )		
		szAlpha = '0.0';
	var fAlpha = parseFloat(szAlpha);
	if( g_bIsIE )
		fAlpha = fAlpha / 100.0;
	
	if( fAlpha < 0.10 )
		fAlpha = 0;

	fAlpha /= 2.0;
	//fAlpha -= 0.10;
	
	if( fAlpha <= 0.03 )
	{
		pDiv.style.visibility = 'hidden';
		pDiv.style.display = 'none';
	}

	if( g_bIsIE )
		pDiv.filters[0].opacity = (fAlpha * 100.0);
	else
		pDiv.style.MozOpacity = fAlpha;

	return fAlpha;
}

function stepUpOpacity(pDiv)
{
	var szAlpha = ( g_bIsIE ? pDiv.filters[0].opacity : pDiv.style.MozOpacity );

	if( szAlpha == '' )		
		szAlpha = '0.0';
	var fAlpha = parseFloat(szAlpha);
	if( g_bIsIE )
		fAlpha /= 100.0;
	
	if( fAlpha > 0.90 )
		fAlpha = 1.00;

	fAlpha = Math.min(1.0, fAlpha * 2.25);
	//fAlpha = Math.min(1.0, fAlpha += 0.10);
	
	if( fAlpha < 0.05 )
		fAlpha = 0.10;

	if( fAlpha > 0.0 )
	{
		pDiv.style.visibility = 'visible';
		pDiv.style.display = 'block';
	}
	
	if( g_bIsIE )
		pDiv.filters[0].opacity = (fAlpha * 100.0);
	else
		pDiv.style.MozOpacity = fAlpha;

	return fAlpha;
}

