Changing scripts to run better with PhoneGap