jQuery is a very nice library, which allows you to do many interface stuff.
Go to http://jquery.com/ for more information.
For an example, with source code, go to http://sonspring.com/journal/jquery-portlets
To save state, get any cookie set of functions (such as a jQuery plugin, or just a group of functions), and set a cookie to store state, every time the layout is changed. Then when the page is opened, read the cookie, and lay out the page appropriately.