// Navigation menu client-side scripting (END)

function UpdateLink(obj, objParent)
{
	if(obj.children)
	{
		for( var i=0; i<obj.children.length; i++)
		{
			if( obj.children[i].children.length > 0)
			{
				var lnk = obj.children[i];
				UpdateLink( lnk, objParent);
			}
		}
		if(obj.children[0].tagName == 'A' && obj.statuscolor!='0')
		{
			if( obj.children[0].style.color != "" && ( objParent.className == 'Menu' || objParent.className == 'MenuSelected'))
			{
				obj.children[0].style.color = "";
			}
			else
			{
				if( objParent.statusbuffer == 'on')
				{
					obj.children[0].style.color = "#39458c";
				}
				else
					obj.children[0].style.color = "#FF0000";
			}
		}
	}
}

function mOver(obj)
{
	var szClass = obj.className;
	if(szClass == "Menu") obj.className = 'MenuActive';
	if(szClass == "MenuSelected") obj.className = 'MenuSelectedActive';
	UpdateLink(obj, obj);
}

function mOut(obj)
{
	var szClass = obj.className;
	var bReset = true;
	if( document.getElementById( obj.id + "_submenu"))
	{
		var objSubMenuStyle = document.getElementById( obj.id + "_submenu").style;
		if(objSubMenuStyle.display != 'none' && objSubMenuStyle.display != '')
		{
			bReset = false;
		}
	}
	if( obj.statusbuffer == 'on') bReset = false;
	if( szClass == "MenuActive" && bReset) obj.className = 'Menu';
	if( szClass == "MenuSelectedActive" && bReset) obj.className = 'MenuSelected';
	if( bReset) UpdateLink( obj, obj);
}

function ManageSubMenu(obj)
{
	if( document.getElementById( obj.id + "_submenu"))
	{
		if(document.getElementById( obj.id + "_submenu").style.display == 'none' || document.getElementById( obj.id + "_submenu").style.display == '')
		{
			document.getElementById( obj.id + "_submenu").style.display = 'inline';
			document.getElementById( obj.id + "_img").src = m_sFrameworkPath + 'images/menu/freccia_menusx_sel.gif';
		}
		else
		{
			document.getElementById( obj.id + "_submenu").style.display = 'none';
			document.getElementById( obj.id + "_img").src = m_sFrameworkPath + 'images/menu/freccia_menusx.gif';
		}
	}
}

function mClick(obj)
{
	ManageSubMenu(obj);
	if(obj.statusbuffer != 'on')
	{
		obj.statusbuffer = 'on';
		UpdateLink(obj, obj);
	}
	else
	{
		obj.statusbuffer = 'off';
		UpdateLink(obj, obj);
	}
	if (obj.statuscolor == '0') {
		obj.statusbuffer = 'off';
		UpdateLink(obj, obj);
	}
}

function Init( startArr)
{
	if( startArr.length > 0)
	{
		for( var i=0; i< startArr.length; i++)
		{
			var subM = startArr[i].subMenu;
			if( startArr[i].status == 'on' || Init( subM))
			{
				var obj = document.getElementById( startArr[ i].ItemID);
				mOver( obj);
				mClick( obj);
				startArr[ i].status = 'on';
				return true;
			}
		}
	}
	return false;
}

Init( arr);