// 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);
	document.getElementById(mMenu).style.backgroundColor = "#355E3B"; //hunter green
	document.getElementById(mMenu).style.color = "#FEEC80";  /*light gold*/
	if (num) {
		//alert("num");
		item.style.visibility = 'visible';
		//document.getElementById(mMenu).style.backgroundColor = "#0d1e37"; //dark blue
		//#355E3B hunter green
		//#C41E3A cardinal red
	}
}

// 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)
{
	document.getElementById(curMenu).style.backgroundColor = 'transparent';	
	document.getElementById(curMenu).style.color = "#FFFFFF"; /*white*/
	//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 = "#355E3B"; /*hunter green*/
	document.getElementById(curMenu).style.color = "#FFFFFF"; //white
	window.clearTimeout(timer);
}
//hides the visualized menu after clicking outside of its area and expiring of the loaded timer
document.onclick = closeelement; 

