var bb_successCallback;var bb_errorCallback;var bb_blackberryTimeout_id=-1;function handleBlackBerryLocationTimeout(){if(bb_blackberryTimeout_id!=-1){bb_errorCallback({message:"Timeout error",code:3})}}function handleBlackBerryLocation(){clearTimeout(bb_blackberryTimeout_id);bb_blackberryTimeout_id=-1;if(bb_successCallback&&bb_errorCallback){if(blackberry.location.latitude==0&&blackberry.location.longitude==0){bb_errorCallback({message:"Position unavailable",code:2})}else{var a=null;if(blackberry.location.timestamp){a=new Date(blackberry.location.timestamp)}bb_successCallback({timestamp:a,coords:{latitude:blackberry.location.latitude,longitude:blackberry.location.longitude}})}bb_successCallback=null;bb_errorCallback=null}}var geo_position_js=function(){var h={};var i=null;h.getCurrentPosition=function(a,b,c){i.getCurrentPosition(a,b,c)}h.init=function(){try{if(typeof(geo_position_js_simulator)!="undefined"){i=geo_position_js_simulator}else if(typeof(bondi)!="undefined"&&typeof(bondi.geolocation)!="undefined"){i=bondi.geolocation}else if(typeof(navigator.geolocation)!="undefined"){i=navigator.geolocation;h.getCurrentPosition=function(a,b,c){function _successCallback(p){if(typeof(p.latitude)!="undefined"){a({timestamp:p.timestamp,coords:{latitude:p.latitude,longitude:p.longitude}})}else{a(p)}}i.getCurrentPosition(_successCallback,b,c)}}else if(typeof(window.google)!="undefined"&&typeof(google.gears)!="undefined"){i=google.gears.factory.create('beta.geolocation')}else if(typeof(Mojo)!="undefined"&&typeof(Mojo.Service.Request)!="Mojo.Service.Request"){i=true;h.getCurrentPosition=function(a,b,c){parameters={};if(c){if(c.enableHighAccuracy&&c.enableHighAccuracy==true){parameters.accuracy=1}if(c.maximumAge){parameters.maximumAge=c.maximumAge}if(c.responseTime){if(c.responseTime<5){parameters.responseTime=1}else if(c.responseTime<20){parameters.responseTime=2}else{parameters.timeout=3}}}r=new Mojo.Service.Request('palm://com.palm.location',{method:"getCurrentPosition",parameters:parameters,onSuccess:function(p){a({timestamp:p.timestamp,coords:{latitude:p.latitude,longitude:p.longitude,heading:p.heading}})},onFailure:function(e){if(e.errorCode==1){b({code:3,message:"Timeout"})}else if(e.errorCode==2){b({code:2,message:"Position Unavailable"})}else{b({code:0,message:"Unknown Error: webOS-code"+errorCode})}}})}}else if(typeof(device)!="undefined"&&typeof(device.getServiceObject)!="undefined"){i=device.getServiceObject("Service.Location","ILocation");h.getCurrentPosition=function(d,e,f){function callback(a,b,c){if(b==4){e({message:"Position unavailable",code:2})}else{d({timestamp:null,coords:{latitude:c.ReturnValue.Latitude,longitude:c.ReturnValue.Longitude,altitude:c.ReturnValue.Altitude,heading:c.ReturnValue.Heading}})}}var g=new Object();g.LocationInformationClass="BasicLocationInformation";i.ILocation.GetLocation(g,callback)}}else if(typeof(window.blackberry)!="undefined"&&blackberry.location.GPSSupported){if(typeof(blackberry.location.setAidMode)=="undefined"){return false}blackberry.location.setAidMode(2);h.getCurrentPosition=function(a,b,c){bb_successCallback=a;bb_errorCallback=b;if(c['timeout']){bb_blackberryTimeout_id=setTimeout("handleBlackBerryLocationTimeout()",c['timeout'])}else{bb_blackberryTimeout_id=setTimeout("handleBlackBerryLocationTimeout()",60000)}blackberry.location.onLocationUpdate("handleBlackBerryLocation()");blackberry.location.refreshLocation()}i=blackberry.location}}catch(e){alert("error="+e);if(typeof(console)!="undefined"){console.log(e)}return false}return i!=null}return h}();