Updated to work with Phonegap 2.2 to 2.9