Panels are hiding but not reappearing

Panels are hiding but not reappearing

I have many TabPanels in my application with each displaying a number of Panels. Most of the Panels contain various buttons (created using a custom function) and some have panels themselves (henceforth called sub-panels) containing HTML text displaying some value. On some of these Panels with sub-panels I have a function being called by the OnDraw event that attempts to hide or show the sub-panel based on a value being pulled from the server by a custom function. These sub-panels have an associated button above them on the Panel that toggles the value that their visibility is based on. All these Panels handle their appropriate sub-panels correctly, either hiding or showing them. The funky stuff happens when the sub-panel's associated button is clicked. When the Panel is the first one displayed when opening the TabPanel, clicking the button subsequently hides or shows the associated sub-panel. However, if the Panel is one in the Tab Panel that isn't displayed first, when clicking the button, it only hides or shows the associated sub-panel if the value is true when first viewing the Panel. If the value was false when opening the Panel, toggling the value with the button does nothing to show and then hide again the associated sub-panel. I am very confused with this and I hope my explanation isn't as confusing. Here is some of the code: