Improve quicknav JavaScript to disable third level if not applicable