Hmm, seems like it could get quickly complicated.
I guess you need to change the div height and overflow property in css... can you do that via JS? I'm not that sure.
The only way I know how to do it is via some AJAX. However, thats where it starts to get quickly more complicated. but having said that, you could achive this very easily with XAJAX