Hi Neomi!
I've reviewed this thread and it would seem your solution is in here - I can't think of any more information to add - except... maybe...
There is one thread with this post by @michelangelo who has a simple set-up (no javascript, just CSS):
The above post takes the approach of reducing the number of layouts needed. The online demo in the post appears to do an effective job (I have not used it). Perhaps this concept might work in your situation.
Here is the post's associated Hype file:3X2.hypetemplate.zip (532.0 KB)