Updated javascript to fit phone gap standards