added support for phonegap build. Deleted superflous code.