core: new state machine for maintaining websocket/comet push connections.
Perpetual comet loop which only polls if there is no active websocket connection.
Websocket connection checks with a periodic ping/pong if the connection works.

(cherry picked from commit 64181a516b3c740b4800dc42e9b74ac9c5f485f1)

Conflicts:
	modules/mod_base/controllers/controller_websocket.erl
	modules/mod_base/lib/js/apps/zotonic-1.0.js

Also copied the websocket handlers from master, as the sender-pid is needed for the ping.