/*------------------------------------------------------------------------------
--  MINDIGTV PORTÁL 3.0
--
--  Minden jog fenntartva (c) Elenet Kft. 2011
--  Készítette Fejes Bence
------------------------------------------------------------------------------*/


// globális változók az aktuális menü adatainak tárolására
var menuTimer = -1;
var menuObj = null;


// a menürendszer felállítása
function setupMenu()
{
	var obj = document.getElementById("menu");
	var num = obj.children.length - 1;

	for (var i = 0; i <= num; i++)
	{	
		obj.children[i].children[0].onmouseover = function(e)
		{
			//this.style.backgroundColor = '#7b96c5';
			if (this.parentNode.children.length > 1)
			{
				var menu = this.nextSibling;
				menu.onmouseover = function(){showMenu(menu);};
				menu.onmouseout = function(){hideMenu(menu, 220);};
				showMenu(menu);
			}
		};
		obj.children[i].children[0].onmouseout = function(e)
		{
			if (this.parentNode.children.length > 1)
			{
				var menu = this.nextSibling;
				hideMenu(menu, 220);
			}
			else
			{
				//this.style.backgroundColor = 'transparent';
			}
		};
	}
}

// a megadott menü lenyitása
function showMenu(menu)
{
	if (menuObj != menu){
		if (menuObj != null){
			hideMenu(menuObj, 0);
		}
		menuObj = menu;
		menu.style.display = "block";
	}
	if (menuTimer != -1){
		clearTimeout(menuTimer);
		menuTimer = -1;
	}
}

// a megadott menü elrejtése
function hideMenu(menu, time)
{
	if (!time)
	{
		menu.style.display = "none";
		//menu.previousSibling.style.backgroundColor = 'transparent';
		menuObj = null;
	}
	else
	{
		menuTimer = setTimeout(function(){hideMenu(menu, 0);}, time);
	}
}

