
watcheeOrange="#ee7d13";watcheeColorSelf=watcheeOrange;watcheeBlue="#377CB1";watcheeDefaultIcon="watchee-point.png";if(typeof net=="undefined"||net==null){net=new Object();}
if(typeof net.watchee=="undefined"||net.watchee==null){net.watchee=new Object();}
net.watchee.checkInterface=function(theObject,theInterface){for(var member in theInterface){if((typeof theObject[member]!=typeof theInterface[member])){alert("Object failed to implement interface member "+member);return false;}}
return true;}
net.watchee.I_PoiMapManager=new Object();net.watchee.I_PoiMapManager.watchee=null;net.watchee.I_PoiMapManager.addPoi=function(gpsData,drawingAttributes){if(!(gpsData instanceof net.watchee.GPSData)){alert("Wrong gpsData '"+gpsData+"' argument of net.watchee.I_PoiMapManager.addPoi");return false;}
if(!(drawingAttributes instanceof net.watchee.DrawingAttributes)){alert("Wrong drawingAttributes '"+drawingAttributes+"' argument of net.watchee.I_PoiMapManager.addPoi");return false;}
return true;}
net.watchee.I_PoiMapManager.highlightPoi=function(gpsData,drawingAttributes){if(!(gpsData instanceof net.watchee.GPSData)){alert("Wrong gpsData '"+gpsData+"' argument of net.watchee.I_PoiMapManager.addPoi");return false;}
var drawingAttributes=drawingAttributes||null;if(drawingAttributes!=null&&!(drawingAttributes instanceof net.watchee.DrawingAttributes)){alert("Wrong drawingAttributes '"+drawingAttributes+"' argument of net.watchee.I_PoiMapManager.highlightPoi");return false;}
return true;}
net.watchee.I_PoiMapManager.removeHighlightPoi=function(){}
net.watchee.I_PoiMapManager.removePoi=function(locationId,attributes){return true;}
net.watchee.I_PoiMapManager.centerPois=function(){return true;}
net.watchee.DrawingAttributes=function(){}
net.watchee.DrawingAttributes.prototype.getGpsData=function(){if(this.gpsData===undefined)
return null;return this.gpsData;}
net.watchee.DrawingAttributes.prototype.getOnMarkerClickCb=function(){if(this.onMarkerClickCb===undefined)
return null;return this.onMarkerClickCb;}
net.watchee.DrawingAttributes.prototype.getOnMarkerClickThisP=function(){if(this.onMarkerClickThisP===undefined)
return null;return this.onMarkerClickThisP;}
net.watchee.DrawingAttributes.prototype.getOnMarkerClickReturnObj=function(){if(this.onMarkerClickReturnObj===undefined)
return null;return this.onMarkerClickReturnObj;}
net.watchee.DrawingAttributes.prototype.getZoomTo=function(){if(this.zoomTo===undefined)
return null;return this.zoomTo;}
net.watchee.DrawingAttributes.prototype.getCenter=function(){if(this.center===undefined)
return false;return this.center;}
net.watchee.DrawingAttributes.prototype.getLabelTop=function(){if(this.labelTop===undefined)
return null;return this.labelTop;}
net.watchee.DrawingAttributes.prototype.getIconUrl=function(){if(this.iconUrl===undefined)
return null;return this.iconUrl;}
net.watchee.DrawingAttributes.prototype.getRadiusPixel=function(){if(this.radiusPixel===undefined)
return 24;return this.radiusPixel;}
net.watchee.util=new Object();net.watchee.STATIC_ICON_URL_PATH="images/marker/";net.watchee.DYNAMIC_ICON_URL_PATH="/watchee/marker/";var defaultXmlBlasterSecurityPlugin="watchee";var watcheeServiceId="watchee.service";net.watchee.TOPICID_ONLINESTATUS="__sys__OnlineStatus";net.watchee.TOPICID_SERVICE_REQUEST="watchee.service";net.watchee.TOPICID_SERVICE_RESPONSE="watchee.service.response";net.watchee.TOPICID_SERVICE_ACCOUNT_WRITE_REQUEST=net.watchee.TOPICID_SERVICE_REQUEST+".account.write";net.watchee.TOPICID_SERVICE_ACCOUNT_READ_REQUEST=net.watchee.TOPICID_SERVICE_REQUEST+".account.read";net.watchee.TOPICID_SERVICE_BUDDY_WRITE_REQUEST=net.watchee.TOPICID_SERVICE_REQUEST+".buddy.write";net.watchee.TOPICID_SERVICE_BUDDY_READ_REQUEST=net.watchee.TOPICID_SERVICE_REQUEST+".buddy.read";net.watchee.TOPICID_SERVICE_REPORT_READ_REQUEST=net.watchee.TOPICID_SERVICE_REQUEST+".report.read";xbProperties=new XbProperties();xbProperties.setDefaultProp("mapSegmentWidth",3);if(org.xmlBlaster.util.isIE6){xbProperties.setDefaultProp("maxGpsDataPerTrack",300);xbProperties.setDefaultProp("maxGpsDataPerTrackCurrent",300);}
else{xbProperties.setDefaultProp("maxGpsDataPerTrack",5000);xbProperties.setDefaultProp("maxGpsDataPerTrackCurrent",5000);}
xbProperties.setDefaultProp("numIconsToShowCurrent",1);xbProperties.setDefaultProp("numIconsToShow",xbProperties.getDefaultInt("maxGpsDataPerTrack",600));xbProperties.setDefaultProp("numSegmentsToShowCurrent",50);xbProperties.setDefaultProp("numSegmentsToShow",xbProperties.getDefaultInt("maxGpsDataPerTrack",50));net.watchee.util.log=log4javascript.getLogger("net.watchee");log4javascript.setEnabled(false);log4javascript.setShowStackTraces(true);net.watchee.util.setLogAppenderContainer=function(logContainerElement,width,height){var domElement=document.getElementById(logContainerElement);org.xmlBlaster.util.inPageAppender=new log4javascript.InPageAppender(domElement);with(org.xmlBlaster.util.inPageAppender){setThreshold(log4javascript.Level.DEBUG);if(org.xmlBlaster.util.isDefined(width))
setWidth(width);if(org.xmlBlaster.util.isDefined(height))
setHeight(height);}
org.xmlBlaster.util.log.removeAllAppenders();org.xmlBlaster.util.log.addAppender(org.xmlBlaster.util.inPageAppender);net.watchee.util.log.removeAllAppenders();net.watchee.util.log.addAppender(org.xmlBlaster.util.inPageAppender);log4javascript.setEnabled(true);}
ME2="watchee.js: ";net.watchee.jsonParse=function(value){try{if(typeof JSON=="undefined"){var obj=eval('('+value+')');return obj;}
else{obj=JSON.parse(value);return obj;}}
catch(e){var str=e;if(typeof e.description!="undefined")
str=e.description;alert("Error during JSON parse: "+str);return null;}}
net.watchee.getReverseGeocodeGoogle=function(lat,lon,callbackFp,callbackThisP){var lat=lat||47.78;var lon=lon||9.18;var callbackFp=callbackFp||null;if(!net.watchee.googleGeocoder)
net.watchee.googleGeocoder=new google.maps.Geocoder();var latlng=new google.maps.LatLng(lat,lon);net.watchee.googleGeocoder.geocode({'latLng':latlng},function(results,status){if(status==google.maps.GeocoderStatus.OK){if(results[0]){var result=results[0];if(callbackFp!=null){callbackFp.call(callbackThisP,result);}
else{alert("net.watchee.getReverseGeocodeGoogle: "+lat+","+lon+": "+result);}}else{alert("net.watchee.getReverseGeocodeGoogle: No results found");return null;}}else{alert("net.watchee.getReverseGeocodeGoogle: Geocoder failed due to: "+status);return null;}});}
net.watchee.getIconBlobBase64=function(url){var usePhp=true;if(usePhp){url="tobase64.php?filename="+url;var base64=net.watchee.getSyncHttpRequest(url);return base64;}
else{var blob=net.watchee.getSyncHttpRequest(url);return org.xmlBlaster.util.Base64.encode(blob);}}
net.watchee.getSyncHttpRequest=function(url){var myXmlHttp=org.xmlBlaster.util.createXmlHttpRequest();var callType="GET";var enc=url;var async=false;myXmlHttp.open(callType,url,async);var timeoutMillis=5000;myXmlHttp.timeout=timeoutMillis;myXmlHttp.ontimeout=function(){net.watchee.util.log.error("net.watchee.getReverseGeocode: timed out natively: "+myXmlHttp.timeout);};var xmlReqTimeout=setTimeout(function(){myXmlHttp.abort();net.watchee.util.log.error("net.watchee.getReverseGeocode: timed out by own handler: "+timeoutMillis);},timeoutMillis);var params="";try{myXmlHttp.send(params);if(xmlReqTimeout!=null){clearTimeout(xmlReqTimeout);}}
catch(ex){if(xmlReqTimeout!=null){clearTimeout(xmlReqTimeout);}
net.watchee.util.log.error("net.watchee.getReverseGeocode: No Geocoding possible: "+ex);return null;}
if(myXmlHttp.status==200){var response=myXmlHttp.responseText;return response;}
else{return null;}}
net.watchee.getReverseGeocode=function(lat,lon){try{var lat=lat||47.78;var lon=lon||9.18;var myXmlHttp=org.xmlBlaster.util.createXmlHttpRequest();var callType="GET";var url="http://open.mapquestapi.com/nominatim/v1/reverse?format=json&email=support@netwake.com&zoom=18&lat="+lat+"&lon="+lon;var enc=url;var async=false;myXmlHttp.open(callType,url,async);var timeoutMillis=5000;myXmlHttp.timeout=timeoutMillis;myXmlHttp.ontimeout=function(){net.watchee.util.log.error("net.watchee.getReverseGeocode: timed out natively: "+myXmlHttp.timeout);};var xmlReqTimeout=setTimeout(function(){myXmlHttp.abort();net.watchee.util.log.error("net.watchee.getReverseGeocode: timed out by own handler: "+timeoutMillis);},timeoutMillis);var params="";try{myXmlHttp.send(params);if(xmlReqTimeout!=null){clearTimeout(xmlReqTimeout);}}
catch(ex){if(xmlReqTimeout!=null){clearTimeout(xmlReqTimeout);}
net.watchee.util.log.error("net.watchee.getReverseGeocode: No Geocoding possible: "+ex);return null;}
if(myXmlHttp.status==200){var addressJson=myXmlHttp.responseText;if(addressJson==null)
return null;var addreesObj=net.watchee.jsonParse(addressJson);return addreesObj;}
else{return null;}}catch(event){var event=event||null;net.watchee.util.log.error("net.watchee.getReverseGeocode: exception failed (cross domain?): "+event);return null;}}
net.watchee.getReverseGeocodeFromGpsData=function(gpsData){var gpsData=gpsData||null;if(gpsData!=null&&gpsData.hasLatLonNotNull()){var lat=gpsData.latitudeDecimal();var lon=gpsData.longitudeDecimal();var addressObj=net.watchee.getReverseGeocode(lat,lon);return addressObj;}
return null;}
net.watchee.getReverseGeocodeStrFromGpsData=function(gpsData,separator){var separator=separator||",";var addressObj=net.watchee.getReverseGeocodeFromGpsData(gpsData);if(addressObj!=null&&addressObj.address!==undefined){var road=addressObj.address.road||"---";var suburb=addressObj.address.suburb||null;var city_district=addressObj.address.city_district||null;var hamlet=addressObj.address.hamlet||null;var postcode=addressObj.address.postcode||"";var village=addressObj.address.village||"";var city=addressObj.address.city||null;var county=addressObj.address.county||null;var state=addressObj.address.state||null;var address=road+separator+postcode+" "+village;if(city==null){city="";if(suburb!=null){city+=suburb;}
if(county!=null){city+=" "+county;}
if(state!=null){city+=" "+state;}}
if(city!=null&&city!=village){address+=separator+city;}
return address;}
return"";}
net.watchee.toWidthHeight=function(str,defaultWidth,defaultHeight){if(!org.xmlBlaster.util.isFilled(str))
return{width:defaultWidth,height:defaultHeight};str=org.xmlBlaster.util.trim(str);if(str.length<1)
return{width:defaultWidth,height:defaultHeight};var i=str.indexOf("x");if(i==-1)
return{width:defaultWidth,height:defaultHeight};try{var w=new Number(str.substring(0,i)).valueOf();var h=new Number(str.substring(i+1)).valueOf();if(isNaN(w)||isNaN(h))
return{width:defaultWidth,height:defaultHeight};return{width:w,height:h};}catch(e){return{width:defaultWidth,height:defaultHeight};}}
net.watchee.toPictureInfo=function(watchee,gpsData){var locationPictureId=gpsData.getPictureId("");var mimeType=gpsData.getInfo("pt","image/jpeg");var photoMarkup="";if(locationPictureId.length>0){var url=watchee.urlBase+"?ActionType=request&topicId=watchee.service&task="+org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETRAWPHOTO+"&data="+locationPictureId;var size=net.watchee.toWidthHeight(gpsData.getInfo("ps",""),160,120);return{url:url,width:size.width,height:size.height,pictureId:locationPictureId,mimeType:mimeType};}
return null;}
net.watchee.toPictureUrl=function(watchee,pictureId,mimeType){var ext=net.watchee.mimeTypeToExtension(mimeType);if(ext!=null&&ext.length>0){var url=watchee.urlBase+"/dummy."+ext+"?ActionType=request&topicId=watchee.service&task="+org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETRAWPHOTO+"&data="+pictureId+"&resultMime="+mimeType;return url;}
else{var url=watchee.urlBase+"?ActionType=request&topicId=watchee.service&task="+org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETRAWPHOTO+"&data="+pictureId+"&resultMime="+mimeType;return url;}}
net.watchee.checkNativeAudioSupport=function(){var info="canPlay: ";var nativeSupport=true;var mimeType="audio/x-wav";var audioTagSupport=!!(document.createElement('audio').canPlayType);if(audioTagSupport){var myAudio=document.createElement('audio');if(myAudio.canPlayType){var canPlayMp3=!!myAudio.canPlayType&&""!=myAudio.canPlayType('audio/mpeg');var canPlayOgg=!!myAudio.canPlayType&&""!=myAudio.canPlayType('audio/ogg; codecs="vorbis"');var canPlayWav=!!myAudio.canPlayType&&""!=myAudio.canPlayType('audio/x-wav');if(canPlayMp3||canPlayOgg||canPlayWav){if(canPlayMp3)info+="audio/mpeg ";if(canPlayOgg)info+="audio/ogg ";if(canPlayWav)info+="audio/x-wav";}else{info+="nothing";}
if(canPlayOgg){mimeType="audio/ogg";}else if(canPlayMp3){mimeType="audio/mp3";}else if(canPlayWav){mimeType="audio/x-wav";}else{info="_noAudioTypeSupport";nativeSupport=false;}
if(canPlayWav&&org.xmlBlaster.util.isFF3){mimeType="audio/x-wav";}}else{info="_noAudioCanPlayType";nativeSupport=false;}}else{info="_noAudioTagSupport";nativeSupport=false;}
return{nativeSupport:nativeSupport,mimeType:mimeType,info:info}}
net.watchee.toAudioUrl=function(watchee,audioId,mimeType){var ext=net.watchee.mimeTypeToExtension(mimeType);if(ext!=null&&ext.length>0){var url=watchee.urlBase+"/dummy."+ext+"?ActionType=request&topicId=watchee.service&task="+org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETRAWAUDIO+"&data="+audioId+"&resultMime="+mimeType;return url;}
else{var url=watchee.urlBase+"?ActionType=request&topicId=watchee.service&task="+org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETRAWAUDIO+"&data="+audioId+"&resultMime="+mimeType;return url;}}
net.watchee.mimeTypeToExtension=function(mimeType){var mimeType=mimeType||null;if(mimeType==null)
return null;mimeType=mimeType.toLowerCase();var toks=mimeType.split("/");if(toks.length==0)
return mimeType;else if(toks.length==1){var ext=toks[0];if(ext==null)
return mimeType;if(ext.indexOf("x-")==0&&ext.length>2)
ext=ext.substring(2);return ext;}
var ext=toks[1];var i=ext.indexOf(" ");if(i!=-1)
ext=ext.substring(0,i);if(ext.startsWith("x-")&&ext.length>2)
ext=ext.substring(2);return ext;}
net.watchee.GroupIdInfo=function(propertyCollections,groupId){this.propertyCollections=propertyCollections;this.groupId=groupId||"RUND UM";this.groupSubIdMap=new org.xmlBlaster.util.Hashtable();var array=this.propertyCollections.getPropertyCollections();for(var ii=0,jj=array.length;ii<jj;ii++){var pc=array[ii];if(pc.getStr("groupId",null)!=null)
this.groupId=pc.getStr("groupId",null);var identifierFields=pc.getStr("identifierFields","aliasName");var cols=identifierFields.split(";");for(var i=0,l=cols.length;i<l;i++){var col=cols[i];var colValue=org.xmlBlaster.util.trim(pc.getStr(col,""));if(colValue.length==0){continue;}
colValue=org.xmlBlaster.util.replaceAllTokens(colValue.toUpperCase()," ","");this.groupSubIdMap.put(colValue,pc);}}}
net.watchee.GroupIdInfo.prototype.getGroupSubIdArray=function(){var array=this.propertyCollections.getPropertyCollections();return array;}
net.watchee.GroupIdInfo.prototype.countGroupSubIds=function(){return this.propertyCollections.size();}
net.watchee.GroupIdInfo.prototype.getGroupId=function(){return this.groupId;}
net.watchee.GroupIdInfo.prototype.getGroupSubIdInfo=function(groupSubId){var groupSubId=groupSubId||null;if(groupSubId==null||groupSubId.length==0){return net.watchee.GroupIdInfo.getDefault(groupSubId);}
var pc=this.getGroupSubIdInfoOrNull(groupSubId);if(pc==null){return net.watchee.GroupIdInfo.getDefault(groupSubId);}}
net.watchee.GroupIdInfo.prototype.getGroupSubIdInfoOrNull=function(groupSubId){var groupSubId=groupSubId||"";groupSubId=org.xmlBlaster.util.trim(groupSubId);groupSubId=org.xmlBlaster.util.replaceAllTokens(groupSubId.toUpperCase()," ","");var pc=this.groupSubIdMap.get(groupSubId);if(pc==null){return null;}
return pc;}
net.watchee.GroupIdInfo.getDefault=function(groupSubId){var groupSubId=groupSubId||"";var pc=new net.watchee.PropertyCollection("groupSubId");pc.addKeyValue("idnr","-1");pc.addKeyValue("klassen_folge","");pc.addKeyValue("klasse","");pc.addKeyValue("bootstyp","");pc.addKeyValue("yardfaktor","");pc.addKeyValue("schiffname","");pc.addKeyValue("zulnr","");pc.addKeyValue("segelnr","");pc.addKeyValue("lastName","");pc.addKeyValue("firstName","");pc.addKeyValue("email","");pc.addKeyValue("phoneNumber","");pc.addKeyValue("club","");pc.addKeyValue("groupSubId",groupSubId);pc.addKeyValue("aliasName",groupSubId);pc.addKeyValue("isDefault",true);return pc;}
net.watchee.TrackingRate=function(){this.sendIntervalAtMinSpeed=120;this.sendIntervalAtMaxSpeed=30;this.speedForMaxInterval=80;this.sendIntervalHeartBeat=240;this.switchIntervalHeartBeat=-1;this.minSpeedForHeadingChangeThreshold=4;this.headingChangeThreshold=30;this.switchHeadingChangeThreshold=-1;this.timerStartCmd="void";this.timerStopCmd="void";this.distanceMeter=500;this.switchDistanceMeter=-1;this.stopAndGoDelaySec=4;this.switchStopAndGo=-1;this.switchSpeed=-1;this.countLocations=0;this.onlyWithValidGps=true;this.switchedOn=true;}
net.watchee.TrackingRate.prototype.isSwitchedOn=function(){return this.switchedOn;}
net.watchee.TrackingRate.prototype.setSwitchedOn=function(isOn){this.switchedOn=isOn;}
net.watchee.TrackingRate.prototype.__toSwitch=function(value,defaultValue){if(value==undefined||value==null){return-1;}
else if(org.xmlBlaster.util.isBoolean(value)){return value?1:0;}
else{value=org.xmlBlaster.util.toNumber(value,defaultValue);if(value>0)
return 1;else if(value<0)
return-1;else
return 0;}}
net.watchee.TrackingRate.prototype.setDistanceMeter=function(distanceMeter){this.distanceMeter=org.xmlBlaster.util.toNumber(distanceMeter,this.distanceMeter);}
net.watchee.TrackingRate.prototype.setSwitchDistanceMeter=function(switchDistanceMeter){this.switchDistanceMeter=this.__toSwitch(switchDistanceMeter,this.switchDistanceMeter);}
net.watchee.TrackingRate.prototype.useSwitchDistanceMeter=function(){return(this.switchDistanceMeter>0||this.switchDistanceMeter<0&&this.distanceMeter>0);}
net.watchee.TrackingRate.prototype.setSendIntervalHeartBeat=function(sendIntervalHeartBeat){this.sendIntervalHeartBeat=org.xmlBlaster.util.toNumber(sendIntervalHeartBeat,this.sendIntervalHeartBeat);}
net.watchee.TrackingRate.prototype.setSwitchIntervalHeartBeat=function(switchIntervalHeartBeat){this.switchIntervalHeartBeat=this.__toSwitch(switchIntervalHeartBeat,this.switchIntervalHeartBeat);}
net.watchee.TrackingRate.prototype.useSwitchIntervalHeartBeat=function(){return(this.switchIntervalHeartBeat>0||this.switchIntervalHeartBeat<0&&this.sendIntervalHeartBeat>0);}
net.watchee.TrackingRate.prototype.setHeadingChangeThreshold=function(headingChangeThreshold){this.headingChangeThreshold=org.xmlBlaster.util.toNumber(headingChangeThreshold,this.headingChangeThreshold);if(this.headingChangeThreshold<10)
this.headingChangeThreshold=10;}
net.watchee.TrackingRate.prototype.setSwitchHeadingChangeThreshold=function(switchHeadingChangeThreshold){this.switchHeadingChangeThreshold=this.__toSwitch(switchHeadingChangeThreshold,this.switchHeadingChangeThreshold);}
net.watchee.TrackingRate.prototype.useSwitchHeadingChangeThreshold=function(){return(this.switchHeadingChangeThreshold>0||this.switchHeadingChangeThreshold<0&&this.headingChangeThreshold>0);}
net.watchee.TrackingRate.prototype.useSwitchSpeed=function(){return(this.switchSpeed!=0&&this.speedForMaxInterval>0);}
net.watchee.TrackingRate.prototype.useSwitchStopAndGo=function(){return(this.switchStopAndGo!=0&&this.stopAndGoDelaySec>0);}
net.watchee.TrackingRate.prototype.hasStartCmd=function(){return("void"!=this.timerStartCmd);}
net.watchee.TrackingRate.prototype.hasStopCmd=function(){return("void"!=this.timerStopCmd);}
net.watchee.TrackingRate.prototype.toKeyValue=function(){var hash=new org.xmlBlaster.util.Hashtable();if(this.switchSpeed!=-1)
hash.put("Strv",this.useSwitchSpeed()?"1":"0");if(this.switchSpeed==1||this.sendIntervalAtMinSpeed!=120)
hash.put("Vtrmin",""+this.sendIntervalAtMinSpeed);if(this.switchSpeed==1||this.sendIntervalAtMaxSpeed!=30)
hash.put("Vtrmax",""+this.sendIntervalAtMaxSpeed);if(this.switchSpeed==1||this.speedForMaxInterval!=80)
hash.put("Vtrvmax",""+this.speedForMaxInterval);if(this.switchIntervalHeartBeat!=-1)
hash.put("Strt",this.useSwitchIntervalHeartBeat()?"1":"0");if(this.switchIntervalHeartBeat==1||this.sendIntervalHeartBeat!=240)
hash.put("Vtrt",""+this.sendIntervalHeartBeat);if(this.switchHeadingChangeThreshold==1||this.minSpeedForHeadingChangeThreshold!=4)
hash.put("Vtrcvmin",""+this.minSpeedForHeadingChangeThreshold);if(this.switchHeadingChangeThreshold==1||this.headingChangeThreshold!=30)
hash.put("Vtrc",""+this.headingChangeThreshold);if(this.switchHeadingChangeThreshold!=-1)
hash.put("Strc",this.useSwitchHeadingChangeThreshold()?"1":"0");if(this.switchDistanceMeter==1||this.distanceMeter!=500)
hash.put("Vtrd",""+this.distanceMeter);if(this.switchDistanceMeter!=-1)
hash.put("Strd",this.useSwitchDistanceMeter()?"1":"0");if(this.switchStopAndGo==1||this.stopAndGoDelaySec!=4)
hash.put("Vtrs",""+this.stopAndGoDelaySec);if(this.switchStopAndGo!=-1)
hash.put("Strs",this.useSwitchStopAndGo()?"1":"0");if(this.countLocations>0)
hash.put("Vtrn",""+this.countLocations);if(this.onlyWithValidGps!=true)
hash.put("Vtrg",this.onlyWithValidGps?"1":"0");if(this.hasStartCmd())
hash.put("Vtrstart",this.timerStartCmd);if(this.hasStopCmd())
hash.put("Vtrstop",this.timerStopCmd);hash.put("Str",this.switchedOn?"1":"0");return hash;}
net.watchee.TrackingRate.prototype.toOldCSV=function(){var sb="";sb+=this.sendIntervalAtMinSpeed;sb+=",";sb+=this.sendIntervalAtMaxSpeed;sb+=",";sb+=this.speedForMaxInterval;sb+=",";sb+=this.sendIntervalHeartBeat;sb+=",";sb+=this.minSpeedForHeadingChangeThreshold;sb+=",";sb+=this.headingChangeThreshold;sb+=",";sb+=this.distanceMeter;sb+=",";sb+=this.stopAndGoDelaySec;if(this.hasStartCmd()||this.hasStopCmd()){sb+=",";sb+=this.timerStartCmd;sb+=",";sb+=this.timerStopCmd;}
return sb;}
net.watchee.TrackingRate.prototype.toCSV=function(){return this.toKeyValue().toCSV();}
net.watchee.TrackingRate.parseOldOrNew=function(trackingRateStr){if(!org.xmlBlaster.util.isDefined(trackingRateStr))
trackingRateStr="";var trackingRateStruct=new net.watchee.TrackingRate();if(trackingRateStr.indexOf("=")!=-1){return net.watchee.TrackingRate.parseKeyValue(trackingRateStr);}
else{return net.watchee.TrackingRate.parseOldStyle(trackingRateStr);}}
net.watchee.TrackingRate.parseKeyValue=function(trackingRateStr){if(!org.xmlBlaster.util.isDefined(trackingRateStr))
trackingRateStr="";var hash=org.xmlBlaster.util.Hashtable.parseCSV(trackingRateStr);return net.watchee.TrackingRate.parseHashtable(hash);}
net.watchee.TrackingRate.parseHashtable=function(hash){var trackingRateStruct=new net.watchee.TrackingRate();if(!org.xmlBlaster.util.isDefined(hash))
return trackingRateStruct;trackingRateStruct.sendIntervalAtMinSpeed=hash.getNumber("Vtrmin",trackingRateStruct.sendIntervalAtMinSpeed);trackingRateStruct.sendIntervalAtMaxSpeed=hash.getNumber("Vtrmax",trackingRateStruct.sendIntervalAtMaxSpeed);trackingRateStruct.speedForMaxInterval=hash.getNumber("Vtrvmax",trackingRateStruct.speedForMaxInterval);trackingRateStruct.sendIntervalHeartBeat=hash.getNumber("Vtrt",trackingRateStruct.sendIntervalHeartBeat);trackingRateStruct.switchIntervalHeartBeat=hash.getNumber("Strt",trackingRateStruct.switchIntervalHeartBeat);trackingRateStruct.minSpeedForHeadingChangeThreshold=hash.getNumber("Vtrcvmin",trackingRateStruct.minSpeedForHeadingChangeThreshold);trackingRateStruct.headingChangeThreshold=hash.getNumber("Vtrc",trackingRateStruct.headingChangeThreshold);trackingRateStruct.switchHeadingChangeThreshold=hash.getNumber("Strc",trackingRateStruct.switchHeadingChangeThreshold);trackingRateStruct.timerStartCmd=hash.get("Vtrstart",trackingRateStruct.timerStartCmd);trackingRateStruct.timerStopCmd=hash.get("Vtrstop",trackingRateStruct.timerStopCmd);trackingRateStruct.distanceMeter=hash.getNumber("Vtrd",trackingRateStruct.distanceMeter);trackingRateStruct.switchDistanceMeter=hash.getNumber("Strd",trackingRateStruct.switchDistanceMeter);trackingRateStruct.switchSpeed=hash.getNumber("Strv",trackingRateStruct.switchSpeed);trackingRateStruct.countLocations=hash.getNumber("Vtrn",trackingRateStruct.countLocations);trackingRateStruct.onlyWithValidGps=hash.getBoolean("Vtrg",trackingRateStruct.onlyWithValidGps);trackingRateStruct.switchedOn=hash.getBoolean("Str",trackingRateStruct.switchedOn);return trackingRateStruct;}
net.watchee.TrackingRate.parseOldStyle=function(trackingRateStr){if(!org.xmlBlaster.util.isDefined(trackingRateStr))
trackingRateStr="";var trackingRateStruct=new net.watchee.TrackingRate();var arr=(trackingRateStr=="")?[]:trackingRateStr.split(',');trackingRateStruct.sendIntervalAtMinSpeed=(arr.length>0)?org.xmlBlaster.util.toNumber(arr[0],trackingRateStruct.sendIntervalAtMinSpeed):trackingRateStruct.sendIntervalAtMinSpeed;trackingRateStruct.sendIntervalAtMaxSpeed=(arr.length>1)?org.xmlBlaster.util.toNumber(arr[1],trackingRateStruct.sendIntervalAtMaxSpeed):trackingRateStruct.sendIntervalAtMaxSpeed;trackingRateStruct.speedForMaxInterval=(arr.length>2)?org.xmlBlaster.util.toNumber(arr[2],trackingRateStruct.speedForMaxInterval):trackingRateStruct.speedForMaxInterval;trackingRateStruct.sendIntervalHeartBeat=(arr.length>3)?org.xmlBlaster.util.toNumber(arr[3],trackingRateStruct.sendIntervalHeartBeat):trackingRateStruct.sendIntervalHeartBeat;trackingRateStruct.minSpeedForHeadingChangeThreshold=(arr.length>4)?org.xmlBlaster.util.toNumber(arr[4],trackingRateStruct.minSpeedForHeadingChangeThreshold):trackingRateStruct.minSpeedForHeadingChangeThreshold;trackingRateStruct.headingChangeThreshold=(arr.length>5)?org.xmlBlaster.util.toNumber(arr[5],trackingRateStruct.headingChangeThreshold):trackingRateStruct.headingChangeThreshold;trackingRateStruct.distanceMeter=(arr.length>6)?org.xmlBlaster.util.toNumber(arr[6],trackingRateStruct.distanceMeter):trackingRateStruct.distanceMeter;trackingRateStruct.stopAndGoDelaySec=(arr.length>7)?org.xmlBlaster.util.toNumber(arr[7],trackingRateStruct.stopAndGoDelaySec):trackingRateStruct.stopAndGoDelaySec;trackingRateStruct.timerStartCmd=(arr.length>8)?arr[8]:"void";trackingRateStruct.timerStopCmd=(arr.length>9)?arr[9]:"void";return trackingRateStruct;}
org.xmlBlaster.util.PropTO.OID_DEVICE_PREFIX="device.";org.xmlBlaster.util.PropTO.OID_NMEA_POSTFIX=".nmea";org.xmlBlaster.util.PropTO.VALUE_SERVICE_ACCOUNT="account";org.xmlBlaster.util.PropTO.VALUE_SERVICE_BUDDY="buddy";org.xmlBlaster.util.PropTO.VALUE_SERVICE_TRACK="track";org.xmlBlaster.util.PropTO.VALUE_SERVICE_GEOFENCE="geofence";org.xmlBlaster.util.PropTO.VALUE_SERVICE_ALARM="alarm";org.xmlBlaster.util.PropTO.VALUE_SERVICE_RULE="rule";org.xmlBlaster.util.PropTO.VALUE_SERVICE_REPLICATION="replication";org.xmlBlaster.util.PropTO.VALUE_SERVICE_REPORT="report";org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_PREFIX="application/watchee.service";org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_PROPERTYCOLLECTION=org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_PREFIX+".pc";org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_PROPERTYCOLLECTIONCOLLECTION=org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_PREFIX+".pcc";org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_CSV=org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_PREFIX+".csv";org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_ACCOUNT=org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_PREFIX+".account";org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_BUDDY_PREFIX=org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_PREFIX+".buddy";org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_BUDDYLIST=org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_BUDDY_PREFIX+".buddylist";org.xmlBlaster.util.PropTO.VALUE_RESULTMIME_EXCEPTION="application/watchee.service.exception";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETACCOUNT="getAccount";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETACCOUNTLOGINNAMES="getAccountLoginNames";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETACCOUNTDEVICEIMPORTANTFIELDS="getAccountDeviceImportantFields";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_REMOVEACCOUNT="removeAccount";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETACCOUNTPROPERTY="getAccountProperty";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GET_POI_INPUTCONFIG="getPoiInputConfig";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_CHANGEACCOUNTPROPERTY="changeAccountProperty";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_CHANGEPASSWORD="changePassword";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_CHANGEACCOUNT="changeAccount";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETFRIENDOF="getFriendOf";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETBUDDIES="getBuddies";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_ONLINESTATUS="onlineStatus";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_CREATEREPORT="createReport";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_ADDDEVICEMAPPING="addDeviceMapping";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETDEVICEMAPPING="getDeviceMapping";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_REMOVEDEVICEMAPPING="removeDeviceMapping";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_ALARMEVENT="alarmEvent";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_ADDBUDDIES="addBuddies";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_NEWTFRIENDOF="newFriendOf";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_REMOVEBUDDIES="removeBuddies";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETMYPERMISSIONS="getMyPermissions";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETPERMISSIONSTEMPLATES="getPermissionTemplates";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_ADDACCOUNT="addAccount";org.xmlBlaster.util.PropTO.VALUE_BUDDYADD="application/watchee-service-buddy-buddyadd";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_ADDLOCATION="addLocation";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_CHANGELOCATIONS="changeLocations";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_REMOVELOCATIONS="removeLocations";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETTRACKS="getTracks";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETLOCATIONS="getLocations";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETTRACK="getTrack";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_REMOVETRACK="removeTrack";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETRAWPHOTO="getRawPhoto";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETRAWAUDIO="getRawAudio";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETRULES="getRules";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_ADDRULE="addRule";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_REMOVERULE="removeRule";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETGEOFENCES="getGeofences";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_ADDGEOFENCE="addGeofence";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_REMOVEGEOFENCE="removeGeofence";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETALARMS="getAlarms";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETCOUNTALARMSOFTYPESINCE="getCountAlarmsOfTypeSince";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_ADDALARM="addAlarm";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_CONFIRMALARM="confirmAlarm";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_REMOVEALARM="removeAlarm";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETCURRENTLOCATION="getCurrentLocation";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_STARTREPLICATION="startReplication";org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_GETREPLICATIONINFO="getReplicationInfo";net.watchee.PC_ACTION="_action";net.watchee.PC_ACTION_SET="set";net.watchee.PC_ACTION_ADD="add";net.watchee.PC_ACTION_REMOVE="remove";net.watchee.getHexaColor=function(colorName,withPrefix){var withPrefix=org.xmlBlaster.util.toBoolean(withPrefix,true);if(withPrefix&&colorName.indexOf("#")!=0)
colorName="#"+colorName;if(!withPrefix&&colorName.indexOf("#")==0)
colorName=colorName.substring(1);return colorName;}
net.watchee.Coordinate=function(lng,lat,height){this.lng=lng||0.0;this.lat=lat||0.0;this.height=height||0.0;this.getLng=function(){return this.lng;}
this.getLat=function(){return this.lat;}
this.getLngEW=function(){var postfix=this.lng>=0.0?"E":"W";return""+Math.abs(this.lng)+postfix;}
this.getLatNS=function(){var postfix=this.lat>=0.0?"N":"S";return""+Math.abs(this.lat)+postfix;}
this.getHeight=function(){return this.height;}
this.toKmlLngLatStr=function(){return net.watchee.Coordinate.round(this.lng)+","+net.watchee.Coordinate.round(this.lat);}
this.toKmlStr=function(){var result=this.toKmlLngLatStr();if(this.height!=0.0)
result+=","+net.watchee.Coordinate.round(this.height,2);return result;}}
net.watchee.Coordinate.round=function(num,decimalDigits){var decimalDigits=decimalDigits||6;var ROUND=Math.pow(10,decimalDigits);return Math.round(num*ROUND)/ROUND;}
net.watchee.Coordinate.prototype.distanceKmTo=function(second){return getDistanceKmHaversine(this.getLat(),this.getLng(),second.getLat(),second.getLng());}
net.watchee.toRad=function(deg){return deg*Math.PI/180;}
net.watchee.Coordinate.getDistanceKmHaversine=function(lat1,lon1,lat2,lon2){var R=6371;var dLat=net.watchee.toRad(lat2-lat1);var dLon=net.watchee.toRad(lon2-lon1);var a=Math.sin(dLat/2)*Math.sin(dLat/2)+
Math.cos(net.watchee.toRad(lat1))*Math.cos(net.watchee.toRad(lat2))*Math.sin(dLon/2)*Math.sin(dLon/2);var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));var d=R*c;return d;}
net.watchee.Coordinates=function(){this.coordinates=[];this.append=function(coordinate){return this.coordinates.push(coordinate);}
this.toKmlStr=function(){var str="";var first=true;for(var i=0,l=this.coordinates.length;i<l;i++){var coordinate=this.coordinates[i];if(!first)str+=" ";str+=coordinate.toKmlStr();first=false;}
return str;}
this.getCoordinate=function(index){if(index<this.coordinates.length)
return this.coordinates[index];return null;}
this.size=function(){return this.coordinates.length;}
this.clear=function(){delete this.coordinates;this.coordinates=[];}}
net.watchee.Coordinates.parseKmlStr=function(coordinatesStr){coordinatesStr=coordinatesStr||"";var coordinates=new net.watchee.Coordinates();var coordStrArr=coordinatesStr.split(" ");for(var i=0,l=coordStrArr.length;i<l;i++){var coordStr=coordStrArr[i];var partsArr=coordStr.split(",");if(partsArr.length<2)continue;var coordinate=new net.watchee.Coordinate(org.xmlBlaster.util.toNumber(partsArr[0]),org.xmlBlaster.util.toNumber(partsArr[1]));if(partsArr.length>2)
coordinate.height=org.xmlBlaster.util.toNumber(partsArr[2],0.0);coordinates.append(coordinate);}
return coordinates;}
net.watchee.Track=function(device,trackName,buddyTO){var buddyTO=buddyTO||null;if(!org.xmlBlaster.util.isDefined(device)){throw"IllegalArgument: Can't create net.watchee.Track without device";}
this.device=device;this.watchee=this.device.watchee;this.trackName=trackName||net.watchee.DEVICE.CUR_TRACK_KEY;this.isCurrentTrack=function(){return this.trackName==net.watchee.Device.CUR_TRACK_KEY;}
this.trackDisplayInfoDefault=new net.watchee.TrackDisplayInfo(this.isCurrentTrack());this.trackDisplayInfoDefaultIsMerged=false;this.infoWindowForLatestPosition=xbProperties.getBoolean("showInfoWindowForLatestPosition",true);this.getTrackName=function(){return this.trackName;}
this.getSegmentDisplayInfoDefault=function(){return this.getTrackDisplayInfoDefault().segmentDisplayInfo;}
this.getIconDisplayInfoDefault=function(gpsData){return this.getTrackDisplayInfoDefault(gpsData).iconDisplayInfo;}
this.fifoGpsQueue=new org.xmlBlaster.util.FifoQueue(xbProperties.getInt(this.isCurrentTrack()?"maxGpsDataPerTrackCurrent":"maxGpsDataPerTrack"));this.historyPolyline=null;this.historyIcons=null;this.getTrackDisplayInfoDefault=function(gpsData){if(gpsData!==undefined){this.trackDisplayInfoDefault.setGpsData(gpsData);}
if(this.trackDisplayInfoDefaultIsMerged==false){this.trackDisplayInfoDefaultIsMerged=true;var key=net.watchee.TrackDisplayInfo.KEY_TRACK_DISPLAY_INFO_PREFIX+this.device.getDeviceId();var csv=this.device.getBuddyTO().getAccountPropertyStr(key,null);if(csv!=null){var mergeAll=this.isCurrentTrack();this.trackDisplayInfoDefault.mergeCSV(csv,mergeAll);}}
return this.trackDisplayInfoDefault;}
this.showInfoWindowForLatestPosition=function(){return this.infoWindowForLatestPosition;}
this.getDevice=function(){return this.device;}
this.getDeviceId=function(){return this.device.getDeviceId();}
this.locationsAreLoaded=function(){return this.fifoGpsQueue.size()>0;}
this.setIconNameAndFire=function(iconName,renderType,labelType){this.setIconName(iconName,renderType,labelType);var eventData={device:this.device,track:this,reason:"icon",trackDisplayInfo:this.getTrackDisplayInfoDefault()};this.watchee.getEventManager().fireEvent("trackDisplayInfoChanged",eventData);}
this.setSegmentColor=function(col){var old=this.getSegmentDisplayInfoDefault().getSegmentColor();this.getSegmentDisplayInfoDefault().setSegmentColor(col);if(old!=this.getSegmentDisplayInfoDefault().getSegmentColor()){this.drawHistoryLine();}
this.getIconDisplayInfoDefault().setLabelColor(this.getHexaColor(false));this.getIconDisplayInfoDefault().setArrowColor(this.getHexaColor(false));var eventData={device:this.device,track:this,reason:"segmentColor",trackDisplayInfo:this.getTrackDisplayInfoDefault()};this.watchee.getEventManager().fireEvent("trackDisplayInfoChanged",eventData);}
this.getHexaColor=function(withPrefix){var withPrefix=(withPrefix===undefined)?true:withPrefix;if(withPrefix)
return this.getSegmentDisplayInfoDefault().getSegmentColor();else
return this.getSegmentDisplayInfoDefault().getSegmentColorRGB();}
this.setIconName=function(iconName,renderType,labelType){var iconDisplayInfo=this.getIconDisplayInfoDefault();iconDisplayInfo.setLabelType(labelType);iconDisplayInfo.setIconName(iconName,renderType);}
this.getIconDisplayInfoCalculated=function(iconDisplayInfo){var gpsData=null;if(org.xmlBlaster.util.isDefined(iconDisplayInfo))
gpsData=iconDisplayInfo.gpsData;var deviceId=this.device.getDeviceId();if(!org.xmlBlaster.util.isFilled(deviceId)){var iconDisplayInfo=new net.watchee.IconDisplayInfo(net.watchee.IconDisplayInfo.RENDER_STATIC,true);iconDisplayInfo.gpsData=gpsData;return iconDisplayInfo;}
var iconDisplayInfo=org.xmlBlaster.util.isDefined(iconDisplayInfo)?iconDisplayInfo:this.getIconDisplayInfoDefault();if(iconDisplayInfo.isIconNameStatic()&&iconDisplayInfo.getIconName().indexOf("eppelin")!=-1){var gpsNewest=org.xmlBlaster.util.isDefined(iconDisplayInfo.gpsData)?iconDisplayInfo.gpsData:this.fifoGpsQueue.peekNewest();if(org.xmlBlaster.util.isDefined(gpsNewest)){var course=gpsNewest.getCourse();var iconName=(course>=0&&course<180)?"zeppelin90.gif":"zeppelin270.gif"
var iconDisplayInfo=new net.watchee.IconDisplayInfo(net.watchee.IconDisplayInfo.RENDER_STATIC,true);iconDisplayInfo.gpsData=gpsNewest;iconDisplayInfo.setIconName(iconName);return iconDisplayInfo;}}
var isPoiStaticHack=iconDisplayInfo.url!=null&&iconDisplayInfo.url.indexOf("/poi/")>=0;if(!isPoiStaticHack&&iconDisplayInfo.getRenderType()==net.watchee.IconDisplayInfo.RENDER_STATIC_ARROW){var gpsNewest=org.xmlBlaster.util.isDefined(iconDisplayInfo.gpsData)?iconDisplayInfo.gpsData:this.fifoGpsQueue.peekNewest();if(org.xmlBlaster.util.isDefined(gpsNewest)){var iconName=iconDisplayInfo.getIconName();var course=gpsNewest.getCourse();var speed=gpsNewest.getSpeedKmh();var courseString="999";if(speed>=3){course=Math.round(course/45)*45;if(course<=0||course>=360)courseString="000";else if(course<99)courseString="0"+course;else courseString=""+course;}
var front=iconName.substring(0,iconName.length-7);iconDisplayInfo.setIconName(front+courseString+".png");return iconDisplayInfo;}}
if(iconDisplayInfo.isIconNameStatic()){iconDisplayInfo.gpsData=gpsData;return iconDisplayInfo;}
var gpsNewest=org.xmlBlaster.util.isDefined(iconDisplayInfo.gpsData)?iconDisplayInfo.gpsData:this.fifoGpsQueue.peekNewest();if(!org.xmlBlaster.util.isDefined(gpsNewest)){iconDisplayInfo.gpsData=gpsNewest;return iconDisplayInfo;}
var PREFIX="";var W=iconDisplayInfo.iconPixelWidth;var H=W;var course=gpsNewest.getCourse();if(!org.xmlBlaster.util.isDefined(iconDisplayInfo.courseModulo))iconDisplayInfo.courseModulo=45;var speed=gpsNewest.getSpeedKmh();var maxSpeed=iconDisplayInfo.maxSpeed;var speedSteps=iconDisplayInfo.speedSteps;if(speedSteps<1)speedSteps=1;var maxLen=W/2;var ARROW_LEN=Math.round(maxLen/2);if(speed<(maxSpeed/speedSteps)){ARROW_LEN=Math.round(maxLen/speedSteps);}
else if(speed>maxSpeed){ARROW_LEN=Math.round(maxLen);}
else{ARROW_LEN=Math.round(maxLen*speed/maxSpeed);}
var ARROW_WIDTH=iconDisplayInfo.getArrowWidth();var DIR=(speed<2)?"":Math.round(((course*1.0)/iconDisplayInfo.courseModulo))*Math.round(iconDisplayInfo.courseModulo);var LABEL_COLOR=iconDisplayInfo.getLabelColorRGB();var ARROW_COLOR=iconDisplayInfo.getArrowColorRGB();var LABEL="xx";if(iconDisplayInfo.labelType==net.watchee.IconDisplayInfo.LABEL_TYPE_LOGINNAME){LABEL=this.getDeviceId();}
else if(iconDisplayInfo.labelType==net.watchee.IconDisplayInfo.LABEL_TYPE_ALIAS){LABEL=this.getDevice().getBuddyTO().getAlias();}
else if(iconDisplayInfo.labelType==net.watchee.IconDisplayInfo.LABEL_TYPE_LOGINNAME_ALIAS){LABEL=this.getDevice().getBuddyTO().getAliasAndLoginName();}
else if(iconDisplayInfo.labelType==net.watchee.IconDisplayInfo.LABEL_TYPE_TIME){LABEL=gpsNewest.getLocalTime(false);}
else{LABEL=org.xmlBlaster.util.replaceAllTokens(iconDisplayInfo.getLabelFormat(),"${loginName}",this.getDeviceId());LABEL=org.xmlBlaster.util.replaceAllTokens(LABEL,"${aliasName}",this.getDevice().getAlias());LABEL=org.xmlBlaster.util.replaceAllTokens(LABEL,"${localDate}",gpsNewest.getLocalDate());LABEL=org.xmlBlaster.util.replaceAllTokens(LABEL,"${localTime}",gpsNewest.getLocalTime());LABEL=org.xmlBlaster.util.replaceAllTokens(LABEL,"${localHHMM}",gpsNewest.getLocalTime(false));}
var isAnalogBar=iconDisplayInfo.getRenderType()==net.watchee.IconDisplayInfo.RENDER_ARROW_IN1_BAR||iconDisplayInfo.getRenderType()==net.watchee.IconDisplayInfo.RENDER_ARROW_IN2_BAR;var isAnalogSpeedDir=iconDisplayInfo.getRenderType()==net.watchee.IconDisplayInfo.RENDER_IN1_ARROW_SPEEDDIR||iconDisplayInfo.getRenderType()==net.watchee.IconDisplayInfo.RENDER_IN2_ARROW_SPEEDDIR;var inputNumber=iconDisplayInfo.getRenderType()==net.watchee.IconDisplayInfo.RENDER_ARROW_IN1_BAR||iconDisplayInfo.getRenderType()==net.watchee.IconDisplayInfo.RENDER_IN1_ARROW_SPEEDDIR?1:2;if(iconDisplayInfo.getRenderType()==net.watchee.IconDisplayInfo.RENDER_ARROW_TIME){LABEL=gpsNewest.getLocalTime(false);}
else if(isAnalogBar||isAnalogSpeedDir){if(this.getDevice().isInputAnalog(inputNumber)){var analogAliasName=this.getDevice().getIOAnalogText(inputNumber);var fx=this.getDevice().getIOAnalogComputedResultRounded(inputNumber,"?",gpsNewest);LABEL=fx+this.getDevice().getIOAnalogUnit(inputNumber);}
else{}}
LABEL=org.xmlBlaster.util.replaceAllTokens(LABEL,' ','-');var EXT="png";if(speed<2){ARROW_LEN=5;DIR='o';}
var iconName=PREFIX+"_"+W+"_"+H+"_"+ARROW_LEN+"_"+ARROW_WIDTH+"_"+DIR+"_"+LABEL_COLOR+"_"+ARROW_COLOR+"_"+LABEL+"_"+"."+EXT;if(isAnalogBar){W=100;H=100;ARROW_WIDTH=4;var factorVoltsToPixel=24;ARROW_LEN=Math.round(factorVoltsToPixel*this.getDevice().getInputVoltage(inputNumber,gpsNewest));DIR='b';iconName=PREFIX+"_"+W+"_"+H+"_"+ARROW_LEN+"_"+ARROW_WIDTH+"_"+DIR+"_"+LABEL_COLOR+"_"+ARROW_COLOR+"_"+LABEL+"_"+"."+EXT;}
iconDisplayInfo.setIconName(iconName);return iconDisplayInfo;}
this.getFifoGpsQueueSize=function(){return this.fifoGpsQueue.size();}
this.getFifoGpsQueueMax=function(){return this.fifoGpsQueue.maxEntries;}
this.getFifoGpsQueue=function(){return this.fifoGpsQueue;}
this.getFifoGpsArraySorted=function(){var arr=this.fifoGpsQueue.fifoQueue;arr.sort(function(x,y){var a=x.getUtcIsoStr();var b=y.getUtcIsoStr();if(a>b)
return 1
if(a<b)
return-1
return 0;});return arr;}
this.getHistoryIcons=function(){if(this.historyIcons==null){this.historyIcons=new org.xmlBlaster.util.FifoQueue(this.getIconDisplayInfoDefault().getNumIconsToShow());}
return this.historyIcons;}
this.setMaxGpsData=function(num){this.fifoGpsQueue.setMaxEntries(num);}
this.getMaxGpsData=function(){return this.fifoGpsQueue.getMaxEntries();}
this.getNumGpsData=function(){return this.fifoGpsQueue.size();}
this.getNumOfHistoryIcons=function(){return this.getHistoryIcons().size();}
this.getNumIconsToShow=function(){return org.xmlBlaster.util.toNumber(this.getHistoryIcons().maxEntries,1);}
this.setNumIconsToShow=function(max){var len=this.getHistoryIcons().fifoQueue.length;if(len>max){for(var jj=0;jj<len-max;jj++){this.watchee.getMapManager().removeMarker(this,this.getHistoryIcons().fifoQueue[jj]);}}
this.getHistoryIcons().setMaxEntries(max);this.getIconDisplayInfoDefault().setNumIconsToShow(max);}
this.isDisplayedOnMap=function(){return this.historyPolyline!=null||this.getNumOfHistoryIcons()>0;}
this.getCurrentGpsData=function(){return this.fifoGpsQueue.peekNewest();}
this.getLastValidGpsData=function(){var arr=this.fifoGpsQueue.getArray();for(var i=(arr.length-1);i>=0;i--){var gpsData=arr[i];if(gpsData!=null&&gpsData.isValid())
return gpsData;}
return this.getCurrentGpsData();}
this.getNiceName=function(){return this.getDevice().getBuddyTO().getAliasAndLoginName()+" / "+this.trackName;}
this.dump=function(){return"\deviceId="+this.getNiceName()+" historyIcons="+this.getNumOfHistoryIcons()+"/"+this.getNumIconsToShow()+" gpsData="+this.getNumGpsData()+"/"+this.getMaxGpsData();}
this.clearMappingData=function(removeGpsData){var remove=org.xmlBlaster.util.toBoolean(removeGpsData,true);this.hideHistoryLines();this.hideHistoryIcons();if(remove){this.removeGpsData();}
this.watchee.getMapManager().hideInfoWindow(this);}
this.removeGpsData=function(){this.fifoGpsQueue.clear();}
this.hideHistoryLines=function(){var foundOne=(this.historyPolyline!=null);if(this.historyPolyline!=null){net.watchee.util.log.debug(ME2+"Removing history lines of "+this.dump());this.watchee.getMapManager().removeLineOverlay(this.historyPolyline);this.historyPolyline=null;}
return foundOne;}
this.hideHistoryIcons=function(){var len=this.getHistoryIcons().getArray().length;this.watchee.getMapManager().removeMarkerOverlay(this);this.getHistoryIcons().clear();return(len>0);}
this.drawPositionIcons=function(drawingDoneFp,drawingDoneThisArg,mapInfoDrawerCb){this.watchee.getMapManager().drawPositionIcons(this,drawingDoneFp,drawingDoneThisArg,mapInfoDrawerCb);}
this.drawHistoryLine=function(){this.watchee.getMapManager().drawHistoryLine(this);}}
net.watchee.Track.prototype.addGPSSentence=function(gpsSentence,msgUnit){if(gpsSentence.charAt(0)!='$'){net.watchee.util.log.warn(ME2+"Ignoring unknown gpsSentence="+gpsSentence);return null;}
var gpsData=new net.watchee.GPSData(gpsSentence,this);gpsData.additionalInfo=msgUnit;this.fifoGpsQueue.push(gpsData);return gpsData;}
net.watchee.Track.prototype.addGPSData=function(gpsData,msgUnit){gpsData.additionalInfo=msgUnit;return this.fifoGpsQueue.push(gpsData);}
net.watchee.Track.prototype.getLatestValid=function(){var gpsDataArr=this.getFifoGpsQueue().getArray();for(var i=gpsDataArr.length-1;i>=0;i--){var gpsData=gpsDataArr[i];if(gpsData==null)
continue;if(!gpsData.isValid())
continue;if(gpsData.hasLatLonNull())
continue;return gpsData;}
return null;}
net.watchee.convertToDomDocumentChecked=function(ME,xmlString){var log=net.watchee.util.log;if(!org.xmlBlaster.util.isDefined(xmlString)){log.error(ME+" xmlString is undefined");return null;}
if(xmlString=="javax.ejb.EJBException"){log.error(ME+": "+xmlString);return null;}
var domDocument=org.xmlBlaster.util.getDOMDocument(xmlString);var rootNode=domDocument.documentElement;if(rootNode.nodeName=="parsererror"){log.error(ME+"'parsererror' for "+xmlString);return null;}
return domDocument;}
net.watchee.Track.parseGpxEnmea=function(device,xmlString,taskName){var log=net.watchee.util.log;var ME="watchee.js-Track.parseGpxEnmea(): ";if(!org.xmlBlaster.util.isDefined(device)){log.error("net.watchee.Track.parseGpxEnmea 'device' is undefined");return null;}
var domDocument=net.watchee.convertToDomDocumentChecked(ME,xmlString);if(domDocument==null)return;var rootNode=domDocument.documentElement;var tracks=new Array();var track=null;for(var i=0;i<rootNode.childNodes.length;i++){var node=rootNode.childNodes[i];if(node.nodeType!=Node.ELEMENT_NODE){var nval=org.xmlBlaster.util.trim(node.nodeValue);if(nval!=null&&nval!=""){var val=(node.nodeValue!=undefined&&node.nodeValue!=null)?(": '"+node.nodeValue+"'"):"";var txt="Track(): Ignoring track response node "+org.xmlBlaster.util.getXPathLocation(node,true)+val;(node.nodeType==Node.COMMENT_NODE||node.nodeType==Node.TEXT_NODE)?net.watchee.util.log.debug(ME2+txt):net.watchee.util.log.warn(ME2+txt);}
continue;}
switch(node.nodeName){case"gpx":log.info("gpx");break;case"extensions":break;case"trk":for(var j=0;j<node.childNodes.length;j++){var nd=node.childNodes[j];switch(nd.nodeName){case"name":var trackName=org.xmlBlaster.util.collectTextFromNodeChilds(nd);log.info("/gpx/trk/name="+trackName);track=device.getTrackOrNull(trackName);if(track==null){track=new net.watchee.Track(device,trackName);}
else{track.getFifoGpsQueue().clear();}
tracks.push(track);break;case"trkseg":for(var k=0,lseg=nd.childNodes.length;k<lseg;k++){var pt=nd.childNodes[k];switch(pt.nodeName){case"trkpt":for(var m=0,lpt=pt.childNodes.length;m<lpt;m++){var extNode=pt.childNodes[m];for(var n=0,lext=extNode.childNodes.length;n<lext;n++){var n2=extNode.childNodes[n];switch(n2.nodeName){case"enmea":if(n2.firstChild){var gpsSentence=org.xmlBlaster.util.collectTextFromNodeChilds(n2);if(gpsSentence.length>0){var msgUnit=null;track.addGPSSentence(gpsSentence,msgUnit);}}
break;default:break;}}}
break;}}
break;}}
break;default:log.warn(ME2+"Track("+org.xmlBlaster.util.getXPathLocation(node,true)+"): Ignoring Track-GPX tag '"+node.nodeName+"'");break;}}
for(var i=0,l=tracks.length;i<l;i++){var taskNameInfo={taskName:taskName,currTrackIndex:i,countTracks:l};device.addTrack(tracks[i],taskNameInfo);}
return tracks;}
net.watchee.IconDisplayInfo=function(renderType,isCurrentTrack){var isCurrentTrack=(isCurrentTrack===undefined)?true:isCurrentTrack;this.url=null;this.numIconsToShow=xbProperties.getInt(isCurrentTrack?"numIconsToShowCurrent":"numIconsToShow");this.iconName=xbProperties.getStr("defaultIcon.name",watcheeDefaultIcon);this.path=null;var isStatic=xbProperties.getBoolean("defaultIcon.isStatic",true);this.setRenderTypeAdjusted((renderType==undefined||renderType==null)?xbProperties.getStr("defaultIcon.renderType",isStatic?"static":"arrow"):renderType);this.gpsData=null;this.iconPixelWidth=xbProperties.getInt("defaultIcon.iconPixelWidth",80);this.arrowWidth=xbProperties.getInt("defaultIcon.arrowWidth",2);this.setLabelFormat(xbProperties.getStr("defaultIcon.labelFormat","${loginName}"));this.setLabelColor(xbProperties.getStr("defaultIcon.labelColor","0000FF"));this.setArrowColor(xbProperties.getStr("defaultIcon.arrowColor","FF0000"));this.maxSpeed=xbProperties.getInt("defaultIcon.maxSpeed",80);this.speedSteps=xbProperties.getInt("defaultIcon.speedSteps",4);this.courseModulo=xbProperties.getInt("defaultIcon.courseModulo",20);this.labelType=xbProperties.getInt("defaultIcon.labelType",0);}
net.watchee.IconDisplayInfo.DEFAULT_LABEL_COLOR="0000FF";net.watchee.IconDisplayInfo.DEFAULT_ARROW_COLOR="FF0000";net.watchee.IconDisplayInfo.RENDER_STATIC="static";net.watchee.IconDisplayInfo.RENDER_STATIC_ARROW="static_arrow";net.watchee.IconDisplayInfo.RENDER_ARROW="arrow";net.watchee.IconDisplayInfo.RENDER_ARROW_TIME="arrow_time";net.watchee.IconDisplayInfo.RENDER_ARROW_IN1_BAR="in1_bar";net.watchee.IconDisplayInfo.RENDER_ARROW_IN2_BAR="in1_bar";net.watchee.IconDisplayInfo.RENDER_IN1_ARROW_SPEEDDIR="in1_speeddir";net.watchee.IconDisplayInfo.RENDER_IN2_ARROW_SPEEDDIR="in2_speeddir";net.watchee.IconDisplayInfo.prototype.setIconName=function(iconName,renderType){this.iconName=iconName;var renderType=(renderType!=undefined&&renderType!=null)?renderType:this.renderType;this.setRenderTypeAdjusted(renderType);}
net.watchee.IconDisplayInfo.prototype.getIconName=function(){return this.iconName;}
net.watchee.IconDisplayInfo.prototype.getUrlEncoded=function(){if(this.url==null)
this.url=this.path+this.iconName;var encoded=this.url;return encoded;}
net.watchee.IconDisplayInfo.prototype.setRenderTypeAdjusted=function(renderType){this.renderType=(renderType===undefined||renderType==null)?net.watchee.IconDisplayInfo.RENDER_STATIC:renderType;if(this.isIconNameStatic()){this.path=net.watchee.STATIC_ICON_URL_PATH;}
else{this.path=net.watchee.DYNAMIC_ICON_URL_PATH;}
this.url=this.path+this.iconName;}
net.watchee.IconDisplayInfo.prototype.setRenderType=function(renderType){this.renderType=renderType;}
net.watchee.IconDisplayInfo.prototype.getRenderType=function(){return this.renderType;}
net.watchee.IconDisplayInfo.prototype.isIconNameStatic=function(){return this.renderType==net.watchee.IconDisplayInfo.RENDER_STATIC||this.renderType==net.watchee.IconDisplayInfo.RENDER_STATIC_ARROW;}
net.watchee.IconDisplayInfo.prototype.getArrowWidth=function(){return this.arrowWidth;}
net.watchee.IconDisplayInfo.prototype.setLabelFormat=function(labelFormat){if(labelFormat==undefined||labelFormat==null)
return;this.labelFormat=labelFormat;}
net.watchee.IconDisplayInfo.prototype.getLabelFormat=function(){return this.labelFormat;}
net.watchee.IconDisplayInfo.prototype.setLabelColor=function(labelColor){if(labelColor==undefined||labelColor==null)
return;this.labelColor=net.watchee.getHexaColor(labelColor,false);}
net.watchee.IconDisplayInfo.prototype.getLabelColorRGB=function(){return this.labelColor;}
net.watchee.IconDisplayInfo.prototype.setArrowColor=function(arrowColor){if(arrowColor==undefined||arrowColor==null)
return;this.arrowColor=net.watchee.getHexaColor(arrowColor,false);}
net.watchee.IconDisplayInfo.prototype.getArrowColorRGB=function(){return this.arrowColor;}
net.watchee.IconDisplayInfo.prototype.setMaxSpeed=function(maxSpeed){this.maxSpeed=org.xmlBlaster.util.toNumber(maxSpeed,this.maxSpeed);}
net.watchee.IconDisplayInfo.prototype.getMaxSpeed=function(){return this.maxSpeed;}
net.watchee.IconDisplayInfo.prototype.setSpeedSteps=function(speedSteps){this.speedSteps=org.xmlBlaster.util.toNumber(speedSteps,this.speedSteps);}
net.watchee.IconDisplayInfo.prototype.getSpeedSteps=function(){return this.speedSteps;}
net.watchee.IconDisplayInfo.prototype.setCourseModulo=function(courseModulo){this.courseModulo=org.xmlBlaster.util.toNumber(courseModulo,this.courseModulo);}
net.watchee.IconDisplayInfo.prototype.getCourseModulo=function(){return this.courseModulo;}
net.watchee.IconDisplayInfo.prototype.setNumIconsToShow=function(numIconsToShow){this.numIconsToShow=numIconsToShow;}
net.watchee.IconDisplayInfo.prototype.getNumIconsToShow=function(){return this.numIconsToShow;}
net.watchee.IconDisplayInfo.prototype.setLabelType=function(labelType){this.labelType=labelType;}
net.watchee.IconDisplayInfo.LABEL_TYPE_LOGINNAME=0;net.watchee.IconDisplayInfo.LABEL_TYPE_ALIAS=1;net.watchee.IconDisplayInfo.LABEL_TYPE_LOGINNAME_ALIAS=2;;net.watchee.IconDisplayInfo.LABEL_TYPE_DYNAMIC=3;net.watchee.IconDisplayInfo.LABEL_TYPE_TIME=4;net.watchee.IconDisplayInfo.prototype.getLabelType=function(){return this.labelType;}
net.watchee.IconDisplayInfo.prototype.mergeCSV=function(csv,mergeAll){var hash=org.xmlBlaster.util.Hashtable.parseCSV(csv);if(hash.contains("segmentColor")){var segmentColor=hash.get("segmentColor");this.setLabelColor(segmentColor);this.setArrowColor(segmentColor);}
if(hash.contains("labelFormat")){this.setLabelFormat(hash.get("labelFormat"));}
if(hash.contains("labelColor")){this.setLabelColor(hash.get("labelColor"));}
if(hash.contains("arrowColor")){this.setArrowColor(hash.get("arrowColor"));}
if(hash.contains("maxSpeed")){this.setMaxSpeed(hash.get("maxSpeed"));}
if(hash.contains("speedSteps")){this.setSpeedSteps(hash.get("speedSteps"));}
if(hash.contains("courseModulo")){this.setCourseModulo(hash.get("courseModulo"));}
if(hash.contains("labelType")){this.setLabelType(hash.get("labelType"));}
if(hash.contains("renderType")){this.setRenderType(hash.get("renderType"));}
if(hash.contains("labelType")){this.setLabelType(hash.getNumber("labelType",net.watchee.IconDisplayInfo.LABEL_TYPE_LOGINNAME));}
if(hash.contains("iconName")){this.setIconName(hash.get("iconName"));this.setRenderTypeAdjusted(this.renderType);}
if(mergeAll&&hash.contains("numIconsToShow")){this.setNumIconsToShow(hash.get("numIconsToShow"));}}
net.watchee.IconDisplayInfo.prototype.toCSV=function(){var csv="";csv+="renderType="+this.getRenderType();csv+=",";csv+="iconName="+this.getIconName();csv+=",";csv+="numIconsToShow="+this.getNumIconsToShow();csv+=",";csv+="labelFormat="+this.getLabelFormat();if(this.labelColor!=net.watchee.IconDisplayInfo.DEFAULT_LABEL_COLOR){csv+=",";csv+="labelColor="+this.labelColor;}
if(this.arrowColor!=net.watchee.IconDisplayInfo.DEFAULT_ARROW_COLOR){csv+=",";csv+="arrowColor="+this.arrowColor;}
if(this.getLabelType()!=net.watchee.IconDisplayInfo.LABEL_TYPE_LOGINNAME){csv+=",";csv+="labelType="+this.getLabelType();}
csv+=",";csv+="maxSpeed="+this.getMaxSpeed();csv+=",";csv+="speedSteps="+this.getSpeedSteps();csv+=",";csv+="courseModulo="+this.getCourseModulo();return csv;}
net.watchee.SegmentDisplayInfo=function(isCurrentTrack,segmentColor,segmentWidth){var isCurrentTrack=(isCurrentTrack===undefined)?true:isCurrentTrack;this.setSegmentColor(segmentColor);this.setSegmentWidth(segmentWidth);this.segmentOpacity=1;this.numSegmentsToShow=xbProperties.getInt(isCurrentTrack?"numSegmentsToShowCurrent":"numSegmentsToShow");}
net.watchee.SegmentDisplayInfo.prototype.setSegmentColor=function(segmentColor){this.segmentColor=(segmentColor===undefined||segmentColor==null)?xbProperties.getStr("mapSegmentColor","#FF0000"):segmentColor;this.segmentColor=net.watchee.getHexaColor(this.segmentColor,true);}
net.watchee.SegmentDisplayInfo.prototype.getSegmentColor=function(){return this.segmentColor;}
net.watchee.SegmentDisplayInfo.prototype.getSegmentColorRGB=function(){return this.segmentColor.substring(1);}
net.watchee.SegmentDisplayInfo.prototype.setSegmentWidth=function(segmentWidth){this.segmentWidth=(segmentWidth===undefined)?xbProperties.getInt("mapSegmentWidth",3):org.xmlBlaster.util.toNumber(segmentWidth,3);}
net.watchee.SegmentDisplayInfo.prototype.getSegmentWidth=function(){return this.segmentWidth;}
net.watchee.SegmentDisplayInfo.prototype.getNumSegmentsToShow=function(){return this.numSegmentsToShow}
net.watchee.SegmentDisplayInfo.prototype.setNumSegmentsToShow=function(numSegmentsToShow){this.numSegmentsToShow=org.xmlBlaster.util.toNumber(numSegmentsToShow,600);}
net.watchee.SegmentDisplayInfo.prototype.getSegmentOpacity=function(){return this.segmentOpacity;}
net.watchee.SegmentDisplayInfo.prototype.setSegmentOpacity=function(segmentOpacity){this.segmentOpacity=segmentOpacity;}
net.watchee.SegmentDisplayInfo.prototype.mergeCSV=function(csv,mergeAll){var hash=org.xmlBlaster.util.Hashtable.parseCSV(csv);if(hash.contains("segmentColor")){this.setSegmentColor(hash.get("segmentColor"));}
if(hash.contains("segmentWidth")){this.setSegmentWidth(hash.get("segmentWidth"));}
if(hash.contains("segmentOpacity")){this.setSegmentOpacity(hash.get("segmentOpacity"));}
if(mergeAll&&hash.contains("numSegmentsToShow")){this.setNumSegmentsToShow(hash.get("numSegmentsToShow"));}}
net.watchee.SegmentDisplayInfo.prototype.toCSV=function(){var csv="";csv+="segmentColor="+this.getSegmentColor();csv+=",";csv+="segmentWidth="+this.getSegmentWidth();csv+=",";csv+="segmentOpacity="+this.getSegmentOpacity();csv+=",";csv+="numSegmentsToShow="+this.getNumSegmentsToShow();return csv;}
net.watchee.HomeViews=function(){this.homeViewHash=new org.xmlBlaster.util.Hashtable();}
net.watchee.HomeViews.prototype.add=function(homeView){this.homeViewHash.put(homeView.getName(),homeView);}
net.watchee.HomeViews.prototype.remove=function(name){return this.homeViewHash.remove(name);}
net.watchee.HomeViews.prototype.getHomeView=function(name){return this.homeViewHash.get(name,null);}
net.watchee.HomeViews.prototype.getArr=function(homeView){return this.homeViewHash.getValues();}
net.watchee.HomeViews.prototype.size=function(homeView){return this.homeViewHash.size();}
net.watchee.HomeViews.parse=function(pc){var arr=pc.getHashtable().getValues();var homeViews=new net.watchee.HomeViews();for(var i=0,l=arr.length;i<l;i++){var propertyPair=arr[i];if(!propertyPair.getKey().indexOf(net.watchee.HomeView.KEY_HOMEVIEW_PREFIX)==0){continue;}
var homeView=net.watchee.HomeView.parse(propertyPair.getValueStr());homeViews.add(homeView);}
return homeViews;}
net.watchee.HomeView=function(name,lat,lon,zoom){this.hash=null;if(typeof name!="undefined"){this.hash=new org.xmlBlaster.util.Hashtable();this.hash.put("name",name);var lat=lat||47.78;this.hash.put("lat",lat);var lon=lon||9.18;this.hash.put("lon",lon);var zoom=zoom||12;this.hash.put("zoom",zoom);}}
net.watchee.HomeView.parse=function(csv){var homeView=new net.watchee.HomeView();homeView.hash=org.xmlBlaster.util.Hashtable.parseCSV(csv);return homeView;}
net.watchee.HomeView.prototype.getName=function(){return this.hash.get("name","NONAME");}
net.watchee.HomeView.prototype.getLat=function(){return this.hash.get("lat",47.78);}
net.watchee.HomeView.prototype.getLon=function(){return this.hash.get("lon",9.18);}
net.watchee.HomeView.prototype.getZoom=function(){return this.hash.get("zoom",12);}
net.watchee.HomeView.prototype.toCSV=function(){var csv=this.hash.toCSV();return csv;}
net.watchee.HomeView.KEY_HOMEVIEW_PREFIX="homeView/";net.watchee.TrackDisplayInfo=function(isCurrentTrack,iconDisplayInfo,segmentDisplayInfo,gpsData){this.iconDisplayInfo=(iconDisplayInfo===undefined)?new net.watchee.IconDisplayInfo(null,isCurrentTrack):iconDisplayInfo;this.segmentDisplayInfo=(segmentDisplayInfo===undefined)?new net.watchee.SegmentDisplayInfo(isCurrentTrack):segmentDisplayInfo;this.setGpsData(gpsData);}
net.watchee.TrackDisplayInfo.prototype.setGpsData=function(gpsData){this.iconDisplayInfo.gpsData=gpsData||null;}
net.watchee.TrackDisplayInfo.prototype.mergeCSV=function(csv,mergeAll){this.iconDisplayInfo.mergeCSV(csv,mergeAll);this.segmentDisplayInfo.mergeCSV(csv,mergeAll);}
net.watchee.TrackDisplayInfo.prototype.toCSV=function(){var csv="";csv+=this.iconDisplayInfo.toCSV();csv+=",";csv+=this.segmentDisplayInfo.toCSV();return csv;}
net.watchee.TrackDisplayInfo.KEY_TRACK_DISPLAY_INFO_PREFIX="trackDisplayInfo/";net.watchee.Device=function(watchee,aDeviceId,niceDeviceName_,buddyTO){this.watchee=watchee;this.deviceId=aDeviceId;this.niceDeviceName=niceDeviceName_||aDeviceId;this.receive_xSMSQueue=new org.xmlBlaster.util.FifoQueue(10);this.send_xSMSQueue=new org.xmlBlaster.util.FifoQueue(10);this.tracks=new org.xmlBlaster.util.Hashtable();this.CUR_TRACK_KEY="__current";this.tracks.put(this.CUR_TRACK_KEY,new net.watchee.Track(this,this.CUR_TRACK_KEY,buddyTO));this.eventManager=new org.xmlBlaster.util.EventManager();this.propertyCollection=null;this.showSleepModeInIcon=xbProperties.getBoolean("showSleepModeInIcon",false);this.countAlarms=0;this.countAlarmsAttachedToRules=0;this.rules=[];this.showingOnMap=false;this.volt=-1.0;this.voltDate=null;this.batteryLevelPercent=-1;this.gpsSignalOk=true;this.deviceSleeping=false;this.charged=false;this.tableAtomsCache=[];this.tableAtomsCache[0]=[];this.tableAtomsCache[1]=[];this.ioAliasNamesHash=null;this.ioAnalogHash=null;this.outputStatusArr=[];}
net.watchee.Device.prototype.getDeviceMapping=function(){return this.getBuddyTO().getDeviceMapping();}
net.watchee.Device.prototype.getHwPhoneNumber=function(){var deviceMapping=this.getDeviceMapping();if(deviceMapping==null)
return"";var phone=this.watchee.validateSmsPhoneNumber(deviceMapping.getHwPhoneNumber(),true);if(phone==null)
return"";return phone;}
net.watchee.Device.prototype.getAlias=function(){return this.getBuddyTO().getAlias();}
net.watchee.Device.prototype.getAvatarIconUrl=function(){return this.getBuddyTO().getAvatarIconUrl();}
net.watchee.Device.prototype.isGpsSignalOk=function(){return this.gpsSignalOk;}
net.watchee.Device.prototype.setGpsSignalOk=function(gpsSignalOk){var old=this.gpsSignalOk;this.gpsSignalOk=gpsSignalOk;return old;}
net.watchee.Device.prototype.toggleOnline=function(){if(this.getBuddyTO().getOnlineStatus()==net.watchee.BuddyTO.STATUS_ONLINE){this.getBuddyTO().setOnlineStatus(net.watchee.BuddyTO.STATUS_OFFLINE);}
else{this.getBuddyTO().setOnlineStatus(net.watchee.BuddyTO.STATUS_ONLINE);}
return this.getBuddyTO().getOnlineStatus();}
net.watchee.Device.prototype.getTrackSegmentColor=function(withPrefix){var track=this.getTrack(this.CUR_TRACK_KEY);return track.getHexaColor(withPrefix);}
net.watchee.Device.prototype.getTrackSegmentMarker=function(withPrefix){var track=this.getTrack(this.CUR_TRACK_KEY);return track.getIconDisplayInfoCalculated().getUrlEncoded();}
net.watchee.Device.prototype.getOnlineStatusOrderBy=function(){var hasPerm=this.getBuddyTO().hasPermission(net.watchee.BuddyPermissionTO.PERMISSION_DEVICE_STATUS);if(hasPerm){if(false){return 0;}
else if(this.getDeviceInfo().isDeviceSleepMode()&&!this.isOnline()){return 2;}
else if(this.isOnline()&&this.isGpsSignalOk()){return 0;}
else if(this.isOnline()&&!this.isGpsSignalOk()){return 1;}
else if(!this.isOnline()){return 3;}
else{return 4;}}
else{return 9;}}
net.watchee.Device.prototype.getOnlineStatusIcon=function(){var hasPerm=this.getBuddyTO().hasPermission(net.watchee.BuddyPermissionTO.PERMISSION_DEVICE_STATUS);if(hasPerm){if(this.getDeviceInfo().isDeviceSleepMode()&&!this.isOnline()){if(this.showSleepModeInIcon){var num=this.getConfiguredPowerSaveMode();if(num>0)
return xbGetIcon("32/statusLine/deviceStateSleep"+num+".png");else
return xbGetIcon("32/statusLine/deviceStateSleep.png");}
else{return xbGetIcon("32/statusLine/deviceStateSleep.png");}}
if(this.isOnline()&&!this.isGpsSignalOk()){if(this.showSleepModeInIcon){var num=this.getConfiguredPowerSaveMode();if(num>0)
return xbGetIcon("32/statusLine/deviceStateNoGPS"+num+".png");else
return xbGetIcon("32/statusLine/deviceStateNoGPS.png");}
else{return xbGetIcon("32/statusLine/deviceStateNoGPS.png");}}
if(this.isOnline()){if(this.showSleepModeInIcon){var num=this.getConfiguredPowerSaveMode();if(num>0)
return xbGetIcon("32/statusLine/deviceStateOn"+num+".png");else
return xbGetIcon("32/statusLine/deviceStateOn.png");}
else{return xbGetIcon("32/statusLine/deviceStateOn.png");}}
else{return xbGetIcon("32/statusLine/deviceStateOff.png");}}
return xbGetIcon("32/statusLine/deviceStateOff.png");}
net.watchee.Device.prototype.isBatteryEmpty=function(){return this.batteryLevelPercent<=0;}
net.watchee.Device.prototype.isBatteryUnknown=function(){return this.batteryLevelPercent<0;}
net.watchee.Device.prototype.getBatteryIcon=function(){var name="";if(this.isCharged())
name="batteryCharger.png";else if(this.batteryLevelPercent>=70)
name="batteryFull.png";else if(this.batteryLevelPercent>=20)
name="batteryHalf.png";else if(this.batteryLevelPercent>=0)
name="batteryLow.png";else if(this.batteryLevelPercent<0)
name="batteryNA.png";return xbGetIcon("32/statusLine/"+name);}
net.watchee.Device.prototype.hasVolt=function(){return this.volt>=0.0;}
net.watchee.Device.prototype.getVolt=function(){return this.volt;}
net.watchee.Device.prototype.getVoltTimeStr=function(){if(this.voltDate==null)
return"";var dateStr=org.xmlBlaster.util.getDateStr(this.voltDate);var nowDateStr=org.xmlBlaster.util.getDateStr(null);if(nowDateStr==dateStr){return org.xmlBlaster.util.getTimeStr(this.voltDate,false);}
else{return dateStr+" "+org.xmlBlaster.util.getTimeStr(this.voltDate,false);}}
net.watchee.Device.prototype.getBatteryLevelForSortingStr=function(){if(this.isCharged())
return"A";else if(this.isBatteryUnknown())
return"#";else if(this.batteryLevelPercent==100)
return"9";else
return""+(this.batteryLevelPercent/10);}
net.watchee.Device.prototype.getBatteryPercent=function(){if(this.batteryLevelPercent<=0)
return 0;return this.batteryLevelPercent;}
net.watchee.Device.prototype.setBatteryLevelPercent=function(batteryLevel){this.batteryLevelPercent=batteryLevel;}
net.watchee.Device.prototype.isCharged=function(){return this.charged;}
net.watchee.Device.prototype.setCountAlarms=function(countAlarms){this.countAlarms=countAlarms<0?0:countAlarms;}
net.watchee.Device.prototype.getCountAlarms=function(){return this.countAlarms;}
net.watchee.Device.prototype.countAlarmsIncrement=function(){return this.countAlarms++;}
net.watchee.Device.prototype.countAlarmsReset=function(){return this.countAlarms=0;}
net.watchee.Device.prototype.setCountAlarmsAttachedToRules=function(countAlarms){this.countAlarmsAttachedToRules=countAlarms<0?0:countAlarms;}
net.watchee.Device.prototype.getCountAlarmsAttachedToRules=function(){return this.countAlarmsAttachedToRules;}
net.watchee.Device.prototype.countAlarmsAttachedToRulesIncrement=function(){return this.countAlarmsAttachedToRules++;}
net.watchee.Device.prototype.countAlarmsAttachedToRulesReset=function(){return this.countAlarmsAttachedToRules=0;}
net.watchee.Device.prototype.hasAlarms=function(){return this.countAlarms>0;}
net.watchee.Device.prototype.hasAlarmsAttachedToRules=function(){return this.countAlarmsAttachedToRules>0;}
net.watchee.Device.prototype.getAlarmIcon=function(){return xbGetIcon("32/statusLine/alarm"+(this.hasAlarmsAttachedToRules()?"On":"Off")+".png");}
net.watchee.Device.prototype.hasHistoryTracks=function(){return this.tracks.length>0;}
net.watchee.Device.prototype.hasRules=function(){return this.rules.length>0;}
net.watchee.Device.prototype.getRulesIcon=function(){return xbGetIcon("32/statusLine/rules"+(this.hasRules()?"On":"Off")+".png");}
net.watchee.Device.prototype.isAutoTracking=function(){return this.getBuddyTO().isAutoTracking();}
net.watchee.Device.prototype.setAutoTracking=function(autoTracking){this.getBuddyTO().setAutoTracking(autoTracking);}
net.watchee.Device.prototype.toggleAutoTracking=function(){return this.getBuddyTO().toggleAutoTracking();}
net.watchee.Device.prototype.getAutoTrackingIcon=function(){if(this.isAutoTracking()){if(this.isAutoTrackingCentered()){return xbGetIcon("32/statusLine/deviceAutoTrackingOnCentered.png");}
else{return xbGetIcon("32/statusLine/deviceAutoTrackingOn.png");}}
else{return xbGetIcon("32/statusLine/deviceAutoTrackingOff.png");}}
net.watchee.Device.prototype.isAutoTrackingCentered=function(){return this.getBuddyTO().isAutoTrackingCentered();}
net.watchee.Device.prototype.setAutoTrackingCentered=function(doCenter){this.getBuddyTO().setAutoTrackingCentered(doCenter);}
net.watchee.Device.prototype.getAutoTrackingOptions=function(){return this.getBuddyTO().getAutoTrackingOptions();}
net.watchee.Device.prototype.isShowingOnMap=function(){return this.showingOnMap;}
net.watchee.Device.prototype.setShowingOnMap=function(showingOnMap){this.showingOnMap=showingOnMap;}
net.watchee.Device.prototype.toggleShowingOnMap=function(){this.showingOnMap=!this.showingOnMap;;return this.showingOnMap;}
net.watchee.Device.prototype.getShowingOnMapIcon=function(width){var width=width||32;return xbGetIcon(width+"/statusLine/showingOnMap"+(this.isShowingOnMap()?"On":"Off")+".png");}
net.watchee.Device.prototype.getHistoryTracksIcon=function(){return xbGetIcon("32/statusLine/historyTracksOn.png");}
net.watchee.Device.prototype.getDeviceConfigIcon=function(){return xbGetIcon("32/statusLine/deviceConfigOn.png");}
net.watchee.Device.prototype.isCurrentLoginAccount=function(){return this.getBuddyTO().isCurrentLoginAccount();}
net.watchee.Device.prototype.getEventManager=function(){return this.eventManager;}
net.watchee.Device.prototype.isTrackingInitiallyOn=function(){if(this.watchee==null)
return false;return this.watchee.getBuddyManager().isTrackingOnFor(this.getLoginName());}
net.watchee.Device.prototype.getDeviceInfo=function(){return this.getBuddyTO().getDeviceInfo();}
net.watchee.Device.prototype.hasPermission=function(permissionName){return this.getBuddyTO().hasPermission(permissionName);}
net.watchee.Device.prototype.__getCurrentTrack=function(){var track=this.tracks.get(this.CUR_TRACK_KEY);if(track==null)
this.tracks.put(this.CUR_TRACK_KEY,new net.watchee.Track(this,this.CUR_TRACK_KEY));return this.tracks.get(this.CUR_TRACK_KEY);}
net.watchee.Device.prototype.getTrack=function(trackName){if(!org.xmlBlaster.util.isFilled(trackName)){return this.__getCurrentTrack();}
var track=this.tracks.get(trackName);if(track!=null)
return track;return this.__getCurrentTrack();}
net.watchee.Device.prototype.getTracks=function(){this.__getCurrentTrack();return this.tracks.getValues();}
net.watchee.Device.prototype.getTrackOrNull=function(trackName){if(!org.xmlBlaster.util.isFilled(trackName)){return this.tracks.get(this.CUR_TRACK_KEY);}
return this.tracks.get(trackName);}
net.watchee.Device.prototype.hasTrack=function(trackName){if(!org.xmlBlaster.util.isFilled(trackName))
return true;return(this.tracks.get(trackName)!=null)?true:false;}
net.watchee.Device.prototype.getCurrentTrack=function(){return this.getTrack();}
net.watchee.Device.prototype.addTrack=function(track,taskNameInfo){var trackName=track.getTrackName();var oldTrack=this.tracks.put(trackName,track);this.eventManager.fireEvent("addTrack",{track:track,taskNameInfo:taskNameInfo});return oldTrack;}
net.watchee.Device.prototype.removeTrack=function(trackName,fireEvent){var fireEvent=org.xmlBlaster.util.toBoolean(fireEvent,true);if(org.xmlBlaster.util.isFilled(trackName)){var track=this.tracks.remove(trackName);if(fireEvent&&track!=null){this.eventManager.fireEvent("removeTrack",track);}
return track;}
return null;}
net.watchee.Device.prototype.getTrackNames=function(){var arr=this.getTracks();var names=new Array();for(var i=0,l=arr.length;i<l;i++){names[i]=arr[i].getTrackName();}
return names;}
net.watchee.Device.prototype.getTracksClone=function(){var arr=this.getTracks();var clone=new Array();for(var i=0,l=arr.length;i<l;i++){clone[i]=arr[i];}
return clone;}
net.watchee.Device.prototype.removeAllTracks=function(what,fireEvent){var what=org.xmlBlaster.util.isDefined(what)?what:"all";var arr=this.getTracksClone();for(var i=0,l=arr.length;i<l;i++){var track=arr[i];if(what=="all")
this.removeTrack(track.getTrackName(),fireEvent);else if(track.isCurrentTrack()&&what=="current"){this.removeTrack(track.getTrackName(),fireEvent);}
else if(!track.isCurrentTrack()&&what=="history"){this.removeTrack(track.getTrackName(),fireEvent);}}}
net.watchee.Device.prototype.getNumGpsData=function(trackName){if(org.xmlBlaster.util.isDefined(trackName)){var t=this.getTrack(trackName);return(t==null)?0:t.getNumGpsData();}
var num=0;var arr=this.getTracks();for(var i=0,l=arr.length;i<l;i++){var track=arr[i];num+=track.getNumGpsData();}
return num;}
net.watchee.Device.prototype.getFifoGpsQueue=function(trackName){var t=this.getTrack(trackName);return(t==null)?null:t.getFifoGpsQueue();}
net.watchee.Device.prototype.getHistoryIcons=function(trackName){var t=this.getTrack(trackName);return(t==null)?null:t.getHistoryIcons();}
net.watchee.Device.prototype.addReceivedxSMS=function(xSMS){this.receive_xSMSQueue.push(xSMS);}
net.watchee.Device.prototype.addReceivedxSMSToInfoWindow=function(){var textArea=document.getElementById("cheapSmsReceive."+this.deviceId);if(textArea!=undefined&&textArea!=null){textArea.value="";for(var ii=0;ii<this.receive_xSMSQueue.fifoQueue.length;ii++){var xSMS=this.receive_xSMSQueue.fifoQueue[ii];if(xSMS==null)
break;if(ii>0)textArea.value+="\n---\n";textArea.value+=xSMS.dump(this.niceDeviceName);}
return true;}
return false;}
net.watchee.Device.prototype.addSendxSMS=function(xSMS){this.send_xSMSQueue.push(xSMS);}
net.watchee.Device.prototype.addGPSData=function(gpsData,msgUnit,trackName){var track=this.getTrack(trackName);var gpsDataOld=track.addGPSData(gpsData,msgUnit);var data={track:track,gpsData:gpsData};this.eventManager.fireEvent("addGps",data);return gpsDataOld;}
net.watchee.Device.prototype.dump=function(){return"\deviceId="+this.getDeviceId();}
net.watchee.Device.prototype.hideHistoryLines=function(trackName){if(org.xmlBlaster.util.isDefined(trackName)){return this.getTrack(trackName).hideHistoryLines();}
var arr=this.getTracks();for(var i=0,l=arr.length;i<l;i++){var track=arr[i];track.hideHistoryLines();}}
net.watchee.Device.prototype.hideHistoryIcons=function(trackName){if(org.xmlBlaster.util.isDefined(trackName)){return this.getTrack(trackName).hideHistoryIcons();}
var arr=this.getTracks();for(var i=0,l=arr.length;i<l;i++){var track=arr[i];track.hideHistoryIcons();}}
net.watchee.Device.prototype.removeGpsData=function(trackName){if(org.xmlBlaster.util.isDefined(trackName)){return this.getTrack(trackName).removeGpsData();}
var arr=this.getTracks();for(var i=0,l=arr.length;i<l;i++){var track=arr[i];track.removeGpsData();}}
net.watchee.Device.prototype.clearMappingData=function(trackName){if(org.xmlBlaster.util.isDefined(trackName)){return this.getTrack(trackName).clearMappingData();}
var arr=this.getTracks();for(var i=0,l=arr.length;i<l;i++){var track=arr[i];track.clearMappingData();}}
net.watchee.Device.prototype.drawHistoryLine=function(){this.getTrack(trackName).drawHistoryLine();}
net.watchee.Device.prototype.updateNiceDeviceName=function(msgUnit){if(org.xmlBlaster.util.isDefined(msgUnit)){if(msgUnit.getQosData().hasClientProperty("niceDeviceName")){this.niceDeviceName=msgUnit.getQosData().getClientProperty("niceDeviceName","");return this.niceDeviceName;}
var sessionName=msgUnit.getQosData().getSender();if(sessionName.getSubjectId().length<16)
this.niceDeviceName=sessionName.getSubjectId();}
return this.niceDeviceName;}
net.watchee.Device.prototype.getNiceName=function(){var alias=this.getBuddyTO().getAlias();var first=this.getBuddyTO().getFirstName();var last=this.getBuddyTO().getLastName();if(alias.length==0&&first.length==0&&last.length==0)
return this.deviceId;else if(alias.length!=0&&(first.length==0||last.length==0))
return alias+" ("+this.deviceId+")";else if(alias.length!=0&&first.length!=0&&last.length!=0)
return alias+" "+last+", "+first+" ("+this.deviceId+")";return this.deviceId;}
net.watchee.Device.prototype.getDeviceId=function(){if(!org.xmlBlaster.util.isFilled(this.deviceId))
return"";return this.deviceId;}
net.watchee.Device.prototype.getBuddyTO=function(){return this.watchee.getBuddyManager().getBuddyOrFriendOf(this.getDeviceId());}
net.watchee.Device.prototype.getLoginName=function(){return this.getBuddyTO().getLoginName();}
net.watchee.Device.prototype.setOnline=function(online){this.getBuddyTO().setOnlineStatus(online);}
net.watchee.Device.prototype.isOnline=function(){return this.getBuddyTO().isOnline();}
net.watchee.Device.prototype.isDeviceCurrentlySleepingOrOffline=function(){if(this.isOnline())
return false;return this.deviceSleeping;}
net.watchee.Device.prototype.isDeviceSleeping=function(){return this.deviceSleeping;}
net.watchee.Device.prototype.setDeviceSleeping=function(sleeping){var old=this.deviceSleeping;this.deviceSleeping=sleeping;return old;}
net.watchee.Device.prototype.getConfiguredPowerSaveMode=function(){if(!this.getDeviceInfo().isWonde()){return-1;}
if(this.getPropertyCollection()!=null&&this.getPropertyCollection().contains("VsleepModeNum")){var sleepActive=this.getPropertyCollection().getBoolean("Ssleep",false);if(!sleepActive)
return 0;var psmMode=this.getPropertyCollection().getInt("VsleepModeNum",0);return psmMode;}
var psmMode=this.getDeviceInfo().getSleepModeNum();if(psmMode!=-1)
return psmMode;return 0;}
net.watchee.Device.prototype.getCurrentPowerSaveMode=function(){if(!this.getDeviceInfo().isWonde()){return-1;}
if(!this.isDeviceSleeping()){return 0;}
if(this.getPropertyCollection()!=null&&this.getPropertyCollection().contains("VsleepModeNum")){var psmMode=this.getPropertyCollection().getStr("VsleepModeNum",0);return psmMode;}
var psmMode=this.getDeviceInfo().getSleepModeNum();return psmMode;}
net.watchee.Device.prototype.getCurrentGpsData=function(){var track=this.getCurrentTrack();if(track==null)
return null;return track.getCurrentGpsData();}
net.watchee.Device.prototype.getHwPasswd=function(){var deviceMapping=this.getDeviceMapping();if(deviceMapping!=null&&deviceMapping.getHwPasswd()!=null&&deviceMapping.getHwPasswd().length>0)
return deviceMapping.getHwPasswd();if(this.getPropertyCollection()!=null){var hwPasswd=this.getPropertyCollection().getStr("pw",null);if(hwPasswd!=null&&hwPasswd.length>0){return hwPasswd;}}
if(this.getDeviceInfo().isWonde())
return"0000";return"123456";},net.watchee.Device.prototype.addGPSSentence=function(gpsSentence,msgUnit,trackName){var trackName=trackName||null;var isCurrent=(trackName==null);var track=this.getTrack(trackName);var gpsData=track.addGPSSentence(gpsSentence,msgUnit);var data={track:track,gpsData:gpsData};this.eventManager.fireEvent("addGps",data);if(isCurrent){var propertyCollection=new net.watchee.PropertyCollection("Configuration",net.watchee.BuddyListTO.TYPE_UPDATE);var bat=gpsData.getBatteryPercent(-1);if(bat>=0){var pair=new net.watchee.PropertyPair(net.watchee.GPSData.KEY_BATTERY_LEVEL_PERCENT,bat,false,"int");pair.setTimestampUtcIsoStr(gpsData.getUtcIsoStr());propertyCollection.add(pair);}
var volt=gpsData.getInfoNumber(net.watchee.GPSData.KEY_VOLTAGE,-1.0);if(volt>0.1){var pair=new net.watchee.PropertyPair(net.watchee.GPSData.KEY_VOLTAGE,volt,false,"float");pair.setTimestampUtcIsoStr(gpsData.getUtcIsoStr());propertyCollection.add(pair);}
if(gpsData.containsInfo(net.watchee.GPSData.KEY_CHARGED)!=null){var charged=gpsData.getInfoBoolean(net.watchee.GPSData.KEY_CHARGED,null);var pair=new net.watchee.PropertyPair(net.watchee.GPSData.KEY_CHARGED,charged,false,"bool");pair.setTimestampUtcIsoStr(gpsData.getUtcIsoStr());propertyCollection.add(pair);}
if(propertyCollection.size()>0){this.setPropertyCollection(propertyCollection,false);}}
return gpsData;}
net.watchee.Device.prototype.getPropertyCollection=function(){return this.propertyCollection;}
net.watchee.Device.prototype.isInputAnalog=function(inputNumber,trackGui){if(inputNumber<1||inputNumber>2){return false;}
if(!this.getDeviceInfo().supportsAnalogInput()){return false;}
var hash=this.getIOAnalogHash();var isAnalogX=hash.contains("inAnalog"+inputNumber+".a");if(isAnalogX){if(this.hasPropertyCollectionCompleteCached()){var key="SanalogIn"+inputNumber;var ison=this.getPropertyCollection().getBoolean(key,false);return ison;}
else{var trackGui=trackGui||null;if(trackGui!=null&&trackGui.sendGetDeviceConfiguration!==undefined){var loginName=this.getLoginName();if(this.autoRetrieveDeviceConfiguration===undefined)
this.autoRetrieveDeviceConfiguration=false;if(!this.autoRetrieveDeviceConfiguration){this.autoRetrieveDeviceConfiguration=true;trackGui.sendGetDeviceConfiguration(loginName);}}}}
return isAnalogX;}
net.watchee.Device.prototype.getInputVoltage=function(inputNumber,gpsData){if(!this.isInputAnalog(inputNumber)){return null;}
var gpsData=gpsData||this.getCurrentGpsData();if(gpsData==null){return null;}
var key=this.analogInputNumberToKey(inputNumber);var voltage=gpsData.getInfo(key,0.0);return voltage;}
net.watchee.Device.prototype.getInputStatus=function(inputNumber){var gpsData=this.getCurrentGpsData();if(gpsData==null){return null;}
return gpsData.getInputStatus(inputNumber);}
net.watchee.Device.prototype.getInputLedIcon=function(inputNumber,pixelSize){var gpsData=this.getCurrentGpsData();if(gpsData==null){var pixelSize=org.xmlBlaster.util.toNumber(pixelSize,12);return xbGetIcon(pixelSize+"/led-gray.png");}
return gpsData.getInputLedIcon(inputNumber,pixelSize);}
net.watchee.Device.prototype.getInputAliasNameKey=function(inputNumber,isOn){var labelKey=net.watchee.GPSData.KEY_IN_PREFIX+inputNumber;labelKey+=isOn?".labelOn":".labelOff";return labelKey;}
net.watchee.Device.prototype.getCountInputStatus=function(){return 4;}
net.watchee.Device.prototype.getOutputStatus=function(inputNumber){var index=inputNumber-1;if(index>=0&&index<this.outputStatusArr.length)
return this.outputStatusArr[index];return null;}
net.watchee.Device.prototype.getCountOutputStatus=function(){return this.outputStatusArr.length;}
net.watchee.Device.prototype.getOutputAliasNameKey=function(inputNumber,isOn){var labelKey=net.watchee.GPSData.KEY_OUT_PREFIX+inputNumber;labelKey+=isOn?".labelOn":".labelOff";return labelKey;}
net.watchee.Device.prototype.getOutputLedIcon=function(inputNumber,pixelSize){var pixelSize=org.xmlBlaster.util.toNumber(pixelSize,12);var status=this.getOutputStatus(inputNumber);if(status==null){return xbGetIcon(pixelSize+"/led-gray.png");}
else if(status==true){return xbGetIcon(pixelSize+"/led-green.png");}
else{return xbGetIcon(pixelSize+"/led-red.png");}}
net.watchee.Device.prototype.getIOAliasName=function(portName,isOn){var hash=this.getIOAliasNameHash();var alias=isOn?hash.get(portName+".labelOn"):hash.get(portName+".labelOff");return alias;}
net.watchee.Device.prototype.resetIOAnalogCache=function(){this.ioAnalogHash=null;}
net.watchee.Device.prototype.getIOAliasNameHash=function(){if(this.ioAliasNamesHash==null){var csv=this.getBuddyTO()!=null?this.getBuddyTO().getAccountPropertyStr("ioAliasNames"):null;if(csv!=null){this.ioAliasNamesHash=org.xmlBlaster.util.Hashtable.parseCSV(csv);return this.ioAliasNamesHash;}
else{return new org.xmlBlaster.util.Hashtable();}}else{return this.ioAliasNamesHash;}}
net.watchee.Device.prototype.getIOAnalogHash=function(){if(this.ioAnalogHash==null){var csv=this.getBuddyTO()!=null?this.getBuddyTO().getAccountPropertyStr("ioAnalog"):null;if(csv!=null){this.ioAnalogHash=org.xmlBlaster.util.Hashtable.parseCSV(csv);return this.ioAnalogHash;}
else{return new org.xmlBlaster.util.Hashtable();}}else{return this.ioAnalogHash;}}
net.watchee.Device.prototype.analogInputNumberToKey=function(inputNumber){if(inputNumber==1){return net.watchee.GPSData.KEY_INANALOG1;}
else if(inputNumber==2){return net.watchee.GPSData.KEY_INANALOG2;}
return"";}
net.watchee.Device.prototype.getIOAnalogText=function(inputNumber){var key=this.analogInputNumberToKey(inputNumber);return this.getIOAnalogHash().get(key+".label",key);}
net.watchee.Device.prototype.getIOAnalogUnit=function(inputNumber){return this.getIOAnalogHash().get(this.analogInputNumberToKey(inputNumber)+".unit","V");}
net.watchee.Device.prototype.getIOAnalogA=function(inputNumber,defaultValue){var defaultValue=defaultValue||1.0;var a=this.getIOAnalogHash().getNumber(this.analogInputNumberToKey(inputNumber)+".a",defaultValue);return a;}
net.watchee.Device.prototype.getIOAnalogB=function(inputNumber){var b=this.getIOAnalogHash().getNumber(this.analogInputNumberToKey(inputNumber)+".b",0.0);return b;}
net.watchee.Device.prototype.getIOAnalogDecimalDigits=function(inputNumber){var decimalDigits=this.getIOAnalogHash().getNumber(this.analogInputNumberToKey(inputNumber)+".decimalDigits",0);return decimalDigits;}
net.watchee.Device.prototype.getIOAnalogComputedResult=function(inputNumber,gpsData){var a=this.getIOAnalogA(inputNumber);var b=this.getIOAnalogB(inputNumber);var x=this.getInputVoltage(inputNumber,gpsData);if(x==null)return null;var fx=a*x+b;return fx;}
net.watchee.Device.prototype.getIOAnalogComputedResultRounded=function(inputNumber,defaultValue,gpsData){var fx=this.getIOAnalogComputedResult(inputNumber,gpsData);if(fx==null){var defaultValue=defaultValue||0;return defaultValue;}
fx=org.xmlBlaster.util.round(fx,this.getIOAnalogDecimalDigits(inputNumber));return fx;}
net.watchee.Device.prototype.hasPropertyCollectionCompleteCached=function(){if(this.propertyCollection==null)
return false;if(this.propertyCollection.isAll())
return true;return false;}
net.watchee.Device.prototype.setPropertyCollection=function(propertyCollectionNew,isComplete){if(this.propertyCollection==null||isComplete){this.propertyCollection=propertyCollectionNew;}
else{this.propertyCollection.merge(propertyCollectionNew);}
var newVoltDate=propertyCollectionNew.getDate(net.watchee.GPSData.KEY_VOLTAGE);if(newVoltDate==null){newVoltDate=propertyCollectionNew.getDate(net.watchee.GPSData.KEY_BATTERY_LEVEL_PERCENT);if(newVoltDate==null){newVoltDate=propertyCollectionNew.getDate(net.watchee.GPSData.KEY_BATTERY_STATE);}
if(newVoltDate==null){newVoltDate=propertyCollectionNew.getDate("batterylevel");}}
var isNewer=true;if(this.voltDate!=null&&newVoltDate!=null){var existMSec=this.voltDate.getTime();var newMSec=newVoltDate.getTime();if(newMSec<=existMSec){isNewer=false;}}
if(isNewer){this.volt=propertyCollectionNew.getFloat(net.watchee.GPSData.KEY_VOLTAGE,this.volt);var batP=this.batteryLevelPercent;var bat=propertyCollectionNew.getInt(net.watchee.GPSData.KEY_BATTERY_STATE,-9);if(bat>=0&&bat<=9){batP=bat*10;}
else if(bat==-1){batP=-1;}
this.batteryLevelPercent=propertyCollectionNew.getInt(net.watchee.GPSData.KEY_BATTERY_LEVEL_PERCENT,batP);if(this.batteryLevelPercent==-1){this.batteryLevelPercent=propertyCollectionNew.getInt("batterylevel",-1);}
this.charged=propertyCollectionNew.getBooleanRelaxed(net.watchee.GPSData.KEY_CHARGED,this.charged);this.voltDate=newVoltDate;}
var eventData={device:this,propertyCollection:propertyCollectionNew,isComplete:isComplete};this.eventManager.fireEvent("remotePropertiesChanged",eventData);this.watchee.getBuddyManager().getEventManager().fireEvent("remotePropertiesChanged",eventData);}
net.watchee.Device.prototype.setVoltDate=function(date){this.voltDate=date;}
net.watchee.Device.CUR_TRACK_KEY="__current";net.watchee.Device.SERVICE_KEY_GETSETTINGS="getSettings";net.watchee.Device.SERVICE_KEY_SETSETTING="setSetting";net.watchee.Device.VALUE_TASK_NAMED_GETCOMMANDLIST="getCommandList";net.watchee.X_SMS=function(from,to,subject,body){if(!org.xmlBlaster.util.isDefined(from))
this.fromSessionName=null;else if(from instanceof org.xmlBlaster.util.SessionName)
this.fromSessionName=from;else
this.fromSessionName=new org.xmlBlaster.util.SessionName(from);if(!org.xmlBlaster.util.isDefined(to))
this.toSessionName=null;else if(to instanceof org.xmlBlaster.util.SessionName)
this.toSessionName=to;else
this.toSessionName=new org.xmlBlaster.util.SessionName(to);this.subject=subject||"";this.body=body||"";this.receivedGmtDate=org.xmlBlaster.util.getCurrentGmtDate(null);this.sendGmtDate=this.receivedGmtDate;this.isInboundMsg=false;this.enmea="";this.properties=new org.xmlBlaster.util.Hashtable();this.getProperties=function(){return this.properties;}
this.setClientProperties=function(clientProperties){var clientProperties=clientProperties||null;if(clientProperties==null)
return;var arr=clientProperties.getKeys();for(var i=0,l=arr.length;i<l;i++){var cp=clientProperties.get(arr[i],null);if(cp==null)
continue;this.properties.put(arr[i],cp.getValue());}}
this.getToStr=function(){if(this.toSessionName==null)
return"";return this.toSessionName.getSubjectId();}
this.getTo=function(){return this.toSessionName;}
this.isTo=function(loginName){return(this.getTo().getSubjectId()==loginName);}
this.getSubject=function(){return this.subject;}
this.hasSubject=function(){return(this.subject!=null&&this.subject.length>0);}
this.getBody=function(){return this.body;}
this.getSendGmtDate=function(){return this.sendGmtDate;}
this.getSendGmtTimestampStr=function(){return org.xmlBlaster.util.getCurrentIsoGmtTimestampStr(this.sendGmtDate);}
this.getLocalSendTimeStr=function(){var localDate=org.xmlBlaster.util.getLocalDateFromGmt(this.sendGmtDate);return org.xmlBlaster.util.getTimeStr(localDate);}
this.getLocalSendDateStr=function(){var localDate=org.xmlBlaster.util.getLocalDateFromGmt(this.sendGmtDate);return org.xmlBlaster.util.getDateStr(localDate);}
this.getFrom=function(){return this.fromSessionName;}
this.isFrom=function(loginName){return(this.getFrom().getSubjectId()==loginName);}
this.getFromStr=function(){if(this.fromSessionName==null)
return"";return this.fromSessionName.getSubjectId();}
this.getGmtTimestampStr=function(){return org.xmlBlaster.util.getCurrentIsoGmtTimestampStr(this.receivedGmtDate);}
this.getGmtDateStr=function(){return org.xmlBlaster.util.getDateStr(this.receivedGmtDate);}
this.getGmtTimeStr=function(){return org.xmlBlaster.util.getTimeStr(this.receivedGmtDate);}
this.getLocalTimeStr=function(){var localDate=org.xmlBlaster.util.getLocalDateFromGmt(this.receivedGmtDate,withSeconds);return org.xmlBlaster.util.getTimeStr(localDate,withSeconds);}
this.getLocalDateStr=function(){var localDate=org.xmlBlaster.util.getLocalDateFromGmt(this.receivedGmtDate);return org.xmlBlaster.util.getDateStr(localDate);}
this.isInbound=function(){return this.isInboundMsg;}
this.getEnmea=function(){return this.enmea;}
this.toXml=function(){var xml="<x>";xml+="<to>"+org.xmlBlaster.util.escapeXml(this.getToStr())+"</to>";xml+="<sb>"+org.xmlBlaster.util.escapeXml(this.subject)+"</sb>";xml+="<b>"+org.xmlBlaster.util.escapeXml(this.body)+"</b>";xml+="<st>"+org.xmlBlaster.util.escapeXml(org.xmlBlaster.util.getCurrentIsoGmtTimestampStr(this.receivedGmtDate))+"</st>";xml+="<f>"+org.xmlBlaster.util.escapeXml(this.getFromStr())+"</f>";if(org.xmlBlaster.util.isFilled(this.enmea))
xml+="<enmea>"+org.xmlBlaster.util.escapeXml(this.getEnmea())+"</enmea>";xml+="</x>";return xml;}
this.dump=function(niceName){var text="";if(this.isInbound()){text+="From: ";text+=this.getFromStr();}
else{text+="To: ";text+=this.getToStr();}
text+="\n";text+="Date: "+this.getGmtTimestampStr()+"\n";text+=this.body;return text;}}
net.watchee.X_SMS.parse=function(from,xmlString){var log=net.watchee.util.log;if(!org.xmlBlaster.util.isDefined(xmlString)){log.error("net.watchee.X_SMS.parse xmlString is undefined");return null;}
if(from===undefined){log.error("net.watchee.X_SMS.parse 'from' is undefined");return null;}
var domDocument=org.xmlBlaster.util.getDOMDocument(xmlString);var rootNode=domDocument.documentElement;var ME="watchee.js-X_SMS.parse(): ";var log=net.watchee.util.log;if(rootNode.nodeName=="parsererror"){log.error(ME+"'parsererror' for "+xmlString);return null;}
var xsms=new net.watchee.X_SMS();xsms.xmlString=xmlString;if(from instanceof org.xmlBlaster.util.SessionName){xsms.fromSessionName=from;}
else{if(from.length<1)
xsms.fromSessionName=null;else
xsms.fromSessionName=new org.xmlBlaster.util.SessionName(from);}
xsms.isInboundMsg=true;for(var i=0;i<rootNode.childNodes.length;i++){var node=rootNode.childNodes[i];if(node.nodeType!=Node.ELEMENT_NODE){var val=(node.nodeValue!=undefined&&node.nodeValue!=null)?(": '"+node.nodeValue+"'"):"";var txt="X_SMS(): Ignoring xsms response node "+org.xmlBlaster.util.getXPathLocation(node,true)+val;(node.nodeType==Node.COMMENT_NODE||node.nodeType==Node.TEXT_NODE)?net.watchee.util.log.debug(ME2+txt):net.watchee.util.log.warn(ME2+txt);continue;}
switch(node.nodeName){case"to":var toStr=org.xmlBlaster.util.collectTextFromNodeChilds(node);xsms.toSessionName=new org.xmlBlaster.util.SessionName(toStr);break;case"sb":xsms.subject=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"b":xsms.body=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"tt":xsms.toType=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"st":var iso=org.xmlBlaster.util.collectTextFromNodeChilds(node);xsms.sendGmtDate=org.xmlBlaster.util.getDateFromIsoDateStr(iso);break;case"ft":xsms.fromType=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"f":var from2Str=org.xmlBlaster.util.collectTextFromNodeChilds(node);var from2=new org.xmlBlaster.util.SessionName(from2Str);if(xsms.fromSessionName==null)
xsms.fromSessionName=from2;else if(from2.getSubjectId()!=xsms.fromSessionName.getSubjectId()){}
break;case"enmea":xsms.enmea=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;default:log.warn(ME2+"X_SMS("+org.xmlBlaster.util.getXPathLocation(node,true)+"): Ignoring xSMS tag '"+node.nodeName+"'");break;}}
return xsms;}
net.watchee.BuddyPermissionTO=function(name,description,isFriendOf){this.name=name||"";this.description=description||"";this.isFriendOf=org.xmlBlaster.util.parseBoolean(isFriendOf,false);this.getName=function(){return this.name;}
this.getDescription=function(){return this.description;}
this.getLabel=function(){if(this.description.length<1)
return this.name;return this.name+" - "+this.description;}
this.isGranted=function(){return true;}
this.toXml=function(){var xml="<pe n='"+org.xmlBlaster.util.escapeXml(this.name)+"'";if(org.xmlBlaster.util.isFilled(this.description))
xml+=" d='"+org.xmlBlaster.util.escapeXml(this.description)+"'";if(isFriendOf)
xml+=" t='in'";xml+="/>";return xml;}}
net.watchee.PermissionTemplateTO=function(name,type,description){this.name=name||"";this.type=type||"";this.description=description||"";this.getName=function(){return this.name;}
this.getType=function(){return this.type;}
this.getDescription=function(){return this.description;}
this.getLabel=function(){if(this.description.length<1)
return this.name;return this.name+" - "+this.description;}
this.toXml=function(){var xml="<pe n='"+org.xmlBlaster.util.escapeXml(this.name)+"'";if(org.xmlBlaster.util.isFilled(this.type))
xml+=" t='"+org.xmlBlaster.util.escapeXml(this.type)+"'";if(org.xmlBlaster.util.isFilled(this.description))
xml+=" d='"+org.xmlBlaster.util.escapeXml(this.description)+"'";xml+="/>";return xml;}}
net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_Basic="GPSvision.Basic";net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_Comfort="GPSvision.Comfort";net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_Professional="GPSvision.Professional";net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_TrialAccess="GPSvision.TrialAccess";net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_Enterprise="GPSvision.Enterprise";net.watchee.PermissionTemplateTO.PERMISSION_SkipperInAppPurchase="SkipperInAppPurchase";net.watchee.PermissionTemplateListTO=function(permissionTemplates){this.permissionTemplates=permissionTemplates||new Array();this.addPermissionTemplate=function(ptTO){this.permissionTemplates.push(ptTO);}
this.getPermissionTemplates=function(){return this.permissionTemplates;}
this.getPermissionTemplate=function(name){for(var i=0,l=this.permissionTemplates.length;i<l;i++){var perm=this.permissionTemplates[i];if(perm.getName()==name)
return perm;}
return null;}
this.toXml=function(){var xml="<pc>";for(var i=0,l=this.permissionTemplates.length;i<l;i++){var perm=this.permissionTemplates[i];xml+=perm.toXml();}
xml+="</pc>";return xml;}
this.destruct=function(){this.permissionTemplates=null;}}
net.watchee.PermissionTemplateListTO.parse=function(xmlString){if(!org.xmlBlaster.util.isDefined(xmlString)){return null;}
var domDocument=org.xmlBlaster.util.getDOMDocument(xmlString);var rootNode=domDocument.documentElement;var ME="watchee.js-PermissionTemplateListTO.parse(): ";var log=net.watchee.util.log;if(rootNode.nodeName=="parsererror"){log.error(ME+"'parsererror' for "+xmlString);return null;}
var permissionTemplateListTO=new net.watchee.PermissionTemplateListTO();for(var i=0,l=rootNode.childNodes.length;i<l;i++){var node=rootNode.childNodes[i];if(node.nodeType!=Node.ELEMENT_NODE){var val=org.xmlBlaster.util.isDefined(node.nodeValue)?node.nodeValue:"";var tmp=org.xmlBlaster.util.trim(val);if(tmp.length==0)continue;val=": '"+val+"'";var txt="Ignoring permissionTemplate list "+org.xmlBlaster.util.getXPathLocation(node,true)+val;(node.nodeType==Node.COMMENT_NODE||node.nodeType==Node.TEXT_NODE)?org.xmlBlaster.util.log.debug(ME+txt):org.xmlBlaster.util.log.warn(ME+txt);continue;}
if(node.nodeName=="pe"){var name=node.getAttribute('n');var type=node.getAttribute('t');var desc=node.getAttribute('d');var perm=new net.watchee.PermissionTemplateTO(name,type,desc);permissionTemplateListTO.addPermissionTemplate(perm);}
else{if(node.nodeName!="#text")
log.error(ME+"Tag <"+node.nodeName+"> not known: "+xmlString);}}
return permissionTemplateListTO;}
net.watchee.BuddyPermissionTO.PERMISSION_GPS="gps";net.watchee.BuddyPermissionTO.PERMISSION_ALARM="alarm";net.watchee.BuddyPermissionTO.PERMISSION_GPS_HISTORY="hist";net.watchee.BuddyPermissionTO.PERMISSION_POI="hist";net.watchee.BuddyPermissionTO.PERMISSION_XSMS="xsms";net.watchee.BuddyPermissionTO.PERMISSION_DEVICE_STATUS="status"
net.watchee.BuddyPermissionTO.PERMISSION_ALARM="alarm"
net.watchee.BuddyPermissionTO.PERMISSION_CFG="cfg";net.watchee.BuddyPermissionTO.PERMISSION_CFG_TRACKING="cfg";net.watchee.DeviceMapping=function(loginName){this.loginName=loginName;this.hwPasswd="";this.hwPhoneNumber="";this.hwDeviceImei="";this.getHwPasswd=function(){return this.hwPasswd;}
this.setHwPasswd=function(hwPassword){this.hwPasswd=hwPassword;}
this.getHwPhoneNumber=function(){return this.hwPhoneNumber;}
this.setHwPhoneNumber=function(hwPhoneNumber){this.hwPhoneNumber=hwPhoneNumber;}
this.getDeviceImei=function(){return this.hwDeviceImei;}
this.setDeviceImei=function(deviceId){this.hwDeviceImei=deviceId;}}
net.watchee.DeviceMapping.parseCSV=function(loginName,csv){var dm=new net.watchee.DeviceMapping(loginName);if(csv==undefined||csv==null)
return dm;var hash=org.xmlBlaster.util.Hashtable.parseCSV(csv);dm.setHwPasswd(hash.get("hwPasswd",""));dm.setHwPhoneNumber(hash.get("hwPhoneNumber",""));dm.setDeviceImei(hash.get("deviceImei",""));return dm;}
net.watchee.AccountTO=function(watchee,loginName){if(!org.xmlBlaster.util.isDefined(watchee))
throw"IllegalArgumentException net.watchee.AccountTO without watchee";if(!org.xmlBlaster.util.isFilled(loginName))
throw"IllegalArgumentException net.watchee.AccountTO without loginName";this.watchee=watchee;this.loginName=loginName;this.password="";this.active=true;this.oemName="";this.permissionTemplateStr="";this.maxMonthlySms=0;this.alias=this.loginName;this.firstName="";this.lastName="";this.email="";this.gender="";this.phoneNumber="";this.language="en";this.timezone="Europe/Berlin";this.endDate=null;this.pictureId="";this.pictureContentType="image/jpeg";this.pictureSize="";this.buddyTO=null;this.creationTs=null;this.lastLoginDate=null;this.homeViewsData=null;this.deviceMappingCached=null;this.accountPropertyCollection=new net.watchee.PropertyCollection();this._initialOnlineStatus=net.watchee.BuddyTO.STATUS_OFFLINE;this.getHomeViewsData=function(){if(this.homeViewsData==null){this.homeViewsData=net.watchee.HomeViews.parse(this.getAccountPropertyCollection());}
return this.homeViewsData;}
this.setLoginName=function(loginName){this.loginName=loginName;}
this.getLoginName=function(){return this.loginName;}
this.getPassword=function(){return this.password;}
this.setPassword=function(password){this.password=password;}
this.isActive=function(){return this.active;}
this.setActive=function(active){this.active=active;}
this.getOemName=function(){return this.oemName;}
this.setOemName=function(oemName){this.oemName=oemName;}
this.getOemPropertyStr=function(oemKey,defaultValue){return this.buddyTO.getOemPropertyStr(oemKey,defaultValue);}
this.getMaxMonthlySms=function(){return this.maxMonthlySms;}
this.getCurrentMonthlySms=function(){var value=this.getAccountPropertyStr("SMS/counter","");var ts=org.xmlBlaster.util.getCurrentIsoLocalTimestampStrFromUtcStr(null,false,false);var yyyymm=ts.substring(0,7);var arr=value.split(",");for(var i=0;i<arr.length;i++){var tmp=arr[i];if(tmp.indexOf(yyyymm)==0){var xx=tmp.split("=");if(xx.length>1)
return xx[1];return"";}}
return"";}
this.setMaxMonthlySms=function(maxMonthlySms){this.maxMonthlySms=maxMonthlySms;}
this.getAlias=function(){return this.alias;}
this.setAlias=function(aliasName){this.alias=aliasName;}
this.getFirstName=function(){return this.firstName;}
this.setFirstName=function(firstName){this.firstName=firstName;}
this.getLastName=function(){return this.lastName;}
this.setLastName=function(lastName){this.lastName=lastName;}
this.getEmail=function(){return this.email;}
this.setEmail=function(email){this.email=email;}
this.getGender=function(){return this.gender;}
this.setGender=function(genderName){this.gender=genderName;}
this.getPhoneNumber=function(){return this.phoneNumber;}
this.setPhoneNumber=function(phoneNumber){this.phoneNumber=phoneNumber;}
this.setLanguage=function(language){this.language=language;}
this.getLanguage=function(){return this.language;}
this.getLanguageId=function(fallback){var fallback=fallback||"en";var locale=this.getLanguage();if(locale==null)
return fallback;var index=locale.indexOf("_");if(index!=-1){locale=locale.substring(0,index);}
return locale;}
this.getCountryId=function(fallback){var fallback=fallback||"US";var locale=this.getLanguage();if(locale==null)
return fallback;var index=locale.indexOf("_");if(index!=-1){locale=locale.substring(0,index);return locale;}
return fallback;}
this.setTimezone=function(timezone){this.timezone=timezone;}
this.getTimezone=function(){return this.timezone;}
this.getCreationTs=function(){return this.creationTs;}
this.getCreationDateStr=function(){var date=this.creationTs||null;if(date==null)
return"";return org.xmlBlaster.util.getDateStr(date);}
this.setCreationTs=function(creationTs){var creationTs=creationTs||null;this.creationTs=creationTs;}
this.setCreationTsStr=function(isoDateStr){var isoDateStr=isoDateStr||null;if(isoDateStr==null||isoDateStr==""){this.creationTs=null;}
else{this.creationTs=org.xmlBlaster.util.getDateFromIsoDateStr(isoDateStr);}}
this.getDeviceMapping=function(){if(this.deviceMappingCached!=null)
return this.deviceMappingCached;var csv=this.getAccountPropertyStr("DeviceMapping",null);if(csv==null)
return null;this.deviceMappingCached=net.watchee.DeviceMapping.parseCSV(this.loginName,csv);return this.deviceMappingCached;}
this.getLastLoginWebStr=function(){var csv=this.accountPropertyCollection.getStr("lastLoginTsWeb","");return csv;}
this.getEndDate=function(){return this.endDate;}
this.getEndDateStr=function(){var date=this.endDate||null;if(date==null)
return"";return org.xmlBlaster.util.getDateStr(date);}
this.setEndDate=function(endDate){var endDate=endDate||null;this.endDate=endDate;}
this.setEndDateStr=function(isoDateStr){var isoDateStr=isoDateStr||null;if(isoDateStr==null||isoDateStr==""){this.endDate=null;}
else{this.endDate=org.xmlBlaster.util.getDateFromIsoDateStr(isoDateStr);}}
this.getPictureId=function(){return this.pictureId;}
this.getPictureContentType=function(){return this.pictureContentType;}
this.getPictureSize=function(){return this.pictureSize}
this.getLastPositionTs=function(){var ts=this.getTrackingInfoMap().get("lastPositionTs","");return ts;}
this.getNumberOfTracks=function(){var num=this.getTrackingInfoMap().getNumber("numberOfTracks",0);return num;}
this.getTrackingInfoMap=function(){var hash=org.xmlBlaster.util.Hashtable.parseCSV(this.getTrackingInfoCSV());return hash;}
this.getTrackingInfoCSV=function(){var csv=this.accountPropertyCollection.getStr("trackingInfo","");return csv;}
this.getDeviceInfoCSV=function(){return this.accountPropertyCollection.getStr("deviceInfo","");}
this.isPublic=function(){return this.getBuddyTO().isPublic();}
this.getBuddyTO=function(){if(this.buddyTO!=null)
return this.buddyTO;this.buddyTO=new net.watchee.BuddyTO(this.watchee,this.loginName,this.alias,this.pictureId);this.buddyTO.accountTO=this;this.buddyTO.setFirstName(this.firstName);this.buddyTO.setLastName(this.lastName);this.buddyTO.setEmail(this.email);this.buddyTO.setPhoneNumber(this.phoneNumber);this.buddyTO.setOnlineStatus(this._initialOnlineStatus);this.buddyTO.setAccountPropertyCollection(this.getAccountPropertyCollection());return this.buddyTO;}
this.watchee.getEventManager().addListener("setPermissionTemplates",function(ev){if(this.watchee==null)return;this.getBuddyTO();this.loadPerms(ev.getData());},this);this.loadPerms=function(templListTO){var templates=templListTO.getPermissionTemplates();for(var i=0,l=templates.length;i<l;i++){var templ=templates[i];var isFriendOf=true;var perm=new net.watchee.BuddyPermissionTO(templ.getName(),templ.getDescription(),isFriendOf);this.buddyTO.addPermissionInbound(perm);}}
this.toXml=function(){var xml="<ac>";xml+="<ln>"+org.xmlBlaster.util.escapeXml(this.loginName)+"</ln>";if(org.xmlBlaster.util.isFilled(this.active))
xml+="<act>"+org.xmlBlaster.util.escapeXml(this.active)+"</act>";if(org.xmlBlaster.util.isFilled(this.password))
xml+="<pw>"+org.xmlBlaster.util.escapeXml(this.password)+"</pw>";if(org.xmlBlaster.util.isFilled(this.oemName))
xml+="<oem>"+org.xmlBlaster.util.escapeXml(this.oemName)+"</oem>";if(org.xmlBlaster.util.isFilled(this.permissionTemplateStr))
xml+="<ptl>"+org.xmlBlaster.util.escapeXml(this.permissionTemplateStr)+"</ptl>";if(this.maxMonthlySms>0)
xml+="<maxMonthlySms>"+this.maxMonthlySms+"</maxMonthlySms>";if(org.xmlBlaster.util.isFilled(this.alias))
xml+="<al>"+org.xmlBlaster.util.escapeXml(this.alias)+"</al>";if(org.xmlBlaster.util.isFilled(this.firstName))
xml+="<fn>"+org.xmlBlaster.util.escapeXml(this.firstName)+"</fn>";if(org.xmlBlaster.util.isFilled(this.lastName))
xml+="<sn>"+org.xmlBlaster.util.escapeXml(this.lastName)+"</sn>";if(org.xmlBlaster.util.isFilled(this.email))
xml+="<e>"+org.xmlBlaster.util.escapeXml(this.email)+"</e>";if(org.xmlBlaster.util.isFilled(this.gender))
xml+="<ge>"+org.xmlBlaster.util.escapeXml(this.gender)+"</ge>";if(org.xmlBlaster.util.isFilled(this.phoneNumber))
xml+="<pn>"+org.xmlBlaster.util.escapeXml(this.phoneNumber)+"</pn>";if(org.xmlBlaster.util.isFilled(this.language))
xml+="<la>"+org.xmlBlaster.util.escapeXml(this.language)+"</la>";if(org.xmlBlaster.util.isFilled(this.timezone))
xml+="<tz>"+org.xmlBlaster.util.escapeXml(this.timezone)+"</tz>";if(org.xmlBlaster.util.isFilled(this.onlineStatus))
xml+="<st>"+org.xmlBlaster.util.escapeXml(this.onlineStatus)+"</st>";if(this.endDate!=null)
xml+="<ed>"+org.xmlBlaster.util.getCurrentIsoGmtTimestampStr(this.endDate)+"</ed>";if(this.accountPropertyCollection!=null){var keyArray=this.accountPropertyCollection.getHashtable().getKeys();for(var i=0,l=keyArray.length;i<l;i++){var key=keyArray[i];var ap=this.accountPropertyCollection.get(key);xml+=ap.toXml();}}
xml+="</ac>";return xml;}}
net.watchee.AccountTO.prototype.getPermissionTemplateStr=function(){return this.permissionTemplateStr;}
net.watchee.AccountTO.prototype.getPermissionTemplateStrNice=function(){if(this.permissionTemplateStr==null){return null;}
var index=this.permissionTemplateStr.indexOf(".");if(index==-1){return this.permissionTemplateStr;}
var postfix=this.permissionTemplateStr.substring(index+1);return postfix;}
net.watchee.AccountTO.prototype.setPermissionTemplateStr=function(permissionTemplateStr){this.permissionTemplateStr=permissionTemplateStr;}
net.watchee.AccountTO.prototype.hasPermissionTemplate=function(permissionTemplateStr){var permissionTemplateStr=permissionTemplateStr||null;if(permissionTemplateStr==null)
return false;if(this.permissionTemplateStr==null)
return false;return this.permissionTemplateStr==permissionTemplateStr;}
net.watchee.AccountTO.prototype.hasPermissionRestWebService=function(){return this.hasPermissionTemplate(net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_Enterprise);}
net.watchee.AccountTO.prototype.hasPermissionPoiConfig=function(){return this.hasPermissionTemplate(net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_Enterprise);}
net.watchee.AccountTO.prototype.hasPermissionPoiReport=function(){return this.hasPermissionTemplate(net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_Enterprise);}
net.watchee.AccountTO.prototype.getAccountPropertyCollection=function(){return this.accountPropertyCollection;}
net.watchee.AccountTO.prototype.hasPermissionStatistic=function(){return this.hasPermissionTemplate(net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_Enterprise)||this.hasPermissionTemplate(net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_Professional)||this.hasPermissionTemplate(net.watchee.PermissionTemplateTO.PERMISSION_GPSvision_TrialAccess)||this.hasPermissionTemplate(net.watchee.PermissionTemplateTO.PERMISSION_SkipperInAppPurchase);}
net.watchee.AccountTO.prototype.addAccountPropertyPair=function(propertyPair){if(propertyPair.getKey()=="ioAnalog"){this.getBuddyTO().getDevice().resetIOAnalogCache();}
return this.accountPropertyCollection.add(propertyPair);}
net.watchee.AccountTO.prototype.removeAccountProperty=function(key){return this.accountPropertyCollection.remove(key);}
net.watchee.AccountTO.prototype.mergeAccountProperties=function(propertyCollection,fireEvent){var arr=propertyCollection.getPropertyPairArr();for(var i=0,l=arr.length;i<l;i++){var pair=arr[i];this.addAccountPropertyPair(pair);}
var fireEvent=org.xmlBlaster.util.toBoolean(fireEvent,false);if(fireEvent){var eventData={buddyTO:this.getBuddyTO(),propertyCollection:propertyCollection};this.watchee.getBuddyManager().getEventManager().fireEvent("accountPropertiesChanged",eventData);}}
net.watchee.AccountTO.prototype.addAccountPropertyKeyValue=function(key,value){var propertyPair=new net.watchee.PropertyPair(key,value);return this.addAccountPropertyPair(propertyPair);}
net.watchee.AccountTO.prototype.getAccountPropertyStr=function(key,defaultValue){var csv=this.accountPropertyCollection.getStr(key,defaultValue);return csv;}
net.watchee.AccountTO.prototype.getAccountPropertyHashtable=function(key,defaultCsv){var csv=this.accountPropertyCollection.getStr(key,defaultCsv);var hash=org.xmlBlaster.util.Hashtable.parseCSV(csv);return hash;}
net.watchee.AccountTO.prototype.getAccountPropertiesStartsWith=function(start){var pairArr=this.accountPropertyCollection.getStartsWith(start);return pairArr;}
net.watchee.AccountTO.parse=function(watchee,xmlString,verifyLoginName){var verifyLoginName=org.xmlBlaster.util.toBoolean(verifyLoginName,true);if(!org.xmlBlaster.util.isDefined(xmlString)){return null;}
var domDocument=org.xmlBlaster.util.getDOMDocument(xmlString);var rootNode=domDocument.documentElement;var ME="watchee.js-AccountTO.parse(): ";var log=net.watchee.util.log;if(rootNode.nodeName=="parsererror"){log.error(ME+"'parsererror' for "+xmlString);return null;}
var accountTO=null;var loginName=rootNode.getAttribute('ln');if(!org.xmlBlaster.util.isFilled(loginName))
return null;var isLoginAccount=(loginName==watchee.getLoginName());if(!isLoginAccount){if(verifyLoginName){log.error("Got loginName = "+loginName+" but expected "+watchee.getLoginName());return null;}
accountTO=new net.watchee.AccountTO(watchee,loginName);}
else{accountTO=watchee.getAccountTO();}
for(var i=0,l=rootNode.childNodes.length;i<l;i++){var node=rootNode.childNodes[i];if(node.nodeType!=Node.ELEMENT_NODE){var val=org.xmlBlaster.util.isDefined(node.nodeValue)?node.nodeValue:"";var tmp=org.xmlBlaster.util.trim(val);if(tmp.length==0)continue;val=": '"+val+"'";var txt="Ignoring accounTO "+org.xmlBlaster.util.getXPathLocation(node,true)+val;(node.nodeType==Node.COMMENT_NODE||node.nodeType==Node.TEXT_NODE)?org.xmlBlaster.util.log.debug(ME+txt):org.xmlBlaster.util.log.warn(ME+txt);continue;}
switch(node.nodeName){case"accountId":break;case"lnm":break;case"pw":accountTO.password=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"oem":accountTO.oemName=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"ptl":accountTO.permissionTemplateStr=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"maxMonthlySms":accountTO.maxMonthlySms=org.xmlBlaster.util.toNumber(org.xmlBlaster.util.collectTextFromNodeChilds(node),0);break;case"al":accountTO.alias=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"act":accountTO.active=org.xmlBlaster.util.toBoolean(org.xmlBlaster.util.collectTextFromNodeChilds(node),true);break;case"fn":accountTO.firstName=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"sn":accountTO.lastName=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"e":accountTO.email=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"ge":accountTO.gender=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"pn":accountTO.phoneNumber=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"la":accountTO.language=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"tz":accountTO.timezone=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"ts":accountTO.setCreationTsStr(org.xmlBlaster.util.collectTextFromNodeChilds(node));break;case"ed":accountTO.setEndDateStr(org.xmlBlaster.util.collectTextFromNodeChilds(node));break;case"pr":var pr=net.watchee.PropertyPair.parseXml(node);if(pr!=null)
accountTO.accountPropertyCollection.add(pr);break;case"pi":accountTO.pictureId=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"pt":accountTO.pictureContentType=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"ps":accountTO.pictureSize=org.xmlBlaster.util.collectTextFromNodeChilds(node);break;case"st":accountTO._initialOnlineStatus=org.xmlBlaster.util.collectNumberFromNodeChilds(node,accountTO._initialOnlineStatus);break;default:log.warn(ME+"("+org.xmlBlaster.util.getXPathLocation(node,true)+"): Ignoring <"+node.nodeName+"> tag");break;}}
if(isLoginAccount&&accountTO.accountPropertyCollection!=null){var keyArray=accountTO.accountPropertyCollection.getHashtable().getKeys();for(var i=0,l=keyArray.length;i<l;i++){var key=keyArray[i];var ap=accountTO.accountPropertyCollection.get(key);xbProperties.setAccountProp(ap.getKey(),ap.getValue());}}
return accountTO;}
net.watchee.DeviceInfo=function(buddyTO){this.deviceEnum="";this.platform="";this.deviceGuid="";this.version="";this.timestampStrUTC="";this.deviceSleepMode=false;this.sleepModeNum=-1;this.isParsed=false;}
net.watchee.DeviceInfo.prototype.isDeviceSleepMode=function(){return this.deviceSleepMode;}
net.watchee.DeviceInfo.prototype.setDeviceSleepMode=function(sleepMode){var old=this.deviceSleepMode;this.deviceSleepMode=sleepMode;return old;}
net.watchee.DeviceInfo.prototype.isJ2me=function(){if(this.deviceEnum=="J2ME")
return true;return false;}
net.watchee.DeviceInfo.prototype.isAndroid=function(){if(this.deviceEnum=="ANDROID")
return true;return false;}
net.watchee.DeviceInfo.prototype.isIPhone=function(){if(this.deviceEnum=="IPHONE")
return true;return false;}
net.watchee.DeviceInfo.prototype.isIPad=function(){if(this.deviceEnum=="IPAD")
return true;return false;}
net.watchee.DeviceInfo.prototype.isIOS=function(){return this.isIPhone()||this.isIPad();}
net.watchee.DeviceInfo.prototype.isWindowsCE=function(){if(this.deviceEnum=="WINDOWSCE")
return true;return false;}
net.watchee.DeviceInfo.prototype.isBlackbox=function(){if(!this.hasTrackerConfigured())
return false;if(this.deviceEnum=="TK105"||this.deviceEnum=="TK102"||this.deviceEnum=="TK2000"||this.deviceEnum=="SPT10"||this.deviceEnum=="VT10"||this.deviceEnum=="VT300")
return true;return false;}
net.watchee.DeviceInfo.prototype.supportsAnalogInput=function(){if(!this.hasTrackerConfigured())
return false;if(this.deviceEnum=="VT10"||this.deviceEnum=="VT300")
return true;return false;}
net.watchee.DeviceInfo.prototype.isWonde=function(){if(!this.hasTrackerConfigured())
return false;if(this.deviceEnum=="SPT10"||this.deviceEnum=="VT10"||this.deviceEnum=="VT300")
return true;return false;}
net.watchee.DeviceInfo.prototype.isWondeVtSeries=function(){if(!this.hasTrackerConfigured())
return 0;if(this.deviceEnum=="VT10"||this.deviceEnum=="VT300")
return 4;return 0;}
net.watchee.DeviceInfo.prototype.getCountOutputControls=function(){if(!this.hasTrackerConfigured())
return 0;if(this.deviceEnum=="VT10"||this.deviceEnum=="VT300")
return 4;return 0;}
net.watchee.DeviceInfo.prototype.getCountInputControls=function(){if(!this.hasTrackerConfigured())
return 0;if(this.deviceEnum=="VT10"||this.deviceEnum=="VT300")
return 4;return 0;}
net.watchee.DeviceInfo.prototype.hasTrackerConfigured=function(){return this.deviceEnum!="";}
net.watchee.DeviceInfo.prototype.supportsTrackingByHeartbeat=function(){return true;}
net.watchee.DeviceInfo.prototype.supportsTrackingByHeadingChange=function(){if(this.deviceEnum=="TK105"||this.deviceEnum=="TK102")
return false;return true;}
net.watchee.DeviceInfo.prototype.supportsTrackingByHeadingChangeThreshold=function(){if(this.deviceEnum=="TK105"||this.deviceEnum=="TK102"||this.deviceEnum=="SPT10"||this.deviceEnum=="VT10"||this.deviceEnum=="VT300")
return false;return true;}
net.watchee.DeviceInfo.prototype.supportsTrackingByDistance=function(){if(this.deviceEnum=="TK105"||this.deviceEnum=="TK102")
return false;return true;}
net.watchee.DeviceInfo.prototype.supportsTrackingBySpeed=function(){if(this.deviceEnum=="TK105"||this.deviceEnum=="TK102"||this.deviceEnum=="TK2000"||this.deviceEnum=="SPT10"||this.deviceEnum=="VT10"||this.deviceEnum=="VT300")
return false;return true;}
net.watchee.DeviceInfo.prototype.supportsTransientTrackingChange=function(){if(this.deviceEnum=="TK105"||this.deviceEnum=="TK102"||this.deviceEnum=="TK2000"||this.deviceEnum=="SPT10"||this.deviceEnum=="VT10"||this.deviceEnum=="VT300"||this.isIOS())
return false;return true;}
net.watchee.DeviceInfo.prototype.supportsSleepingMode=function(){if(this.deviceEnum=="TK2000"||this.deviceEnum=="SPT10"||this.deviceEnum=="VT10"||this.deviceEnum=="VT300")
return true;return false;}
net.watchee.DeviceInfo.prototype.supportsRoamingSwitching=function(){if(this.deviceEnum=="SPT10"||this.deviceEnum=="VT10"||this.deviceEnum=="VT300")
return true;return false;}
net.watchee.DeviceInfo.prototype.hasOfflineProxyConfiguration=function(){if(this.deviceEnum=="ANDROID"||this.deviceEnum=="IPHONE"||this.deviceEnum=="IPAD"||this.deviceEnum=="J2ME"||this.deviceEnum=="WINDOWSCE")
return false;return true;}
net.watchee.DeviceInfo.prototype.supportsSmsConfigurationOnly=function(){if(this.deviceEnum=="TK102")
return true;return false;}
net.watchee.DeviceInfo.prototype.getDeviceEnumStr=function(){return this.deviceEnum;}
net.watchee.DeviceInfo.prototype.getDeviceEnumMarketingStr=function(oemName){var oemName=oemName||null;return net.watchee.DeviceInfo.deviceEnumToMarketingName(this.deviceEnum,oemName);}
net.watchee.DeviceInfo.deviceEnumToMarketingName=function(deviceEnum,oemName){if(deviceEnum=="SPT10")
return"TK5000";else if(deviceEnum=="VT10")
return"CT100";else if(deviceEnum=="VT300")
return"CT300";return deviceEnum;}
net.watchee.DeviceInfo.prototype.setSleepModeNum=function(num){this.sleepModeNum=num;}
net.watchee.DeviceInfo.prototype.getSleepModeNum=function(){return this.sleepModeNum;}
net.watchee.BuddyTO=function(watchee,loginName,alias,iconName,device){if(!org.xmlBlaster.util.isFilled(loginName))
throw"IllegalArgumentException net.watchee.BuddyTO without loginName";this.watchee=watchee;this.loginName=loginName;this.alias=alias||this.loginName;this.firstName=null;this.lastName=null;this.email=null;this.phoneNumber=null;this.deviceInfo=new net.watchee.DeviceInfo(this);this.accountTO=null;this.accountPropertyCollection=new net.watchee.PropertyCollection();this.instanceCounter=org.xmlBlaster.util.getUniqueCounter();this.onlineStatus=net.watchee.BuddyTO.STATUS_OFFLINE;this.introduction="";this.reason="";this.device=org.xmlBlaster.util.isDefined(device)?device:new net.watchee.Device(watchee,this.loginName,this.alias,this);this.permissionsInbound=null;this.permissionsOutbound=null;this.deviceMappingCached=null;this.isTracking=false;this.autoTrackingOptions={center:xbProperties.getBoolean("mapCenterOnLocationUpdate",false),panningFenceLatPercent:this.watchee.panningFenceLatPercent,panningFenceLngPercent:this.watchee.panningFenceLngPercent};net.watchee.BuddyTO.prototype.setAvatarIconName=function(offline,online){if(!org.xmlBlaster.util.isFilled(offline))
offline="buddy_offline_32.png";if(!org.xmlBlaster.util.isFilled(online))
online="buddy_online_32.png";if(offline.indexOf("/")!=-1)
this.avatarIconUrl=offline;else if(offline.indexOf(".")!=-1)
this.avatarIconUrl="images/32/"+offline;else
this.avatarIconUrl=offline;if(online.indexOf("/")!=-1)
this.avatarOnlineIconUrl=online;else if(online.indexOf(".")!=-1)
this.avatarOnlineIconUrl="images/32/"+online;else
this.avatarOnlineIconUrl=online;}
net.watchee.BuddyTO.prototype.setAvatarIconName(iconName);}
net.watchee.BuddyTO.prototype.setAutoTrackingCentered=function(doCenter){if(doCenter==undefined)
return;this.autoTrackingOptions.center=doCenter;}
net.watchee.BuddyTO.prototype.isAutoTrackingCentered=function(){return this.autoTrackingOptions.center;}
net.watchee.BuddyTO.prototype.getAutoTrackingOptions=function(){return this.autoTrackingOptions;}
net.watchee.BuddyTO.prototype.isAutoTracking=function(){return this.isTracking;}
net.watchee.BuddyTO.prototype.setAutoTracking=function(autoTracking,autoTrackingOptions){this.isTracking=autoTracking;if(autoTrackingOptions!=undefined&&autoTrackingOptions!=null)
this.autoTrackingOptions=autoTrackingOptions;}
net.watchee.BuddyTO.prototype.toggleAutoTracking=function(){this.isTracking=!this.isTracking;;return this.isTracking;}
net.watchee.BuddyTO.prototype.getLoginName=function(){return this.loginName;}
net.watchee.BuddyTO.prototype.getAlias=function(){return(this.accountTO!=null)?this.accountTO.getAlias():this.alias;}
net.watchee.BuddyTO.prototype.setAlias=function(aliasName){if(this.accountTO!=null)
this.accountTO.setAlias(aliasName);this.alias=aliasName;}
net.watchee.BuddyTO.prototype.getFirstName=function(){var x=(this.accountTO!=null)?this.accountTO.getFirstName():this.firstName;if(x==null)
x="";return x;}
net.watchee.BuddyTO.prototype.setFirstName=function(firstName){if(this.accountTO!=null)
this.accountTO.setFirstName(firstName);this.firstName=firstName;}
net.watchee.BuddyTO.prototype.getLastName=function(){var x=(this.accountTO!=null)?this.accountTO.getLastName():this.lastName;if(x==null)
x="";return x;}
net.watchee.BuddyTO.prototype.setLastName=function(lastName){if(this.accountTO!=null)
this.accountTO.setLastName(lastName);this.lastName=lastName;}
net.watchee.BuddyTO.prototype.getEmail=function(){var x=(this.accountTO!=null)?this.accountTO.getEmail():this.email;if(x==null)
x="";return x;}
net.watchee.BuddyTO.prototype.setEmail=function(email){if(this.accountTO!=null)
this.accountTO.setEmail(email);this.email=email;}
net.watchee.BuddyTO.prototype.getPhoneNumber=function(){var x=(this.accountTO!=null)?this.accountTO.getPhoneNumber():this.phoneNumber;if(x==null)
x="";return x;}
net.watchee.BuddyTO.prototype.setPhoneNumber=function(phoneNumber){if(this.accountTO!=null)
this.accountTO.setPhoneNumber(phoneNumber);this.phoneNumber=phoneNumber;}
net.watchee.BuddyTO.prototype.getOemPropertyStr=function(oemKey,defaultValue){var oemKey=oemKey||null;if(oemKey==null){return defaultValue;}
if(defaultValue===undefined){defaultValue=null;}
if(oemKey.indexOf("OEM/")!=0){oemKey="OEM/"+this.watchee.getAccountTO().getOemName()+"/"+oemKey;}
var value=this.accountPropertyCollection.getStr(oemKey,defaultValue);return value;}
net.watchee.BuddyTO.prototype.getAccountPropertyHashtable=function(key,defaultCsv){var csv=this.accountPropertyCollection.getStr(key,defaultCsv);var hash=org.xmlBlaster.util.Hashtable.parseCSV(csv);return hash;}
net.watchee.BuddyTO.prototype.getDeviceMapping=function(){if(this.deviceMappingCached!=null)
return this.deviceMappingCached;var csv=this.getAccountPropertyStr("DeviceMapping",null);if(csv==null)
return null;this.deviceMappingCached=net.watchee.DeviceMapping.parseCSV(this.loginName,csv);return this.deviceMappingCached;}
net.watchee.BuddyTO.prototype.getDeviceInfo=function(){var deviceInfoCSV=this.getAccountPropertyStr("deviceInfo",null);if(deviceInfoCSV==null||deviceInfoCSV=="")return this.deviceInfo;if(this.deviceInfo.isParsed)return this.deviceInfo;var hash=org.xmlBlaster.util.Hashtable.parseCSV(deviceInfoCSV);this.deviceInfo.deviceEnum=hash.get("deviceEnum","");this.deviceInfo.platform=hash.get("platform","");this.deviceInfo.deviceGuid=hash.get("deviceGuid","");this.deviceInfo.version=hash.get("vers","");this.deviceInfo.timestampStrUTC=hash.get("ts","");this.deviceInfo.setDeviceSleepMode(hash.getBoolean("Ssleep",false));this.deviceInfo.setSleepModeNum(hash.getNumber("VsleepModeNum",-1));var batPercent=hash.getNumber(net.watchee.GPSData.KEY_BATTERY_LEVEL_PERCENT,-9);if(batPercent!=-9){this.getDevice().setBatteryLevelPercent(batPercent);var date=null;if(this.deviceInfo.timestampStrUTC.length>0){date=org.xmlBlaster.util.getDateFromIsoDateStr(this.deviceInfo.timestampStrUTC,false);}
this.getDevice().setVoltDate(date);}
this.deviceInfo.isParsed=true;return this.deviceInfo;}
net.watchee.BuddyTO.prototype.updateFromFriendOf=function(buddyTO){if(!org.xmlBlaster.util.isDefined(buddyTO))return;this.loginName=buddyTO.loginName;this.alias=buddyTO.alias;this.onlineStatus=buddyTO.onlineStatus;this.introduction=buddyTO.introduction;this.reason=buddyTO.reason;this.permissionsInbound=buddyTO.permissionsInbound;}
net.watchee.BuddyTO.prototype.updateFromOutbound=function(buddyTO){if(!org.xmlBlaster.util.isDefined(buddyTO))return;this.loginName=buddyTO.loginName;this.alias=buddyTO.alias;if(buddyTO.firstName!=null)
this.firstName=buddyTO.firstName;if(buddyTO.lastName!=null)
this.lastName=buddyTO.lastName;if(buddyTO.email!=null)
this.email=buddyTO.email;if(buddyTO.phoneNumber!=null)
this.phoneNumber=buddyTO.phoneNumber;this.onlineStatus=buddyTO.onlineStatus;this.introduction=buddyTO.introduction;this.reason=buddyTO.reason;this.permissionsOutbound=buddyTO.permissionsOutbound;}
net.watchee.BuddyTO.prototype.isOutbound=function(){return this.permissionsOutbound!=null;}
net.watchee.BuddyTO.prototype.isInbound=function(){return this.permissionsInbound!=null;}
net.watchee.BuddyTO.prototype.clone=function(){var buddyTO=new net.watchee.BuddyTO(this.watchee,this.loginName,this.alias,this.iconName,this.device);buddyTO.firstName=this.firstName;buddyTO.lastName=this.lastName;buddyTO.email=this.email;buddyTO.phoneNumber=this.phoneNumber;buddyTO.onlineStatus=this.onlineStatus;buddyTO.introduction=this.introduction;buddyTO.reason=this.reason;buddyTO.permissionsInbound=this.permissionsInbound;buddyTO.permissionsOutbound=this.permissionsOutbound;buddyTO.accountPropertyCollection=this.accountPropertyCollection;return buddyTO;}
net.watchee.BuddyTO.prototype.getAvatarIconUrlSmall=function(){if(this.hasPermission(net.watchee.BuddyPermissionTO.PERMISSION_DEVICE_STATUS)){if(this.isOnline())
return"images/16/buddy_online_16.png";else
return"images/16/buddy_offline_16.png";}
else
return"images/16/buddy_offline_16.png";}
net.watchee.BuddyTO.prototype.getAvatarIconUrl=function(){if(this.hasPermission(net.watchee.BuddyPermissionTO.PERMISSION_DEVICE_STATUS)){if(this.isOnline())
return this.avatarOnlineIconUrl;else
return this.avatarIconUrl;}
else
return this.avatarIconUrl;}
net.watchee.BuddyTO.prototype.isCurrentLoginAccount=function(){if(this.watchee==null)return false;return this.watchee.loginName==this.loginName;}
net.watchee.BuddyTO.prototype.isPublic=function(){return this.loginName.substr(0,"public".length).toLowerCase()=="public"||this.loginName.toLowerCase()=="rundum";}
net.watchee.BuddyTO.prototype.getAliasAndLoginName=function(){var title=this.getAlias();if(this.getAlias()!=this.getLoginName())
title+=" ("+this.getLoginName()+")";return title;}
net.watchee.BuddyTO.prototype.setOnlineStatus=function(onlineStatus){this.onlineStatus=onlineStatus;}
net.watchee.BuddyTO.prototype.getOnlineStatus=function(){return this.onlineStatus;}
net.watchee.BuddyTO.prototype.getDevice=function(){return this.device;}
net.watchee.BuddyTO.prototype.setDevice=function(device){var old=this.device;this.device=device;return old;}
net.watchee.BuddyTO.prototype.isOnline=function(){return net.watchee.BuddyTO.STATUS_ONLINE==this.onlineStatus;}
net.watchee.BuddyTO.prototype.getIntroduction=function(){return this.introduction;}
net.watchee.BuddyTO.prototype.getReason=function(){return this.reason;}
net.watchee.BuddyTO.prototype.addPermissionInbound=function(permissionTO){if(this.permissionsInbound==null)
this.permissionsInbound=new Array();this.permissionsInbound.push(permissionTO);}
net.watchee.BuddyTO.prototype.addPermissionOutbound=function(permissionTO){if(this.permissionsOutbound==null)
this.permissionsOutbound=new Array();this.permissionsOutbound.push(permissionTO);}
net.watchee.BuddyTO.prototype.getPermissionsInbound=function(){if(this.permissionsInbound==null)return new Array();return this.permissionsInbound;}
net.watchee.BuddyTO.prototype.getPermissionsOutbound=function(){if(this.permissionsOutbound==null)return new Array();return this.permissionsOutbound;}
net.watchee.BuddyTO.prototype.setPermissionsInbound=function(permissions){this.permissionsInbound=permissions;}
net.watchee.BuddyTO.prototype.setPermissionsOutbound=function(permissions){this.permissionsOutbound=permissions;}
net.watchee.BuddyTO.prototype.hasPermission=function(permissionName){if(this.isCurrentLoginAccount())
return true;var perm=this.getPermissionInbound(permissionName);return(perm==null)?false:perm.isGranted();}
net.watchee.BuddyTO.prototype.getPermissionInbound=function(permissionName){if(this.permissionsInbound==null)return null;for(var i=0,l=this.permissionsInbound.length;i<l;i++){var perm=this.permissionsInbound[i];if(perm.getName()==permissionName)
return perm;}
return null;}
net.watchee.BuddyTO.prototype.hasPermissionOutbound=function(permissionName){var perm=this.getPermissionOutbound(permissionName);return(perm==null)?false:perm.isGranted();}
net.watchee.BuddyTO.prototype.getPermissionOutbound=function(permissionName){if(this.permissionsOutbound==null)return null;for(var i=0,l=this.permissionsOutbound.length;i<l;i++){var perm=this.permissionsOutbound[i];if(perm.getName()==permissionName)
return perm;}
return null;}
net.watchee.BuddyTO.prototype.permissionInboundIsSame=function(permissionName,otherBuddyTO){var mine=this.hasPermission(permissionName);var other=otherBuddyTO.hasPermission(permissionName);return mine==other;}
net.watchee.BuddyTO.prototype.toXml=function(isFriendOf){var isFriendOf=org.xmlBlaster.util.parseBoolean(isFriendOf,false);var xml="<b>";xml+="<ln>"+org.xmlBlaster.util.escapeXml(this.loginName)+"</ln>";if(org.xmlBlaster.util.isFilled(this.alias))
xml+="<al>"+org.xmlBlaster.util.escapeXml(this.alias)+"</al>";if(org.xmlBlaster.util.isFilled(this.firstName))
xml+="<fn>"+org.xmlBlaster.util.escapeXml(this.firstName)+"</fn>";if(org.xmlBlaster.util.isFilled(this.lastName))
xml+="<sn>"+org.xmlBlaster.util.escapeXml(this.lastName)+"</sn>";if(org.xmlBlaster.util.isFilled(this.email))
xml+="<e>"+org.xmlBlaster.util.escapeXml(this.email)+"</e>";if(org.xmlBlaster.util.isFilled(this.phoneNumber))
xml+="<pn>"+org.xmlBlaster.util.escapeXml(this.phoneNumber)+"</pn>";if(org.xmlBlaster.util.isFilled(this.onlineStatus))
xml+="<st>"+org.xmlBlaster.util.escapeXml(this.onlineStatus)+"</st>";if(org.xmlBlaster.util.isFilled(this.introduction))
xml+="<iu>"+org.xmlBlaster.util.escapeXml(this.introduction)+"</iu>";if(org.xmlBlaster.util.isFilled(this.reason))
xml+="<rs>"+org.xmlBlaster.util.escapeXml(this.reason)+"</rs>";if(this.accountPropertyCollection!=null){for(var i=0,l=this.accountPropertyCollection.length;i<l;i++){var ap=this.accountPropertyCollection[i];xml+=ap.toXml();}}
if(isFriendOf&&this.permissionsInbound!=null){for(var i=0,l=this.permissionsInbound.length;i<l;i++){var perm=this.permissionsInbound[i];xml+=perm.toXml();}}
else if(this.permissionsOutbound!=null){for(var i=0,l=this.permissionsOutbound.length;i<l;i++){var perm=this.permissionsOutbound[i];xml+=perm.toXml();}}
xml+="</b>";return xml;}
net.watchee.BuddyTO.prototype.destruct=function(){this.loginName=null;;this.alias=null;this.firstName=null;this.lastName=null;this.email=null;this.onlineStatus=null;this.introduction=null;this.reason=null;this.accountPropertyCollection=null;this.device=null;this.permissionsInbound=null;this.isTracking=null;}
net.watchee.BuddyTO.STATUS_OFFLINE=0;net.watchee.BuddyTO.STATUS_ONLINE=1;net.watchee.BuddyTO.prototype.setAccountPropertyCollection=function(accountPropertyCollection){this.accountPropertyCollection=accountPropertyCollection;if(this.accountPropertyCollection!=null&&this.accountPropertyCollection.contains("ioAnalog")){this.getDevice().resetIOAnalogCache();}}
net.watchee.BuddyTO.prototype.addAccountPropertyPair=function(propertyPair){if(propertyPair.getKey()=="ioAnalog"){this.getDevice().resetIOAnalogCache();}
return this.accountPropertyCollection.add(propertyPair);}
net.watchee.BuddyTO.prototype.mergeAccountProperties=function(propertyCollection,fireEvent){var arr=propertyCollection.getPropertyPairArr();for(var i=0,l=arr.length;i<l;i++){var pair=arr[i];this.addAccountPropertyPair(pair);}
var fireEvent=org.xmlBlaster.util.toBoolean(fireEvent,false);if(fireEvent){var eventData={buddyTO:this,propertyCollection:propertyCollection};this.watchee.getBuddyManager().getEventManager().fireEvent("accountPropertiesChanged",eventData);}}
net.watchee.BuddyTO.prototype.addAccountPropertyKeyValue=function(key,value){var propertyPair=new net.watchee.PropertyPair(key,value);return this.addAccountPropertyPair(propertyPair);}
net.watchee.BuddyTO.prototype.getAccountPropertyCollection=function(){return this.accountPropertyCollection;}
net.watchee.BuddyTO.prototype.getAccountPropertyStr=function(key,defaultValue){var csv=this.accountPropertyCollection.getStr(key,defaultValue);return csv;}
net.watchee.BuddyTO.prototype.getAccountPropertiesStartsWith=function(start){var pairArr=this.accountPropertyCollection.getStartsWith(start);return pairArr;}
net.watchee.BuddyListTO=function(loginName,buddies){this.loginName=loginName||"";this.buddies=buddies||new Array();this.type=net.watchee.BuddyListTO.TYPE_DEFAULT;this.getLoginName=function(){return this.loginName;}
this.getSize=function(){return this.buddies.length;}
this.getType=function(){return this.type;}
this.isUpdate=function(){return net.watchee.BuddyListTO.TYPE_UPDATE==this.type;}
this.isAll=function(){return net.watchee.BuddyListTO.TYPE_ALL==this.type;}
this.isDelete=function(){return net.watchee.BuddyListTO.TYPE_DELETE==this.type;}
this.addBuddy=function(buddyTO){this.buddies.push(buddyTO);}
this.getFirstBuddy=function(){if(this.buddies.length>0)
return this.buddies[0];return null;}
this.getBuddyList=function(){return this.buddies;}
this.createHashtable=function(){var hash=new org.xmlBlaster.util.Hashtable();for(var i=0,l=this.buddies.length;i<l;i++){var buddy=this.buddies[i];hash.put(buddy.getLoginName(),buddy);}
return hash;}
this.toXml=function(isFriendOf){var xml="<bc ln='"+this.loginName+"' t='"+this.type+"'>";for(var i=0,l=this.buddies.length;i<l;i++){var buddy=this.buddies[i];xml+=buddy.toXml(isFriendOf);}
xml+="</bc>";return xml;}
this.destruct=function(){this.loginName=null;this.buddies=null;this.type=null;}}
net.watchee.BuddyListTO.TYPE_ALL="all";net.watchee.BuddyListTO.TYPE_UPDATE="update";net.watchee.BuddyListTO.TYPE_DELETE="delete";net.watchee.BuddyListTO.TYPE_DEFAULT=net.watchee.BuddyListTO.TYPE_ALL;net.watchee.BuddyListTO.parse=function(watchee,xmlString,isFriendOf){if(!org.xmlBlaster.util.isDefined(xmlString)){return null;}
var isFriendOf=org.xmlBlaster.util.parseBoolean(isFriendOf,false);var domDocument=org.xmlBlaster.util.getDOMDocument(xmlString);var rootNode=domDocument.documentElement;var ME="watchee.js-BuddyListTO.parse(isFriendOf="+isFriendOf+"): ";var log=net.watchee.util.log;if(rootNode.nodeName=="parsererror"){log.error(ME+"'parsererror' for "+xmlString);return null;}
var buddyListTO=new net.watchee.BuddyListTO();var loginName=rootNode.getAttribute('ln');if(org.xmlBlaster.util.isFilled(loginName)){buddyListTO.loginName=loginName;}
var type=rootNode.getAttribute('t');if(org.xmlBlaster.util.isFilled(type)){buddyListTO.type=type;}
for(var i=0,l=rootNode.childNodes.length;i<l;i++){var node=rootNode.childNodes[i];if(node.nodeType!=Node.ELEMENT_NODE){var val=org.xmlBlaster.util.isDefined(node.nodeValue)?node.nodeValue:"";var tmp=org.xmlBlaster.util.trim(val);if(tmp.length==0)continue;val=": '"+val+"'";var txt="Ignoring buddy list "+org.xmlBlaster.util.getXPathLocation(node,true)+val;(node.nodeType==Node.COMMENT_NODE||node.nodeType==Node.TEXT_NODE)?org.xmlBlaster.util.log.debug(ME+txt):org.xmlBlaster.util.log.warn(ME+txt);continue;}
switch(node.nodeName){case"b":var buddyTO=null;for(var j=0;j<node.childNodes.length;j++){var nd=node.childNodes[j];if(nd.nodeName=="pe"){var name=nd.getAttribute('n');var desc=nd.getAttribute('d');var perm=new net.watchee.BuddyPermissionTO(name,desc,isFriendOf);if(isFriendOf)
buddyTO.addPermissionInbound(perm);else
buddyTO.addPermissionOutbound(perm);}
else if(nd.nodeName=="ln"){var loginName=org.xmlBlaster.util.collectTextFromNodeChilds(nd);if(!org.xmlBlaster.util.isFilled(loginName)){log.error("Missing buddy loginName: "+xmlString);break;}
buddyTO=new net.watchee.BuddyTO(watchee,loginName);buddyListTO.addBuddy(buddyTO);}
else if(nd.nodeName=="al"){buddyTO.alias=org.xmlBlaster.util.collectTextFromNodeChilds(nd);}
else if(nd.nodeName=="fn"){buddyTO.firstName=org.xmlBlaster.util.collectTextFromNodeChilds(nd);}
else if(nd.nodeName=="sn"){buddyTO.lastName=org.xmlBlaster.util.collectTextFromNodeChilds(nd);}
else if(nd.nodeName=="e"){buddyTO.email=org.xmlBlaster.util.collectTextFromNodeChilds(nd);}
else if(nd.nodeName=="pn"){buddyTO.phoneNumber=org.xmlBlaster.util.collectTextFromNodeChilds(nd);}
else if(nd.nodeName=="st"){buddyTO.onlineStatus=org.xmlBlaster.util.collectNumberFromNodeChilds(nd,net.watchee.BuddyTO.STATUS_OFFLINE);}
else if(nd.nodeName=="iu"){buddyTO.introduction=org.xmlBlaster.util.collectTextFromNodeChilds(nd);}
else if(nd.nodeName=="rs"){buddyTO.reason=org.xmlBlaster.util.collectTextFromNodeChilds(nd);}
else if(nd.nodeName=="pr"){var pr=net.watchee.PropertyPair.parseXml(nd);if(pr!=null)
buddyTO.accountPropertyCollection.add(pr);}
else{if(nd.nodeName!="#text")
log.error(ME+"Tag <"+nd.nodeName+"> not known: "+xmlString);continue;}}
break;default:log.warn(ME+"("+org.xmlBlaster.util.getXPathLocation(node,true)+"): Ignoring buddy tag");break;}}
return buddyListTO;}
net.watchee.BuddyManager=function(watchee){this.watchee=watchee||null;this.buddiesOutbound=new org.xmlBlaster.util.Hashtable();this.buddiesOutboundIsSet=false;this.buddiesInbound=new org.xmlBlaster.util.Hashtable();this.buddiesInboundIsSet=false;this.eventManager=new org.xmlBlaster.util.EventManager();this.hideAccountHashtable=null;this.trackingOnForHashtable=null;this.getEventManager=function(){return this.eventManager;}
this.showAccount=function(loginName){if(this.hideAccountHashtable==null){this.hideAccountHashtable=xbProperties.getHashtable("hideAccounts");}
return!this.hideAccountHashtable.contains(loginName);}
this.isTrackingOnFor=function(loginName){if(loginName==undefined||loginName==null)
return false;if(xbProperties.getBoolean("trackingOn",false))
return true;if(this.trackingOnForHashtable==null){this.trackingOnForHashtable=xbProperties.getHashtable("trackingOnFor",".*");}
var found=this.trackingOnForHashtable.contains(loginName);if(found)
return true;var arr=this.trackingOnForHashtable.getKeys();for(var i=0,l=arr.length;i<l;i++){var ln=arr[i];if(ln==null)
continue;var found=loginName.match(ln);if(found)
return true;}
return false;}
this.changedOnlineStatus=function(loginName,onlineStatus,sleepMode){var sleepMode=(sleepMode==undefined)?false:sleepMode;var buddyTO=this.getBuddyOrFriendOf(loginName);if(buddyTO==null){net.watchee.util.log.warn("changedOnlineStatus: Ignoring "+net.watchee.TOPICID_ONLINESTATUS+" for unknown buddy");return;}
buddyTO.setOnlineStatus(onlineStatus);buddyTO.getDeviceInfo().setDeviceSleepMode(sleepMode);var data={loginName:loginName,buddyTO:buddyTO,onlineStatus:onlineStatus,sleepMode:sleepMode};this.eventManager.fireEvent(org.xmlBlaster.util.PropTO.VALUE_TASK_NAMED_ONLINESTATUS,data);}
this.getBuddyAndFriendOfList=function(){var merge=new org.xmlBlaster.util.Hashtable();merge.add(this.buddiesOutbound);merge.add(this.buddiesInbound);return merge.getValues();}
this.getFriendOfList=function(permissionName,appendMyself){var appendMyself=appendMyself||false;if(!org.xmlBlaster.util.isFilled(permissionName)){var arr=this.buddiesInbound.getValues();if(appendMyself){arr.push(this.watchee.getAccountTO().getBuddyTO());}
return arr;}
var arr=new Array();var values=this.buddiesInbound.getValues();for(var i=0,l=values.length;i<l;i++){var buddyTO=values[i];if(buddyTO.hasPermission(permissionName))
arr.push(buddyTO);}
if(appendMyself){arr.push(this.watchee.getAccountTO().getBuddyTO());}
return arr;}
this.getBuddies=function(permissionName){if(!org.xmlBlaster.util.isFilled(permissionName))
return this.buddiesOutbound.getValues();var arr=new Array();var values=this.buddiesOutbound.getValues();for(var i=0,l=values.length;i<l;i++){var buddyTO=values[i];if(buddyTO.hasPermissionOutbound(permissionName))
arr.push(buddyTO);}
return arr;}
this.isSync=function(){return this.buddiesInboundIsSet&&this.buddiesOutboundIsSet;}
this.setBuddies=function(buddyListTO){var newArr=buddyListTO.getBuddyList();if(buddyListTO.isDelete()){for(var i=0,l=newArr.length;i<l;i++){var buddyTO=newArr[i];var existing=this.buddiesOutbound.get(buddyTO.getLoginName());this.buddiesOutbound.remove(buddyTO.getLoginName());if(existing!=null){existing.permissionsOutbound=null;}
this.eventManager.fireEvent("removeBuddy",buddyTO);}}
else if(buddyListTO.isAll()||this.buddiesOutboundIsSet==false){for(var i=0,l=newArr.length;i<l;i++){var buddyTO=newArr[i];var existing=this.getBuddyOrFriendOf(buddyTO.getLoginName());if(existing){existing.updateFromOutbound(buddyTO);this.buddiesOutbound.put(existing.getLoginName(),existing);}
else{this.buddiesOutbound.put(buddyTO.getLoginName(),buddyTO);}}
this.buddiesOutboundIsSet=true;this.watchee.getXbAccess().logTimeElapsed("BuddyManager.setBuddies() firing now event");this.eventManager.fireEvent("setBuddies",buddyListTO);}
else if(buddyListTO.isUpdate()){for(var i=0,l=newArr.length;i<l;i++){var buddyTO=newArr[i];var existing=this.getBuddyOrFriendOf(buddyTO.getLoginName());var oldBuddyTO=null;if(existing!=null){oldBuddyTO=existing.clone();existing.updateFromOutbound(buddyTO);this.buddiesOutbound.put(existing.getLoginName(),existing);}
else{oldBuddyTO=new net.watchee.BuddyTO(this.watchee,buddyTO.getLoginName(),buddyTO.getAlias());this.buddiesOutbound.put(buddyTO.getLoginName(),buddyTO);existing=buddyTO;}
this.fireUpdateBuddyEvent(existing,oldBuddyTO,"update");}}
this.eventManager.fireEvent("changed",buddyListTO);}
this.fireChangeMyAccountEvent=function(accountTO){var data={accountTO:accountTO||null};this.eventManager.fireEvent("changeMyAccount",data);}
this.fireChangeAccountEvent=function(buddyTO){var data={buddyTO:buddyTO||null};this.eventManager.fireEvent("changeAccount",data);}
this.fireUpdateBuddyEvent=function(buddyTO,oldBuddyTO,updateType){var data={buddyTO:buddyTO,oldBuddyTO:oldBuddyTO||null,updateType:updateType||"all"};this.eventManager.fireEvent("updateBuddy",data);}
this.setFriendOf=function(buddyListTO){var newArr=buddyListTO.getBuddyList();for(var i=0,l=newArr.length;i<l;i++){var buddyTO=newArr[i];var loginName=buddyTO.getLoginName();var oldBuddyTO=this.buddiesInbound.get(loginName);if(oldBuddyTO!=null&&!buddyTO.hasPermission(net.watchee.BuddyPermissionTO.PERMISSION_GPS_HISTORY)){oldBuddyTO.getDevice().removeAllTracks("history",true);}
if(oldBuddyTO!=null&&!buddyTO.hasPermission(net.watchee.BuddyPermissionTO.PERMISSION_GPS)){oldBuddyTO.getDevice().removeAllTracks("current",true);}}
if(buddyListTO.isDelete()){for(var i=0,l=newArr.length;i<l;i++){var buddyTO=newArr[i];this.buddiesInbound.remove(buddyTO.getLoginName());var existing=this.buddiesOutbound.get(buddyTO.getLoginName());if(existing!=null){existing.permissionsInbound=null;}
this.eventManager.fireEvent("removeFriendOf",buddyTO);}}
else if(buddyListTO.isAll()||this.buddiesInboundIsSet==false){var inArr=this.buddiesInbound.getValues();for(var i=0,l=inArr.length;i<l;i++){inArr[i].permissionsInbound=null;}
for(var i=0,l=newArr.length;i<l;i++){var buddyTO=newArr[i];var existing=this.getBuddyOrFriendOf(buddyTO.getLoginName());if(existing){existing.updateFromFriendOf(buddyTO);this.buddiesInbound.put(existing.getLoginName(),existing);}
else{this.buddiesInbound.put(buddyTO.getLoginName(),buddyTO);}}
this.buddiesInboundIsSet=true;this.watchee.getXbAccess().logTimeElapsed("BuddyManager.setFriendOf() firing now event");this.eventManager.fireEvent("setFriendOf",buddyListTO);}
else if(buddyListTO.isUpdate()){for(var i=0,l=newArr.length;i<l;i++){var buddyTO=newArr[i];var existing=this.getBuddyOrFriendOf(buddyTO.getLoginName());var oldBuddyTO=null;if(existing!=null){oldBuddyTO=existing.clone();existing.updateFromFriendOf(buddyTO);this.buddiesInbound.put(existing.getLoginName(),existing);}
else{oldBuddyTO=new net.watchee.BuddyTO(this.watchee,buddyTO.getLoginName(),buddyTO.getAlias());this.buddiesInbound.put(buddyTO.getLoginName(),buddyTO);existing=buddyTO;}
var data={buddyTO:existing,oldBuddyTO:oldBuddyTO};this.eventManager.fireEvent("updateFriendOf",data);}}
this.eventManager.fireEvent("changed",buddyListTO);}
this.addBuddy=function(buddyTO){var oldBuddy=this.buddiesOutbound.put(buddyTO.getLoginName(),buddyTO);this.eventManager.fireEvent("addBuddy",buddyTO);this.eventManager.fireEvent("changed",buddyTO);return oldBuddy;}
this.getBuddyOrFriendOf=function(loginName){if(this.watchee!=null&&this.watchee.getLoginName()==loginName)
return this.watchee.getAccountTO().getBuddyTO();var buddy=this.buddiesOutbound.get(loginName);if(buddy!=null)
return buddy;return this.buddiesInbound.get(loginName);}
this.getBuddy=function(loginName){return this.buddiesOutbound.get(loginName);}
this.getBuddyOrMyself=function(loginName){if(this.watchee!=null&&this.watchee.getLoginName()==loginName)
return this.watchee.getAccountTO().getBuddyTO();return this.buddiesOutbound.get(loginName);}
this.getFriendOf=function(loginName){return this.buddiesInbound.get(loginName);}
this.getFriendOfOrMyself=function(loginName){if(this.watchee!=null&&this.watchee.getLoginName()==loginName)
return this.watchee.getAccountTO().getBuddyTO();return this.buddiesInbound.get(loginName);}
this.getAlias=function(loginName){var b=this.getBuddyOrFriendOf(loginName);if(b==null)
return loginName;return b.getAlias();}
this.sendGetBuddies=function(responseFp,responseThisArg,returnObj){var PropTO=org.xmlBlaster.util.PropTO;var propTOs=new Array();propTOs.push(new PropTO(PropTO.KEY_SERVICENAME,PropTO.VALUE_SERVICE_BUDDY));propTOs.push(new PropTO(PropTO.KEY_TASKTYPE,PropTO.VALUE_TASKTYPE_NAMED));propTOs.push(new PropTO(PropTO.KEY_TASK,PropTO.VALUE_TASK_NAMED_GETBUDDIES));propTOs.push(new PropTO(PropTO.KEY_RESULTENCODING,PropTO.ENCODING_PLAIN));var serviceTO=new org.xmlBlaster.util.ServiceTO(propTOs)
var serviceListTO=new org.xmlBlaster.util.ServiceListTO(serviceTO);if(this.watchee!=null)
this.watchee.publishServiceMessage(serviceListTO,responseFp,responseThisArg,returnObj);}
this.sendGetFriendOf=function(responseFp,responseThisArg,returnObj){var PropTO=org.xmlBlaster.util.PropTO;var propTOs=new Array();propTOs.push(new PropTO(PropTO.KEY_SERVICENAME,PropTO.VALUE_SERVICE_BUDDY));propTOs.push(new PropTO(PropTO.KEY_TASKTYPE,PropTO.VALUE_TASKTYPE_NAMED));propTOs.push(new PropTO(PropTO.KEY_TASK,PropTO.VALUE_TASK_NAMED_GETFRIENDOF));propTOs.push(new PropTO(PropTO.KEY_RESULTENCODING,PropTO.ENCODING_PLAIN));var serviceTO=new org.xmlBlaster.util.ServiceTO(propTOs)
var serviceListTO=new org.xmlBlaster.util.ServiceListTO(serviceTO);if(this.watchee!=null)
this.watchee.publishServiceMessage(serviceListTO,responseFp,responseThisArg,returnObj);}
this.sendGetPermissionTemplates=function(responseFp,responseThisArg,returnObj){var PropTO=org.xmlBlaster.util.PropTO;var propTOs=new Array();propTOs.push(new PropTO(PropTO.KEY_SERVICENAME,PropTO.VALUE_SERVICE_BUDDY));propTOs.push(new PropTO(PropTO.KEY_TASKTYPE,PropTO.VALUE_TASKTYPE_NAMED));propTOs.push(new PropTO(PropTO.KEY_TASK,PropTO.VALUE_TASK_NAMED_GETPERMISSIONSTEMPLATES));propTOs.push(new PropTO(PropTO.KEY_RESULTENCODING,PropTO.ENCODING_PLAIN));var serviceTO=new org.xmlBlaster.util.ServiceTO(propTOs)
var serviceListTO=new org.xmlBlaster.util.ServiceListTO(serviceTO);if(this.watchee!=null)
this.watchee.publishServiceMessage(serviceListTO,responseFp,responseThisArg,returnObj);}
this.sendAddBuddy=function(buddy,responseFp,responseThisArg,returnObj){var PropTO=org.xmlBlaster.util.PropTO;var propTOs=new Array();propTOs.push(new PropTO(PropTO.KEY_SERVICENAME,PropTO.VALUE_SERVICE_BUDDY));propTOs.push(new PropTO(PropTO.KEY_TASKTYPE,PropTO.VALUE_TASKTYPE_NAMED));propTOs.push(new PropTO(PropTO.KEY_TASK,PropTO.VALUE_TASK_NAMED_ADDBUDDIES));propTOs.push(new PropTO(PropTO.KEY_TASKACK,true));propTOs.push(new PropTO(PropTO.KEY_BOUNCE,buddy.getLoginName()));var buddyList=new net.watchee.BuddyListTO(this.watchee.getLoginName());buddyList.addBuddy(buddy);propTOs.push(new PropTO(PropTO.KEY_DATA,buddyList.toXml()));var serviceTO=new org.xmlBlaster.util.ServiceTO(propTOs)
var serviceListTO=new org.xmlBlaster.util.ServiceListTO(serviceTO);if(this.watchee!=null)
this.watchee.publishServiceMessage(serviceListTO,responseFp,responseThisArg,returnObj);}
this.sendRemoveBuddy=function(buddy,forceDestroyRelation,responseFp,responseThisArg,returnObj){var forceDestroyRelation=org.xmlBlaster.util.toBoolean(forceDestroyRelation,false);var PropTO=org.xmlBlaster.util.PropTO;var propTOs=new Array();propTOs.push(new PropTO(PropTO.KEY_SERVICENAME,PropTO.VALUE_SERVICE_BUDDY));propTOs.push(new PropTO(PropTO.KEY_TASKTYPE,PropTO.VALUE_TASKTYPE_NAMED));propTOs.push(new PropTO(PropTO.KEY_TASK,PropTO.VALUE_TASK_NAMED_REMOVEBUDDIES));propTOs.push(new PropTO(PropTO.KEY_BOUNCE,buddy.getLoginName()));propTOs.push(new PropTO("forceDestroyRelation",forceDestroyRelation));var buddyList=new net.watchee.BuddyListTO(this.watchee.getLoginName());buddyList.addBuddy(buddy);propTOs.push(new PropTO(PropTO.KEY_DATA,buddyList.toXml()));var serviceTO=new org.xmlBlaster.util.ServiceTO(propTOs)
var serviceListTO=new org.xmlBlaster.util.ServiceListTO(serviceTO);if(this.watchee!=null)
this.watchee.publishServiceMessage(serviceListTO,responseFp,responseThisArg,returnObj);}
this.clearBuddies=function(){this.buddiesOutbound=null;this.buddiesInbound=null;this.buddiesOutbound=new org.xmlBlaster.util.Hashtable();this.buddiesInbound=new org.xmlBlaster.util.Hashtable();this.buddiesOutboundIsSet=false;this.buddiesInboundIsSet=false;if(this.watchee!=null){var buddyListTO=new net.watchee.BuddyListTO(this.watchee.getLoginName());this.eventManager.fireEvent("clearBuddies",buddyListTO);this.eventManager.fireEvent("changed",buddyListTO);}}
this.clear=function(){this.clearBuddies();this.eventManager.clear();}
this.dispose=function(){this.clearBuddies();this.eventManager.dispose();this.watchee=null;}}
net.watchee.Watchee=function(urlBase,mapFrame,userName,buddyManager,requestResponseDispatcher,doMapInitialize){var doMapInitialize=org.xmlBlaster.util.toBoolean(doMapInitialize,true);this.log=net.watchee.util.log;this.urlBase=urlBase;if(org.xmlBlaster.util.isDefined(mapFrame)){useOpenLayers=xbProperties.getBoolean("useOpenLayers",true);if(useOpenLayers){this.log.info(ME2+"OpenLayersMapManager implementation");this.mapManager=new net.watchee.OpenLayersMapManager(this,mapFrame);}
else{this.log.info(ME2+"GoogleMapManager implementation");this.mapManager=new net.watchee.GoogleMapManager(this,mapFrame);}
if(doMapInitialize)
this.mapManager.initializeMap();}
this.loginName=(userName)?userName:"anonymous";this.xbAccess=new org.xmlBlaster.client.XbAccess(urlBase,userName);this.requestResponseDispatcher=requestResponseDispatcher||null;this.panningFenceLatPercent=xbProperties.getDouble("panningFenceLatPercent",0.9);this.panningFenceLngPercent=xbProperties.getDouble("panningFenceLngPercent",0.9);this.log.info(ME2+"Creating watchee instance for "+this.loginName);if(org.xmlBlaster.util.isDefined(buddyManager)){this.buddyManager=buddyManager;this.buddyManager.watchee=this;this.buddyManagerOwned=false;}
else{this.buddyManager=new net.watchee.BuddyManager(this);this.buddyManagerOwned=true;}
this.eventManager=new org.xmlBlaster.util.EventManager();this.accountTO=null;this.permissionTemplateList=new net.watchee.PermissionTemplateListTO();this.ruleManager=null;this.getRequestResponseDispatcher=function(){if(this.requestResponseDispatcher==null)
this.requestResponseDispatcher=new org.xmlBlaster.util.RequestResponseDispatcher();return this.requestResponseDispatcher;}
this.getRuleManager=function(){if(this.ruleManager==null)
this.ruleManager=new net.watchee.RuleManager(this);return this.ruleManager;}
this.registerMapInfoGui=function(mapInfoGui){this.mapManager.registerMapInfoGui(mapInfoGui);}
this.getAccountTO=function(){if(this.accountTO==null)
this.accountTO=new net.watchee.AccountTO(this,this.loginName);return this.accountTO;}
this.getEventManager=function(){return this.eventManager;}
this.getPermissionTemplateList=function(){return this.permissionTemplateList;}
this.setPermissionTemplateList=function(list){if(!org.xmlBlaster.util.isDefined(list))
return;this.permissionTemplateList=list;this.eventManager.fireEvent("setPermissionTemplates",list);}
this.getTopicSmssend=function(sms){var topicId="smssend";var sms=sms||null;if(sms==null||sms.length<6||sms.indexOf("+")!=0){return topicId;}
if(sms.indexOf("+420")==0){topicId+=".+420";}
else{topicId+="."+sms.substring(0,3);}
return topicId;}
this.validateSmsPhoneNumber=function(sms,allowAllNumbers){var allowAllNumbers=(allowAllNumbers==undefined)?false:allowAllNumbers;var sms=sms||null;if(sms==null){return null;}
sms=org.xmlBlaster.util.trim(sms);if(sms.indexOf("0049")==0){sms="+49"+sms.substring(4);}
else if(sms.indexOf("49")==0){sms="+49"+sms.substring(2);}
else if(sms.indexOf("0041")==0){sms="+41"+sms.substring(4);}
else if(sms.indexOf("41")==0){sms="+41"+sms.substring(2);}
else if(sms.indexOf("0091")==0){sms="+91"+sms.substring(4);}
else if(sms.indexOf("91")==0){sms="+91"+sms.substring(2);}
else if(sms.indexOf("00420")==0){sms="+420"+sms.substring(5);}
else if(sms.indexOf("420")==0){sms="+420"+sms.substring(3);}
if(!allowAllNumbers){var found=sms.indexOf("+49")==0||sms.indexOf("+420")==0||sms.indexOf("+41")==0||sms.indexOf("+91")==0;if(!found){return null;}}
for(var i=0,l=sms.length;i<l;i++){var c=sms.charAt(i);if("0123456789+:".indexOf(c)==-1)
return null;}
if(sms.length<8){return null;}
return sms;}
this.mapMarkerClicked=function(track,gpsData,marker){var data={deviceId:track.getDeviceId(),trackName:track.getTrackName(),gpsData:gpsData,marker:marker};this.eventManager.fireEvent("mapMarkerClicked",data);}
this.mapLineClicked=function(track,gpsData,polyLine){var data={deviceId:track.getDeviceId(),trackName:track.getTrackName(),gpsData:gpsData,polyLine:polyLine};this.eventManager.fireEvent("mapLineClicked",data);}
this.getBuddyManager=function(){return this.buddyManager;}
this.getMapManager=function(){return this.mapManager;}
this.getXbAccess=function(){return this.xbAccess;}
this.getLoginName=function(){return this.loginName;}
this.getUserName=function(){return this.loginName;}
this.createNewDevice=function(deviceId){var device=this.getDevice(deviceId);if(device!=null)
return device;var loginName=deviceId;var buddyTO=new net.watchee.BuddyTO(this,loginName);this.buddyManager.addBuddy(buddyTO);return buddyTO.getDevice();}
this.getDevice=function(deviceId){var loginName=deviceId;if(this.loginName==loginName)
return this.getAccountTO().getBuddyTO().getDevice();var buddyTO=this.buddyManager.getBuddyOrFriendOf(loginName);if(buddyTO==null)
return null;return buddyTO.getDevice();}
this.getDevices=function(){var buddies=this.buddyManager.getBuddyAndFriendOfList();var arr=new Array();for(var i=0,l=buddies.length;i<l;i++){arr.push(buddies[i].getDevice());}
return arr;}
this.dump=function(){var dd="\n{";var arr=this.buddyManager.getBuddyAndFriendOfList();for(var i=0;i<arr.length;i++){var buddyTO=arr[i];dd+="\n";dd+=" "+buddyTO.toXml();}
dd+="\n}";var ret=" userName="+this.getUserName()+" countDevices="+this.devices.length+
dd;return ret;}
this.hideHistoryLines=function(deviceId){if(deviceId==undefined){for(var i=0;i<this.devices.length;i++){this.devices[i].hideHistoryLines();}
return;}
else{var device=this.getDevice(deviceId);if(device!=null)
device.hideHistoryLines();}
return false;}
this.hideHistoryIcons=function(deviceId){if(deviceId==undefined){for(var i=0;i<this.devices.length;i++){this.devices[i].hideHistoryIcons();}}
else{var device=this.getDevice(deviceId);if(device!=null){device.hideHistoryIcons();}}}
this.sendxSMS=function(deviceId_,topicId_,content_,responseFp_,responseThisArg,returnObj_){this.log.debug(ME2+"sendxSMS called");var deviceId=deviceId_||null;var content_=content_||"";if(deviceId==null){this.log.error(ME2+"sendxSMS() failed, missing deviceId");return null;}
var topic=new net.watchee.WatcheeTopic(null,deviceId,"xsms");var topicId=topic.getTopicId();var sessionName=new org.xmlBlaster.util.SessionName(null,deviceId);var xsms=(content_ instanceof net.watchee.X_SMS)?content_:new net.watchee.X_SMS(this.loginName,sessionName.getAbsoluteName(),content_.substring(0,24),content_);var content=xsms.toXml();var responseFp=responseFp_||null;var qos="<xmlBlaster>"+"  <publish>"+"    <key oid='"+topicId+"'/>"+"    <content>"+org.xmlBlaster.util.escapeXml(content)+"</content>"+"    <qos><clientProperty name='"+org.xmlBlaster.client.KEY_REPLY_TO+"'>"+org.xmlBlaster.util.escapeXml(this.loginName)+"</clientProperty></qos>"+"  </publish>"+"</xmlBlaster>";var async=true;var forceLoad=false;this.postXmlScript(qos,responseFp,responseThisArg,async,forceLoad,returnObj_);return null;}
this.publishContent=function(topicId,content,qosDetail,responseFp_,responseThisArg,returnObj_,contentMime){this.log.debug(ME2+"publishContent called");var topicId=topicId||null;var content=content||"";var qosDetail=qosDetail||"";var contentMime=contentMime||null;if(topicId==null){this.log.error(ME2+"publishContent() failed, missing topicId or publishContent");return null;}
var responseFp=responseFp_||null;var attr=(contentMime==null)?"":("contentMime='"+contentMime+"'");var replyTo=qosDetail.indexOf(org.xmlBlaster.client.KEY_REPLY_TO)==-1?("<clientProperty name='"+org.xmlBlaster.client.KEY_REPLY_TO+"'>"+org.xmlBlaster.util.escapeXml(this.loginName)+"</clientProperty>"):"";var script="<xmlBlaster>"+"  <publish>"+"    <key oid='"+topicId+"' "+attr+"/>"+"    <content>"+org.xmlBlaster.util.escapeXml(content)+"</content>"+"    <qos>"+qosDetail+replyTo+"</qos>"+"  </publish>"+"</xmlBlaster>";var async=true;var forceLoad=false;this.postXmlScript(script,responseFp,responseThisArg,async,forceLoad,returnObj_);return null;}
this.setHttpMockCb=function(httpMockCb){this.xbAccess.setHttpMockCb(httpMockCb);}
this.postXmlScript=function(script,responseFp,responseThisArg,async,forceLoad,returnObj){return this.xbAccess.postXmlScript(script,responseFp,responseThisArg,async,forceLoad,returnObj);}
this.connect=function(forceLoad,securityLoginName,passwd,securityPlugin_,returnObj_){var securityPlugin=(securityPlugin_==undefined||securityPlugin_==null)?defaultXmlBlasterSecurityPlugin:securityPlugin_;var maxSessions=xbProperties.getInt("session.maxSessions",10);var admin=xbProperties.getBoolean("admin",false);var additionalParams=null;if(admin)
additionalParams="admin=true";return this.xbAccess.connect(forceLoad,securityLoginName,passwd,securityPlugin_,maxSessions,returnObj_,additionalParams);}
this.disconnect=function(){if(this.xbAccess==null)return;return this.xbAccess.disconnect();}
this.shutdown=function shutdown(){this.xbAccess.stopAjaxPolling();if(this.mapManager!=null){this.mapManager.shutdown();this.mapManager=null;}
if(this.xbAccess!=null){this.xbAccess.shutdown();this.xbAccess=null;}
if(this.buddyManager!=null){if(this.buddyManagerOwned)
this.buddyManager.dispose();else
this.buddyManager.clear();this.buddyManager=null;}
if(this.eventManager!=null){this.eventManager.dispose();this.eventManager=null;}
this.accountTO=null;xbProperties.resetAllButNotDefaultProperties();}
this.subscribe=function(key,qos,responseFp,responseThisArg,returnObj){return this.xbAccess.subscribe(key,qos,responseFp,responseThisArg,returnObj);}
this.unSubscribe=function(key,qos,responseFp,responseThisArg,returnObj){return this.xbAccess.unSubscribe(key,qos,responseFp,responseThisArg,returnObj);}
this.publishServiceMessage=function(serviceListTO,responseFp,responseThisArg,returnObj){return this.xbAccess.publishServiceMessage(watcheeServiceId,serviceListTO,responseFp,responseThisArg,returnObj);}
this.startAjaxPolling=function(onAjaxUpdateFp,pollingType){return this.xbAccess.startAjaxPolling(onAjaxUpdateFp,pollingType);}
this.stopAjaxPolling=function(){return this.xbAccess.stopAjaxPolling();}}
net.watchee.Watchee.prototype.addCurrentENMEA=function(device,msgUnit,groupIdInfo){var gpsData=device.addGPSSentence(msgUnit.getContentStr(),msgUnit);if(gpsData==null)return null;var isFromHistoryQueue=msgUnit.getQosData().getClientProperty(org.xmlBlaster.util.ClientProperty.CLIENTPROPERTY_ISINITIALUPDATE,false);gpsData.isInitialUpdate=isFromHistoryQueue;var groupIdInfo=groupIdInfo||null;if(groupIdInfo!=null){var groupId=msgUnit.getQosData().getClientProperty("groupId",null);var groupSubId=msgUnit.getQosData().getClientProperty("groupSubId",null);var pc=groupIdInfo.getGroupSubIdInfoOrNull(groupSubId);if(pc!=null){gpsData.propertyCollectionGroupSubId=pc;}
else{var aliasName=device.getAlias();if(aliasName!="RUND UM"){var pc=groupIdInfo.getGroupSubIdInfoOrNull(aliasName);if(pc!=null){gpsData.propertyCollectionGroupSubId=pc;}}}}
var track=device.getCurrentTrack();var forceShowingBecauseOfPhoto=false;var isValid=gpsData.isValid();{var old=device.setGpsSignalOk(isValid);if(old!=isValid){this.getBuddyManager().changedOnlineStatus(device.getLoginName(),device.getBuddyTO().getOnlineStatus(),device.getDeviceInfo().isDeviceSleepMode());}}
this.getMapManager().updateMap(track,gpsData,forceShowingBecauseOfPhoto);var data={track:track,gpsData:gpsData};this.eventManager.fireEvent("addGps",data);return gpsData;}
net.watchee.WatcheeTopic=function(something_,deviceId_,topicType_){if(something_ instanceof org.xmlBlaster.util.MsgUnit){this.msgUnit=something_;this.topicId=this.msgUnit.getKeyData().getOid();this.clientProperties=this.msgUnit.getQosData().clientProperties;}
else if(something_==undefined||something_==null||typeof something_=="string"){this.topicId=(something_==undefined||something_==null)?"":something_;this.clientProperties=new org.xmlBlaster.util.Hashtable();}
else{net.watchee.util.log.error(ME2+"WatcheeTopic called with invalid arguments");return;}
var firstIndex=this.topicId.indexOf(".");var lastIndex=this.topicId.lastIndexOf(".");this.prefix=(firstIndex>0)?this.topicId.substring(0,firstIndex):"device";if(firstIndex==lastIndex)
this.deviceId="";else if(firstIndex>0&&lastIndex>0)
this.deviceId=this.topicId.substring(firstIndex+1,lastIndex);else if(firstIndex>0)
this.deviceId=this.topicId.substring(firstIndex+1);else
this.deviceId="";this.topicType=(lastIndex>0)?this.topicId.substring(lastIndex+1):"";var given=false;if(org.xmlBlaster.util.isDefined(deviceId_)){this.deviceId=deviceId_;given=true;}
if(org.xmlBlaster.util.isDefined(topicType_)){this.topicType=topicType_;given=true;}
if(given){this.topicId=this.prefix+"."+this.deviceId+"."+this.topicType;}
this.hasClientProperty=function(key){var cp=this.clientProperties.get(key);if(cp==undefined||cp==null)return false;return true;}
this.getClientProperty=function(key,defaultValue){if(defaultValue==undefined)
return this.clientProperties.get(key);var cp=this.clientProperties.get(key);if(cp==undefined||cp==null)return defaultValue;return cp.getValue();}
this.getTopicId=function(){return this.topicId;}
this.getPrefix=function(){return this.prefix;}
this.getDeviceId=function(){return this.deviceId;}
this.getTopicType=function(){return this.topicType;}
this.isDevice=function(){return"device"==this.prefix;}
this.isxSMS=function(){return"xsms"==this.topicType;}
this.isNmea=function(){return"nmea"==this.topicType;}
this.isAlarm=function(){return"alarm"==this.topicType;}
this.isCmd=function(){return"cmd"==this.topicType;}
this.isStatus=function(){return"status"==this.topicType;}
this.isCfg=function(){return"cfg"==this.topicType;}
this.isReset=function(){return this.isCmd()&&this.getClientProperty("_cmd","")=="reset";}
this.isServiceResponse=function(){return"watchee.service.response"==this.topicId;}
this.getCmdStr=function(){return this.getClientProperty("_cmd","");}
this.isValid=function(){return this.deviceId!=""&&this.topicType!="";}
this.isKnown=function(){return this.isxSMS()||this.isNmea()||this.isCmd();}
this.toString=function(){return this.getTopicId();}}
net.watchee._DEGREE="&deg;";net.watchee.GPSData=function(nmeaDatas,device_){this.device=device_||null;var nmeaData=(nmeaDatas instanceof Array)?nmeaDatas[0]:nmeaDatas;var array=nmeaData.split(",");var i=0;this.DEGREE=net.watchee._DEGREE;this.cachedUtcIsoStr=null;this.isInitialUpdate=false;this.sentence=array[i++];this.time=null;this.warning=null;this.latitude=null;this.latitudeNS=null;this.longitude=null;this.longitudeEW=null;this.speed=null;this.course=null;this.date=null;this.magneticVariation=null;this.ewIndicator=null;this.modeIndicator="A";this.checksum=null;this.altitude=null;this.infoMap=null;this.poiMap=null;this.addressStrFromDb=false;this.propertyCollectionGroupSubId=null;this.isGPRMC=function(){return"$GPRMC"===this.sentence;}
this.isGPGGA=function(){return"$GPGGA"===this.sentence;}
this.isGPGSV=function(){return"$GPGSV"===this.sentence;}
this.isWATCHEE=function(){return"$WATCHEE"===this.sentence;}
this.trailingInfo="";if("$WATCHEE"==this.sentence){while(array.length>i){this.trailingInfo+=(this.trailingInfo=="")?array[i++]:(","+array[i++]);}}
else if("$GPRMC"==this.sentence){if(array.length<12)net.watchee.util.log.error(ME2+"Invalid $GPRMC has "+array.length+" instead of 12 elements: "+nmeaData);this.time=array[i++];this.warning=array[i++];this.latitude=array[i++];this.latitudeNS=array[i++];this.longitude=array[i++];this.longitudeEW=array[i++];this.speed=array[i++];this.course=array[i++];this.date=array[i++];this.magneticVariation=array[i++];if(array[i].charAt(0)!='*')
this.ewIndicator=array[i++];this.modeIndicator="";if(array[i].charAt(0)!='*')
this.modeIndicator=array[i++];if(this.modeIndicator!=undefined&&this.modeIndicator!=null&&this.modeIndicator.length>1){this.checksum=this.modeIndicator.substring(1,20);this.modeIndicator=this.modeIndicator.substring(0,1);}
else{this.checksum=array[i++];}
if(this.checksum!=null&&this.checksum.indexOf("*")==0)
this.checksum=this.checksum.substring(1);while(array.length>i)
this.trailingInfo+=(this.trailingInfo=="")?array[i++]:(","+array[i++]);this.dump=function(){return"\nsentence="+this.sentence+"\ntime="+this.time+"\nwarning="+this.warning+"\nlatitude="+this.latitude+this.latitudeNS+" = "+this.latitudeDegMinSec()+" = "+this.latitudeDecimal(6)+"\nlongitude="+this.longitude+this.longitudeEW+" = "+this.longitudeDegMinSec()+" = "+this.longitudeDecimal(6)+"\nspeed="+this.speed+"\ncourse="+this.course+"\ndate="+this.date+"\nmagneticVariation="+this.magneticVariation+"\newIndicator="+this.ewIndicator+"\nmodeIndicator="+this.modeIndicator+"\nchecksum="+this.checksum+"\ntrailingInfo="+this.trailingInfo;}}
else if("$GPGGA"==this.sentence){if(array.length<15)net.watchee.util.log.error(ME2+"Invalid $GPGGA has "+array.length+" instead of 15 elements: "+nmeaData);this.time=array[i++];this.latitude=array[i++];this.latitudeNS=array[i++];this.longitude=array[i++];this.longitudeEW=array[i++];this.quality=array[i++];this.numSatellites=array[i++];this.horizontalDilution=array[i++];this.altitude=array[i++];this.altitudeUnit=array[i++];this.heightEllipsoid=array[i++];this.heightEllipsoidUnit=array[i++];this.timeSinceLastUpdate=array[i++];if(array[i].charAt(0)!='*')
this.refStationId=array[i++];if(this.refStationId!=null&&this.refStationId.indexOf('*')!=-1){var index=this.refStationId.indexOf('*');this.checksum=this.refStationId.substring(index+1);this.refStationId=this.refStationId.substring(0,index);}
else{this.checksum=array[i++];}
if(this.checksum!=null&&this.checksum.indexOf("*")==0)
this.checksum=this.checksum.substring(1);while(array.length>i)
this.trailingInfo+=(this.trailingInfo=="")?array[i++]:(","+array[i++]);this.dump=function(){return"\nsentence="+this.sentence+"\ntime="+this.time+"\nlatitude="+this.latitude+this.latitudeNS+"\nlongitude="+this.longitude+this.longitudeEW+"\nquality="+this.quality+"\nnumSatellites="+this.numSatellites+"\nhorizontalDilution="+this.horizontalDilution+"\naltitude="+this.altitude+"\naltitudeUnit="+this.altitudeUnit+"\nheightEllipsoid="+this.heightEllipsoid+"\nheightEllipsoidUnit="+this.heightEllipsoidUnit+"\ntimeSinceLastUpdate="+this.timeSinceLastUpdate+"\nrefStationId="+this.refStationId+"\nchecksum="+this.checksum+"\ntrailingInfo="+this.trailingInfo;}}
else if("$GPGSV"==this.sentence){if(array.length<20)net.watchee.util.log.error(ME2+"Invalid $GPGSV has "+array.length+" instead of 20 elements: "+nmeaData);this.satellites=new Array();var count=0;function Satellite(prnNumber,evelationDeg,azimuth,snr){this.prnNumber=prnNumber;this.evelationDeg=evelationDeg;this.azimuth=azimuth;this.snr=snr;this.dump=function(){return"\nprnNumber="+this.prnNumber+"\nevelationDeg="+this.evelationDeg+"\nazimuth="+this.azimuth+"\nsnr="+this.snr;}}
for(jj=0;jj<nmeaDatas.length;jj++){nmeaData=nmeaDatas[jj];i=0;array=nmeaData.split(",");this.sentence=array[i++];this.msgNum=array[i++];this.msgIndex=array[i++];this.numInView=new Number(array[i++]).valueOf();if(this.numInView<=this.satellites.length)break;this.satellites[count++]=new Satellite(array[i++],array[i++],array[i++],array[i++]);if(this.numInView<=this.satellites.length)break;this.satellites[count++]=new Satellite(array[i++],array[i++],array[i++],array[i++]);if(this.numInView<=this.satellites.length)break;this.satellites[count++]=new Satellite(array[i++],array[i++],array[i++],array[i++]);}
this.dump=function(){return"\nsentence="+this.sentence+"\nnumInView="+this.numInView+"\narrayLength="+this.satellites.length+"\nFirst:"+this.satellites[0].dump()+"\nLast:"+this.satellites[this.satellites.length-1].dump();}}
else{this.dump=function(){return"No NMEA data found";}}
if(this.trailingInfo.length>0){this.infoMap=new org.xmlBlaster.util.Hashtable();var entries=this.trailingInfo.split(",");var startsWithApos=false;var key="";var value="";for(var ii=0;ii<entries.length;ii++){if(startsWithApos==true){value+=","+entries[ii];if(value[value.length-1]=='"'){startsWithApos=false;value=value.substring(0,value.length-1);this.infoMap.put(key,value);}
continue;}
var tuple=entries[ii].split("=");if(tuple.length<1){net.watchee.util.log.warn(ME2+"Ignoring illegal trailing info in "+this.trailingInfo);continue;}
var key=tuple[0];if(tuple.length<2){value=org.xmlBlaster.util.replaceAllTokens(key,"&comma;",",");key='i';}
else{var value=org.xmlBlaster.util.replaceAllTokens(tuple[1],"&comma;",",");}
if(value.length>0){if(value[0]=='"'){startsWithApos=true;value=value.substring(1);}
if(value[value.length-1]=='"'){startsWithApos=false;value=value.substring(0,value.length-1);}
if(startsWithApos){continue;}}
this.infoMap.put(key,value);}}
if(this.infoMap!=null&&this.infoMap.contains(net.watchee.GPSData.KEY_ADDRESS)){this.addressStrFromDb=true;}}
net.watchee.GPSData.KEY_WATCHEE="$WATCHEE";net.watchee.GPSData.KEY_UNIQUEID="id";net.watchee.GPSData.KEY_STATUS_POI="_status";net.watchee.GPSData.KEY_HEIGHT="h";net.watchee.GPSData.KEY_BATTERY_STATE="bat";net.watchee.GPSData.KEY_BATTERY_LEVEL_PERCENT="batp";net.watchee.GPSData.KEY_VOLTAGE="volt";net.watchee.GPSData.KEY_CHARGED="ch";net.watchee.GPSData.KEY_WARNING="w";net.watchee.GPSData.KEY_LAT="lat";net.watchee.GPSData.KEY_LON="lon";net.watchee.GPSData.KEY_SRC="src";net.watchee.GPSData.KEY_KMH="kmh";net.watchee.GPSData.KEY_KMSUM="kmsum";net.watchee.GPSData.KEY_TIMESTAMP="ts";net.watchee.GPSData.KEY_RECEIVED_AT_TIMESTAMP="rts";net.watchee.GPSData.KEY_MAGNETIC_VARIATION="mi";net.watchee.GPSData.KEY_EWINDICATOR="ewi";net.watchee.GPSData.KEY_MODEINDICATOR="mi";net.watchee.GPSData.KEY_COURSE="c";net.watchee.GPSData.KEY_IN_PREFIX="in";net.watchee.GPSData.KEY_IN1="in1";net.watchee.GPSData.KEY_IN2="in2";net.watchee.GPSData.KEY_IN3="in3";net.watchee.GPSData.KEY_IN4="in4";net.watchee.GPSData.KEY_OUT_PREFIX="out";net.watchee.GPSData.KEY_OUT1="out1";net.watchee.GPSData.KEY_OUT2="out2";net.watchee.GPSData.KEY_OUT3="out3";net.watchee.GPSData.KEY_OUT4="out4";net.watchee.GPSData.KEY_INANALOG1="inAnalog1";net.watchee.GPSData.KEY_INANALOG2="inAnalog2";net.watchee.GPSData.KEY_ADDRESS="addr";net.watchee.GPSData.prototype.getInputStatus=function(inputNumber){var key=net.watchee.GPSData.KEY_IN_PREFIX+inputNumber;if(!this.hasInfo(key))
return null;return this.getInfoBoolean(key,false);}
net.watchee.GPSData.prototype.getInputLedIcon=function(inputNumber,pixelSize){var pixelSize=org.xmlBlaster.util.toNumber(pixelSize,12);var status=this.getInputStatus(inputNumber);if(status==null){return xbGetIcon(pixelSize+"/led-gray.png");}
else if(status==true){return xbGetIcon(pixelSize+"/led-green.png");}
else{return xbGetIcon(pixelSize+"/led-red.png");}}
net.watchee.GPSData.getInputAliasNameKey=function(inputNumber,isOn){var labelKey=net.watchee.GPSData.KEY_IN_PREFIX+inputNumber;labelKey+=isOn?".labelOn":".labelOff";return labelKey;}
net.watchee.GPSData.prototype.getCountInputStatus=function(){if(this.hasInfo(net.watchee.GPSData.KEY_IN4)){return 4;}
return 0;}
net.watchee.GPSData.prototype.getOutputStatus=function(inputNumber){var key=net.watchee.GPSData.KEY_OUT_PREFIX+inputNumber;if(!this.hasInfo(key))
return null;return this.getInfoBoolean(key,false);}
net.watchee.GPSData.prototype.getCountOutputStatus=function(){if(this.hasInfo(net.watchee.GPSData.KEY_OUT4)){return 4;}
return 0;}
net.watchee.GPSData.getOutputAliasNameKey=function(inputNumber,isOn){var labelKey=net.watchee.GPSData.KEY_OUT_PREFIX+inputNumber;labelKey+=isOn?".labelOn":".labelOff";return labelKey;}
net.watchee.GPSData.prototype.getOutputLedIcon=function(inputNumber,pixelSize){var pixelSize=org.xmlBlaster.util.toNumber(pixelSize,12);var status=this.getOutputStatus(inputNumber);if(status==null){return xbGetIcon(pixelSize+"/led-gray.png");}
else if(status==true){return xbGetIcon(pixelSize+"/led-green.png");}
else{return xbGetIcon(pixelSize+"/led-red.png");}}
net.watchee.GPSData.prototype.getTime=function(withMillis){if(this.isWATCHEE()){var ts=this.getInfo("ts",null);if(ts==null)
return"";var time=org.xmlBlaster.util.getTimeStrFromIsoDateStr(ts);return time;}
if(this.time==undefined||this.time==null)
return"";var str="";var index=0;if(this.time.length>=2)
str+=this.time.substring(0,2);if(this.time.length>=4)
str+=":"+this.time.substring(2,4);if(this.time.length>=6)
str+=":"+this.time.substring(4,6);if(org.xmlBlaster.util.toBoolean(withMillis)){if(this.time.length>=7)
str+=this.time.substring(6,this.time.length);}
return str;}
net.watchee.GPSData.prototype.getLocalTime=function(withSeconds){withSeconds=org.xmlBlaster.util.toBoolean(withSeconds,true);var da=this.getLocalDateObj();var hourS=new String(da.getHours());var minS=new String(da.getMinutes());var secS=new String(da.getSeconds());var iso="";if(hourS.length==1)iso+="0";iso+=da.getHours();iso+=":";if(minS.length==1)iso+="0";iso+=da.getMinutes();if(withSeconds){iso+=":";if(secS.length==1)iso+="0";iso+=da.getSeconds();}
return iso;}
net.watchee.GPSData.prototype.getDate=function(){if(this.isWATCHEE()){var ts=this.getInfo("ts",null);if(ts==null)
return"";var date=org.xmlBlaster.util.getDateStrFromIsoDateStr(ts);return date;}
if(this.date==undefined||this.date==null)
return"";var str="";var index=0;if(this.date.length>=6)
str+="20"+this.date.substring(4,6);if(this.date.length>=4)
str+="-"+this.date.substring(2,4);if(this.date.length>=2)
str+="-"+this.date.substring(0,2);return str;}
net.watchee.GPSData.prototype.getLocalDate=function(){var da=this.getLocalDateObj();var dy=da.getFullYear()
var dm=da.getMonth()+1
var dd=da.getDate()
if(dy<1970)dy=dy+100;var ys=new String(dy)
var ms=new String(dm)
var ds=new String(dd)
if(ms.length==1)ms="0"+ms;if(ds.length==1)ds="0"+ds;return ys+"-"+ms+"-"+ds;}
net.watchee.GPSData.prototype.getUtcIsoStr=function(){if(this.cachedUtcIsoStr!=null)return this.cachedUtcIsoStr;this.cachedUtcIsoStr=this.getDate()+"T"+this.getTime(true)+"Z";return this.cachedUtcIsoStr;}
net.watchee.GPSData.prototype.getUtcDateObj=function(){var date=this.getLocalDateObj();return org.xmlBlaster.util.getCurrentGmtDate(date);}
net.watchee.GPSData.prototype.getLocalDateObj=function(){return org.xmlBlaster.util.getDateFromIsoDateStr(this.getUtcIsoStr());}
net.watchee.GPSData.prototype.getLocalTsIsoStr=function(){return this.getLocalDate()+" "+this.getLocalTime();}
net.watchee.GPSData.prototype.getGoogleMapsLink=function(zoomLevel,infoText){var zoomLevel=zoomLevel||16;var infoText=infoText||"";var latLon=""+this.latitudeDecimal(7)+","+this.longitudeDecimal(7);var url="http://maps.google.com/maps?z="+zoomLevel+"&ll="+latLon+"&q="+latLon;var encoded=escape(org.xmlBlaster.util.trim(infoText));url+="("+encoded+")";return url;}
net.watchee.GPSData.prototype.getUniqueId=function(){var uniqueId=this.getInfo(net.watchee.GPSData.KEY_UNIQUEID,null);if(uniqueId==null||uniqueId.length==0){return this.getUtcIsoStr();}
return uniqueId;}
net.watchee.GPSData.prototype.latitudeDegMinSec=function(secFracDigits){if(this.isWATCHEE()){var val=net.watchee.GPSData.toLatitudeDegMinSecFromDeci(this.latitudeDecimal(),this.getLatitudeNS(),secFracDigits,true);return val;}
else{if(this.latitude==undefined||this.latitude==null)
return 0;if(!this.isValid())
return 0;if(secFracDigits==undefined)secFracDigits=2;return net.watchee.GPSData.toLatitudeDegMinSecFromNmea(this.latitude,this.latitudeNS,secFracDigits,true);}}
net.watchee.GPSData.prototype.longitudeDegMinSec=function(secFracDigits){if(this.isWATCHEE()){var val=net.watchee.GPSData.toLongitudeDegMinSecFromDeci(this.longitudeDecimal(),this.getLongitudeEW(),secFracDigits,true);return val;}
else{if(this.longitude==undefined||this.longitude==null)
return 0;if(!this.isValid())
return 0;if(secFracDigits==undefined)secFracDigits=2;return net.watchee.GPSData.toLongitudeDegMinSecFromNmea(this.longitude,this.longitudeEW,secFracDigits,true);}}
net.watchee.GPSData.prototype.hasAddressStrFromDb=function(){return this.addressStrFromDb;}
net.watchee.GPSData.prototype.getAddressCacheKey=function(countryCode){var countryCode=countryCode||"en";var decimals=5;var lat=this.latitudeDecimal(decimals);var lon=this.longitudeDecimal(decimals);var key=lat+","+lon+","+countryCode;return key;}
net.watchee.GPSData.prototype.getAddressStr=function(separator,lookupIfMissing,defaultValue){var lookupIfMissing=org.xmlBlaster.util.toBooleanRelaxed(lookupIfMissing,true);var defaultValue=defaultValue||null;var addressStr=this.getInfoMap().get(net.watchee.GPSData.KEY_ADDRESS,null);if(!lookupIfMissing){if(addressStr==null)
return defaultValue;return addressStr;}
if(addressStr==null){addressStr=net.watchee.getReverseGeocodeStrFromGpsData(this,";");}
if(addressStr==null){return"";}
this.setAddressStr(addressStr);var separator=separator||";";if(separator==";")
return addressStr;var addr=org.xmlBlaster.util.replaceAllTokens(addressStr,";",separator);return addr;}
net.watchee.GPSData.prototype.setAddressStr=function(addressStr){var old=this.getInfoMap().put(net.watchee.GPSData.KEY_ADDRESS,addressStr);return old;}
net.watchee.GPSData.prototype.getSpeedMeterPerSec=function(){var sp=this.getSpeedKnots();if(sp==0)
return 0;return sp*0.5144;}
net.watchee.GPSData.prototype.getSpeedMph=function(){var sp=this.getSpeedKnots();if(sp==0)
return 0;return sp/0.8690;}
net.watchee.GPSData.prototype.getSpeedKmh=function(){var sp=this.getSpeedKnots();if(sp==0)
return 0;return sp*1.852;}
net.watchee.GPSData.prototype.getSpeedKmhInteger=function(){var kmh=this.getSpeedKmh();return Math.round(kmh);}
net.watchee.GPSData.prototype.getCourse=function(){if(this.isWATCHEE()){var course=this.getInfoNumber("c",0);return course;}
else{if(this.course==undefined||this.course==null)
return 0;return new Number(this.course).valueOf();}}
net.watchee.GPSData.prototype.getCourseInteger=function(){return Math.round(this.getCourse());}
net.watchee.GPSData.prototype.hasValidHeight=function(){if(this.altitude!=null&&org.xmlBlaster.util.trim(this.altitude).length()>0||this.containsInfo("h")){if(this.isValid()){return true;}}
return false;}
net.watchee.GPSData.prototype.getHeight=function(decimals){var decimals=decimals||0;var floatNum=0;if(this.altitude!=null&&org.xmlBlaster.util.trim(this.altitude).length()>0){floatNum=org.xmlBlaster.util.toNumber(this.altitude,0);}
else{floatNum=org.xmlBlaster.util.toNumber(this.getInfo("h","0"));}
var num=org.xmlBlaster.util.round(floatNum,decimals);return num;}
net.watchee.GPSData.prototype.getTrackName=function(defaultName){var defaultName=defaultName||"";var tn=this.getInfo("t",defaultName);return tn;}
net.watchee.GPSData.prototype.getPictureId=function(defaultValue){var pictureId=this.getInfo("pi",null);if(pictureId==null)
pictureId=this.getInfo("p",defaultValue);return pictureId;}
net.watchee.GPSData.prototype.getPictureInfo=function(defaultValue){var pictureId=this.getPictureId(defaultValue);if(pictureId==defaultValue)return pictureId;var sizeString=this.getInfo("ps","");var size=net.watchee.toWidthHeight(sizeString,160,120);var mimeType=this.getInfo("pt","image/jpeg");return{pictureId:pictureId,mimeType:mimeType,width:size.width,height:size.height}}
net.watchee.GPSData.prototype.getSignatureId=function(defaultValue){var pictureId=this.getInfo("sig",null);return pictureId;}
net.watchee.GPSData.prototype.getSignatureInfo=function(defaultValue){var pictureId=this.getSignatureId(defaultValue);if(pictureId==defaultValue)return pictureId;var sizeString=this.getInfo("sigSize","");var size=net.watchee.toWidthHeight(sizeString,160,120);var mimeType=this.getInfo("sigType","image/jpeg");return{pictureId:pictureId,mimeType:mimeType,width:size.width,height:size.height}}
net.watchee.GPSData.prototype.getAudioId=function(defaultValue){var audioId=this.getInfo("audio",defaultValue);return audioId;}
net.watchee.GPSData.prototype.getBatteryPercent=function(defaultValue){var bat=this.getInfoNumber(net.watchee.GPSData.KEY_BATTERY_STATE,-1);var batP=-1;if(bat>0)
batP=bat*10;var batP=this.getInfoNumber(net.watchee.GPSData.KEY_BATTERY_LEVEL_PERCENT,batP);return batP;}
net.watchee.GPSData.prototype.getAudioInfo=function(defaultValue){var audioId=this.getAudioId(defaultValue);if(audioId==defaultValue)return audioId;var audioSec=this.getInfo("audioSec",defaultValue);var audioType=this.getInfo("audioType",defaultValue);return{audioId:audioId,audioSec:audioSec,audioType:audioType}}
net.watchee.GPSData.prototype.makeWatcheeMap=function(withAllInfo){var map=this.getInfoMap();var ts=this.getUtcIsoStr();if(ts==null)
ts=IsoDateParser.getCurrentUTCTimestampT();this.addMap(map,net.watchee.GPSData.KEY_TIMESTAMP,ts);this.addMap(map,net.watchee.GPSData.KEY_WARNING,this.warning);if(this.hasLatLon())
this.addMap(map,net.watchee.GPSData.KEY_LAT,""+this.latitudeDecimal());if(this.hasLatLon())
this.addMap(map,net.watchee.GPSData.KEY_LON,""+this.longitudeDecimal());if(this.hasSpeed())
this.addMap(map,net.watchee.GPSData.KEY_KMH,""+this.getSpeedKmh());if(this.hasCourse())
this.addMap(map,net.watchee.GPSData.KEY_COURSE,this.getCourse());if(this.magneticVariation!=null)
this.addMap(map,net.watchee.GPSData.KEY_MAGNETIC_VARIATION,this.magneticVariation);if(this.ewIndicator!=null)
this.addMap(map,net.watchee.GPSData.KEY_EWINDICATOR,this.ewIndicator);if(this.modeIndicator!=null)
this.addMap(map,net.watchee.GPSData.KEY_MODEINDICATOR,this.modeIndicator);var withAllInfo=org.xmlBlaster.util.toBoolean(withAllInfo,false);if(withAllInfo){if(this.latitude!=null){this.addMap(map,"latitudeNMEA",this.latitude);this.addMap(map,"latitudeNS",this.latitudeNS);}
if(this.longitude!=null){this.addMap(map,"longitudeNMEA",this.longitude);this.addMap(map,"longitudeEW",this.longitudeEW);}}
return map;}
net.watchee.GPSData.prototype.addMap=function(map,key,value){if(key==null||value==null||value.length==0)
return;map.put(key,value);}
net.watchee.GPSData.prototype.makeWatcheeString=function(withAllInfo){var map=this.makeWatcheeMap(withAllInfo);return net.watchee.GPSData.KEY_WATCHEE+","+map.toCSV();}
net.watchee.GPSData.prototype.getSpeedKnots=function(){if(this.isWATCHEE()){if(this.containsInfo("v")){var sp=this.getInfoNumber("v",0)
return sp;}
else if(this.containsInfo("kmh")){var kmh=this.getInfoNumber("kmh",0);var sp=kmh/1.852;return sp;}
return 0;}
else{if(this.speed==undefined||this.speed==null)
return 0;var sp=new Number(this.speed).valueOf();return sp;}}
net.watchee.GPSData.prototype.hasCourse=function(){return(this.course!=null);}
net.watchee.GPSData.prototype.hasSpeed=function(){return(this.speed!=null);}
net.watchee.GPSData.prototype.hasAlarm=function(){return(this.getAlarmType()!=null);}
net.watchee.GPSData.prototype.getAlarmType=function(){return this.getInfo("alarm",null);}
net.watchee.GPSData.prototype.getAlarmTypeNotNull=function(){return this.getInfo("alarm","");}
net.watchee.GPSData.prototype.isInputAnalog=function(inputNumber){var str=this.getInfo("inAnalog"+inputNumber,null);if(str!=null)
return true;else
return false;}
net.watchee.GPSData.prototype.hasAlarmOfType=function(alarmType){var alarmType=alarmType||null;var alarm=this.getAlarmType();return(alarm!=null&&alarm==alarmType);}
net.watchee.GPSData.prototype.isValid=function(){if(this.hasAlarmOfType("GPSSIGNAL_LOST"))
return false;if(this.isGPRMC()){return"A"==this.warning;}
else if(this.isWATCHEE()){var warn=this.getInfo("w","A");return(warn=="A");}
else if(this.isGPGGA()){return this.getQuality()!=net.watchee.GPSData.FixQuality.INVALID;}
else if(this.isGPGSV()){return true;}
return false;}
net.watchee.GPSData.prototype.isFromCellId=function(){if(this.isWATCHEE()){var src=this.getInfo("src",null);if(src=="CELL")
return true;return false;}
else{return"E"==this.modeIndicator;}}
net.watchee.GPSData.prototype.hasOnlyCellId=function(){return this.isFromCellId()&&!this.hasLatLon();}
net.watchee.GPSData.prototype.hasLatLon=function(){if(this.isWATCHEE()){var hasLat=this.containsInfo("lat");var hasLon=this.containsInfo("lon");return hasLat&&hasLon;}
else{return org.xmlBlaster.util.isFilled(this.latitude)&&org.xmlBlaster.util.isFilled(this.longitude);}}
net.watchee.GPSData.prototype.hasLatLonNull=function(){return!this.hasLatLonNotNull();}
net.watchee.GPSData.prototype.hasLatLonNotNull=function(){if(!this.hasLatLon())return false;var lat=this.latitudeDecimal();var lon=this.longitudeDecimal();if(lat<0.0000001&&lat>-0.0000001&&lon<0.0000001&&lon>-0.0000001)
return false;return true;}
net.watchee.GPSData.prototype.getMcc=function(){var mcc=this.getInfo("cmcc",null);if(mcc==null)
mcc=this.getInfo("mcc",null);return mcc;}
net.watchee.GPSData.prototype.getMnc=function(){var mnc=this.getInfo("cmnc",null);if(mnc==null)
mnc=this.getInfo("mnc",null);return mnc;}
net.watchee.GPSData.prototype.getCellId=function(){return this.getInfo("cellid",null);}
net.watchee.GPSData.prototype.getLac=function(){return this.getInfo("lac",null);}
net.watchee.GPSData.prototype.getInfoMap=function(){if(this.infoMap==undefined||this.infoMap==null)
return new org.xmlBlaster.util.Hashtable();return this.infoMap;}
net.watchee.GPSData.prototype.containsInfo=function(key_){if(key_==undefined||key_==null)
return false;var hashtable=this.getInfoMap();var val=hashtable.get(key_,null);if(val==undefined||val==null)
return false;return true;}
net.watchee.GPSData.prototype.isPoi=function(){return this.getContainerId()!=null;}
net.watchee.GPSData.prototype.getPoiCSV=function(){var hashtable=this.getInfoMap();var array=hashtable.getKeys();var csv="";for(var i=0,l=array.length;i<l;i++){var key=array[i];if(key.indexOf("@")!=0)
continue;var value=hashtable.get(key,"");if(csv.length>0)
csv+=",";csv+=key.substring(1)+"="+value;}
return csv;}
net.watchee.GPSData.prototype.getContainerId=function(){if(this.getPoiMap().hasOwnProperty("containerId")){return this.getPoiMap().containerId;}
return null;}
net.watchee.GPSData.prototype.getPoiMap=function(){if(this.poiMap!=null)return this.poiMap;var hashtable=this.getInfoMap();var array=hashtable.getKeys();var map=new Object();for(var i=0,l=array.length;i<l;i++){var key=array[i];if(key.indexOf("@")!=0)continue;var poiKeyStruct=net.watchee.GPSData.parsePoiKey(key);var value=hashtable.get(key,"");map[poiKeyStruct.inputId]=value;}
this.poiMap=map;return map;}
net.watchee.GPSData.parsePoiKey=function(key){var key=key||"";var poiKeyStruct={nameSpace:"",containerId:"",containerSubId:"",inputId:""};if(key.indexOf("@")!=0)
return poiKeyStruct;key=key.substring(1);if(key.indexOf("/")>=0){var arr=key.split("/");if(arr.length>0)
poiKeyStruct.nameSpace=arr[0];if(arr.length>1)
poiKeyStruct.containerId=arr[1];if(arr.length>2)
poiKeyStruct.containerSubId=arr[2];if(arr.length>3)
poiKeyStruct.inputId=arr[3];}
else{var arr=key.split("-");poiKeyStruct.containerId=arr[0];if(arr.length>2)
poiKeyStruct.inputId=arr[2];}
return poiKeyStruct;}
net.watchee.GPSData.prototype.getFoil=function(defaultValue){var defaultValue=defaultValue||null;var name=this.getInfo("foil",defaultValue);if(name==defaultValue)return this.getTrackName(defaultValue);return name;}
net.watchee.GPSData.prototype.parsePoiKey=function(key){if(key==undefined||key==null)
return null;var keyObj={namespacePoi:null,containerId:null,containerSubId:null,attributeId:null};var arr=key.split("-");if(arr.length>0)
keyObj.containerId=arr[0];if(arr.length>1)
keyObj.containerSubId=arr[1];if(arr.length>2)
keyObj.attributeId=arr[2];return keyObj;}
net.watchee.GPSData.prototype.getPoiInfo=function(key_,defaultValue_){if(key_==undefined||key_==null)
return defaultValue_;var hashtable=this.getInfoMap();if(key_.indexOf("@")!=0)
key_="@"+key_;var val=hashtable.get(key_,defaultValue_);if(val==undefined||val==null)
return defaultValue_;return val;}
net.watchee.GPSData.prototype.getInfo=function(key_,defaultValue_){if(key_==undefined||key_==null)
return defaultValue_;var hashtable=this.getInfoMap();var val=hashtable.get(key_,defaultValue_);if(val==undefined||val==null)
return defaultValue_;return val;}
net.watchee.GPSData.prototype.hasInfo=function(key_){if(key_==undefined||key_==null)
return false;var hashtable=this.getInfoMap();var val=hashtable.contains(key_);return val;}
net.watchee.GPSData.prototype.getInfoBoolean=function(key_,defaultValue_){if(key_==undefined||key_==null)
return defaultValue_;var hashtable=this.getInfoMap();var val=hashtable.getBoolean(key_,defaultValue_);if(val==undefined||val==null)
return defaultValue_;return val;}
net.watchee.GPSData.prototype.getInfoNumber=function(key_,defaultValue_){if(key_==undefined||key_==null)
return defaultValue_;var hashtable=this.getInfoMap();var val=hashtable.getNumber(key_,defaultValue_);if(val==undefined||val==null)
return defaultValue_;return val;}
net.watchee.GPSData.prototype.latitudeDecimal=function(decimals){if(this.isWATCHEE()){var decimals=decimals||6;var lat=this.getInfoNumber("lat",0.0);lat=org.xmlBlaster.util.round(lat,decimals);return lat;}
else{var lat=net.watchee.GPSData.toLatDecimalFromNmea(this.latitude,this.latitudeNS,decimals);return lat;}}
net.watchee.GPSData.prototype.longitudeDecimal=function(decimals){if(this.isWATCHEE()){var decimals=decimals||6;var lon=this.getInfoNumber("lon",0.0);lon=org.xmlBlaster.util.round(lon,decimals);return lon;}
else{var lon=net.watchee.GPSData.toLonDecimalFromNmea(this.longitude,this.longitudeEW,decimals);return lon;}}
net.watchee.GPSData.prototype.getLatitudeNS=function(){if(this.isWATCHEE()){if(this.latitudeDecimal()>=0)
return"N";else
return"S";}
else{return this.latitudeNS}}
net.watchee.GPSData.prototype.getLongitudeEW=function(){if(this.isWATCHEE()){if(this.longitudeDecimal()>=0)
return"E";else
return"W";}
else{return this.longitudeEW;}}
net.watchee.GPSData.prototype.getDistance=function(other){if(other==null)
return 0.;if(!this.isValid()||!other.isValid())
return 0.;var lat=this.latitudeDecimal(9);var lon=this.longitudeDecimal(9);if(lat<0.0000001&&lat>-0.0000001&&lon<0.0000001&&lon>-0.0000001)
return 0.0;var olat=other.latitudeDecimal(9);var olon=other.longitudeDecimal(9);if(olat<0.0000001&&olat>-0.0000001&&olon<0.0000001&&olon>-0.0000001)
return 0.0;var distanceKmh=net.watchee.Coordinate.getDistanceKmHaversine(lat,lon,olat,olon);return distanceKmh;}
net.watchee.GPSData.FixQuality=new Object();net.watchee.GPSData.FixQuality.INVALID=0;net.watchee.GPSData.FixQuality.GPS=1;net.watchee.GPSData.FixQuality.DGPS=2;net.watchee.GPSData.FixQuality.PPS=3;net.watchee.GPSData.FixQuality.RTK=4;net.watchee.GPSData.FixQuality.FRTK=5;net.watchee.GPSData.FixQuality.ESTDR=6;net.watchee.GPSData.FixQuality.MAN=7;net.watchee.GPSData.FixQuality.SIMUL=8;net.watchee.GPSData.toLatitudeDegMinSecFromDeci=function(latitudeDeci,northSouth,secFracDigits,withUnits){if(latitudeDeci==undefined||latitudeDeci==null)
return"";var withPrefix=false;var witPostfix=false;var nmea=net.watchee.GPSData.toLatNmeaFromDecimal(latitudeDeci,withPrefix,witPostfix);var degMinSec=net.watchee.GPSData.toLatitudeDegMinSecFromNmea(nmea,northSouth,secFracDigits,withUnits);return degMinSec;}
net.watchee.GPSData.toLongitudeDegMinSecFromDeci=function(longitudeDeci,eastWest,secFracDigits,withUnits){if(longitudeDeci==undefined||longitudeDeci==null)
return"";var withPrefix=false;var witPostfix=false;var nmea=net.watchee.GPSData.toLngNmeaFromDecimal(longitudeDeci,withPrefix,witPostfix);var degMinSec=net.watchee.GPSData.toLongitudeDegMinSecFromNmea(nmea,eastWest,secFracDigits,withUnits);return degMinSec;}
net.watchee.GPSData.toLatitudeDegMinSecFromNmea=function(latitudeNmea,northSouth,secFracDigits,withUnits){if(latitudeNmea==null||org.xmlBlaster.util.trim(latitudeNmea).length<1)
return"";var prefix="";var postfix="";if(northSouth=='N'||northSouth=='S'){postfix=" "+northSouth;}
else{northSouth='N';if(latitudeNmea.indexOf("-")==0){latitudeNmea=latitudeNmea.substring(1);northSouth='S';}
prefix=northSouth=='S'?"-":"";}
var dot=latitudeNmea.indexOf('.');var degrees=latitudeNmea.substring(0,dot-2);if(degrees.length==1)
degrees="0"+degrees;var minutes=latitudeNmea.substring(dot-2,dot);if(minutes.length==1)
minutes="0"+minutes;var tmpSec="0."+latitudeNmea.substring(dot+1);var seconds=org.xmlBlaster.util.toNumber(tmpSec,0.)*60.;var secStr=org.xmlBlaster.util.round(seconds,secFracDigits);if(Math.abs(seconds)<10)
secStr="0"+secStr;if(withUnits)
return prefix+degrees+net.watchee._DEGREE+minutes+"'"+secStr+'"'+postfix;else
return prefix+degrees+minutes+secStr+postfix;}
net.watchee.GPSData.toLongitudeDegMinSecFromNmea=function(longitudeNmea,eastWest,secFracDigits,withUnits){if(longitudeNmea==null||org.xmlBlaster.util.trim(longitudeNmea).length<1)
return"";var prefix="";var postfix="";if(longitudeNmea.indexOf("-")==0&&eastWest=='E'){eastWest='W';}
if(eastWest=='W'||eastWest=='E'){postfix=" "+eastWest;}
else{eastWest='E';if(longitudeNmea.indexOf("-")==0){longitudeNmea=longitudeNmea.substring(1);eastWest='W';}
prefix=(eastWest=='W')?"-":"";}
var dot=longitudeNmea.indexOf('.');var degrees=longitudeNmea.substring(0,dot-2);if(degrees.length==1)
degrees="00"+degrees;if(degrees.length==2)
degrees="0"+degrees;var minutes=longitudeNmea.substring(dot-2,dot);if(minutes.length==1)
minutes="0"+minutes;var tmpSec="0."+longitudeNmea.substring(dot+1);var seconds=org.xmlBlaster.util.toNumber(tmpSec,0.)*60.;var secStr=org.xmlBlaster.util.round(seconds,secFracDigits);if(Math.abs(seconds)<10)
secStr="0"+secStr;if(withUnits)
return prefix+degrees+net.watchee._DEGREE+minutes+"'"+secStr+'"'+postfix;else
return prefix+degrees+minutes+secStr+postfix;}
net.watchee.GPSData.toLatDecimalFromNmea=function(latitudeNmea,northSouth,decimals){var northSouth=northSouth||null;var decimals=decimals||6;if(latitudeNmea==null||org.xmlBlaster.util.trim(latitudeNmea).length<1)
return 0.;if(northSouth==null||latitudeNmea.indexOf("-")==0){northSouth='N';if(latitudeNmea.indexOf("-")==0){latitudeNmea=latitudeNmea.substring(1);northSouth='S';}}
var dot=latitudeNmea.indexOf('.');if(dot<2)return 0.;var degree=latitudeNmea.substring(0,dot-2);var minutes=latitudeNmea.substring(dot-2);var result=org.xmlBlaster.util.toNumber(degree,0.)+org.xmlBlaster.util.toNumber(minutes,0.)/60.;result=org.xmlBlaster.util.round(result,decimals);if(northSouth=='S')
result*=-1;return result;}
net.watchee.GPSData.toLonDecimalFromNmea=function(longitudeNmea,eastWest,decimals){var eastWest=eastWest||null;var decimals=decimals||6;if(longitudeNmea==null||org.xmlBlaster.util.trim(longitudeNmea).length<1)
return 0.;if(eastWest==null||longitudeNmea.indexOf("-")==0){eastWest='E';if(longitudeNmea.indexOf("-")==0){longitudeNmea=longitudeNmea.substring(1);eastWest='W';}}
var dot=longitudeNmea.indexOf('.');if(dot<2)return 0;var degree=longitudeNmea.substring(0,dot-2);var minutes=longitudeNmea.substring(dot-2);var result=org.xmlBlaster.util.toNumber(degree,0.)+org.xmlBlaster.util.toNumber(minutes,0.)/60;result=org.xmlBlaster.util.round(result,decimals);if(eastWest=='W')
result*=-1;return result;}
net.watchee.GPSData.toLatNmeaFromDecimal=function(latitudeDeci,withPrefix,witPostfix){var isNorth=(latitudeDeci>=0);var prefix=(withPrefix&&!isNorth)?"-":"";var postfix=(witPostfix)?(isNorth?"N":"S"):"";if(latitudeDeci<0)
latitudeDeci*=-1;var deg=Math.floor(latitudeDeci);var degStr=""+deg;degStr=org.xmlBlaster.util.fillZero(degStr,2);var min=latitudeDeci-deg;min*=60;var minStr=""+min;if(min<10)
minStr="0"+minStr;if(minStr.indexOf(".")==-1)
minStr+=".00";var res=degStr+minStr;if(res.length>11)
res=res.substring(0,11);return prefix+res+postfix;}
net.watchee.GPSData.toLngNmeaFromDecimal=function(longitudeDeci,withPrefix,witPostfix){var isEast=(longitudeDeci>=0);var prefix=(withPrefix&&!isEast)?"-":"";var postfix=(witPostfix)?(isEast?"E":"W"):"";if(longitudeDeci<0)
longitudeDeci*=-1;var deg=Math.floor(longitudeDeci);var degStr=""+deg;degStr=org.xmlBlaster.util.fillZero(degStr,3);var min=longitudeDeci-deg;min*=60;var minStr=""+min;if(min<10)
minStr="0"+minStr;if(minStr.indexOf(".")==-1)
minStr+=".00";var res=degStr+minStr;if(res.length>12)
res=res.substring(0,12);return prefix+res+postfix;}
net.watchee.PropertyPair=function(key,value,durable,type,info,flag){this.key=key;var PROP_PRREFIX="watchee-";if(this.key.indexOf(PROP_PRREFIX)==0){this.key=this.key.substring(PROP_PRREFIX.length);}
this.value=value;this.type=type||null;this.durable=(durable===undefined)?"0":(durable?"1":"0");this.timestamp=null;this.flag=flag||"";this.info=info||"";this.setType=function(type){this.type=type||null;}
this.isDurable=function(){return"1"==this.durable;}
this.setDurable=function(on){if(org.xmlBlaster.util.toBoolean(on,false)==true)
this.durable="1";else
this.durable="0";}
this.isString=function(){return this.type==null||this.type=="string";}
this.isInt=function(){return this.type!=null&&(this.type=="int"||this.type=="long");}
this.isBool=function(){return this.type!=null&&this.type=="bool";}
this.isFloat=function(){return this.type!=null&&this.type=="float";}
this.getType=function(){return this.type;}
this.getKey=function(){return this.key;}
this.getValue=function(){return this.value;}
this.getValueStr=function(){return""+this.value;}
this.hasTimestamp=function(){return this.timestamp!=null;}
this.getTimestamp=function(){return this.timestamp;}
this.setTimestampUtcIsoStr=function(timestampUtcIsoStr){this.timestamp=timestampUtcIsoStr;}
this.setCurrentTimestamp=function(){this.timestamp=org.xmlBlaster.util.getCurrentIsoGmtTimestampStr(null,true,true);}
this.getFlag=function(){return(this.flag==null?"":this.flag);}
this.getInfo=function(){return(this.info==null?"":this.info);}
this.getTypedValue=function(){if(this.isInt())
return parseInt(value);else if(this.isBool())
return org.xmlBlaster.util.toBoolean(this.value);else if(this.isFloat())
return parseFloat(value);else
return this.value;}
this.toXml=function(){var xml="";xml+="<pr k='"+org.xmlBlaster.util.escapeXmlAttr(key);if(this.type!=null)
xml+="' t='"+this.type
if(this.durable!=null&&this.durable!="0")
xml+="' d='"+this.durable;if(this.timestamp!=null&&this.timestamp.length>0)
xml+="' ts='"+org.xmlBlaster.util.escapeXmlAttr(this.timestamp);if(this.flag!=null&&this.flag.length>0)
xml+="' f='"+org.xmlBlaster.util.escapeXmlAttr(this.flag);if(this.info!=null&&this.info.length>0)
xml+="' i='"+org.xmlBlaster.util.escapeXmlAttr(this.info);if(this.value==null||this.value.length<1){xml+="'/>";return xml;}
xml+="'>";xml+=org.xmlBlaster.util.escapeXml(this.value);xml+="</pr>";return xml;}}
net.watchee.PropertyPair.parseXml=function(node){var key=node.getAttribute('k');if(key==null){var log=net.watchee.util.log;log.error("net.watchee.PropertyPair.parseXml: No <pr key=''> found, ignoring node "+org.xmlBlaster.util.getXPathLocation(node,true));return null;}
var durable=node.getAttribute('d');var type=node.getAttribute('t');var timestamp=node.getAttribute('ts');var flag=node.getAttribute('f');var info=node.getAttribute('i');var value=org.xmlBlaster.util.collectTextFromNodeChilds(node);var pr=new net.watchee.PropertyPair(key,value);if(org.xmlBlaster.util.isFilled(durable))
pr.durable=durable;if(org.xmlBlaster.util.isFilled(type))
pr.type=type;if(org.xmlBlaster.util.isFilled(timestamp))
pr.timestamp=timestamp;if(org.xmlBlaster.util.isFilled(flag))
pr.flag=flag;if(org.xmlBlaster.util.isFilled(info))
pr.info=info;return pr;}
net.watchee.PropertyCollection=function(clazz,updateType){this.propHash=new org.xmlBlaster.util.Hashtable();this.clazz=clazz||null;this.updateType=updateType||null;}
net.watchee.PropertyCollection.prototype.getClazz=function(){return this.clazz;}
net.watchee.PropertyCollection.prototype.getHashtable=function(){return this.propHash;}
net.watchee.PropertyCollection.prototype.sortByKeys=function(){this.propHash.sort();}
net.watchee.PropertyCollection.prototype.sortByKeysInsensitive=function(){var ascending=true;this.propHash.sortByKeysIgnoreCase(ascending);}
net.watchee.PropertyCollection.prototype.__checkMarkerKeys=function(){var clazzPropertyPair=this.propHash.remove(net.watchee.PropertyCollection.KEY_CLAZZ);if(clazzPropertyPair!=null)
this.clazz=clazzPropertyPair.getValue();var updateTypePropertyPair=this.propHash.remove(net.watchee.PropertyCollection.KEY_UPDATETYPE);if(updateTypePropertyPair!=null)
this.updateType=updateTypePropertyPair.getValue();}
net.watchee.PropertyCollection.prototype.isAll=function(){if(this.updateType==null)return true;return"all"==this.updateType;}
net.watchee.PropertyCollection.prototype.isUpdate=function(){return"update"==this.updateType;}
net.watchee.PropertyCollection.prototype.isDelete=function(){return"delete"==this.updateType;}
net.watchee.PropertyCollection.prototype.merge=function(propertyCollection){var arr=this.propHash.getValues();for(var i=0,l=arr.length;i<l;i++){var pair=arr[i];this.add(pair);}}
net.watchee.PropertyCollection.prototype.getPropertyPairArr=function(){var arr=this.propHash.getValues();return arr;}
net.watchee.PropertyCollection.prototype.contains=function(key){return this.propHash.get(key)!=null;}
net.watchee.PropertyCollection.prototype.get=function(key){return this.propHash.get(key);}
net.watchee.PropertyCollection.prototype.remove=function(key){return this.propHash.remove(key);}
net.watchee.PropertyCollection.prototype.getIsoDateStr=function(key,defaultValue){var propertyPair=this.propHash.get(key);if(propertyPair!=null){return propertyPair.getTimestamp();}
if(org.xmlBlaster.util.isDefined(defaultValue)){return defaultValue;}
return null;}
net.watchee.PropertyCollection.prototype.getDate=function(key){var isoDateStr=this.getIsoDateStr(key,null);if(isoDateStr==null)return null;return org.xmlBlaster.util.getDateFromIsoDateStr(isoDateStr);}
net.watchee.PropertyCollection.prototype.getStr=function(key,defaultValue){var propertyPair=this.propHash.get(key);if(propertyPair!=null){return propertyPair.getValue();}
if(org.xmlBlaster.util.isDefined(defaultValue)){return defaultValue;}
return null;}
net.watchee.PropertyCollection.prototype.getNumber=function(key,defaultValue){return org.xmlBlaster.util.toNumber(this.getStr(key,defaultValue),defaultValue);}
net.watchee.PropertyCollection.prototype.getInt=function(key,defaultValue){return org.xmlBlaster.util.toNumber(this.getStr(key,defaultValue),defaultValue);}
net.watchee.PropertyCollection.prototype.getFloat=function(key,defaultValue){return org.xmlBlaster.util.toNumber(this.getStr(key,defaultValue),defaultValue);}
net.watchee.PropertyCollection.prototype.getBoolean=function(key,defaultValue){return org.xmlBlaster.util.toBoolean(this.getStr(key,defaultValue),defaultValue);}
net.watchee.PropertyCollection.prototype.getBooleanRelaxed=function(key,defaultValue){return org.xmlBlaster.util.toBooleanRelaxed(this.getStr(key,defaultValue),defaultValue);}
net.watchee.PropertyCollection.prototype.addKeyValue=function(key,value){var propertyPair=this.get(key);if(propertyPair==null){propertyPair=new net.watchee.PropertyPair(key,value);this.add(propertyPair);}
else{propertyPair.value=value;}
return propertyPair;},net.watchee.PropertyCollection.prototype.add=function(propertyPair){if(propertyPair==null){return null;}
return this.propHash.put(propertyPair.key,propertyPair);}
net.watchee.PropertyCollection.prototype.size=function(){return this.propHash.size();}
net.watchee.PropertyCollection.prototype.deepClone=function(){var xml=this.toXml();return net.watchee.PropertyCollection.parseXml(xml);}
net.watchee.PropertyCollection.prototype.toXml=function(){var xml="<pc>";if(this.clazz!=null){var pair=new net.watchee.PropertyPair(net.watchee.PropertyCollection.KEY_CLAZZ,this.clazz);xml+=pair.toXml();}
if(this.updateType!=null){var pair=new net.watchee.PropertyPair(net.watchee.PropertyCollection.KEY_UPDATETYPE,this.updateType);xml+=pair.toXml();}
var arr=this.propHash.getValues();for(var i=0,l=arr.length;i<l;i++){var pr=arr[i];xml+=pr.toXml();}
xml+="</pc>";return xml;}
net.watchee.PropertyCollection.KEY_CLAZZ="__class";net.watchee.PropertyCollection.KEY_UPDATETYPE="__updateType";net.watchee.PropertyCollection.prototype.getKeys=function(){return this.propHash.getKeys();}
net.watchee.PropertyCollection.prototype.getStartsWith=function(start){var ret=new Array();var arr=this.propHash.getValues();for(var i=0,l=arr.length;i<l;i++){var pr=arr[i];if(pr.getKey().startsWith(start)){ret.push(pr);}}
return ret;}
net.watchee.PropertyCollection.parseXml=function(xmlString){var log=net.watchee.util.log;if(!org.xmlBlaster.util.isDefined(xmlString)){log.error("net.watchee.PropertyCollection.parseXml xmlString is undefined");return null;}
if(xmlString.indexOf("<")==-1)
log.error("watchee.js-PropertyCollection.parseXml(): The given xml does not look like xml, parsing nevertheless '"+xmlString+"'");var domDocument=org.xmlBlaster.util.getDOMDocument(xmlString);var rootNode=domDocument.documentElement;var pc=net.watchee.PropertyCollection.parseNode(rootNode);return pc;}
net.watchee.PropertyCollection.parseNode=function(rootNode){var log=net.watchee.util.log;var ME="watchee.js-PropertyCollection.parse(): ";if(rootNode.nodeName=="parsererror"){log.error(ME+"'parsererror' for "+rootNode);return null;}
var pc=new net.watchee.PropertyCollection();for(var i=0;i<rootNode.childNodes.length;i++){var node=rootNode.childNodes[i];if(node.nodeType!=Node.ELEMENT_NODE){var val=(node.nodeValue!=undefined&&node.nodeValue!=null)?(": '"+node.nodeValue+"'"):"";var txt=ME+"Ignoring node "+org.xmlBlaster.util.getXPathLocation(node,true)+val;(node.nodeType==Node.COMMENT_NODE||node.nodeType==Node.TEXT_NODE)?net.watchee.util.log.debug(ME2+txt):net.watchee.util.log.warn(ME2+txt);continue;}
if(node.nodeName=="p"||node.nodeName=="pr"){var pr=net.watchee.PropertyPair.parseXml(node);if(pr!=null)
pc.propHash.put(pr.key,pr);}
else{log.warn(ME+"("+org.xmlBlaster.util.getXPathLocation(node,true)+"): Ignoring tag '"+node.nodeName+"'");}}
pc.__checkMarkerKeys();return pc;}
net.watchee.PropertyCollections=function(){this.pcList=[];this.getPropertyCollections=function(){return this.pcList;}
this.size=function(){return this.pcList.length;}
this.getClazz=function(clazz){var clazz=clazz||null;if(clazz==null)return null;for(var i=0,l=this.pcList.length;i<l;i++){var pc=this.pcList[i];if(pc.getClazz()==clazz)
return pc;}
return null;}
this.getClazzes=function(clazz){var clazz=clazz||null;var arr=[];if(clazz==null)return arr;for(var i=0,l=this.pcList.length;i<l;i++){var pc=this.pcList[i];if(pc.getClazz()==clazz)
arr.push(pc);}
return arr;}
this.get=function(keyName,keyValue){var keyName=keyName||null;if(keyName==null)return null;for(var i=0,l=this.pcList.length;i<l;i++){var pc=this.pcList[i];if(pc.getStr(keyName,null)==keyValue)
return pc;}
return null;}
this.add=function(propertyCollection){this.pcList.push(propertyCollection);}
this.addPropertyCollectionArray=function(arr){for(var i=0,l=arr.length;i<l;i++)
this.pcList.push(arr[i]);}
this.addPropertyCollections=function(pcc){this.addPropertyCollectionArray(pcc.pcList);}
this.toXml=function(){var xml="<pcc>";for(var i=0,l=this.pcList.length;i<l;i++){var pc=this.pcList[i];xml+=pc.toXml();}
xml+="</pcc>";return xml;}}
net.watchee.PropertyCollections.parseXml=function(xmlString){var log=net.watchee.util.log;if(!org.xmlBlaster.util.isDefined(xmlString)){log.error("net.watchee.PropertyCollections.parseXml xmlString is undefined");return null;}
if(xmlString.indexOf("<")==-1)
log.error("net.watchee.PropertyCollections.parseXml The given xml does not look like xml, parsing nevertheless '"+xmlString+"'");var domDocument=org.xmlBlaster.util.getDOMDocument(xmlString);var rootNode=domDocument.documentElement;if(rootNode.nodeName=="parsererror"){log.error("net.watchee.PropertyCollections.parseXml 'parsererror' for "+xmlString);return null;}
var pcc=new net.watchee.PropertyCollections();for(var i=0;i<rootNode.childNodes.length;i++){var pc=net.watchee.PropertyCollection.parseNode(rootNode.childNodes[i]);pcc.add(pc);}
return pcc;}
