Refactor javascript to be contained in the window.loungeChat object and fixed the reconnection issue.