Manually merged and refactored slightly from Chetan's source.
Added todo list to html/chatbox.js. More cleanup to follow.
More cleanup.