var _anomFunkMap={};var _anomFunkMapNextId=0;function anomToNameFunk(fun){var funkId="f"+_anomFunkMapNextId++;var funk=function(){fun.apply(this,arguments);_anomFunkMap[funkId]=null;delete _anomFunkMap[funkId]};_anomFunkMap[funkId]=funk;return"_anomFunkMap."+funkId}function GetFunctionName(fn){if(fn){var m=fn.toString().match(/^\s*function\s+([^\s\(]+)/);return m?m[1]:anomToNameFunk(fn)}else{return null}}if(typeof(DeviceInfo)!="object"){DeviceInfo={}}PhoneGap={queue:{ready:true,commands:[],timer:null},_constructors:[]};PhoneGap.available=DeviceInfo.uuid!=undefined;PhoneGap.addConstructor=function(func){var state=document.readyState;if((state=="loaded"||state=="complete")&&DeviceInfo.uuid!=null){func()}else{PhoneGap._constructors.push(func)}};(function(){var timer=setInterval(function(){var state=document.readyState;if((state=="loaded"||state=="complete")&&DeviceInfo.uuid!=null){clearInterval(timer);while(PhoneGap._constructors.length>0){var constructor=PhoneGap._constructors.shift();try{constructor()}catch(e){if(typeof(debug.log)=="function"){debug.log("Failed to run constructor: "+debug.processMessage(e))}else{alert("Failed to run constructor: "+e.message)}}}var e=document.createEvent("Events");e.initEvent("deviceready");document.dispatchEvent(e)}},1)})();PhoneGap.exec=function(){PhoneGap.queue.commands.push(arguments);if(PhoneGap.queue.timer==null){PhoneGap.queue.timer=setInterval(PhoneGap.run_command,10)}};PhoneGap.run_command=function(){if(!PhoneGap.available||!PhoneGap.queue.ready){return}PhoneGap.queue.ready=false;var args=PhoneGap.queue.commands.shift();if(PhoneGap.queue.commands.length==0){clearInterval(PhoneGap.queue.timer);PhoneGap.queue.timer=null}var uri=[];var dict=null;for(var i=1;i0){successCallback(this.freeDiskSpace);return this.freeDiskSpace}else{this.successCallback=successCallback;this.errorCallback=errorCallback;PhoneGap.exec("File.getFreeDiskSpace")}}};function FileReader(filename){this.fileName=filename}FileReader.EMPTY=0;FileReader.LOADING=1;FileReader.DONE=2;FileReader.prototype={fileName:null,result:null,onloadstart:null,onprogress:null,onload:null,onerror:null,onloadend:null,abort:function(){},readAsBinaryString:function(filename){},readAsDataURL:function(url){},readAsArrayBuffer:function(filename){},readAsText:function(fname){if(this.fileName&&this.fileName.length>0){navigator.fileMgr.removeFileReader(this.fileName,this)}this.fileName=fname;navigator.fileMgr.addFileReader(this.fileName,this);PhoneGap.exec("File.readFile",this.fileName)}};function FileWriter(filename){if(navigator.fileMgr.fileWriters[filename]!=null){return navigator.fileMgr.fileWriters[filename]}else{this.fileName=filename}}FileWriter.INIT=0;FileWriter.WRITING=1;FileWriter.DONE=2;FileWriter.prototype={fileName:"",result:null,readyState:0,onerror:null,oncomplete:null,onwritestart:null,onprogress:null,onload:null,onabort:null,onerror:null,onwriteend:null,length:0,position:0,error:null,write:function(text){return this.writeAsText(this.fileName,text)},truncate:function(offset){if(this.readyState==FileWriter.WRITING){throw FileError.INVALID_STATE_ERR}this.readyState=FileWriter.WRITING;if(this.fileName&&this.fileName.length>0){navigator.fileMgr.removeFileWriter(this.fileName)}navigator.fileMgr.addFileWriter(this.fileName,this);this.readyState=0;this.result=null;PhoneGap.exec("File.truncateFile",this.fileName,offset)},seek:function(offset){if(this.readyState===FileWriter.WRITING){throw FileError.INVALID_STATE_ERR}if(!offset){return}if(offset<0){this.position=Math.max(offset+this.length,0)}else{if(offset>this.length){this.position=this.length}else{this.position=offset}}},abort:function(){if(this.readyState!=FileWriter.WRITING){throw FileError.INVALID_STATE_ERR}var error=new FileError();error.code=FileError.ABORT_ERR;this.error=error;if(typeof this.onerror=="function"){var evt=File._createEvent("error",this);this.onerror(evt)}if(typeof this.onabort=="function"){var evt=File._createEvent("abort",this);this.onabort(evt)}this.readyState=FileWriter.DONE;if(typeof this.onloadend=="function"){var evt=File._createEvent("writeend",this);this.onloadend(evt)}},writeAsText:function(fname,text){if(this.readyState==FileWriter.WRITING){throw FileError.INVALID_STATE_ERR}this.readyState=FileWriter.WRITING;if(this.fileName&&this.fileName.length>0){navigator.fileMgr.removeFileWriter(this.fileName)}this.fileName=fname;navigator.fileMgr.addFileWriter(this.fileName,this);this.readyState=0;this.result=null;PhoneGap.exec("File.write",this.fileName,text,this.position)}};function PositionError(){this.code=0;this.message=""}PositionError.PERMISSION_DENIED=1;PositionError.POSITION_UNAVAILABLE=2;PositionError.TIMEOUT=3;function Geolocation(){this.lastPosition=null;this.lastError=null}Geolocation.prototype.getCurrentPosition=function(successCallback,errorCallback,options){var referenceTime=0;if(this.lastError!=null){if(typeof(errorCallback)=="function"){errorCallback.call(null,this.lastError)}this.stop();return}this.start(options);var timeout=30000;var interval=2000;if(options&&options.interval){interval=options.interval}if(typeof(successCallback)!="function"){successCallback=function(){}}if(typeof(errorCallback)!="function"){errorCallback=function(){}}var dis=this;var delay=0;var timer;var onInterval=function(){delay+=interval;if(dis.lastPosition!=null&&dis.lastPosition.timestamp>referenceTime){clearInterval(timer);successCallback(dis.lastPosition)}else{if(delay>timeout){clearInterval(timer);errorCallback("Error Timeout")}else{if(dis.lastError!=null){clearInterval(timer);errorCallback(dis.lastError)}}}};timer=setInterval(onInterval,interval)};Geolocation.prototype.watchPosition=function(successCallback,errorCallback,options){this.getCurrentPosition(successCallback,errorCallback,options);var frequency=(options&&options.frequency)?options.frequency:10000;var that=this;return setInterval(function(){that.getCurrentPosition(successCallback,errorCallback,options)},frequency)};Geolocation.prototype.clearWatch=function(watchId){clearInterval(watchId)};Geolocation.prototype.setLocation=function(position){this.lastError=null;this.lastPosition=position};Geolocation.prototype.setError=function(error){this.lastError=error};Geolocation.prototype.start=function(args){PhoneGap.exec("Location.startLocation",args)};Geolocation.prototype.stop=function(){PhoneGap.exec("Location.stopLocation")};function __proxyObj(origObj,proxyObj,funkList){var replaceFunk=function(org,proxy,fName){org[fName]=function(){return proxy[fName].apply(proxy,arguments)}};for(var v in funkList){replaceFunk(origObj,proxyObj,funkList[v])}}PhoneGap.addConstructor(function(){if(typeof navigator._geo=="undefined"){navigator._geo=new Geolocation();__proxyObj(navigator.geolocation,navigator._geo,["setLocation","getCurrentPosition","watchPosition","clearWatch","setError","start","stop"])}});function Compass(){this.lastHeading=null;this.lastError=null;this.callbacks={onHeadingChanged:[],onError:[]}}Compass.prototype.getCurrentHeading=function(successCallback,errorCallback,options){if(this.lastHeading==null){this.start(options)}else{if(typeof successCallback=="function"){successCallback(this.lastHeading)}}};Compass.prototype.watchHeading=function(successCallback,errorCallback,options){this.getCurrentHeading(successCallback,errorCallback,options);var frequency=100;if(typeof(options)=="object"&&options.frequency){frequency=options.frequency}var self=this;return setInterval(function(){self.getCurrentHeading(successCallback,errorCallback,options)},frequency)};Compass.prototype.clearWatch=function(watchId){clearInterval(watchId)};Compass.prototype.setHeading=function(heading){this.lastHeading=heading;for(var i=0;i