// JavaScript Document

//variables' declaration
var timer        = 0;
var item      = 0;

//function for opening of submenu elements
function openelement(num, mMenu)
{    

//checks whether there is an open submenu and makes it invisible
if(item) item.style.visibility = 'hidden';

	window.clearTimeout(timer);
    //shows the chosen submenu element
    item = document.getElementById(num);
    item.style.visibility = 'visible';
		document.getElementById(mMenu).style.backgroundColor = "#0d1e37";
		document.getElementById(mMenu).style.color = "#FFFFFF";
}

// function for closing of submenu elements
function closeelementmain()
{
//closes the open submenu elements and loads the timer with 500ms
timer = window.setTimeout("if(item) item.style.visibility = 'hidden';",100);
}

// function for closing of submenu elements
function closeelement(curMenu)
{

		
		if (curMenu == 'main1') {
			document.getElementById(curMenu).style.backgroundColor = '#42609c';	
			document.getElementById(curMenu).style.color = '#FFFFFF';
		} else {
			document.getElementById(curMenu).style.backgroundColor = 'transparent';	
			document.getElementById(curMenu).style.color = "#0d1e37";
		}

//closes the open submenu elements and loads the timer with 500ms
timer = window.setTimeout("if(item) item.style.visibility = 'hidden';",100);

}

//function for keeping the submenu loaded after the end of the 500 ms timer
function keepsubmenu(curMenu)
{
		document.getElementById(curMenu).style.backgroundColor = "#0d1e37";
		document.getElementById(curMenu).style.color = "#FFFFFF";
        window.clearTimeout(timer);
}
//hides the visualized menu after clicking outside of its area and expiring of the loaded timer
document.onclick = closeelement; 

