added chat helper functions
added client javascript logic