//********************MENU*******************
//#######################################################################################
MenuTimerCloseAll = false;
MenuArrOpenedNodes = Array(1);
MenuArrOpenedNodes[0]=1;
stopAll = false;
function setTimer()
{
	MenuTimerCloseAll = window.setTimeout("MenuHideAll()", 2000);
}// end of function setTimer()

function stopTimer()
{
	MenuTimerCloseAll = window.clearTimeout(MenuTimerCloseAll);
}// end of function stopTimer()

function MenuShowChildern(objA)
{
	
	// hide previousy opened nodes
	objMainDiv = MenuGetMainDiv(objA);
	MenuHide(objA.parentNode.parentNode.id, objMainDiv);
	// get ul in parent li
	objUL = objA.parentNode.getElementsByTagName("UL");
	if(objUL[0])
	{
		// get ULs ID into array of opened nodes
		MenuArrOpenedNodes[MenuArrOpenedNodes.length] = objUL[0].id;
		// set visibility submenu to true
		objUL[0].style.display = "block";
		// positing submenu after width of actual menu
		if(MenuGetOrientation(objMainDiv) == "1")
		{
			if(objA.parentNode.parentNode.parentNode.tagName != 'DIV')objUL[0].style.left = objA.parentNode.offsetWidth;
			else 
			{
				// setup by horizontal menu top position to submenu
				objDiv = MenuGetMainDiv(objA);
				objLIs = objDiv.getElementsByTagName("LI");
				objUL[0].style.top = objLIs[0].offsetHeight+"px";
			}
		}else objUL[0].style.left = objA.parentNode.offsetWidth;
	}
}// end of function MenuShowHideChildern(objA)

function MenuShowHideSubmenu(objA)
{
	objMainDiv = MenuGetMainDiv(objA);	
	// get ul in parent li
	objUL = objA.parentNode.parentNode.getElementsByTagName("UL");
	if(objUL[0])
	{
		if(objUL[0].style.display == "block")// set visibility submenu to true
			objUL[0].style.display = "none";
		else
		{
			// get ULs ID into array of opened nodes
			MenuArrOpenedNodes[MenuArrOpenedNodes.length] = objUL[0].id;
			// set visibility submenu to true
			objUL[0].style.display = "block";
			// positing submenu after width of actual menu
			if(MenuGetOrientation(objMainDiv) == "1")
				if(objA.parentNode.parentNode.parentNode.tagName != 'DIV')objUL[0].style.left = objA.parentNode.offsetWidth;
				else 
				{
					// setup by horizontal menu top position to submenu
					objDiv = MenuGetMainDiv(objA);
					objLIs = objDiv.getElementsByTagName("LI");
					objUL[0].style.top = objLIs[0].offsetHeight+"px";
				}
			else objUL[0].style.left = objA.parentNode.offsetWidth;
		}
		return false;
	}
	return true;
}// end of function MenuShowHideSubmenu(objA)

function MenuHide(LiName, objMainDiv)
{// set to hidden submenus, whats are not submenu actual LI
	
	for(i=MenuArrOpenedNodes.length-1; i > 0; i--)
	{
		if(LiName == MenuArrOpenedNodes[i]) i=0;
		else
		{
			objUL = document.getElementById(MenuArrOpenedNodes[i]);
			objUL.style.display = "none";	
		}
	}
}// end of function MenuShowHideChildern(objA)

function MenuHideAll()
{// hide all UL tags in menu
	for(i=arrTreeMenus.length-1; i>=0; i--)
	{
		objDiv = window.document.getElementById("menuMain"+arrTreeMenus[i][1]);
		objULs = objDiv.getElementsByTagName("UL");
		objULs = objULs[0].getElementsByTagName("UL");
		for(ii=objULs.length-1; ii >= 0 ;ii--)objULs[ii].style.display = "none";
	}
}// end of function MenuHideAll()

function MenuGetMainDiv(objInMenu)
{
	if(objInMenu.parentNode.tagName == "DIV")return objInMenu.parentNode;
	else return MenuGetMainDiv(objInMenu.parentNode);
}// end of function MenuGetMainDiv(objInMenu)

function MenuGetOrientation(objMainDiv)
{
	for(i=arrTreeMenus.length-1; i>=0; i--)if(arrTreeMenus[i][1] == objMainDiv.id.replace("menuMain", ""))return arrTreeMenus[i][0];
}
