Recipe 1 from the book 20 Recipes for programming PhoneGap.