/*
	Author		Jack Wootton
	Version		1.2
	Updated		23/03/2007
*/

/* 
	Constants used throughout script.  Do not change. 
*/
function Utility() 
{
	this.LIST_ITEM_ELEMENT = 'LI';
	this.EMPTY_STRING = '';
	this.CSS_HIGHLIGHT = 'current';
	this.CSS_BLOCK = 'block';
	this.CSS_NONE = 'none';
}

var utility = new Utility();

/*
	Each set of tabs must be declared in an array.
*/
TABS_CMS = new Array("story","images","media","keywords","search");


/*
	Hide a layer if it exists.

	@param  layerName  Name of div element to hide.
*/
function HideContent(layerName)
{
	if(layerName.length < 1) { return; }
	document.getElementById(layerName).style.display = utility.CSS_NONE;
}



/*
	Shows layer when tab clicked.

	@param  layerName  Name of div element to show.
	@param  tabElement  Reference to actual <li> element in list.
	@param  tabArray  Array of div names in tabbed navigation.
*/
function ShowContent(layerName, tabElement, tabArray) 
{
	// If it exists, show tab
	if(layerName.length < 1) { return; }
	document.getElementById(layerName).style.display = utility.CSS_BLOCK;

	// Hide all other tabs
	for (var i=0;i<tabArray.length ;i++ )
	{
		if (layerName != tabArray[i])
		{
			HideContent(tabArray[i]);
		}
	}

	// Highight tab
	tabElement.className = utility.CSS_HIGHLIGHT;

	// Grey out all tabs before the new active tab.
	var obj = tabElement.previousSibling;

	// Cycle through nodes inside UL tag prior to the current LI tab, picking out LI nodes
	while (obj)
	{
		disableTab(obj);
		obj = obj.previousSibling;
	}

	// Grey out all tabs after the new active tab
	obj = tabElement.nextSibling;
	
	// Cycle through nodes inside UL tag after the current LI tab, picking out LI nodes 
	while (obj)
	{
		disableTab(obj);
		obj = obj.nextSibling;
	}
}


/*
	Removes the CSS class value from an <li> element.

	@param	obj	Reference to html element, not guaranteed to be <li> element.
*/
function disableTab(obj)
{
	if (obj.nodeName == utility.LIST_ITEM_ELEMENT);
	{
		obj.className = utility.EMPTY_STRING;
	}
}
