var arrTimers = new Array();
var TIMERVALHIDE = 2000;
var TIMERVALSHOW = 0;

function showsubmenu(id,bRoot){
	fnShow(id,bRoot);
	if(bRoot) {	
		arrTimers[id] = setTimeout('fnHide('+id +')',TIMERVALHIDE);	
	}
//	alert(bRoot);
}

function hidemenu(id){
	var arrMenu = objSubMenu;
	arrTimers[id] = setTimeout('fnHide('+id +')',TIMERVALHIDE);
	
	//hide parent menu (if available)
	if( arrMenu[id]  )
		arrTimers[arrMenu[id]] = setTimeout('fnHide('+ arrMenu[id] +')',TIMERVALHIDE);
}

//cancel the hide functionality when mouse moves over div
function killtimer(id){
	var arrMenu = objSubMenu;	
	//clear timer menuid	
	clearTimeout( arrTimers[id] );	
	//clear timer child
	clearTimeout( arrTimers[arrMenu[id]] );	
	//clear timer parents
	for (var obj in arrMenu){
		if( obj == id){
			clearTimeout( arrTimers[arrMenu[obj]] );
		}
	}					
}

function fnHide(id){
	var arrMenu = objSubMenu;
	//hide childmenu's
	for (var obj in arrMenu){
		if( arrMenu[obj] == id){
			document.getElementById('mnu' + obj ).style.display="none";			
		}
	}		
	//hide self
	document.getElementById('mnu' + id ).style.display="none";			
	//default to all menu's
	top.frames.fraMenu.enabletopmenus(id,0);
	//enable default menu
	top.frames.fraMenu.enabletopmenus(top.frames.fraMenu.m_nDefaultMenu,2);
}


function fnShow(id,bRoot){
	var nPosY = 0;
	if( parent.frames.fraMenu.document.getElementById('ref_id_' + id) )
		nPosY = findPosY( parent.frames.fraMenu.document.getElementById('ref_id_' + id),false);
	else
		nPosY = findPosY( document.getElementById('ref_id_' + id), true);
	nPosY+=4;
	document.getElementById('mnu' + id).style.top	  = nPosY;
	document.getElementById('mnu' + id).style.display = "block";
	// when id = rootid, enable topmenuitems	
	if( bRoot)
		top.frames.fraMenu.enabletopmenus(id,1);
}

function findPosY(obj,bParent)
{
	var curtop = 0;
	if( bParent){
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop;
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
	}
	else
		curtop = obj.offsetTop;
	return curtop;
}