var geo = null; if(google) { geo = google.gears.factory.create('beta.geolocation'); } function getCurrentPosition(successfunction,errorfunction,option) { if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(successfunction,errorfunction,option); } else { if(geo) { geo.getCurrentPosition(successfunction, errorfunction); } } }