/*
** Javascript Menu engine
*/

var CNavMenuManager = 
{	
	deselectAll: function(szUBlockName)
	{		
		// Select the container
		oTabPane = document.getElementById(szUBlockName);
		
		// cycle through the children
		for (oCurPane = oTabPane.firstChild; oCurPane; oCurPane = oCurPane.nextSibling)
		{
			if (oCurPane.id)
			{
				szFirstClass = oCurPane.className.split(" ");
				
				if (szFirstClass[0] != "cItemSel")
				{
					oCurPane.className = "cItem";
				}								
			}
		}
	},
	
	revert: function()
	{										
		this.deselectUpper();
		this.hideSubNavs();
	
		
		// Select the container
		oTabPane = document.getElementById("idUBottomRow");
		
		// cycle through the children
		for (oCurPane = oTabPane.firstChild; oCurPane; oCurPane = oCurPane.nextSibling)
		{
			if (oCurPane.id)
			{
				// For companion class issues, take only the first class name				
				szFirstClass = oCurPane.className.split(" ");
				
				if (szFirstClass[0] == "cItemSel")
				{
					szContainerName = this.refineContainerName( oCurPane.id, "container" );				
					
					oContainer = document.getElementById(szContainerName);
					oContainer.style.display = "block";
				}
			}
		}
	},
	
	hideSubNavs: function()
	{		
		// Select the container
		oTabPane = document.getElementById("idLBottomRow");
		
		// cycle through the children
		for (oCurPane = oTabPane.firstChild; oCurPane; oCurPane = oCurPane.nextSibling)
		{
			if (oCurPane.id)
			{
				oCurPane.style.display = "none";
			}
		}
	},
	
	deselectUpper: function()
	{
		this.deselectAll("idUBottomRow");
	},
	
	deselectLower: function()
	{
		this.deselectAll("idLBottomRow");
	},
	
	refineContainerName: function(szID, szPrefix)
	{
		// get the appropriate links container
		szLinksContainer = szID; 
		
		// generate the container ID name
		aItemChunks = szLinksContainer.split("_");
		
		szContainerName = szPrefix + "_" + aItemChunks[1];
		
		return szContainerName;
	},
	
	mouseOver: function(oParentEl)
	{
		// Deselect all items
		this.deselectUpper();
		
		szContainerName = this.refineContainerName( oParentEl.id, "container" );
		
		this.hideSubNavs();
		
		oContainer = document.getElementById(szContainerName);
		
		oContainer.style.display = "block";
		
		szFirstClass = oParentEl.className.split(" ");
				
		if (szFirstClass[0] != "cItemSel")
		{
			// Set the class to 'cur'
			oParentEl.className = "cItemCur";
		}
	},
	
	mouseOverLower: function( oParentEl )
	{
		szContainerName = this.refineContainerName( oParentEl.id, "links" );
		
		this.mouseOver(document.getElementById(szContainerName));	
	}
};

var CLeftMenuManager = 
{	
	mouseOver: function(oParentEl)
	{				
		// If the parent isn't 'selected', then 'current' it
		szFirstClass = oParentEl.className.split(" ");
		
		if (szFirstClass[1])
		{
			// reject 'selected's
			if (szFirstClass[1] == "selected")
			{
				return;
			}
		}
		
		// Otherwise, colour it in
		oParentEl.className = "cItem current";
	},
	
	mouseOut: function(oParentEl)
	{				
		// If the parent isn't 'selected', then 'current' it
		szFirstClass = oParentEl.className.split(" ");
		
		if (szFirstClass[1])
		{
			if (szFirstClass[1] == "current")
			{
				oParentEl.className = "cItem";
				return;
			}			
		}		
	}
}