There is some pretty nice code available at http://www.qld.gov.au/web/cue/template/implementations.html that sounds close to what you want. It doesn't "remember last state" but it does generate some very nice tight & simple markup, works across a range of browers and degrades well in the absences of js and/or css.
Cheers Mark ***************************************************** The discussion list for http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm for some hints on posting to the list & getting help *****************************************************