﻿
$(document).ready(function() {
    hideEmpty();


}); // END ready()


// This is used for the non-product pages. It hides the nav items that have no ul's
function hideEmpty() {
    var nav = $(".mainBody .sideContent .sideNav");
    if (nav.length > 1) { // only run this if NOT the product nav.
        //alert(nav.length);
        return true;
    }

    $(".sideNav > .item .element").each(function() {
        var uls = $(this).children("ul");
        if (uls.length == 0) {
            $(this).hide();
        } else {
            //$(this).removeClass("closed");
            //$(this).addClass("element");
            var ul = $(this).children("ul");
            var li = $(ul).children("li");
            var a = $(li).children("a");
            $(a).addClass("nonProductNavItem");

            // Add "top" class to next title
            var nextItem = $(this).parent().next(".sideNav > .item").children(".title");
            $(nextItem).addClass("title top");
        }
    });
}





// Hide all in the product nav on start up.
// We want our nav to be closed on startup.
function hideAllClosed() {
    $(".sideNav > .item .element.closed").hide();
    $(".sideNav > .item .element ul li.subClosed ul").hide();
    
    //var test = $(".sideNav > .item .element.open ul li.subClosed ul.subClosed");
    //alert(test.length);
    
}

