// JavaScript Document
var navMenuClass = 'dkGreyLeftNavLink';
var allDivs = document.getElementsByTagName('div');
var allLinks = document.getElementsByTagName('a');
var siteLinks = new Array();
var pageDivs = new Array();
var pageRe = /^pageNav_/;

var imgBase = '/images/nav/main_nav/nav_';
var mouseOutSuffix = '.png';
var mouseOverSuffix = '_on.png'; 
var allDivs = new Array();
var subDivs = new Array();
var subRe = /_Div$/;

//store all divs in an array
allDivs = document.getElementsByTagName('div');

//loop through this array, find all divs that match the test expression
//store these in a subDiv array 
for (i=0; i < allDivs.length; i++)
{
	if (subRe.test(allDivs[i].id))
	{
		subDivs[subDivs.length] = allDivs[i];
	}
}

//hide all subdivs
hideSubDivs();


var allARef = document.getElementsByTagName('a');
var thisPage;
var thisHref = (window.location.protocol+'//'+window.location.host+window.location.pathname).split('/');
//var thisHref = document.location.href.split('/');
var aStr = '';
for(var i=0;i<thisHref.length;i++) {
	aStr += thisHref[i] + ' ';
	}
var thisPage = thisHref[thisHref.length - 1];
var defaultPage = thisHref[0] + '/' + thisHref[1] + '/' + thisHref[2] + '/';
for (var i = 3;i < thisHref.length - 1;i++) {
	defaultPage += thisHref[i] + '/';
	}
var folderRe = new RegExp("^" + defaultPage + "[^/]*");
defaultPage += 'index.php';
var foundMe = false;

for (var i = 0;i < allARef.length;i++) {
		if (allARef[i].href==window.location.protocol+'//'+window.location.host+window.location.pathname || allARef[i].href == window.location.href) {
			if (allARef[i].className == navMenuClass) { 
				allARef[i].className=allARef[i].className+'Hover';
				thisPage=allARef[i].id;
				foundMe = true;
				break;
				}
			}
		}
if (foundMe == false) { 
	for (var i = 0;i < allARef.length;i++) {
		if (allARef[i].href==defaultPage) {
			if (allARef[i].className == navMenuClass) { 
				allARef[i].className=allARef[i].className+'Hover';
				thisPage=allARef[i].id;
				foundMe = true;
				break;
				}
			}
		}
	}
/*
if (foundMe == false) {
	for (var i = 0;i < allARef.length;i++) {
		if (folderRe.test(allARef[i].href)) {
			if (allARef[i].href==defaultPage) {
				allARef[i].className=allARef[i].className+'Hover';
				thisPage=allARef[i].id;
				foundMe = true;
				break;
				}
			}
		}
	}
*/
function setOpen(elem) {
    var walkOut = "";
    var thisNode = "";
    if (document.getElementById(elem)) {
		if (document.getElementById(elem + "_Div")) {
			document.getElementById(elem + "_Div").className = 'showItem';
		}
        walkOut = document.getElementById(elem).parentNode;
        if (walkOut && walkOut.className == "hideItem") {
            walkOut.className = 'showItem';
            }
        while(walkOut && walkOut.id != 'menuStopper') {
            walkOut = walkOut.parentNode;
            if (walkOut && walkOut.className == "hideItem") {
                walkOut.className = 'showItem';
                }
            }
        }
    }

function hideSubDivs()
{
	for (i=0; i<subDivs.length; i++)
	{
		subDivs[i].className='hideItem';
	}
}
setOpen(thisPage);
	

