<!--
/*
Custom script to handle the animated fade in DHTML menu. The animator is from some site, see animator.js for disclaimer and stuff.
The rest is copyright Paperino 2008. Anyway there isn't much to copy, the menu structure is generated on the server side.
*/

var m_nDisplayedSection = 0;
var m_nLastDisplayed = 0;
var m_oFade = null;

// Objective: Shows a given menu section with a fade in effect.
// Arguments: - sElementID; id of the element to display.
function animateSection(sElementID)
{
	var oElement = document.getElementById(sElementID);
	
	if (oElement.style.display == "none")
	{
	if (window.ActiveXObject)
	{
		oElement.style.filter = "alpha(opacity=25)";
	}
	else
	{
		oElement.style.opacity = 0.25;
	}
	m_oFade = new Animator().addSubject(new NumericalStyleSubject(oElement, "opacity", 0.25, 1));
	oElement.style.display = "block";
	m_oFade.play();
	}

}

// Objective: Gets the absolute position of an element. offsetLeft/Top work differently in IE and other browsers, this function returns the actual value for most browsers.
// Arguments: theElement, object;
// Returns:   Array. returns a named array containing the X and Y cooerdinated of the item.
function getElementPosition(theElement)
{
	var posX = 0;  var posY = 0;
	while(theElement != null)
	{
		posX += theElement.offsetLeft;
		posY += theElement.offsetTop;
		theElement = theElement.offsetParent;
	}
	return {x:posX,y:posY};
}

// Objective: hilites a given element, by changing it's class name.
// Arguments: - bOnOff, boolean.
function hilite(sElementID, bOnOff)
{
	var oElement = document.getElementById(sElementID);

	if (bOnOff)
	{
		oElement.className = "menu_item_h";
	}
	else
	{
		oElement.className = "menu_item";
	}
}

// Objective: This function is executed periodically every 1 second when a menu section is displayed, until the m_nDisplayedSection is set to 0 in some onmouseout event.
// Arguments: none.
function checkAndHide()
{
	if (m_nDisplayedSection != 0)
	{
		m_nLastDisplayed = m_nDisplayedSection;
		setTimeout("checkAndHide()", 1000);
	}
	else
	{
		for (var i = 1; i < 3; i++)
		{
			document.getElementById("divMenuSect" + i).style.display = "none";
		}
	}
	if (m_nLastDisplayed != m_nDisplayedSection)
		document.getElementById("divMenuSect" + m_nLastDisplayed).style.display = "none";
}

// Objective: Shows a given menu section and hides the last displayed section.
// Arguments: - nSection, integer; number of the section to display (1..3).
function showMenuSection(nSection)
{
	var oSection = null;

	oSection = document.getElementById("divMenuSect" + nSection);
	{
		if ((m_nLastDisplayed != nSection) && (m_nLastDisplayed > 0))
		{
			document.getElementById("divMenuSect" + m_nLastDisplayed).style.display = "none";
		}
		for (var i = 1; i < 3; i++)
		{
			if (i != nSection)
				document.getElementById("divMenuSect" + i).style.display = "none";
		}
		
		oSection.style.zIndex = 10;
		oSection.style.left = getElementPosition(document.getElementById("divMenuHeader1"))["x"] + 96 + "px"; //document.getElementById("divMenuHeader1").offsetLeft + 96;

		animateSection("divMenuSect" + nSection);
		m_nDisplayedSection = nSection;
		
		checkAndHide();
	}
}
//-->