Merge script.js from phonegap branch