﻿function get_nextsibling(n) {
    x = n.nextSibling;
        if (x != null) {
        while (x.nodeType != 1) {
            x = x.nextSibling;
            if (x == null) {
                x = n;
            }
        }

    } else {
    x = n;
    }
    
   
    return x;
}


function setActivePage(arr) {
       for (var i = 0; i < arr.length; i++) {
        var anchor = arr[i];

        var anc = anchor.href.toLocaleLowerCase();
        var loc = location.href.toLocaleLowerCase();      
        var loclen = loc.length;
        var lIndex = loc.lastIndexOf('/');
        var lQstring = loc.lastIndexOf('?');

// handle pages with querystrings
        if (lQstring > 0) {
            loc = loc.substring(0, lQstring);
        }
       
        if ((loclen-1) == lIndex) {
            loc = loc + 'default.aspx';
           } 

        if (anc == loc) {
             anchor.className = "current";
             return get_nextsibling(anchor)
             break;
        }
       
    }
}

function intMenu(id) {
   
      if (document.getElementById(id) != null)
          var d = document.getElementById(id)
      
   var cNode =  setActivePage(d.getElementsByTagName("a"));
    showCurrentSection(cNode)
}

function showCurrentSection(cNode) {
       var objCurrentSection = cNode; //document.getElementById("navcurrentsection");
    if (objCurrentSection != null) {
	
	  objCurrentSection.style.display = "block";
	  objCurrentSection.parentNode.childNodes[0].className = "open current";
			
		if (objCurrentSection.parentNode.parentNode.tagName == "UL")
			showSection(objCurrentSection.parentNode.parentNode);		
	}
}

function showSection(objSection)
{	
	objSection.style.display = "block";
	objSection.parentNode.childNodes[0].className = "open";	
	if (objSection.parentNode.parentNode != null && objSection.parentNode.parentNode.tagName == "UL")
		showSection(objSection.parentNode.parentNode);
}
