added code to detect phonegap and jqm loading more correctly