Update code for phonegap 2.7+