cordova.js: Copying from firefoxos and wrapping in a function so it does not run immediately.