Updated for phone gap 3.0