if(Garmin==undefined)var Garmin={};Garmin.Broadcaster=function(){};Garmin.Broadcaster=Class.create();Garmin.Broadcaster.prototype={initialize:function(){this.responders=[]},register:function(a){this.responders.include(a)||this.responders.push(a)},unregister:function(a){this.responders=this.responders.without(a)},dispatch:function(a,b){this.responders.each(function(c){if(c[a]&&typeof c[a]=="function")try{c[a].apply(c,[b])}catch(d){}})}};if(Garmin==undefined)Garmin={};
var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(a){for(var b=0;b<a.length;b++){var c=a[b].string,d=a[b].prop;this.versionSearchString=a[b].versionSearch||a[b].identity;if(c){if(c.indexOf(a[b].subString)!=-1)return a[b].identity}else if(d)return a[b].identity}},searchVersion:function(a){var b=
a.indexOf(this.versionSearchString);if(b!=-1)return parseFloat(a.substring(b+this.versionSearchString.length+1))},dataBrowser:[{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},
{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",
identity:"Mac"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};BrowserDetect.init();if(Garmin==undefined)Garmin={};Garmin.DateTimeFormat=function(){};Garmin.DateTimeFormat=Class.create();
Garmin.DateTimeFormat.prototype={initialize:function(){this.hoursInADay=24;this.secondsInAMinute=this.minutesInAnHour=60;this.millisecondsInASecond=1E3;this.millisecondsInADay=this.hoursInADay*this.minutesInAnHour*this.secondsInAMinute*this.millisecondsInASecond;this.millisecondsInAnHour=this.minutesInAnHour*this.secondsInAMinute*this.millisecondsInASecond;this.millisecondsInAMinute=this.secondsInAMinute*this.millisecondsInASecond;this.xsdString="";this.date=new Date},getDate:function(){return this.date},
parseXsdDateTime:function(a){this.xsdString=a;a=a.split("T");var b=a[1],c=a[0].split("-");a=parseInt(c[0],10);var d=parseInt(c[1],10)-1;c=parseInt(c[2],10);var e;e=b.indexOf("Z")!=-1?b.indexOf("Z"):b.indexOf("+")!=-1?b.indexOf("+"):b.indexOf("-")!=-1?b.indexOf("-"):b.length;var g=b.substring(e).split(":"),i=0,h=0;if(g.length>1){i=parseInt(g[0],10);h=parseInt(g[1],10)}g=(i*60+h)*60*1E3;i=b.substring(0,e).split(":");b=parseInt(i[0],10);e=parseInt(i[1],10);var f=i[2].split(".");i=parseInt(f[0],10);h=
0;if(f.length>1)h=parseInt(f[1],10);f=new Date;f.setUTCFullYear(a);f.setUTCMonth(d);f.setUTCDate(c);f.setUTCHours(b);f.setUTCMinutes(e);f.setUTCSeconds(i);f.setUTCMilliseconds(h);f.setTime(f.getTime()-g);this.date=f;return this},formatDuration:function(a){a=a;for(var b="",c=Array(this.millisecondsInADay,this.millisecondsInAnHour,this.millisecondsInAMinute,this.millisecondsInASecond),d=0;d<c.length;d++){var e=c[d],g=parseInt(a/e);if(d!=0||g!=0){if(g<10)b+="0";b+=g.toString();if(d<c.length-1)b+=":"}a-=
g*e}return b},getDurationTo:function(a){return this.formatDuration(a.getDate().getTime()-this.getDate().getTime())},getDayOfYear:function(){with(this.getDate())var a=getFullYear(),b=getMonth(),c=getDate();Date.UTC(a,b,c);Date.UTC(a,0,0);with(this.getDate()){a=valueOf();setMonth(0);setDate(0);a=Math.round((a-valueOf())/864E5)}return a},getDateString:function(){return this.formatDate(true)},getTimeString:function(){return this.format(Garmin.DateTimeFormat.FORMAT.timestamp12hour,true,true)},getXsdString:function(){return this.xsdString},
toString:function(){return this.date.toString()},formatDate:function(a){return this.format(Garmin.DateTimeFormat.FORMAT.date,a)},formatTime:function(a){return this.format(Garmin.DateTimeFormat.FORMAT.time,a)},formatTimestamp:function(a){return this.format(Garmin.DateTimeFormat.FORMAT.timestamp,a)},format:function(a,b,c){if(b!=false)b=true;var d=this.date.getHours();b={meridian:this.date.getHours()>=12?"PM":"AM",month:this.leftPad(this.date.getMonth()+1,b),day:this.leftPad(this.date.getDate(),b),year:this.date.getFullYear(),
hour:this.leftPad(c&&d>12?d-12:d,b),minute:this.leftPad(this.date.getMinutes(),b),second:this.leftPad(this.date.getSeconds(),b),millisecond:this.date.getMilliseconds(),timezone:this.date.getTimezoneOffset()/60};return(new Template(a)).evaluate(b)},leftPad:function(a,b){return b&&a<10?"0"+a:""+a}};Garmin.DateTimeFormat.FORMAT={date:"#{month}/#{day}/#{year}",time:"#{hour}:#{minute}:#{second}",timestamp:"#{month}/#{day}/#{year} #{hour}:#{minute}:#{second}",timestamp12hour:"#{month}/#{day}/#{year} #{hour}:#{minute}:#{second} #{meridian}"};this.JSON||(JSON=function(){function a(d){return d<10?"0"+d:d}function b(d,e){var g,i,h,f;g=/["\\\x00-\x1f\x7f-\x9f]/g;var j;switch(typeof d){case "string":return g.test(d)?'"'+d.replace(g,function(k){var l=c[k];if(l)return l;l=k.charCodeAt();return"\\u00"+Math.floor(l/16).toString(16)+(l%16).toString(16)})+'"':'"'+d+'"';case "number":return isFinite(d)?String(d):"null";case "boolean":case "null":return String(d);case "object":if(!d)return"null";if(typeof d.toJSON==="function")return b(d.toJSON());
g=[];if(typeof d.length==="number"&&!d.propertyIsEnumerable("length")){f=d.length;for(i=0;i<f;i+=1)g.push(b(d[i],e)||"null");return"["+g.join(",")+"]"}if(e){f=e.length;for(i=0;i<f;i+=1){h=e[i];if(typeof h==="string")(j=b(d[h],e))&&g.push(b(h)+":"+j)}}else for(h in d)if(typeof h==="string")(j=b(d[h],e))&&g.push(b(h)+":"+j);return"{"+g.join(",")+"}"}}Date.prototype.toJSON=function(){return this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+
":"+a(this.getUTCSeconds())+"Z"};var c={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return{stringify:b,parse:function(d,e){function g(h,f){var j,k;if(f&&typeof f==="object")for(j in f)if(Object.prototype.hasOwnProperty.apply(f,[j])){k=g(j,f[j]);if(k!==undefined)f[j]=k}return e(h,f)}var i;if(/^[\],:{}\s]*$/.test(d.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){i=eval("("+
d+")");return typeof e==="function"?g("",i):i}throw new SyntaxError("parseJSON");}}}());if(Garmin==undefined)Garmin={};
var detectableWithVB=false,PluginDetect={init:function(){if(navigator.userAgent.indexOf("MSIE")!=-1&&navigator.userAgent.indexOf("Win")!=-1){document.writeln('<script language="VBscript">');document.writeln("'do a one-time test for a version of VBScript that can handle this code");document.writeln("detectableWithVB = False");document.writeln("If ScriptEngineMajorVersion >= 2 then");document.writeln("  detectableWithVB = True");document.writeln("End If");document.writeln("'this next function will detect most plugins");document.writeln("Function detectActiveXControl(activeXControlName)");
document.writeln("  on error resume next");document.writeln("  detectActiveXControl = False");document.writeln("  If detectableWithVB Then");document.writeln("     detectActiveXControl = IsObject(CreateObject(activeXControlName))");document.writeln("  End If");document.writeln("End Function");document.writeln("<\/script>")}},canDetectPlugins:function(){return detectableWithVB||navigator.plugins&&navigator.plugins.length>0?true:false},detectFlash:function(){var a=PluginDetect.detectPlugin("Shockwave",
"Flash");if(!a&&detectableWithVB)a=detectActiveXControl("ShockwaveFlash.ShockwaveFlash.1");return a},detectGarminCommunicatorPlugin:function(){var a=PluginDetect.detectPlugin("Garmin Communicator");if(!a&&detectableWithVB)a=detectActiveXControl("GARMINAXCONTROL.GarminAxControl_t.1");return a},detectPlugin:function(){var a=PluginDetect.detectPlugin.arguments,b=false;if(navigator.plugins&&navigator.plugins.length>0){var c=navigator.plugins.length;for(pluginsArrayCounter=0;pluginsArrayCounter<c;pluginsArrayCounter++){var d=
0;for(namesCounter=0;namesCounter<a.length;namesCounter++)if(navigator.plugins[pluginsArrayCounter].name.indexOf(a[namesCounter])>=0||navigator.plugins[pluginsArrayCounter].description.indexOf(a[namesCounter])>=0)d++;if(d==a.length){b=true;break}}}return b}};PluginDetect.init();if(Garmin==undefined)Garmin={};Garmin.XmlConverter=function(){};Garmin.XmlConverter={toDocument:function(a){return Try.these(function(){var b=new ActiveXObject("Microsoft.XMLDOM");b.async="false";b.loadXML(a);return b},function(){return(new DOMParser).parseFromString(a,"text/xml")})},toString:function(a){return window.ActiveXObject?a.xml:(new XMLSerializer).serializeToString(a)}};if(Garmin==undefined)Garmin={};Garmin.Device=function(){};Garmin.Device=Class.create();
Garmin.Device.prototype={initialize:function(a,b){this.displayName=a;this.number=b;this.id=this.description=this.softwareVersion=this.partNumber=null;this.dataTypes=new Hash({})},getDisplayName:function(){return this.displayName},getNumber:function(){return this.number},setPartNumber:function(a){this.partNumber=a},getPartNumber:function(){return this.partNumber},setSoftwareVersion:function(a){this.softwareVersion=a},getSoftwareVersion:function(){return this.softwareVersion},setDescription:function(a){this.description=
a},getDescription:function(){return this.description},setId:function(a){this.id=a},getId:function(){return this.id},addDeviceDataType:function(a){var b=new Hash;b.set(a.getTypeName(),a);this.dataTypes.update(b)},getDeviceDataType:function(a){return this.dataTypes.get(a)},getDeviceDataTypes:function(){return this.dataTypes},supportDeviceDataTypeRead:function(a){a=this.getDeviceDataType(a);return a!=null&&a.hasReadAccess()?true:false},supportDeviceDataTypeWrite:function(a){a=this.getDeviceDataType(a);
return a!=null&&a.hasWriteAccess()?true:false},toString:function(){return"Device["+this.getDisplayName()+", "+this.getDescription()+", "+this.getNumber()+"]"}};Garmin.DeviceDataType=function(){};Garmin.DeviceDataType=Class.create();
Garmin.DeviceDataType.prototype={initialize:function(a,b){this.typeName=a;this.fileExtension=b;this.writeAccess=this.readAccess=false;this.identifier=this.writeFilePath=this.readFilePath=this.filePath=null},getTypeName:function(){return this.typeName},getDisplayName:function(){return this.getTypeName()},getFileExtension:function(){return this.fileExtension},getFilePath:function(){return this.filePath},setFilePath:function(a){this.filePath=a},getReadFilePath:function(){return this.readFilePath},setReadFilePath:function(a){this.readFilePath=
a},getWriteFilePath:function(){return this.writeFilePath},setWriteFilePath:function(a){this.writeFilePath=a},getIdentifier:function(){return this.identifier},setIdentifier:function(a){this.identifier=a},setReadAccess:function(a){this.readAccess=a},hasReadAccess:function(){return this.readAccess},setWriteAccess:function(a){this.writeAccess=a},hasWriteAccess:function(){return this.writeAccess}};if(Garmin==undefined)Garmin={};Garmin.DeviceControl=function(){};Garmin.DeviceControl=Class.create();
Garmin.DeviceControl.prototype={initialize:function(){this.pluginUnlocked=false;try{if(typeof Garmin.DevicePlugin=="undefined")throw"";}catch(a){throw Error(Garmin.DeviceControl.MESSAGES.deviceControlMissing);}if(!BrowserSupport.isBrowserSupported()){var b=Error(Garmin.DeviceControl.MESSAGES.browserNotSupported);b.name="BrowserNotSupportedException";throw b;}if(!PluginDetect.detectGarminCommunicatorPlugin()){b=Error(Garmin.DeviceControl.MESSAGES.pluginNotInstalled);b.name="PluginNotInstalledException";
throw b;}b=window.ActiveXObject?$("GarminActiveXControl"):$("GarminNetscapePlugin");if(b==null){b=Error(Garmin.DeviceControl.MESSAGES.missingPluginTag);b.name="HtmlTagNotFoundException";throw b;}this.garminPlugin=new Garmin.DevicePlugin(b);this.validatePlugin();this._broadcaster=new Garmin.Broadcaster;this.getDetailedDeviceData=true;this.devices=[];this.deviceNumber=null;this.numDevices=0;this.gpsDataType=this.gpsData=null;this.gpsDataStringCompressed=this.gpsDataString=""},validatePlugin:function(){if(!this.isPluginInstalled()){var a=
Error(Garmin.DeviceControl.MESSAGES.pluginNotInstalled);a.name="PluginNotInstalledException";throw a;}if(this.garminPlugin.isPluginOutOfDate()){a=Error(Garmin.DeviceControl.MESSAGES.outOfDatePlugin1+Garmin.DevicePlugin.REQUIRED_VERSION.toString()+Garmin.DeviceControl.MESSAGES.outOfDatePlugin2+this.getPluginVersionString());a.name="OutOfDatePluginException";a.version=this.getPluginVersionString();throw a;}},checkForUpdates:function(){if(this.garminPlugin.isUpdateAvailable()){var a=Error(Garmin.DeviceControl.MESSAGES.updatePlugin1+
Garmin.DevicePlugin.LATEST_VERSION.toString()+Garmin.DeviceControl.MESSAGES.updatePlugin2+this.getPluginVersionString());a.name="UpdatePluginException";a.version=this.getPluginVersionString();throw a;}},findDevices:function(){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);this.garminPlugin.startFindDevices();this._broadcaster.dispatch("onStartFindDevices",{controller:this});setTimeout(function(){this._finishFindDevices()}.bind(this),1E3)},cancelFindDevices:function(){this.garminPlugin.cancelFindDevices();
this._broadcaster.dispatch("onCancelFindDevices",{controller:this})},_finishFindDevices:function(){if(this.garminPlugin.finishFindDevices()){this.devices=Garmin.PluginUtils.parseDeviceXml(this.garminPlugin,this.getDetailedDeviceData);this.numDevices=this.devices.length;this.deviceNumber=0;this._broadcaster.dispatch("onFinishFindDevices",{controller:this})}else setTimeout(function(){this._finishFindDevices()}.bind(this),500)},setDeviceNumber:function(a){this.deviceNumber=a},getDeviceNumber:function(){return this.deviceNumber},
getDevices:function(){return this.devices},getCurrentDeviceXml:function(){return this.garminPlugin.getDeviceDescriptionXml(this.deviceNumber)},readDataFromDevice:function(a){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);if(this.numDevices==0)throw Error(Garmin.DeviceControl.MESSAGES.noDevicesConnected);if(!this._isAMember(a,[Garmin.DeviceControl.FILE_TYPES.gpx,Garmin.DeviceControl.FILE_TYPES.gpxDetail,Garmin.DeviceControl.FILE_TYPES.gpxDir,Garmin.DeviceControl.FILE_TYPES.tcx,
Garmin.DeviceControl.FILE_TYPES.crs,Garmin.DeviceControl.FILE_TYPES.tcxDir,Garmin.DeviceControl.FILE_TYPES.crsDir,Garmin.DeviceControl.FILE_TYPES.wkt,Garmin.DeviceControl.FILE_TYPES.tcxProfile,Garmin.DeviceControl.FILE_TYPES.goals,Garmin.DeviceControl.FILE_TYPES.fit,Garmin.DeviceControl.FILE_TYPES.fitDir])){a=Error(Garmin.DeviceControl.MESSAGES.invalidFileType+a);a.name="InvalidTypeException";throw a;}if(!this.checkDeviceReadSupport(a)){a=Error(Garmin.DeviceControl.MESSAGES.unsupportedReadDataType+
a);a.name="UnsupportedDataTypeException";throw a;}this.gpsDataType=a;this.gpsDataString=this.gpsData=null;this.idle=false;try{this._broadcaster.dispatch("onStartReadFromDevice",{controller:this});switch(this.gpsDataType){case Garmin.DeviceControl.FILE_TYPES.gpxDir:case Garmin.DeviceControl.FILE_TYPES.gpx:this.garminPlugin.startReadFromGps(this.deviceNumber);break;case Garmin.DeviceControl.FILE_TYPES.tcx:case Garmin.DeviceControl.FILE_TYPES.crs:case Garmin.DeviceControl.FILE_TYPES.wkt:case Garmin.DeviceControl.FILE_TYPES.goals:case Garmin.DeviceControl.FILE_TYPES.tcxProfile:this.garminPlugin.startReadFitnessData(this.deviceNumber,
this.gpsDataType);break;case Garmin.DeviceControl.FILE_TYPES.tcxDir:this.garminPlugin.startReadFitnessDirectory(this.deviceNumber,Garmin.DeviceControl.FILE_TYPES.tcx);break;case Garmin.DeviceControl.FILE_TYPES.crsDir:this.garminPlugin.startReadFitnessDirectory(this.deviceNumber,Garmin.DeviceControl.FILE_TYPES.crs);break;case Garmin.DeviceControl.FILE_TYPES.fitDir:this.garminPlugin.startReadFitDirectory(this.deviceNumber);break;case Garmin.DeviceControl.FILE_TYPES.deviceXml:this.gpsDataString=this.getCurrentDeviceXml();
break}this._progressRead()}catch(b){this._reportException(b)}},readDetailFromDevice:function(a,b){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);if(this.numDevices==0)throw Error(Garmin.DeviceControl.MESSAGES.noDevicesConnected);if(!this._isAMember(a,[Garmin.DeviceControl.FILE_TYPES.tcxDetail,Garmin.DeviceControl.FILE_TYPES.crsDetail])){var c=Error(Garmin.DeviceControl.MESSAGES.invalidFileType+a);c.name="InvalidTypeException";throw c;}if(!this.checkDeviceReadSupport(a))throw Error(Garmin.DeviceControl.MESSAGES.unsupportedReadDataType+
a);this.gpsDataType=a;this.gpsDataString=this.gpsData=null;this.idle=false;try{this._broadcaster.dispatch("onStartReadFromDevice",{controller:this});switch(this.gpsDataType){case Garmin.DeviceControl.FILE_TYPES.tcxDetail:this.garminPlugin.startReadFitnessDetail(this.deviceNumber,Garmin.DeviceControl.FILE_TYPES.tcx,b);break;case Garmin.DeviceControl.FILE_TYPES.crsDetail:this.garminPlugin.startReadFitnessDetail(this.deviceNumber,Garmin.DeviceControl.FILE_TYPES.crs,b);break}this._progressRead()}catch(d){this._reportException(d)}},
readFromDevice:function(){this.readDataFromDevice(Garmin.DeviceControl.FILE_TYPES.gpx)},readHistoryDetailFromFitnessDevice:function(a){this.readDetailFromDevice(Garmin.DeviceControl.FILE_TYPES.tcx,a)},readCourseDetailFromFitnessDevice:function(a){this.readDetailFromDevice(Garmin.DeviceControl.FILE_TYPES.crs,a)},readHistoryFromFitnessDevice:function(){this.readDataFromDevice(Garmin.DeviceControl.FILE_TYPES.tcx)},readCoursesFromFitnessDevice:function(){this.readDataFromDevice(Garmin.DeviceControl.FILE_TYPES.crs)},
readWorkoutsFromFitnessDevice:function(){this.readDataFromDevice(Garmin.DeviceControl.FILE_TYPES.wkt)},readUserProfileFromFitnessDevice:function(){this.readDataFromDevice(Garmin.DeviceControl.FILE_TYPES.tcxProfile)},readGoalsFromFitnessDevice:function(){this.readDataFromDevice(Garmin.DeviceControl.FILE_TYPES.goals)},getGpsData:function(){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);if(this.numDevices==0)throw Error(Garmin.DeviceControl.MESSAGES.noDevicesConnected);
if(this.getReadCompletionState!=Garmin.DeviceControl.FINISH_STATES.finished)throw Error(Garmin.DeviceControl.MESSAGES.incompleteRead);return this.gpsData},getGpsDataString:function(){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);if(this.numDevices==0)throw Error(Garmin.DeviceControl.MESSAGES.noDevicesConnected);if(this.getReadCompletionState!=Garmin.DeviceControl.FINISH_STATES.finished)throw Error(Garmin.DeviceControl.MESSAGES.incompleteRead);return this.gpsDataString},
getCompressedFitnessData:function(){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);if(this.numDevices==0)throw Error(Garmin.DeviceControl.MESSAGES.noDevicesConnected);if(this.getReadCompletionState!=Garmin.DeviceControl.FINISH_STATES.finished)throw Error(Garmin.DeviceControl.MESSAGES.incompleteRead);try{this.garminPlugin.getTcdXmlz()}catch(a){this._reportException(a)}},getReadCompletionState:function(){switch(this.gpsDataType){case Garmin.DeviceControl.FILE_TYPES.gpxDir:case Garmin.DeviceControl.FILE_TYPES.gpxDetail:case Garmin.DeviceControl.FILE_TYPES.gpx:return this.garminPlugin.finishReadFromGps();
case Garmin.DeviceControl.FILE_TYPES.tcx:case Garmin.DeviceControl.FILE_TYPES.crs:case Garmin.DeviceControl.FILE_TYPES.wkt:case Garmin.DeviceControl.FILE_TYPES.tcxProfile:case Garmin.DeviceControl.FILE_TYPES.goals:return this.garminPlugin.finishReadFitnessData();case Garmin.DeviceControl.FILE_TYPES.tcxDir:case Garmin.DeviceControl.FILE_TYPES.crsDir:return this.garminPlugin.finishReadFitnessDirectory();case Garmin.DeviceControl.FILE_TYPES.tcxDetail:case Garmin.DeviceControl.FILE_TYPES.crsDetail:return this.garminPlugin.finishReadFitnessDetail();
case Garmin.DeviceControl.FILE_TYPES.fitDir:return this.garminPlugin.finishReadFitDirectory()}},_progressRead:function(){this._broadcaster.dispatch("onProgressReadFromDevice",{progress:this.getDeviceStatus(),controller:this});setTimeout(function(){this._finishReadFromDevice()}.bind(this),200)},_finishReadFromDevice:function(){var a=this.getReadCompletionState();try{if(a==Garmin.DeviceControl.FINISH_STATES.finished)switch(this.gpsDataType){case Garmin.DeviceControl.FILE_TYPES.gpxDir:case Garmin.DeviceControl.FILE_TYPES.gpxDetail:case Garmin.DeviceControl.FILE_TYPES.gpx:if(this.garminPlugin.gpsTransferSucceeded()){this.gpsDataString=
this.garminPlugin.getGpsXml();this.gpsData=Garmin.XmlConverter.toDocument(this.gpsDataString);this._broadcaster.dispatch("onFinishReadFromDevice",{success:this.garminPlugin.gpsTransferSucceeded(),controller:this})}break;case Garmin.DeviceControl.FILE_TYPES.tcx:case Garmin.DeviceControl.FILE_TYPES.crs:case Garmin.DeviceControl.FILE_TYPES.tcxDir:case Garmin.DeviceControl.FILE_TYPES.crsDir:case Garmin.DeviceControl.FILE_TYPES.tcxDetail:case Garmin.DeviceControl.FILE_TYPES.crsDetail:case Garmin.DeviceControl.FILE_TYPES.wkt:case Garmin.DeviceControl.FILE_TYPES.tcxProfile:case Garmin.DeviceControl.FILE_TYPES.goals:if(this.garminPlugin.fitnessTransferSucceeded()){this.gpsDataString=
this.garminPlugin.getTcdXml();this.gpsDataStringCompressed=this.garminPlugin.getTcdXmlz();this.gpsData=Garmin.XmlConverter.toDocument(this.gpsDataString);this._broadcaster.dispatch("onFinishReadFromDevice",{success:this.garminPlugin.fitnessTransferSucceeded(),controller:this})}break;case Garmin.DeviceControl.FILE_TYPES.fitDir:this.gpsDataString=this.garminPlugin.getDirectoryXml();this.gpsData=Garmin.XmlConverter.toDocument(this.gpsDataString);this._broadcaster.dispatch("onFinishReadFromDevice",{success:this.garminPlugin.fitnessTransferSucceeded(),
controller:this});break}else a==Garmin.DeviceControl.FINISH_STATES.messageWaiting?this._broadcaster.dispatch("onWaitingReadFromDevice",{message:this._messageWaiting(),controller:this}):this._progressRead()}catch(b){this._reportException(b)}},cancelReadFromDevice:function(){this.gpsDataType==Garmin.DeviceControl.FILE_TYPES.gpx?this.garminPlugin.cancelReadFromGps():this.garminPlugin.cancelReadFitnessData();this._broadcaster.dispatch("onCancelReadFromDevice",{controller:this})},getBinaryFile:function(a,
b){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);if(this.numDevices==0)throw Error(Garmin.DeviceControl.MESSAGES.noDevicesConnected);this.gpsDataType=b.capitalize().endsWith(".fit")?Garmin.DeviceControl.FILE_TYPES.fit:Garmin.DeviceControl.FILE_TYPES.binary;var c;try{this.gpsDataString=this.garminPlugin.getBinaryFile(a,b,false)}catch(d){c=false;this._reportException(d)}this._broadcaster.dispatch("onFinishReadFromDevice",{success:c,controller:this});return this.gpsData},
writeAddressToDevice:function(a){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);if(!this.geocoder){this.geocoder=new Garmin.Geocode;this.geocoder.register(this)}this.geocoder.findLatLng(a)},onException:function(a){this._reportException(a.msg)},onFinishedFindLatLon:function(a){a.fileName="address.gpx";a.controller=this;this._broadcaster.dispatch("onFinishedFindLatLon",a);this.writeToDevice((new Garmin.GpsDataFactory).produceGpxString(null,[a.waypoint]),a.fileName)},
writeDataToDevice:function(a,b,c){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);if(this.numDevices==0)throw Error(Garmin.DeviceControl.MESSAGES.noDevicesConnected);this.gpsDataType=a;if(!this.checkDeviceWriteSupport(this.gpsDataType))throw Error(Garmin.DeviceControl.MESSAGES.unsupportedWriteDataType+this.gpsDataType);try{this._broadcaster.dispatch("onStartWriteToDevice",{controller:this});switch(this.gpsDataType){case Garmin.DeviceControl.FILE_TYPES.gpx:this.garminPlugin.startWriteToGps(b,
c,this.deviceNumber);break;case Garmin.DeviceControl.FILE_TYPES.crs:case Garmin.DeviceControl.FILE_TYPES.wkt:case Garmin.DeviceControl.FILE_TYPES.goals:case Garmin.DeviceControl.FILE_TYPES.tcxProfile:case Garmin.DeviceControl.FILE_TYPES.nlf:this.garminPlugin.startWriteFitnessData(b,this.deviceNumber,c,this.gpsDataType);break;default:throw Error(Garmin.DeviceControl.MESSAGES.unsupportedWriteDataType+this.gpsDataType);}this._progressWrite()}catch(d){this._reportException(d)}},writeToDevice:function(a,
b){this.writeDataToDevice(Garmin.DeviceControl.FILE_TYPES.gpx,a,b)},writeFitnessToDevice:function(a,b){this.writeDataToDevice(Garmin.DeviceControl.FILE_TYPES.crs,a,b)},writeCoursesToFitnessDevice:function(a,b){this.writeDataToDevice(Garmin.DeviceControl.FILE_TYPES.crs,a,b)},writeGoalsToFitnessDevice:function(a){this.writeDataToDevice(Garmin.DeviceControl.FILE_TYPES.goals,a,"")},writeWorkoutsToFitnessDevice:function(a,b){this.writeDataToDevice(Garmin.DeviceControl.FILE_TYPES.wkt,a,b)},writeUserProfileToFitnessDevice:function(a,
b){this.writeDataToDevice(Garmin.DeviceControl.FILE_TYPES.tcxProfile,a,b)},downloadToDevice:function(a){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);if(this.numDevices==0)throw Error(Garmin.DeviceControl.MESSAGES.noDevicesConnected);this.gpsDataType=Garmin.DeviceControl.FILE_TYPES.binary;try{this.garminPlugin.startDownloadData(a,this.deviceNumber);this._progressWrite()}catch(b){this._reportException(b)}},_progressWrite:function(){this._broadcaster.dispatch("onProgressWriteToDevice",
{progress:this.getDeviceStatus(),controller:this});setTimeout(function(){this._finishWriteToDevice()}.bind(this),200)},_finishWriteToDevice:function(){try{var a,b;switch(this.gpsDataType){case Garmin.DeviceControl.FILE_TYPES.gpx:a=this.garminPlugin.finishWriteToGps();b=this.garminPlugin.gpsTransferSucceeded();break;case Garmin.DeviceControl.FILE_TYPES.crs:case Garmin.DeviceControl.FILE_TYPES.goals:case Garmin.DeviceControl.FILE_TYPES.wkt:case Garmin.DeviceControl.FILE_TYPES.tcxProfile:case Garmin.DeviceControl.FILE_TYPES.nlf:a=
this.garminPlugin.finishWriteFitnessData();b=this.garminPlugin.fitnessTransferSucceeded();break;case Garmin.DeviceControl.FILE_TYPES.gpi:case Garmin.DeviceControl.FILE_TYPES.fitCourse:case Garmin.DeviceControl.FILE_TYPES.fitSettings:case Garmin.DeviceControl.FILE_TYPES.fitSport:case Garmin.DeviceControl.FILE_TYPES.binary:a=this.garminPlugin.finishDownloadData();b=this.garminPlugin.downloadDataSucceeded();break;case Garmin.DeviceControl.FILE_TYPES.firmware:a=this.garminPlugin.finishUnitSoftwareUpdate();
b=this.garminPlugin.downloadDataSucceeded();break;default:throw Error(Garmin.DeviceControl.MESSAGES.unsupportedWriteDataType+this.gpsDataType);}if(a==Garmin.DeviceControl.FINISH_STATES.finished)this._broadcaster.dispatch("onFinishWriteToDevice",{success:b,controller:this});else a==Garmin.DeviceControl.FINISH_STATES.messageWaiting?this._broadcaster.dispatch("onWaitingWriteToDevice",{message:this._messageWaiting(),controller:this}):this._progressWrite()}catch(c){this._reportException(c)}},cancelWriteToDevice:function(){switch(this.gpsDataType){case Garmin.DeviceControl.FILE_TYPES.gpx:this.garminPlugin.cancelWriteToGps();
break;case Garmin.DeviceControl.FILE_TYPES.gpi:case Garmin.DeviceControl.FILE_TYPES.binary:this.garminPlugin.cancelDownloadData();break;case Garmin.DeviceControl.FILE_TYPES.firmware:this.garminPlugin.cancelUnitSoftwareUpdate();break;case Garmin.DeviceControl.FILE_TYPES.crs:case Garmin.DeviceControl.FILE_TYPES.goals:case Garmin.DeviceControl.FILE_TYPES.wkt:case Garmin.DeviceControl.FILE_TYPES.tcxProfile:case Garmin.DeviceControl.FILE_TYPES.nlf:this.garminPlugin.cancelWriteFitnessData();break}this._broadcaster.dispatch("onCancelWriteToDevice",
{controller:this})},bytesAvailable:function(a){return this.garminPlugin.bytesAvailable(this.getDeviceNumber(),a)},downloadFirmwareToDevice:function(a){if(!this.isUnlocked())throw Error(Garmin.DeviceControl.MESSAGES.pluginNotUnlocked);if(this.numDevices==0)throw Error(Garmin.DeviceControl.MESSAGES.noDevicesConnected);this.gpsDataType=Garmin.DeviceControl.FILE_TYPES.firmware;try{this.garminPlugin.startUnitSoftwareUpdate(a,this.deviceNumber);this._progressWrite()}catch(b){this._reportException(b)}},
unlock:function(a){return this.pluginUnlocked=this.garminPlugin.unlock(a)},register:function(a){this._broadcaster.register(a)},isUnlocked:function(){return this.pluginUnlocked},respondToMessageBox:function(a){this.garminPlugin.respondToMessageBox(a?1:2);this._progressWrite()},_messageWaiting:function(){var a=Garmin.XmlConverter.toDocument(this.garminPlugin.getMessageBoxXml()),b=a.getElementsByTagName("Text")[0].childNodes[0].nodeValue;b=new Garmin.MessageBox("Question",b);a=a.getElementsByTagName("Button");
for(var c=0;c<a.length;c++){var d=a[c].getAttribute("Caption"),e=a[c].getAttribute("Value");b.addButton(d,e)}return b},getDeviceStatus:function(){var a=this.garminPlugin.getProgressXml();a=Garmin.XmlConverter.toDocument(a);var b="";if(a.getElementsByTagName("Title").length>0)b=a.getElementsByTagName("Title")[0].childNodes[0].nodeValue;b=new Garmin.TransferProgress(b);for(var c=a.getElementsByTagName("Text"),d=0;d<c.length;d++)if(c[d].childNodes.length>0){var e=c[d].childNodes[0].nodeValue;e!=""&&
b.addText(e)}a=a.getElementsByTagName("ProgressBar")[0];if(a!=undefined)if(a.getAttribute("Type")=="Percentage")b.setPercentage(a.getAttribute("Value"));else a.getAttribute("Type")=="Indefinite"&&b.setPercentage(100);return b},fetchDirectoryXML:function(a,b){try{this.bytesAvailable("/")==-1?b(null):this.garminPlugin.fetchDirectoryXML(this.deviceNumber,a,b)}catch(c){if(c.message.indexOf("is too high")!=-1)this.fetchDirectoryXML(a,b);else throw c;}},_isAMember:function(a,b){return b.any(function(c){return c==
a})},getPluginVersion:function(){return this.garminPlugin.getPluginVersion()},getPluginVersionString:function(){return this.garminPlugin.getPluginVersionString()},setPluginRequiredVersion:function(a){a!=null&&this.garminPlugin.setPluginRequiredVersion(a)},setPluginLatestVersion:function(a){a!=null&&this.garminPlugin.setPluginLatestVersion(a)},isPluginInitialized:function(){return this.garminPlugin!=null},isPluginInstalled:function(){return this.garminPlugin.getVersionXml()!=undefined},_reportException:function(a){this._broadcaster.dispatch("onException",
{msg:a,controller:this})},getDevicesCount:function(){return this.numDevices},checkDeviceReadSupport:function(a){if(a==Garmin.DeviceControl.FILE_TYPES.fitDir)if(this.garminPlugin.getSupportsFitDirectoryRead()==false)return false;var b=this._getDeviceByNumber(this.deviceNumber);switch(a){case Garmin.DeviceControl.FILE_TYPES.gpxDir:case Garmin.DeviceControl.FILE_TYPES.gpxDetail:a=Garmin.DeviceControl.FILE_TYPES.gpx;break;case Garmin.DeviceControl.FILE_TYPES.tcxDir:case Garmin.DeviceControl.FILE_TYPES.tcxDetail:a=
Garmin.DeviceControl.FILE_TYPES.tcx;break;case Garmin.DeviceControl.FILE_TYPES.crsDir:case Garmin.DeviceControl.FILE_TYPES.crsDetail:a=Garmin.DeviceControl.FILE_TYPES.crs;break;case Garmin.DeviceControl.FILE_TYPES.fitDir:case Garmin.DeviceControl.FILE_TYPES.fitFile:a=Garmin.DeviceControl.FILE_TYPES.fit;break;default:a=a}return a==Garmin.DeviceControl.FILE_TYPES.deviceXml||a==Garmin.DeviceControl.FILE_TYPES.firmware?true:b.supportDeviceDataTypeRead(a)},checkDeviceWriteSupport:function(a){var b=false;
b=this._getDeviceByNumber(this.deviceNumber);return b=a==Garmin.DeviceControl.FILE_TYPES.binary||a==Garmin.DeviceControl.FILE_TYPES.gpi?true:b.supportDeviceDataTypeWrite(a)},_getDeviceByNumber:function(a){for(var b=0;b<this.devices.length;b++)if(this.devices[b].getNumber()==a)return this.devices[b]},toString:function(){return"Garmin Javascript GPS Controller managing "+this.numDevices+" device(s)"}};
var BrowserSupport={isBrowserSupported:function(){return BrowserDetect.OS=="Windows"&&(BrowserDetect.browser=="Firefox"||BrowserDetect.browser=="Mozilla"||BrowserDetect.browser=="Explorer"||BrowserDetect.browser=="Safari")||BrowserDetect.OS=="Mac"&&(BrowserDetect.browser=="Firefox"||BrowserDetect.browser=="Mozilla"||BrowserDetect.browser=="Safari")}};
Garmin.DeviceControl.MESSAGES={deviceControlMissing:"Garmin.DeviceControl depends on the Garmin.DevicePlugin framework.",missingPluginTag:"Plug-In HTML tag not found.",browserNotSupported:"Your browser is not supported to use the Garmin Communicator Plug-In.",pluginNotInstalled:"Garmin Communicator Plugin NOT detected.",outOfDatePlugin1:"Your version of the Garmin Communicator Plug-In is out of date.<br/>Required: ",outOfDatePlugin2:"Current: ",updatePlugin1:"Your version of the Garmin Communicator Plug-In is not the latest version. Latest version: ",
updatePlugin2:", current: ",pluginNotUnlocked:"Garmin Plugin has not been unlocked",noDevicesConnected:"No device connected, can't communicate with device.",invalidFileType:"Cannot process the device file type: ",incompleteRead:"Incomplete read, cannot get compressed format.",unsupportedReadDataType:"Your device does not support reading of the type: ",unsupportedWriteDataType:"Your device does not support writing of the type: "};
Garmin.DeviceControl.FINISH_STATES={idle:0,working:1,messageWaiting:2,finished:3};
Garmin.DeviceControl.FILE_TYPES={gpx:"GPSData",tcx:"FitnessHistory",gpi:"gpi",crs:"FitnessCourses",wkt:"FitnessWorkouts",goals:"FitnessActivityGoals",tcxProfile:"FitnessUserProfile",binary:"BinaryData",voices:"Voices",nlf:"FitnessNewLeaf",fit:"FITBinary",fitCourse:"FIT_TYPE_6",fitSettings:"FIT_TYPE_2",fitSport:"FIT_TYPE_3",tcxDir:"FitnessHistoryDirectory",crsDir:"FitnessCoursesDirectory",gpxDir:"GPSDataDirectory",tcxDetail:"FitnessHistoryDetail",crsDetail:"FitnessCoursesDetail",gpxDetail:"GPSDataDetail",
deviceXml:"DeviceXml",fitDir:"FitDirectory",fitFile:"FitFile",firmware:"Firmware"};Garmin.DeviceControl.TRANSFER_DIRECTIONS={read:"OutputFromUnit",write:"InputToUnit",both:"InputOutput"};Garmin.TransferProgress=Class.create();
Garmin.TransferProgress.prototype={initialize:function(a){this.title=a;this.text=[];this.percentage=null},addText:function(a){this.text.push(a)},getText:function(){return this.text},getTitle:function(){return this.title},setPercentage:function(a){this.percentage=a},getPercentage:function(){return this.percentage},toString:function(){var a="";if(this.getTitle()!=null)a+=this.getTitle();if(this.getPercentage()!=null)a+=": "+this.getPercentage()+"%";return a}};Garmin.MessageBox=Class.create();
Garmin.MessageBox.prototype={initialize:function(a,b){this.type=a;this.text=b;this.buttons=[]},getType:function(){return this.type},getText:function(){return this.text},addButton:function(a,b){this.buttons.push({caption:a,value:b})},getButtons:function(){return this.buttons},getButtonValue:function(a){for(var b=0;b<this.buttons.length;b++)if(this.buttons[b].caption==a)return this.buttons[b].value;return null},toString:function(){return this.getText()}};if(Garmin==undefined)Garmin={};Garmin.DevicePlugin=function(){};Garmin.DevicePlugin=Class.create();
Garmin.DevicePlugin.prototype={initialize:function(a){this.plugin=a;this.unlocked=false;this.fetchDirectoryStatus="idle";this.downloading=false},unlock:function(a){for(var b=a?a.length/2:0,c=0;c<b;c++)if(this.plugin.Unlock(a[c*2],a[c*2+1]))return this.unlocked=true;this.tryUnlock=this.plugin.Unlock("file:///","cb1492ae040612408d87cc53e3f7ff3c")||this.plugin.Unlock("http://localhost","45517b532362fc3149e4211ade14c9b2")||this.plugin.Unlock("http://127.0.0.1","40cd4860f7988c53b15b8491693de133");return this.unlocked=
!this.plugin.Locked},isUnlocked:function(){return this.unlocked},_getPluginFunctionExists:function(a){a="this.plugin."+a;try{return typeof eval(a)=="function"?true:eval(a)?true:false}catch(b){return true}},_getPluginFieldExists:function(a){return typeof a=="string"?true:a?true:false},getSupportsFitnessWrite:function(){return this._getPluginFunctionExists("StartWriteFitnessData")},getSupportsFitnessDirectoryRead:function(){return this._getPluginFunctionExists("StartReadFitnessDirectory")},getSupportsFitDirectoryRead:function(){return this._getPluginFunctionExists("StartReadFITDirectory")},
getSupportsFitnessReadCompressed:function(){return this._getPluginFieldExists(this.plugin.TcdXmlz)},startFindDevices:function(){this.plugin.StartFindDevices()},cancelFindDevices:function(){this.plugin.CancelFindDevices()},finishFindDevices:function(){return this.plugin.FinishFindDevices()},getDevicesXml:function(){return this.plugin.DevicesXmlString()},getDeviceDescriptionXml:function(a){return this.plugin.DeviceDescription(a)},startReadFromGps:function(a){this.plugin.StartReadFromGps(a)},finishReadFromGps:function(){return this.plugin.FinishReadFromGps()},
cancelReadFromGps:function(){this.plugin.CancelReadFromGps()},startReadFitnessData:function(a,b){if(!this.checkPluginVersionSupport([2,1,0,3]))throw Error("Your Communicator Plug-in version ("+this.getPluginVersionString()+") does not support reading this type of fitness data.");this.plugin.StartReadFitnessData(a,b)},finishReadFitnessData:function(){return this.plugin.FinishReadFitnessData()},cancelReadFitnessData:function(){this.plugin.CancelReadFitnessData()},startReadFitDirectory:function(a){if(!this.getSupportsFitDirectoryRead())throw Error("Your Communicator Plug-in version ("+
this.getPluginVersionString()+") does not support reading directory listing data.");this.plugin.StartReadFITDirectory(a)},finishReadFitDirectory:function(){return this.plugin.FinishReadFITDirectory()},startReadFitnessDirectory:function(a,b){if(!this.getSupportsFitnessDirectoryRead())throw Error("Your Communicator Plug-in version ("+this.getPluginVersionString()+") does not support reading fitness directory data.");this.plugin.StartReadFitnessDirectory(a,b)},finishReadFitnessDirectory:function(){return this.plugin.FinishReadFitnessDirectory()},
cancelReadFitnessDirectory:function(){this.plugin.CancelReadFitnessDirectory()},cancelReadFitDirectory:function(){this.plugin.CancelReadFitDirectory()},startReadFitnessDetail:function(a,b,c){if(!this.checkPluginVersionSupport([2,2,0,2]))throw Error("Your Communicator Plug-in version ("+this.getPluginVersionString()+") does not support reading fitness detail.");this.plugin.StartReadFitnessDetail(a,b,c)},finishReadFitnessDetail:function(){return this.plugin.FinishReadFitnessDetail()},cancelReadFitnessDetail:function(){this.plugin.CancelReadFitnessDetail()},
startWriteToGps:function(a,b,c){this._setWriteGpsXml(a);this._setWriteFilename(b);var d=this,e=function(){d.plugin.FinishWriteToGps()!=3?setTimeout(e,1E3):d.plugin.StartWriteToGps(c)};setTimeout(e,0)},_setWriteGpsXml:function(a){this.plugin.GpsXml=a},_setWriteFilename:function(a){this.plugin.FileName=a},finishWriteToGps:function(){return this.plugin.FinishWriteToGps()},cancelWriteToGps:function(){this.plugin.CancelWriteToGps()},startWriteFitnessData:function(a,b,c,d){if(!this.checkPluginVersionSupport([2,
2,0,1]))throw Error("Your Communicator Plug-in version ("+this.getPluginVersionString()+") does not support writing fitness data.");this._setWriteTcdXml(a);this._setWriteFilename(c);this.plugin.StartWriteFitnessData(b,d)},finishWriteFitnessData:function(){return this.plugin.FinishWriteFitnessData()},cancelWriteFitnessData:function(){this.plugin.CancelWriteFitnessData()},_setWriteTcdXml:function(a){this.plugin.TcdXml=a},bytesAvailable:function(a,b,c){try{return this.plugin.BytesAvailable(a,b)}catch(d){if(c<
100)this.bytesAvailable(a,b,c++);else return-1}},respondToMessageBox:function(a){this.plugin.RespondToMessageBox(a)},startDownloadData:function(a,b){var c=this,d=function(){c.plugin.FinishWriteToGps()!=3?setTimeout(d,1E3):c.plugin.StartDownloadData(a,b)};setTimeout(d,0)},finishDownloadData:function(){return this.plugin.FinishDownloadData()},cancelDownloadData:function(){this.plugin.CancelDownloadData()},downloadDataSucceeded:function(){return this.plugin.DownloadDataSucceeded},startUnitSoftwareUpdate:function(a,
b){this.plugin.StartUnitSoftwareUpdate(a,b)},finishUnitSoftwareUpdate:function(){return this.plugin.FinishUnitSoftwareUpdate()},cancelUnitSoftwareUpdate:function(){this.plugin.CancelUnitSoftwareUpdate()},gpsTransferSucceeded:function(){return this.plugin.GpsTransferSucceeded},fitnessTransferSucceeded:function(){return this.plugin.FitnessTransferSucceeded},getBinaryFile:function(a,b,c){return this.plugin.GetBinaryFile(a,b,c)},getGpsXml:function(){return this.plugin.GpsXml},getTcdXml:function(){return this.plugin.TcdXml},
getTcdXmlz:function(){return this.plugin.TcdXmlz},getDirectoryXml:function(){return this.plugin.DirectoryListingXml},fetchDirectoryXML:function(a,b,c){var d=this;if(d.fetchDirectoryStatus!="idle")setTimeout(function(){d.fetchDirectoryXML(a,b,c)},500);else{var e=function(){if(d.plugin.DirectoryListingXml==g)setTimeout(e,500);else if(d.plugin.DirectoryListingXml.indexOf("does*not*exist*asdf")!=-1){g=d.plugin.DirectoryListingXml;d.plugin.StartDirectoryListing(0,b,false);setTimeout(e,500)}else{c(d.plugin.DirectoryListingXml);
d.fetchDirectoryStatus="idle"}};d.fetchDirectoryStatus="fetching";var g=d.plugin.DirectoryListingXml;try{d.plugin.StartDirectoryListing(0,"Garmin/does*not*exist*asdf",false)}catch(i){}setTimeout(e,500)}},getMessageBoxXml:function(){return this.plugin.MessageBoxXml},getProgressXml:function(){return this.plugin.ProgressXml},getVersionXml:function(){return this.plugin.VersionXml},getPluginVersionString:function(){var a=this.getPluginVersion();return a[0]+"."+a[1]+"."+a[2]+"."+a[3]},getPluginVersion:function(){var a=
parseInt(this._getElementValue(this.getVersionXml(),"VersionMajor")),b=parseInt(this._getElementValue(this.getVersionXml(),"VersionMinor")),c=parseInt(this._getElementValue(this.getVersionXml(),"BuildMajor")),d=parseInt(this._getElementValue(this.getVersionXml(),"BuildMinor"));return[a,b,c,d]},setPluginRequiredVersion:function(a){Garmin.DevicePlugin.REQUIRED_VERSION.versionMajor=a[0];Garmin.DevicePlugin.REQUIRED_VERSION.versionMinor=a[1];Garmin.DevicePlugin.REQUIRED_VERSION.buildMajor=a[2];Garmin.DevicePlugin.REQUIRED_VERSION.buildMinor=
a[3]},setPluginLatestVersion:function(a){Garmin.DevicePlugin.LATEST_VERSION.versionMajor=a[0];Garmin.DevicePlugin.LATEST_VERSION.versionMinor=a[1];Garmin.DevicePlugin.LATEST_VERSION.buildMajor=a[2];Garmin.DevicePlugin.LATEST_VERSION.buildMinor=a[3]},checkPluginVersionSupport:function(a){var b=this._versionToNumber(this.getPluginVersion());a=this._versionToNumber(a);return b>=a},_versionToNumber:function(a){if(a[1]>99||a[2]>99||a[3]>99)throw Error("version segment is greater than 99: "+a);return 1E6*
a[0]+1E4*a[1]+100*a[2]+a[3]},isPluginOutOfDate:function(){var a=this._versionToNumber(this.getPluginVersion()),b=this._versionToNumber(Garmin.DevicePlugin.REQUIRED_VERSION.toArray());return a<b},isUpdateAvailable:function(){var a=this._versionToNumber(this.getPluginVersion()),b=this._versionToNumber(Garmin.DevicePlugin.LATEST_VERSION.toArray());return a<b},_getElementValue:function(a,b){var c=a.indexOf("<"+b+">");if(c==-1)return null;c+=b.length+2;var d=a.indexOf("</"+b+">");return a.substring(c,
d)}};Garmin.DevicePlugin.LATEST_VERSION={versionMajor:2,versionMinor:7,buildMajor:3,buildMinor:0,toString:function(){return this.versionMajor+"."+this.versionMinor+"."+this.buildMajor+"."+this.buildMinor},toArray:function(){return[this.versionMajor,this.versionMinor,this.buildMajor,this.buildMinor]}};
Garmin.DevicePlugin.REQUIRED_VERSION={versionMajor:2,versionMinor:1,buildMajor:0,buildMinor:1,toString:function(){return this.versionMajor+"."+this.versionMinor+"."+this.buildMajor+"."+this.buildMinor},toArray:function(){return[this.versionMajor,this.versionMinor,this.buildMajor,this.buildMinor]}};if(Garmin==undefined)Garmin={};Garmin.Geocode=function(){};Garmin.Geocode=Class.create();
Garmin.Geocode.prototype={initialize:function(){this.geocoder=new GClientGeocoder;this._broadcaster=new Garmin.Broadcaster},findLatLng:function(a){var b=this;b.geocoder.getLocations(a,function(c){if(c){place=c.Placemark[0];point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);c=new Garmin.WayPoint(point.lat(),point.lng(),null,a,place.AddressDetails);b._broadcaster.dispatch("onFinishedFindLatLon",{waypoint:c})}else{c=Error("Unable to convert address to location: "+a);b._broadcaster.dispatch("onException",
{msg:c})}})},register:function(a){this._broadcaster.register(a)}};if(Garmin==undefined)Garmin={};Garmin.WayPoint=function(){};Garmin.WayPoint=Class.create();
Garmin.WayPoint.prototype={initialize:function(a,b,c,d,e,g,i,h,f){this.lat=a;this.lng=b;this.name=d;(this.addrdetails=e)&&this._initSubArea();this.elev=c;this.desc=g;this.sym=i;this.type=h;this.cmt=f;this.date=null},_initSubArea:function(){if(this.addrdetails.Country){this.country=this.addrdetails.Country.CountryNameCode;if(this.addrdetails.Country.AdministrativeArea){this.state=this.addrdetails.Country.AdministrativeArea.AdministrativeAreaName;if(this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea)if(this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.Locality){this.city=
this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;if(this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare)this.streetaddr=this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName;if(this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode)this.zip=this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber}else{this.city=
this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName;if(this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.Thoroughfare)this.streetaddr=this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.Thoroughfare.ThoroughfareName;if(this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.PostalCode)this.zip=this.addrdetails.Country.AdministrativeArea.SubAdministrativeArea.PostalCode.PostalCodeNumber}else if(this.addrdetails.Country.AdministrativeArea.Locality){this.city=
this.addrdetails.Country.AdministrativeArea.Locality.LocalityName;if(this.addrdetails.Country.AdministrativeArea.Locality.Thoroughfare)this.streetaddr=this.addrdetails.Country.AdministrativeArea.Locality.Thoroughfare.ThoroughfareName;if(this.addrdetails.Country.AdministrativeArea.Locality.PostalCode)this.zip=this.addrdetails.Country.AdministrativeArea.Locality.PostalCode.PostalCodeNumber}else{this.city=this.addrdetails.Country.AdministrativeArea.SubAdministrativeAreaName;if(this.addrdetails.Country.AdministrativeArea.Thoroughfare)this.streetaddr=
this.addrdetails.Country.AdministrativeArea.Thoroughfare.ThoroughfareName;if(this.addrdetails.Country.AdministrativeArea.PostalCode)this.zip=this.addrdetails.Country.AdministrativeArea.PostalCode.PostalCodeNumber}}}},getSymbol:function(){return this.sym},getType:function(){return this.type},getName:function(){return this.name},getAddress:function(){return this.addrdetails!=null?"<gpxx:Address><gpxx:StreetAddress>"+this.getStreetAddr()+"</gpxx:StreetAddress><gpxx:City>"+this.getCity()+"</gpxx:City><gpxx:State>"+
this.getState()+"</gpxx:State><gpxx:PostalCode>"+this.getZip()+"</gpxx:PostalCode></gpxx:Address>":null},getCountry:function(){return this.country},getState:function(){return this.state},getCity:function(){return this.city},getStreetAddr:function(){return this.streetaddr},getZip:function(){return this.zip},getDescription:function(){return this.desc},getLat:function(){return this.lat},getLng:function(){return this.lng},getElev:function(){return this.elev},getComment:function(){return this.cmt},getDate:function(){return this.date},
toString:function(){return"Waypoint: ("+this.getLat()+", "+this.getLng()+")"}};Garmin.TrackPoint=function(){};Garmin.TrackPoint=Class.create();
Garmin.TrackPoint.prototype={initialize:function(){this.date=this.measurements=null},getMeasurement:function(a){a=this.measurements[a];if(a==undefined)a=null;return a},isValidLocation:function(){return this.getLat()!="null"&&this.getLat()!=null&&this.getLng()!="null"&&this.getLng()!=null},getLat:function(){var a=this.getMeasurement("latitude");return a==null?null:a.value},getLng:function(){var a=this.getMeasurement("longitude");return a==null?null:a.value},getElev:function(){var a=this.getMeasurement("elevation");
return a==null?null:a.value},getDate:function(){return this.date},toString:function(){return"TrackPoint Point: ("+this.getLat()+", "+this.getLng()+")"}};Garmin.TrackSegment=function(){};Garmin.TrackSegment=Class.create();
Garmin.TrackSegment.prototype={initialize:function(){this.points=[]},addTrackPoint:function(a){this.points.push(a)},findNearestValidLocationPoint:function(a,b){return this.getPoint(a).isValidLocation()?this.getPoint(a):a>=this.getLength()?this.findNearestValidLocationPoint(this.getLength()-1,-1):this.findNearestValidLocationPoint(a+b,b)},getPoint:function(a){a=Math.floor(a);if(a>=this.getLength())return this.getEnd();if(a<=0)return this.getStart();return this.points[a]},getStart:function(){return this.points[0]},
getEnd:function(){return this.points[this.getLength()-1]},getStartLat:function(){return this.getStart().getLat()},getStartLng:function(){return this.getStart().getLng()},getStartDate:function(){return this.getStart().getDate()},getEndDate:function(){return this.getEnd().getDate()},getDuration:function(){return this.getStartDate().getDurationTo(this.getEndDate())},getLength:function(){return this.points.length},toString:function(){return"Track Segment w/ "+this.getLength()+" points."}};
Garmin.Track=function(){};Garmin.Track=Class.create();
Garmin.Track.prototype={initialize:function(){this.segments=[]},addSegment:function(a){this.segments.push(a)},getSegment:function(a){a=Math.floor(a);if(a>=this.getLastSegment())return this.getEnd();if(a<=0)return this.getFirstSegment();return this.segments[a]},getFirstSegment:function(){return this.segments[0]},getLastSegment:function(){return this.segments[this.getNumSegments()-1]},getNumSegments:function(){return this.segments.length},getStart:function(){return this.getFirstSegment().getStart()},getStartLat:function(){return this.getFirstSegment().getStartLat()},
getStartLng:function(){return this.getFirstSegment().getStartLng()},getStartDate:function(){return this.getFirstSegment().getStartDate()},getEnd:function(){return this.getLastSegment().getEnd()},getEndDate:function(){return this.getLastSegment().getEndDate()},getDuration:function(){return this.getStartDate().getDurationTo(this.getEndDate())},getLength:function(){for(var a=0,b=0;b<this.segments.length;b++)a+=this.segments[b].getLength();return a},isDrawable:function(){return this.getStartDate()!=null},
toString:function(){return"Track w/ "+this.getNumSegments()+" segments."}};Garmin.GpsDataFactory=function(){};Garmin.GpsDataFactory=Class.create();
Garmin.GpsDataFactory.prototype={initialize:function(){this.tracks=[];this.waypoints=[]},getTracks:function(){return this.tracks},getWaypoints:function(){return this.waypoints},parseGpxString:function(a){this.parseGpxDocument(Garmin.XmlConverter.toDocument(a))},parseGpxDocument:function(a){this.parseGpxTracks(a);this.parseGpxWaypoints(a)},parseGpxTracks:function(a){var b=[];a=a.getElementsByTagName("trk");for(var c=0;c<a.length;c++){for(var d=new Garmin.Track,e=a[c].getElementsByTagName("trkseg"),
g=0;g<e.length;g++){for(var i=new Garmin.TrackSegment,h=e[g].getElementsByTagName("trkpt"),f=0;f<h.length;f++){var j=new Garmin.TrackPoint,k=h[f].getAttribute("lat"),l=h[f].getAttribute("lon"),m=h[f].getElementsByTagName("ele");m=m.length>0?m[0].childNodes[0].nodeValue:null;var n=h[f].getElementsByTagName("time");if(n.length>0){n=n[0].childNodes[0].nodeValue;j.date=(new Garmin.DateTimeFormat).parseXsdDateTime(n)}j.measurements={latitude:{value:k,context:"latitude"},longitude:{value:l,context:"longitude"},
elevation:{value:m,context:"feet"}};i.addTrackPoint(j)}d.addSegment(i)}b.push(d)}return this.tracks=b},parseGpxWaypoint:function(a){var b=a.getAttribute("lat"),c=a.getAttribute("lon"),d=this._tagValue(a,"name"),e=this._tagValue(a,"desc"),g=this._tagValue(a,"ele"),i=this._tagValue(a,"sym"),h=this._tagValue(a,"type");a=this._tagValue(a,"cmt");return new Garmin.WayPoint(b,c,g,d,null,e,i,h,a)},parseGpxWaypoints:function(a){var b=[];a=a.getElementsByTagName("wpt");for(var c=0;c<a.length;c++){var d=this.parseGpxWaypoint(a[c]);
b.push(d)}return this.waypoints=b},produceGpxString:function(a,b){gpxString='<?xml version="1.0" encoding="UTF-8" standalone="no" ?>';gpxString+='<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" creator="Garmin Communicator Plug-In API" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensions/v3/GpxExtensionsv3.xsd">';
if(a!=null)for(var c=0;c<a.length;c++)gpxString+=this.produceTrackGpxString(a[c]);if(b!=null)for(c=0;c<b.length;c++)gpxString+=this.produceWaypointGpxString(b[c]);gpxString+="</gpx>";return gpxString},produceTrackGpxString:function(a){gpxString="<trk>";for(var b=0;b<a.getNumSegments();b++){var c=a.getSegment(b);gpxString+="<trkseg>";for(var d=0;d<c.getLength();d++){var e=c.getPoint(d);gpxString+='<trkpt lat="'+e.getLat()+'" lon="'+e.getLng()+'">';if(e.getElev())gpxString+="<ele>"+e.getElev()+"</ele>";
if(e.getDate())gpxString+="<time>"+e.getDate().getXsdString()+"</time>";gpxString+="</trkpt>"}gpxString+="</trkseg>"}gpxString+="</trk>";return gpxString},produceWaypointGpxString:function(a){gpxString='<wpt lat="'+a.getLat()+'" lon="'+a.getLng()+'">';if(a.getElev())gpxString+="<ele>"+a.getElev()+"</ele>";if(a.getName())gpxString+="<name>"+a.getName()+"</name>";if(a.getComment())gpxString+="<cmt>"+a.getComment()+"</cmt>";if(a.getDescription())gpxString+="<desc>"+a.getDescription()+"</desc>";if(a.getSymbol())gpxString+=
"<sym>"+a.getSymbol()+"</sym>";if(a.getAddress())gpxString+="<extensions><gpxx:WaypointExtension>"+a.getAddress()+"</gpxx:WaypointExtension></extensions>";if(a.getType())gpxString+="<type>"+a.getType()+"</type>";gpxString+="</wpt>";return gpxString},_tagValue:function(a,b){var c=a.getElementsByTagName(b);return c.length>0?c[0].childNodes[0].nodeValue:null},toString:function(){return"GpsDataFactory."}};if(PluginDetect.detectGarminCommunicatorPlugin())switch(BrowserDetect.browser){case "Explorer":document.write('<object id="GarminActiveXControl" style="WIDTH: 0px; HEIGHT: 0px; visible: hidden" height="0" width="0" classid="CLSID:099B5A62-DE20-48C6-BF9E-290A9D1D8CB5">&#160;</object>');break;case "Firefox":case "Mozilla":case "Safari":document.write('<div style="height:0px; width:0px;">');document.write('<object id="GarminNetscapePlugin" type="application/vnd-garmin.mygarmin" width="0" height="0">&#160;</object>');
document.write("</div>");break;default:document.write('<div style="height:0px; width:0px;"><object id="GarminActiveXControl" style="WIDTH: 0px; HEIGHT: 0px; visible: hidden" height="0" width="0" classid="CLSID:099B5A62-DE20-48C6-BF9E-290A9D1D8CB5">');document.write('\t<object id="GarminNetscapePlugin" type="application/vnd-garmin.mygarmin" width="0" height="0">&#160;</object>');document.write("</object></div>");break};if(Garmin==undefined)Garmin={};Garmin.PluginUtils=function(){};
Garmin.PluginUtils={initialize:function(){},parseDeviceXml:function(a,b){var c=a.getDevicesXml();c=Garmin.XmlConverter.toDocument(c).getElementsByTagName("Device");for(var d=[],e=c.length,g=0;g<e;g++){var i=c[g].getAttribute("DisplayName"),h=parseInt(c[g].getAttribute("Number")),f=null;if(b){f=a.getDeviceDescriptionXml(h);f=Garmin.XmlConverter.toDocument(f)}d.push(Garmin.PluginUtils._createDeviceFromXml(i,h,f))}return d},_createDeviceFromXml:function(a,b,c){a=new Garmin.Device(a,b);if(c){b=c.getElementsByTagName("PartNumber")[0].childNodes[0].nodeValue;
var d=c.getElementsByTagName("SoftwareVersion")[0].childNodes[0].nodeValue,e=c.getElementsByTagName("Description")[0].childNodes[0].nodeValue,g=c.getElementsByTagName("Id")[0].childNodes[0].nodeValue;a.setPartNumber(b);a.setSoftwareVersion(d);a.setDescription(e);a.setId(g);c=c.getElementsByTagName("MassStorageMode")[0].getElementsByTagName("DataType");b=c.length;for(d=0;d<b;d++){e=c[d].getElementsByTagName("Name")[0].childNodes[0].nodeValue;g=c[d].getElementsByTagName("FileExtension")[0].childNodes[0].nodeValue;
e=new Garmin.DeviceDataType(e,g);g=c[d].getElementsByTagName("File");for(var i=g.length,h=0;h<i;h++){var f=g[h].getElementsByTagName("Path"),j=g[h].getElementsByTagName("TransferDirection")[0].childNodes[0].nodeValue;if(j==Garmin.DeviceControl.TRANSFER_DIRECTIONS.read){e.setReadAccess(true);if(f.length>0){j=f[0].childNodes[0].nodeValue;e.setReadFilePath(j)}}else if(j==Garmin.DeviceControl.TRANSFER_DIRECTIONS.write){e.setWriteAccess(true);if(f.length>0){j=f[0].childNodes[0].nodeValue;e.setWriteFilePath(j)}}else if(j==
Garmin.DeviceControl.TRANSFER_DIRECTIONS.both){e.setReadAccess(true);e.setWriteAccess(true);if(f.length>0){j=f[0].childNodes[0].nodeValue;e.setReadFilePath(j);e.setWriteFilePath(j)}}if(f.length>0){j=f[0].childNodes[0].nodeValue;e.setFilePath(j)}f=g[h].getElementsByTagName("Identifier");f.length>0&&e.setIdentifier(f[0].childNodes[0].nodeValue)}a.addDeviceDataType(e)}}return a},isDeviceErrorXml:function(a){return(typeof a=="string"?a:a.name+": "+a.message).indexOf("<ErrorReport")>0},getDeviceErrorMessage:function(a){a=
typeof a=="string"?a:a.name+": "+a.message;var b=a.indexOf("<ErrorReport");if(b>0){var c=a.indexOf("</ErrorReport>")+14;a=a.substring(b,c)}c=Garmin.XmlConverter.toDocument(a);a=Garmin.PluginUtils._getElementValue(c,"Extra");b=Garmin.PluginUtils._getElementValue(c,"SourceFileName");c=Garmin.PluginUtils._getElementValue(c,"SourceFileLine");if(a)a=a;else{a="Plugin error: ";if(b)a+="source: "+b;if(c)a+=", line: "+c}return a},_getElementValue:function(a,b){var c=a.getElementsByTagName(b);return c&&c.length>
0?c[0].childNodes[0].nodeValue:null}};Garmin.GpiUtil=function(){};
Garmin.GpiUtil={buildMultipleDeviceDownloadsXML:function(a){if(a.length%2!=0)throw Error("buildMultipleDeviceDownloadsXML expects even sized array with matching source and destination pairs");for(var b='<?xml version="1.0" encoding="UTF-8"?>\n<DeviceDownload xmlns="http://www.garmin.com/xmlschemas/PluginAPI/v1"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://www.garmin.com/xmlschemas/PluginAPI/v1 http://www.garmin.com/xmlschemas/GarminPluginAPIV1.xsd">\n',c=0;c<
a.length;c+=2)b+=' <File Source="'+a[c]+'" Destination="'+a[c+1]+'" RegionId="46" />\n';b+="</DeviceDownload>";return b},buildDeviceDownloadXML:function(a,b){return Garmin.GpiUtil.buildMultipleDeviceDownloadsXML([a,b])},isDestinationValid:function(a){a=a.split("/");var b=a[a.length-1];a=b.length;b=Garmin.GpiUtil.cleanUpFilename(b);return a==b.length},cleanUpFilename:function(a){a=a;a=a.stripTags();a=a.replace(/&amp;/,"");a=a.replace(/[\x21-\x2F]/g,"");a=a.replace(/[\x5B-\x60]/g,"");a=a.replace(/[\x3A-\x40]/g,
"");return a=a.strip()}};

