/**
 * class	Q_Menu
 * author	Paul Kruijt
 */
var Q_Menu = new Class({
	
	/**
	 * initialize
	 * @return	void
	 */
	initialize: function(menu_wrapper_id)
	{
		// nodes
		this.menu_wrapper	= $(menu_wrapper_id);
		this.menu			= this.menu_wrapper.getElement('ul');
		
		// set strings
		this.active_class	= 'active';
	},
	
	/**
	 * start
	 * @return void
	 */
	start: function()
	{
		var _this = this;
		
		var menu_items = this.menu.getChildren();
		
		menu_items.each(function(menu_item)
		{
			if (menu_item.nodeName == 'LI')
			{
				var submenu = menu_item.getElement('ul');
				
				if(submenu)
				{
					var item_anchor = menu_item.getElement('a');
					
					if (item_anchor)
					{
						item_anchor.onclick = function()
						{
							// hide active submenu
							_this.hideSubMenu();
							
							// show submenu
							this.parentNode.className	= _this.active_class;
							
							return false;
						}
					}
				}
			}
		});
	},
	
	/**
	 * hide submenu
	 * @return void
	 */
	hideSubMenu: function()
	{
		var _this = this;
		
		var menu_items = this.menu.getChildren();
		
		menu_items.each(function(menu_item)
		{
			if (menu_item.nodeName == 'LI')
			{
				menu_item.className = '';
			}
		});
	}
	
});