Sorry tried to post the code here but the editor is a bit different that the version i run on my personal blogs site. The code is available @. Not sure the editor that is being used but it doesn’t handle the formatted HTML as well as the one on adminblogs.
http://adminblogs.com/steve/archive/2004/08/13/379.aspx