var timer
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

var mainMenu = function()
{
	var mainTotalList = document.getElementById("mainMenu");
	var mainMenuList = mainTotalList.getElementsByTagName("a");

	for ( var i = 0 ; i < mainMenuList.length ; i++ )
	{
		mainMenuList[i].value = i + 1
		mainMenuList[i].onmouseover = function()
		{					
			menuList(this.value);
		}
	}
}


var menuOutAct = function()
{
	var totalList = document.getElementById("totalList");
	var nowMenu = document.getElementById("nowMenu");
	totalList.style.display = "none";
	nowMenu.style.display = "";
	clearTimeout(timer);
}

var menuList = function(thisNum)
{	
	clearTimeout(timer);
	var menuNum = document.getElementById("menuNum");
	var nowMenu = document.getElementById("nowMenu");
	var totalList = document.getElementById("totalList");
	var menuList = totalList.getElementsByTagName("div");

	if (thisNum == menuNum.getAttribute("value"))
	{
		totalList.style.display = "none";
		nowMenu.style.display = "";
		return false;
	}
	thisNum = (thisNum - 1) * 2	
	for ( var i = 0 ; i < menuList.length ; i++ )
	{					
		if (menuList[i].getAttribute("id") == "menuList")
		{
			if ( i == thisNum)
			{				
				nowMenu.style.display = "none";
				menuList[i].style.display = "";	
				timer = window.setTimeout('menuOutAct()', 5000);
			}
			else
			{
				menuList[i].style.display = "none";
			}
		}
		
	}
	totalList.style.display = "";
}


/*var menuUpDown = function()
{
	var totalList = document.getElementById("totalList");
	var ypos = parseInt(totalList.style.top)		
	var timer
	timer = setTimeout('menuUpDown()', 50);
	if (totalList)
	{
		if (ypos < 0)
		{
			totalList.style.position = "relative";
			totalList.style.top = ypos + Math.ceil((Math.abs(ypos)/11));			
		}
		else
		{
			clearTimeout(timer);
		}

	}
	
}
*/

addLoadEvent(mainMenu);
addLoadEvent(function()
{
	menuList(0);
});