Thanks for the huge help! I reworked your code to replace some of the longer parts with shorter jQuery alternatives, but your solution was straightforward and logical.
Thanks to your help, I finally managed to finish my jSlabify plugin for jQuery. In case you were wondering, here's a demo of what you helped me build:
Which is now a new feature of jSlabify: