
var Menu = 
{
	menu : [],
	run  : [],
	
	hide : function(obj)
	{
		var id = obj.getAttribute('pid');
		
		if (this.menu[id]) {
			this.menu[id].style.display = 'none';
		};
	},
	
	show : function(obj) 
	{
		var id = obj.getAttribute('pid');
		
		if (this.menu[id]) 
		{
			this.menu[id].style.display = '';
			return;
		};
		
		if (this.run[id]) {
			return;
		};
		
		var oUl = document.createElement('ul');
		
		if (obj.parentNode.parentNode.nodeName != 'DIV') 
		{
			oUl.style.position = 'absolute';
			oUl.style.left     = '160px';
			oUl.style.top      = '-46px';
			oUl.style.width    = '160px';
		};
		
		obj.appendChild(oUl);
		
		this.menu[id] = oUl;
		this.run[id]  = true;
		
		_Ajax.asyncPost('ajax_get_navigation', function(result, Ajax) 
		{
			var oUl = Ajax.getParams('ul');
			var _li = document.createElement('li');
			var _a  = document.createElement('a');
			var _s  = document.createElement('span');
			
			for (var i = 0, len = result.length; i < len; i++) 
			{
				var oLi = _li.cloneNode(true);
				var oA  = _a.cloneNode(true);
				var oS  = _s.cloneNode(true);
				
				oA.href = result[i].url;
					
				if (result[i].has_children > 0) 
				{
					oA.className = 'has_children';
					
					oLi.setAttribute('pid', result[i].id);
					
					oLi.onmouseover = function() 
					{
						Menu.show(this);
					};
					
					oLi.onmouseout = function() 
					{
						Menu.hide(this);
					};
				};
				
				oS.innerHTML = result[i].title;
				
				oA.appendChild(oS);
				
				oLi.appendChild(oA);
				oUl.appendChild(oLi);
			};
			
			if (len > 0) {
				oUl.className = 'pMenu'; 
			};
			
		}, {
			project : _Project.name,
			lang    : _Project.lang,
			id      : id,
			obj		: obj,
			ul		: oUl
		});
	}
};