/* ---------------------------------------
	navigation script
--------------------------------------- */

	var strSticky = 'sticky';
	var strActive = 'active';
	var strNavigation = 'navigation';
	var intTimeout = 0.4;
	
	var objNav = document.getElementById (strNavigation), arrItems = objNav.getElementsByTagName ('li'), objTimeout;
	
	function checkSticky(objItem)
	{
		return (objItem.parentNode.id != objNav.id && objItem.getElementsByTagName ('a')[0].className.indexOf (strSticky) != -1)
	}
	
	function checkSubNav(objItem)
	{
		return !(objItem.parentNode.id == objNav.id && objItem.getElementsByTagName('ul').length == 0)
	}
	
	function clearNav (blnSticky)
	{
		clearTimeout (objTimeout);
		for (var i = 0; i < arrItems.length; i++)
		{
			if (checkSticky(arrItems[i]) && blnSticky == true) enableNav (arrItems[i].parentNode.parentNode, true);
			else enableNav (arrItems[i], false);
		}
	}
	
	function enableNav (objItem, blnEnable)
	{
		var objNavItem = (objItem.parentNode.parentNode.parentNode.id == objNav.id)? objItem.parentNode.parentNode.getElementsByTagName ('a')[0] : objItem.getElementsByTagName ('a')[0];
	
		if (objItem.className.indexOf (strActive) == -1 && blnEnable == true)
		{
			if (objNavItem.className.indexOf (strActive) == -1) objNavItem.className += ' ' + strActive;
			if (objItem.className.indexOf (strActive) == -1) objItem.className += ' ' + strActive;
		}
		else if (blnEnable == false)
		{
			objItem.className = objItem.className.replace (strActive, '');
			if (objNavItem.className.indexOf (strSticky) == -1) objNavItem.className = objNavItem.className.replace (strActive, '');
		}
	}
	
	for (var i = 0; i < arrItems.length; i++)
	{
		if (checkSticky(arrItems[i])) enableNav (arrItems[i].parentNode.parentNode, true);
	
		arrItems[i].onmouseover = function ()
		{
			clearNav ();

			if (checkSubNav(this)) enableNav (this, true);
		}
	
		arrItems[i].onmouseout = function ()
		{
			clearTimeout (objTimeout);

			if (!checkSubNav(this))
			{
				clearNav(true);
				return;
			}

			objTimeout = setTimeout (function () { clearNav(true); }, intTimeout * 1000);
		}
	}
