moving var ref= outside ondeviceready(), removing cordova version, adding debug alert()