/**
 * class	TopMenu
 * author	Marco Troost
 */
var TopMenu = new Class({

	/**
	 * initialize
	 * @return	void
	 */
	initialize: function(root_node_id)
	{
		// nodes
		this.root_node				= $(root_node_id);

		// classes
		this.hide_class				= 'hide';
	},

	/**
	 * start
	 * @return void
	 */
	start: function()
	{
		if (this.root_node)
		{
			// set events
			this.setEvents();
		}
	},

	/**
	 * set events
	 * @return	void
	 */
	setEvents: function()
	{
		// set vars
		var _this = this;

		// get anchors
		var anchor_nodes		= this.root_node.getElements('li');
		var total_anchor_nodes	= anchor_nodes.length;
		if (total_anchor_nodes)
		{
			anchor_nodes.each(function(anchor_node, index)
			{
				anchor_node.removeEvents();
				anchor_node.addEvents(
				{
					'click' : function()
					{
						_this.setInActive();

						this.addClass('active');

						return false;
					}
				});
			});
		}
	},

	/**
	 * Set inactive item
	 * @return	void
	 */
	setInActive: function()
	{
		var _this 		= this;

		// first hide all text blocks
		// get anchors
		var anchor_nodes		= this.root_node.getElements('li');
		var total_anchor_nodes	= anchor_nodes.length;
		if (total_anchor_nodes)
		{
			anchor_nodes.each(function(anchor_node, index)
			{
				class_name = anchor_node.get('class');
				if (class_name == 'active')
				{
					anchor_node.toggleClass('active');
				}
			});
		}
	}

});


