I'd update this value when you call the show/hide functions instead of querying the DOM