I was way over thinking this problem I ended up simplifying the code substantially and just dropping it to the bottom of the php that runs before the HTML starts. The code that works is amazingly simple.
I also discovered that I could add as many 'cases and header locations ad I want for various levels.
I hope this solution solves problems for others. As is my usual practice, I tend to make things way too complicated.