﻿
var oTitles;
function initmenu() {
var mdiv = document.getElementById("NavMenu");
//if(!mdiv)
//    mdiv = document.getElementById("BrandNavMenu");
if(!mdiv)
    return;
	oTitles = mdiv.getElementsByTagName("h2");
	for (var i = 0; i < oTitles.length; i++) {		
		oTitles[i].onclick = function() {
			if (this.nextSibling.nodeType == 1) {
			    this.nextSibling.className = (this.nextSibling.className == "Collapse" || this.nextSibling.className == "") ? "Expand" : "Collapse";
			}
			else if(this.nextSibling.nodeType == 3) {
			    this.nextSibling.nextSibling.className = (this.nextSibling.nextSibling.className == "Collapse" || this.nextSibling.nextSibling.className == "") ? "Expand" : "Collapse";
			}
			else {
			    return false;
			}
		}
	}
}

function expandAll() {
	for (var i = 0; i < oTitles.length; i++) {
		if (oTitles[i].nextSibling.nodeType == 1) {
			oTitles[i].nextSibling.className = "Expand";
		}
		else if(oTitles[i].nextSibling.nodeType == 3) {
			oTitles[i].nextSibling.nextSibling.className = "Expand";
		}
		else {
			return false;
		}
}

//alert(document.getElementById("NavMenuDiv").clientHeight);
if (document.getElementById("NavMenuDiv")) {
   // if (document.getElementById("NavMenuDiv").style.height < document.getElementById("NavMenuDiv").clientHeight)
    document.getElementById("NavMenuDiv").style.height = document.getElementById("NavMenu").clientHeight;
}
else {
    if (document.getElementById("BrandNavMenuDiv"))
        document.getElementById("BrandNavMenuDiv").style.height = document.getElementById("NavMenu").clientHeight + document.getElementById("NavMenuLogo").clientHeight + document.getElementById("BrandDesc").clientHeight; //'1300';
    }
    
}

function collapseAll() {
	for (var i = 0; i < oTitles.length; i++) {
		if (oTitles[i].nextSibling.nodeType == 1) {
			oTitles[i].nextSibling.className = "Collapse";
		}
		else if(oTitles[i].nextSibling.nodeType == 3) {
			oTitles[i].nextSibling.nextSibling.className = "Collapse";
		}
		else {
			return false;
		}
    }
    if (document.getElementById("NavMenuDiv"))
        document.getElementById("NavMenuDiv").style.height = '100%';
    else { 
        if (document.getElementById("BrandNavMenuDiv"))
            document.getElementById("BrandNavMenuDiv").style.height = '100%';
       }
}
window.onload = initmenu;