Refactor: JS flow somewhat less confusing; Buttons moved into HTML; Retired use of jQuery.parseJSON; Removed focus() call on chatbox due to iOS annoyance; Sprinkled comments around