finally rewrote the chat.js to jquery