Merge pull request #6 from jamalex/checkconnection

General JS helper functions and auto-checking as needed for online status.
Reworked connection checking as per code review, switched to Deferreds.