oRcsf.RegisterObject('Module_Structure_Menu');
var RCSF_Base_Module_Structure_Menu = 
{
	 'msExtends'	: 'RCSF_Base_Base'
	,'maItems'		: []
	,'maLists'		: []
	
		
	/**
	 * 
	 */
	,OnDomLoaded : function()
	{
		return;
		
		// Build list of menu items
		this.maItems = $$('#structure_navigation li');
		this.maLists = $$('#structure_navigation ul');
		this.maItems.each(function(oLi)
		{
			if (!Object.isUndefined(oLi.down('a')))
			{
				// Add click handlers
				//oLi.down('a').observe('click', this.OnItemClicked.bindAsEventListener(this, oLi));
				
				// Show has child icon
				if (oLi.down('ul')) oLi.down('a').addClassName('has_childs_off');
				
				// Expand active item
				if (oLi.down('a').hasClassName('active')) this.ExpandItem(oLi);
			}
		}.bind(this));
				
		// Set first class
		this.maItems.first().addClassName('first');
	}
	
	/**
	 * 
	 */
	,OnItemClicked : function(oEvent, oLi)
	{
		// Reset active item
		this.maItems.each(function(oLi)
		{
			var oLink = oLi.down('a');
			oLink.removeClassName('active');
		});
		
		oLi.down('a').addClassName('active');
		if (oLi.down('ul')) 
		{
			oEvent.stop();
			this.ExpandItem(oLi);
		}
	}
	
	
	/**
	 * Expands clicked or active item
	 * 
	 * @param	Object	oItem	LI element
	 * TODO: use scriptaculous animations
	 */
	,ExpandItem : function(oItem)
	{
		// Hide all lists
		this.maLists.each(function(oUl) { oUl.style.display = 'none'; });
		
		// Reset has childs class
		this.maItems.each(function(oLi)
		{
			var oLink = oLi.down('a');
			if (oLink.hasClassName('has_childs_on'))
			{
				oLink.removeClassName('has_childs_on');
				oLink.addClassName('has_childs_off');
			}
		});
		
		// Find all elements above this item
		oItem.ancestors().each(function(oParent)
		{
			// Show parent elements of active element and rotate arrow
			if (oParent.tagName.toLowerCase() == 'li') 
			{
				oParent.down('a').addClassName('has_childs_on');
			}
			// Show active element and it's siblings
			else if (oParent.tagName.toLowerCase() == 'ul')
			{
				oParent.style.display = 'block';				
			}
		});
		
		// Show child elements of active element
		if (oItem.down('ul'))
		{
			oItem.down('a').removeClassName('has_childs_off');
			oItem.down('a').addClassName('has_childs_on');
			oItem.down('ul').style.display = 'block';
			//Effect.SlideDown(oItem.down('ul').id, { duration: 3.0 });
		}
		oItem.down('a').addClassName('active');
	}
}