Added script tag to improve readability in IDEs.
Removed whitespace.
Update message counter only on demand.

Earlier the unread messages were checked every 10 seconds, but this was causing too much server overhead.
Made chat independent from messages plugin css.

The message counter was using the css of the messages plugin so the css was unavailable if messages plugin was disabled. Now the chat message counter has it's own css.
Add empty counter element so the value can be added via XHR.
Moved markMessageRead() to messaging js lib.

Messaging.php is a better location for the function because it is loaded only when displaying a single chat page.
Added better confirmation message for leaving a chat.
Use white list to prevent unwanted items in chat message menu.
Use white list to prevent unwanted items in chat entity menu.
Added CHANGES.txt
Do not allow the admin status of current user to affect the permission check.

Overriding the permissions based on the admin role of current user caused problems when the goal was to check the permissions for a non-logged-in user.
Added changes from the latest commit