var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	

	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 

//highlight the current selected menu item
function highlight_menu_item(id){
       
	if (id){
	id='a'+id;
	//highlight by the joomla article id received
	//for the drop down items specific cases to highlight their parent
// alert("Start id =>>"+id+"<<");
	switch (id){
		case 'a':
		document.getElementById('home').style.color='rgb(101, 155, 223)';
		break;
		case 'a7':	
//		alert("a7 id =>>"+id+"<<");	
		document.getElementById('a6').style.color='rgb(101, 155, 223)';
		break;
		case 'a8':
//		alert("a8 id =>>"+id+"<<");	
		document.getElementById('a6').style.color='rgb(101, 155, 223)';
		break;
		default:
		document.getElementById(id).style.color='rgb(101, 155, 223)';
		}
	}else{
		//this is home page - its id is undefined
		document.getElementById('home').style.color='rgb(101, 155, 223)';
	}
}
