/*
 * window.contentId is the variable to be used by Below to specify the location
 * in the site.
 * The home page should have a null contentId
 */
window.contentId = null;

window.activeTop = null;
window.activeSub = null;
window.activeLi = null;
window.hideTimeout = null;
window.currentTopNav = null;
window.hoverTimeout = 300;
 
// change this value to set the hover timeout

function highlightNavigation()
{
   var hierarchy = new Array();
   hierarchy.push(window.contentId);
   currentPage = window.contentId;

   // if the element is not found, return
   if(pageArray[currentPage] == null)
   {
      return;
   }

   while (pageArray[currentPage] != 'null')
   {
      hierarchy.push(pageArray[currentPage]);
      currentPage = pageArray[currentPage];
   }

   var topNavElem = document.getElementById("topNav" + hierarchy[hierarchy.length - 1]);
   topNavElem.className = "topNav_on";
   window.activeTop = topNavElem;
   window.currentTopNav = topNavElem;
}

function findPosXX(obj)
{
 
 if(proc == topNavProcdiv)
   {
      var curleft =0;
   }
    else if(pos =="R"){
	   curleft=(-455);}
   
   else
   {
      curleft = (170);
   }

   if (obj.offsetParent)
   {
      while (obj.offsetParent)
      {
         curleft += obj.offsetLeft
         obj = obj.offsetParent;
      }
   }
   else if (obj.x)
   curleft += obj.x;
   return curleft;
}
//function forleft(proc){
//	var str=proc;
//	if(str ==topNavL5100){
//	return str;}
//	else {
//		return null;}
//	}

function findPosYY(obj)
{
   if(proc == topNavProcdiv)
   {
      var curtop = 0;
   }
  
   else
   {
      curtop = (- 29);
   }
   if (obj.offsetParent)
   {
      while (obj.offsetParent)
      {
         curtop += obj.offsetTop
         obj = obj.offsetParent;
      }
   }
   else if (obj.y)
   curtop += obj.y;
   return curtop;
}

function showSubNav(parentId, childId, force,side)
{   pos=side;
   proc = document.getElementById(parentId);
if(force == 1)
   {
      hideSubNav();
   }
   else if(window.activeTop != null) return;
   window.clearInterval(window.hideTimeout);
   window.hideTimeout = null;

   var subNav = document.getElementById(childId);
   var parent = document.getElementById(parentId);
   parent.className = "topNav_on";
   window.activeTop = parent;
   if(subNav != null)
   {
      var parent_bottom = findPosYY(parent) + parent.offsetHeight;
      var parent_x_position = findPosXX(parent);
      if(isIE)
      {
         subNav.style.left = parent_x_position + 0 + "px";
         subNav.style.top = parent_bottom + 0 + "px";
      }
      else
      {
         subNav.style.left = parent_x_position - 0 +  "px";
         subNav.style.top = parent_bottom - 1 +  "px";
      }
      subNav.style.visibility = "visible";
      window.activeSub = subNav;
   }

}


function hideSubNav()
{
   window.clearInterval(window.hideTimeout);
   window.hideTimeout = null;

   if (window.activeTop != null)
   {
      window.activeTop.className = "topNav";
      window.activeTop = null;
   }
   if (window.activeSub != null)
   {
      window.activeSub.style.visibility = "hidden";
      window.activeSub = null;
   }

   // return to current page highlight if one is specified
   if(window.currentTopNav != null)
   {
      window.currentTopNav.className = "topNav_on";
      window.activeTop = window.currentTopNav;
   }
}

// highlights a subnav list item on mouseover
function highlightSubnavLi(divObj)
{
   window.clearInterval(window.hideTimeout);
   window.hideTimeout = null;

   if(window.activeLi != null)
   {
      window.activeLi.className = "";
   }
   divObj.className = "onLink";
   window.activeLi = divObj;
}

// removes highlight from the subnav list item
function deHighlightSubnavLi(divObj)
{
   divObj.className = "";
   window.activeLi = null;
}

function startHideTimeout()
{
   window.clearInterval(window.hideTimeout);
   window.hideTimeout = null;
   window.hideTimeout = window.setInterval("hideSubNav()", window.hoverTimeout);
}

