Files
VSC/Web/webphone/js/lib/lib_webphone.js
T
claudio 368d6fafea Issue
Code backup
2026-05-10 16:59:01 +02:00

58 lines
1.7 MiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
webphone_api.platformClass=function(){"use strict";function e(e){return e=String(e),e.charAt(0).toUpperCase()+e.slice(1)}function n(e,n,t){var i={"11.0":"11","10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return n&&t&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(i=i[/[\d.]+$/.exec(e)])&&(e="Windows "+i),e=String(e),n&&t&&(e=e.replace(RegExp(n,"i"),t)),e=o(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}function t(e,n){var t=-1,o=e?e.length:0;if("number"==typeof o&&o>-1&&o<=b)for(;++t<o;)n(e[t],t,e);else i(e,n)}function o(n){return n=p(n),/^(?:webOS|i(?:OS|P))/.test(n)?n:e(n)}function i(e,n){for(var t in e)w.call(e,t)&&n(e[t],t,e)}function a(n){return null==n?e(n):v.call(n).slice(8,-1)}function r(e,n){var t=null!=e?typeof e[n]:"number";return!(/^(?:boolean|number|string|undefined)$/.test(t)||"object"==t&&!e[n])}function l(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function s(e,n){var o=null;return t(e,function(t,i){o=n(o,t,i,e)}),o}function p(e){return String(e).replace(/^ +| +$/g,"")}function c(e){function t(n){return s(n,function(n,t){var i=t.pattern||l(t);return!n&&(n=RegExp("\\b"+i+" *\\d+[.\\w_]*","i").exec(e)||RegExp("\\b"+i+" *\\w+-[\\w]*","i").exec(e)||RegExp("\\b"+i+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(e))&&((n=String(t.label&&!RegExp(i,"i").test(t.label)?t.label:n).split("/"))[1]&&!/[\d.]+/.test(n[0])&&(n[0]+=" "+n[1]),t=t.label||t,n=o(n[0].replace(RegExp(i,"i"),t).replace(RegExp("; *(?:"+t+"[_-])?","i")," ").replace(RegExp("("+t+")[-_.]?(\\w)","i"),"$1 $2"))),n})}function u(n){return s(n,function(n,t){return n||(RegExp(t+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(e)||0)[1]||null})}function h(){return this.description||""}var m=g,d=e&&"object"==typeof e&&"String"!=a(e);d&&(m=e,e=null);var b=m.navigator||{},f=b.userAgent||"";e||(e=f);var w="";try{w=b.platform}catch(q){}void 0!==w&&null!=w||(w="");var E,P=d?!!b.likeChrome:/\bChrome\b/.test(e)&&!/internal|\n/i.test(v.toString()),T=d?"Object":"ScriptBridgingProxyObject",S=d?"Object":"Environment",N=d&&m.java?"JavaPackage":a(m.java),I=d?"Object":"RuntimeObject",C=/\bJava/.test(N)&&m.java,G=C&&a(m.environment)==S,L=C?"a":"α",R=C?"b":"β",y=m.document||{},D=m.operamini||m.opera;try{E=_.test(E=d&&D?D["[[Class]]"]:a(D))?E:D=null}catch(q){}var O,x,A=e,k=[],U=null,V=e==f,W=V&&D&&"function"==typeof D.version&&D.version(),F=function(n){return s(n,function(n,t){return n||RegExp("\\b"+(t.pattern||l(t))+"\\b","i").exec(e)&&(t.label||t)})}([{label:"EdgeHTML",pattern:"(?:Edge|EdgA|EdgiOS)"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),M=function(n){return s(n,function(n,t){return n||RegExp("\\b"+(t.pattern||l(t))+"\\b","i").exec(e)&&(t.label||t)})}(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),H=t([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),B=function(n){return s(n,function(n,t,o){return n||(t[H]||t[/^[a-z]+(?: +[a-z]+\b)*/i.exec(H)]||RegExp("\\b"+l(o)+"(?:\\b|\\w*\\d)","i").exec(e))&&o})}({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),j=function(t){return s(t,function(t,o){var i=o.pattern||l(o);return!t&&(t=RegExp("\\b"+i+"(?:/[\\d.]+|[ \\w.]*)","i").exec(e))&&(t=n(t,i,o.label||o)),t})}(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);if(F&&(F=[F]),/\bAndroid\b/.test(j)&&!H&&(O=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(e))&&(H=p(O[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),B&&!H?H=t([B]):B&&H&&(H=H.replace(RegExp("^("+l(B)+")[-_.\\s]","i"),B+" ").replace(RegExp("^("+l(B)+")[-_.]?(\\w)","i"),B+" $2")),(O=/\bGoogle TV\b/.exec(H))&&(H=O[0]),/\bSimulator\b/i.test(e)&&(H=(H?H+" ":"")+"Simulator"),"Opera Mini"==M&&/\bOPiOS\b/.test(e)&&k.push("running in Turbo/Uncompressed mode"),"IE"==M&&/\blike iPhone OS\b/.test(e)?(O=c(e.replace(/like iPhone OS/,"")),B=O.manufacturer,H=O.product):/^iP/.test(H)?(M||(M="Safari"),j="iOS"+((O=/ OS ([\d_]+)/i.exec(e))?" "+O[1].replace(/_/g,"."):"")):"Konqueror"==M&&/^Linux\b/i.test(j)?j="Kubuntu":B&&"Google"!=B&&e.indexOf("Windows NT")<0&&w.indexOf("Win32")<0&&(/Chrome/.test(M)&&!/\bMobile Safari\b/i.test(e)||/\bVita\b/.test(H))||/\bAndroid\b/.test(j)&&/^Chrome/.test(M)&&/\bVersion\//i.test(e)?(M="Android Browser",j=/\bAndroid\b/.test(j)?j:"Android"):"Silk"==M?(/\bMobi/i.test(e)||(j="Android",k.unshift("desktop mode")),/Accelerated *= *true/i.test(e)&&k.unshift("accelerated")):"UC Browser"==M&&/\bUCWEB\b/.test(e)?k.push("speed mode"):"PaleMoon"==M&&(O=/\bFirefox\/([\d.]+)\b/.exec(e))?k.push("identifying as Firefox "+O[1]):"Firefox"==M&&(O=/\b(Mobile|Tablet|TV)\b/i.exec(e))?(j||(j="Firefox OS"),H||(H=O[1])):!M||(O=!/\bMinefield\b/i.test(e)&&/\b(?:Firefox|Safari)\b/.exec(M))?(M&&!H&&/[\/,]|^[^(]+?\)/.test(e.slice(e.indexOf(O+"/")+8))&&(M=null),(O=H||B||j)&&(H||B||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(j))&&(M=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(j)?j:O)+" Browser")):"Electron"==M&&(O=(/\bChrome\/([\d.]+)\b/.exec(e)||0)[1])&&k.push("Chromium "+O),W||(W=u(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",l(M),"(?:Firefox|Minefield|NetFront)"])),(O="iCab"==F&&parseFloat(W)>3&&"WebKit"||/\bOpera\b/.test(M)&&(/\bOPR\b/.test(e)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(e)&&!/^(?:Trident|EdgeHTML)$/.test(F)&&"WebKit"||!F&&/\bMSIE\b/i.test(e)&&("Mac OS"==j?"Tasman":"Trident")||"WebKit"==F&&/\bPlayStation\b(?! Vita\b)/i.test(M)&&"NetFront")&&(F=[O]),"IE"==M&&(O=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(e)||0)[1])?(M+=" Mobile",j="Windows Phone "+(/\+$/.test(O)?O:O+".x"),k.unshift("desktop mode")):/\bWPDesktop\b/i.test(e)?(M="IE Mobile",j="Windows Phone 8.x",k.unshift("desktop mode"),W||(W=(/\brv:([\d.]+)/.exec(e)||0)[1])):"IE"!=M&&"Trident"==F&&(O=/\brv:([\d.]+)/.exec(e))&&(M&&k.push("identifying as "+M+(W?" "+W:"")),M="IE",W=O[1]),V){if(r(m,"global"))if(C&&(O=C.lang.System,A=O.getProperty("os.arch"),j=j||O.getProperty("os.name")+" "+O.getProperty("os.version")),G){try{W=m.require("ringo/engine").version.join("."),M="RingoJS"}catch(z){(O=m.system)&&O.global.system==m.system&&(M="Narwhal",j||(j=O[0].os||null))}M||(M="Rhino")}else"object"==typeof m.process&&!m.process.browser&&(O=m.process)&&("object"==typeof O.versions&&("string"==typeof O.versions.electron?(k.push("Node "+O.versions.node),M="Electron",W=O.versions.electron):"string"==typeof O.versions.nw&&(k.push("Chromium "+W,"Node "+O.versions.node),M="NW.js",W=O.versions.nw)),M||(M="Node.js",A=O.arch,j=O.platform,W=/[\d.]+/.exec(O.version),W=W?W[0]:null));else a(O=m.runtime)==T?(M="Adobe AIR",j=O.flash.system.Capabilities.os):a(O=m.phantom)==I?(M="PhantomJS",W=(O=O.version||null)&&O.major+"."+O.minor+"."+O.patch):"number"==typeof y.documentMode&&(O=/\bTrident\/(\d+)/i.exec(e))?(W=[W,y.documentMode],(O=+O[1]+4)!=W[1]&&(k.push("IE "+W[1]+" mode"),F&&(F[1]=""),W[1]=O),W="IE"==M?String(W[1].toFixed(1)):W[0]):"number"==typeof y.documentMode&&/^(?:Chrome|Firefox)\b/.test(M)&&(k.push("masking as "+M+" "+W),M="IE",W="11.0",F=["Trident"],j="Windows");j=j&&o(j)}if(W&&(O=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(W)||/(?:alpha|beta)(?: ?\d)?/i.exec(e+";"+(V&&b.appMinorVersion))||/\bMinefield\b/i.test(e)&&"a")&&(U=/b/i.test(O)?"beta":"alpha",W=W.replace(RegExp(O+"\\+?$"),"")+("beta"==U?R:L)+(/\d+\+?/.exec(O)||"")),"Fennec"==M||"Firefox"==M&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(j))M="Firefox Mobile";else if("Maxthon"==M&&W)W=W.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(H))"Xbox 360"==H&&(j=null),"Xbox 360"==H&&/\bIEMobile\b/.test(e)&&k.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(M)&&(!M||H||/Browser|Mobi/.test(M))||"Windows CE"!=j&&!/Mobi/i.test(e))if("IE"==M&&V)try{null===m.external&&k.unshift("platform preview")}catch(z){k.unshift("embedded")}else(/\bBlackBerry\b/.test(H)||/\bBB10\b/.test(e))&&(O=(RegExp(H.replace(/ +/g," *")+"/([.\\d]+)","i").exec(e)||0)[1]||W)?(O=[O,/BB10/.test(e)],j=(O[1]?(H=null,B="BlackBerry"):"Device Software")+" "+O[0],W=null):this!=i&&"Wii"!=H&&(V&&D||/Opera/.test(M)&&/\b(?:MSIE|Firefox)\b/i.test(e)||"Firefox"==M&&/\bOS X (?:\d+\.){2,}/.test(j)||"IE"==M&&(j&&!/^Win/.test(j)&&W>5.5||/\bWindows XP\b/.test(j)&&W>8||8==W&&!/\bTrident\b/.test(e)))&&!_.test(O=c.call(i,e.replace(_,"")+";"))&&O.name&&(O="ing as "+O.name+((O=O.version)?" "+O:""),_.test(M)?(/\bIE\b/.test(O)&&"Mac OS"==j&&(j=null),O="identify"+O):(O="mask"+O,M=E?o(E.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(O)&&(j=null),V||(W=null)),F=["Presto"],k.push(O));else M+=" Mobile";(O=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(e)||0)[1])&&(O=[parseFloat(O.replace(/\.(\d)$/,".0$1")),O],"Safari"==M&&"+"==O[1].slice(-1)?(M="WebKit Nightly",U="alpha",W=O[1].slice(0,-1)):W!=O[1]&&W!=(O[2]=(/\bSafari\/([\d.]+\+?)/i.exec(e)||0)[1])||(W=null),O[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(e)||0)[1],537.36==O[0]&&537.36==O[2]&&parseFloat(O[1])>=28&&"WebKit"==F&&(F=["Blink"]),V&&(P||O[1])?(F&&(F[1]="like Chrome"),O=O[1]||(O=O[0],O<530?1:O<532?2:O<532.05?3:O<533?4:O<534.03?5:O<534.07?6:O<534.1?7:O<534.13?8:O<534.16?9:O<534.24?10:O<534.3?11:O<535.01?12:O<535.02?"13+":O<535.07?15:O<535.11?16:O<535.19?17:O<536.05?18:O<536.1?19:O<537.01?20:O<537.11?"21+":O<537.13?23:O<537.18?24:O<537.24?25:O<537.36?26:"Blink"!=F?"27":"28")):(F&&(F[1]="like Safari"),O=O[0],O=O<400?1:O<500?2:O<526?3:O<533?4:O<534?"4+":O<535?5:O<537?6:O<538?7:O<601?8:O<602?9:O<604?10:O<606?11:O<608?12:"12"),F&&(F[1]+=" "+(O+="number"==typeof O?".x":/[.+]/.test(O)?"":"+")),"Safari"==M&&(!W||parseInt(W)>45)?W=O:"Chrome"==M&&/\bHeadlessChrome/i.test(e)&&k.unshift("headless")),"Opera"==M&&(O=/\bzbov|zvav$/.exec(j))?(M+=" ",k.unshift("desktop mode"),"zvav"==O?(M+="Mini",W=null):M+="Mobile",j=j.replace(RegExp(" *"+O+"$"),"")):"Safari"==M&&/\bChrome\b/.exec(F&&F[1])?(k.unshift("desktop mode"),M="Chrome Mobile",W=null,/\bOS X\b/.test(j)?(B="Apple",j="iOS 4.3+"):j=null):/\bSRWare Iron\b/.test(M)&&!W&&(W=u("Chrome")),W&&0==W.indexOf(O=/[\d.]+$/.exec(j))&&e.indexOf("/"+O+"-")>-1&&(j=p(j.replace(O,""))),j&&-1!=j.indexOf(M)&&!RegExp(M+" OS").test(j)&&(j=j.replace(RegExp(" *"+l(M)+" *"),"")),F&&!/\b(?:Avant|Nook)\b/.test(M)&&(/Browser|Lunascape|Maxthon/.test(M)||"Safari"!=M&&/^iOS/.test(j)&&/\bSafari\b/.test(F[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(M)&&F[1])&&(O=F[F.length-1])&&k.push(O),(void 0===j||null==j||j.length<1)&&(e.toLowerCase().indexOf("windows")>=0||w.toLowerCase().indexOf("win32")>=0?j="Windows":e.toLowerCase().indexOf("android")>=0||w.toLowerCase().indexOf("android")>=0?j="Android":e.toLowerCase().indexOf("ios")>=0||w.toLowerCase().indexOf("ios")>=0?j="iOS":e.toLowerCase().indexOf("mac")>=0||w.toLowerCase().indexOf("mac")>=0?j="Android":(e.toLowerCase().indexOf("linux")>=0||e.toLowerCase().indexOf("debian")>=0||e.toLowerCase().indexOf("gentoo")>=0||e.toLowerCase().indexOf("ubuntu")>=0||e.toLowerCase().indexOf("centos")>=0||e.toLowerCase().indexOf("red hat")>=0||e.toLowerCase().indexOf("suse")>=0||w.toLowerCase().indexOf("linux")>=0||w.toLowerCase().indexOf("debian")>=0||w.toLowerCase().indexOf("gentoo")>=0||w.toLowerCase().indexOf("ubuntu")>=0||w.toLowerCase().indexOf("centos")>=0||w.toLowerCase().indexOf("red hat")>=0||w.toLowerCase().indexOf("suse")>=0)&&(j="Linux")),k.length&&(k=["("+k.join("; ")+")"]),B&&H&&H.indexOf(B)<0&&k.push("on "+B),H&&k.push((/^on /.test(k[k.length-1])?"":"on ")+H),j&&(O=/ ([\d.+]+)$/.exec(j),x=O&&"/"==j.charAt(j.length-O[0].length-1),j={architecture:32,family:O&&!x?j.replace(O[0],""):j,version:O?O[1]:null,toString:function(){var e=this.version;return this.family+(e&&!x?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(O=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(A))&&!/\bi686\b/i.test(A)?(j&&(j.architecture=64,j.family=j.family.replace(RegExp(" *"+O),"")),M&&(/\bWOW64\b/i.test(e)||V&&/\w(?:86|32)$/.test(b.cpuClass||b.platform)&&!/\bWin64; x64\b/i.test(e))&&k.unshift("32-bit")):j&&/^OS X/.test(j.family)&&"Chrome"==M&&parseFloat(W)>=39&&(j.architecture=64),e||(e=null);var $={};return $.description=e,$.layout=F&&F[0],$.manufacturer=B,$.name=M,$.prerelease=U,$.product=H,$.ua=e,$.version=M&&W,$.os=j||{architecture:null,family:null,version:null,toString:function(){return"null"}},$.parse=c,$.toString=h,$.version&&k.unshift(W),$.name&&k.unshift(M),j&&M&&(j!=String(j).split(" ")[0]||j!=M.split(" ")[0]&&!H)&&k.push(H?"("+j+")":"on "+j),k.length&&($.description=k.join(" ")),$}var u={"function":!0,object:!0},g=u[typeof window]&&window||this,h=u[typeof exports]&&exports,m=u[typeof module]&&module&&!module.nodeType&&module,d=h&&m&&"object"==typeof global&&global;!d||d.global!==d&&d.window!==d&&d.self!==d||(g=d);var b=Math.pow(2,53)-1,_=/\bOpera/,f=Object.prototype,w=f.hasOwnProperty,v=f.toString;webphone_api.platform=c()}(),function(e,n){"use strict";e.webphone_api.picoModal=function(){"use strict";function e(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType}function n(e){return"string"==typeof e}function t(){var e=[];return{watch:e.push.bind(e),trigger:function(n){for(var t=!0,o={preventDefault:function(){t=!1}},i=0;i<e.length;i++)e[i](n,o);return t}}}function o(e){this.elem=e}function i(e,n){return o.div().clazz("pico-overlay").clazz(e("overlayClass","")).stylize({display:"none",position:"fixed",top:"0px",left:"0px",height:"100%",width:"100%",zIndex:1e4}).stylize(e("overlayStyles",{opacity:.5,background:"#000"})).onClick(function(){e("overlayClose",!0)&&n()})}function a(e,n){var t=e("width","auto");return"number"==typeof t&&(t+="px"),o.div().clazz("pico-content").clazz(e("modalClass","")).stylize({display:"none",position:"fixed",zIndex:10001,left:"50%",top:"50px",width:t,"-ms-transform":"translateX(-50%)","-moz-transform":"translateX(-50%)","-webkit-transform":"translateX(-50%)","-o-transform":"translateX(-50%)",transform:"translateX(-50%)"}).stylize(e("modalStyles",{backgroundColor:"white",padding:"20px",borderRadius:"5px"})).html(e("content")).attr("role","dialog").onClick(function(e){new o(e.target).anyAncestor(function(e){return/\bpico-close\b/.test(e.elem.className)})&&n()})}function r(e,n){if(n("closeButton",!0))return e.child().html(n("closeHtml","&#xD7;")).clazz("pico-close").clazz(n("closeClass")).stylize(n("closeStyles",{borderRadius:"2px",cursor:"pointer",height:"15px",width:"15px",position:"absolute",top:"5px",right:"5px",fontSize:"16px",textAlign:"center",lineHeight:"15px",background:"#CCC"}))}function l(e){return function(){return e().elem}}return o.div=function(e){var n=document.createElement("div");return(e||document.body).appendChild(n),new o(n)},o.prototype={child:function(){return o.div(this.elem)},stylize:function(e){e=e||{},"undefined"!=typeof e.opacity&&(e.filter="alpha(opacity="+100*e.opacity+")");for(var n in e)e.hasOwnProperty(n)&&(this.elem.style[n]=e[n]);return this},clazz:function(e){return this.elem.className+=" "+e,this},html:function(n){return e(n)?this.elem.appendChild(n):this.elem.innerHTML=n,this},onClick:function(e){return this.elem.addEventListener("click",e),this},destroy:function(){document.body.removeChild(this.elem)},hide:function(){this.elem.style.display="none"},show:function(){this.elem.style.display="block"},attr:function(e,n){return this.elem.setAttribute(e,n),this},anyAncestor:function(e){for(var n=this.elem;n;){if(e(new o(n)))return!0;n=n.parentNode}return!1}},function(o){function s(e,n){var t=o[e];return"function"==typeof t&&(t=t(n)),t===undefined?n:t}function p(){v().hide(),w().hide(),f.trigger(P)}function c(){_.trigger(P)&&p()}function u(e){return function(){return e.apply(this,arguments),P}}function g(e){if(!h){var n=a(s,c);h={modal:n,overlay:i(s,c),close:r(n,s)},m.trigger(P)}return h[e]}(n(o)||e(o))&&(o={content:o});var h,m=t(),d=t(),b=t(),_=t(),f=t(),w=g.bind(window,"modal"),v=g.bind(window,"overlay"),E=g.bind(window,"close"),P={modalElem:l(w),closeElem:l(E),overlayElem:l(v),buildDom:u(g),show:function(){return d.trigger(P)&&(v().show(),E(),w().show(),b.trigger(P)),this},close:u(c),forceClose:u(p),destroy:function(){w=w().destroy(),v=v().destroy(),E=undefined},options:function(e){o=e},afterCreate:u(m.watch),beforeShow:u(d.watch),afterShow:u(b.watch),beforeClose:u(_.watch),afterClose:u(f.watch)};return P}}()}(this),webphone_api.swfobject=function(){function e(){if(!F){try{var e=O.getElementsByTagName("body")[0].appendChild(b("span"));e.parentNode.removeChild(e)}catch(o){return}F=!0;for(var n=k.length,t=0;t<n;t++)k[t]()}}function n(e){F?e():k[k.length]=e}function t(e){if(typeof D.addEventListener!=G)D.addEventListener("load",e,!1);else if(typeof O.addEventListener!=G)O.addEventListener("load",e,!1);else if(typeof D.attachEvent!=G)_(D,"onload",e);else if("function"==typeof D.onload){var n=D.onload;D.onload=function(){n(),e()}}else D.onload=e}function o(){A?i():a()}function i(){if(!0!==webphone_api.flashdeepdetect)return void a();var e=O.getElementsByTagName("body")[0],n=b(L);n.setAttribute("type",R);var t=e.appendChild(n);if(t){var o=0;!function(){if(typeof t.GetVariable!=G){var i=t.GetVariable("$version");i&&(i=i.split(" ")[1].split(","),B.pv=[parseInt(i[0],10),parseInt(i[1],10),parseInt(i[2],10)])}else if(o<10)return o++,void setTimeout(arguments.callee,10);e.removeChild(n),t=null,a()}()}else a()}function a(){var e=U.length;if(e>0)for(var n=0;n<e;n++){var t=U[n].id,o=U[n].callbackFn,i={success:!1,id:t};if(B.pv[0]>0){var a=d(t);if(a)if(!f(U[n].swfVersion)||B.wk&&B.wk<312)if(U[n].expressInstall&&l()){var c={};c.data=U[n].expressInstall,c.width=a.getAttribute("width")||"0",c.height=a.getAttribute("height")||"0",a.getAttribute("class")&&(c.styleclass=a.getAttribute("class")),a.getAttribute("align")&&(c.align=a.getAttribute("align"));for(var u={},g=a.getElementsByTagName("param"),h=g.length,m=0;m<h;m++)"movie"!=g[m].getAttribute("name").toLowerCase()&&(u[g[m].getAttribute("name")]=g[m].getAttribute("value"));s(c,u,t,o)}else p(a),o&&o(i);else v(t,!0),o&&(i.success=!0,i.ref=r(t),o(i))}else if(v(t,!0),o){var b=r(t);b&&typeof b.SetVariable!=G&&(i.success=!0,i.ref=b),o(i)}}}function r(e){var n=null,t=d(e);if(t&&"OBJECT"==t.nodeName)if(typeof t.SetVariable!=G)n=t;else{var o=t.getElementsByTagName(L)[0];o&&(n=o)}return n}function l(){return!M&&f("6.0.65")&&(B.win||B.mac)&&!(B.wk&&B.wk<312)}function s(e,n,t,o){M=!0,S=o||null,N={success:!1,id:t};var i=d(t);if(i){"OBJECT"==i.nodeName?(P=c(i),T=null):(P=i,T=t),e.id=y,(typeof e.width==G||!/%$/.test(e.width)&&parseInt(e.width,10)<310)&&(e.width="310"),(typeof e.height==G||!/%$/.test(e.height)&&parseInt(e.height,10)<137)&&(e.height="137"),O.title=O.title.slice(0,47)+" - Flash Player Installation";var a=B.ie&&B.win?"ActiveX":"PlugIn",r="MMredirectURL="+encodeURI(D.location).toString().replace(/&/g,"%26")+"&MMplayerType="+a+"&MMdoctitle="+O.title;if(typeof n.flashvars!=G?n.flashvars+="&"+r:n.flashvars=r,B.ie&&B.win&&4!=i.readyState){var l=b("div");t+="SWFObjectNew",l.setAttribute("id",t),i.parentNode.insertBefore(l,i),i.style.display="none",function(){4==i.readyState?i.parentNode.removeChild(i):setTimeout(arguments.callee,10)}()}u(e,n,t)}}function p(e){if(B.ie&&B.win&&4!=e.readyState){var n=b("div");e.parentNode.insertBefore(n,e),n.parentNode.replaceChild(c(e),n),e.style.display="none",function(){4==e.readyState?e.parentNode.removeChild(e):setTimeout(arguments.callee,10)}()}else e.parentNode.replaceChild(c(e),e)}function c(e){var n=b("div");if(B.win&&B.ie)n.innerHTML=e.innerHTML;else{var t=e.getElementsByTagName(L)[0];if(t){var o=t.childNodes;if(o)for(var i=o.length,a=0;a<i;a++)1==o[a].nodeType&&"PARAM"==o[a].nodeName||8==o[a].nodeType||n.appendChild(o[a].cloneNode(!0))}}return n}function u(e,n,t){var o,i=d(t);if(B.wk&&B.wk<312)return o;if(i)if(typeof e.id==G&&(e.id=t),B.ie&&B.win){var a="";for(var r in e)e[r]!=Object.prototype[r]&&("data"==r.toLowerCase()?n.movie=e[r]:"styleclass"==r.toLowerCase()?a+=' class="'+e[r]+'"':"classid"!=r.toLowerCase()&&(a+=" "+r+'="'+e[r]+'"'));var l="";for(var s in n)n[s]!=Object.prototype[s]&&(l+='<param name="'+s+'" value="'+n[s]+'" />');i.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+a+">"+l+"</object>",V[V.length]=e.id,o=d(e.id)}else{var p=b(L);p.setAttribute("type",R);for(var c in e)e[c]!=Object.prototype[c]&&("styleclass"==c.toLowerCase()?p.setAttribute("class",e[c]):"classid"!=c.toLowerCase()&&p.setAttribute(c,e[c]));for(var u in n)n[u]!=Object.prototype[u]&&"movie"!=u.toLowerCase()&&g(p,u,n[u]);i.parentNode.replaceChild(p,i),o=p}return o}function g(e,n,t){var o=b("param");o.setAttribute("name",n),o.setAttribute("value",t),e.appendChild(o)}function h(e){var n=d(e);n&&"OBJECT"==n.nodeName&&(B.ie&&B.win?(n.style.display="none",function(){4==n.readyState?m(e):setTimeout(arguments.callee,10)}()):n.parentNode.removeChild(n))}function m(e){var n=d(e);if(n){for(var t in n)"function"==typeof n[t]&&(n[t]=null);n.parentNode.removeChild(n)}}function d(e){var n=null;try{n=O.getElementById(e)}catch(t){}return n}function b(e){return O.createElement(e)}function _(e,n,t){e.attachEvent(n,t),W[W.length]=[e,n,t]}function f(e){var n=B.pv,t=e.split(".");return t[0]=parseInt(t[0],10),t[1]=parseInt(t[1],10)||0,t[2]=parseInt(t[2],10)||0,n[0]>t[0]||n[0]==t[0]&&n[1]>t[1]||n[0]==t[0]&&n[1]==t[1]&&n[2]>=t[2]}function w(e,n,t,o){if(!B.ie||!B.mac){var i=O.getElementsByTagName("head")[0];if(i){var a=t&&"string"==typeof t?t:"screen";if(o&&(I=null,C=null),!I||C!=a){var r=b("style");r.setAttribute("type","text/css"),r.setAttribute("media",a),I=i.appendChild(r),B.ie&&B.win&&typeof O.styleSheets!=G&&O.styleSheets.length>0&&(I=O.styleSheets[O.styleSheets.length-1]),C=a}B.ie&&B.win?I&&typeof I.addRule==L&&I.addRule(e,n):I&&typeof O.createTextNode!=G&&I.appendChild(O.createTextNode(e+" {"+n+"}"))}}}function v(e,n){if(H){var t=n?"visible":"hidden";F&&d(e)?d(e).style.visibility=t:w("#"+e,"visibility:"+t)}}function E(e){return null!=/[\\\"<>\.;]/.exec(e)&&typeof encodeURIComponent!=G?encodeURIComponent(e):e}var P,T,S,N,I,C,G="undefined",L="object",R="application/x-shockwave-flash",y="SWFObjectExprInst",D=window,O=document,x=navigator,A=!1,k=[o],U=[],V=[],W=[],F=!1,M=!1,H=!0,B=function(){var e=typeof O.getElementById!=G&&typeof O.getElementsByTagName!=G&&typeof O.createElement!=G,n=x.userAgent.toLowerCase(),t=x.platform.toLowerCase(),o=/win/.test(t?t:n),i=/mac/.test(t?t:n),a=!!/webkit/.test(n)&&parseFloat(n.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")),r=!1,l=[0,0,0],s=null;if(typeof x.plugins!=G&&typeof x.plugins["Shockwave Flash"]==L)!(s=x.plugins["Shockwave Flash"].description)||typeof x.mimeTypes!=G&&x.mimeTypes[R]&&!x.mimeTypes[R].enabledPlugin||(A=!0,r=!1,s=s.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),l[0]=parseInt(s.replace(/^(.*)\..*$/,"$1"),10),l[1]=parseInt(s.replace(/^.*\.(.*)\s.*$/,"$1"),10),l[2]=/[a-zA-Z]/.test(s)?parseInt(s.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof D.ActiveXObject!=G)try{var p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");p&&(s=p.GetVariable("$version"))&&(r=!0,s=s.split(" ")[1].split(","),l=[parseInt(s[0],10),parseInt(s[1],10),parseInt(s[2],10)])}catch(c){}return{w3:e,pv:l,wk:a,ie:r,win:o,mac:i}}();(function(){B.w3&&((typeof O.readyState!=G&&"complete"==O.readyState||typeof O.readyState==G&&(O.getElementsByTagName("body")[0]||O.body))&&e(),F||(typeof O.addEventListener!=G&&O.addEventListener("DOMContentLoaded",e,!1),B.ie&&B.win&&(O.attachEvent("onreadystatechange",function(){"complete"==O.readyState&&(O.detachEvent("onreadystatechange",arguments.callee),e())}),D==top&&function(){if(!F){try{O.documentElement.doScroll("left")}catch(n){return void setTimeout(arguments.callee,0)}e()}}()),B.wk&&function(){if(!F)/loaded|complete/.test(O.readyState)?e():setTimeout(arguments.callee,0)}(),t(e)))})(),function(){B.ie&&B.win&&window.attachEvent("onunload",function(){for(var e=W.length,n=0;n<e;n++)W[n][0].detachEvent(W[n][1],W[n][2]);for(var t=V.length,o=0;o<t;o++)h(V[o]);for(var i in B)B[i]=null;B=null;for(var a in webphone_api.swfobject)webphone_api.swfobject[a]=null;webphone_api.swfobject=null})}();return{registerObject:function(e,n,t,o){if(B.w3&&e&&n){var i={};i.id=e,i.swfVersion=n,i.expressInstall=t,i.callbackFn=o,U[U.length]=i,v(e,!1)}else o&&o({success:!1,id:e})},getObjectById:function(e){if(B.w3)return r(e)},embedSWF:function(e,t,o,i,a,r,p,c,g,h){var m={success:!1,id:t};B.w3&&!(B.wk&&B.wk<312)&&e&&t&&o&&i&&a?(v(t,!1),n(function(){o+="",i+="";var n={};if(g&&typeof g===L)for(var d in g)n[d]=g[d];n.data=e,n.width=o,n.height=i;var b={};if(c&&typeof c===L)for(var _ in c)b[_]=c[_];if(p&&typeof p===L)for(var w in p)typeof b.flashvars!=G?b.flashvars+="&"+w+"="+p[w]:b.flashvars=w+"="+p[w];if(f(a)){var E=u(n,b,t);n.id==t&&v(t,!0),m.success=!0,m.ref=E}else{if(r&&l())return n.data=r,void s(n,b,t,h);v(t,!0)}h&&h(m)})):h&&h(m)},switchOffAutoHideShow:function(){H=!1},ua:B,getFlashPlayerVersion:function(){return{major:B.pv[0],minor:B.pv[1],release:B.pv[2]}},hasFlashPlayerVersion:f,createSWF:function(e,n,t){return B.w3?u(e,n,t):undefined},showExpressInstall:function(e,n,t,o){B.w3&&l()&&s(e,n,t,o)},removeSWF:function(e){B.w3&&h(e)},createCSS:function(e,n,t,o){B.w3&&w(e,n,t,o)},addDomLoadEvent:n,addLoadEvent:t,getQueryParamValue:function(e){var n=O.location.search||O.location.hash;if(n){if(/\?/.test(n)&&(n=n.split("?")[1]),null==e)return E(n);for(var t=n.split("&"),o=0;o<t.length;o++)if(t[o].substring(0,t[o].indexOf("="))==e)return E(t[o].substring(t[o].indexOf("=")+1))}return""},expressInstallCallback:function(){if(M){var e=d(y);e&&P&&(e.parentNode.replaceChild(P,e),T&&(v(T,!0),B.ie&&B.win&&(P.style.display="block")),S&&S(N)),M=!1}}}}(),webphone_api.mwphonecfg=function(){function e(e){return void 0===e||null===e?"":(e=e.toLowerCase(),"undefined"==typeof t[e]||null===t[e]?"":t[e])}function n(){return t}var t={passphrase:"dcid_MApRKAlQVyUWcEtAUzVcXQ--",loglevel:"5",autotransportdetect:!1,cfgusetunneling:0,useencryption:!1,upperserverfromuser:2,featureset:"10",needactivation:!1,brandid:-1,video:1,enable_video:!0,has_video:!0,enablepresence2:1,enablepresence:1,hasfiletransfer:!0,screensharing:1,hasconference:!0,useg729:2,useopuswb:2,customizedversion:!1,autoprovisioning:1,colortheme:-1,actionbarhideicon:!1,usemizuwebrtcgateway:-1,deploydate:"12/10/2024 11:18:27",homepage:"dcid_H0RORwkLHARaQV5YRkkLBwU-",server_comment:"dcid_PlxwOUQRAwMBUkMRVwMMGg1ASklMBgkcFl5fEVkVSCE4CUkGFhZP",companynameex:"dcid_JVpDHDAHBRk-",confighash:"dcid_XgIAWVFUUxNAVgVSVVNYUQsECQxcUQAXEQBSUg9QW1E-",apibehaviour:1,firstdeploydate:"dcid_WQEWWFRNVEFFAxEAB11ZUFIBDg--",lastdeploydate:"12/10/2024 11:18:27",BUILDNUMBER:"5483",pgw1_address:"dcid_GkdaRwkLHARaQV5YRkkLBwU-",pgw1_delay:0,pgw1_apikey:"dcid_WQYPUVVSXkJDAg--",pgw1_salt:"dcid_XgYMXFZbVERH",pgw1_sipport:5060,pgw1_stunport:8090,pgw1_turnport:80,pgw1_rtmpport:1939,pgw1_try:!0,pgw2_address:"dcid_HUBLHQdMERQVQV5YRhcABwZWFwoLDw--",pgw2_delay:20,pgw2_apikey:"dcid_WQYPUVVSXkJDAg--",pgw2_salt:"dcid_XgYMXFZbVERH",pgw2_sipport:10096,pgw2_stunport:8090,pgw2_turnport:80,pgw2_rtmpport:1939,pgw2_try:!0,pc_alternatebrowserurl:"dcid_AEdNGRdYSV4AQEYfWwgSAQRfWEcLEAFeEV5DVFAIEEcGVk5G",android_aletrnatebrowserurl:"dcid_AEdNGRdYSV4HW1BIGAAHBw9fXEcHDQteBENeQ1NICRgYQBYNARYHGBtEDlhSWgsHBR1YBwAQCRgTGVJZRAgFDQ--",android_nativedialerurl:"dcid_AEdNGRdYSV4HW1BIGAAHBw9fXEcHDQteBENeQ1NICRgYQBYNARYHGBtEDlhSWgsHBR1UAB4XEB4eRx9cXx0dDBpcUA1KAxYB",ios_nativedialerurl:"dcid_AEdNGRdYSV4eQ0RfUxRGCRhDVQxKAQkcWEJCHlcXGEcFWkMcFAoJHxIYWFUCX1teUAYMXlc-",mclientid:"5795"};return{get:e,getAll:n}}(),function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.webphone_api.localforage=e()}}(function(){return function e(n,t,o){function i(r,l){if(!t[r]){if(!n[r]){var s="function"==typeof require&&require;if(!l&&s)return s(r,!0);if(a)return a(r,!0);var p=new Error("Cannot find module '"+r+"'");throw p.code="MODULE_NOT_FOUND",p}var c=t[r]={exports:{}};n[r][0].call(c.exports,function(e){var t=n[r][1][e];return i(t||e)},c,c.exports,e,n,t,o)}return t[r].exports}for(var a="function"==typeof require&&require,r=0;r<o.length;r++)i(o[r]);return i}({1:[function(e,n,t){(function(e){"use strict";function t(){c=!0;for(var e,n,t=u.length;t;){for(n=u,u=[],e=-1;++e<t;)n[e]();t=u.length}c=!1}function o(e){1!==u.push(e)||c||i()}var i,a=e.MutationObserver||e.WebKitMutationObserver;if(a){var r=0,l=new a(t),s=e.document.createTextNode("");l.observe(s,{characterData:!0}),i=function(){s.data=r=++r%2}}else if(e.setImmediate||"undefined"==typeof e.MessageChannel)i="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var n=e.document.createElement("script");n.onreadystatechange=function(){t(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},e.document.documentElement.appendChild(n)}:function(){setTimeout(t,0)};else{var p=new e.MessageChannel;p.port1.onmessage=t,i=function(){p.port2.postMessage(0)}}var c,u=[];n.exports=o}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,n,t){"use strict";function o(){}function i(e){
if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=f,this.queue=[],this.outcome=void 0,e!==o&&s(this,e)}function a(e,n,t){this.promise=e,"function"==typeof n&&(this.onFulfilled=n,this.callFulfilled=this.otherCallFulfilled),"function"==typeof t&&(this.onRejected=t,this.callRejected=this.otherCallRejected)}function r(e,n,t){m(function(){var o;try{o=n(t)}catch(i){return d.reject(e,i)}o===e?d.reject(e,new TypeError("Cannot resolve promise with itself")):d.resolve(e,o)})}function l(e){var n=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof n)return function(){n.apply(e,arguments)}}function s(e,n){function t(n){a||(a=!0,d.reject(e,n))}function o(n){a||(a=!0,d.resolve(e,n))}function i(){n(o,t)}var a=!1,r=p(i);"error"===r.status&&t(r.value)}function p(e,n){var t={};try{t.value=e(n),t.status="success"}catch(o){t.status="error",t.value=o}return t}function c(e){return e instanceof this?e:d.resolve(new this(o),e)}function u(e){var n=new this(o);return d.reject(n,e)}function g(e){var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var t=e.length,i=!1;if(!t)return this.resolve([]);for(var a=new Array(t),r=0,l=-1,s=new this(o);++l<t;)!function(e,o){function l(e){a[o]=e,++r!==t||i||(i=!0,d.resolve(s,a))}n.resolve(e).then(l,function(e){i||(i=!0,d.reject(s,e))})}(e[l],l);return s}function h(e){var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var t=e.length,i=!1;if(!t)return this.resolve([]);for(var a=-1,r=new this(o);++a<t;)!function(e){n.resolve(e).then(function(e){i||(i=!0,d.resolve(r,e))},function(e){i||(i=!0,d.reject(r,e))})}(e[a]);return r}var m=e(1),d={},b=["REJECTED"],_=["FULFILLED"],f=["PENDING"];n.exports=i,i.prototype["catch"]=function(e){return this.then(null,e)},i.prototype.then=function(e,n){if("function"!=typeof e&&this.state===_||"function"!=typeof n&&this.state===b)return this;var t=new this.constructor(o);if(this.state!==f){r(t,this.state===_?e:n,this.outcome)}else this.queue.push(new a(t,e,n));return t},a.prototype.callFulfilled=function(e){d.resolve(this.promise,e)},a.prototype.otherCallFulfilled=function(e){r(this.promise,this.onFulfilled,e)},a.prototype.callRejected=function(e){d.reject(this.promise,e)},a.prototype.otherCallRejected=function(e){r(this.promise,this.onRejected,e)},d.resolve=function(e,n){var t=p(l,n);if("error"===t.status)return d.reject(e,t.value);var o=t.value;if(o)s(e,o);else{e.state=_,e.outcome=n;for(var i=-1,a=e.queue.length;++i<a;)e.queue[i].callFulfilled(n)}return e},d.reject=function(e,n){e.state=b,e.outcome=n;for(var t=-1,o=e.queue.length;++t<o;)e.queue[t].callRejected(n);return e},i.resolve=c,i.reject=u,i.all=g,i.race=h},{1:1}],3:[function(e,n,t){(function(n){"use strict";"function"!=typeof n.Promise&&(n.Promise=e(2))}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{2:2}],4:[function(e,n,t){"use strict";function o(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function i(e,n){e=e||[],n=n||{};try{return new Blob(e,n)}catch(a){if("TypeError"!==a.name)throw a;for(var t="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder,o=new t,i=0;i<e.length;i+=1)o.append(e[i]);return o.getBlob(n.type)}}function a(e,n){n&&e.then(function(e){n(null,e)},function(e){n(e)})}function r(e,n,t){"function"==typeof n&&e.then(n),"function"==typeof t&&e["catch"](t)}function l(e){return"string"!=typeof e&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function s(){if(arguments.length&&"function"==typeof arguments[arguments.length-1])return arguments[arguments.length-1]}function p(e){for(var n=e.length,t=new ArrayBuffer(n),o=new Uint8Array(t),i=0;i<n;i++)o[i]=e.charCodeAt(i);return t}function c(e){return new _e(function(n){var t=e.transaction(fe,Te),o=i([""]);t.objectStore(fe).put(o,"key"),t.onabort=function(e){e.preventDefault(),e.stopPropagation(),n(!1)},t.oncomplete=function(){var e=navigator.userAgent.match(/Chrome\/(\d+)/),t=navigator.userAgent.match(/Edge\//);n(t||!e||parseInt(e[1],10)>=43)}})["catch"](function(){return!1})}function u(e){return"boolean"==typeof we?_e.resolve(we):c(e).then(function(e){return we=e})}function g(e){var n=ve[e.name],t={};t.promise=new _e(function(e,n){t.resolve=e,t.reject=n}),n.deferredOperations.push(t),n.dbReady?n.dbReady=n.dbReady.then(function(){return t.promise}):n.dbReady=t.promise}function h(e){var n=ve[e.name],t=n.deferredOperations.pop();if(t)return t.resolve(),t.promise}function m(e,n){var t=ve[e.name],o=t.deferredOperations.pop();if(o)return o.reject(n),o.promise}function d(e,n){return new _e(function(t,o){if(ve[e.name]=ve[e.name]||N(),e.db){if(!n)return t(e.db);g(e),e.db.close()}var i=[e.name];n&&i.push(e.version);var a=be.open.apply(be,i);n&&(a.onupgradeneeded=function(n){var t=a.result;try{t.createObjectStore(e.storeName),n.oldVersion<=1&&t.createObjectStore(fe)}catch(o){if("ConstraintError"!==o.name)throw o;console.warn('The database "'+e.name+'" has been upgraded from version '+n.oldVersion+" to version "+n.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),o(a.error)},a.onsuccess=function(){var n=a.result;n.onversionchange=function(e){e.target.close()},t(n),h(e)}})}function b(e){return d(e,!1)}function _(e){return d(e,!0)}function f(e,n){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,i=e.version>e.db.version;if(o&&(e.version!==n&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||t){if(t){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function w(e){return new _e(function(n,t){var o=new FileReader;o.onerror=t,o.onloadend=function(t){var o=btoa(t.target.result||"");n({__local_forage_encoded_blob:!0,data:o,type:e.type})},o.readAsBinaryString(e)})}function v(e){return i([p(atob(e.data))],{type:e.type})}function E(e){return e&&e.__local_forage_encoded_blob}function P(e){var n=this,t=n._initReady().then(function(){var e=ve[n._dbInfo.name];if(e&&e.dbReady)return e.dbReady});return r(t,e,e),t}function T(e){g(e);for(var n=ve[e.name],t=n.forages,o=0;o<t.length;o++){var i=t[o];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,b(e).then(function(n){return e.db=n,f(e)?_(e):n}).then(function(o){e.db=n.db=o;for(var i=0;i<t.length;i++)t[i]._dbInfo.db=o})["catch"](function(n){throw m(e,n),n})}function S(e,n,t,o){o===undefined&&(o=1);try{var i=e.db.transaction(e.storeName,n);t(null,i)}catch(a){if(o>0&&(!e.db||"InvalidStateError"===a.name||"NotFoundError"===a.name))return _e.resolve().then(function(){if(!e.db||"NotFoundError"===a.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),_(e)}).then(function(){return T(e).then(function(){S(e,n,t,o-1)})})["catch"](t);t(a)}}function N(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function I(e){function n(){return _e.resolve()}var t=this,o={db:null};if(e)for(var i in e)o[i]=e[i];var a=ve[o.name];a||(a=N(),ve[o.name]=a),a.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=P);for(var r=[],l=0;l<a.forages.length;l++){var s=a.forages[l];s!==t&&r.push(s._initReady()["catch"](n))}var p=a.forages.slice(0);return _e.all(r).then(function(){return o.db=a.db,b(o)}).then(function(e){return o.db=e,f(o,t._defaultConfig.version)?_(o):e}).then(function(e){o.db=a.db=e,t._dbInfo=o;for(var n=0;n<p.length;n++){var i=p[n];i!==t&&(i._dbInfo.db=o.db,i._dbInfo.version=o.version)}})}function C(e,n){var t=null;try{var o=this;e=l(e),t=new _e(function(n,t){o.ready().then(function(){S(o._dbInfo,Pe,function(i,a){if(i)return t(i);try{var r=a.objectStore(o._dbInfo.storeName),l=r.get(e);l.onsuccess=function(){var e=l.result;e===undefined&&(e=null),E(e)&&(e=v(e)),n(e)},l.onerror=function(){t(l.error)}}catch(s){t(s)}})})["catch"](t)})}catch(i){}return a(t,n),t}function G(e,n){var t=this,o=new _e(function(n,o){t.ready().then(function(){S(t._dbInfo,Pe,function(i,a){if(i)return o(i);try{var r=a.objectStore(t._dbInfo.storeName),l=r.openCursor(),s=1;l.onsuccess=function(){var t=l.result;if(t){var o=t.value;E(o)&&(o=v(o));var i=e(o,t.key,s++);void 0!==i?n(i):t["continue"]()}else n()},l.onerror=function(){o(l.error)}}catch(p){o(p)}})})["catch"](o)});return a(o,n),o}function L(e,n,t){var o=this;e=l(e);var i=new _e(function(t,i){var a;o.ready().then(function(){return a=o._dbInfo,"[object Blob]"===Ee.call(n)?u(a.db).then(function(e){return e?n:w(n)}):n}).then(function(n){S(o._dbInfo,Te,function(a,r){if(a)return i(a);try{var l=r.objectStore(o._dbInfo.storeName);null===n&&(n=undefined);var s=l.put(n,e);r.oncomplete=function(){n===undefined&&(n=null),t(n)},r.onabort=r.onerror=function(){var e=s.error?s.error:s.transaction.error;i(e)}}catch(p){i(p)}})})["catch"](i)});return a(i,t),i}function R(e,n){var t=this;e=l(e);var o=new _e(function(n,o){t.ready().then(function(){S(t._dbInfo,Te,function(i,a){if(i)return o(i);try{var r=a.objectStore(t._dbInfo.storeName),l=r["delete"](e);a.oncomplete=function(){n()},a.onerror=function(){o(l.error)},a.onabort=function(){var e=l.error?l.error:l.transaction.error;o(e)}}catch(s){o(s)}})})["catch"](o)});return a(o,n),o}function y(e){var n=this,t=new _e(function(e,t){n.ready().then(function(){S(n._dbInfo,Te,function(o,i){if(o)return t(o);try{var a=i.objectStore(n._dbInfo.storeName),r=a.clear();i.oncomplete=function(){e()},i.onabort=i.onerror=function(){var e=r.error?r.error:r.transaction.error;t(e)}}catch(l){t(l)}})})["catch"](t)});return a(t,e),t}function D(e){var n=this,t=new _e(function(e,t){n.ready().then(function(){S(n._dbInfo,Pe,function(o,i){if(o)return t(o);try{var a=i.objectStore(n._dbInfo.storeName),r=a.count();r.onsuccess=function(){e(r.result)},r.onerror=function(){t(r.error)}}catch(l){t(l)}})})["catch"](t)});return a(t,e),t}function O(e,n){var t=this,o=new _e(function(n,o){if(e<0)return void n(null);t.ready().then(function(){S(t._dbInfo,Pe,function(i,a){if(i)return o(i);try{var r=a.objectStore(t._dbInfo.storeName),l=!1,s=r.openKeyCursor();s.onsuccess=function(){var t=s.result;if(!t)return void n(null);0===e?n(t.key):l?n(t.key):(l=!0,t.advance(e))},s.onerror=function(){o(s.error)}}catch(p){o(p)}})})["catch"](o)});return a(o,n),o}function x(e){var n=this,t=new _e(function(e,t){n.ready().then(function(){S(n._dbInfo,Pe,function(o,i){if(o)return t(o);try{var a=i.objectStore(n._dbInfo.storeName),r=a.openKeyCursor(),l=[];r.onsuccess=function(){var n=r.result;if(!n)return void e(l);l.push(n.key),n["continue"]()},r.onerror=function(){t(r.error)}}catch(s){t(s)}})})["catch"](t)});return a(t,e),t}function A(e,n){n=s.apply(this,arguments);var t=this.config();e="function"!=typeof e&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o,i=this;if(e.name){var r=e.name===t.name&&i._dbInfo.db,l=r?_e.resolve(i._dbInfo.db):b(e).then(function(n){var t=ve[e.name],o=t.forages;t.db=n;for(var i=0;i<o.length;i++)o[i]._dbInfo.db=n;return n});o=e.storeName?l.then(function(n){if(n.objectStoreNames.contains(e.storeName)){var t=n.version+1;g(e);var o=ve[e.name],i=o.forages;n.close();for(var a=0;a<i.length;a++){var r=i[a];r._dbInfo.db=null,r._dbInfo.version=t}return new _e(function(n,o){var i=be.open(e.name,t);i.onerror=function(e){i.result.close(),o(e)},i.onupgradeneeded=function(){i.result.deleteObjectStore(e.storeName)},i.onsuccess=function(){var e=i.result;e.close(),n(e)}}).then(function(e){o.db=e;for(var n=0;n<i.length;n++){var t=i[n];t._dbInfo.db=e,h(t._dbInfo)}})["catch"](function(n){throw(m(e,n)||_e.resolve())["catch"](function(){}),n})}}):l.then(function(n){g(e);var t=ve[e.name],o=t.forages;n.close();for(var i=0;i<o.length;i++){o[i]._dbInfo.db=null}return new _e(function(n,t){var o=be.deleteDatabase(e.name);o.onerror=function(){var e=o.result;e&&e.close(),t(o.error)},o.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},o.onsuccess=function(){var e=o.result;e&&e.close(),n(e)}}).then(function(e){t.db=e;for(var n=0;n<o.length;n++)h(o[n]._dbInfo)})["catch"](function(n){throw(m(e,n)||_e.resolve())["catch"](function(){}),n})})}else o=_e.reject("Invalid arguments");return a(o,n),o}function k(e){var n,t,o,i,a,r=.75*e.length,l=e.length,s=0;"="===e[e.length-1]&&(r--,"="===e[e.length-2]&&r--);var p=new ArrayBuffer(r),c=new Uint8Array(p);for(n=0;n<l;n+=4)t=Ne.indexOf(e[n]),o=Ne.indexOf(e[n+1]),i=Ne.indexOf(e[n+2]),a=Ne.indexOf(e[n+3]),c[s++]=t<<2|o>>4,c[s++]=(15&o)<<4|i>>2,c[s++]=(3&i)<<6|63&a;return p}function U(e){var n,t=new Uint8Array(e),o="";for(n=0;n<t.length;n+=3)o+=Ne[t[n]>>2],o+=Ne[(3&t[n])<<4|t[n+1]>>4],o+=Ne[(15&t[n+1])<<2|t[n+2]>>6],o+=Ne[63&t[n+2]];return t.length%3==2?o=o.substring(0,o.length-1)+"=":t.length%3==1&&(o=o.substring(0,o.length-2)+"=="),o}function V(e,n){var t="";if(e&&(t=He.call(e)),e&&("[object ArrayBuffer]"===t||e.buffer&&"[object ArrayBuffer]"===He.call(e.buffer))){var o,i=Ge;e instanceof ArrayBuffer?(o=e,i+=Re):(o=e.buffer,"[object Int8Array]"===t?i+=De:"[object Uint8Array]"===t?i+=Oe:"[object Uint8ClampedArray]"===t?i+=xe:"[object Int16Array]"===t?i+=Ae:"[object Uint16Array]"===t?i+=Ue:"[object Int32Array]"===t?i+=ke:"[object Uint32Array]"===t?i+=Ve:"[object Float32Array]"===t?i+=We:"[object Float64Array]"===t?i+=Fe:n(new Error("Failed to get type for BinaryArray"))),n(i+U(o))}else if("[object Blob]"===t){var a=new FileReader;a.onload=function(){var t=Ie+e.type+"~"+U(this.result);n(Ge+ye+t)},a.readAsArrayBuffer(e)}else try{n(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),n(null,r)}}function W(e){if(e.substring(0,Le)!==Ge)return JSON.parse(e);var n,t=e.substring(Me),o=e.substring(Le,Me);if(o===ye&&Ce.test(t)){var a=t.match(Ce);n=a[1],t=t.substring(a[0].length)}var r=k(t);switch(o){case Re:return r;case ye:return i([r],{type:n});case De:return new Int8Array(r);case Oe:return new Uint8Array(r);case xe:return new Uint8ClampedArray(r);case Ae:return new Int16Array(r);case Ue:return new Uint16Array(r);case ke:return new Int32Array(r);case Ve:return new Uint32Array(r);case We:return new Float32Array(r);case Fe:return new Float64Array(r);default:throw new Error("Unkown type: "+o)}}function F(e,n,t,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+n.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,o)}function M(e){var n=this,t={db:null};if(e)for(var o in e)t[o]="string"!=typeof e[o]?e[o].toString():e[o];var i=new _e(function(e,o){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(i){return o(i)}t.db.transaction(function(i){F(i,t,function(){n._dbInfo=t,e()},function(e,n){o(n)})},o)});return t.serializer=Be,i}function H(e,n,t,o,i,a){e.executeSql(t,o,i,function(e,r){r.code===r.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[n.storeName],function(e,l){l.rows.length?a(e,r):F(e,n,function(){e.executeSql(t,o,i,a)},a)},a):a(e,r)},a)}function B(e,n){var t=this;e=l(e);var o=new _e(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(t){H(t,i,"SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[e],function(e,t){var o=t.rows.length?t.rows.item(0).value:null;o&&(o=i.serializer.deserialize(o)),n(o)},function(e,n){o(n)})})})["catch"](o)});return a(o,n),o}function j(e,n){var t=this,o=new _e(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(t){H(t,i,"SELECT * FROM "+i.storeName,[],function(t,o){for(var a=o.rows,r=a.length,l=0;l<r;l++){var s=a.item(l),p=s.value;if(p&&(p=i.serializer.deserialize(p)),void 0!==(p=e(p,s.key,l+1)))return void n(p)}n()},function(e,n){o(n)})})})["catch"](o)});return a(o,n),o}function $(e,n,t,o){var i=this;e=l(e);var r=new _e(function(a,r){i.ready().then(function(){n===undefined&&(n=null);var l=n,s=i._dbInfo;s.serializer.serialize(n,function(n,p){p?r(p):s.db.transaction(function(t){H(t,s,"INSERT OR REPLACE INTO "+s.storeName+" (key, value) VALUES (?, ?)",[e,n],function(){a(l)},function(e,n){r(n)})},function(n){if(n.code===n.QUOTA_ERR){if(o>0)return void a($.apply(i,[e,l,t,o-1]));r(n)}})})})["catch"](r)});return a(r,t),r}function q(e,n,t){return $.apply(this,[e,n,t,1])}function z(e,n){var t=this;e=l(e);var o=new _e(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(t){H(t,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],function(){n()},function(e,n){o(n)})})})["catch"](o)});return a(o,n),o}function K(e){var n=this,t=new _e(function(e,t){n.ready().then(function(){var o=n._dbInfo;o.db.transaction(function(n){H(n,o,"DELETE FROM "+o.storeName,[],function(){e()},function(e,n){t(n)})})})["catch"](t)});return a(t,e),t}function X(e){var n=this,t=new _e(function(e,t){n.ready().then(function(){var o=n._dbInfo;o.db.transaction(function(n){H(n,o,"SELECT COUNT(key) as c FROM "+o.storeName,[],function(n,t){var o=t.rows.item(0).c;e(o)},function(e,n){t(n)})})})["catch"](t)});return a(t,e),t}function J(e,n){var t=this,o=new _e(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(t){H(t,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,t){var o=t.rows.length?t.rows.item(0).key:null;n(o)},function(e,n){o(n)})})})["catch"](o)});return a(o,n),o}function Y(e){var n=this,t=new _e(function(e,t){n.ready().then(function(){var o=n._dbInfo;o.db.transaction(function(n){H(n,o,"SELECT key FROM "+o.storeName,[],function(n,t){for(var o=[],i=0;i<t.rows.length;i++)o.push(t.rows.item(i).key);e(o)},function(e,n){t(n)})})})["catch"](t)});return a(t,e),t}function Q(e){return new _e(function(n,t){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(t,o){for(var i=[],a=0;a<o.rows.length;a++)i.push(o.rows.item(a).name);n({db:e,storeNames:i})},function(e,n){t(n)})},function(e){t(e)})})}function Z(e,n){n=s.apply(this,arguments);var t=this.config();e="function"!=typeof e&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o,i=this;return o=e.name?new _e(function(n){var o;o=e.name===t.name?i._dbInfo.db:openDatabase(e.name,"","",0),n(e.storeName?{db:o,storeNames:[e.storeName]}:Q(o))}).then(function(e){return new _e(function(n,t){e.db.transaction(function(o){for(var i=[],a=0,r=e.storeNames.length;a<r;a++)i.push(function(e){return new _e(function(n,t){o.executeSql("DROP TABLE IF EXISTS "+e,[],function(){n()},function(e,n){t(n)})})}(e.storeNames[a]));_e.all(i).then(function(){n()})["catch"](function(e){t(e)})},function(e){t(e)})})}):_e.reject("Invalid arguments"),a(o,n),o}function ee(e,n){var t=e.name+"/";return e.storeName!==n.storeName&&(t+=e.storeName+"/"),t}function ne(){try{return localStorage.setItem("_localforage_support_test",!0),localStorage.removeItem("_localforage_support_test"),!1}catch(e){return!0}}function te(){return!ne()||localStorage.length>0}function oe(e){var n=this,t={};if(e)for(var o in e)t[o]=e[o];return t.keyPrefix=ee(e,n._defaultConfig),te()?(n._dbInfo=t,t.serializer=Be,_e.resolve()):_e.reject()}function ie(e){var n=this,t=n.ready().then(function(){for(var e=n._dbInfo.keyPrefix,t=localStorage.length-1;t>=0;t--){var o=localStorage.key(t);0===o.indexOf(e)&&localStorage.removeItem(o)}});return a(t,e),t}function ae(e,n){var t=this;e=l(e);var o=t.ready().then(function(){var n=t._dbInfo,o=localStorage.getItem(n.keyPrefix+e);return o&&(o=n.serializer.deserialize(o)),o});return a(o,n),o}function re(e,n){var t=this,o=t.ready().then(function(){for(var n=t._dbInfo,o=n.keyPrefix,i=o.length,a=localStorage.length,r=1,l=0;l<a;l++){var s=localStorage.key(l);if(0===s.indexOf(o)){var p=localStorage.getItem(s);if(p&&(p=n.serializer.deserialize(p)),void 0!==(p=e(p,s.substring(i),r++)))return p}}});return a(o,n),o}function le(e,n){var t=this,o=t.ready().then(function(){var n,o=t._dbInfo;try{n=localStorage.key(e)}catch(i){n=null}return n&&(n=n.substring(o.keyPrefix.length)),n});return a(o,n),o}function se(e){var n=this,t=n.ready().then(function(){for(var e=n._dbInfo,t=localStorage.length,o=[],i=0;i<t;i++){var a=localStorage.key(i);0===a.indexOf(e.keyPrefix)&&o.push(a.substring(e.keyPrefix.length))}return o});return a(t,e),t}function pe(e){var n=this,t=n.keys().then(function(e){return e.length});return a(t,e),t}function ce(e,n){var t=this;e=l(e);var o=t.ready().then(function(){var n=t._dbInfo;localStorage.removeItem(n.keyPrefix+e)});return a(o,n),o}function ue(e,n,t){var o=this;e=l(e);var i=o.ready().then(function(){n===undefined&&(n=null);var t=n;return new _e(function(i,a){var r=o._dbInfo;r.serializer.serialize(n,function(n,o){if(o)a(o);else try{localStorage.setItem(r.keyPrefix+e,n),i(t)}catch(l){"QuotaExceededError"!==l.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==l.name||a(l),a(l)}})})});return a(i,t),i}function ge(e,n){if(n=s.apply(this,arguments),e="function"!=typeof e&&e||{},!e.name){var t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}var o,i=this;return o=e.name?new _e(function(n){n(e.storeName?ee(e,i._defaultConfig):e.name+"/")}).then(function(e){for(var n=localStorage.length-1;n>=0;n--){var t=localStorage.key(n);0===t.indexOf(e)&&localStorage.removeItem(t)}}):_e.reject("Invalid arguments"),a(o,n),o}function he(e,n){e[n]=function(){var t=arguments;return arguments.length&&"function"==typeof arguments[arguments.length-1]&&(webphone_api.global.localforage_last_cb=arguments[arguments.length-1]),e.ready().then(function(){return e[n].apply(e,t)})}}function me(){for(var e=1;e<arguments.length;e++){var n=arguments[e];if(n)for(var t in n)n.hasOwnProperty(t)&&(Ke(n[t])?arguments[0][t]=n[t].slice():arguments[0][t]=n[t])}return arguments[0]}var de="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},be=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();"undefined"==typeof Promise&&e(3);var _e=Promise,fe="local-forage-detect-blob-support",we=void 0,ve={},Ee=Object.prototype.toString,Pe="readonly",Te="readwrite",Se={_driver:"asyncStorage",_initStorage:I,_support:function(){try{if(!be||!be.open)return!1;var e="undefined"!=typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),n="function"==typeof fetch&&-1!==fetch.toString().indexOf("[native code");return(!e||n)&&"undefined"!=typeof indexedDB&&"undefined"!=typeof IDBKeyRange}catch(t){return!1}}(),iterate:G,getItem:C,setItem:L,removeItem:R,clear:y,length:D,key:O,keys:x,dropInstance:A},Ne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ie="~~local_forage_type~",Ce=/^~~local_forage_type~([^~]+)~/,Ge="__lfsc__:",Le=Ge.length,Re="arbf",ye="blob",De="si08",Oe="ui08",xe="uic8",Ae="si16",ke="si32",Ue="ur16",Ve="ui32",We="fl32",Fe="fl64",Me=Le+Re.length,He=Object.prototype.toString,Be={serialize:V,deserialize:W,stringToBuffer:k,bufferToString:U},je={_driver:"webSQLStorage",_initStorage:M,_support:function(){return"function"==typeof openDatabase}(),iterate:j,getItem:B,setItem:q,removeItem:z,clear:K,length:X,key:J,keys:Y,dropInstance:Z},$e={_driver:"localStorageWrapper",_initStorage:oe,_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:re,getItem:ae,setItem:ue,removeItem:ce,clear:ie,length:pe,key:le,keys:se,dropInstance:ge},qe=function(e,n){return e===n||"number"==typeof e&&"number"==typeof n&&isNaN(e)&&isNaN(n)},ze=function(e,n){for(var t=e.length,o=0;o<t;){if(qe(e[o],n))return!0;o++}return!1},Ke=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Xe={},Je={},Ye={INDEXEDDB:Se,WEBSQL:je,LOCALSTORAGE:$e},Qe=[Ye.INDEXEDDB._driver,Ye.WEBSQL._driver,Ye.LOCALSTORAGE._driver],Ze=["dropInstance"],en=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Ze),nn={description:"",driver:Qe.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1},tn=function(){function e(n){o(this,e);for(var t in Ye)if(Ye.hasOwnProperty(t)){var i=Ye[t],a=i._driver;this[t]=a,Xe[a]||this.defineDriver(i)}this._defaultConfig=me({},nn),this._config=me({},this._defaultConfig,n),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver)["catch"](function(){})}return e.prototype.config=function(e){if("object"===(void 0===e?"undefined":de(e))){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var n in e){if("storeName"===n&&(e[n]=e[n].replace(/\W/g,"_")),"version"===n&&"number"!=typeof e[n])return new Error("Database version must be a number.");this._config[n]=e[n]}return!("driver"in e&&e.driver)||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config},e.prototype.defineDriver=function(e,n,t){var o=new _e(function(n,t){try{var o=e._driver,i=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void t(i);for(var r=en.concat("_initStorage"),l=0,s=r.length;l<s;l++){var p=r[l];if((!ze(Ze,p)||e[p])&&"function"!=typeof e[p])return void t(i)}!function(){for(var n=0,t=Ze.length;n<t;n++){var o=Ze[n];e[o]||(e[o]=function(e){return function(){var n=new Error("Method "+e+" is not implemented by the current driver"),t=_e.reject(n);return a(t,arguments[arguments.length-1]),t}}(o))}}();var c=function(t){Xe[o]&&console.info("Redefining LocalForage driver: "+o),Xe[o]=e,Je[o]=t,n()};"_support"in e?e._support&&"function"==typeof e._support?e._support().then(c,t):c(!!e._support):c(!0)}catch(u){t(u)}});return r(o,n,t),o},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(e,n,t){var o=Xe[e]?_e.resolve(Xe[e]):_e.reject(new Error("Driver not found."));return r(o,n,t),o},e.prototype.getSerializer=function(e){var n=_e.resolve(Be);return r(n,e),n},e.prototype.ready=function(e){var n=this,t=n._driverSet.then(function(){return null===n._ready&&(n._ready=n._initDriver()),n._ready});return r(t,e,e),t},e.prototype.setDriver=function(e,n,t){function o(){l._config.driver=l.driver()}function i(e){return l._extend(e),o(),l._ready=l._initStorage(l._config),l._ready}function a(e){return function(){function n(){for(;t<e.length;){var a=e[t];return t++,l._dbInfo=null,l._ready=null,l.getDriver(a).then(i)["catch"](n)}o();var r=new Error("No available storage method found.");return null!==webphone_api.global.localforage_last_cb&&"function"==typeof webphone_api.global.localforage_last_cb&&webphone_api.global.localforage_last_cb("ERROR, driverPromiseLoop:No available storage method found.",""),l._driverSet=_e.reject(r),l._driverSet}var t=0;return n()}}var l=this;Ke(e)||(e=[e]);var s=this._getSupportedDrivers(e),p=null!==this._driverSet?this._driverSet["catch"](function(){return _e.resolve()}):_e.resolve();return this._driverSet=p.then(function(){var e=s[0];return l._dbInfo=null,l._ready=null,l.getDriver(e).then(function(e){l._driver=e._driver,o(),l._wrapLibraryMethodsWithReady(),l._initDriver=a(s)})})["catch"](function(){o();var e=new Error("No available storage method found.");return l._driverSet=_e.reject(e),l._driverSet}),r(this._driverSet,n,t),this._driverSet},e.prototype.supports=function(e){return!!Je[e]},e.prototype._extend=function(e){me(this,e)},e.prototype._getSupportedDrivers=function(e){for(var n=[],t=0,o=e.length;t<o;t++){var i=e[t];this.supports(i)&&n.push(i)}return n},e.prototype._wrapLibraryMethodsWithReady=function(){for(var e=0,n=en.length;e<n;e++)he(this,en[e])},e.prototype.createInstance=function(n){return new e(n)},e}(),on=new tn;n.exports=on},{3:3}]},{},[4])(4)}),function(e,n){function t(e){var n=e.length,t=se.type(e);return!se.isWindow(e)&&(!(1!==e.nodeType||!n)||("array"===t||"function"!==t&&(0===n||"number"==typeof n&&n>0&&n-1 in e)))}function o(e){var n=_e[e]={};return se.each(e.match(ce)||[],function(e,t){n[t]=!0}),n}function i(e,t,o,i){if(se.acceptData(e)){var a,r,l=se.expando,s="string"==typeof t,p=e.nodeType,c=p?se.cache:e,u=p?e[l]:e[l]&&l;if(u&&c[u]&&(i||c[u].data)||!s||o!==n)return u||(p?e[l]=u=Z.pop()||se.guid++:u=l),c[u]||(c[u]={},p||(c[u].toJSON=se.noop)),("object"==typeof t||"function"==typeof t)&&(i?c[u]=se.extend(c[u],t):c[u].data=se.extend(c[u].data,t)),a=c[u],i||(a.data||(a.data={}),a=a.data),o!==n&&(a[se.camelCase(t)]=o),s?null==(r=a[t])&&(r=a[se.camelCase(t)]):r=a,r}}function a(e,n,t){if(se.acceptData(e)){var o,i,a,r=e.nodeType,s=r?se.cache:e,p=r?e[se.expando]:se.expando;if(s[p]){if(n&&(a=t?s[p]:s[p].data)){se.isArray(n)?n=n.concat(se.map(n,se.camelCase)):n in a?n=[n]:(n=se.camelCase(n),n=n in a?[n]:n.split(" "));for(o=0,i=n.length;i>o;o++)delete a[n[o]];if(!(t?l:se.isEmptyObject)(a))return}(t||(delete s[p].data,l(s[p])))&&(r?se.cleanData([e],!0):se.support.deleteExpando||s!=s.window?delete s[p]:s[p]=null)}}}function r(e,t,o){if(o===n&&1===e.nodeType){var i="data-"+t.replace(we,"-$1").toLowerCase();if("string"==typeof(o=e.getAttribute(i))){try{o="true"===o||"false"!==o&&("null"===o?null:+o+""===o?+o:fe.test(o)?se.parseJSON(o):o)}catch(K){}se.data(e,t,o)}else o=n}return o}function l(e){var n;for(n in e)if(("data"!==n||!se.isEmptyObject(e[n]))&&"toJSON"!==n)return!1;return!0}function s(){return!0}function p(){return!1}function c(e,n){do{e=e[n]}while(e&&1!==e.nodeType);return e}function u(e,n,t){if(n=n||0,se.isFunction(n))return se.grep(e,function(e,o){return!!n.call(e,o,e)===t});if(n.nodeType)return se.grep(e,function(e){return e===n===t});if("string"==typeof n){var o=se.grep(e,function(e){return 1===e.nodeType});if(ke.test(n))return se.filter(n,o,!t);n=se.filter(n,o)}return se.grep(e,function(e){return se.inArray(e,n)>=0===t})}function g(e){var n=We.split("|"),t=e.createDocumentFragment();if(t.createElement)for(;n.length;)t.createElement(n.pop());return t}function h(e,n){return e.getElementsByTagName(n)[0]||e.appendChild(e.ownerDocument.createElement(n))}function m(e){var n=e.getAttributeNode("type");return e.type=(n&&n.specified)+"/"+e.type,e}function d(e){var n=Je.exec(e.type);return n?e.type=n[1]:e.removeAttribute("type"),e}function b(e,n){for(var t,o=0;null!=(t=e[o]);o++)se._data(t,"globalEval",!n||se._data(n[o],"globalEval"))}function _(e,n){if(1===n.nodeType&&se.hasData(e)){var t,o,i,a=se._data(e),r=se._data(n,a),l=a.events;if(l){delete r.handle,r.events={};for(t in l)for(o=0,i=l[t].length;i>o;o++)se.event.add(n,t,l[t][o])}r.data&&(r.data=se.extend({},r.data))}}function f(e,n){var t,o,i;if(1===n.nodeType){if(t=n.nodeName.toLowerCase(),!se.support.noCloneEvent&&n[se.expando]){i=se._data(n);for(o in i.events)se.removeEvent(n,o,i.handle);n.removeAttribute(se.expando)}"script"===t&&n.text!==e.text?(m(n).text=e.text,d(n)):"object"===t?(n.parentNode&&(n.outerHTML=e.outerHTML),se.support.html5Clone&&e.innerHTML&&!se.trim(n.innerHTML)&&(n.innerHTML=e.innerHTML)):"input"===t&&ze.test(e.type)?(n.defaultChecked=n.checked=e.checked,n.value!==e.value&&(n.value=e.value)):"option"===t?n.defaultSelected=n.selected=e.defaultSelected:("input"===t||"textarea"===t)&&(n.defaultValue=e.defaultValue)}}function w(e,t){var o,i,a=0,r=typeof e.getElementsByTagName!==z?e.getElementsByTagName(t||"*"):typeof e.querySelectorAll!==z?e.querySelectorAll(t||"*"):n;if(!r)for(r=[],o=e.childNodes||e;null!=(i=o[a]);a++)!t||se.nodeName(i,t)?r.push(i):se.merge(r,w(i,t))
;return t===n||t&&se.nodeName(e,t)?se.merge([e],r):r}function v(e){ze.test(e.type)&&(e.defaultChecked=e.checked)}function E(e,n){if(n in e)return n;for(var t=n.charAt(0).toUpperCase()+n.slice(1),o=n,i=bn.length;i--;)if((n=bn[i]+t)in e)return n;return o}function P(e,n){return e=n||e,"none"===se.css(e,"display")||!se.contains(e.ownerDocument,e)}function T(e,n){for(var t,o,i,a=[],r=0,l=e.length;l>r;r++)o=e[r],o.style&&(a[r]=se._data(o,"olddisplay"),t=o.style.display,n?(a[r]||"none"!==t||(o.style.display=""),""===o.style.display&&P(o)&&(a[r]=se._data(o,"olddisplay",C(o.nodeName)))):a[r]||(i=P(o),(t&&"none"!==t||!i)&&se._data(o,"olddisplay",i?t:se.css(o,"display"))));for(r=0;l>r;r++)o=e[r],o.style&&(n&&"none"!==o.style.display&&""!==o.style.display||(o.style.display=n?a[r]||"":"none"));return e}function S(e,n,t){var o=pn.exec(n);return o?Math.max(0,o[1]-(t||0))+(o[2]||"px"):n}function N(e,n,t,o,i){for(var a=t===(o?"border":"content")?4:"width"===n?1:0,r=0;4>a;a+=2)"margin"===t&&(r+=se.css(e,t+dn[a],!0,i)),o?("content"===t&&(r-=se.css(e,"padding"+dn[a],!0,i)),"margin"!==t&&(r-=se.css(e,"border"+dn[a]+"Width",!0,i))):(r+=se.css(e,"padding"+dn[a],!0,i),"padding"!==t&&(r+=se.css(e,"border"+dn[a]+"Width",!0,i)));return r}function I(e,n,t){var o=!0,i="width"===n?e.offsetWidth:e.offsetHeight,a=nn(e),r=se.support.boxSizing&&"border-box"===se.css(e,"boxSizing",!1,a);if(0>=i||null==i){if(i=tn(e,n,a),(0>i||null==i)&&(i=e.style[n]),cn.test(i))return i;o=r&&(se.support.boxSizingReliable||i===e.style[n]),i=parseFloat(i)||0}return i+N(e,n,t||(r?"border":"content"),o,a)+"px"}function C(e){var n=K,t=gn[e];return t||(t=G(e,n),"none"!==t&&t||(en=(en||se("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(n.documentElement),n=(en[0].contentWindow||en[0].contentDocument).document,n.write("<!doctype html><html><body>"),n.close(),t=G(e,n),en.detach()),gn[e]=t),t}function G(e,n){var t=se(n.createElement(e)).appendTo(n.body),o=se.css(t[0],"display");return t.remove(),o}function L(e,n,t,o){var i;if(se.isArray(n))se.each(n,function(n,i){t||_n.test(e)?o(e,i):L(e+"["+("object"==typeof i?n:"")+"]",i,t,o)});else if(t||"object"!==se.type(n))o(e,n);else for(i in n)L(e+"["+i+"]",n[i],t,o)}function R(e){return function(n,t){"string"!=typeof n&&(t=n,n="*");var o,i=0,a=n.toLowerCase().match(ce)||[];if(se.isFunction(t))for(;o=a[i++];)"+"===o[0]?(o=o.slice(1)||"*",(e[o]=e[o]||[]).unshift(t)):(e[o]=e[o]||[]).push(t)}}function y(e,t,o,i){function a(s){var p;return r[s]=!0,se.each(e[s]||[],function(e,s){var c=s(t,o,i);return"string"!=typeof c||l||r[c]?l?!(p=c):n:(t.dataTypes.unshift(c),a(c),!1)}),p}var r={},l=e===yn;return a(t.dataTypes[0])||!r["*"]&&a("*")}function D(e,t){var o,i,a=se.ajaxSettings.flatOptions||{};for(i in t)t[i]!==n&&((a[i]?e:o||(o={}))[i]=t[i]);return o&&se.extend(!0,e,o),e}function O(e,t,o){var i,a,r,l,s=e.contents,p=e.dataTypes,c=e.responseFields;for(l in c)l in o&&(t[c[l]]=o[l]);for(;"*"===p[0];)p.shift(),a===n&&(a=e.mimeType||t.getResponseHeader("Content-Type"));if(a)for(l in s)if(s[l]&&s[l].test(a)){p.unshift(l);break}if(p[0]in o)r=p[0];else{for(l in o){if(!p[0]||e.converters[l+" "+p[0]]){r=l;break}i||(i=l)}r=r||i}return r?(r!==p[0]&&p.unshift(r),o[r]):n}function x(e,n){var t,o,i,a,r={},l=0,s=e.dataTypes.slice(),p=s[0];if(e.dataFilter&&(n=e.dataFilter(n,e.dataType)),s[1])for(i in e.converters)r[i.toLowerCase()]=e.converters[i];for(;o=s[++l];)if("*"!==o){if("*"!==p&&p!==o){if(!(i=r[p+" "+o]||r["* "+o]))for(t in r)if(a=t.split(" "),a[1]===o&&(i=r[p+" "+a[0]]||r["* "+a[0]])){!0===i?i=r[t]:!0!==r[t]&&(o=a[0],s.splice(l--,0,o));break}if(!0!==i)if(i&&e["throws"])n=i(n);else try{n=i(n)}catch(Z){return{state:"parsererror",error:i?Z:"No conversion from "+p+" to "+o}}}p=o}return{state:"success",data:n}}function A(){try{return new e.XMLHttpRequest}catch(n){}}function k(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(n){}}function U(){return setTimeout(function(){Wn=n}),Wn=se.now()}function V(e,n){se.each(n,function(n,t){for(var o=($n[n]||[]).concat($n["*"]),i=0,a=o.length;a>i;i++)if(o[i].call(e,n,t))return})}function W(e,n,t){var o,i,a=0,r=jn.length,l=se.Deferred().always(function(){delete s.elem}),s=function(){if(i)return!1;for(var n=Wn||U(),t=Math.max(0,p.startTime+p.duration-n),o=t/p.duration||0,a=1-o,r=0,s=p.tweens.length;s>r;r++)p.tweens[r].run(a);return l.notifyWith(e,[p,a,t]),1>a&&s?t:(l.resolveWith(e,[p]),!1)},p=l.promise({elem:e,props:se.extend({},n),opts:se.extend(!0,{specialEasing:{}},t),originalProperties:n,originalOptions:t,startTime:Wn||U(),duration:t.duration,tweens:[],createTween:function(n,t){var o=se.Tween(e,p.opts,n,t,p.opts.specialEasing[n]||p.opts.easing);return p.tweens.push(o),o},stop:function(n){var t=0,o=n?p.tweens.length:0;if(i)return this;for(i=!0;o>t;t++)p.tweens[t].run(1);return n?l.resolveWith(e,[p,n]):l.rejectWith(e,[p,n]),this}}),c=p.props;for(F(c,p.opts.specialEasing);r>a;a++)if(o=jn[a].call(p,e,c,p.opts))return o;return V(p,c),se.isFunction(p.opts.start)&&p.opts.start.call(e,p),se.fx.timer(se.extend(s,{elem:e,anim:p,queue:p.opts.queue})),p.progress(p.opts.progress).done(p.opts.done,p.opts.complete).fail(p.opts.fail).always(p.opts.always)}function F(e,n){var t,o,i,a,r;for(i in e)if(o=se.camelCase(i),a=n[o],t=e[i],se.isArray(t)&&(a=t[1],t=e[i]=t[0]),i!==o&&(e[o]=t,delete e[i]),(r=se.cssHooks[o])&&"expand"in r){t=r.expand(t),delete e[o];for(i in t)i in e||(e[i]=t[i],n[i]=a)}else n[o]=a}function M(e,n,t){var o,i,a,r,l,s,p,c,u,g=this,h=e.style,m={},d=[],b=e.nodeType&&P(e);t.queue||(c=se._queueHooks(e,"fx"),null==c.unqueued&&(c.unqueued=0,u=c.empty.fire,c.empty.fire=function(){c.unqueued||u()}),c.unqueued++,g.always(function(){g.always(function(){c.unqueued--,se.queue(e,"fx").length||c.empty.fire()})})),1===e.nodeType&&("height"in n||"width"in n)&&(t.overflow=[h.overflow,h.overflowX,h.overflowY],"inline"===se.css(e,"display")&&"none"===se.css(e,"float")&&(se.support.inlineBlockNeedsLayout&&"inline"!==C(e.nodeName)?h.zoom=1:h.display="inline-block")),t.overflow&&(h.overflow="hidden",se.support.shrinkWrapBlocks||g.always(function(){h.overflow=t.overflow[0],h.overflowX=t.overflow[1],h.overflowY=t.overflow[2]}));for(i in n)if(r=n[i],Mn.exec(r)){if(delete n[i],s=s||"toggle"===r,r===(b?"hide":"show"))continue;d.push(i)}if(a=d.length){l=se._data(e,"fxshow")||se._data(e,"fxshow",{}),"hidden"in l&&(b=l.hidden),s&&(l.hidden=!b),b?se(e).show():g.done(function(){se(e).hide()}),g.done(function(){var n;se._removeData(e,"fxshow");for(n in m)se.style(e,n,m[n])});for(i=0;a>i;i++)o=d[i],p=g.createTween(o,b?l[o]:0),m[o]=l[o]||se.style(e,o),o in l||(l[o]=p.start,b&&(p.end=p.start,p.start="width"===o||"height"===o?1:0))}}function H(e,n,t,o,i){return new H.prototype.init(e,n,t,o,i)}function B(e,n){var t,o={height:e},i=0;for(n=n?1:0;4>i;i+=2-n)t=dn[i],o["margin"+t]=o["padding"+t]=e;return n&&(o.opacity=o.width=e),o}function j(e){return se.isWindow(e)?e:9===e.nodeType&&(e.defaultView||e.parentWindow)}var $,q,z=typeof n,K=e.document,X=e.location,J=e.jQuery,Y=e.$,Q={},Z=[],ee="1.9.1",ne=Z.concat,te=Z.push,oe=Z.slice,ie=Z.indexOf,ae=Q.toString,re=Q.hasOwnProperty,le=ee.trim,se=function(e,n){return new se.fn.init(e,n,q)},pe=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ce=/\S+/g,ue=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,ge=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,he=/^[\],:{}\s]*$/,me=function(e,n){return n.toUpperCase()},de=function(e){(K.addEventListener||"load"===e.type||"complete"===K.readyState)&&(be(),se.ready())},be=function(){K.addEventListener?(K.removeEventListener("DOMContentLoaded",de,!1),e.removeEventListener("load",de,!1)):(K.detachEvent("onreadystatechange",de),e.detachEvent("onload",de))};se.fn=se.prototype={jquery:ee,constructor:se,init:function(e,t,o){var i,a;if(!e)return this;if("string"==typeof e){if(!(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:ue.exec(e))||!i[1]&&t)return!t||t.jquery?(t||o).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof se?t[0]:t,se.merge(this,se.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:K,!0)),ge.test(i[1])&&se.isPlainObject(t))for(i in t)se.isFunction(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}if((a=K.getElementById(i[2]))&&a.parentNode){if(a.id!==i[2])return o.find(e);this.length=1,this[0]=a}return this.context=K,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):se.isFunction(e)?o.ready(e):(e.selector!==n&&(this.selector=e.selector,this.context=e.context),se.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return oe.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var n=se.merge(this.constructor(),e);return n.prevObject=this,n.context=this.context,n},each:function(e,n){return se.each(this,e,n)},ready:function(e){return se.ready.promise().done(e),this},slice:function(){return this.pushStack(oe.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var n=this.length,t=+e+(0>e?n:0);return this.pushStack(t>=0&&n>t?[this[t]]:[])},map:function(e){return this.pushStack(se.map(this,function(n,t){return e.call(n,t,n)}))},end:function(){return this.prevObject||this.constructor(null)},push:te,sort:[].sort,splice:[].splice},se.fn.init.prototype=se.fn,se.extend=se.fn.extend=function(){var e,t,o,i,a,r,l=arguments[0]||{},s=1,p=arguments.length,c=!1;for("boolean"==typeof l&&(c=l,l=arguments[1]||{},s=2),"object"==typeof l||se.isFunction(l)||(l={}),p===s&&(l=this,--s);p>s;s++)if(null!=(a=arguments[s]))for(i in a)e=l[i],o=a[i],l!==o&&(c&&o&&(se.isPlainObject(o)||(t=se.isArray(o)))?(t?(t=!1,r=e&&se.isArray(e)?e:[]):r=e&&se.isPlainObject(e)?e:{},l[i]=se.extend(c,r,o)):o!==n&&(l[i]=o));return l},se.extend({noConflict:function(n){return e.$===se&&(e.$=Y),n&&e.jQuery===se&&(e.jQuery=J),se},isReady:!1,readyWait:1,holdReady:function(e){e?se.readyWait++:se.ready(!0)},ready:function(e){if(!0===e?!--se.readyWait:!se.isReady){if(!K.body)return setTimeout(se.ready);se.isReady=!0,!0!==e&&--se.readyWait>0||($.resolveWith(K,[se]),se.fn.trigger&&se(K).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===se.type(e)},isArray:Array.isArray||function(e){return"array"===se.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?Q[ae.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==se.type(e)||e.nodeType||se.isWindow(e))return!1;try{if(e.constructor&&!re.call(e,"constructor")&&!re.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch($){return!1}var t;for(t in e);return t===n||re.call(e,t)},isEmptyObject:function(e){var n;for(n in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,n,t){if(!e||"string"!=typeof e)return null;"boolean"==typeof n&&(t=n,n=!1),n=n||K;var o=ge.exec(e),i=!t&&[];return o?[n.createElement(o[1])]:(o=se.buildFragment([e],n,i),i&&se(i).remove(),se.merge([],o.childNodes))},parseJSON:function(t){return e.JSON&&e.JSON.parse?e.JSON.parse(t):null===t?t:"string"==typeof t&&(t=se.trim(t))&&he.test(t.replace(/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,"@").replace(/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))?Function("return "+t)():(se.error("Invalid JSON: "+t),n)},parseXML:function(t){var o,i;if(!t||"string"!=typeof t)return null;try{e.DOMParser?(i=new DOMParser,o=i.parseFromString(t,"text/xml")):(o=new ActiveXObject("Microsoft.XMLDOM"),o.async="false",o.loadXML(t))}catch(K){o=n}return o&&o.documentElement&&!o.getElementsByTagName("parsererror").length||se.error("Invalid XML: "+t),o},noop:function(){},globalEval:function(n){n&&se.trim(n)&&(e.execScript||function(n){e.eval.call(e,n)})(n)},camelCase:function(e){return e.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,me)},nodeName:function(e,n){return e.nodeName&&e.nodeName.toLowerCase()===n.toLowerCase()},each:function(e,n,o){var i=0,a=e.length,r=t(e);if(o){if(r)for(;a>i&&!1!==n.apply(e[i],o);i++);else for(i in e)if(!1===n.apply(e[i],o))break}else if(r)for(;a>i&&!1!==n.call(e[i],i,e[i]);i++);else for(i in e)if(!1===n.call(e[i],i,e[i]))break;return e},trim:le&&!le.call("\ufeff ")?function(e){return null==e?"":le.call(e)}:function(e){return null==e?"":(e+"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},makeArray:function(e,n){var o=n||[];return null!=e&&(t(Object(e))?se.merge(o,"string"==typeof e?[e]:e):te.call(o,e)),o},inArray:function(e,n,t){var o;if(n){if(ie)return ie.call(n,e,t);for(o=n.length,t=t?0>t?Math.max(0,o+t):t:0;o>t;t++)if(t in n&&n[t]===e)return t}return-1},merge:function(e,t){var o=t.length,i=e.length,a=0;if("number"==typeof o)for(;o>a;a++)e[i++]=t[a];else for(;t[a]!==n;)e[i++]=t[a++];return e.length=i,e},grep:function(e,n,t){var o,i=[],a=0,r=e.length;for(t=!!t;r>a;a++)o=!!n(e[a],a),t!==o&&i.push(e[a]);return i},map:function(e,n,o){var i,a=0,r=e.length,l=t(e),s=[];if(l)for(;r>a;a++)null!=(i=n(e[a],a,o))&&(s[s.length]=i);else for(a in e)null!=(i=n(e[a],a,o))&&(s[s.length]=i);return ne.apply([],s)},guid:1,proxy:function(e,t){var o,i,a;return"string"==typeof t&&(a=e[t],t=e,e=a),se.isFunction(e)?(o=oe.call(arguments,2),i=function(){return e.apply(t||this,o.concat(oe.call(arguments)))},i.guid=e.guid=e.guid||se.guid++,i):n},access:function(e,t,o,i,a,r,l){var s=0,p=e.length,c=null==o;if("object"===se.type(o)){a=!0;for(s in o)se.access(e,t,s,o[s],!0,r,l)}else if(i!==n&&(a=!0,se.isFunction(i)||(l=!0),c&&(l?(t.call(e,i),t=null):(c=t,t=function(e,n,t){return c.call(se(e),t)})),t))for(;p>s;s++)t(e[s],o,l?i:i.call(e[s],s,t(e[s],o)));return a?e:c?t.call(e):p?t(e[0],o):r},now:function(){return(new Date).getTime()}}),se.ready.promise=function(n){if(!$)if($=se.Deferred(),"complete"===K.readyState)setTimeout(se.ready);else if(K.addEventListener)K.addEventListener("DOMContentLoaded",de,!1),e.addEventListener("load",de,!1);else{K.attachEvent("onreadystatechange",de),e.attachEvent("onload",de);var t=!1;try{t=null==e.frameElement&&K.documentElement}catch(z){}t&&t.doScroll&&function o(){if(!se.isReady){try{t.doScroll("left")}catch(e){return setTimeout(o,50)}be(),se.ready()}}()}return $.promise(n)},se.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,n){Q["[object "+n+"]"]=n.toLowerCase()}),q=se(K);var _e={};se.Callbacks=function(e){e="string"==typeof e?_e[e]||o(e):se.extend({},e);var t,i,a,r,l,s,p=[],c=!e.once&&[],u=function(n){for(i=e.memory&&n,a=!0,l=s||0,s=0,r=p.length,t=!0;p&&r>l;l++)if(!1===p[l].apply(n[0],n[1])&&e.stopOnFalse){i=!1;break}t=!1,p&&(c?c.length&&u(c.shift()):i?p=[]:g.disable())},g={add:function(){if(p){var n=p.length;(function o(n){se.each(n,function(n,t){var i=se.type(t);"function"===i?e.unique&&g.has(t)||p.push(t):t&&t.length&&"string"!==i&&o(t)})})(arguments),t?r=p.length:i&&(s=n,u(i))}return this},remove:function(){return p&&se.each(arguments,function(e,n){for(var o;(o=se.inArray(n,p,o))>-1;)p.splice(o,1),t&&(r>=o&&r--,l>=o&&l--)}),this},has:function(e){return e?se.inArray(e,p)>-1:!(!p||!p.length)},empty:function(){return p=[],this},disable:function(){return p=c=i=n,this},disabled:function(){return!p},lock:function(){return c=n,i||g.disable(),this},locked:function(){return!c},fireWith:function(e,n){return n=n||[],n=[e,n.slice?n.slice():n],!p||a&&!c||(t?c.push(n):u(n)),this},fire:function(){return g.fireWith(this,arguments),this},fired:function(){return!!a}};return g},se.extend({Deferred:function(e){var n=[["resolve","done",se.Callbacks("once memory"),"resolved"],["reject","fail",se.Callbacks("once memory"),"rejected"],["notify","progress",se.Callbacks("memory")]],t="pending",o={state:function(){return t},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return se.Deferred(function(t){se.each(n,function(n,a){var r=a[0],l=se.isFunction(e[n])&&e[n];i[a[1]](function(){var e=l&&l.apply(this,arguments);e&&se.isFunction(e.promise)?e.promise().done(t.resolve).fail(t.reject).progress(t.notify):t[r+"With"](this===o?t.promise():this,l?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?se.extend(e,o):o}},i={};return o.pipe=o.then,se.each(n,function(e,a){var r=a[2],l=a[3];o[a[1]]=r.add,l&&r.add(function(){t=l},n[1^e][2].disable,n[2][2].lock),i[a[0]]=function(){return i[a[0]+"With"](this===i?o:this,arguments),this},i[a[0]+"With"]=r.fireWith}),o.promise(i),e&&e.call(i,i),i},when:function(e){var n,t,o,i=0,a=oe.call(arguments),r=a.length,l=1!==r||e&&se.isFunction(e.promise)?r:0,s=1===l?e:se.Deferred(),p=function(e,t,o){return function(i){t[e]=this,o[e]=arguments.length>1?oe.call(arguments):i,o===n?s.notifyWith(t,o):--l||s.resolveWith(t,o)}};if(r>1)for(n=Array(r),t=Array(r),o=Array(r);r>i;i++)a[i]&&se.isFunction(a[i].promise)?a[i].promise().done(p(i,o,a)).fail(s.reject).progress(p(i,t,n)):--l;return l||s.resolveWith(o,a),s.promise()}}),se.support=function(){var n,t,o,i,a,r,l,s,p,c,u=K.createElement("div");if(u.setAttribute("className","t"),u.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",t=u.getElementsByTagName("*"),o=u.getElementsByTagName("a")[0],!t||!o||!t.length)return{};a=K.createElement("select"),l=a.appendChild(K.createElement("option")),i=u.getElementsByTagName("input")[0],o.style.cssText="top:1px;float:left;opacity:.5",n={getSetAttribute:"t"!==u.className,leadingWhitespace:3===u.firstChild.nodeType,tbody:!u.getElementsByTagName("tbody").length,htmlSerialize:!!u.getElementsByTagName("link").length,style:/top/.test(o.getAttribute("style")),hrefNormalized:"/a"===o.getAttribute("href"),opacity:/^0.5/.test(o.style.opacity),cssFloat:!!o.style.cssFloat,checkOn:!!i.value,optSelected:l.selected,enctype:!!K.createElement("form").enctype,html5Clone:"<:nav></:nav>"!==K.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===K.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},i.checked=!0,n.noCloneChecked=i.cloneNode(!0).checked,a.disabled=!0,n.optDisabled=!l.disabled;try{delete u.test}catch(oe){n.deleteExpando=!1}i=K.createElement("input"),i.setAttribute("value",""),n.input=""===i.getAttribute("value"),i.value="t",i.setAttribute("type","radio"),n.radioValue="t"===i.value,i.setAttribute("checked","t"),i.setAttribute("name","t"),r=K.createDocumentFragment(),r.appendChild(i),n.appendChecked=i.checked,n.checkClone=r.cloneNode(!0).cloneNode(!0).lastChild.checked,u.attachEvent&&(u.attachEvent("onclick",function(){n.noCloneEvent=!1}),u.cloneNode(!0).click());for(c in{submit:!0,change:!0,focusin:!0})u.setAttribute(s="on"+c,"t"),n[c+"Bubbles"]=s in e||!1===u.attributes[s].expando;return u.style.backgroundClip="content-box",u.cloneNode(!0).style.backgroundClip="",n.clearCloneStyle="content-box"===u.style.backgroundClip,se(function(){var t,o,i,a="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",r=K.getElementsByTagName("body")[0];r&&(t=K.createElement("div"),t.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",r.appendChild(t).appendChild(u),u.innerHTML="<table><tr><td></td><td>t</td></tr></table>",i=u.getElementsByTagName("td"),i[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===i[0].offsetHeight,i[0].style.display="",i[1].style.display="none",n.reliableHiddenOffsets=p&&0===i[0].offsetHeight,u.innerHTML="",u.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",n.boxSizing=4===u.offsetWidth,n.doesNotIncludeMarginInBodyOffset=1!==r.offsetTop,e.getComputedStyle&&(n.pixelPosition="1%"!==(e.getComputedStyle(u,null)||{}).top,n.boxSizingReliable="4px"===(e.getComputedStyle(u,null)||{width:"4px"}).width,o=u.appendChild(K.createElement("div")),o.style.cssText=u.style.cssText=a,o.style.marginRight=o.style.width="0",u.style.width="1px",n.reliableMarginRight=!parseFloat((e.getComputedStyle(o,null)||{}).marginRight)),typeof u.style.zoom!==z&&(u.innerHTML="",u.style.cssText=a+"width:1px;padding:1px;display:inline;zoom:1",n.inlineBlockNeedsLayout=3===u.offsetWidth,u.style.display="block",u.innerHTML="<div></div>",u.firstChild.style.width="5px",n.shrinkWrapBlocks=3!==u.offsetWidth,n.inlineBlockNeedsLayout&&(r.style.zoom=1)),r.removeChild(t),t=u=i=o=null)}),t=a=r=l=o=i=null,n}();var fe=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,we=/([A-Z])/g;se.extend({cache:{},expando:"jQuery"+(ee+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return!!(e=e.nodeType?se.cache[e[se.expando]]:e[se.expando])&&!l(e)},data:function(e,n,t){return i(e,n,t)},removeData:function(e,n){return a(e,n)},_data:function(e,n,t){return i(e,n,t,!0)},_removeData:function(e,n){return a(e,n,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var n=e.nodeName&&se.noData[e.nodeName.toLowerCase()];return!n||!0!==n&&e.getAttribute("classid")===n}}),se.fn.extend({data:function(e,t){var o,i,a=this[0],l=0,s=null;if(e===n){if(this.length&&(s=se.data(a),1===a.nodeType&&!se._data(a,"parsedAttrs"))){for(o=a.attributes;o.length>l;l++)i=o[l].name,i.indexOf("data-")||(i=se.camelCase(i.slice(5)),r(a,i,s[i]));se._data(a,"parsedAttrs",!0)}return s}return"object"==typeof e?this.each(function(){se.data(this,e)}):se.access(this,function(t){return t===n?a?r(a,e,se.data(a,e)):null:(this.each(function(){se.data(this,e,t)}),n)},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){se.removeData(this,e)})}}),se.extend({queue:function(e,t,o){var i;return e?(t=(t||"fx")+"queue",i=se._data(e,t),o&&(!i||se.isArray(o)?i=se._data(e,t,se.makeArray(o)):i.push(o)),i||[]):n},dequeue:function(e,n){n=n||"fx";var t=se.queue(e,n),o=t.length,i=t.shift(),a=se._queueHooks(e,n),r=function(){se.dequeue(e,n)};"inprogress"===i&&(i=t.shift(),o--),a.cur=i,i&&("fx"===n&&t.unshift("inprogress"),delete a.stop,i.call(e,r,a)),!o&&a&&a.empty.fire()},_queueHooks:function(e,n){var t=n+"queueHooks";return se._data(e,t)||se._data(e,t,{empty:se.Callbacks("once memory").add(function(){se._removeData(e,n+"queue"),se._removeData(e,t)})})}}),se.fn.extend({queue:function(e,t){var o=2;return"string"!=typeof e&&(t=e,e="fx",o--),o>arguments.length?se.queue(this[0],e):t===n?this:this.each(function(){var n=se.queue(this,e,t);se._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&se.dequeue(this,e)})},dequeue:function(e){return this.each(function(){se.dequeue(this,e)})},delay:function(e,n){return e=se.fx?se.fx.speeds[e]||e:e,n=n||"fx",this.queue(n,function(n,t){var o=setTimeout(n,e);t.stop=function(){clearTimeout(o)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var o,i=1,a=se.Deferred(),r=this,l=this.length,s=function(){--i||a.resolveWith(r,[r])};for("string"!=typeof e&&(t=e,e=n),e=e||"fx";l--;)(o=se._data(r[l],e+"queueHooks"))&&o.empty&&(i++,o.empty.add(s));return s(),a.promise(t)}});var ve,Ee,Pe=/[\t\r\n]/g,Te=/^(?:input|select|textarea|button|object)$/i,Se=/^(?:a|area)$/i,Ne=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,Ie=/^(?:checked|selected)$/i,Ce=se.support.getSetAttribute,Ge=se.support.input;se.fn.extend({attr:function(e,n){return se.access(this,se.attr,e,n,arguments.length>1)},removeAttr:function(e){return this.each(function(){se.removeAttr(this,e)})},prop:function(e,n){return se.access(this,se.prop,e,n,arguments.length>1)},removeProp:function(e){return e=se.propFix[e]||e,this.each(function(){try{this[e]=n,delete this[e]}catch($){}})},addClass:function(e){var n,t,o,i,a,r=0,l=this.length,s="string"==typeof e&&e;if(se.isFunction(e))return this.each(function(n){se(this).addClass(e.call(this,n,this.className))});if(s)for(n=(e||"").match(ce)||[];l>r;r++)if(t=this[r],o=1===t.nodeType&&(t.className?(" "+t.className+" ").replace(Pe," "):" ")){for(a=0;i=n[a++];)0>o.indexOf(" "+i+" ")&&(o+=i+" ");t.className=se.trim(o)}return this},removeClass:function(e){var n,t,o,i,a,r=0,l=this.length,s=0===arguments.length||"string"==typeof e&&e;if(se.isFunction(e))return this.each(function(n){se(this).removeClass(e.call(this,n,this.className))});if(s)for(n=(e||"").match(ce)||[];l>r;r++)if(t=this[r],o=1===t.nodeType&&(t.className?(" "+t.className+" ").replace(Pe," "):"")){for(a=0;i=n[a++];)for(;o.indexOf(" "+i+" ")>=0;)o=o.replace(" "+i+" "," ");t.className=e?se.trim(o):""}return this},toggleClass:function(e,n){var t=typeof e,o="boolean"==typeof n;return se.isFunction(e)?this.each(function(t){se(this).toggleClass(e.call(this,t,this.className,n),n)}):this.each(function(){if("string"===t)for(var i,a=0,r=se(this),l=n,s=e.match(ce)||[];i=s[a++];)l=o?l:!r.hasClass(i),r[l?"addClass":"removeClass"](i);else(t===z||"boolean"===t)&&(this.className&&se._data(this,"__className__",this.className),this.className=this.className||!1===e?"":se._data(this,"__className__")||"")})},hasClass:function(e){for(var n=" "+e+" ",t=0,o=this.length;o>t;t++)if(1===this[t].nodeType&&(" "+this[t].className+" ").replace(Pe," ").indexOf(n)>=0)return!0;return!1},val:function(e){var t,o,i,a=this[0];return arguments.length?(i=se.isFunction(e),this.each(function(t){var a,r=se(this);1===this.nodeType&&(a=i?e.call(this,t,r.val()):e,null==a?a="":"number"==typeof a?a+="":se.isArray(a)&&(a=se.map(a,function(e){return null==e?"":e+""})),(o=se.valHooks[this.type]||se.valHooks[this.nodeName.toLowerCase()])&&"set"in o&&o.set(this,a,"value")!==n||(this.value=a))})):a?(o=se.valHooks[a.type]||se.valHooks[a.nodeName.toLowerCase()],o&&"get"in o&&(t=o.get(a,"value"))!==n?t:(t=a.value,"string"==typeof t?t.replace(/\r/g,""):null==t?"":t)):void 0}}),se.extend({valHooks:{option:{get:function(e){var n=e.attributes.value;return!n||n.specified?e.value:e.text}},select:{get:function(e){for(var n,t,o=e.options,i=e.selectedIndex,a="select-one"===e.type||0>i,r=a?null:[],l=a?i+1:o.length,s=0>i?l:a?i:0;l>s;s++)if(t=o[s],!(!t.selected&&s!==i||(se.support.optDisabled?t.disabled:null!==t.getAttribute("disabled"))||t.parentNode.disabled&&se.nodeName(t.parentNode,"optgroup"))){if(n=se(t).val(),a)return n;r.push(n)}return r},set:function(e,n){var t=se.makeArray(n);return se(e).find("option").each(function(){this.selected=se.inArray(se(this).val(),t)>=0}),t.length||(e.selectedIndex=-1),t}}},attr:function(e,t,o){var i,a,r,l=e.nodeType;if(e&&3!==l&&8!==l&&2!==l)return typeof e.getAttribute===z?se.prop(e,t,o):(a=1!==l||!se.isXMLDoc(e),a&&(t=t.toLowerCase(),i=se.attrHooks[t]||(Ne.test(t)?Ee:ve)),o===n?i&&a&&"get"in i&&null!==(r=i.get(e,t))?r:(typeof e.getAttribute!==z&&(r=e.getAttribute(t)),null==r?n:r):null!==o?i&&a&&"set"in i&&(r=i.set(e,o,t))!==n?r:(e.setAttribute(t,o+""),o):(se.removeAttr(e,t),n))},removeAttr:function(e,n){var t,o,i=0,a=n&&n.match(ce);if(a&&1===e.nodeType)for(;t=a[i++];)o=se.propFix[t]||t,Ne.test(t)?!Ce&&Ie.test(t)?e[se.camelCase("default-"+t)]=e[o]=!1:e[o]=!1:se.attr(e,t,""),e.removeAttribute(Ce?t:o)},attrHooks:{type:{set:function(e,n){if(!se.support.radioValue&&"radio"===n&&se.nodeName(e,"input")){var t=e.value;return e.setAttribute("type",n),t&&(e.value=t),n}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,t,o){var i,a,r,l=e.nodeType;if(e&&3!==l&&8!==l&&2!==l)return r=1!==l||!se.isXMLDoc(e),r&&(t=se.propFix[t]||t,a=se.propHooks[t]),o!==n?a&&"set"in a&&(i=a.set(e,o,t))!==n?i:e[t]=o:a&&"get"in a&&null!==(i=a.get(e,t))?i:e[t]},propHooks:{tabIndex:{get:function(e){var t=e.getAttributeNode("tabindex");return t&&t.specified?parseInt(t.value,10):Te.test(e.nodeName)||Se.test(e.nodeName)&&e.href?0:n}}}}),Ee={get:function(e,t){var o=se.prop(e,t),i="boolean"==typeof o&&e.getAttribute(t),a="boolean"==typeof o?Ge&&Ce?null!=i:Ie.test(t)?e[se.camelCase("default-"+t)]:!!i:e.getAttributeNode(t);return a&&!1!==a.value?t.toLowerCase():n},set:function(e,n,t){return!1===n?se.removeAttr(e,t):Ge&&Ce||!Ie.test(t)?e.setAttribute(!Ce&&se.propFix[t]||t,t):e[se.camelCase("default-"+t)]=e[t]=!0,t}},Ge&&Ce||(se.attrHooks.value={get:function(e,t){var o=e.getAttributeNode(t);return se.nodeName(e,"input")?e.defaultValue:o&&o.specified?o.value:n},set:function(e,t,o){return se.nodeName(e,"input")?(e.defaultValue=t,n):ve&&ve.set(e,t,o)}}),Ce||(ve=se.valHooks.button={get:function(e,t){var o=e.getAttributeNode(t);return o&&("id"===t||"name"===t||"coords"===t?""!==o.value:o.specified)?o.value:n},set:function(e,t,o){var i=e.getAttributeNode(o);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(o)),i.value=t+="","value"===o||t===e.getAttribute(o)?t:n}},se.attrHooks.contenteditable={get:ve.get,set:function(e,n,t){ve.set(e,""!==n&&n,t)}},se.each(["width","height"],function(e,t){se.attrHooks[t]=se.extend(se.attrHooks[t],{set:function(e,o){return""===o?(e.setAttribute(t,"auto"),o):n}})})),se.support.hrefNormalized||(se.each(["href","src","width","height"],function(e,t){se.attrHooks[t]=se.extend(se.attrHooks[t],{get:function(e){var o=e.getAttribute(t,2);return null==o?n:o}})}),se.each(["href","src"],function(e,n){se.propHooks[n]={get:function(e){return e.getAttribute(n,4)}}})),se.support.style||(se.attrHooks.style={get:function(e){return e.style.cssText||n},set:function(e,n){return e.style.cssText=n+""}}),se.support.optSelected||(se.propHooks.selected=se.extend(se.propHooks.selected,{get:function(e){var n=e.parentNode;return n&&(n.selectedIndex,n.parentNode&&n.parentNode.selectedIndex),null}})),se.support.enctype||(se.propFix.enctype="encoding"),se.support.checkOn||se.each(["radio","checkbox"],function(){se.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),se.each(["radio","checkbox"],function(){se.valHooks[this]=se.extend(se.valHooks[this],{set:function(e,t){return se.isArray(t)?e.checked=se.inArray(se(e).val(),t)>=0:n}})});var Le=/^(?:input|select|textarea)$/i,Re=/^key/,ye=/^(?:mouse|contextmenu)|click/,De=/^(?:focusinfocus|focusoutblur)$/,Oe=/^([^.]*)(?:\.(.+)|)$/;se.event={global:{},add:function(e,t,o,i,a){var r,l,s,p,c,u,g,h,m,d,b,_=se._data(e);if(_){for(o.handler&&(p=o,o=p.handler,a=p.selector),o.guid||(o.guid=se.guid++),(l=_.events)||(l=_.events={}),(u=_.handle)||(u=_.handle=function(e){return typeof se===z||e&&se.event.triggered===e.type?n:se.event.dispatch.apply(u.elem,arguments)},u.elem=e),t=(t||"").match(ce)||[""],s=t.length;s--;)r=Oe.exec(t[s])||[],m=b=r[1],d=(r[2]||"").split(".").sort(),c=se.event.special[m]||{},m=(a?c.delegateType:c.bindType)||m,c=se.event.special[m]||{},g=se.extend({type:m,origType:b,data:i,handler:o,guid:o.guid,selector:a,needsContext:a&&se.expr.match.needsContext.test(a),namespace:d.join(".")},p),(h=l[m])||(h=l[m]=[],h.delegateCount=0,c.setup&&!1!==c.setup.call(e,i,d,u)||(e.addEventListener?e.addEventListener(m,u,!1):e.attachEvent&&e.attachEvent("on"+m,u))),c.add&&(c.add.call(e,g),g.handler.guid||(g.handler.guid=o.guid)),a?h.splice(h.delegateCount++,0,g):h.push(g),se.event.global[m]=!0;e=null}},remove:function(e,n,t,o,i){var a,r,l,s,p,c,u,g,h,m,d,b=se.hasData(e)&&se._data(e);if(b&&(c=b.events)){for(n=(n||"").match(ce)||[""],p=n.length;p--;)if(l=Oe.exec(n[p])||[],h=d=l[1],m=(l[2]||"").split(".").sort(),h){for(u=se.event.special[h]||{},h=(o?u.delegateType:u.bindType)||h,g=c[h]||[],l=l[2]&&RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=a=g.length;a--;)r=g[a],!i&&d!==r.origType||t&&t.guid!==r.guid||l&&!l.test(r.namespace)||o&&o!==r.selector&&("**"!==o||!r.selector)||(g.splice(a,1),r.selector&&g.delegateCount--,u.remove&&u.remove.call(e,r));s&&!g.length&&(u.teardown&&!1!==u.teardown.call(e,m,b.handle)||se.removeEvent(e,h,b.handle),
delete c[h])}else for(h in c)se.event.remove(e,h+n[p],t,o,!0);se.isEmptyObject(c)&&(delete b.handle,se._removeData(e,"events"))}},trigger:function(t,o,i,a){var r,l,s,p,c,u,g,h=[i||K],m=re.call(t,"type")?t.type:t,d=re.call(t,"namespace")?t.namespace.split("."):[];if(s=u=i=i||K,3!==i.nodeType&&8!==i.nodeType&&!De.test(m+se.event.triggered)&&(m.indexOf(".")>=0&&(d=m.split("."),m=d.shift(),d.sort()),l=0>m.indexOf(":")&&"on"+m,t=t[se.expando]?t:new se.Event(m,"object"==typeof t&&t),t.isTrigger=!0,t.namespace=d.join("."),t.namespace_re=t.namespace?RegExp("(^|\\.)"+d.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=n,t.target||(t.target=i),o=null==o?[t]:se.makeArray(o,[t]),c=se.event.special[m]||{},a||!c.trigger||!1!==c.trigger.apply(i,o))){if(!a&&!c.noBubble&&!se.isWindow(i)){for(p=c.delegateType||m,De.test(p+m)||(s=s.parentNode);s;s=s.parentNode)h.push(s),u=s;u===(i.ownerDocument||K)&&h.push(u.defaultView||u.parentWindow||e)}for(g=0;(s=h[g++])&&!t.isPropagationStopped();)t.type=g>1?p:c.bindType||m,r=(se._data(s,"events")||{})[t.type]&&se._data(s,"handle"),r&&r.apply(s,o),(r=l&&s[l])&&se.acceptData(s)&&r.apply&&!1===r.apply(s,o)&&t.preventDefault();if(t.type=m,!(a||t.isDefaultPrevented()||c._default&&!1!==c._default.apply(i.ownerDocument,o)||"click"===m&&se.nodeName(i,"a")||!se.acceptData(i)||!l||!i[m]||se.isWindow(i))){u=i[l],u&&(i[l]=null),se.event.triggered=m;try{i[m]()}catch(le){}se.event.triggered=n,u&&(i[l]=u)}return t.result}},dispatch:function(e){e=se.event.fix(e);var t,o,i,a,r,l=[],s=oe.call(arguments),p=(se._data(this,"events")||{})[e.type]||[],c=se.event.special[e.type]||{};if(s[0]=e,e.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,e)){for(l=se.event.handlers.call(this,e,p),t=0;(a=l[t++])&&!e.isPropagationStopped();)for(e.currentTarget=a.elem,r=0;(i=a.handlers[r++])&&!e.isImmediatePropagationStopped();)(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,(o=((se.event.special[i.origType]||{}).handle||i.handler).apply(a.elem,s))!==n&&!1===(e.result=o)&&(e.preventDefault(),e.stopPropagation()));return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,t){var o,i,a,r,l=[],s=t.delegateCount,p=e.target;if(s&&p.nodeType&&(!e.button||"click"!==e.type))for(;p!=this;p=p.parentNode||this)if(1===p.nodeType&&(!0!==p.disabled||"click"!==e.type)){for(a=[],r=0;s>r;r++)i=t[r],o=i.selector+" ",a[o]===n&&(a[o]=i.needsContext?se(o,this).index(p)>=0:se.find(o,this,null,[p]).length),a[o]&&a.push(i);a.length&&l.push({elem:p,handlers:a})}return t.length>s&&l.push({elem:this,handlers:t.slice(s)}),l},fix:function(e){if(e[se.expando])return e;var n,t,o,i=e.type,a=e,r=this.fixHooks[i];for(r||(this.fixHooks[i]=r=ye.test(i)?this.mouseHooks:Re.test(i)?this.keyHooks:{}),o=r.props?this.props.concat(r.props):this.props,e=new se.Event(a),n=o.length;n--;)t=o[n],e[t]=a[t];return e.target||(e.target=a.srcElement||K),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,r.filter?r.filter(e,a):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,n){return null==e.which&&(e.which=null!=n.charCode?n.charCode:n.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,t){var o,i,a,r=t.button,l=t.fromElement;return null==e.pageX&&null!=t.clientX&&(i=e.target.ownerDocument||K,a=i.documentElement,o=i.body,e.pageX=t.clientX+(a&&a.scrollLeft||o&&o.scrollLeft||0)-(a&&a.clientLeft||o&&o.clientLeft||0),e.pageY=t.clientY+(a&&a.scrollTop||o&&o.scrollTop||0)-(a&&a.clientTop||o&&o.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?t.toElement:l),e.which||r===n||(e.which=1&r?1:2&r?3:4&r?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return se.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):n}},focus:{trigger:function(){if(this!==K.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===K.activeElement&&this.blur?(this.blur(),!1):n},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==n&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,n,t,o){var i=se.extend(new se.Event,t,{type:e,isSimulated:!0,originalEvent:{}});o?se.event.trigger(i,null,n):se.event.dispatch.call(n,i),i.isDefaultPrevented()&&t.preventDefault()}},se.removeEvent=K.removeEventListener?function(e,n,t){e.removeEventListener&&e.removeEventListener(n,t,!1)}:function(e,n,t){var o="on"+n;e.detachEvent&&(typeof e[o]===z&&(e[o]=null),e.detachEvent(o,t))},se.Event=function(e,t){return this instanceof se.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||!1===e.returnValue||e.defaultPrevented?s:p):this.type=e,t&&se.extend(this,t),this.timeStamp=e&&e.timeStamp||se.now(),this[se.expando]=!0,n):new se.Event(e,t)},se.Event.prototype={isDefaultPrevented:p,isPropagationStopped:p,isImmediatePropagationStopped:p,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=s,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=s,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=s,this.stopPropagation()}},se.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,n){se.event.special[e]={delegateType:n,bindType:n,handle:function(e){var t,o=this,i=e.relatedTarget,a=e.handleObj;return(!i||i!==o&&!se.contains(o,i))&&(e.type=a.origType,t=a.handler.apply(this,arguments),e.type=n),t}}}),se.support.submitBubbles||(se.event.special.submit={setup:function(){return!se.nodeName(this,"form")&&(se.event.add(this,"click._submit keypress._submit",function(e){var t=e.target,o=se.nodeName(t,"input")||se.nodeName(t,"button")?t.form:n;o&&!se._data(o,"submitBubbles")&&(se.event.add(o,"submit._submit",function(e){e._submit_bubble=!0}),se._data(o,"submitBubbles",!0))}),n)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&se.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return!se.nodeName(this,"form")&&(se.event.remove(this,"._submit"),n)}}),se.support.changeBubbles||(se.event.special.change={setup:function(){return Le.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(se.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),se.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),se.event.simulate("change",this,e,!0)})),!1):(se.event.add(this,"beforeactivate._change",function(e){var n=e.target;Le.test(n.nodeName)&&!se._data(n,"changeBubbles")&&(se.event.add(n,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||se.event.simulate("change",this.parentNode,e,!0)}),se._data(n,"changeBubbles",!0))}),n)},handle:function(e){var t=e.target;return this!==t||e.isSimulated||e.isTrigger||"radio"!==t.type&&"checkbox"!==t.type?e.handleObj.handler.apply(this,arguments):n},teardown:function(){return se.event.remove(this,"._change"),!Le.test(this.nodeName)}}),se.support.focusinBubbles||se.each({focus:"focusin",blur:"focusout"},function(e,n){var t=0,o=function(e){se.event.simulate(n,e.target,se.event.fix(e),!0)};se.event.special[n]={setup:function(){0==t++&&K.addEventListener(e,o,!0)},teardown:function(){0==--t&&K.removeEventListener(e,o,!0)}}}),se.fn.extend({on:function(e,t,o,i,a){var r,l;if("object"==typeof e){"string"!=typeof t&&(o=o||t,t=n);for(r in e)this.on(r,t,o,e[r],a);return this}if(null==o&&null==i?(i=t,o=t=n):null==i&&("string"==typeof t?(i=o,o=n):(i=o,o=t,t=n)),!1===i)i=p;else if(!i)return this;return 1===a&&(l=i,i=function(e){return se().off(e),l.apply(this,arguments)},i.guid=l.guid||(l.guid=se.guid++)),this.each(function(){se.event.add(this,e,i,o,t)})},one:function(e,n,t,o){return this.on(e,n,t,o,1)},off:function(e,t,o){var i,a;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,se(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(a in e)this.off(a,t,e[a]);return this}return(!1===t||"function"==typeof t)&&(o=t,t=n),!1===o&&(o=p),this.each(function(){se.event.remove(this,e,o,t)})},bind:function(e,n,t){return this.on(e,null,n,t)},unbind:function(e,n){return this.off(e,null,n)},delegate:function(e,n,t,o){return this.on(n,e,t,o)},undelegate:function(e,n,t){return 1===arguments.length?this.off(e,"**"):this.off(n,e||"**",t)},trigger:function(e,n){return this.each(function(){se.event.trigger(e,n,this)})},triggerHandler:function(e,t){var o=this[0];return o?se.event.trigger(e,t,o,!0):n}}),function(e,n){function t(e){return ue.test(e+"")}function o(){var e,n=[];return e=function(t,o){return n.push(t+=" ")>P.cacheLength&&delete e[n.shift()],e[t]=o}}function i(e){return e[U]=!0,e}function a(e){var n=L.createElement("div");try{return e(n)}catch(v){return!1}finally{n=null}}function r(e,n,t,o){var i,a,r,l,s,u,g,h,m,d;if((n?n.ownerDocument||n:V)!==L&&G(n),n=n||L,t=t||[],!e||"string"!=typeof e)return t;if(1!==(l=n.nodeType)&&9!==l)return[];if(!y&&!o){if(i=ge.exec(e))if(r=i[1]){if(9===l){if(!(a=n.getElementById(r))||!a.parentNode)return t;if(a.id===r)return t.push(a),t}else if(n.ownerDocument&&(a=n.ownerDocument.getElementById(r))&&A(n,a)&&a.id===r)return t.push(a),t}else{if(i[2])return X.apply(t,J.call(n.getElementsByTagName(e),0)),t;if((r=i[3])&&W.getByClassName&&n.getElementsByClassName)return X.apply(t,J.call(n.getElementsByClassName(r),0)),t}if(W.qsa&&!D.test(e)){if(g=!0,h=U,m=n,d=9===l&&e,1===l&&"object"!==n.nodeName.toLowerCase()){for(u=p(e),(g=n.getAttribute("id"))?h=g.replace(de,"\\$&"):n.setAttribute("id",h),h="[id='"+h+"'] ",s=u.length;s--;)u[s]=h+c(u[s]);m=ce.test(e)&&n.parentNode||n,d=u.join(",")}if(d)try{return X.apply(t,J.call(m.querySelectorAll(d),0)),t}catch(se){}finally{g||n.removeAttribute("id")}}}return f(e.replace(oe,"$1"),n,t,o)}function l(e,n){var t=n&&e,o=t&&(~n.sourceIndex||q)-(~e.sourceIndex||q);if(o)return o;if(t)for(;t=t.nextSibling;)if(t===n)return-1;return e?1:-1}function s(e){return i(function(n){return n=+n,i(function(t,o){for(var i,a=e([],t.length,n),r=a.length;r--;)t[i=a[r]]&&(t[i]=!(o[i]=t[i]))})})}function p(e,n){var t,o,i,a,l,s,p,c=B[e+" "];if(c)return n?0:c.slice(0);for(l=e,s=[],p=P.preFilter;l;){(!t||(o=ie.exec(l)))&&(o&&(l=l.slice(o[0].length)||l),s.push(i=[])),t=!1,(o=ae.exec(l))&&(t=o.shift(),i.push({value:t,type:o[0].replace(oe," ")}),l=l.slice(t.length));for(a in P.filter)!(o=pe[a].exec(l))||p[a]&&!(o=p[a](o))||(t=o.shift(),i.push({value:t,type:a,matches:o}),l=l.slice(t.length));if(!t)break}return n?l.length:l?r.error(e):B(e,s).slice(0)}function c(e){for(var n=0,t=e.length,o="";t>n;n++)o+=e[n].value;return o}function u(e,n,t){var o=n.dir,i=t&&"parentNode"===o,a=M++;return n.first?function(n,t,a){for(;n=n[o];)if(1===n.nodeType||i)return e(n,t,a)}:function(n,t,r){var l,s,p,c=F+" "+a;if(r){for(;n=n[o];)if((1===n.nodeType||i)&&e(n,t,r))return!0}else for(;n=n[o];)if(1===n.nodeType||i)if(p=n[U]||(n[U]={}),(s=p[o])&&s[0]===c){if(!0===(l=s[1])||l===E)return!0===l}else if(s=p[o]=[c],s[1]=e(n,t,r)||E,!0===s[1])return!0}}function g(e){return e.length>1?function(n,t,o){for(var i=e.length;i--;)if(!e[i](n,t,o))return!1;return!0}:e[0]}function h(e,n,t,o,i){for(var a,r=[],l=0,s=e.length,p=null!=n;s>l;l++)(a=e[l])&&(!t||t(a,o,i))&&(r.push(a),p&&n.push(l));return r}function m(e,n,t,o,a,r){return o&&!o[U]&&(o=m(o)),a&&!a[U]&&(a=m(a,r)),i(function(i,r,l,s){var p,c,u,g=[],m=[],d=r.length,b=i||_(n||"*",l.nodeType?[l]:l,[]),f=!e||!i&&n?b:h(b,g,e,l,s),w=t?a||(i?e:d||o)?[]:r:f;if(t&&t(f,w,l,s),o)for(p=h(w,m),o(p,[],l,s),c=p.length;c--;)(u=p[c])&&(w[m[c]]=!(f[m[c]]=u));if(i){if(a||e){if(a){for(p=[],c=w.length;c--;)(u=w[c])&&p.push(f[c]=u);a(null,w=[],p,s)}for(c=w.length;c--;)(u=w[c])&&(p=a?Y.call(i,u):g[c])>-1&&(i[p]=!(r[p]=u))}}else w=h(w===r?w.splice(d,w.length):w),a?a(null,r,w,s):X.apply(r,w)})}function d(e){for(var n,t,o,i=e.length,a=P.relative[e[0].type],r=a||P.relative[" "],l=a?1:0,s=u(function(e){return e===n},r,!0),p=u(function(e){return Y.call(n,e)>-1},r,!0),h=[function(e,t,o){return!a&&(o||t!==C)||((n=t).nodeType?s(e,t,o):p(e,t,o))}];i>l;l++)if(t=P.relative[e[l].type])h=[u(g(h),t)];else{if(t=P.filter[e[l].type].apply(null,e[l].matches),t[U]){for(o=++l;i>o&&!P.relative[e[o].type];o++);return m(l>1&&g(h),l>1&&c(e.slice(0,l-1)).replace(oe,"$1"),t,o>l&&d(e.slice(l,o)),i>o&&d(e=e.slice(o)),i>o&&c(e))}h.push(t)}return g(h)}function b(e,n){var t=0,o=n.length>0,a=e.length>0,l=function(i,l,s,p,c){var u,g,m,d=[],b=0,_="0",f=i&&[],w=null!=c,v=C,T=i||a&&P.find.TAG("*",c&&l.parentNode||l),S=F+=null==v?1:Math.random()||.1;for(w&&(C=l!==L&&l,E=t);null!=(u=T[_]);_++){if(a&&u){for(g=0;m=e[g++];)if(m(u,l,s)){p.push(u);break}w&&(F=S,E=++t)}o&&((u=!m&&u)&&b--,i&&f.push(u))}if(b+=_,o&&_!==b){for(g=0;m=n[g++];)m(f,d,l,s);if(i){if(b>0)for(;_--;)f[_]||d[_]||(d[_]=K.call(p));d=h(d)}X.apply(p,d),w&&!i&&d.length>0&&b+n.length>1&&r.uniqueSort(p)}return w&&(F=S,C=v),f};return o?i(l):l}function _(e,n,t){for(var o=0,i=n.length;i>o;o++)r(e,n[o],t);return t}function f(e,n,t,o){var i,a,r,l,s,u=p(e);if(!o&&1===u.length){if(a=u[0]=u[0].slice(0),a.length>2&&"ID"===(r=a[0]).type&&9===n.nodeType&&!y&&P.relative[a[1].type]){if(!(n=P.find.ID(r.matches[0].replace(be,_e),n)[0]))return t;e=e.slice(a.shift().value.length)}for(i=pe.needsContext.test(e)?0:a.length;i--&&(r=a[i],!P.relative[l=r.type]);)if((s=P.find[l])&&(o=s(r.matches[0].replace(be,_e),ce.test(a[0].type)&&n.parentNode||n))){if(a.splice(i,1),!(e=o.length&&c(a)))return X.apply(t,J.call(o,0)),t;break}}return N(e,u)(o,n,y,t,ce.test(e)),t}function w(){}var v,E,P,T,S,N,I,C,G,L,R,y,D,O,x,A,k,U="sizzle"+-new Date,V=e.document,W={},F=0,M=0,H=o(),B=o(),j=o(),$=typeof n,q=1<<31,z=[],K=z.pop,X=z.push,J=z.slice,Y=z.indexOf||function(e){for(var n=0,t=this.length;t>n;n++)if(this[n]===e)return n;return-1},Q="[\\x20\\t\\r\\n\\f]",Z="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",ee=Z.replace("w","w#"),ne="\\["+Q+"*("+Z+")"+Q+"*(?:([*^$|!~]?=)"+Q+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+ee+")|)|)"+Q+"*\\]",te=":("+Z+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+ne.replace(3,8)+")*)|.*)\\)|)",oe=RegExp("^"+Q+"+|((?:^|[^\\\\])(?:\\\\.)*)"+Q+"+$","g"),ie=RegExp("^"+Q+"*,"+Q+"*"),ae=RegExp("^"+Q+"*([\\x20\\t\\r\\n\\f>+~])"+Q+"*"),re=RegExp(te),le=RegExp("^"+ee+"$"),pe={ID:RegExp("^#("+Z+")"),CLASS:RegExp("^\\.("+Z+")"),NAME:RegExp("^\\[name=['\"]?("+Z+")['\"]?\\]"),TAG:RegExp("^("+Z.replace("w","w*")+")"),ATTR:RegExp("^"+ne),PSEUDO:RegExp("^"+te),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+Q+"*(even|odd|(([+-]|)(\\d*)n|)"+Q+"*(?:([+-]|)"+Q+"*(\\d+)|))"+Q+"*\\)|)","i"),needsContext:RegExp("^"+Q+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+Q+"*((?:-\\d)?\\d*)"+Q+"*\\)|)(?=[^-]|$)","i")},ce=/[\x20\t\r\n\f]*[+~]/,ue=/^[^{]+\{\s*\[native code/,ge=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,he=/^(?:input|select|textarea|button)$/i,me=/^h\d$/i,de=/'|\\/g,be=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,_e=function(e,n){var t="0x"+n-65536;return t!==t?n:0>t?String.fromCharCode(t+65536):String.fromCharCode(55296|t>>10,56320|1023&t)};try{J.call(V.documentElement.childNodes,0)[0].nodeType}catch(De){J=function(e){for(var n,t=[];n=this[e++];)t.push(n);return t}}S=r.isXML=function(e){var n=e&&(e.ownerDocument||e).documentElement;return!!n&&"HTML"!==n.nodeName},G=r.setDocument=function(e){var o=e?e.ownerDocument||e:V;return o!==L&&9===o.nodeType&&o.documentElement?(L=o,R=o.documentElement,y=S(o),W.tagNameNoComments=a(function(e){return e.appendChild(o.createComment("")),!e.getElementsByTagName("*").length}),W.attributes=a(function(e){e.innerHTML="<select></select>";var n=typeof e.lastChild.getAttribute("multiple");return"boolean"!==n&&"string"!==n}),W.getByClassName=a(function(e){return e.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",!(!e.getElementsByClassName||!e.getElementsByClassName("e").length)&&(e.lastChild.className="e",2===e.getElementsByClassName("e").length)}),W.getByName=a(function(e){e.id=U+0,e.innerHTML="<a name='"+U+"'></a><div name='"+U+"'></div>",R.insertBefore(e,R.firstChild);var n=o.getElementsByName&&o.getElementsByName(U).length===2+o.getElementsByName(U+0).length;return W.getIdNotName=!o.getElementById(U),R.removeChild(e),n}),P.attrHandle=a(function(e){return e.innerHTML="<a href='#'></a>",e.firstChild&&typeof e.firstChild.getAttribute!==$&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},W.getIdNotName?(P.find.ID=function(e,n){if(typeof n.getElementById!==$&&!y){var t=n.getElementById(e);return t&&t.parentNode?[t]:[]}},P.filter.ID=function(e){var n=e.replace(be,_e);return function(e){return e.getAttribute("id")===n}}):(P.find.ID=function(e,t){if(typeof t.getElementById!==$&&!y){var o=t.getElementById(e);return o?o.id===e||typeof o.getAttributeNode!==$&&o.getAttributeNode("id").value===e?[o]:n:[]}},P.filter.ID=function(e){var n=e.replace(be,_e);return function(e){var t=typeof e.getAttributeNode!==$&&e.getAttributeNode("id");return t&&t.value===n}}),P.find.TAG=W.tagNameNoComments?function(e,t){return typeof t.getElementsByTagName!==$?t.getElementsByTagName(e):n}:function(e,n){var t,o=[],i=0,a=n.getElementsByTagName(e);if("*"===e){for(;t=a[i++];)1===t.nodeType&&o.push(t);return o}return a},P.find.NAME=W.getByName&&function(e,t){return typeof t.getElementsByName!==$?t.getElementsByName(name):n},P.find.CLASS=W.getByClassName&&function(e,t){return typeof t.getElementsByClassName===$||y?n:t.getElementsByClassName(e)},O=[],D=[":focus"],(W.qsa=t(o.querySelectorAll))&&(a(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||D.push("\\["+Q+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||D.push(":checked")}),a(function(e){e.innerHTML="<input type='hidden' i=''/>",e.querySelectorAll("[i^='']").length&&D.push("[*^$]="+Q+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||D.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),D.push(",.*:")})),(W.matchesSelector=t(x=R.matchesSelector||R.mozMatchesSelector||R.webkitMatchesSelector||R.oMatchesSelector||R.msMatchesSelector))&&a(function(e){W.disconnectedMatch=x.call(e,"div"),x.call(e,"[s!='']:x"),O.push("!=",te)}),D=RegExp(D.join("|")),O=RegExp(O.join("|")),A=t(R.contains)||R.compareDocumentPosition?function(e,n){var t=9===e.nodeType?e.documentElement:e,o=n&&n.parentNode;return e===o||!(!o||1!==o.nodeType||!(t.contains?t.contains(o):e.compareDocumentPosition&&16&e.compareDocumentPosition(o)))}:function(e,n){if(n)for(;n=n.parentNode;)if(n===e)return!0;return!1},k=R.compareDocumentPosition?function(e,n){var t;return e===n?(I=!0,0):(t=n.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(n))?1&t||e.parentNode&&11===e.parentNode.nodeType?e===o||A(V,e)?-1:n===o||A(V,n)?1:0:4&t?-1:1:e.compareDocumentPosition?-1:1}:function(e,n){var t,i=0,a=e.parentNode,r=n.parentNode,s=[e],p=[n];if(e===n)return I=!0,0;if(!a||!r)return e===o?-1:n===o?1:a?-1:r?1:0;if(a===r)return l(e,n);for(t=e;t=t.parentNode;)s.unshift(t);for(t=n;t=t.parentNode;)p.unshift(t);for(;s[i]===p[i];)i++;return i?l(s[i],p[i]):s[i]===V?-1:p[i]===V?1:0},I=!1,[0,0].sort(k),W.detectDuplicates=I,L):L},r.matches=function(e,n){return r(e,null,null,n)},r.matchesSelector=function(e,n){if((e.ownerDocument||e)!==L&&G(e),n=n.replace(/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,"='$1']"),!(!W.matchesSelector||y||O&&O.test(n)||D.test(n)))try{var t=x.call(e,n);if(t||W.disconnectedMatch||e.document&&11!==e.document.nodeType)return t}catch(E){}return r(n,L,null,[e]).length>0},r.contains=function(e,n){return(e.ownerDocument||e)!==L&&G(e),A(e,n)},r.attr=function(e,n){var t;return(e.ownerDocument||e)!==L&&G(e),y||(n=n.toLowerCase()),(t=P.attrHandle[n])?t(e):y||W.attributes?e.getAttribute(n):((t=e.getAttributeNode(n))||e.getAttribute(n))&&!0===e[n]?n:t&&t.specified?t.value:null},r.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},r.uniqueSort=function(e){var n,t=[],o=1,i=0;if(I=!W.detectDuplicates,e.sort(k),I){for(;n=e[o];o++)n===e[o-1]&&(i=t.push(o));for(;i--;)e.splice(t[i],1)}return e},T=r.getText=function(e){var n,t="",o=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)t+=T(e)}else if(3===i||4===i)return e.nodeValue}else for(;n=e[o];o++)t+=T(n);return t},P=r.selectors={cacheLength:50,createPseudo:i,match:pe,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(be,_e),e[3]=(e[4]||e[5]||"").replace(be,_e),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||r.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&r.error(e[0]),e},PSEUDO:function(e){var n,t=!e[5]&&e[2];return pe.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:t&&re.test(t)&&(n=p(t,!0))&&(n=t.indexOf(")",t.length-n)-t.length)&&(e[0]=e[0].slice(0,n),e[2]=t.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(be,_e).toLowerCase(),function(n){return n.nodeName&&n.nodeName.toLowerCase()===e})},CLASS:function(e){var n=H[e+" "];return n||(n=RegExp("(^|"+Q+")"+e+"("+Q+"|$)"))&&H(e,function(e){return n.test(e.className||typeof e.getAttribute!==$&&e.getAttribute("class")||"")})},ATTR:function(e,n,t){return function(o){var i=r.attr(o,e);return null==i?"!="===n:!n||(i+="","="===n?i===t:"!="===n?i!==t:"^="===n?t&&0===i.indexOf(t):"*="===n?t&&i.indexOf(t)>-1:"$="===n?t&&i.slice(-t.length)===t:"~="===n?(" "+i+" ").indexOf(t)>-1:"|="===n&&(i===t||i.slice(0,t.length+1)===t+"-"))}},CHILD:function(e,n,t,o,i){var a="nth"!==e.slice(0,3),r="last"!==e.slice(-4),l="of-type"===n;return 1===o&&0===i?function(e){return!!e.parentNode}:function(n,t,s){var p,c,u,g,h,m,d=a!==r?"nextSibling":"previousSibling",b=n.parentNode,_=l&&n.nodeName.toLowerCase(),f=!s&&!l;if(b){if(a){for(;d;){for(u=n;u=u[d];)if(l?u.nodeName.toLowerCase()===_:1===u.nodeType)return!1;m=d="only"===e&&!m&&"nextSibling"}return!0}if(m=[r?b.firstChild:b.lastChild],r&&f){for(c=b[U]||(b[U]={}),p=c[e]||[],h=p[0]===F&&p[1],g=p[0]===F&&p[2],u=h&&b.childNodes[h];u=++h&&u&&u[d]||(g=h=0)||m.pop();)if(1===u.nodeType&&++g&&u===n){c[e]=[F,h,g];break}}else if(f&&(p=(n[U]||(n[U]={}))[e])&&p[0]===F)g=p[1];else for(;(u=++h&&u&&u[d]||(g=h=0)||m.pop())&&((l?u.nodeName.toLowerCase()!==_:1!==u.nodeType)||!++g||(f&&((u[U]||(u[U]={}))[e]=[F,g]),u!==n)););return(g-=i)===o||0==g%o&&g/o>=0}}},PSEUDO:function(e,n){var t,o=P.pseudos[e]||P.setFilters[e.toLowerCase()]||r.error("unsupported pseudo: "+e);return o[U]?o(n):o.length>1?(t=[e,e,"",n],P.setFilters.hasOwnProperty(e.toLowerCase())?i(function(e,t){for(var i,a=o(e,n),r=a.length;r--;)i=Y.call(e,a[r]),e[i]=!(t[i]=a[r])}):function(e){return o(e,0,t)}):o}},pseudos:{not:i(function(e){var n=[],t=[],o=N(e.replace(oe,"$1"));return o[U]?i(function(e,n,t,i){for(var a,r=o(e,null,i,[]),l=e.length;l--;)(a=r[l])&&(e[l]=!(n[l]=a))}):function(e,i,a){return n[0]=e,o(n,null,a,t),!t.pop()}}),has:i(function(e){return function(n){return r(e,n).length>0}}),contains:i(function(e){return function(n){return(n.textContent||n.innerText||T(n)).indexOf(e)>-1}}),lang:i(function(e){return le.test(e||"")||r.error("unsupported lang: "+e),e=e.replace(be,_e).toLowerCase(),function(n){var t;do{if(t=y?n.getAttribute("xml:lang")||n.getAttribute("lang"):n.lang)return(t=t.toLowerCase())===e||0===t.indexOf(e+"-")}while((n=n.parentNode)&&1===n.nodeType);return!1}}),target:function(n){var t=e.location&&e.location.hash;return t&&t.slice(1)===n.id},root:function(e){return e===R},focus:function(e){return e===L.activeElement&&(!L.hasFocus||L.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return!1===e.disabled},disabled:function(e){return!0===e.disabled},checked:function(e){var n=e.nodeName.toLowerCase();return"input"===n&&!!e.checked||"option"===n&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!P.pseudos.empty(e)},header:function(e){return me.test(e.nodeName)},input:function(e){return he.test(e.nodeName)},button:function(e){var n=e.nodeName.toLowerCase();return"input"===n&&"button"===e.type||"button"===n},text:function(e){var n;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(n=e.getAttribute("type"))||n.toLowerCase()===e.type)},first:s(function(){return[0]}),last:s(function(e,n){return[n-1]}),eq:s(function(e,n,t){return[0>t?t+n:t]}),even:s(function(e,n){for(var t=0;n>t;t+=2)e.push(t);return e}),odd:s(function(e,n){for(var t=1;n>t;t+=2)e.push(t);return e}),lt:s(function(e,n,t){for(var o=0>t?t+n:t;--o>=0;)e.push(o);return e}),gt:s(function(e,n,t){for(var o=0>t?t+n:t;n>++o;)e.push(o);return e})}};for(v in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})P.pseudos[v]=function(e){return function(n){return"input"===n.nodeName.toLowerCase()&&n.type===e}}(v);for(v in{submit:!0,reset:!0})P.pseudos[v]=function(e){return function(n){var t=n.nodeName.toLowerCase();return("input"===t||"button"===t)&&n.type===e}}(v);N=r.compile=function(e,n){var t,o=[],i=[],a=j[e+" "];if(!a){for(n||(n=p(e)),t=n.length;t--;)a=d(n[t]),a[U]?o.push(a):i.push(a);a=j(e,b(i,o))}return a},P.pseudos.nth=P.pseudos.eq,P.filters=w.prototype=P.pseudos,P.setFilters=new w,G(),r.attr=se.attr,se.find=r,se.expr=r.selectors,se.expr[":"]=se.expr.pseudos,se.unique=r.uniqueSort,se.text=r.getText,se.isXMLDoc=r.isXML,se.contains=r.contains}(e);var xe=/Until$/,Ae=/^(?:parents|prev(?:Until|All))/,ke=/^.[^:#\[\.,]*$/,Ue=se.expr.match.needsContext,Ve={children:!0,contents:!0,next:!0,prev:!0};se.fn.extend({find:function(e){var n,t,o,i=this.length;if("string"!=typeof e)return o=this,this.pushStack(se(e).filter(function(){for(n=0;i>n;n++)if(se.contains(o[n],this))return!0}));for(t=[],n=0;i>n;n++)se.find(e,this[n],t);return t=this.pushStack(i>1?se.unique(t):t),t.selector=(this.selector?this.selector+" ":"")+e,t},has:function(e){var n,t=se(e,this),o=t.length;return this.filter(function(){for(n=0;o>n;n++)if(se.contains(this,t[n]))return!0})},not:function(e){return this.pushStack(u(this,e,!1))},filter:function(e){return this.pushStack(u(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?Ue.test(e)?se(e,this.context).index(this[0])>=0:se.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,n){for(var t,o=0,i=this.length,a=[],r=Ue.test(e)||"string"!=typeof e?se(e,n||this.context):0;i>o;o++)for(t=this[o];t&&t.ownerDocument&&t!==n&&11!==t.nodeType;){if(r?r.index(t)>-1:se.find.matchesSelector(t,e)){a.push(t);break}t=t.parentNode}return this.pushStack(a.length>1?se.unique(a):a)},index:function(e){return e?"string"==typeof e?se.inArray(this[0],se(e)):se.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,n){var t="string"==typeof e?se(e,n):se.makeArray(e&&e.nodeType?[e]:e),o=se.merge(this.get(),t);return this.pushStack(se.unique(o))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),se.fn.andSelf=se.fn.addBack,se.each({parent:function(e){var n=e.parentNode;return n&&11!==n.nodeType?n:null},parents:function(e){return se.dir(e,"parentNode")},parentsUntil:function(e,n,t){return se.dir(e,"parentNode",t)},next:function(e){return c(e,"nextSibling")},prev:function(e){return c(e,"previousSibling")},nextAll:function(e){return se.dir(e,"nextSibling")},prevAll:function(e){return se.dir(e,"previousSibling")},nextUntil:function(e,n,t){return se.dir(e,"nextSibling",t)},prevUntil:function(e,n,t){return se.dir(e,"previousSibling",t)},siblings:function(e){return se.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return se.sibling(e.firstChild)},contents:function(e){return se.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:se.merge([],e.childNodes)}},function(e,n){se.fn[e]=function(t,o){var i=se.map(this,n,t);return xe.test(e)||(o=t),o&&"string"==typeof o&&(i=se.filter(o,i)),i=this.length>1&&!Ve[e]?se.unique(i):i,this.length>1&&Ae.test(e)&&(i=i.reverse()),this.pushStack(i)}}),se.extend({filter:function(e,n,t){return t&&(e=":not("+e+")"),1===n.length?se.find.matchesSelector(n[0],e)?[n[0]]:[]:se.find.matches(e,n)},dir:function(e,t,o){for(var i=[],a=e[t];a&&9!==a.nodeType&&(o===n||1!==a.nodeType||!se(a).is(o));)1===a.nodeType&&i.push(a),a=a[t];return i},sibling:function(e,n){for(var t=[];e;e=e.nextSibling)1===e.nodeType&&e!==n&&t.push(e);return t}});var We="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Fe=RegExp("<(?:"+We+")[\\s/>]","i"),Me=/^\s+/,He=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Be=/<([\w:]+)/,je=/<tbody/i,$e=/<|&#?\w+;/,qe=/<(?:script|style|link)/i,ze=/^(?:checkbox|radio)$/i,Ke=/checked\s*(?:[^=]|=\s*.checked.)/i,Xe=/^$|\/(?:java|ecma)script/i,Je=/^true\/(.*)/,Ye={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:se.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},Qe=g(K),Ze=Qe.appendChild(K.createElement("div"));Ye.optgroup=Ye.option,Ye.tbody=Ye.tfoot=Ye.colgroup=Ye.caption=Ye.thead,Ye.th=Ye.td,se.fn.extend({text:function(e){return se.access(this,function(e){return e===n?se.text(this):this.empty().append((this[0]&&this[0].ownerDocument||K).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(se.isFunction(e))return this.each(function(n){se(this).wrapAll(e.call(this,n))});if(this[0]){var n=se(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&n.insertBefore(this[0]),n.map(function(){for(var e=this;e.firstChild&&1===e.firstChild.nodeType;)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return se.isFunction(e)?this.each(function(n){se(this).wrapInner(e.call(this,n))}):this.each(function(){var n=se(this),t=n.contents();t.length?t.wrapAll(e):n.append(e)})},wrap:function(e){var n=se.isFunction(e);return this.each(function(t){se(this).wrapAll(n?e.call(this,t):e)})},unwrap:function(){return this.parent().each(function(){se.nodeName(this,"body")||se(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,n){for(var t,o=0;null!=(t=this[o]);o++)(!e||se.filter(e,[t]).length>0)&&(n||1!==t.nodeType||se.cleanData(w(t)),t.parentNode&&(n&&se.contains(t.ownerDocument,t)&&b(w(t,"script")),t.parentNode.removeChild(t)));return this},empty:function(){
for(var e,n=0;null!=(e=this[n]);n++){for(1===e.nodeType&&se.cleanData(w(e,!1));e.firstChild;)e.removeChild(e.firstChild);e.options&&se.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,n){return e=null!=e&&e,n=null==n?e:n,this.map(function(){return se.clone(this,e,n)})},html:function(e){return se.access(this,function(e){var t=this[0]||{},o=0,i=this.length;if(e===n)return 1===t.nodeType?t.innerHTML.replace(/ jQuery\d+="(?:null|\d+)"/g,""):n;if(!("string"!=typeof e||qe.test(e)||!se.support.htmlSerialize&&Fe.test(e)||!se.support.leadingWhitespace&&Me.test(e)||Ye[(Be.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(He,"<$1></$2>");try{for(;i>o;o++)t=this[o]||{},1===t.nodeType&&(se.cleanData(w(t,!1)),t.innerHTML=e);t=0}catch(K){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){return se.isFunction(e)||"string"==typeof e||(e=se(e).not(this).detach()),this.domManip([e],!0,function(e){var n=this.nextSibling,t=this.parentNode;t&&(se(this).remove(),t.insertBefore(e,n))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,o){e=ne.apply([],e);var i,a,r,l,s,p,c=0,u=this.length,g=this,b=u-1,_=e[0],f=se.isFunction(_);if(f||!(1>=u||"string"!=typeof _||se.support.checkClone)&&Ke.test(_))return this.each(function(i){var a=g.eq(i);f&&(e[0]=_.call(this,i,t?a.html():n)),a.domManip(e,t,o)});if(u&&(p=se.buildFragment(e,this[0].ownerDocument,!1,this),i=p.firstChild,1===p.childNodes.length&&(p=i),i)){for(t=t&&se.nodeName(i,"tr"),l=se.map(w(p,"script"),m),r=l.length;u>c;c++)a=p,c!==b&&(a=se.clone(a,!0,!0),r&&se.merge(l,w(a,"script"))),o.call(t&&se.nodeName(this[c],"table")?h(this[c],"tbody"):this[c],a,c);if(r)for(s=l[l.length-1].ownerDocument,se.map(l,d),c=0;r>c;c++)a=l[c],Xe.test(a.type||"")&&!se._data(a,"globalEval")&&se.contains(s,a)&&(a.src?se.ajax({url:a.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):se.globalEval((a.text||a.textContent||a.innerHTML||"").replace(/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,"")));p=i=null}return this}}),se.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,n){se.fn[e]=function(e){for(var t,o=0,i=[],a=se(e),r=a.length-1;r>=o;o++)t=o===r?this:this.clone(!0),se(a[o])[n](t),te.apply(i,t.get());return this.pushStack(i)}}),se.extend({clone:function(e,n,t){var o,i,a,r,l,s=se.contains(e.ownerDocument,e);if(se.support.html5Clone||se.isXMLDoc(e)||!Fe.test("<"+e.nodeName+">")?a=e.cloneNode(!0):(Ze.innerHTML=e.outerHTML,Ze.removeChild(a=Ze.firstChild)),!(se.support.noCloneEvent&&se.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||se.isXMLDoc(e)))for(o=w(a),l=w(e),r=0;null!=(i=l[r]);++r)o[r]&&f(i,o[r]);if(n)if(t)for(l=l||w(e),o=o||w(a),r=0;null!=(i=l[r]);r++)_(i,o[r]);else _(e,a);return o=w(a,"script"),o.length>0&&b(o,!s&&w(e,"script")),o=l=i=null,a},buildFragment:function(e,n,t,o){for(var i,a,r,l,s,p,c,u=e.length,h=g(n),m=[],d=0;u>d;d++)if((a=e[d])||0===a)if("object"===se.type(a))se.merge(m,a.nodeType?[a]:a);else if($e.test(a)){for(l=l||h.appendChild(n.createElement("div")),s=(Be.exec(a)||["",""])[1].toLowerCase(),c=Ye[s]||Ye._default,l.innerHTML=c[1]+a.replace(He,"<$1></$2>")+c[2],i=c[0];i--;)l=l.lastChild;if(!se.support.leadingWhitespace&&Me.test(a)&&m.push(n.createTextNode(Me.exec(a)[0])),!se.support.tbody)for(a="table"!==s||je.test(a)?"<table>"!==c[1]||je.test(a)?0:l:l.firstChild,i=a&&a.childNodes.length;i--;)se.nodeName(p=a.childNodes[i],"tbody")&&!p.childNodes.length&&a.removeChild(p);for(se.merge(m,l.childNodes),l.textContent="";l.firstChild;)l.removeChild(l.firstChild);l=h.lastChild}else m.push(n.createTextNode(a));for(l&&h.removeChild(l),se.support.appendChecked||se.grep(w(m,"input"),v),d=0;a=m[d++];)if((!o||-1===se.inArray(a,o))&&(r=se.contains(a.ownerDocument,a),l=w(h.appendChild(a),"script"),r&&b(l),t))for(i=0;a=l[i++];)Xe.test(a.type||"")&&t.push(a);return l=null,h},cleanData:function(e,n){for(var t,o,i,a,r=0,l=se.expando,s=se.cache,p=se.support.deleteExpando,c=se.event.special;null!=(t=e[r]);r++)if((n||se.acceptData(t))&&(i=t[l],a=i&&s[i])){if(a.events)for(o in a.events)c[o]?se.event.remove(t,o):se.removeEvent(t,o,a.handle);s[i]&&(delete s[i],p?delete t[l]:typeof t.removeAttribute!==z?t.removeAttribute(l):t[l]=null,Z.push(i))}}});var en,nn,tn,on=/alpha\([^)]*\)/i,an=/opacity\s*=\s*([^)]*)/,rn=/^(top|right|bottom|left)$/,ln=/^(none|table(?!-c[ea]).+)/,sn=/^margin/,pn=RegExp("^("+pe+")(.*)$","i"),cn=RegExp("^("+pe+")(?!px)[a-z%]+$","i"),un=RegExp("^([+-])=("+pe+")","i"),gn={BODY:"block"},hn={position:"absolute",visibility:"hidden",display:"block"},mn={letterSpacing:0,fontWeight:400},dn=["Top","Right","Bottom","Left"],bn=["Webkit","O","Moz","ms"];se.fn.extend({css:function(e,t){return se.access(this,function(e,t,o){var i,a,r={},l=0;if(se.isArray(t)){for(a=nn(e),i=t.length;i>l;l++)r[t[l]]=se.css(e,t[l],!1,a);return r}return o!==n?se.style(e,t,o):se.css(e,t)},e,t,arguments.length>1)},show:function(){return T(this,!0)},hide:function(){return T(this)},toggle:function(e){var n="boolean"==typeof e;return this.each(function(){(n?e:P(this))?se(this).show():se(this).hide()})}}),se.extend({cssHooks:{opacity:{get:function(e,n){if(n){var t=tn(e,"opacity");return""===t?"1":t}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":se.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,t,o,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var a,r,l,s=se.camelCase(t),p=e.style;if(t=se.cssProps[s]||(se.cssProps[s]=E(p,s)),l=se.cssHooks[t]||se.cssHooks[s],o===n)return l&&"get"in l&&(a=l.get(e,!1,i))!==n?a:p[t];if(r=typeof o,"string"===r&&(a=un.exec(o))&&(o=(a[1]+1)*a[2]+parseFloat(se.css(e,t)),r="number"),!(null==o||"number"===r&&isNaN(o)||("number"!==r||se.cssNumber[s]||(o+="px"),se.support.clearCloneStyle||""!==o||0!==t.indexOf("background")||(p[t]="inherit"),l&&"set"in l&&(o=l.set(e,o,i))===n)))try{p[t]=o}catch(Z){}}},css:function(e,t,o,i){var a,r,l,s=se.camelCase(t);return t=se.cssProps[s]||(se.cssProps[s]=E(e.style,s)),l=se.cssHooks[t]||se.cssHooks[s],l&&"get"in l&&(r=l.get(e,!0,o)),r===n&&(r=tn(e,t,i)),"normal"===r&&t in mn&&(r=mn[t]),""===o||o?(a=parseFloat(r),!0===o||se.isNumeric(a)?a||0:r):r},swap:function(e,n,t,o){var i,a,r={};for(a in n)r[a]=e.style[a],e.style[a]=n[a];i=t.apply(e,o||[]);for(a in n)e.style[a]=r[a];return i}}),e.getComputedStyle?(nn=function(n){return e.getComputedStyle(n,null)},tn=function(e,t,o){var i,a,r,l=o||nn(e),s=l?l.getPropertyValue(t)||l[t]:n,p=e.style;return l&&(""!==s||se.contains(e.ownerDocument,e)||(s=se.style(e,t)),cn.test(s)&&sn.test(t)&&(i=p.width,a=p.minWidth,r=p.maxWidth,p.minWidth=p.maxWidth=p.width=s,s=l.width,p.width=i,p.minWidth=a,p.maxWidth=r)),s}):K.documentElement.currentStyle&&(nn=function(e){return e.currentStyle},tn=function(e,t,o){var i,a,r,l=o||nn(e),s=l?l[t]:n,p=e.style;return null==s&&p&&p[t]&&(s=p[t]),cn.test(s)&&!rn.test(t)&&(i=p.left,a=e.runtimeStyle,r=a&&a.left,r&&(a.left=e.currentStyle.left),p.left="fontSize"===t?"1em":s,s=p.pixelLeft+"px",p.left=i,r&&(a.left=r)),""===s?"auto":s}),se.each(["height","width"],function(e,t){se.cssHooks[t]={get:function(e,o,i){return o?0===e.offsetWidth&&ln.test(se.css(e,"display"))?se.swap(e,hn,function(){return I(e,t,i)}):I(e,t,i):n},set:function(e,n,o){var i=o&&nn(e);return S(e,n,o?N(e,t,o,se.support.boxSizing&&"border-box"===se.css(e,"boxSizing",!1,i),i):0)}}}),se.support.opacity||(se.cssHooks.opacity={get:function(e,n){return an.test((n&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":n?"1":""},set:function(e,n){var t=e.style,o=e.currentStyle,i=se.isNumeric(n)?"alpha(opacity="+100*n+")":"",a=o&&o.filter||t.filter||"";t.zoom=1,(n>=1||""===n)&&""===se.trim(a.replace(on,""))&&t.removeAttribute&&(t.removeAttribute("filter"),""===n||o&&!o.filter)||(t.filter=on.test(a)?a.replace(on,i):a+" "+i)}}),se(function(){se.support.reliableMarginRight||(se.cssHooks.marginRight={get:function(e,t){return t?se.swap(e,{display:"inline-block"},tn,[e,"marginRight"]):n}}),!se.support.pixelPosition&&se.fn.position&&se.each(["top","left"],function(e,t){se.cssHooks[t]={get:function(e,o){return o?(o=tn(e,t),cn.test(o)?se(e).position()[t]+"px":o):n}}})}),se.expr&&se.expr.filters&&(se.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!se.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||se.css(e,"display"))},se.expr.filters.visible=function(e){return!se.expr.filters.hidden(e)}),se.each({margin:"",padding:"",border:"Width"},function(e,n){se.cssHooks[e+n]={expand:function(t){for(var o=0,i={},a="string"==typeof t?t.split(" "):[t];4>o;o++)i[e+dn[o]+n]=a[o]||a[o-2]||a[0];return i}},sn.test(e)||(se.cssHooks[e+n].set=S)});var _n=/\[\]$/,fn=/^(?:submit|button|image|reset|file)$/i,wn=/^(?:input|select|textarea|keygen)/i;se.fn.extend({serialize:function(){return se.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=se.prop(this,"elements");return e?se.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!se(this).is(":disabled")&&wn.test(this.nodeName)&&!fn.test(e)&&(this.checked||!ze.test(e))}).map(function(e,n){var t=se(this).val();return null==t?null:se.isArray(t)?se.map(t,function(e){return{name:n.name,value:e.replace(/\r?\n/g,"\r\n")}}):{name:n.name,value:t.replace(/\r?\n/g,"\r\n")}}).get()}}),se.param=function(e,t){var o,i=[],a=function(e,n){n=se.isFunction(n)?n():null==n?"":n,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(n)};if(t===n&&(t=se.ajaxSettings&&se.ajaxSettings.traditional),se.isArray(e)||e.jquery&&!se.isPlainObject(e))se.each(e,function(){a(this.name,this.value)});else for(o in e)L(o,e[o],t,a);return i.join("&").replace(/%20/g,"+")},se.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,n){se.fn[n]=function(e,t){return arguments.length>0?this.on(n,null,e,t):this.trigger(n)}}),se.fn.hover=function(e,n){return this.mouseenter(e).mouseleave(n||e)};var vn,En,Pn=se.now(),Tn=/\?/,Sn=/([?&])_=[^&]*/,Nn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,In=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Cn=/^(?:GET|HEAD)$/,Gn=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Ln=se.fn.load,Rn={},yn={},Dn="*/".concat("*");try{En=X.href}catch(qn){En=K.createElement("a"),En.href="",En=En.href}vn=Gn.exec(En.toLowerCase())||[],se.fn.load=function(e,t,o){if("string"!=typeof e&&Ln)return Ln.apply(this,arguments);var i,a,r,l=this,s=e.indexOf(" ");return s>=0&&(i=e.slice(s,e.length),e=e.slice(0,s)),se.isFunction(t)?(o=t,t=n):t&&"object"==typeof t&&(r="POST"),l.length>0&&se.ajax({url:e,type:r,dataType:"html",data:t}).done(function(e){a=arguments,l.html(i?se("<div>").append(se.parseHTML(e)).find(i):e)}).complete(o&&function(e,n){l.each(o,a||[e.responseText,n,e])}),this},se.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,n){se.fn[n]=function(e){return this.on(n,e)}}),se.each(["get","post"],function(e,t){se[t]=function(e,o,i,a){return se.isFunction(o)&&(a=a||i,i=o,o=n),se.ajax({url:e,type:t,dataType:a,data:o,success:i})}}),se.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:En,type:"GET",isLocal:In.test(vn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":se.parseJSON,"text xml":se.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,n){return n?D(D(e,se.ajaxSettings),n):D(se.ajaxSettings,e)},ajaxPrefilter:R(Rn),ajaxTransport:R(yn),ajax:function(e,t){function o(e,t,o,i){var a,u,f,w,E,T=t;2!==v&&(v=2,s&&clearTimeout(s),c=n,l=i||"",P.readyState=e>0?4:0,o&&(w=O(g,P,o)),e>=200&&300>e||304===e?(g.ifModified&&(E=P.getResponseHeader("Last-Modified"),E&&(se.lastModified[r]=E),(E=P.getResponseHeader("etag"))&&(se.etag[r]=E)),204===e?(a=!0,T="nocontent"):304===e?(a=!0,T="notmodified"):(a=x(g,w),T=a.state,u=a.data,f=a.error,a=!f)):(f=T,(e||!T)&&(T="error",0>e&&(e=0))),P.status=e,P.statusText=(t||T)+"",a?d.resolveWith(h,[u,T,P]):d.rejectWith(h,[P,T,f]),P.statusCode(_),_=n,p&&m.trigger(a?"ajaxSuccess":"ajaxError",[P,g,a?u:f]),b.fireWith(h,[P,T]),p&&(m.trigger("ajaxComplete",[P,g]),--se.active||se.event.trigger("ajaxStop")))}"object"==typeof e&&(t=e,e=n),t=t||{};var i,a,r,l,s,p,c,u,g=se.ajaxSetup({},t),h=g.context||g,m=g.context&&(h.nodeType||h.jquery)?se(h):se.event,d=se.Deferred(),b=se.Callbacks("once memory"),_=g.statusCode||{},f={},w={},v=0,E="canceled",P={readyState:0,getResponseHeader:function(e){var n;if(2===v){if(!u)for(u={};n=Nn.exec(l);)u[n[1].toLowerCase()]=n[2];n=u[e.toLowerCase()]}return null==n?null:n},getAllResponseHeaders:function(){return 2===v?l:null},setRequestHeader:function(e,n){var t=e.toLowerCase();return v||(e=w[t]=w[t]||e,f[e]=n),this},overrideMimeType:function(e){return v||(g.mimeType=e),this},statusCode:function(e){var n;if(e)if(2>v)for(n in e)_[n]=[_[n],e[n]];else P.always(e[P.status]);return this},abort:function(e){var n=e||E;return c&&c.abort(n),o(0,n),this}};if(d.promise(P).complete=b.add,P.success=P.done,P.error=P.fail,g.url=((e||g.url||En)+"").replace(/#.*$/,"").replace(/^\/\//,vn[1]+"//"),g.type=t.method||t.type||g.method||g.type,g.dataTypes=se.trim(g.dataType||"*").toLowerCase().match(ce)||[""],null==g.crossDomain&&(i=Gn.exec(g.url.toLowerCase()),g.crossDomain=!(!i||i[1]===vn[1]&&i[2]===vn[2]&&(i[3]||("http:"===i[1]?80:443))==(vn[3]||("http:"===vn[1]?80:443)))),g.data&&g.processData&&"string"!=typeof g.data&&(g.data=se.param(g.data,g.traditional)),y(Rn,g,t,P),2===v)return P;p=g.global,p&&0==se.active++&&se.event.trigger("ajaxStart"),g.type=g.type.toUpperCase(),g.hasContent=!Cn.test(g.type),r=g.url,g.hasContent||(g.data&&(r=g.url+=(Tn.test(r)?"&":"?")+g.data,delete g.data),!1===g.cache&&(g.url=Sn.test(r)?r.replace(Sn,"$1_="+Pn++):r+(Tn.test(r)?"&":"?")+"_="+Pn++)),g.ifModified&&(se.lastModified[r]&&P.setRequestHeader("If-Modified-Since",se.lastModified[r]),se.etag[r]&&P.setRequestHeader("If-None-Match",se.etag[r])),(g.data&&g.hasContent&&!1!==g.contentType||t.contentType)&&P.setRequestHeader("Content-Type",g.contentType),P.setRequestHeader("Accept",g.dataTypes[0]&&g.accepts[g.dataTypes[0]]?g.accepts[g.dataTypes[0]]+("*"!==g.dataTypes[0]?", "+Dn+"; q=0.01":""):g.accepts["*"]);for(a in g.headers)P.setRequestHeader(a,g.headers[a]);if(g.beforeSend&&(!1===g.beforeSend.call(h,P,g)||2===v))return P.abort();E="abort";for(a in{success:1,error:1,complete:1})P[a](g[a]);if(c=y(yn,g,t,P)){P.readyState=1,p&&m.trigger("ajaxSend",[P,g]),g.async&&g.timeout>0&&(s=setTimeout(function(){P.abort("timeout")},g.timeout));try{v=1,c.send(f,o)}catch(ge){if(!(2>v))throw ge;o(-1,ge)}}else o(-1,"No Transport");return P},getScript:function(e,t){return se.get(e,n,t,"script")},getJSON:function(e,n,t){return se.get(e,n,t,"json")}}),se.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return se.globalEval(e),e}}}),se.ajaxPrefilter("script",function(e){e.cache===n&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),se.ajaxTransport("script",function(e){if(e.crossDomain){var t,o=K.head||se("head")[0]||K.documentElement;return{send:function(n,i){t=K.createElement("script"),t.async=!0,e.scriptCharset&&(t.charset=e.scriptCharset),t.src=e.url,t.onload=t.onreadystatechange=function(e,n){(n||!t.readyState||/loaded|complete/.test(t.readyState))&&(t.onload=t.onreadystatechange=null,t.parentNode&&t.parentNode.removeChild(t),t=null,n||i(200,"success"))},o.insertBefore(t,o.firstChild)},abort:function(){t&&t.onload(n,!0)}}}});var On=[],xn=/(=)\?(?=&|$)|\?\?/;se.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=On.pop()||se.expando+"_"+Pn++;return this[e]=!0,e}}),se.ajaxPrefilter("json jsonp",function(t,o,i){var a,r,l,s=!1!==t.jsonp&&(xn.test(t.url)?"url":"string"==typeof t.data&&!(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&xn.test(t.data)&&"data");return s||"jsonp"===t.dataTypes[0]?(a=t.jsonpCallback=se.isFunction(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,s?t[s]=t[s].replace(xn,"$1"+a):!1!==t.jsonp&&(t.url+=(Tn.test(t.url)?"&":"?")+t.jsonp+"="+a),t.converters["script json"]=function(){return l||se.error(a+" was not called"),l[0]},t.dataTypes[0]="json",r=e[a],e[a]=function(){l=arguments},i.always(function(){e[a]=r,t[a]&&(t.jsonpCallback=o.jsonpCallback,On.push(a)),l&&se.isFunction(r)&&r(l[0]),l=r=n}),"script"):n});var An,kn,Un=0,Vn=e.ActiveXObject&&function(){var e;for(e in An)An[e](n,!0)};se.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&A()||k()}:A,kn=se.ajaxSettings.xhr(),se.support.cors=!!kn&&"withCredentials"in kn,(kn=se.support.ajax=!!kn)&&se.ajaxTransport(function(t){if(!t.crossDomain||se.support.cors){var o;return{send:function(i,a){var r,l,s=t.xhr();if(t.username?s.open(t.type,t.url,t.async,t.username,t.password):s.open(t.type,t.url,t.async),t.xhrFields)for(l in t.xhrFields)s[l]=t.xhrFields[l];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(l in i)s.setRequestHeader(l,i[l])}catch(Q){}s.send(t.hasContent&&t.data||null),o=function(e,i){var l,p,c,u;try{if(o&&(i||4===s.readyState))if(o=n,r&&(s.onreadystatechange=se.noop,Vn&&delete An[r]),i)4!==s.readyState&&s.abort();else{u={},l=s.status,p=s.getAllResponseHeaders(),"string"==typeof s.responseText&&(u.text=s.responseText);try{c=s.statusText}catch(ne){c=""}l||!t.isLocal||t.crossDomain?1223===l&&(l=204):l=u.text?200:404}}catch(te){i||a(-1,te)}u&&a(l,c,u,p)},t.async?4===s.readyState?setTimeout(o):(r=++Un,Vn&&(An||(An={},se(e).unload(Vn)),An[r]=o),s.onreadystatechange=o):o()},abort:function(){o&&o(n,!0)}}}});var Wn,Fn,Mn=/^(?:toggle|show|hide)$/,Hn=RegExp("^(?:([+-])=|)("+pe+")([a-z%]*)$","i"),Bn=/queueHooks$/,jn=[M],$n={"*":[function(e,n){var t,o,i=this.createTween(e,n),a=Hn.exec(n),r=i.cur(),l=+r||0,s=1,p=20;if(a){if(t=+a[2],"px"!==(o=a[3]||(se.cssNumber[e]?"":"px"))&&l){l=se.css(i.elem,e,!0)||t||1;do{s=s||".5",l/=s,se.style(i.elem,e,l+o)}while(s!==(s=i.cur()/r)&&1!==s&&--p)}i.unit=o,i.start=l,i.end=a[1]?l+(a[1]+1)*t:t}return i}]};se.Animation=se.extend(W,{tweener:function(e,n){se.isFunction(e)?(n=e,e=["*"]):e=e.split(" ");for(var t,o=0,i=e.length;i>o;o++)t=e[o],$n[t]=$n[t]||[],$n[t].unshift(n)},prefilter:function(e,n){n?jn.unshift(e):jn.push(e)}}),se.Tween=H,H.prototype={constructor:H,init:function(e,n,t,o,i,a){this.elem=e,this.prop=t,this.easing=i||"swing",this.options=n,this.start=this.now=this.cur(),this.end=o,this.unit=a||(se.cssNumber[t]?"":"px")},cur:function(){var e=H.propHooks[this.prop];return e&&e.get?e.get(this):H.propHooks._default.get(this)},run:function(e){var n,t=H.propHooks[this.prop];return this.pos=n=this.options.duration?se.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*n+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),t&&t.set?t.set(this):H.propHooks._default.set(this),this}},H.prototype.init.prototype=H.prototype,H.propHooks={_default:{get:function(e){var n;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(n=se.css(e.elem,e.prop,""),n&&"auto"!==n?n:0):e.elem[e.prop]},set:function(e){se.fx.step[e.prop]?se.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[se.cssProps[e.prop]]||se.cssHooks[e.prop])?se.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},H.propHooks.scrollTop=H.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},se.each(["toggle","show","hide"],function(e,n){var t=se.fn[n];se.fn[n]=function(e,o,i){return null==e||"boolean"==typeof e?t.apply(this,arguments):this.animate(B(n,!0),e,o,i)}}),se.fn.extend({fadeTo:function(e,n,t,o){return this.filter(P).css("opacity",0).show().end().animate({opacity:n},e,t,o)},animate:function(e,n,t,o){var i=se.isEmptyObject(e),a=se.speed(n,t,o),r=function(){var n=W(this,se.extend({},e),a);r.finish=function(){n.stop(!0)},(i||se._data(this,"finish"))&&n.stop(!0)};return r.finish=r,i||!1===a.queue?this.each(r):this.queue(a.queue,r)},stop:function(e,t,o){var i=function(e){var n=e.stop;delete e.stop,n(o)};return"string"!=typeof e&&(o=t,t=e,e=n),t&&!1!==e&&this.queue(e||"fx",[]),this.each(function(){var n=!0,t=null!=e&&e+"queueHooks",a=se.timers,r=se._data(this);if(t)r[t]&&r[t].stop&&i(r[t]);else for(t in r)r[t]&&r[t].stop&&Bn.test(t)&&i(r[t]);for(t=a.length;t--;)a[t].elem!==this||null!=e&&a[t].queue!==e||(a[t].anim.stop(o),n=!1,a.splice(t,1));(n||!o)&&se.dequeue(this,e)})},finish:function(e){return!1!==e&&(e=e||"fx"),this.each(function(){var n,t=se._data(this),o=t[e+"queue"],i=t[e+"queueHooks"],a=se.timers,r=o?o.length:0;for(t.finish=!0,se.queue(this,e,[]),i&&i.cur&&i.cur.finish&&i.cur.finish.call(this),n=a.length;n--;)a[n].elem===this&&a[n].queue===e&&(a[n].anim.stop(!0),a.splice(n,1));for(n=0;r>n;n++)o[n]&&o[n].finish&&o[n].finish.call(this);delete t.finish})}}),se.each({slideDown:B("show"),slideUp:B("hide"),slideToggle:B("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,n){se.fn[e]=function(e,t,o){return this.animate(n,e,t,o)}}),se.speed=function(e,n,t){var o=e&&"object"==typeof e?se.extend({},e):{complete:t||!t&&n||se.isFunction(e)&&e,duration:e,easing:t&&n||n&&!se.isFunction(n)&&n};return o.duration=se.fx.off?0:"number"==typeof o.duration?o.duration:o.duration in se.fx.speeds?se.fx.speeds[o.duration]:se.fx.speeds._default,(null==o.queue||!0===o.queue)&&(o.queue="fx"),o.old=o.complete,o.complete=function(){se.isFunction(o.old)&&o.old.call(this),o.queue&&se.dequeue(this,o.queue)},o},se.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},se.timers=[],se.fx=H.prototype.init,se.fx.tick=function(){var e,t=se.timers,o=0;for(Wn=se.now();t.length>o;o++)(e=t[o])()||t[o]!==e||t.splice(o--,1);t.length||se.fx.stop(),Wn=n},se.fx.timer=function(e){e()&&se.timers.push(e)&&se.fx.start()},se.fx.interval=13,se.fx.start=function(){Fn||(Fn=setInterval(se.fx.tick,se.fx.interval))},se.fx.stop=function(){clearInterval(Fn),Fn=null},se.fx.speeds={slow:600,fast:200,_default:400},se.fx.step={},se.expr&&se.expr.filters&&(se.expr.filters.animated=function(e){return se.grep(se.timers,function(n){return e===n.elem}).length}),se.fn.offset=function(e){if(arguments.length)return e===n?this:this.each(function(n){se.offset.setOffset(this,e,n)});var t,o,i={top:0,left:0},a=this[0],r=a&&a.ownerDocument;return r?(t=r.documentElement,se.contains(t,a)?(typeof a.getBoundingClientRect!==z&&(i=a.getBoundingClientRect()),o=j(r),{top:i.top+(o.pageYOffset||t.scrollTop)-(t.clientTop||0),left:i.left+(o.pageXOffset||t.scrollLeft)-(t.clientLeft||0)}):i):void 0},se.offset={setOffset:function(e,n,t){var o=se.css(e,"position");"static"===o&&(e.style.position="relative");var i,a,r=se(e),l=r.offset(),s=se.css(e,"top"),p=se.css(e,"left"),c=("absolute"===o||"fixed"===o)&&se.inArray("auto",[s,p])>-1,u={},g={};c?(g=r.position(),i=g.top,a=g.left):(i=parseFloat(s)||0,a=parseFloat(p)||0),se.isFunction(n)&&(n=n.call(e,t,l)),null!=n.top&&(u.top=n.top-l.top+i),null!=n.left&&(u.left=n.left-l.left+a),"using"in n?n.using.call(e,u):r.css(u)}},se.fn.extend({position:function(){if(this[0]){var e,n,t={top:0,left:0},o=this[0];return"fixed"===se.css(o,"position")?n=o.getBoundingClientRect():(e=this.offsetParent(),n=this.offset(),se.nodeName(e[0],"html")||(t=e.offset()),t.top+=se.css(e[0],"borderTopWidth",!0),t.left+=se.css(e[0],"borderLeftWidth",!0)),{top:n.top-t.top-se.css(o,"marginTop",!0),left:n.left-t.left-se.css(o,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent||K.documentElement;e&&!se.nodeName(e,"html")&&"static"===se.css(e,"position");)e=e.offsetParent;return e||K.documentElement})}}),se.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var o=/Y/.test(t);se.fn[e]=function(i){return se.access(this,function(e,i,a){var r=j(e);return a===n?r?t in r?r[t]:r.document.documentElement[i]:e[i]:(r?r.scrollTo(o?se(r).scrollLeft():a,o?a:se(r).scrollTop()):e[i]=a,n)},e,i,arguments.length,null)}}),se.each({Height:"height",Width:"width"},function(e,t){se.each({padding:"inner"+e,content:t,"":"outer"+e},function(o,i){se.fn[i]=function(i,a){var r=arguments.length&&(o||"boolean"!=typeof i),l=o||(!0===i||!0===a?"margin":"border");return se.access(this,function(t,o,i){var a;return se.isWindow(t)?t.document.documentElement["client"+e]:9===t.nodeType?(a=t.documentElement,Math.max(t.body["scroll"+e],a["scroll"+e],t.body["offset"+e],a["offset"+e],a["client"+e])):i===n?se.css(t,o,l):se.style(t,o,i,l)},t,r?i:n,r,null)}})}),e.webphone_api.$=se,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return se})}(window),webphone_api.global={isdebugversion_showengineselection:!1,isdebugversion:!1,isdebugversionwebrtc:!1,isdebugengine:!1,linnsengine:!0,macnsengine:!1,winlinmacnsengine:!1,deviceType:"-1",autoServerDeployVersion:!1,lastautoprovserver:"",checkforautoprov:!0,flagWaitforautoprov:!1,code_version:17,config_version:1,versionstr:"4.0.24108",minimumserviceversion:59,maximumserviceversion:64,useengine:"",useengineclicked_cache:0,last_useengine:"",last_last_useengine:"",ENGINE_JAVA:"java",ENGINE_WEBRTC:"webrtc",ENGINE_SERVICE:"ns",ENGINE_FLASH:"flash",ENGINE_APP:"app",webrtcavailable:-1,engineselecttime:0,engineselectstage:-1,ENGINE_DELAY:1e3,iscurrengineworking:!1,isfirststart:!1,browsersessionid:0,languageautodetect:1,languagelist_js_good:"en,de,hu,pt,es,fr,ja,pt-PT,ro,ru,tr",languagelist_js_all:"en,de,hu,pt,it,es,fr,ja,pt-PT,ro,ru,tr",sip_referreplace_all:"",sip_referreplace_sendcallid:"",transferreplacerectick:0,recwsload:-1,wsc_contimeout:0,wsc_reqtimeout:0,canfailover_gateway:!0,failover_gateway:!0,selected_apikey:"",pgw_decide_finished:!1,pgw_selected:-1,waitingforusukdecide:-1,predefLoglevel:5,logs:"",nrofrecentstodisplay:10,closeCallAtivity:!1,nrOfCallfunctionsToDisplay:5,pagewasrefreshed:!0,ringstart_time:0,callstart_time:0,lastringtimeouttick:0,wasSettModified:!1,wasCtModified:!1,wasChModified:!1,autoprovsrv_1:"https://www.webvoipphone.com/psettings/",autoprovsrv_2:"https://www.mizu-voip.com/phonesettings/",ctlist:[],chlist:[],aclist:[],recentlist:[],searchctlist:[],reloadcontactsaftersync:!1,refreshrecents:!1,readcallhistoryforrecents:!0,isencrypted:0,audio_rec_device_list:"",audio_play_device_list:"",audio_ring_device_list:"",audio_devices_loaded:!1,audio_rec_curr_device:"",audio_play_curr_device:"",audio_ring_curr_device:"",video_rec_device_list:"",video_rec_curr_device:"",usestorage:!0,phonestarted:0,service_last_life_signal:0,useajax_forservice:!1,serviceStatusPollTimer:null,webrtcsocketconnected:0,webrtcsipsignalingreceived:0,STORAGE_AUTO:0,STORAGE_COOKIE:1,STORAGE_LOCAL:2,ACCOUNTS_FILENAME:"wp_accounts",CONTACTS_FILENAME:"wp_contacts",SALT:"q8fgdahp9",SALT2:"vm1nye8ur2w",WIN_SOFTPHONE_URL:"http://127.0.0.1:18420",NATIVE_PLUGIN_URL:"ws://127.0.0.1",NATIVE_PLUGIN_URL_SECURE:"wss://ns4.webvoipphone.com",NATIVE_PLUGIN_URL_SECURE2:"",NATIVE_PLUGIN_URL_WIN_PORT:18520,NATIVE_PLUGIN_URL_LINMAC_PORT:18320,NATIVE_PLUGIN_URL_WIN_SSL_PORT:10443,NATIVE_PLUGIN_URL_LINMAC_SSL_PORT:19433,NPUSECURE1_YEAR:3022,NPUSECURE1_MONTH:1,NPUSECURE2_YEAR:3024,NPUSECURE2_MONTH:0,ENABLE_JAVA_URL:"http://java.com/en/download/help/enable_browser.xml",INSTALL_JAVA_URL:"http://www.java.com/download/",ec_apikey:"aJ6aqK4Nah3hnP7aht",ec_autoprov:"gJa6B2oa5Nx3Kya8n",wssupported:!1,httpmehod:"",currhttpmehodworking:!1,domloaded:!1,loglevel:1,incommingCall:!1,acceptReject:!1,checkIfInCall:!1,checkIfCallActive:!1,hadStartMediaPending:!1,callTypeInOut:"",lastRingEvenet:"",hangupPressedCount:0,maintimerid:null,polltimerid:null,worktimer:null,httpkatimer:0,initcalled:!1,callName:"",credit:"",creditRequestIval:100,CREDIT_REQUEST_IVAL_DEFVAL:12e3,creditRequestTimer:0,apppletloaded:!1,presenceHM:{},waitforpresence:0,presence_started:!1,last_used_engine_cache:"",textmessaging:-1,applet_started:!1,speakerState:!0,bluetoothState:!0,lastcalldetails:"",lastcallduration:0,isfirstwsu:!0,wsuser_succeded:!1,notifs:[],intentsettings:[],intentctdetails:[],intentcall:[],intentaddeditct:[],intentchdetails:[],intentmsg:[],intentbrowser:[],intentstartpage:[],intentfiletransfer:[],intentsmscodeverify:[],rating:"",httpreqasynccallback:null,bwanswercallback:null,bwanswerfilename:null,bwanswerINCNUMBER:0,dispSaveSettMsg:0,showratewhiletype_cache:0,nsupdatepending:!1,isDialpadStarted:!1,isCallStarted:!1,isContactslistStarted:!1,isContactdetailsStarted:!1,isCallhistorylistStarted:!1,isCallhistorydetailsStarted:!1,isSettingsStarted:!1,isAddeditcontactStarted:!1,isMessagelistStarted:!1,isMessageStarted:!1,isInternalbrowserStarted:!1,isStartpageStarted:!1,isLogviewStarted:!1,isNewuserStarted:!1,isSmscodeverifyStarted:!1,isFiletransferStarted:!1,isFiltersStarted:!1,isAccountsStarted:!1,isExtra1Started:!1,isExtra2Started:!1,isExtra3Started:!1,isExtra4Started:!1,isExtra5Started:!1,alreadyCalledNrs:"",contactExists:!0,contactExistsNr:"",authenticated_displayed:!1,favafone_autologin:!1,aline:1,lastalineset:-5,lastalinesetreal:-5,lastalinesettick:0,lastalinesetrealtick:0,acallcount:0,onloaded_called:!1,wploaded:!1,ep:[],lnstat:[],redialof:!1,redialhideevt:!1,lastcallcdr:"",sendwsuserjsonp:!1,callhistoryfilter:-1,webrtcpermissionaccepted:!1,isconfcall:!1,sessionid:-1,dispregfailed:0,onunregistered_flag:!1,onunload_flag:!1,handlesett_finished:!1,dploadingdisplayed:!1,telsearchname:"",pres_set_at_start:!1,laststarttick:0,pres_unreg_called:!1,presenceinterval:72e4,msg_presence_timer:0,startendelayed_wascalled:!1,sipaccounts:[],waiting_conf_numbers:"",isconfroom_call:!1,checkpres_callback:[],active_incoming_call:!1,android_aletrnatebrowserurl_DEF:"https://play.google.com/store/apps/details?id=com.android.chrome",testmessagevalidity:3,last_event:"",aua_handled:!1,stacknotstarted_time:0,stacknotstarted_retry:!1,dontshowdiscreason:!1,cansetuseengine:!1,lastconfroom:"",lastcontarget:"",lastconftargetstate:0,confcanfailover:!1,nostun:!1,noturn:!1,isvideocall:!1,lastpermreq:0,dontshow_closecall:!1,chrome_ss_plugin_url:"https://chrome.google.com/webstore/detail/screen-capturing/ajhifddimkapgcifgcodmmfdlknahffk",printwad_called:!1,custmenusL:[],bname_charcount:0,dontclosecurrpopup:!1,last_presence_enabled:!1,currcallnumber:"",isfirstcall:!0,confanswer_received:!1,calltransf_completed:!1,flagclientreset:!1,phonestarttick:0,httpheaderslogged:!1,onregisteredcalled:!1,flag_delsett:-1,resetsett_handled:!1,apistartstate:0,apistarttick:0,sipstackstarted:!1,wnotstartedsession:!1,flagnsreconnect:!1,colorizelog:0,webrtclastregsent:0,webrtcregtimer_exec:0,wsload_type:-1,webrtc_regstate:-1,addauser_header:!1,fcmstate:-1,fcmtoken:"",fcmIsEnabled:-1,add_recall_header:!1,domloaded_tick:0,last_ns_ws_succwss:0,callPageStatusCachePerLine:{},autoacceptsipheader:"",localforage_last_cb:null,last_wsu_tick:0,pingpong:0,ever_received_pong:!1,sipunicoderewritefrom:"",sipunicoderewriteto:"",firstregister_sessiontick:0,bothpartyhold:!1,firefoxholdcount:0,isholdresume:!1,isresume:0,ishold:0,lastaddtrack:0,rtcincallinit_incoming:0,rtcincallinit_outgoing:!1,holdorresumeinprogress:0,lastholdorresume:0,lastinvitesent:0,lastholdinvitesent:0,needholdreinvite:0,holdresumecount:0,win_nsplugin_filename:"WebPhoneService_Install.exe",mac_nsplugin_filename:"webphone_ns_mac.zip",mac_nsplugin_path:"www",lin32_nsplugin_filename:"webphone_ns_lin32.zip",lin32arm_nsplugin_filename:"webphone_ns_lin32arm.zip",
lin64_nsplugin_filename:"webphone_ns_lin64.zip",lin64arm_nsplugin_filename:"webphone_ns_lin64arm.zip",enstarteddisplayed:!1,usemutemutiline:!1,nuiswebpage:null,minimumservicebuild:0,last_good_status:"",laststatusdisplay:"",display_last_status:!1,minten:!1,mto:"",last_transfer_tick:0,dontSendSignaling:!1,dontSendSignalingTimer:0,isappenginestarted:!1,smsCodeUser:"",isconfdtmf:!1,CLOSE_CALL_TIMER:-100,lastengine_working_ok:"",lastengine_started_ok:"",restartice_time:0,ice_timer:null,icecompleted:!1,ice_callaccepted:!1,settmap:{},settmap2:{},mRealm:"",webphone_started:!1,atransfer_line:-1,atransfer_callid:"",atransfer_number:"",attendedtransfer_alreadycalled:"",attendedtransfer_origline:-1,prev_transfer_line:-1,prev_transfer_number:"",prev_transfer_replaces_tick:0,transfer_disablereplaces:!1,transfer_retryonnotsent:"",nextcallid:"",nsegnineneeded:!1,removemultilinestream:!1,lastholdline:-5,needmuteafterreload:0,callaftermute_line:0,callaftermute_number:"",callaftermute_mode:0,wasmuteinsteadhold:0,wasmultilineoop:0,addrtcpmux:0,needaudiodevicepopup:-1,unregisteredfromidle:0,wenThisGlobal:null},webphone_api.common=function(){function ClassSipAccounts(){this.serveraddress,this.username,this.password,this.ival,this.enabled,this.ismain,this.callerid,this.displayname,this.proxyaddress,this.realm}function ReceiveNotifications(e){try{if(isNull(e)&&(e=""),e=Trim(e),0===e.length||e.indexOf(notsep)===e.lastIndexOf(notsep)&&e.indexOf(notsep2)===e.lastIndexOf(notsep2))CleanNotifications(e);else if(e.indexOf(notsep)!==e.lastIndexOf(notsep)){var n=e.split(notsep);if(!isNull(n)&&n.length>0)for(var t=0;t<n.length;t++)isNull(n[t])||CleanNotifications(n[t])}else if(e.indexOf(notsep2)!==e.lastIndexOf(notsep2)){var n=e.split(notsep2);if(!isNull(n)&&n.length>0)for(var t=0;t<n.length;t++)isNull(n[t])||CleanNotifications(n[t])}else CleanNotifications(e)}catch(o){PutToDebugLogException(2,"common: ReceiveNotifications",o)}}function CleanNotifications(e){try{isNull(e)&&(e=""),e=e.toString(),CanLog(7)&&PutToDebugLog(7,"RECEIVED: "+e),e=e.replace("WPNOTIFICATION,",""),!1===webphone_api.global.iscurrengineworking&&((webphone_api.common.isNull(webphone_api.common.getuseengine())||webphone_api.common.getuseengine().length<1)&&(webphone_api.global.last_useengine=webphone_api.global.ENGINE_SERVICE),getuseengine()===webphone_api.global.ENGINE_SERVICE?(e.indexOf("STATUS")>=0&&e.indexOf("STOP")<0||e.indexOf("START")>=0)&&(webphone_api.global.iscurrengineworking=!0,SaveParameter("lastsessionsuccess","2")):(webphone_api.global.iscurrengineworking=!0,SaveParameter("lastsessionsuccess","2")));var n=e.indexOf(notsep);if(n>0&&(e=e.substring(0,n)),n=e.indexOf(notsep2),n>0&&(e=e.substring(0,n)),e=e.replace("EOFLINE","\r\n"),e=Trim(e),e.indexOf("DISPLAY")>0&&e.indexOf("LCCERRDISPLAY")<1)return e=Trim(e.replace("DISPLAY","")),PutToDebugLog(1,e),void ShowToast(e);e.indexOf("APIREQUEST:")>=0?(CanLog(5)&&PutToDebugLog(5,e),ProcessServiceReqResponse(e)):0===e.indexOf("LOG")?PutToDebugLog(5,e):!0===IsWindowsSoftphone()||getuseengine()===webphone_api.global.ENGINE_JAVA||getuseengine()===webphone_api.global.ENGINE_SERVICE?PutToDebugLog(1,e,"NOTIFICATION,"):PutToDebugLog(1,e)}catch(t){PutToDebugLogException(2,"common: CleanNotifications",t)}}function GetLogTimeStamp(){var e=new Date,n=e.getHours(),t=e.getMinutes(),o=e.getSeconds(),i=e.getMilliseconds();return n<10&&(n="0"+n),t<10&&(t="0"+t),o<10&&(o="0"+o),i<10?i="00"+i:i<100&&(i="0"+i),"["+n+":"+t+":"+o+"."+i+"] "}function CanLog(e){return!(e>webphone_api.global.loglevel)}function PutToDebugLog(e,n,t){if(!(inlog>1)){if(inlog>0)return inlog=2,PutToDebugLogIntern(e,n,t,!0),void(inlog>1&&(inlog=1));inlog<2&&(inlog=1),PutToDebugLogIntern(e,n,t),inlog=0}}function PutToDebugLogIntern(e,n,t,o){try{if(logcount++,!me1){var i=[];i.push("t"),i.push("r"),i.push("i"),i.push("a"),i.push("l "),i.push("e"),i.push("x"),i.push("p"),i.push("i"),i.push("r"),i.push("e"),i.push("d"),me1=i.join(""),i=[],i.push("t"),i.push("r"),i.push("i"),i.push("a"),i.push("l "),i.push("session "),i.push("time"),i.push("out"),me2=i.join(""),i=[],i.push("l"),i.push("i"),i.push("c"),i.push("e"),i.push("n"),i.push("s"),i.push("e"),i.push(" "),i.push("e"),i.push("r"),i.push("r"),i.push("o"),i.push("r"),me3=i.join(""),i=[],i.push("t"),i.push("r"),i.push("i"),i.push("a"),i.push("l "),i.push("v"),i.push("e"),i.push("r"),i.push("s"),i.push("i"),i.push("o"),i.push("n"),i.push(" "),i.push("n"),i.push("e"),i.push("e"),i.push("d"),i.push(" "),i.push("r"),i.push("e"),i.push("s"),i.push("t"),i.push("a"),i.push("r"),i.push("t"),me4=i.join(""),i=[],i.push("s"),i.push("e"),i.push("r"),i.push("v"),i.push("e"),i.push("r"),i.push(" "),i.push("i"),i.push("s"),i.push(" "),i.push("n"),i.push("o"),i.push("t"),i.push(" "),i.push("e"),i.push("n"),i.push("a"),i.push("b"),i.push("l"),i.push("e"),i.push("d"),i.push("_"),i.push("9"),me5=i.join("")}if((logfirstrun||logcount>1e3)&&!o){logcount=0;logfirstrun=!1,webphone_api.global.loglevel=GetLogLevel();return void LogWebphoneInfo("\r\n",e,n)}var i="",a=0;if(isNull(n)||isNull(e))return;if(IsNumber(e))a=e,i=n;else{if(!IsNumber(n))return;a=n,i=e}if(i.indexOf("Stack not started")>=0&&(webphone_api.global.stacknotstarted_time=GetTickCount()),i.indexOf("=wsuser")>0&&i.indexOf("authpwd=")>0){var r=i.substring(0,i.indexOf("authpwd="));i=i.substring(i.indexOf("authpwd=")),i=i.indexOf("&")>0?i.substring(i.indexOf("&")+1):"",i=r+i}if(lastlogmsg===i)return;if(lastlogmsg=i,(webphone_api.global.useengine===webphone_api.global.ENGINE_JAVA||webphone_api.global.useengine===webphone_api.global.ENGINE_SERVICE)&&!o&&((i.indexOf(me1)>=0||i.indexOf(me2)>=0||i.indexOf(me3)>=0||i.indexOf(me4)>=0)&&(lmsg=i,lm=!0),(i.indexOf(me1)>=0||i.indexOf(me3)>=0||i.indexOf(me5)>=0)&&getuseengine()===webphone_api.global.ENGINE_SERVICE&&!1===srvinst_offered)){if(0===GetParameterInt("nsupdate",-1))return PutToDebugLog(1,"ERROR, NS update failed second time, prompt user to send logs"),void(1!=GetParameterInt("disablepopup",-1)&&(!0===IsSDK()?AlertDialog("ERROR","Please contact support and send logs from browser console"):AlertDialog("ERROR","Please contact support and send logs from Menu -> Help -> Logs")));if(srvinst_offered=!0,setTimeout(function(){srvinst_offered=!1},18e4),!1===Te()){var l=i;WinAPI("extcmd_version",function(e){try{if(isNull(e)||e.indexOf("ERROR:")>=0)return;var n=-1,t=e.toString(),o=t.indexOf("version:");o>0&&(t=t.substring(o+8)),o=t.indexOf("eov"),o>0&&(t=t.substring(0,o)),t=Trim(t),!isNull(t)&&IsNumber(t)&&(n=StrToInt(t)),n>0&&!webphone_api.global.nsupdatepending&&(SaveParameter("srvupgrade_currversion",n),webphone_api.global.maximumserviceversion>0&&n>=webphone_api.global.maximumserviceversion&&1!=GetParameterInt("disablepopup",-1)?AlertDialog("ERROR",l):setTimeout(function(){SaveParameter("nsupdate","0");try{console&&console.log&&console.log(2,"EVENT, common: PutToDebugLog, service upgrade needed: "+GetMinServiceVersion().toString())}catch(e){}EngineForcedInstall("ns",webphone_api.stringres.get("service_update")),webphone_api.global.nsupdatepending=!0},1))}catch(i){console.log("ERROR, catch on PutToDebugLog: extcmd_version"+i)}})}}!0===lm&&!o&&i.toLowerCase().indexOf("engine")<0&&(i=lmsg,a=1);try{o||webphone_api.onEventCb("log",i,null)}catch(h){}try{o||webphone_api.onLogCb(i)}catch(h){}sendlogstoandroid<0&&(sendlogstoandroid=IsCExt());try{sendlogstoandroid>0&&!o&&"undefined"!=typeof AndroidWebphoneJsInterface&&null!==AndroidWebphoneJsInterface&&"undefined"!=typeof AndroidWebphoneJsInterface.jstoandroidPutToDebugLog&&null!==AndroidWebphoneJsInterface.jstoandroidPutToDebugLog&&AndroidWebphoneJsInterface.jstoandroidPutToDebugLog(a.toString(),i)}catch(h){}if(webphone_api.global.useengine!==webphone_api.global.ENGINE_WEBRTC||o||i.toLowerCase().indexOf("failed to find transport")>=0&&(isNull(console)||isNull(console.log)||console.log("detected in Log: failed to find transport"),webphone_api.flagrestartwebrtc=!0,webphone_api.webrtcapi.ReStart(0,!0)),i.indexOf("STOP")>0&&(a=2),!0===webphone_api.global.redialhideevt&&console&&console.log&&console.log("webphone: event dropped_1 redialonfail: "+i),1===a&&i.indexOf("param platform")<0&&!1===webphone_api.global.redialhideevt&&!o)"undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications?webphone_api.notifications.ProcessNotifications(i):(console&&console.log&&console.log("ERROR, common PutToDebugLog webphone_api.notifications is not defined"),i+=" (NOT PROCESSED)");else if(a>webphone_api.global.loglevel)return;if(a>webphone_api.global.loglevel)return;void 0!==t&&null!==t&&(i=t+i),i=ReplaceAll(i,"EOFLINE","\r\n");var s=GetLogTimeStamp();if(webphone_api.global.logs=webphone_api.global.logs+s+i+"&#10;",webphone_api.global.logs.length>6e5){var p=webphone_api.global.logs.substring(0,1e4);webphone_api.global.logs=p+webphone_api.global.logs.substring(3e5)}try{if("false"==webphone_api.parameters.logtoconsole||0==webphone_api.parameters.logtoconsole)return}catch(h){}if(s="webphone: "+s,webphone_api.global.deviceType>0||navigator.userAgent.toLowerCase().indexOf("firefox")>-1||navigator.userAgent.toLowerCase().indexOf("chrome")>-1)if(i.indexOf("ERROR")>-1&&webphone_api.global.colorizelog>0)try{console.error(s+i+" ")}catch(m){}else if(i.length>1e3)for(var c=0;i.length>0&&!(++c>15);){var u=i.length;u>1e3&&(u=1e3);var g=i.substring(0,u);i=i.substring(u),c>1&&(s="\t"+s);try{g=ReplaceAll(g,"\r\n","\r\n\t")}catch(d){}try{console.log(s+g+" ")}catch(b){}}else if(i.length>140&&i.length<400&&(i.indexOf("http:")>=0||i.indexOf("https:")>=0))for(var c=0;i.length>0&&!(++c>5);){var u=i.length;u>140&&(u=140);var g=i.substring(0,u);i=i.substring(u),c>1&&(s="\t"+s);try{g=ReplaceAll(g,"\r\n","\r\n\t")}catch(d){}try{console.log(s+g+" ")}catch(b){}}else try{console.log(s+i+" ")}catch(b){}else if(i.length>1e3)for(var c=0;i.length>0&&!(++c>15);){var u=i.length;u>1e3&&(u=1e3);var g=i.substring(0,u);i=i.substring(u),c>1&&(s="\t"+s);try{g=ReplaceAll(g,"\r\n","\r\n\t")}catch(_){}try{isNull(console)||isNull(console.log)||console.log(s+g+" ")}catch(f){}}else if(i.length>140&&i.length<400&&(i.indexOf("http:")>=0||i.indexOf("https:")>=0))for(var c=0;i.length>0&&!(++c>5);){var u=i.length;u>140&&(u=140);var g=i.substring(0,u);i=i.substring(u),c>1&&(s="\t"+s);try{g=ReplaceAll(g,"\r\n","\r\n\t")}catch(_){}try{isNull(console)||isNull(console.log)||console.log(s+g+" ")}catch(f){}}else try{isNull(console)||isNull(console.log)||console.log(s+i+" ")}catch(f){}}catch(h){alert(h)}}function PutToDebugLogSpecial(e,n,t,o){function i(e){try{return void 0!==e&&null!=e&&(e=e.toString(),!(e.length<1)&&(!(null==(e=Trim(e))||e.length<1)&&!isNaN(e)))}catch(n){alert("ERROR, common: IsNumberInner"+n)}return!1}if(splevel<1)try{splevel=webphone_api.global.loglevel;var a=StrToInt(GetParameter("loglevel"));!isNull(a)&&i(a)&&a>splevel&&a<1e3&&(splevel=a),a=webphone_api.parameters.loglevel,!isNull(a)&&i(a)&&a>splevel&&a<1e3&&(splevel=a),splevel<0&&(splevel=2)}catch(l){alert("PutToDebugLogSpecialA"+l)}if(!(!isNull(e)&&i(e)&&e>splevel)&&void 0!==n&&null!==n){t=void 0!==t&&null!==t&&!1!==t;try{void 0!==o&&null!==o||(o="");var r=GetLogTimeStamp();webphone_api.global.logs=webphone_api.global.logs+r+n+" "+o+"&#10;";try{if("false"==webphone_api.parameters.logtoconsole||0==webphone_api.parameters.logtoconsole)return}catch(l){}if(n="webphone: "+r+n+" "+o,!0===t&&webphone_api.global.colorizelog>0)try{console.error(n)}catch(s){}else try{console.log(n)}catch(s){}}catch(l){alert("PutToDebugLogSpecial"+l)}}}function LogConfig(){function e(e){try{return void 0===e||null===e?"":(e=e.toLowerCase(),"undefined"==typeof n[e]||null===n[e]?"":n[e])}catch(t){}return""}if(CanLog(5))try{PutToDebugLog(5,"EVENT,built in Config parameters: ");var n=GetConfigAll(!1);GetSecureKey();var t=e("loglevel");!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_loglevel: "+t),t=e("autotransportdetect"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_autotransportdetect: "+t),t=e("cfgusetunneling"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_cfgusetunneling: "+t),t=e("useencryption"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_useencryption: "+e("useencryption")),t=e("upperserverfromuser"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_upperserverfromuser: "+t),t=e("allowsimpleudpencrypt"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_allowsimpleudpencrypt: "+t),t=e("cantryudpdirectep"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_cantryudpdirectep: "+t),t=e("featureset"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_featureset: "+e("featureset")),t=e("brandid"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_brandid: "+e("brandid")),t=e("enabledirectcalls"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_enabledirectcalls: "+e("enabledirectcalls")),t=e("enabledirectcallstolan"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_enabledirectcallstolan: "+e("enabledirectcallstolan")),t=e("colortheme"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_colortheme: "+e("colortheme")),t=e("actionbarhideicon"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_actionbarhideicon: "+e("actionbarhideicon")),t=e("usemizuwebrtcgateway"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_usemizuwebrtcgateway: "+e("usemizuwebrtcgateway")),t=e("deploydate"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_deploydate: "+e("deploydate")),t=e("useg729"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_useg729: "+e("useg729")),t=e("hidedomaininput"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_hidedomaininput: "+e("hidedomaininput")),t=e("usestun"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_usestun: "+e("usestun")),t=e("serveraddress"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_serveraddress: "+e("serveraddress")),t=e("userport"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_userport: "+e("userport")),t=e("voicemail"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_voicemail: "+e("voicemail")),t=e("needapikey"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_needapikey: "+e("needapikey")),t=e("firstdeploydate"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_firstdeploydate: "+e("firstdeploydate")),t=e("lastdeploydate"),!isNull(t)&&t.length>0&&PutToDebugLog(5,"\tcfg_lastdeploydate: "+e("lastdeploydate"))}catch(o){alert("LogConfig: "+o)}}function LogWebphoneInfo(e,n,t){try{if(!CanLog(2))return void(isNull(n)||isNull(t)||PutToDebugLog(n,t));logwphoneinfodone<1&&(logwphoneinfodone=1),isNull(e)&&(e="\r\n");var o=GetWebphoneInfo(e);!isNull(o)&&o.length>0&&(PutToDebugLog(3,o),PutToDebugLog(3,"EVENT, Location: "+window.location.href+e)),isNull(n)||isNull(t)||PutToDebugLog(n,t);var i=!1;if((webphone_api.global.loglevel>=7||!0===webphone_api.global.isdebugversion&&webphone_api.global.loglevel>=5)&&(i=!0),webphone_api.global.loglevel<2&&"undefined"!=typeof console&&null!==console&&"undefined"!=typeof console.log&&null!==console.log&&!1===basicinfologged)return"false"!=webphone_api.parameters.logtoconsole&&0!=webphone_api.parameters.logtoconsole&&(console.log(o),console.log("Location: "+window.location.href+e)),void(basicinfologged=!0);if(!CanLog(5))return;if(!origparamslogged&&!isNull(webphone_api.origparameters)){origparamslogged=!0,PutToDebugLog(5,"EVENT,webphone_api.parameters (orig): ");for(var a in webphone_api.origparameters)if(!isNull(a)&&a.length>0){var r=webphone_api.origparameters[a];if(isNull(r))continue;r=r.toString(),r.length>0&&(!i&&(a.indexOf("password")>=0||"extraregisteraccounts"===a)?r="'*'":!i&&(0==a.indexOf("pgw")||r.indexOf("com.mizuvoip.mizudroid")>=0||r.indexOf("app/mizuphone")>=0||a.indexOf("transfwithreplace")>=0&&"-1"==r||a.indexOf("domaintoip_cache")>=0||"get"==a||"getAll"==a)||(!IsNumber(r)||a.indexOf("username")||a.indexOf("sipusername")>=0)&&(r="'"+r+"'"),PutToDebugLog(5,"\t"+a+": "+r+","))}}if(!isNull(webphone_api.parameters)){var l=!1;try{isNull(webphone_api.origparameters)||JSON.stringify(webphone_api.origparameters)!==JSON.stringify(webphone_api.parameters)||(l=!0)}catch(s){}if(!l){PutToDebugLog(5,"EVENT,webphone_api.parameters: ");for(var a in webphone_api.parameters)if(!isNull(a)&&a.length>0){var r=webphone_api.parameters[a];if(isNull(r))continue;r=r.toString(),r.length>0&&(r.indexOf("password")>0&&!i?r="'*'":(!IsNumber(r)||a.indexOf("username")||a.indexOf("sipusername")>=0)&&(r="'"+r+"'"),PutToDebugLog(5,"\t"+a+": "+r+","))}}}logwphoneinfodone<2&&(logwphoneinfodone=2,LogConfig())}catch(p){alert("LogWebphoneInfo: "+p)}}function GetBrowserPlatform(){try{return(({"function":!0,object:!0}[typeof window]&&window||this).navigator||{}).platform||""}catch(e){}return""}function GetUserAgent(){try{var e={"function":!0,object:!0},n=e[typeof window]&&window||this,t=n.navigator||{},o=t.userAgent||"";try{o=o+" PL: "+t.platform}catch(i){}try{o=o+" APP: "+t.appName}catch(i){}return o}catch(i){}return""}function GetWebphoneInfo(e,n){var t="";try{isNull(e)&&(e=""),t="About:",t+=e,t=t+"Brand: "+GetBrandName()+" JSApp Version: "+GetVersionStr()+" ("+webphone_api.global.code_version+")",!isNull(n)&&n.length>0&&(t=t+"Problem description: "+n+e);var o=webphone_api.platform.name,i=webphone_api.platform.version;(isNull(o)||"Android"===GetOs())&&(o=GetBrowser()),isNull(i)&&(i=GetBrowserVersion());var a="",r=new Date;if(!isNull(r)){var l=r.getMonth()+1;a=r.getFullYear()+"/"+l+"/"+r.getDate()}var s=IsWebphoneInIframe(),p="; isiframe: "+s.toString();!0===s&&(p=e+p+"; iframeParentLocation: "+GetParentIframeUrl());var c=webphone_api.platform.os;(/iPad|iPhone|iPod/.test(navigator.platform)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&!window.MSStream&&(c="iOS"),c=c.toString(),c.toLowerCase().indexOf("win")<0&&GetBrowserPlatform().toLowerCase().indexOf("win")>=0&&(c="Windows"),t=t+"; Build date: "+GetConfig("lastdeploydate")+" (M/D/Y)",t=t+"; OS: "+c+"; voipen: "+getuseengine()+"; date: "+a+p+e,t=t+"Browser: "+o+" "+i,t=t+"; Bengine: "+webphone_api.platform.layout,t=t+"; GetBrowser: "+GetBrowser()+"; Bver: "+GetBrowserVersion()+"; GetOs: "+GetOs()+e,t=t+"UA: "+GetUserAgent()+e;var u="0";if(0!=webphone_api.global.phonestarttick){var g=Math.floor((GetTickCount()-webphone_api.global.phonestarttick)/1e3),h=Math.floor(g/60);g%=60,g<10&&(g="0"+g),u=h+":"+g}t=t+"Uptime: "+u;var m=GetLogLevel();void 0!==m&&null!==m||(m=""),m=m.toString(),t=t+"; loglevel: "+m;var d=!1;!0===IsSDK()&&(d=!0);try{t=t+"; Used as SDK: "+d.toString()}catch(b){}return t}catch(_){alert("GetWebphoneInfo: "+_)}return""}function xml_to_string(e){try{if(e.xml)return e.xml;if(XMLSerializer){return(new XMLSerializer).serializeToString(e)}return""}catch(n){PutToDebugLogException(2,"common: xml_to_string",n)}}function PutToDebugLogException(e,n,t){try{var o="";if(isNull(n)||isNull(e))return;0!=n.indexOf("ERROR")&&(n="ERROR, catch on "+n),void 0===t||null===t?PutToDebugLog(e,n+" unknown exception"):("undefined"!=typeof t.message&&null!==t.message&&t.message.length>0&&(o=o+" ("+t.message+") "),"undefined"!=typeof t.fileName&&null!==t.fileName&&t.fileName.length>0&&(o=o+" class: "+t.fileName),"undefined"!=typeof t.lineNumber&&null!==t.lineNumber&&t.fileName.lineNumber>0&&(o=o+": "+t.lineNumber),PutToDebugLog(e,n+" "+t+o)),(!0===webphone_api.global.usestorage||Strl(90))&&n.indexOf("There is an error in")>=0&&ShowToast("ERROR, "+n+t+o,8e3)}catch(i){}}function PutToDebugLogWarning(e,n,t){try{var o="";if(isNull(n)||isNull(e))return;0!=n.indexOf("WARNING")&&(n="WARNING, catch on "+n),void 0===t||null===t?PutToDebugLog(e,n+" unknown exception"):("undefined"!=typeof t.message&&null!==t.message&&t.message.length>0&&(o=o+" ("+t.message+") "),"undefined"!=typeof t.fileName&&null!==t.fileName&&t.fileName.length>0&&(o=o+" class: "+t.fileName),"undefined"!=typeof t.lineNumber&&null!==t.lineNumber&&t.fileName.lineNumber>0&&(o=o+": "+t.lineNumber),PutToDebugLog(e,n+" "+t+o))}catch(i){}}function ReplaceAll(e,n,t){try{return isNull(e)||isNull(n)||isNull(t)?(PutToDebugLogSpecial(2,"ERROR, common ReplaceAll null value",!0,""),""):(e=e.toString(),e.split(n).join(t))}catch(o){PutToDebugLogSpecial(2,"ERROR, ReplaceAll: ",!0,o)}return""}function Trim(e){try{return isNull(e)||e.length<1?"":(e=e.toString(),hastrim<0&&(hastrim=isNull(e.trim)&&"function"!=typeof e.trim?0:1),hastrim>0?e.trim():e.replace(/^\s+|\s+$/g,""))}catch(n){PutToDebugLogSpecial(2,"ERROR, common: Trim",!0,n)}return e}function EscapeRegExp(e){try{return isNull(e)||e.length<1?(PutToDebugLog(3,"ERROR, common EscapeRegExp null value"),""):e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}catch(n){PutToDebugLogException(2,"common: EscapeRegExp",n)}return""}function IsString(e){return null==e||"string"==typeof e}function IsNumber(e){try{return void 0!==e&&null!=e&&(e=e.toString(),!(null==(e=e.replace(/\s+/g,""))||e.length<1)&&!isNaN(e))}catch(n){PutToDebugLogSpecial(2,"ERROR, common: IsNumber",!0,n)}return!1}function IsNumeric(e,n){try{if(void 0===e||null==e)return!1;e=e.toString(),e=e.replace(/\s+/g,"");var t=e.split("");if(isNull(t)||t.length<1)return!1;var o=[];if(void 0!==n&&null!==n&&n.length>0){o=n.split(","),void 0!==o&&null!==o||(o=[]);for(var i=0;i<o.length;)"undefined"==typeof o[i]||null===o[i]||1!==o[i].length?o.splice(i,1):i++}if(void 0!==o&&null!==o||(o=[]),o.length>0){for(var a=0;a<t.length;a++)if((t[a]<"0"||t[a]>"9")&&o.indexOf(t[a])<0)return!1}else for(var a=0;a<t.length;a++)if(t[a]<"0"||t[a]>"9")return!1;return!0}catch(r){PutToDebugLogSpecial(2,"ERROR, common: IsNumeric",!0,r)}return!1}function StrToInt(e){return"number"==typeof e&&isFinite(e)?e:isNull(e)||!IsNumber(e)?null:(e.toString().indexOf(" ")>=0&&(e=ReplaceAll(e.toString()," ","")),parseInt(e.toString(),10))}function StrToIntDef(e,n){if("number"==typeof e&&isFinite(e))return e;if(isNull(e)||!IsNumber(e))return n;e.toString().indexOf(" ")>=0&&(e=ReplaceAll(e.toString()," ",""));var t=parseInt(e.toString(),10);return isNaN(t)?n:t}function StrToIntPx(e){if("number"==typeof e&&isFinite(e))return e;if(isNull(e))return 0;e.toString().indexOf(" ")>=0&&(e=ReplaceAll(e.toString()," ",""));var n=parseInt(e.toString(),10);return isNaN(n)?0:n}function StrIsUpperCase(e){try{if(isNull(e))return!1;for(var n=!0,t=0,o=0;o<e.length;o++)if(t=e.charCodeAt(o),!(isNull(t)||t<65||t>90&&t<97||t>122)){var i=e.charAt(o);if(i===i.toLowerCase()){n=!1;break}}return n}catch(a){PutToDebugLogException(2,"common: StrIsUpperCase",a)}return!1}function GetDeviceWidth(){try{return Math.floor(webphone_api.$("#phone_app_main_container").width())}catch(e){PutToDebugLogException(2,"common: GetDeviceWidth",e)}}function GetDeviceHeight(){try{return Math.floor(webphone_api.$("#phone_app_main_container").height())}catch(e){PutToDebugLogException(2,"common: GetDeviceHeight",e)}}function IsWindowsSoftphone(){try{if(!0===isPlatformSet)return isWindows;var e=window.location.href;if(isNull(e)||e.length<1)return isPlatformSet=!0,isWindows;if(e=Trim(e),e.indexOf("platform")>0&&e.indexOf("windesktop")>0)return isPlatformSet=!0,isWindows=!0}catch(n){PutToDebugLogException(2,"common: IsWindowsSoftphone",n)}return isWindows}function DeviceType(){return webphone_api.global.deviceType}function DEVICE_WEBPHONE(){return CONST_DEVICE_WEBPHONE}function DEVICE_WIN_SOFTPHONE(){return CONST_DEVICE_WIN_SOFTPHONE}function DEVICE_ANDROID(){return CONST_DEVICE_ANDROID}function DEVICE_IPHONE(){return CONST_DEVICE_IPHONE}function DEVICE_BB(){return CONST_DEVICE_BB}function DEVICE_WP(){return CONST_DEVICE_WP}function isNull(e){return void 0===e||null==e}function ToStringSafe(e){try{if(!isNull(e))return e.toString()}catch(n){}return""}function SetALineInternal(e,n,t){if(!(isNull(e)||!IsNumber(e)||e<=-10||e>=99999))return!isNull(t)&&!1===t&&e!==webphone_api.global.lastalinesetreal&&webphone_api.global.lastalinesetreal>=-2&&GetTickCount()-webphone_api.global.lastalinesetrealtick<300&&0!=webphone_api.global.lastalinesetrealtick&&GetTickCount()-webphone_api.global.lastalinesetrealtick>=0?void(webphone_api.global.aline!==e&&PutToDebugLog(5,"EVENT, skip internal change aline from "+webphone_api.global.aline.toString()+" to "+e.toString()+" from "+n.toString())):void(webphone_api.global.aline!==e&&(PutToDebugLog(5,"EVENT, change alinex from "+webphone_api.global.aline.toString()+" to "+e.toString()+" from "+n.toString()),webphone_api.global.aline=e))}function IsFunction(e){try{if("function"===Object.prototype.toString.call(e).slice(8,-1).toLowerCase())return!0}catch(n){PutToDebugLogSpecial(2,"ERROR,common: IsFunction",!0,n)}return!1}function getBgColor(e){var n=0;try{n=1;var t="#000000",o="";if(n=2,webphone_api.$(e).length>0){n=3;var i=webphone_api.$(e).css("background-color");if(n=4,isNull(i))return t;n=41,o=i.toString(),n=42,isNull(o)&&(o=""),n=5;var a=i.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(n=6,isNull(a)||a.length<4)return n=61,CanLog(5)&&PutToDebugLog(5,"EVENT, (warn) common: common: getBgColor: "+o),t;n=7,delete a[0],n=8;for(var r=1;r<=3;++r)n=81,a[r]=parseInt(a[r]).toString(16),n=82,1==a[r].length&&(n=83,a[r]="0"+a[r]);n=9,t="#"+a.join(""),n=10}return t}catch(l){PutToDebugLogWarning(2,"common: getBgColor "+n.toString()+" "+o,l)}return"#000000"}function getElementColor(e){try{var n="#000000";if(webphone_api.$(e).length>0){var t=webphone_api.$(e).css("color");if(isNull(t))return n;var o=t.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);delete o[0];for(var i=1;i<=3;++i)o[i]=parseInt(o[i]).toString(16),1==o[i].length&&(o[i]="0"+o[i]);n="#"+o.join("")}return n}catch(a){PutToDebugLogException(2,"common: getElementColor",a)}return"#000000"}function AlertDialog(e,n,t,o,i){try{if(1==GetParameterInt("disablepopup",-1))return void PutToDebugLog(1,e+", "+n);if(isNull(n)&&(n=""),isNull(e)&&(e=""),n=n.replace("[BRAND]",GetBrandName()),!isNull(webphone_api.displaycb)||"function"==typeof webphone_api.displaycb)try{webphone_api.onDisplayCb(n,e)}catch(r){PutToDebugLogException(2,"There is an error in ondisplay() callback 1",r)}try{webphone_api.onEventCb("display",e+","+n,e)}catch(r){PutToDebugLogException(2,"There is an error in onEvent() callback 5",r)}if(!1===GetParameterBool("showtoasts",!0))return void(t&&"function"==typeof t&&t());var a=n;a===webphone_api.stringres.get("app_en_warning")&&(a=webphone_api.stringres.get("app_en_warning_short")),isNull(i)||!1!==i?PutToDebugLog(1,"EVENT,"+a):a.length<400&&a.indexOf("\n")<0&&a.indexOf("<")<0&&PutToDebugLog(3,"EVENT,"+a),!0===IsSDK()?setTimeout(function(){try{AlertDialogSDK(e,n,t)}catch(r){PutToDebugLogException(2,"common: AlertDialog - SDK",r)}},100):setTimeout(function(){try{AlertDialogDelayed(e,n,t,o)}catch(r){PutToDebugLogException(2,"common: AlertDialog - Delayed",r)}},100)}catch(r){PutToDebugLogException(2,"common: AlertDialog",r)}}function AlertDialogDelayed(e,n,t,o){try{if(1==GetParameterInt("disablepopup",-1))return void PutToDebugLog(1,e+", "+n);t=t||function(){};var i=GetDeviceWidth();i=!isNull(i)&&IsNumber(i)&&i>100?Math.floor(i/1.2):220,i>400?i=400:i<120&&(i=120),isNull(o)&&(o=webphone_api.stringres.get("btn_close"));var a='<div data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+i+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+e+'</h1></div><div role="main" class="ui-content adialog_content adialog_alert"><span style="-ms-user-select: text; -moz-user-select: text; -khtml-user-select: text; -webkit-user-select: text; user-select: text;"> '+n+' </span></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="btn_adialog_alert_ok" style="width: 98%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+o+"</a></div></div>";!1===IsSDK()&&(webphone_api.$.mobile.activePage.append(a).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").bind({popupbeforeposition:function(){webphone_api.$(this).unbind("popupbeforeposition");var e=Math.floor(.6*GetDeviceHeight());webphone_api.$(this).height()>e+100&&webphone_api.$(".messagePopup .ui-content").height(e)}}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#btn_adialog_alert_ok").off("click"),t(!1)}})),webphone_api.$("#btn_adialog_alert_ok").on("click",function(){t&&"function"==typeof t&&(t(!0),t=function(){})})}catch(r){PutToDebugLogException(2,"common: AlertDialog",r)}}function ShowToast(e,n,t){try{if(PutToDebugLog(1,"EVENT, "+e),1==GetParameterInt("disabletoasts",-1))return;(isNull(n)||!IsNumber(n)&&e.length>75)&&(n=e.length-75,n=3e3+n),setTimeout(function(){ShowToastDelayed(e,n,t)},100)}catch(o){PutToDebugLogSpecial(2,"common: ShowToastF",!0,o)}}function ShowToastDelayed(e,n,t){try{if(PutToDebugLog(1,"EVENT, "+e),1==GetParameterInt("disabletoasts",-1))return;if(t=t||function(){},CanLog(3)&&PutToDebugLog(3,"EVENT, toast: "+e),!isNull(webphone_api.displaycb)||"function"==typeof webphone_api.displaycb)try{webphone_api.onDisplayCb(e,"")}catch(a){PutToDebugLogException(2,"There is an error in ondisplay() callback 2",a)}try{webphone_api.onEventCb("display",","+e,null)}catch(a){PutToDebugLogException(2,"There is an error in onEvent() callback 6",a)}if(!1===GetParameterBool("showtoasts",!0))return void(t&&"function"==typeof t&&t());if(!0===IsSDK())return void ShowToastSDK(e,n);if(!isNull(e)&&!0===webphone_api.global.isSettingsStarted&&e.toLowerCase().indexOf("register")>=0&&e.toLowerCase().indexOf("failed")>0)return;var o=GetDeviceWidth();o=!isNull(o)&&IsNumber(o)&&o>100?Math.floor(o/1.2):220,o>400?o=400:o<120&&(o=120);var i='<div data-role="popup" style="padding: .5em;" class="ui-content toastPopup" data-overlay-theme="b" data-transition="fade" data-theme="a" style="max-width:'+o+'px"><span> '+e+" </span></div>";webphone_api.$.mobile.activePage.append(i).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".toastPopup").popup("close")}),webphone_api.$.mobile.activePage.find(".toastPopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),t()}}),isNull(n)&&(n=3e3),n>0&&setTimeout(function(){webphone_api.$.mobile.activePage.find(".toastPopup").popup("close")},n)}catch(a){PutToDebugLogSpecial(2,"common: ShowToast",!0,a)}}function UsePresence2(){try{if(!1===Glpr())return!1;var e=1,n=GetParameterInt("enablepresence",-1),t=GetParameterInt("enablepresence2",-1);if(IsNumber(t)&&StrToInt(t)>0&&(e=StrToInt(t)),IsNumber(n)&&StrToInt(n)>=0&&(e=StrToInt(n)),isNull(enablepres_httpapi)&&(enablepres_httpapi=GetParameterInt("enablepres_httpapi",1),enablepres_javaapi=GetParameterInt("enablepres_javaapi",1),enablepres_webrtc=GetParameterInt("enablepres_webrtc",1)),e>2)return!0;if(-1==webphone_api.global.recwsload&&(webphone_api.global.recwsload=GetParameter("lastrecwsload",-2)),webphone_api.global.recwsload>3)return!1;if(e<1)return!1;if(e>1)return!0;if(1===e){if(webphone_api.global.recwsload>2)return!1;if(!1===webphone_api.global.usestorage&&0!=webphone_api.global.recwsload&&!1===Strl(90)&&(1==GetParameterBool("customizedversion",!1)||webphone_api.global.recwsload>1))return!1;if(enablepres_httpapi<1&&enablepres_javaapi<1&&enablepres_webrtc<1)return!1===errmsgdisp&&(PutToDebugLog(2,"ERROR, common Presence disabled_1"),errmsgdisp=!0),!1;if(getuseengine()===webphone_api.global.ENGINE_WEBRTC&&enablepres_webrtc<1&&enablepres_httpapi<1)return!1===errmsgdisp&&(PutToDebugLog(2,"ERROR, common Presence disabled_2"),errmsgdisp=!0),!1;if((!0===IsWindowsSoftphone()||getuseengine()===webphone_api.global.ENGINE_JAVA||getuseengine()===webphone_api.global.ENGINE_SERVICE)&&enablepres_javaapi<1&&enablepres_httpapi<1)return!1===errmsgdisp&&(PutToDebugLog(2,"ERROR, common Presence disabled_3"),errmsgdisp=!0),!1
;if(getuseengine()===webphone_api.global.ENGINE_WEBRTC&&enablepres_webrtc<1&&enablepres_httpapi>0){if(GetHttpAPIKey().length<1)return!1===errmsgdisp&&(PutToDebugLog(2,"ERROR, common Presence disabled_4"),errmsgdisp=!0),!1}else if(enablepres_httpapi>0&&enablepres_javaapi<1&&enablepres_webrtc<1){if(!IsMizuServerOrGateway())return!1===errmsgdisp&&(PutToDebugLog(2,"ERROR, common Presence disabled_5"),errmsgdisp=!0),!1}else{if(getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.global.recwsload>1)return!1===errmsgdisp&&(PutToDebugLog(2,"WARNING, common Presence disabled_6 high webrtc load"),errmsgdisp=!0),!1;if(!0===IsSDK()&&IsMizuServerOrGateway())return!1}return!0}}catch(o){PutToDebugLogException(2,"common: UsePresence2",o)}return!1}function GetPresenceServer2(){try{if(!UsePresence2())return"";var e=-1,n=GetParameter("mainaport"),t=GetParameter("mainaporttls"),o="",i=GetUsableWebrtcSrvAddr();if(!isNull(i)&&i.length>0&&(i=NormalizeInput(i,0),e=i.indexOf("/"),e>0&&(i=i.substring(0,e)),e=i.indexOf(":"),e>0&&(i=i.substring(e+1)),!isNull(i)&&IsNumber(i)&&(o=i)),IsMizuServerOrGateway()){var a=GetParameter2("serveraddress_user");return(isNull(a)||a.length<2)&&(a=GetParameter2("serveraddress")),(IsIPAddrress(a)||!1===UseSecureSrvConnection())&&n.length>0?(AddressHasPort(a)&&(a=GetIPFromAddressSimple(a)),a="http://"+GetIPEnclosed(a)+":"+n):((isNull(o)||o.length<1)&&(o=t),!isNull(o)&&o.length>0&&(AddressHasPort(a)&&(a=GetIPFromAddressSimple(a)),a="https://"+GetIPEnclosed(a)+":"+o)),a}if(GetConfigInt("cfgusetunneling",0)>0&&!0===GetConfigBool("useencryption",!1)){var a=GetParameter2("tunnelserveraddress");return(IsIPAddrress(a)||!1===UseSecureSrvConnection())&&n.length>0?(AddressHasPort(a)&&(a=GetIPFromAddressSimple(a)),a="http://"+GetIPEnclosed(a)+":"+n):((isNull(o)||o.length<1)&&(o=t),!isNull(o)&&o.length>0&&(AddressHasPort(a)&&(a=GetIPFromAddressSimple(a)),a="https://"+GetIPEnclosed(a)+":"+o)),a}if(getuseengine()!==webphone_api.global.ENGINE_WEBRTC&&getuseengine()!==webphone_api.global.ENGINE_FLASH&&(a=GetServerForHttpReq(),!isNull(a)&&a.length>0))return a;var r=1,l=GetParameterInt("enablepresence",-1),s=GetParameterInt("enablepresence2",-1);if(IsNumber(s)&&StrToInt(s)>0&&(r=StrToInt(s)),IsNumber(l)&&StrToInt(l)>=0&&(r=StrToInt(l)),!0===IsMizuPublicWebRTCGatewayUsed()||2===r){var p=webphone_api.global.pgw_selected;p<0&&(CanLog(5)&&PutToDebugLog(5,"EVENT, (warn) no selected gw at presence. using the first/default"),p=0);var c=PGW_Get(p,PGW_ADDRESS);return c=!0===UseSecureSrvConnection()?"https://"+c:"http://"+c}}catch(u){PutToDebugLogException(2,"common: GetPresenceServer2",u)}return""}function PresenceVerifyuser2(e){try{if(isNull(e)||e.length<1)return;var n="http://";UseSecureSrvConnection()&&(n="https://");var t=GetPresenceServer2();if(t.indexOf("://")>0&&(n=""),isNull(t)||t.length<2)return void PutToDebugLog(3,"ERROR, PresenceVerifyuser2 invalid server");var o=GetHttpAPIKey();GetWebrtcSrvAddr().indexOf("rtc.mizu-voip.com:2443")>=0&&(o="1568108399");UriParser(n+t+"/?apientry=verifyuser&authkey="+o+"&authid=USERNAME&authmd5=MD5VALUE&authsalt=MD5SALT&userlist="+e,"","","","","presence_verify")}catch(i){PutToDebugLogException(2,"common: PresenceVerifyuser2",i)}}function PresenceGet2(e){try{if(isNull(e)||e.length<1)return;if(e.length>128&&e.indexOf(",")<0)return;if(e=e.replace(" ",""),isNull(pgstart_timer)||clearTimeout(pgstart_timer),pgstart_timer=null,(getuseengine().length<1||webphone_api.global.phonestarted<3)&&pgmaxloop<120)return pgmaxloop++,void(pgstart_timer=setTimeout(function(){PresenceGet2(e)},1e3));pgmaxloop=0;var n="",t=GetHttpAPIKey();if(GetPresenceServer2().indexOf("rtc.mizu-voip.com:2443")>=0&&(t="1568108399"),IsMizuServerOrGateway()){var o="http://";IsHttps()&&(o="https://");var i=GetPresenceServer2();if(i.indexOf("://")>0&&(o=""),!isNull(i)&&i.length>2){var a="1";!0===first_presence_req&&(a="0",first_presence_req=!1);var r="";GetParameter("upperserver").length>0&&(r=GetParameter("upperserver")),n=o+i+"/mvapireq/?apientry=presence_get&authkey="+t+"&authid=USERNAME&authmd5=MD5VALUE&authsalt=MD5SALT&ptype="+a+"&domain="+r+"&userlist="+e}}!isNull(enablepres_httpapi)&&enablepres_httpapi>0&&n.length>0&&UriParser(n,"","","","","presence_get"),!isNull(enablepres_webrtc)&&enablepres_webrtc>0&&getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.PresenceGet(e),!isNull(enablepres_javaapi)&&enablepres_javaapi>0&&(GetParameter("devicetype")===DEVICE_WIN_SOFTPHONE()||getuseengine()===webphone_api.global.ENGINE_SERVICE?WinAPI("API_CheckPresence",null,e):getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.CheckPresence(e))}catch(l){PutToDebugLogException(2,"common: PresenceGet2",l)}}function PresenceSet2(){try{var e="",n=GetParameter("presencestatus");if(IsMizuServerOrGateway()){var t="http://";UseSecureSrvConnection()&&(t="https://");var o=GetPresenceServer2();o.indexOf("://")>0&&(t="");var i=GetHttpAPIKey();GetWebrtcSrvAddr().indexOf("rtc.mizu-voip.com:2443")>=0&&(i="1568108399"),!isNull(o)&&o.length>2&&(e=t+o+"/mvapireq/?apientry=presence_set&authkey="+i+"&authid=USERNAME&authmd5=MD5VALUE&authsalt=MD5SALT&pstatus="+n)}!isNull(enablepres_httpapi)&&enablepres_httpapi>0&&e.length>0&&UriParser(e,"","","","","presence_set"),!isNull(enablepres_webrtc)&&enablepres_webrtc>0&&getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.PresenceSet(n),!isNull(enablepres_javaapi)&&enablepres_javaapi>0&&(GetParameter("devicetype")===DEVICE_WIN_SOFTPHONE()||getuseengine()===webphone_api.global.ENGINE_SERVICE?WinAPI("API_SetPresenceStatus",null,n):getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.SetPresenceStatus(n))}catch(a){PutToDebugLogException(2,"common: PresenceSet2",a)}}function SaveReceivedPresence2(e,n){try{if(isNull(e)||e.length<1)return void PutToDebugLog(3,"ERROR, SaveReceivedPresence2 number is NULL: "+e);if(isNull(n)||n.length<1)return void PutToDebugLog(3,"ERROR, SaveReceivedPresence2 status is NULL: "+n);e=Trim(e),e=e.toLowerCase(),n=Trim(n),n=n.toLowerCase(),"notexists"===n&&(n="not exists");var t=!1,o="-1";if("open"===n||"online"===n||"reachable"===n||"available"===n||"call me"===n||"registered"===n||"ready"===n)o="5",UpdateContactLastActive(e),t=!0;else if("dnd"===n||"busy"===n||"donotdisturb"===n)o="4",t=!0;else if("pending"===n||"forwarding"===n||"speaking"===n||"callsetup"===n)o="3",t=!0;else if("away"===n||"idle"===n)o="2",t=!0;else if("invisible"===n)o="1",t=!0;else if("closed"===n||"close"===n||"unreachable"===n||"offline"===n||"unregistered"===n)o="0",t=!0;else{if("unknown"!==n&&"not set"!==n&&"not exists"!==n)return"-2";o="-1",t=!0}var i=GetTickCount().toString();if(webphone_api.global.presenceHM[e]=[],webphone_api.global.presenceHM[e][PRES_STATUS]=o,webphone_api.global.presenceHM[e][PRES_TIME]=i,!1===t&&PutToDebugLog(3,"ERROR, SaveReceivedPresence2 invalid status: "+n),!isNull(webphone_api.global.checkpres_callback)&&webphone_api.global.checkpres_callback.length>0){var a=webphone_api.global.checkpres_callback.pop();a&&"function"==typeof a&&a(e,n)}return o}catch(r){PutToDebugLogException(2,"common: SaveReceivedPresence2",r)}return"-1"}function StartPresence2(){try{if(!UsePresence2())return;if(!0===webphone_api.global.presence_started)return;if(isNull(startpres_timer)||clearTimeout(startpres_timer),startpres_timer=null,(getuseengine().length<1||webphone_api.global.phonestarted<3)&&spmaxloop<120)return spmaxloop++,void(startpres_timer=setTimeout(function(){StartPresence2()},1e3));spmaxloop=0,webphone_api.global.presence_started=!0,PutToDebugLog(2,"EVENT, common StartPresence2");var e=GetParameterInt("verifyuser",0),n=GetAllContactsNumbersSipuris();isNull(n)&&(n=""),n.length>0&&(n=ReplaceAll(n," ",""),n=ReplaceAll(n,"-",""),n=ReplaceAll(n,"(",""),n=ReplaceAll(n,")","")),n.length>0&&(GetParameter("devicetype")!==DEVICE_WIN_SOFTPHONE()&&getuseengine()!==webphone_api.global.ENGINE_SERVICE||WinAPI("API_PushContactlist",null,n),getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.PushContactlist(n)),webphone_api.global.isdebugversion||e<1||GetTickCount()-e>2592e6?(PutToDebugLog(2,"EVENT, common StartPresence2 verifyuser"),PresenceVerifyuser2(n),SaveParameter("verifyuser",GetTickCount())):PresenceGet2(GetParameter("srvcontacts"))}catch(t){PutToDebugLogException(2,"common: StartPresence2",t)}}function PresenceProcessUserlist2(e,n){try{if(isNull(e)||e.length<1)return;if(e=e.toString(),e.toLowerCase().indexOf("error")>=0||e.toLowerCase().indexOf("auserlist:")<0&&e.toLowerCase().indexOf("puserlist:")<0)return void(e.toLowerCase().indexOf("no users found")>=0?PutToDebugLog(2,"EVENT, PresenceProcessUserlist2: no users: "+e):0==e.toLowerCase().indexOf("<html")?PutToDebugLog(2,"WARNING, PresenceProcessUserlist2: html"):PutToDebugLog(2,"ERROR, PresenceProcessUserlist2: "+e));var t=e;!isNull(t)&&t.length>500&&(t=t.substring(0,500)),PutToDebugLog(4,"EVENT, PresenceProcessUserlist2: "+t);var o=e.indexOf("auserlist:");o<1&&(o=e.indexOf("puserlist:")),o>0&&(e=Trim(e.substring(o+10,e.length)));var i=e.split(",");if(isNull(i)||i.length<1)return;var a=GetParameter("srvcontacts");a.length>128&&a.indexOf(",")<0&&(a="");var r=a.split(",");isNull(r)&&(r=[]);for(var l=0;l<i.length;l++){var s=i[l];if(!(isNull(s)||s.length<1||s.indexOf(":")<0)){var p=Trim(s.substring(0,s.indexOf(":"))),c=Trim(s.substring(s.indexOf(":")+1));if(!(isNull(p)||p.length<1||isNull(c)||c.length<1)){c=c.toLowerCase();var u=SaveReceivedPresence2(p,c);webphone_api._dialpad.PopulateListRecents(),!0===webphone_api.global.isContactdetailsStarted&&webphone_api._contactdetails.PopulateData(),!0===webphone_api.global.isMessageStarted&&webphone_api._message.DisplayPresence(u);for(var g=!0,h=0;h<r.length;h++)if(!isNull(r[h])&&r[h]===p){g=!1;break}g&&r.push(p)}}}var m="";if(!isNull(r)&&r.length>0)for(var l=0;l<r.length;l++)isNull(r[l])||Trim(r[l]).length<1||(m.length>0&&(m+=","),m+=r[l]);m.length>128&&m.indexOf(",")<0||SaveParameter("srvcontacts",m),webphone_api.global.waitforpresence=0}catch(d){PutToDebugLogException(2,"common: PresenceProcessUserlist2",d)}}function PresenceSelector(e,n){try{var t=GetDeviceWidth();t=!isNull(t)&&IsNumber(t)&&t>100?Math.floor(t/1.2):220,t>400?t=400:t<120&&(t=120),PutToDebugLog(2,"EVENT, PresenceSelector called from: "+e);var o=GetParameter("presencestatus");(isNull(o)||o.length<1)&&(o="Online",SaveParameter("presencestatus",o));var i="",a="",r="",l="",s="";"Online"===o||"Ready"===o||"Open"===o||"Reachable"===o||"Available"===o||"Registered"===o||"Call Me"===o?i='checked="checked"':"Away"===o||"Idle"===o?a='checked="checked"':"DND"===o?r='checked="checked"':"Invisible"===o?l='checked="checked"':"Offline"!==o&&"Close"!==o&&"Unreachable"!==o&&"Unregistered"!==o||(s='checked="checked"');var p='<form><fieldset data-role="controlgroup"><input name="presence_sel" id="radio_online" value="on" '+i+' type="radio"><label for="radio_online">'+webphone_api.stringres.get("presence_stat_online")+'</label><input name="presence_sel" id="radio_away" value="on" '+a+' type="radio"><label for="radio_away">'+webphone_api.stringres.get("presence_stat_away")+'</label><input name="presence_sel" id="radio_dnd" value="on" '+r+' type="radio"><label for="radio_dnd">'+webphone_api.stringres.get("presence_stat_dnd")+'</label><input name="presence_sel" id="radio_invisible" value="on" '+l+' type="radio"><label for="radio_invisible">'+webphone_api.stringres.get("presence_stat_invisible")+'</label><input name="presence_sel" id="radio_offline" value="on" '+s+' type="radio"><label for="radio_offline">'+webphone_api.stringres.get("presence_stat_offline")+"</label></fieldset></form>",c='<div data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+t+"px; min-width: "+Math.floor(.6*t)+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("presence_title")+'</h1></div><div role="main" class="ui-content">'+p+"</div></div>";n=n||function(){},!1===IsSDK()&&(webphone_api.$.mobile.activePage.append(c).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),n()}})),webphone_api.$(":radio").on("change",function(e){!1===IsSDK()&&webphone_api.$.mobile.activePage.find(".messagePopup").popup("close");var n=webphone_api.$(this).attr("id");if(!(isNull(n)||n.length<1)){var t=n.indexOf("_");t>0&&t<n.length&&(n=n.substring(t+1)),PutToDebugLog(2,"EVENT, PresenceSelector USER selected: "+n),SetSelectedPresence(n)}})}catch(u){PutToDebugLogException(2,"common: PresenceSelector",u)}}function SetSelectedPresence(e,n){try{(isNull(e)||e.length<1)&&(e=GetParameter("presencestatus"),PutToDebugLog(2,"WARNING, SetSelectedPresence invalid status: "+e)),CanLog(3)&&PutToDebugLog(3,"EVENT, SetSelectedPresence status: "+e+"; allow unregister: "+n),e=Trim(e.toLowerCase());var t='<img src="'+GetElementSource()+'images/presence_green.png" />';"offline"===e?(t='<img src="'+GetElementSource()+'images/presence_grey.png" />',SaveParameter("presencestatus","Offline"),!1!==n&&webphone_api.global.phonestarted>2&&(webphone_api.global.pres_unreg_called=!0,PutToDebugLog(2,"EVENT, mlogic API_Unregister SetSelectedPresence Offline"),webphone_api.unregister())):"invisible"===e?(t='<img src="'+GetElementSource()+'images/presence_white.png" />',SaveParameter("presencestatus","Invisible"),!0===webphone_api.global.pres_unreg_called&&webphone_api.global.phonestarted<3&&!0===NeedRegister()&&(webphone_api.global.pres_unreg_called=!1,PutToDebugLog(2,"EVENT, mlogic API_Register SetSelectedPresence invisible"),webphone_api.register())):"away"===e?(t='<img src="'+GetElementSource()+'images/presence_yellow.png" />',SaveParameter("presencestatus","Away"),!0===webphone_api.global.pres_unreg_called&&webphone_api.global.phonestarted<3&&!0===NeedRegister()&&(webphone_api.global.pres_unreg_called=!1,PutToDebugLog(2,"EVENT, mlogic API_Register SetSelectedPresence away"),webphone_api.register())):"dnd"===e?(t='<img src="'+GetElementSource()+'images/presence_red.png" />',SaveParameter("presencestatus","DND"),!0===webphone_api.global.pres_unreg_called&&webphone_api.global.phonestarted<3&&!0===NeedRegister()&&(webphone_api.global.pres_unreg_called=!1,PutToDebugLog(2,"EVENT, mlogic API_Register SetSelectedPresence dnd"),webphone_api.register())):"online"===e&&(t='<img src="'+GetElementSource()+'images/presence_green.png" />',SaveParameter("presencestatus","Online"),!0===webphone_api.global.pres_unreg_called&&webphone_api.global.phonestarted<3&&!0===NeedRegister()&&(PutToDebugLog(2,"EVENT, mlogic API_Register SetSelectedPresence online"),webphone_api.register(),webphone_api.global.pres_unreg_called=!1));var o=document.getElementById("dialpad_presence"),i=document.getElementById("contactslist_presence"),a=document.getElementById("callhistorylist_presence");isNull(o)||(o.innerHTML=t,setTimeout(function(){"undefined"!=typeof webphone_api._dialpad&&null!==webphone_api._dialpad&&webphone_api._dialpad.MeasureDialPad()},10)),isNull(i)||(i.innerHTML=t,setTimeout(function(){"undefined"!=typeof webphone_api._contactslist&&null!==webphone_api._contactslist&&webphone_api._contactslist.MeasureContacslist()},10)),isNull(a)||(a.innerHTML=t,setTimeout(function(){"undefined"!=typeof webphone_api._callhistorylist&&null!==webphone_api._callhistorylist&&webphone_api._callhistorylist.MeasureCallhistorylist()},10)),webphone_api.global.phonestarted>2&&PresenceSet2()}catch(r){PutToDebugLogException(2,"common: SetSelectedPresence",r)}}function HelpWindow(e,n){try{if(60===GetConfigInt("brandid",-1))return void AboutWindow();var t=GetDeviceWidth();t=!isNull(t)&&IsNumber(t)&&t>100?Math.floor(t/1.2):220,t>400?t=400:t<120&&(t=120);var o="",i='<li id="[ITEMID]"><a data-rel="back">[ITEMTITLE]</a></li>',a=ReplaceAll(webphone_api.stringres.get("help_text"),"[BRANDNAME]",GetBrandName()),r=GetBrandName();"cryptphone"!==r.toLowerCase()&&r.toLowerCase().indexOf("mizu")<0&&(a=ReplaceAll(webphone_api.stringres.get("help_text_custom"),"[BRANDNAME]",GetBrandName())),2===GetParameterInt("brandid",-1)&&(a=ReplaceAll('Contact GMSDIALER support:<br /><br /><a href="mailto:support@gmstechuk.com">support@gmstechuk.com</a>',"[BRANDNAME]",GetBrandName()));var l="";!0!==GetParameterBool("customizedversion",!0)&&!0===webphone_api.global.usestorage&&(l='<li id="#item_help"><a href="https://www.mizu-voip.com/Portals/0/Files/Webphone_Documentation.pdf" target="_blank">[ITEMTITLE]</a></li>',l=l.replace("[ITEMTITLE]",GetBrandName()+" "+webphone_api.stringres.get("help_help")),o+=l,l="");var s=GetParameter2("webcallme");!1!==IsWindowsSoftphone()||isNull(s)||1!==s.length||"0"===s||(l=i.replace("[ITEMID]","#item_webcallme"),l=l.replace("[ITEMTITLE]",webphone_api.stringres.get("menu_webcallme")),o+=l,l=""),1===GetLogLevel()?(l=i.replace("[ITEMID]","#item_enablelog"),l=l.replace("[ITEMTITLE]",webphone_api.stringres.get("help_enablelog")),o+=l,l=""):(l=i.replace("[ITEMID]","#item_logwindow"),l=l.replace("[ITEMTITLE]",webphone_api.stringres.get("help_logwindow")),o+=l,l=""),l=i.replace("[ITEMID]","#item_reconnect"),l=l.replace("[ITEMTITLE]",webphone_api.stringres.get("menu_reconnect")),o+=l,l="";webphone_api.global.usestorage&&(l=i.replace("[ITEMID]","#item_upgrade"),l=l.replace("[ITEMTITLE]",webphone_api.stringres.get("btn_upgrade")),o+=l,l=""),l=i.replace("[ITEMID]","#item_about"),l=l.replace("[ITEMTITLE]",webphone_api.stringres.get("help_about")),o+=l,l="";var p='<div id="help_window" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+t+"px; min-width: "+Math.floor(.6*t)+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("menu_help")+'</h1></div><div role="main" class="ui-content adialog_content" style="padding: 0; margin: 0;"><ul id="help_window_ul" data-role="listview" data-inset="true" data-icon="false" style="margin: 0;">'+o+'</ul></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" style="width: 98%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_close")+"</a></div></div>";n=n||function(){},webphone_api.$.mobile.activePage.append(p).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#help_window_ul").off("click","li"),n()}}),webphone_api.$("#help_window_ul").on("click","li",function(e){var n=webphone_api.$(this).attr("id");"#item_help"===n&&(webphone_api.$("#help_window").popup("close"),AlertDialog(GetBrandName()+" "+webphone_api.stringres.get("help_help"),a,null,null,!1)),webphone_api.$("#help_window").on("popupafterclose",function(e){if(webphone_api.$("#help_window").off("popupafterclose"),"#item_proversion"===n)UpgradeToProVersion();else if("#item_upgrade"===n)Opu();else if("#item_loging"===n)LogWindow();else if("#item_rate"===n)alert("not implemented yet");else if("#item_about"===n)AboutWindow();else if("#item_webcallme"===n)GenerateWebcallmeLink();else if("#item_reconnect"===n)PutToDebugLog(2,"EVENT, reconnect request"),webphone_api.global.authenticated_displayed=!1,GetParameter("devicetype")===DEVICE_WIN_SOFTPHONE()||getuseengine()===webphone_api.global.ENGINE_SERVICE?WinAPI("API_Restart",null):getuseengine()===webphone_api.global.ENGINE_JAVA?webphone_api.webphone.Restart():(webphone_api.plhandler.Start(webphone_api.parameters,!1),webphone_api.plhandler.Stop(!0,2),setTimeout(function(){webphone_api.startInner()},1500));else if("#item_enablelog"===n){var t=GetLogLevel();t<webphone_api.global.predefLoglevel&&(t=webphone_api.global.predefLoglevel),SaveParameter("loglevel",t.toString()),SaveParameter("jsscriptevent","3"),webphone_api.setparameter("jsscriptevent","3"),webphone_api.global.loglevel=t}else"#item_logwindow"===n&&webphone_api.$.mobile.changePage("#page_logview",{transition:"pop",role:"page"})})})}catch(c){PutToDebugLogException(2,"common: HelpWindow",c)}}function GenerateWebcallmeLink(){var e=window.location.href;try{if(isNull(e))return;e=Trim(e);var n=e.indexOf("?");n>0&&(e=e.substring(0,n)),n=e.indexOf("#"),n>0&&(e=e.substring(0,n)),e=Trim(e),e+="?wp_serveraddress=YOURSIPDOMAIN&wp_username=USERNAME&wp_password=PASSWORD&wp_callto=CALLEDNUMBER";var t=GetParameter("serveraddress_user"),o=GetSipusername(!0);e=e.replace("YOURSIPDOMAIN",t),e=e.replace("USERNAME","webcallme"),e=e.replace("PASSWORD","webcallme"),e=e.replace("CALLEDNUMBER",o);var i=webphone_api.stringres.get("webcallme_msg")+":";i=i+'<br /><br /><textarea id="webcallme_textarea" class="noshadow" data-theme="a">'+e+"</textarea>",AlertDialog(webphone_api.stringres.get("menu_webcallme"),i,null,null,!1)}catch(a){PutToDebugLogException(2,"common: GenerateWebcallmeLink",a)}}function AboutWindow(){try{if("warble"===GetBrandName().toLowerCase())return void OpenWebURL("https://support.warbleapp.com","");var e=GetBrandName();60===GetConfigInt("brandid",-1)&&(e="VoIPMuchPhone");var n=webphone_api.stringres.get("help_about")+" "+e,t="",o=[];o.push("m"),o.push("i"),o.push("z"),o.push("u"),o.push("-"),o.push("v"),o.push("o"),o.push("i"),o.push("p");var i=o.join("");!isNull(e)&&e.length>0&&(t=t+e+" "+GetVersionStr());var a=GetConfig("homepage");if(!isNull(a)&&a.length>0){var r=a.indexOf(",");r>0&&(a=Trim(a.substring(0,r))),t=t+'<div class="about_item"><a href="'+a+'" target="_blank" onclick="webphone_api.common.OpenLinkInExternalBrowser(\''+a+"')\">"+webphone_api.stringres.get("about_homepage")+"</a></div>"}else if(webphone_api.global.usestorage){var o="http://www."+i+".com/Software/WebPhone.aspx";t=t+'<div class="about_item"><a href="'+o+'" target="_blank" onclick="webphone_api.common.OpenLinkInExternalBrowser(\''+o+"')\">"+webphone_api.stringres.get("about_homepage")+"</a></div>"}var l=GetConfig("supporturl");if(!isNull(l)&&l.length>0)t=t+'<div class="about_item"><a href="'+l+'" target="_blank" onclick="webphone_api.common.OpenLinkInExternalBrowser(\''+l+"')\">"+webphone_api.stringres.get("about_support")+"</a></div>";else{var s=GetConfig("supportmail");!isNull(s)&&s.length>0?t=t+'<div class="about_item"><a href="mailto:'+s+'" target="_blank" onclick="webphone_api.common.OpenLinkInExternalBrowser(\''+s+"')\">"+webphone_api.stringres.get("about_support")+"</a></div>":webphone_api.global.usestorage&&(s="support@"+i+".com",t=t+'<div class="about_item"><a href="mailto:'+s+'" target="_blank" onclick="webphone_api.common.OpenLinkInExternalBrowser(\''+s+"')\">"+webphone_api.stringres.get("about_support")+"</a></div>")}var p=GetConfig("logo");!isNull(p)&&p.length>2&&(p.toLowerCase().indexOf(".jpg")>0||p.toLowerCase().indexOf(".jpeg")>0||p.toLowerCase().indexOf(".png")>0||p.toLowerCase().indexOf(".gif")>0)&&(t=t+'<br /><img src="'+GetElementSource()+"images/"+p+'" style="width: 100%; border: 0;">');var c=GetConfig("companyname"),u=new Date,g=u.getFullYear();if(!isNull(c)&&c.length>0)t=t+'<div class="about_item2"><i>'+webphone_api.stringres.get("about_copyright")+" "+g+" "+c+"<br />"+webphone_api.stringres.get("about_copyright2")+"</i></div>";else if(webphone_api.global.usestorage){var h=[];h.push("M"),h.push("i"),h.push("z"),h.push("u"),h.push("t"),h.push("e"),h.push("c"),h.push("h "),h.push("S"),h.push("R"),h.push("L"),c=h.join(""),t=t+'<div class="about_item2"><i>'+webphone_api.stringres.get("about_copyright")+" "+g+" "+c+"<br />"+webphone_api.stringres.get("about_copyright2")+"</i></div>"}var m=GetConfig("licenseurl");t=!isNull(m)&&m.length>0?t+'<div class="about_item2"><a href="'+m+'" target="_blank" onclick="webphone_api.common.OpenLinkInExternalBrowser(\''+m+"')\">"+webphone_api.stringres.get("about_license")+"</a></div>":t+'<div class="about_item2"><a href="javascript:;" onclick="webphone_api.common.LicenseAgreementWindow()">'+webphone_api.stringres.get("about_license")+"</a></div>",IsWindowsSoftphone()&&"true"==GetConfig("needactivation")&&!1===CanShowLicKeyInput()&&(t=t+'<div class="about_item2"><i>'+webphone_api.stringres.get("activated")+"</i></div>"),AlertDialog(n,t,null,null,!1)}catch(d){PutToDebugLogException(2,"common: AboutWindow",d)}}function Opu(){try{var e=[];e.push("h"),e.push("t"),e.push("t"),e.push("p"),e.push("s"),e.push(":"),e.push("/"),e.push("/"),e.push("w"),e.push("w"),e.push("w"),e.push("."),e.push("m"),e.push("i"),e.push("z"),e.push("u"),e.push("-"),e.push("v"),e.push("o"),e.push("i"),e.push("p"),e.push("."),e.push("c"),e.push("o"),e.push("m"),e.push("/"),e.push("S"),e.push("u"),e.push("p"),e.push("p"),e.push("o"),e.push("r"),e.push("t"),e.push("/"),e.push("W"),e.push("e"),e.push("b"),e.push("p"),e.push("h"),e.push("o"),e.push("n"),e.push("e"),e.push("p"),e.push("r"),e.push("i"),e.push("c"),e.push("i"),e.push("n"),e.push("g"),e.push("."),e.push("a"),e.push("s"),e.push("p"),e.push("x"),e.push("?"),e.push("S"),e.push("k"),e.push("i"),e.push("n"),e.push("S"),e.push("r"),e.push("c"),e.push("="),e.push("P"),e.push("o"),e.push("r"),e.push("t"),e.push("a"),e.push("l"),e.push("s"),e.push("/"),e.push("_"),e.push("d"),e.push("e"),e.push("f"),e.push("a"),e.push("u"),e.push("l"),e.push("t"),e.push("/"),e.push("S"),e.push("k"),e.push("i"),e.push("n"),e.push("s"),e.push("/"),e.push("D"),e.push("a"),e.push("r"),e.push("k"),e.push("K"),e.push("n"),e.push("i"),e.push("g"),e.push("h"),e.push("t"),e.push("M"),e.push("o"),e.push("b"),e.push("i"),e.push("l"),e.push("e"),e.push("/"),e.push("h"),e.push("o"),e.push("m"),e.push("e"),e.push("&"),e.push("C"),e.push("o"),e.push("n"),e.push("t"),e.push("a"),e.push("i"),e.push("n"),e.push("r"),e.push("S"),e.push("r"),e.push("c"),e.push("="),e.push("P"),e.push("o"),e.push("r"),e.push("t"),e.push("a"),e.push("l"),e.push("s"),e.push("/"),e.push("_"),e.push("d"),e.push("e"),e.push("f"),e.push("a"),e.push("u"),e.push("l"),e.push("t"),e.push("/"),e.push("C"),e.push("o"),e.push("n"),e.push("t"),e.push("a"),e.push("i"),e.push("n"),e.push("e"),e.push("r"),e.push("s"),e.push("/"),e.push("D"),e.push("a"),e.push("r"),e.push("k"),e.push("K"),e.push("n"),e.push("i"),e.push("g"),e.push("h"),e.push("t"),e.push("/"),e.push("P"),e.push("a"),e.push("g"),e.push("e"),e.push("T"),e.push("i"),e.push("T"),e.push("i"),e.push("t"),e.push("l"),e.push("l"),e.push("e"),e.push("_"),e.push("B"),e.push("l"),e.push("u"),e.push("e");var n=e.join(""),t=window.open(n);t&&!t.closed&&"undefined"!=typeof t.closed||OpenWebURL(n,"")}catch(o){PutToDebugLogException(2,"common: Abs",o)}}function LicenseAgreementWindow(){try{var e=GetConfig("companyname"),n=GetConfig("brandname");if((isNull(e)||e.length<2)&&webphone_api.global.usestorage){var t=[];t.push("M"),t.push("i"),t.push("z"),t.push("u"),t.push("t"),t.push("e"),t.push("c"),t.push("h "),t.push("S"),t.push("R"),t.push("L"),e=t.join("")}(isNull(e)||e.length<2)&&(e=n);var o="";o=!0===webphone_api.global.usestorage||Strl(60)?ReplaceAll(webphone_api.stringres.get("dlg_about_msg"),"[BRANDNAME]",n):ReplaceAll(webphone_api.stringres.get("dlg_about_msg2"),"[BRANDNAME]",n),o=ReplaceAll(o,"[APPVERSION]",GetVersionStr());var i=e;(isNull(i)||i.length<2)&&(i=n),o=ReplaceAll(o,"[COMPANY]",i),webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),setTimeout(function(){AlertDialog(webphone_api.stringres.get("about_license"),o.toString(),null,null,!1)},200)}catch(a){PutToDebugLogException(2,"common: LicenseAgreementWindow",a)}}function LogWindow(e){try{var n=GetDeviceWidth();n=!isNull(n)&&IsNumber(n)&&n>100?Math.floor(n/1.2):220,n>400?n=400:n<120&&(n=120);var t="",o='<li id="[ITEMID]"><a data-rel="back">[ITEMTITLE]</a></li>',i="";1!==GetParameterInt("loglevel",1)?(i=o.replace("[ITEMID]","#item_stoplog"),i=i.replace("[ITEMTITLE]",webphone_api.stringres.get("help_stoplog")),t+=i,i="",i=o.replace("[ITEMID]","#item_sendlog"),i=i.replace("[ITEMTITLE]",webphone_api.stringres.get("help_sendlog")),t+=i,i=""):(i=o.replace("[ITEMID]","#item_startlog"),i=i.replace("[ITEMTITLE]",webphone_api.stringres.get("help_startlog")),t+=i,i="");var a='<div id="log_window" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+n+"px; min-width: "+Math.floor(.6*n)+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("help_loging")+'</h1></div><div role="main" class="ui-content adialog_content" style="padding: 0; margin: 0;"><ul id="log_window_ul" data-role="listview" data-inset="true" data-icon="false" style="margin: 0;">'+t+'</ul></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" style="width: 98%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_close")+"</a></div></div>";e=e||function(){},webphone_api.$.mobile.activePage.append(a).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#log_window_ul").off("click","li"),e()}}),webphone_api.$("#log_window_ul").on("click","li",function(e){var n=webphone_api.$(this).attr("id");webphone_api.$("#log_window").on("popupafterclose",function(e){if(webphone_api.$("#log_window").off("popupafterclose"),"#item_startlog"===n){var t=GetLogLevel();t<webphone_api.global.predefLoglevel&&(t=webphone_api.global.predefLoglevel),SaveParameter("loglevel",t.toString()),SaveParameter("jsscriptevent","3"),webphone_api.setparameter("jsscriptevent","3"),webphone_api.global.loglevel=t}else"#item_stoplog"===n?(SaveParameter("loglevel","1"),SaveParameter("jsscriptevent","2"),webphone_api.setparameter("jsscriptevent","2"),webphone_api.global.loglevel=1,webphone_api.$("#log_text").html("")):"#item_sendlog"===n&&webphone_api.$.mobile.changePage("#page_logview",{transition:"pop",role:"page"})})})}catch(r){PutToDebugLogException(2,"common: LogWindow",r)}}function UpgradeToProVersion(e){try{var n=GetDeviceWidth();n=!isNull(n)&&IsNumber(n)&&n>100?Math.floor(n/1.2):220,n>400?n=400:n<120&&(n=120)
;var t='<div data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+n+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("help_proversion")+'</h1></div><div role="main" class="ui-content adialog_content adialog_alert"><span> '+webphone_api.stringres.get("proversion_content_text")+' </span><br /><button id="btn_buynow">Buy now</button><br />'+webphone_api.stringres.get("license_key")+': <input type="text" id="proversion_input" name="setting_item" data-theme="a" placeholder="'+webphone_api.stringres.get("enter_license_key")+'" autocapitalize="off"/></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="btn_upgrade" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_activate")+'</a><a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_close")+"</a></div></div>";e=e||function(){},webphone_api.$.mobile.activePage.append(t).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").bind({popupbeforeposition:function(){webphone_api.$(this).unbind("popupbeforeposition");var e=Math.floor(.6*GetDeviceHeight());webphone_api.$(this).height()>e&&webphone_api.$(".messagePopup .ui-content").height(e)}}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#btn_upgrade").off("click"),e()}}),webphone_api.$("#btn_upgrade").on("click",function(){var e=document.getElementById("proversion_input").value;if(isNull(e)||Trim(e).length<1)return void ShowToast("Invalid license key.");e=Trim(e),WinAPI("API_EnterLicKey",function(e){},e),setTimeout(function(){canshowlickeyinput=null,CanShowLicKeyInput()},1e4)}),webphone_api.$("#btn_buynow").on("click",function(){OpenLinkInExternalBrowser("https://www.mizu-voip.com/Support/Store.aspx")})}catch(o){PutToDebugLogException(2,"common: UpgradeToProVersion",o)}}function GetTickCount(){try{return(new Date).getTime()}catch(e){PutToDebugLogSpecial(2,"common: GetTickCount",!0,e)}return 0}function HoverCalc(e,n){try{var t=e,o=e.indexOf("#");if(o>=0&&(e=e.substring(o+1)),6===e.length){var i=parseInt(e.substring(0,2),16),a=parseInt(e.substring(2,4),16),r=parseInt(e.substring(4,6),16);i+n>255?i-=n:i+n<0?i-=n:i+=n,a+n>255?a-=n:a+n<0?a-=n:a+=n,r+n>255?r-=n:r+n<0?r-=n:r+=n,i=i.toString(16),a=a.toString(16),r=r.toString(16),i.length<2&&(i="0"+i),a.length<2&&(a="0"+a),r.length<2&&(r="0"+r),e="#"+i+a+r}else{if(3!==e.length)return t;var i=parseInt(e.substring(0,1),16),a=parseInt(e.substring(1,2),16),r=parseInt(e.substring(2,3),16);i+n>255?i-=n:i+n<0?i-=n:i+=n,a+n>255?a-=n:a+n<0?a-=n:a+=n,r+n>255?r-=n:r+n<0?r-=n:r+=n,i=i.toString(16),a=a.toString(16),r=r.toString(16),i.length<2&&(i="0"+i),a.length<2&&(a="0"+a),r.length<2&&(r="0"+r),e="#"+i+a+r}return e}catch(l){PutToDebugLogException(2,"common: HoverCalc",l)}return""}function IsIeLocal(){try{if(!0===lf_isconfigured)return isielocal;lf_isconfigured=!0;var e=GetBrowser();if(isNull(e))return;e=e.toLowerCase();var n=window.location.href;if(isNull(n))return;n=n.toLowerCase(),n=Trim(n),"msie"===e&&n.indexOf("http")<0&&n.indexOf("https")<0&&(isielocal=!0,PutToDebugLog(2,"EVENT, common: IsIeLocalFilesystem: IE from local file system"))}catch(t){PutToDebugLogException(2,"common: IsIeLocal",t)}return isielocal}function IsIeVersion(e){try{if(isNull(e))return!1;var n=navigator.userAgent,t=n.match(/MSIE\s?(\d+)(?:\.(\d+))?/i);if(!isNull(t)&&!isNull(t[0])&&t[0].indexOf(e)>=0)return!0}catch(o){PutToDebugLogException(2,"common: IsIeVersion",o)}return!1}function GetBrowser(){try{if(isNull(browserName)||isNull(browserName2)){var e=navigator.userAgent.toLowerCase();-1!==e.indexOf("edge")?(browserName="Edge",browserName2="Edge"):-1!==e.indexOf("msie")&&-1===e.indexOf("opera")?(browserName="MSIE",browserName2="MSIE"):-1!==e.indexOf("trident")||-1!==e.indexOf("Trident")?(browserName="MSIE",browserName2="MSIE"):-1!==e.indexOf("iphone")?(browserName2=-1!==e.indexOf("fxios")||-1!==e.indexOf("firefox")?"Firefox":-1!==e.indexOf("crios")||-1!==e.indexOf("chrome")?"Chrome":"iPhone",browserName="Netscape Family"):-1!==e.indexOf("firefox")&&-1===e.indexOf("opera")?(browserName="Netscape Family",browserName2="Firefox"):-1!==e.indexOf("chrome")?(browserName="Netscape Family",browserName2="Chrome","Android"===GetOs()&&(e=e.replace("mozilla/",""),browserName2=e.match(/\/\d\.\d /i)?"AndroidNative":"Chrome")):-1!==e.indexOf("safari")?(browserName="Netscape Family",browserName2="Safari"):-1!==e.indexOf("mozilla")&&-1===e.indexOf("opera")?(browserName="Netscape Family",browserName2="Other"):-1!==e.indexOf("opera")?(browserName="Netscape Family",browserName2="Opera"):(browserName="?",browserName2="unknown")}}catch(n){PutToDebugLogException(2,"common: GetBrowser",n)}return browserName2}function GetBrowserVersion(){try{if(browserversion>0)return browserversion;var e=GetBrowser(),n=navigator.userAgent.toLowerCase();if("Chrome"===e){var t=n.indexOf("chrome");t>0&&(n=n.substring(t+6)),isNull(n)||(n=n.replace("/","")),t=n.indexOf("."),t>0&&(n=n.substring(0,t)),isNull(n)||(n=Trim(n),IsNumber(n)&&(browserversion=StrToInt(n)))}else if("Firefox"===e){var t=n.indexOf("firefox");t>0&&(n=n.substring(t+7)),isNull(n)||(n=n.replace("/","")),t=n.indexOf("."),t>0&&(n=n.substring(0,t)),isNull(n)||(n=Trim(n),IsNumber(n)&&(browserversion=StrToInt(n)))}else if("Safari"===e||"iPhone"===e){var t=n.indexOf("version");t>0?n=n.substring(t+7):n.indexOf("_")>0&&(n=n.substring(0,n.indexOf("_")),n=Trim(n),n=n.substring(n.lastIndexOf(" "))),isNull(n)||(n=n.replace("/","")),t=n.indexOf("."),t>0&&(n=n.substring(0,t)),isNull(n)||(n=Trim(n),IsNumber(n)&&(browserversion=StrToInt(n)))}else if("MSIE"===e){var o=window.navigator.userAgent,i=o.indexOf("MSIE ");i>0&&(browserversion=parseInt(o.substring(i+5,o.indexOf(".",i)),10));var a=o.indexOf("Trident/");if(a>0){var r=o.indexOf("rv:");browserversion=parseInt(o.substring(r+3,o.indexOf(".",r)),10)}var l=o.indexOf("Edge/");l>0&&(browserversion=parseInt(o.substring(l+5,o.indexOf(".",l)),10))}else if("Edge"===e){var t=n.indexOf("edge");t>0&&(n=n.substring(t+4)),isNull(n)||(n=n.replace("/","")),t=n.indexOf("."),t>0&&(n=n.substring(0,t)),isNull(n)||(n=Trim(n),IsNumber(n)&&(browserversion=StrToInt(n)))}!isNull(browserversion)&&IsNumber(browserversion)||(browserversion=-1),webphone_api.global.loglevel=GetLogLevel(),CanLog(2)&&PutToDebugLog(2,"EVENT, common: GetBrowserVersion Detected browser version: "+browserversion)}catch(s){PutToDebugLogException(2,"common: GetBrowserVersion",s)}return browserversion}function IsARM(){try{var e=navigator.userAgent.toLowerCase();if(e.indexOf("arm")>=0&&e.indexOf("x86")<0)return!0}catch(n){PutToDebugLogException(2,"common: IsARM",n)}return!1}function Is64BitBrowser(){try{var e=navigator.userAgent.toLowerCase();return"Firefox"===GetBrowser()&&e.indexOf("x64")>0&&!0,!(e.indexOf("64")<0)}catch(n){PutToDebugLogException(2,"common: Is64BitBrowser",n)}return!1}function GetOs(){var e="";try{if(!isNull(curros)&&curros.length>0)return curros;if(e=webphone_api.platform.os,isNull(e)||(e=e.toString()),isNull(e)||e.length<1)return curros;e=e.toLowerCase(),curros=e.indexOf("windows")>=0?"Windows":e.indexOf("win")<0&&GetBrowserPlatform().toLowerCase().indexOf("win")>=0?"Windows":e.indexOf("mac os x")>=0||"macintosh"==e||"mac"==e?"Mac":e.indexOf("android")>=0?"Android":e.indexOf("centos")>-1||e.indexOf("debian")>-1||e.indexOf("fedora")>-1||e.indexOf("gentoo")>-1||e.indexOf("ubuntu")>-1||e.indexOf("linux mint")>-1||e.indexOf("red hat")>-1||e.indexOf("suse")>-1||e.indexOf("linux")>-1||e.indexOf("x11")>-1||e.indexOf("openbsd")>-1?"Linux":e.indexOf("ios")>=0?"iOS":e.indexOf("osx")>=0||e.indexOf("mac")>=0||e.indexOf("os x")>=0?"Mac":Trim(e),(/iPad|iPhone|iPod/.test(navigator.platform)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&!window.MSStream&&(curros="iOS")}catch(n){PutToDebugLogException(2,"common: GetOs",n)}return curros}function PickContact(e,n){try{var t=GetDeviceWidth();t=!isNull(t)&&IsNumber(t)&&t>100?Math.floor(t/1.2):220,t>400?t=400:t<120&&(t=120);var o=GetDeviceHeight();o=!isNull(o)&&IsNumber(o)&&o>100?Math.floor(o/1.5):250;for(var i="",a=0;a<webphone_api.global.ctlist.length;a++){var r=webphone_api.global.ctlist[a];if(!(isNull(r)||r.length<1)){var l=r[CT_NAME];if(isNull(l)||l.length<1){var s=p[CT_NUMBER];if(isNull(s)||s.length<1||isNull(s[0])||s[0].length<1)continue;l=s[0]}var p='<li id="pickcontact_'+a+'"><a data-rel="back">'+l+"</a></li>";i+=p}}var c='<div id="pickcontact_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+t+"px; min-width: "+Math.floor(.6*t)+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("pick_ct")+'</h1></div><div role="main" class="ui-content adialog_content adialog_alert" style="padding: 0; margin: 0;"><ul id="pickcontact_ul" data-role="listview" data-inset="true" data-icon="false" data-filter="true" data-filter-placeholder="Search Contacts" data-autodividers="true" style="margin: 0; max-height: '+o+'px;">'+i+'</ul></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" style="width: 98%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_close")+"</a></div></div>";n=n||function(){},!1===IsSDK()&&(webphone_api.$.mobile.activePage.append(c).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#pickcontact_ul").off("click","li"),n()}})),webphone_api.$("#pickcontact_ul").on("click","li",function(n){var t=webphone_api.$(this).attr("id"),o="",i=t.indexOf("_");if(i<2)return void PutToDebugLog(2,"ERROR, common PickContact OnListItemClick invalid id: "+t);o=Trim(t.substring(i+1));var a=webphone_api.global.ctlist[o];if(isNull(a)||a.length<1)return void PutToDebugLog(3,"ERROR, PickContact ctentry is NULL");var r=a[CT_NUMBER];webphone_api.$("#pickcontact_popup").on("popupafterclose",function(n){if(webphone_api.$("#pickcontact_popup").off("popupafterclose"),1===r.length)return void e(r[0],a[CT_NAME]);PickContactNumber(o,e)})})}catch(u){PutToDebugLogException(2,"common: PickContact",u)}}function PickContactNumber(e,n,t){try{if(!n||"function"!=typeof n)return void PutToDebugLog(2,"ERROR, PickContactNumber callback is NULL");var o=GetDeviceWidth();o=!isNull(o)&&IsNumber(o)&&o>100?Math.floor(o/1.2):220,o>400?o=400:o<120&&(o=120);var i=webphone_api.global.ctlist[e];if(isNull(i)||i.length<1)return void PutToDebugLog(3,"ERROR, PickContactNumber ctentry is NULL");for(var a=i[CT_NUMBER],r="",l=0;l<a.length;l++)if(!(isNull(a[l])||a[l].length<1)){var s='<li id="pickcontactnumber_'+l+'"><a data-rel="back">'+a[l]+"</a></li>";r+=s}var p='<div id="pickcontactnumber_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+o+"px; min-width: "+Math.floor(.6*o)+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+i[CT_NAME]+'</h1></div><div role="main" class="ui-content adialog_content adialog_alert" style="padding: 0; margin: 0;"><ul id="pickcontactnumber_ul" data-role="listview" data-inset="true" data-icon="false" style="margin: 0;">'+r+'</ul></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" style="width: 98%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_close")+"</a></div></div>";t=t||function(){},!1===IsSDK()&&(webphone_api.$.mobile.activePage.append(p).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#pickcontactnumber_ul").off("click","li"),t()}})),webphone_api.$("#pickcontactnumber_ul").on("click","li",function(e){var t=webphone_api.$(this).attr("id"),o="",r=t.indexOf("_");if(r<2)return void PutToDebugLog(2,"ERROR, common PickContactNumber OnListItemClick invalid nrid: "+t);o=Trim(t.substring(r+1)),webphone_api.$("#pickcontactnumber_popup").on("popupafterclose",function(e){webphone_api.$("#pickcontactnumber_popup").off("popupafterclose"),n(a[o],i[CT_NAME])})})}catch(c){PutToDebugLogException(2,"common: PickContactNumber",c)}}function NormalizeNumber(e){try{if(isNull(e))return"";if(e=Trim(e),e=NormalizeInput(e,0),!IsWindowsSoftphone()&&(getuseengine()===webphone_api.global.ENGINE_WEBRTC||getuseengine()===webphone_api.global.ENGINE_FLASH)){var n=GetParameter2("techprefix");(!isNull(n)||n.length>0)&&(n=Trim(n),e=n+e)}var t=GetParameterInt("normalizenumber",-1);if(0==t||-2==t)return ApplyFilters(e);for(var o="",i=0;i<e.length;i++)e.charAt(i)>30&&" "!=e.charAt(i)&&"\t"!=e.charAt(i)&&"\r"!=e.charAt(i)&&"\n"!=e.charAt(i)&&"["!=e.charAt(i)&&"]"!=e.charAt(i)&&"("!=e.charAt(i)&&")"!=e.charAt(i)&&(o+=e.charAt(i));if(o.length>0&&(e=o),t<1&&(e.length<6||e.length>20))return ApplyFilters(e);if(t>=1&&(e.length<3||e.length>40))return ApplyFilters(e);if(t<1){var a=GetSipusername(!0);if(!isNull(a)&&a.length>0&&a!==NormalizeInput2(a,1))return ApplyFilters(e);for(var r=0,i=0;i<e.length;i++)e.charAt(i)>="0"&&e.charAt(i)<="9"&&r++;if(r<5)return ApplyFilters(e);for(var i=0;i<e.length;i++)if(e.charAt(i)>="a"&&e.charAt(i)<="z"||e.charAt(i)>="A"&&e.charAt(i)<="Z"||"@"==e.charAt(i))return ApplyFilters(e)}o="";for(var i=0;i<e.length;i++)(e.charAt(i)>="0"&&e.charAt(i)<="9"||"*"==e.charAt(i)||","==e.charAt(i)||"#"==e.charAt(i)||0==i&&"+"==e.charAt(i))&&(o+=e.charAt(i));return o.length>0&&(e=o),ApplyFilters(e)}catch(l){PutToDebugLogException(2,"common: NormalizeNumber",l)}return ApplyFilters(e)}function NormalizeInputBasic(e,n){try{var t=e;return isNull(t)?"":(t=t.toString(),t=Trim(t),t=ReplaceAll(t,"WSS://","wss://"),t=ReplaceAll(t,"WS://","ws://"),t=ReplaceAll(t,"SIP:",""),t=ReplaceAll(t,"sip:",""),t=ReplaceAll(t,"SIPS:",""),t=ReplaceAll(t,"sips:",""),t=ReplaceAll(t,"UDP:",""),t=ReplaceAll(t,"udp:",""),t=ReplaceAll(t,"TCP:",""),t=ReplaceAll(t,"tcp:",""),t=ReplaceAll(t,"URL:",""),t=ReplaceAll(t,"url:",""),t=ReplaceAll(t,"TEL:",""),t=ReplaceAll(t,"tel:",""),t=ReplaceAll(t,"HTTPS://","https://"),t=ReplaceAll(t,"HTTP://","http://"),t=ReplaceAll(t,"'",""),t=ReplaceAll(t,'"',""))}catch(o){PutToDebugLogException(2,"common: NormalizeInputBasic",o)}return e}function NormalizeInput(e,n){try{var t=e;return isNull(t)?"":(t=t.toString(),t=Trim(t),n<1&&(t=ReplaceAll(t,"WSS://",""),t=ReplaceAll(t,"wss://",""),t=ReplaceAll(t,"WSS:",""),t=ReplaceAll(t,"wss:",""),t=ReplaceAll(t,"WS://",""),t=ReplaceAll(t,"ws://",""),t=ReplaceAll(t,"WS:",""),t=ReplaceAll(t,"ws:","")),t=ReplaceAll(t,"SIP:",""),t=ReplaceAll(t,"sip:",""),t=ReplaceAll(t,"SIPS:",""),t=ReplaceAll(t,"sips:",""),t=ReplaceAll(t,"UDP:",""),t=ReplaceAll(t,"udp:",""),t=ReplaceAll(t,"TCP:",""),t=ReplaceAll(t,"tcp:",""),t=ReplaceAll(t,"URL:",""),t=ReplaceAll(t,"url:",""),t=ReplaceAll(t,"TEL:",""),t=ReplaceAll(t,"tel:",""),t=ReplaceAll(t,"HTTPS://",""),t=ReplaceAll(t,"https://",""),t=ReplaceAll(t,"HTTPS:",""),t=ReplaceAll(t,"https:",""),t=ReplaceAll(t,"HTTP://",""),t=ReplaceAll(t,"http://",""),t=ReplaceAll(t,"HTTP:",""),t=ReplaceAll(t,"http:",""),t=ReplaceAll(t,"'",""),t=ReplaceAll(t,'"',""),0==t.indexOf("//")&&(t=StrGetAfter(t,"//")),0==t.indexOf("//")&&(t=StrGetAfter(t,"//")),0==t.indexOf("/")&&(t=StrGetAfter(t,"/")),t)}catch(o){PutToDebugLogException(2,"common: NormalizeInput",o)}return e}function NormalizeInput2(e,n){try{var t=e;if(isNull(t))return"";t=t.toString(),t=Trim(t),t=NormalizeInput(t,0);var o=t.split("");if(isNull(o)||o.length<1)return e;if(n<1){for(var i=0;i<o.length;i++)o[i]>="0"&&o[i]<="9"||(o[i]="");return o.join("")}if(1===n){for(var i=0;i<o.length;i++)o[i]>="0"&&o[i]<="9"||o[i]>="A"&&o[i]<="Z"||o[i]>="a"&&o[i]<="z"||"_"===o[i]||"."===o[i]||"-"===o[i]||(o[i]="_");return o.join("")}if(2===n){for(var i=0;i<o.length;i++)o[i]>="0"&&o[i]<="9"||o[i]>="A"&&o[i]<="Z"||o[i]>="a"&&o[i]<="z"||"_"===o[i]||"."===o[i]||"-"===o[i]||" "===o[i]||(o[i]="_");return o.join("")}for(var i=0;i<o.length;i++)o[i]>="0"&&o[i]<="9"||o[i]>="A"&&o[i]<="Z"||o[i]>="a"&&o[i]<="z"||"_"===o[i]||"."===o[i]||"-"===o[i]||" "===o[i]||"+"===o[i]||":"===o[i]||"@"===o[i]||(o[i]="_");return o.join("")}catch(a){PutToDebugLogException(2,"common: NormalizeInput2",a)}return e}function PasswordStringIsValidForServer(e){try{if(isNull(e)||e.length<1)return!1;for(var n=0;n<e.length;n++)if(e.charCodeAt(n)<33||e.charCodeAt(n)>126||"'"===e.charAt(n)||'"'===e.charAt(n)||"<"===e.charAt(n)||">"===e.charAt(n))return!1}catch(t){PutToDebugLogException(2,"common: PasswordStringIsValidForServer",t)}return!0}function UsernameStringIsValidForServer(e){try{if(isNull(e)||e.length<1)return!1;for(var n=0;n<e.length;n++)if(!(e.charAt(n)>="0"&&e.charAt(n)<="9"||e.charAt(n)>="a"&&e.charAt(n)<="z"||e.charAt(n)>="A"&&e.charAt(n)<="Z"||"#"===e.charAt(n)||"*"===e.charAt(n)||"("===e.charAt(n)||")"===e.charAt(n)||"["===e.charAt(n)||"]"===e.charAt(n)||"{"===e.charAt(n)||"}"===e.charAt(n)||"+"===e.charAt(n)||"."===e.charAt(n)||","===e.charAt(n)||"/"===e.charAt(n)||"\\"===e.charAt(n)||"_"===e.charAt(n)||"-"===e.charAt(n)||"^"===e.charAt(n)||"~"===e.charAt(n)||"!"===e.charAt(n)))return!1}catch(t){PutToDebugLogException(2,"common: UsernameStringIsValidForServer",t)}return!0}function ApplyFilters(e){try{if(isNull(e))return"";e=Trim(e),PutToDebugLog(4,"EVENT, normalized number: "+e);var n=GetParameter("filters");if(isNull(n)||n.length<3)return e;var t=n.split(";");if(isNull(t)||t.length<1)return e;for(var o=0;o<t.length;o++)if(!isNull(t[o])){var i=t[o].split(",");if(!isNull(i)&&4===i.length){var a="",r="",l=-1,s=-1;try{if(a=i[F_WHAT],r=i[F_WITH],isNull(a)&&(a=""),isNull(r)&&(r=""),a.length<1&&r.length<1)continue;!isNull(i[F_MIN])&&IsNumber(i[F_MIN])&&(l=StrToInt(i[F_MIN])),!isNull(i[F_MAX])&&IsNumber(i[F_MAX])&&(s=StrToInt(i[F_MAX])),0!==a.length&&0!==e.indexOf(a)||(l<0&&s<0?e=e.replace(a,r):l<0&&s>0&&e.length<=s?e=e.replace(a,r):s<0&&l>0&&e.length>l?e=e.replace(a,r):l>=0&&s>0&&s>=l&&e.length>=l&&e.length<=s&&(e=e.replace(a,r)))}catch(p){}}}PutToDebugLog(4,"EVENT, filtered number: "+e)}catch(c){PutToDebugLogException(2,"common: ApplyFilters",c)}return e}function getBrowserLanguage(){var e=null;return isNull(window)||(e=window.navigator),isNull(e)&&(e=navigator),isNull(e)?"":!isNull(e.languages)&&Array.isArray(e.languages)&&e.languages.length>0&&!isNull(e.languages[0])&&e.languages[0].length>1?e.languages[0]:!isNull(e.language)&&e.language.length>1?e.language:!isNull(e.userLanguage)&&e.userLanguage.length>1?e.userLanguage:!isNull(e.systemLanguage)&&e.systemLanguage.length>1?e.systemLanguage:!isNull(e.browserLanguage)&&e.browserLanguage.length>1?e.browserLanguage:""}function InitializeSettings(){var e=0;try{e=1,CanLog(2)&&PutToDebugLog(2,"EVENT, common: InitializeSettings called");var n="",t="2";!isNull(GetConfig("upperserverfromuser"))&&GetConfig("upperserverfromuser").length>0&&(t=Trim(GetConfig("upperserverfromuser"))),SettingItem("upperserverfromuser",t,"-1",GROUP_NOGROUP,"","","1","2"),e=2,"9999"!==GetConfig("brandid")&&(!1===RequestUserServerInput(t)&&!isNull(GetConfig("serveraddress"))&&GetConfig("serveraddress").length>0&&(n=Trim(GetConfig("serveraddress"))),SettingItem("serveraddress_user",n,"8",GROUP_LOGIN,"","","1","")),e=3,SettingItem("serveraddress_orig","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("upperserver","","-1","-1","","","1",""),SettingItem("sipusername","","1",GROUP_LOGIN,"","","1",""),SettingItem("password","","1",GROUP_LOGIN,"","","1",""),SettingItem("settlevelbasic","true","-1",GROUP_NOGROUP,"","","1","true"),SettingItem("submenu_sipsettings","","6",GROUP_MAIN,"","","1",""),SettingItem("submenu_media","","6",GROUP_MAIN,"","","1",""),SettingItem("submenu_video","","6",GROUP_MEDIA,"","","1",""),SettingItem("submenu_calldivert","","6",GROUP_MAIN,"","","1",""),SettingItem("submenu_general","","6",GROUP_MAIN,"","","1",""),SettingItem("submenu_profile","","6",GROUP_MAIN,"","","1",""),SettingItem("advancedloginsettings2","","6",GROUP_SIP,"","","1",""),SettingItem("submenu_integrate","","6",GROUP_GENERAL,"","","1",""),SettingItem("submenu_screenshare","","6",GROUP_MEDIA,"","","1",""),e=4;var o="true";!isNull(GetConfig("customizedversion"))&&GetConfig("customizedversion").length>0&&(o=Trim(GetConfig("customizedversion"))),SettingItem("customizedversion",o,"-1",GROUP_NOGROUP,"","","1","true");var i="1";!isNull(GetConfig("autoprovisioning"))&&GetConfig("autoprovisioning").length>0&&(i=Trim(GetConfig("autoprovisioning"))),!0!==i&&"true"!==i||(i="1"),!1!==i&&"false"!==i||(i="0"),SettingItem("autoprovisioning",i,"-1",GROUP_NOGROUP,"","","1","1");var a="Server";!isNull(GetConfig("server_label"))&&GetConfig("server_label").length>0&&(a=Trim(GetConfig("server_label"))),SettingItem("server_label",a,"-1",GROUP_NOGROUP,"","","1","Server"),e=5;var r="false";!isNull(GetConfig("serverinputisupperserver"))&&GetConfig("serverinputisupperserver").length>0&&(r=Trim(GetConfig("serverinputisupperserver"))),SettingItem("serverinputisupperserver",r,"-1",GROUP_NOGROUP,"","","1","false");var l="";!isNull(GetConfig("serveraddress"))&&GetConfig("serveraddress").length>0&&(l=Trim(GetConfig("serveraddress"))),SettingItem("serveraddress",l,"-1",GROUP_NOGROUP,"","","1","");var s="";!isNull(GetConfig("webrtcserveraddress"))&&GetConfig("webrtcserveraddress").length>0&&(s=Trim(GetConfig("webrtcserveraddress"))),SettingItem("webrtcserveraddress",s,"-1",GROUP_NOGROUP,"","","1","");var p="";!isNull(GetConfig("rtmpserveraddress"))&&GetConfig("rtmpserveraddress").length>0&&(p=Trim(GetConfig("rtmpserveraddress"))),SettingItem("rtmpserveraddress",p,"-1",GROUP_NOGROUP,"","","1","");var c="";!isNull(GetConfig("realm"))&&GetConfig("realm").length>0&&(c=Trim(GetConfig("realm"))),SettingItem("realm",c,"1",GROUP_SIP,"","","1","");var u="1";!isNull(GetConfig("showserverinput"))&&GetConfig("showserverinput").length>0&&(u=Trim(GetConfig("showserverinput"))),SettingItem("showserverinput",u,"-1",GROUP_NOGROUP,"","","1","1");var g="";!isNull(GetConfig("apiv2md5salt"))&&GetConfig("apiv2md5salt").length>0&&(g=Trim(GetConfig("apiv2md5salt"))),SettingItem("apiv2md5salt",g,"-1",GROUP_NOGROUP,"","","1",""),e=6,e=7,SettingItem("displaypopupdirectcalls","true","-1",GROUP_NOGROUP,"","","1","true"),SettingItem("register","1","2",GROUP_SIP,webphone_api.stringres.get("register__no")+","+webphone_api.stringres.get("register__auto")+","+webphone_api.stringres.get("register__yes"),"0,1,2","1","1"),SettingItem("registerinterval","180","1",GROUP_SIP,"","","1","180"),SettingItem("cfgnetworkspeed","0","2",GROUP_MEDIA,"Auto guess,Slow (< 20 KBits on GPRS or 3G),Normal (20 - 60 kbits),Fast (> 60 KBits)","0,1,2,3","1","0"),SettingItem("prefcodec","","3",GROUP_NOGROUP,"","","1",""),SettingItem("dtmfmode","2","2",GROUP_SIP,webphone_api.stringres.get("dtmfmode_op_0")+","+webphone_api.stringres.get("dtmfmode_op_1")+","+webphone_api.stringres.get("dtmfmode_op_2")+","+webphone_api.stringres.get("dtmfmode_op_3")+","+webphone_api.stringres.get("dtmfmode_op_4")+","+webphone_api.stringres.get("dtmfmode_op_5")+","+webphone_api.stringres.get("dtmfmode_op_6"),"0,1,2,3,4,5,6","1","2"),SettingItem("audiorecorder","1","2",GROUP_MEDIA,"Default,Auto guess, Mic,Voice call,Voice downlink,Voice uplink,Voice communication","0,1,2,3,4,5,6","1","1"),SettingItem("audioplayer","-2147483648","2",GROUP_MEDIA,"Default (Automatic),Alarm stream,Music playback,Notifications stream,Ring stream,System sounds,Voice call","-2147483648,4,3,5,2,1,0","1","-2147483648"),SettingItem("speakerphoneplayer","-2147483648","2",GROUP_MEDIA,"Default (Automatic),Alarm stream,Music playback,Notifications stream,Ring stream,System sounds,Voice call,No change","-2147483648,4,3,5,2,1,0,6","1","-2147483648"),SettingItem("speakerphoneoutput","0","2",GROUP_MEDIA,"Auto guess,Speaker,Speaker and mode,VoIP,Bluetooth,Normal,Mode only,No changes","0,1,2,3,4,5,6,7","1","0"),SettingItem("autousebluetooth","0","2",GROUP_MEDIA,"Guess,No,Yes","0,1,2","1","0"),SettingItem("playring","2","2",GROUP_MEDIA,webphone_api.stringres.get("playring__no")+","+webphone_api.stringres.get("playring__incoming")+","+webphone_api.stringres.get("playring__both"),"0,1,2","1","2"),SettingItem("volumein","50","4",GROUP_MEDIA,"","","1","50"),SettingItem("volumeout","50","4",GROUP_MEDIA,"","","1","50"),SettingItem("agc","3","2",GROUP_MEDIA,webphone_api.stringres.get("agc__disabled")+","+webphone_api.stringres.get("agc__for_redcording")+","+webphone_api.stringres.get("agc__both_for_recording_and_playback")+","+webphone_api.stringres.get("agc__guess"),"0,1,2,3","1","3"),SettingItem("aec","1","8",GROUP_MEDIA,"No,Yes except if headset is guessed,Yes if supported,Forced yes even if not supported (might result in unexpected errors)","0,1,2,3","1","1"),SettingItem("denoise","3","2",GROUP_MEDIA,webphone_api.stringres.get("denoise__disabled")+","+webphone_api.stringres.get("denoise__recording")+","+webphone_api.stringres.get("denoise__both")+","+webphone_api.stringres.get("denoise__auto"),"0,1,2,3","1","3"),SettingItem("plc","1","2",GROUP_MEDIA,webphone_api.stringres.get("plc__no")+","+webphone_api.stringres.get("plc__auto")+","+webphone_api.stringres.get("plc__yes"),"0,1,2","1","1"),SettingItem("silencesupress","-1","2",GROUP_MEDIA,webphone_api.stringres.get("silencesupress__auto")+","+webphone_api.stringres.get("silencesupress__no")+","+webphone_api.stringres.get("silencesupress__yes"),"-1,0,1","1","-1"),SettingItem("hardwaremedia","0","2",GROUP_MEDIA,webphone_api.stringres.get("hardwaremedia__auto")+","+webphone_api.stringres.get("hardwaremedia__no")+","+webphone_api.stringres.get("hardwaremedia__yes"),"0,1,2","1","0"),SettingItem("mediaencryption","0","2",GROUP_MEDIA,webphone_api.stringres.get("mediaencryption__no")+","+webphone_api.stringres.get("mediaencryption__auto")+","+webphone_api.stringres.get("mediaencryption__srtp"),"0,1,2","1","0"),SettingItem("setqos","0","2",GROUP_MEDIA,webphone_api.stringres.get("setqos__auto")+","+webphone_api.stringres.get("setqos__no")+","+webphone_api.stringres.get("setqos__yes"),"0,1,2","1","0"),SettingItem("codecframecount","0","2",GROUP_MEDIA,webphone_api.stringres.get("codecframecount_auto")+",1,2,3,4,5,6","0,1,2,3,4,5,6","1","0"),SettingItem("doublesendrtp","0","2",GROUP_MEDIA,webphone_api.stringres.get("doublesendrtp__no")+","+webphone_api.stringres.get("doublesendrtp__yes"),"0,1","1","0"),SettingItem("ringtimeout","90000","1",GROUP_SIP,"","","1","90000"),SettingItem("calltimeout","10800000","1",GROUP_SIP,"","","1","10800000"),e=8;var h="1";!isNull(GetConfig("displaynotification"))&&GetConfig("displaynotification").length>0&&(h=Trim(GetConfig("displaynotification"))),"2"===h&&(h="1"),SettingItem("displaynotification",h,"2",GROUP_CALLDIVERT,webphone_api.stringres.get("displaynotification__never")+","+webphone_api.stringres.get("displaynotification__onevent"),"0,1","1",h);var m="false";!isNull(GetConfig("hasvolume"))&&GetConfig("hasvolume").length>0&&(0==GetConfigInt("hasvolume",-1)?m="false":GetConfigInt("hasvolume",-1)>1&&(m="true")),SettingItem("displayvolumecontrols",m,"0",GROUP_GENERAL,"","","1",m),SettingItem("displayaudiodevice","false","0",GROUP_GENERAL,"","","1","false"),e=9,SettingItem("use_fast_ice","1","2",GROUP_SIP,webphone_api.stringres.get("use_fast_ice__no")+","+webphone_api.stringres.get("use_fast_ice__auto")+","+webphone_api.stringres.get("use_fast_ice__yes")+","+webphone_api.stringres.get("use_fast_ice__always"),"0,1,2,3","1","1"),SettingItem("use_stun","1","2",GROUP_SIP,webphone_api.stringres.get("use_stun__force")+","+webphone_api.stringres.get("use_stun__no")+","+webphone_api.stringres.get("use_stun__stable_nat")+","+webphone_api.stringres.get("use_stun__all_symetric")+","+webphone_api.stringres.get("use_stun__always")+","+webphone_api.stringres.get("use_stun__public_ip"),"-1,0,1,2,3,4","1","1"),SettingItem("prack","false","0",GROUP_SIP,"","","1","false"),SettingItem("localip","","1",GROUP_SIP,"","","1",""),SettingItem("signalingport","","1",GROUP_SIP,"","","1",""),SettingItem("rtpport","","1",GROUP_SIP,"","","1","");var d="2";!isNull(GetConfig("earlymedia"))&&GetConfig("earlymedia").length>0&&(d=Trim(GetConfig("earlymedia"))),SettingItem("earlymedia",d,"2",GROUP_SIP,webphone_api.stringres.get("earlymedia__no")+","+webphone_api.stringres.get("earlymedia__reserved")+","+webphone_api.stringres.get("earlymedia__auto")+","+webphone_api.stringres.get("earlymedia__just_early")+","+webphone_api.stringres.get("earlymedia__null_packets")+","+webphone_api.stringres.get("earlymedia__yes")+","+webphone_api.stringres.get("earlymedia__always_force"),"0,1,2,3,4,5,6","1",d),SettingItem("jittersize","3","2",GROUP_MEDIA,webphone_api.stringres.get("jittersize__no")+","+webphone_api.stringres.get("jittersize__esmall")+","+webphone_api.stringres.get("jittersize__small")+","+webphone_api.stringres.get("jittersize__normal")+","+webphone_api.stringres.get("jittersize__big")+","+webphone_api.stringres.get("jittersize__ebig")+","+webphone_api.stringres.get("jittersize__max"),"0,1,2,3,4,5,6","1","3"),SettingItem("proxyaddress","","1",GROUP_SIP,"","","1",""),SettingItem("username","","1",GROUP_SIP,"","","1",""),SettingItem("displayname","","1",GROUP_SIP,"","","1",""),SettingItem("email","","1",GROUP_GENERAL,"","","1",""),SettingItem("textmessaging","-1","2",GROUP_SIP,webphone_api.stringres.get("chatsms__auto_guess_or_ask")+","+webphone_api.stringres.get("chatsms__sms_only")+","+webphone_api.stringres.get("chatsms__chat_only")+","+webphone_api.stringres.get("chatsms__disable"),"-1,3,6,0","1","-1"),SettingItem("savetocontacts","1","2",GROUP_GENERAL,webphone_api.stringres.get("savetocontacts__no")+","+webphone_api.stringres.get("savetocontacts__ask")+","+webphone_api.stringres.get("savetocontacts__yes"),"0,1,2","1","1"),SettingItem("call_access","","7",GROUP_GENERAL,"","","1",""),e=10;var b="-1";!isNull(GetConfig("transfertype"))&&GetConfig("transfertype").length>0&&(b=Trim(GetConfig("transfertype"))),SettingItem("transfertype",b,"2",GROUP_CALLDIVERT,webphone_api.stringres.get("transfertype__auto")+","+webphone_api.stringres.get("transfertype__unattended")+","+webphone_api.stringres.get("transfertype__withhold")+","+webphone_api.stringres.get("transfertype__attanded")+","+webphone_api.stringres.get("transfertype__with_no_hold")+","+webphone_api.stringres.get("transfertype__with_conf"),"-1,1,6,5,7,8","1",b),e=11,SettingItem("transfertype1",GetConfigInt("transfertype1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace1",GetConfigInt("transfwithreplace1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace1",GetConfigInt("allowreplace1",-1),"-1",GROUP_NOGROUP,"","","-1",""),
SettingItem("discontransfer1",GetConfigInt("discontransfer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer1",GetConfigInt("disconincomingrefer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer1",GetConfigInt("inversetransfer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay1",GetConfigInt("transferdelay1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer1",GetConfigInt("newdialogforrefer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer1",GetConfigInt("useserverdomainforrefer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer1",GetConfigInt("holdontransfer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype2",GetConfigInt("transfertype2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace2",GetConfigInt("transfwithreplace2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace2",GetConfigInt("allowreplace2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer2",GetConfigInt("discontransfer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer2",GetConfigInt("disconincomingrefer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer2",GetConfigInt("inversetransfer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay2",GetConfigInt("transferdelay2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer2",GetConfigInt("newdialogforrefer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer2",GetConfigInt("useserverdomainforrefer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer2",GetConfigInt("holdontransfer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype3",GetConfigInt("transfertype3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace3",GetConfigInt("transfwithreplace3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace3",GetConfigInt("allowreplace3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer3",GetConfigInt("discontransfer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer3",GetConfigInt("disconincomingrefer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer3",GetConfigInt("inversetransfer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay3",GetConfigInt("transferdelay3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer3",GetConfigInt("newdialogforrefer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer3",GetConfigInt("useserverdomainforrefer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer3",GetConfigInt("holdontransfer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype4",GetConfigInt("transfertype4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace4",GetConfigInt("transfwithreplace4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace4",GetConfigInt("allowreplace4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer4",GetConfigInt("discontransfer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer4",GetConfigInt("disconincomingrefer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer4",GetConfigInt("inversetransfer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay4",GetConfigInt("transferdelay4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer4",GetConfigInt("newdialogforrefer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer4",GetConfigInt("useserverdomainforrefer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer4",GetConfigInt("holdontransfer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype5",GetConfigInt("transfertype5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace5",GetConfigInt("transfwithreplace5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace5",GetConfigInt("allowreplace5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer5",GetConfigInt("discontransfer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer5",GetConfigInt("disconincomingrefer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer5",GetConfigInt("inversetransfer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay5",GetConfigInt("transferdelay5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer5",GetConfigInt("newdialogforrefer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer5",GetConfigInt("useserverdomainforrefer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer5",GetConfigInt("holdontransfer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype6",GetConfigInt("transfertype6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace6",GetConfigInt("transfwithreplace6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace6",GetConfigInt("allowreplace6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer6",GetConfigInt("discontransfer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer6",GetConfigInt("disconincomingrefer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer6",GetConfigInt("inversetransfer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay6",GetConfigInt("transferdelay6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer6",GetConfigInt("newdialogforrefer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer6",GetConfigInt("useserverdomainforrefer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer6",GetConfigInt("holdontransfer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype7",GetConfigInt("transfertype7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace7",GetConfigInt("transfwithreplace7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace7",GetConfigInt("allowreplace7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer7",GetConfigInt("discontransfer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer7",GetConfigInt("disconincomingrefer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer7",GetConfigInt("inversetransfer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay7",GetConfigInt("transferdelay7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer7",GetConfigInt("newdialogforrefer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer7",GetConfigInt("useserverdomainforrefer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer7",GetConfigInt("holdontransfer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype8",GetConfigInt("transfertype8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace8",GetConfigInt("transfwithreplace8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace8",GetConfigInt("allowreplace8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer8",GetConfigInt("discontransfer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer8",GetConfigInt("disconincomingrefer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer8",GetConfigInt("inversetransfer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay8",GetConfigInt("transferdelay8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer8",GetConfigInt("newdialogforrefer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer8",GetConfigInt("useserverdomainforrefer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer8",GetConfigInt("holdontransfer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype9",GetConfigInt("transfertype9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace9",GetConfigInt("transfwithreplace9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace9",GetConfigInt("allowreplace9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer9",GetConfigInt("discontransfer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer9",GetConfigInt("disconincomingrefer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer9",GetConfigInt("inversetransfer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay9",GetConfigInt("transferdelay9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer9",GetConfigInt("newdialogforrefer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer9",GetConfigInt("useserverdomainforrefer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer9",GetConfigInt("holdontransfer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype10",GetConfigInt("transfertype10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace10",GetConfigInt("transfwithreplace10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace10",GetConfigInt("allowreplace10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer10",GetConfigInt("discontransfer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer10",GetConfigInt("disconincomingrefer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer10",GetConfigInt("inversetransfer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay10",GetConfigInt("transferdelay10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer10",GetConfigInt("newdialogforrefer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer10",GetConfigInt("useserverdomainforrefer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer10",GetConfigInt("holdontransfer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),e=12;var _="";!isNull(GetConfig("transfername1"))&&GetConfig("transfername1").length>0&&(_=Trim(GetConfig("transfername1"))),SettingItem("transfername1",_,"-1",GROUP_NOGROUP,"","","-1",_);var f="";!isNull(GetConfig("transfername2"))&&GetConfig("transfername2").length>0&&(f=Trim(GetConfig("transfername2"))),SettingItem("transfername2",f,"-1",GROUP_NOGROUP,"","","-1",f);var w="";!isNull(GetConfig("transfername3"))&&GetConfig("transfername3").length>0&&(w=Trim(GetConfig("transfername3"))),SettingItem("transfername3",w,"-1",GROUP_NOGROUP,"","","-1",w);var v="";!isNull(GetConfig("transfername4"))&&GetConfig("transfername4").length>0&&(v=Trim(GetConfig("transfername4"))),SettingItem("transfername4",v,"-1",GROUP_NOGROUP,"","","-1",v);var E="";!isNull(GetConfig("transfername5"))&&GetConfig("transfername5").length>0&&(E=Trim(GetConfig("transfername5"))),SettingItem("transfername5",E,"-1",GROUP_NOGROUP,"","","-1",E);var P="";!isNull(GetConfig("transfername6"))&&GetConfig("transfername6").length>0&&(P=Trim(GetConfig("transfername6"))),SettingItem("transfername6",P,"-1",GROUP_NOGROUP,"","","-1",P);var T="";!isNull(GetConfig("transfername7"))&&GetConfig("transfername7").length>0&&(T=Trim(GetConfig("transfername7"))),SettingItem("transfername7",T,"-1",GROUP_NOGROUP,"","","-1",T);var S="";!isNull(GetConfig("transfername8"))&&GetConfig("transfername8").length>0&&(S=Trim(GetConfig("transfername8"))),SettingItem("transfername8",S,"-1",GROUP_NOGROUP,"","","-1",S);var N="";!isNull(GetConfig("transfername9"))&&GetConfig("transfername9").length>0&&(N=Trim(GetConfig("transfername9"))),SettingItem("transfername9",N,"-1",GROUP_NOGROUP,"","","-1",N);var I="";!isNull(GetConfig("transfername10"))&&GetConfig("transfername10").length>0&&(I=Trim(GetConfig("transfername10"))),SettingItem("transfername10",I,"-1",GROUP_NOGROUP,"","","-1",I),e=13,SettingItem("startonboot","true","0",GROUP_GENERAL,"","","1","true"),SettingItem("callforwardonbusy","","1",GROUP_CALLDIVERT,"","","1",""),SettingItem("rejectonvoipbusy","3","2",GROUP_CALLDIVERT,"Auto,Reject calls,Allow calls,Forward calls","3,0,1,2","1","3"),SettingItem("rejectonphonebusy","0","2",GROUP_CALLDIVERT,"Reject calls,Allow calls,Forward calls","0,1,2","1","0");var C="";!isNull(GetConfig("voicemailnum"))&&GetConfig("voicemailnum").length>0&&(C=Trim(GetConfig("voicemailnum"))),SettingItem("voicemailnum",C,"1",GROUP_CALLDIVERT,"","","1","");var G="2";!isNull(GetConfig("voicemail"))&&GetConfig("voicemail").length>0&&(G=Trim(GetConfig("voicemail"))),SettingItem("voicemail",G,"2",GROUP_CALLDIVERT,"Disabled,Only if NOTIFY is received,Auto-detect if SUBSCRIBE is needed,Subscribe for voicemail after registration,Subscribe for voicemail on startup","0,1,2,3,4","1","false"),SettingItem("techprefix","","1",GROUP_CALLDIVERT,"","","1",""),SettingItem("filters","","5",GROUP_CALLDIVERT,"","","1",""),SettingItem("startonboot","true","0",GROUP_GENERAL,"","","1","true"),SettingItem("startwithos","true","0",GROUP_GENERAL,"","","1","true"),SettingItem("startwithos_was_sent","false","-1",GROUP_NOGROUP,"","","1","false"),e=4;var L="14";webphone_api.global.isdebugversion?(e=15,webphone_api.global.loglevel<5&&(webphone_api.global.loglevel=5),SettingItem("loglevel",webphone_api.global.loglevel.toString(),"0",GROUP_GENERAL,"","","1","1")):(e=16,isNull(webphone_api.parameters.loglevel)||1!==webphone_api.parameters.loglevel.length&&2!==webphone_api.parameters.loglevel.length||!IsNumber(webphone_api.parameters.loglevel)||(L=Trim(webphone_api.parameters.loglevel)),SettingItem("loglevel",L,"0",GROUP_GENERAL,"","","1","1")),e=17,SettingItem("loglevel_dbg",L,"1",GROUP_GENERAL,"","","1","1"),SettingItem("code_version","1","-1",GROUP_NOGROUP,"","","1","1"),e=18;var R="";!isNull(GetConfig("brandname"))&&GetConfig("brandname").length>0&&(R=Trim(GetConfig("brandname"))),SettingItem("brandname",R,"-1",GROUP_NOGROUP,"","","1","");!isNull(GetConfig("brandid"))&&GetConfig("brandid").length>0&&(R=Trim(GetConfig("brandid"))),SettingItem("brandid","","-1",GROUP_NOGROUP,"","","1","");var y="";!isNull(GetConfig("companyname"))&&GetConfig("companyname").length>0&&(y=Trim(GetConfig("companyname"))),SettingItem("companyname",y,"-1",GROUP_NOGROUP,"","","1","");var D="";!isNull(GetConfig("newuser"))&&GetConfig("newuser").length>0&&(D=Trim(GetConfig("newuser"))),SettingItem("newuser",D,"-1",GROUP_NOGROUP,"","","1","");var O="";!isNull(GetConfig("homepage"))&&GetConfig("homepage").length>0&&(O=Trim(GetConfig("homepage"))),SettingItem("homepage",O,"-1",GROUP_NOGROUP,"","","1","");var x="";!isNull(GetConfig("accounturi"))&&GetConfig("accounturi").length>0&&(x=Trim(GetConfig("accounturi"))),SettingItem("accounturi",x,"-1",GROUP_NOGROUP,"","","1","");var A="";!isNull(GetConfig("recharge"))&&GetConfig("recharge").length>0&&(A=Trim(GetConfig("recharge"))),SettingItem("recharge",A,"-1",GROUP_NOGROUP,"","","1","");var k="";!isNull(GetConfig("p2p"))&&GetConfig("p2p").length>0&&(k=Trim(GetConfig("p2p"))),SettingItem("p2p",k,"1",GROUP_CALLDIVERT,"","","1","");var U="";!isNull(GetConfig("callback"))&&GetConfig("callback").length>0&&(U=Trim(GetConfig("callback"))),SettingItem("callback",U,"1",GROUP_CALLDIVERT,"","","1","");var V="";!isNull(GetConfig("sms"))&&GetConfig("sms").length>0&&(V=Trim(GetConfig("sms"))),SettingItem("sms",V,"1",GROUP_CALLDIVERT,"","","1","");var W="";!isNull(GetConfig("sms_recieve"))&&GetConfig("sms_recieve").length>0&&(W=Trim(GetConfig("sms_recieve"))),SettingItem("sms_recieve",W,"-1",GROUP_NOGROUP,"","","1","");var F="";!isNull(GetConfig("creditrequest"))&&GetConfig("creditrequest").length>0&&(F=Trim(GetConfig("creditrequest"))),SettingItem("creditrequest",F,"1",GROUP_CALLDIVERT,"","","1","");var M="";!isNull(GetConfig("ratingrequest"))&&GetConfig("ratingrequest").length>0&&(M=Trim(GetConfig("ratingrequest"))),SettingItem("ratingrequest",M,"1",GROUP_CALLDIVERT,"","","1","");var H="";!isNull(GetConfig("supportmail"))&&GetConfig("supportmail").length>0&&(H=Trim(GetConfig("supportmail"))),SettingItem("supportmail",H,"-1",GROUP_NOGROUP,"","","1","");var B="";!isNull(GetConfig("supporturl"))&&GetConfig("supporturl").length>0&&(B=Trim(GetConfig("supporturl"))),SettingItem("supporturl",B,"-1",GROUP_NOGROUP,"","","1","");var j=GetParameter("header");!isNull(GetConfig("header"))&&GetConfig("header").length>0&&(j=Trim(GetConfig("header"))),(isNull(j)||j.length<1)&&!isNull(GetConfig("headertext"))&&GetConfig("headertext").length>0&&(j=GetConfig("headertext")),SettingItem("header",j,"-1",GROUP_NOGROUP,"","","1","");var $="";!isNull(GetConfig("footer"))&&GetConfig("footer").length>0&&($=Trim(GetConfig("footer"))),(isNull($)||$.length<1)&&!isNull(GetConfig("footertext"))&&GetConfig("footertext").length>0&&($=GetConfig("footertext")),SettingItem("footer",$,"-1",GROUP_NOGROUP,"","","1","");var q="";!isNull(GetConfig("logo"))&&GetConfig("logo").length>0&&(q=Trim(GetConfig("logo"))),SettingItem("logo",q,"-1",GROUP_NOGROUP,"","","1","");var z="";!isNull(GetConfig("version"))&&GetConfig("version").length>0&&(z=Trim(GetConfig("version"))),SettingItem("version",z,"-1",GROUP_NOGROUP,"","","1","");var K="";!isNull(GetConfig("messagedisplay"))&&GetConfig("messagedisplay").length>0&&(K=Trim(GetConfig("messagedisplay"))),SettingItem("messagedisplay",K,"-1",GROUP_NOGROUP,"","","1","");var X="";!isNull(GetConfig("messagepopup"))&&GetConfig("messagepopup").length>0&&(X=Trim(GetConfig("messagepopup"))),SettingItem("messagepopup",X,"-1",GROUP_NOGROUP,"","","1","");var J="";!isNull(GetConfig("advertisement"))&&GetConfig("advertisement").length>0&&(J=Trim(GetConfig("advertisement"))),SettingItem("advertisement",J,"-1",GROUP_NOGROUP,"","","1","");var Y="";!isNull(GetConfig("helpurl"))&&GetConfig("helpurl").length>0&&(Y=Trim(GetConfig("helpurl"))),SettingItem("helpurl",Y,"-1",GROUP_NOGROUP,"","","1","");var Q="";!isNull(GetConfig("licenseurl"))&&GetConfig("licenseurl").length>0&&(Q=Trim(GetConfig("licenseurl"))),SettingItem("licenseurl",Q,"-1",GROUP_NOGROUP,"","","1","");var Z="";!isNull(GetConfig("extramenuurl"))&&GetConfig("extramenuurl").length>0&&(Z=Trim(GetConfig("extramenuurl"))),SettingItem("extramenuurl",Z,"-1",GROUP_NOGROUP,"","","1","");var ee="";!isNull(GetConfig("extramenutxt"))&&GetConfig("extramenutxt").length>0&&(ee=Trim(GetConfig("extramenutxt"))),SettingItem("extramenutxt",ee,"-1",GROUP_NOGROUP,"","","1","");var ne="";!isNull(GetConfig("extramenuurl1"))&&GetConfig("extramenuurl1").length>0&&(ne=Trim(GetConfig("extramenuurl1"))),SettingItem("extramenuurl1",ne,"-1",GROUP_NOGROUP,"","","1","");var te="";!isNull(GetConfig("extramenutxt1"))&&GetConfig("extramenutxt1").length>0&&(te=Trim(GetConfig("extramenutxt1"))),SettingItem("extramenutxt1",te,"-1",GROUP_NOGROUP,"","","1","");var oe="";!isNull(GetConfig("extramenuurl2"))&&GetConfig("extramenuurl2").length>0&&(oe=Trim(GetConfig("extramenuurl2"))),SettingItem("extramenuurl2",oe,"-1",GROUP_NOGROUP,"","","1","");var ie="";!isNull(GetConfig("extramenutxt2"))&&GetConfig("extramenutxt2").length>0&&(ie=Trim(GetConfig("extramenutxt2"))),SettingItem("extramenutxt2",ie,"-1",GROUP_NOGROUP,"","","1","");var ae="";!isNull(GetConfig("extramenuurl3"))&&GetConfig("extramenuurl3").length>0&&(ae=Trim(GetConfig("extramenuurl3"))),SettingItem("extramenuurl3",ae,"-1",GROUP_NOGROUP,"","","1","");var re="";!isNull(GetConfig("extramenutxt3"))&&GetConfig("extramenutxt3").length>0&&(re=Trim(GetConfig("extramenutxt3"))),SettingItem("extramenutxt3",re,"-1",GROUP_NOGROUP,"","","1","");var le="";!isNull(GetConfig("extramenuurl4"))&&GetConfig("extramenuurl4").length>0&&(le=Trim(GetConfig("extramenuurl4"))),SettingItem("extramenuurl4",le,"-1",GROUP_NOGROUP,"","","1","");var se="";!isNull(GetConfig("extramenutxt4"))&&GetConfig("extramenutxt4").length>0&&(se=Trim(GetConfig("extramenutxt4"))),SettingItem("extramenutxt4",se,"-1",GROUP_NOGROUP,"","","1","");var pe="";!isNull(GetConfig("extramenuurl5"))&&GetConfig("extramenuurl5").length>0&&(pe=Trim(GetConfig("extramenuurl5"))),SettingItem("extramenuurl5",pe,"-1",GROUP_NOGROUP,"","","1","");var ce="";!isNull(GetConfig("extramenutxt5"))&&GetConfig("extramenutxt5").length>0&&(ce=Trim(GetConfig("extramenutxt5"))),SettingItem("extramenutxt5",ce,"-1",GROUP_NOGROUP,"","","1",""),e=19;var ue="1";!isNull(GetConfig("enablepresence"))&&GetConfig("enablepresence").length>0&&(ue=Trim(GetConfig("enablepresence"))),SettingItem("enablepresence",ue,"-1",GROUP_NOGROUP,"","","1","0"),SettingItem("presencestatus","Online","2",GROUP_PROFILE,"Online,Away,DND,Invisible,Offline","Online,Away,DND,Invisible,Offline","1","Online"),SettingItem("numexistscalled","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("servercontacts","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("verifyuser","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("srvcontacts","","-1",GROUP_NOGROUP,"","","1","0");var ge="false";!isNull(GetConfig("contacttoggle"))&&GetConfig("contacttoggle").length>0&&(ge=Trim(GetConfig("contacttoggle"))),SettingItem("contacttoggle",ge,"-1",GROUP_NOGROUP,"","","1","false"),e=20,SettingItem("last_callback_nr","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("callback_mode","0","2",GROUP_CALLDIVERT,"No,Ask,On no internet,On no WIFI,Always","0,1,2,3,4","1","0"),SettingItem("accounts","","5",GROUP_SIP,"","","1",""),SettingItem("reset_settings","","8",GROUP_GENERAL,"","","1","");var he="false";!isNull(GetConfig("voicerecording"))&&GetConfig("voicerecording").length>0&&("true"==he||"false"==he)&&(he=Trim(GetConfig("voicerecording"))),SettingItem("voicerecording",he,"0",GROUP_GENERAL,"","","1",he),e=21,SettingItem("ringtone","","8",GROUP_GENERAL,"Ringtone1,Ringtone2,Ringtone3","0,1,2","1",""),SettingItem("changesptoring","2","2",GROUP_SIP,webphone_api.stringres.get("changesptoring__nothing")+","+webphone_api.stringres.get("changesptoring__disp_ringing")+","+webphone_api.stringres.get("changesptoring__start_media")+","+webphone_api.stringres.get("changesptoring__start_media_disp"),"0,1,2,3","1","2");var me="-1";isNull(GetConfig("transport"))||(me=GetConfigInt("transport",-1)),SettingItem("transport",me.toString(),"2",GROUP_SIP,"Auto,UDP,TCP,TLS","-1,0,1,2","1",me.toString()),SettingItem("defmute","0","2",GROUP_SIP,webphone_api.stringres.get("defmute__both")+","+webphone_api.stringres.get("defmute__speakers_only")+","+webphone_api.stringres.get("defmute__mic_only"),"0,1,2","1","2"),SettingItem("automute","0","2",GROUP_CALLDIVERT,webphone_api.stringres.get("automute__no")+","+webphone_api.stringres.get("automute__incoming")+","+webphone_api.stringres.get("automute__outgoing")+","+webphone_api.stringres.get("automute__both")+","+webphone_api.stringres.get("automute__other_line"),"0,1,2,3,4","1","0"),SettingItem("autohold","0","2",GROUP_CALLDIVERT,webphone_api.stringres.get("autohold__no")+","+webphone_api.stringres.get("autohold__incoming")+","+webphone_api.stringres.get("autohold__outgoing")+","+webphone_api.stringres.get("autohold__both")+","+webphone_api.stringres.get("autohold__other_line"),"0,1,2,3,4","1","0"),e=22,SettingItem("customsipheader","","1",GROUP_SIP,"","","1",""),SettingItem("sendrtponmuted","false","0",GROUP_SIP,"","","1","false"),SettingItem("capabilityrequest","false","0",GROUP_SIP,"","","1","false"),SettingItem("devtest","0,0,0,0,0,0,0,0,0","8",GROUP_SIP,"","","1","0,0,0,0,0,0,0,0,0"),SettingItem("enableaudio","true","0",GROUP_CALLDIVERT,"","","1","true"),SettingItem("dialerintegration","false","0",GROUP_INTEGRATE,"","","1","false"),SettingItem("screenrotation","0","2",GROUP_GENERAL,"Auto,No,Yes","0,1,2","1","0"),SettingItem("audiobufferlength","-1","1",GROUP_MEDIA,"","","1","-1"),SettingItem("keepaliveival","28000","1",GROUP_SIP,"","","1","28000"),SettingItem("cpualwayspartiallock","false","0",GROUP_GENERAL,"","","1","false"),SettingItem("disablewbforpstn","1","2",GROUP_MEDIA,"No,Yes (check on first call),Yes (check always)","0,1,2","1","1"),SettingItem("storecallhistory","1","2",GROUP_GENERAL,"Local + Native,Local,Native,No history","0,1,2,3","1","1"),SettingItem("keepdeviceawakeincall","2","2",GROUP_GENERAL,"No,Basic only,Auto,Full then partial,Always full","0,1,2,3,4","1","2"),SettingItem("speakermode","0","2",GROUP_MEDIA,webphone_api.stringres.get("speakermode__auto")+","+webphone_api.stringres.get("speakermode__never")+","+webphone_api.stringres.get("speakermode__always"),"0,1,2","1","0"),SettingItem("focusaudio","1","2",GROUP_MEDIA,"Auto guess,No,Yes","0,1,2","1","1"),SettingItem("useroutingapi","0","2",GROUP_MEDIA,"Auto,No,Yes","0,1,2","1","0"),SettingItem("integrateifwifionly","false","0",GROUP_INTEGRATE,"","","1","false"),SettingItem("nativefilterallow","","1",GROUP_INTEGRATE,"","","1",""),SettingItem("nativefilterblock","","1",GROUP_INTEGRATE,"","","1",""),SettingItem("companyname","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("supportpageuri","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("proversioncallcount","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("magicnumber",SETT_MAGIC_NUMBER,"-1",GROUP_NOGROUP,"","","1",SETT_MAGIC_NUMBER),SettingItem("upgradesettfromdatabase","true","-1",GROUP_NOGROUP,"","","1","true"),SettingItem("cfgvideo","4","2",GROUP_VIDEO,"Never,On Request,Ask,Autoaccept,Always","2,4,6,8,10","1","4"),SettingItem("video_profile","0","2",GROUP_VIDEO,"Auto,Low,Medium,High,Ultra,Extra","0,4,6,8,10,15","1","0"),SettingItem("cust_lastautoprov","0","-1",GROUP_NOGROUP,"","","1","0"),e=23,SettingItem("lastautoprov","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("loglastusage","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("callfunctionsbtnusage","10,0,5,9,8,10,12,1,3,-2","-1",GROUP_NOGROUP,"","","1"),e=24,SettingItem("redial","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("vibrate","0","2",GROUP_GENERAL,"Auto,Never,Always","0,1,2","1","0"),SettingItem("video_fps","0","1",GROUP_VIDEO,"","","1","0"),SettingItem("setfinalcodec","1","2",GROUP_MEDIA,webphone_api.stringres.get("setfinalcodec__never")+","+webphone_api.stringres.get("setfinalcodec__auto")+","+webphone_api.stringres.get("setfinalcodec__multiple_codec")+","+webphone_api.stringres.get("setfinalcodec__always"),"0,1,2,3","1","1"),SettingItem("use_rport","1","2",GROUP_SIP,webphone_api.stringres.get("use_rport__no")+","+webphone_api.stringres.get("use_rport__simmetric_nat")+","+webphone_api.stringres.get("use_rport__always")+","+webphone_api.stringres.get("use_rport__public_ip")+","+webphone_api.stringres.get("use_rport__request"),"0,1,2,3,9","1","1"),SettingItem("natopenpackets","2","1",GROUP_SIP,"","","1","2"),SettingItem("video_accept_checkbox","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("successfulcalls","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("webrtc_successfulcalls","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("wasrated","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("lastratedate","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("hidemyidentity","false","0",GROUP_SIP,"","","1","false"),SettingItem("last_transfer_number","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("last_conference_number","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("last_forward_number","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("validprovisioning","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("jsscriptevent","2","-1",GROUP_NOGROUP,"","","1","2"),SettingItem("devicetype",""+DEVICE_WEBPHONE(),"-1",GROUP_NOGROUP,"","","1",""+DEVICE_WEBPHONE()),SettingItem("extraoption","","1",GROUP_GENERAL,"","","1",""),e=25,SettingItem("enginepriority_java","2","2",GROUP_SIP,"Disabled,Lower,Default,Higher,Highest,Force","0,1,2,3,4,5","1","2"),SettingItem("enginepriority_webrtc","2","2",GROUP_SIP,"Disabled,Lower,Default,Higher,Highest,Force","0,1,2,3,4,5","1","2"),SettingItem("enginepriority_ns","2","2",GROUP_SIP,"Disabled,Lower,Default,Higher,Highest,Force","0,1,2,3,4,5","1","2"),SettingItem("enginepriority_flash","2","2",GROUP_SIP,"Disabled,Lower,Default,Higher,Highest,Force","0,1,2,3,4,5","1","2"),SettingItem("enginepriority_app","2","2",GROUP_SIP,"Disabled,Lower,Default,Higher,Highest,Force","0,1,2,3,4,5","1","2"),SettingItem("enginepriority_p2p","2","2",GROUP_SIP,"Disabled,Lower,Default,Higher,Highest,Force","0,1,2,3,4,5","1","2"),SettingItem("enginepriority_accessnum","2","2",GROUP_SIP,"Disabled,Lower,Default,Higher,Highest,Force","0,1,2,3,4,5","1","2"),SettingItem("enginepriority_nativedial","2","2",GROUP_SIP,"Disabled,Lower,Default,Higher,Highest,Force","0,1,2,3,4,5","1","2"),SettingItem("enginepriority_otherbrowser","2","2",GROUP_SIP,"Disabled,Lower,Default,Higher,Highest,Force","0,1,2,3,4,5","1","2"),SettingItem("engineoldavailable_java","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("engineoldavailable_webrtc","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("engineoldavailable_ns","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("engineoldavailable_flash","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("engineoldavailable_app","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("engineoldavailable_p2p","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("engineoldavailable_accessnum","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("engineoldavailable_nativedial","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("lastusedengine","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("ignoreengineselect","false","-1",GROUP_NOGROUP,"","","1","false"),e=26;var de="";!isNull(GetConfig("pc_alternatebrowserurl"))&&GetConfig("pc_alternatebrowserurl").length>0&&(de=Trim(GetConfig("pc_alternatebrowserurl"))),SettingItem("pc_alternatebrowserurl",de,"-1",GROUP_NOGROUP,"","","1",""),SettingItem("lccnr","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("vdnr","0","-1",GROUP_NOGROUP,"","","1","0");var be="";!isNull(GetConfig("ios_nativedialerurl"))&&GetConfig("ios_nativedialerurl").length>0&&(be=Trim(GetConfig("ios_nativedialerurl"))),SettingItem("ios_nativedialerurl",be,"-1",GROUP_NOGROUP,"","","1","");var _e="";!isNull(GetConfig("android_nativedialerurl"))&&GetConfig("android_nativedialerurl").length>0&&(_e=Trim(GetConfig("android_nativedialerurl"))),SettingItem("android_nativedialerurl",_e,"-1",GROUP_NOGROUP,"","","1","");var fe="";!isNull(GetConfig("showsynccontactsmenu"))&&GetConfig("showsynccontactsmenu").length>0&&(fe=Trim(GetConfig("showsynccontactsmenu"))),SettingItem("showsynccontactsmenu",fe,"-1",GROUP_NOGROUP,"","","1","");var we="";!isNull(GetConfig("accessnumber"))&&GetConfig("accessnumber").length>0&&(we=Trim(GetConfig("accessnumber"))),SettingItem("accessnumber",we,"-1",GROUP_NOGROUP,"","","1","");var ve="0";!isNull(GetConfig("colortheme"))&&GetConfig("colortheme").length>0&&(ve=Trim(GetConfig("colortheme"))),e=27,SettingItem("theme",ve,"2",GROUP_GENERAL,"Default,Light Blue,Light Green,Light Orange,Light Purple,Dark Red,Yellow,Blue,Purple,Turquoise,Light Skin,Green Orange,Custom 1,Custom 2,Custom 3,Custom 4,Custom 5,Blue2,iPhone,MZ,WebPhone,Custom","0,1,2,3,4,5,6,7,8,9,10,11,14,15,16,18,19,21,22,23,24,25","1","0");var Ee="-1";!isNull(GetConfig("useloginpage"))&&GetConfig("useloginpage").length>0&&(Ee=Trim(GetConfig("useloginpage"))),SettingItem("useloginpage",Ee,"-1",GROUP_NOGROUP,"","","1","-1");var Pe="10";!isNull(GetConfig("featureset"))&&GetConfig("featureset").length>0&&(Pe=Trim(GetConfig("featureset"))),SettingItem("featureset",Pe,"-1",GROUP_NOGROUP,"","","1",Pe),SettingItem("wsusers","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("mainconfigs","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("notifications2","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("canshowlickeyinput","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("normalizenumber","-1","2",GROUP_CALLDIVERT,webphone_api.stringres.get("normalizenumber__auto")+","+webphone_api.stringres.get("normalizenumber__no")+","+webphone_api.stringres.get("normalizenumber__yes"),"-1,0,1","1","-1");var Te="";!isNull(GetConfig("callforwardonbusy"))&&GetConfig("callforwardonbusy").length>0&&(Te=Trim(GetConfig("callforwardonbusy"))),SettingItem("callforwardonbusy",Te,"1",GROUP_CALLDIVERT,"","","1","");var Se="";!isNull(GetConfig("callforwardonnoanswer"))&&GetConfig("callforwardonnoanswer").length>0&&(Se=Trim(GetConfig("callforwardonnoanswer"))),
SettingItem("callforwardonnoanswer",Se,"1",GROUP_CALLDIVERT,"","","1","");var Ne="15";!isNull(GetConfig("callforwardonnoanswertimeout"))&&GetConfig("callforwardonnoanswertimeout").length>0&&(Ne=Trim(GetConfig("callforwardonnoanswertimeout"))),SettingItem("callforwardonnoanswertimeout",Ne,"1",GROUP_CALLDIVERT,"","","1","");var Ie="";!isNull(GetConfig("callforwardalways"))&&GetConfig("callforwardalways").length>0&&(Ie=Trim(GetConfig("callforwardalways"))),SettingItem("callforwardalways",Ie,"1",GROUP_CALLDIVERT,"","","1","");var Ce="";!isNull(GetConfig("calltransferalways"))&&GetConfig("calltransferalways").length>0&&(Ce=Trim(GetConfig("calltransferalways"))),SettingItem("calltransferalways",Ce,"1",GROUP_CALLDIVERT,"","","1","");var Ge="0";!isNull(GetConfig("autoignore"))&&GetConfig("autoignore").length>0&&(Ge=Trim(GetConfig("autoignore"))),SettingItem("autoignore",Ge,"2",GROUP_CALLDIVERT,webphone_api.stringres.get("autoignore__dont")+","+webphone_api.stringres.get("autoignore__silently")+","+webphone_api.stringres.get("autoignore__reject"),"0,1,2","1","0");var Le="false";!isNull(GetConfig("enableautoaccept"))&&GetConfig("enableautoaccept").length>0&&("3"==GetConfig("enableautoaccept")?Le="true":"0"==GetConfig("enableautoaccept")&&(Le="false")),!isNull(GetConfig("autoaccept"))&&GetConfig("autoaccept").length>0&&(Le=Trim(GetConfig("autoaccept"))),SettingItem("autoaccept",Le,"0",GROUP_CALLDIVERT,"","","1","false"),SettingItem("filters","","5",GROUP_CALLDIVERT,"","","1",""),SettingItem("blocked_contacts","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("usemizutlsproxy","1","-1",GROUP_NOGROUP,"No,Auto,Yes","0,1,2","1",""),SettingItem("usemizutlsproxy_userreload","","-1",GROUP_NOGROUP,"","0,1,2","1",""),SettingItem("notification_count2","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("autostart","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("displaypeerdetails","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("rejectonbusy","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("voicerecupload","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("lastsessionsuccess","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("codec","-1","3",GROUP_MEDIA,"Optimal,PCMU,PCMA,GSM,iLBC,SPEEX,SPEEX-WB,G.729,OpusNB,OpusWB,OpusUWB,G.722.1,iSAC","-1,1,2,3,4,5,6,8,10,11,13,14,15","1","-1"),SettingItem("vcodec","-1","3",GROUP_MEDIA,"Optimal,H264,H265,VP8,VP9,AV1","-1,50,51,52,53,55","1","-1"),GetCodecsFromApiParam(),SettingItem("blacklist","","1",GROUP_CALLDIVERT,"","","1",""),SettingItem("sel_rtc_audio_in","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("sel_rtc_audio_out","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("sel_rtc_audio_ring","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("sel_rtc_video_in","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("audiodevices","","8",GROUP_MEDIA,"","","1",""),SettingItem("autoaction","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("webcallme","1","-1",GROUP_NOGROUP,"","","1","1"),e=28;var Re=GetConfigInt("conferencetype",1);SettingItem("conferencetype",Re.toString(),"2",GROUP_CALLDIVERT,webphone_api.stringres.get("conferencetype__disabled")+","+webphone_api.stringres.get("conferencetype__auto")+","+webphone_api.stringres.get("conferencetype__native")+","+webphone_api.stringres.get("conferencetype__server")+","+webphone_api.stringres.get("conferencetype__3way")+","+webphone_api.stringres.get("conferencetype__cr_msg_ref")+","+webphone_api.stringres.get("conferencetype__cr_msg")+","+webphone_api.stringres.get("conferencetype__cr_ref"),"0,1,2,3,4,5,6,7","1",Re.toString()),SettingItem("received_confrooms","","-1",GROUP_NOGROUP,"","","1","");var ye="";!isNull(GetConfig("callbacknumber"))&&GetConfig("callbacknumber").length>0&&(ye=Trim(GetConfig("callbacknumber"))),SettingItem("callbacknumber",ye,"1",GROUP_CALLDIVERT,"","","1",""),SettingItem("iswebrtcuppersrvfromuser","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("java_worked","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("ns_worked","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("webrtc_worked","false","-1",GROUP_NOGROUP,"","","1","false");var De="-1";if(!isNull(GetConfig("video"))&&GetConfig("video").length>0&&(De=Trim(GetConfig("video"))),"-1"==De&&!isNull(GetConfig("video_config"))&&GetConfig("video_config").length>0){var Oe=StrToIntDef(GetConfig("video_config"),-1);2==Oe?De="0":Oe>2&&Oe<8||(Oe>9?De="2":Oe>=8&&(De="1"))}SettingItem("video",De,"2",GROUP_MEDIA,webphone_api.stringres.get("video__auto")+","+webphone_api.stringres.get("video__disable")+","+webphone_api.stringres.get("video__enable")+","+webphone_api.stringres.get("video__force"),"-1,0,1,2","1","1");var xe="0";!isNull(GetConfig("video_bandwidth"))&&GetConfig("video_bandwidth").length>0&&(xe=Trim(GetConfig("video_bandwidth"))),SettingItem("video_bandwidth",xe,"1",GROUP_MEDIA,"","","1","0");var Ae="640";!isNull(GetConfig("video_width"))&&GetConfig("video_width").length>0&&(Ae=Trim(GetConfig("video_width"))),SettingItem("video_width",Ae,"1",GROUP_MEDIA,"","","1","640");var ke="480";!isNull(GetConfig("video_height"))&&GetConfig("video_height").length>0&&(ke=Trim(GetConfig("video_height"))),SettingItem("video_height",ke,"1",GROUP_MEDIA,"","","1","480"),SettingItem("androidchromedisplayed","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("conf_engineswitcheoffered","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("transf_engineswitcheoffered","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("filterchatduplicates","true","-1",GROUP_NOGROUP,"","","1","true");var Ue="true";!isNull(GetConfig("has_video"))&&GetConfig("has_video").length>0&&(Ue=Trim(GetConfig("has_video"))),"0"===GetParameter2("video")&&(Ue="false"),SettingItem("has_video",Ue,"1",GROUP_MEDIA,"","","1",Ue),SettingItem("sendchatonenter","true","0",GROUP_GENERAL,"","","1","true");var Ve="-1";!isNull(GetConfig("transfwithreplace"))&&GetConfig("transfwithreplace").length>0&&(Ve=Trim(GetConfig("transfwithreplace"))),SettingItem("transfwithreplace",Ve,"2",GROUP_CALLDIVERT,webphone_api.stringres.get("transfwithreplace__auto")+","+webphone_api.stringres.get("transfwithreplace__no")+","+webphone_api.stringres.get("transfwithreplace__yes"),"-1,0,1","1","-1"),SettingItem("acceptcall_onsharedevice","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("showratewhiletype_minlenth","3","-1",GROUP_NOGROUP,"","","1","3"),SettingItem("showratewhiletype_maxlenth","6","-1",GROUP_NOGROUP,"","","1","6");var We="1";!isNull(GetConfig("multilinegui"))&&GetConfig("multilinegui").length>0&&(We=Trim(GetConfig("multilinegui"))),SettingItem("multilinegui",We,"-1",GROUP_NOGROUP,"","","1",We),SettingItem("enginechecksum","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("redialonfail","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("autosrvupgrade","1","-1",GROUP_NOGROUP,"","","1","1"),SettingItem("srvupgrade_count","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("srvupgrade_version","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("srvupgrade_currversion","-1","-1",GROUP_NOGROUP,"","","1","-1"),SettingItem("srvupgrade_currversion_extcmd_test","-1","-1",GROUP_NOGROUP,"","","1","-1"),SettingItem("srv_exe_version","0","-1",GROUP_NOGROUP,"","","1","-1"),SettingItem("srv_java_version","0","-1",GROUP_NOGROUP,"","","1","-1"),e=30;var Fe="1";!isNull(GetConfig("useaudiorecord"))&&GetConfig("useaudiorecord").length>0&&(Fe=Trim(GetConfig("useaudiorecord"))),SettingItem("useaudiorecord",Fe,"-1",GROUP_NOGROUP,"","","1",Fe),SettingItem("fasthold","0","-1",GROUP_NOGROUP,"","","1","-1");SettingItem("calldivertchecksum",Md5Hash(Te+Se+Ie+Ne),"-1",GROUP_NOGROUP,"","","1",""),SettingItem("calldivertsuccess","-1","-1",GROUP_NOGROUP,"","","1","-1"),SettingItem("muteholdalllines","0","-1",GROUP_NOGROUP,"","","1","0");var Me="1";!isNull(GetConfig("allowcallredirect"))&&GetConfig("allowcallredirect").length>0&&(Me=Trim(GetConfig("allowcallredirect"))),SettingItem("allowcallredirect",Me,"-1",GROUP_NOGROUP,"","","1",Me);var He="1";!isNull(GetConfig("playdtmfsound"))&&GetConfig("playdtmfsound").length>0&&(He=Trim(GetConfig("playdtmfsound"))),SettingItem("playdtmfsound",He,"-1",GROUP_NOGROUP,"","","1",He);var Be=","+webphone_api.global.languagelist_js_good+",",je=webphone_api.global.languagelist_js_all;je.length>0&&","!=je[je.length-1]&&(je+=",");var $e="";if("rigitel"===GetConfig("brandname").toLowerCase()&&($e="de"),!isNull(GetConfig("language"))&&GetConfig("language").length>1&&($e=Trim(GetConfig("language"))),$e.length>0&&(","+je+",").indexOf(","+$e+",")<0&&(je.length>0&&","!=je[je.length-1]&&(je+=","),je+=$e),$e.length>0&&(","+Be+",").indexOf(","+$e+",")<0&&(Be.length>0&&","!=Be[Be.length-1]&&(Be+=","),Be+=$e),$e.length<1&&webphone_api.global.languageautodetect>0){var qe=getBrowserLanguage();qe.length>0&&Be.indexOf(","+qe+",")>=0?$e=qe:qe.length>2&&(qe.indexOf("-")>0?qe=qe.substr(0,qe.indexOf("-")):qe.indexOf("_")>0&&(qe=qe.substr(0,qe.indexOf("_"))),qe.length>0&&Be.indexOf(","+qe+",")>=0&&($e=qe))}$e.length<1&&($e="en"),je.length>0&&","==je[je.length-1]&&(je=je.substr(0,je.length-1));for(var ze=je.split(","),Ke="",Xe=0;Xe<ze.length;Xe++)Ke=Ke+","+webphone_api.stringres.getLanguageName(ze[Xe]);Ke.length>0&&(Ke=Ke.substr(1));var $e="en";isNull(GetConfig("language"))||2!==GetConfig("language").length||($e=Trim(GetConfig("language"))),SettingItem("language",$e,"2",GROUP_GENERAL,"English,German,Hungarian,Italian,Spanish,Portuguese","en,de,hu,it,es,pt","1","en"),SettingItem("chrome_local_alert_displayed","false","-1",GROUP_NOGROUP,"","","1","false");var Je=GetConfig("telsearchurl");!isNull(Je)&&Je.length>0&&SettingItem("telsearchkey","3606e399f2ec49f31831949efba6daf1","1",GROUP_GENERAL,"","","1","3606e399f2ec49f31831949efba6daf1");var Ye="1";!isNull(GetConfig("screensharing"))&&GetConfig("screensharing").length>0&&(Ye=Trim(GetConfig("screensharing"))),SettingItem("screensharing",Ye,"-1",GROUP_NOGROUP,"","","1",Ye),SettingItem("extraregisteraccounts","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("lastsucc","-1","-1",GROUP_NOGROUP,"","","1","-1"),SettingItem("enproblem","0","-1",GROUP_NOGROUP,"","","1","0");var Qe="0";!isNull(GetConfig("audio_bandwidth"))&&GetConfig("audio_bandwidth").length>0&&(Qe=Trim(GetConfig("audio_bandwidth"))),SettingItem("audio_bandwidth",Qe,"1",GROUP_MEDIA,"","","1","0");var Ze="1";!isNull(GetConfig("enablepres_httpapi"))&&GetConfig("enablepres_httpapi").length>0&&(Ze=Trim(GetConfig("enablepres_httpapi"))),SettingItem("enablepres_httpapi",Ze,"-1",GROUP_NOGROUP,"","","1","1");var en="1";!isNull(GetConfig("enablepres_javaapi"))&&GetConfig("enablepres_javaapi").length>0&&(en=Trim(GetConfig("enablepres_javaapi"))),SettingItem("enablepres_javaapi",en,"-1",GROUP_NOGROUP,"","","1","1");var nn="1";!isNull(GetConfig("enablepres_webrtc"))&&GetConfig("enablepres_webrtc").length>0&&(nn=Trim(GetConfig("enablepres_webrtc"))),SettingItem("enablepres_webrtc",nn,"-1",GROUP_NOGROUP,"","","1","1"),e=31;var tn="1";!isNull(GetConfig("incomingcallpopup"))&&GetConfig("incomingcallpopup").length>0&&(tn=Trim(GetConfig("incomingcallpopup"))),SettingItem("incomingcallpopup",tn,"2",GROUP_GENERAL,webphone_api.stringres.get("incomingcallpopup__no")+","+webphone_api.stringres.get("incomingcallpopup__auto")+","+webphone_api.stringres.get("incomingcallpopup__yes")+","+webphone_api.stringres.get("incomingcallpopup__always"),"0,1,2,3","1","1"),SettingItem("wpfirststart","true","-1",GROUP_NOGROUP,"","","1","true"),SettingItem("useragent","","-1",GROUP_NOGROUP,"","","1","");var on=(GetConfigInt("enabledirectcalls",-5),"0");!isNull(GetConfig("beeponconnect"))&&GetConfig("beeponconnect").length>0&&(on=Trim(GetConfig("beeponconnect"))),SettingItem("beeponconnect",on,"-1",GROUP_NOGROUP,"","","1","0");var an="0";!isNull(GetConfig("disablepopups"))&&GetConfig("disablepopups").length>0&&(an=Trim(GetConfig("disablepopups"))),SettingItem("disablepopups",an,"-1",GROUP_NOGROUP,"","","1",an);var rn="true";!isNull(GetConfig("showtoasts"))&&GetConfig("showtoasts").length>0&&(rn=Trim(GetConfig("showtoasts"))),SettingItem("showtoasts",rn,"-1",GROUP_NOGROUP,"","","1","true"),SettingItem("isfirstcallfwd","true","-1",GROUP_NOGROUP,"","","1","true");var ln="0";!isNull(GetConfig("beeponincoming"))&&GetConfig("beeponincoming").length>0&&(ln=Trim(GetConfig("beeponincoming"))),SettingItem("beeponincoming",ln,"0",GROUP_GENERAL,"","","1","0");var sn="2";!isNull(GetConfig("flash"))&&GetConfig("flash").length>0&&(sn=Trim(GetConfig("flash"))),SettingItem("flash",sn,"0",GROUP_GENERAL,"","","1","2");var pn="1";!isNull(GetConfig("importonlywithnum"))&&GetConfig("importonlywithnum").length>0&&(pn=Trim(GetConfig("importonlywithnum"))),SettingItem("importonlywithnum",pn,"2",GROUP_GENERAL,webphone_api.stringres.get("importonlywithnum__no")+","+webphone_api.stringres.get("importonlywithnum__yes"),"0,1","1","1");var cn="2";!isNull(GetConfig("videomode"))&&GetConfig("videomode").length>0&&(cn=Trim(GetConfig("importonlywithnum"))),SettingItem("videomode",cn,"2",GROUP_MEDIA,webphone_api.stringres.get("videomode__always")+","+webphone_api.stringres.get("videomode__noask")+","+webphone_api.stringres.get("videomode__askonce")+","+webphone_api.stringres.get("videomode__alwaysask")+","+webphone_api.stringres.get("videomode__disable"),"1,2,3,4,5","1","2");var un="2";!isNull(GetConfig("sscontrol"))&&GetConfig("sscontrol").length>0&&(un=Trim(GetConfig("sscontrol"))),SettingItem("sscontrol",un,"0",GROUP_SCRSHARE,"","","1","2");var gn="2";!isNull(GetConfig("ssscroll"))&&GetConfig("ssscroll").length>0&&(gn=Trim(GetConfig("ssscroll"))),SettingItem("ssscroll",gn,"0",GROUP_SCRSHARE,"","","1","2");var hn="1";!isNull(GetConfig("sstop"))&&GetConfig("sstop").length>0&&(hn=Trim(GetConfig("sstop"))),SettingItem("sstop",hn,"0",GROUP_SCRSHARE,"","","1","1");var mn="2";!isNull(GetConfig("ssquality"))&&GetConfig("ssquality").length>0&&(mn=Trim(GetConfig("ssquality"))),SettingItem("ssquality",mn,"2",GROUP_SCRSHARE,webphone_api.stringres.get("ssquality__low")+","+webphone_api.stringres.get("ssquality__medium")+","+webphone_api.stringres.get("ssquality__high"),"1,2,3","1","2"),e=32;var dn="";!isNull(GetConfig("bundlepolicy"))&&GetConfig("bundlepolicy").length>0&&(dn=Trim(GetConfig("bundlepolicy"))),SettingItem("bundlepolicy",dn,"-1",GROUP_NOGROUP,"","","1",dn);var bn="";!isNull(GetConfig("icecandidatepoolsize"))&&GetConfig("icecandidatepoolsize").length>0&&(bn=Trim(GetConfig("icecandidatepoolsize"))),SettingItem("icecandidatepoolsize",bn,"-1",GROUP_NOGROUP,"","","1",bn);var _n="";!isNull(GetConfig("icetransportpolicy"))&&GetConfig("icetransportpolicy").length>0&&(_n=Trim(GetConfig("icetransportpolicy"))),SettingItem("icetransportpolicy",_n,"-1",GROUP_NOGROUP,"","","1",_n);var fn="0";!isNull(GetConfig("displayvideodevice"))&&GetConfig("displayvideodevice").length>0&&(fn=Trim(GetConfig("displayvideodevice"))),SettingItem("displayvideodevice",fn,"-1",GROUP_NOGROUP,"","","1",fn);var wn="30000";!isNull(GetConfig("wskeepaliveival"))&&GetConfig("wskeepaliveival").length>0&&(wn=Trim(GetConfig("wskeepaliveival"))),SettingItem("wskeepaliveival",wn,"-1",GROUP_NOGROUP,"","","1",wn);var vn="1";!isNull(GetConfig("enableblf"))&&GetConfig("enableblf").length>0&&(vn=Trim(GetConfig("enableblf"))),SettingItem("enableblf",vn,"-1",GROUP_SIP,"","","1",vn);var En="";!isNull(GetConfig("profilestatustext"))&&GetConfig("profilestatustext").length>0&&(En=Trim(GetConfig("profilestatustext"))),SettingItem("profilestatustext",En,"1",GROUP_PROFILE,"","","1",En);var Pn="0";!isNull(GetConfig("share_location"))&&GetConfig("share_location").length>0&&(Pn=Trim(GetConfig("share_location"))),SettingItem("share_location",Pn,"2",GROUP_PROFILE,webphone_api.stringres.get("share_location__no")+","+webphone_api.stringres.get("share_location__yes"),"0,1","1",Pn);var Tn="";!isNull(GetConfig("profilepicture"))&&GetConfig("profilepicture").length>0&&(Tn=Trim(GetConfig("profilepicture"))),SettingItem("profilepicture",Tn,"1",GROUP_PROFILE,"","","1",Tn),e=33,SettingItem("profilehistory","","-1",GROUP_NOGROUP,"","","1","");var Sn="1";!isNull(GetConfig("p2psignaling"))&&GetConfig("p2psignaling").length>0&&(Sn=Trim(GetConfig("p2psignaling"))),SettingItem("p2psignaling",Sn,"-1",GROUP_NOGROUP,"","","1",Sn),SettingItem("nsupdate","-1","-1",GROUP_NOGROUP,"","","1","-1"),SettingItem("lastwpapixxx","","-1",GROUP_NOGROUP,"","","1","");var Nn="-1";!isNull(GetConfig("androidspeaker"))&&GetConfig("androidspeaker").length>0&&(Nn=Trim(GetConfig("androidspeaker"))),SettingItem("androidspeaker",Nn,"2",GROUP_MEDIA,webphone_api.stringres.get("androidspeaker__ignore")+","+webphone_api.stringres.get("androidspeaker__guess")+","+webphone_api.stringres.get("androidspeaker__def")+","+webphone_api.stringres.get("androidspeaker__before_fcall")+","+webphone_api.stringres.get("androidspeaker__after_fcall")+","+webphone_api.stringres.get("androidspeaker__atstart"),"-2,-1,0,1,2,3","-1",Nn),e=34;var In=[];In.push("wss://ws.ifelse.io"),In.push(","),In.push("wss://steemd.privex.io"),In.push(","),In.push("wss://xrplcluster.com"),In.push(","),In.push(",");var Cn=In.join("");SettingItem("wstestservers",Cn,"-1",GROUP_NOGROUP,"","","1",Cn),SettingItem("lastgood_wstest","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("domaintoip_cache"+webphone_api.global.versionstr,"","-1",GROUP_NOGROUP,"","","1",""),SettingItem("last_clientreset","-1","-1",GROUP_NOGROUP,"","","1","-1"),SettingItem("last_clientresetall","-1","-1",GROUP_NOGROUP,"","","1","-1"),e=35;var Gn="1";!isNull(GetConfig("alwaysallowlowcodec"))&&GetConfig("alwaysallowlowcodec").length>0&&(Gn=Trim(GetConfig("alwaysallowlowcodec"))),SettingItem("alwaysallowlowcodec",Gn,"2",GROUP_MEDIA,webphone_api.stringres.get("alwaysallowlowcodec__never")+","+webphone_api.stringres.get("alwaysallowlowcodec__auto")+","+webphone_api.stringres.get("alwaysallowlowcodec__always"),"0,1,2","1",Gn);var Ln="90";!isNull(GetConfig("keeprecfiles"))&&GetConfig("keeprecfiles").length>0&&(Ln=Trim(GetConfig("keeprecfiles"))),SettingItem("keeprecfiles",Ln,"1",GROUP_GENERAL,"","","1",Ln);var Rn="0";!isNull(GetConfig("sipprotocol"))&&GetConfig("sipprotocol").length>0&&(Rn=Trim(GetConfig("sipprotocol"))),SettingItem("sipprotocol",Rn,"-1",GROUP_NOGROUP,"","","1",Rn),SettingItem("resetsettings","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("wphoneappurl","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("wphoneappurl2","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("needunregister","true","-1",GROUP_NOGROUP,"","","1","true");var yn="-1";!isNull(GetConfig("holdtype"))&&GetConfig("holdtype").length>0&&(yn=Trim(GetConfig("holdtype"))),SettingItem("holdtype",yn,"2",GROUP_CALLDIVERT,webphone_api.stringres.get("holdtype__never")+","+webphone_api.stringres.get("holdtype__auto")+","+webphone_api.stringres.get("holdtype__no")+","+webphone_api.stringres.get("holdtype__notused")+","+webphone_api.stringres.get("holdtype__hold")+","+webphone_api.stringres.get("holdtype__otherparty")+","+webphone_api.stringres.get("holdtype__both"),"-2,-1,0,1,2,3,4","1",yn);var Dn="0";!isNull(GetConfig("colorizelog"))&&GetConfig("colorizelog").length>0&&(Dn=Trim(GetConfig("colorizelog"))),SettingItem("colorizelog",Dn,"-1",GROUP_NOGROUP,"","","1",Dn),e=36;var On="1";!isNull(GetConfig("forcereregister"))&&GetConfig("forcereregister").length>0&&(On=Trim(GetConfig("forcereregister"))),SettingItem("forcereregister",On,"-1",GROUP_NOGROUP,"","","1",On);var xn="0";!isNull(GetConfig("enablepush"))&&GetConfig("enablepush").length>0&&(xn=Trim(GetConfig("enablepush"))),SettingItem("enablepush",xn,"2",GROUP_GENERAL,webphone_api.stringres.get("enablepush__auto")+","+webphone_api.stringres.get("enablepush__no")+","+webphone_api.stringres.get("enablepush__yes"),"-1,0,1","1",xn);var An="-1";!isNull(GetConfig("callreceiver"))&&GetConfig("callreceiver").length>0&&(An=Trim(GetConfig("callreceiver"))),SettingItem("callreceiver",An,"-1",GROUP_NOGROUP,webphone_api.stringres.get("callreceiver__auto")+","+webphone_api.stringres.get("callreceiver__noincoming")+","+webphone_api.stringres.get("callreceiver__enablewhilerunning")+","+webphone_api.stringres.get("callreceiver__enablebackgroud"),"-1,0,1,2","1",An),SettingItem("appinstalltime",GetTickCount().toString(),"-1",GROUP_NOGROUP,"","","1",GetTickCount().toString()),SettingItem("lastincalltime","0","-1",GROUP_NOGROUP,"","","1","0");var vn="1";!isNull(GetConfig("enableblf"))&&GetConfig("enableblf").length>0&&(vn=Trim(GetConfig("enableblf"))),SettingItem("enableblf",vn,"2",GROUP_SIP,webphone_api.stringres.get("enableblf__no")+","+webphone_api.stringres.get("enableblf__auto")+","+webphone_api.stringres.get("enableblf__always")+","+webphone_api.stringres.get("enableblf__must"),"0,1,2,3","1",vn),SettingItem("firststart_webrtc","true","-1",GROUP_NOGROUP,"","","1","true");var kn="2";!isNull(GetConfig("dropsameoldcall"))&&GetConfig("dropsameoldcall").length>0&&(kn=Trim(GetConfig("dropsameoldcall"))),SettingItem("dropsameoldcall",kn,"2",GROUP_CALLDIVERT,webphone_api.stringres.get("dropsameoldcall__no")+","+webphone_api.stringres.get("dropsameoldcall__requested")+","+webphone_api.stringres.get("dropsameoldcall__reqvideo")+","+webphone_api.stringres.get("dropsameoldcall__forall"),"0,1,2,3","1",kn),e=37,SettingItem("wseverconnected","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("sortcontacts","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("filtercontacts","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("lastfilterval","0","-1",GROUP_NOGROUP,"","","1","0");var Un="";!isNull(GetConfig("serveraddressbook_url"))&&GetConfig("serveraddressbook_url").length>0&&(Un=Trim(GetConfig("serveraddressbook_url"))),SettingItem("serveraddressbook_url",Un,"-1",GROUP_NOGROUP,"","","1",Un);var Vn="0";!isNull(GetConfig("serveraddressbook_sync"))&&GetConfig("serveraddressbook_sync").length>0&&(Vn=Trim(GetConfig("serveraddressbook_sync"))),SettingItem("serveraddressbook_sync",Vn,"-1",GROUP_NOGROUP,"","","1",Vn),SettingItem("serveraddressbook_status","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("last_good_webrtc_gw","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("last_login_failed","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("startpage_disp_count","0","-1",GROUP_NOGROUP,"","","1","0");var Wn="false";!isNull(GetConfig("mustconnect"))&&GetConfig("mustconnect").length>0&&(Wn=Trim(GetConfig("mustconnect"))),SettingItem("mustconnect",Wn,"-1",GROUP_NOGROUP,"","","1",Wn),SettingItem("reloadalertdisplayed","false","-1",GROUP_NOGROUP,"","","1","false");var Fn="1";!isNull(GetConfig("networkchecks"))&&GetConfig("networkchecks").length>0&&(Fn=Trim(GetConfig("networkchecks"))),SettingItem("networkchecks",Fn,"-1",GROUP_NOGROUP,"","","1",Fn);var Mn="0";!isNull(GetConfig("qrcode_login"))&&GetConfig("qrcode_login").length>0&&(Mn=Trim(GetConfig("qrcode_login"))),SettingItem("qrcode_login",Mn,"-1",GROUP_NOGROUP,"","","1",Mn);var Hn="2000";!isNull(GetConfig("icetimeout"))&&GetConfig("icetimeout").length>0&&(Hn=Trim(GetConfig("icetimeout"))),SettingItem("icetimeout",Hn,"1",GROUP_SIP,"","","1",Hn);var Bn="1";!isNull(GetConfig("normalize_contact"))&&GetConfig("normalize_contact").length>0&&(Bn=Trim(GetConfig("normalize_contact"))),SettingItem("normalize_contact",Bn,"1",GROUP_SIP,"","","1",Bn);var jn="300";!isNull(GetConfig("nspollinterval"))&&GetConfig("nspollinterval").length>0&&(jn=Trim(GetConfig("nspollinterval"))),SettingItem("nspollinterval",jn,"-1",GROUP_NOGROUP,"","","1",jn),SettingItem("cache_audio_rec_device_list","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("cache_audio_play_device_list","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("cache_audio_ring_device_list","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("cache_video_rec_device_list","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("cache_audio_rec_curr_device","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("cache_audio_play_curr_device","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("cache_audio_ring_curr_device","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("cache_video_rec_curr_device","","-1",GROUP_NOGROUP,"","","1",""),e=38,SettingItem("lnsengine","-1","-1",GROUP_NOGROUP,"","","1","-1"),SettingItem("cancelonnsdownload","0","-1",GROUP_NOGROUP,"","","1","0");var $n="0";!isNull(GetConfig("autogenpassword"))&&GetConfig("autogenpassword").length>0&&($n=Trim(GetConfig("autogenpassword"))),SettingItem("autogenpassword",$n,"-1",GROUP_NOGROUP,"","","1",$n);var qn="2";!isNull(GetConfig("appengine_startat"))&&GetConfig("appengine_startat").length>0&&(qn=Trim(GetConfig("appengine_startat"))),SettingItem("appengine_startat",qn,"-1",GROUP_NOGROUP,"","","1",qn);var zn="";!isNull(GetConfig("customautoprov_url"))&&GetConfig("customautoprov_url").length>0&&(zn=Trim(GetConfig("customautoprov_url"))),SettingItem("customautoprov_url",zn,"-1",GROUP_NOGROUP,"","","1",zn);var Kn="1";!isNull(GetConfig("customautoprov_when"))&&GetConfig("customautoprov_when").length>0&&(Kn=Trim(GetConfig("customautoprov_when"))),SettingItem("customautoprov_when",Kn,"-1",GROUP_NOGROUP,"","","1",Kn);var Xn="1";!isNull(GetConfig("customautoprov_repeat"))&&GetConfig("customautoprov_repeat").length>0&&(Xn=Trim(GetConfig("customautoprov_repeat"))),SettingItem("customautoprov_repeat",Xn,"-1",GROUP_NOGROUP,"","","1",Xn),SettingItem("custautoprov_exectimes","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("storagecookiefailback","1","-1",GROUP_NOGROUP,"","","1","0");var Jn="1";!isNull(GetConfig("quick_access_list"))&&GetConfig("quick_access_list").length>0&&(Jn=Trim(GetConfig("quick_access_list"))),SettingItem("quick_access_list",Jn,"-1",GROUP_NOGROUP,"","","1",Jn);var Yn="1";!isNull(GetConfig("nsupgrademode"))&&GetConfig("nsupgrademode").length>0&&(Yn=Trim(GetConfig("nsupgrademode"))),SettingItem("nsupgrademode",Yn,"2",GROUP_SIP,webphone_api.stringres.get("nsupgrademode__background")+","+webphone_api.stringres.get("nsupgrademode__delayed")+","+webphone_api.stringres.get("nsupgrademode__immediate"),"0,1,2","1",Yn),SettingItem("last_good_ns_plugin_url","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("app_popup_displayed","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("allow_start_app_engine","1","-1",GROUP_NOGROUP,"","","1","1"),e=39;var Qn="0";!isNull(GetConfig("logmanualemail"))&&GetConfig("logmanualemail").length>0&&(Qn=Trim(GetConfig("logmanualemail"))),SettingItem("logmanualemail",Qn,"-1",GROUP_NOGROUP,"","","1",Qn);var Zn="";!isNull(GetConfig("logmanualemail_adress"))&&GetConfig("logmanualemail_adress").length>0?Zn=Trim(GetConfig("logmanualemail_adress")):!isNull(GetConfig("logmanualemail_address"))&&GetConfig("logmanualemail_address").length>0&&(Zn=Trim(GetConfig("logmanualemail_address"))),SettingItem("logmanualemail_adress",Zn,"-1",GROUP_NOGROUP,"","","1",Zn);var et="";!isNull(GetConfig("logmanualemail_subject"))&&GetConfig("logmanualemail_subject").length>0&&(et=Trim(GetConfig("logmanualemail_subject"))),SettingItem("logmanualemail_subject",et,"-1",GROUP_NOGROUP,"","","1",et);var nt="1";!isNull(GetConfig("safaricookie"))&&GetConfig("safaricookie").length>0&&(nt=Trim(GetConfig("safaricookie"))),SettingItem("safaricookie",nt,"-1",GROUP_NOGROUP,"","","1",nt);var tt="-1";!isNull(GetConfig("useurlshortener"))&&GetConfig("useurlshortener").length>0&&IsNumber(GetConfig("useurlshortener"))&&(tt=Trim(GetConfig("useurlshortener"))),SettingItem("useurlshortener",tt,"-1",GROUP_NOGROUP,"","","1",tt);var ot="https://www.mizu-voip.com/G";!isNull(GetConfig("urlshortener_orig"))&&GetConfig("urlshortener_orig").length>0&&(ot=Trim(GetConfig("urlshortener_orig"))),SettingItem("urlshortener_orig",ot,"-1",GROUP_NOGROUP,"","","1",ot);var it="https://tinyurl.com/qm6oja3";!isNull(GetConfig("urlshortener_replace"))&&GetConfig("urlshortener_replace").length>0&&(it=Trim(GetConfig("urlshortener_replace"))),SettingItem("urlshortener_replace",it,"-1",GROUP_NOGROUP,"","","1",it);var at="";!isNull(GetConfig("contactimport_url"))&&GetConfig("contactimport_url").length>0&&(at=Trim(GetConfig("contactimport_url"))),SettingItem("contactimport_url",at,"-1",GROUP_NOGROUP,"","","1",at);var rt="";!isNull(GetConfig("backupserver"))&&GetConfig("backupserver").length>0&&(rt=Trim(GetConfig("backupserver"))),SettingItem("backupserver",rt,"-1",GROUP_NOGROUP,"","","1",rt),e=40,58===GetConfigInt("brandid",-1)&&(SaveParameter("dtmfmode","1"),SaveParameter("aec","0"),SaveParameter("agc","0"),SaveParameter("silencesupress","0"),SaveParameter("voicemailnum","*97")),SaveParameter("code_version",webphone_api.global.code_version),e=41,"undefined"==typeof webphone_api.plhandler||webphone_api.plhandler}catch(lt){PutToDebugLogException(2,"common: InitializeSettings "+e,lt)}}function DoVersioning(){try{var e=GetParameterInt("code_version",0);if(!isNull(e)&&IsNumber(e)||(e=0),e<1)return;if(PutToDebugLog(2,"EVENT, common: DoVersioning called, oldversion: "+e+" current: "+webphone_api.global.code_version),e<webphone_api.global.code_version){if(GetConfig("autoprovisioning").length<1||"0"===GetConfig("autoprovisioning")||"false"===GetConfig("autoprovisioning")||!1===GetConfig("autoprovisioning")){var n=GetParameter("customizedversion");!isNull(GetConfig("customizedversion"))&&GetConfig("customizedversion").length>0&&(n=Trim(GetConfig("customizedversion"))),SettingItem("customizedversion",n,"-1",GROUP_NOGROUP,"","","1","true");var t=GetParameter("serveraddress");!isNull(GetConfig("serveraddress"))&&GetConfig("serveraddress").length>0&&(t=Trim(GetConfig("serveraddress"))),SettingItem("serveraddress",t,"-1",GROUP_NOGROUP,"","","1","");var o=GetParameter("server_label");!isNull(GetConfig("server_label"))&&GetConfig("server_label").length>0&&(o=Trim(GetConfig("server_label"))),SettingItem("server_label",o,"-1",GROUP_NOGROUP,"","","1","Server");var i=GetParameter("showserverinput");!isNull(GetConfig("showserverinput"))&&GetConfig("showserverinput").length>0&&(i=Trim(GetConfig("showserverinput"))),SettingItem("showserverinput",i,"-1",GROUP_NOGROUP,"","","1","1");var a=GetParameter("brandname");!isNull(GetConfig("brandname"))&&GetConfig("brandname").length>0&&(a=Trim(GetConfig("brandname"))),SettingItem("brandname",a,"-1",GROUP_NOGROUP,"","","1","");var r=GetParameter("brandid");!isNull(GetConfig("brandid"))&&GetConfig("brandid").length>0&&(a=Trim(GetConfig("brandid"))),SettingItem("brandid",r,"-1",GROUP_NOGROUP,"","","1","");var l=GetParameter("companyname");!isNull(GetConfig("companyname"))&&GetConfig("companyname").length>0&&(l=Trim(GetConfig("companyname"))),SettingItem("companyname",l,"-1",GROUP_NOGROUP,"","","1","");var s=GetParameter("newuser");!isNull(GetConfig("newuser"))&&GetConfig("newuser").length>0&&(s=Trim(GetConfig("newuser"))),SettingItem("newuser",s,"-1",GROUP_NOGROUP,"","","1","");var p=GetParameter("homepage");!isNull(GetConfig("homepage"))&&GetConfig("homepage").length>0&&(p=Trim(GetConfig("homepage"))),SettingItem("homepage",p,"-1",GROUP_NOGROUP,"","","1","");var c=GetParameter("accounturi");!isNull(GetConfig("accounturi"))&&GetConfig("accounturi").length>0&&(c=Trim(GetConfig("accounturi"))),SettingItem("accounturi",c,"-1",GROUP_NOGROUP,"","","1","");var u=GetParameter("recharge");!isNull(GetConfig("recharge"))&&GetConfig("recharge").length>0&&(u=Trim(GetConfig("recharge"))),SettingItem("recharge",u,"-1",GROUP_NOGROUP,"","","1","");var g=GetParameter("p2p");!isNull(GetConfig("p2p"))&&GetConfig("p2p").length>0&&(g=Trim(GetConfig("p2p"))),SettingItem("p2p",g,"1",GROUP_CALLDIVERT,"","","1","");var h=GetParameter("callback");!isNull(GetConfig("callback"))&&GetConfig("callback").length>0&&(h=Trim(GetConfig("callback"))),SettingItem("callback",h,"1",GROUP_CALLDIVERT,"","","1","");var m=GetParameter("sms");!isNull(GetConfig("sms"))&&GetConfig("sms").length>0&&(m=Trim(GetConfig("sms"))),SettingItem("sms",m,"1",GROUP_CALLDIVERT,"","","1","");var d=GetParameter("sms_recieve");!isNull(GetConfig("sms_recieve"))&&GetConfig("sms_recieve").length>0&&(d=Trim(GetConfig("sms_recieve"))),SettingItem("sms_recieve",d,"-1",GROUP_NOGROUP,"","","1","");var b=GetParameter("creditrequest")
;!isNull(GetConfig("creditrequest"))&&GetConfig("creditrequest").length>0&&(b=Trim(GetConfig("creditrequest"))),SettingItem("creditrequest",b,"1",GROUP_CALLDIVERT,"","","1","");var _=GetParameter("ratingrequest");!isNull(GetConfig("ratingrequest"))&&GetConfig("ratingrequest").length>0&&(_=Trim(GetConfig("ratingrequest"))),SettingItem("ratingrequest",_,"1",GROUP_CALLDIVERT,"","","1","");var f=GetParameter("supportmail");!isNull(GetConfig("supportmail"))&&GetConfig("supportmail").length>0&&(f=Trim(GetConfig("supportmail"))),SettingItem("supportmail",f,"-1",GROUP_NOGROUP,"","","1","");var w=GetParameter("supporturl");!isNull(GetConfig("supporturl"))&&GetConfig("supporturl").length>0&&(w=Trim(GetConfig("supporturl"))),SettingItem("supporturl",w,"-1",GROUP_NOGROUP,"","","1","");var v=GetParameter("header");!isNull(GetConfig("header"))&&GetConfig("header").length>0&&(v=Trim(GetConfig("header"))),v.length<1&&!isNull(GetConfig("headertext"))&&GetConfig("headertext").length>0&&(v=GetConfig("headertext")),SettingItem("header",v,"-1",GROUP_NOGROUP,"","","1","");var E="";!isNull(GetConfig("footer"))&&GetConfig("footer").length>0&&(E=Trim(GetConfig("footer"))),E.length<1&&!isNull(GetConfig("footertext"))&&GetConfig("footertext").length>0&&(E=GetConfig("footertext")),SettingItem("footer",E,"-1",GROUP_NOGROUP,"","","1","");var P=GetParameter("logo");!isNull(GetConfig("logo"))&&GetConfig("logo").length>0&&(P=Trim(GetConfig("logo"))),SettingItem("logo",P,"-1",GROUP_NOGROUP,"","","1","");var T=GetParameter("version");!isNull(GetConfig("version"))&&GetConfig("version").length>0&&(T=Trim(GetConfig("version"))),SettingItem("version",T,"-1",GROUP_NOGROUP,"","","1","");var S=GetParameter("messagedisplay");!isNull(GetConfig("messagedisplay"))&&GetConfig("messagedisplay").length>0&&(S=Trim(GetConfig("messagedisplay"))),SettingItem("messagedisplay",S,"-1",GROUP_NOGROUP,"","","1","");var N=GetParameter("messagepopup");!isNull(GetConfig("messagepopup"))&&GetConfig("messagepopup").length>0&&(N=Trim(GetConfig("messagepopup"))),SettingItem("messagepopup",N,"-1",GROUP_NOGROUP,"","","1","");var I=GetParameter("advertisement");!isNull(GetConfig("advertisement"))&&GetConfig("advertisement").length>0&&(I=Trim(GetConfig("advertisement"))),SettingItem("advertisement",I,"-1",GROUP_NOGROUP,"","","1","");var C=GetParameter("helpurl");!isNull(GetConfig("helpurl"))&&GetConfig("helpurl").length>0&&(C=Trim(GetConfig("helpurl"))),SettingItem("helpurl",C,"-1",GROUP_NOGROUP,"","","1","");var G=GetParameter("licenseurl");!isNull(GetConfig("licenseurl"))&&GetConfig("licenseurl").length>0&&(G=Trim(GetConfig("licenseurl"))),SettingItem("licenseurl",G,"-1",GROUP_NOGROUP,"","","1","");var L=GetParameter("extramenuurl");!isNull(GetConfig("extramenuurl"))&&GetConfig("extramenuurl").length>0&&(L=Trim(GetConfig("extramenuurl"))),SettingItem("extramenuurl",L,"-1",GROUP_NOGROUP,"","","1","");var R=GetParameter("extramenutxt");!isNull(GetConfig("extramenutxt"))&&GetConfig("extramenutxt").length>0&&(R=Trim(GetConfig("extramenutxt"))),SettingItem("extramenutxt",R,"-1",GROUP_NOGROUP,"","","1","")}if(e<12){var y=GetParameter("username"),D=GetParameter("password"),O=GetParameter("serveraddress_orig"),x=GetParameter("serveraddress_user"),A=GetParameter("proxyaddress"),k=GetParameter("sipusername"),U=GetParameter("displayname"),V=GetParameter("email"),W=GetParameter("voicemailnum"),F=GetParameter("callforwardonbusy"),M=GetParameter("wsusers");for(var H in webphone_api.global.settmap)delete webphone_api.global.settmap[H];PutToDebugLog(2,"WARNING, DoVersioning, Initializesettings, because older version "+e+" vs "+webphone_api.global.code_version),HandleSettings("","",function(){}),SaveParameter("username",y),SaveParameter("password",D),SaveParameter("serveraddress_orig",O),SaveParameter("serveraddress_user",x),SaveParameter("proxyaddress",A),SaveParameter("sipusername",k),SaveParameter("displayname",U),SaveParameter("email",V),SaveParameter("voicemailnum",W),SaveParameter("callforwardonbusy",F),SaveParameter("wsusers",M)}if(e<13){var B="";!isNull(GetConfig("rtmpserveraddress"))&&GetConfig("rtmpserveraddress").length>0&&(B=Trim(GetConfig("rtmpserveraddress"))),SettingItem("rtmpserveraddress",B,"-1",GROUP_NOGROUP,"","","1",""),SettingItem("audiodevices","","8",GROUP_MEDIA,"","","1",""),SettingItem("autoaction","0","-1",GROUP_NOGROUP,"","","1","0"),SettingItem("webcallme","1","-1",GROUP_NOGROUP,"","","1","1");var j="";!isNull(GetConfig("callbacknumber"))&&GetConfig("callbacknumber").length>0&&(j=Trim(GetConfig("callbacknumber"))),SettingItem("callbacknumber",j,"1",GROUP_CALLDIVERT,"","","1",""),SettingItem("received_confrooms","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("iswebrtcuppersrvfromuser","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("java_worked","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("ns_worked","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("webrtc_worked","false","-1",GROUP_NOGROUP,"","","1","false");var $="-1";if(!isNull(GetConfig("video"))&&GetConfig("video").length>0&&($=Trim(GetConfig("video"))),"-1"==$&&!isNull(GetConfig("video_config"))&&GetConfig("video_config").length>0){var q=StrToIntDef(GetConfig("video_config"),-1);2==q?$="0":q>2&&q<8||(q>9?$="2":q>=8&&($="1"))}SettingItem("video",$,"2",GROUP_MEDIA,webphone_api.stringres.get("video__auto")+","+webphone_api.stringres.get("video__disable")+","+webphone_api.stringres.get("video__enable")+","+webphone_api.stringres.get("video__force"),"-1,0,1,2","1","1");var z="0";!isNull(GetConfig("video_bandwidth"))&&GetConfig("video_bandwidth").length>0&&(z=Trim(GetConfig("video_bandwidth"))),SettingItem("video_bandwidth",z,"1",GROUP_MEDIA,"","","1","0");var K="640";!isNull(GetConfig("video_width"))&&GetConfig("video_width").length>0&&(K=Trim(GetConfig("video_width"))),SettingItem("video_width",K,"1",GROUP_MEDIA,"","","1","640");var X="480";!isNull(GetConfig("video_height"))&&GetConfig("video_height").length>0&&(X=Trim(GetConfig("video_height"))),SettingItem("video_height",X,"1",GROUP_MEDIA,"","","1","480"),SettingItem("androidchromedisplayed","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("conf_engineswitcheoffered","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("transf_engineswitcheoffered","false","-1",GROUP_NOGROUP,"","","1","false"),SettingItem("filterchatduplicates","true","-1",GROUP_NOGROUP,"","","1","true");var J="true";!isNull(GetConfig("has_video"))&&GetConfig("has_video").length>0&&(J=Trim(GetConfig("has_video"))),"0"===GetParameter2("video")&&(J="false"),SettingItem("has_video",J,"1",GROUP_MEDIA,"","","1",J),SettingItem("sendchatonenter","true","0",GROUP_GENERAL,"","","1","true");var Y="-1";!isNull(GetConfig("transfwithreplace"))&&GetConfig("transfwithreplace").length>0&&(Y=Trim(GetConfig("transfwithreplace"))),SettingItem("transfwithreplace",Y,"2",GROUP_CALLDIVERT,webphone_api.stringres.get("transfwithreplace__auto")+","+webphone_api.stringres.get("transfwithreplace__no")+","+webphone_api.stringres.get("transfwithreplace__yes"),"-1,0,1","1","-1"),SettingItem("showratewhiletype_minlenth","3","-1",GROUP_NOGROUP,"","","1","3"),SettingItem("showratewhiletype_maxlenth","6","-1",GROUP_NOGROUP,"","","1","6")}if(e<14&&(SettingItem("enginechecksum","","-1",GROUP_NOGROUP,"","","1",""),SettingItem("redialonfail","1","-1",GROUP_NOGROUP,"","","1","1")),e<15&&(SettingItem("calldivertsuccess","-1","-1",GROUP_NOGROUP,"","","1","-1"),SettingItem("enginepriority_otherbrowser",GetParameter("enginepriority_otherbrowser"),"2",GROUP_SIP,"Disabled,Lower,Default,Higher,Highest,Force","0,1,2,3,4,5","1","2")),e<16){var Q="en";isNull(GetConfig("language"))||2!==GetConfig("language").length||(Q=Trim(GetConfig("language"))),SettingItem("language",Q,"2",GROUP_GENERAL,"English,German,Hungarian,Italian,Spanish,Portuguese","en,de,hu,it,es,pt","1","en");var Z=GetParameter("extraregisteraccounts");isNull(Z)&&(Z=""),SettingItem("extraregisteraccounts",Z,"-1",GROUP_NOGROUP,"","","1","");var ee="0";!isNull(GetConfig("audio_bandwidth"))&&GetConfig("audio_bandwidth").length>0&&(ee=Trim(GetConfig("audio_bandwidth"))),SettingItem("audio_bandwidth",ee,"1",GROUP_MEDIA,"","","1","0")}if(e<18){SettingItem("normalizenumber",GetParameterInt("normalizenumber",-1).toString(),"2",GROUP_CALLDIVERT,webphone_api.stringres.get("normalizenumber__auto")+","+webphone_api.stringres.get("normalizenumber__no")+","+webphone_api.stringres.get("normalizenumber__yes"),"-1,0,1","1","-1"),SettingItem("nsupgrademode",GetParameterInt("nsupgrademode",1),"2",GROUP_SIP,webphone_api.stringres.get("nsupgrademode__background")+","+webphone_api.stringres.get("nsupgrademode__delayed")+","+webphone_api.stringres.get("nsupgrademode__immediate"),"0,1,2","1","1");var ne=GetParameterInt("transfertype",-1);SettingItem("transfertype",ne,"2",GROUP_CALLDIVERT,webphone_api.stringres.get("transfertype__auto")+","+webphone_api.stringres.get("transfertype__unattended")+","+webphone_api.stringres.get("transfertype__withhold")+","+webphone_api.stringres.get("transfertype__attanded")+","+webphone_api.stringres.get("transfertype__with_no_hold")+","+webphone_api.stringres.get("transfertype__with_conf"),"-1,1,6,5,7,8","1",ne),SettingItem("transfertype1",GetParameterInt("transfertype1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace1",GetParameterInt("transfwithreplace1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace1",GetParameterInt("allowreplace1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer1",GetParameterInt("discontransfer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer1",GetParameterInt("disconincomingrefer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer1",GetParameterInt("inversetransfer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay1",GetParameterInt("transferdelay1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer1",GetParameterInt("newdialogforrefer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer1",GetParameterInt("useserverdomainforrefer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer1",GetParameterInt("holdontransfer1",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype2",GetParameterInt("transfertype2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace2",GetParameterInt("transfwithreplace2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace2",GetParameterInt("allowreplace2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer2",GetParameterInt("discontransfer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer2",GetParameterInt("disconincomingrefer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer2",GetParameterInt("inversetransfer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay2",GetParameterInt("transferdelay2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer2",GetParameterInt("newdialogforrefer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer2",GetParameterInt("useserverdomainforrefer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer2",GetParameterInt("holdontransfer2",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype3",GetParameterInt("transfertype3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace3",GetParameterInt("transfwithreplace3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace3",GetParameterInt("allowreplace3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer3",GetParameterInt("discontransfer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer3",GetParameterInt("disconincomingrefer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer3",GetParameterInt("inversetransfer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay3",GetParameterInt("transferdelay3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer3",GetParameterInt("newdialogforrefer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer3",GetParameterInt("useserverdomainforrefer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer3",GetParameterInt("holdontransfer3",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype4",GetParameterInt("transfertype4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace4",GetParameterInt("transfwithreplace4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace4",GetParameterInt("allowreplace4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer4",GetParameterInt("discontransfer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer4",GetParameterInt("disconincomingrefer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer4",GetParameterInt("inversetransfer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay4",GetParameterInt("transferdelay4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer4",GetParameterInt("newdialogforrefer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer4",GetParameterInt("useserverdomainforrefer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer4",GetParameterInt("holdontransfer4",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype5",GetParameterInt("transfertype5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace5",GetParameterInt("transfwithreplace5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace5",GetParameterInt("allowreplace5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer5",GetParameterInt("discontransfer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer5",GetParameterInt("disconincomingrefer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer5",GetParameterInt("inversetransfer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay5",GetParameterInt("transferdelay5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer5",GetParameterInt("newdialogforrefer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer5",GetParameterInt("useserverdomainforrefer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer5",GetParameterInt("holdontransfer5",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype6",GetParameterInt("transfertype6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace6",GetParameterInt("transfwithreplace6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace6",GetParameterInt("allowreplace6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer6",GetParameterInt("discontransfer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer6",GetParameterInt("disconincomingrefer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer6",GetParameterInt("inversetransfer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay6",GetParameterInt("transferdelay6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer6",GetParameterInt("newdialogforrefer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer6",GetParameterInt("useserverdomainforrefer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer6",GetParameterInt("holdontransfer6",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype7",GetParameterInt("transfertype7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace7",GetParameterInt("transfwithreplace7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace7",GetParameterInt("allowreplace7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer7",GetParameterInt("discontransfer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer7",GetParameterInt("disconincomingrefer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer7",GetParameterInt("inversetransfer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay7",GetParameterInt("transferdelay7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer7",GetParameterInt("newdialogforrefer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer7",GetParameterInt("useserverdomainforrefer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer7",GetParameterInt("holdontransfer7",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype8",GetParameterInt("transfertype8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace8",GetParameterInt("transfwithreplace8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace8",GetParameterInt("allowreplace8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer8",GetParameterInt("discontransfer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer8",GetParameterInt("disconincomingrefer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer8",GetParameterInt("inversetransfer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay8",GetParameterInt("transferdelay8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer8",GetParameterInt("newdialogforrefer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer8",GetParameterInt("useserverdomainforrefer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer8",GetParameterInt("holdontransfer8",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype9",GetParameterInt("transfertype9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace9",GetParameterInt("transfwithreplace9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace9",GetParameterInt("allowreplace9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer9",GetParameterInt("discontransfer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer9",GetParameterInt("disconincomingrefer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer9",GetParameterInt("inversetransfer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay9",GetParameterInt("transferdelay9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer9",GetParameterInt("newdialogforrefer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer9",GetParameterInt("useserverdomainforrefer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer9",GetParameterInt("holdontransfer9",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfertype10",GetParameterInt("transfertype10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfwithreplace10",GetParameterInt("transfwithreplace10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("allowreplace10",GetParameterInt("allowreplace10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("discontransfer10",GetParameterInt("discontransfer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("disconincomingrefer10",GetParameterInt("disconincomingrefer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("inversetransfer10",GetParameterInt("inversetransfer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transferdelay10",GetParameterInt("transferdelay10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("newdialogforrefer10",GetParameterInt("newdialogforrefer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("useserverdomainforrefer10",GetParameterInt("useserverdomainforrefer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("holdontransfer10",GetParameterInt("holdontransfer10",-1),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfername1",GetParameter("transfername1"),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfername2",GetParameter("transfername2"),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfername3",GetParameter("transfername3"),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfername4",GetParameter("transfername4"),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfername5",GetParameter("transfername5"),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfername6",GetParameter("transfername6"),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfername7",GetParameter("transfername7"),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfername8",GetParameter("transfername8"),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfername9",GetParameter("transfername9"),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("transfername10",GetParameter("transfername10"),"-1",GROUP_NOGROUP,"","","-1","");var te=GetParameter("useaudiodevicerecord");te=GetParameter("useaudiorecord",te),(isNull(te)||"-1"!==te&&"0"!==te&&"1"!==te||"2"!==te)&&(te="1");var oe=GetParameter("checkmicrophone");!isNull(oe)&&oe.length>0&&("-1"===oe||"0"===oe||"1"===oe||"2"===oe?te=oe:"true"===oe?te="2":"false"===oe&&(te="-1"));var ie=te;!isNull(GetConfig("useaudiorecord"))&&GetConfig("useaudiorecord").length>0&&(ie=Trim(GetConfig("useaudiorecord"))),SettingItem("useaudiorecord",ie,"-1",GROUP_NOGROUP,"","","1",ie);var ae=GetParameterInt("useurlshortener",-1);!isNull(GetConfig("useurlshortener"))&&GetConfig("useurlshortener").length>0&&IsNumber(GetConfig("useurlshortener"))&&(ae=Trim(GetConfig("useurlshortener"))),SettingItem("useurlshortener",ae,"-1",GROUP_NOGROUP,"","","1",ae);var re=GetParameter("urlshortener_orig");(isNull(re)||re.length<1)&&(re="https://www.mizu-voip.com/G"),!isNull(GetConfig("urlshortener_orig"))&&GetConfig("urlshortener_orig").length>0&&(re=Trim(GetConfig("urlshortener_orig"))),SettingItem("urlshortener_orig",re,"-1",GROUP_NOGROUP,"","","1",re);var le=GetParameter("urlshortener_replace");(isNull(le)||le.length<1)&&(le="https://tinyurl.com/qm6oja3"),!isNull(GetConfig("urlshortener_replace"))&&GetConfig("urlshortener_replace").length>0&&(le=Trim(GetConfig("urlshortener_replace"))),SettingItem("urlshortener_replace",le,"-1",GROUP_NOGROUP,"","","1",le),SettingItem("contactimport_url",GetParameter("contactimport_url"),"-1",GROUP_NOGROUP,"","","-1",""),SettingItem("backupserver",GetParameter("backupserver"),"-1",GROUP_NOGROUP,"","","-1","")}}SaveParameter("code_version",webphone_api.global.code_version)}catch(se){PutToDebugLogException(2,"_settings: DoVersioning",se)}}function SettingItem(e,n,t,o,i,a,r,l,s){try{if(isNull(e)||e.length<1)return void PutToDebugLog(2,"WARNING, _settings: SettingItem invalid setting: "+e+", "+n+", "+t+", "+o+", "+i+", "+a+", "+r+", "+l);isNull(n)?n="":"DEF"===n?n=l:"NULL"===n&&(n="");var p=[];p[SETT_VALUE]=n,p[SETT_TYPE]=t,p[SETT_GROUP]=o,p[SETT_ALLNAMES]=i,p[SETT_ALLVALUES]=a,p[SETT_ISDEFAULT]=r,p[SETT_DEF_VALUE]=l,!0===s?webphone_api.global.settmap2[e]=p:webphone_api.global.settmap[e]=p}catch(c){PutToDebugLogException(2,"common: SettingItem",c)}}function ParamAsBool(e){try{if(isNull(e)||e.length<1)return!1;if(e=e.toString(),e=e.toLowerCase(),e.indexOf("false")>=0)return!1;if(e.indexOf("true")>=0)return!0;if(e.indexOf("no")>=0)return!1;if(e.indexOf("yes")>=0)return!0;if(e.indexOf("ok")>=0)return!0;if(IsNumber(e)){if(StrToInt(e)>0)return!0}}catch(n){PutToDebugLogException(2,"common: ParamAsBool",n)}return!1}function ParamAsInt(e,n){try{if(isNull(e)||e.length<1)return!isNull(n)&&IsNumber(n)?StrToInt(n):n;if(IsNumber(e))return StrToInt(e);if(e=e.toString(),e=e.toLowerCase(),e.indexOf("false")>=0)return 0;if(e.indexOf("true")>=0)return 1}catch(t){PutToDebugLogException(2,"common: ParamAsInt",t)}return e}function GetParameter2(e,n){try{if(isNull(e)&&(e=""),e=e.toString(),e=Trim(e),e.length<1)return PutToDebugLogSpecial(2,"WARNING, common: GetParameter2 no input param",!0,""),"";e.indexOf(",")>=0&&(e=ReplaceAll(e,",",""));var t=webphone_api.parameters[e];return isNull(t)&&(t=GetParameter(e,n)),isNull(t)&&(t=""),t=t.toString(),0===t.indexOf("encrypted__")&&(t=StrDc(t)),"NULL"===t&&(t=""),isNull(t)&&(t=""),Trim(t)}catch(o){PutToDebugLogSpecial(2,"ERROR, common: GetParameter2",!0,o)}return""}function GetParameterOrConfig(e,n){var t=GetParameter(e);return!isNull(t)&&t.length>0?t:(t=GetConfig(e),!isNull(t)&&t.length>0?t:isNull(n)?"":n)}function GetParameterOrConfigInt(e,n){try{!isNull(n)&&IsNumber(n)||(n=0);var t=null,o=GetParameter(e);if(!isNull(o)&&o.length>0&&IsNumber(Trim(o))&&(t=StrToInt(o),!isNull(t)))return t;var i=GetConfig(e);if(!isNull(i)&&i.length>0&&IsNumber(Trim(i))&&(t=StrToInt(i),!isNull(t)))return t;if(!isNull(o)&&o.length>0&&(o=Trim(o.toLowerCase()),"true"===o||"yes"===o?t=1:"false"===o||"no"===o?t=0:IsNumber(o)&&(t=StrToInt(o)),!isNull(t)))return t;if(!isNull(i)&&i.length>0&&(i=Trim(i.toLowerCase()),"true"===i||"yes"===i?t=1:"false"===i||"no"===i?t=0:IsNumber(i)&&(t=StrToInt(i)),!isNull(t)))return t}catch(a){PutToDebugLogException(3,"common: GetParameterOrConfigInt parameter: "+e,a)}return n}function GetParameterOrConfigBool(e,n){try{(isNull(n)||"true"!==n.toString()&&"false"!==n.toString())&&(n=!1);var t=GetParameter(e);if(!isNull(t)&&t.length>0){if("true"==(t=Trim(t.toLowerCase())))return!0;if("false"==t)return!1}var o=GetParameter(e);if(!isNull(o)&&o.length>0){if("true"==(o=Trim(o.toLowerCase())))return!0;if("false"==o)return!1}if(!isNull(t)&&t.length>0){var i=null;if("true"===t||"1"===t||"2"===t||"3"===t||"yes"===t?i=!0:"false"!==t&&"0"!==t&&"no"!==t||(i=!1),!isNull(i))return i}if(!isNull(o)&&o.length>0){var i=null;if("true"===o||"1"===o||"2"===o||"3"===o||"yes"===o?i=!0:"false"!==o&&"0"!==o&&"no"!==o||(i=!1),!isNull(i))return i}}catch(a){PutToDebugLogException(3,"common: GetParameterOrConfigBool parameter: "+e,a)}return n}function GetParameter(e,n){var t=0;try{if(isNull(e)&&(e=""),e=e.toString(),e=Trim(e),e.length<1)return t=2,PutToDebugLogSpecial(2,"WARNING, common: GetParameter no input param",!1,""),"";e.indexOf(",")>=0&&(e=ReplaceAll(e,",",""));var o=!0;(isNull(webphone_api.global.settmap2)||isNull(webphone_api.global.settmap2.magicnumber))&&"loglevel"!==e&&(t=8,o=!1,e!=lastnosettingslog&&(lastnosettingslog=e,PutToDebugLogSpecial(6,"EVENT, common GetParameter no settings: "+e,!1,""))),t=9,!o||e in webphone_api.global.settmap2||(o=!1);var i;if(o){var a=webphone_api.global.settmap2[e];if("serveraddress"===e&&(a[SETT_VALUE]=StripServeraddress(a[SETT_VALUE])),"username"===e||"sipusername"===e){var r=GetParameterInt("handlesipusernameuri",-2);r<-1&&0===GetParameterInt("allowsipuriasusername",1)&&(r=1),a[SETT_VALUE]=r>0||"username"===e?StripUsername(a[SETT_VALUE],!0):StripUsername(a[SETT_VALUE],!1)}isNull(n)||!0!==n?(i=a[SETT_VALUE],isNull(i)&&(i=webphone_api.parameters[e])):i=a[SETT_DEF_VALUE]}else i=webphone_api.parameters[e],isNull(i)||"DEF"!==i||(isNull(webphone_api.global.settmap2)||isNull(webphone_api.global.settmap2[e])?i="":(i=webphone_api.global.settmap2[e][SETT_DEF_VALUE],isNull(i)&&(i="")));return t=10,isNull(i)?"":(i=i.toString(),"NULL"===i&&(i=""),0===i.indexOf("encrypted__")&&(i=StrDc(i)),i.indexOf("CRLF")>=0&&(i=ReplaceAll(i,"CRLF","\r\n")),i)}catch(l){PutToDebugLogSpecial(2,"common: GetParameter ("+t+"), parameter: "+e,!0,l)}return""}function ParameterIsDefault(e){try{if(isNull(e)||e.length<1)return 2,PutToDebugLogSpecial(2,"WARNING, common: ParameterIsDefault no input param",!1,""),!1;if(isNull(webphone_api.global.settmap))return 8,PutToDebugLogSpecial(2,"WARNING, common: ParameterIsDefault no settings param A: "+e,!1,""),!1;if(isNull(webphone_api.global.settmap.magicnumber))return 8,PutToDebugLogSpecial(2,"WARNING, common: ParameterIsDefault no settings param B: "+e,!1,""),!1;if(9,!(e in webphone_api.global.settmap))return!1;return"1"===webphone_api.global.settmap[e][SETT_ISDEFAULT]}catch(n){PutToDebugLogSpecial(2,"ERROR, common: ParameterIsDefault",!0,n)}return!1}function GetParameterInt(e,n){function t(e){try{return void 0!==e&&null!=e&&(e=e.toString(),!(null==(e=e.replace(/\s+/g,""))||e.length<1)&&!isNaN(e))}catch(n){alert("ERROR, common: IsNumberInnerInt"+n)}return!1}try{var o=GetParameter(e);if(isNull(o)||(o=o.toString()),!isNull(o)&&o.length>0){var i=null;return o=o.toLowerCase(),"true"===o||"yes"===o?i=1:"false"===o||"no"===o?i=0:t(Trim(o))&&(i=StrToInt(o)),isNull(i)?isNull(n)?0:t(n)?n:"true"===n||"yes"===n?1:0:i}}catch(a){PutToDebugLogSpecial(2,"ERROR, common: GetParameterInt parameter: "+e,!0,a)}return n}function GetParameterBool(e,n){try{(isNull(n)||"true"!==n.toString()&&"false"!==n.toString())&&(n=!1);var t=GetParameter(e);if(!isNull(t)){var o=null;return t=t.toString(),t=t.toLowerCase(),"true"===t||"1"===t||"2"===t||"3"===t||"yes"===t?o=!0:"false"!==t&&"0"!==t&&"no"!==t||(o=!1),isNull(o)?!isNull(n)&&("true"===n||"1"===n||"2"===n||"3"===n||"yes"===n||"false"!==n&&"0"!==n&&"no"!==n&&n):o}}catch(i){PutToDebugLogException(3,"common: GetParameterBool parameter: "+e,i)}return n}function SaveParameter(e,n,t){try{if(isNull(e)&&(e=""),e=e.toString(),e=Trim(e),e.length<1)return PutToDebugLog(3,"WARNING, common: SaveParameter no input param"),!1;if(isNull(webphone_api.global.settmap))return PutToDebugLog(2,"WARNING, common: SaveParameter no settings"),!1;if(e.indexOf(",")>=0&&(e=ReplaceAll(e,",","")),!isNull(n)&&n.toString().indexOf(",")>=0&&0!=e.indexOf("cache_audio")&&"ice"!=e&&0!=e.indexOf("domaintoip_cache")&&"codec"!=e&&"vcodec"!=e&&"presenceuserlist"!=e&&"blfuserlist"!=e&&"extraregisteraccounts"!=e&&"numpxrewrite"!=e&&"blacklist"!=e&&"defcontacts"!=e&&"disableoptions"!=e&&"srvcontacts"!=e&&(n=ReplaceAll(n,",","")),e.indexOf("server")>=0){if("YOURSIPDOMAIN.COM"===n||"YOURSIPSERVER.COM"===n||"SIPSERVER"===n||"VOIPSERVER"===n||"SERVERADDRESS"===n)return!1}else if("sipusername"==e){if("USERNAME"===n||"SIPUSERNAME"===n)return!1}else if(e.indexOf("username")>=0){if("USERNAME"===n||"SIPUSERNAME"===n)return!1}else if(e.indexOf("password")>=0){if("PASSWORD"===n||"SIPPASSWORD"===n||"SIPASSWORD"===n)return!1}else if(e.indexOf("callto")>=0&&("DESTINATION"===n||"CALLTO"===n))return!1;if("lastsessionsuccess"===e&&GetParameter("lastsessionsuccess")===n)return;if(isNull(n)||(n=n.toString()),isNull(n)||0!==n.indexOf("encrypted__")||(n=StrDc(n)),isNull(n)||(n.indexOf("\r\n")>=0?n=ReplaceAll(n,"\r\n","CRLF"):n.indexOf("\n")>=0?n=ReplaceAll(n,"\n","CRLF"):n.indexOf("\r")>=0&&(n=ReplaceAll(n,"\n","CRLF"))),"webrtcserver"!==e&&"webrtcaddress"!==e&&"rtcserver"!==e&&"rtcaddress"!==e||(e="webrtcserveraddress"),"webrtcserveraddress"===e)"undefined"!=typeof webphone_api.parameters.webrtcserveraddress&&null!==webphone_api.parameters.webrtcserveraddress&&webphone_api.parameters.webrtcserveraddress.length>0&&("undefined"==typeof webphone_api.parameters.origwebrtcserveraddress||null==webphone_api.parameters.origwebrtcserveraddress||webphone_api.parameters.origwebrtcserveraddress.length>0&&webphone_api.parameters.webrtcserveraddress.length>0&&webphone_api.parameters.origwebrtcserveraddress!==webphone_api.parameters.webrtcserveraddress&&n!==webphone_api.parameters.webrtcserveraddress)&&(webphone_api.parameters.origwebrtcserveraddress=webphone_api.parameters.webrtcserveraddress),webphone_api.parameters.webrtcserveraddress=n,selectedwserver="";else{if("callto"===e)return webphone_api.parameters.callto="NULL"===n?"":n,!0;if(("username"===e||"sipusername"===e)&&!isNull(n)&&n.indexOf("@")>0){n=StripUsername(n,!1);var o=GetParameterInt("handlesipusernameuri",-2);o<-1&&0===GetParameterInt("allowsipuriasusername",1)&&(o=1);var i=GetParameterInt("handleusernameuri",3);if(4==i||5==i){var a=webphone_api.global.settmap.serveraddress_user;(5==i||isNull(a[SETT_VALUE])||a[SETT_VALUE].length<1)&&(a[SETT_VALUE]=StripServeraddress(n),webphone_api.global.settmap.serveraddress_user=a)}("username"===e||o>0)&&(n=StripUsername(n,!0))}else if(e===Ssidcode()&&(PutToDebugLog(2,"EVENT,"+Ssidcode()+"_1: "+n),!isNull(n)&&n.length>0&&unlockcodetricktogled<1)){var r=StrDc(unlockcodetrick,alsvkey);PutToDebugLog(2,"EVENT,"+Ssidcode()+"_2: "+r),Trim(n)===r&&(PutToDebugLog(2,"EVENT,"+Ssidcode()+"_3: "+n),unlockcodetricktogled=1)}}var l;if(e in webphone_api.global.settmap2){var s="0";l=webphone_api.global.settmap2[e],"DEF"===n?(n=l[SETT_DEF_VALUE],
s="1"):"NULL"===n&&(n=""),l[SETT_VALUE]=n,l[SETT_ISDEFAULT]=s,webphone_api.global.settmap2[e]=l,webphone_api.global.wasSettModified=!0}else SettingItem(e,n,"-1","-1","","","0",n,!0),webphone_api.global.wasSettModified=!0;if(!0!==t)if(l=null,e in webphone_api.global.settmap){var s="0";l=webphone_api.global.settmap[e],"DEF"===n?(n=l[SETT_DEF_VALUE],s="1"):"NULL"===n&&(n=""),l[SETT_VALUE]=n,l[SETT_ISDEFAULT]=s,webphone_api.global.settmap[e]=l,webphone_api.global.wasSettModified=!0}else SettingItem(e,n,"-1","-1","","","0",n),webphone_api.global.wasSettModified=!0;return"extraregisteraccounts"===e&&ParseSipAccounts(),"loglevel"===e&&(webphone_api.global.loglevel=GetLogLevel()),!0}catch(p){PutToDebugLogException(3,"common: SaveParameter",p)}return!1}function Ssidcode(){if(null!==ssidcode_string)return ssidcode_string;var e=[];return e.push("s"),e.push("s"),e.push("i"),e.push("d"),e.push("c"),e.push("o"),e.push("d"),e.push("e"),ssidcode_string=e.join("")}function GetConfigAll(e){var n=webphone_api.mwphonecfg.getAll();try{if(void 0!==n&&null!==n&&!0===e&&GetPassphrase().length>0){var t=GetPassphrase();for(var o in n)void 0===o||null===o||o.length<1||"passphrase"==o||"undefined"==typeof n[o]||null===n[o]||n[o].toString().length<1||0!=n[o].toString().indexOf("encrypted__")&&0!=n[o].toString().indexOf("dcid_")||(n[o]=StrDc(n[o],t))}}catch(i){PutToDebugLogException(3,"common: GetConfigAll",i)}return n}function GetConfig(e,n){try{if(isNull(e)||e.length<1)return PutToDebugLog(3,"WARNING, common: GetConfig no input param"),"";var t=webphone_api.mwphonecfg.get(e);return isNull(t)?(PutToDebugLog(5,"EVENT, (wanr) common: GetConfig value is NULL for "+e),""):(t=t.toString(),t.length<1?t:(isNull(n)&&(n=!0),(n||0===t.indexOf("encrypted__"))&&(t=StrDc(t)),"serveraddress"===e&&(t=StripServeraddress(t)),"username"===e&&(t=StripUsername(t,!0)),"sipusername"===e&&(t=StripUsername(t,!1)),t))}catch(o){PutToDebugLogException(3,"common: GetConfig",o)}return""}function GetConfigInt(e,n){try{!isNull(n)&&IsNumber(n)||(n=0);var t=GetConfig(e);if(!isNull(t)&&t.length>0){var o=null;return t=t.toLowerCase(),"true"===t||"yes"===t?o=1:"false"===t||"no"===t?o=0:IsNumber(Trim(t))&&(o=StrToInt(t)),isNull(o)?n:o}}catch(i){PutToDebugLogException(3,"common: GetConfigInt parameter: "+e,i)}return n}function GetConfigBool(e,n){try{(isNull(n)||"true"!==n.toString()&&"false"!==n.toString())&&(n=!1);var t=GetConfig(e);if(!isNull(t)){var o=null;return"true"===t.toLowerCase()||"1"===t||"2"===t||"3"===t||"yes"===t.toLowerCase()?o=!0:"false"!==t.toLowerCase()&&"0"!==t&&"no"!==t.toLowerCase()||(o=!1),isNull(o)?n:o}}catch(i){PutToDebugLogException(3,"common: GetConfigBool parameter: "+e,i)}return n}function SaveSettingsFile(e,n,t){try{if(0===GetPreferredStorage())return PutToDebugLog(2,"EVENT, SaveSettingsFile do not save because preferred_storage is 0 from "+e.toString()),void t(!0);if(webphone_api.global.flag_delsett>1||!0===GetParameterBool("resetsettings",!1))return PutToDebugLog(2,"EVENT, SaveSettingsFile DO NOT SAVE, flag delsett is: "+webphone_api.global.flag_delsett.toString()+"; resetsettings is: "+GetParameterBool("resetsettings",!1)+" from: "+e.toString()),void t(!0);if(!t||"function"!=typeof t)return PutToDebugLog(2,"ERROR, common: SaveSettingsFile callback not defined from "+e.toString()),!1;if(isNull(n)||n.length<1)return PutToDebugLog(2,"ERROR, common: SaveSettingsFile filename is NULL from "+e.toString()),t(!1),!1;if(isNull(webphone_api.global.settmap)||isNull(webphone_api.global.settmap.magicnumber))return PutToDebugLog(2,"WARNING, common: SaveSettingsFile no setings to be saved from "+e.toString()),t(!1),!1;webphone_api.global.dispSaveSettMsg++,webphone_api.global.dispSaveSettMsg<3&&PutToDebugLog(2,"EVENT, SaveSettingsFile filename: "+n+" from "+e.toString());var o="",i="";if(!0===GetParameterBool("serverinputisupperserver",!1)){var a=GetParameter("upperserver"),r=GetParameter("serveraddress_user");if((a.length<0||r.indexOf(".")>0)&&ShowServerInput()){var l=GetConfigInt("upperserverfromuser",2),s=GetConfig("upperserver");l<2&&s.length>0?SaveParameter("upperserver",s):SaveParameter("upperserver",r),webphone_api.global.wasSettModified=!1}}var p=GetSafariCookie();for(var c in webphone_api.global.settmap)if(!(isNull(c)||c.length<1)&&"clientreset"!==c&&"clientresetall"!==c){var u=webphone_api.global.settmap[c];o=o+c+";"+u[SETT_VALUE]+";"+u[SETT_TYPE]+";"+u[SETT_GROUP]+";"+u[SETT_ALLNAMES]+";"+u[SETT_ALLVALUES]+";"+u[SETT_ISDEFAULT]+";"+u[SETT_DEF_VALUE]+"\r\n","username"===c||"sipusername"===c||"password"===c||"serveraddress_user"===c||"serveraddress_orig"===c||"upperserver"===c||"loglevel"===c||"code_version"===c||"lastusedengine"===c?i=i+c+";"+u[SETT_VALUE]+"\r\n":1===p&&("server_label"!==c&&"realm"!==c&&"register"!==c&&"registerinterval"!==c&&"enginepriority_java"!==c&&"enginepriority_webrtc"!==c&&"enginepriority_ns"!==c&&"enginepriority_flash"!==c&&"enginepriority_app"!==c&&"enginepriority_p2p"!==c&&"enginepriority_accessnum"!==c&&"enginepriority_nativedial"!==c&&"enginepriority_otherbrowser"!==c&&"last_good_webrtc_gw"!==c&&"volumein"!==c&&"volumeout"!==c&&"codecframecount"!==c&&"displaynotification"!==c&&"signalingport"!==c&&"proxyaddress"!==c&&"displayname"!==c&&"email"!==c&&"chatsms"!==c&&"textmessaging"!==c&&"savetocontacts"!==c&&"transfertype"!==c&&"techprefix"!==c&&"callforwardonbusy"!==c&&"voicemail"!==c&&"filters"!==c&&"startwithos"!==c&&"brandname"!==c&&"brandid"!==c&&"enablepresence"!==c&&"presencestatus"!==c&&"accounts"!==c&&"transport"!==c&&"accessnumber"!==c&&"theme"!==c&&"autostart"!==c&&"conferencetype"!==c&&"sendchatonenter"!==c&&"language"!==c&&"extraregisteraccounts"!==c&&"incomingcallpopup"!==c&&"enablepush"!==c&&"serveraddressbook_url"!==c&&"quick_access_list"!==c||(i=i+c+";"+u[SETT_VALUE]+"\r\n"))}if(1!==GetParameterInt("storagecookiefailback",1)&&1!==p||webphone_api.global.dispSaveSettMsg<3&&webphone_api.global.loglevel>6&&PutToDebugLog(2,"EVENT, SaveSettingsFile save coockie backup = "+i+" from: "+e.toString()),isNull(webphone_api.File))return CanLog(2)&&PutToDebugLog(2,"EVENT, SaveSettingsFile File handling module not loaded yet from: "+e.toString()),t(!1),!1;1!==GetParameterInt("storagecookiefailback",1)&&1!==p||webphone_api.File.SaveFile(n+"_backup",i,webphone_api.global.STORAGE_COOKIE,function(n){webphone_api.global.dispSaveSettMsg<3&&PutToDebugLog(3,"EVENT, SaveSettingsFile save coockie backup: "+n.toString()+" from: "+e.toString())}),IsWindowsSoftphone()?ApiWinSaveFile(n,o,function(e){t(!0)}):webphone_api.File.SaveFile(n,o,webphone_api.global.STORAGE_LOCAL,function(e){t(!0)})}catch(g){PutToDebugLogException(2,"common: SaveSettingsFile",g)}}function ReadSettingsFile(e,n){try{return PutToDebugLogSpecial(3,"EVENT, common ReadSettingsFile called; filename: "+e,!1,""),n&&"function"==typeof n?isNull(e)||e.length<1?(PutToDebugLog(2,"ERROR, common: ReadSettingsFile filename is NULL"),void n(!1)):isNull(webphone_api.File)?(PutToDebugLog(2,"ERROR, ReadSettingsFile File handling module not loaded yet"),n(!1),!1):!webphone_api.parameters.resetsettings||!0!==webphone_api.parameters.resetsettings&&"true"!==webphone_api.parameters.resetsettings?IsWindowsSoftphone()?(ApiWinLoadFile(e,function(t){t+="",isNull(t)||Trim(t).length<2||"null"==t?(PutToDebugLog(4,"EVENT, common: ReadSettingsFile no content WinApi"),webphone_api.File.ReadFile(e+"_backup",webphone_api.global.STORAGE_COOKIE,function(t){(isNull(t)||Trim(t).length<1)&&(t=""),PutToDebugLog(2,"READ contentfromcookie WinApi = "+HideClearPassword(t)),HandleSettings("",e,n),webphone_api.plhandler.ConfigChanged();var o=t.split("\r\n");(isNull(o)||o.length<1)&&(o=[]);for(var i=0;i<o.length;i++)if(!(isNull(o[i])||o[i].length<2||o[i].indexOf(";")<0)){var a=o[i].indexOf(";");if(!(a<1)){var r=Trim(o[i].substring(0,a)),l=Trim(o[i].substring(a+1));SaveParameter(r,l),!0}}PutToDebugLog(2,"EVENT, common: ReadSettingsFile important settings restored from cookie WinApi: "+t)})):(HandleSettings(t,e,n),webphone_api.plhandler.ConfigChanged())}),n(!0),!0):(webphone_api.File.ReadFile(e,webphone_api.global.STORAGE_LOCAL,function(t){return isNull(t)||Trim(t).length<1?(PutToDebugLog(4,"EVENT, common: ReadSettingsFile no content"),1!==GetParameterInt("storagecookiefailback",1)&&1!==GetSafariCookie()?(n(!1),!1):void webphone_api.File.ReadFile(e+"_backup",webphone_api.global.STORAGE_COOKIE,function(t){(isNull(t)||Trim(t).length<1)&&(t=""),PutToDebugLog(2,"READ contentfromcookie = "+HideClearPassword(t)),HandleSettings("",e,n),webphone_api.plhandler.ConfigChanged();var o=t.split("\r\n");(isNull(o)||o.length<1)&&(o=[]);for(var i=!1,a=0;a<o.length;a++)if(!(isNull(o[a])||o[a].length<2||o[a].indexOf(";")<0)){var r=o[a].indexOf(";");if(!(r<1)){var l=Trim(o[a].substring(0,r)),s=Trim(o[a].substring(r+1));"lastusedengine"===l||"prevusedengine"===l?s.length>0&&(SaveParameter(l,s),webphone_api.global.last_used_engine_cache=s):SaveParameter(l,s),i=!0}}return PutToDebugLog(2,"EVENT, common: ReadSettingsFile important settings restored from cookie: "+HideClearPassword(t)),n(i),i})):(HandleSettings(t,e,n),webphone_api.plhandler.ConfigChanged(),n(!0),!0)}),!0):(!1===settdeleted&&(settdeleted=!0,webphone_api.File.DeleteAllCookies(),webphone_api.File.DeleteFile(GetActiveAccSettingsFilename(),function(e){PutToDebugLog(2,"EVENT, delete settings file resetsettings: "+GetActiveAccSettingsFilename()+" result: "+e)})),PutToDebugLog(2,"EVENT, ReadSettingsFile not read because resetsettings"),InitializeSettings(),n(!0),!0):void PutToDebugLog(2,"ERROR, common: ReadSettingsFile callback not defined")}catch(t){PutToDebugLogException(2,"common: ReadSettingsFile",t)}return n(!1),!1}function ClientReset(e,n,t,o){try{if(!0===webphone_api.global.flagclientreset)return;if((isNull(t)||t.length<1)&&(t=!0===IsSDK()?GetSettFilenameSDK():GetActiveAccSettingsFilename()),!0===o){webphone_api.File.DeleteFile(GetActiveAccCallhistoryFilename(),function(e){PutToDebugLog(2,"EVENT, ClientReset delete call history file: "+GetActiveAccCallhistoryFilename()+" result: "+e)}),webphone_api.global.chlist=[],webphone_api.global.recentlist=[];var i=GetParameter("messagefiles");if(!isNull(i)){for(var a=i.split(","),r=0;r<a.length;r++)if(!(isNull(a[r])||a[r].length<3)){var l=a[r].indexOf("[#");l>0&&(a[r]=a[r].substring(0,l));a[r]}SaveParameter("messagefiles","")}var s=GetConfig("brandid");(isNull(s)||s.length<1||"-1"==s)&&(s=GetBrandName().toLowerCase()),webphone_api.File.DeleteFile(GetAccountsFilename(),function(e){PutToDebugLog(2,"EVENT, ClientReset delete accounts file result: "+e)}),webphone_api.global.aclist=[],webphone_api.File.DeleteFile(webphone_api.global.CONTACTS_FILENAME+s,function(e){PutToDebugLog(2,"EVENT, ClientReset delete contacts file result: "+e)}),webphone_api.global.ctlist=[]}!isNull(t)&&t.length>0&&(webphone_api.global.flagclientreset=!0,webphone_api.global.flag_delsett=1,webphone_api.File.DeleteAllCookies(),webphone_api.File.DeleteFile(t,function(t){PutToDebugLog(2,"EVENT, ClientReset delete settings file result: "+t),webphone_api.global.flag_delsett=-1,HandleSettings("","",function(){}),webphone_api.global.flagclientreset=!1,SaveParameter("last_clientreset",e),SaveParameter("last_clientresetall",n),!1===IsSDK()&&OpenSettings(!0,1)}))}catch(p){PutToDebugLogException(2,"common: ClientReset",p)}}function HandleSettings(e,n,t){try{var o="";if(isNull(e)||isNull(e.length)||(o=o+" , content: "+e.length.toString()),!isNull(n)&&!isNull(n.length)&&n.length>0&&(o=o+" , file: "+n),PutToDebugLogSpecial(2,"EVENT,HandleSettings"+o,!1,""),isNull(webphone_api.global.settmap))webphone_api.global.settmap={};else for(var i in webphone_api.global.settmap)delete webphone_api.global.settmap[i];if(isNull(webphone_api.global.settmap2))webphone_api.global.settmap2={};else for(var i in webphone_api.global.settmap2)delete webphone_api.global.settmap2[i];handlesettingscalled=!0,InitializeSettings(),forced_engine_checked=!1;var a=GetConfigAll(!0);if(!isNull(a)){CanLog(3)&&(isNull(a.length)?PutToDebugLog(3,"EVENT,HandleSettingsX cfg "+a):PutToDebugLog(3,"EVENT,HandleSettings cfg "+a.length));for(var r in a)if(!(isNull(r)||r.length<1||r.indexOf("overwrite_")>=0)){var l=a[r];"NULL"===l&&(l=""),SaveParameter(r,l)}}var s=e.split("\r\n");if(isNull(s)||s.length<1)PutToDebugLog(2,"ERROR, common: ParseSettingsReadFromFile empty content");else if(e.indexOf("magicnumber")<0&&e.length>30)PutToDebugLog(3,"ERROR, common ParseSettingsReadFromFile settings file is corrupt "+e.length),webphone_api.File.DeleteAllCookies(),webphone_api.File.DeleteFile(n,function(e){PutToDebugLog(2,"EVENT, ParseSettingsReadFromFile delete settings file result: "+e)});else{CanLog(4)&&PutToDebugLog(4,"EVENT,HandleSettings file "+e.length);for(var p=!1,c=!1,u="",g="",h="",m="",d="",b="",_=-1,f=-1,w=0;w<s.length;w++)if(!(isNull(s[w])||s[w].length<2||s[w].indexOf(";")<0)){var v=s[w].split(";");isNull(v)||8!==v.length||("serveraddress"===v[0]&&(u=v[1]),"webrtcserveraddress"===v[0]&&(g=v[1]),"upperserver"===v[0]&&(h=v[1]),"proxyaddress"===v[0]&&(m=v[1]),"lastsettcrc"===v[0]&&(d=v[1]),"last_clientreset"===v[0]&&IsNumber(v[1])&&(_=StrToInt(v[1])),"last_clientresetall"===v[0]&&IsNumber(v[1])&&(f=StrToInt(v[1])))}!isNull(webphone_api.parameters.last_clientreset)&&IsNumber(webphone_api.parameters.last_clientreset)&&(_=StrToInt(webphone_api.parameters.last_clientreset)),!isNull(webphone_api.parameters.last_clientresetall)&&IsNumber(webphone_api.parameters.last_clientresetall)&&(f=StrToInt(webphone_api.parameters.last_clientresetall));var E=-1,P=-1;if(!isNull(webphone_api.parameters.clientreset)&&IsNumber(webphone_api.parameters.clientreset)&&(E=StrToInt(webphone_api.parameters.clientreset)),!isNull(webphone_api.parameters.clientresetall)&&IsNumber(webphone_api.parameters.clientresetall)&&(P=StrToInt(webphone_api.parameters.clientresetall)),P>f&&(ClientReset(E,P,n,!0),p=!0),E>_&&(ClientReset(E,P,n,!1),p=!0),!isNull(webphone_api.parameters.serveraddress)&&webphone_api.parameters.serveraddress.length>0&&(u=webphone_api.parameters.serveraddress),!isNull(webphone_api.parameters.webrtcserveraddress)&&webphone_api.parameters.webrtcserveraddress.length>0&&(g=webphone_api.parameters.webrtcserveraddress),!isNull(webphone_api.parameters.upperserver)&&webphone_api.parameters.upperserver.length>0&&(h=webphone_api.parameters.upperserver),!isNull(webphone_api.parameters.proxyaddress)&&webphone_api.parameters.proxyaddress.length>0&&(m=webphone_api.parameters.proxyaddress),isNull(u)&&(u=""),isNull(g)&&(g=""),isNull(h)&&(h=""),isNull(m)&&(m=""),isNull(d)&&(d=""),b=Md5Hash(u+g+h+m),d.length>0&&!isNull(b)&&b!==d&&(c=!0,PutToDebugLog(2,"EVENT, HandleSettings: key settings changed, omit them from local storage"),SaveParameter("autostart",0)),setTimeout(function(){SaveParameter("lastsettcrc",b)},500),!1===p)for(var T="",S="",N="",I="",C="",G="",L="",R="",y=0;y<s.length;y++)if(!(isNull(s[y])||s[y].length<2||s[y].indexOf(";")<0)){var D=s[y].split(";");if(isNull(D))PutToDebugLog(2,"WARNING, common ReadSettingsFile can't parse. clen: "+e.length+", alen: "+s.length+", setting: "+s[y]);else if(8===D.length||"get"===D[0]||"getAll"===D[0])T=D[0],(!0!==c||"serveraddress"!==T&&"serveraddress_orig"!==T&&"serveraddress_user"!==T&&"webrtcserveraddress"!==T&&"upperserver"!==T&&"proxyaddress"!==T&&"realm"!==T&&"lastsettcrc"!==T)&&(S=D[1],N=D[2],I=D[3],C=D[4],G=D[5],L=D[6],R=D[7],SettingItem(T,S,N,I,C,G,L,R),"loglevel"===T&&SettingItem(T,S,N,I,C,G,L,R,!0),T="",S="",N="",I="",C="",G="",L="",R="");else{PutToDebugLog(2,"WARNING, common ReadSettingsFile broken or invalid setting after parse. clen: "+e.length+", alen: "+s.length+", len: "+D.length+", tmp: "+D)}}}if(!isNull(a))for(var r in a)if(!(isNull(r)||r.length<1||r.indexOf("overwrite_")<0)){r=r.replace("overwrite_","");var l=a[r];"NULL"===l&&(l=""),SaveParameter(r,l)}for(var i in webphone_api.global.settmap)isNull(i)||i.length<1||(webphone_api.global.settmap2[i]=webphone_api.global.settmap[i]);if(!isNull(webphone_api.parameters)){for(var i in webphone_api.parameters)if(!(isNull(i)||i.length<1||"codec"===i||"extraregisteraccounts"==i)){var S=webphone_api.parameters[i];if(isNull(S)&&(S=""),"object"==typeof S)try{S=JSON.stringify(S)}catch(A){}S=isNull(S)?"":S.toString(),S.length<1||0===i.indexOf("ucfg_")&&!isNull(GetParameter(i))&&GetParameter(i).length>0||(i=i.replace("ucfg_",""),"NULL"===S&&(S=""),"webrtcserver"!==i&&"webrtcaddress"!==i&&"rtcserver"!==i&&"rtcaddress"!==i||(i="webrtcserveraddress"),"loglevel"===i?!isNull(StrToInt(S))&&StrToInt(S)>1&&SaveParameter(i,S,!0):SaveParameter(i,S,!0),"username"!==i||"undefined"!=typeof webphone_api.parameters.sipusername&&null!==webphone_api.parameters.sipusername?"sipusername"!==i||"undefined"!=typeof webphone_api.parameters.username&&null!==webphone_api.parameters.username||SaveParameter("username",S,!0):SaveParameter("sipusername",S,!0))}var O=webphone_api.parameters.serveraddress;!isNull(O)&&O.length>1&&(SaveParameter("serveraddress",O,!0),SaveParameter("serveraddress_user",O,!0),SaveParameter("serveraddress_orig",O,!0)),GetCodecsAudioFromApiParam(),GetCodecsVideoFromApiParam()}GetSettingsFromUrl();var x=GetParameter("serveraddress");return!isNull(x)&&x.length>0&&SaveParameter("serveraddress",NormalizeInput(x,0)),x=GetParameter("serveraddress_user"),!isNull(x)&&x.length>0&&SaveParameter("serveraddress_user",NormalizeInput(x,0)),x=GetParameter("serveraddress_orig"),!isNull(x)&&x.length>0&&SaveParameter("serveraddress_orig",NormalizeInput(x,0)),x=GetParameter("webrtcserveraddress"),!isNull(x)&&x.length>0&&SaveParameter("webrtcserveraddress",NormalizeInputBasic(x,0)),x=GetParameter("turnserveraddress"),!isNull(x)&&x.length>0&&SaveParameter("turnserveraddress",NormalizeInput(x,0)),x=GetParameter("sipusername"),!isNull(x)&&x.length>0&&SaveParameter("sipusername",NormalizeInput(x,0)),x=GetParameter("username"),!isNull(x)&&x.length>0&&SaveParameter("username",NormalizeInput(x,0)),webphone_api.global.loglevel=GetLogLevel(),IsCExt(),SetLanguage(),SetCurrTheme(),HandleScurlSetparameters(),ParseSipAccounts(),void t(!0)}catch(k){PutToDebugLog(2,"EVENT, common: HandleSettings er1")}HandleScurlSetparameters(),ParseSipAccounts(),t(!1)}function GetSettingsFromUrl(){var e=!1;try{var n=window.location.href,t="",o="",i="";if(isNull(n)||n.length<1)return;n=decodeURIComponent(n),n=Trim(n),CanLog(4)&&PutToDebugLog(4,"EVENT, GetSettingsFromUrl url: "+n);var a=n.indexOf("?");if(a<0)return;n=n.substring(a+1,n.length),a=n.indexOf("#page_"),a>0&&(n=n.substring(0,a));for(var r=0;n.length>3&&r<100;){r++,a=n.indexOf("&"),a<0&&(a=n.length);var l=n.substring(0,a);if(n=n.substring(a,n.length),0===n.indexOf("&")&&(n=n.substring(1,n.length)),!(isNull(l)||l.length<1))if(l=Trim(l),(a=l.indexOf("="))<1)PutToDebugLog(3,"EVENT, GetSettingsFromUrl invalid settings: "+l);else{var s=Trim(l.substring(0,a)),p=Trim(l.substring(a+1,l.length));p=0==p.indexOf("encrypted__16__")?StrDc(p,"1AzbNh5FdLT9m"):StrDc(p),"platform"!==s||"windesktop"!==p?0===s.indexOf("wp_")&&((s.indexOf("serveraddres")>0||s.indexOf("username")>0||s.indexOf("sipusername")>0||s.indexOf("password")>0)&&(webphone_api.global.sipaccounts=[],SaveSipAccounts()),s=s.substring(s.indexOf("wp_")+3,s.length),"brandnamestr"===s&&p.length>0?s="brandname":"resetsettings"===s&&p.length>0&&("1"===p.toLowerCase()||"true"===p.toLowerCase())?e=!0:"serveraddress"===s&&p.length>0&&(SaveParameter("iswebrtcuppersrvfromuser","true",!0),SaveParameter("serveraddress_user",Trim(p),!0),SaveParameter("serveraddress_orig",Trim(p),!0)),"video"===s&&!0===CanIUseWebRTC()&&(PutToDebugLog(2,"WARNING, Enginepriority_WebRTC is set manually to 4 because video is forced"),SaveParameter("enginepriority_webrtc","4")),"callto"===s&&!isNull(p)&&p.length>0?t=p:"sendchat"===s&&!isNull(p)&&p.length>0?o=p:"to"===s&&!isNull(p)&&p.length>0?i=p:SaveParameter(s,Trim(p),!0)):(s="devicetype",p=""+DEVICE_WIN_SOFTPHONE(),SaveParameter(s,p,!0))}}if(!0===e)return PutToDebugLog(2,"EVENT, mlogic Delsettings GetSettingsFromUrl"),void webphone_api.delsettings(2);(isNull(t)||t.length<1)&&(t=GetParameter("callto")),!isNull(t)&&t.length>0&&!1===autocall_called&&(autocall_called=!0,webphone_api.global.aua_handled=!0,setTimeout(function(){3===GetParameterInt("autoaction",0)?(PutToDebugLog(2,"EVENT,GetSettingsFromUrl initiate autoaction video call to: "+t),PutToDebugLog(2,"EVENT, mlogic API_VideoCall GetSettingsFromUrl"),webphone_api.videocall(decodeURIComponent(t))):(PutToDebugLog(2,"EVENT,GetSettingsFromUrl initiate autoaction call to: "+t),PutToDebugLog(2,"EVENT, mlogic API_Call GetSettingsFromUrl"),webphone_api.call(decodeURIComponent(t)))},200)),!isNull(o)&&o.length>0&&!isNull(i)&&i.length>0&&!1===sendchat_called&&(sendchat_called=!0,webphone_api.global.aua_handled=!0,setTimeout(function(){PutToDebugLog(2,"EVENT, mlogic API_SendChat GetSettingsFromUrl"),webphone_api.sendchat(decodeURIComponent(i),decodeURIComponent(o))},200))}catch(c){PutToDebugLogException(2,"common: GetSettingsFromUrl",c)}}function GetOverWriteSettings(){try{var e=GetConfigAll(!0);if(isNull(e))return;for(var n in e)isNull(n)||n.length<1||n.indexOf("overwrite_")<0||(n=n.replace("overwrite_",""),SaveParameter(n,e[n]))}catch(t){PutToDebugLogException(2,"common: GetOverWriteSettings",t)}}function OpenSettings(e,n){try{webphone_api.global.sipstackstarted=!1,3===n&&(getuseengine()===webphone_api.global.ENGINE_SERVICE||getuseengine()===webphone_api.global.ENGINE_JAVA)||8===n?PutToDebugLog(2,"EVENT, mlogic OpenSettings: "+n):(PutToDebugLog(2,"EVENT, mlogic API_Unregister OpenSettings: "+n),webphone_api.unregister(),PutToDebugLog(2,"EVENT, mlogic API_Stop OpenSettings: "+n),webphone_api.stop()),!1===IsSDK()&&(isNull(e)||!0!==e||(webphone_api.global.intentsettings[0]="startedfrom=app"),"undefined"!=typeof webphone_api.$&&null!==webphone_api.$&&"undefined"!=typeof webphone_api.$.mobile&&null!==webphone_api.$.mobile&&webphone_api.$.mobile.changePage("#page_settings",{transition:"pop",role:"page"})),IsWindowsSoftphone()||"Android"===GetOs()||setTimeout(function(){ChooseEngineLogic(function(){PutToDebugLog(3,"EVENT, ChooseEngineLogic called on going to settings page")},!1,3)},350)}catch(t){PutToDebugLogException(2,"common: OpenSettings",t)}}function GetIntentParam(e,n){try{if(isNull(e)||isNull(n))return"";if(n=Trim(n),e.length<1||n.length<1)return"";for(var t=0;t<e.length;t++)if(!isNull(e[t])&&0===e[t].indexOf(n)&&e[t].indexOf("=")>0){var o=e[t].substring(e[t].indexOf("=")+1);return Trim(o)}}catch(i){PutToDebugLogException(2,"common: GetIntentParam",i)}return""}function SaveContactsFile(e){try{if(0===GetPreferredStorage())return PutToDebugLog(2,"EVENT, SaveContactsFile do not save because preferred_storage is 0"),void e(!0);if(webphone_api.global.flag_delsett>1||!0===GetParameterBool("resetsettings",!1))return void PutToDebugLog(2,"EVENT, SaveContactsFile DO NOT SAVE, flag delsett is: "+webphone_api.global.flag_delsett.toString()+"; resetsettings is: "+GetParameterBool("resetsettings",!1));if(!e||"function"!=typeof e)return void PutToDebugLog(2,"ERROR, common: SaveContactsFile callback not defined");if(isNull(webphone_api.global.ctlist))return PutToDebugLog(2,"EVENT, SaveContactsFile no contacts to be saved"),e(!1),!1;if(isNull(webphone_api.File))return PutToDebugLog(2,"EVENT, SaveContactsFile File handling module not loaded yet"),e(!1),!1;for(var n="",t=null,o=0;o<webphone_api.global.ctlist.length;o++)if(t=webphone_api.global.ctlist[o],!isNull(t)){var i=t[CT_EMAIL],a=t[CT_ADDRESS],r=t[CT_NOTES],l=t[CT_WEBSITE],s=t[CT_LASTACTIVE],p=t[CT_ISFROMSYNC];isNull(i)&&(i=""),isNull(a)&&(a=""),isNull(r)&&(r=""),isNull(l)&&(l=""),(isNull(s)||s.length<1||!1===IsNumber(s))&&(s="0"),(isNull(p)||p.length<1||!1===IsNumber(p))&&(p="1"),n=n+t[CT_NAME]+",[",n=n+t[CT_NUMBER].join(";")+"],[",n=n+t[CT_PTYPE].join(";")+"],",n=n+t[CT_USAGE]+","+t[CT_LASTMODIF]+","+t[CT_DELFLAG]+","+t[CT_FAV]+","+i+","+a+","+r+","+l+","+s+","+p+"\r\n"}var c=GetConfig("brandid");(isNull(c)||c.length<1||"-1"==c)&&(c=GetBrandName().toLowerCase()),IsWindowsSoftphone()?ApiWinSaveFile(webphone_api.global.CONTACTS_FILENAME+c,n,function(n){webphone_api.global.wereCtModified=!1,e(!0)}):webphone_api.File.SaveFile(webphone_api.global.CONTACTS_FILENAME+c,n,webphone_api.global.STORAGE_LOCAL,function(n){webphone_api.global.wereCtModified=!1,e(n)})}catch(u){PutToDebugLogException(2,"common: SaveContactsFile",u)}}function ReadContactsFile(e){try{if(!e||"function"!=typeof e)return void PutToDebugLog(2,"ERROR, common: ReadContactsFile callback not defined");if(isNull(webphone_api.File))return PutToDebugLog(2,"EVENT, ReadContactsFile File handling module not loaded yet"),e(!1),!1;var n=GetConfig("brandid");if((isNull(n)||n.length<1||"-1"==n)&&(n=GetBrandName().toLowerCase()),webphone_api.parameters.resetsettings&&(!0===webphone_api.parameters.resetsettings||"true"===webphone_api.parameters.resetsettings))return!1===contactsdeleted&&(contactsdeleted=!0,webphone_api.File.DeleteFile(webphone_api.global.CONTACTS_FILENAME+n,function(e){PutToDebugLog(2,"EVENT, delete contacts file resetsettings result: "+e)}),webphone_api.global.ctlist=[]),PutToDebugLog(2,"EVENT, ReadContactsFile not read because resetsettings"),e(!0),!0;IsWindowsSoftphone()?ApiWinLoadFile(webphone_api.global.CONTACTS_FILENAME+n,function(n){if(isNull(n)||Trim(n).length<1)return PutToDebugLog(2,"EVENT, common: ReadContactsFile no content WinApi"),e(!1),!1;ParseContactsReadFromFile(n,!0,e)}):webphone_api.File.ReadFile(webphone_api.global.CONTACTS_FILENAME+n,webphone_api.global.STORAGE_LOCAL,function(n){if(isNull(n)||Trim(n).length<1)return PutToDebugLog(2,"EVENT, common: ReadContactsFile no content"),e(!1),!1;ParseContactsReadFromFile(n,!0,e)})}catch(t){PutToDebugLogException(2,"common: ReadContactsFile",t)}}function ParseContactsReadFromFile(e,n,t){try{var o=e.split("\r\n");if(isNull(o)||o.length<1)return PutToDebugLog(2,"ERROR, common: ParseContactsReadFromFile empty content"),t&&t(!1),!1;if(!0===n&&!isNull(webphone_api.global.ctlist))for(var i in webphone_api.global.ctlist)delete webphone_api.global.ctlist[i];for(var a="",r="",l=0;l<o.length;l++)if(isNull(o[l])||o[l].length<2||o[l].indexOf(",")<0)PutToDebugLog(2,"EVENT, common ParseContactsReadFromFile broken or invalid contact (1): "+o[l]);else if(a=o[l].split(","),r="",r=a[CT_NUMBER],isNull(r)||r.length<2||r.indexOf("[")<0)PutToDebugLog(2,"EVENT, common ParseContactsReadFromFile broken or invalid contact: (2)"+o[l]);else{r=r.substring(1,r.length-1);var s=r.split(";");if(isNull(s)&&(s=[]),r="",r=a[CT_PTYPE],isNull(r)||r.length<2||r.indexOf("[")<0)PutToDebugLog(2,"WARNING, common ParseContactsReadFromFile broken or invalid contact: (3)"+o[l]);else{r=r.substring(1,r.length-1);var p=r.split(";");isNull(p)&&(p=[]);var c=a[CT_EMAIL],u=a[CT_ADDRESS],g=a[CT_NOTES],h=a[CT_WEBSITE],m="0";a.length>CT_LASTACTIVE&&(m=a[CT_LASTACTIVE]);var d="1";a.length>CT_ISFROMSYNC&&(d=a[CT_ISFROMSYNC]),isNull(c)&&(c=""),isNull(u)&&(u=""),isNull(g)&&(g=""),isNull(h)&&(h="");var b=[];b[CT_NAME]=a[CT_NAME],b[CT_NUMBER]=s,b[CT_PTYPE]=p,b[CT_USAGE]=a[CT_USAGE],b[CT_LASTMODIF]=a[CT_LASTMODIF],b[CT_DELFLAG]=a[CT_DELFLAG],b[CT_FAV]=a[CT_FAV],b[CT_EMAIL]=c,b[CT_ADDRESS]=u,b[CT_NOTES]=g,b[CT_WEBSITE]=h,b[CT_LASTACTIVE]=m,b[CT_ISFROMSYNC]=d,webphone_api.global.ctlist.push(b)}}SortContacts(),t&&t(!0)}catch(_){PutToDebugLogException(2,"common: ParseContactsReadFromFile",_)}}function ParseContactsFromServer(e,n,t){try{var o=e.split("\r\n");if(isNull(o)||o.length<1)return PutToDebugLog(2,"ERROR, common: ParseContactsFromServer empty content"),t(!1),!1;if(!0===n&&!isNull(webphone_api.global.ctlist))for(var i in webphone_api.global.ctlist)delete webphone_api.global.ctlist[i];for(var a="",r=0;r<o.length;r++)if(isNull(o[r])||o[r].length<2||o[r].indexOf(",")<0)PutToDebugLog(2,"EVENT, common ParseContactsFromServer broken or invalid contact ["+r.toString()+"] (1): "+o[r]);else if(a=o[r].split(","),isNull(a)||a.length<7)PutToDebugLog(2,"EVENT, common ParseContactsFromServer broken or invalid contact ["+r.toString()+"] (2): "+o[r]);else{var l=a[0];isNull(l)&&(l=""),l=Trim(l);for(var s=[],p=[],c=1;c<=5;){var u=a[c];!isNull(u)&&u.length>0&&(u=ReplaceAll(u," ",""),u=ReplaceAll(u,"-",""),u=ReplaceAll(u,"(",""),u=ReplaceAll(u,")",""),s.indexOf(u)<0&&(s.push(a[c]),!0===IsNumeric(a[c],"+")&&a[c].length>6?p.push("phone"):p.push("sip"))),c++}var g=[];g[CT_NAME]=l,g[CT_NUMBER]=s,g[CT_PTYPE]=p,g[CT_USAGE]="0",g[CT_LASTMODIF]="0",g[CT_DELFLAG]="0",g[CT_FAV]="0",g[CT_EMAIL]="",g[CT_ADDRESS]="",g[CT_NOTES]="",g[CT_WEBSITE]="",g[CT_LASTACTIVE]="0",g[CT_ISFROMSYNC]="1",webphone_api.global.ctlist.push(g)}SortContacts(),t(!0)}catch(h){PutToDebugLogException(2,"common: ParseContactsFromServer",h)}}function GetContacts(e){try{isNull(webphone_api.global.ctlist)||webphone_api.global.ctlist.length<1||GetParameter("lastfilterval")!==GetParameter("filtercontacts")?ReadContactsFile(function(n){SortContacts(),e&&e(n)}):webphone_api.global.wasCtModified?(SortContacts(),e&&e(!0)):e&&e(!0)}catch(n){PutToDebugLogException(2,"common: GetContacts",n)}}function SortContacts(){try{var e=GetParameterInt("sortcontacts",0);0===e?webphone_api.global.ctlist.sort(function(e,n){return e[CT_NAME].toLowerCase()<n[CT_NAME].toLowerCase()?-1:e[CT_NAME].toLowerCase()>n[CT_NAME].toLowerCase()?1:0}):1===e?webphone_api.global.ctlist.sort(function(e,n){return StrToInt(e[CT_USAGE])<StrToInt(n[CT_USAGE])?1:StrToInt(e[CT_USAGE])>StrToInt(n[CT_USAGE])?-1:0}):2===e&&webphone_api.global.ctlist.sort(function(e,n){for(var t=0,o=0,i=0;i<e[CT_NUMBER].length;i++){var a=webphone_api.global.presenceHM[e[CT_NUMBER][i]];if(!isNull(a)&&"5"===a[PRES_STATUS]){t=5;break}}for(var r=0;r<n[CT_NUMBER].length;r++){var l=webphone_api.global.presenceHM[e[CT_NUMBER][r]];if(!isNull(l)&&"5"===l[PRES_STATUS]){o=5;break}}return t<o?1:t>o?-1:0})}catch(n){PutToDebugLogException(2,"common: SortContacts",n)}}function UpdateContactLastActive(e){try{if(isNull(e)||e.length<1)return;var n=GetContactIdFromNumber(e);if(n>=0){var t=webphone_api.global.ctlist[n];t[CT_LASTACTIVE]=GetTickCount().toString(),webphone_api.global.ctlist[n]=t}}catch(o){PutToDebugLogException(2,"common: UpdateContactLastActive",o)}}function GetContactIdFromNumber(e){var n=-1,t=0;try{if(t=1,isNull(e)||Trim(e).length<1||isNull(webphone_api.global.ctlist)||webphone_api.global.ctlist.length<1)return-1;t=2,e=Trim(e.replace("+",""));var o=e;o.length>4&&(o=Trim(o.substring(1))),o.length>4&&"0"===o.charAt(0)&&(o=Trim(o.substring(1)));var i=o;i=i.replace("-",""),i=i.replace(" ",""),i=i.replace("(",""),i=i.replace(")",""),i=Trim(i),t=3;for(var a,r=0;r<webphone_api.global.ctlist.length;r++){t=4;var l=webphone_api.global.ctlist[r];if(!isNull(l)){var s=l[CT_NUMBER];if(!isNull(s)){t=5;for(var p=0;p<s.length;p++)if(!isNull(s[p])&&(t=55,a=s[p].toString(),t=6,!(a.length<1)&&(t=7,a.indexOf(e)>=0&&a.indexOf(e)<5&&a.indexOf(e)==a.length-e.length||a.indexOf(o)>=0&&a.indexOf(o)<5&&a.indexOf(o)==a.length-o.length||a.indexOf(i)>=0&&a.indexOf(i)<5&&a.indexOf(i)==a.length-i.length))){n=r;break}}}}}catch(c){PutToDebugLogException(2,"common: GetContactIdFromNumber ("+t.toString()+")",c)}return n}function GetContactNameFromNumber(e){var n=e;try{if(isNull(e)||Trim(e).length<1)return"";if(isNull(webphone_api.global.ctlist)||webphone_api.global.ctlist.length<1)return e;e=Trim(e),e=e.replace("-",""),e=e.replace(" ",""),e=e.replace("(",""),e=e.replace(")","");for(var t=!1,o=0;o<webphone_api.global.ctlist.length;o++){var i=webphone_api.global.ctlist[o];if(!isNull(i)){var a=i[CT_NUMBER];if(!isNull(a))for(var r=0;r<a.length;r++)if(!isNull(a[r])&&a[r]===e){n=i[CT_NAME],t=!0;break}}}if(!1===t)for(var o=0;o<webphone_api.global.ctlist.length;o++){var i=webphone_api.global.ctlist[o];if(!isNull(i)){var a=i[CT_NUMBER];if(!isNull(a))for(var r=0;r<a.length;r++)if(!isNull(a[r])&&(a[r].length>6&&e.length>5&&a[r].indexOf(e)>=0||a[r].length>5&&e.length>6&&e.indexOf(a[r])>=0||e==="+"+a[r]||e==="00"+a[r]||a[r]==="+"+e||a[r]==="00"+e)){n=i[CT_NAME],t=!0;break}}}}catch(l){PutToDebugLogException(2,"common: GetContactNameFromNumber",l)}return n}function ContactExists(e,n){try{
if(isNull(webphone_api.global.ctlist)||webphone_api.global.ctlist.length<1)return!1;isNull(e)&&(e=""),e=Trim(e),isNull(n)&&(n=""),n=Trim(n);var t=!1,o=!1;if(e.length>0&&(t=!0),n.length>0&&(o=!0),(isNull(e)||e.length<1)&&(isNull(n)||n.length<1)||!1===t&&!1===o)return PutToDebugLog(2,"ERROR, ContactExists invalid name and number"),!1;for(var i=0;i<webphone_api.global.ctlist.length;i++){var a=webphone_api.global.ctlist[i];if(!(isNull(a)||a.length<4)){if(!0===t&&a[CT_NAME]===e)return!0;if(!0===o){var r=a[CT_NUMBER];if(isNull(r)||r.length<1)continue;for(var l=0;l<r.length;l++)if(r[l]===n)return!0}}}}catch(s){PutToDebugLogException(2,"common: ContactExists",s)}return!1}function SaveCallhistoryFile(e){try{if(0===GetPreferredStorage())return PutToDebugLog(2,"EVENT, SaveCallhistoryFile do not save because preferred_storage is 0"),void e(!0);if(webphone_api.global.flag_delsett>1||!0===GetParameterBool("resetsettings",!1))return void PutToDebugLog(2,"EVENT, SaveCallhistoryFile DO NOT SAVE, flag delsett is: "+webphone_api.global.flag_delsett.toString()+"; resetsettings is: "+GetParameterBool("resetsettings",!1));if(!e||"function"!=typeof e)return void PutToDebugLog(2,"ERROR, common: SaveCallhistoryFile callback not defined");if(isNull(webphone_api.global.chlist))return PutToDebugLog(2,"EVENT, SaveCallhistoryFile no contacts to be saved"),e(!1),!1;if(isNull(webphone_api.File))return PutToDebugLog(2,"EVENT, SaveCallhistoryFile File handling module not loaded yet"),e(!1),!1;for(var n="",t=null,o=0;o<webphone_api.global.chlist.length;o++)if(t=webphone_api.global.chlist[o],!isNull(t)){var i="";t.length>6&&(i=t[CH_REASON]),n.length>3&&(n+="\r\n"),n=n+t[CH_TYPE]+","+t[CH_NAME]+","+t[CH_NUMBER]+","+t[CH_DATE]+","+t[CH_DURATION]+","+t[CH_RECORDING]+","+i}IsWindowsSoftphone()?ApiWinSaveFile(GetActiveAccCallhistoryFilename(),n,function(n){webphone_api.global.wasChModified=!1,e(!0)}):webphone_api.File.SaveFile(GetActiveAccCallhistoryFilename(),n,webphone_api.global.STORAGE_LOCAL,function(n){webphone_api.global.wasChModified=!1,e(n)})}catch(a){PutToDebugLogException(2,"common: SaveCallhistoryFile",a)}}function ReadCallhistoryFile(e){try{if(!e||"function"!=typeof e)return void PutToDebugLog(2,"ERROR, common: ReadCallhistoryFile callback not defined");if(isNull(webphone_api.File))return PutToDebugLog(2,"EVENT, ReadCallhistoryFile File handling module not loaded yet"),e(!1),!1;if(!0===webphone_api.parameters.resetsettings||"true"===webphone_api.parameters.resetsettings)return!1===callhdeleted&&(callhdeleted=!0,webphone_api.File.DeleteFile(GetActiveAccCallhistoryFilename(),function(e){PutToDebugLog(2,"EVENT, delete call history file resetsettings: "+GetActiveAccCallhistoryFilename()+" result: "+e)}),webphone_api.global.chlist=[],webphone_api.global.recentlist=[]),PutToDebugLog(2,"EVENT, ReadCallhistoryFile not read because resetsettings"),e(!0),!0;IsWindowsSoftphone()?ApiWinLoadFile(GetActiveAccCallhistoryFilename(),function(n){if(isNull(n)||Trim(n).length<1)return PutToDebugLog(2,"EVENT, common: ReadCallhistoryFile no content WinApi"),e(!1),!1;ParseCallhistoryReadFromFile(n,e)}):webphone_api.File.ReadFile(GetActiveAccCallhistoryFilename(),webphone_api.global.STORAGE_LOCAL,function(n){if(isNull(n)||Trim(n).length<1)return PutToDebugLog(2,"EVENT, common: ReadCallhistoryFile no content"),e(!1),!1;ParseCallhistoryReadFromFile(n,e)})}catch(n){PutToDebugLogException(2,"common: ReadCallhistoryFile",n)}}function ParseCallhistoryReadFromFile(e,n){try{var t=e.split("\r\n");if(isNull(t)||t.length<1)return PutToDebugLog(2,"ERROR, common: ReadCallhistoryFile empty content"),n(!1),!1;if(!isNull(webphone_api.global.chlist))for(var o in webphone_api.global.chlist)delete webphone_api.global.chlist[o];for(var i=null,a=0;a<t.length;a++)isNull(t[a])?PutToDebugLog(2,"WARNING, common ReadCallhistoryFile broken or invalid contact (1a): "+t.length.toString()+":"+t[a]):t[a].length<2||t[a].indexOf(",")<0?PutToDebugLog(2,"WARNING, common ReadCallhistoryFile broken or invalid contact (1): "+t.length.toString()+":"+t[a].length.toString()+":"+t[a]):(i=t[a].split(","),isNull(i)||i.length<2?PutToDebugLog(2,"WARNING, common ReadCallhistoryFile broken or invalid contact: (2): "+t.length.toString()+":"+t[a].length.toString()+":"+t[a]):(i.length<7&&i.push(""),webphone_api.global.chlist.push(i)));n(!0)}catch(r){PutToDebugLogException(2,"common: ParseCallhistoryReadFromFile",r)}}function StartMsg(e,n,t){try{e=NormalizeNumber(e);var o="",i=GetParameter("sms"),a=GetParameterInt("textmessaging",-2);if(a<-1){switch(GetParameterInt("chatsms",-2)){case 0:a=-1;break;case 1:a=3;break;case 2:a=6;break;case 3:a=0}if(a<-1){switch(GetParameterInt("haschat",-2)){case 0:a=0;break;case 1:a=3;break;case 2:a=5;break;case 3:a=6;break;case 4:a=-1}}}if(!isNull(i)&&i.length>0)if(3===a||4===a||5===a)o="sms",PutToDebugLog(4,"EVENT, StartMsg called action: "+o+"; number: "+e+"; fromclass: "+t+" (1)"),StartMsgActivity(e,n,o,t);else if(6===a)o="chat",PutToDebugLog(4,"EVENT, StartMsg called action: "+o+"; number: "+e+"; fromclass: "+t+" (2)"),StartMsgActivity(e,n,o,t);else{var r=e;r.indexOf("+")>=0&&(r=r.substring(r.indexOf("+")+1,r.length)),IsNumber(r)&&r.length>6&&r.length<20?(o="sms",PutToDebugLog(4,"EVENT, StartMsg called action: "+o+"; number: "+e+"; fromclass: "+t+" (3)"),StartMsgActivity(e,n,o,t)):(o="chat",PutToDebugLog(4,"EVENT, StartMsg called action: "+o+"; number: "+e+"; fromclass: "+t+" (4)"),StartMsgActivity(e,n,o,t))}else o=3===a||4===a||5===a?"sms":"chat",PutToDebugLog(4,"EVENT, StartMsg called action: "+o+"; number: "+e+"; fromclass: "+t+" (5)"),StartMsgActivity(e,n,o,t)}catch(l){PutToDebugLogException(2,"common: StartMsg",l)}}function ChooseChatOrSms(e,n,t,o){try{var i=GetDeviceWidth();i=!isNull(i)&&IsNumber(i)&&i>100?Math.floor(i/1.2):220,i>400?i=400:i<120&&(i=120);var a="",r='<li id="[ITEMID]"><a data-rel="back">[ITEMTITLE]</a></li>',l="";l=r.replace("[ITEMID]","#item_chat"),l=l.replace("[ITEMTITLE]",webphone_api.stringres.get("chat")),a+=l,l="",l=r.replace("[ITEMID]","#item_sms"),l=l.replace("[ITEMTITLE]",webphone_api.stringres.get("sms")),a+=l,l="";var s='<div id="chatsms_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+i+"px; min-width: "+Math.floor(.6*i)+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("chat_sms_title")+'</h1></div><div role="main" class="ui-content adialog_content" style="padding: 0; margin: 0;"><ul id="chatsms_ul" data-role="listview" data-inset="true" data-icon="false" style="margin: 0;">'+a+'</ul></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" style="width: 98%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_close")+"</a></div></div>";o=o||function(){},!1===IsSDK()&&(webphone_api.$.mobile.activePage.append(s).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#chatsms_ul").off("click","li"),o()}}));var p="";webphone_api.$("#chatsms_ul").on("click","li",function(o){var i=webphone_api.$(this).attr("id");"#item_chat"===i&&(p="chat"),"#item_sms"===i&&(p="sms"),webphone_api.$("#chatsms_popup").on("popupafterclose",function(o){webphone_api.$("#chatsms_popup").off("popupafterclose"),PutToDebugLog(5,"EVENT, ChooseChatOrSms: action: "+p+"; number: "+e+"; fromclass: "+t+"; msg: "+n),StartMsgActivity(e,n,p,t)})})}catch(c){PutToDebugLogException(2,"common: ChooseChatOrSms",c)}}function StartMsgActivity(e,n,t,o){try{if("_messagelist"!==o&&(isNull(e)||e.length<1)){var i=GetParameter("messagefiles");isNull(i)||i.length<3?(isNull(n)&&(n=""),webphone_api.global.intentmsg[0]="action="+t,webphone_api.global.intentmsg[1]="to="+e,webphone_api.global.intentmsg[2]="message="+n,webphone_api.$.mobile.changePage("#page_message",{transition:"slide",role:"page"})):webphone_api.$.mobile.changePage("#page_messagelist",{transition:"none",role:"page"})}else isNull(n)&&(n=""),webphone_api.global.intentmsg[0]="action="+t,webphone_api.global.intentmsg[1]="to="+e,webphone_api.global.intentmsg[2]="message="+n,webphone_api.$.mobile.changePage("#page_message",{transition:"slide",role:"page"})}catch(a){PutToDebugLogException(2,"common: StartMsgActivity",a)}}function OpenLinkInExternalBrowser(e){try{!isNull(e)&&e.length>0&&GetParameter("devicetype")===DEVICE_WIN_SOFTPHONE()&&(PutToDebugLog(2,"EVENT, OpenLinkInExternalBrowser: "+e),WinAPI("API_BrowserOpenExtern",null,e))}catch(n){PutToDebugLogException(2,"common: OpenLinkInExternalBrowser",n)}}function OpenLinkInInternalBrowser(e){try{!isNull(e)&&e.length>0&&GetParameter("devicetype")===DEVICE_WIN_SOFTPHONE()&&WinAPI("API_BrowserOpen",null,e)}catch(n){PutToDebugLogException(2,"common: OpenLinkInInternalBrowser",n)}}function OpenWebURL(e,n,t){try{if(isNull(e)||e.length<3)return void PutToDebugLog(2,"WARNING, common OpenWebURL no url passed");var o=GetSipusername(!0),i=GetParameter("password"),a="",r="",l="",s="",p="",c="",u="",g=RandomInt(1e4,9999999).toString();return l=Md5Hash("C8y5:"+o+":"+i+":"+g),s=Md5Hash(o+":"+i),p=Md5Hash(o+":"+i+":"+g),c=Md5Hash("rD58s:"+o+":"+i+":"+g),u=Md5Hash("ck5Gp"+o+i+GetParameter("apiv2md5salt")+g),1===GetParameter("brandid")&&(a=Md5Hash("C8y5:"+o+":"+i+":8294032567")),e.indexOf("mvapireq")>0&&(o=encodeURIComponent(o),i=encodeURIComponent(i),a=encodeURIComponent(a),r=encodeURIComponent(r),l=encodeURIComponent(l),s=encodeURIComponent(s),p=encodeURIComponent(p),g=encodeURIComponent(g),c=encodeURIComponent(c),u=encodeURIComponent(u)),e=Trim(e),e=e.replace("[USERNAME]",o),e=e.replace("USERNAME",o),e=e.replace("USRNAME",o),e=e.replace("[PASSWORD]",i),e=e.replace("PASSWORD",i),e=e.replace("PWD",i),e=e.replace("[MD5AUTH]",a),e=e.replace("[SHA1HASH]",r),e=e.replace("SHA1CHECKSUM",r),e=e.replace("MD5WEB",l),e=e.replace("MD5SIMPLE",s),e=e.replace("MD5NORMAL",p),e=e.replace("MD5SALT",g),e=e.replace("MD5CHECKSUM",c),e=e.replace("MD5VALUE",u),e=e.replace("CURRENCY",""),e=e.replace("DEVICEID",GetDeviceId()),e=e.replace("SERVERAPIKEY",GetConfig("serverapikey")),Trim(e.toLowerCase()).indexOf("http")<0&&n!==webphone_api.stringres.get("np_download")&&(e="http://"+e),!1!==t&&(IsHttps()&&e.indexOf("https:")<0&&(e=GetTlsProxyUrl(e)),PutToDebugLog(3,"EVENT, OpenWebURL = "+e),webphone_api.global.intentbrowser[0]="url="+e,webphone_api.global.intentbrowser[1]="lastpage="+webphone_api.$.mobile.activePage.attr("id"),isNull(n)&&(n=""),webphone_api.global.intentbrowser[2]="title="+n,webphone_api.$.mobile.changePage("#page_internalbrowser",{transition:"pop",role:"page"})),e}catch(h){PutToDebugLogException(2,"common: OpenWebURL",h)}return e}function Md5Hash(e){var n="";try{return isNull(e)||Trim(e).length<1?(PutToDebugLog(2,"EVENT, common: Md5Hash string to hash is NULL"),""):(n=Md5Lib(e),isNull(n)&&(n=""),n)}catch(t){PutToDebugLogException(2,"common: Md5Hash",t)}return""}function Md5Lib(e){function n(e,n){var t=e[0],l=e[1],s=e[2],p=e[3];t=o(t,l,s,p,n[0],7,-680876936),p=o(p,t,l,s,n[1],12,-389564586),s=o(s,p,t,l,n[2],17,606105819),l=o(l,s,p,t,n[3],22,-1044525330),t=o(t,l,s,p,n[4],7,-176418897),p=o(p,t,l,s,n[5],12,1200080426),s=o(s,p,t,l,n[6],17,-1473231341),l=o(l,s,p,t,n[7],22,-45705983),t=o(t,l,s,p,n[8],7,1770035416),p=o(p,t,l,s,n[9],12,-1958414417),s=o(s,p,t,l,n[10],17,-42063),l=o(l,s,p,t,n[11],22,-1990404162),t=o(t,l,s,p,n[12],7,1804603682),p=o(p,t,l,s,n[13],12,-40341101),s=o(s,p,t,l,n[14],17,-1502002290),l=o(l,s,p,t,n[15],22,1236535329),t=i(t,l,s,p,n[1],5,-165796510),p=i(p,t,l,s,n[6],9,-1069501632),s=i(s,p,t,l,n[11],14,643717713),l=i(l,s,p,t,n[0],20,-373897302),t=i(t,l,s,p,n[5],5,-701558691),p=i(p,t,l,s,n[10],9,38016083),s=i(s,p,t,l,n[15],14,-660478335),l=i(l,s,p,t,n[4],20,-405537848),t=i(t,l,s,p,n[9],5,568446438),p=i(p,t,l,s,n[14],9,-1019803690),s=i(s,p,t,l,n[3],14,-187363961),l=i(l,s,p,t,n[8],20,1163531501),t=i(t,l,s,p,n[13],5,-1444681467),p=i(p,t,l,s,n[2],9,-51403784),s=i(s,p,t,l,n[7],14,1735328473),l=i(l,s,p,t,n[12],20,-1926607734),t=a(t,l,s,p,n[5],4,-378558),p=a(p,t,l,s,n[8],11,-2022574463),s=a(s,p,t,l,n[11],16,1839030562),l=a(l,s,p,t,n[14],23,-35309556),t=a(t,l,s,p,n[1],4,-1530992060),p=a(p,t,l,s,n[4],11,1272893353),s=a(s,p,t,l,n[7],16,-155497632),l=a(l,s,p,t,n[10],23,-1094730640),t=a(t,l,s,p,n[13],4,681279174),p=a(p,t,l,s,n[0],11,-358537222),s=a(s,p,t,l,n[3],16,-722521979),l=a(l,s,p,t,n[6],23,76029189),t=a(t,l,s,p,n[9],4,-640364487),p=a(p,t,l,s,n[12],11,-421815835),s=a(s,p,t,l,n[15],16,530742520),l=a(l,s,p,t,n[2],23,-995338651),t=r(t,l,s,p,n[0],6,-198630844),p=r(p,t,l,s,n[7],10,1126891415),s=r(s,p,t,l,n[14],15,-1416354905),l=r(l,s,p,t,n[5],21,-57434055),t=r(t,l,s,p,n[12],6,1700485571),p=r(p,t,l,s,n[3],10,-1894986606),s=r(s,p,t,l,n[10],15,-1051523),l=r(l,s,p,t,n[1],21,-2054922799),t=r(t,l,s,p,n[8],6,1873313359),p=r(p,t,l,s,n[15],10,-30611744),s=r(s,p,t,l,n[6],15,-1560198380),l=r(l,s,p,t,n[13],21,1309151649),t=r(t,l,s,p,n[4],6,-145523070),p=r(p,t,l,s,n[11],10,-1120210379),s=r(s,p,t,l,n[2],15,718787259),l=r(l,s,p,t,n[9],21,-343485551),e[0]=g(t,e[0]),e[1]=g(l,e[1]),e[2]=g(s,e[2]),e[3]=g(p,e[3])}function t(e,n,t,o,i,a){return n=g(g(n,e),g(o,a)),g(n<<i|n>>>32-i,t)}function o(e,n,o,i,a,r,l){return t(n&o|~n&i,e,n,a,r,l)}function i(e,n,o,i,a,r,l){return t(n&i|o&~i,e,n,a,r,l)}function a(e,n,o,i,a,r,l){return t(n^o^i,e,n,a,r,l)}function r(e,n,o,i,a,r,l){return t(o^(n|~i),e,n,a,r,l)}function l(e){var t,o=e.length,i=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)n(i,s(e.substring(t-64,t)));e=e.substring(t-64);var a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)a[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(a[t>>2]|=128<<(t%4<<3),t>55)for(n(i,a),t=0;t<16;t++)a[t]=0;return a[14]=8*o,n(i,a),i}function s(e){var n,t=[];for(n=0;n<64;n+=4)t[n>>2]=e.charCodeAt(n)+(e.charCodeAt(n+1)<<8)+(e.charCodeAt(n+2)<<16)+(e.charCodeAt(n+3)<<24);return t}function p(e){for(var n="",t=0;t<4;t++)n+=h[e>>8*t+4&15]+h[e>>8*t&15];return n}function c(e){for(var n=0;n<e.length;n++)e[n]=p(e[n]);return e.join("")}function u(e){return c(l(e))}function g(e,n){return e+n&4294967295}function g(e,n){var t=(65535&e)+(65535&n);return(e>>16)+(n>>16)+(t>>16)<<16|65535&t}try{var h="0123456789abcdef".split("");return u("hello"),u(e)}catch(m){PutToDebugLogException(2,"common: Md5Lib",m)}return""}function UriParser(e,n,t,o,i,a){try{if(isNull(e)||Trim(e).length<1)return void PutToDebugLog(2,"WARNING, common: UriParser uri is NULL");var r=GetSipusername(!0),l=GetParameter("password"),s="";!isNull(l)&&l.length>0&&(s=Md5Hash(l));var p="",c="",u="",g="",h="",m="",d=RandomInt(1e4,9999999).toString();if(c=Md5Hash("C8y5:"+r+":"+l+":"+d),u=Md5Hash(r+":"+l),g=Md5Hash(r+":"+l+":"+d),h=Md5Hash("rD58s:"+r+":"+l+":"+d),m=Md5Hash("ck5Gp"+r+l+GetParameter("apiv2md5salt")+d),0===Trim(e).indexOf("*")&&(e=e.substring(1)),CanLog(3)){var b=e,_=b.indexOf("authpwd=");if(_>0&&GetLogLevel()<5){var f=b.substring(0,_+8);b=b.substring(_+8),_=b.indexOf("&"),_<0&&(_=b.length),b=b.substring(_),b=f+"*****"+b}PutToDebugLog(3,"EVENT, uri = "+b)}e.indexOf("mvapireq")>0&&(r=encodeURIComponent(r),l=encodeURIComponent(l),s=encodeURIComponent(s),n=encodeURIComponent(n),t=encodeURIComponent(t),o=encodeURIComponent(o),p=encodeURIComponent(p),c=encodeURIComponent(c),u=encodeURIComponent(u),g=encodeURIComponent(g),d=encodeURIComponent(d),h=encodeURIComponent(h),m=encodeURIComponent(m)),e=Trim(e),e=e.replace("[USERNAME]",r),e=e.replace("USERNAME",r),e=e.replace("USRNAME",r),e=e.replace("[PASSWORD]",l),e=e.replace("PASSWORD",l),e=e.replace("PWD",l),e=e.replace("[MD5AUTH]",s),e=e.replace("MD5AUTH",s),e=e.replace("[PIN]",n),e=e.replace("PINCODE",n),e=e.replace("[ANUM]",t),e=e.replace("ANUM",t),e=e.replace("MYNUMBER",t),e=e.replace("PHONE1",t),e=e.replace("PREFIX_OR_NUMBER",t),e=e.replace("CALLEDNUMBER",t),e=e.replace("[CALLBACKNR]",GetParameter("callbacknumber")),e=e.replace("CALLBACKNR",GetParameter("callbacknumber")),e=e.replace("[BNUM]",o),e=e.replace("BNUM",o),e=e.replace("PHONE2",o),e=e.replace("TARGETMOBILE",o),e=e.replace("[TXT]",i),e=e.replace("TEXT",i),e=e.replace("CURRENCY",""),e=e.replace("DEVICEID",GetDeviceId()),e=e.replace("[SHA1HASH]",p),e=e.replace("SHA1CHECKSUM",p),e=e.replace("MD5WEB",c),e=e.replace("MD5SIMPLE",u),e=e.replace("MD5NORMAL",g),e=e.replace("MD5SALT",d),e=e.replace("SALT",d),e=e.replace("MD5CHECKSUM",h),e=e.replace("MD5VALUE",m),e=e.replace("BRANDNAME",encodeURIComponent(GetBrandName()));var w=GetParameter("upperserver");if((isNull(w)||w.length<1)&&(w=GetWebrtcUpperServer()),e=e.replace("UPPERSERVER",w),e=e.replace("SERVERAPIKEY",GetConfig("serverapikey")),e=e.replace("KEY",GetConfig("serverapikey")),e.indexOf("tel.search")>0){var v=GetParameter2("telsearchkey");isNull(v)&&(v=""),e=e.replace("TELSEARCHKEY",v)}if(Trim(e.toLowerCase()).indexOf("http")<0&&(e=UseSecureSrvConnection()?"https://"+e:"http://"+e),!1===E&&IsMizuServerOrGateway()&&e.indexOf("mvapireq")>0&&e.indexOf("?")>0&&(e=e+"&requestid="+GetRequestId()),CanLog(5)){var b=e,_=b.indexOf("authpwd=");if(_>0){var f=b.substring(0,_+8);b=b.substring(_+8),_=b.indexOf("&"),_<0&&(_=b.length),b=b.substring(_),b=f+"*****"+b}PutToDebugLog(5,"EVENT,httpRequestUri = "+b+"; action = "+a)}if("return_uri"===a)return e;var E=!1,P="";e.indexOf("[POST]")>0?(E=!0,P=e.substring(e.indexOf("[POST]")+6),e=e.substring(0,e.indexOf("[POST]"))):(P=GetUrlParamVal(e,"POSTDATA"),!isNull(P)&&P.length>2&&(E=!0,e.indexOf("?")>0&&(e=e.substring(0,e.indexOf("?"))))),!1===webphone_api.global.isdebugversion&&!1===E&&IsMizuServerOrGateway()&&e.indexOf("mvapireq")>0&&(e=McrfsEnc(e,a)),HttpRequest(e,a,E,P)}catch(T){PutToDebugLogException(2,"common: UriParser",T)}}function McrfsEnc(e,n){try{if(isNull(e)||e.length<1)return e;var t=e,o=t.indexOf("?");if(o<0)return t;var i=t.substring(o+1);t=t.substring(0,o+1);var a="",r="",l=i.split("&");if(!isNull(l)&&l.length>0){i="";for(var s=0;s<l.length;s++)if(!isNull(l[s])){var p=l[s].indexOf("=");if(!(p<1)){var c=l[s].substring(0,p+1),u=l[s].substring(p+1);i.length>0&&(i+="&"),i=i+c+encodeURIComponent(u),"authkey="===c||"authid="===c||"authpwd="===c?(r.length>0&&(r+="&"),r=r+c+encodeURIComponent(u)):(a.length>0&&(a+="&"),a=a+c+encodeURIComponent(u))}}}var g=StrEc(i,webphone_api.global.ec_apikey,!0);if(i===StrDc("mcrfs_"+g,webphone_api.global.ec_apikey,!0))return t=t+"mcrfs="+g,PutToDebugLog(5,"EVENT,httpRequestUri ENC All = "+t+"; action = "+n),t;if(!isNull(r)&&r.length>0){var h=StrEc(r,webphone_api.global.ec_apikey,!0);if(r===StrDc("mcrfs_"+h,webphone_api.global.ec_apikey,!0))return!isNull(a)&&a.length>0&&(t=t+a+"&"),t=t+"mcrfs="+h,PutToDebugLog(5,"EVENT,httpRequestUri ENC main = "+t+"; action = "+n),t}}catch(m){PutToDebugLogException(2,"common: McrfsEnc",m)}return e}function ConfigureRequestEngine(e,n,t){try{if(e&&("jsonp"===webphone_api.global.httpmehod||"ws"===webphone_api.global.httpmehod))return void ReConfigureRequestEngine(1,e);if(!1===e&&n.indexOf("mvapireq")<1&&n.indexOf("mcrfs=")<1&&"ws"===webphone_api.global.httpmehod)return GetParameter("devicetype")===DEVICE_WIN_SOFTPHONE()||getuseengine()===webphone_api.global.ENGINE_SERVICE?void(webphone_api.global.httpmehod="win"):void(webphone_api.global.httpmehod="jsonp");if(n.indexOf("mvapireq")>=0||n.indexOf("mcrfs=")>=0&&getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void(webphone_api.global.httpmehod="ws");if(webphone_api.global.httpmehod.length>0)return;return"waitforparameters"===t?void(webphone_api.global.httpmehod="cors"):(IsMizuServerOrGateway()&&window.WebSocket&&!0!==e&&(webphone_api.global.wssupported=!0),!0===webphone_api.global.wssupported?void(webphone_api.global.httpmehod="ws"):GetParameter("devicetype")===DEVICE_WIN_SOFTPHONE()||getuseengine()===webphone_api.global.ENGINE_SERVICE?void(webphone_api.global.httpmehod="win"):getuseengine()===webphone_api.global.ENGINE_JAVA?void(webphone_api.global.httpmehod="java"):IsMizuServerOrGateway()||!isNull(n)&&n.indexOf("xautoprov")>=0?void(webphone_api.global.httpmehod="cors"):void(webphone_api.global.httpmehod="jsonp"))}catch(o){PutToDebugLogException(2,"common: ConfigureRequestEngine",o)}}function ReConfigureRequestEngine(e,n){try{if(!1===webphone_api.global.currhttpmehodworking&&"ws"===webphone_api.global.httpmehod&&CheckInternetConnectionWS(),!0===n)return void(webphone_api.global.httpmehod="cors");if(!0===webphone_api.global.currhttpmehodworking)return;GetParameter("devicetype")===DEVICE_WIN_SOFTPHONE()?"win"===webphone_api.global.httpmehod?!0===webphone_api.global.wssupported&&(webphone_api.global.httpmehod="ws"):"ws"===webphone_api.global.httpmehod&&getuseengine()===webphone_api.global.ENGINE_JAVA?webphone_api.global.httpmehod="java":"ws"===webphone_api.global.httpmehod||"java"===webphone_api.global.httpmehod?webphone_api.global.httpmehod="cors":"cors"===webphone_api.global.httpmehod?webphone_api.global.httpmehod="jsonp":webphone_api.global.httpmehod="win":"ws"===webphone_api.global.httpmehod?getuseengine()===webphone_api.global.ENGINE_JAVA?webphone_api.global.httpmehod="java":getuseengine()===webphone_api.global.ENGINE_SERVICE?webphone_api.global.httpmehod="win":webphone_api.global.httpmehod="cors":"java"===webphone_api.global.httpmehod||"win"===webphone_api.global.httpmehod?webphone_api.global.httpmehod="cors":"cors"===webphone_api.global.httpmehod&&(webphone_api.global.httpmehod="jsonp"),PutToDebugLog(4,"EVENT, common:ReConfigureRequestEngine called from: "+e+" post: "+n+" . HTTP method: "+webphone_api.global.httpmehod)}catch(t){PutToDebugLogException(2,"common: ReConfigureRequestEngine",t)}}function HttpRequest(e,n,t,o){var i=0;try{if(isNull(o)&&(o=""),"downloadcontacts"===n&&"cors"!==webphone_api.global.httpmehod){PutToDebugLog(2,"EVENT, HttpRequest method: cors downloadcontacts");var a=CORSRequest(e,n,t,o);return void(!1===a&&(PutToDebugLog(2,"WARNING, HttpRequest method: cors not available downloadcontacts; retry with other method"),ReConfigureRequestEngine(2,!1),HttpRequest(e,n,t,o)))}if(ConfigureRequestEngine(t,e,n),setTimeout(function(){ReConfigureRequestEngine(3,t)},3500),isNull(t)||!0!==t||"post",i=1,"telsearchname"===n){PutToDebugLog(2,"EVENT, HttpRequest method: cors telsearchname");var a=CORSRequest(e,n,t,o);return void(!1===a&&(PutToDebugLog(2,"WARNING, HttpRequest method: cors not available telsearchname"),ReConfigureRequestEngine(4,!1),HttpRequest(e,n,t,o)))}if(i=2,50===GetConfigInt("brandid",-1)&&(webphone_api.global.httpmehod="win"),"win"===webphone_api.global.httpmehod){if(i=10,PutToDebugLog(2,"EVENT, HttpRequest method: win"),e=e.replace("[POST]",""),(isNull(o)||o.length<1)&&(o="data=dummy"),50===GetConfigInt("brandid",-1))return void WinAPI("API_HTTPReqAsyncFavafone",function(e){PutToDebugLog(2,"EVENT, common: API_HTTPReqAsyncFavafone returned (4): "+e+" waiting for response in notifications")},e,o);i=11,WinAPI("API_HTTPReqAsync",function(e){PutToDebugLog(2,"EVENT, common: API_HTTPReqAsync returned (4): "+e+" waiting for response in notifications")},e,o)}else if("ws"===webphone_api.global.httpmehod){PutToDebugLog(2,"EVENT, HttpRequest method: ws");var a=WSRequest(e,n,t);!1===a&&(i=20,PutToDebugLog(2,"WARNING, HttpRequest method: ws not available"),ReConfigureRequestEngine(5,!1),i=21,HttpRequest(e,n,t,o))}else if("java"===webphone_api.global.httpmehod)PutToDebugLog(2,"EVENT, HttpRequest method: java"),i=25,webphone_api.webphone_handle.API_HTTPReqAsync(e,o),i=26;else if("cors"===webphone_api.global.httpmehod){PutToDebugLog(2,"EVENT, HttpRequest method: cors"),i=30;var a=CORSRequest(e,n,t,o);i=31,!1===a&&(PutToDebugLog(2,"WARNING, HttpRequest method: cors not available"),ReConfigureRequestEngine(6,!1),i=32,HttpRequest(e,n,t,o))}else if("jsonp"===webphone_api.global.httpmehod){PutToDebugLog(2,"EVENT, HttpRequest method: jsonp"),i=40;var r=decodeURIComponent(e);if(r=encodeURIComponent(r),r.toLowerCase().indexOf("wsuser")>0||r.toLowerCase().indexOf("wsload")>0)return PutToDebugLog(2,"WARNING, will not send wsuser/wsload over jsonp"),void(webphone_api.global.sendwsuserjsonp=!0);i=41;var l="http://";IsHttps()&&(l="https://"),r.toLowerCase().indexOf("wsuser")>0&&(l="https://");var s="rtc.mizu-voip.com";if(webphone_api.global.pgw_selected>=0&&(s=PGW_Get(webphone_api.global.pgw_selected,PGW_ADDRESS)),i=42,IsMizuServerOrGateway()&&webphone_api.global.pgw_selected<0&&(r.toLowerCase().indexOf("wsuser")<0||r.toLowerCase().indexOf("wsload")<0))if(i=45,GetWsAddressCfg().length>3){s=GetWsAddressCfg();var p=s.indexOf("://");p>=0&&(s=s.substring(p+3)),p=s.indexOf("/"),p>0&&(s=s.substring(0,p))}else GetConfig("serveraddress").length>1?s=GetConfig("serveraddress"):!isNull(webphone_api.parameters)&&!isNull(webphone_api.parameters.serveraddress)&&webphone_api.parameters.serveraddress.length>1&&(s=Trim(webphone_api.parameters.serveraddress),s=NormalizeInput(s,0),AddressHasPort(s)&&(s=GetIPFromAddressSimple(s)));i=46,IsHttps()&&IsIPAddrress(s)&&jsonpmaxloop<3&&(jsonpmaxloop++,ReConfigureRequestEngine(7,t),HttpRequest(e,n,t,o)),jsonpmaxloop=0,i=50;var c=GetConfig("mainaport");!isNull(c)&&c.length>0&&(AddressHasPort(s)&&(s=GetIPFromAddressSimple(s)),s=GetIPEnclosed(s)+":"+c);var u=l+s+"/mvapireq/jppget?url="+r+"&callback=cbf";PutToDebugLog(4,"EVENT, jsonpurl: "+u),i=51,webphone_api.$.getJSON(u,function(e){var t="";isNull(e)?PutToDebugLog(2,"ERROR, HttpRequest jsonp response is NULL"):t=e.contents,HttpResponseHandler(t,n)})}else PutToDebugLog(2,"ERROR, common: HttpRequest NO supported http request method");i=59}catch(g){PutToDebugLogException(2,"common: HttpRequest ("+i.toString()+")",g);try{"creditrequest"===n&&(webphone_api.global.creditRequestIval<3e4?webphone_api.global.creditRequestIval=2*webphone_api.global.creditRequestIval:webphone_api.global.creditRequestIval=webphone_api.global.CREDIT_REQUEST_IVAL_DEFVAL)}catch(h){}}}function CORSRequest(e,n,t,o){try{var i="GET";t&&(i="POST"),e=e.replace("[POST]","");var a=new XMLHttpRequest;if(PutToDebugLog(2,"EVENT, CORSRequest url: "+e+"; action: "+n+"; ispost: "+t+"; postdata: "+o),"withCredentials"in a)a.open(i,e,!0);else{if("undefined"==typeof XDomainRequest)return a=null,PutToDebugLog(2,"ERROR, common: CORSRequest, CORS not supported"),webphone_api.global.httpmehod="jsonp",!1;a=new XDomainRequest,a.open(i,e)}var r=0;a.onload=function(){try{PutToDebugLog(4,"EVENT, CORSRequest.onload"),r=19;var e=a.responseText,t="";t=!isNull(e)&&e.length>250?e.substring(0,250)+"....":e,isNull(t)&&(t="NULL"),r=20,PutToDebugLog(2,"EVENT, CORSRequest response: "+t);return r=21,isNull(e)||e.length<1?(r=23,PutToDebugLog(2,"ERROR, CORSRequest response is NULL"),!1):(HttpResponseHandler(e,n),e)}catch(o){PutToDebugLogException(2,"common: CORSRequest.onload inner ("+r+")",o)}},a.onerror=function(e){var n="";isNull(e)||(n=e.toString(),isNull(e.target)||(n=isNull(e.target.status)?n+" "+e.target.toString():n+" "+e.target.status.toString())),PutToDebugLog(2,"ERROR, common: CORSRequest: onerror: "+n)};var l=reqtimeout;!0===t&&(l+=2e3),e.indexOf("xautoprov")>=0&&(l+=15e3),a.timeout=l,a.ontimeout=function(e){PutToDebugLog(2,"ERROR, common: CORSRequest: Timeout")},t?(isNull(o)&&(o=""),o=Trim(o),0===o.indexOf("?")&&(o=o.replace("?","")),a.send(o)):a.send()}catch(s){PutToDebugLogException(2,"common: CORSRequest",s)}}function ResetWsapisocket(e){try{isNull(e)&&(e=""),void 0!==wsapisocket&&null!==wsapisocket&&(wsapisocket.close&&(PutToDebugLog(2,"EVENT, ResetWsapisocket, websocketNS close from: "+e),wsapiskt_closedmanually=!0,wsapisocket.close()),wsapisocket.onopen&&(wsapisocket.onopen=null),wsapisocket.onclose&&(wsapisocket.onclose=null),wsapisocket.onerror&&(wsapisocket.onerror=null))}catch(n){PutToDebugLogException(2,"common: ResetWsapisocket",n)}wsapisocket=null}function WSAPIRequest(method,data,apiname,callback){try{if(!callback||"function"!=typeof callback)return void PutToDebugLog(2,"ERROR, WSAPIRequest websocketNS callback is NULL");if(!1===Glsp())return void PutToDebugLog(2,"WARNING, WSAPIRequest websocketNS do not send");if(!isNull(apiname)&&apiname.length>0&&(apiname=Trim(apiname),0===apiname.indexOf("API_")&&"API_Poll"!==apiname&&"API_Stop"!==apiname)){srv_cb.push(callback),srv_apiname.push(apiname.toLowerCase());var finalparam="";if(!isNull(data)&&data.indexOf("param1=")>0){var tmp=ReplaceAll(data,"BOFLINE","");tmp=ReplaceAll(tmp,"EOFLINE","");var param1=tmp.substring(tmp.indexOf("param1=")+7),param2="";param1.indexOf("param2=")>=0?(param2=param1.substring(param1.indexOf("param2=")+7),param2=param2.indexOf("param3=")>=0?param2.substring(0,param2.indexOf("param3=")):param2.substring(0,param2.indexOf("EOFCOMMAND")),param2=Trim(param2),param1=param1.substring(0,param1.indexOf("param2=")),param1=Trim(param1)):(param1=param1.substring(0,param1.indexOf("EOFCOMMAND")),param1=Trim(param1)),finalparam=param1+param2}var sparamtmp=finalparam;sparamtmp.indexOf("requestid=")>=0&&(sparamtmp=sparamtmp.replace("requestid=","")),srv_params.push(sparamtmp)}if(!0===TestNSPolling()&&(webphone_api.global.useajax_forservice=!0),wsapimaxloop>15&&!IsMacLin()&&!IsWinMacLinNsTest()&&(webphone_api.global.useajax_forservice=!0),!0===webphone_api.global.useajax_forservice||"API_Poll"===apiname)WSAPIReqHTTP(method,data,callback);else if(!0===webphone_api.global.flagnsreconnect&&(PutToDebugLog(2,"EVENT,WSAPIReconnect websocketNS because engine was stopped"),webphone_api.global.flagnsreconnect=!1,void 0!==wsapisocket&&null!==wsapisocket&&(wsapisocket.close&&(wsapiskt_closedmanually=!0,wsapisocket.close()),wsapisocket.onopen=null,wsapisocket.onclose=null,wsapisocket.onerror=null),wsapisocket=null),void 0===wsapisocket||null===wsapisocket){var url=GetParameter("last_good_ns_plugin_url");(isNull(url)||url.length<5)&&!isNull(lastgoodnspluginurl)&&lastgoodnspluginurl.length>0?url=lastgoodnspluginurl:lastgoodnspluginurl=url,"API_Poll"!==apiname&&"API_Stop"!==apiname&&"API_HTTPKeepAlive"!==apiname&&(wsapi_method.push(method),wsapi_data.push(data),wsapi_cb.push(callback)),isNull(url)||url.length<5?IsServiceInstalled(function(e){PutToDebugLog(2,"EVENT, WSAPIRequest IsServiceInstalled returned: "+e)}):WSAPIConnect(url,method,data,callback)}else{if((!1===wsapiready||wsapi_method.length>0)&&"API_Poll"!==apiname&&"API_Stop"!==apiname&&"API_HTTPKeepAlive"!==apiname){"API_SetParameters"===apiname||"API_Start"===apiname||"API_SetDIDChange"===apiname?RemoveFromWsapiQueue(apiname):RemoveFromWsapiQueue(apiname,data),wsapi_method.push(method),wsapi_data.push(data),wsapi_cb.push(callback);var toprint=data;return isNull(toprint)&&(toprint=""),toprint.length>100&&(toprint=toprint.substring(0,99)),void(!0===wsapiready&&wsapi_method.length>0?(CanLog(2)&&PutToDebugLog(2,"EVENT, WSAPIRequest websocketNS attempt to start sending out cached data: "+wsapiready+"("+wsapi_method.length+"): "+toprint),HandleWsapiQueue()):CanLog(2)&&PutToDebugLog(2,"EVENT, WSAPIRequest websocketNS cached for later execution: Websocket not ready: "+wsapiready+"("+wsapi_method.length+"): "+toprint))}if("API_Start"!==apiname&&"API_SetParameters"!==apiname&&"API_Poll"!==apiname&&"API_Stop"!==apiname&&webphone_api.global.apistartstate<2&&webphone_api.global.apistarttick>0&&GetTickCount()-webphone_api.global.apistarttick<3e3){if("API_Poll"!==apiname){wsapi_method.push(method),wsapi_data.push(data),wsapi_cb.push(callback);var toprint=data;isNull(toprint)&&(toprint=""),toprint.length>100&&(toprint=toprint.substring(0,99)),CanLog(2)&&PutToDebugLog(2,"EVENT, WSAPIRequest websocketNS cached for later execution: no API_Start feedback: "+toprint)}return}CanLog(4)&&PutToDebugLog(4,"EVENT, _common: WSAPIRequest websocketNS SEND data: "+data),void 0!==wsapisocket&&null!==wsapisocket||PutToDebugLog(2,"ERROR, _common: WSAPIRequest websocketNS wsapisocket is NULL 1"),
wsapisocket.send(data),wsapisocket.onmessage=function(evt){var recdata=null;if(isNull(evt)||(recdata=evt.data),isNull(recdata))return void PutToDebugLog(2,"ERROR, common: WSAPIRequest.onmessage websocketNS, received data is NULL");webphone_api.webphone_pollstatus=!1;var resp=ArrayBufferToString(recdata);if((resp.indexOf("WPNOTIFICATION,")>=0||0==resp.indexOf("STATUS,"))&&!0===webphone_api.global.cansetuseengine&&(StrToIntDef(GetParameter2("enginepriority_ns"),6)>0&&(webphone_api.global.useengine=webphone_api.global.ENGINE_SERVICE,webphone_api.global.last_useengine=webphone_api.global.ENGINE_SERVICE,webphone_api.global.last_last_useengine=webphone_api.global.ENGINE_SERVICE,webphone_api.common.PutToDebugLog(5,"EVENT, Settings set useengine to NS on NS answer received")),webphone_api.global.cansetuseengine=!1),isNull(resp)||(resp=Trim(resp)),0!==resp.indexOf("webphone_api.")||resp.lastIndexOf(")")!==resp.length-1&&resp.lastIndexOf(");")!==resp.length-2)ProcessServiceReqResponse(resp,callback);else{resp=Trim(resp),PutToDebugLog(2,"EVENT, Process service command: "+resp);try{eval(resp)}catch(errp){PutToDebugLogException(2,"ERROR, Process service command failed: "+resp,errp)}}}}}catch(err){PutToDebugLogException(2,"common: WSAPIRequest websocketNS",err)}}function WSAPIHandleReConnect(){try{if(0!=-webphone_api.global.service_last_life_signal&&webphone_api.common.GetTickCount()-webphone_api.global.service_last_life_signal<8e3)return void PutToDebugLog(2,"EVENT, skip exec WSAPIReConnect because data received meantime");WinAPI("extcmd_version",function(e){isNull(e)||e.indexOf("ERROR:")>=0||(webphone_api.global.last_ns_ws_succwss=GetTickCount())}),setTimeout(function(){0==webphone_api.global.last_ns_ws_succwss||GetTickCount()-webphone_api.global.last_ns_ws_succwss>1200?(PutToDebugLog(2,"ERROR, exec WSAPIReConnect from timer (1)"),WSAPIReConnect()):!0===webphone_api.isincall()?PutToDebugLog(2,"EVENT, skip exec WSAPIReConnect from timer (2) incall and responded to version request"):WinAPI("API_Start2",function(e){PutToDebugLog(2,"EVENT, exec API_Start2 because NS engine was not responsive: answer: "+e)})},1e3)}catch(e){PutToDebugLogException(2,"common: WSAPIHandleReConnect",e)}}function WSAPIReConnect(){try{wsar_count++;var e=GetTickCount();if(e-wsar_lastcalled<100)return;if(wsar_lastcalled=e,(!0===wsa_ever_connected&&wsar_count<150||wsar_count<50)&&null===wsar_timer){wsar_delay>2e3&&getuseengine()===webphone_api.global.ENGINE_SERVICE&&webphone_api.global.phonestarted>1&&(PutToDebugLog(1,"STATUS,"+webphone_api.stringres.get("ns_engine_unreachable")),webphone_api.global.display_last_status=!0),wsar_delay<32e3&&(wsar_delay*=2);return PutToDebugLog(2,"EVENT, WSAPIReConnect websocketNS after: "+(wsar_delay/1e3).toString()+" sec"),wsar_timer=setTimeout(function(){wsar_delay>3e4?(PutToDebugLog(2,"EVENT, WSAPIReConnect websocketNS whole SIPStack restart"),WSAPIConnect(wsapi_reconnect_address,"","",function(){})):(PutToDebugLog(2,"EVENT, WSAPIReConnect websocketNS reconnecting..."),WSAPIConnect(wsapi_reconnect_address,"","",function(){})),isNull(wsar_timer)||clearTimeout(wsar_timer),wsar_timer=null},wsar_delay),wsar_delay<10&&(wsar_delay=500),!0}}catch(n){PutToDebugLogException(2,"common: WSAPIReConnect websocketNS",n)}}function WSAPIConnect(e,n,t,o){try{if(isNull(e)||e.length<1){PutToDebugLog(2,"EVENT, load WSAPIConnect websocketNS url from scratch c");var i=GetNsPluginWsUrl();if(null===i||i.length<1)return void PutToDebugLog(2,"ERROR, WSAPIReqHTTP could not find a valid URL c");e=i[0]}0!==e.indexOf("ws")&&(e="ws://"+e),CanLog(3)&&PutToDebugLog(3,"EVENT, common: WSAPIConnect websocketNS url: "+e),wsapi_reconnect_address=e,wsapiskt_closedmanually=!1;var a=!1;0===e.toLowerCase().indexOf("wss:")&&(a=!0),(e.indexOf("/mvstwebsock")>0||e.indexOf("/mfstwebsock")>0)&&e.indexOf("requestid=")<0&&(e=e.indexOf("?")>0?e+"&requestid="+GetRequestId():e+"?requestid="+GetRequestId());var r=!1;if(!1===TestNSPolling()){try{CanLog(2)&&PutToDebugLog(3,"EVENT, common: WSAPIConnect websocketNS create socket (1)"),void 0!==wsapisocket&&null!==wsapisocket&&(wsapisocket.close&&(PutToDebugLog(2,"EVENT, WSAPIConnect websocketNS, close previous WebSocket connection (1)"),wsapiskt_closedmanually=!0,wsapisocket.close()),wsapisocket.onopen=null,wsapisocket.onclose=null,wsapisocket.onerror=null),wsapisocket=null,wsapisocket=new WebSocket(e,"api"),wsapisocket.binaryType="arraybuffer",wsapisocket.onopen=WsapisktOnOpen,wsapisocket.onclose=WsapisktOnClose,wsapisocket.onerror=WsapisktOnError,r=!0,webphone_api.global.cansetuseengine=!0}catch(l){PutToDebugLogException(2,"common: WSAPIConnect websocketNS failed to connect to: "+e,l)}if(!1===r&&!1===a){e=GetParameter("nsdomain",webphone_api.global.NATIVE_PLUGIN_URL_SECURE),0!=e.indexOf("ws")&&(e="wss://"+e),(e.indexOf("/mvstwebsock")>0||e.indexOf("/mfstwebsock")>0)&&e.indexOf("requestid=")<0&&(e=e.indexOf("?")>0?e+"&requestid="+GetRequestId():e+"?requestid="+GetRequestId());try{CanLog(2)&&PutToDebugLog(3,"EVENT, common: WSAPIConnect websocketNS create socket (2)"),void 0!==wsapisocket&&null!==wsapisocket&&(wsapisocket.close&&(PutToDebugLog(2,"EVENT, WSAPIConnect websocketNS, close previous WebSocket connection (2)"),wsapiskt_closedmanually=!0,wsapisocket.close()),wsapisocket.onopen=null,wsapisocket.onclose=null,wsapisocket.onerror=null),wsapisocket=null,wsapisocket=new WebSocket(e,"api"),wsapisocket.binaryType="arraybuffer",wsapisocket.onopen=WsapisktOnOpen,wsapisocket.onclose=WsapisktOnClose,wsapisocket.onerror=WsapisktOnError,r=!0}catch(s){PutToDebugLogException(2,"WSAPIConnect failed to connect on 2nd attempt to (on SECURE connection) : "+e,s)}}}if(!1===r)return void(IsMacLin()||IsWinMacLinNsTest()||(WSAPIReqHTTP(n,t,o),webphone_api.global.useajax_forservice=!0));(isNull(wsapisocket)||!1===r)&&(CanLog(2)&&PutToDebugLog(3,"EVENT, common: WSAPIConnect websocketNS create socket (3)"),void 0!==wsapisocket&&null!==wsapisocket&&(wsapisocket.close&&(PutToDebugLog(2,"EVENT, WSAPIConnect websocketNS, close previous WebSocket connection (3)"),wsapiskt_closedmanually=!0,wsapisocket.close()),wsapisocket.onopen&&(wsapisocket.onopen=null),wsapisocket.onclose&&(wsapisocket.onclose=null),wsapisocket.onerror&&(wsapisocket.onerror=null)),(e.indexOf("/mvstwebsock")>0||e.indexOf("/mfstwebsock")>0)&&e.indexOf("requestid=")<0&&(e=e.indexOf("?")>0?e+"&requestid="+GetRequestId():e+"?requestid="+GetRequestId()),wsapisocket=null,wsapisocket=new WebSocket(e,"api"),wsapisocket.binaryType="arraybuffer",wsapisocket.onopen=WsapisktOnOpen,wsapisocket.onclose=WsapisktOnClose,wsapisocket.onerror=WsapisktOnError),wsapisocket.onopen=WsapisktOnOpen,wsapisocket.onclose=WsapisktOnClose,wsapisocket.onerror=WsapisktOnError}catch(p){PutToDebugLogException(2,"common: WSAPIConnect websocketNS",p)}}function WsapisktOnOpen(){CanLog(2)&&PutToDebugLog(2,"EVENT, common: WSAPIConnect.onopen websocketNS, connection ready"),wsapiready=!0,wsapimaxloop=0,wsa_ever_connected=!0,wsar_delay=1,webphone_api.global.display_last_status&&(webphone_api.global.display_last_status=!1,PutToDebugLog(2,"EVENT, Display last good status to hide Engine unreachable"),PutToDebugLog(1,"EVENT, "+webphone_api.global.last_good_status)),HandleWsapiQueue()}function WsapisktOnClose(){CanLog(2)&&PutToDebugLog(2,"EVENT, common: WSAPIConnect.onclose websocketNS, connection closed"),wsapisocket=null,wsapiready=!1,!1===wsapiskt_closedmanually&&(PutToDebugLog(2,"ERROR, common: WSAPIConnect.onclose connection interrupted"),PutToDebugLog(2,"ERROR, common: WSAPIConnect.onclose websocketNS, call WSAPIReConnect"),WSAPIReConnect())}function WsapisktOnError(){var e="";"undefined"!=typeof wserr&&null!==wserr&&(e=wserr.toString()),PutToDebugLog(2,"ERROR, common: WSAPIConnect.onerror websocketNS, connection onerror: "+e),PutToDebugLog(2,"ERROR, common: WSAPIConnect.onerror websocketNS, call WSAPIReConnect"),WSAPIReConnect(),setTimeout(function(){void 0!==wsapisocket&&null!==wsapisocket&&!0===wsapiready&&(webphone_api.global.wnotstartedsession=!1)},1500),wsapiready=!1,wsapimaxloop++}function RemoveFromWsapiQueue(e,n){try{if(isNull(e)||e.length<1)return;if(isNull(wsapi_method)||wsapi_method.length<1)return;for(var t=wsapi_method.length-1;t>=0;t--)wsapi_method[t]===e&&(isNull(n)||n.length<1||wsapi_data[t]===n)&&(delete wsapi_method[t],delete wsapi_data[t],delete wsapi_cb[t])}catch(o){PutToDebugLogException(2,"common: RemoveFromWsapiQueue",o)}}function HandleWsapiQueue(){try{if(isNull(wsapi_data)||wsapi_data.length<1)return wsapi_method=[],wsapi_data=[],void(wsapi_cb=[]);if(!isNull(hwqueue_timer))return;CanLog(5)&&PutToDebugLog(5,"EVENT, HandleWsapiQueue "+wsapi_data.length),hwqueue_timer=setInterval(function(){try{if(isNull(wsapi_data)||wsapi_data.length<1)return isNull(hwqueue_timer)||clearInterval(hwqueue_timer),hwqueue_timer=null,wsapi_method=[],wsapi_data=[],void(wsapi_cb=[]);if(void 0===wsapisocket||null===wsapisocket)return void PutToDebugLog(2,"WANING, _common: WSAPIRequest websocketNS HandleWsapiQueue wsapisocket is NULL 2");var e=wsapi_data[0],n="",t=e.indexOf("function=");if(t>0&&(n=e.substring(t+9),t=n.indexOf("EOFLINE"),n=t>0?n.substring(0,t):""),"API_Start"!==n&&"API_SetParameters"!==n&&webphone_api.global.apistartstate<2&&webphone_api.global.apistarttick>0&&GetTickCount()-webphone_api.global.apistarttick<3e3)return;e=wsapi_data.shift();var o=(wsapi_method.shift(),wsapi_cb.shift());CanLog(4)&&(e.indexOf("API_SetParameters")>=0&&webphone_api.common.GetLogLevel()<7&&(!1===webphone_api.global.isdebugversion||webphone_api.common.GetLogLevel()<5)?PutToDebugLog(4,"EVENT, _common: WSAPIRequest websocketNS HandleWsapiQueue SEND data: API_SetParameters"):PutToDebugLog(4,"EVENT, _common: WSAPIRequest websocketNS HandleWsapiQueue SEND data: "+e)),wsapisocket.send(e),wsapisocket.onmessage=function(e){var n=null;if(isNull(e)||(n=e.data),isNull(n))return void PutToDebugLog(2,"ERROR, common: WSAPIRequest.onmessage websocketNS HandleWsapiQueue, received data is NULL");ProcessServiceReqResponse(ArrayBufferToString(n),o)}}catch(i){PutToDebugLogException(2,"common: HandleWsapiQueue Timer, skip all cached requests",i),wsapi_method=[],wsapi_data=[],wsapi_cb=[]}},2)}catch(e){PutToDebugLogException(2,"common: HandleWsapiQueue",e)}}function WSAPIReqHTTP(e,n,t){try{if(isNull(wreqhttp)||wreqhttp.length<1){if(wreqhttp=GetParameter("last_good_ns_plugin_url"),isNull(wreqhttp)||wreqhttp.length<5){var o=GetNsPluginWsUrl();if(null===o||o.length<1)return void PutToDebugLog(2,"ERROR, WSAPIReqHTTP could not find a valid URL");wreqhttp=o[0],o.length>1&&UseSecureSrvConnection()&&o[0].indexOf("wss://")<0&&o[1].indexOf("wss://")>=0&&(wreqhttp=o[1])}wreqhttp=wreqhttp.toLowerCase(),wreqhttp=wreqhttp.replace("wss:","https:"),wreqhttp=wreqhttp.replace("ws:","http:"),wreqhttp=wreqhttp.replace("msstwebsock",""),PutToDebugLog(2,"EVENT, WSAPIReqHTTP url: "+wreqhttp)}PollServiceStatus(e,wreqhttp);var i="POST";"get"===e.toLowerCase()&&(i="GET"),webphone_api.$.ajax({url:wreqhttp,data:n,timeout:2500,method:i}).done(function(e,n,o){if(PutToDebugLog(2,"EVENT, common: WSAPIReqHTTP response: "+e),isNull(e))return void PutToDebugLog(2,"ERROR, common: WSAPIReqHTTP received data is NULL");ProcessServiceReqResponse(e,t)}).fail(function(e,n,t){PutToDebugLog(2,"ERROR, common: WSAPIReqHTTP ajax failed, status: "+n+"; error: "+t)})}catch(a){PutToDebugLogException(2,"common: WSAPIReqHTTP",a)}}function PollServiceStatus(e,n){try{if(!0!==webphone_api.global.useajax_forservice)return;if(!isNull(webphone_api.global.serviceStatusPollTimer))return;nspollinterval<1&&(nspollinterval=GetParameterInt("nspollinterval",300)),webphone_api.global.serviceStatusPollTimer=setInterval(function(){pollreqcount++,!0===TestNSPolling()&&PutToDebugLog(2,"EVENT, common: PollServiceStatus: send extcmd_poll; request sent count: "+pollreqcount),webphone_api.$.ajax({url:n,data:"extcmd_poll",timeout:1e3,method:e.toUpperCase()}).done(function(e,n,t){isNull(e)&&(e="");var o=e.indexOf("APIRESULT:");o>0&&(e=e.substring(o+10),e.indexOf("nomessage")<0&&(o=e.indexOf("message:"))>0&&(e=Trim(e.substring(o+8)),webphonetojs(e)))}).fail(function(e,n,t){PutToDebugLog(2,"ERROR, common: PollServiceStatus ajax failed, status: "+n+"; error: "+t)})},nspollinterval)}catch(t){PutToDebugLogException(2,"common: WSAPIReqHTTP",t)}}function ProcessServiceReqResponse(e,n){var t=0;try{var o="";if(t=11,isNull(e)||e.length<1)return t=13,CanLog(4)&&PutToDebugLog(4,"EVENT, common: ServiceResponse, received data(1) is null: "+e),n(null),n=null,"";if(CanLog(7)&&PutToDebugLog(7,"PROCESSING_SRVRESPONSE: "+e),e=e.replace("NORETRY",""),e.indexOf("webphone_api.")>=0&&(")"===e.charAt(e.length-1)||")"===e.charAt(e.length-2)&&";"===e.charAt(e.length-1)))return CanLog(2)&&PutToDebugLog(2,"EVENT, common: ServiceResponse exec function received form websocket: "+e),void ExecFunction(e);if(e.indexOf("OK: pending")>=0)return void(CanLog(2)&&PutToDebugLog(2,"EVENT, common: ServiceResponse received pending, waiting for answer"));if(e.indexOf("WPNOTIFICATION")>=0)return webphonetojs(e),!0;if(!(e.indexOf("APIREQUEST:")>=0))return CanLog(4)&&PutToDebugLog(4,"EVENT, common: ServiceResponse, received data(3): "+e),t=46,void 0!==n&&null!==n&&IsFunction(n)&&n(o),n=null,o;if(CanLog(4)){var i=e;i.indexOf("ERROR:")>=0&&(i=i.replace("ERROR:","EVENT: (err) ")),CanLog(4)&&PutToDebugLog(4,"EVENT, common: ServiceResponse, received data(2): "+i)}t=14;var a="",r="",l="";if(e.indexOf("APIRESULT:")>0&&(t=15,getuseengine()===webphone_api.global.ENGINE_SERVICE&&(webphone_api.global.service_last_life_signal=GetTickCount()),e.indexOf("RPARAM1")>0?(a=e.substring(e.indexOf("APIREQUEST:")+11,e.indexOf("RPARAM1:")),e.indexOf("RPARAM2")>0?(r=e.substring(e.indexOf("RPARAM1:")+8,e.indexOf("RPARAM2")),l=e.substring(e.indexOf("RPARAM2:")+8,e.indexOf("APIRESULT:"))):r=e.substring(e.indexOf("RPARAM1:")+8,e.indexOf("APIRESULT:")),o=e.substring(e.indexOf("APIRESULT:")+10,e.length)):(a=e.substring(e.indexOf("APIREQUEST:")+11,e.indexOf("APIRESULT:")),o=e.substring(e.indexOf("APIRESULT:")+10,e.length))),t=18,isNull(a)?a="":(a=Trim(a),a=a.toLowerCase()),o=isNull(o)?"":Trim(o),t=19,50===GetConfigInt("brandid",-1)&&(isNull(r)&&(r=""),r=r.toLowerCase(),r.indexOf("ww.favafone")>0))return r.indexOf("countries-list")>0?HttpResponseHandler(o,"get_new_user_countrylist"):r.indexOf("registration-form")>0?HttpResponseHandler(o,"get_new_user_form_fields"):r.indexOf("create-account")>0&&HttpResponseHandler(o,"newuser_dynamic"),o;if(t=20,"api_poll"===a)t=21,webphonetojs(o),t=22;else{if(0!==a.indexOf("api_"))return o.indexOf("ERROR")>=0?(t=30,PutToDebugLog(2,"ERROR, "+o),t=31,n&&IsFunction(n)&&(t=32,n(o),n=null),""):"true"===o.toLowerCase()?(t=35,n(!0),n=null,!0):"false"===o.toLowerCase()?(t=36,n(!1),n=null,!1):IsNumber(o)?(t=37,n(StrToInt(o)),n=null,StrToInt(o)):o.indexOf("OK")>=0&&o.length<12?(t=40,n(!0),n=null,!0):(t=41,n(o),n=null,o);if(t=23,o.indexOf("ERROR")>=0)if(GetParameter("devicetype")===DEVICE_WIN_SOFTPHONE()||getuseengine()===webphone_api.global.ENGINE_SERVICE)o.indexOf("wphone")>0&&o.indexOf("not")>0&&o.indexOf("started")>0&&!1===webphone_api.global.wnotstartedsession&&webphone_api.global.apistartstate>0&&webphone_api.global.apistarttick>0&&GetTickCount()-webphone_api.global.apistarttick>3e3&&(webphone_api.global.wnotstartedsession=!0,PutToDebugLog(2,"WARNING, mlogic API_Sart because: wphone not started received"),WinAPI("API_Start",function(e){PutToDebugLog(2,"ERROR, API_Start because: wphone not started answer: "+e)},webphone_api.common.GetBrowserSessionID()));else if("api_call"===a){t=24;var s=o.replace("ERROR","");s=s.replace(":",""),PutToDebugLog(1,"ERROR, "+s)}else t=25,PutToDebugLog(2,"ERROR, "+o);t=26;var p=null,c=!1;if(!isNull(srv_cb)&&srv_cb.length>0){var u=r+l;!isNull(u)&&u.length>85&&(u=u.substring(0,85));for(var g=0;g<srv_apiname.length;g++)if(srv_apiname[g]===a){!isNull(srv_params[g])&&srv_params[g].length>85&&(srv_params[g]=srv_params[g].substring(0,85));var h=srv_params[g],m=u,d=h.indexOf("\r");if(d>0&&(h=h.substring(0,d)),h=Trim(h),d=m.indexOf("\r"),d>0&&(m=m.substring(0,d)),m=Trim(m),srv_params[g]===u||!isNull(h)&&h.length>0&&h===m){srv_apiname[g],p=srv_cb[g],isNull(p)||IsFunction(p)||(PutToDebugLog(2,"WARNING,ProcessServiceReqResponse callback is not a functionC ("+typeof p+") ("+srv_apiname+"): "+e),p=null),srv_apiname.splice(g,1),srv_cb.splice(g,1),srv_params.splice(g,1),c=!0;break}}if(!c)for(var g=0;g<srv_apiname.length;g++)if(srv_apiname[g]===a){!isNull(srv_params[g])&&srv_params[g].length>10&&(srv_params[g]=srv_params[g].substring(0,10)),!isNull(u)&&u.length>10&&(u=u.substring(0,10));var h=srv_params[g],m=u,d=h.indexOf("\r");if(d>0&&(h=h.substring(0,d)),h=Trim(h),d=m.indexOf("\r"),d>0&&(m=m.substring(0,d)),m=Trim(m),srv_params[g]===u||!isNull(h)&&h.length>0&&h===m||!isNull(h)&&h.length>0&&(0==h.indexOf(m)||0==m.indexOf(h))){srv_apiname[g],p=srv_cb[g],isNull(p)||IsFunction(p)||(PutToDebugLog(2,"WARNING,ProcessServiceReqResponse callback is not a functionC2 ("+typeof p+") ("+srv_apiname+"): "+e),p=null),srv_apiname.splice(g,1),srv_cb.splice(g,1),srv_params.splice(g,1),c=!0;break}}if(!c)for(var g=0;g<srv_apiname.length;g++)if(srv_apiname[g]===a){!isNull(srv_params[g])&&srv_params[g].length>1&&(srv_params[g]=srv_params[g].substring(0,1)),!isNull(u)&&u.length>1&&(u=u.substring(0,1));var h=srv_params[g],m=u,d=h.indexOf("\r");if(d>0&&(h=h.substring(0,d)),h=Trim(h),d=m.indexOf("\r"),d>0&&(m=m.substring(0,d)),m=Trim(m),srv_params[g]===u||!isNull(h)&&h.length>0&&h===m){srv_apiname[g],p=srv_cb[g],isNull(p)||IsFunction(p)||(PutToDebugLog(2,"WARNING,ProcessServiceReqResponse callback is not a functionC3 ("+typeof p+") ("+srv_apiname+"): "+e),p=null),srv_apiname.splice(g,1),srv_cb.splice(g,1),srv_params.splice(g,1),c=!0;break}}if(!c)for(var g=0;g<srv_apiname.length;g++)if(srv_apiname[g]===a){srv_apiname[g],p=srv_cb[g],isNull(p)||IsFunction(p)||(PutToDebugLog(2,"WARNING,ProcessServiceReqResponse callback is not a functionC4 ("+typeof p+") ("+srv_apiname+"): "+e),p=null),srv_apiname.splice(g,1),srv_cb.splice(g,1),srv_params.splice(g,1),c=!0;break}}if(t=27,!isNull(p)&&IsFunction(p)){if(t=28,isNull(o)&&(t=102,o=""),t=103,o=o.toString(),t=104,"true"===o.toLowerCase())return t=105,p(!0),t=106,!0;if("false"===o.toLowerCase())return t=107,p(!1),t=108,!1;if(o.toString&&IsNumber(o.toString().replace("OK:","")))return t=109,p(StrToInt(o.toString().replace("OK:",""))),StrToInt(o.toString().replace("OK:",""));if(o.indexOf("OK")>=0&&o.length<15)return t=110,p(!0),t=111,!0;t=112;try{"function"==typeof p?(t=1120101,p(o)):PutToDebugLog(2,"WARNING, ProcessServiceResponse cb_tmp is not a functionA ("+t+") ("+srv_apiname+"): "+e)}catch(w){PutToDebugLogException(2,"common: ProcessServiceReqResponseInner ("+t.toString()+") res: "+o+", cb: "+p,w)}return t=113,o}var b="";if(isNull(p))b="NULL";else try{b=p.toString()}catch(w){b="NOTAFUNCTION"}"api_setparameters"===a||"api_setdidchange"===a||"api_httpkeepalive"===a||"api_checkconnection"===a||"api_isnewbrowserconnection"===a||"api_setachange"===a||"api_setbchange"===a?PutToDebugLog(5,"EVENT, ProcessServiceResponse cb_tmp is not a functionB1 "+a):PutToDebugLog(2,"WARNING, ProcessServiceResponse cb_tmp is not a functionB. req: "+a+", cb: "+b+", list: "+srv_apiname+", received: "+e),t=29}t=45}catch(w){if(void 0!==w&&null!==w){var _=w.toString(),f="";if("undefined"!=typeof w.message&&null!==w.message&&(f=w.message),_.toLowerCase().indexOf("is not a function")>=0||f.toLowerCase().indexOf("is not a function")>=0)return void PutToDebugLog(2,"EVENT, (warn) common: ProcessServiceReqResponse ("+t.toString()+")"+_+" "+f)}PutToDebugLogWarning(2,"common: ProcessServiceReqResponse ("+t.toString()+")",w)}}function WSRequest(e,n,t){var o=0;try{if(isNull(wssocket)){PutToDebugLog(2,"EVENT, WSRequest need WsConnect websocketAPI, url: "+e),o=1;var i=GetWebrtcSrvAddr();if(o=2,isNull(i)||i.length<2){if(i=GetWp(),IsLocalServer(!0)&&IsMizuReallyPublicWebRTCGatewayAddress(i))return PutToDebugLog(2,"ERROR, "+webphone_api.stringres.get("webrtc_local_sipserver")+" (1)"),!1}else PutToDebugLog(2,"EVENT, WSRequest webrtcserveraddress found: "+i);if(i=i.replace("*",""),o=11,IsMizuServerOrGateway()){o=12;var a=i.indexOf("/mfst");a>0&&(i=i.substring(0,a)),i+="/mvstwebsock"}return i=i.replace("/mfstwebsock","/mvstwebsock"),(o=14,ws_inurl.push(e),ws_action.push(n),ws_ispost.push(t),HandleQueueOverload(),o=15,IsMizuPublicWebRTCGatewayUsed()&&!1===webphone_api.global.pgw_decide_finished&&getuseengine()===webphone_api.global.ENGINE_WEBRTC)?(PutToDebugLog(2,"EVENT, WSRequest decidegw not yet finished"),!0):(o=16,PutToDebugLog(2,"EVENT, WSRequest call WsConnect websocketAPI "+e+" / "+i),WSConnect(e,n,t,i),o=17,!0)}if(!1===wsready||ws_inurl.length>0)return ws_inurl.push(e),ws_action.push(n),ws_ispost.push(t),HandleQueueOverload(),PutToDebugLog(2,"EVENT, WSRequest request cached for later execution "+wsready.toString()+" "+ws_inurl.length),!0;var r=e;r=r.replace("mvapireq","mvstwebsock/mvapireq"),r=HandleApiKey(r),!isNull(r)&&r.indexOf("google.com")>0?PutToDebugLog(4,"EVENT, _common: WSRequest initialized"):PutToDebugLog(4,"EVENT, _common: WSRequest url: "+r);try{return o=30,isNull(ws_action_sent)&&(ws_action_sent=[]),isNull(n)&&(n=""),ws_action_sent.push(n),void 0!==wssocket&&null!==wssocket||PutToDebugLog(2,"ERROR, _common: WSRequest wssocket is NULL 1"),webphone_api.global.wsc_reqtimeout=GetTickCount(),wssocket.send(r+"\r\n"),o=34,!0}catch(l){PutToDebugLogWarning(3,"WARNING, common: WSRequest",l)}o=35}catch(s){PutToDebugLogException(2,"common: WSRequest ("+o.toString()+")",s)}return!1}function HandleQueueOverload(){try{var e=0,n=0;if(!isNull(ws_inurl)&&ws_inurl.length>0)for(;n<ws_inurl.length&&e<15;)"webrtcload"===ws_action[n]||"webrtccreateuser"===ws_action[n]?n++:(ws_inurl.splice(n,1),ws_action.splice(n,1),ws_ispost.splice(n,1),e++)}catch(t){PutToDebugLogException(2,"common: HandleQueueOverload",t)}}function WSConnect(e,n,t,o){var i=0;try{if(isNull(o)||o.length<2)PutToDebugLog(2,"ERROR, common: WSConnect websocketAPI address is NULL");else{i=2,0!==o.indexOf("ws")&&(o=BrowserRequiresHttps(!1,!0)?"wss://"+o:"ws://"+o);var a="";try{a=location.host.toLowerCase()}catch(l){}if(UseSecureSrvConnection()||a.indexOf("localhost")>=0||a.indexOf("127.0.0.1")>=0){var r=GetWsAddressCfg();(isNull(r)||void 0===r||r.length<4||r.indexOf("wss:")<0&&r.indexOf("ws:")<0)&&(r=GetParameter("webrtcserveraddress"),(isNull(r)||void 0===r||r.length<4||r.indexOf("wss:")<0&&r.indexOf("ws:")<0)&&"undefined"!=typeof webphone_api.parameters.origwebrtcserveraddress&&null!==webphone_api.parameters.origwebrtcserveraddress&&webphone_api.parameters.origwebrtcserveraddress.length>3&&(r=webphone_api.parameters.origwebrtcserveraddress)),!isNull(r)&&void 0!==r&&null!==r&&r.length>4&&r.indexOf("ws:")>=0||(o=o.replace("ws:","wss:"))}o=o.toString(),(o.indexOf("/mvstwebsock")>0||o.indexOf("/mfstwebsock")>0)&&o.indexOf("requestid=")<0&&(o=o.indexOf("?")>0?o+"&requestid="+GetRequestId():o+"?requestid="+GetRequestId()),PutToDebugLog(2,"EVENT, WSConnect websocketAPI address: "+o),webphone_api.global.wsc_contimeout=GetTickCount(),wsconnect_address=o,wssocket=new WebSocket(o,"api"),wssocket.binaryType="arraybuffer",i=5}wssocket.onopen=function(){webphone_api.global.wsc_contimeout=0;var e="";isNull(wssocket)||isNull(wssocket.url)||(e=wssocket.url.toString()),PutToDebugLog(2,"EVENT, common: WSConnect.onopen websocketAPI, connection ready "+e),SaveParameter("wseverconnected","true"),wsready=!0,HandleWsQueue()},wssocket.onclose=function(e){if(CanLog(2)){var n="";isNull(wssocket)||isNull(wssocket.url)||(n=wssocket.url.toString());var t="";isNull(e)||isNull(e.code)||(t=t+", code: "+e.code.toString()),isNull(e)||isNull(e.wasClean)||(t=t+", clean: "+e.wasClean.toString()),isNull(e)||isNull(e.reason)||(t=t+", reason: "+e.reason.toString()),PutToDebugLog(2,"EVENT, common: WSConnect.onclose websocketAPI, connection closed "+n+t)}wssocket=null,wsready=!1},wssocket.onerror=function(e){var n="";isNull(e)||(n=e.toString());var t="";isNull(wssocket)||isNull(wssocket.url)||(t=wssocket.url.toString()),PutToDebugLog(2,"ERROR, common: WSConnect.onerror websocketAPI, connection onerror: "+n+" url: "+t),wsready=!1,wssocket=null,PutToDebugLog(2,"ERROR, common: WSConnect.onerror websocketAPI, call WSReConnect"),WSReConnect()},i=20,wssocket.onmessage=function(e){webphone_api.global.wsc_reqtimeout=0;var n=null;if(isNull(e)||(n=e.data),isNull(n))return void PutToDebugLog(2,"ERROR, common: WSConnect.onmessage websocketAPI, received data is NULL");var t="";isNull(ws_action_sent)||isNull(ws_action_sent[0])||(t=ws_action_sent.shift()),HttpResponseHandler(ArrayBufferToString(n),t)}}catch(s){PutToDebugLogException(2,"common: WSConnect websocketAPI ("+i.toString()+")",s)}}function WSReConnect(){try{if(++wsr_count<80&&null===wsr_timer){wsr_delay<32e3&&(wsr_delay*=2);return PutToDebugLog(2,"EVENT, WSReConnect websocketAPI after: "+(wsr_delay/1e3).toString()+" sec"),wsr_timer=setTimeout(function(){PutToDebugLog(2,"EVENT, WSReConnect websocketAPI reconnecting..."),WSConnect("","","",wsconnect_address),isNull(wsr_timer)||clearTimeout(wsr_timer),wsr_timer=null},wsr_delay),wsr_delay<10&&(wsr_delay=500),!0}}catch(e){PutToDebugLogException(2,"common: WSReConnect websocketAPI",e)}return!1}function HandleWsQueue(){try{if(isNull(ws_inurl)||ws_inurl.length<1)return;if(!isNull(hawsqueue_timer))return;hawsqueue_timer=setInterval(function(){if(isNull(ws_inurl)||ws_inurl.length<1)return isNull(hawsqueue_timer)||clearInterval(hawsqueue_timer),void(hawsqueue_timer=null);if(void 0===wssocket||null===wssocket)return void PutToDebugLog(2,"WARNING, _common: WSRequest HandleWsQueue wssocket is NULL 2");var e=ws_inurl.shift(),n=ws_action.shift();ws_ispost.shift();ws_action_sent.push(n),e=HandleApiKey(e),PutToDebugLog(4,"EVENT, _common: WSRequest HandleWsQueue SEND data: "+e),webphone_api.global.wsc_reqtimeout=GetTickCount(),wssocket.send(e+"\r\n")},200)}catch(e){PutToDebugLogException(2,"common: HandleWsQueue",e)}}function HandleApiKey(e){try{if(isNull(e)||e.length<1)return e;var n=e,t=n.indexOf("mcrfs=");if(t>0&&(n=StrDc("mcrfs_"+n.substring(t+6),webphone_api.global.ec_apikey)),n.indexOf("authkey=")<0)return e;var o;if(e.indexOf("rtc.mizu-voip.com:2443")>=0)o="1568108399";else{var i=-1;if(!isNull(wsconnect_address)&&wsconnect_address.length>3&&(i=PGW_GetGwIndex(wsconnect_address)),i<0&&(i=PGW_GetGwIndex(e)),o=PGW_Get(i,PGW_APIKEY),o.length<1&&i>=0&&CanLog(5)&&PutToDebugLog(5,"EVENT, no authkey A for gw "+i.toString()+" / "+wsconnect_address+" / "+n),o.length<1&&(o=GetParameterOrConfig("serverapikey"),"1568108345"==o&&i<0&&CanLog(5)&&PutToDebugLog(5,"EVENT, no authkey B for gw "+i.toString()+" / "+wsconnect_address+" / "+n),CanLog(5)&&PutToDebugLog(5,"EVENT, apply key: "+o),!(o.length>0&&n.indexOf(o)<0&&e.indexOf(o)<0&&(!isNull(wsconnect_address)&&wsconnect_address.indexOf("mvstwebsock")>=0||e.indexOf("mvstwebsock")>=0||n.indexOf("mvstwebsock")>=0))))return e}var a="";if(t=e.indexOf("mcrfs="),t>0&&(a=e.substring(0,e.indexOf("mcrfs=")+6)),!((t=n.indexOf("authkey="))>=0))return e;var r=n.substring(0,t),l="";n=n.substring(t),t=n.indexOf("&"),t<0&&(t=n.length),t>=0&&(l=n.substring(t)),isNull(l)&&(l=""),n=r+"authkey="+o+l,e.indexOf("mcrfs=")>0&&(n=StrEc(n,webphone_api.global.ec_apikey,!0)),e=a+n}catch(s){PutToDebugLogException(2,"common: HandleApiKey",s)}return e}function HttpAsyncHandler(e){try{if(isNull(e)||e.length<1)return void PutToDebugLog(2,"ERROR, HttpAsyncHandler notification is NULL");e=Trim(e),webphone_api.global.currhttpmehodworking=!0;var n="",t="";if(IsMizuServerOrGateway()){var o=e.indexOf("oenc1_");o>0&&(e=e.substring(o+6),e=StrDc(e,webphone_api.global.ec_apikey))}var o=e.indexOf("REQUEST:");if(o>0&&(t=e.substring(o+8,e.length),t=Trim(t)),(o=e.indexOf("RESULT:"))>=0){var i=e.indexOf("REQUEST:");i<1&&(i=e.length),n=e.substring(o+7,i),n=Trim(n),n.lastIndexOf(",")===n.length-1&&(n=Trim(n.substring(0,n.length-1)))}if(isNull(n)||n.length<1)return void PutToDebugLog(2,"WARNING, HttpAsyncHandler response is NULL");if(isNull(t)||t.length<1)return void PutToDebugLog(2,"WARNING, HttpAsyncHandler request is NULL");if(t.indexOf("AUTOPROVISIONING")>=0){if(isNull(n)||!(n.toLowerCase().indexOf("endofautoprovisioning")>0))return void PutToDebugLog(2,"ERROR, HttpAsyncHandler autoprovidioning error: "+n);PutToDebugLog(2,"EVENT, HttpAsyncHandler autoprovidioning succeded: "+n),ParseAutoprovisioning(n),"false"===GetParameter("serverinputisupperserver")&&RestartPhone()}t.toLowerCase().indexOf("balance")>0||t.toLowerCase().indexOf("includecurrency")>0?HttpResponseHandler(n,"creditrequest"):t.toLowerCase().indexOf("rating")>0||t.toLowerCase().indexOf("tariffs")>0?HttpResponseHandler(n,"getrating"):t.toLowerCase().indexOf("=callback")>0?HttpResponseHandler(n,"callback"):t.toLowerCase().indexOf("=wsload")>0?HttpResponseHandler(n,"webrtcload"):t.toLowerCase().indexOf("srvct")>0||t.toLowerCase().indexOf("contacts")>0?HttpResponseHandler(n,"downloadcontacts"):t.toLowerCase().indexOf("lastcalldetails")>0?HttpResponseHandler(n,"lastcalldetails"):t.toLowerCase().indexOf("wrtcload_")>0?HttpResponseHandler(n,"wrtcload_"+StrGetAfter(t,"wrtcload_")):t.toLowerCase().indexOf("scurl_displaypeerdetails")>0?HttpResponseHandler(n,"scurl_displaypeerdetails"):t.toLowerCase().indexOf("getconfroom")>0?HttpResponseHandler(n,"getconferenceroom"):t.toLowerCase().indexOf("waitforparameters")>0?HttpResponseHandler(n,"waitforparameters"):t.toLowerCase().indexOf("recharge")>0?HttpResponseHandler(n,"recharge"):t.toLowerCase().indexOf("tel.search.ch")>0?HttpResponseHandler(n,"telsearchname"):t.toLowerCase().indexOf("calldivert")>0?HttpResponseHandler(n,"calldivertapi"):t.toLowerCase().indexOf("presence_set")>0?HttpResponseHandler(n,"presence_set"):(t.toLowerCase().indexOf("get_custom_menu")>0||t.toLowerCase().indexOf("logincheck")>0)&&HttpResponseHandler(n,"get_custom_menu")}catch(a){PutToDebugLogException(2,"common: HttpAsyncHandler",a)}}function HttpResponseHandler(e,n){try{if(webphone_api.global.currhttpmehodworking=!0,!isNull(e)&&e.toString().indexOf("auth failed: wrong key")>=0){var t=e.toString();t=t.substring(0,t.indexOf("wrong key")+9)}if(isNull(e))return void PutToDebugLog(3,"ERROR, common: httpResponse is NULL");var o=e.toString(),i="";i=o.length>600?o.substring(0,600)+" ...":o;var a=o.toLowerCase();if(a.indexOf("wsuser")>=0||"webrtccreateuser"===n){var r=o;if(r.indexOf("DISPLAY")>0)return r=Trim(r.replace("DISPLAY","")),PutToDebugLog(1,r),void ShowToast(r);if(a.indexOf("ok:")>=0){var l=GetParameter("wsusers"),s=GetSipusername(!0);if(webphone_api.iswebrtcengineworking=1,webphone_api.global.last_wsu_tick=GetTickCount(),s.length>0)l.indexOf(s)<0&&(l.length>0&&","!==l.charAt(l.length-1)&&(l+=","),l+=s,SaveParameter("wsusers",l));else{a.indexOf(" ")>0&&(a=Trim(a),s=a.substring(a.lastIndexOf(" ")+1),s=Trim(s),s.length>0&&l.indexOf(s)<0&&(l.length>0&&","!==l.charAt(l.length-1)&&(l+=","),l+=s,SaveParameter("wsusers",l)))}PutToDebugLog(3,"EVENT, common wsuser response: "+i),webphone_api.global.wsuser_succeded=!0,webphone_api.global.isfirstwsu=!1}else PutToDebugLog(3,"ERROR, common wsuser failed, response: "+i);return}if(PutToDebugLog(3,"EVENT, common: httpResponse: "+i+"; action: "+n),isNull(n)||Trim(n).length<1)return void PutToDebugLog(2,"ERROR, common: HttpResponseHandler action is NULL");if("creditrequest"===n){var p=o.toLowerCase();if(p.indexOf("error")>=0&&50!==GetConfigInt("brandid",-1)||p.indexOf("postpaid")>=0||p.indexOf("invalid")>=0||p.indexOf("not found")>=0)webphone_api.global.creditRequestIval<3e4?webphone_api.global.creditRequestIval=2*webphone_api.global.creditRequestIval:webphone_api.global.creditRequestIval=webphone_api.global.CREDIT_REQUEST_IVAL_DEFVAL;else{if(50===GetConfigInt("brandid",-1)){var c=JSON.parse(o),u=c.data,g=c.error;if(!isNull(g)&&g.length>0)return void PutToDebugLog(2,"ERROR, Favafone creditrequest error: "+g);if(isNull(u))return void PutToDebugLog(3,"ERROR, Favafone creditrequest httpresponsehandler data is NULL");var h=u.balance,m=u.currency_sign
;return!isNull(h)&&h.length>0&&(webphone_api.global.credit="Credit: "+m+" "+h),void PutToDebugLog(4,"EVENT, Favafone received credit balance: "+webphone_api.global.credit)}o=o.replace("{",""),o=o.replace("}",""),o=ReplaceAll(o,'"',"");webphone_api.global.credit=""+o,webphone_api.global.credit.indexOf("Your credit is")>=0&&(webphone_api.global.credit=webphone_api.global.credit.replace("Your credit is","Credit:")),webphone_api.global.creditRequestIval=webphone_api.global.CREDIT_REQUEST_IVAL_DEFVAL}}else if("getrating"===n){if((o.toLowerCase().indexOf("error")>=0||o.indexOf("postpaid")>=0||o.indexOf("invalid")>=0||o.indexOf("not found")>=0)&&50!==GetConfigInt("brandid",-1))return void PutToDebugLog(2,"ERROR, HttpResponseHandler action: Call, error: "+o);var d=o;if(50===GetConfigInt("brandid",-1)){var c=JSON.parse(o),b=c.data,g=c.error;if(!isNull(g)&&g.length>0)return void PutToDebugLog(2,"ERROR, Favafone getrating error: "+g);if(isNull(b)||isNull(b[0]))return void PutToDebugLog(3,"ERROR, Favafone getrating httpresponsehandler data is NULL");var _=b[0].voice_rate,f=b[0].description,m=b.currency_sign;if(_.length<1||"null"===_.toLowerCase())return void PutToDebugLog(2,"ERROR, Favafone getrating, rating request respose2: "+o);d=m+" "+_+" / min ("+f+")"}50!==GetConfigInt("brandid",-1)&&(d+=webphone_api.stringres.get("rating_minute")),ShowRatingWhyleType(d),webphone_api.global.rating=" ("+d+webphone_api.stringres.get("rating_minute")+")"}else if("get_custom_menu"===n)ProcessCustomMenu(o);else if("waitforparameters"===n)webphone_api.plhandler.ParseReceivedParameters(o);else if("presence_set"===n)HandleOfflineMessages(o);else if("webrtcload"===n){if(o.toLowerCase().indexOf("error")>=0)return void PutToDebugLog(2,"ERROR, HttpResponseHandler action: webrtcload, error: "+o);var w=o.toLowerCase(),v=w.indexOf("ws load:");if(v>=0){if(w.indexOf("type:")>0){var E=w.substring(w.indexOf("type:")+5);E=Trim(E),!isNull(E)&&IsNumber(E)&&(webphone_api.global.wsload_type=StrToInt(E))}w=w.substring(v+8),w=Trim(w);var P=-1;try{P=parseInt(w,10)}catch($){PutToDebugLogException(2,"common: HttpResponseHandler parse webrtc load",$)}if(P<4){webphone_api.iswebrtcengineworking=1;var T=GetEngine("webrtc");T.serversupport_cache=P,SetEngine("webrtc",T)}if(webphone_api.global.recwsload!=P&&P>=0&&P<=7&&(webphone_api.global.recwsload=P,SaveParameter("lastrecwsload",P)),SetPresenceIval(P),P>2)if(P>3){if(!1===webphone_api.global.usestorage&&!1===Strl(60)&&getuseengine()===webphone_api.global.ENGINE_WEBRTC&&!0===CanIUseService()){GetParameter("lastusedengine").length>0&&"ns"!=GetParameter("lastusedengine")&&SaveParameter("prevusedengine",GetParameter("lastusedengine")),SaveParameter("lastusedengine","ns"),webphone_api.flagrestartwebrtc=!1,ResetEngineClicked();var S=GetEngine("ns");S.clicked=2,SetEngine("ns",S),EngineSelect(1,6),PutToDebugLog(2,"WARNING, common wsload: offer ns engine because webrtc load is too high: "+P.toString()),EngineForcedInstall("ns",webphone_api.stringres.get("serviceengine_msg"),function(){webphone_api.startInner()})}}else getuseengine()===webphone_api.global.ENGINE_WEBRTC?(SaveParameter("enablepresence","0"),PutToDebugLog(2,"EVENT, disable presence because wsload is high: "+P.toString())):setTimeout(function(){getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(SaveParameter("enablepresence","0"),PutToDebugLog(2,"EVENT, disable presence because wsload is high: "+P.toString()))},5e3)}}else if(0==n.indexOf("wrtcload_")){var N=StrToIntDef(StrGetAfter(n,"wrtcload_"),-1);if(N<0||N>=PGW_Get_Count())return void PutToDebugLog(2,"ERROR, HttpResponseHandler invalid gwidx "+n+" / "+o);if(o.toLowerCase().indexOf("error")>=0)return PutToDebugLog(2,"ERROR, HttpResponseHandler action: webrtcload, error: "+o),void(0==PGW_Get(N,PGW_WSREC)&&PGW_Set(N,PGW_FAILED,!0));var w=o.toLowerCase(),v=w.indexOf("ws load:");if(v>=0){var I=-1;if(w.indexOf("type:")>0){var E=w.substring(w.indexOf("type:")+5);E=Trim(E),!isNull(E)&&IsNumber(E)&&(I=StrToInt(E))>=0&&webphone_api.global.wsload_type<1&&(webphone_api.global.wsload_type=I)}var C=0;if(w.indexOf("pmsec:")>0){var G=StrGetBetween(w,"pmsec:"," from");G=Trim(G),!isNull(G)&&IsNumber(G)&&((C=StrToInt(G))<-9e4||C>9e4)&&(C=0)}w=w.substring(v+8),w=Trim(w);var P=-1;try{P=parseInt(w,10)}catch($){PutToDebugLogException(2,"common: HttpResponseHandler parse webrtc load",$)}var L=GetParameter("last_good_webrtc_gw");PGW_Set(N,PGW_WSLOAD,P);var R=PGW_Get(N,PGW_WSTIME_BGN);0!=R&&-1!=R||(R=GetTickCount()-3e3);var y=GetTickCount()-R,D="orig:"+y.toString()+" - pmsec:"+C.toString();y-=C,isNull(L)||L!=N||(y-=20,D+=" - last:20"),y<1&&(y=1);var O=PGW_Get(N,PGW_DELAY);0!=O&&(y+=O,D=D+" + delay:"+O.toString()),y<1&&(y=1),PGW_Set(N,PGW_WSTIME_DIFF_REAL,D),PGW_Set(N,PGW_WSTIME_DIFF,y),PGW_Set(N,PGW_WSREC,!0),PGW_Set(N,PGW_FAILED,!1),I>=0&&PGW_Set(N,PGW_TYPE,I),wsloadanswersreceived<2&&wsloadanswersreceived++;for(var x=!0,A=PGW_Get_Count(),k=0;k<A;k++){var U=PGW_Get(k,PGW_ADDRESS);if(!(U.length<1)&&(!1!==PGW_Get(k,PGW_TRY)&&1!=PGW_Get(k,PGW_FAILED)&&!1===PGW_Get(k,PGW_WSREC))){x=!1;break}}x&&(wsloadanswersreceived=3),DecideUsUk(N)}else 0==PGW_Get(N,PGW_WSREC)&&PGW_Set(N,PGW_FAILED,!0)}else if("recharge"===n)o.toLowerCase().indexOf("error")>=0&&PutToDebugLog(2,"ERROR, HttpResponseHandler action: recharge, error: "+o),ShowToast(o);else if("newuserreg"===n)webphone_api._newuser.HttpResponseHandler(o,n);else if("get_new_user_form_fields"===n||"newuser_dynamic"===n||"get_new_user_countrylist"===n)webphone_api._newuser.HttpResponseHandler(o,n);else if("verifysmscode"===n)webphone_api._smscodeverify.HttpResponseHandler(o,n);else if("phone2phone"===n)o.toLowerCase().indexOf("error")>=0&&PutToDebugLog(2,"ERROR, HttpResponseHandler action: phone2phone, error: "+o),ShowToast(o);else if("callback"===n){if(o.toLowerCase().indexOf("error")>=0)return void PutToDebugLog(2,"ERROR, HttpResponseHandler action: callback, error: "+o);isNull(o)&&(o=""),o=Trim(o),ShowToast(o)}else if("presence_verify"===n||"presence_get"===n)PresenceProcessUserlist2(Trim(o),n);else if("downloadcontacts"===n){if(o.toLowerCase().indexOf("error")>=0)return void PutToDebugLog(2,"ERROR, HttpResponseHandler action: "+n+", error: "+o);o=StrDc(o,key,"rPv9NKwm4Ua"),ParseContactsFromServer(o,!1,function(e){e?(PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("sync_succeded")),PutToDebugLog(1,"EVENT, POPUP, "+webphone_api.stringres.get("sync_succeded")),webphone_api.global.reloadcontactsaftersync=!0):(PutToDebugLog(1,"ERROR, "+webphone_api.stringres.get("sync_failed")),PutToDebugLog(1,"EVENT, POPUP, "+webphone_api.stringres.get("sync_failed")))})}else if("lastcalldetails"===n)webphone_api.global.lastcalldetails=o;else if("additional_info"===n){if(o.toLowerCase().indexOf("error")>=0)return void PutToDebugLog(2,"ERROR, HttpResponseHandler action: "+n+", error: "+o);var V=o;V=ReplaceAll(V,"\r\n","<br>"),V=ReplaceAll(V,"\n","<br>"),isNull(document.getElementById("page_call_additional_info"))||(PutToDebugLog(4,"EVENT, HttpResponseHandler Display additional call info: "+V),document.getElementById("page_call_additional_info").innerHTML=V)}else if("scurl_displaypeerdetails"===n){if(o.toLowerCase().indexOf("error")>=0)return void PutToDebugLog(2,"ERROR, HttpResponseHandler action: "+n+", error: "+o);DisplayPeerDetails(o)}else if("getconferenceroom"===n)ConferenceRoomReceived(o);else if("webcontactsearch"===n)WebContactReceived(o);else if("telsearchname"===n)TelSearchNameReceived(o);else if("calldivertapi"===n){var W=o.toLowerCase();if(W.indexOf("error")>=0)return void PutToDebugLog(2,"ERROR, HttpResponseHandler action: "+n+", error: "+o);if(W.indexOf("ok")>=0){SaveParameter("calldivertsuccess","1");var F=GetParameter2("callforwardonbusy"),M=GetParameter2("callforwardonnoanswer"),H=GetParameter2("callforwardalways"),B=GetParameter2("callforwardonnoanswertimeout"),j=Md5Hash(F+M+H+B);SaveParameter("calldivertchecksum",j)}}else if("get_custom_menu"===n){var W=o.toLowerCase();if(W.indexOf("error")>=0)return void PutToDebugLog(2,"ERROR, HttpResponseHandler action: "+n+", error: "+o);ProcessCustomMenu(o)}}catch(q){PutToDebugLogException(2,"common: HttpResponseHandler",q)}}function WinAPI(e,n,t,o,i,a,r,l,s,p,c){var u="BOFLINE",g="EOFLINE";try{if(n&&"function"==typeof n||(n=function(e){isNull(e)||(e=e.toString(),e.indexOf("OK:")>=0&&e.indexOf("wphone")>0&&e.indexOf("started")>0&&setTimeout(function(){webphone_api.global.phonestarted<2&&(webphone_api.global.phonestarted=2)},2e3)),PutToDebugLog(2,"EVENT, common: WinAPI NO callback specified; result: "+e)}),isNull(e)||e.length<1)return PutToDebugLog(2,"ERROR, common: WinAPI: apiname is NULL"),n(!1),!1;var h="BOFCOMMAND";h=h+u+"function="+e+g,!isNull(t)&&t.toString().length>0&&(t=Trim(t),h=h+u+"param1="+t+g),!isNull(o)&&o.toString().length>0&&(o=Trim(o),h=h+u+"param2="+o+g),!isNull(i)&&i.toString().length>0&&(i=Trim(i),h=h+u+"param3="+i+g),!isNull(a)&&a.toString().length>0&&(a=Trim(a),h=h+u+"param4="+a+g),!isNull(r)&&r.toString().length>0&&(r=Trim(r),h=h+u+"param5="+r+g),!isNull(l)&&l.toString().length>0&&(l=Trim(l),h=h+u+"param6="+l+g),!isNull(s)&&s.toString().length>0&&(s=Trim(s),h=h+u+"param7="+s+g),!isNull(p)&&p.toString().length>0&&(p=Trim(p),h=h+u+"param8="+p+g),!isNull(c)&&c.toString().length>0&&(c=Trim(c),h=h+u+"param9="+c+g),h=h+u+"requestid="+GetRequestId()+g,h+="EOFCOMMAND";var m="";webphone_api.global.httpkatimer=GetTickCount(),IsWindowsSoftphone()?(m=AddJscommport(webphone_api.global.WIN_SOFTPHONE_URL)+m,CanLog(7)&&PutToDebugLog(7,"EVENT, WinAPI windows url: "+m),WinSoftphoneHttpReq(m,"POST","data="+h,e,function(e){if(isNull(e))e="";else if(IsString(e))try{e=e.replace("EOFLINE","\r\n")}catch(t){PutToDebugLogWarning(2,"common: WinAPIInternA",t)}return n(e),e})):getuseengine()===webphone_api.global.ENGINE_SERVICE||!0===webphone_api.global.onunload_flag?WSAPIRequest("POST","data="+h,e,function(e){if(isNull(e))e="";else if(IsString(e))try{e=e.replace("EOFLINE","\r\n")}catch(t){PutToDebugLogWarning(2,"common: WinAPIInternB",t)}return n(e),e}):CanLog(5)&&(e.indexOf("API_Unregister")>=0||e.indexOf("API_Stop")>=0||e.indexOf("API_Exit")>=0?PutToDebugLog(3,"EVENT, (warn) common: winapi invalid engine/device: "+getuseengine()+"; apiname: "+e+"; data="+h):PutToDebugLog(2,"WARNING, common: winapi invalid engine/device: "+getuseengine()+"; apiname: "+e+"; data="+h))}catch(d){PutToDebugLogException(2,"common: WinAPI",d)}return!1}function WinSoftphoneHttpReq(e,n,t,o,i){var a=0;try{var r="";if(isNull(t)||(r=t.length>300?t.substring(0,300)+"....":t),CanLog(5)&&PutToDebugLog(5,"EVENT, WinSoftphoneHttpReq called "+n+" url: "+e+"; data: "+r),(isNull(n)||n.length<1)&&(a=1,PutToDebugLog(2,"WARNING, common: WinSoftphoneHttpReq: method not specified; fallback to GET"),n="GET"),a=2,isNull(t))return a=3,PutToDebugLog(2,"ERROR, common: WinSoftphoneHttpReq: data is NULL "),cbexecuted=!0,i(null),"";a=4,t.indexOf("API_CallEOFLINE"),a=5,setTimeout(function(){if(a=6,!isNull(i)&&i&&"function"==typeof i)return a=7,PutToDebugLog(3,"EVENT, common: WinSoftphoneHttpReq: manual Timeout"),i(null),i=null,""},reqtimeout+1e3);var l=!1;if(!isNull(o)&&o.length>0&&!isNull(i)&&"function"==typeof i&&(o=Trim(o),0===o.indexOf("API_")&&"API_Poll"!==o&&"API_Stop"!==o&&o.indexOf("extcmd_")<0)){srv_cb.push(i),srv_apiname.push(o.toLowerCase()),l=!0;var s="";if(!isNull(t)&&t.indexOf("param1=")>0){var p=ReplaceAll(t,"BOFLINE","");p=ReplaceAll(p,"EOFLINE","");var c=p.substring(p.indexOf("param1=")+7),u="";c.indexOf("param2=")>=0?(u=c.substring(c.indexOf("param2=")+7),u=u.indexOf("param3=")>=0?u.substring(0,u.indexOf("param3=")):u.substring(0,u.indexOf("EOFCOMMAND")),u=Trim(u),c=c.substring(0,c.indexOf("param2=")),c=Trim(c)):(c=c.substring(0,c.indexOf("EOFCOMMAND")),c=Trim(c)),s=c+u}var g=s;g.indexOf("requestid=")>=0&&(g=g.replace("requestid=","")),srv_params.push(g)}var h;window.XMLHttpRequest?(a=8,h=new XMLHttpRequest):(a=9,h=new ActiveXObject("Microsoft.XMLHTTP")),"get"===n.toLowerCase()?(a=10,h.open("GET",e+t,!0)):(h.open("POST",e,!0),a=11),h.onreadystatechange=function(){try{if(CanLog(7)&&PutToDebugLog(7,"EVENT, WinSoftphoneHttpReq: xmlhttp.readyState: "+h.readyState+"; xmlhttp.status: "+h.status),a=19,4==h.readyState&&200==h.status){var e=h.responseText;if(CanLog(5)){a=20;var n="";n=!isNull(e)&&e.length>250?e.substring(0,250)+"....":e,isNull(n)&&(n="NULL"),n.indexOf("ERROR: header not found")>0&&(n=n.replace("ERROR: header not found","ERR: header not found")),PutToDebugLog(5,"EVENT, WinSoftphoneHttpReq response ("+e.length.toString()+"): "+n)}cbexecuted=!0;var t="";if(a=21,isNull(e)||e.length<1)return a=23,isNull(i)?PutToDebugLog(3,"EVENT, WinSoftphoneHttpReq inner_1 callback is null__1"):i(null),i=null,"";if(l&&0==e.indexOf("OK: pending"));else{if(!(e.indexOf("APIREQUEST:")>=0))return a=42,isNull(i)?PutToDebugLog(3,"EVENT, WinSoftphoneHttpReq inner_1 callback is null__3"):(a=304,i(t)),i=null,t;a=24;var o="",r="";if(e.indexOf("APIRESULT:")>0&&(a=25,e.indexOf("RPARAM1")>0?(o=e.substring(e.indexOf("APIREQUEST:")+11,e.indexOf("RPARAM1:")),e.indexOf("RPARAM2")>0?(r=e.substring(e.indexOf("RPARAM1:")+8,e.indexOf("RPARAM2")),e.substring(e.indexOf("RPARAM2:")+8,e.indexOf("APIRESULT:"))):r=e.substring(e.indexOf("RPARAM1:")+8,e.indexOf("APIRESULT:")),t=e.substring(e.indexOf("APIRESULT:")+10,e.length)):(o=e.substring(e.indexOf("APIREQUEST:")+11,e.indexOf("APIRESULT:")),t=e.substring(e.indexOf("APIRESULT:")+10,e.length))),a=28,isNull(o)?o="":(o=Trim(o),o=o.toLowerCase()),t=isNull(t)?"":Trim(t),a=29,50===GetConfigInt("brandid",-1)&&(isNull(r)&&(r=""),r=r.toLowerCase(),r.indexOf("ww.favafone")>0))return r.indexOf("countries-list")>0?HttpResponseHandler(t,"get_new_user_countrylist"):r.indexOf("registration-form")>0?HttpResponseHandler(t,"get_new_user_form_fields"):r.indexOf("create-account")>0&&HttpResponseHandler(t,"newuser_dynamic"),t;if(isNull(i)&&PutToDebugLog(3,"EVENT, WinSoftphoneHttpReq inner_1 callback is null__2"),a=30,"api_poll"!==o){if(t.indexOf("ERROR")>=0){if(a=33,t.indexOf("ERROR: header not found")>=0)PutToDebugLog(5,"EVENT, whresponse: header not found");else if("api_call"===o){var s=t.replace("ERROR","");s=s.replace(":",""),PutToDebugLog(1,"ERROR, whresponse: "+s)}else PutToDebugLog(2,"ERROR, whresponse: "+t);return a=34,isNull(i)||i(null),i=null,""}return"true"===t.toLowerCase()?(a=301,isNull(i)||i(!0),i=null,!0):"false"===t.toLowerCase()?(a=302,isNull(i)||i(!1),i=null,!1):IsNumber(t)?(a=303,isNull(i)||i(StrToInt(t)),i=null,StrToInt(t)):t.indexOf("OK")>=0&&t.length<12?(a=37,isNull(i)||i(!0),i=null,!0):(a=3888,isNull(i)||i(t),i=null,t)}a=31,webphonetojs(t),a=32,a=40}a=48}}catch(p){PutToDebugLogException(2,"common: WinSoftphoneHttpReq inner_1 ("+a+")",p)}},h.timeout=reqtimeout,h.ontimeout=function(e){if(!isNull(i)&&i&&"function"==typeof i)return a=49,PutToDebugLog(2,"ERROR, common: WinSoftphoneHttpReq: Timeout"),cbexecuted=!0,i(null),i=null,""},"get"===n.toLowerCase()?(t.length>0&&(t="?"+t),a=50,h.send()):(a=51,50===GetConfigInt("brandid",-1)&&PutToDebugLog(2,"EVENT, WinSoftphoneHttpReq SEND post request with data: "+t),h.send(t))}catch(m){PutToDebugLogException(2,"common: WinSoftphoneHttpReq ("+a+")",m)}}function GetNotifications2(){try{if(!0===nread)return;nread=!0;var e=GetParameter("notifications2");if(webphone_api.global.notifs=[],isNull(e)||e.length<10)return;var n=e.split(not_linesep);if(isNull(n)||n.length<1)return;for(var t=0;t<n.length;t++)if(!(isNull(n[t])||n[t].length<1||n[t].indexOf(",")<0)){var o=n[t].split(not_sep);isNull(o)||o.length<4||webphone_api.global.notifs.push(o)}}catch(i){PutToDebugLogException(2,"common: GetNotifications2",i)}}function SaveNotifications2(){var e="";try{if(!isNull(webphone_api.global.notifs)&&webphone_api.global.notifs.length>0)for(var n=0;n<webphone_api.global.notifs.length;n++)if(!(isNull(webphone_api.global.notifs[n])||webphone_api.global.notifs[n].length<1)){var t=webphone_api.global.notifs[n];isNull(t)||t.length<4||(e.length>0&&(e+=not_linesep),e=e+t[0]+not_sep+t[1]+not_sep+t[2]+not_sep+t[3])}SaveParameter("notifications2",e)}catch(o){PutToDebugLogException(2,"common: SaveNotifications2",o)}}function PutNotifications2(e,n,t,o){try{if(GetParameterInt("displaynotification",0)<1)return;if(isNull(e)||!IsNumber(e))return void PutToDebugLog(4,"ERROR, common: PutNotifications2 invalid type");GetNotifications2(),isNull(n)&&(n=""),isNull(t)&&(t=""),(isNull(o)||!IsNumber(o)||o<1e3)&&(o=GetTickCount());var i=[];i[0]=e,i[1]=n,i[2]=t,i[3]=o.toString(),webphone_api.global.notifs.unshift(i),SaveNotifications2(),ShowNotifications2();var a=GetParameterInt("notification_count2",0);a<0&&(a=0),a++,SaveParameter("notification_count2",a)}catch(r){PutToDebugLogException(2,"common: PutNotifications2",r)}}function GetDateForNotifications(e){try{if(isNull(e)||!IsNumber(e)||e<1)return"";var n=new Date(e),t=n.getMinutes();t<10&&(t="0"+t);var o=n.getDate();o<10&&(o="0"+o);return month[n.getMonth()]+", "+o+" "+n.getHours()+":"+t}catch(i){PutToDebugLogException(2,"common: GetDateForNotifications",i)}return""}function ShowNotifications2(){try{if(GetNotifications2(),isNull(webphone_api.global.notifs)||webphone_api.global.notifs.length<1)return void HideNotificationsElements();for(var e="",n="",t="",o="",i='<li class="mlistitem"><a id="[PAGE]_notitem_[NOTID]" class="nt_anchor"><div class="nt_title">[TITLE]</div><div class="nt_desc">[DESC]</div><div class="nt_date">[DATE]</div></a><a id="[PAGE]_notmenu_[NOTID]" class="ui-btn ui-btn-inline ui-icon-delete nt_menu">'+webphone_api.stringres.get("hint_notif_clear")+"</a></li>",a=0;a<webphone_api.global.notifs.length;a++)if(!(isNull(webphone_api.global.notifs[a])||webphone_api.global.notifs[a].length<1)){var r=webphone_api.global.notifs[a],l=i;!isNull(r[2])&&r[2].length>0&&webphone_api.stringres.lang.length<1?l=l.replace("[TITLE]",r[1]):"0"===r[0]?l=l.replace("[TITLE]",webphone_api.stringres.get("not_missed_call")+":"):"1"===r[0]&&(l=l.replace("[TITLE]",webphone_api.stringres.get("not_missed_chat")+":")),l=l.replace("[DESC]",r[2]);var s=StrToInt(r[3]);isNull(s)&&(s=0);var p=GetDateForNotifications(s);l=l.replace("[DATE]",p),l=ReplaceAll(l,"[NOTID]",a.toString()),e+=ReplaceAll(l,"[PAGE]","dialpad"),n+=ReplaceAll(l,"[PAGE]","contactslist"),t+=ReplaceAll(l,"[PAGE]","callhistorylist"),o+=ReplaceAll(l,"[PAGE]","message")}var c=GetParameterInt("notification_count2",0);e.length>0?(webphone_api.$(".not_panel_title").html(webphone_api.stringres.get("not_panel_title")),webphone_api.$(".not_close_btn").html(webphone_api.stringres.get("btn_close")),webphone_api.$("#dialpad_notification_list").html(""),webphone_api.$("#dialpad_notification_list").hasClass("ui-listview")&&webphone_api.$("#dialpad_notification_list").append(e).listview("refresh"),c>0?(webphone_api.$("#dialpad_not_counter").html(c),webphone_api.$("#dialpad_not_counter").show()):(webphone_api.$("#dialpad_not_counter").html(""),webphone_api.$("#dialpad_not_counter").hide()),webphone_api.$("#dialpad_not_btn").show(),webphone_api.$("#contactslist_notification_list").html(""),webphone_api.$("#contactslist_notification_list").hasClass("ui-listview")&&webphone_api.$("#contactslist_notification_list").append(n).listview("refresh"),c>0?(webphone_api.$("#contactslist_not_counter").html(c),webphone_api.$("#contactslist_not_counter").show()):(webphone_api.$("#contactslist_not_counter").html(""),webphone_api.$("#contactslist_not_counter").hide()),webphone_api.$("#contactslist_not_btn").show(),webphone_api.$("#callhistorylist_notification_list").html(""),webphone_api.$("#callhistorylist_notification_list").hasClass("ui-listview")&&webphone_api.$("#callhistorylist_notification_list").append(t).listview("refresh"),c>0?(webphone_api.$("#callhistorylist_not_counter").html(c),webphone_api.$("#callhistorylist_not_counter").show()):(webphone_api.$("#callhistorylist_not_counter").html(""),webphone_api.$("#callhistorylist_not_counter").hide()),webphone_api.$("#callhistorylist_not_btn").show(),webphone_api.$("#messagelist_notification_list").html(""),webphone_api.$("#messagelist_notification_list").hasClass("ui-listview")&&webphone_api.$("#messagelist_notification_list").append(o).listview("refresh"),c>0?(webphone_api.$("#messagelist_not_counter").html(c),webphone_api.$("#messagelist_not_counter").show()):(webphone_api.$("#messagelist_not_counter").html(""),webphone_api.$("#messagelist_not_counter").hide()),webphone_api.$("#messagelist_not_btn").show()):HideNotificationsElements()}catch(u){PutToDebugLogException(2,"common: ShowNotifications2",u)}}function HideNotificationsElements(){webphone_api.$("#dialpad_notification_list").html(""),webphone_api.$("#dialpad_not_counter").html(""),webphone_api.$("#dialpad_not_counter").hide(),webphone_api.$("#dialpad_not_btn").hide(),webphone_api.$("#contactslist_notification_list").html(""),webphone_api.$("#contactslist_not_counter").html(""),webphone_api.$("#contactslist_not_counter").hide(),webphone_api.$("#contactslist_not_btn").hide(),webphone_api.$("#callhistorylist_notification_list").html(""),webphone_api.$("#callhistorylist_not_counter").html(""),webphone_api.$("#callhistorylist_not_counter").hide(),webphone_api.$("#callhistorylist_not_btn").hide(),webphone_api.$("#messagelist_notification_list").html(""),webphone_api.$("#messagelist_not_counter").html(""),webphone_api.$("#messagelist_not_counter").hide(),webphone_api.$("#messagelist_not_btn").hide()}function HideCallNotifications2(){try{if(!isNull(webphone_api.global.notifs)||webphone_api.global.notifs.length>0){for(var e=0;e<webphone_api.global.notifs.length&&webphone_api.global.notifs.length>0;){var n=webphone_api.global.notifs[e];!isNull(n)&&n.length>0&&"0"===n[0]?webphone_api.global.notifs.splice(e,1):e++}SaveNotifications2()}ShowNotifications2()}catch(t){PutToDebugLogException(2,"common: HideCallNotifications2",t)}}function HideMessageNotifications2(){try{if(!isNull(webphone_api.global.notifs)||webphone_api.global.notifs.length>0){for(var e=0;e<webphone_api.global.notifs.length&&webphone_api.global.notifs.length>0;){var n=webphone_api.global.notifs[e];!isNull(n)&&n.length>0&&"1"===n[0]?webphone_api.global.notifs.splice(e,1):e++}SaveNotifications2()}ShowNotifications2()}catch(t){PutToDebugLogException(2,"common: HideMessageNotifications2",t)}}function NotificationOnClick2(e,n){try{if(isNull(e)||e.indexOf("notitem_")<0&&e.indexOf("notmenu_")<0)return void PutToDebugLog(4,"ERROR, common: NotificationOnClick2 invalid id: "+e);if(n){if(e=e.substring(e.indexOf("notmenu_")+8),isNull(e)||!IsNumber(e))return;var t=StrToInt(e);if(t>=0&&t<webphone_api.global.notifs.length)return webphone_api.global.notifs.splice(t,1),void ShowNotifications2()}else{if(e=e.substring(e.indexOf("notitem_")+8),isNull(e)||!IsNumber(e))return;var t=StrToInt(e);if(t>=0&&t<webphone_api.global.notifs.length){var o=webphone_api.global.notifs[t],i=o[0];"0"===i?webphone_api.$.mobile.changePage("#page_callhistorylist",{transition:"none",role:"page"}):"1"===i&&webphone_api.$.mobile.changePage("#page_messagelist",{transition:"none",role:"page"})}}}catch(a){PutToDebugLogException(2,"common: NotificationOnClick2",a)}}function PutNotifications(e,n,t){try{if(GetParameterInt("displaynotification",0)<1)return;if(isNull(t)&&(t=!0),isNull(n))return void PutToDebugLog(2,"ERROR, common: PutNotifications number is NULL");var o=GetParameter("call_notifications"),i=GetParameter("message_notifications");if(o=isNull(o)?"":Trim(o),i=isNull(i)?"":Trim(i),t)if(o.length>2)if(IsNumber(o.charAt(0))){var a=StrToInt(o.charAt(0));o=o.replace(a.toString(),(a+1).toString())}else o="2 "+webphone_api.stringres.get("calls");else o=webphone_api.stringres.get("call_from")+": "+e+", "+n;else if(i.length>2)if(IsNumber(i.charAt(0))){var a=StrToInt(i.charAt(0));i=i.replace(a.toString(),(a+1).toString())}else i="2 "+webphone_api.stringres.get("messages");else i=webphone_api.stringres.get("message_from")+": "+e+", "+n;SaveParameter("call_notifications",o),SaveParameter("message_notifications",i),ShowNotifications()}catch(r){PutToDebugLogException(2,"common: PutNotifications",r)}}function ShowNotifications(){try{var e=GetParameter("call_notifications"),n=GetParameter("message_notifications"),t="";!isNull(e)&&e.length>2&&(t=e+"<br>"),t+=n,PutToDebugLog(2,"EVENT, ShowNotifications: "+t),webphone_api.$("#dialpad_notification").html(t),webphone_api.$("#contactslist_notification").html(t),webphone_api.$("#callhistorylist_notification").html(t),webphone_api.$("#messagelist_notification").html(t),!isNull(t)&&t.length>2?(webphone_api.$("#msglist_title").hide(),webphone_api.$("#messagelist_notification").show(),webphone_api.$("#ctlist_title").hide(),webphone_api.$("#contactslist_notification").show(),webphone_api.$("#chlist_title").hide(),webphone_api.$("#callhistorylist_notification").show(),webphone_api.$("#dialpad_title").hide(),webphone_api.$("#dialpad_notification").show()):(webphone_api.$("#msglist_title").show(),webphone_api.$("#messagelist_notification").hide(),webphone_api.$("#ctlist_title").show(),webphone_api.$("#contactslist_notification").hide(),webphone_api.$("#chlist_title").show(),webphone_api.$("#callhistorylist_notification").hide(),webphone_api.$("#dialpad_title").show(),webphone_api.$("#dialpad_notification").hide())}catch(o){PutToDebugLogException(2,"common: ShowNotifications",o)}}function HideCallNotifications(){try{SaveParameter("call_notifications","");var e=GetParameter("message_notifications");webphone_api.$("#dialpad_notification").html(e),webphone_api.$("#contactslist_notification").html(e),webphone_api.$("#callhistorylist_notification").html(e),webphone_api.$("#messagelist_notification").html(e),!isNull(e)&&e.length>2?(webphone_api.$("#msglist_title").hide(),webphone_api.$("#messagelist_notification").show(),webphone_api.$("#ctlist_title").hide(),webphone_api.$("#contactslist_notification").show(),webphone_api.$("#chlist_title").hide(),webphone_api.$("#callhistorylist_notification").show(),webphone_api.$("#dialpad_title").hide(),webphone_api.$("#dialpad_notification").show()):(webphone_api.$("#msglist_title").show(),webphone_api.$("#messagelist_notification").hide(),webphone_api.$("#ctlist_title").show(),webphone_api.$("#contactslist_notification").hide(),webphone_api.$("#chlist_title").show(),webphone_api.$("#callhistorylist_notification").hide(),webphone_api.$("#dialpad_title").show(),webphone_api.$("#dialpad_notification").hide())}catch(n){PutToDebugLogException(2,"common: HideCallNotifications",n)}}function HideMessageNotifications(){try{SaveParameter("message_notifications","");var e=GetParameter("call_notifications");webphone_api.$("#dialpad_notification").html(e),webphone_api.$("#contactslist_notification").html(e),webphone_api.$("#callhistorylist_notification").html(e),webphone_api.$("#messagelist_notification").html(e),!isNull(e)&&e.length>2?(webphone_api.$("#msglist_title").hide(),webphone_api.$("#messagelist_notification").show(),webphone_api.$("#ctlist_title").hide(),webphone_api.$("#contactslist_notification").show(),webphone_api.$("#chlist_title").hide(),webphone_api.$("#callhistorylist_notification").show(),webphone_api.$("#dialpad_title").hide(),webphone_api.$("#dialpad_notification").show()):(webphone_api.$("#msglist_title").show(),webphone_api.$("#messagelist_notification").hide(),webphone_api.$("#ctlist_title").show(),webphone_api.$("#contactslist_notification").hide(),webphone_api.$("#chlist_title").show(),webphone_api.$("#callhistorylist_notification").hide(),webphone_api.$("#dialpad_title").show(),webphone_api.$("#dialpad_notification").hide())}catch(n){PutToDebugLogException(2,"common: HideMessageNotifications",n)}}function HideAllNotifications(){try{SaveParameter("call_notifications",""),SaveParameter("message_notifications",""),webphone_api.$("#dialpad_notification").html(""),webphone_api.$("#contactslist_notification").html(""),webphone_api.$("#callhistorylist_notification").html(""),webphone_api.$("#messagelist_notification").html(""),webphone_api.$("#msglist_title").show(),webphone_api.$("#messagelist_notification").hide(),webphone_api.$("#ctlist_title").show(),webphone_api.$("#contactslist_notification").hide(),webphone_api.$("#chlist_title").show(),webphone_api.$("#callhistorylist_notification").hide(),webphone_api.$("#dialpad_title").show(),webphone_api.$("#dialpad_notification").hide()}catch(e){PutToDebugLogException(2,"common: HideAllNotifications",e)}}function NotificationOnClick(e){try{var n=GetParameter("call_notifications"),t=GetParameter("message_notifications");if(isNull(n)&&(n=""),isNull(t)&&(t=""),n.length<2&&t.length<2)return;if(n.length>2&&t.length<2)webphone_api.$.mobile.changePage("#page_callhistorylist",{transition:"none",role:"page"});else if(n.length<2&&t.length>2)webphone_api.$.mobile.changePage("#page_messagelist",{transition:"none",role:"page"});else{var o=GetDeviceWidth();o=!isNull(o)&&IsNumber(o)&&o>100?Math.floor(o/1.2):220,o>400?o=400:o<120&&(o=120);var i="",a='<li id="[ITEMID]"><a data-rel="back">[ITEMTITLE]</a></li>',r="";r=a.replace("[ITEMID]","#item_call_history"),r=r.replace("[ITEMTITLE]",webphone_api.stringres.get("callhistory")),i+=r,r="",r=a.replace("[ITEMID]","#item_message_history"),r=r.replace("[ITEMTITLE]",webphone_api.stringres.get("messagehistory")),i+=r,r="";var l='<div id="notification_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+o+"px; min-width: "+Math.floor(.6*o)+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("goto")+'</h1></div><div role="main" class="ui-content adialog_content" style="padding: 0; margin: 0;"><ul id="notifications_ul" data-role="listview" data-inset="true" data-icon="false" style="margin: 0;">'+i+'</ul></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" style="width: 98%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_close")+"</a></div></div>";e=e||function(){},webphone_api.$.mobile.activePage.append(l).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#notifications_ul").off("click","li"),e()}}),webphone_api.$("#notifications_ul").on("click","li",function(e){var n=webphone_api.$(this).attr("id");webphone_api.$("#notification_popup").on("popupafterclose",function(e){webphone_api.$("#notification_popup").off("popupafterclose"),"#item_call_history"===n?webphone_api.$.mobile.changePage("#page_callhistorylist",{transition:"none",role:"page"}):"#item_message_history"===n&&webphone_api.$.mobile.changePage("#page_messagelist",{transition:"none",role:"page"})})})}}catch(s){PutToDebugLogException(2,"common: NotificationOnClick",s)}}function RestartPhone(){try{OpenSettings(!0,2),webphone_api.global.flagWaitforautoprov=!1,!1===IsSDK()&&webphone_api.$.mobile.changePage("#page_dialpad",{transition:"pop",role:"page"}),webphone_api.startInner()}catch(e){PutToDebugLogException(2,"common: RestartPhone",e)}}function ApiWinSaveFile(e,n,t){try{if(!t||"function"!=typeof t)return PutToDebugLog(2,"ERROR, common: ApiWinSaveFile callback not defined"),!1;if(isNull(e)||e.length<1)return PutToDebugLog(2,"ERROR, common: ApiWinSaveFile: filename is NULL"),t(!1),!1;if(isNull(n))return PutToDebugLog(2,"ERROR, common: ApiWinSaveFile: content is NULL"),t(!1),!1;n="BOFFILE"+n+"EOFFILE",e=Trim(e);WinSoftphoneHttpReq(AddJscommport(webphone_api.global.WIN_SOFTPHONE_URL)+"?extcmd_savedata="+e,"POST","data="+n,"",function(e){return t(e),e})}catch(o){PutToDebugLogException(2,"common: ApiWinSaveFile",o)}}function ApiWinLoadFile(e,n){try{
if(!n||"function"!=typeof n)return PutToDebugLog(2,"ERROR, common: ApiWinLoadFile callback not defined"),!1;if(isNull(e)||e.length<1)return PutToDebugLog(2,"ERROR, common: ApiWinLoadFile: filename is NULL"),n(null),!1;e=Trim(e);return WinSoftphoneHttpReq(AddJscommport(webphone_api.global.WIN_SOFTPHONE_URL)+"?extcmd_loaddata="+e,"GET","","",function(e){return isNull(e)||(e=StrDc(e,webphone_api.global.ec_apikey)),n(e),e}),!1}catch(t){PutToDebugLogException(2,"common: ApiWinLoadFile",t)}return n(null),!1}function ApiWinSaveFileNew(e,n,t,o){try{if(!t||"function"!=typeof t)return PutToDebugLog(2,"ERROR, common: ApiWinSaveFileNew callback not defined"),!1;var i=document.getElementById("EXTERNREQUESTELEM");if(isNull(i))return PutToDebugLog(2,"ERROR, common: ApiWinSaveFileNew: html element: EXTERNREQUESTELEM is NULL"),t(!1),!1;if(isNull(e)||e.length<1)return PutToDebugLog(2,"ERROR, common: ApiWinSaveFileNew: filename is NULL"),t(!1),!1;if(isNull(n))return PutToDebugLog(2,"ERROR, common: ApiWinSaveFileNew: content is NULL"),t(!1),!1;n="BOFFILE"+n+"EOFFILEEOFCOMMAND",e=Trim(e);var a="";a=!isNull(o)&&o.length>0?o:"extcmd_savedata="+e,webphone_api.global.bwanswerINCNUMBER++,a=a+"&now="+webphone_api.global.bwanswerINCNUMBER.toString()+"\r\n",PutToDebugLog(2,"EVENT, common: ApiWinSaveFileNew cmd: "+a);var r=a+encodeURIComponent(n);return PutToDebugLog(2,"EVENT, common: ApiWinSaveFileNew encoded: "+r),i.innerHTML=r,t(!0),!0}catch(l){PutToDebugLogException(2,"common: ApiWinSaveFileNew",l)}}function bwanswer(e){try{if(PutToDebugLog(2,"ERROR, bwanswer called; answer: "+e),webphone_api.global.bwanswercallback&&"function"==typeof webphone_api.global.bwanswercallback)if(isNull(e)||e.length<1||e.indexOf("ERROR")>=0)webphone_api.global.bwanswercallback(null),webphone_api.global.bwanswercallback=null;else if(e.length>100||tempfile.length>10){if(tempfile=tempfile=e,tempfile.indexOf("EOFFILE")){var n=decodeURIComponent(tempfile);webphone_api.global.bwanswercallback(n),webphone_api.global.bwanswercallback=null}}else{var n=decodeURIComponent(e);webphone_api.global.bwanswercallback(n),webphone_api.global.bwanswercallback=null}else PutToDebugLog(2,"ERROR, bwanswer: bwanswercallback is NULL")}catch(t){PutToDebugLogException(2,"common: bwanswer",t)}}function ApiWinLoadFileNew(e,n){try{if(!n||"function"!=typeof n)return PutToDebugLog(2,"ERROR, common: ApiWinLoadFileNew callback not defined"),!1;var t=document.getElementById("EXTERNREQUESTELEM");if(isNull(t))return PutToDebugLog(2,"ERROR, common: ApiWinLoadFileNew: html element: EXTERNREQUESTELEM is NULL"),n(!1),!1;if(isNull(e)||e.length<1)return PutToDebugLog(2,"ERROR, common: ApiWinLoadFileNew: filename is NULL"),n(null),!1;e=Trim(e),webphone_api.global.bwanswerINCNUMBER++;var o="extcmd_loaddata="+e+"&now="+webphone_api.global.bwanswerINCNUMBER.toString()+"\r\n";PutToDebugLog(2,"EVENT, common: ApiWinLoadFileNew cmd: "+o+"EOFCOMMAND"),webphone_api.global.bwanswercallback=n,t.innerHTML=o+"EOFCOMMAND",PutToDebugLog(2,"EVENT, common: ApiWinLoadFileNew element.innerHTML: "+t.innerHTML)}catch(i){PutToDebugLogException(2,"common: ApiWinLoadFileNew",i)}}function Exit(){WinSoftphoneHttpReq(AddJscommport(webphone_api.global.WIN_SOFTPHONE_URL)+"?extcmd_exit=true","GET","","",function(e){PutToDebugLog(2,"EVENT, common: Exit response: "+e)})}function CallNumberProtocolHandler(e,n){try{if(isNull(e)||e.length<2||e.length>10)return void PutToDebugLog(2,"ERROR, CallNumberProtocolHandler invalid protocol: "+e);if(isNull(n)||n.length<1)return void PutToDebugLog(2,"ERROR, CallNumberProtocolHandler invalid number: "+n);var t=e+"://"+encodeURIComponent(n),o='<a href="'+t+'" id="make_native_call" style="display: none;">call</a>';webphone_api.$("body").append(o),webphone_api.$("#make_native_call").on("click",function(){var e=webphone_api.$("#make_native_call").attr("href");webphone_api.$("#make_native_call").remove(),window.location=e}),webphone_api.$("#make_native_call").click(),ShowToast(webphone_api.stringres.get("native_call"))}catch(i){PutToDebugLogException(2,"common: CallNumberProtocolHandler",i)}}function EnterKeyPress(){try{return"page_dialpad"===webphone_api.$.mobile.activePage.attr("id")?webphone_api.$("#btn_call").click():"page_settings"===webphone_api.$.mobile.activePage.attr("id")&&webphone_api.$("#adialog_positive").click(),!0}catch(e){PutToDebugLogException(2,"common: EnterKeyPress",e)}return!1}function GetNrOfAcc(){try{if(!isNull(webphone_api.global.sipaccounts))return webphone_api.global.sipaccounts.length}catch(e){PutToDebugLogException(2,"common: GetNrOfAcc",e)}return 1}function SaveAccountsFile(e){try{if(webphone_api.global.flag_delsett>1||!0===GetParameterBool("resetsettings",!1))return void PutToDebugLog(2,"EVENT, SaveAccountsFile DO NOT SAVE, flag delsett is: "+webphone_api.global.flag_delsett.toString()+"; resetsettings is: "+GetParameterBool("resetsettings",!1));if(!e||"function"!=typeof e)return void PutToDebugLog(2,"ERROR, common: SaveAccountsFile callback not defined");var n=GetAccountsFilename();if(isNull(webphone_api.global.aclist))return PutToDebugLog(2,"EVENT, SaveAccountsFile no accounts to be saved"),e(!1),!1;if(isNull(webphone_api.File))return PutToDebugLog(2,"EVENT, SaveAccountsFile File handling module not loaded yet"),e(!1),!1;for(var t="",o=null,i=0;i<webphone_api.global.aclist.length;i++)o=webphone_api.global.aclist[i],isNull(o)||(t.length>2&&(t+="\r\n"),t=t+o[AC_NAME]+","+o[AC_SIPUSERNAME]+","+o[AC_SETTFILE]+","+o[AC_CHFILE]+","+o[AC_ISACTIVE]);PutToDebugLog(2,"EVENT, acfile = "+t),IsWindowsSoftphone()&&(ApiWinSaveFile(n,t,function(n){e(!0)}),webphone_api.File.SaveFile(n,t,webphone_api.global.STORAGE_COOKIE,function(e){PutToDebugLog(2,"EVENT, SaveAccountsFile saved in cookie")})),webphone_api.File.SaveFile(n,t,webphone_api.global.STORAGE_LOCAL,function(n){e(n)})}catch(a){PutToDebugLogException(2,"common: SaveAccountsFile",a)}}function ReadAccountsFile(e){try{if(!e||"function"!=typeof e)return void PutToDebugLog(2,"ERROR, common: ReadAccountsFile callback not defined");var n=GetAccountsFilename();if(isNull(webphone_api.File))return PutToDebugLog(2,"ERROR, ReadAccountsFile File handling module not loaded yet"),e(!1),!1;IsWindowsSoftphone()?ApiWinLoadFile(n,function(t){isNull(t)||Trim(t).length<1?(PutToDebugLog(2,"WARNING, common: ReadAccountsFile no content WinApi"),webphone_api.File.ReadFile(n,webphone_api.global.STORAGE_COOKIE,function(n){if(isNull(n)||Trim(n).length<1){var t=[],o="Account"+GetSipusername(!0),i=Md5Hash(o+GetParameter("serveraddress_user")+GetSipusername()+webphone_api.global.SALT+GetParameter("password")+GetLocationPathName());t[AC_NAME]=o,t[AC_SIPUSERNAME]=GetSipusername(),t[AC_SETTFILE]=i,t[AC_CHFILE]=i+"_ch",t[AC_ISACTIVE]="true",(isNull(t)||t.length<2||t.indexOf(",")<0||t.indexOf("true")<0&&t.indexOf("false")<0)&&PutToDebugLog(2,"WARNING, trying to save invalid acc : "+t),webphone_api.global.aclist.push(t),PutToDebugLog(3,"EEVENT, common ReadAccountsFile(2) save new account file"),SaveAccountsFile(function(e){e?PutToDebugLog(3,"EVENT, common ReadAccountsFile(2) saved successfully"):PutToDebugLog(3,"EVENT, common ReadAccountsFile(2) failed to saved")}),n=o+","+GetSipusername(!0)+","+i+","+i+"_ch,true"}ParseAccountsReadFromFile(n,e)})):ParseAccountsReadFromFile(t,e)}):webphone_api.File.ReadFile(n,webphone_api.global.STORAGE_LOCAL,function(n){if(isNull(n)||Trim(n).length<1){var t=[],o=GetSipusername(!0),i="Account"+o,a=Md5Hash(i+GetParameter("serveraddress_user")+o+webphone_api.global.SALT+GetParameter("password")+GetLocationPathName());t[AC_NAME]=i,t[AC_SIPUSERNAME]=GetSipusername(),t[AC_SETTFILE]=a,t[AC_CHFILE]=a+"_ch",t[AC_ISACTIVE]="true",webphone_api.global.aclist.push(t),PutToDebugLog(3,"EVENT, common ReadAccountsFile(3) save new account file"),SaveAccountsFile(function(e){e?PutToDebugLog(3,"EVENT, common ReadAccountsFile(3) saved successfully"):PutToDebugLog(3,"EVENT, common ReadAccountsFile(3) failed to saved")}),n=i+","+o+","+a+","+a+"_ch,true"}ParseAccountsReadFromFile(n,e)})}catch(t){PutToDebugLogException(2,"common: ReadAccountsFile",t)}}function ParseAccountsReadFromFile(e,n){try{var t=e.split("\r\n");if(isNull(t)||t.length<1)return PutToDebugLog(2,"ERROR, common: ParseAccountsReadFromFile empty content"),n(!1),!1;if(!isNull(webphone_api.global.aclist))for(var o in webphone_api.global.aclist)delete webphone_api.global.aclist[o];for(var i=1,a=0;a<t.length;a++)if(isNull(t[a])||t[a].length<2||t[a].indexOf(",")<0||t[a].indexOf("true")<0&&t[a].indexOf("false")<0)i=2,PutToDebugLog(2,"WARNING, common ParseAccountsReadFromFile broken or invalid account (1) ("+GetAccountsFilename()+":"+parseInt(a,10)+"): "+t[a]);else{if(i=i<2?0:1){for(var r=!0,l=t[a],s=0;s<l.length;s++)if(l[s].charCodeAt(0)<32||l[s].charCodeAt(0)>122){r=!1;break}if(!r)continue;PutToDebugLog(2,"EVENT, broken account file but allowing ("+parseInt(a,10)+"): "+l)}var p=t[a].split(",");webphone_api.global.aclist.push(p)}return i>0&&(2==i?PutToDebugLog(3,"ERROR, common ParseAccountsReadFromFile accounts is corrupt"):PutToDebugLog(3,"WARNING, common ParseAccountsReadFromFile accounts missing"),webphone_api.File.DeleteAllCookies(),webphone_api.File.DeleteFile(GetAccountsFilename(),function(e){PutToDebugLog(2,"EVENT, delsettings accounts result: "+e);var n=[],t="Account"+GetSipusername(!0),o=Md5Hash(t+GetParameter("serveraddress_user")+GetSipusername(!0)+webphone_api.global.SALT+GetParameter("password")+GetLocationPathName());n[AC_NAME]=t,n[AC_SIPUSERNAME]=GetSipusername(),n[AC_SETTFILE]=o,n[AC_CHFILE]=o+"_ch",n[AC_ISACTIVE]="true",webphone_api.global.aclist.push(n),PutToDebugLog(3,"EVENT, common ParseAccountsReadFromFile save new account file "+o),SaveAccountsFile(function(e){e?PutToDebugLog(3,"EVENT, common ParseAccountsReadFromFile Accounts file saved successfully"):PutToDebugLog(2,"ERROR, common ParseAccountsReadFromFile Accounts file save failed")})})),n(!0),!0}catch(c){PutToDebugLogException(2,"common: ParseAccountsReadFromFile",c)}}function GetActiveAccount(){try{if(isNull(webphone_api.global.aclist)||webphone_api.global.aclist.length<1)return PutToDebugLog(2,"EVENT, common GetActiveAccount no available accounts"),null;for(var e=0;e<webphone_api.global.aclist.length;e++)if(!(isNull(webphone_api.global.aclist[e])||webphone_api.global.aclist[e].length<2)){var n=webphone_api.global.aclist[e];if("true"===n[AC_ISACTIVE])return n}}catch(t){PutToDebugLogException(2,"common: GetActiveAccount",t)}return null}function GetActiveAccSettingsFilename(){try{var e=GetActiveAccount();return isNull(e)||e.length<2?(PutToDebugLog(2,"EVENT, common GetActiveAccSettingsFilename cant get filename, probably doesn't exist"),""):isNull(e[AC_SETTFILE])||e[AC_SETTFILE].length<1?(PutToDebugLog(2,"ERROR, common GetActiveAccSettingsFilename no filename"),""):e[AC_SETTFILE]}catch(n){PutToDebugLogException(2,"common: GetActiveAccount",n)}return""}function GetActiveAccCallhistoryFilename(){try{var e=GetActiveAccSettingsFilename();return isNull(e)||e.length<1?"":e+"_ch"}catch(n){PutToDebugLogException(2,"common: GetActiveAccCallhistoryFilename",n)}return""}function GetActiveAccUsername(){try{var e=GetActiveAccount();return isNull(e)||e.length<2?(PutToDebugLog(2,"EVENT, common GetActiveAccUsername cant get active account"),""):isNull(e[AC_SIPUSERNAME])||e[AC_SIPUSERNAME].length<1?GetSipusername():e[AC_SIPUSERNAME]}catch(n){PutToDebugLogException(2,"common: GetActiveAccUsername",n)}return""}function GetAccountsFilename(){try{if(!isNull(sessionaccfilename)&&sessionaccfilename.length>0)return sessionaccfilename;var e=GetConfig("brandid");return(isNull(e)||e.length<1||"-1"==e)&&(e=GetBrandName().toLowerCase()),sessionaccfilename=webphone_api.global.ACCOUNTS_FILENAME+"_"+Md5Hash(GetLocationPathName()+e)}catch(n){PutToDebugLogException(2,"common: GetAccountsFilename",n)}return""}function GetLocationPathName(){try{if(!isNull(lpname)&&lpname.length>0)return lpname;if(upfn_fname<0)if("undefined"!=typeof webphone_api.parameters.usepathinfilenames&&null!==webphone_api.parameters.usepathinfilenames)"false"===webphone_api.parameters.usepathinfilenames.toString()?upfn_fname=0:"true"===webphone_api.parameters.usepathinfilenames.toString()?upfn_fname=3:IsNumber(webphone_api.parameters.usepathinfilenames)&&(upfn_fname=StrToIntDef(webphone_api.parameters.usepathinfilenames,3));else{var e=GetConfig("usepathinfilenames");void 0!==e&&null!==e&&("false"===e.toString()?upfn_fname=0:"true"===e.toString()?upfn_fname=3:IsNumber(e)&&(upfn_fname=StrToIntDef(e,3)))}if((upfn_fname<0||upfn_fname>3)&&(upfn_fname=3),0===upfn_fname)return"";var n=GetProfile();isNull(n)&&(n="");var t=location.href;isNull(t)&&(t=""),t=Trim(t),t=t.toLowerCase();var o=t.indexOf("file:");if(o>=0&&o<5){o=t.indexOf("?"),o>0&&(t=t.substring(0,o)),o=t.indexOf("#"),o>0&&(t=t.substring(0,o));var i="";o=t.lastIndexOf("/"),o>0&&(i=t.substring(o+1),t=t.substring(0,o),(isNull(i)||i.indexOf(".")>0)&&(i="")),lpname=t+i,isNull(lpname)&&(lpname=""),lpname=ReplaceAll(lpname,"/",""),n.length>0&&(lpname=lpname+"_"+n),CanLog(3)&&(lpname.length>0||CanLog(6))&&PutToDebugLog(3,"EVENT, LPname local and profile: "+lpname)}else{var a=location.hostname;if(isNull(a)&&(a=""),1===upfn_fname);else{!isNull(location.pathname)&&location.pathname.toString().length>0&&(2===upfn_fname?a+=location.pathname:a=location.pathname),a=Trim(a);var o=a.indexOf("://");o>0&&(a=a.substring(o+3)),a=Trim(a);var o=a.indexOf("/");if(0===o&&(a=a.substring(1)),(o=a.lastIndexOf("/"))>0){var r=a.substring(o);!isNull(r)&&r.indexOf(".")>0&&(a=a.substring(0,o))}o=a.lastIndexOf("?"),o>0&&(a=a.substring(0,o)),o=a.lastIndexOf("#"),o>0&&(a=a.substring(0,o)),a=ReplaceAll(a,"/",""),isNull(a)&&(a=""),a=Trim(a)}lpname=a,n.length>0&&(lpname=lpname+"_"+n),CanLog(3)&&(lpname.length>0||CanLog(6))&&PutToDebugLog(3,"EVENT, LPname: "+lpname)}return lpname}catch(l){PutToDebugLogException(2,"common: GetLocationPathName",l)}return""}function GetProfile(){try{if(!isNull(currprofile))return currprofile;currprofile="";var e=window.location.href;e=decodeURIComponent(e),e=e.toLowerCase();var n=e.indexOf("profile=");n>0&&(e=e.substring(n+8),n=e.indexOf("&"),n>0&&(e=e.substring(0,n)),n=e.indexOf("#"),n>0&&(e=e.substring(0,n)),e=Trim(e),currprofile=e),currprofile.length<1&&!isNull(webphone_api.parameters)&&!isNull(webphone_api.parameters.profile)&&webphone_api.parameters.profile.length>0&&(currprofile=webphone_api.parameters.profile),currprofile.length<1&&!isNull(GetConfig("profile"))&&GetConfig("profile").length>0&&(currprofile=GetConfig("profile"))}catch(t){PutToDebugLogException(2,"common: GetProfile",t)}return currprofile}function GetSettFilenameSDK(){try{var e=Md5Hash("sdksettfilename"+GetLocationPathName()),n=GetConfig("brandid");return(isNull(n)||n.length<1||"-1"==n)&&(n=GetBrandName().toLowerCase()),e+=n}catch(t){PutToDebugLogException(2,"common: GetSettFilenameSDK",t)}return""}function Encrypt(e,n){try{if(isNull(n)||n.length<1||isNull(e))return PutToDebugLog(2,"ERROR, file: common no key or value"),null;for(var t="",o=0;o<n.length;o++)t+=n.charCodeAt(o).toString();var i=Math.floor(t.length/5),a=parseInt(t.charAt(i)+t.charAt(2*i)+t.charAt(3*i)+t.charAt(4*i)+t.charAt(5*i)),r=Math.ceil(n.length/2),l=Math.pow(2,31)-1;if(a<2)return PutToDebugLog(2,"ERROR, Algorithm cannot find a suitable hash. Please choose a different key. \nPossible considerations are to choose a more complex or longer key."),null;var s=Math.round(1e9*Math.random())%1e8;for(t+=s;t.length>10;)t=(parseInt(t.substring(0,10))+parseInt(t.substring(10,t.length))).toString();t=(a*t+r)%l;for(var p,c="",o=0;o<e.length;o++)p=parseInt(e.charCodeAt(o)^Math.floor(t/l*255)),c+=p<16?"0"+p.toString(16):p.toString(16),t=(a*t+r)%l;for(s=s.toString(16);s.length<8;)s="0"+s;return c+=s}catch(u){PutToDebugLogException(2,"common: Encrypt",u)}return null}function Decrypt(e,n){try{if(isNull(e)||e.length<8)return PutToDebugLog(2,"ERROR, A salt value could not be extracted from the encrypted message because it's length is too short. The message cannot be decrypted."),null;if(isNull(n)||n.length<1)return PutToDebugLog(2,"ERROR, Please enter a key with which to decrypt the message."),null;var t="",o=e.indexOf("almakorte_2_");o>=0&&(e=e.substring(o+12));for(var i=0;i<n.length;i++)t+=n.charCodeAt(i).toString();var a=Math.floor(t.length/5),r=parseInt(t.charAt(a)+t.charAt(2*a)+t.charAt(3*a)+t.charAt(4*a)+t.charAt(5*a)),l=Math.round(n.length/2),s=Math.pow(2,31)-1,p=parseInt(e.substring(e.length-8,e.length),16);for(e=e.substring(0,e.length-8),t+=p;t.length>10;)t=(parseInt(t.substring(0,10))+parseInt(t.substring(10,t.length))).toString();t=(r*t+l)%s;for(var c,u="",i=0;i<e.length;i+=2)c=parseInt(parseInt(e.substring(i,i+2),16)^Math.floor(t/s*255)),u+=String.fromCharCode(c),t=(r*t+l)%s;return u}catch(g){PutToDebugLogException(2,"common: Decrypt",g)}return null}function B64Enc(e){try{if(isNull(e))return PutToDebugLog(2,"ERROR, B6 value could not be extracted"),null;if(e.length<1)return"";var n=e;return n=Base64.encode(n),n=ReplaceAll(n,"=","-"),n=ReplaceAll(n,"+","_"),n=ReplaceAll(n,"/",".")}catch(t){PutToDebugLogException(2,"common: B64Enc",t)}return e}function B64Dec(e){try{if(isNull(e))return"";if(0!=e.indexOf("_BASE64_"))return e;var n=e.replace("_BASE64_","");return n=ReplaceAll(n,"-","="),n=ReplaceAll(n,"_","+"),n=ReplaceAll(n,".","/"),n=Base64.decode(n)}catch(t){PutToDebugLogException(2,"common: B64Dec",t)}return e}function StrEc(e,n,t){var o="";try{if(isNull(e))return PutToDebugLog(2,"ERROR, A salt value could not be extracted(2)"),"";if(e.length<1)return"";if(isNull(n)||n.length<1)return PutToDebugLog(2,"ERROR, Please enter a correct key(2)"),e;if(0===e.indexOf("encrypted")||0===e.indexOf("oenc1_")||0===e.indexOf("alenc1_")||0===e.indexOf("dcid_")||0===e.indexOf("wetrt_")||0===e.indexOf("mcrfs_"))return e;for(var i=0,a=n.length,r=0,l=0;l<e.length;l++){r=e.charCodeAt(l)^n.charCodeAt(i),!0===t&&(r%=128)<0&&(r=95);o+=String.fromCharCode(r),i<a-1?i++:i=0}return o=Base64.encode(o),o=ReplaceAll(o,"=","-"),o=ReplaceAll(o,"+","_"),o=ReplaceAll(o,"/",".")}catch(s){PutToDebugLogException(2,"common: StrEc",s)}return e}function StrDc(e,n,t){var o="";try{if(isNull(e))return PutToDebugLog(2,"ERROR, A salt value could not be extracted(3)"),"";if(e.length<1)return e;if((isNull(n)||n.length<1)&&(n=0==e.indexOf("encrypted__6__")?GetEncV6Key():0==e.indexOf("encrypted__16__")?"1AzbNh5FdLT9m":GetPassphrase(),isNull(n)||n.length<1))return PutToDebugLog(2,"ERROR, Please enter a correct key(3)"),e;if(e=e.toString(),e=Trim(e),0!==e.indexOf("encrypted")&&0!==e.indexOf("oenc1_")&&0!==e.indexOf("alenc1_")&&0!==e.indexOf("dcid_")&&0!==e.indexOf("wetrt_")&&0!==e.indexOf("mcrfs_"))return e;if(e=e.replace("oenc1_",""),e=e.replace("alenc1_",""),e=e.replace("dcid_",""),e=e.replace("wetrt_",""),e=e.replace("encrypted__3__",""),e=e.replace("encrypted__6__",""),e=e.replace("encrypted__16__",""),e=e.replace("mcrfs_",""),e.length<1)return e;if(e.indexOf("encrypted__4")>=0)return e=e.replace("encrypted__4__",""),e=Base64.decode(e);var i=e.indexOf("__");i>0&&(e=e.substring(i+2));i=e.indexOf("__"),i>=0&&(e.substring(0,i),e=e.substring(i+2)),e=ReplaceAll(e,"-","="),e=ReplaceAll(e,"_","+"),e=ReplaceAll(e,".","/"),e=Base64.decode(e);for(var a=0,r=n.length,l=0,s=0;s<e.length;s++){l=e.charCodeAt(s)^n.charCodeAt(a),!0===t&&(l%=128)<0&&(l=95);o+=String.fromCharCode(l),a<r-1?a++:a=0}return o}catch(p){PutToDebugLogException(2,"common: StrDc",p)}return e}function delsettings(e){try{if(isNull(e)&&(e=0),PutToDebugLog(2,"EVENT, common delsettings called, level: "+e.toString()),delsettingswascalled&&e<1&&webphone_api.common.PutToDebugLog(3,"EVENT, ignore delsettings because it was already executed B"),delsettingswascalled=!0,e>2&&(e=2),webphone_api.global.flag_delsett=e,webphone_api.global.resetsett_handled=!0,!isNull(webphone_api.origparameters)&&!isNull(webphone_api.parameters))if(webphone_api.parameters={},Object.assign)Object.assign(webphone_api.parameters,webphone_api.origparameters);else for(var n in webphone_api.origparameters)webphone_api.parameters[n]=webphone_api.origparameters[n];if(2===e){webphone_api.File.DeleteFile(GetActiveAccCallhistoryFilename(),function(e){PutToDebugLog(2,"EVENT, delete call history file: "+GetActiveAccCallhistoryFilename()+" result: "+e)}),webphone_api.global.chlist=[],webphone_api.global.recentlist=[];var t=GetParameter("messagefiles");if(!isNull(t)){for(var o=t.split(","),i=0;i<o.length;i++)if(!(isNull(o[i])||o[i].length<3)){var a=o[i].indexOf("[#");a>0&&(o[i]=o[i].substring(0,a));o[i]}SaveParameter("messagefiles","")}var r=GetConfig("brandid");(isNull(r)||r.length<1||"-1"==r)&&(r=GetBrandName().toLowerCase()),webphone_api.File.DeleteFile(GetAccountsFilename(),function(e){PutToDebugLog(2,"EVENT, delete accounts file result: "+e)}),webphone_api.global.aclist=[],webphone_api.File.DeleteFile(webphone_api.global.CONTACTS_FILENAME+r,function(e){PutToDebugLog(2,"EVENT, delete contacts file result: "+e)}),webphone_api.global.ctlist=[]}webphone_api.File.DeleteAllCookies(),webphone_api.File.DeleteFile(GetActiveAccSettingsFilename(),function(e){PutToDebugLog(2,"EVENT, delete settings file: "+GetActiveAccSettingsFilename()+" result: "+e)}),webphone_api.global.settmap={},HandleSettings("","",function(){}),setTimeout(function(){webphone_api.global.flag_delsett=-1,PutToDebugLog(2,"EVENT, delete settings flag delsett is reset to: 0")},250),OpenSettings(!0,3)}catch(l){PutToDebugLogException(2,"common: delsettings",l)}}function HideClearPassword(e){var n=e,t="";try{if(isNull(e))return PutToDebugLog(2,"WARNING, common: HideClearPassword textin is NULL"),"";var o=n.indexOf("password");if(o>0)return t=n.substring(0,o)+"password: *****",n=n.substring(o,n.length),o=n.indexOf("\r\n"),o<0&&(o=("password "+GetParameter("password")).length)>n.length&&(o=n.length-1),n=n.substring(o,n.length),t+=n}catch(i){PutToDebugLogException(2,"common: HideClearPassword",i)}return e}function UseCustomAutoprov(e){try{var n=GetParameter("customautoprov_url");if(isNull(n)||n.length<3)return!1;if(1==GetParameterInt("customautoprov_repeat",1)&&GetParameterInt("custautoprov_exectimes",0)>0)return!1;var t=GetParameterInt("customautoprov_when",1);return!(!0===e&&2==t||!1===e&&1==t)}catch(o){PutToDebugLogException(2,"common: UseCustomAutoprov",o)}return!1}function GetCustomAutoprov(e){try{var n=GetParameter("customautoprov_url");if(isNull(n)||n.length<5)return PutToDebugLog(2,"ERROR, GetCustomAutoprov invalid url"),void e("ERROR, GetCustomAutoprov invalid url");IsHttps()&&(n=n.replace("http:","https:")),n=UriParser(n,"","","","","return_uri"),PutToDebugLog(3,"EVENT, GetCustomAutoprov url: "+n),acploop++;var t=new XMLHttpRequest;if("withCredentials"in t)t.open("GET",n,!0);else{if("undefined"==typeof XDomainRequest)return PutToDebugLog(2,"ERROR, common: GetCustomAutoprov, CORS not supported"),void e("ERROR, GetCustomAutoprov CORS not supported callback");t=new XDomainRequest,t.open("GET",n)}var o=0;t.onload=function(){try{PutToDebugLog(4,"EVENT, GetCustomAutoprov.onload"),o=19;var n=t.responseText;return o=20,PutToDebugLog(2,"EVENT, GetCustomAutoprov response: "+n),o=21,isNull(n)||n.length<1?(o=23,PutToDebugLog(2,"ERROR, GetCustomAutoprov response is NULL"),void e("")):void e(n)}catch(i){PutToDebugLogException(2,"common: GetCustomAutoprov.onload inner ("+o+")",i),e("ERROR, catch on: common: GetCustomAutoprov.onload inner ("+o+")")}},t.onerror=function(n){var t="";isNull(n)||(t=n.toString(),isNull(n.target)||(t=isNull(n.target.status)?t+" "+n.target.toString():t+" "+n.target.status.toString())),PutToDebugLog(2,"ERROR, common: GetCustomAutoprov: onerror: "+t),e("ERROR, common: GetCustomAutoprov: onerror FAILED")},t.timeout=9e3,t.ontimeout=function(n){PutToDebugLog(2,"ERROR, common: GetCustomAutoprov: Timeout"),e("ERROR, common: GetCustomAutoprov: ontimeout FAILED")},t.send()}catch(i){PutToDebugLogException(2,"common: GetCustomAutoprov",i),e("ERROR, common: GetCustomAutoprov: global failure")}}function RecAutoprovCustom(e){try{PutToDebugLog(3,"EVENT, RecAutoprovCustom: "+e);if(isNull(e)||Trim(e).length<=0||e.toLowerCase().indexOf("error")>=0&&e.length<160)return void PutToDebugLog(3,"ERROR, can't get custom autoprovisioning: "+e);if(e.indexOf("AUTOPROVISIONINGSTART")<0||e.indexOf("AUTOPROVISIONINGEND")<0)return void PutToDebugLog(3,"ERROR, custom autoprovisioning: no AUTOPROVISIONINGSTART and AUTOPROVISIONINGEND found: "+e);e=e.substring(e.indexOf("AUTOPROVISIONINGSTART")+21,e.indexOf("AUTOPROVISIONINGEND")),e=Trim(e);var n=e.split("\n");if(isNull(n)||n.length<1)return void PutToDebugLog(3,"ERROR, custom autoprovisioning invalid received data: "+e);var t=[];t.push("s"),t.push("e"),t.push("r"),t.push("v"),t.push("e"),t.push("r"),t.push("a"),t.push("d"),t.push("d"),t.push("r"),t.push("e"),t.push("s"),t.push("s");for(var o=t.join(""),i=0,a=0;a<n.length;a++)if(!(isNull(n[a])||n[a].length<3||n[a].indexOf(":")<1)){n[a]=Trim(n[a]);var r=Trim(n[a].substring(0,n[a].indexOf(":"))),l=Trim(n[a].substring(n[a].indexOf(":")+1));r=r.toLowerCase(),PutToDebugLog(5,"EVENT, custom autoprovisioning set: "+r+" = "+l),r!==o&&0!==Trim(r).indexOf(o)&&(SaveParameter(r,l),i++)}if(PutToDebugLog(2,"EVENT, RecAutoprovCustom number of configs received: "+i),i>1){var s=GetParameterInt("custautoprov_exectimes",0);s+=1,SaveParameter("custautoprov_exectimes",s.toString())}else PutToDebugLog(5,"WARNING, custom autoprovisioning probably failed because too few parameters found: "+i)}catch(p){PutToDebugLogException(2,"common: RecAutoprovCustom",p)}}function GetAutoprovisioning(e,n){try{if(getuseengine()!==webphone_api.global.ENGINE_WEBRTC&&getuseengine()!==webphone_api.global.ENGINE_FLASH)return PutToDebugLog(2,"ERROR, GetAutoprovisioning invalid engine: "+getuseengine()),void n("");(isNull(e)||e.length<1)&&(e=webphone_api.global.autoprovsrv_1);var t=GetParameter("serveraddress_user");if(isNull(t)||Trim(t).length<1)return PutToDebugLog(2,"ERROR, GetAutoprovisioning no serveraddress_user specified"),void n("ERROR, GetAutoprovisioning no serveraddress_user specified callback");e=e+t+".txt",IsHttps()&&(e=e.replace("http:","https:")),PutToDebugLog(3,"EVENT, GetAutoprovisioning url: "+e),aploop++;var o=new XMLHttpRequest;if("withCredentials"in o)o.open("GET",e,!0);else{if("undefined"==typeof XDomainRequest)return PutToDebugLog(2,"ERROR, common: GetAutoprovisioning, CORS not supported"),void n("ERROR, GetAutoprovisioning CORS not supported callback");o=new XDomainRequest,o.open("GET",e)}var i=0;o.onload=function(){try{PutToDebugLog(4,"EVENT, GetAutoprovisioning.onload"),i=19;var e=o.responseText;return i=20,PutToDebugLog(2,"EVENT, GetAutoprovisioning response: "+e),i=21,isNull(e)||e.length<1?(i=23,PutToDebugLog(2,"ERROR, GetAutoprovisioning response is NULL"),void n("")):void n(e)}catch(t){PutToDebugLogException(2,"common: GetAutoprovisioning.onload inner ("+i+")",t),n("ERROR, catch on: common: GetAutoprovisioning.onload inner ("+i+")")}},o.onerror=function(e){var t="";isNull(e)||(t=e.toString(),isNull(e.target)||(t=isNull(e.target.status)?t+" "+e.target.toString():t+" "+e.target.status.toString())),PutToDebugLog(2,"ERROR, common: GetAutoprovisioning: onerror: "+t),n("ERROR, common: GetAutoprovisioning: onerror FAILED")},o.timeout=9e3,o.ontimeout=function(e){PutToDebugLog(2,"ERROR, common: GetAutoprovisioning: Timeout"),n("ERROR, common: GetAutoprovisioning: ontimeout FAILED")},o.send()}catch(a){PutToDebugLogException(2,"common: GetAutoprovisioning",a),n("ERROR, common: GetAutoprovisioning: global failure")}}function ParseAutoprovisioning(e,n){try{!0===n?SaveParameter("cust_lastautoprov",GetTickCount().toString()):SaveParameter("lastautoprov",GetTickCount().toString()),e.lastIndexOf("EOFLINE")>0&&(e=ReplaceAll(e,"EOFLINE","\r\n")),SaveParameter("serveraddress_orig",GetAPparam("server",e)),SaveParameter("proxyaddress",GetAPparam("proxyserver",e)),SaveParameter("cfgusetunneling",GetAPparam("encryption",e)),SaveParameter("cfgusetunneling",GetAPparam("cfgusetunneling",e)),SaveParameter("techprefix",GetAPparam("techprefix",e)),SaveParameter("creditrequest",GetAPparam("creditrequest",e)),SaveParameter("ratingrequest",GetAPparam("ratingrequest",e)),SaveParameter("accounturi",GetAPparam("accounturi",e)),SaveParameter("newuser",GetAPparam("newuser",e)),SaveParameter("callback",GetAPparam("callback",e)),SaveParameter("p2p",GetAPparam("p2p",e)),SaveParameter("sms",GetAPparam("sms",e)),SaveParameter("brandname",GetAPparam("brandname",e)),SaveParameter("companyname",GetAPparam("companyname",e)),SaveParameter("homepage",GetAPparam("website",e)),SaveParameter("recharge",GetAPparam("recharge",e)),SaveParameter("brandtext",GetAPparam("brandtext",e)),SaveParameter("voicemail",GetAPparam("voicemail",e)),SaveParameter("voicemailnum",GetAPparam("voicemailnum",e)),SaveParameter("messagepopup",GetAPparam("messagepopup",e)),SaveParameter("messagedisplay",GetAPparam("messagedisplay",e)),SaveParameter("encryptionseries",GetAPparam("encryptionseries",e)),SaveParameter("directserveraddress",GetAPparam("directserveraddress",e)),SaveParameter("consoleaddress",GetAPparam("consoleaddress",e)),SaveParameter("httptunnelport",GetAPparam("httptunnelport",e)),SaveParameter("tcptunnelingport",GetAPparam("tcptunnelingport",e)),SaveParameter("rsakey_public_k",GetAPparam("rsakey_public_k",e)),SaveParameter("fastencryptkey",GetAPparam("fastencryptkey",e)),SaveParameter("autotransportdetect",GetAPparam("autotransportdetect",e)),SaveParameter("remotehttpport",GetAPparam("remotehttpport",e)),SaveParameter("encryptionmethod",GetAPparam("encryptionmethod",e)),SaveParameter("cantryudpdirectep",GetAPparam("cantryudpdirectep",e)),SaveParameter("usingmizuserver",GetAPparam("usingmizuserver",e)),SaveParameter("upperserver",GetAPparam("upperserver",e)),SaveParameter("serverinputisupperserver",GetAPparam("serverinputisupperserver",e)),SaveParameter("version",GetAPparam("version",e)),SaveParameter("header",GetAPparam("header",e)),SaveParameter("footer",GetAPparam("footer",e)),SaveParameter("logo",GetAPparam("logo",e)),SaveParameter("supportmail",GetAPparam("supportmail",e)),SaveParameter("supporturl",GetAPparam("supporturl",e)),SaveParameter("advertisement",GetAPparam("advertisement",e)),SaveParameter("helpurl",GetAPparam("helpurl",e)),SaveParameter("licenseurl",GetAPparam("licenseurl",e)),SaveParameter("extramenuurl",GetAPparam("extramenuurl",e)),SaveParameter("extramenutxt",GetAPparam("extramenutxt",e)),SaveParameter("extramenuurl1",GetAPparam("extramenuurl1",e)),SaveParameter("extramenutxt1",GetAPparam("extramenutxt1",e)),SaveParameter("extramenuurl2",GetAPparam("extramenuurl2",e)),SaveParameter("extramenutxt2",GetAPparam("extramenutxt2",e)),SaveParameter("extramenuurl3",GetAPparam("extramenuurl3",e)),SaveParameter("extramenutxt3",GetAPparam("extramenutxt3",e)),SaveParameter("extramenuurl4",GetAPparam("extramenuurl4",e)),SaveParameter("extramenutxt4",GetAPparam("extramenutxt4",e)),SaveParameter("extramenuurl5",GetAPparam("extramenuurl5",e)),SaveParameter("extramenutxt5",GetAPparam("extramenutxt5",e))}catch(t){PutToDebugLogException(2,"common: ParseAutoprovisioning",t)}}function GetAPparam(e,n){try{if(isNull(e)||e.length<1||isNull(n)||n.indexOf(e)<0)return"";var t=n.split("\r\n");if(isNull(t)||t.length<1)return"";for(var o=0;o<t.length;o++)if(!isNull(t[o])&&0===Trim(t[o]).indexOf(e+":")){var i=t[o].substring(t[o].indexOf(e+":")+e.length+1,t[o].length);return Trim(i)}}catch(a){PutToDebugLogException(2,"common: GetAPparam",a)}return""}function RandomInt(e,n){try{var t=n-e+1,o=Math.round(Math.random()*t)%t;return o+=Math.round(e)}catch(i){PutToDebugLogException(2,"common: RandomInt",i)}return 0}function RandomStr(e,n,t){try{if(isNull(e)||e<1)return"";isNull(n)&&(n=!1),isNull(t)&&(t=!1);var o=48;!1===t&&(o=65);for(var i="",a=0;a<5e3;a++){var r=RandomInt(o,122);if(!1===n?ASCII_NRLOWER.indexOf(r)>-1&&(i+=String.fromCharCode(r)):ASCII_ALL.indexOf(r)>-1&&(i+=String.fromCharCode(r)),i.length>=e)return i}return i}catch(l){PutToDebugLogException(2,"common: RandomStr",l)}return 0}function ShowModalLoader(e){try{if(!0===IsSDK())return
;webphone_api.$("body").append('<div class="modalWindow"/>'),!1===IsSDK()&&webphone_api.$.mobile.loading("show",{text:e,textVisible:!0,theme:"b",html:""})}catch(n){PutToDebugLogException(2,"common: ShowModalLoader",n)}}function HideModalLoader(){try{webphone_api.$(".modalWindow").remove(),!1===IsSDK()&&webphone_api.$.mobile.loading("hide")}catch(e){PutToDebugLogException(2,"common: HideModalLoader",e)}}function GetDefaultFontSize(e){var n=0;try{e=e||document.body;var t=document.createElement("span");return t.style.cssText="display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em",t.appendChild(document.createTextNode("M")),e.appendChild(t),n=t.offsetHeight,e.removeChild(t),isNull(n)&&(n=0),n}catch(o){PutToDebugLogException(2,"common: GetDefaultFontSize",o)}return 0}function ShowServerInput(){try{var e=GetParameter("showserverinput");if("0"===e)return!1;if("2"===e)return!0;if("1"===e){var n=webphone_api.parameters.serveraddress,t=GetConfig("serveraddress");return isNull(n)&&(n=""),isNull(t)&&(t=""),!(n.length>0||t.length>0)||"false"!==GetParameter("serverinputisupperserver")}}catch(o){PutToDebugLogException(2,"common: ShowServerInput",o)}return!1}function RequestUserServerInput(e){try{if(isNull(e)&&(e=GetParameter("upperserverfromuser")),"0"===e||"1"===e)return!1;if("3"===e)return!0;if("2"===e)return!!ShowServerInput()}catch(n){PutToDebugLogException(2,"common: RequestUserServerInput",n)}return!1}function GetAllContactsNumbersSipuris(){var e="";try{if(isNull(webphone_api.global.ctlist))return PutToDebugLog(2,"WARNING, common: GetAllContactsNumbersSipuris no numbers to return"),"";if(webphone_api.global.ctlist.length<1)return PutToDebugLog(2,"EVENT, common: GetAllContactsNumbersSipuris no numbers to return"),"";for(var n=0;n<webphone_api.global.ctlist.length;n++){var t=webphone_api.global.ctlist[n];if(!(isNull(t)||t.length<1)){var o=t[CT_NUMBER];if(!(isNull(o)||o.length<1))for(var i=0;i<o.length;i++)!isNull(o[i])&&o[i].length>0&&(e.length>0&&(e+=","),e+=o[i])}}return e}catch(a){PutToDebugLogException(2,"common: GetAllContactsNumbersSipuris",a)}return""}function SetDID(){try{if(sdcalled)return;sdt++,sdt>3&&(sdcalled=!0),setTimeout(function(){SetDID()},8e3);var e=RandomInt(1e4,99999999);WinAPI("API_SetDIDChange",null,e,Md5Hash("didchange"+e))}catch(n){PutToDebugLogException(2,"common: SetDIDX",n)}}function GtUc(){return unlockcodetrick}function GtUct(){return unlockcodetricktogled}function Hasesw(){return!isNull(alsv)&&alsv.length>0||!isNull(alsww)&&alsww.length>0}function Us(){return webphone_api.global.usestorage}function Alwr(){var e=!1;try{if(webphone_api.global.useengine!==webphone_api.global.ENGINE_WEBRTC||isNull(alswrt)||Trim(alswrt).length<1)return!0;var n=GetWebrtcSrvAddr();if(n=n.toLowerCase(),n=GetDomainFromAddress(n),n=n.replace("www.",""),isNull(n)||Trim(n).length<1)return!1;n=Trim(n);var t=[];t.push("l"),t.push("o"),t.push("c"),t.push("a"),t.push("l"),t.push("f"),t.push("i"),t.push("l"),t.push("e");var o=t.join("");t=[],t.push("l"),t.push("o"),t.push("c"),t.push("a"),t.push("l");var i=t.join("");t=[],t.push("1"),t.push("2"),t.push("7"),t.push("."),t.push("0"),t.push("."),t.push("0"),t.push("."),t.push("1");var a=t.join("");t=[],t.push("l"),t.push("o"),t.push("c"),t.push("a"),t.push("l"),t.push("h"),t.push("o"),t.push("s"),t.push("t");var r=t.join(""),l=StrDc(alswrt,alsvkey);if(!isNull(l)&&l.length>0){var s=l.split(",");if(!isNull(s)&&s.length>0)for(var p=0;p<s.length;p++)if(!(isNull(s[p])||s[p].length<1)){if(s[p]=Trim(s[p]),s[p]=s[p].toLowerCase(),n.indexOf(s[p])>=0){e=!0;break}if(s[p]===o&&!0===IsLocalFileSys()||s[p]===r&&(n.indexOf(a)>=0||n.indexOf(r)>=0)||s[p]===i&&(!0===IsLocalFileSys()||n.indexOf(a)>=0||n.indexOf(r)>=0)){e=!0;break}}}return e}catch(c){PutToDebugLogException(2,"common: Alwr",c)}return!1}function Awre(){if(!1===Alwr()){var e=[];e.push("E"),e.push("R"),e.push("R"),e.push("O"),e.push("R"),e.push(","),e.push("w"),e.push("e"),e.push("b"),e.push("r"),e.push("t"),e.push("c"),e.push(" "),e.push("s"),e.push("e"),e.push("r"),e.push("v"),e.push("e"),e.push("r"),e.push(" "),e.push("n"),e.push("o"),e.push("t"),e.push(" "),e.push("a"),e.push("l"),e.push("l"),e.push("o"),e.push("w"),e.push("e"),e.push("d"),e.push("_"),e.push("1");var n=e.join("");setTimeout(function(){PutToDebugLog(1,n)},1881)}}function Alwm(){var e=!1,n=!1,t=0;try{if(t=1,void 0===alsww||isNull(alsww)||null==alsww||Trim(alsww).length<2)return void 0!==malsx2&&null!=malsx2&&44===malsx2;al_isreliable=!1,al2_isreliable=!1,t=2;var o="",i=GetParameter("aldm");t=3,(isNull(i)||Trim(i).length<2)&&(i=window.location.href),isNull(i)||Trim(i).length<2?i="":(t=4,i=decodeURIComponent(i),isNull(i)||(o=i),al_isreliable=!0,0!=i.toLowerCase().indexOf("http")&&0!=i.toLowerCase().indexOf("file")&&(al_isreliable=!1),t=5,i=GetDomainFromURL(i),isNull(i)&&(i=""),i=i.toLowerCase(),i=Trim(i)),t=6;var a=webphone_api.getbasedir2();if(isNull(a)&&(a=""),a.length>1&&(t=7,a=decodeURIComponent(a),isNull(a)||(o=o.length>0?o+","+a:a),al2_isreliable=!0,0!=a.toLowerCase().indexOf("http")&&0!=a.toLowerCase().indexOf("file")&&(al2_isreliable=!1),t=8,a=GetDomainFromURL(a),isNull(a)&&(a=""),a=a.toLowerCase(),a=Trim(a)),t=9,!isNull(alswwp)&&alswwp.length>1&&o.length>0){t=10;var r=StrDc(alswwp,alsvkey);if(r=r.toLowerCase(),o=o.toLowerCase(),t=11,o.indexOf(",")>=0){t=12;var l=r.split(",");if(!isNull(l)&&l.length>0){t=13;for(var s=0;s<l.length;s++)if(!(isNull(l[s])||l[s].length<2)&&(l[s]=Trim(l[s]),o.indexOf(l[s])>=0))return!0}}else if(o.indexOf(r)>=0)return!0}if(t=14,(isNull(a)||a.length<2)&&(a=i),(isNull(a)||a.length<2)&&(n=!0),(isNull(i)||i.length<2)&&(i=a),isNull(i)||i.length<2)return!0;al_isreliable||!IsIPAddrress(i)&&!IsDomainName(i)||(al_isreliable=!0),al2_isreliable||!IsIPAddrress(a)&&!IsDomainName(a)||(al2_isreliable=!0),t=15;var p=[];p.push("l"),p.push("o"),p.push("c"),p.push("a"),p.push("l"),p.push("f"),p.push("i"),p.push("l"),p.push("e");var c=p.join("");p=[],p.push("l"),p.push("o"),p.push("c"),p.push("a"),p.push("l");var u=p.join("");p=[],p.push("1"),p.push("2"),p.push("7"),p.push("."),p.push("0"),p.push("."),p.push("0"),p.push(".");var g=p.join("");p=[],p.push("l"),p.push("o"),p.push("c"),p.push("a"),p.push("l"),p.push("h"),p.push("o"),p.push("s"),p.push("t");var h=p.join("");if(t=16,(i.indexOf("localhost")>=0||i.indexOf("127.0.0.1")>=0)&&(!al2_isreliable||a.indexOf("localhost")>=0||a.indexOf("127.0.0.1")>=0))return!0;if((a.indexOf("localhost")>=0||a.indexOf("127.0.0.1")>=0)&&(!al_isreliable||i.indexOf("localhost")>=0||i.indexOf("127.0.0.1")>=0))return!0;t=17;var m=StrDc(alsww,alsvkey);if(!isNull(m)&&m.length>0){t=18;var l=m.split(",");if(t=19,!isNull(l)&&l.length>0){t=20;for(var s=0;s<l.length;s++)isNull(l[s])||l[s].length<2||(l[s]=Trim(l[s]),l[s]=l[s].toLowerCase(),!1===e&&(i.indexOf(l[s])>=0&&(e=!0),(l[s]===c&&!0===IsLocalFileSys()||l[s]===h&&(i.indexOf(g)>=0||i.indexOf(h)>=0)||l[s]===u&&(!0===IsLocalFileSys()||i.indexOf(g)>=0||i.indexOf(h)>=0))&&(e=!0)),!1===n&&(a.indexOf(l[s])>=0&&(n=!0),(l[s]===c&&!0===IsLocalFileSys()||l[s]===h&&(a.indexOf(g)>=0||a.indexOf(h)>=0)||l[s]===u&&(!0===IsLocalFileSys()||a.indexOf(g)>=0||a.indexOf(h)>=0))&&(n=!0)))}}return t=21,!(!0!==e||!0!==n&&al2_isreliable)||!(!0!==n||!0!==e&&al_isreliable)}catch(d){PutToDebugLogException(2,"common: Alwm "+t.toString(),d)}return!0}function Awe(){if(!1===Alwm()){var e=[];e.push("E"),e.push("R"),e.push("R"),e.push("O"),e.push("R"),e.push(","),e.push("W"),e.push("e"),e.push("b"),e.push("s"),e.push("e"),e.push("r"),e.push("v"),e.push("e"),e.push("r"),e.push(" "),e.push("n"),e.push("o"),e.push("t"),e.push(" "),e.push("a"),e.push("l"),e.push("l"),e.push("o"),e.push("w"),e.push("e"),e.push("d"),e.push("_"),e.push("1");var n=e.join(""),t=n,o=n;try{var i=GetParameter("aldm");(isNull(i)||Trim(i).length<1)&&(i=window.location.href),isNull(i)||Trim(i).length<1?i="":(i=decodeURIComponent(i),i=GetDomainFromURL(i),isNull(i)&&(i=""),i=i.toLowerCase(),i=Trim(i));var a=webphone_api.getbasedir2();isNull(a)&&(a=""),a=decodeURIComponent(a),a=GetDomainFromURL(a),isNull(a)&&(a=""),a=a.toLowerCase(),a=Trim(a),o+=" ",o+="(",o+="a ",o+=": ",o+=alsww,o+=")",n+=" ",n+="(",n+="d ",n+=": ",n+=i,n+=",",n+=al_isreliable.toString(),n+=",",n+=a,n+=",",n+=al2_isreliable.toString(),n+=",",n+=webphone_api.getbasedir2(),n+=",",n+=window.location.href,n+=",",n+=window.location,n+=",",n+=window.location.domain,n+=")"}catch(r){PutToDebugLogException(2,"common: CheckDIDXInnerA",r)}setTimeout(function(){PutToDebugLog(2,n)},1881),setTimeout(function(){PutToDebugLog(2,o)},1889),setTimeout(function(){PutToDebugLog(1,t)},1353),setTimeout(function(){ShowToast(t)},1246)}}function Awb(){var e=Alwm();return!1===e&&Awe(),e=Alwr(),!1===e&&Awre(),e}function Awb2(){var e=Alwm();return!1===e&&Awe(),e}function CheckDID(e,n){var t=!1;try{if(isNull(e)||e.length<1)return!0!==n;if(e=e.toLowerCase(),AddressHasPort(e)&&(e=GetIPFromAddressSimple(e)),e=Trim(e),isNull(e)||e.length<1)return!0!==n;if(e.indexOf(".")<1&&e.indexOf(":")<1)return!0;var o=e;!IsIPAddrress(e)&&e.indexOf(".")>0&&(o=HostToIPQuick(e),(isNull(o)||o.length<1)&&(o=e));var i=[];i.push("l"),i.push("a"),i.push("n"),i.push("i"),i.push("p");var a=i.join("");i=[],i.push("l"),i.push("o"),i.push("c"),i.push("a"),i.push("l"),i.push("f"),i.push("i"),i.push("l"),i.push("e");var r=i.join("");i=[],i.push("l"),i.push("o"),i.push("c"),i.push("a"),i.push("l");var l=i.join("");i=[],i.push("1"),i.push("2"),i.push("7"),i.push("."),i.push("0"),i.push("."),i.push("0"),i.push("."),i.push("1");var s=i.join("");i=[],i.push("l"),i.push("o"),i.push("c"),i.push("a"),i.push("l"),i.push("h"),i.push("o"),i.push("s"),i.push("t");var p=i.join(""),c=[];c.push("w"),c.push("e"),c.push("b"),c.push("s"),c.push("e"),c.push("r"),c.push("v"),c.push("e"),c.push("r");var u=c.join("");if(void 0===alsv||null==alsv||Trim(alsv).length<1)return void 0!==malsx1&&null!=malsx1&&77===malsx1;if(!(!isNull(alsv)&&alsv.length>0||!isNull(alsvir1)&&alsvir1.length>0||!isNull(alsvir2)&&alsvir2.length>0||!isNull(alsvir3)&&alsvir3.length>0))return!0!==n;var g=StrDc(alsv,alsvkey);if(!isNull(g)&&g.length>0){var h=g.split(",");if(!isNull(h)&&h.length>0){for(var m=0;m<h.length;m++)if(!(isNull(h[m])||h[m].length<1)&&(h[m]=Trim(h[m]),h[m]=h[m].toLowerCase(),u===h[m])){var d=e.indexOf("sip.");0===d&&(e=e.substring(d+4));var b=GetDomainFromURL(window.location.href);if(!isNull(b)&&b.length>=3&&(b=b.toLowerCase(),b=Trim(b),d=b.indexOf("www."),0===d&&(b=b.substring(d+4)),e===b||o===b))return!0}for(var m=0;m<h.length;m++)if(!(isNull(h[m])||h[m].length<1)){if(h[m]=Trim(h[m]).toLowerCase(),e.indexOf(h[m])>=0||o.indexOf(h[m])>=0){t=!0;break}if(h[m]===a&&(IsLanIP(e)||IsLanIP(o))){t=!0;break}if(h[m]===r&&!0===IsLocalFileSys()||h[m]===p&&(e.indexOf(s)>=0||e.indexOf(p)>=0)||h[m]===l&&(!0===IsLocalFileSys()||e.indexOf(s)>=0||e.indexOf(p)>=0)){t=!0;break}}if(!t)for(var m=0;m<h.length;m++)if(!(isNull(h[m])||h[m].length<1||(h[m]=Trim(h[m]).toLowerCase(),!IsIPAddrress(h[m])&&h[m].indexOf(".")>0&&(h[m]=HostToIPQuick(h[m]),isNull(h[m])||h[m].length<1)))){if(e.indexOf(h[m])>=0||o.indexOf(h[m])>=0){t=!0;break}if(h[m]===a&&(IsLanIP(e)||IsLanIP(o))){t=!0;break}if(h[m]===r&&!0===IsLocalFileSys()||h[m]===p&&(e.indexOf(s)>=0||e.indexOf(p)>=0)||h[m]===l&&(!0===IsLocalFileSys()||e.indexOf(s)>=0||e.indexOf(p)>=0)){t=!0;break}}}}if(!t&&!isNull(alsvir1)&&Trim(alsvir1).length>2){var _=StrDc(alsvir1,alsvkey);_=Trim(_),_=_.toLowerCase(),0===e.indexOf(_)&&(t=!0),0===o.indexOf(_)&&(t=!0)}if(!t&&!isNull(alsvir2)&&Trim(alsvir2).length>2){var f=StrDc(alsvir2,alsvkey);f=Trim(f),f=f.toLowerCase(),0===e.indexOf(f)&&(t=!0),0===o.indexOf(f)&&(t=!0)}if(!t&&!isNull(alsvir3)&&Trim(alsvir3).length>2){var w=StrDc(alsvir3,alsvkey);w=Trim(w),w=w.toLowerCase(),0===e.indexOf(w)&&(t=!0),0===o.indexOf(w)&&(t=!0)}}catch(v){PutToDebugLogException(2,"common: CheckDIDX",v)}return t}function Ch(){try{if(alsvu1.length<1&&alsvu2.length<1&&alsvu3.length<1)return!0;if(hua.length<1&&(hua=GetSipHeaderInternal("User-agent",!0)),hsrv.length<1&&(hsrv=GetSipHeaderInternal("Server",!0)),hsrvx.length<1&&(hsrvx=GetSipHeaderInternal("X-Server",!0)),webphone_api.global.useengine!==webphone_api.global.ENGINE_WEBRTC)return!0;if(hua.length<1&&hsrv.length<1)return!1;hua=hua.toLowerCase(),hsrv=hsrv.toLowerCase(),hsrvx=hsrvx.toLowerCase();var e=alsvu1,n=alsvu2,t=alsvu3;isNull(e)&&(e=""),isNull(n)&&(n=""),isNull(t)&&(t=""),e=StrDc(e,alsvkey),n=StrDc(n,alsvkey),t=StrDc(t,alsvkey),e=e.toLowerCase(),n=n.toLowerCase(),t=t.toLowerCase();var o=!1;if(hua.length>0&&(e.length>0&&hua.indexOf(e)>=0?o=!0:n.length>0&&hua.indexOf(n)>=0?o=!0:t.length>0&&hua.indexOf(t)>=0&&(o=!0)),hsrv.length>0&&(e.length>0&&hsrv.indexOf(e)>=0?o=!0:n.length>0&&hsrv.indexOf(n)>=0?o=!0:t.length>0&&hsrv.indexOf(t)>=0&&(o=!0)),hsrvx.length>0&&(e.length>0&&hsrvx.indexOf(e)>=0?o=!0:n.length>0&&hsrvx.indexOf(n)>=0?o=!0:t.length>0&&hsrvx.indexOf(t)>=0&&(o=!0)),void 0===alsv||null==alsv||Trim(alsv).length<1)return void 0!==malsx1&&null!=malsx1&&77===malsx1;if(!1===o&&!isNull(alsv)&&alsv.length>2){var i=GetParameter("serveraddress_user");(isNull(i)||i.length<2)&&(i=GetParameter("serveraddress")),o=CheckDID(i,!0)}return o}catch(a){PutToDebugLogException(2,"common: Ch",a)}return!0}function Loa(){if(lic_onlyandroidvideo<1)return!0;if(null===myLoaCachedvalueFrom){var e=[];e.push("c"),e.push("a"),e.push("l"),e.push("l"),e.push("e"),e.push("r"),e.push("e"),e.push("x"),e.push("t"),e.push("e"),e.push("n"),e.push("s"),e.push("i"),e.push("o"),e.push("n"),e.push("="),e.push("3"),e.push("4"),e.push("5");var n=e.join("");e=[],e.push("A"),e.push("n"),e.push("d"),e.push("r"),e.push("o"),e.push("i"),e.push("d");var t=e.join("");e=[],e.push("w"),e.push("e"),e.push("b"),e.push("v"),e.push("o"),e.push("i"),e.push("p"),e.push("p"),e.push("h"),e.push("o"),e.push("n"),e.push("e"),e.push("."),e.push("c"),e.push("o"),e.push("m");var o=e.join("");e=[],e.push("a"),e.push("r"),e.push("t"),e.push("c"),e.push("v"),e.push("i"),e.push("d"),e.push("e"),e.push("o"),e.push("c"),e.push("a"),e.push("l"),e.push("l");var i=e.join(""),a=window.location.href;myLoaCachedvalueFrom=!(GetOs()!==t||a.indexOf(o)<1||a.indexOf(i)<1||a.indexOf(n)<1)}return myLoaCachedvalueFrom}function Glsp(){var e=GetOs();e=e.toLowerCase();var n=[];n.push("w"),n.push("i"),n.push("n"),n.push("d"),n.push("o"),n.push("w"),n.push("s");var t=n.join("");n=[],n.push("m"),n.push("a"),n.push("c");var o=n.join("");n=[],n.push("l"),n.push("i"),n.push("n"),n.push("u"),n.push("x");var i=n.join("");return n=[],e===t||e===o||e===i||!(lic_smartphone<1)&&!(lic_smartphone<2&&lversion<2)}function Glv(){return lversion}function Glss(){return!(lic_screensharing<1)&&!(lic_screensharing<2&&lversion<2)}function Glbr(){return!(lic_balancerating<1)&&!(lic_balancerating<2&&lversion<2)}function Glop(){return!(lic_opus<1)&&!(lic_opus<2&&lversion<2)}function Glpr(){return!(lic_presence<1)&&!(lic_presence<2&&lversion<2)}function Glcr(){return!(lic_callrecord<1)&&!(lic_callrecord<2&&lversion<2)}function Glcf(){var e=[];return e.push("h"),e.push("a"),e.push("s"),e.push("c"),e.push("o"),e.push("n"),e.push("f"),e.push("e"),e.push("r"),e.push("e"),e.push("n"),e.push("c"),e.push("e"),!(!1===GetParameterBool(e.join(""),!0)||lic_conference<1||lic_conference<2&&lversion<2)}function Glft(){return!(lic_filetransfer<1)&&!(lic_filetransfer<2&&lversion<1)}function Glvd(){return!(lic_video<1)&&!(lic_video<2&&lversion<2)}function Glt(){return!(lic_transfer<1)&&!(lic_transfer<2&&lversion<1)}function Te(){try{var e=1012,n=11,t=25;e*=2;try{e=StrToInt(StrDc(usestoragetry,alsvkey))}catch(l){return!1}try{n=StrToInt(StrDc(usestoragetrm,alsvkey))}catch(l){n=11}try{t=StrToInt(StrDc(usestoragetrd,alsvkey))}catch(l){t=25}if(e>2300)return!1;var o=new Date,i=o.getFullYear(),a=o.getMonth(),r=o.getDate();return a+=1,i>e||(i===e&&a>n||i===e&&a===n&&r>=t)}catch(l){PutToDebugLogException(2,"common: te",l)}return!1}function Te2(){try{var e=1012,n=11,t=gtriald;e*=2;try{e=StrToInt(StrDc(usestoragetry2,alsvkey))}catch(s){return!1}try{n=StrToInt(StrDc(usestoragetrm2,alsvkey))}catch(s){n=11}if(e>2300)return!1;var o=new Date,i=o.getFullYear(),a=o.getMonth(),r=o.getDate();if(a+=1,t<0||t>27){var l=GetParameterInt("stgrnd",-1);(l<0||l>27)&&(l=RandomInt(1,27),SaveParameter("stgrnd",l)),t=l,gtriald=l}return i>e||(i===e&&a>n||i===e&&a===n&&r>=t)}catch(s){PutToDebugLogException(2,"common: te2",s)}return!1}function Ted(){try{var e=1012,n=11,t=25;e*=2;try{e=StrToInt(StrDc(usestoragetry,alsvkey))}catch(s){return 1e4}try{n=StrToInt(StrDc(usestoragetrm,alsvkey))}catch(s){n=11}try{t=StrToInt(StrDc(usestoragetrd,alsvkey))}catch(s){t=25}if(e>2300)return 1e4;var o=new Date,i=o.getFullYear(),a=o.getMonth(),r=o.getDate();a+=1;var l=183;return l=2*l*(e-i),l+=30*(n-a),l+=t-r}catch(s){PutToDebugLogException(2,"common: ted",s)}return 1e4}function Strl(e){try{if(void 0!==e&&null!==e&&IsNumber(e)||(e=9,e*=10),Ted()<e){if(null===days_since_deploy){days_since_deploy=130;var n=GetConfig("lastdeploydate");if(!isNull(n)&&n.length>0&&n.indexOf("/")>0){var t=StrToIntDef(Trim(n.substring(0,n.indexOf("/"))),1);n=n.substring(n.indexOf("/")+1);var o=StrToIntDef(Trim(n.substring(0,n.indexOf("/"))),1);n=n.substring(n.indexOf("/")+1);var i=StrToIntDef(Trim(n.substring(0,n.indexOf(" "))),2021),a=new Date,r=a.getFullYear(),l=a.getMonth(),s=a.getDate();return l+=1,days_since_deploy=183,days_since_deploy=2*days_since_deploy*(r-i),days_since_deploy+=30*(l-t),!((days_since_deploy+=s-o)>e+10)}return!0}return!(days_since_deploy>e+10)}}catch(p){PutToDebugLogException(2,"common: strl",p)}return!1}function GetFp(){var e=webphone_api.global.pgw_selected;return e<0&&(CanLog(5)&&PutToDebugLog(5,"EVENT, (warn) no selected gw at getfp. using the first/default"),e=0),"udp://"+PGW_Get(e,PGW_ADDRESS)+":"+PGW_Get(e,PGW_SIPPORT).toString()}function GetWp(e,n){try{isNull(n)&&(n=!0),(isNull(e)||e.toString().length<1)&&webphone_api.global.pgw_selected>=0&&(e=webphone_api.global.pgw_selected),(isNull(e)||e.toString().length<1)&&(e="0",n&&CanLog(5)&&PutToDebugLog(5,"EVENT, no servertype at getwp. using the default"));var t=PGW_Get(e,PGW_ADDRESS);return t.length<1?(n&&CanLog(5)&&PutToDebugLog(5,"EVENT, (warn) no pgw at getwp for "+e),t):(t+="/mfstwebsock",t=!0===BrowserRequiresHttps(!1,!1)?"wss://"+t:"ws://"+t)}catch(o){PutToDebugLogException(2,"common: GetWp",o)}return""}function GetWpS(e){try{(isNull(e)||e.toString().length<1)&&webphone_api.global.pgw_selected>=0&&(e=webphone_api.global.pgw_selected),(isNull(e)||e.toString().length<1)&&(e="0",CanLog(5)&&PutToDebugLog(5,"EVENT, (warn) no servertype at getwps. using the default"));var n=PGW_Get(e,PGW_ADDRESS);return n.length<1?(CanLog(5)&&PutToDebugLog(5,"EVENT, (warn) no pgw at getwps for "+e),n):"wss://"+n+"/mfstwebsock"}catch(t){PutToDebugLogException(2,"common: GetWpS",t)}return""}function GetPassphrase(){if(pphe.length>0)return pphe;try{return pphe=GetConfig("passphrase",!1),isNull(pphe)||pphe.length<1?(pphe="",""):(pphe.indexOf("dcid_")>=0&&(pphe=StrDc(pphe,alsvkey),isNull(pphe)&&(pphe="")),pphe)}catch(e){PutToDebugLogException(2,"common: GetPassph",e)}return""}function GetEncV6Key(){if(encv6key.length>0)return encv6key;try{return isNull(encv6key_encrypted)||encv6key_encrypted.length<1?"":(encv6key=encv6key_encrypted,encv6key.indexOf("dcid_")>=0&&(encv6key=StrDc(encv6key,alsvkey),isNull(encv6key)&&(encv6key="")),encv6key)}catch(e){PutToDebugLogException(2,"common: GetEV6",e)}return""}function SvCont(){try{var e=[];e.push("m"),e.push("i"),e.push("z"),e.push("u"),e.push("-"),e.push("v"),e.push("o"),e.push("i"),e.push("p");var n=e.join(""),t=GetParameter("serveraddress_user"),o=GetParameter("serveraddress_orig"),i=GetParameter("serveraddress");if(t.length>0&&t.toLowerCase().indexOf(n)||o.length>0&&o.toLowerCase().indexOf(n)||i.length>0&&i.toLowerCase().indexOf(n))return!0}catch(a){PutToDebugLogException(2,"common: SvCont",a)}return!1}function WbCont(){try{var e=[];e.push("m"),e.push("i"),e.push("z"),e.push("u"),e.push("-"),e.push("v"),e.push("o"),e.push("i"),e.push("p");var n=e.join(""),t=document.location.hostname;if(!isNull(t)&&t.length>2&&(t=t.toLowerCase(),t.indexOf(n)>=0))return!0}catch(o){PutToDebugLogException(2,"common: WbCont",o)}return!1}function IsServiceInstalled(e,n){function t(e){function n(e){if(isNull(h)||h.length<5)return o(e),!1;if(t)return!1;t=!0,CanLog(2)&&(PutToDebugLog(2,"EVENT, common: IsServiceInstalled.CheckWebsocket3 exec: "+e),PutToDebugLog(2,"EVENT, IsServiceInstalled url_3: "+h));try{wsocket3&&wsocket3.close&&wsocket3.close(),wsocket3=null,wsocket3=new WebSocket(h),wsocket3.binaryType="arraybuffer",wsocket3.onopen=function(){ws3ready=!0,wready=!0,i(wsocket3,3,h)},wsocket3.onclose=function(){a(3)},wsocket3.onerror=function(e){r(3,e),o("onerror")},wsocket3.onmessage=function(e){l(3,e)},m=!0}catch(n){PutToDebugLogException(2,"IsServiceInstalled.CheckWebsocket2 failed to connect to: "+h,n),o("onexception")}isNull(wstimer3)||clearTimeout(wstimer3),wstimer3=setTimeout(function(){ws3ready||o("ontimer")},srvinstalled_timeout)}if(isNull(g)||g.length<5)return o(e,u),!1;if(d)return!1;d=!0,CanLog(2)&&(PutToDebugLog(2,"EVENT, common: IsServiceInstalled.CheckWebsocket2 exec: "+e),PutToDebugLog(2,"EVENT, IsServiceInstalled url_2: "+g));try{wsocket2&&wsocket2.close&&wsocket2.close(),wsocket2=null,wsocket2=new WebSocket(g),wsocket2.binaryType="arraybuffer",wsocket2.onopen=function(){ws2ready=!0,wready=!0,i(wsocket2,2,g)},wsocket2.onclose=function(){a(2)},wsocket2.onerror=function(e){r(2,e),n("onerror")},wsocket2.onmessage=function(e){l(2,e)},m=!0}catch(s){PutToDebugLogException(2,"IsServiceInstalled.CheckWebsocket2 failed to connect to: "+g,s),n("onexception")}isNull(wstimer2)||clearTimeout(wstimer2),wstimer2=setTimeout(function(){ws2ready||n("ontimer")},srvinstalled_timeout);var t=!1}function o(e,n){try{if(!0===NSMacLinEnabled())return PutToDebugLog(2,"EVENT, IsServiceInstalled.CheckHttpPolling returned FALSE because http polling is not available on: "+GetOs()),ExecSrvInstalledCallback(!1),!1;PutToDebugLog(2,"EVENT, common: IsServiceInstalled.CheckHttpPolling exec: "+e+"; addr: "+u);var t="";if(!isNull(n)&&n.length>5&&(t=n),isNull(t)||t.length<5)for(var o=0;o<s.length;o++)if(!(isNull(s[o])||!0===IsHttps&&s[o].indexOf("wss://")<0)){t=s[o];break}t=t.toLowerCase(),t=t.replace("wss:","https:"),t=t.replace("ws:","http:"),t=t.replace("msstwebsock","extcmd_test"),!0===IsHttps()&&(t=t.replace("http:","https:")),PutToDebugLog(2,"EVENT, IsServiceInstalled try ajax, url: "+t),webphone_api.$.ajax(t).done(function(e,n,t){if(wready=!0,PutToDebugLog(2,"EVENT, common: IsServiceInstalled ajax connected, status: "+n+"; msg: "+e),!isNull(e)&&(e=e.toLowerCase(),e.indexOf("error")<0)){var o=e.indexOf("apiresult:");if(o>0&&(e=e.substring(o+10)),!isNull(e)&&e.length>0&&!webphone_api.global.nsupdatepending)if(e.indexOf("version")<0)CanLog(2)&&PutToDebugLog(2,"EVENT, common: IsServiceInstalled.onmessage, service upgrade needed(1): "+GetMinServiceVersion().toString()),setTimeout(function(){EngineForcedInstall("ns",webphone_api.stringres.get("service_update")),webphone_api.global.nsupdatepending=!0},5e3);else{var i=e.substring(e.indexOf("version")+7);isNull(i)&&(i=""),i=i.replace(":",""),i=Trim(i),i.indexOf(" ")>0&&(i=Trim(i.substring(0,i.indexOf(" ")))),!isNull(i)&&IsNumber(i)&&SaveParameter("srvupgrade_currversion_extcmd_test",i)}}return PutToDebugLog(2,"EVENT, common: IsServiceInstalled AJAX it is installed"),ExecSrvInstalledCallback(!0),!0}).fail(function(e,n,t){return wready=!1,PutToDebugLog(2,"EVENT, Note: it is not a webphone bug if the connection attempt will fail. We are just checking the availability of the local NS engine here"),PutToDebugLog(2,"EVENT, common: IsServiceInstalled ajax failed, status: "+n+"; error: "+t),ExecSrvInstalledCallback(!1),!1})}catch(i){return PutToDebugLogException(2,"IsServiceInstalled.CheckHttpPolling",i),ExecSrvInstalledCallback(!1),!1}}function i(e,n,t){if(CanLog(2)&&PutToDebugLog(2,"EVENT, common: IsServiceInstalled.onopen, connection ready: "+n+"; addr: "+t),!isNull(t)&&t.length>0&&(SaveParameter("last_good_ns_plugin_url",t),lastgoodnspluginurl=t.toString()),isNull(e))return void PutToDebugLog(2,"ERROR, common: IsServiceInstalled.onopen websocket is NULL");if(e!==wsocket&&e!==wsocket2&&e!==wsocket3)return void PutToDebugLog(2,"ERROR, common: IsServiceInstalled.onopen invalid websocket connection");e===wsocket?(void 0!==wsocket&&null!==wsocket||PutToDebugLog(2,"ERROR, _common: IsServiceInstalled wsocket is NULL"),wsocket.send("extcmd_test")):e===wsocket2?(void 0!==wsocket2&&null!==wsocket2||PutToDebugLog(2,"ERROR, _common: IsServiceInstalled wsocket2 is NULL"),wsocket2.send("extcmd_test")):e===wsocket3&&(void 0!==wsocket3&&null!==wsocket3||PutToDebugLog(2,"ERROR, _common: IsServiceInstalled wsocket3 is NULL"),wsocket3.send("extcmd_test"));var o=GetEngine("ns");return o.isinstalled_cache=2,SetEngine("ns",o),ExecSrvInstalledCallback(!0),!0}function a(e){return PutToDebugLog(2,"EVENT, common: IsServiceInstalled.onclose, connection closed: "+e),!1}function r(e,n){var t="";if(void 0!==n&&null!==n)try{t=JSON.stringify(n)}catch(o){t=n.toString()}PutToDebugLog(2,"EVENT, Note: it is not a webphone bug if the connection attempt will fail. We are just checking the availability of the local NS engine here"),PutToDebugLog(2,"EVENT, common: IsServiceInstalled.onerror: "+e+": "+t)}function l(e,n){var t=null;if(isNull(n)||isNull(n.data)||(t=ArrayBufferToString(n.data)),!isNull(wsocket)&&wsocket.close&&(wsocket.close(),CanLog(2)&&PutToDebugLog(2,"EVENT, common: IsServiceInstalled.onmessage websocket closed_1")),wsocket=null,!isNull(wsocket2)&&wsocket2.close&&(wsocket2.close(),CanLog(2)&&PutToDebugLog(2,"EVENT, common: IsServiceInstalled.onmessage websocket closed_2")),wsocket2=null,!isNull(wsocket3)&&wsocket3.close&&(wsocket3.close(),CanLog(2)&&PutToDebugLog(2,"EVENT, common: IsServiceInstalled.onmessage websocket closed_3")),wsocket3=null,!isNull(t)&&(CanLog(2)&&PutToDebugLog(2,"EVENT, common: IsServiceInstalled.onmessage, received data: "+e+": "+t),t=t.toLowerCase(),t.indexOf("error")<0&&t.indexOf("extcmd_test")>=0&&!webphone_api.global.nsupdatepending)){var o=t.indexOf("apiresult:");if(o>0&&(t=t.substring(o+10)),!isNull(t)&&t.length>0)if(t.indexOf("version")<0)PutToDebugLog(2,"EVENT, common: IsServiceInstalled.onmessage, service upgrade needed(2): "+GetMinServiceVersion().toString()),setTimeout(function(){EngineForcedInstall("ns",webphone_api.stringres.get("service_update")),webphone_api.global.nsupdatepending=!0},5e3);else{var i=t.substring(t.indexOf("version")+7);isNull(i)&&(i=""),i=i.replace(":",""),i=Trim(i),i.indexOf(" ")>0&&(i=Trim(i.substring(0,i.indexOf(" ")))),!isNull(i)&&IsNumber(i)&&SaveParameter("srvupgrade_currversion_extcmd_test",i)}}return ExecSrvInstalledCallback(!0),!0}if(!0===IsWinMacLinNsTest()){if((isNull(lastgoodnspluginurl)||lastgoodnspluginurl.length<1)&&(lastgoodnspluginurl=GetParameter("last_good_ns_plugin_url"),isNull(lastgoodnspluginurl)||lastgoodnspluginurl.length<1)){PutToDebugLog(5,"EVENT, load WSAPIConnect websocketNS url from scratch d");var s=GetNsPluginWsUrl();if(null===s||s.length<1)return void PutToDebugLog(4,"WARNING, WSAPIReqHTTP could not find a valid URL d");lastgoodnspluginurl=s[0],SaveParameter("last_good_ns_plugin_url",lastgoodnspluginurl)}return e(!0),!0}var s=null;try{if(e&&"function"==typeof e||(e=function(){}),"Windows"!==GetOs()&&!IsMacLin()||IsMacLin()&&!1===NSMacLinEnabled())return e(!1),!1;if(void 0!==srvinstalled_callback&&null!==srvinstalled_callback||(srvinstalled_callback=[]),srvinstalled_callback.push(e),!webphone_api.global.nsegnineneeded&&!MightUseEngine("ns",!0))return CanLog(4)&&PutToDebugLog(4,"EVENT, IsServiceInstalled returned FALSE because of might not use"),ExecSrvInstalledCallback(!1),!1;if(!webphone_api.global.nsegnineneeded&&!0!==n){var p=GetLastUsedEngine(),c=GetParameterInt("enginepriority_ns",2);if(!isNull(p)&&p.length>0&&p!==webphone_api.global.ENGINE_SERVICE&&c<=2)return CanLog(4)&&PutToDebugLog(4,"EVENT, IsServiceInstalled returned FALSE because of priority2"),ExecSrvInstalledCallback(!1),!1}if(wready)return CanLog(4)&&PutToDebugLog(4,"EVENT, IsServiceInstalled returned TRUE already checked"),ExecSrvInstalledCallback(!0),!0;if(lastCheckTick>0&&GetTickCount()-lastCheckTick<2e3)return void((isNull(srvinstalled_callback)||srvinstalled_callback.length<2)&&(CanLog(4)&&PutToDebugLog(4,"EVENT, IsServiceInstalled skip because recently checked: "+wready.toString()),ExecSrvInstalledCallback(wready?!0:!1)));if(lastCheckTick=GetTickCount(),s=GetNsPluginWsUrl(),isNull(s)||s.length<1)return CanLog(3)&&PutToDebugLog(3,"ERROR, IsServiceInstalled win failed, address list is empty"),ExecSrvInstalledCallback(!1),!1;var u=s[0],g="",h="",m=!1;s.length>1&&(g=s[1]),s.length>2&&(h=s[2]),CanLog(2)&&PutToDebugLog(2,"EVENT, IsServiceInstalled url_1: "+u);try{wsocket&&wsocket.close&&wsocket.close(),wsocket=null,wsocket=new WebSocket(u),wsocket.binaryType="arraybuffer",wsocket.onopen=function(){ws1ready=!0,wready=!0,i(wsocket,1,u)},wsocket.onclose=function(){a(1)},wsocket.onerror=function(e){r(1,e),setTimeout(function(){t("onerror")},3)},wsocket.onmessage=function(e){l(1,e)},m=!0}catch(b){PutToDebugLogException(2,"IsServiceInstalled failed to connect to: "+u,b),t("onexception")}isNull(wstimer1)||clearTimeout(wstimer1),wstimer1=setTimeout(function(){ws1ready||t("ontimer")},srvinstalled_timeout);var d=!1}catch(_){return PutToDebugLogException(2,"common: ServiceInstalled",_),e&&"function"==typeof e&&e(!1),!1}}function ExecSrvInstalledCallback(e){try{if(void 0===srvinstalled_callback||null===srvinstalled_callback||srvinstalled_callback.length<1)return;for(;srvinstalled_callback.length>0;)try{var n=srvinstalled_callback.shift();if("function"!=typeof n||null===n)continue;n(e)}catch(t){PutToDebugLogException(2,"common: ExecSrvInstalledCallback inner while",t)}}catch(t){PutToDebugLogException(2,"common: ExecSrvInstalledCallback",t)}srvinstalled_callback=null,srvinstalled_callback=[]}function ServiceStartPolling(){try{if(stopPolling)return;PutToDebugLog(5,"EVENT, common: ServiceStartPolling"),IsServiceInstalled(function(e){webphone_api.global.phonestarted<3&&(!1===e?setTimeout(function(){ServiceStartPolling()},1e3):(GetParameter("lastusedengine").length>0&&"ns"!=GetParameter("lastusedengine")&&SaveParameter("prevusedengine",GetParameter("lastusedengine")),SaveParameter("lastusedengine","ns"),webphone_api.startInner(),!1===IsSDK()&&webphone_api.$.mobile.changePage("#page_dialpad",{transition:"pop",role:"page"})))},!0)}catch(e){PutToDebugLogException(2,"common: ServiceStartPolling",e)}}function ApplyParameters(e){try{if(!isNull(e)){var n;for(n in e)if(!isNull(n)&&n.length>0&&!isNull(e[n])){if("loglevel"===n&&!1===ParameterIsDefault("loglevel"))continue;var t=n;"aec"===t?t="aec_orig":"agc"===t?t="agc_orig":"denoise"===t?t="denoise_orig":"plc"===t?t="plc_orig":"sippassword"===t&&(t="password");var o=Trim(e[n]);0===o.indexOf("encrypted__")&&(o=StrDc(o)),webphone_api.setparameter(t,o,!1),"serveraddress"===n?(SaveParameter("serveraddress_user",o),"true"===GetParameter("serverinputisupperserver")?SaveParameter("upperserver",o):SaveParameter("serveraddress_orig",o)):SaveParameter(n,o)}}}catch(i){PutToDebugLogException(2,"common: ApplyParameters "+GetSecureKey(),i)}}function GetEngineDisplayName(e){var n="";try{if(isNull(e)||e.length<1)return"";switch(e){case"java":n="Java";break;case"ns":n="NS - Service Plugin";break;case"webrtc":n="WebRTC";break;case"flash":n="Flash";break;case"app":n="App - Native Application";break;case"p2p":n="Phone to Phone";break;case"accessnum":n="Access Number";break;case"nativedial":n="Native Dialer";break;case"otherbrowser":n="Alternate Browser";break;default:n="Engine"}return n}catch(t){PutToDebugLogException(2,"common: GetEngineDisplayName",t)}return""}function ChooseEngineLogic2(e){try{if(GetParameter("devicetype")!==DEVICE_WEBPHONE())return;if(isNull(e)||e.length<1)return void PutToDebugLog(2,"ERROR, ChooseEngineLogic2 invalid engine")
;if("java"===e)return void(IsJavaInstalled()<1&&InstallJavaPopup(!0));if("ns"!==e)return;var n=GetEngine("ns");n.isinstalled_cache<0?IsServiceInstalled(function(e){!1===e&&NPDownloadAndInstall(8)},!0):0===n.isinstalled_cache&&NPDownloadAndInstall(9)}catch(t){PutToDebugLogException(2,"common: ChooseEngineLogic2",t)}}function ChooseEngineLogic(e,n,t){var o=0;try{if(o=1,CanLog(4)&&PutToDebugLog(4,"EVENT, ChooseEngineLogic; isstart: "+n+" fromcode: "+t.toString()),!1===Glsp())return void PutToDebugLog(2,"WARNING, ChooseEngineLogic wait");o=2;var i=[];if(i.push("E"),i.push("R"),i.push("R"),i.push("O"),i.push("R"),i.push(","),i.push(" "),i.push("T"),i.push("h"),i.push("e"),i.push(" "),i.push("B"),i.push("a"),i.push("s"),i.push("i"),i.push("c"),i.push(" "),i.push("v"),i.push("e"),i.push("r"),i.push("s"),i.push("i"),i.push("o"),i.push("n"),i.push(" "),i.push("o"),i.push("f"),i.push(" "),i.push("W"),i.push("e"),i.push("b"),i.push("p"),i.push("h"),i.push("o"),i.push("n"),i.push("e"),i.push(" "),i.push("d"),i.push("o"),i.push("e"),i.push("s"),i.push(" "),i.push("n"),i.push("o"),i.push("t"),i.push(" "),i.push("s"),i.push("u"),i.push("p"),i.push("p"),i.push("o"),i.push("r"),i.push("t"),i.push(" "),i.push("["),i.push("B"),i.push("R"),i.push("S"),i.push("]"),i.push(" "),i.push("b"),i.push("r"),i.push("o"),i.push("w"),i.push("s"),i.push("e"),i.push("r"),i.push("_"),o=3,Glv()<=0&&"Chrome"===GetBrowser()){o=4;var a=i.join("");return a=a.replace("[BRS]",GetBrowser()),setTimeout(function(){PutToDebugLog(1,a)},1400),setTimeout(function(){PutToDebugLog(1,a.replace("ERROR","STATUS"))},2400),setTimeout(function(){AlertDialog("",a)},2400),void e(!1)}if(Glv()<=0&&!1===CanIUseApplet()){o=5;var a=i.join("");return a=a.replace("[BRS]",GetBrowser()),setTimeout(function(){PutToDebugLog(1,a)},1450),setTimeout(function(){PutToDebugLog(1,a.replace("ERROR","STATUS"))},2450),setTimeout(function(){AlertDialog("",a)},2450),void e(!1)}o=6;var r="",l=GetSelectedEngine(),s=GetRecommendedEngine();if(!isNull(l)&&l.name===webphone_api.global.ENGINE_SERVICE&&-3===GetMinServiceVersion())return o=7,PutToDebugLog(2,"EVENT, ChooseEngineLogic: "+l.name+"; install popup is disabled by minserviceversion: "+GetMinServiceVersion().toString()),void e();if(!0===n){o=8;var p=GetSinglePossibleEngine(),c="";if(isNull(l)||(c=l.name),p.length>0&&!MightUseEngine(p)&&(p=""),c.length>0&&!MightUseEngine(c)&&(c=""),c!==p);else{if(c===webphone_api.global.ENGINE_APP||p===webphone_api.global.ENGINE_APP)return o=9,GetParameterInt("enginepriority_app",2)<1?void(!0===webphone_api.global.usestorage||Strl(60)?(PutToDebugLog(1,"WARNING,"+webphone_api.stringres.get("only_app_engine1")),AlertDialog("Warning",webphone_api.stringres.get("only_app_engine1"))):(PutToDebugLog(1,"WARNING,"+webphone_api.stringres.get("only_app_engine2")),AlertDialog("Warning",webphone_api.stringres.get("only_app_engine2")))):(PutToDebugLog(2,"EVENT, Selected only possible engine: "+webphone_api.global.ENGINE_APP),selected_engine=GetEngine(webphone_api.global.ENGINE_APP),void e());if(c===webphone_api.global.ENGINE_SERVICE||p===webphone_api.global.ENGINE_SERVICE){o=10;var u=GetParameterInt("enginepriority_ns",2);return u<1?(o=11,void("Windows"===GetOs()&&c===webphone_api.global.ENGINE_JAVA?(PutToDebugLog(1,"WARNING,"+webphone_api.stringres.get("only_ns_engine3")),AlertDialog("Warning",webphone_api.stringres.get("only_ns_engine3"))):!0===webphone_api.global.usestorage||Strl(60)?(PutToDebugLog(1,"WARNING,"+webphone_api.stringres.get("only_ns_engine1")),AlertDialog("Warning",webphone_api.stringres.get("only_ns_engine1"))):(PutToDebugLog(1,"WARNING,"+webphone_api.stringres.get("only_ns_engine2")),AlertDialog("Warning",webphone_api.stringres.get("only_ns_engine2"))))):(o=12,PutToDebugLog(2,"EVENT, Selected only possible engine: "+webphone_api.global.ENGINE_SERVICE),selected_engine=GetEngine(webphone_api.global.ENGINE_SERVICE),e(),void(5!==u&&(o=13,IsServiceInstalled(function(e){if(!1===e){o=14;var n=GetParameterBool("wpfirststart",!0),t=GetParameterInt("prev_sess_failed",0);(!0===n||t<1||t>1)&&(PutToDebugLog(2,"EVENT, common: ChooseEngineLogic, install service: "+GetMinServiceVersion().toString()),EngineForcedInstall("ns"))}},!0))))}if(c===webphone_api.global.ENGINE_JAVA&&0==CanIUseApplet()&&p===webphone_api.global.ENGINE_WEBRTC&&GetParameterInt("enginepriority_java",2)>GetParameterInt("enginepriority_webrtc",2)+1)return o=15,void("Windows"===GetOs()?(PutToDebugLog(1,"WARNING,"+webphone_api.stringres.get("only_ns_engine3")),AlertDialog("Warning",webphone_api.stringres.get("only_ns_engine3"))):(PutToDebugLog(1,"WARNING,"+webphone_api.stringres.get("only_ns_engine4")),AlertDialog("Warning",webphone_api.stringres.get("only_ns_engine4"))))}}o=16;var g=-1,h=-1,m="",d="",b="";!0!==IsSDK()&&(b=webphone_api.$.mobile.activePage.attr("id"));var _=b.indexOf("page_");if(_>=0&&(b=b.substring(_+5)),isNull(l)||(g=l.pushlevel,m=l.name),isNull(s)||(h=s.pushlevel,d=s.name),CanLog(4)&&(PutToDebugLog(4,"EVENT, ChooseEngineLogic selected engine> "+m+" pushlevel: "+g),PutToDebugLog(4,"EVENT, ChooseEngineLogic recommended engine> "+d+" pushlevel: "+h),PutToDebugLog(4,"EVENT, ChooseEngineLogic active page: "+b)),o=17,webphone_api.global.isdebugengine&&(g=3,h=3,m="ns",d="webrtc"),"Android"!==GetOs()&&"iOS"!==GetOs()||"app"===m&&(isNull(d)||d.length<1)&&(g=6),g<3&&h<3)return PutToDebugLog(4,"EVENT, ChooseEngineLogic return callback"),void e(!1);o=18,!isNull(selected_engine2)&&"webrtc"==selected_engine2.name&&(!isNull(l)&&"ns"==l.name||isNull(l)&&!isNull(s)&&"ns"==s.name)&&(o=19,PutToDebugLog(2,"EVENT, ChooseEngineLogic selected engine webrtc instead of ns popup"),selected_engine=GetEngine("webrtc"),selected_engine.pushlevel=2,selected_engine2=null,e()),o=20;var f=GetNPLocation(),w='<a href="'+f+'" target="_blank" id="adialog_nativeplugin">'+webphone_api.stringres.get("nativeplugin")+"</a>";PutToDebugLog(5,"EVENT, common ChooseEngineLogic nplink: "+w);var v=webphone_api.stringres.get("ce_installnativeplugin");v=v.replace("[NATIVE_PLUGIN]",w);var E=!1,P=!1,T='Enable Java in your browser or enable from the settings( <a href="'+webphone_api.global.ENABLE_JAVA_URL+'" id="click_enable_java" target="_blank">How to enable Java ?</a>)',S='Install Java from <a href="'+webphone_api.global.INSTALL_JAVA_URL+'" id="click_install_java" target="_blank">here.</a>',N='<a href="'+GetNPLocation()+'" target="_blank" id="adialog_nativeplugin">'+webphone_api.stringres.get("ce_browser_install")+" "+webphone_api.stringres.get("nativeplugin")+"</a>",I="For best experience: ",C='<a href="javascript:;" id="click_use_webrtc" target="_blank">Use WebRTC.</a>',G='Use <a href="[BWURL]" id="click_use_alternatebrowser" target="_blank">alternate browser.</a>',L="",R='Use <a href="javascript:;" id="click_use_p2p">phone to phone</a> server initiated call.',y='Call <a href="javascript:;" id="click_use_accessnumber">access number</a> using native dialer.',D='<a href="javascript:;" id="click_use_internetexplorer">use Internet Explorer</a>';if(o=21,"iOS"===GetOs()){o=22;var O=GetParameter("ios_nativedialerurl");if((isNull(O)||O.length<3)&&(O="https://itunes.apple.com/ro/app/mizuphone/id483685573"),r="",("Safari"===GetBrowser()||"iPhone"===GetBrowser())&&GetBrowserVersion()<11)r="&SmallCircle; "+webphone_api.stringres.get("ce_native_ios_safari")+' <a href="javascript:;" id="click_use_app">'+webphone_api.stringres.get("ce_native_ios2")+"</a><br /><br />";else{try{var x=webphone_api.platform.os;if(!isNull(x)&&x.length>0&&(x=Trim(x),x.indexOf(" ")>0)){x=x.substring(x.indexOf(" ")+1),x.indexOf(".")>0&&(x=x.substring(0,x.indexOf("."))),x=Trim(x);var A=StrToIntDef(x,-1);A>0&&A>=11&&(r="&SmallCircle; "+webphone_api.stringres.get("ce_native_ios_not_safari")+' <a href="javascript:;" id="click_use_app">'+webphone_api.stringres.get("ce_native_ios2")+"</a><br /><br />")}}catch(W){PutToDebugLogException(2,"common: ChooseEngineLogic inner iOS",W)}r.length<1&&(r="&SmallCircle; "+webphone_api.stringres.get("ce_native_ios_safari")+' <a href="javascript:;" id="click_use_app">'+webphone_api.stringres.get("ce_native_ios2")+"</a><br /><br />")}}else if("Android"===GetOs()){if(o=23,GetBrowserVersion()<40){if(GetParameterInt("enginepriority_otherbrowser",2)>0){o=24;var k=GetConfig("android_aletrnatebrowserurl");(isNull(k)||k.length<5)&&(k=webphone_api.global.android_aletrnatebrowserurl_DEF),r=r+"&SmallCircle; "+webphone_api.stringres.get("ce_browser_install")+' <a href="'+k+'" target="_blank">'+webphone_api.stringres.get("ce_browser_alternate")+"</a>",r+="<br /><br />"}}else o=25,r=r+'&SmallCircle; <a href="javascript:;" id="click_use_webrtc">'+webphone_api.stringres.get("ce_usewebrtc")+"</a>",-1==webphone_api.global.recwsload&&(webphone_api.global.recwsload=GetParameter("lastrecwsload",-2)),webphone_api.global.recwsload>2&&(r=r+" "+webphone_api.stringres.get("ce_webrtcnot")),r+="<br /><br />";"app"===m&&(o=26,GetParameterInt("enginepriority_app",2)>0&&(r=r+'&SmallCircle; <a href="javascript:;" id="click_use_app">'+webphone_api.stringres.get("ce_native_android")+"</a>"))}else{if(o=27,3===g||4===g||5===g||6===g){if("java"===m){var U=IsJavaInstalled();0===U?(6===g&&(E=!0),"MSIE"===GetBrowser()&&(r=r+T+" OR "),r=r+S+"<br><br>"):1===U&&(6===g&&(E=!0),r=r+T+"<br><br>")}else if("ns"!==m||webphone_api.global.isdebugengine)if("otherbrowser"===m){var k="";k=GetParameter("Windows"===GetOs()?"pc_alternatebrowserurl":"pc_alternatebrowserurl"),G=G.replace("[BWURL]",k),r+=I,r=r+G+"<br>",L.length>0&&(r=r+L.replace("[ENGINE]",V)+"<br>"),r+="<br>"}else"p2p"===m?r=r+R+"<br><br>":"accessnum"===m&&(r=r+y+"<br><br>");else!isNull(selected_engine)&&selected_engine.isinstalled_cache<2?(6===g&&(E=!0),r=r+N+"<br><br>"):e(!1);"Edge"===GetBrowser()&&(r+=I,r=r+D+"<br><br>")}if(3===h||4===h||5===h||6===h){if(o=28,6===h&&(E=!0),3===h&&"settings"!==b)return void UserChooseEnginePopup(r,E,P,e,null,1);if("true"===GetParameter("ignoreengineselect"))return void UserChooseEnginePopup(r,E,P,e,null,2);var V=GetEngineDisplayName(m);if(L=V.length>0?L.replace("[ENGINE]",V):"",P=!0,"java"===d){o=29;var U=IsJavaInstalled();0===U?"MSIE"===GetBrowser()?(r+=I,r=r+T+" OR ",r=r+S+"<br>",L.length>0&&(r=r+L.replace("[ENGINE]",V)+"<br>"),r+="<br>"):(r+=I,r=r+S+"<br>",L.length>0&&(r=r+L.replace("[ENGINE]",V)+"<br>"),r+="<br>"):1===U&&(r+=I,r=r+T+"<br>",L.length>0&&(r=r+L.replace("[ENGINE]",V)+"<br>"),r+="<br>")}else if("ns"===d)recommend_engine.isinstalled_cache<2&&(r+=I,r=r+N+"<br>",L.length>0&&(r=r+L.replace("[ENGINE]",V)+"<br>"),r+="<br>");else if("webrtc"===d)r=r+C+"<br>",L.length>0&&(r=r+L.replace("[ENGINE]",V)+"<br>"),r+="<br>";else if("app"===d){if(o=30,GetParameterInt("enginepriority_otherbrowser",2)>0){var k="";k=GetParameter("Windows"===GetOs()?"pc_alternatebrowserurl":"pc_alternatebrowserurl"),G=G.replace("[BWURL]",k),r+=I,r=r+G+"<br>",L.length>0&&(r=r+L.replace("[ENGINE]",V)+"<br>"),r+="<br>"}}else"p2p"===d?r=r+R+"<br><br>":"accessnum"===d?r=r+y+"<br><br>":"nativedial"===d&&(r+='Direct call with <a href="javascript:;" id="click_use_nativedialer">native dialer</a>.<br><br>');"Edge"===GetBrowser()&&r.indexOf(D)<1&&(r+=I,r=r+D+"<br><br>")}}o=31,webphone_api.global.isdebugengine&&(o=32,L=L.replace("[ENGINE]","JAVA"),r=S+"<br><br>",r+=I,r=r+N+"<br>",L.length>0&&(r=r+L.replace("[ENGINE]",V)+"<br>"),r+="<br>",r+=I,r=r+C+"<br>",L.length>0&&(r=r+L.replace("[ENGINE]",V)+"<br>"),r+="<br>",k=GetParameter("pc_alternatebrowserurl"),G=G.replace("[BWURL]",k),r+=I,r=r+G+"<br><br>",r=r+R+"<br><br>",r+=I,r=r+D+"<br><br>",E=!0,P=!1),o=33,UserChooseEnginePopup(r,E,P,e,null,3)}catch(F){PutToDebugLogException(2,"common: ChooseEngineLogic "+o.toString(),F)}}function UserChooseEnginePopupSDK(e,n,t,o,i){try{PutToDebugLog(4,"EVENT, UserChooseEnginePopupSDK");var a=!1;if(-1===GetParameterInt("nsupgrademode",1))return void o(!1);if(isNull(e)||e.length<2)return void o(!1);var r='<span style="width: 100%; display: inline-block; background: #eeeeee; padding-top: 1.2em; padding-bottom: 1.2em;">',l="",s=e.split("<br><br>"),p=0;if(!isNull(s)&&s.length>0)for(var c=0;c<s.length;c++)isNull(s[c])||s[c].length<3||(l+='<div style="margin:0; padding:0; border:0; width:100%; height: .1em; clear:both; background: #dddddd;">\x3c!--//--\x3e</div>',l=l+r+"&nbsp;&nbsp;&nbsp;"+s[c]+"</span>",p++);else l=r+"&nbsp;&nbsp;&nbsp;"+e+"</span>";var u=webphone_api.stringres.get("choose_engine_title");p<2&&(u=webphone_api.stringres.get("choose_engine_title_single_engine")),l='<div id="adialog_formattedmsg" style="display: inline-block; width: 100%;">'+l+"</div>";var g="";if(g='<div id="checkbox_ignore_container" style="width: 100%; background: #eeeeee; height: 3.5em; line-height: 3.5em; border-top: .1em solid #dddddd; border-bottom: .1em solid #dddddd; text-align: right;"><label for="checkbox_ignore">'+webphone_api.stringres.get("ce_dontask")+'&nbsp;&nbsp;</label><input name="checkbox_ignore" id="checkbox_ignore" type="checkbox">&nbsp;&nbsp;&nbsp;</div>',!isNull(cemodal))return void cemodal.show();cemodal=webphone_api.picoModal({content:'<div id="ce_modal" class="pmodal_container" style="height: 100%;"><div id="ce_modal_header" class="pmodal_header">'+u+'</div><div id="ce_modal_content" class="pmodal_content"><div id="ce_modal_content_inner">'+l+"</div>"+g+'</div><div id="ce_modal_footer" class="pmodal_footer"><button id="btn_close_adialog">'+webphone_api.stringres.get("btn_close")+"</button></div></div>",overlayStyles:{backgroundColor:"#565656",opacity:.6},modalStyles:{width:"20em"},closeButton:!1,overlayClose:!1,closeStyles:{background:"#eeeeee",position:"absolute",top:".2em",right:".3em",textAlign:"center",fontSize:"1.2em",fontWeight:"bold",border:".15em solid #bbb",borderRadius:".8em",paddingLeft:".25em",paddingRight:".25em",cursor:"pointer"}}).afterCreate(function(e){}).beforeShow(function(e,n){}).afterShow(function(e){try{var n=webphone_api.$("#ce_modal").height()-webphone_api.$("#ce_modal_header").height()-webphone_api.$("#ce_modal_footer").height()-1;webphone_api.$("#ce_modal_content").height(n),webphone_api.$("#ce_modal_content_inner").height(n-webphone_api.$("#checkbox_ignore_container").height()-5);var t=webphone_api.$("#ce_modal_content_inner").height()-webphone_api.$("#adialog_formattedmsg").height();webphone_api.$("#adialog_formattedmsg").css("margin-top",t/2)}catch(o){PutToDebugLogException(2,"common: UserChooseEnginePopupSDK afterShow",o)}}).beforeClose(function(e,n){}).afterClose(function(e){e.destroy(),cemodal=null,(!1===a||"MSIE"===GetBrowser()&&IsJavaInstalled()<2||"flash"===GetSelectedEngineName())&&(PutToDebugLog(3,"EVENT, UserChooseEngine callback onclose"),a=!0,EngineSelect(1,7),o(!0))}),cemodal.show(),n&&webphone_api.$("#ce_modal_footer").hide(),webphone_api.$("#checkbox_ignore").on("change",function(e){webphone_api.$(this).prop("checked")?SaveParameter("ignoreengineselect","true"):SaveParameter("ignoreengineselect","false")}),webphone_api.$("#click_use_alternatebrowser").on("click",function(){a=!0,webphone_api.flagrestartwebrtc=!1,cemodal.close()}),webphone_api.$("#click_enable_java").on("click",function(){a=!0,webphone_api.flagrestartwebrtc=!1,cemodal.close(),ResetEngineClicked();var e=GetEngine("java");e.clicked=2,SetEngine("java",e)}),webphone_api.$("#click_install_java").on("click",function(){a=!0,webphone_api.flagrestartwebrtc=!1,cemodal.close(),ResetEngineClicked();var e=GetEngine("java");e.clicked=2,SetEngine("java",e),setTimeout(function(){InstallJavaPopup(!1)},400)}),webphone_api.$("#adialog_nativeplugin").on("click",function(){a=!0,webphone_api.flagrestartwebrtc=!1,cemodal.close(),ResetEngineClicked();var e=GetEngine("ns");e.clicked=2,SetEngine("ns",e),setTimeout(function(){NPDownloadAndInstall(11)},400);var n=GetNPLocation();!isNull(n)&&n.length>0&&window.open(n)}),webphone_api.$("#click_use_webrtc").on("click",function(){a=!0,webphone_api.flagrestartwebrtc=!0,cemodal.close(),ResetEngineClicked();var e=GetEngine("webrtc");e.clicked=2,SetEngine("webrtc",e),EngineSelect(1,77),o(!0)}),webphone_api.$("#click_use_p2p").on("click",function(){a=!0,webphone_api.flagrestartwebrtc=!1,cemodal.close(),ResetEngineClicked();var e=GetEngine("p2p");e.clicked=2,SetEngine("p2p",e),EngineSelect(1,8),o(!0)}),webphone_api.$("#click_use_accessnumber").on("click",function(){a=!0,webphone_api.flagrestartwebrtc=!1,cemodal.close(),ResetEngineClicked();var e=GetEngine("accessnum");e.clicked=2,SetEngine("accessnum",e),EngineSelect(1,9),o(!0)}),webphone_api.$("#click_use_nativedialer").on("click",function(){a=!0,webphone_api.flagrestartwebrtc=!1,cemodal.close(),ResetEngineClicked();var e=GetEngine("nativedial");e.clicked=2,SetEngine("nativedial",e),EngineSelect(1,10),o(!0)}),webphone_api.$("#click_use_app").on("click",function(){SaveParameter("allow_start_app_engine","1"),a=!0,webphone_api.flagrestartwebrtc=!1,cemodal.close(),ResetEngineClicked();var e=GetEngine("app");e.clicked=2,SetEngine("app",e),StartAppEngine(!1,"")}),webphone_api.$("#click_use_internetexplorer").on("click",function(){a=!0,webphone_api.flagrestartwebrtc=!1,cemodal.close()}),webphone_api.$("#btn_close_adialog").on("click",function(){PutToDebugLog(5,"EVENT, common UserChooseEngineSDK close on click"),cemodal.close(),(n||!1===a)&&(PutToDebugLog(3,"EVENT, UserChooseEngineSDK callback"),EngineSelect(1,11),a=!0,o(!0))})}catch(h){PutToDebugLogException(2,"common: UserChooseEnginePopupSDK",h)}}function UserChooseEnginePopup(e,n,t,o,i,a){try{PutToDebugLog(2,"EVENT, UserChooseEnginePopup message: "+e+" (force: "+n.toString()+" ignore: "+n.toString()+" fromcode: "+a.toString()+")");var r=GetBrowserVersion();if("java"===GetSelectedEngineName()&&"Chrome"===GetBrowser()&&StrToIntDef(r,70)>webphone_api.getmaxchromeversionforjava()){PutToDebugLog(2,"EVENT,"+webphone_api.stringres.get("jnotsupported")+"_1"),e=webphone_api.stringres.get("jnotsupported");var l=GetConfig("pc_alternatebrowserurl");return!isNull(l)&&l.length>2&&(e=e+': <a href="'+l+'" target="_blank">'+l+"</a>"),AlertDialog("Warning",e),void o(!1)}var s=!1;if("true"===GetParameter("ignoreengineselect"))return void o(!1);if(isNull(e)||e.length<2)return void o(!1);if(-1===GetParameterInt("nsupgrademode",1))return void o(!1);if(1==IsSDK())return void UserChooseEnginePopupSDK(e,n,t,o,i);var p=GetParameterInt("enproblem",0);p<1?p=1:p>3&&(p=3),p++,SaveParameter("enproblem",p),PutToDebugLog(4,"EVENT, UserChooseEnginePopup");var c="",u=e.split("<br><br>"),g=0;if(!isNull(u)&&u.length>0)for(var h=0;h<u.length;h++)isNull(u[h])||u[h].length<3||(c+='<div class="separator_line_chooseengine">\x3c!--//--\x3e</div>',c=c+"<span>&nbsp;&nbsp;&nbsp;"+u[h]+"</span>",g++);else c="<span>&nbsp;&nbsp;&nbsp;"+e+"</span>";var m=webphone_api.stringres.get("choose_engine_title");g<2&&(m=webphone_api.stringres.get("choose_engine_title_single_engine")),c='<div id="adialog_formattedmsg" style="display: inline-block; width: 100%;">'+c+"</div>";var d="";t&&!n&&(d='<div id="checkbox_ignore_container"><label for="checkbox_ignore">'+webphone_api.stringres.get("ce_dontask")+'</label><input name="checkbox_ignore" id="checkbox_ignore" type="checkbox"></div>');var b=GetDeviceWidth();(isNull(b)||b<10)&&(b=220);var _='<div data-role="popup" id="choose_engine" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+b+"px; width:"+b+"px; margin=0; float:left; height="+GetDeviceHeight()+'px;"><div data-role="header" data-theme="b" id="choose_engine_header"><h1 class="adialog_title" style="font-weight: bold;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+m+'</h1></div><div role="main" id="choose_engine_container" class="ui-content adialog_content adialog_alert"><div id="choose_engine_top_section" style="margin: 0em;"><div id="chooseengine_spacer" style="display: inline-block; width: 100%;">&nbsp;</div>'+c+"</div>"+d+'</div><div data-role="footer" data-theme="b" class="adialog_footer" id="choose_engine_footer"><a href="javascript:;" id="adialog_positive" style="width: 100%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_close")+"</a></div></div>";i=i||function(){},webphone_api.$.mobile.activePage.append(_).trigger("create"),webphone_api.$.mobile.activePage.find(".messagePopup").popup({beforeposition:function(){webphone_api.$(".ui-popup-screen").off(),webphone_api.$(this).css({width:window.innerWidth,height:window.innerHeight-10}),n&&webphone_api.$("#choose_engine_footer").hide();var e=GetDeviceHeight()-webphone_api.$("#choose_engine_header").height();webphone_api.$("#choose_engine_footer").is(":visible")&&(e-=webphone_api.$("#choose_engine_footer").height()),e=Math.floor(e),webphone_api.$(".messagePopup .ui-content").height(e-Math.floor(.015*e)),webphone_api.$(".messagePopup .ui-content").css({padding:0,margin:0,background:"#ffffff"})},afteropen:function(e,n){webphone_api.$(this).parent().css({top:0,left:0,position:"absolute"});var t=webphone_api.$("#choose_engine_container").height()-20;isNull(document.getElementById("checkbox_ignore_container"))||(t-=webphone_api.$("#checkbox_ignore_container").height()),document.getElementById("choose_engine_top_section").style.height=t+"px";var o=t-webphone_api.$("#adialog_formattedmsg").height();document.getElementById("chooseengine_spacer").style.height=Math.floor(o/2)+"px"}}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),i(),(!1===s||"MSIE"===GetBrowser()&&IsJavaInstalled()<2||"flash"===GetSelectedEngineName())&&(PutToDebugLog(3,"EVENT, UserChooseEngine callback onclose"),EngineSelect(1,12),s=!0,o(!0))}}),webphone_api.$("#checkbox_ignore").on("change",function(e){webphone_api.$(this).prop("checked")?SaveParameter("ignoreengineselect","true"):SaveParameter("ignoreengineselect","false")}),webphone_api.$("#click_use_alternatebrowser").on("click",function(){s=!0,webphone_api.flagrestartwebrtc=!1,webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$("#click_enable_java").on("click",function(){s=!0,webphone_api.flagrestartwebrtc=!1,webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),ResetEngineClicked();var e=GetEngine("java");e.clicked=2,SetEngine("java",e)}),webphone_api.$("#click_install_java").on("click",function(){s=!0,webphone_api.flagrestartwebrtc=!1,webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),ResetEngineClicked();var e=GetEngine("java");e.clicked=2,SetEngine("java",e),webphone_api.$("#choose_engine").on("popupafterclose",function(e){OpenSettings(!0,5),setTimeout(function(){InstallJavaPopup(!1)},400)})}),webphone_api.$("#adialog_nativeplugin").on("click",function(){s=!0,webphone_api.flagrestartwebrtc=!1,webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),webphone_api.$("#choose_engine").on("popupafterclose",function(e){ResetEngineClicked();var n=GetEngine("ns");n.clicked=2,SetEngine("ns",n),setTimeout(function(){NPDownloadAndInstall(13)},400);var t=GetNPLocation();!isNull(t)&&t.length>0&&window.open(t)})}),webphone_api.$("#click_use_webrtc").on("click",function(){s=!0,webphone_api.flagrestartwebrtc=!0,webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),ResetEngineClicked();var e=GetEngine("webrtc");e.clicked=2,SetEngine("webrtc",e),EngineSelect(1,13),o(!0)}),webphone_api.$("#click_use_p2p").on("click",function(){s=!0,webphone_api.flagrestartwebrtc=!1,webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),ResetEngineClicked();var e=GetEngine("p2p");e.clicked=2,SetEngine("p2p",e),EngineSelect(1,14),o(!0)}),webphone_api.$("#click_use_accessnumber").on("click",function(){s=!0,webphone_api.flagrestartwebrtc=!1,webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),ResetEngineClicked();var e=GetEngine("accessnum");e.clicked=2,SetEngine("accessnum",e),EngineSelect(1,15),o(!0)}),webphone_api.$("#click_use_nativedialer").on("click",function(){s=!0,webphone_api.flagrestartwebrtc=!1,webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),ResetEngineClicked();var e=GetEngine("nativedial");e.clicked=2,SetEngine("nativedial",e),EngineSelect(1,16),o(!0)}),webphone_api.$("#click_use_app").on("click",function(){SaveParameter("allow_start_app_engine","1"),s=!0,webphone_api.flagrestartwebrtc=!1,webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),ResetEngineClicked();var e=GetEngine("app");e.clicked=2,SetEngine("app",e),StartAppEngine(!1,"")}),webphone_api.$("#click_use_internetexplorer").on("click",function(){s=!0,webphone_api.flagrestartwebrtc=!1,webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$("#adialog_positive").on("click",function(e){PutToDebugLog(5,"EVENT, common UserChooseEngine close on click"),(n||!1===s)&&(PutToDebugLog(3,"EVENT, UserChooseEngine callback"),EngineSelect(1,17),s=!0,o(!0))})}catch(f){PutToDebugLogException(2,"common: UserChooseEnginePopup",f)}}function AppEngineClick(){try{alert("AppEngineClick")}catch(e){PutToDebugLogException(2,"common: AppEngineClick",e)}}function ShowEngineOptionOnPage(e){try{if(GetParameter("devicetype")!==DEVICE_WEBPHONE())return void e("","");if("true"===GetParameter("ignoreengineselect"))return void e("","");if(isNull(GetSelectedEngine())&&semaxloop<10)return setTimeout(function(){ShowEngineOptionOnPage(e)},500),void semaxloop++;semaxloop=0;var n=GetSelectedEngine(),t=GetRecommendedEngine(),o=-1,i=-1,a="",r="";isNull(n)||(o=n.pushlevel,a=n.name),isNull(t)||(i=t.pushlevel,r=t.name);var l="Engine is [XXX]. Click here if wish to use [YYY].",s="";webphone_api.global.useengine.length>0&&a.length>0&&webphone_api.global.useengine!==a&&2===o?(s=l.replace("[XXX]",GetEngineDisplayName(webphone_api.global.useengine)),s=s.replace("[YYY]",GetEngineDisplayName(a)),e(s,a)):webphone_api.global.useengine.length>0&&r.length>0&&webphone_api.global.useengine!==r&&2===i&&(s=l.replace("[XXX]",GetEngineDisplayName(webphone_api.global.useengine)),s=s.replace("[YYY]",GetEngineDisplayName(r)),e(s,r))}catch(p){PutToDebugLogException(2,"common: ShowEngineOptionOnPage",p)}e("","")}function GatewayFailower(e,n){try{if(gwround++,isNull(n)&&(n=""),PutToDebugLog(2,"EVENT,GatewayCheck called: "+n+" ("+gwround+")"),getuseengine()!==webphone_api.global.ENGINE_WEBRTC)return void PutToDebugLog(2,"EVENT,skip GatewayCheck because not WebRTC ("+gwround+")");if(!1===webphone_api.global.canfailover_gateway)return void PutToDebugLog(2,"EVENT,skip GatewayCheck because already failowered once in this session ("+gwround+")");if(!1===IsMizuPublicWebRTCGateway())return void PutToDebugLog(2,"EVENT,skip GatewayCheck because not Mwebrtc gateway ("+gwround+")");isNull(fail_timer)||clearTimeout(fail_timer),fail_timer=null,e<0&&(e=8e3),PutToDebugLog(2,"EVENT,GatewayCheck started checking, delay: "+e.toString()+" ("+gwround+")"),webphone_api.global.canfailover_gateway=!1,fail_timer=setTimeout(function(){try{if(PGW_Get_Count()<2)return void PutToDebugLog(2,"EVENT,skip GatewayCheck failower because gw count is ("+PGW_Get_Count().toString()+" / "+gwround+")");if(webphone_api.global.pgw_selected>=0&&!0!==PGW_Get(webphone_api.global.pgw_selected,PGW_WSREC,!1))return void PutToDebugLog(2,"EVENT,skip GatewayCheck because no answers for wsload ("+webphone_api.global.pgw_selected.toString()+" / "+gwround+")");if(!1===IsMizuPublicWebRTCGateway())return void PutToDebugLog(2,"EVENT,skip GatewayCheck because not Mwebrtc gateway from timer ("+gwround+")");if(webphone_api.global.pgw_selected<0)return void PutToDebugLog(2,"ERROR,skip GatewayCheck failower final gw NOT defined ("+gwround+")");var e=GetWsAddressCfg(1);if(!isNull(e)&&e.length>3&&PGW_GetGwIndex(e)>=0)return void PutToDebugLog(2,"EVENT,GatewayCheck do NOT failower because gateway address is set manually ("+gwround+") to "+e);!0===webphone_api.global.failover_gateway&&!0===NeedRegister()?(webphone_api.global.failover_gateway=!1,selectedwserver="",webphone_api.global.pgw_selected++,webphone_api.global.pgw_selected>=PGW_Get_Count()&&(webphone_api.global.pgw_selected=0),isNull(webphone_api.global.worktimer)||(clearTimeout(webphone_api.global.worktimer),webphone_api.global.worktimer=null),PutToDebugLog(2,"EVENT, mlogic API_Unregister GatewayCheck ("+gwround+")"),PutToDebugLog(2,"ERROR,GatewayCheck failower to: "+webphone_api.global.pgw_selected.toString()+" "+PGW_Get(webphone_api.global.pgw_selected,PGW_ADDRESS)+" ("+gwround+")"),!isNull(wssocket)&&wssocket.close&&wssocket.close(),wssocket=null,PutToDebugLog(2,"EVENT, mlogic API_Start GatewayCheck ("+gwround+")"),webphone_api.start()):PutToDebugLog(2,"EVENT,skip GatewayCheck because failover_gateway: "+webphone_api.global.failover_gateway.toString()+"; NeedRegister: "+NeedRegister()+" ("+gwround+")")}catch(n){PutToDebugLogException(2,"common: GatewayCheck inner timer",n)}},e)}catch(t){PutToDebugLogException(2,"common: GatewayCheck",t)}}function CheckEngineFirstStart(e){try{if(isNull(isWebphoneFirstStart)&&(isWebphoneFirstStart=GetParameterBool("wpfirststart",!1)),!1===isWebphoneFirstStart)return;isWebphoneFirstStart=!1,isNull(cestimer)||clearTimeout(cestimer),cestimer=setTimeout(function(n){try{if(getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.iswebrtcengineworking<1&&!0===CanIUseService()){var t=StrToInt(GetParameter2("enginepriority_webrtc")),o=StrToInt(GetParameter2("enginepriority_ns"));if(t<5&&t<=o){IsCurrentEngineWorking(e,1,!0);var i=GetParameter2("serveraddress");(isNull(i)||i.length<2||"YOURSIPDOMAIN.COM"===i||"YOURSIPSERVER.COM"===i||"SIPSERVER"===i||"VOIPSERVER"===i||"SERVERADDRESS"===i)&&(SaveParameter("serveraddress",""),i=GetParameter2("serveraddress_user"),(isNull(i)||i.length<2||"YOURSIPDOMAIN.COM"===i||"YOURSIPSERVER.COM"===i||"SIPSERVER"===i||"VOIPSERVER"===i||"SERVERADDRESS"===i)&&("undefined"!=typeof webphone_api.global.worktimer&&null!==webphone_api.global.worktimer&&clearTimeout(webphone_api.global.worktimer),webphone_api.global.worktimer=null))}}}catch(a){PutToDebugLogException(2,"common: CheckEngineFirstStart Inner Timer",a)}},4e3)}catch(n){PutToDebugLogException(2,"common: CheckEngineFirstStart",n)}}function IsCurrentEngineWorking(e,n,t){try{if((isNull(n)||!1===IsNumber(n))&&(n=25e3,GetTickCount()-lastcalledtick<2500))return;lastcalledtick=GetTickCount(),isNull(webphone_api.global.worktimer)||clearTimeout(webphone_api.global.worktimer),paramcache=e,webphone_api.global.iscurrengineworking=!1,webphone_api.global.lastengine_working_ok="",webphone_api.global.worktimer=setTimeout(function(e){try{if(HandleCalldivert(),"app"===getuseengine()||"p2p"===getuseengine()||"accessnum"===getuseengine()||"nativedial"===getuseengine()||"otherbrowser"===getuseengine())return;if(webphone_api.global.phonestarted>2&&(SaveParameter("wpfirststart","false"),PutToDebugLog(3,"EVENT, Save wpfirststart = false")),webphone_api.global.useengine===webphone_api.global.ENGINE_WEBRTC&&!1===backupserver_tried&&1===webphone_api.global.webrtcsocketconnected&&0===webphone_api.global.webrtcsipsignalingreceived){var n=GetParameter("backupserver");if(!isNull(n)&&n.length>0){var o=GetUDPServerAddress();return SaveParameter("serveraddress_user",n),SaveParameter("backupserver",o),backupserver_tried=!0,PutToDebugLog(2,"WARNING, common: IsCurrentEngineWorking: trying to register using backupserver: "+GetUDPServerAddress()),void webphone_api.startInner(e)}}if(!1===webphone_api.global.iscurrengineworking){PutToDebugLog(3,"ERROR, common: IsCurrentEngineWorking "+getuseengine()+"> NOT WORKING no SIP signaling received from server");var i=GetEngine(webphone_api.global.useengine),a=GetParameterBool("wpfirststart",!0),r=GetParameterInt("prev_sess_failed",0);if(!0===a||r<1||(EngineSelect(1,18),isNull(i)||("Linux"!==GetOs()&&"Mac"!==GetOs()||!1!==CanIUseService()||0!=CanIUseApplet())&&(i.failed=1,SetEngine(webphone_api.global.useengine,i))),SaveParameter("prev_sess_failed",(r+1).toString()),!1===a){var l=GetSelectedEngineName();EngineSelect(1,19);var s=GetSelectedEngineName()
;if(l!==s){var p=GetParameterInt("enginepriority_"+l,2),c=GetParameterInt("enginepriority_"+s,2);if(l!==webphone_api.global.ENGINE_WEBRTC&&l!==webphone_api.global.ENGINE_SERVICE||s!==webphone_api.global.ENGINE_WEBRTC&&s!==webphone_api.global.ENGINE_SERVICE){if(s!==webphone_api.global.ENGINE_WEBRTC&&s!==webphone_api.global.ENGINE_SERVICE&&p>=c)return void PutToDebugLog(2,"WARNING, IsCurrentEngineWorking, NO engine switch because of priority HIGHER or EQUAL from: "+l+"("+p.toString()+") to: "+s+"("+c.toString()+")")}else if(p>c)return void PutToDebugLog(2,"WARNING, IsCurrentEngineWorking, NO engine switch because of priority HIGHER from: "+l+"("+p.toString()+") to: "+s+"("+c.toString()+")")}}if(2===webphone_api.global.useengineclicked_cache||!0===t){webphone_api.global.useengineclicked_cache=1;var u=webphone_api.stringres.get("ce_ask_user"),g=GetSelectedEngineName();u=u.replace("[SELECTEDENGINE]",GetEngineDisplayName(g)),PutToDebugLog(2,"WARNING, IsCurrentEngineWorking: "+u),EngineSelect(1,20),ChooseEngineLogic(function(n){if(!1===n){var t=GetSelectedEngineName();if(u=u.replace("[RECOMMENDED]",GetEngineDisplayName(t)),PutToDebugLog(2,"WARNING, IsCurrentEngineWorking 2: "+u),isNull(g)||g.length<1||isNull(t)||t.length<1||g===t)return PutToDebugLog(2,"ERROR, IsCurrentEngineWorking invalid message to be displayed: "+u+" reset useengine"),webphone_api.global.useengine="",webphone_api.global.last_useengine="",void webphone_api.plhandler.StartUp(e);if(!0!==confirm(u))return PutToDebugLog(2,"WARNING, user denied recommended engine failback"),void IsCurrentEngineWorking(e);PutToDebugLog(2,"EVENT, user confirmed recommended engine failback reset useengine"),webphone_api.global.useengine="",webphone_api.global.last_useengine="",webphone_api.plhandler.StartUp(e)}else webphone_api.plhandler.StartUp(e)},!0,4)}else PutToDebugLog(2,"WARNING, IsCurrentEngineWorking just start webphone"),webphone_api.startInner(e)}else webphone_api.global.lastengine_started_ok=webphone_api.global.useengine,webphone_api.global.lastengine_working_ok=webphone_api.global.useengine,PutToDebugLog(3,"EVENT, this engine is working: "+webphone_api.global.useengine),"java"!==webphone_api.global.useengine&&"ns"!==webphone_api.global.useengine&&"webrtc"!==webphone_api.global.useengine||SaveParameter(webphone_api.global.useengine+"_worked","true"),"ns"===webphone_api.global.useengine&&HandleServiceBuildUpgrade(),setTimeout(function(){webphone_api.global.isencrypted=webphone_api.isencrypted()},3e3)}catch(h){PutToDebugLogException(2,"common: IsCurrentEngineWorking timer",h)}},n)}catch(o){PutToDebugLogException(2,"common: IsCurrentEngineWorking",o)}}function InstallJavaPopupSDK(e,n){try{if(PutToDebugLog(4,"EVENT, InstallJavaPopupSDK"),e&&window.open(webphone_api.global.INSTALL_JAVA_URL,"_blank"),!isNull(jinstallmodal))return void jinstallmodal.show();jinstallmodal=webphone_api.picoModal({content:'<div id="ce_modal" class="pmodal_container"><div id="ce_modal_header" class="pmodal_header">'+webphone_api.stringres.get("java_install_title")+'</div><div id="ce_modal_content" class="pmodal_content" style="padding: 1em;"><div id="ce_modal_content_inner">'+webphone_api.stringres.get("java_install")+'</div></div><div id="ce_modal_footer" class="pmodal_footer"><button id="btn_close_jsinst_adialog">'+webphone_api.stringres.get("btn_ok")+"</button></div></div>",overlayStyles:{backgroundColor:"#565656",opacity:.6},modalStyles:{},overlayClose:!1,closeStyles:{background:"#eeeeee",position:"absolute",top:".2em",right:".3em",textAlign:"center",fontSize:"1.2em",fontWeight:"bold",border:".15em solid #bbb",borderRadius:".8em",paddingLeft:".25em",paddingRight:".25em",cursor:"pointer"}}).afterCreate(function(e){}).beforeShow(function(e,n){}).afterShow(function(e){}).beforeClose(function(e,n){}).afterClose(function(e){e.destroy(),jinstallmodal=null}),jinstallmodal.show(),webphone_api.$("#btn_close_jsinst_adialog").on("click",function(){jinstallmodal.close()})}catch(t){PutToDebugLogException(2,"common: InstallJavaPopupSDK",t)}}function InstallJavaPopup(e,n){try{if(1==IsSDK())return void InstallJavaPopupSDK(e,n);PutToDebugLog(4,"EVENT, InstallJavaPopup");var t=GetDeviceWidth();t=!isNull(t)&&IsNumber(t)&&t>100?Math.floor(t/1.2):220,t>400?t=400:t<120&&(t=120);var o=webphone_api.stringres.get("java_install"),i='<div data-role="popup" id="np_downloadinstall" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+t+'px;"><div data-role="header" data-theme="b"><h1 class="adialog_title">'+webphone_api.stringres.get("java_install_title")+'</h1></div><div role="main" class="ui-content adialog_content adialog_alert"><span> '+o+' </span></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_positive" style="width: 100%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_ok")+"</a></div></div>";n=n||function(){},webphone_api.$.mobile.activePage.append(i).trigger("create"),webphone_api.$.mobile.activePage.find(".messagePopup").bind({popupbeforeposition:function(){webphone_api.$(".ui-popup-screen").off(),webphone_api.$(this).unbind("popupbeforeposition")}}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),n()}}),webphone_api.$("#adialog_positive").on("click",function(n){e&&window.open(webphone_api.global.INSTALL_JAVA_URL,"_blank"),PutToDebugLog(5,"EVENT, common InstallJavaPopup ok click")})}catch(a){PutToDebugLogException(2,"common: InstallJavaPopup",a)}}function GetNPLocation(){var e="";try{if(e=GetConfig("nativepluginurl"),(isNull(e)||e.length<2)&&(e=GetParameter2("nativepluginurl")),!isNull(e)&&e.length>5)return CanLog(4)&&PutToDebugLog(4,"EVENT, GetNPLocation service location(1): "+e),e;e=webphone_api.getbasedir2(),isNull(e)&&(e="");var n=GetConfig("nativepluginname");"Mac"===GetOs()?n=GetConfig("nativepluginname_mac"):"Linux"===GetOs()&&(n=GetConfig("nativepluginname_linux"));var t=e+"native/";return(isNull(n)||n.length<3)&&(!0===NSMacLinEnabled()?"Mac"===GetOs()?(!isNull(webphone_api.global.mac_nsplugin_path)&&webphone_api.global.mac_nsplugin_path.length>0&&("www"==webphone_api.global.mac_nsplugin_path&&(webphone_api.global.mac_nsplugin_path="https://www.mizu-voip.com/G/webphone/publicfiles/"),t=webphone_api.global.mac_nsplugin_path),n=webphone_api.global.mac_nsplugin_filename):n=!0===Is64BitBrowser()?!0===IsARM()?webphone_api.global.lin64arm_nsplugin_filename:webphone_api.global.lin64_nsplugin_filename:!0===IsARM()?webphone_api.global.lin32arm_nsplugin_filename:webphone_api.global.lin32_nsplugin_filename:n=webphone_api.global.win_nsplugin_filename),"/"!==t.charAt(t.length-1)&&(t+="/"),e=t+n,CanLog(4)&&(PutToDebugLog(4,"EVENT, GetNPLocation doc location: "+location.href),PutToDebugLog(4,"EVENT, GetNPLocation service location: "+e)),e}catch(o){PutToDebugLogException(2,"common: GetNPLocation",o)}return""}function NPDownloadAndInstallSDK(e,n,t){try{if(PutToDebugLog(4,"EVENT, NPDownloadAndInstallSDK popup displayed "+e.toString()),webphone_api.global.nsegnineneeded=!0,ServiceStartPolling(),!isNull(npmodal))return void npmodal.show();t=t||function(){};var o=webphone_api.stringres.get("np_install_msg"),i='<a href="https://www.webvoipphone.com/hosted/webphonedemo/nsenginedownload.html" target="_blank">'+webphone_api.stringres.get("np_install_why")+"</a>";"Linux"===GetOs()?(o=webphone_api.stringres.get("np_install_msg_lin"),(!0===webphone_api.global.usestorage||Strl(90))&&(o=o+"<br><br>"+i)):"Mac"===GetOs()&&(o=webphone_api.stringres.get("np_install_msg_mac"),(!0===webphone_api.global.usestorage||Strl(90))&&(o=o+"<br><br>"+i));var a='<button id="btn_np_negative">'+webphone_api.stringres.get("btn_cancel")+"</button>";!0===n&&(a=""),npmodal=webphone_api.picoModal({content:'<div id="ce_modal" class="pmodal_container"><div id="ce_modal_header" class="pmodal_header">'+webphone_api.stringres.get("np_install_title")+'</div><div id="ce_modal_content" class="pmodal_content" style="padding: 1em;"><div id="ce_modal_content_inner">'+o+'</div></div><div id="ce_modal_footer" class="pmodal_footer"><button id="btn_np_positive">'+webphone_api.stringres.get("btn_ok")+"</button>"+a+"</div></div>",overlayStyles:{backgroundColor:"#565656",opacity:.6},modalStyles:{},closeButton:!1,overlayClose:!1,closeStyles:{background:"#eeeeee",position:"absolute",top:".2em",right:".3em",textAlign:"center",fontSize:"1.2em",fontWeight:"bold",border:".15em solid #bbb",borderRadius:".8em",paddingLeft:".25em",paddingRight:".25em",cursor:"pointer"}}).afterCreate(function(e){}).beforeShow(function(e,n){}).afterShow(function(e){}).beforeClose(function(e,n){}).afterClose(function(e){e.destroy(),npmodal=null,PutToDebugLog(4,"EVENT, NPDownloadAndInstallSDK popup closed")}),npmodal.show(),webphone_api.$("#btn_np_positive").on("click",function(){npmodal.close(),PutToDebugLog(5,"EVENT, common NPDownloadAndInstallSDK 1 ok"),lm=!1,!0===webphone_api.global.nsupdatepending&&(webphone_api.global.nsupdatepending=!1,PutToDebugLog(2,"EVENT, mlogic API_Start NPDownloadAndInstallSDK"),webphone_api.start()),t("ok")}),webphone_api.$("#btn_np_negative").on("click",function(){npmodal.close(),PutToDebugLog(5,"EVENT, settings NPDownloadAndInstallSDK 1 cancel");var e=GetEngine("webrtc");e.clicked=0,SetEngine("webrtc",e),EngineSelect(1,21),stopPolling=!0,t("cancel")})}catch(r){PutToDebugLogException(2,"common: NPDownloadAndInstallSDK",r)}}function NPDownloadAndInstall(e,n,t){try{if(npclosehandled=!1,webphone_api.global.nsegnineneeded=!0,1==IsSDK())return void NPDownloadAndInstallSDK(e,n,t);PutToDebugLog(4,"EVENT, NPDownloadAndInstall popup displayed from "+e.toString()),ServiceStartPolling();var o=GetDeviceWidth();o=!isNull(o)&&IsNumber(o)&&o>100?Math.floor(o/1.2):220,o>400?o=400:o<120&&(o=120),enginep.ns=enginep.ns+5e3;var i=webphone_api.stringres.get("np_install_msg"),a='<a href="https://www.webvoipphone.com/hosted/webphonedemo/nsenginedownload.html" target="_blank">'+webphone_api.stringres.get("np_install_why")+"</a>";i=i+"<br><br>"+a,"Linux"===GetOs()?(i=webphone_api.stringres.get("np_install_msg_lin"),(!0===webphone_api.global.usestorage||Strl(90))&&(i=i+"<br><br>"+a)):"Mac"===GetOs()&&(i=webphone_api.stringres.get("np_install_msg_mac"),(!0===webphone_api.global.usestorage||Strl(90))&&(i=i+"<br><br>"+a));var r='<a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_cancel")+"</a>";!0===n&&(r="");var l='<div data-role="popup" id="np_downloadinstall" class="ui-content messagePopup" data-overlay-theme="a" data-dismissible="false" data-theme="a" style="max-width:'+o+'px;"><div data-role="header" data-theme="b"><h1 class="adialog_title">'+webphone_api.stringres.get("np_install_title")+'</h1></div><div role="main" class="ui-content adialog_content adialog_alert"><span> '+i+' </span></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_ok")+"</a>"+r+"</div></div>";t=t||function(){},webphone_api.$.mobile.activePage.append(l).trigger("create"),webphone_api.$.mobile.activePage.find(".messagePopup").bind({popupbeforeposition:function(){webphone_api.$(".ui-popup-screen").off(),webphone_api.$(this).unbind("popupbeforeposition");var e=Math.floor(.6*GetDeviceHeight());webphone_api.$(this).height()>e&&webphone_api.$(".messagePopup .ui-content").height(e)}}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){!1===npclosehandled&&NPHandleCancel(),webphone_api.$(this).unbind("popupafterclose").remove(),PutToDebugLog(4,"EVENT, NPDownloadAndInstall popup closed")}}),webphone_api.$("#adialog_positive").on("click",function(e){PutToDebugLog(5,"EVENT, common NPDownloadAndInstall 1 ok"),npclosehandled=!0,lm=!1,setTimeout(function(){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")},500),!0===webphone_api.global.nsupdatepending&&(webphone_api.global.nsupdatepending=!1,PutToDebugLog(2,"EVENT, mlogic API_Start NPDownloadAndInstall"),webphone_api.start()),setTimeout(function(){IsServiceInstalled(function(e){!1===e&&(PutToDebugLog(2,"WARNING, on NPDownloadAndInstall OK clikc, NS service is not reachable"),AlertDialog(webphone_api.stringres.get("warning"),webphone_api.stringres.get("np_install_warn")))},!0)},500),t("ok")}),webphone_api.$("#adialog_negative").on("click",function(e){PutToDebugLog(5,"EVENT, settings NPDownloadAndInstall 1 cancel"),t("cancel"),NPHandleCancel(),setTimeout(function(){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")},500)})}catch(s){PutToDebugLogException(2,"common: NPDownloadAndInstall",s)}}function NPHandleCancel(){npclosehandled=!0;var e=GetEngine("ns");e.clicked=0,SetEngine("ns",e),EngineSelect(1,22),stopPolling=!0,webphone_api.startInner()}function EngineForcedInstallSDK(e,n,t,o){function i(){if("java"===e)InstallJavaPopup(!0),o("ok");else if("ns"===e){o("ok"),setTimeout(function(){NPDownloadAndInstall(14,!0)},450);var n=GetNPLocation();!isNull(n)&&n.length>0&&window.open(n)}}try{var a=!1;if(PutToDebugLog(4,"EVENT, EngineForcedInstallSDK popup displayed: "+e+"; message: "+n),o=o||function(){},!isNull(efmodal))return void efmodal.show();if(isNull(n)||n.length<1)if("java"===e&&"Chrome"===GetBrowser()){PutToDebugLog(2,"EVENT,"+webphone_api.stringres.get("jnotsupported")+"_2"),n=webphone_api.stringres.get("jnotsupported");var r=GetConfig("pc_alternatebrowserurl");!isNull(r)&&r.length>2&&(n=n+': <a href="'+r+'" target="_blank">'+r+"</a>"),a=!0}else n=webphone_api.stringres.get("ce_alert_user")+" "+GetEngineDisplayName(e)+".",n=n.replace("[BRAND]",GetBrandName());n.indexOf(webphone_api.stringres.get("service_update"))>=0&&(n+='<br /><a id="efi_download_link" style="cursor:pointer; color:#3f8fcf;">Download NS -Service Plugin</a>');var l=webphone_api.stringres.get("btn_ok");e===webphone_api.global.ENGINE_SERVICE&&(l=webphone_api.stringres.get("btn_download"));var s='<button id="btn_ef_positive">'+l+"</button>";!0===t&&(s='<button id="btn_ef_negative">'+webphone_api.stringres.get("btn_cancel")+"</button>"+s),efmodal=webphone_api.picoModal({content:'<div id="ce_modal" class="pmodal_container"><div id="ce_modal_header" class="pmodal_header">'+webphone_api.stringres.get("ce_alert_title")+'</div><div id="ce_modal_content" class="pmodal_content" style="padding: 1em;"><div id="ce_modal_content_inner">'+n+'</div></div><div id="ce_modal_footer" class="pmodal_footer">'+s+"</div></div>",overlayStyles:{backgroundColor:"#565656",opacity:.6},modalStyles:{},closeButton:!1,overlayClose:!1,closeStyles:{background:"#eeeeee",position:"absolute",top:".2em",right:".3em",textAlign:"center",fontSize:"1.2em",fontWeight:"bold",border:".15em solid #bbb",borderRadius:".8em",paddingLeft:".25em",paddingRight:".25em",cursor:"pointer"}}).afterCreate(function(e){}).beforeShow(function(e,n){}).afterShow(function(e){}).beforeClose(function(e,n){}).afterClose(function(e){webphone_api.$("#efi_download_link").off("click"),e.destroy(),PutToDebugLog(4,"EVENT, EngineForcedInstallSDK popup closed"),efmodal=null}),efmodal.show(),webphone_api.$("#efi_download_link").on("click",function(e){PutToDebugLog(5,"EVENT, common EngineForcedInstallSDK link click"),i(),efmodal.close()}),webphone_api.$("#btn_ef_positive").on("click",function(){efmodal.close(),!0!==a&&(PutToDebugLog(5,"EVENT, common EngineForcedInstallSDK 1 ok"),i())}),webphone_api.$("#btn_ef_negative").on("click",function(){efmodal.close(),PutToDebugLog(5,"EVENT, common EngineForcedInstallSDK 1 cancel");var e=GetEngine("webrtc");e.clicked=0,SetEngine("webrtc",e),EngineSelect(1,23),stopPolling=!0,o("cancel")})}catch(p){PutToDebugLogException(2,"common: EngineForcedInstallSDK",p)}}function EngineForcedInstall(e,n,t,o){function i(){if("java"===e)InstallJavaPopup(!0),o("ok");else if("ns"===e){o("ok"),setTimeout(function(){NPDownloadAndInstall(15,!0)},450);var n=GetNPLocation();!isNull(n)&&n.length>0&&window.open(n)}setTimeout(function(){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")},200)}try{if("ns"===e&&-3===GetMinServiceVersion())return void PutToDebugLog(2,"ERROR, EngineForcedInstall: "+e+"; install popup is disabled by minserviceversion: "+GetMinServiceVersion().toString());var a=!1;if(1==IsSDK())return void EngineForcedInstallSDK(e,n,t,o);PutToDebugLog(4,"EVENT, EngineForcedInstall popup displayed: "+e+"; message: "+n);var r=GetDeviceWidth();if(r=!isNull(r)&&IsNumber(r)&&r>100?Math.floor(r/1.2):220,r>400?r=400:r<120&&(r=120),isNull(n)||n.length<1)if("java"===e&&"Chrome"===GetBrowser()){PutToDebugLog(2,"EVENT,"+webphone_api.stringres.get("jnotsupported")+"_3"),n=webphone_api.stringres.get("jnotsupported");var l=GetConfig("pc_alternatebrowserurl");!isNull(l)&&l.length>2&&(n=n+': <a href="'+l+'" target="_blank">'+l+"</a>"),a=!0}else n=webphone_api.stringres.get("ce_alert_user")+" "+GetEngineDisplayName(e)+".",n=n.replace("[BRAND]",GetBrandName());var s=webphone_api.stringres.get("btn_ok");e===webphone_api.global.ENGINE_SERVICE&&(s=webphone_api.stringres.get("btn_download")),n.indexOf(webphone_api.stringres.get("service_update"))>=0&&(n+='<br /><a id="efi_download_link" style="cursor:pointer;">Download NS -Service Plugin</a>');var p='<a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+s+"</a>";!0===t&&(p='<a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_cancel")+"</a>"+p);var c='<div data-role="popup" id="np_forcedinstall" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+r+'px;"><div data-role="header" data-theme="b"><h1 class="adialog_title" style="margin-left: 2.2em;">'+webphone_api.stringres.get("ce_alert_title")+'</h1></div><div role="main" class="ui-content adialog_content adialog_alert"><span> '+n+' </span></div><div data-role="footer" data-theme="b" class="adialog_footer">'+p+"</div></div>";o=o||function(){},webphone_api.$.mobile.activePage.append(c).trigger("create"),webphone_api.$.mobile.activePage.find(".messagePopup").bind({popupbeforeposition:function(){webphone_api.$(".ui-popup-screen").off(),webphone_api.$(this).unbind("popupbeforeposition");var e=Math.floor(.6*GetDeviceHeight());webphone_api.$(this).height()>e&&webphone_api.$(".messagePopup .ui-content").height(e)}}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$("#efi_download_link").off("click"),webphone_api.$(this).unbind("popupafterclose").remove(),PutToDebugLog(4,"EVENT, EngineForcedInstall popup closed")}}),webphone_api.$("#efi_download_link").on("click",function(e){PutToDebugLog(5,"EVENT, common EngineForcedInstall link click"),webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),i()}),webphone_api.$("#adialog_positive").on("click",function(e){!0!==a&&(PutToDebugLog(5,"EVENT, common EngineForcedInstall ok"),i())}),webphone_api.$("#adialog_negative").on("click",function(e){PutToDebugLog(5,"EVENT, common EngineForcedInstall 1 cancel"),o("cancel"),NPHandleCancel(),setTimeout(function(){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")},200)})}catch(u){PutToDebugLogException(2,"common: EngineForcedInstall",u)}}function GetAppEnProtocol(e){try{var n=GetConfig("app_protocol");if((isNull(n)||n.length<1)&&(n="webphone:"),n.indexOf(":")<1&&(n+=":"),n.indexOf("//")<1&&(n+="//"),"Mac"!==GetOs()&&"Linux"!==GetOs()||(n="sip://"),(isNull(n)||n.length<1)&&(n="webphone://"),n=n.toLowerCase(),!0===e){var t=GetParameter("callto");isNull(t)&&(t=""),t=Trim(t),n+=t}return n}catch(o){PutToDebugLogException(2,"common: GetAppEnProtocol",o)}return"webphone://"}function HandleProtocol(e){var n=0;try{if(PutToDebugLog(2,"EVENT, HandleProtocol called: "+e),!1===webphone_api.global.isdebugversion&&"iOS"!==GetOs()&&"Android"!==GetOs())return;n=1;var t=window.location;if(n=2,n=5,PutToDebugLog(2,"EVENT, HandleProtocol: "+e),"iOS"===GetOs())if(n=6,!0===IsWebphoneInIframe()){var o=GetNativeDialerUrl(GetOs());PutToDebugLog(2,"EVENT, HandleProtocol open protocol (iOS-iframe): "+o),window.open(o)}else PutToDebugLog(2,"EVENT, HandleProtocol open protocol (iOS): "+e),window.location=e;else if("Chrome"===GetBrowser()){var i=e;i=i.replace(":",""),i=i.replace("//",""),i=i.replace("\\","");var a=GetNativeDialerUrl(GetOs());a=a.toLowerCase();var r=a.indexOf("id=");r>0?(a=a.substring(r+3),r=a.indexOf("&"),r>0&&(a=a.substring(0,r)),r=a.indexOf("#"),r>0&&(a=a.substring(0,r)),a=Trim(a)):a="com.mizuvoip.mizudroid.app";var l=encodeURIComponent(GetNativeDialerUrl(GetOs())),s="intent://#Intent;scheme="+i+";apppackage="+a+";S.browser_fallback_url="+l+";end";PutToDebugLog(2,"EVENT, HandleProtocol for Chrome in Android: "+s),window.location=s}else{n=7;var p=document.getElementById("loader");if(isNull(p))return PutToDebugLog(1,"ERROR, HandleProtocol loader iframe is NULL"),void ShowToast("ERROR, app loader is not defined.");p.src=e}n=11,t=GetNativeDialerUrl(GetOs()),n=14,PutToDebugLog(2,"EVENT, HandleProtocol fallbackLink: "+t),redirect_timer=setTimeout(function(){try{n=15,PutToDebugLog(2,"EVENT, HandleProtocol open fallback link because could not open app"),window.location=t,n=16}catch(e){PutToDebugLogException(2,"common: HandleProtocol inner timer second( "+n+" ), fallbackLink: "+t,e)}},3e3),n=17,clear_timer=setInterval(function(){try{n=18,protocolmaxloop++;var e=window.document.hasFocus();n=17,(!e||document.hidden||protocolmaxloop>100)&&(n=21,protocolmaxloop=0,isNull(clear_timer)||clearInterval(clear_timer),clear_timer=null,n=22,isNull(redirect_timer)||clearTimeout(redirect_timer),redirect_timer=null,n=23,PutToDebugLog(2,"EVENT, HandleProtocol redirect timer cleared, because app was found and opened"))}catch(t){PutToDebugLogException(2,"common: HandleProtocol inner timer( "+n+" )",t)}},200),n=24}catch(c){PutToDebugLogException(2,"common: HandleProtocol( "+n+" )",c)}}function StartAppEngine(e,n,t,o){try{if(GetParameterInt("allow_start_app_engine",1)<1)return void PutToDebugLog(1,"STATUS, Skip app engine start, last start was cancelled");0===GetAppEnProtocol(t).indexOf("webphone:")?(UploadAutoprov(),setTimeout(function(){StartAppEnginePopup(e,n,t,o)},600)):StartAppEnginePopup(e,n,t,o)}catch(i){PutToDebugLogException(2,"common: StartAppEngine",i)}}function StartAppEnginePopup(e,n,t,o){try{var i=GetParameterInt("app_popup_displayed",0);if((!0!==e||i>0)&&("iOS"!==GetOs()||!0!==IsWebphoneInIframe()))return void StartAppEngineExec(e,n,t,o);var a=GetParameterInt("enginepriority_webrtc",2),r=GetParameterInt("enginepriority_app",2),l=GetParameterInt("enginepriority_p2p",2),s=GetParameterInt("enginepriority_accessnum",2);if((r>=5&&a<5&&l<5&&s<5||r>=2&&a<r&&l<r&&s<r)&&("iOS"!==GetOs()||!0!==IsWebphoneInIframe()))return void StartAppEngineExec(e,n,t,o);var p=webphone_api.stringres.get("app_en_message3");a<1&&(p=webphone_api.stringres.get("app_en_message2")),i+=1,SaveParameter("app_popup_displayed",i.toString());var c=GetDeviceWidth();c=!isNull(c)&&IsNumber(c)&&c>100?Math.floor(c/1.2):220,c>400?c=400:c<120&&(c=120);var u='<div id="adialog_appenalert" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+c+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("warning")+'</h1></div><div role="main" class="ui-content adialog_content adialog_btn_nexttoinput"><span>'+p+'</span><div style="clear: both;">\x3c!--//--\x3e</div></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_ok")+'</a><a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_cancel")+"</a></div></div>";webphone_api.$.mobile.activePage.append(u).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#adialog_positive").off("click"),webphone_api.$("#adialog_negative").off("click")}}),webphone_api.$("#adialog_positive").on("click",function(i){StartAppEngineExec(e,n,t,o)}),webphone_api.$("#adialog_negative").on("click",function(e){PutToDebugLog(1,"STATUS, No engines to start."),ShowToast("ERROR, No engines to start!",8e3),PutToDebugLog(2,"ERROR, StartAppEngine user clicked cancel, so do NOT start APP engine"),SaveParameter("allow_start_app_engine","0")})}catch(g){PutToDebugLogException(2,"common: StartAppEngine",g)}}function StartAppEngineExec(e,n,t,o){try{void 0!==t&&null!==t||(t=!1),void 0!==o&&null!==o&&o.length>0&&Trim(o),function(e,n,t){try{webphone_api.global.isappenginestarted=!0,!isNull(e)&&e.length>0&&PutToDebugLog(2,e),isNull(t)&&(t=""),HandleProtocol(GetAppEnProtocol(n)+t)}catch(o){PutToDebugLogException(2,"common: StartAE",o)}}(n,t,o)}catch(i){PutToDebugLogException(2,"common: StartAppEngineExec",i)}}function Phone2Phone(e,n){try{var t=GetParameter("p2p");if(0!==Trim(t).indexOf("*"))return void OpenWebURL(t,webphone_api.stringres.get("p2p"));var o=GetDeviceWidth();o=!isNull(o)&&IsNumber(o)&&o>100?Math.floor(o/1.2):220,o>400?o=400:o<120&&(o=120),isNull(e)&&(e=""),isNull(n)&&(n="");var i='<div id="adialog_p2p" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+o+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("p2p")+'</h1></div><div role="main" class="ui-content adialog_content"><span>'+webphone_api.stringres.get("p2p_nra")+'</span><input type="text" id="phonea_input" name="phonea_input" value="'+e+'" data-theme="a" autocapitalize="off"/><span>'+webphone_api.stringres.get("p2p_nrb")+'</span><input type="text" id="phoneb_input" name="phoneb_input" value="'+n+'" data-theme="a" autocapitalize="off"/></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_ok")+'</a><a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_cancel")+"</a></div></div>";webphone_api.$.mobile.activePage.append(i).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#adialog_positive").off("click"),webphone_api.$("#adialog_negative").off("click")}});var a=document.getElementById("phonea_input"),r=document.getElementById("phoneb_input");isNull(a)||a.focus(),webphone_api.$("#adialog_positive").on("click",function(e){PutToDebugLog(5,"EVENT, _dialpad Phone2Phone 1 ok");var n=a.value,t=r.value;return isNull(n)||Trim(n).length<1?void ShowToast(webphone_api.stringres.get("p2p_err1")):(n=Trim(n),isNull(t)||Trim(t).length<1?void ShowToast(webphone_api.stringres.get("p2p_err2")):(t=Trim(t),void UriParser(GetParameter("p2p"),"",n,t,"","phone2phone")))}),webphone_api.$("#adialog_negative").on("click",function(e){})}catch(l){PutToDebugLogException(2,"common: Phone2Phone",l)}}function AlertDialogSDK(e,n,t,o){try{if(1==GetParameterInt("disablepopup",-1))return void PutToDebugLog(1,e+", "+n);if(!isNull(admodal))return void admodal.show();isNull(o)&&(o=webphone_api.stringres.get("btn_ok")),admodal=webphone_api.picoModal({content:'<div id="ce_modal" class="pmodal_container"><div id="ce_modal_header" class="pmodal_header">'+e+'</div><div id="ce_modal_content" class="pmodal_content" style="padding: 1em;"><div id="ce_modal_content_inner">'+n+'</div></div><div id="ce_modal_footer" class="pmodal_footer"><button id="btn_close_adialog">'+o+"</button></div></div>",overlayStyles:{backgroundColor:"#565656",opacity:.6},modalStyles:{},overlayClose:!1,closeStyles:{background:"#eeeeee",position:"absolute",top:".2em",right:".3em",textAlign:"center",fontSize:"1.2em",fontWeight:"bold",border:".15em solid #bbb",borderRadius:".8em",paddingLeft:".25em",paddingRight:".25em",cursor:"pointer"}}).afterCreate(function(e){}).beforeShow(function(e,n){}).afterShow(function(e){}).beforeClose(function(e,n){}).afterClose(function(e){e.destroy(),admodal=null}),admodal.show(),webphone_api.$("#btn_close_adialog").on("click",function(){admodal.close(),t&&"function"==typeof t&&(t(!0),t=null)})}catch(i){PutToDebugLogException(2,"common: AlertDialogSDK",i)}}function ShowToastSDK(e,n){try{if(!isNull(toastmodal))return void toastmodal.show();toastmodal=webphone_api.picoModal({content:'<div id="ce_modal" class="pmodal_container"><div id="ce_modal_content" class="modal_content" style="font-size: .8em; padding: .7em;"><div id="ce_modal_content_inner" style="margin-right: 1.6em;">'+e+"</div></div></div>",overlayStyles:{backgroundColor:"#565656",opacity:.6},modalStyles:{padding:"0",margin:"0",border:".2em solid #d8d8d8",borderRadius:".5em",width:"auto",background:"#ffffff",fontFamily:"sans-serif"},overlayClose:!1,closeStyles:{background:"#eeeeee",position:"absolute",top:".2em",right:".3em",textAlign:"center",fontSize:"1.2em",fontWeight:"bold",border:".15em solid #bbb",borderRadius:".8em",paddingLeft:".25em",paddingRight:".25em",cursor:"pointer"}}).afterCreate(function(e){}).beforeShow(function(e,n){}).afterShow(function(e){}).beforeClose(function(e,n){}).afterClose(function(e){e.destroy(),toastmodal=null}),toastmodal.show(),webphone_api.$("#btn_close_adialog").on("click",function(){toastmodal.close()}),isNull(n)&&(n=3e3),n>0&&setTimeout(function(){isNull(toastmodal)||toastmodal.close()},n)}catch(t){PutToDebugLogSpecial(2,"common: ShowToastSDK",!0,t)}}function LcAc(e,n){try{if(IsWindowsSoftphone()||!webphone_api.global.usestorage)return!0;if(e&&isNull(lctmr))return lctmr=setTimeout(function(){lcsexp=1},36e5),!0;var t=1;!0===SvCont()&&!0===WbCont()?t=5:!0===SvCont()?t=3:!0===WbCont()&&(t=2);if(lccsenr>15*t&&(lcsexp=2),!0===n){var o=GetParameter("lccnr");if(!isNull(o)&&o.length>0){o=Trim(o);var i=0;try{i=StrToInt(o)}catch(c){PutToDebugLogException(2,"_call: convert to int",c)}var a=t;a>1&&(a/=2),a*=300,i>a?lcsexp=3:(i++,lccsenr++,SaveParameter("lccnr",i.toString()))}else SaveParameter("lccnr","1");if(o=GetParameter("lccnrv"+webphone_api.global.versionstr),!isNull(o)&&o.length>0){o=Trim(o);var i=0;try{i=StrToInt(o)}catch(c){PutToDebugLogException(2,"_call: convert to int",c)}var a=t;a>1&&(a/=2),a*=100,i>a?lcsexp=4:(i++,lccsenr++,SaveParameter("lccnrv"+webphone_api.global.versionstr,i.toString()))}else SaveParameter("lccnrv"+webphone_api.global.versionstr,"1")}if(lcsexp>0){var r=[];r.push("D"),r.push("e"),r.push("m"),r.push("o "),r.push("l"),r.push("i"),r.push("m"),
r.push("i"),r.push("t "),r.push("r"),r.push("e"),r.push("a"),r.push("c"),r.push("h"),r.push("e"),r.push("d"),r.push(". "),r.push("("),r.push(lcsexp.toString()),r.push(")"),r.push(" "),lcsexp<3&&(r.push("P"),r.push("l"),r.push("e"),r.push("a"),r.push("s"),r.push("e "),r.push("r"),r.push("e"),r.push("s"),r.push("t"),r.push("a"),r.push("r"),r.push("t "),r.push("t"),r.push("h"),r.push("e "),r.push("b"),r.push("r"),r.push("o"),r.push("w"),r.push("s"),r.push("e"),r.push("r "),r.push("t"),r.push("o "),r.push("c"),r.push("o"),r.push("n"),r.push("t"),r.push("i"),r.push("n"),r.push("u"),r.push("e "),r.push("t"),r.push("e"),r.push("s"),r.push("t"),r.push("i"),r.push("n"),r.push("g"),r.push(". ")),r.push("\n<br>"),r.push("C"),r.push("o"),r.push("n"),r.push("t"),r.push("a"),r.push("c"),r.push("t "),r.push("M"),r.push("i"),r.push("z"),r.push("u"),r.push("t"),r.push("e"),r.push("c"),r.push("h "),r.push("f"),r.push("o"),r.push("r"),r.push(" "),r.push("a"),r.push(" "),r.push("t"),r.push("r"),r.push("i"),r.push("a"),r.push("l"),r.push(" "),r.push("o"),r.push("r"),r.push(" "),r.push("t"),r.push("o "),r.push("b"),r.push("u"),r.push("y "),r.push("a "),r.push("l"),r.push("i"),r.push("c"),r.push("e"),r.push("n"),r.push("s"),r.push("e"),r.push("d "),r.push("c"),r.push("o"),r.push("p"),r.push("y"),r.push(": "),r.push("\n<br>"),r.push("s"),r.push("u"),r.push("p"),r.push("p"),r.push("o"),r.push("r"),r.push("t"),r.push("@"),r.push("m"),r.push("i"),r.push("z"),r.push("u"),r.push("-"),r.push("v"),r.push("o"),r.push("i"),r.push("p"),r.push("."),r.push("c"),r.push("o"),r.push("m");var l=r.join(""),s=[];s.push("D"),s.push("e"),s.push("m"),s.push("o");var p=s.join("");return setTimeout(function(){AlertDialog(p,l)},950),!1}}catch(c){PutToDebugLogException(2,"common: LcAc",c)}return!0}function GetServerForHttpReq(){var e="";try{e=GetParameter("serveraddress_user");var n=GetParameter("upperserver");return(GetConfigInt("cfgusetunneling",0)>0||!isNull(e)&&e.length>0&&e.indexOf(".")<1&&e.indexOf(":")<0)&&!isNull(n)&&n.length>1&&(e=n),(isNull(e)||e.length<1)&&(e=GetParameter2("serveraddress"),(isNull(e)||e.length<1)&&(e=GetParameter("serveraddress_user")),(isNull(e)||e.length<1)&&(e=GetParameter("serveraddress_orig")),(isNull(e)||e.length<1)&&(e=GetConfig("serveraddress")),(isNull(e)||e.length<1)&&(e=GetProxyaddress("")),(isNull(e)||e.length<1)&&(e=GetWebrtcUpperServer("")),(isNull(e)||e.length<1)&&(e=GetParameter("upperserver")),GetConfigInt("cfgusetunneling",0)>0&&!isNull(GetConfig("upperserver"))&&GetConfig("upperserver").length>1&&(e=GetConfig("upperserver"))),isNull(e)&&(e=""),AddressHasPort(e)&&(e=GetIPFromAddressSimple(e)),e}catch(t){PutToDebugLogException(2,"common: GetServerForHttpReq",t)}return""}function GetProxyaddress(e){try{var n="";if(!isNull(e)&&e.length>0)n=e;else{if((isNull(n)||n.length<3)&&(n=GetConfig("proxyaddress")),!isNull(n)&&n.length>2&&n.indexOf(":")<1){var t=GetConfig("serverport");!isNull(t)&&t.length>0&&"5060"!==t&&(n=GetIPEnclosed(n)+":"+t)}(isNull(n)||n.length<3)&&(n=GetParameter("proxyaddress"))}return isNull(n)&&(n=""),n=RemoveProtocolString(n)}catch(o){PutToDebugLogException(2,"common: GetProxyaddress",o)}return""}function GetWebrtcUpperServer(e){var n=0;try{n=1;var t="",o=GetParameter("upperserverip");if(!isNull(o)&&Trim(o).length>0)return o;if(n=2,!0!==e){n=3;var i=GetParameter("upperserverdomain");if(!isNull(i)&&Trim(i).length>0)return i}n=4;var a=GetConfig("wsuser");if(!isNull(a)&&a.length>10){if(n=5,o=GetUrlParamVal("upperserverip"),i=GetUrlParamVal("upperserverdomain"),!isNull(o)&&Trim(o).length>0)return o;if(!0!==e&&!isNull(i)&&Trim(i).length>0)return i}n=6;var r=GetWsAddressCfg();if(isNull(r)||r.length<2){n=7,t=GetParameter("serveraddress_user");var l=GetParameter("upperserver");return(GetConfigInt("cfgusetunneling",0)>0||!isNull(t)&&t.length>0&&t.indexOf(".")<1&&t.indexOf(":")<0)&&!isNull(l)&&l.length>1&&(t=l),Trim(t)}return n=8,t=GetParameter2("serveraddress"),(isNull(t)||t.length<1)&&(t=GetParameter("serveraddress_user")),(isNull(t)||t.length<1)&&(t=GetParameter("serveraddress_orig")),(isNull(t)||t.length<1)&&(t=GetConfig("serveraddress")),n=9,GetConfigInt("cfgusetunneling",0)>0&&!isNull(GetConfig("upperserver"))&&GetConfig("upperserver").length>1&&(t=GetConfig("upperserver")),t}catch(s){PutToDebugLogException(2,"common: GetWebrtcUpperServer "+n,s)}return""}function GetWebrtcSyUpperHeader(e){try{var n=GetParameter("jsupperserver");if((isNull(n)||n.length<1)&&(n=GetWebrtcUpperServer(!0)),!isNull(n)&&n.length>0){var t=GetConfig("transport");if(IsNumber(t))switch(t){case 0:n="udp:"+n;break;case 1:n="tcp:"+n;break;case 2:n="tls:"+n}return n}PutToDebugLog(2,"WARNING, GetWebrtcUpperServer is NULL ("+e+")")}catch(o){PutToDebugLogException(2,"common: GetWebrtcSyUpperHeader",o)}return""}function GetWebrtcSyUpperDomainHeader(e){try{var n=GetParameter("upperserverd");isNull(n)&&(n="");var t=GetConfig("wsuser");if(!isNull(t)&&t.length>10){var o=GetParameter("upperserverdomain");if(!isNull(o)&&Trim(o).length>0)return o}if(n.length>0){var i=GetConfig("transport");if(IsNumber(i))switch(i){case 0:n="udp:"+n;break;case 1:n="tcp:"+n;break;case 2:n="tls:"+n}return n}}catch(a){PutToDebugLogException(2,"common: GetWebrtcSyUpperHeader",a)}return""}function GetUpperProxyHeaderForSignaling(){var e="";try{if(e=GetParameter("upperproxy"),!isNull(e)&&Trim(e).length>0)return e;if(e=GetParameter("proxyaddress"),!isNull(e)&&Trim(e).length>0)return e;var n=GetConfig("wsuser");if(!isNull(n)&&n.length>10&&(e=GetUrlParamVal(n,"proxyaddress"),!isNull(e)&&Trim(e).length>0))return e}catch(t){PutToDebugLogException(2,"common: GetUpperProxyHeaderForSignaling",t)}return""}function GetWebrtcSrvAddr(){return GetBestWsAddress()}function GetUsableWebrtcSrvAddr(){var e=GetWsAddressCfg();if(!isNull(e)&&e.length>3)return e;var n=getuseengine();if(isNull(n)||n.length<1);else if(n===webphone_api.global.ENGINE_WEBRTC)return e=GetWebrtcSrvAddr(),!isNull(e)&&e.length,e;return""}function HandleAddress(e){try{if(isNull(e)||e.length<1)return"";e=e.toLowerCase(),e=Trim(e);var n=!1;location.host.toLowerCase();!0!==PreferWss()&&!0!==IsHttps()||(n=!0),!0===n&&0===e.indexOf("ws:")&&(e=e.replace("ws:","wss:")),e.indexOf("ws:")<0&&e.indexOf("wss:")<0&&(e=!0===n?"wss://"+e:"ws://"+e),e.indexOf("?")>0&&(e=e.substring(0,e.indexOf("?")))}catch(t){PutToDebugLogException(2,"common: HandleAddress",t)}return e}function AddWsAddress(e,n){try{if(isNull(e)||!e.address||isNull(e.address)||e.address.length<4)return void PutToDebugLog(2,"ERROR, AddWsAddress invalid object");if(isNull(wsrvL)&&(wsrvL=[]),wsrvL.length>0)for(var t=0;t<wsrvL.length;t++)if(wsrvL[t].address===e.address)return void(wsrvL[t].answertime<2&&(wsrvL[t].answertime=e.answertime,wsrvL[t].load=e.load));var o=GetParameter("lastwebrtcserver");!isNull(o)&&o.length>3&&o===e.address&&(e.answertime=e.answertime-20),o=GetParameter("topprioritywebrtcserver"),!isNull(o)&&o.length>3&&o===e.address&&(e.answertime=e.answertime-20),wsrvL.push(e),GetBestWsAddress(n)}catch(i){PutToDebugLogException(2,"common: AddWsAddress",i)}}function GetWsAddressCfg(e,n,t){var o;if((isNull(e)||e<2)&&void 0!==(o=selectedwserver)&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 1 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=GetParameter("webrtcserveraddress"))&&null!==o&&o.length>3&&0==o.indexOf("ws")&&o.indexOf(",")<0)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 2 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=webphone_api.parameters.webrtcserveraddress)&&null!==o&&o.length>3&&0==o.indexOf("ws")&&o.indexOf(",")<0)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 3 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(webphone_api.global.pgw_decide_finished&&webphone_api.global.pgw_selected>=0&&webphone_api.global.waitingforusukdecide<=0&&(isNull(e)||e<1)){var i=PGW_Get(webphone_api.global.pgw_selected,PGW_ADDRESS);if(i.length>0)return isNull(n)||!1!==n?!0===BrowserRequiresHttps(!0,!0)?(o="wss://"+i+"/mfstwebsock",CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 4 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o):(o="ws://"+i+"/mfstwebsock",CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 5 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o):(o="wss://"+i+"/mfstwebsock",CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 6 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o);CanLog(5)&&PutToDebugLog(5,"EVENT, (warn) no pgw at getwscfg for "+webphone_api.global.pgw_selected.toString()+" / "+e.toString())}if(void 0!==(o=GetParameter("webrtcserveraddress"))&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 7 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=webphone_api.parameters.webrtcserveraddress)&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 8 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=GetParameter("origwebrtcserveraddress"))&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 9 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=GetParameter("webrtcserver"))&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 10 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=GetParameter("webrtcaddress"))&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 11 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=GetParameter("rtcserver"))&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 12 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=GetParameter("rtcaddress"))&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 13 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=webphone_api.parameters.webrtcserver)&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 14 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=webphone_api.parameters.webrtcaddress)&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 15 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=webphone_api.parameters.rtcserver)&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 16 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(void 0!==(o=webphone_api.parameters.rtcaddress)&&null!==o&&o.length>3)return CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 17 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o;if(!isNull(t)&&1==t&&(webphone_api.global.pgw_selected>=0||GetParameterOrConfigInt("ismrtcgateway",0)>0)){var a=webphone_api.global.pgw_selected;a<0&&(a=0);var i=PGW_Get(a,PGW_ADDRESS);if(i.length>0)return isNull(n)||!1!==n?!0===BrowserRequiresHttps(!0,!0)?(o="wss://"+i+"/mfstwebsock",CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 18 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o):(o="ws://"+i+"/mfstwebsock",CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 19 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o):(o="wss://"+i+"/mfstwebsock",CanLog(6)&&(o!=oldwsaddrtmp||oldwsaddrtmp.length<1)&&(PutToDebugLog(6,"EVENT, wscfg ret 20 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o)}return o="",CanLog(6)&&o!=oldwsaddrtmp&&(PutToDebugLog(6,"EVENT, wscfg ret 21 "+oldwsaddrtmp+" / "+o),oldwsaddrtmp=o),o}function GetSecureKey(){if(secure_key2.length>0)return secure_key2;try{secure_key2=Base64.decode(secure_key)}catch(e){}return secure_key2}function GetBestWsAddress(e){try{if(!isNull(selectedwserver)&&selectedwserver.length>3)return CanLog(10)&&PutToDebugLog(10,"EVENT, GetBestWsAddress ret A "+selectedwserver),selectedwserver;var n=GetWsAddressCfg();if(void 0!==n&&null!==n&&n.length>3&&n.indexOf(",")<0)return CanLog(10)&&PutToDebugLog(10,"EVENT, GetBestWsAddress ret B "+n),selectedwserver=n;var t=!0;if(MightUseEngine("webrtc")||MightUseEngine("flash")||(PutToDebugLog(5,"EVENT, might not use engine webrtc and flash"),t=!1),t||(decide_already_run=!0),!1===decide_already_run)return CanLog(10)&&PutToDebugLog(10,"EVENT, GetBestWsAddress calling DecideWebrtcServer"),DecideWebrtcServer(),"";if(CanLog(10)&&PutToDebugLog(10,"EVENT, GetBestWsAddress decide_already_run"),!1===t)return CanLog(10)&&PutToDebugLog(10,"EVENT, GetBestWsAddress needwsaddress false"),"";if(!0===e){if(!isNull(wsrvL)&&!isNull(wsrvL[0])&&!isNull(wsrvL[0].address)&&wsrvL[0].address.length>0){CanLog(10)&&PutToDebugLog(10,"EVENT, GetBestWsAddress is isthirdparty A"),decide_already_run=!0,selectedwserver=wsrvL[0].address;var o=wsrvL[0].load;return webphone_api.global.recwsload!=o&&o>=0&&o<=7&&(webphone_api.global.recwsload=o,SaveParameter("lastrecwsload",o)),wsrvL[0].apikey.length>0&&(webphone_api.global.selected_apikey=wsrvL[0].apikey),!0===e&&SaveParameter("lastwebrtcserver",selectedwserver),selectedwserver}return CanLog(10)&&PutToDebugLog(10,"EVENT, GetBestWsAddress is isthirdparty B"),""}isNull(addrtimer)&&(ADDR_TIMERSTART=GetTickCount(),addrtimer=setInterval(function(){if(addr_maxloop>60||!isNull(selectedwserver)&&selectedwserver.length>3)return isNull(addrtimer)||clearInterval(addrtimer),void(addrtimer=null);var e=null;if(!isNull(wsrvL)&&wsrvL.length>0)for(var n=0;n<wsrvL.length;n++)!0!==wsrvL[n].worked||wsrvL[n].load<0||(isNull(e)&&wsrvL[n].answertime<9e4&&wsrvL[n].load<2||e.answertime>wsrvL[n].answertime&&wsrvL[n].load<2)&&(e=wsrvL[n]);if(isNull(e)){var t=GetTickCount(),o=!0,i=!1;wsrvL.length<1&&(o=!1);for(var n=0;n<wsrvL.length;n++)wsrvL[n].load<0?o=!1:i=!0;if(!0===o||t-ADDR_TIMERSTART>=3e3&&!0===i||t-ADDR_TIMERSTART>=6e3){for(var a=wsrvL.length,r=0,n=0;n<a&&(wsrvL[n].load<0&&(wsrvL.push(wsrvL.splice(n,1)[0]),n<a-1&&n--),!(++r>3*a));n++);for(var n=0;n<a;n++)for(var l=n+1;l<a;l++)if(wsrvL[n].load>-1&&wsrvL[l].load>-1&&wsrvL[n].load>wsrvL[l].load){var s=wsrvL[n];wsrvL[n]=wsrvL[l],wsrvL[l]=s}for(var p=-1,n=0;n<a;n++)wsrvL[n].load<0||(p<0&&(p=wsrvL[n].load),isNull(e)&&(e=wsrvL[n]),wsrvL[n].load>p||e.answertime>wsrvL[n].answertime&&(e=wsrvL[n]))}if(!isNull(e)){selectedwserver=e.address;var c=e.load;webphone_api.global.recwsload!=c&&c>=0&&c<=7&&(webphone_api.global.recwsload=c,SaveParameter("lastrecwsload",c)),e.apikey.length>0&&(webphone_api.global.selected_apikey=e.apikey),isNull(addrtimer)||clearInterval(addrtimer),addrtimer=null;var u=PGW_GetGwIndex(selectedwserver);if(u>=0&&u!=webphone_api.global.pgw_selected&&(CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw set pgw_selected B from: "+webphone_api.global.pgw_selected.toString()+" to: "+u.toString()),webphone_api.global.pgw_selected=u),!webphone_api.global.pgw_decide_finished&&c<4){webphone_api.global.pgw_decide_finished=!0;var g=GetWsAddressCfg();g.length>0&&SaveParameter("lastwebrtcserver",g),PutToDebugLog(5,"EVENT, decidegw select finished on fastest2 "+g),OnDecideUsUkFinished(u)}}}else{selectedwserver=e.address;var c=e.load;webphone_api.global.recwsload!=c&&c>=0&&c<=7&&(webphone_api.global.recwsload=c,SaveParameter("lastrecwsload",c)),e.apikey.length>0&&(webphone_api.global.selected_apikey=e.apikey),isNull(addrtimer)||clearInterval(addrtimer),addrtimer=null;var u=PGW_GetGwIndex(selectedwserver);if(u>=0&&webphone_api.global.pgw_selected!=u&&(CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw set pgw_selected A from: "+webphone_api.global.pgw_selected.toString()+" to: "+u.toString()),webphone_api.global.pgw_selected=u),!webphone_api.global.pgw_decide_finished&&c<4){webphone_api.global.pgw_decide_finished=!0;var g=GetWsAddressCfg();g.length>0&&SaveParameter("lastwebrtcserver",g),CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw select finished on fastest1 "+g),OnDecideUsUkFinished(u)}}},100))}catch(i){PutToDebugLogException(2,"common: GetBestWsAddress",i)}return""}function GetSpecialWsloadUrl(e){try{var n=GetWsloadUrl(GetSipusername(!0)),t=n.indexOf("://");if(t>0){var o=n.substring(0,t+3),i=n.substring(t+3);i=i.substring(i.indexOf("/"));n=o+NormalizeInput(e,0)+i}return n=n.replace("/mfstwebsock","/mvstwebsock")}catch(a){PutToDebugLogException(2,"common: GetSpecialWsloadUrl",a)}return""}function ClassWServers(){this.address="",this.worked=!1,this.answertime=99999,this.load=-1,this.apikey=""}function DecideWebrtcServer(){try{if(!isNull(selectedwserver)&&selectedwserver.length>3)return void(CanLog(10)&&PutToDebugLog(10,"EVENT, DecideWebrtcServer ret A "+selectedwserver));if(!0===decide_already_run)return void PutToDebugLog(5,"EVENT, DecideWebrtcServer already run");var e=GetWsAddressCfg(),n=GetParameter("lastwebrtcserver"),t=GetParameter("topprioritywebrtcserver"),o="";webphone_api.global.pgw_selected>=0&&(o=PGW_Get(webphone_api.global.pgw_selected,PGW_ADDRESS));var i=GetParameter("lastbadwebrtcserver");if(isNull(n)&&(i=""),isNull(t)&&(i=""),isNull(o)&&(i=""),isNull(i)&&(i=""),e.length<4){if(t.length>0)return void(CanLog(10)&&PutToDebugLog(10,"EVENT, DecideWebrtcServer skip with top "+t+" ("+n+"/"+o+"/"+i+")"));if(o.length>0&&i!=o)return void(CanLog(10)&&PutToDebugLog(10,"EVENT, DecideWebrtcServer skip with curr "+o+" ("+t+"/"+n+"/"+i+")"));if(n.length>0&&i!=n)return void(CanLog(10)&&PutToDebugLog(10,"EVENT, DecideWebrtcServer skip with last "+n+" ("+t+"/"+o+"/"+i+")"));if(!IsMizuPublicWebRTCGateway())return void(CanLog(10)&&PutToDebugLog(10,"EVENT, DecideWebrtcServer skip with nonmz "+n+" / "+t));e="";for(var a=PGW_Get_Count(),r=0;r<a;r++){var l=PGW_Get(r,PGW_ADDRESS);l.length<1||!1!==PGW_Get(r,PGW_TRY)&&(e.length>0&&(e+=","),e=e+"ws://"+l+"/mfstwebsock")}CanLog(10)&&PutToDebugLog(10,"EVENT, DecideWebrtcServer set "+e+" / "+n+" / "+t)}if(PutToDebugLog(5,"EVENT, DecideWebrtcServer "+e),e.indexOf(",")<0){e.indexOf("://")<0&&(e=UseSecureSrvConnection()||!1===IsIPAddrress(e)?"wss://"+e:"ws://"+e),selectedwserver=e;var s="",p=selectedwserver.indexOf("authkey=");if(p>0){s=selectedwserver.substring(p+8),selectedwserver=selectedwserver.substring(0,p),isNull(s)&&(s=""),p=s.indexOf("&"),p>0&&(s=s.substring(0,p)),s=Trim(s),webphone_api.global.selected_apikey=s;var r=PGW_GetGwIndex(selectedwserver);if(r>=0&&webphone_api.global.pgw_selected!=r&&(CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw set pgw_selected C from: "+webphone_api.global.pgw_selected.toString()+" to: "+r.toString()),webphone_api.global.pgw_selected=r),!webphone_api.global.pgw_decide_finished){webphone_api.global.pgw_decide_finished=!0;var c=GetWsAddressCfg();c.length>0&&SaveParameter("lastwebrtcserver",c),PutToDebugLog(5,"EVENT, decidegw select finished on single "+c),OnDecideUsUkFinished(r)}}return}for(var u=e.split(","),g=0;g<u.length;)isNull(u[g])||u[g].length<4?u.splice(g,1):g++;if(isNull(u)||u.length<1)return;for(var h=!0,m=u.length,d=0;d<m;d++)if(u[d].toLowerCase().indexOf("mfstwebsock")<1&&u[d].toLowerCase().indexOf("mvstwebsock")<1){h=!1;break}if(u=ShuffleArray(u),!isNull(t)&&t.length>0)for(var d=0;d<m;d++)if(u[d]===t){var b=u.splice(d,1);u.unshift(b);break}if(!isNull(n)&&n.length>0)for(var d=0;d<m;d++)if(u[d]===n){var b=u.splice(d,1);u.unshift(b);break}var _=GetTickCount();if(wsrvL=[],isNull(addrtimer)||clearInterval(addrtimer),addrtimer=null,addr_maxloop=0,decide_already_run=!0,!0===h)for(var d=0;d<m;d++)!function(){function e(){!isNull(s)&&s.close&&s.close(),s=null}var n=d,t=new ClassWServers;try{var o=u[n],i="",a=o.indexOf("authkey=");a>0&&(i=o.substring(a+8),isNull(i)&&(i=""),a=i.indexOf("&"),a>0&&(i=i.substring(0,a)),i=Trim(i));var r=!1;o.indexOf("mfstwebsock")>0&&(r=!0);var l=HandleAddress(o);t.address=l,t.apikey=i,PutToDebugLog(2,"EVENT, DecideWebrtcServer ("+n+") url: "+l);var s=new WebSocket(l,"sip");s.binaryType="arraybuffer",s.onopen=function(){c=!0};var p=0,c=!1,g=setInterval(function(){p++,1===s.readyState&&!0===c&&!0===r&&(m=GetTickCount(),s.send("mrtcping\r\n")),(p>25||1===s.readyState)&&(isNull(g)||clearInterval(g),g=null)},100),h=-1,m=0;s.onerror=function(){t.worked=!1,AddWsAddress(t)},s.onclose=function(){t.worked=!1,AddWsAddress(t)},s.onmessage=function(o){var i=null;if(isNull(o)||(i=o.data),!isNull(i)){var r=ArrayBufferToString(i);if(r=r.toLowerCase(),r.indexOf("mrtcpong")>=0){h=GetTickCount()-m,t.answertime=h;var p=GetSpecialWsloadUrl(l);PutToDebugLog(2,"EVENT, DecideWebrtcServer send wsload ("+n+") address: "+l+"; answertime: "+h.toString()+"; url: "+p),s.send(p+"\r\n")}else{var c=r;if((a=c.indexOf("ws load:"))>=0){c=c.substring(a+8),c=Trim(c),a=c.indexOf(" "),a>0&&(c=c.substring(0,a));var u=-1;!isNull(c)&&IsNumber(c)&&(u=StrToInt(c)),t.load=u,PutToDebugLog(2,"EVENT, DecideWebrtcServer rec wsload ("+n+") url: "+l+"; answertime: "+h.toString()+"; load: "+c),AddWsAddress(t),e()}}}},setTimeout(function(){e()},6500)}catch(b){t.worked=!1,PutToDebugLogException(2,"DecideWebrtcServer ("+n+") failure",b)}}();else{var f=0;if(f<m){var w=f,v=new ClassWServers;try{var E=HandleAddress(u[w]);v.address=E,PutToDebugLog(2,"EVENT, DecideWebrtcServerT ("+w+") url: "+E);var P=new WebSocket(E,"sip");P.binaryType="arraybuffer",P.onopen=function(){var e=GetTickCount()-_;v.answertime=e,v.worked=!0,PutToDebugLog(2,"EVENT, DecideWebrtcServerT onopen ("+w+") url: "+E+"; answertime: "+e.toString()),!isNull(P)&&P.close&&P.close(),P=null,AddWsAddress(v,!0)}}catch(T){v.worked=!1,PutToDebugLogException(2,"DecideWebrtcServerT ("+w+") failed to connect",T)}}if(++f<m){var w=f,v=new ClassWServers;try{var E=HandleAddress(u[w]);v.address=E,PutToDebugLog(2,"EVENT, DecideWebrtcServerT ("+w+") url: "+E);var P=new WebSocket(E,"sip");P.binaryType="arraybuffer",P.onopen=function(){var e=GetTickCount()-_;v.answertime=e,v.worked=!0,PutToDebugLog(2,"EVENT, DecideWebrtcServerT onopen ("+w+") url: "+E+"; answertime: "+e.toString()),!isNull(P)&&P.close&&P.close(),P=null,AddWsAddress(v,!0)}}catch(T){v.worked=!1,PutToDebugLogException(2,"DecideWebrtcServerT ("+w+") failed to connect",T)}}if(++f<m){var w=f,v=new ClassWServers;try{var E=u[w];v.address=E,PutToDebugLog(2,"EVENT, DecideWebrtcServerT ("+w+") url: "+E);var P=new WebSocket(E,"sip");P.binaryType="arraybuffer",P.onopen=function(){var e=GetTickCount()-_;v.answertime=e,v.worked=!0,PutToDebugLog(2,"EVENT, DecideWebrtcServerT onopen ("+w+") url: "+E+"; answertime: "+e.toString()),!isNull(P)&&P.close&&P.close(),P=null,AddWsAddress(v,!0)}}catch(T){v.worked=!1,PutToDebugLogException(2,"DecideWebrtcServerT ("+w+") failed to connect",T)}}if(++f<m){var w=f,v=new ClassWServers;try{var E=u[w];v.address=E,PutToDebugLog(2,"EVENT, DecideWebrtcServerT ("+w+") url: "+E);var P=new WebSocket(E,"sip");P.binaryType="arraybuffer",P.onopen=function(){var e=GetTickCount()-_;v.answertime=e,v.worked=!0,PutToDebugLog(2,"EVENT, DecideWebrtcServerT onopen ("+w+") url: "+E+"; answertime: "+e.toString()),!isNull(P)&&P.close&&P.close(),P=null,AddWsAddress(v,!0)}}catch(T){v.worked=!1,PutToDebugLogException(2,"DecideWebrtcServerT ("+w+") failed to connect",T)}}if(++f<m){var w=f,v=new ClassWServers;try{var E=u[w];v.address=E,PutToDebugLog(2,"EVENT, DecideWebrtcServerT ("+w+") url: "+E);var P=new WebSocket(E,"sip");P.binaryType="arraybuffer",P.onopen=function(){var e=GetTickCount()-_;v.answertime=e,v.worked=!0,PutToDebugLog(2,"EVENT, DecideWebrtcServerT onopen ("+w+") url: "+E+"; answertime: "+e.toString()),!isNull(P)&&P.close&&P.close(),P=null,AddWsAddress(v,!0)}}catch(T){v.worked=!1,PutToDebugLogException(2,"DecideWebrtcServerT ("+w+") failed to connect",T)}}if(++f<m){var w=f,v=new ClassWServers;try{var E=u[w];v.address=E,PutToDebugLog(2,"EVENT, DecideWebrtcServerT ("+w+") url: "+E);var P=new WebSocket(E,"sip");P.binaryType="arraybuffer",P.onopen=function(){var e=GetTickCount()-_;v.answertime=e,v.worked=!0,PutToDebugLog(2,"EVENT, DecideWebrtcServerT onopen ("+w+") url: "+E+"; answertime: "+e.toString()),!isNull(P)&&P.close&&P.close(),P=null,AddWsAddress(v,!0)}}catch(T){v.worked=!1,PutToDebugLogException(2,"DecideWebrtcServerT ("+w+") failed to connect",T)}}if(++f<m){var w=f,v=new ClassWServers;try{var E=u[w];v.address=E,PutToDebugLog(2,"EVENT, DecideWebrtcServerT ("+w+") url: "+E);var P=new WebSocket(E,"sip");P.binaryType="arraybuffer",P.onopen=function(){var e=GetTickCount()-_;v.answertime=e,v.worked=!0,PutToDebugLog(2,"EVENT, DecideWebrtcServerT onopen ("+w+") url: "+E+"; answertime: "+e.toString()),!isNull(P)&&P.close&&P.close(),P=null,AddWsAddress(v,!0)}}catch(T){v.worked=!1,PutToDebugLogException(2,"DecideWebrtcServerT ("+w+") failed to connect",T)}}if(++f<m){var w=f,v=new ClassWServers;try{var E=u[w];v.address=E,PutToDebugLog(2,"EVENT, DecideWebrtcServerT ("+w+") url: "+E);var P=new WebSocket(E,"sip");P.binaryType="arraybuffer",P.onopen=function(){var e=GetTickCount()-_;v.answertime=e,v.worked=!0,PutToDebugLog(2,"EVENT, DecideWebrtcServerT onopen ("+w+") url: "+E+"; answertime: "+e.toString()),!isNull(P)&&P.close&&P.close(),P=null,AddWsAddress(v,!0)}}catch(T){v.worked=!1,PutToDebugLogException(2,"DecideWebrtcServerT ("+w+") failed to connect",T)}}if(++f<m){var w=f,v=new ClassWServers;try{var E=u[w];v.address=E,PutToDebugLog(2,"EVENT, DecideWebrtcServerT ("+w+") url: "+E);var P=new WebSocket(E,"sip");P.binaryType="arraybuffer",P.onopen=function(){var e=GetTickCount()-_;v.answertime=e,v.worked=!0,PutToDebugLog(2,"EVENT, DecideWebrtcServerT onopen ("+w+") url: "+E+"; answertime: "+e.toString()),!isNull(P)&&P.close&&P.close(),P=null,AddWsAddress(v,!0)}}catch(T){v.worked=!1,PutToDebugLogException(2,"DecideWebrtcServerT ("+w+") failed to connect",T)}}if(++f<m){var w=f,v=new ClassWServers;try{var E=u[w];v.address=E,PutToDebugLog(2,"EVENT, DecideWebrtcServerT ("+w+") url: "+E);var P=new WebSocket(E,"sip");P.binaryType="arraybuffer",P.onopen=function(){var e=GetTickCount()-_;v.answertime=e,v.worked=!0,PutToDebugLog(2,"EVENT, DecideWebrtcServerT onopen ("+w+") url: "+E+"; answertime: "+e.toString()),!isNull(P)&&P.close&&P.close(),P=null,AddWsAddress(v,!0)}}catch(T){v.worked=!1,PutToDebugLogException(2,"DecideWebrtcServerT ("+w+") failed to connect",T)}}f++}}catch(S){PutToDebugLogException(2,"common: DecideWebrtcServer",S)}}function ShuffleArray(e){try{var n,t,o,i=e;for(o=i.length-1;o>0;o--)n=Math.floor(Math.random()*(o+1)),t=i[o],i[o]=i[n],i[n]=t;return i}catch(a){PutToDebugLogException(2,"common: ShuffleArray",a)}return e}function Engine(){this.name,this.cfg_priority,this.defpriority,this.available,this.serversupport,this.finalscore,this.finalscorex,this.pushlevel,this.failed,this.clicked,this.issupported_cache,this.isinstalled_cache,this.serversupport_cache,this.available_old,this.asyncreqbegintime,this.getwebrtcserversupportime}function ResetSelEngine(){selected_engine=null,selected_engine2=null,recommend_engine=null,webphone_api.global.lastengine_working_ok="",webphone_api.global.lastengine_started_ok="",webphone_api.global.last_used_engine_cache="",webphone_api.global.last_useengine="",webphone_api.global.useengine="",SaveParameter("lastusedengine",""),SaveParameter("prevusedengine","")}function GetLicenseOptions(){return licenseoption1+licenseoption2+licenseoption3+licenseoption4+licenseoption5+licenseoption6}function GetEngineList(){if(isNull(engines)){engines=[];var e=30;!1===CanIUseApplet()&&(e=.1);var n;n=new Engine,n.name="java",n.defpriority=GetEngineDefPriority("java",e),engines.push(n),n=new Engine,n.name="webrtc",n.defpriority=GetEngineDefPriority("webrtc",26),engines.push(n),n=new Engine,n.name="flash",n.defpriority=GetEngineDefPriority("flash",10),engines.push(n),n=new Engine,n.name="ns",n.defpriority=GetEngineDefPriority("ns",31),engines.push(n);var t=10;"Windows"!==GetOs()&&"Mac"!==GetOs()&&"Linux"!==GetOs()||(t=.1),n=new Engine,n.name="app",n.defpriority=GetEngineDefPriority("app",t),engines.push(n),n=new Engine,n.name="p2p",n.defpriority=GetEngineDefPriority("p2p",5),engines.push(n),n=new Engine,n.name="nativedial",n.defpriority=GetEngineDefPriority("nativedial",3),engines.push(n),n=new Engine,n.name="otherbrowser",n.defpriority=GetEngineDefPriority("otherbrowser",2),engines.push(n),n=new Engine,n.name="java_avail",n.defpriority=GetEngineDefPriority("java_avail",33),engines.push(n),n=new Engine,n.name="ns_avail",n.defpriority=GetEngineDefPriority("ns_avail",31),engines.push(n),n=new Engine,n.name="app_avail",n.defpriority=GetEngineDefPriority("app_avail",t),engines.push(n);for(var o=0;o<engines.length;o++)n=engines[o],n.pushlevel=-1,n.issupported_cache=-1,n.isinstalled_cache=-1,n.serversupport_cache=-1,n.failed=0,n.clicked=0,n.asyncreqbegintime=0,n.getwebrtcserversupportime=0,n.available_old=GetCfgOldAvailable(n.name)}return engines}function GetSelectedEngine(){return selected_engine}function GetRecommendedEngine(){return recommend_engine}function GetSelectedEngineName(){try{if(!isNull(selected_engine)&&!isNull(selected_engine.name))return selected_engine.name}catch(e){PutToDebugLogException(2,"common: GetSelectedEngineName",e)}return null}function GetRecommendedEngineName(){try{if(!isNull(recommend_engine)&&!isNull(recommend_engine.name))return recommend_engine.name}catch(e){PutToDebugLogException(2,"common: GetRecommendedEngineName",e)}return null}function GetEngine(e){try{if(isNull(engines))return null;for(var n,t=0;t<engines.length;t++)if(n=engines[t],n.name===e)return n;for(var t=0;t<engines.length;t++){if(n=engines[t],n.name+"_avail"===e)return n;if(n.name===e+"_avail")return n}for(var t=0;t<engines.length;t++)if((n=engines[t])===e)return n}catch(o){PutToDebugLogException(2,"common: GetEngine",o)}return null}function SetEngine(e,n){try{if(isNull(e)||e.length<1)return PutToDebugLog(2,"ERROR, common SetEngine invalid engine name: "+e),!1;if(isNull(n))return PutToDebugLog(2,"ERROR, common SetEngine invalid engine object"),!1;if(isNull(engines))return PutToDebugLog(2,"ERROR, common SetEngine engines is NULL"),!1;for(var t=0;t<engines.length;t++)engines[t].name===e&&(engines[t]=n)}catch(o){PutToDebugLogException(2,"common: GetEngine",o)}return!1}function ResetEngineClicked(){try{if(isNull(engines))return PutToDebugLog(2,"ERROR, common ResetEngineClicked engines is NULL"),!1;for(var e,n=0;n<engines.length;n++)e=engines[n],e.clicked=0,engines[n]=e}catch(t){PutToDebugLogException(2,"common: ResetEngineClicked",t)}}function HasUsableEngine(e){try{if(isNull(engines))return!1;for(var n,t=0;t<engines.length;t++)if(n=engines[t],n.available>1&&n.failed<1&&e.name!==n.name&&n.name.indexOf("_avail")<0&&n.defpriority>0)return!0}catch(o){PutToDebugLogException(2,"common: HasUsableEngine",o)}return!1}function HasUsableEngineFromEngines(e,n){try{if(isNull(engines))return!1;for(var t,o=0;o<engines.length;o++)if(t=engines[o],!(n.indexOf(t.name)<0)&&t.available>1&&t.failed<1&&e.name!==t.name&&t.name.indexOf("_avail")<0&&t.defpriority>0)return!0}catch(i){PutToDebugLogException(2,"common: HasUsableEngineFromEngines",i)}return!1}function IsMizuPublicWebRTCGateway(){return IsMizuPublicWebRTCGatewayIntern(!0)}function IsMizuPublicWebRTCGatewayUsed(){return IsMizuPublicWebRTCGatewayIntern(!1)}function IsMizuReallyPublicWebRTCGatewayAddress(e){return!(isNull(e)||e.length<3)&&((e.indexOf(".webvoipphone.com")>=0||e.indexOf(".mizu-voip.com")>=0)&&e.indexOf("rtc")>=0&&e.indexOf("local")<0&&e.indexOf("private")<0&&e.indexOf("intra")<0&&e.indexOf("intern")<0)}function IsMizuReallyPublicWebRTCGateway(){return IsMizuPublicWebRTCGatewayIntern(!1,!0)}function IsMizuPublicWebRTCGatewayIntern(e,n){try{if(0===GetConfigInt("usemizuwebrtcgateway",1))return isfirstmizupublicgwcheck&&CanLog(5)&&(isfirstmizupublicgwcheck=!1,PutToDebugLog(5,"EVENT, ismpwgw 1")),!1;var t=GetWsAddressCfg();if((isNull(t)||t.length<3)&&n&&(t=PGW_Get(0,PGW_ADDRESS)),
isNull(t)||t.length<3)return webphone_api.global.pgw_decide_finished&&(webphone_api.global.pgw_selected>=0||getuseengine()===webphone_api.global.ENGINE_WEBRTC)?(isfirstmizupublicgwcheck&&CanLog(5)&&(isfirstmizupublicgwcheck=!1,PutToDebugLog(5,"EVENT, ismpwgw 2 ")),!0):webphone_api.global.pgw_selected>=0&&(webphone_api.global.pgw_decide_finished||getuseengine()===webphone_api.global.ENGINE_WEBRTC)?(isfirstmizupublicgwcheck&&CanLog(5)&&(isfirstmizupublicgwcheck=!1,PutToDebugLog(5,"EVENT, ismpwgw 3 ")),!0):2===GetConfigInt("usemizuwebrtcgateway",1)?(isfirstmizupublicgwcheck&&CanLog(5)&&(isfirstmizupublicgwcheck=!1,PutToDebugLog(5,"EVENT, ismpwgw 4 "+t)),!0):e?(isfirstmizupublicgwcheck&&CanLog(5)&&(isfirstmizupublicgwcheck=!1,PutToDebugLog(5,"EVENT, ismpwgw 5 ")),!0):(isfirstmizupublicgwcheck&&CanLog(5)&&(isfirstmizupublicgwcheck=!1,PutToDebugLog(5,"EVENT, ismpwgw 6 ")),!1);t=t.toLowerCase(),t=NormalizeInput(t,0),t=t.replace("*","");var o=t.indexOf("/");return o>0&&(t=t.substring(0,o)),isNull(n)||!0!==n||IsMizuReallyPublicWebRTCGatewayAddress(t)?PGW_GetGwIndex(t)>=0?(isfirstmizupublicgwcheck&&CanLog(5)&&(isfirstmizupublicgwcheck=!1,PutToDebugLog(5,"EVENT, ismpwgw 8 "+t)),!0):(isfirstmizupublicgwcheck&&CanLog(5)&&(isfirstmizupublicgwcheck=!1,PutToDebugLog(5,"EVENT, ismpwgw 1")),!1):(isfirstmizupublicgwcheck&&CanLog(5)&&(isfirstmizupublicgwcheck=!1,PutToDebugLog(5,"EVENT, ismpwgw 7 "+t)),!1)}catch(i){PutToDebugLogException(2,"common: IsMizuPublicWebRTCGateway",i)}return!1}function IsMizuWebRTCGatewayAndNotMizuServer(){try{if(ismizuserverdetected>=2)return!1;if(!0===GetParameterOrConfigBool("usingmizuserver",!1))return!1;if(!0===GetParameterOrConfigBool("usingmizuserveronly",!1))return!1;if(0===GetParameterOrConfigInt("usemizuwebrtcgateway",1))return!1;if(GetParameterOrConfigInt("ismrtcgateway",0)>0)return!0;if(webphone_api.global.wsload_type>0)return!0;var e=GetWsAddressCfg();return!(!(isNull(e)||e.length<3)||1!=ismizuserverdetected)||IsMizuPublicWebRTCGateway()}catch(n){PutToDebugLogException(2,"common: IsMizuWebRTCGateway2",n)}return!1}function IsMizuServer(){return!(!IsMizuServerOrGateway()||IsMizuWebRTCGatewayAndNotMizuServer())}function IsMizuServerOrGateway(){try{if(ismizuserverdetected>0)return!0;if(!0===GetParameterOrConfigBool("usingmizuserver",!1))return!0;if(!0===GetParameterOrConfigBool("usingmizuserveronly",!1))return!0;if(GetParameterOrConfigInt("ismrtcgateway",0)>0)return!0;if(webphone_api.global.wsload_type>0)return!0;if(GetParameterOrConfigInt("cfgusetunneling",0)>0&&!0===GetParameterOrConfigBool("useencryption",!1))return!0;var e=GetServerForHttpReq();if(!isNull(e)&&(e.indexOf("mizu-voip.com")>=0||e.indexOf("webvoipphone.com")>=0))return!0;var n=GetWsAddressCfg();if(n=n.toLowerCase(),n.indexOf("mfstwebsock")>0)return!0;if((isNull(n)||n.length<3)&&getuseengine()===webphone_api.global.ENGINE_WEBRTC){if(webphone_api.global.pgw_decide_finished&&webphone_api.global.pgw_selected>=0)return!0;if(2===GetParameterOrConfigInt("usemizuwebrtcgateway",1))return!0}}catch(t){PutToDebugLogException(2,"common: IsMizuServerOrGateway",t)}return!1}function CanIUseApplet(){return gcaniuseapplet||(gcaniuseapplet=CanIUseAppletInternal())}function CanIUseAppletInternal(){try{var e=GetBrowserVersion(),n=GetBrowser(),t=GetOs(),o=webphone_api.getmaxchromeversionforjava();if(CanLog(4)&&PutToDebugLog(4,"EVENT, CanIUseApplet, OS: "+t+"; browser: "+n),"Windows"===t){if("Chrome"===n)return!(isNull(e)||IsNumber(e)&&(e<1||e>o));if("Firefox"===n){var i=GetParameterInt("nojavaforff",52);return!(!0===Is64BitBrowser()||GetBrowserVersion()>=i)||(CanLog(4)&&PutToDebugLog(4,"EVENT, CanIUseApplet, nojavaforff: "+i),!1)}return"Safari"===n?GetBrowserVersion()<6:"Edge"!==n}if("Mac"===t)return"Chrome"===n?!(isNull(e)||IsNumber(e)&&(e<1||e>o)):"Safari"!==n||!!(!isNull(e)&&IsNumber(e)&&e>0&&e<7);if("Linux"===t)return"Chrome"!==n||!(isNull(e)||IsNumber(e)&&(e<1||e>o))}catch(a){PutToDebugLogException(2,"common: CanIUseApplet",a)}return!1}function GetUDPServerAddress(){try{var e="";if((isNull(e)||e.length<3)&&(e=GetParameter("serveraddress_user")),isNull(e)||e.length<3){var n=GetConfig("serverdomain");!isNull(n)&&(isNull(e)||e.length<1||n.length>=3)&&(e=n)}if(isNull(e)||e.length<3){var n=GetConfig("serveraddress");!isNull(n)&&(isNull(e)||e.length<1||n.length>=3)&&(e=n)}if(isNull(e)||e.length<3){var n=GetConfig("server");!isNull(n)&&(isNull(e)||e.length<1||n.length>=3)&&(e=n)}if((isNull(e)||e.length<1)&&(e=GetConfig("serverip")),!isNull(e)&&e.length>2&&e.indexOf(":")<1){var t=GetConfig("serverport");!isNull(t)&&t.length>0&&"5060"!==t&&(e=GetIPEnclosed(e)+":"+t)}if(isNull(e)||e.length<1)e=GetParameter("upperserver");else if(isNull(e)||e.length<3||e.indexOf(".")<1&&e.indexOf(":")<0){var n=GetParameter("upperserver");isNull(n)||n.length<3||(e=n)}if(isNull(e)||e.length<1)e=GetFp();else if(isNull(e)||e.length<3){var o=GetProxyaddress();(isNull(o)||o.length<3||o.indexOf(".")<1&&o.indexOf(":")<0)&&(e=GetFp())}return e=e.replace("udp://",""),e=e.replace("tcp://",""),e=e.replace("http://",""),e=e.replace("https://","")}catch(i){PutToDebugLogException(2,"common: GetUDPServerAddress",i)}return""}function CanIUseWebRTC(e){return gcaniusewebrtc||(gcaniusewebrtc=CanIUseWebRTCInternal(e))}function CanIUseWebRTCInternal(e){try{if(lversion<=0){var n=[];if("Android"===GetOs()||"iOS"===GetOs()){n.push("D"),n.push("e"),n.push("s"),n.push("k"),n.push("t"),n.push("o"),n.push("p"),n.push(" "),n.push("o"),n.push("n"),n.push("l"),n.push("y"),n.push("_");var t=n.join("");setTimeout(function(){PutToDebugLog(1,"ERROR, "+t)},500)}return!1}if(1===lversion&&!1===Glsp()){var n=[];n.push("D"),n.push("e"),n.push("s"),n.push("k"),n.push("t"),n.push("o"),n.push("p"),n.push(" "),n.push("o"),n.push("n"),n.push("l"),n.push("y"),n.push("_");var t=n.join("");return setTimeout(function(){PutToDebugLog(1,"ERROR, "+t)},510),!1}if(IsMizuReallyPublicWebRTCGateway()&&1==IsLanIPEx(GetWebrtcUpperServer()))return PutToDebugLog(2,"EVENT, CanIUseWebRTC server is on local network"),!1;var o=-1;if(webphone_api.webrtcapi){var i=webphone_api.webrtcapi.WebRtcIsSupported();if(!0===i)o=1;else if(!1===i)return o=0,PutToDebugLog(5,"EVENT, CanIUseWebRTC no capabilities"),!1}if("iOS"===GetOs()){if("Safari"!==GetBrowser()&&"iPhone"!==GetBrowser())return 1===o?PutToDebugLog(5,"EVENT, (warn) CanIUseWebRTC ios other browser but webrtc supported"):PutToDebugLog(5,"EVENT, CanIUseWebRTC ios other browser"),!1;if(GetBrowserVersion()<11)return 1===o?PutToDebugLog(5,"EVENT, (warn) CanIUseWebRTC old safari but webrtc supported"):PutToDebugLog(5,"EVENT, CanIUseWebRTC old safari "),!1}var a="";if(75!==GetParameterInt("brandid",-1)){var r=GetWsAddressCfg();if(isNull(r)||Trim(r).length<1){var l=GetUDPServerAddress();if(isNull(l)&&(l=""),l=NormalizeInput(GetDomainPart(l)),l.length>0&&!1===IsIPAddrress(l)){var s=GetParameterInt("enginepriority_java",2),p=GetParameterInt("enginepriority_webrtc",2),c=GetParameterInt("enginepriority_ns",2),u=GetParameterInt("enginepriority_flash",2);p>2||p>s&&p>c&&p>u||DomainToIpServer(l,function(e){isNull(e)||e.length<1||(a=e,canresolvedomain=!(e.indexOf("cannotresolve")>=0)&&(!IsIPAddrress(e)||!IsLanIP(e)))})}else l.length>0&&IsIPAddrress(l)&&IsLanIP(l)&&(canresolvedomain=!1);if(!1===canresolvedomain&&!CanUseAnyAddrForWebRTC())return PutToDebugLog(3,"EVENT, CanIUseWebRTC WebRTC NOT available: Cannot resolve SIP server domain ("+l+") to public ip: "+a),!1}}if(webphone_api.global.webrtcavailable<1)return PutToDebugLog(2,"EVENT, CanIUseWebRTC WebRTC NOT available in this environment: "+webphone_api.global.webrtcavailable.toString()),!1;if(0===GetConfigInt("usemizuwebrtcgateway",1)&&GetWsAddressCfg(1).length<2)return PutToDebugLog(2,"WARNING, CanIUseWebRTC WebRTC available but there is no webrtc server"),!1;if("Windows"===GetOs()){if("MSIE"===GetBrowser())return!1;if("Edge"===GetBrowser()&&GetBrowserVersion()<14)return!1}return!0}catch(g){PutToDebugLogException(2,"common: CanIUseWebRTC",g)}return!1}function CanIUseService(){try{if("Windows"!==GetOs()&&!IsMacLin()||IsMacLin()&&!1===NSMacLinEnabled())return PutToDebugLog(2,"EVENT, CanIUseService not windows/mac/linux: false"),!1;var e=StrToInt(GetParameter2("enginepriority_java")),n=StrToInt(GetParameter2("enginepriority_webrtc")),t=StrToInt(GetParameter2("enginepriority_ns")),o=StrToInt(GetParameter2("enginepriority_flash")),i=StrToInt(GetParameter2("enginepriority_app")),a=StrToInt(GetParameter2("enginepriority_p2p")),r=StrToInt(GetParameter2("enginepriority_accessnum")),l=StrToInt(GetParameter2("enginepriority_nativedial")),s=!1;if(!isNull(e)&&IsNumber(e)||(s=!0,e=2),!isNull(n)&&IsNumber(n)||(s=!0,n=2),!isNull(t)&&IsNumber(t)||(s=!0,t=2),!isNull(o)&&IsNumber(o)||(s=!0,o=2),!isNull(i)&&IsNumber(i)||(s=!0,i=2),!isNull(a)&&IsNumber(a)||(s=!0,a=2),!isNull(r)&&IsNumber(r)||(s=!0,r=2),!isNull(l)&&IsNumber(l)||(s=!0,l=2),!0===s&&PutToDebugLog(2,"EVENT, CanIUseService priorities are NULL, probably couldnt read settings"),t<1||e>4||n>4||o>4||i>4||a>4||r>4||l>4)return PutToDebugLog(2,"EVENT, CanIUseService: false, other forced "+t),!1;if(lversion<=0)return!1;if(1===lversion&&!1===Glsp()){var p=[];p.push("D"),p.push("e"),p.push("s"),p.push("k"),p.push("t"),p.push("o"),p.push("p"),p.push(" "),p.push("o"),p.push("n"),p.push("l"),p.push("y"),p.push("_"),p.push("2");var c=p.join("");return setTimeout(function(){PutToDebugLog(1,"ERROR, "+c)},620),!1}if(window.WebSocket)return PutToDebugLog(2,"EVENT, CanIUseService_1 true "+t),!0;if("Chrome"===GetBrowser())return PutToDebugLog(2,"EVENT, CanIUseService_2 true "+t),!0;PutToDebugLog(2,"EVENT, CanIUseService final false "+t)}catch(u){PutToDebugLogException(2,"common: CanIUseService",u)}return!1}function CanIUseFlash(){return gcaniuseflash||(gcaniuseflash=CanIUseWebRTCInternal())}function CanIUseFlashInternal(){try{if(IsLocalServer(!0)||ServerIsIPv6())return CanLog(2)&&PutToDebugLog(2,"EVENT, Cannot use flash (can i use this engine) server to connect to local network VoIP server or ipv6 servers"),!1;if(lversion<=0){var e=[];if("Android"===GetOs()||"iOS"===GetOs()){e.push("D"),e.push("e"),e.push("s"),e.push("k"),e.push("t"),e.push("o"),e.push("p"),e.push(" "),e.push("o"),e.push("n"),e.push("l"),e.push("y"),e.push("_"),e.push("3");var n=e.join("");setTimeout(function(){PutToDebugLog(1,"ERROR, "+n)},650)}return!1}if(1===lversion&&!1===Glsp()){e.push("D"),e.push("e"),e.push("s"),e.push("k"),e.push("t"),e.push("o"),e.push("p"),e.push(" "),e.push("o"),e.push("n"),e.push("l"),e.push("y"),e.push("_"),e.push("3");var n=e.join("");return setTimeout(function(){PutToDebugLog(1,"ERROR, "+n)},680),!1}var t=GetParameterInt("enginepriority_java",2),o=GetParameterInt("enginepriority_webrtc",2),i=GetParameterInt("enginepriority_ns",2),a=GetParameterInt("enginepriority_flash",2),r=GetParameterInt("enginepriority_app",2),l=GetParameterInt("enginepriority_p2p",2),s=GetParameterInt("enginepriority_accessnum",2),p=GetParameterInt("enginepriority_nativedial",2);if(CanLog(5)&&PutToDebugLog(5,"EVENT, CanIUseFlash__6"),a>2||t<a&&o<a&&i<a&&r<a&&l<a&&s<a&&p<a){if(CanLog(5)&&PutToDebugLog(5,"EVENT, CanIUseFlash__7 old style detect"),webphone_api.flashdeepdetect=!0,webphone_api.swfobject.hasFlashPlayerVersion("9.0.115"))return!0}else try{var c=navigator.plugins["ShockwaveFlash.ShockwaveFlash"];if(c)return!0;if(c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))return!0}catch(u){if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]!=undefined&&navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)return!0}}catch(g){PutToDebugLogException(2,"common: CanIUseFlash",g)}return!1}function IsJavaInstalled(){try{if("Windows"===GetOs()&&"Edge"===GetBrowser())return 0;var e=null,n=!1,t=0;if(navigator.mimeTypes&&navigator.mimeTypes.length?(e=navigator.mimeTypes["application/x-java-jnlp-file"],null==e&&(e=navigator.mimeTypes["application/x-java-vm"]),null==e&&(e=navigator.mimeTypes["application/x-java-applet"]),e?t=1:"MSIE"===GetBrowser()&&(n=!0)):n=!0,n){isNull(document.getElementById("deployJavaPlugin"))&&mwpdeploy.writePluginTag();var o=mwpdeploy.getJREs();if(!isNull(o)&&o.length>0)for(var i=0;i<o.length;i++)t=1;return t<1?0:2}return t?navigator.javaEnabled()?2:1:0}catch(a){PutToDebugLogException(2,"common: IsJavaInstalled",a)}return 0}function EngineIsSupported(e){try{e.indexOf("_avail")>0&&(e=e.substring(0,e.indexOf("_avail")));var n=[];if(lversion<=0){if("Android"===GetOs()||"iOS"===GetOs()){n.push("D"),n.push("e"),n.push("s"),n.push("k"),n.push("t"),n.push("o"),n.push("p"),n.push(" "),n.push("o"),n.push("n"),n.push("l"),n.push("y");var t=n.join("");return setTimeout(function(){PutToDebugLog(1,"ERROR, "+t)},500),0}if("java"!==e)return 0}else if(1===lversion){if(!1===Glsp()){n.push("D"),n.push("e"),n.push("s"),n.push("k"),n.push("t"),n.push("o"),n.push("p"),n.push(" "),n.push("o"),n.push("n"),n.push("l"),n.push("y");var t=n.join("");return setTimeout(function(){PutToDebugLog(1,"ERROR, "+t)},500),0}if("java"!==e&&"webrtc"!==e&&"ns"!==e)return 0}if("java"===e){var o=CanIUseApplet();return PutToDebugLog(2,"EVENT, EngineIsSupported CanIUseApplet returned: "+o.toString()),!0===o?1:0}if("webrtc"===e){if(CanIUseWebRTC()){if(!0===BrowserRequiresHttps(!0)&&!1===IsHttps()){var i=GetUsemizutlsproxy();return"false"===GetParameter("usemizutlsproxy_userreload")||"2"!==i&&("1"!==i||!0!==webphone_api.global.usestorage&&!Strl(60))?(PutToDebugLog(2,"EVENT, CanIUseWebRTC engine maybe supported"),1):(PutToDebugLog(2,"EVENT, CanIUseWebRTC engine supported"),2)}return PutToDebugLog(2,"EVENT, CanIUseWebRTC engine supported"),2}return PutToDebugLog(2,"EVENT, CanIUseWebRTC engine not supported"),0}if("ns"===e)return CanIUseService()?1:0;if("flash"===e)return CanIUseFlash()?2:0;if("app"===e){var a=GetNativeDialerUrl(GetOs());return!isNull(a)&&a.length>5?2:(PutToDebugLog(2,"ERROR, EngineIsSupported: app engine not supported, because cannot find URL"),0)}return"p2p"===e?GetParameter("p2p").length<4?0:2:"accessnum"===e?("Android"===GetOs()||"iOS"===GetOs())&&GetParameter("accessnumber").length>2?2:0:"nativedial"===e?"Android"===GetOs()||"iOS"===GetOs()?2:0:"otherbrowser"===e?("Windows"===GetOs()||"Mac"===GetOs()||"Linux"===GetOs())&&GetParameterInt("enginepriority_otherbrowser",2)>0&&GetParameter("pc_alternatebrowserurl").length>3?2:0:(PutToDebugLog(2,"ERROR, common: EngineIsSupported invalid engine name: "+e),0)}catch(r){PutToDebugLogException(2,"common: EngineIsSupported",r)}}function EngineIsInstalled(e,n,t){var o=EngineIsInstalledInternal(e,n,t),i=GetEngine(e);return-1==i.isinstalled_cache&&(i.isinstalled_cache=-2),o>=0&&i.isinstalled_cache<0&&(i.isinstalled_cache=o),o}function EngineIsInstalledInternal(e,n,t){try{if(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal try "+e.toString()+"/"+n.toString()),e.indexOf("_avail")>0)return CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 1"),2;if("java"!==e&&"ns"!==e&&"app"!==e&&"webrtc"!==e)return CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 2"),2;var o=GetEngine(e);if(o.isinstalled_cache>=0)return CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 3"),o.isinstalled_cache;if(n>0&&0===o.asyncreqbegintime&&(n=0),"java"!==e)return 0===n&&0!==o.asyncreqbegintime?(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 4"),1):n>0&&-2==o.isinstalled_cache&&0!==o.asyncreqbegintime&&GetTickCount()-o.asyncreqbegintime>3e3?(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 5"),0):n>0&&-2==o.isinstalled_cache&&0!==o.getwebrtcserversupportime&&"webrtc"===e&&GetTickCount()-o.getwebrtcserversupportime>3e3?(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 555"),0):(0===o.asyncreqbegintime&&(o.asyncreqbegintime=GetTickCount()),n>0&&-2==o.isinstalled_cache?(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 6"),-1):(o.isinstalled_cache=-2,"ns"===e?(PutToDebugLog(2,"EVENT, engine waiting for IsServiceInstalled"),IsServiceInstalled(function(e){PutToDebugLog(2,"EVENT, engine IsServiceInstalled: "+e);var n=GetEngine("ns");n.isinstalled_cache=e?2:0,SetEngine("ns",n)},!1),CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 7"),-2):"app"===e?(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 8"),2):"webrtc"===e?CanIUseWebRTC()?!0===BrowserRequiresHttps(!0)?(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 9"),1):(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 10"),2):(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 11"),0):(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 12"),1)));if("java"===e){if("Windows"===GetOs()&&"Edge"===GetBrowser()||"Chrome"===GetBrowser())return CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 13"),0;var i=IsJavaInstalled(),a=GetEngine("java");return a.isinstalled_cache=i,SetEngine("java",a),1===i?(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 14"),-2):(CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 15"),i)}return CanLog(11)&&PutToDebugLog(11,"EVENT, EngineIsInstalledInternal ret 16"),1}catch(r){PutToDebugLogException(2,"common: EngineIsInstalled",r)}return 0}function createwebsocket(e){try{var n=PGW_Get(e,PGW_ADDRESS);if(n.length<1)return!1;if(!1===PGW_Get(e,PGW_TRY))return!1;var t=PGW_Get(e,PGW_APIKEY),o=GetConfig("brandid"),i=GetBrandName(),a=GetConfig("companyname"),r="";GetSipusername(!0).length>0&&(r="&username="+GetSipusername(!0));var l="http://"+n+"/mvapireq?",s="authkey="+t+"&apientry=wsload&brandid="+o+"&brandname="+encodeURIComponent(i)+"&companyname="+encodeURIComponent(a)+"&upperserver="+GetWebrtcUpperServer()+"&authid="+r+"&now=415";!0===BrowserRequiresHttps(!1)&&(l=l.replace("http:","https:"));var p=GetWp(e);p=p.replace("/mfstwebsock","/mvstwebsock"),p.indexOf("/mvstwebsock")>0&&p.indexOf("requestid=")<0&&(p=p.indexOf("?")>0?p+"&requestid="+GetRequestId():p+"?requestid="+GetRequestId()),CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw url (Websocket connect): "+n+" / "+p+" / "+l+" / "+s);var c=StrEc(s,webphone_api.global.ec_apikey,!0);s===StrDc("mcrfs_"+c,webphone_api.global.ec_apikey,!0)?l=l+"mcrfs="+c:l+=s,PGW_Set(e,PGW_WSTIME_BGN,GetTickCount()),CanLog(5)&&PutToDebugLog(5,"EVENT, wsload connect to "+n);var u=new WebSocket(p,"api");return u.binaryType="arraybuffer",u.onopen=function(){u.send(l+"\r\n"),CanLog(3)&&PutToDebugLog(3,"EVENT, wsload sent (Websocket onopen) for "+n),SaveParameter("wseverconnected","true")},u.onclose=function(t){if(0==PGW_Get(e,PGW_WSREC)&&PGW_Set(e,PGW_FAILED,!0),CanLog(5)){var o="";isNull(t)||isNull(t.code)||(o=o+", code: "+t.code.toString()),isNull(t)||isNull(t.wasClean)||(o=o+", clean: "+t.wasClean.toString()),isNull(t)||isNull(t.reason)||(o=o+", reason: "+t.reason.toString()),PutToDebugLog(5,"EVENT, wsload onclose "+n+o)}u=null},u.onerror=function(t){if(0==PGW_Get(e,PGW_WSREC)&&PGW_Set(e,PGW_FAILED,!0),CanLog(5)){isNull(t)||t.toString(),PutToDebugLog(5,"EVENT, wsload onerror "+n+": "+t.toString())}},u.onmessage=function(t){var o=null;if(isNull(t)||(o=t.data),isNull(o))0==PGW_Get(e,PGW_WSREC)&&PGW_Set(e,PGW_FAILED,!0),CanLog(2)&&PutToDebugLog(2,"ERROR, wsload failed, received data is NULL "+n);else{HttpResponseHandler(ArrayBufferToString(o),"wrtcload_"+e.toString())}u&&u.close&&u.close()},!0}catch(g){PutToDebugLogException(2,"common: createwebsocket",g)}return!1}function GetServersupport(e,n,t){try{if(CanLog(11)&&PutToDebugLog(11,"EVENT, GetServersupport try "+e.toString()+"/"+n.toString()+"/"+t.toString()),e.indexOf("_avail")>0)return CanLog(11)&&PutToDebugLog(11,"EVENT, GetServersupport ret 1"),1;if("webrtc"!==e)return CanLog(11)&&PutToDebugLog(11,"EVENT, GetServersupport ret 2"),1;var o=GetEngine(e);if(o.serversupport_cache>=0)return CanLog(11)&&PutToDebugLog(11,"EVENT, GetServersupport ret 3"),o.serversupport_cache;if(n>0&&0===o.getwebrtcserversupportime&&(n=0),0===n&&0!==o.getwebrtcserversupportime)return CanLog(11)&&PutToDebugLog(11,"EVENT, GetServersupport ret 4"),1;if(n>0&&0!==o.getwebrtcserversupportime&&GetTickCount()-o.getwebrtcserversupportime>3e3)return CanLog(11)&&PutToDebugLog(11,"EVENT, GetServersupport ret 5"),0;if(0===o.getwebrtcserversupportime&&(o.getwebrtcserversupportime=GetTickCount()),n>0)return CanLog(11)&&PutToDebugLog(11,"EVENT, GetServersupport ret 6"),-1;var i=GetLastUsedEngine(),a=GetSelectedEngineName();if(isNull(i)||i.length<1||"webrtc"===i||"java"!==i&&"ns"!==i||"webrtc"===a){PutToDebugLog(5,"EVENT, GetServersupport check for webrtc: "+i+" / "+a),DecideWebrtcServer();var r=1;if(wsloadanswersreceived=0,IsMizuPublicWebRTCGateway()){PutToDebugLog(5,"EVENT, GetServersupport check mzpublicgateway (decidegw reset)"),webphone_api.global.pgw_decide_finished=!1,webphone_api.global.waitingforusukdecide<=0&&(webphone_api.global.waitingforusukdecide=1);var l=3200;if(setTimeout(function(){if(!1===webphone_api.global.pgw_decide_finished){PutToDebugLog(2,"EVENT, decidegw not yet finihed after delay: "+l.toString()),webphone_api.global.waitingforusukdecide>0&&(webphone_api.global.waitingforusukdecide=-2);var e=GetWebrtcSrvAddr();(isNull(e)||e.length<2)&&(e=GetWp());var n=PGW_GetGwIndex(e);if(n>=0&&webphone_api.global.pgw_selected!=n&&(PutToDebugLog(2,"WARNING, common manually setting pgw_selected D from: "+webphone_api.global.pgw_selected.toString()+" to: "+n.toString()+", because decidegw has not yet finished after delay: "+l.toString()),webphone_api.global.pgw_selected=n),!webphone_api.global.pgw_decide_finished){webphone_api.global.pgw_decide_finished=!0;var t=GetWsAddressCfg();t.length>0&&SaveParameter("lastwebrtcserver",t),PutToDebugLog(5,"EVENT, decidegw select finished on timeout2 "+t),OnDecideUsUkFinished(n)}}},l),s<=0||IsLocalServer(!0)&&IsMizuReallyPublicWebRTCGatewayAddress(PGW_Get(0,PGW_ADDRESS)))webphone_api.global.waitingforusukdecide>0&&(webphone_api.global.waitingforusukdecide=-3),PutToDebugLog(2,"ERROR, wsload decide"+webphone_api.stringres.get("webrtc_local_sipserver")+" (8)");else try{webphone_api.global.waitingforusukdecide<=0&&(webphone_api.global.waitingforusukdecide=4);for(var s=PGW_Get_Count(),p=0;p<s;p++)PGW_Set(p,PGW_WSREC,!1),PGW_Set(p,PGW_FAILED,!1),PGW_Set(p,PGW_WSLOAD,-1),PGW_Set(p,PGW_WSTIME_BGN,-1),PGW_Set(p,PGW_WSTIME_DIFF,-1),PGW_Set(p,PGW_WSTIME_DIFF_REAL,"");for(var p=0;p<s;p++)createwebsocket(p)&&(r=1600)}catch(d){PutToDebugLogException(2,"common: GetServersupport wsload inner",d)}}else if(PutToDebugLog(5,"EVENT, GetServersupport not mzpublicgateway"),!webphone_api.global.pgw_decide_finished){webphone_api.global.pgw_decide_finished=!0;var c=GetWsAddressCfg();c.length>0&&SaveParameter("lastwebrtcserver",c),PutToDebugLog(5,"EVENT, decidegw select finished on notpublgw "+c),OnDecideUsUkFinished()}if(r<10)PutToDebugLog(5,"EVENT, common: GetServersupport imnmediate"),MSendWebRTCLoad();else var u=r/60,g=0,h=GetTickCount(),m=setInterval(function(){++g,(wsloadanswersreceived>1&&(g>=u/2||GetTickCount()-h>r/2)||wsloadanswersreceived>0&&(g>=u||GetTickCount()-h>r)||wsloadanswersreceived<1&&(g>=2*u||GetTickCount()-h>2*r)||webphone_api.global.pgw_decide_finished&&3==wsloadanswersreceived&&webphone_api.global.pgw_selected>=0)&&(webphone_api.global.pgw_decide_finished&&3==wsloadanswersreceived&&webphone_api.global.pgw_selected>=0||PutToDebugLog(5,"EVENT, common: GetServersupport timeout "+webphone_api.global.pgw_selected.toString()+" / "+webphone_api.global.pgw_decide_finished.toString()+" / "+wsloadanswersreceived.toString()),MSendWebRTCLoad(),clearInterval(m))},60)}else PutToDebugLog(5,"EVENT, GetServersupport check for not webrtc: "+i+" / "+a);IsMizuServerOrGateway()||(o.serversupport_cache=0,SetEngine(e,o))}catch(d){PutToDebugLogException(2,"common: GetServersupport",d)}return 0}function MSendWebRTCLoad(){try{if(webphone_api.global.pgw_selected>=0&&1==PGW_Get(webphone_api.global.pgw_selected,PGW_WSREC)&&PGW_Get(webphone_api.global.pgw_selected,PGW_WSLOAD)>=0)return;var e=GetWsloadUrl(GetSipusername(!0));webphone_api.global.waitingforusukdecide>0&&(webphone_api.global.waitingforusukdecide=-5),(isNull(e)||e.length<1)&&(e=GetWsloadUrl(GetUsername())),!isNull(e)&&e.length>0&&(PutToDebugLog(5,"EVENT, common: GetServersupport GetWebrtcLoad "+webphone_api.global.pgw_selected.toString()+" / "+webphone_api.global.pgw_decide_finished.toString()+" / "+wsloadanswersreceived.toString()+" / "+e),UriParser(e,"","","","","webrtcload"))}catch(n){PutToDebugLogException(2,"common: MSendWebRTCLoad",n)}}function GetCfgPriority(e){try{e.indexOf("_avail")>0&&(e=e.substring(0,e.indexOf("_avail")));var n=2;try{n=parseInt(GetParameter2("enginepriority_"+e))}catch(o){PutToDebugLogException(2,"common: GetCfgPriority parseint: "+e,o)}var t=window.location.protocol;return"flash"===e&&!isNull(t)&&t.length>0&&t.toLowerCase().indexOf("file")>=0&&(n=0),n}catch(o){PutToDebugLogException(2,"common: GetCfgPriority",o)}return 2}function GetCfgOldAvailable(e){try{e.indexOf("_avail")>0&&(e=e.substring(0,e.indexOf("_avail")));var n=1;try{n=parseInt(GetParameter("engineoldavailable_"+e))}catch(t){PutToDebugLogException(2,"common: GetCfgOldAvailable parseint: "+e,t)}return IsNumber(n)||(n=1),n}catch(t){PutToDebugLogException(2,"common: GetCfgOldAvailable",t)}return 1}function SaveCfgOldAvailable(e,n){try{if(e.indexOf("_avail")>0)return;SaveParameter("engineoldavailable_"+e,n)}catch(t){PutToDebugLogException(2,"common: SaveCfgOldAvailable",t)}}function GetEngineDefPriority(e,n){try{e.indexOf("_avail")>0&&(e=e.substring(0,e.indexOf("_avail")));var t=GetConfig("enginedefpriority_"+e);if(!isNull(t)&&t.length>0&&IsNumber(t))return StrToInt(t)}catch(o){PutToDebugLogException(2,"common: GetEngineDefPriority",o)}return n}function GetSinglePossibleEngine(){try{var e=GetParameterInt("enginepriority_java",2),n=GetParameter2("enginepriority_webrtc",2),t=GetParameter2("enginepriority_ns",2),o=CanIUseWebRTC(),i=CanIUseApplet(),a=GetOs();if("Android"===a){if(!1===o)return webphone_api.global.ENGINE_APP}else if("iOS"===a){if(!1===o)return webphone_api.global.ENGINE_APP}else if("Windows"===a)if("Edge"===GetBrowser()){if(!1===o)return webphone_api.global.ENGINE_SERVICE}else if(!1===i||e<1){if(!1===o||n<1)return webphone_api.global.ENGINE_SERVICE;if(!0===o&&t<1)return webphone_api.global.ENGINE_WEBRTC}}catch(r){PutToDebugLogException(2,"common: GetSinglePossibleEngine",r)}return""}function MightUseEngine(e,n){try{if(isNull(e)||e.length<1)return!0;GetEngineList();var t=GetEngine(e);if(isNull(t))return!0;var o=GetOs();if(gcaniusewebrtc&&!1===gcaniusewebrtc&&"webrtc"===e)return!1;if(gcaniuseapplet&&!1===gcaniuseapplet&&"java"===e)return!1;if(gcaniuseflash&&!1===gcaniuseflash&&"flash"===e)return!1;if(!("Android"!=o&&"iOS"!=o||"ns"!=t.name&&"java"!=t.name&&"flash"!=t.name))return!1;var i=GetForcedEngine();if(i){if(e===i.name)return!0;if(e!==i.name+"_avail"&&e+"_avail"!==i.name)return!1}if(!isNull(n)&&!0===n)return!0;if(i=GetSelectedEngine()){if(e===i.name||e===i.name+"_avail"||e+"_avail"===i.name)return!0;if(GetCfgPriority(i.name)>=GetCfgPriority(t.name)&&"flash"!==i.name&&"app"!==i.name&&"p2p"!==i.name&&"nativedial"!==i.name&&"otherbrowser"!==i.name)return!1}if(webphone_api.global.lastengine_working_ok.length<1?webphone_api.global.lastengine_working_ok=GetLastUsedEngine():webphone_api.global.lastengine_working_ok.length<1&&(webphone_api.global.lastengine_started_ok=GetLastUsedEngine(),webphone_api.global.lastengine_working_ok=webphone_api.global.lastengine_started_ok),webphone_api.global.lastengine_working_ok.length>0&&(i=GetEngine(webphone_api.global.lastengine_working_ok))){if(e===i.name||e===i.name+"_avail"||e+"_avail"===i.name)return!0;if(i.failed<1&&i.name.indexOf("_avail")<0&&GetCfgPriority(i.name)>=GetCfgPriority(t.name)&&"flash"!==i.name&&"app"!==i.name&&"p2p"!==i.name&&"nativedial"!==i.name&&"otherbrowser"!==i.name)return!1}}catch(a){PutToDebugLogException(2,"common: MightUseEngine",a)}return!0}function CanUseAnyAddrForWebRTC(){if(GetParameterInt("enginepriority_webrtc",2)>1&&GetWsAddressCfg(2).length>0)return!0;var e=GetForcedEngine();return!(!e||"webrtc"!==e)}function GetForcedEngine(){try{if(null!=forced_engine)return forced_engine;if(forced_engine_checked)return forced_engine;forced_engine_checked=!0,GetEngineList();for(var e,n=GetOs(),t=0;t<engines.length;t++)if(e=engines[t],e.cfg_priority=GetCfgPriority(e.name),IsNumber(e.cfg_priority)&&(e.cfg_priority>=5||e.clicked>=2)&&e.name.indexOf("_avail")<0&&(isNull(selected_engine)||selected_engine.name===e.name))if(gcaniusewebrtc&&!1===gcaniusewebrtc&&"webrtc"===e.name);else if(gcaniuseapplet&&!1===gcaniuseapplet&&"java"===e.name);else if(gcaniuseflash&&!1===gcaniuseflash&&"flash"===e.name);else if("Android"!=n&&"iOS"!=n||"ns"!=e.name&&"java"!=e.name&&"flash"!=e.name)return forced_engine=e,e;for(var o=null,t=0;t<engines.length;t++)if(e=engines[t],e.cfg_priority=GetCfgPriority(e.name),IsNumber(e.cfg_priority))if(e.cfg_priority<1){if(o&&o.name===e.name){o=null;break}}else{if(o){o=null;break}o=e}if(o&&o.name.indexOf("_avail")<0&&(isNull(selected_engine)||selected_engine.name===o.name))if(gcaniusewebrtc&&!1===gcaniusewebrtc&&"webrtc"===e.name);else if(gcaniuseapplet&&!1===gcaniuseapplet&&"java"===e.name);else if(gcaniuseflash&&!1===gcaniuseflash&&"flash"===e.name);else if("Android"!=n&&"iOS"!=n||"ns"!=e.name&&"java"!=e.name&&"flash"!=e.name)return forced_engine=o,o}catch(i){PutToDebugLogException(2,"common: GetForcedEngine",i)}return forced_engine}function EngineSelect(e,n,t){try{logwphoneinfodone<1&&LogWebphoneInfo(),webphone_api.plhandler.ConfigChanged();var o;CanLog(2)&&(!1===t?PutToDebugLog(2,"ERROR, EngineSelect called with cannot wait stage: "+e+" from: "+n):PutToDebugLog(2,"EVENT, EngineSelect called with stage: "+e+" from: "+n)),webphone_api.global.engineselecttime=GetTickCount(),webphone_api.global.engineselectstage=e,GetEngineList();var i=GetForcedEngine();if(!isNull(i))return selected_engine=i,selected_engine.pushlevel=1,recommend_engine=null,CanLog(2)&&PutToDebugLog(2,"EVENT, EngineSelect Returning forced only engine allowed by config: "+i.name),"webrtc"===i.name&&!1===getsrvsupportcalled&&(getsrvsupportcalled=!0,GetServersupport("webrtc",e,1)),1;var a=webphone_api.global.lastengine_working_ok;a.length<1&&(a=webphone_api.global.lastengine_started_ok),webphone_api.global.lastengine_started_ok=GetLastUsedEngine(),webphone_api.global.lastengine_working_ok=webphone_api.global.lastengine_started_ok,CanLog(2)&&PutToDebugLog(2,"EVENT, EngineSelect at stage: "+e+"; last working engine: "+webphone_api.global.lastengine_working_ok+" (prev: "+a+" / "+GetParameter("prevusedengine")+")");var r=GetWsAddressCfg(1);if(!isNull(r)&&r.length>3){2===GetParameterInt("enginepriority_webrtc",2)&&(PutToDebugLog(2,"EVENT, EngineSelect enginepriority_webrtc auto increased to: 3"),SaveParameter("enginepriority_webrtc","3"))}if(webphone_api.global.lastengine_working_ok.length>0)for(var l=0;l<engines.length;l++)if(o=engines[l],o.name===webphone_api.global.lastengine_working_ok&&o.failed<1&&o.name.indexOf("_avail")<0&&o.defpriority>0)if("webrtc"===o.name&&IsMizuServerOrGateway())avoidjavapopup=2;else if("flash"!==o.name||"true"!==GetParameter("java_worked")&&"true"!==GetParameter("ns_worked")&&"true"!==GetParameter("webrtc_worked")){selected_engine=o,selected_engine.pushlevel=1,recommend_engine=null;var s="";try{s=selected_engine.name}catch(y){}return CanLog(2)&&PutToDebugLog(2,"EVENT, EngineSelect Returning last working ok engine: "+s),2}for(var l=0;l<engines.length;l++){o=engines[l];var p=o.issupported_cache;"webrtc"===o.name&&e>0&&(p=-1),p<0&&(p=EngineIsSupported(o.name)),o.issupported_cache=p,0===p?o.available=0:2===p?o.available=3:webphone_api.global.lastengine_started_ok===o.name||webphone_api.global.lastengine_working_ok===o.name?o.available=2:o.available=1}for(var c=0,u=null,l=0;l<engines.length;l++)if(o=engines[l],o.available>2&&o.failed<1&&o.name.indexOf("_avail")<0){if(u=o,++c>1){u=null;break}}else if(o.available>0){u=null;break}if(!isNull(u))return selected_engine=u,selected_engine.pushlevel=1,
recommend_engine=null,CanLog(2)&&PutToDebugLog(2,"EVENT, EngineSelect Returning the only good engine: "+selected_engine.name),3;if(1===avoidjavapopup){var g=GetEngine("java");avoidjavapopup=g.available_old>2?2:0===g.available_old?2:0}for(var l=0;l<engines.length;l++)if(o=engines[l],!(o.available<1||o.available>2))if(o.name.indexOf("_avail")>0)o.available=3;else if(!((avoidjavapopup>1||0===e)&&"java"===o.name||(avoidflashpopup>1||0===e)&&"flash"===o.name)){var p=o.isinstalled_cache,h=HasUsableEngine(o);if(p<0&&(p=EngineIsInstalled(o.name,e,h)),p<0){if(!0===t)return CanLog(5)&&PutToDebugLog(5,"EVENT, EngineSelect wait for available engine"),0;o.available=1,p=1}else o.isinstalled_cache=p,0===p?o.available=0:2===p&&(o.available=3)}if(IsMizuServerOrGateway()){CanLog(10)&&PutToDebugLog(10,"EVENT, EngineSelect might check rtc gateways");for(var l=0;l<engines.length;l++)if(o=engines[l],o.serversupport=1,"webrtc"===o.name)if(CanLog(10)&&PutToDebugLog(10,"EVENT, EngineSelect check rtc engine "+l.toString()+" available: "+o.available.toString()+" serversuppoert: "+o.serversupport_cache.toString()+" stage: "+e+" from: "+n),o.available<1)o.serversupport=2;else if(o.serversupport=o.serversupport_cache,o.serversupport<0&&(o.serversupport=GetServersupport(o.name,e,2)),o.serversupport<0){if(t)return CanLog(5)&&PutToDebugLog(5,"EVENT, EngineSelect wait for serversupport"),-1;o.serversupport=3}else o.serversupport_cache=o.serversupport}else CanLog(10)&&PutToDebugLog(10,"EVENT, EngineSelect no rtc gateway check "+GetParameterOrConfig("ismrtcgateway"));if(avoidjavapopup>1&&e>0){var g=GetEngine("java"),h=HasUsableEngine(g);if(g.available_old>2?g.available=g.available_old:0===g.available_old&&h&&(g.available=g.available_old),g.available<1||g.available>2);else{var m=GetEngine("webrtc"),d=GetEngine("ns");if((1===g.available||2===g.available)&&g.cfg_priority<=2&&(m.available>2&&m.cfg_priority>=2&&m.serversupport<=1||d.available>2&&d.cfg_priority>=2));else{var p=o.isinstalled_cache;if(p<0&&(p=EngineIsInstalled(g.name,e,h)),p<0)return PutToDebugLog(5,"EVENT, EngineSelect wait for java engine"),-2;o.isinstalled_cache=p,0===p?g.available=0:2===p&&(g.available=3)}}}if(avoidflashpopup>1&&e>0){var b=GetEngine("flash"),h=HasUsableEngine(b);if(b.available_old>2?b.available=b.available_old:0==b.available_old&&h&&(b.available=b.available_old),b.available<1||b.available>2);else{var m=GetEngine("webrtc"),d=GetEngine("service"),g=GetEngine("java");if((1==b.available||2==b.available)&&b.cfg_priority<=2&&(m.available>2&&m.cfg_priority>=2&&m.serversupport<=1||d.available>2&&d.cfg_priority>=2||g.available>2&&g.cfg_priority>=2));else{var p=o.isinstalled_cache;if(p<0&&(p=EngineIsInstalled(b.name,e,h)),p<0)return PutToDebugLog(5,"EVENT, EngineSelect wait for flash engine"),-3;o.isinstalled_cache=p,0==p?b.available=0:2==p&&(b.available=3)}}}for(var _=!1,l=0;l<engines.length;l++)if(o=engines[l],e>0&&o.name.indexOf("_avail")<0&&(o.available_old=o.available,SaveCfgOldAvailable(o.name,o.available)),o.cfg_priority<1)o.finalscore=0;else{switch(o.available){case 0:o.finalscore=10;break;case 1:o.finalscore=25;break;case 2:o.finalscore=35;break;case 3:o.finalscore=60;break;default:o.finalscore=25}switch(!0===NSMacLinEnabled()||"ns"===o.name&&"Windows"!==GetOs()&&(o.finalscore=0),o.cfg_priority){case 1:o.finalscore*=.75;break;case 3:o.finalscore*=1.66;break;case 4:o.finalscore*=2.5}switch(o.defpriority<=3?o.finalscore*=.1:o.defpriority<=4?o.finalscore*=.2:o.defpriority<=6?o.finalscore*=.3:o.defpriority<=15?o.finalscore*=.4:o.defpriority<=25?o.finalscore*=.8:o.defpriority<=30?o.finalscore*=.9:o.defpriority<=35||(o.defpriority<=45?o.finalscore*=1.2:o.defpriority<=55?o.finalscore*=1.35:o.finalscore*=1.45),o.serversupport){case 0:o.finalscore*=1.1;break;case-1:case 2:o.finalscore*=.7;break;case 3:o.finalscore*=.4;break;case 4:o.finalscore*=.2}"webrtc"==o.name&&GetParameter("webrtcserveraddress").length>0&&!IsMizuReallyPublicWebRTCGateway()&&(o.finalscore*=1.5),o.clicked>0&&(o.finalscore*=5,_=!0),webphone_api.global.lastengine_started_ok.length>0&&webphone_api.global.lastengine_started_ok===o.name?o.finalscore*=1.2:o.name==GetParameter("prevusedengine")&&(o.finalscore*=1.1),o.failed&&o.finalscore>13&&(o.finalscore=13),lversion<1&&"java"!==o.name&&(o.finalscore*=.8)}if(e>0&&!0===CanIUseService()){var f=GetEngine("ns"),w=GetEngine("webrtc");if(GetParameterInt("enginepriority_ns",2)>=GetParameterInt("enginepriority_webrtc",2)){var v=f.finalscore;if(w.failed>0&&IsNumber(v)){for(var l=0;l<engines.length;l++)o=engines[l],"ns"===o.name||o.name.indexOf("_avail")>0||o.finalscore>=v&&(v=o.finalscore+1);f.finalscore=v,SetEngine("ns",f)}}}if(e>0&&!0===CanIUseService()&&!1===IsHttps()&&!0===UseTLSReload()&&("Chrome"===GetBrowser()||"Safari"===GetBrowser()||"Firefox"===GetBrowser()&&GetBrowserVersion()>=68)){var f=GetEngine("ns"),w=GetEngine("webrtc");if(GetParameterInt("enginepriority_ns",2)>=GetParameterInt("enginepriority_webrtc",2)){var v=1.1*f.finalscore;SetEngine("ns",f),(!0===webphone_api.global.usestorage||Strl(90))&&!1===GetParameterBool("reloadalertdisplayed",!0)&&(AlertDialog(webphone_api.stringres.get("warning"),webphone_api.stringres.get("chrome_https")),PutToDebugLog(2,"WARNING, EngineSelect reload "+webphone_api.stringres.get("chrome_https")),SaveParameter("reloadalertdisplayed","true"))}}var E,P=null;E=-1e3;for(var l=0;l<engines.length;l++)o=engines[l],"java_avail"!==o.name&&"ns_avail"!==o.name&&"app_avail"!==o.name&&o.finalscore>E&&(E=o.finalscore,P=o);if(isNull(P))return PutToDebugLog(2,"EVENT, EngineSelect no best engine"),6;if("webrtc"===P.name&&!0===CanIUseService()&&GetEngine("ns").finalscore>15&&GetParameterInt("enginepriority_ns",2)>GetParameterInt("enginepriority_webrtc",2)+1&&!0===GetParameterBool("isfirststart",!0)){PutToDebugLog(3,"EVENT, Engineselect switch to NS because it has higher priority");for(var T=GetEngine("ns").finalscore,S=GetEngine("webrtc").finalscore,l=0;l<engines.length;l++)"ns"===engines[l].name&&(engines[l].finalscore=S),"webrtc"===engines[l].name&&(engines[l].finalscore=T);P=GetEngine("ns")}P.finalscorex=P.finalscore,recommend_engine=null,selected_engine=P,selected_engine.pushlevel=1;var N=null;E=-1e3;for(var l=0;l<engines.length;l++)o=engines[l],o.finalscorex=o.finalscore,o!==P&&"java_avail"!==o.name&&"ns_avail"!==o.name&&"app_avail"!==o.name&&(!(P.finalscorex>40)||"ns"!==P.name&&"app"!==P.name||"ns"!==o.name&&"app"!==o.name)&&(!(P.finalscorex>50)||"java"!==P.name&&"ns"!==P.name&&"app"!==P.name||"java"!==o.name&&"ns"!==o.name&&"app"!==o.name||(o.finalscorex=.75*o.finalscorex),o.finalscorex>E&&(E=o.finalscorex,N=o));var I=null;E=-1e3;for(var l=0;l<engines.length;l++)o=engines[l],"java_avail"!==o.name&&"ns_avail"!==o.name&&"app_avail"!==o.name||o.name!==P.name+"_avail"&&(P.finalscorex>40&&("ns"===P.name||"app"===P.name)||(P.finalscorex>50&&("java"===P.name||"ns"===P.name||"app"===P.name)&&(o.finalscorex=.75*o.finalscorex),o.finalscorex>E&&(E=o.finalscorex,I=o)));if("webrtc"===P.name||"flash"===P.name||"p2p"===P.name||"accessnum"===P.name||"nativedial"===P.name)selected_engine.pushlevel=1;else switch(P.available){case 0:selected_engine.pushlevel=5;break;case 1:selected_engine.pushlevel=4;break;case 2:selected_engine.pushlevel=3;break;case 3:selected_engine.pushlevel=1}var I=null;if(E=-1e3,e>0)try{for(var C="",l=0;l<engines.length;l++)o=engines[l],o.name.indexOf("_avail")>0||(C.length>0&&(C+="\r\n"),C+="EngineSelectPriority: "+o.name+": "+o.finalscorex+" (available: "+o.available+", cfg_priority: "+o.cfg_priority+", defpriority: "+o.defpriority+", serversupport: "+o.serversupport+", finalscore: "+o.finalscore+", pushlevel: "+o.pushlevel+", failed: "+o.failed+", clicked: "+o.clicked+", issupported_cache: "+o.issupported_cache+", isinstalled_cache: "+o.isinstalled_cache+", serversupport_cache: "+o.serversupport_cache+", available_old: "+o.available_old+", asyncreqbegintime: "+o.asyncreqbegintime+"/"+o.getwebrtcserversupportime+")");!isNull(C)&&C.length>0&&PutToDebugLog(2,"EVENT, EngineSelect engines:\r\n"+C)}catch(y){}if(isNull(N)&&isNull(I))return PutToDebugLog(2,"EVENT,EngineSelect recommended engine result: same as selected"),7;if(isNull(N)&&!isNull(I)?N=I:!isNull(N)&&isNull(I)||N.finalscorex>50||N.finalscorex>.8*I.finalscorex||(N=I),isNull(N))return PutToDebugLog(2,"EVENT,EngineSelect recommended engine result: null"),8;if(P.finalscorex>60)return PutToDebugLog(2,"EVENT,EngineSelect recommended engine result: not needed1 "+P.finalscorex+" "+TestEngineToString(N,!1)),9;if(N.finalscorex<15&&N.available<1)return PutToDebugLog(2,"EVENT,EngineSelect recommended engine result: not needed3 "+P.finalscorex+" "+TestEngineToString(N,!1)),10;if(P.finalscorex>22&&N.finalscorex<=10)return PutToDebugLog(2,"EVENT,EngineSelect recommended engine result: not needed3 "+P.finalscorex+" "+TestEngineToString(N,!1)),11;if(P.finalscorex>30&&P.finalscorex>1.35*N.finalscorex)return PutToDebugLog(2,"EVENT,EngineSelect recommended engine result: not needed2 "+P.finalscorex+" > "+1.35*N.finalscorex+" "+TestEngineToString(N,!1)),12;recommend_engine=N;var G=3;if(P.finalscorex<20&&recommend_engine.finalscorex>=60?G=6:P.finalscorex<30&&recommend_engine.finalscorex>50?G=5:P.finalscorex>60||P.finalscorex>50&&recommend_engine.finalscorex<30||P.finalscorex>2*recommend_engine.finalscorex?G=0:recommend_engine.finalscorex>15&&recommend_engine.finalscorex>P.finalscorex&&(P.finalscorex<30||P.finalscorex<35&&recommend_engine.finalscorex>45||recommend_engine.finalscorex>2*P.finalscorex||recommend_engine.finalscorex-P.finalscorex>25)?G=4:P.finalscorex>55&&P.finalscorex>.9*recommend_engine.finalscorex&&(G=2),recommend_engine.name.indexOf("_avail")>0){PutToDebugLog(2,"EVENT, EngineSelect adjusting from virtual engine "+TestEngineToString(recommend_engine,!1));for(var L=recommend_engine.name.substring(0,recommend_engine.name.indexOf("_avail")),l=0;l<engines.length;l++)if(o=engines[l],o.name===L){recommend_engine=o;break}}CanLog(5)&&(null!=selected_engine&&PutToDebugLog(5,"EVENT, EngineSelect selected_engine: "+selected_engine.name),null!=recommend_engine&&PutToDebugLog(5,"EVENT, EngineSelect recommend_engine: "+recommend_engine.name),null!=N&&PutToDebugLog(5,"EVENT, EngineSelect second_engine: "+N.name));var R=selected_engine;null==R&&(R=selected_engine),!_&&null!=R&&"ns"==R.name&&null!=N&&"webrtc"==N.name&&N.finalscorex>10&&N.finalscorex>R.finalscorex/2&&N.finalscorex>R.finalscorex-5&&(N.name==webphone_api.global.lastengine_working_ok||N.name==webphone_api.global.lastengine_started_ok||N.name==GetParameter("prevusedengine"))&&(selected_engine2=N),recommend_engine.pushlevel=G,recommend_engine===selected_engine&&(recommend_engine=null)}catch(D){PutToDebugLogException(2,"common: EngineSelect",D)}return 13}function TestEngineToString(e,n){try{if(isNull(e))return"engine not set";var t=e.name;return n&&(t=t.toUpperCase()),t+"> cfgpriority: "+e.cfg_priority+", available: "+e.available+", serversupport: "+e.serversupport+", finalscore: "+e.finalscore+" ("+e.finalscorex+"), pushlevel: "+e.pushlevel+" "+TestPushLevelToString(e.pushlevel)}catch(o){PutToDebugLogException(2,"common: TestEngineToString",o)}}function TestPushLevelToString(e){try{switch(e){case-1:return"not set";case 0:return"no";case 1:return"just use";case 2:return"barely mention";case 3:return"mention on login/settings page";case 4:return"offer also after login";case 5:return"always ask for";case 6:return"force (allow only this)";default:return"unknown"}}catch(n){PutToDebugLogException(2,"common: TestPushLevelToString",n)}}function CheckInternetConnection(){try{if(!1===webphone_api.global.sipstackstarted)return;var e=GetParameterInt("networkchecks",1);if(0===e)return;if(e<2&&0!=lastcheckinetconnectiontick&&GetTickCount()-lastcheckinetconnectiontick<3e5)return;if(lastcheckinetconnectiontick=GetTickCount(),!0===IsLocalServer())return;if(GetParameter("devicetype")!==DEVICE_WEBPHONE())return;isNull(contimer)&&(contimer=setInterval(function(){if(++ccmaxloop>100)return isNull(contimer)||clearInterval(contimer),contimer=null,void(ccmaxloop=0);webphone_api.$(".messagePopup").is(":visible")||(isNull(contimer)||clearInterval(contimer),contimer=null,ccmaxloop=0,"undefined"!=typeof navigator.onLine&&null!==navigator.onLine?!1===navigator.onLine&&(ShowToast(webphone_api.stringres.get("connection_msg")+"_2",5e3),PutToDebugLog(1,"ERROR, "+webphone_api.stringres.get("connection_msg")+"_2"),PutToDebugLog(2,"ERROR, CheckInternetConnection No internet connection is available at this time")):PutToDebugLog(2,"EVENT, CheckInternetConnection could NOT check"))},1e3))}catch(n){PutToDebugLogException(2,"common: CheckInternetConnection",n)}}function CheckInternetConnectionWS(){try{if(!1===webphone_api.global.sipstackstarted)return;var e=GetParameterInt("networkchecks",1);if(0===e)return;if(e<2&&0!=lastcheckinetconnectionwstick&&GetTickCount()-lastcheckinetconnectionwstick<3e5)return;lastcheckinetconnectionwstick=GetTickCount();if(lastnetsucceded>0&&GetTickCount()-lastnetsucceded<6e5)return;if(lastgood_set=!1,good_succeded=!1,e<2&&GetLogLevel()<2)return void PutToDebugLog(2,"EVENT, skip CheckInternetConnectionWS because loglevel is 1");var n=GetParameter("wstestservers");if(isNull(n)||n.length<3||"null"===n.toLowerCase())return void PutToDebugLog(2,"EVENT, CheckInternetConnectionWS no websocket addresses");if(!0===IsLocalServer())return;var t=n.split(",");if(isNull(t)||t.length<1)return void PutToDebugLog(2,"ERROR, CheckInternetConnectionWS list is NULL");if(!1===GetParameterBool("wseverconnected",!1))return void PutToDebugLog(2,"EVENT, skip CheckInternetConnectionWS because no previous sucessfull WebSocket connection");var o=GetParameter("lastgood_wstest");isNull(o)&&(o="");for(var i=0;i<t.length;)isNull(t[i])||t[i].length<3?t.splice(i,1):(!0===BrowserRequiresHttps(!1)&&(t[i]=t[i].replace("ws:","wss:")),i++);if(isNull(t)||t.length<1)return void PutToDebugLog(3,"WARNING, CheckInternetConnectionWS list is NULL after checksplit");o.length>0&&t.unshift(o);var a=1;webphone_api.global.domloaded_tick>0&&GetTickCount()-webphone_api.global.domloaded_tick<2e4&&(a=2e4-(GetTickCount()-webphone_api.global.domloaded_tick))<1&&(a=1),isNull(wsconn_timer)||clearTimeout(wsconn_timer),wsconn_timer=null,wsconn_timer=setTimeout(function(){try{if(!1===webphone_api.global.sipstackstarted)return;if(PutToDebugLog(2,"EVENT, CheckInternetConnectionWS start: "+t.length.toString()),t.length>0){ws1ok=-1;var e=new WebSocket(t[0]);e.onopen=function(){ws1ok=1,!1===lastgood_set&&(SaveParameter("lastgood_wstest",t[0]),lastgood_set=!0),good_succeded=!0,PutToDebugLog(2,"EVENT, CheckInternetConnectionWS public Internet connection is available(1)"),e&&e.close&&e.close(),e=null},e.onclose=function(){e=null},e.onerror=function(n){ws1ok=0,e=null}}setTimeout(function(){if(!1===good_succeded){if(t.length>1){ws2ok=-1;var e=new WebSocket(t[1]);e.onopen=function(){ws2ok=1,!1===lastgood_set&&(SaveParameter("lastgood_wstest",t[0]),lastgood_set=!0),PutToDebugLog(2,"EVENT, CheckInternetConnectionWS public Internet connection is available(2)"),e&&e.close&&e.close(),e=null},e.onclose=function(){e=null},e.onerror=function(n){ws2ok=0,e=null}}if(t.length>2){ws3ok=-1;var n=new WebSocket(t[2]);n.onopen=function(){ws3ok=1,!1===lastgood_set&&(SaveParameter("lastgood_wstest",t[0]),lastgood_set=!0),PutToDebugLog(2,"EVENT, CheckInternetConnectionWS public Internet connection is available(3)"),n&&n.close&&n.close(),n=null},n.onclose=function(){n=null},n.onerror=function(e){ws3ok=0,n=null}}if(t.length>3){ws4ok=-1;var o=new WebSocket(t[2]);o.onopen=function(){ws4ok=1,!1===lastgood_set&&(SaveParameter("lastgood_wstest",t[0]),lastgood_set=!0),PutToDebugLog(2,"EVENT, CheckInternetConnectionWS public Internet connection is available(4)"),o&&o.close&&o.close(),o=null},o.onclose=function(){o=null},o.onerror=function(e){ws4ok=0,o=null}}}},1200),isNull(cic_timer)||clearTimeout(cic_timer),cic_timer=null,cic_timer=setTimeout(function(){PutToDebugLog(2,"EVENT, CheckInternetConnectionWS result: con1: "+ws1ok.toString()+"; con2: "+ws2ok.toString()+"; con3: "+ws3ok.toString()),-1!==ws1ok&&0!==ws1ok||-1!==ws2ok&&0!==ws2ok||-1!==ws3ok&&0!==ws3ok||-1!==ws4ok&&0!==ws4ok?lastnetsucceded=GetTickCount():(ShowToast(webphone_api.stringres.get("connection_msg"),5e3),PutToDebugLog(1,"ERROR, "+webphone_api.stringres.get("connection_msg")),PutToDebugLog(2,"ERROR, CheckInternetConnectionWS.onerror, public Internet connection NOT available")),lastgood_set=!1},3500)}catch(n){PutToDebugLogException(2,"common: CheckInternetConnectionWS inner timer",n)}},a)}catch(r){PutToDebugLogException(2,"common: CheckInternetConnectionWS",r)}}function GetAvailableCallfunctions(){var e="callforward,conference,transfer,numpad,mute,hold,chat";if(!0===CanIUseVideo()&&(e+=",video"),0===GetParameterInt("conferencetype",1)&&(e=e.replace("conference,","")),!1===Glcf()&&(e=e.replace("conference,","")),!1===Glvd()&&(e=e.replace("video,",""),e=e.replace(",video","")),lversion<2&&(e="callforward,transfer,numpad,mute,hold,chat"),!1===Glt()&&(e=e.replace("callforward,",""),e=e.replace("transfer,","")),GetParameterInt("featureset",10)<10&&(e="numpad,mute,chat"),5===GetParameterInt("defmute",0)&&(e=e.replace("mute,",""),e=e.replace(",mute",""),e=e.replace("mute","")),getuseengine()===webphone_api.global.ENGINE_WEBRTC&&"Firefox"===GetBrowser()&&GetBrowserVersion()>=63){var n=ParamAsInt(GetParameter2("fasthold"),-1);1===n?e=e.replace("mute,",""):-1===n&&getuseengine()===webphone_api.global.ENGINE_WEBRTC&&"Firefox"===GetBrowser()&&(e=e.replace("mute,",""))}else getuseengine()===webphone_api.global.ENGINE_FLASH&&(e="transfer,numpad,chat",lversion<1&&(e=e.replace("transfer,","")));var t=e.split(",");if(!isNull(t)&&t.length>0){e="";for(var o=0;o<t.length;o++)isNull(t[o])||t[o].length<1||!1===HideSettings(t[o],webphone_api.stringres.get("sett_display_name_"+t[o]),t[o],!0)&&(e.length>0&&(e+=","),e+=t[o])}return e}function UploadAutoprov(){try{var e="http://mnt.mizu-voip.com/mmexreqvitserverjrsktt/xautoprovpush",n="";if(isNull(webphone_api.global.settmap2))return void PutToDebugLog(2,"ERROR, common: UploadAutoprov no settins to be uploaded (1)");for(var t in webphone_api.global.settmap2)if(!(isNull(t)||t.length<1||"enablepush"===t)){var o=webphone_api.global.settmap2[t];n.length>0&&(n+="\r\n"),n=n+t+";"+o[SETT_VALUE]}var i=location.href;i=decodeURIComponent(i);var a=i.indexOf("?");if(a>0&&(i=i.substring(0,a)),a=i.indexOf("#"),a>0&&(i=i.substring(0,a)),a=i.lastIndexOf("."),a>0&&i.length-a<7&&(a=i.lastIndexOf("/"))>0&&(i=i.substring(0,a)),i+="/webphone_api.js",PutToDebugLog(2,"EVENT, UploadAutoprov pathtowpapi: "+i),n+="\r\n",n=n+"pathtowpapi;"+i,isNull(n)||n.length<10)return void PutToDebugLog(2,"ERROR, common: UploadAutoprov no settins to be uploaded (2)");n="aenc_10_"+StrEc(n,webphone_api.global.ec_autoprov,!0),n="WPAUTOPROVSTART"+n+"WPAUTOPROVEND",!0===IsHttps()&&(e=GetTlsProxyUrl(e)),PutToDebugLog(2,"EVENT, UploadAutoprov url: "+e),HttpRequest(e,"wpautoprov",!0,n)}catch(r){PutToDebugLogException(2,"common: UploadAutoprov",r)}}function SendLog(e){try{if(isNull(e))return void PutToDebugLog(1,"ERROR, common: SendLog no logs to be sent");HttpRequest("http://mnt.mizu-voip.com/mmexreqvitserverjrsktt/xlogpush","wpsendlog",!0,e)}catch(n){PutToDebugLogException(2,"common: SendLog",n)}}function GetColortheme(){try{var e=GetParameter("theme");(isNull(e)||e.length<1)&&(e=GetConfig("colortheme")),isNull(webphone_api.parameters.theme)||(e=webphone_api.parameters.theme),isNull(webphone_api.parameters.colortheme)||(e=webphone_api.parameters.colortheme),(isNull(e)||e.length<1)&&(e="0");var n=0;try{n=StrToInt(e)}catch(t){}return(isNull(n)||n<0||n>100)&&(n=0),n}catch(o){PutToDebugLogException(2,"common: GetColortheme",o)}return 0}function SetCurrTheme(){try{if(1==IsSDK())return;if(isNull(document.getElementById("colortheme"))){webphone_api.$("<style />").appendTo("head").attr("id","colortheme")}var e=GetColortheme();if(0===e){webphone_api.$("#colortheme").html("");return"MSIE"!==GetBrowser()&&"Edge"!==GetBrowser()||webphone_api.$("#colortheme").html("#phone_app_main_container{scrollbar-face-color: #151515;scrollbar-base-color: #1d1d1d;scrollbar-3dlight-color: #1d1d1d;scrollbar-highlight-color: #1d1d1d;scrollbar-track-color: #3c3c3c;scrollbar-arrow-color: #000000;scrollbar-shadow-color: #1d1d1d;scrollbar-dark-shadow-color: #1d1d1d;"),void(CanLog(4)&&PutToDebugLog(4,"EVENT, SetCurrTheme, default theme"))}var n=webphone_api.themes.gettheme("theme_"+e);if(isNull(n))return void PutToDebugLog(2,"WARNING, common: SetCurrTheme no available theme "+n);var t=n.bgcolorheader,o=n.bgcolor,i=n.scrollbarcolor,a=n.listbgcolor,r=n.listitembgcolor,l=n.buttoncolor,s=n.buttonhover,p=n.buttonbordercolor,c=n.tabcolor,u=n.tabselectedcolor,g=n.bgdialpadnrfield,h=n.bgdialpadbtn,m=n.bgdialpadfooter,d=n.fontctheme,b=n.fontcwhite,_=n.fontfamily;if(isNull(t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid bgcolorheader");if(isNull(o.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid bgcolor");if(isNull(i.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid scrollbarcolor");if(isNull(a.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid listbgcolor");if(isNull(r.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid listitembgcolor");if(isNull(l.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid buttoncolor");if(isNull(s.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid buttonhover");if(isNull(p.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid buttonbordercolor");if(isNull(c.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid tabcolor");if(isNull(u.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid tabselectedcolor");if(isNull(d.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid fontctheme");if(isNull(b.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)))return void PutToDebugLog(2,"ERROR, SetCurrTheme invalid fontcwhite");isNull(_)&&(_="sans-serif"),PutToDebugLog(4,"EVENT, SetCurrTheme, applying color theme");webphone_api.$("#js_not_enabled_settings").css("background-color",o),webphone_api.$("#js_not_enabled_dialpad").css("background-color",o),webphone_api.$("#js_not_enabled").css("background-color",o),webphone_api.$("#choose_engine").css("background-color",o),webphone_api.$("#colortheme").html("");var f="";f+=".ui-overlay-b .ui-content, .ui-content, .all_app_pages, .ui-body-b, .ui-page-theme-b .ui-body-inherit, html .ui-bar-b .ui-body-inherit, html .ui-body-b .ui-body-inherit, html body .ui-group-theme-b .ui-body-inherit, html .ui-panel-page-container-b { background-color: "+o+"; }",f+="#phone_app_main_container { background-color: "+o+" !important;}","MSIE"!==GetBrowser()&&"Edge"!==GetBrowser()||(f+="body{scrollbar-face-color: #151515;scrollbar-base-color: "+o+";scrollbar-3dlight-color: "+o+";scrollbar-highlight-color: "+o+";scrollbar-track-color: #3c3c3c;scrollbar-arrow-color: #000000;scrollbar-shadow-color: "+o+";scrollbar-dark-shadow-color: "+o+";}"),f+="#phone_app_main_container ::-webkit-scrollbar { background: "+o+"; }#phone_app_main_container ::-webkit-scrollbar-thumb { background: "+i+"; }#phone_app_main_container ::-webkit-scrollbar-corner { background: #000; }",f+="#page_call_content #page_call_additional_info, #page_call_content #page_call_peer_details { color: "+b+"; }",f+=".ui-body-b,.ui-page-theme-b .ui-body-inherit,html .ui-bar-b .ui-body-inherit,html .ui-body-b .ui-body-inherit,html body .ui-group-theme-b .ui-body-inherit,html .ui-panel-page-container-b { background-color: "+a+"; text-shadow:0 0 0; }",f+=".mlistview .mlistitem { background-color: "+r+" !important; text-shadow:0 0 0; }",f+=".mlistview .mlistitem:hover { background-color: "+s+" !important; text-shadow:0 0 0; }",f+=".ui-page-theme-b .ui-btn,html .ui-bar-b .ui-btn,html .ui-body-b .ui-btn,html body .ui-group-theme-b .ui-btn,html head + body .ui-btn.ui-btn-b,.ui-page-theme-b .ui-btn:visited,html .ui-bar-b .ui-btn:visited,html .ui-body-b .ui-btn:visited,html body .ui-group-theme-b .ui-btn:visited,html head + body .ui-btn.ui-btn-b:visited {background-color: "+l+"; border-color: "+p+"; color: "+b+"; text-shadow:0 0 0; }",f+="#page_contactdetails_content .cd_container, #page_callhistorydetails_content .ch_container { border-bottom: .1em solid "+p+"; }",f+=".ui-page-theme-b .ui-btn:hover,html .ui-bar-b .ui-btn:hover,html .ui-body-b .ui-btn:hover,html body .ui-group-theme-b .ui-btn:hover,html head + body .ui-btn.ui-btn-b:hover,.ui-page-theme-b .ui-btn:active,html .ui-bar-b .ui-btn:active,html .ui-body-b .ui-btn:active,html body .ui-group-theme-b .ui-btn:active,html head + body .ui-btn.ui-btn-b:active {background-color: "+s+"; border-color: "+p+"; color: "+b+"; text-shadow:0 0 0; }",f+=".additional_header_left .btn_header_back SPAN { color: "+b+"; }",f+=".ui-bar-b,.ui-page-theme-b .ui-bar-inherit,html .ui-bar-b .ui-bar-inherit,html .ui-body-b .ui-bar-inherit,html body .ui-group-theme-b .ui-bar-inherit {background-color: "+t+"; border-color: "+o+"; color: "+b+";text-shadow: 0 0 0; }",f+=".navigation_bar .ui-btn {background-color: "+c+" !important; border-color: #125d79;color: "+b+"; text-shadow: 0 0 0; }",f+=".navigation_bar .ui-btn.ui-btn-active {background-color: "+u+" !important; border-color: #125d79;color: "+b+"; text-shadow: 0 0 0; }",f+="#phone_number_container { background: "+g+"; }",f+="#dialpad_btn_grid, #numpad_btn_grid { background: "+h+"; }",f+="#dialpad_call_grid { background: "+m+"; }",f+="#page_dialpad_content #phone_number_container .ui-btn:hover, #dialpad_btn_grid .ui-btn:hover, #dialpad_footer .ui-btn:hover { background: "+s+"; filter: Alpha(Opacity=5); opacity: .5; }",22===GetColortheme()?(f+="#contact_name, #ch_contact_name { background: "+c+"; }",f+="#dialpad_btn_grid .ui-btn .number, #numpad_btn_grid .ui-btn .number { font-size: 2.6em; font-family: Courier New, Courier, Helvetica, Lucida Sans Unicode, Trebuchet MS; }",f+="#dialpad_footer #dialpad_call_grid #btn_call .ui-btn:hover { background: "+s+"; }",f+=".navigation_bar .ui-btn.ui-btn-active { background-color: #ffffff !important; }",f+="#page_contactdetails_content .cd_call:hover, #page_contactdetails_content .cd_msg:hover, #page_callhistorydetails_content .ch_call:hover, #page_callhistorydetails_content .ch_msg:hover { background:#e8e8e8 !important; filter: Alpha(Opacity=7) !important; opacity: .7 !important; }"):f+="#contact_name, #ch_contact_name { background: "+m+"; }",f+="#page_call_content #callfunctions_layout { background: "+m+"; }",f+=".page_title, .additional_header_middle, .additional_header_left SPAN, .additional_header_left .page_title_small, #page_dialpad_content .ch_numberonly, #page_dialpad_content .ch_data .ch_name, #page_dialpad_content .ch_ctname, #page_contactdetails_content .cd_number, #page_callhistorylist_content .ch_data .ch_name, #page_callhistorydetails_content .ch_number, UL#settings_list .sett_display_name, .ui-header H1.adialog_title, #page_addeditcontact_content .aec_label, #page_messagelist_content #btn_newmessage, #page_messagelist_content .msg_name, #page_newuser_content SPAN, .notification_list .nt_title { color: "+d+"; }",f+=d===h?"#dialpad_btn_grid .ui-btn SPAN, #numpad_btn_grid .ui-btn SPAN{ color: "+b+"; }":"#dialpad_btn_grid .ui-btn SPAN, #numpad_btn_grid .ui-btn SPAN{ color: "+d+"; }",f+="#sendtosupport_container #btn_sendlog { background: "+d+"; }",f+=".all_app_pages .notification:hover, #page_contactdetails_content .cd_call:hover, #page_contactdetails_content .cd_msg:hover, #page_callhistorydetails_content .ch_call:hover, #page_callhistorydetails_content .ch_msg:hover, #callfunctions_layout .callfunc_status_on, #callfunctions_layout .ui-btn:hover { background: "+d+"; }",f+=".ui-page .ui-header, .ui-page .ui-bar-b { background-color: "+t+" !important; }",f+=".separator_color_bg { background-color: "+p+" !important; }",f+="#phone_number_container .ui-input-text, #page_contactslist_content .ui-input-search, #contact_name, #page_contactdetails_content .cd_type, #page_contactdetails_content .cd_button, #ch_contact_name, #page_callhistorydetails_content .ch_type { color: "+b+"; }",webphone_api.$("#colortheme").html(f)}catch(w){PutToDebugLogException(2,"common: SetCurrTheme",w)}}function NeedRegister(){try{var e=GetParameter("register");if("0"===e)return!1;if("2"===e)return!0;if("1"===e){var n=GetSipusername(!0),t=GetParameter("password");return n.length>0&&t.length>0}}catch(o){PutToDebugLogException(2,"common: NeedRegister",o)}return!0}function IsDomainName(e){try{if(isNull(e)||e.length<1)return!1;var n=e.indexOf("://");if(n>=0&&(e=e.substring(n+3)),n=e.indexOf("/"),n>=0&&(e=e.substring(0,n)),e=Trim(e),isNull(e)||e.length<1)return!1;if("localhost"===(e=e.toLowerCase()))return!0;var t=e.lastIndexOf(".");return!(t<2)&&(e=e.substr(t+1),!(e.length<2||e.length>3)&&!IsNumber(e))}catch(o){PutToDebugLogException(2,"common: IsDomainName",o)}return!1}function IsIPAddrress(e){try{if(isNull(e)||e.length<1)return!1;var n=e.indexOf("://");if(n>=0&&(e=e.substring(n+3)),n=e.indexOf("/"),n>=0&&(e=e.substring(0,n)),e=Trim(e),isNull(e)||e.length<1)return!1;if(e.indexOf(".")>0){if(e.length<6||e.length>17)return!1;for(var t=0,o=0;o<e.length;o++)"."==e.charAt(o)&&++t;return 3==t&&(e=ReplaceAll(e,".",""),e=ReplaceAll(e," ",""),e=ReplaceAll(e,":",""),IsNumber(e))}if(e.indexOf(":")>=0){if(e.length<3||e.length>60)return!1;if(":"==e.charAt(0)&&":"!=e.charAt(1))return!1;for(var i=0,o=0;o<e.length;o++)if(":"==e.charAt(o))++i;else if("["==e.charAt(o)||"]"==e.charAt(o)||"%"==e.charAt(o));else if(e.charAt(o)>="0"&&e.charAt(o)<="9");else if(e.charAt(o)>="a"&&e.charAt(o)<="f");else if(!(e.charAt(o)>="A"&&e.charAt(o)<="F"))return!1;if(i>=2&&i<=7)return!0}}catch(a){PutToDebugLogException(2,"common: IsIPAddrress",a)}return!1}function IsLanIP(e,n){if(IsLanIPEx(e)>0)return!0;if(!isNull(n)){if(!0===n)return!0;if(!1===n)return!1}return!1}function IsLanIPEx(e){try{if(isNull(e))return-1;if(e=e.toString(),e.length<3)return-1;if("mnt.mizu-voip.com"===e||"rtc.mizu-voip.com"===e||"usrtc3.webvoipphone.com"===e||"usrtcx.webvoipphone.com"===e||"usrtc.webvoipphone.com"===e||"usrtc2.webvoipphone.com"===e||"www.webvoipphone.com"===e||"www.mizu-voip.com"===e||"fcm.webvoipphone.com"===e||"voip.mizu-voip.com"===e||"sip.mizu-voip.com"===e)return 0;if(IsIPAddrress(e)||(isNull(dtisrvcache)||isNull(dtisrvcache[e.toLowerCase()])||!IsIPAddrress(dtisrvcache[e.toLowerCase()])?e===GetConfig("knowndomain")&&!isNull(GetConfig("knownip"))&&IsIPAddrress(GetConfig("knownip"))?e=GetConfig("knownip"):lasttrytoresolveadd&&lasttrytoresolveadd.length>0&&lasttrytoresolveadd.toLowerCase()!==e.toLowerCase()&&(isNull(dtisrvcache)||isNull(dtisrvcache[e.toLowerCase()]))&&(lasttrytoresolveadd=e,DomainToIp(e,function(e){})):e=dtisrvcache[e.toLowerCase()]),e=e.toLowerCase(),
0===e.indexOf("192.168.")||0===e.indexOf("10.")||0===e.indexOf("172.")&&(0===e.indexOf("172.16.")||0===e.indexOf("172.17.")||0===e.indexOf("172.18.")||0===e.indexOf("172.19.")||0===e.indexOf("172.20.")||0===e.indexOf("172.21.")||0===e.indexOf("172.22.")||0===e.indexOf("172.23.")||0===e.indexOf("172.24.")||0===e.indexOf("172.25.")||0===e.indexOf("172.26.")||0===e.indexOf("172.27.")||0===e.indexOf("172.28.")||0===e.indexOf("172.29.")||0===e.indexOf("172.30.")||0===e.indexOf("172.31."))||0===e.indexOf("169.254.")||0===e.indexOf("127.")||0===e.indexOf("0.")||"4.3.2.1"===e||"9.8.7.6"===e||0===e.indexOf("192.0.0.")||0===e.indexOf("192.0.2.")||e.indexOf("intranet")>=0||e.indexOf("private")>=0||e.indexOf("inner")>=0||e.indexOf("intern")>=0||e.indexOf(".lan")>=0||e.indexOf("local")>=0||IsIPv6Loopback(e)||0==e.toLowerCase().indexOf("fec")||0==e.toLowerCase().indexOf("fc")||0==e.toLowerCase().indexOf("fd")||0==e.indexOf("100::")||0==e.toLowerCase().indexOf("fe80::")||0==e.toLowerCase().indexOf("2001:db8::"))return 1;if(0===e.indexOf("ERROR")||e.indexOf("cannotresolve")>=0)return-1;if(e.indexOf(".")<0)return 1;if(IsIPAddrress(e))return 0;if(e.indexOf("mizu-voip.com")>=0||e.indexOf("google.com")>=0)return 0}catch(n){PutToDebugLogException(2,"common: IsLanIP",n)}return-1}function GetIpType(e){if(isNull(e)||e.length<3||e.length>60)return 0;for(var n=0;n<e.length;n++){if("."==e.charAt(n)){if(e.length<7||e.length>23)return 0;for(var t=0,o=n+1;o<e.length;o++)if("."==e.charAt(o)&&2==++t)return 1;return 0}if(":"==e.charAt(n)){if("["==e.charAt(0))return 2;if(0==n&&":"!=e.charAt(1))return 0;for(var o=n+1;o<e.length;o++){if(":"==e.charAt(o))return 2;if("."==e.charAt(o))return 0}return 0}}return 0}function AddressHasPort(e,n){if(isNull(e)||e.length<2)return!1;var t=e.lastIndexOf(":");if(t<0)return!1;var o=GetIpType(e);if(1==o)return!0;if("["==e.charAt(0)){if(e.length<4)return!1;for(var i=1;i<e.length-2;i++)if("]"==e.charAt(i))return":"==e.charAt(i+1);return!1}if(2!=o){var a=e.substring(t+1);if(e.indexOf(".")<0&&!IsPortNumber(a))return!1;var r=StrToIntDef(a,0);return r>0&&r<65536}if(2==o){for(var l=0,i=0;i<e.length;i++)":"==e.charAt(i)&&l++;if(8==l)return!0;if(7==l)return!1;var a=e.substring(t+1);if(!IsPortNumber(a))return!1;var r=StrToIntDef(a,0);return r>9999&&r<=65535||(n<1&&r>0&&r<=65535||(n<2&&(5060==r||5061==r||80==r||443==r)||n<2&&3==l&&":"==e.charAt(0)&&r>0&&r<=65535&&e.length<10&&(0==e.indexOf(":::")||0==e.indexOf("::1:"))))}return!1}function GetIPFromAddressSimple(e){if(isNull(e))return"";if(e=Trim(e),e.length<2)return e;if("["==e.charAt(0))return Trim(StrGetBetween(e,"[","]"));var n=e.lastIndexOf(":");if(n<0)return Trim(e);for(var t=0,o=0;o<e.length;o++){if("."==e.charAt(o)){t=-1;break}":"==e.charAt(o)&&t++}if(7==t)return Trim(e);if(e.indexOf(".")<0){var i=Trim(e.substring(n+1));if(!IsPortNumber(i))return Trim(e);var a=StrToIntDef(i,0);if(a<=0||a>65535)return Trim(e)}return Trim(e.substring(0,n))}function GetPortFromAddressSimple(e){if(isNull(e)||e.length<1)return-1;if(e=Trim(e),IsPortNumber(e)){var n=StrToIntDef(e,0);if(n>2&&n<=65535)return n}if(e.length<2)return-1;var t=e.lastIndexOf(":");if(t<0)return-1;if("["==e.charAt(0)){if((t=e.indexOf("]"))>0&&t<e.length-1&&":"==e.charAt(t+1)){var o=StrToIntDef(e.substring(t+2),-1);if(o>0&&o<65536)return o}return-1}for(var i=0,a=0;a<e.length;a++){if("."==e.charAt(a)){i=-1;break}":"==e.charAt(a)&&i++}if(0==i)return-1;if(7==i)return-1;var r=e.substring(t+1);if(e.indexOf(".")<0&&!IsPortNumber(r))return-1;var o=StrToIntDef(r,-1);return o>0&&o<65536?o:-1}function GetIPEnclosed(e){return e.length<2?e:"["!=e.charAt(0)&&2==GetIpType(e)&&e.indexOf("/")<0&&e.indexOf("\\")<0&&e.indexOf("@")<0&&e.indexOf(">")<0&&e.indexOf(",")<0?AddressHasPort(e,2)?"["+GetIPFromAddressSimple(e)+"]:"+GetPortFromAddressSimple(e).toString():"["+Trim(e)+"]":Trim(e)}function GetIPRaw(e){return isNull(e)?"":e.length<2?e:"["==e.charAt(0)?StrGetBetween(e,"[","]"):Trim(e)}function GetIPRawEx(e){return isNull(e)?"":e.length<2?e:"["==e.charAt(0)&&"]"==e.charAt(e.length-1)?StrGetBetween(e,"[","]"):Trim(e)}function IsIPv6Loopback(e){if(isNull(e)||e.length<3||e.indexOf(":")<0)return!1;if("["==e.charAt(0))return IsIPv6Loopback(StrGetBetween(e,"[","]"));if("1"!=e.charAt(e.length-1))return!1;if("::1"==e)return!0;for(var n=0;n<e.length-1;n++)if("0"==e.charAt(n));else if(":"!=e.charAt(n))return!1;return!0}function RemovePrefix(e,n){return 0==e.indexOf(n)?e.substring(n.length):e}function RemoveProtoPrefix(e,n){return 0!=e.indexOf(n)&&0!=e.indexOf(n.toUpperCase())?e:(e=RemovePrefix(e,n+"s://"),e=RemovePrefix(e,n.toUpperCase()+"S://"),e=RemovePrefix(e,n+"s:/"),e=RemovePrefix(e,n.toUpperCase()+"S:/"),e=RemovePrefix(e,n+"s:\\\\"),e=RemovePrefix(e,n.toUpperCase()+"S:\\"),e=RemovePrefix(e,n+"s:\\\\"),e=RemovePrefix(e,n.toUpperCase()+"S:\\"),e=RemovePrefix(e,n+"s//"),e=RemovePrefix(e,n.toUpperCase()+"S//"),e=RemovePrefix(e,n+"s\\\\"),e=RemovePrefix(e,n.toUpperCase()+"S\\\\"),e=RemovePrefix(e,n+"s\\"),e=RemovePrefix(e,n.toUpperCase()+"S\\"),e=RemovePrefix(e,n+"s:"),e=RemovePrefix(e,n.toUpperCase()+"S:"),e=RemovePrefix(e,n+"://"),e=RemovePrefix(e,n.toUpperCase()+"://"),e=RemovePrefix(e,n+":/"),e=RemovePrefix(e,n.toUpperCase()+":/"),e=RemovePrefix(e,n+":\\\\"),e=RemovePrefix(e,n.toUpperCase()+":\\"),e=RemovePrefix(e,n+":\\\\"),e=RemovePrefix(e,n.toUpperCase()+":\\"),e=RemovePrefix(e,n+"//"),e=RemovePrefix(e,n.toUpperCase()+"//"),e=RemovePrefix(e,n+"\\\\"),e=RemovePrefix(e,n.toUpperCase()+"\\\\"),e=RemovePrefix(e,n+"\\"),e=RemovePrefix(e,n.toUpperCase()+"\\"),e=RemovePrefix(e,n+":"),e=RemovePrefix(e,n.toUpperCase()+":"))}function RemoveProtocolString(e,n){return isNull(e)?"":e.length<1?e:(e=Trim(e),e=RemovePrefix(e,"*"),e=RemoveProtoPrefix(e,"http"),e=RemoveProtoPrefix(e,"ws"),e=RemoveProtoPrefix(e,"sip"),e=RemoveProtoPrefix(e,"tel"),e=RemoveProtoPrefix(e,"url"),e=RemoveProtoPrefix(e,"file"),e=RemoveProtoPrefix(e,"udp"),e=RemoveProtoPrefix(e,"tcp"),e=RemoveProtoPrefix(e,"tls"),e=RemovePrefix(e,"\\\\"),e=RemovePrefix(e,"//"),e=RemovePrefix(e,"\\"),e=RemovePrefix(e,"/"),e=RemovePrefix(e,":"),isNull(n)||1!=n||(e=RemovePrefix(e,"www."),e=RemovePrefix(e,"WWW.")),Trim(e))}function GetDomainFromAddress(e,n){try{if(isNull(e))return"";if(e=e.toString(),e.length<1)return e;e=Trim(e);var t=e.indexOf("'");t>0&&(e=ReplaceAll(e,"'","")),t=e.indexOf('"'),t>0&&(e=ReplaceAll(e,'"',"")),e=RemoveProtocolString(e,!1),t=e.indexOf("/"),t>=0&&(e=e.substring(0,t)),t=e.indexOf("?"),t>=0&&(e=e.substring(0,t)),t=e.indexOf("#"),t>=0&&(e=e.substring(0,t)),t=e.indexOf("\\"),t>0&&(e=e.substring(0,t)),t=e.indexOf("&"),t>0&&(e=e.substring(0,t)),t=e.indexOf(","),t>0&&(e=e.substring(0,t)),t=e.indexOf("<"),t>=0&&(e=StrGetBetween(e,"<",">")),e=Trim(e),(isNull(n)||1!=n)&&AddressHasPort(e)&&(e=GetIPFromAddressSimple(e))}catch(o){PutToDebugLogException(2,"common: GetDomainFromAddress",o)}return e}function IsPortNumber(e){for(var n=0;n<e.length;n++){if(0==n&&"0"==e.charAt(n))return!1;if(!(e.charAt(n)>="0"&&e.charAt(n)<="9"))return!1}return!0}function IsLocalUpperServer(){if(0==islocaluppersrvcache)return!1;if(1==islocaluppersrvcache)return!0;try{var e=GetWsuserUrl(GetSipusername(!0),GetParameter("password"),null,!1);if(!isNull(e)&&e.indexOf("upperserver=")>0&&(e=e.substring(e.indexOf("upperserver=")+12),e.indexOf("&")>=0&&(e=e.substring(0,e.indexOf("&"))),!isNull(e)&&e.length>0&&1===IsLanIPEx(e)))return islocaluppersrvcache=1,!0;islocaluppersrvcache=0}catch(n){PutToDebugLogException(2,"common: IsLocalUpperServer",n)}return!1}function ServerIsIPv6(){try{if((isNull(ils_srv1)||ils_srv1.length<1)&&(ils_srv1=GetParameter("serveraddress_user")),ils_srv1.length>0&&IsIPAddrress(ils_srv1)&&2==GetIpType(ils_srv1))return!0;if((isNull(ils_srv2)||ils_srv2.length<1)&&(ils_srv2=GetParameter("serveraddress_orig")),ils_srv2.length>0&&IsIPAddrress(ils_srv2)&&2==GetIpType(ils_srv2))return!0;if((isNull(ils_srv3)||ils_srv3.length<1)&&(ils_srv3=GetParameter("serveraddress")),ils_srv3.length>0&&IsIPAddrress(ils_srv3)&&2==GetIpType(ils_srv3))return!0;var e=GetConfig("serverip");if(isNull(e)&&(e=""),e=Trim(e),e.length>0&&IsIPAddrress(e)&&2==GetIpType(e))return!0;var n=GetConfig("server");if(isNull(n)&&(n=""),n=Trim(n),n.length>0&&IsIPAddrress(n)&&2==GetIpType(n))return!0;var t=GetConfig("knownip");if(isNull(t)&&(t=""),t=Trim(t),t.length>0&&IsIPAddrress(t)&&2==GetIpType(t))return!0}catch(o){PutToDebugLogException(2,"common: ServerIsIPv6",o)}return!1}function IsLocalServer(e){try{(isNull(ils_srv1)||ils_srv1.length<1)&&(ils_srv1=GetParameter("serveraddress_user")),(isNull(ils_srv2)||ils_srv2.length<1)&&(ils_srv2=GetParameter("serveraddress_orig")),(isNull(ils_srv3)||ils_srv3.length<1)&&(ils_srv3=GetParameter("serveraddress"));var n=GetConfig("serverip");isNull(n)&&(n=""),n=Trim(n);var t=GetConfig("server");isNull(t)&&(t=""),t=Trim(t);var o=GetConfig("knownip");if(isNull(o)&&(o=""),o=Trim(o),n.length>0||t.length>0||o.length>0)return!!(n.length>0&&IsIPAddrress(n)&&1==IsLanIPEx(n))||(!!(t.length>0&&IsIPAddrress(t)&&1==IsLanIPEx(t))||(!!(o.length>0&&IsIPAddrress(o)&&1==IsLanIPEx(o))||!(n.length>0&&IsIPAddrress(n)&&0==IsLanIPEx(n))&&(!(t.length>0&&IsIPAddrress(t)&&0==IsLanIPEx(t))&&(!(o.length>0&&IsIPAddrress(o)&&0==IsLanIPEx(o))&&(!!(n.length>0&&IsIPAddrress(n)&&IsLanIP(n))||(!!(t.length>0&&IsIPAddrress(t)&&IsLanIP(t))||!!(o.length>0&&IsIPAddrress(o)&&IsLanIP(o))))))));if(!isNull(alsv)&&alsv.length>0){var i=StrDc(alsv,alsvkey),a=i.split(",");if(!isNull(a)&&a.length>0){var r=!0,l=!0,s=!1,p=!1,c=[];c.push("l"),c.push("a"),c.push("n"),c.push("i"),c.push("p");var u=c.join("");c=[],c.push("l"),c.push("o"),c.push("c"),c.push("a"),c.push("l"),c.push("f"),c.push("i"),c.push("l"),c.push("e");var g=c.join("");c=[],c.push("l"),c.push("o"),c.push("c"),c.push("a"),c.push("l");var h=c.join("");c=[],c.push("l"),c.push("o"),c.push("c"),c.push("a"),c.push("l"),c.push("h"),c.push("o"),c.push("s"),c.push("t");for(var m=c.join(""),d=-1,b=0;b<a.length;b++)isNull(a[b])||Trim(a[b]).length<1||(a[b]=Trim(a[b]),a[b]!==u?a[b]!==g&&a[b]!==h&&a[b]!==u&&a[b]!==m&&"127.0.0.1"!==a[b]&&"file"!==a[b]&&(IsIPAddrress(a[b])?a[b].length<1||0!==(d=IsLanIPEx(a[b]))&&1!==d||(s=!0,p=!0,1==d?l=!1:0==d&&(r=!1)):a[b]=HostToIPQuick(a[b])):(s=!0,l=!1));if(!0===s&&!0===r)return!0;if(!0===p&&!0===l)return!1}}if(ils_srv1.length>0&&!IsIPAddrress(ils_srv1)&&DomainToIp(ils_srv1,function(e){ils_srv1=e}),ils_srv2.length>0&&!IsIPAddrress(ils_srv1)&&DomainToIp(ils_srv2,function(e){ils_srv2=e}),ils_srv3.length>0&&!IsIPAddrress(ils_srv3)&&DomainToIp(ils_srv3,function(e){ils_srv3=e}),!0===e){var _="",f="",w="",v=GetParameter("serveraddress_user");!isNull(v)&&v.length>0&&(_=DomainToIp(v,function(){}),isNull(_)&&(_=""));var E=GetParameter("serveraddress_orig");!isNull(E)&&E.length>0&&(f=DomainToIp(E,function(){}),isNull(f)&&(f=""));var P=GetParameter("serveraddress");return!isNull(P)&&P.length>0&&(w=DomainToIp(P,function(){}),isNull(w)&&(w="")),v.length>0&&1==IsLanIPEx(v)||(E.length>0&&1==IsLanIPEx(E)||(P.length>0&&1==IsLanIPEx(P)||(_.length>0&&1==IsLanIPEx(_)||(f.length>0&&1==IsLanIPEx(f)||(w.length>0&&1==IsLanIPEx(w)||!(v.length>0&&0==IsLanIPEx(v))&&(!(E.length>0&&0==IsLanIPEx(E))&&(!(P.length>0&&0==IsLanIPEx(P))&&(!(_.length>0&&0==IsLanIPEx(_))&&(!(f.length>0&&0==IsLanIPEx(f))&&(!(w.length>0&&0==IsLanIPEx(w))&&(!!(v.length>0&&IsLanIP(v))||(!!(E.length>0&&IsLanIP(E))||(!!(P.length>0&&IsLanIP(P))||(!(!(_.length>0)||!IsLanIP(_)&&!1!==IsIPAddrress(_))||(!(!(f.length>0)||!IsLanIP(f)&&!1!==IsIPAddrress(f))||!(!(w.length>0)||!IsLanIP(w)&&!1!==IsIPAddrress(w)))))))))))))))))}var T=GetWebrtcSrvAddr();if(T.length<2){if(ils_srv1.length>0&&1===IsLanIPEx(ils_srv1))return!0;if(ils_srv2.length>0&&1===IsLanIPEx(ils_srv2))return!0;if(ils_srv3.length>0&&1===IsLanIPEx(ils_srv3))return!0;if(ils_srv1.length>0&&0===IsLanIPEx(ils_srv1))return!1;if(ils_srv2.length>0&&0===IsLanIPEx(ils_srv2))return!1;if(ils_srv3.length>0&&0===IsLanIPEx(ils_srv3))return!1;if(ils_srv1.length>0&&(IsLanIP(ils_srv1)||!1===IsIPAddrress(ils_srv1)))return!0;if(ils_srv2.length>0&&(IsLanIP(ils_srv2)||!1===IsIPAddrress(ils_srv1)))return!0;if(ils_srv3.length>0&&(IsLanIP(ils_srv3)||!1===IsIPAddrress(ils_srv1)))return!0}else if(T=GetDomainFromAddress(T),!isNull(T)&&T.length>0&&!0===IsLanIP(T))return!0}catch(S){PutToDebugLogException(2,"common: IsLocalServer",S)}return!1}function GetWebdomain(){try{var e=window.location.host,n=window.location.protocol;return isNull(e)&&(e=""),isNull(n)||n.length<1?n="":n+="//",n+e}catch(t){PutToDebugLogException(2,"common: GetWebdomain",t)}return""}function GetBrandName(e){if(cachedbrandname.length>0)return 1==cachedbrandname.length&&"-"==cachedbrandname?((isNull(e)||!1!==e)&&(n="WebPhone"),""):cachedbrandname;try{var n="";return webphone_api.global.usestorage?(n=GetParameter("brandname"),(isNull(n)||n.length<1)&&(n=GetConfig("brandname")),(isNull(n)||n.length<1)&&(n=IsWindowsSoftphone()?"Softphone":"WebPhone")):(n=GetParameter("brandname"),(isNull(n)||n.length<1)&&(n=GetConfig("brandname")),isNull(n)&&(n="")),cachedbrandname=n,cachedbrandname.length<1&&(cachedbrandname="-"),n.length<1&&(isNull(e)||!0!==e)&&(n="WebPhone"),n}catch(t){PutToDebugLogException(2,"common: GetWebdomain",t)}return"WebPhone"}function CanShowLicKeyInput(){try{if(!IsWindowsSoftphone())return!1;if(!isNull(canshowlickeyinput)&&(!0===canshowlickeyinput||!1===canshowlickeyinput))return canshowlickeyinput;WinAPI("API_CanShowLicKeyUserInput",function(e){canshowlickeyinput=!(isNull(e)||!0!==e&&"true"!=e),SaveParameter("canshowlickeyinput",canshowlickeyinput.toString()),PutToDebugLog(4,"EVENT, common API_CanShow: "+e)})}catch(e){PutToDebugLogException(2,"common: CanShowLicKeyInput",e)}return!1}function BrowserRequiresHttps(e,n){try{if((isNull(n)||!1!==n&&!0!==n)&&(n=!1),UseSecureSrvConnection())return!0;var t=GetBrowser();if(isNull(e)||!0!==e){if("Chrome"===t||"Safari"===t||"Firefox"===t&&GetBrowserVersion()>=68)return!0}else{var o=window.location.href;if(isNull(o)&&(o=""),o=Trim(o.toLowerCase()),o.length<1&&(o=window.location.protocol,isNull(o)&&(o=""),o=Trim(o.toLowerCase()),o.length<1&&(o=location.href,isNull(o)&&(o=""),o=Trim(o.toLowerCase()))),o.toLowerCase().indexOf("file://")>=0)return!1;if(o.indexOf("localhost")<0&&o.indexOf("127.0.0.1")<0&&("Chrome"===t||"Safari"===t||"Firefox"===t&&GetBrowserVersion()>=68))return!0}}catch(i){PutToDebugLogException(2,"common: BrowserRequiresHttps",i)}return n}function IsHttps(){try{if(!isNull(is_https))return is_https;if(!0===PreferWss())return is_https=null,!0;is_https=!1;var e=window.location.protocol;return isNull(e)&&(e=""),(e=Trim(e.toLowerCase()),(e.length<4||e.indexOf("http")<0||e.indexOf("extension")<0)&&(e=location.href,isNull(e)&&(e=""),e=Trim(e.toLowerCase())),e.length<4)?is_https=!1:((e.indexOf("https")>=0&&e.indexOf("https")<10||e.indexOf("extension")>=0&&e.indexOf("extension")<12)&&(is_https=!0),is_https)}catch(n){PutToDebugLogException(2,"common: IsHttps",n)}return!1}function IsHttpsOrFile(){try{if(!isNull(is_httpsorfile))return is_httpsorfile;is_httpsorfile=!1;var e=window.location.protocol;return isNull(e)&&(e=""),(e=Trim(e.toLowerCase()),e.indexOf("https")>=0||e.indexOf("file")>=0)?is_httpsorfile=!0:(e=location.href,isNull(e)&&(e=""),e=Trim(e.toLowerCase()),is_httpsorfile=e.indexOf("https:")>=0||e.indexOf("file:")>=0)}catch(n){PutToDebugLogException(2,"common: IsHttpsOrFile",n)}return!1}function UseSecureSrvConnection(){try{if(!0===PreferWss())return!0;var e=window.location.protocol;if(isNull(e)&&(e=""),e=Trim(e.toLowerCase()),(e.length<1||0!=e.indexOf("http"))&&(e=location.href,isNull(e)&&(e=""),e=Trim(e.toLowerCase()),(e.length<1||0!=e.indexOf("http"))&&(e=window.location.href,isNull(e)&&(e=""),e=Trim(e.toLowerCase()))),0==e.indexOf("https:"))return!0;var n=GetWsAddressCfg(null,!1);if(isNull(n)&&(n=""),0==n.indexOf("*")&&(n=n.substring(1)),0==n.indexOf("wss:"))return!0;if(0==n.indexOf("ws:"))return!1;if(n=GetConfig("wsuser"),isNull(n)&&(n=""),0==n.indexOf("*")&&(n=n.substring(1)),0==n.indexOf("https:"))return!0;if(0==n.indexOf("http:"))return!1}catch(t){PutToDebugLogException(2,"common: UseSecureSrvConnection",t)}return IsHttps()}function PreferWss(){var e=!1;try{return!0===GetConfig("preferwss")&&(e=!0),isNull(webphone_api.parameters.preferwss)||!0!==webphone_api.parameters.preferwss&&!1!==webphone_api.parameters.preferwss||(e=webphone_api.parameters.preferwss,wsprinted||(wsprinted=!0,PutToDebugLog(3,"EVENT, PreferWss() set manually in webphone_api."))),e}catch(n){PutToDebugLogException(2,"common: PreferWss",n)}return!1}function MediaStreamPermissionDenied(){var e=GetBrandName();try{e+=" "+webphone_api.stringres.get("allowmedia_general"),1==IsSDK()?AlertDialogSDK(webphone_api.stringres.get("allowmedia_title"),e):AlertDialog(webphone_api.stringres.get("allowmedia_title"),e)}catch(n){PutToDebugLogException(2,"common: MediaStreamPermissionDenied",n)}}function GetTransferDirectoryName(e){try{var n=GetSipusername(!0),t=GetParameter("password"),o=GetParameter("serveraddress_user");isNull(n)&&(n=""),isNull(t)&&(t=""),isNull(o)&&(o=""),isNull(e)&&(e="");return Md5Hash(n+t+o+e+"539249178376")}catch(i){PutToDebugLogException(2,"common: GetTransferDirectoryName",i)}return""}function FileTransfer(e){try{isNull(e)&&(e=""),e=Trim(e),webphone_api.global.intentfiletransfer[0]="destination="+e,!1===IsSDK()&&webphone_api.$.mobile.changePage("#page_filetransfer",{transition:"slide",role:"page"})}catch(n){PutToDebugLogException(2,"common: FileTransfer",n)}}function GetLastUsedEngine(){var e="";try{var n=GetParameter("enginechecksum"),t=GetNewConfig(),o=Md5Hash(t);return n!==o&&(SaveParameter("enginechecksum",o),n.length>0)?(PutToDebugLog(2,"EVENT, Reset lastusedengine because config changed: "+t),PutToDebugLog(2,"EVENT, old checksum: "+n+"; new checksum: "+o),gcaniusewebrtc=null,gcaniuseapplet=null,gcaniuseflash=null,webphone_api.global.last_used_engine_cache="",GetParameter("lastusedengine").length>0&&SaveParameter("prevusedengine",GetParameter("lastusedengine")),SaveParameter("lastusedengine",""),SaveParameter("engineoldavailable_werbrtc",""),SaveParameter("engineoldavailable_ns",""),SaveParameter("engineoldavailable_java",""),SaveParameter("engineoldavailable_p2p",""),SaveParameter("engineoldavailable_app",""),SaveParameter("engineoldavailable_flash",""),SaveParameter("engineoldavailable_nativedial",""),""):(e=GetParameter("lastusedengine"),(isNull(e)||e.length<1)&&(e=webphone_api.global.last_used_engine_cache),isNull(e)&&(e=""),e)}catch(i){PutToDebugLogException(2,"common: GetLastUsedEngine",i)}return""}function IsConfigChanged(){try{if(GetParameter("enginechecksum")!==Md5Hash(GetNewConfig()))return!0}catch(e){PutToDebugLogException(2,"common: IsConfigChanged",e)}return!1}function GetNewConfig(){try{var e=location.href;isNull(e)&&(e=""),e=decodeURIComponent(e),e=e.toLowerCase();var n;n=e.indexOf("?"),n>=0&&(e=e.substring(0,n)),n=e.indexOf("#"),n>=0&&(e=e.substring(0,n)),e=Trim(e);var t=GetParameter("serveraddress_user");(isNull(t)||t.length<2)&&(t=GetParameter("serveraddress")),isNull(t)&&(t=""),t=t.toLowerCase();var o=GetWsAddressCfg(2);isNull(o)&&(o=""),o=o.toLowerCase();var i=GetProxyaddress(),a=GetParameter("transport"),r=GetParameterInt("enginepriority_java",2),l=GetParameterInt("enginepriority_webrtc",2),s=GetParameterInt("enginepriority_ns",2),p=GetParameterInt("enginepriority_flash",2),c=GetParameterInt("enginepriority_app",2),u=GetParameterInt("enginepriority_p2p",2),g=GetParameterInt("enginepriority_accessnum",2),h=GetParameterInt("enginepriority_nativedial",2),m=GetParameter("realm");isNull(m)&&(m="");var d=GetParameter("webphonebasedir");isNull(d)&&(d="");return e+":"+t+":"+o+":"+r+":"+l+":"+s+":"+p+":"+c+":"+u+":"+g+":"+h+":"+m+":"+d+":"+i+":"+a}catch(b){PutToDebugLogException(2,"common: GetNewConfig",b)}return""}function IsLastUsedEngineSaved(){return lastusedenginesaved}function SaveLastUsedEngine(){try{lastusedenginesaved=!0;var e="";if(getuseengine()===webphone_api.global.ENGINE_JAVA)e="java";else if(getuseengine()===webphone_api.global.ENGINE_WEBRTC)e="webrtc";else if(getuseengine()===webphone_api.global.ENGINE_SERVICE)e="ns";else{if(getuseengine()!==webphone_api.global.ENGINE_FLASH)return;e="flash"}"Windows"===GetOs()&&"flash"===e||(GetParameter("lastusedengine").length>0&&GetParameter("lastusedengine")!=e?SaveParameter("prevusedengine",GetParameter("lastusedengine")):GetParameter("prevusedengine").length<1&&e.length>0&&SaveParameter("prevusedengine",e),SaveParameter("lastusedengine",e),!isNull(e)&&e.length>0&&(webphone_api.global.last_used_engine_cache=e),PutToDebugLog(2,"EVENT, lastusedengine saved: "+e))}catch(n){PutToDebugLogException(2,"common: SaveLastUsedEngine",n)}}function IsLocalFileSystem(){try{var e=location.protocol;if(isNull(e)&&(e=location.href,e=decodeURIComponent(e),isNull(e)||e.length<2))return!1;if(e=e.toLowerCase(),e=Trim(e),e.indexOf("file:")>=0)return!0}catch(n){PutToDebugLogException(2,"common: IsLocalFileSystem",n)}return!1}function IsLocalFileSys(){try{var e=location.protocol;if(isNull(e)&&(e=location.href,e=decodeURIComponent(e),isNull(e)||e.length<2))return!1;var n=[];n.push("f"),n.push("i"),n.push("l"),n.push("e"),n.push(":");var t=n.join("");if(e=e.toLowerCase(),e=Trim(e),e.indexOf(t)>=0)return!0}catch(o){PutToDebugLogException(2,"common: ilfs",o)}return!1}function CallScriptingUrl(e,n,t,o,i,a,r,l,s,p){try{if(isNull(e)||Trim(e).length<4)return;isNull(n)&&(n=""),isNull(t)&&(t=""),isNull(o)&&(o=""),isNull(a)&&(a=""),isNull(l)&&(l=""),isNull(s)&&(s=""),isNull(i)&&(i="");var c=GetSipusername(!0),u=GetParameter("password"),g=GetParameter("serveraddress"),h=RandomInt(1e4,9999999).toString(),m=Md5Hash(c+":"+u),d=Md5Hash(c+":"+u+":"+h);(isNull(r)||r.length<1)&&(r="scripting_cb"),e.indexOf("USERNAME")>0?e=e.replace("USERNAME",c):(e.indexOf("?")<0?e+="?":e+="&",e=e+"username="+c),e=e.replace("PASSWORD",u),e=e.replace("CALLEDNUMBER",o),e.indexOf("PEERNUM")>0?e=e.replace("PEERNUM",o):(e.indexOf("?")<0?e+="?":e+="&",e=e+"peernumber="+o),e.indexOf("PEERDETAILS")>0?e=e.replace("PEERDETAILS",i):(e.indexOf("?")<0?e+="?":e+="&",e=e+"peerdetails="+i),e.indexOf("SERVERADDRESS")>0?e=e.replace("SERVERADDRESS",g):(e.indexOf("?")<0?e+="?":e+="&",e=e+"server="+g),e=e.replace("DIRECTION",t),e=e.replace("STATUS",n),e=e.replace("TEXT",a),e=e.replace("CURRENCY",""),e=e.replace("DEVICEID",GetDeviceId()),e=e.replace("CONNECTTIME",l),e=e.replace("DURATION",s),e=e.replace("MD5SIMPLE",m),e=e.replace("MD5NORMAL",d),e=e.replace("MD5SALT",h),!isNull(p)&&p.length>0&&(e=e+"&cdr="+encodeURIComponent(p)),PutToDebugLogSpecial(3,"EVENT,CallScriptingUrl: "+e,!1,""),UriParser(e,"","","","",r)}catch(b){PutToDebugLogException(2,"common: CallScriptingUrl",b)}}function ShowOfferSaveContact(){try{if(webphone_api.global.lastcallduration<1)return;if(IsCExt()>0)return;if(webphone_api.global.lastcallduration=0,webphone_api.$(".ui-page-active .ui-popup-active").length>0)return;!1===webphone_api.global.contactExists&&!isNull(webphone_api.global.contactExistsNr)&&webphone_api.global.contactExistsNr.length>0&&"1"===GetParameter("savetocontacts")&&0!=webphone_api.common.GetParameterInt("serveraddressbook_allowedit",1)&&(OfferSaveContact(webphone_api.global.contactExistsNr,webphone_api.global.callName),webphone_api.global.contactExists=!0,webphone_api.global.contactExistsNr="")}catch(e){PutToDebugLogException(2,"common: ShowOfferSaveContact",e)}}function OfferSaveContact(e,n,t){try{if(!0===IsSDK())return;var o=GetDeviceWidth();if(o=!isNull(o)&&IsNumber(o)&&o>100?Math.floor(o/1.2):220,o>400?o=400:o<120&&(o=120),!isNull(webphone_api.global.lastconfroom)&&webphone_api.global.lastconfroom.length>2){var i=" "+e;if(webphone_api.global.lastconfroom.indexOf(i)>0)return}n=isNull(n)||n===e?"":"<br />"+n;var a="";a='<li id="#offer_item_save"><a data-rel="back" style="text-align: center;">'+webphone_api.stringres.get("btn_save_to_contacts_1")+"</a></li>"+('<li id="#offer_item_cancel"><a data-rel="back" style="text-align: center;">'+webphone_api.stringres.get("btn_cancel")+"</a></li>")+('<li id="#offer_item_dontask"><a data-rel="back">'+webphone_api.stringres.get("btn_save_to_contacts_dontask")+"</a></li>");var r='<div id="savetocontacts" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+o+"px; min-width: "+Math.floor(.6*o)+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("save_to_contacts_title")+'</h1></div><div role="main" class="ui-content adialog_content" style="padding: 0; margin: 0;"><div style="text-align: center; margin-top: .5em; margin-bottom: .5em;">'+webphone_api.stringres.get("save_to_contacts_msg")+"<br />"+e+n+'</div><ul id="savetocontacts_ul" data-role="listview" data-inset="true" data-icon="false" style="margin: 0;">'+a+"</ul></div></div>";savectpopup_wasclosed=!1,t=t||function(){},webphone_api.$.mobile.activePage.append(r).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),savectpopup_wasclosed=!0}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){savectpopup_wasclosed=!0,webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#savetocontacts_ul").off("click","li"),t()}}),webphone_api.$("#savetocontacts_ul").on("click","li",function(t){var o=webphone_api.$(this).attr("id");webphone_api.$("#savetocontacts").on("popupafterclose",function(t){savectpopup_wasclosed=!0,"#offer_item_save"===o&&(webphone_api.global.intentaddeditct[0]="action=add",webphone_api.global.intentaddeditct[1]="numbertoadd="+e,webphone_api.global.intentaddeditct[2]="nametoadd="+n,webphone_api.$.mobile.changePage("#page_addeditcontact",{transition:"pop",role:"page"})),"#offer_item_cancel"===o||"#offer_item_dontask"===o&&SaveParameter("savetocontacts","0")})}),setTimeout(function(){!1===savectpopup_wasclosed&&webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),savectpopup_wasclosed=!0,webphone_api.global.contactExists=!0,webphone_api.global.contactExistsNr=""},15e3)}catch(l){PutToDebugLogException(2,"common: OfferSaveContact",l)}}function ContactIsFavorite(e){try{if(isNull(webphone_api.global.ctlist)||webphone_api.global.ctlist.length<1||isNull(e)||e.length<1||!IsNumber(e))return!1;var n=webphone_api.global.ctlist[e];if(isNull(n))return!1;var t=n[CT_FAV];if(!isNull(t)&&"1"===t)return!0}catch(o){PutToDebugLogException(2,"common: ContactIsFavorite",o)}return!1}function ContactSetFavorite(e,n){try{if(isNull(webphone_api.global.ctlist)||webphone_api.global.ctlist.length<1||isNull(e)||e.length<1)return;var t="0";isNull(n)||!0!==n||(t="1");var o=webphone_api.global.ctlist[e];if(isNull(o))return;o[CT_FAV]=t,webphone_api.global.ctlist[e]=o,webphone_api.global.wasCtModified=!0}catch(i){PutToDebugLogException(2,"common: ContactSetFavorite",i)}}function AudioDevicePopupSDK(e,n,t,o){try{if(!isNull(audiomodal))return void audiomodal.show();var i=GetParameter("volumein"),a=GetParameter("volumeout");!isNull(i)&&IsNumber(i)||(i="50"),!isNull(a)&&IsNumber(a)||(a="50");var r="";!isNull(t)&&t.length>0&&(r='<div class="audio_devider" style="float: left; clear: both; background: #cecece; width: 100%; height: .1em;">\x3c!--//--\x3e</div><div class="audio_left_container" style="width: 35%; float: left; font-size: 1.1em;"><label id="audio_ring_label" style="display: inline-block; margin-top: 1.3em;">'+webphone_api.stringres.get("audio_ring")+':</label></div><div class="audio_right_container" style="width: 60%; float: left; margin: 1em 0em 1em 0em;"><select name="audioselect_ring" id="audioselect_ring" style="margin: 0; width: 100%;">'+t+"</select></div>");var l="";!isNull(o)&&o.length>0&&(l='<div class="audio_devider" style="float: left; clear: both; background: #cecece; width: 100%; height: .1em;">\x3c!--//--\x3e</div><div class="audio_left_container" style="width: 35%; float: left; font-size: 1.1em;"><label id="video_rec_label" style="display: inline-block; margin-top: 1.3em;">'+webphone_api.stringres.get("video_rec")+':</label></div><div class="audio_right_container" style="width: 60%; float: left; margin: 1em 0em 1em 0em;"><select name="videoselect_rec" id="videoselect_rec" style="margin: 0; width: 100%;">'+o+"</select></div>");var s="";!isNull(n)&&n.length>0&&(s='<div class="audio_devider" style="float: left; clear: both; background: #cecece; width: 100%; height: .1em;">\x3c!--//--\x3e</div><div class="audio_left_container" style="width: 35%; float: left; font-size: 1.1em;"><label id="audio_rec_label" style="display: inline-block; margin-top: 2.3em;">'+webphone_api.stringres.get("audio_rec")+':</label></div><div class="audio_right_container" style="width: 60%; float: left; margin: 1em 0em 1em 0em;"><select name="audioselect_play" id="audioselect_play" style="margin: 0; width: 100%;">'+n+'</select><span id="audio_volumeout_value" style="background: #ccc; padding: .5em;">'+a+'</span><input name="audio_volumeout" id="audio_volumeout" min="0" max="100" value="'+a+'" type="range" style="margin-top: 1em; width: 80%;"></div>');var p='<span id="audio_volumein_value" style="background: #ccc; padding: .5em;">'+i+'</span><input name="audio_volumein" id="audio_volumein" min="0" max="100" value="'+i+'" type="range" style="margin-top: 1em; width: 80%;">';getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(p=""),audiomodal=webphone_api.picoModal({content:'<div id="audiodevice_modal" class="pmodal_container"><div id="audiodevice_modal_header" class="pmodal_header">'+webphone_api.stringres.get("audio_title")+'</div><div id="audiodevice_modal_content" class="pmodal_content" style="padding: 1em;"><div class="audio_left_container" style="width: 35%; float: left; font-size: 1.1em;"><label id="audio_mic_label" style="display: inline-block; margin-top: 2.3em;">'+webphone_api.stringres.get("audio_mic")+':</label></div><div class="audio_right_container" style="width: 60%; float: left; margin: 1em 0em 1em 0em;"><select name="audioselect_rec" id="audioselect_rec" style="margin: 0; width: 100%;">'+e+"</select>"+p+"</div>"+s+r+l+'</div><div id="audiodevice_modal_footer" class="pmodal_footer" style="float: left; width: 100%; margin-top: 1em;"><button id="btn_audiodevice_positive">'+webphone_api.stringres.get("btn_ok")+'</button><button id="btn_audiodevice_negative">'+webphone_api.stringres.get("btn_cancel")+"</button></div></div>",overlayStyles:{backgroundColor:"#565656",opacity:.6},modalStyles:{width:"20em"},overlayClose:!1,closeStyles:{background:"#eeeeee",position:"absolute",top:".2em",right:".3em",textAlign:"center",fontSize:"1.2em",fontWeight:"bold",border:".15em solid #bbb",borderRadius:".8em",paddingLeft:".25em",paddingRight:".25em",cursor:"pointer"}}).afterCreate(function(e){}).beforeShow(function(e,n){}).afterShow(function(e){}).beforeClose(function(e,n){}).afterClose(function(e){e.destroy(),audiomodal=null,webphone_api.webrtcapi.HideVideoPriview()}),audiomodal.show(),webphone_api.$("#audio_volumein").on("change",function(){webphone_api.$("#audio_volumein_value").html(webphone_api.$(this).val())}),webphone_api.$("#audio_volumeout").on("change",function(){webphone_api.$("#audio_volumeout_value").html(webphone_api.$(this).val())}),webphone_api.$("#videoselect_rec").on("change",function(){var e=webphone_api.$("#videoselect_rec").val();webphone_api.webrtcapi&&webphone_api.webrtcapi.MyCameraPreview(e)}),webphone_api.$("#btn_audiodevice_positive").on("click",function(){try{PutToDebugLog(5,"EVENT, common AudioDevicePopupSDK OK click");var e=webphone_api.$("#audioselect_rec").val(),n=webphone_api.$("#audioselect_play").val(),t=webphone_api.$("#audioselect_ring").val(),o="";isNull(document.getElementById("videoselect_rec"))||(o=webphone_api.$("#videoselect_rec").val()),!isNull(arecL)&&arecL.length>0&&(PutToDebugLog(2,"EVENT, mlogic API_SetDevice AudioDevicePopupSDK 0"),webphone_api.setdevice(0,e,2,12)),
!isNull(aplayL)&&aplayL.length>0&&(PutToDebugLog(2,"EVENT, mlogic API_SetDevice AudioDevicePopupSDK 1"),webphone_api.setdevice(1,n,2,12)),!isNull(t)&&!isNull(aringL)&&aringL.length>0&&(PutToDebugLog(2,"EVENT, mlogic API_SetDevice AudioDevicePopupSDK 2"),webphone_api.setdevice(2,t,2,14)),!isNull(o)&&o.length>0&&!isNull(vrecL)&&vrecL.length>0&&vrecL[0]!==o&&(PutToDebugLog(2,"EVENT, mlogic API_SetDevice AudioDevicePopupSDK 3"),webphone_api.setdevice(3,o,2,15)),setTimeout(function(){PutToDebugLog(2,"EVENT, mlogic API_GetDevice AudioDevicePopupSDK 0"),webphone_api.getdevice(0,function(e){}),PutToDebugLog(2,"EVENT, mlogic API_GetDevice AudioDevicePopupSDK 1"),webphone_api.getdevice(1,function(e){}),PutToDebugLog(2,"EVENT, mlogic API_GetDevice AudioDevicePopupSDK 3"),webphone_api.getdevice(3,function(e){})},300);var i=webphone_api.$("#audio_volumein").val(),a=webphone_api.$("#audio_volumeout").val();!isNull(i)&&i.length>0&&IsNumber(i)&&(SaveParameter("volumein",i),PutToDebugLog(2,"EVENT, mlogic API_SetVolume AudioDevicePopupSDK 0"),webphone_api.setvolume(0,i)),!isNull(a)&&a.length>0&&IsNumber(a)&&(SaveParameter("volumeout",a),PutToDebugLog(2,"EVENT, mlogic API_SetVolume AudioDevicePopupSDK 1"),webphone_api.setvolume(1,a)),audiomodal.close()}catch(r){PutToDebugLogException(2,"common: AudioDevicePopupSDK OK click",r)}}),webphone_api.$("#btn_audiodevice_negative").on("click",function(){audiomodal.close()})}catch(c){PutToDebugLogException(2,"common: AudioDevicePopupSDK",c)}}function FindInList(e,n){var t=0;try{if(t=1,isNull(n)||n.length<1)return-1;if(isNull(e)||e.length<1)return-2;t=2,n=n.toString(),t=51;for(var o="",i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=o.toString())===n)return i;t=3;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=o.toString(),o.toLowerCase()===n.toLowerCase()))return i;t=4;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=o.toString(),0==o.indexOf(n)))return i;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=o.toString(),0==n.indexOf(o)))return i;if(t=5,n=Trim(n).toLowerCase(),t=6,n.length<1)return-5;t=7;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=Trim(o).toLowerCase(),0==Trim(o).toLowerCase().indexOf(n)))return i;t=8;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=Trim(o).toLowerCase(),0==n.indexOf(o)))return i;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=Trim(o).toLowerCase(),o.indexOf(n)>=0))return i;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=Trim(o).toLowerCase(),n.indexOf(o)>=0))return i;t=9;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=Trim(o).toLowerCase(),o.indexOf(n.substring(0,12))>=0))return i;t=10;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=Trim(o).toLowerCase(),n.indexOf(o.substring(0,12))>=0))return i;t=11;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=Trim(o).toLowerCase(),o.indexOf(n.substring(0,6))>=0))return i;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=Trim(o).toLowerCase(),n.indexOf(o.substring(0,6))>=0))return i;for(var i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)&&(o=Trim(o).toLowerCase(),o.indexOf(n.substring(0,3))>=0))return i;t=12;for(var a="",i=0;i<e.length;i++)if(o=e[i],!(isNull(o)||o.length<1)){if(o=Trim(o).toLowerCase(),n.indexOf(o.substring(0,3))>=0)return i;a=a+e[i].toString()+","}PutToDebugLog(2,"EVENT, (warn) cannot find: "+n+" in: "+a)}catch(r){PutToDebugLogException(2,"common: FindInList "+t.toString(),r)}return-3}function GetAudioDevToSelect(e,n){if(isNull(n)||n.length<1)return"";if(isNull(e)||e.length<1)return n;var t=FindInList(e,n);return t>=0?e[t]:n}function AudioDevicePopup(e){try{CanLog(5)&&PutToDebugLog(5,"EVENT, AudioDevicePopup");var n=GetDeviceWidth();n=!isNull(n)&&IsNumber(n)&&n>100?Math.floor(n/1.2):220,n>400?n=400:n<120&&(n=120);var t=GetAudioPlayList();try{if(webphone_api.global.needaudiodevicepopup<1&&(isNull(t)||t.length<1)&&getuseengine()===webphone_api.global.ENGINE_WEBRTC){if(IsHttpsOrFile())return CanLog(5)&&PutToDebugLog(5,"EVENT, AudioDevicePopup needs permissions"),PutToDebugLog(1,"EVENT, Waiting for media permissions"),webphone_api.global.needaudiodevicepopup=1,webphone_api.webrtcapi.StartGetDevices(!0),void setTimeout(function(){webphone_api.global.needaudiodevicepopup<3&&(CanLog(5)&&PutToDebugLog(5,"EVENT, AudioDevicePopup permissions timeout"),AudioDevicePopup(e))},6e3);"Firefox"===GetBrowser()&&PutToDebugLog(1,"EVENT, Firefox requires HTTPS for audio output device listing")}else if(2==webphone_api.global.needaudiodevicepopup)return webphone_api.global.needaudiodevicepopup=3,CanLog(5)&&PutToDebugLog(5,"EVENT, AudioDevicePopup permission callback"),setTimeout(function(){webphone_api.getdevicelist(0,function(e){}),webphone_api.getdevice(0,function(e){})},10),setTimeout(function(){webphone_api.getdevicelist(1,function(e){}),webphone_api.getdevice(1,function(e){})},110),webphone_api.common.CanIUseVideo()&&setTimeout(function(){webphone_api.getdevicelist(2,function(e){}),webphone_api.getdevice(2,function(e){})},210),void setTimeout(function(){AudioDevicePopup(e)},310)}catch(S){PutToDebugLogException(2,"common: AudioDevicePopupPerm",S)}webphone_api.global.needaudiodevicepopup=4;var o=GetAudioRecList(),i=GetAudioRingList(),a="";isNull(o)&&(o=""),isNull(t)&&(t=""),isNull(i)&&(i=""),o.length>0&&(arecL=o.split("\r\n")),t.length>0&&(aplayL=t.split("\r\n")),i.length>0&&(aringL=i.split("\r\n")),getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(a=GetVideoRecList(),isNull(a)&&(a=""),a.length>0&&(vrecL=a.split("\r\n"))),o=o.replace("\r\n",","),t=t.replace("\r\n",","),i=i.replace("\r\n",","),a=a.replace("\r\n",",");var r='<option value="[VALUE]">[TEXT]</option>',l="",s="",p="",c="";if(!isNull(arecL)){var u=GetAudioDevToSelect(arecL,GetAudioRecDev());CanLog(5)&&PutToDebugLog(5,"EVENT, common devicepopup rec selected: "+u+", list ("+arecL.length.toString()+"): "+o);for(var g=0;g<arecL.length;g++)if(!(isNull(arecL[g])||arecL[g].length<1)){var h=!1;u===arecL[g]&&(h=!0,l=r+l),!1===h&&(l+=r),l=l.replace("[VALUE]",arecL[g]),l=l.replace("[TEXT]",arecL[g])}}if(!isNull(aplayL)){var m=GetAudioDevToSelect(aplayL,GetAudioPlayDev());CanLog(5)&&PutToDebugLog(5,"EVENT, common devicepopup play selected: "+m+", list ("+aplayL.length.toString()+"): "+t);for(var g=0;g<aplayL.length;g++)if(!(isNull(aplayL[g])||aplayL[g].length<1)){var h=!1;m===aplayL[g]&&(h=!0,s=r+s),!1===h&&(s+=r),s=s.replace("[VALUE]",aplayL[g]),s=s.replace("[TEXT]",aplayL[g])}}if(!isNull(aringL)){var d=GetAudioDevToSelect(aringL,GetAudioRingDev());CanLog(5)&&PutToDebugLog(5,"EVENT, common devicepopup ring selected: "+d+", list ("+aringL.length.toString()+"): "+i);for(var g=0;g<aringL.length;g++)if(!(isNull(aringL[g])||aringL[g].length<1)){var h=!1;d===aringL[g]&&(h=!0,p=r+p),!1===h&&(p+=r),p=p.replace("[VALUE]",aringL[g]),p=p.replace("[TEXT]",aringL[g])}}if(!isNull(vrecL)){var b=GetAudioDevToSelect(vrecL,webphone_api.global.video_rec_curr_device);CanLog(5)&&PutToDebugLog(5,"EVENT, common devicepopup video selected: "+b+", list ("+vrecL.length.toString()+"): "+a);for(var g=0;g<vrecL.length;g++)if(!(isNull(vrecL[g])||vrecL[g].length<1)){var h=!1;b===vrecL[g]&&(h=!0,c=r+c),!1===h&&(c+=r),c=c.replace("[VALUE]",vrecL[g]),c=c.replace("[TEXT]",vrecL[g])}}if(!0===IsSDK())return void AudioDevicePopupSDK(l,s,p,c);var _=GetParameter("volumein"),f=GetParameter("volumeout");!isNull(_)&&IsNumber(_)||(_="50"),!isNull(f)&&IsNumber(f)||(f="50");var w="";!isNull(p)&&p.length>0&&(w='<div class="audio_devider">\x3c!--//--\x3e</div><div class="audio_left_container"><label id="audio_ring_label">'+webphone_api.stringres.get("audio_ring")+':</label></div><div class="audio_right_container"><select name="audioselect_ring" id="audioselect_ring" style="margin: 0;">'+p+"</select></div>");var v="";!isNull(c)&&c.length>0&&(v='<div class="audio_devider">\x3c!--//--\x3e</div><div class="audio_left_container"><label id="video_rec_label">'+webphone_api.stringres.get("video_rec")+':</label></div><div class="audio_right_container"><select name="videoselect_rec" id="videoselect_rec" style="margin: 0;">'+c+"</select></div>");var E="";!isNull(s)&&s.length>0&&(E='<div class="audio_devider">\x3c!--//--\x3e</div><div class="audio_left_container"><label id="audio_rec_label">'+webphone_api.stringres.get("audio_rec")+':</label></div><div class="audio_right_container"><select name="audioselect_play" id="audioselect_play" style="margin: 0;">'+s+'</select><input name="audio_volumeout" id="audio_volumeout" data-highlight="true" data-mini="true" min="0" max="100" value="'+f+'" type="range"></div>');var P='<input name="audio_volumein" id="audio_volumein" data-highlight="true" data-mini="true" min="0" max="100" value="'+_+'" type="range">';getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(P="");var T='<div id="audiodevice_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="width:'+n+"px; max-width:"+n+"px; min-width: "+Math.floor(.6*n)+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("audio_title")+'</h1></div><div role="main" class="ui-content adialog_content" style="padding: 0; margin: 0; width: 100%;"><div class="audio_left_container"><label id="audio_mic_label">'+webphone_api.stringres.get("audio_mic")+':</label></div><div class="audio_right_container"><select name="audioselect_rec" id="audioselect_rec" style="margin: 0;">'+l+"</select>"+P+"</div>"+E+w+v+'</div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_ok")+'</a><a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_cancel")+"</a></div></div>";savectpopup_wasclosed=!1,e=e||function(){},webphone_api.$.mobile.activePage.append(T).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#videoselect_rec").off("change"),webphone_api.webrtcapi.HideVideoPriview(),e()}}),webphone_api.$("#videoselect_rec").on("change",function(){var e=webphone_api.$("#videoselect_rec").val();webphone_api.webrtcapi.MyCameraPreview(e)}),webphone_api.$("#adialog_positive").on("click",function(e){PutToDebugLog(5,"EVENT, common AudioDevicePopup close on click");var n=(webphone_api.$(this).attr("id"),webphone_api.$("#audioselect_rec").val()),t=webphone_api.$("#audioselect_play").val(),o=webphone_api.$("#audioselect_ring").val(),i="";isNull(document.getElementById("videoselect_rec"))||(i=webphone_api.$("#videoselect_rec").val()),!isNull(arecL)&&arecL.length>0&&(PutToDebugLog(2,"EVENT, mlogic API_SetDevice AudioDevicePopup 0"),webphone_api.setdevice(0,n,2,16)),!isNull(aplayL)&&aplayL.length>0&&(PutToDebugLog(2,"EVENT, mlogic API_SetDevice AudioDevicePopup 1"),webphone_api.setdevice(1,t,2,17)),!isNull(o)&&!isNull(aringL)&&aringL.length>0&&(PutToDebugLog(2,"EVENT, mlogic API_SetDevice AudioDevicePopup 2"),webphone_api.setdevice(2,o,2,18)),!isNull(i)&&i.length>0&&!isNull(vrecL)&&vrecL.length>0&&vrecL[0]!==i&&webphone_api.setdevice(3,i,2,19),setTimeout(function(){PutToDebugLog(2,"EVENT, mlogic API_GetDevice AudioDevicePopup 0"),webphone_api.getdevice(0,function(e){})},200),setTimeout(function(){PutToDebugLog(2,"EVENT, mlogic API_GetDevice AudioDevicePopup 1"),webphone_api.getdevice(1,function(e){})},300),setTimeout(function(){PutToDebugLog(2,"EVENT, mlogic API_GetDevice AudioDevicePopup 2"),webphone_api.getdevice(2,function(e){})},400),setTimeout(function(){PutToDebugLog(2,"EVENT, mlogic API_GetDevice AudioDevicePopup 3"),webphone_api.getdevice(3,function(e){})},500);var a=webphone_api.$("#audio_volumein").val(),r=webphone_api.$("#audio_volumeout").val();!isNull(a)&&a.length>0&&IsNumber(a)&&(SaveParameter("volumein",a),PutToDebugLog(2,"EVENT, mlogic API_SetVolume AudioDevicePopup 0"),webphone_api.setvolume(0,a)),!isNull(r)&&r.length>0&&IsNumber(r)&&(SaveParameter("volumeout",r),PutToDebugLog(2,"EVENT, mlogic API_SetVolume AudioDevicePopup 1"),webphone_api.setvolume(1,r))})}catch(S){PutToDebugLogException(2,"common: AudioDevicePopup",S)}}function IsContactBlocked(e,n){try{if((isNull(e)||e.length<1)&&(isNull(n)||n.length<1))return!1;var t=GetParameter2("blocked_contacts");if(isNull(t)||t.length<1)return!1;t=Trim(t);var o=t.split(",");if(isNull(o)||o.length<1)return!1;if(!isNull(e)&&Trim(e).length>0)for(var i=0;i<o.length;i++)if(!(isNull(o[i])||o[i].length<1)&&o[i]===e)return!0;if(!isNull(n)&&n.length>0)for(var i=0;i<o.length;i++)if(!(isNull(o[i])||o[i].length<1))for(var a=0;a<n.length;a++)if(!(isNull(n[a])||[a].length<1)&&o[i]===n[a])return!0}catch(r){PutToDebugLogException(2,"common: IsContactBlocked",r)}return!1}function IsNumberBlacklisted(e,n){try{if((isNull(e)||e.length<1)&&(isNull(n)||n.length<1))return!1;var t=GetParameter2("blacklist");if(isNull(t)||t.length<1)return!1;t=Trim(t);var o=t.split(",");if(isNull(o)||o.length<1)return!1;if(!isNull(e)&&Trim(e).length>0)for(var i=0;i<o.length;i++)if(!(isNull(o[i])||o[i].length<1)&&o[i]===e)return!0;if(!isNull(n)&&n.length>0)for(var i=0;i<o.length;i++)if(!(isNull(o[i])||o[i].length<1))for(var a=0;a<n.length;a++)if(!(isNull(n[a])||[a].length<1)&&o[i]===n[a])return!0}catch(r){PutToDebugLogException(2,"common: IsNumberBlacklisted",r)}return!1}function BlockContact(e,n){try{if((isNull(e)||e.length<1)&&(isNull(n)||n.length<1))return;var t=GetParameter2("blocked_contacts");if(isNull(t)&&(t=""),t=Trim(t),isNull(e)&&Trim(e).length>0||(t.length>0&&(t+=","),t+=Trim(e)),!(isNull(n)&&n.length>0))for(var o=0;o<n.length;o++)isNull(n[o])||Trim(n[o]).length<1||(t.length>0&&(t+=","),t+=Trim(n[o]));SaveParameter("blocked_contacts",t)}catch(i){PutToDebugLogException(2,"common: BlockContact",i)}}function UnBlockContact(e,n){try{if((isNull(e)||e.length<1)&&(isNull(n)||n.length<1))return;var t=GetParameter2("blocked_contacts");if(isNull(t)||t.length<1)return;t=Trim(t);var o=t.split(",");if(isNull(o)||o.length<1)return;if(!isNull(e)&&Trim(e).length>0){e=Trim(e);for(var i=0;i<o.length;i++)isNull(o[i])||o[i].length<1||o[i]===e&&(o[i]="")}if(!isNull(n)&&n.length>0)for(var i=0;i<o.length;i++)if(!(isNull(o[i])||o[i].length<1))for(var a=0;a<n.length;a++)isNull(n[a])||[a].length<1||o[i]===n[a]&&(o[i]="");t="";for(var i=0;i<o.length;i++)isNull(o[i])||o[i].length<1||(t.length>0&&(t+=","),t+=o[i]);SaveParameter("blocked_contacts",t)}catch(r){PutToDebugLogException(2,"common: UnBlockContact",r)}}function GetTlsProxyUrl(e){try{if(isNull(e)||e.length<1)return"";var n=RandomInt(1e5,999999999);return"https://rtc.mizu-voip.com:4443/?hsforward="+StrEc(e,"s7n1k8fnz7ejian4k",!1)+"&nocache="+n.toString()}catch(t){PutToDebugLogException(2,"common: GetTlsProxyUrl",t)}return""}function SetLogFormAction(){try{if(!0===IsSDK())return;var e=document.getElementById("xlogpush");if(isNull(e))return void PutToDebugLog(2,"ERROR, log form not found in HTML");var n=GetParameter("logform_action");(isNull(n)||n.length<3)&&(n="http://mnt.mizu-voip.com/mmexreqvitserverjrsktt/xlogpush"),n=n.toLowerCase(),n=Trim(n),0!==n.indexOf("http")&&(n="http://"+n);var t="";t=!0===IsHttps()?GetTlsProxyUrl(n):n,e.action=t,PutToDebugLog(5,"EVENT, SetLogFormAction: "+t.replace("mnt.mizu-voip","*"))}catch(o){PutToDebugLogException(2,"common: SetLogFormAction",o)}}function SentWebrtcSignaling(e){if(!(isNull(e)||e.length<1)&&0!==e.indexOf("INVITE sip")&&(e.indexOf("REGISTER sip:")>=0||e.indexOf("REGISTER sips:")>=0)){webphone_api.global.webrtclastregsent=GetTickCount(),isNull(wrereg_timer)||clearTimeout(wrereg_timer),wrereg_timer=null;var n=GetParameterInt("regtimeout",6e3);0!=n&&n<100&&(n=6e3),0!=n&&GetTickCount()-webphone_api.global.webrtcregtimer_exec>n+2e3&&(wrereg_timer=setTimeout(function(){webphone_api.global.webrtcregtimer_exec=GetTickCount(),0!=webphone_api.global.sipstackstarted&&(PutToDebugLog(2,"WARNING, Webrtc resend REGISTER because no answer received for previous register"),webphone_api.webrtcapi.ResendRegister())},n))}}function GetRecentInviteIn(){return laststoredmsg_invite_in}function GetWebrtcDisplayName(){return!isNull(webphone_api.global.sipunicoderewritefrom)&&webphone_api.global.sipunicoderewritefrom.length>0&&!isNull(webphone_api.global.sipunicoderewriteto)&&webphone_api.global.sipunicoderewriteto.length>0&&webphone_api.global.sipunicoderewriteto===lastincomingdisplayname?webphone_api.global.sipunicoderewritefrom:lastincomingdisplayname}function CatchWebrtcSignaling(e,n,t){try{if(isNull(e)||e.length<1||isNull(n))return;e=e.toString(),(isNull(t)||!0!==t&&!1!==t)&&(n==SIP_INVITE_OUT||n==SIP_REGISTER?t=!0:n==SIP_INVITE_IN?t=!1:e.indexOf("recv=")>=0?t=!1:e.indexOf("SEND")>=0?t=!0:(CanLog(3)&&PutToDebugLog(3,"EVENT, xxxxxxxxxxxx unknown message direction \r\n"+e),t=!0)),0==e.indexOf("EVENT, recv=\n")?e=e.replace("EVENT, recv=\n",""):0==e.indexOf("recv=\n")?e=e.replace("recv=\n",""):0==e.indexOf("recv=")&&(e=e.replace("recv=","")),0==e.indexOf("EVENT, SEND:\n")?e=e.replace("EVENT, SEND:\n",""):0==e.indexOf("SEND:\n")?e=e.replace("SEND:\n",""):0==e.indexOf("SEND:")&&(e=e.replace("SEND:","")),(isNull(webphone_api.common.getuseengine())||webphone_api.common.getuseengine().length<1)&&(webphone_api.global.last_useengine=webphone_api.global.ENGINE_WEBRTC),t||(getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(webphone_api.global.iscurrengineworking=!0),webphone_api.iswebrtcengineworking=1,webphone_api.global.webrtcsipsignalingreceived=1,webphone_api.global.failover_gateway=!1),t?StoreSIPMsg(1,e):StoreSIPMsg(0,e);var o="",i=e.indexOf("\r");if(i>0&&(o=e.substring(0,i),o=Trim(o).toLowerCase()),!t&&GetParameterInt("forcereregister",1)>0){var a=GetSipHeaderFromMsg(e,"CSeq");if(!isNull(a)&&a.indexOf("REGISTER")>0){var r=e.indexOf("\r\n");if(r>0){var l=e.substring(0,i);if(!isNull(l)&&(l=Trim(l),(r=l.indexOf(" "))>0&&(l=Trim(l.substring(r)),!isNull(l)&&(r=l.indexOf(" "),r>0&&(l=l.substring(0,r)),!isNull(l)&&IsNumber(l))))){var s=StrToInt(l);s>=200?(isNull(wrereg_timer)||clearTimeout(wrereg_timer),wrereg_timer=null):200===s&&1===GetParameterInt("forcereregister",1)&&webphone_api.webrtcapi.StartReRegister(!0)}}}}if(!t&&o.indexOf("message sip")>=0)try{var p=GetSipHeaderFromMsg(e,"X-Sms");if((isNull(p)||p.length<1)&&(p=GetSipHeaderFromMsg(e,"P-Sms")),!isNull(p)&&p.length>0&&p.toLowerCase().indexOf("yes")>=0&&e.indexOf("\r\n\r\n")>0){var c=e.substring(e.indexOf("\r\n\r\n")+4);if(isNull(c)&&(c=""),c=Trim(c),c.length>0){var u=GetSipHeaderFromMsg(e,"From");if(!isNull(u)&&u.length>0&&u.indexOf("<")>=0&&(u=u.substring(u.indexOf("<")+1),u.indexOf("@")>0)){u=u.substring(0,u.indexOf("@")),u=u.replace("sips:",""),u=u.replace("sip:","");try{webphone_api.onSmsCb(u,c)}catch(P){PutToDebugLogException(2,"There is an error in onSms() callback",P)}}}}}catch(P){PutToDebugLogException(2,"common: CatchWebrtcSignaling handle SMS",P)}if(o.indexOf("invite sip")>=0){var g="";if(t){var u=GetSipHeaderFromMsg(e,"To");!isNull(u)&&u.length>0&&u.indexOf("<")>=0&&(u=u.substring(u.indexOf("<")+1),u.indexOf("@")>0&&(u=u.substring(0,u.indexOf("@")),u=u.replace("sips:",""),u=u.replace("sip:",""),g=Trim(u)))}else{var u=GetSipHeaderFromMsg(e,"From");!isNull(u)&&u.length>0&&u.indexOf("<")>=0&&(u=u.substring(u.indexOf("<")+1),u.indexOf("@")>0&&(u=u.substring(0,u.indexOf("@")),u=u.replace("sips:",""),u=u.replace("sip:",""),g=Trim(u)))}if(!isNull(g)&&g.length>0)for(var h=0;h<webphone_api.global.ep.length;h++){var m=webphone_api.global.ep[h][EP_DESTNR];if(!isNull(m)&&m.length>0&&m.toLowerCase()===g.toLowerCase()){try{var d=GetSipHeaderFromMsg(e,"Call-ID"),b="";!isNull(webphone_api.global.ep[h][EP_CALLID])&&webphone_api.global.ep[h][EP_CALLID].length>0&&(b=webphone_api.global.ep[h][EP_CALLID]),d.length>0&&b.length<1&&(PutToDebugLog(5,"EVENT,set sipcallid for ep "+h+" on line "+webphone_api.global.ep[h][EP_LINE]+" / "+m+" to "+d),webphone_api.global.ep[h][EP_CALLID]=d,b=d),b===d&&(webphone_api.global.ep[h][EP_SIPINVITE]=e),d=GetSipHeaderFromMsg(e,"X-C-Call-ID"),b="",!isNull(webphone_api.global.ep[h][EP_XCALLID])&&webphone_api.global.ep[h][EP_XCALLID].length>0&&(b=webphone_api.global.ep[h][EP_XCALLID]),d.length>0&&b.length<1&&(webphone_api.global.ep[h][EP_XCALLID]=d)}catch(P){PutToDebugLogException(2,"common: CatchWebrtcSignaling inner 111",P)}break}}}if(!t&&!0===webphone_api.global.redialof&&!isNull(e)&&e.length>0)try{var _=GetSipHeaderFromMsg(e,"CSeq");isNull(_)&&(_=""),_=_.toLowerCase(),_.indexOf("invite")>=0&&(o.indexOf("sip/2.0 100 ")>=0||o.indexOf("sip/2.0 603 ")>=0||o.indexOf("sip/2.0 486 ")>=0)&&(webphone_api.global.redialof=!1)}catch(P){PutToDebugLogException(2,"common: CatchWebrtcSignaling inner 2",P)}!t&&o.indexOf("sip/2.0 503 ")>=0&&(PutToDebugLog(2,"WARNING,Restating webrtc sipstack because 503 received: "+o),webphone_api.flagrestartwebrtc=!0,webphone_api.webrtcapi.ReStart(5e3,!1));var f=!1;switch(n){case SIP_REGISTER:case SIP_INVITE_IN:case SIP_INVITE_OUT:break;case SIP_UNKNOWN:f=!0;break;default:f=!0}if(t||(e.indexOf("X-UT: b")>=0?ismizuserverdetected=3:e.indexOf("X-UT: g")>=0?ismizuserverdetected=2==ismizuserverdetected?3:1:e.indexOf("X-UT: s")>=0?ismizuserverdetected=1==ismizuserverdetected?3:2:ismizuserverdetected<0&&(ismizuserverdetected=0)),n==SIP_INVITE_IN||!0===f&&!t){var w=e.toLowerCase();if(w.indexOf("invite sip")>=0&&w.indexOf("invite sip")<10){lastincomingcallid=GetSipHeaderFromMsg(e,"Call-ID"),lastincomingdisplayname.length>0&&lastincomingcallid!=lastincomingdisplaynamecallid&&(lastincomingdisplayname="");var u=GetSipHeaderFromMsg(e,"From");!isNull(u)&&u.length>0&&u.indexOf("<")>0&&(u=u.substring(0,u.indexOf("<")),isNull(u)&&(u=""),u=ReplaceAll(u,'"',""),u=Trim(u),u.length>0&&(lastincomingdisplayname=Trim(u),lastincomingdisplaynamecallid=lastincomingcallid))}}if(!t){var v=GetSipHeaderFromMsg(e,"X-IMStatus");if(!isNull(v)&&v.length>0){var u=GetSipHeaderFromMsg(e,"From");isNull(u)&&(u="");var E=u.indexOf("<sip:");E>=0&&(u=u.substring(E+5),E=u.indexOf("@"),E>=0&&(u=u.substring(0,E)),u=Trim(u)),u!==GetSipusername()&&u!==GetSipusername(!0)&&u!==GetCallerid()&&SaveReceivedPresence2(u,v)}GetWebrtcCreditRating(e),GetWebrtcOptions(e)}}catch(P){PutToDebugLogException(2,"common: CatchWebrtcSignaling",P)}}function GetSipHeaderFromMsg(e,n){try{if(isNull(e)||e.length<10||isNull(n)||n.length<1)return"";var t="";if(n=Trim(n),t=StrGetBetween(e,"\n"+n+":","\r"),t.length>0)return Trim(t);n=n.toLowerCase(),0===n.indexOf("x-r-")&&(n=n.replace("x-r-",""));var o="\r\n";e.indexOf("\r\n")<0&&(o=e.indexOf("\r")>=0?"\r":"\n");var i=e.split(o);if(isNull(i))return"";for(var a=0,r=0;r<i.length;r++)if(!(isNull(i[r])||i[r].indexOf(":")<1)){a=i[r].indexOf(":");var l=Trim(i[r].substring(0,a));if(l=l.toLowerCase(),0===l.indexOf("x-r-")&&(l=l.replace("x-r-","")),l===n){t=Trim(i[r].substring(a+1,i[r].length));break}}return isNull(t)&&(t=""),t}catch(s){PutToDebugLogException(2,"common: GetSipHeaderFromMsg",s)}return""}function RewriteSipHeaderInMsg(e,n,t){try{if(isNull(e)||e.length<10||isNull(n)||n.length<1||isNull(t))return e;var o=e;n.indexOf(":")<0&&(n+=":");var i=o.indexOf(n);if(i<0)return e;var a=o.substring(0,i);o=o.substring(i);var r="\r\n";o.indexOf("\r\n")<0&&o.indexOf("\n")>=0&&(r="\n"),o=o.substring(o.indexOf(r)+r.length);return a+n+" "+t+r+o}catch(l){PutToDebugLogException(2,"common: RewriteSipHeaderInMsg",l)}return e}function ClassSipHeader(){this.line,this.header,this.value}function ExtractSIPUsername(e){return isNull(e)||e.length<1?"":(e.indexOf("<")>=0&&(e=e.substring(e.indexOf("<")+1)),e.indexOf(">")>0&&(e=e.substring(0,e.indexOf(">"))),e.indexOf(":")>=0&&(e.indexOf("sip:")>=0&&(e=e.substring(e.indexOf("sip:")+4)),e.indexOf("sips:")>=0&&(e=e.substring(e.indexOf("sips:")+5)),e.indexOf("tel:")>=0&&(e=e.substring(e.indexOf("tel:")+4)),e.indexOf("udp:")>=0&&(e=e.substring(e.indexOf("udp:")+4)),e.indexOf("tcp:")>=0&&(e=e.substring(e.indexOf("tcp:")+4)),e.indexOf("tls:")>=0&&(e=e.substring(e.indexOf("tls:")+4)),e.indexOf("wss:\\")>=0&&(e=e.substring(e.indexOf("wss:\\")+6)),e.indexOf("ws:\\")>=0&&(e=e.substring(e.indexOf("ws:\\")+5)),e.indexOf("wss:")>=0&&(e=e.substring(e.indexOf("wss:")+4)),e.indexOf("ws:")>=0&&(e=e.substring(e.indexOf("ws:")+3))),e.indexOf("@")>=0&&(e=e.substring(0,e.indexOf("@"))),e.indexOf(";")>=0&&(e=e.substring(0,e.indexOf(";"))),e)}function GetEpFromMsg(e){if(isNull(e)||e.length<10)return null;var n=(StrToInt(webphone_api.global.aline),""),t=e.indexOf("\r");t>0&&(n=e.substring(0,t),n=Trim(n).toLowerCase());var o=GetSipHeaderFromMsg(e,"CSeq");if(o=isNull(o)?"":o.toLowerCase(),o.indexOf("invite")<0&&n.indexOf("invite sip")<0&&(o.indexOf("register")>=0||o.indexOf("options")>=0||n.indexOf("register sip")>=0||n.indexOf("options sip")>=0))return null;var i=ExtractSIPUsername(GetSipHeaderFromMsg(e,"From")),a=ExtractSIPUsername(GetSipHeaderFromMsg(e,"To")),r=GetSipHeaderFromMsg(e,"Call-ID"),l=GetSipusername(!0),s=a;return(s.length<1||s==l)&&(s=i,(s.length<1||s==l)&&(s="")),GetEndpoint(1013,-1,s,r,"",!1,!0)}function GetLineFromMsg(e){if(getlinefrommsg_ep=null,isNull(e)||e.length<10)return-1;var n="",t=e.indexOf("\r");t>0&&(n=e.substring(0,t),n=Trim(n).toLowerCase());var o=GetSipHeaderFromMsg(e,"CSeq");if(o=isNull(o)?"":o.toLowerCase(),o.indexOf("invite")<0&&n.indexOf("invite sip")<0&&(o.indexOf("register")>=0||o.indexOf("options")>=0||n.indexOf("register sip")>=0||n.indexOf("options sip")>=0))return 0;var i=ExtractSIPUsername(GetSipHeaderFromMsg(e,"From")),a=ExtractSIPUsername(GetSipHeaderFromMsg(e,"To")),r=GetSipHeaderFromMsg(e,"Call-ID"),l=GetSipusername(!0),s=a;(s.length<1||s==l)&&(s=i,(s.length<1||s==l)&&(s=""));var p=GetEndpoint(1013,-1,s,r,"",!1,!0);return!isNull(p)&&p.length>4?(getlinefrommsg_ep=p,StrToIntDef(p[EP_LINE],-1)):(CanLog(5)&&PutToDebugLog(5,"EVENT, (warn) xxxxxxxxxx cannot find ep for "+r),-1)}function RemoveSipHeadreFromCache(e){}function RemoveSessionHeadersFromCache(e){}function MsgStoreObj(){this.callid="",this.dir=-1,this.type=0,this.msg=""}function StoreSIPMsg(e,n){try{if(isNull(n))return!1;if(n.length<20)return!1;if(isNull(e))return!1;(e<-1||e>2)&&(e=-1);var t=Trim(n.toLowerCase());if(0==t.indexOf("ack sip"))return!0;var o=GetSipHeaderFromMsg(n,"Call-ID");if(o.length<1)return!1;var i=!0,a=!1,r=!1;if(e<0&&(0==t.indexOf("regiter sip")?e=1:0==t.indexOf("options sip")&&(e=1)),1==e?(laststoredmsg_any_out=n,0==n.indexOf("SIP/2.0 ")?(i=!1,laststoredmsg_answer_out=n,0==n.indexOf("SIP/2.0 200")&&(r=!0,(laststoredmsg_200ok_out.length<1||GetSipHeaderFromMsg(n,"CSeq").indexOf(" INVITE")>0)&&(laststoredmsg_200ok_out=n))):(laststoredmsg_request_out=n,0==t.indexOf("invite sip")?(a=!0,laststoredmsg_invite_out=n):0==t.indexOf("regiter sip")&&(a=!0,laststoredmsg_register=n))):(laststoredmsg_any_in=n,0==n.indexOf("SIP/2.0 ")?(i=!1,laststoredmsg_answer_in=n,0==n.indexOf("SIP/2.0 200")&&(r=!0,(laststoredmsg_200ok_in.length<1||GetSipHeaderFromMsg(n,"CSeq").indexOf(" INVITE")>0)&&(laststoredmsg_200ok_in=n))):(laststoredmsg_request_in=n,0==t.indexOf("invite sip")?(a=!0,laststoredmsg_invite_in=n):0==t.indexOf("regiter sip")&&(a=!0,laststoredmsg_register=n))),0==t.indexOf("invite sip"));else if(0==t.indexOf("register sip"));else{if(0==t.indexOf("subscribe sip"))return!0;if(0==t.indexOf("notify sip"))return!0;if(0==t.indexOf("options sip"))return!0;if(0==t.indexOf("message sip"))return!0;if(0==t.indexOf("publish sip"))return!0}var l=GetSipHeaderFromMsg(n,"CSeq");if(l.length<1);else if(l.indexOf(" INVITE")>0);else if(l.indexOf(" REGISTER")>0);else{if(l.indexOf(" SUBSCRIBE")>0)return!0;if(l.indexOf(" NOTIFY")>0)return!0;if(l.indexOf(" OPTIONS")>0)return!0;if(l.indexOf(" MESSAGE")>0)return!0;if(l.indexOf(" PUBLISH")>0)return!0}var s=0;i?(s=1,a&&(s=3)):(s=2,r&&(s=4));var p=0;isNull(msgstore)&&(msgstore=[]);for(var c=0;c<msgstore.length;c++)if(isNull(msgstore[c]))msgstore.splice(c,1),c--;else if(msgstore[c].callid===o&&msgstore[c].dir===e){switch(s){case 0:0==msgstore[c].type&&((msgstore[c].msg.length<1||0!=n.indexOf("SIP/2.0 100 "))&&(msgstore[c].msg=n),p=2);break;case 1:0!=msgstore[c].type&&1!=msgstore[c].type||(msgstore[c].msg=n,p=1,1==msgstore[c].type&&(p=2));break;case 2:0!=msgstore[c].type&&2!=msgstore[c].type||((msgstore[c].msg.length<1||0!=n.indexOf("SIP/2.0 100 "))&&(msgstore[c].msg=n),p=1,2==msgstore[c].type&&(p=2));break;case 3:0!=msgstore[c].type&&1!=msgstore[c].type&&3!=msgstore[c].type||(msgstore[c].msg=n,p=1,3==msgstore[c].type&&(p=2));break;case 4:0!=msgstore[c].type&&2!=msgstore[c].type&&4!=msgstore[c].type||(msgstore[c].msg=n,p=1,4==msgstore[c].type&&(p=2))}if(2==p)break}if(p>0)return!0;msgstore.length>120&&msgstore.splice(0,20);var u=new MsgStoreObj;return u.callid=o,u.dir=e,u.type=s,u.msg=n,msgstore.push(u),!0}catch(g){PutToDebugLogException(2,"common: StoreSIPMsg",g)}return!1}function GetSIPMsg(e,n,t,o,i,a,r){try{if(isNull(msgstore))return"";isNull(e)&&(e=""),isNull(n)&&(n=-7),isNull(t)&&(t=-1),isNull(i)&&(i=""),isNull(a)&&(a=!1),isNull(r)&&(r=!1),(t<-1||t>2)&&(t=-1),(isNull(o)||o<0||o>4)&&(o=0),(!IsNumber(n)||n<1&&-2!=n)&&(n=StrToInt(webphone_api.global.aline));var l="",s=a;if(e.length<1&&n<1)l+="a",s=!0;else if(e.length<1&&n>0){if(l+="b",!isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0){var p=GetCallEpIdx(4573,!1,n,"","",null,null,null,!1);if(p>=0&&!isNull(webphone_api.global.ep[p])&&webphone_api.global.ep[p].length>=9&&(l+="c",e=webphone_api.global.ep[p][EP_CALLID]),isNull(e)||e.length<1){l+="d";for(var c,u=0;u<webphone_api.global.ep.length&&(c=webphone_api.global.ep[u],isNull(c)||c.length<9||c[EP_LINE]!=n||(l+="e",e=c[EP_CALLID],isNull(e)||!(e.length>0)));u++);}}(isNull(e)||e.length<1)&&!isNull(eplinecallid)&&eplinecallid.length>n&&(l+="f",e=eplinecallid[n]),isNull(e)&&(e="")}var g="";if(e.length>0){l+="g";for(var h=msgstore.length-1;h>=0;h--)if(isNull(msgstore[h]))msgstore.splice(h,1);else if(msgstore[h].callid==e&&!(t>=0&&msgstore[h].dir!==t||o!=msgstore[h].type&&0!=o&&(1!=o||1!=msgstore[h].type&&3!=msgstore[h].type)&&(2!=o||2!=msgstore[h].type&&4!=msgstore[h].type))){if(l+="h",g.length<1&&(g=msgstore[h].msg),(0==o||1==s)&&i.length>0){if(GetSipHeaderFromMsg(msgstore[h].msg,i).length<1)continue;g=msgstore[h].msg}break}if(0!=o&&!0===s&&(g.length<20||i.length>0&&GetSipHeaderFromMsg(g,i).length<1)){l+="i";for(var h=msgstore.length-1;h>=0;h--)if(isNull(msgstore[h]))msgstore.splice(h,1);else if(msgstore[h].callid==e&&!(t>=0&&msgstore[h].dir!==t)){if(g.length<1&&(g=msgstore[h].msg),i.length>0){if(GetSipHeaderFromMsg(msgstore[h].msg,i).length<1)continue;g=msgstore[h].msg}break}if(g.length<1||i.length>0&&GetSipHeaderFromMsg(g,i).length<1){l+="j";for(var h=msgstore.length-1;h>=0;h--)if(isNull(msgstore[h]))msgstore.splice(h,1);else if(msgstore[h].callid==e){if(g.length<1&&(g=msgstore[h].msg),i.length>0){if(GetSipHeaderFromMsg(msgstore[h].msg,i).length<1)continue;g=msgstore[h].msg}break}}}}if(!0===s&&(g.length<20||i.length>0&&GetSipHeaderFromMsg(g,i).length<1)&&(l+="k",
1==t&&4==o&&laststoredmsg_200ok_out.length>0?g=laststoredmsg_200ok_out:1==t&&3==o&&laststoredmsg_invite_out.length>0?g=laststoredmsg_invite_out:1==t&&2==o&&laststoredmsg_answer_out.length>0?g=laststoredmsg_answer_out:1==t&&1==o&&laststoredmsg_request_out.length>0?g=laststoredmsg_request_out:1==t&&0==o&&laststoredmsg_any_out.length>0?g=laststoredmsg_any_out:(1!=t||1==s)&&4==o&&laststoredmsg_200ok_in.length>0?g=laststoredmsg_200ok_in:(1!=t||1==s)&&3==o&&laststoredmsg_invite_in.length>0?g=laststoredmsg_invite_in:(1!=t||1==s)&&2==o&&laststoredmsg_answer_in.length>0?g=laststoredmsg_answer_in:(1!=t||1==s)&&1==o&&laststoredmsg_request_in.length>0?g=laststoredmsg_request_in:(1!=t||1==s)&&0==o&&laststoredmsg_any_in.length>0?g=laststoredmsg_any_in:1==s&&4==o&&laststoredmsg_200ok_out.length>0?g=laststoredmsg_200ok_out:1==s&&3==o&&laststoredmsg_invite_out.length>0?g=laststoredmsg_invite_out:1==s&&2==o&&laststoredmsg_answer_out.length>0?g=laststoredmsg_answer_out:1==s&&1==o&&laststoredmsg_request_out.length>0?g=laststoredmsg_request_out:1==s&&laststoredmsg_any_out.length>0&&(g=laststoredmsg_any_out),(0==o||s)&&i.length>0&&GetSipHeaderFromMsg(g,i).length<1&&(l+="l",1==t&&laststoredmsg_invite_out.length>0&&GetSipHeaderFromMsg(laststoredmsg_invite_out,i).length>0?g=laststoredmsg_invite_out:1==t&&laststoredmsg_200ok_out.length>0&&GetSipHeaderFromMsg(laststoredmsg_200ok_out,i).length>0?g=laststoredmsg_200ok_out:1==t&&laststoredmsg_request_out.length>0&&GetSipHeaderFromMsg(laststoredmsg_request_out,i).length>0?g=laststoredmsg_request_out:1==t&&laststoredmsg_answer_out.length>0&&GetSipHeaderFromMsg(laststoredmsg_answer_out,i).length>0?g=laststoredmsg_answer_out:1==t&&laststoredmsg_any_out.length>0&&GetSipHeaderFromMsg(laststoredmsg_any_out,i).length>0?g=laststoredmsg_any_out:(1!=t||1==s)&&laststoredmsg_invite_in.length>0&&GetSipHeaderFromMsg(laststoredmsg_invite_in,i).length>0?g=laststoredmsg_invite_in:(1!=t||1==s)&&laststoredmsg_200ok_in.length>0&&GetSipHeaderFromMsg(laststoredmsg_200ok_in,i).length>0?g=laststoredmsg_200ok_in:(1!=t||1==s)&&laststoredmsg_request_in.length>0&&GetSipHeaderFromMsg(laststoredmsg_request_in,i).length>0?g=laststoredmsg_request_in:(1!=t||1==s)&&laststoredmsg_answer_in.length>0&&GetSipHeaderFromMsg(laststoredmsg_answer_in,i).length>0?g=laststoredmsg_answer_in:(1!=t||1==s)&&laststoredmsg_any_in.length>0&&GetSipHeaderFromMsg(laststoredmsg_any_in,i).length>0?g=laststoredmsg_any_in:1==s&&laststoredmsg_invite_out.length>0&&GetSipHeaderFromMsg(laststoredmsg_invite_out,i).length>0?g=laststoredmsg_invite_out:1==s&&laststoredmsg_200ok_out.length>0&&GetSipHeaderFromMsg(laststoredmsg_200ok_out,i).length>0?g=laststoredmsg_200ok_out:1==s&&laststoredmsg_request_out.length>0&&GetSipHeaderFromMsg(laststoredmsg_request_out,i).length>0?g=laststoredmsg_request_out:1==s&&laststoredmsg_answer_out.length>0&&GetSipHeaderFromMsg(laststoredmsg_answer_out,i).length>0?g=laststoredmsg_answer_out:1==s&&laststoredmsg_any_out.length>0&&GetSipHeaderFromMsg(laststoredmsg_any_out,i).length>0&&(g=laststoredmsg_any_out))),i.length>0){var m="";return g.length>0&&(m=GetSipHeaderFromMsg(g,i)),m.length<1?!0===r||"warning"==i||"x-reason"==i||"reason"==i||"Warning"==i||"X-reason"==i||"X-Reason"==i||"Reason"==i?"":(CanLog(3)&&PutToDebugLog(3,"EVENT, GetSIPMsg no header available at this moment: "+i+" (callid: "+e+", line: "+n.toString()+", dir: "+t.toString()+", type: "+o.toString()+", must: "+a.toString()+", from: "+l+", msg: "+g.length.toString()+")"),"WARNING: header not found"):(CanLog(5)&&PutToDebugLog(5,"EVENT, GetSIPMsg header: "+i+" callid: "+e+", line: "+n.toString()+", dir: "+t.toString()+", type: "+o.toString()+", must: "+a.toString()+", from: "+l+", msg: "+g.length.toString()+", ret: "+m),m)}return!0===r||"warning"==i||"x-reason"==i||"reason"==i||"Warning"==i||"X-reason"==i||"X-Reason"==i||"Reason"==i||CanLog(5)&&PutToDebugLog(5,"EVENT, GetSIPMsg callid: "+e+", line: "+n.toString()+", dir: "+t.toString()+", type: "+o.toString()+", must: "+a.toString()+", from: "+l+", ret: "+g.length.toString()),g}catch(d){PutToDebugLogException(2,"common: GetSIPMsg",d)}return""}function GetSipHeaderInternal(e,n){return isNull(e)||e.length<1?"":GetSIPMsg("",-1,0,0,e,n,!0)}function GetSipHeader(e,n,t,o){return isNull(e)||e.length<1?"":GetSIPMsg("",t,0,0,e,o,!1)}function GetSipMessage(e,n,t,o){return GetSIPMsg("",e,n,t,"",o)}function GetWebrtcCreditRating(e){try{if(!1===Glbr())return;if(isNull(e))return;e=e.toString();var n=e.indexOf("Credit:");if(n>0){var t=e.substring(n+7);n=t.indexOf("\r\n"),n>0&&(t=t.substring(0,n)),n=t.indexOf("\n"),n>0&&(t=t.substring(0,n)),!isNull(t)&&t.length>0&&PutToDebugLog(1,"CREDIT,Credit: "+Trim(t))}var n=e.indexOf("Rating:");if(n>0){var o=e.substring(n+7);n=e.indexOf("\r\n"),n>0&&(o=o.substring(0,n)),n=e.indexOf("\n"),n>0&&(o=o.substring(0,n)),!isNull(o)&&o.length>0&&(webphone_api.global.rating=" ("+Trim(o)+")",PutToDebugLog(4,"GetWebrtcCreditRating received rating: "+Trim(o)))}}catch(i){PutToDebugLogException(2,"common: GetWebrtcCreditRating",i)}}function GetWebrtcOptions(e){try{if(isNull(e))return;e=e.toString();var n=e.indexOf("X-RTCOptions:");if(n>0){var t=e.substring(n+13);n=t.indexOf("\r\n"),n>0&&(t=t.substring(0,n)),n=t.indexOf("\n"),n>0&&(t=t.substring(0,n)),!isNull(t)&&t.length>0&&(PutToDebugLog(3,"EVENT,GetWebrtcOptions received: "+t),t.indexOf("nostun")>=0&&(webphone_api.global.nostun=!0),t.indexOf("noturn")>=0&&(webphone_api.global.noturn=!0))}}catch(o){PutToDebugLogException(2,"common: GetWebrtcOptions",o)}}function GetUsemizutlsproxy(){try{var e=GetParameter("usemizutlsproxy"),n=GetConfig("usemizutlsproxy"),t=webphone_api.parameters.usemizutlsproxy;return!isNull(n)&&n.length>0&&IsNumber(n)&&(e=n),!isNull(t)&&t.length>0&&IsNumber(t)&&(e=t),(isNull(e)||1!==e.length)&&(e="1"),e}catch(o){PutToDebugLogException(2,"common: GetUsemizutlsproxy",o)}return"1"}function UseTLSReload(){try{if(!0===IsHttps())return!1;var e=window.location.href;if(!0===IsLanIP(GetDomainFromURL(e),!0)||"localhost"===GetDomainFromURL(e)||e.toLowerCase().indexOf("file:")>=0)return CanLog(4)&&PutToDebugLog(4,"EVENT, TLSReload, page will NOT be reloaded because local webserver"),!1;var n=!1,t=GetParameter2("webrtcserveraddress");if((isNull(t)||t.length<3)&&(t=GetConfig("webrtcserveraddress")),(isNull(t)||t.length<3)&&(t=GetWsAddressCfg()),!isNull(t)&&t.length>3&&t.indexOf("ws:")>=0)return CanLog(4)&&PutToDebugLog(4,"EVENT, TLSReload, page will NOT be reloaded because webrtcserveraddress is not secure"),!1;var o=GetUsemizutlsproxy();"2"===o||"1"===o&&(!0===webphone_api.global.usestorage||Strl(60))?n=!0:PutToDebugLog(2,"EVENT, TLSReload skipped because usemizutlsproxy: "+o);try{decodeURIComponent(window.location.href).toLowerCase()}catch(c){""}if(!0===n&&!0===BrowserRequiresHttps(!0)){SaveParameter("aldm",decodeURIComponent(window.location.href)),PutToDebugLog(2,"EVENT, TLSReload, page will reload over https");var i=GetParameter("serveraddress_user"),a=GetParameter("serveraddress_orig"),r=GetParameter("serveraddress"),l=window.location.hostname;if(l=Trim(l),l=l.toLowerCase(),!1===webphone_api.global.isdebugversion){var s=!0;if(i&&i.length>0&&(1==IsLanIPEx(i)||i.indexOf("localhost")>=0)?s=!0:i&&i.length>0&&0==IsLanIPEx(i)&&i.indexOf("localhost")<0?s=!1:a&&a.length>0&&(1==IsLanIPEx(a)||a.indexOf("localhost")>=0)?s=!0:a&&a.length>0&&0==IsLanIPEx(a)&&a.indexOf("localhost")<0?s=!1:r&&r.length>0&&(1==IsLanIPEx(r)||r.indexOf("localhost")>=0)?s=!0:r&&r.length>0&&0==IsLanIPEx(r)&&r.indexOf("localhost")<0&&(s=!1),s)return PutToDebugLog(4,"EVENT, TLSReload, will NOT reload page, because server is on local network or webphone hosted on localhost"),!1}var p=StrToInt(GetParameter2("enginepriority_webrtc"));if(isNull(p)&&(p=2),p>=2)return PutToDebugLog(3,"EVENT, TLSReload, enginepriority_webrtc: "+p.toString()+"; higher priority, will not ask user, just automatically reload page"),!0;if(p<2)return PutToDebugLog(4,"EVENT, TLSReload, enginepriority_webrtc: "+p.toString()+"; lower priority, will NOT reload page"),!1;GetParameter("usemizutlsproxy_userreload")}}catch(u){PutToDebugLogException(2,"common: UseTLSReload",u)}return!1}function TLSReload(){try{if(!0===tlsrcalled)return;PutToDebugLog(2,"EVENT, TLSReload, reloading page over https"),tlsrcalled=!0;SaveSettingsFile(2,GetActiveAccSettingsFilename(),function(e){e?PutToDebugLog(2,"EVENT, SaveSettingsFile from TLSReload Successfull"):PutToDebugLog(2,"ERROR, SaveSettingsFile from TLSReload Failed");var n=window.location.href;if(!(isNull(n)||n.length<4)){n=decodeURIComponent(n),n.indexOf("#")>0&&(n=n.substring(0,n.indexOf("#"))),PutToDebugLog(2,"EVENT, TLSReload, current location: "+n);var t=GetTlsProxyUrl(n);PutToDebugLog(2,"EVENT, TLSReload, new location: "+t),window.location.href=t}})}catch(e){PutToDebugLogException(2,"common: TLSReload",e)}}function GetDomainFromURL(e){try{return isNull(e)?"":(e=decodeURIComponent(e),e.toLowerCase().indexOf("file:")>=0?e:GetDomainFromAddress())}catch(n){PutToDebugLogException(2,"common: GetDomainFromURL",n)}return e}function CallWsuserKeepAlive(e){try{if(webphone_api.global.useengine!==webphone_api.global.ENGINE_WEBRTC)return;if(!IsMizuServerOrGateway())return;var n=GetTickCount();if(!0!==e&&n-wsuserka_lasttick<36e3)return;wsuserka_lasttick=n;var t=GetSipusername(!0),o=GetParameter("password");if(isNull(t)||t.length<1)return void PutToDebugLog(2,"ERROR, common CallWsuserKeepAlive will NOT send, because invalid username ("+t+")");if(!0!==e&&(isNull(o)||o.length<1))return void PutToDebugLog(2,"EVENT, common CallWsuserKeepAlive will not send wsuser, because we have no password ("+o+")");var i=GetWsuserUrl(t,o);if(i.length<3)return void PutToDebugLog(2,"ERROR, common CallWsuserKeepAlive wsuser not needed");IsMizuServerOrGateway()&&UriParser(i,"","","","","webrtccreateuser")}catch(a){PutToDebugLogException(2,"common: CallWsuserKeepAlive",a)}}function GetVersionStr(){if(!isNull(e))return e;try{var e=webphone_api.versionstr;return(isNull(e)||Trim(e).length<1)&&(e=webphone_api.global.versionstr),e}catch(n){PutToDebugLogException(2,"common: GetVersionStr",n)}return""}function IsSDK(){try{if(isnotsdkcache)return!1;if(1190===GetConfigInt("brandid",-1)&&!isNull(document.getElementById("page_dialpad")))return!1;var e=null;if("undefined"==typeof window.pageissdk||null===window.pageissdk||"false"!=window.pageissdk&&0!=window.pageissdk&&1!=window.pageissdk&&"true"!=window.pageissdk||(e=("undefined"==typeof window.pageissdk||null===window.pageissdk||"false"!==window.pageissdk)&&("undefined"!=typeof window.pageissdk&&null!==window.pageissdk&&"true"===window.pageissdk||window.pageissdk))||(isnotsdkcache=!0),isNull(e)&&webphone_api.parameters&&(e=webphone_api.parameters.issdk),isNull(e)||1==e||"true"==e||e.length<1)return!0}catch(n){PutToDebugLogException(2,"common: IsSDK",n)}return!1}function GetStunServersStr(){var e=0;if(0===GetParameterInt("use_fast_stun",1))return null;if(!0===webphone_api.global.nostun||!0===IsLocalServer(!0))return null;ParseStunTurnNew();var n="",t=!0;try{var o=GetConfig("stunserveraddress");o.length<1&&(t=!1),e=1;var i=o,a="stun:rtc.mizu-voip.com:8090",r=GetSipusername(!0),l=GetParameter("password"),s=GetWsuserUrl(r,l),p=s;e=2;var c=GetParameter("stunserveraddress");if(null===c||"null"===c||"Null"===c||"NULL"===c)return PutToDebugLog(2,"EVENT, GetStunServersStr2: NULL"),null;if(void 0===c||c.length<1?t=!1:(e=3,i=c,t=!0),i.length>0&&(t=!0),e=4,!1===t)if(e=10,!0===IsMizuServerOrGateway()&&!isNull(s)&&s.length>3){e=11;var u=s,g=u.indexOf("://");if(e=12,g>0&&(u=u.substring(g+3)),g=u.indexOf("/"),g>0&&(u=u.substring(0,g)),e=13,s.indexOf("wss:")>=0||s.indexOf("https:")>=0)if(e=14,AddressHasPort(u)){e=16;var h=GetPortFromAddressSimple(u);u=GetIPFromAddressSimple(u),e=20,n="8090"===h||"443"===h?"stun:"+GetIPEnclosed(u)+":8090":a}else e=15,n="stun:"+GetIPEnclosed(u)+":8090";else e=20,n=AddressHasPort(u)?"stun:"+u:"stun:"+GetIPEnclosed(u)+":80",e=21}else n=a;else if("null"==i.toLowerCase())e=22,n=null;else{e=23;var m=i.split(",");if(!isNull(m)&&m.length>0){e=24;for(var d=0;d<m.length;d++)isNull(m[d])||m[d].length<1||(n.length>0&&(n+=","),AddressHasPort(m[d])||(m[d]=GetIPEnclosed(m[d])+":80"),n=n+"stun:"+Trim(m[d]));e=25}}if(e=30,!isNull(p)&&p.length>0){e=31;var g=p.indexOf("://");g>=0&&(p=p.substring(g+3)),e=32,g=p.indexOf("/"),g>0&&(p=p.substring(0,g)),e=33,(p.indexOf("148.251.28.181")>=0||p.indexOf("rtc.mizu-voip.com")>=0)&&(p.indexOf("18080")>0||p.indexOf("2443")>0)&&(e=34,n=a)}e=35,(n.indexOf("148.251.28.181")>=0||n.indexOf("rtc.mizu-voip.com")>=0||n.indexOf("192.145.38.88")>=0||n.indexOf("107.174.212.78")>=0||n.indexOf("usrtcx.webvoipphone.com")>=0||n.indexOf("usrtc.webvoipphone.com")>=0||n.indexOf("usrtc3.webvoipphone.com")>=0||n.indexOf("usrtc2.webvoipphone.com")>=0)&&(e=36,AddressHasPort(n)&&8090!=GetPortFromAddressSimple(n)&&(PutToDebugLog(5,"EVENT, change stun port to 8090 from "+GetPortFromAddressSimple(n).toString()),n=GetIPEnclosed(GetIPFromAddressSimple(n))+":8090"),e=41),webphone_api.global.loglevel>=5&&n.indexOf("mizu-voip.com")<0&&n.indexOf("webvoipphone.com")<0&&n.indexOf("jsiprtc.com")<0&&n.indexOf("webrtc-sip.org")<0&&PutToDebugLog(5,"EVENT, def stun server: "+n)}catch(b){PutToDebugLogException(2,"common: GetStunServersStr: ("+e.toString()+")",b)}return n}function GetOneStunSrv(){var e="";try{var n=GetStunServersStr();if(!isNull(n)&&n.length>3){var t=n.indexOf(",");e=t>0?Trim(n.substring(0,t)):n}isNull(e)&&(e=""),PutToDebugLog(2,"EVENT, GetOneStunSrv: "+e)}catch(o){PutToDebugLogException(2,"common: GetOneStunSrv",o)}return e}function GetTurnSrv(){if(!0===webphone_api.global.noturn||!0===IsLocalServer(!0))return null;ParseStunTurnNew();var e={},n=!0;try{var t=GetConfig("turnserveraddress"),o=GetConfig("turnparameters"),i=GetConfig("turnusername"),a=GetConfig("turnpassword");(t.length<1||i.length<1||a.length<1)&&(n=!1);var r=t,l=o,s=i,p=a;if(null===webphone_api.parameters.turnserveraddress||"null"==webphone_api.parameters.turnserveraddress||"NULL"==webphone_api.parameters.turnserveraddress)return PutToDebugLog(2,"EVENT, GetTurnSrv3: NULL"),null;var c=GetParameter2("turnserveraddress"),u=GetParameter2("turnparameters"),g=GetParameter2("turnusername"),h=GetParameter2("turnpassword");if(null===c||"null"===c||"Null"===c||"NULL"===c)return PutToDebugLog(2,"EVENT, GetTurnSrv4: NULL"),null;if(void 0===c||c.length<1||void 0===g||g.length<1||void 0===h||h.length<1?n=!(r.length<1):(r=c,l=u,s=g,p=h,n=!0),isNull(r)||"null"===r||"NULL"===r||isNull(s)||"null"===s||"NULL"===s||isNull(p)||"null"===p||"NULL"===p)return PutToDebugLog(2,"EVENT, GetTurnSrv2: NULL"),null;var m=!1;if(GetBrowserVersion()>40&&(m=!0),!1===n){var d=webphone_api.parameters.webrtcserveraddress;(isNull(d)||d.length<2)&&(d=GetWsAddressCfg(),(isNull(d)||d.length<2)&&(d=GetWp())),isNull(d)&&(d=""),d=d.toLowerCase();var b=GetConfig("mainaport");if(!0===IsMizuServerOrGateway()&&d.length>0){var _=d,f=d.indexOf("://");if(f>0&&(d=d.substring(f+3)),f=d.indexOf("/"),f>0&&(d=d.substring(0,f)),!isNull(b)&&b.length>0&&IsNumber(b)&&GetPortFromAddressSimple(d)!=b&&(d=GetIPEnclosed(GetIPFromAddressSimple(d))+":"+b),_.indexOf("wss:")>=0)if(AddressHasPort(d)){var w=GetPortFromAddressSimple(d);if(d=GetIPFromAddressSimple(d),"80"===w||"443"===w||"2443"===w){var v="turn:"+GetIPEnclosed(d)+":"+w+"?transport=tcp";e=!0===m?{urls:v,username:"mzturnusr",credential:"rnd87719318572"}:{url:v,username:"mzturnusr",credential:"rnd87719318572"}}else e=null;n=!0}else{var v="turn:"+GetIPEnclosed(d)+":80?transport=tcp";e=!0===m?{urls:v,username:"mzturnusr",credential:"rnd87719318572"}:{url:v,username:"mzturnusr",credential:"rnd87719318572"},n=!0}else{AddressHasPort(d)||(d=GetIPEnclosed(d)+":80");var v="turn:"+d+"?transport=tcp";e=!0===m?{urls:v,username:"mzturnusr",credential:"rnd87719318572"}:{url:v,username:"mzturnusr",credential:"rnd87719318572"},n=!0}}}else null==r?e=null:(r=Trim(r),0!==r.indexOf("turn:")&&(r="turn:"+r),r.indexOf(":")===r.lastIndexOf(":")&&(r+=":80"),isNull(l)&&(l=""),l.length>0&&0!==l.indexOf("?")&&(l="?"+l),e=!0===m?{urls:r+l,username:s,credential:p}:{url:r+l,username:s,credential:p},n=!0);if(!1===n&&(e=null),isNull(e))PutToDebugLog(2,"EVENT, def turn server: NULL");else{var E=JSON.stringify(e);E=E.substring(0,E.indexOf("credential")+10),E+='":"*****"}',PutToDebugLog(2,"EVENT, def turn server: "+E)}return e}catch(P){PutToDebugLogException(2,"common: GetTurnSrv",P)}return{}}function ParseStunTurnNew(){try{var e=GetParameter("stunserveraddress"),n=GetParameter("turnserveraddress");isNull(e)&&(e=""),e=ReplaceAll(e," ",""),e=ReplaceAll(e,'"',""),e=ReplaceAll(e,"'",""),isNull(n)&&(n=""),n=ReplaceAll(n," ",""),n=ReplaceAll(n,'"',""),n=ReplaceAll(n,"'",""),e=ReplaceAll(e,"{",""),e=ReplaceAll(e,"}",""),e=ReplaceAll(e,"[",""),e=ReplaceAll(e,"]",""),n=ReplaceAll(n,"{",""),n=ReplaceAll(n,"}",""),n=ReplaceAll(n,"[",""),n=ReplaceAll(n,"]","");var t=-1,o="";if(n.toLowerCase().indexOf("turn")>=0||n.toLowerCase().indexOf("transport")>=0?o=n:(e.toLowerCase().indexOf("turn")>=0||e.toLowerCase().indexOf("transport")>=0)&&(o=e),o.length>3){t=o.toLowerCase().indexOf("turn:"),t>=0&&(o=o.substring(t+5)),t=o.toLowerCase().indexOf("stun:"),t>=0&&(o=o.substring(0,t));var i="",a="",r="",l="";t=o.toLowerCase().indexOf("username:"),t>=0&&(a=o.substring(t+9),(t=a.indexOf(","))>0&&(a=a.substring(0,t))),t=o.toLowerCase().indexOf("credential:"),t>=0&&(r=o.substring(t+11),(t=r.indexOf(","))>0&&(r=r.substring(0,t))),t=o.toLowerCase().indexOf("?"),t>=0&&(l=o.substring(t+1),(t=l.indexOf(","))>0&&(l=l.substring(0,t))),isNull(a)&&(a=""),isNull(r)&&(r=""),isNull(l)&&(l=""),i=o.toLowerCase(),i=i.replace("username:"+a,""),i=i.replace("credential:"+r,""),i=i.replace("?"+l,""),i=ReplaceAll(i,",",""),t=i.indexOf("url:"),t>=0&&(i=i.substring(t+4)),t=i.indexOf("urls:"),t>=0&&(i=i.substring(t+5)),isNull(i)&&(i=""),i.length>0&&SaveParameter("turnserveraddress",i),l.length>0&&SaveParameter("turnparameters",l),a.length>0&&SaveParameter("turnusername",a),r.length>0&&SaveParameter("turnpassword",r)}var s="";if(s=n.toLowerCase().indexOf("stun:")>=0?n.toLowerCase():e.toLowerCase(),s.length>3){s=ReplaceAll(s,"url:",""),s=ReplaceAll(s,"urls:","");var p=s.indexOf("turn:");t=s.indexOf("stun:"),t>=0&&p>=0&&(s=t>p?s.substring(t):s.substring(t,p)),t=s.toLowerCase().indexOf("url:"),t>=0&&(s=s.substring(t+4)),t=s.toLowerCase().indexOf("urls:"),t>=0&&(s=s.substring(t+5)),t=s.toLowerCase().indexOf("stun:"),t>=0&&(s=s.substring(t+5)),t=s.toLowerCase().indexOf(","),t>=0&&(s=s.substring(0,t)),isNull(s)&&(s=""),s.length>0&&SaveParameter("stunserveraddress",s)}}catch(c){PutToDebugLogException(2,"common: ParseStunTurnNew",c)}return""}function GetDeviceId(){try{if(!isNull(cachedevid)&&cachedevid.length>1)return cachedevid;var e="",n=GetBrandName();isNull(n)&&(n=""),n=n.toLowerCase(),n=Trim(n);var t=GetDomainFromAddress(location.host);t=t.toLowerCase(),t=Trim(t),n=n+"_"+t;for(var o=n+"=",i=document.cookie.split(";"),a=0;a<i.length;a++){for(var r=i[a];" "===r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(o)){e=r.substring(o.length,r.length);break}}if(isNull(e)||Trim(e).length<1){e=Md5Hash(RandomInt(1e3,9999999)+"_"+GetTickCount()+"_"+n)}if(!isNull(e)&&Trim(e).length>1){var l=new Date;l.setTime(l.getTime()+31536e6);var s="; expires="+l.toGMTString();return document.cookie=n+"="+e+s+"; path=/;SameSite=Lax",cachedevid=e,e}}catch(p){PutToDebugLogException(2,"common: GetDeviceId",p)}return""}function LogAllParameters(e,n){if(CanLog(4)){try{if(isNull(e)&&(e="All parameters:"),isNull(n))return void PutToDebugLog(2,"ERROR, LogAllParameters params is NULL");var t=[];t.push("d"),t.push("e"),t.push("m"),t.push("o");var o=t.join("");t=[],t.push("s"),t.push("u"),t.push("p"),t.push("p"),t.push("o"),t.push("r"),t.push("t"),t.push("e"),t.push("n"),t.push("d");var i=t.join("");t=[],t.push("h"),t.push("a"),t.push("s");var a=t.join("");t=[],t.push("u"),t.push("s"),t.push("e");var r=t.join("");t=[],t.push("e"),t.push("n"),t.push("a"),t.push("b"),t.push("l"),t.push("e");var l=t.join("");for(var s in n)if("get"!==s&&"getAll"!==s)if("password"===s&&GetLogLevel()<5){var p=StrEc(n[s],webphone_api.global.ec_apikey,!0);e=e+"\r\nep="+p}else"needactivation"===s||"passphrase"===s||0===s.indexOf(o)||0===s.indexOf(i)||GetLogLevel()<6&&(0===s.indexOf(r)||0===s.indexOf(a)||0===s.indexOf(l))||(e=e+"\r\n"+s+"="+n[s]);PutToDebugLog(4,"EVENT, All parameters: "+e)}catch(c){PutToDebugLogException(2,"common: GetDeviceId",c)}return""}}function AutodetectDirectWebrtc(){try{if("true"===GetParameter("autodetectwebrtc_completed")||!1===CanIUseWebRTC())return;if("java"===getuseengine()||"ns"===getuseengine()||"java"===getuseengine()||IsMizuServerOrGateway()||GetWsAddressCfg().length>3)return void PutToDebugLog(2,"EVENT, AutodetectDirectWebrtc not needed "+getuseengine()+" "+GetWsAddressCfg());var e=GetUA();if(GetParameter("useragent").length>0&&!1===IsMizuReallyPublicWebRTCGateway()&&(e=GetParameter("useragent")),GetConfigInt("autodetectwebrtc",1)<1)return;var n=GetViaRandomAddress(),t="OPTIONS sip:domain.com SIP/2.0\r\nVia: SIP/2.0/WSS "+n+';branch=z9hG4bKZm6ekwKTdh4HVt5KZKbFAiPsa7HfefiL;rport\r\nFrom: "1234"<sip:1234@domain.com>;tag=ExB7vRKwE52lvEsR1WrC\r\nTo: "1234"<sip:1234@domain.com>\r\nContact: "1234"<sips:1234@'+n+";transport=wss>;expires=180\r\nCall-ID: 5ff2d63f-4939-2816-eeb8-6feca8245b92\r\nCSeq: 1522 REGISTER\r\nContent-Length: 0\r\nMax-Forwards: 70\r\nUser-Agent: "+e+"\r\nOrganization: DTC\r\nSupported: path\r\n",o=GetParameter("serveraddress");if((isNull(o)||o.length<2)&&(o=GetParameter("serveraddress_user")),isNull(o)||o.length<2)return void PutToDebugLog(2,"EVENT, AutodetectDirectWebrtc cannot find serveraddress");o=GetDomainFromAddress(o),PutToDebugLog(2,"EVENT, AutodetectDirectWebrtc base serveraddress: "+o),!0===BrowserRequiresHttps(!1)?(wsuri_1="wss://"+o+":443/ws",wsuri_2="wss://"+o+":8089/ws",wsuri_3="wss://"+o+":8088/ws",wsuri_4="wss://"+o+":80/ws",wsuri_5="wss://"+o+":8080/ws"):(wsuri_1="wss://"+o+":443/ws",wsuri_2="wss://"+o+":8089/ws",wsuri_3="ws://"+o+":8088/ws",wsuri_4="ws://"+o+":80/ws",wsuri_5="ws://"+o+":8080/ws",wsuri_6="wss://"+o+":8080/ws",wsuri_7="wss://"+o+":8088/ws",wsuri_8="wss://"+o+":80/ws",wsuri_9="ws://"+o+":443/ws"),wsuri_1.length>0&&(ws_1=new WebSocket(wsuri_1),ws_1.binaryType="arraybuffer",ws_1.onopen=function(e){ws_1.send(t)},ws_1.onmessage=function(e){var n=null;isNull(e)||(n=e.data),!isNull(n)&&n.indexOf("SIP/2.0")>=0&&(at_addr[at_addr.length]=wsuri_1)}),wsuri_2.length>0&&(ws_2=new WebSocket(wsuri_2),ws_2.binaryType="arraybuffer",ws_2.onopen=function(e){ws_2.send(t)},ws_2.onmessage=function(e){var n=null;isNull(e)||(n=e.data),!isNull(n)&&n.indexOf("SIP/2.0")>=0&&(at_addr[at_addr.length]=wsuri_2)}),wsuri_3.length>0&&(ws_3=new WebSocket(wsuri_3),ws_3.binaryType="arraybuffer",ws_3.onopen=function(e){ws_3.send(t)},ws_3.onmessage=function(e){var n=null;isNull(e)||(n=e.data),!isNull(n)&&n.indexOf("SIP/2.0")>=0&&(at_addr[at_addr.length]=wsuri_3)}),wsuri_4.length>0&&(ws_4=new WebSocket(wsuri_4),ws_4.binaryType="arraybuffer",ws_4.onopen=function(e){ws_4.send(t)},ws_4.onmessage=function(e){var n=null;isNull(e)||(n=e.data),!isNull(n)&&n.indexOf("SIP/2.0")>=0&&(at_addr[at_addr.length]=wsuri_4)}),wsuri_5.length>0&&(ws_5=new WebSocket(wsuri_5),ws_5.binaryType="arraybuffer",ws_5.onopen=function(e){ws_5.send(t)},ws_5.onmessage=function(e){var n=null;isNull(e)||(n=e.data),!isNull(n)&&n.indexOf("SIP/2.0")>=0&&(at_addr[at_addr.length]=wsuri_5)}),wsuri_6.length>0&&(ws_6=new WebSocket(wsuri_6),ws_6.binaryType="arraybuffer",ws_6.onopen=function(e){ws_6.send(t)},ws_6.onmessage=function(e){var n=null;isNull(e)||(n=e.data),!isNull(n)&&n.indexOf("SIP/2.0")>=0&&(at_addr[at_addr.length]=wsuri_6)}),wsuri_7.length>0&&(ws_7=new WebSocket(wsuri_7),ws_7.binaryType="arraybuffer",ws_7.onopen=function(e){ws_7.send(t)},ws_7.onmessage=function(e){var n=null;isNull(e)||(n=e.data),!isNull(n)&&n.indexOf("SIP/2.0")>=0&&(at_addr[at_addr.length]=wsuri_7)}),wsuri_8.length>0&&(ws_8=new WebSocket(wsuri_8),ws_8.binaryType="arraybuffer",ws_8.onopen=function(e){ws_8.send(t)},ws_8.onmessage=function(e){var n=null;isNull(e)||(n=e.data),!isNull(n)&&n.indexOf("SIP/2.0")>=0&&(at_addr[at_addr.length]=wsuri_8)}),wsuri_9.length>0&&(ws_9=new WebSocket(wsuri_9),ws_9.binaryType="arraybuffer",ws_9.onopen=function(e){ws_9.send(t)},ws_9.onmessage=function(e){var n=null;isNull(e)||(n=e.data),!isNull(n)&&n.indexOf("SIP/2.0")>=0&&(at_addr[at_addr.length]=wsuri_9)}),setTimeout(function(){if(SaveParameter("autodetectwebrtc_completed","true"),isNull(ws_1)||ws_1.close(),isNull(ws_2)||ws_2.close(),isNull(ws_3)||ws_3.close(),isNull(ws_4)||ws_4.close(),isNull(ws_5)||ws_5.close(),isNull(ws_6)||ws_6.close(),isNull(ws_7)||ws_7.close(),isNull(ws_8)||ws_8.close(),isNull(ws_9)||ws_9.close(),!isNull(at_addr)&&at_addr.length>0){for(var e="",n=0;n<at_addr.length;n++)isNull(at_addr[n])||at_addr[n].length<1||(PutToDebugLog(2,"EVENT, AutodetectDirectWebrtc list["+n+"] = "+at_addr[n]),e.length<1&&(e=at_addr[n]),at_addr[n].indexOf("wss:")>=0&&(e=at_addr[n]));!isNull(e)&&e.length>0&&(SaveParameter("webrtcserveraddress",e),PutToDebugLog(2,"EVENT, AutodetectDirectWebrtc best webrtcserveraddress: "+e))}else PutToDebugLog(2,"EVENT, AutodetectDirectWebrtc not found any valid server")},2500)}catch(i){PutToDebugLogException(2,"common: AutodetectDirectWebrtc",i)}}function GetMediaConstraints(e,n){try{if(isNull(e)&&(e=!1),isNull(n)&&(n=!1),!0===webphone_api.isscreensharecall){return{mandatory:{OfferToReceiveAudio:!1,OfferToReceiveVideo:!0}}}n&&!CanIUseVideo()?n=!1:n||"2"!==GetParameter2("video")||(n=!0);var t="",o="",i="";!0===e&&(o=GetParameter("sel_rtc_audio_out"),i=GetParameter("sel_rtc_audio_in"),!0===n&&(t=GetParameter("sel_rtc_video_in"))),!0===e&&!isNull(o)&&o.length>1&&webphone_api.webrtcapi.SetAudioDevice(1,o);var a=null;if(!0===e&&(!isNull(i)&&i.length>1||n&&!isNull(t)&&t.length>1)){var r=!1;if(!isNull(i)&&i.length>1){var l=webphone_api.webrtcapi.GetAudioVideoInputId(i,!1);!isNull(l)&&l.length>0&&(a={audio:{deviceId:{exact:l}}},r=!0)}if(r||(a={audio:!0}),r=!1,n&&!isNull(t)&&t.length>1){var s=webphone_api.webrtcapi.GetAudioVideoInputId(t,!0);!isNull(s)&&s.length>0&&(a.video={deviceId:{exact:s}},r=!0)}n&&!r?a.video=!0:n||!e||r||(a.video=!1)}else a=CanIUseVideo()&&("2"===GetParameter2("video")||n&&"0"!==GetParameter2("video"))?{OfferToReceiveAudio:!0,OfferToReceiveVideo:!0}:e?{OfferToReceiveAudio:!0,OfferToReceiveVideo:!1}:{OfferToReceiveAudio:!0};if(!0===e&&CanLog(2))try{var p=JSON.stringify(a);isNull(p)?PutToDebugLog(2,"ERROR,GetMediaConstraints is NULL"):PutToDebugLog(2,"EVENT,GetMediaConstraints audio_input: "+i+"; videoSource: "+t+"; gmc: "+p)}catch(c){PutToDebugLogException(2,"common: GetMediaConstraints inner",c)}return a}catch(c){PutToDebugLogException(2,"common: GetMediaConstraints",c)}return null}function GetScreenshareConstraints(){try{return{video:{cursor:"always"},audio:!1}}catch(e){PutToDebugLogException(2,"common: GetScreenshareConstraints",e)}return null}function StripServeraddress(e){try{if(isNull(e)||e.length<1)return"";e=Trim(e),e=e.toLowerCase(),0==e.indexOf("sip:")&&(e=e.replace("sip:","")),0==e.indexOf("sips:")&&(e=e.replace("sips:",""));var n=e.indexOf("@");n>0&&(e=e.substring(n+1)),e=Trim(e)}catch(t){PutToDebugLogException(2,"common: StripServeraddress",t)}return e}function StripUsername(e,n){try{if(isNull(e)||e.length<1)return"";if(e=Trim(e),0==e.indexOf("sip:")&&(e=e.replace("sip:","")),0==e.indexOf("SIP:")&&(e=e.replace("SIP","")),0==e.indexOf("Sip:")&&(e=e.replace("Sip:","")),0==e.indexOf("sips:")&&(e=e.replace("sips:","")),0==e.indexOf("SIPS:")&&(e=e.replace("SIPS","")),0==e.indexOf("Sips:")&&(e=e.replace("Sips:","")),!isNull(n)&&!0===n){var t=e.indexOf("@");t>0&&(e=e.substring(0,t))}return e=Trim(e)}catch(o){PutToDebugLogException(2,"common: StripServeraddress",o)}return e}function AddJscommport(e){try{if(isNull(e))return"";if(isNull(jscport)||jscport.length<1){var n="",t=window.location.href;if(isNull(t)||t.length<1)return e;t=decodeURIComponent(t),t=Trim(t);var o=t.indexOf("jscommport=");o>0&&(n=t.substring(o+11),o=n.indexOf("&"),o>0&&(n=n.substring(0,o)),o=n.indexOf("#page_"),o>0&&(n=n.substring(0,o)),o=n.indexOf("/"),o>0&&(n=n.substring(0,o)),n=Trim(n),!isNull(n)&&n.length>0&&IsNumber(n)&&(PutToDebugLog(2,"EVENT, AddJscommport jscommport found: "+n),jscport=n))}if(!isNull(jscport)&&jscport.length>0&&IsNumber(jscport))return PutToDebugLog(2,"EVENT, AddJscommport adding port: "+jscport),AddressHasPort(e)&&(e=GetIPFromAddressSimple(e)),GetIPEnclosed(e)+":"+jscport}catch(i){PutToDebugLogException(2,"common: AddJscommport",i)}return e}function SetPresenceIval(e){3==e?webphone_api.global.presenceinterval=244e4:2==e?webphone_api.global.presenceinterval=144e4:1==e?webphone_api.global.presenceinterval=72e4:0==e&&(webphone_api.global.presenceinterval=36e4)}function DecideUsUk(e){try{if(isNull(e)&&(e=-1),!0===webphone_api.global.pgw_decide_finished&&webphone_api.global.pgw_selected>=0)return void(CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw already finished as: "+webphone_api.global.pgw_selected.toString()));var n=GetWsAddressCfg(2);if(!isNull(n)&&n.length>3){var t=PGW_GetGwIndex(n);if(t>=0)return n=GetWsAddressCfg(2),webphone_api.global.waitingforusukdecide>0&&(webphone_api.global.waitingforusukdecide=-6),webphone_api.global.pgw_selected=t,webphone_api.global.pgw_decide_finished=!0,n.length>0&&SaveParameter("lastwebrtcserver",n),CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw select finished on cfg "+PGW_Get(t,PGW_ADDRESS)+" "+n),void OnDecideUsUkFinished(t)}var o=PGW_Get_Count();if(webphone_api.global.pgw_selected<0)if(e>=0&&PGW_Get(e,PGW_WSREC))webphone_api.global.pgw_selected=e;else for(var t=0;t<o;t++)if(PGW_Get(t,PGW_WSREC)){webphone_api.global.pgw_selected=t;break}var i=GetParameter("lastwebrtcserver"),a=GetParameter("topprioritywebrtcserver");!isNull(i)&&i.length>0&&PGW_GetGwIndex(i),!isNull(a)&&a.length>0&&PGW_GetGwIndex(a);for(var r=99999,l=-1,s=!1,p=!0,c="",u=0,t=0;t<o;t++)if(!1!==PGW_Get(t,PGW_WSREC)){p=!1,c="",u++;var g=PGW_Get(t,PGW_WSLOAD);(g<0||g>4)&&(g=3);var h=PGW_Get(t,PGW_WSTIME_DIFF);0!=h&&-1!=h||(h=PGW_Get(t,PGW_WSTIME_BGN)>0?GetTickCount()-PGW_Get(t,PGW_WSTIME_BGN):1400);var m=h;1==g?m+=20:2==g?m+=200:3==g?m+=800:4==g&&(m+=8e3),t==i&&(m-=20,c="islast"),t==a&&(m-=40,c+="istop"),CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw "+t.toString()+" "+PGW_Get(t,PGW_ADDRESS)+" load: "+g.toString()+" time_bgn: "+PGW_Get(t,PGW_WSTIME_BGN).toString()+" timediffreal: "+PGW_Get(t,PGW_WSTIME_DIFF_REAL).toString()+" timediff: "+PGW_Get(t,PGW_WSTIME_DIFF).toString()+" timediff: "+h.toString()+" delaycfg: "+PGW_Get(t,PGW_DELAY).toString()+" "+c+" score: "+m.toString()),m<r&&(r=m,l=t,g)}else!0===PGW_Get(t,PGW_TRY)&&!0!==PGW_Get(t,PGW_FAILED)&&(p=!1,s=!0);if(l>=0&&(webphone_api.global.pgw_selected=l),l>=0&&!s){webphone_api.global.waitingforusukdecide>0&&(webphone_api.global.waitingforusukdecide=-7),webphone_api.global.pgw_decide_finished=!0;var d=GetWsAddressCfg();return d.length>0&&SaveParameter("lastwebrtcserver",d),CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw select finished on completed "+PGW_Get(l,PGW_ADDRESS)+" "+d),void OnDecideUsUkFinished(l)}if(l>=0&&(m<170||u>=2&&m<220)){webphone_api.global.waitingforusukdecide>0&&(webphone_api.global.waitingforusukdecide=-8),webphone_api.global.pgw_decide_finished=!0;var d=GetWsAddressCfg();return d.length>0&&SaveParameter("lastwebrtcserver",d),CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw select finished on goodenough "+PGW_Get(l,PGW_ADDRESS)+" "+d),void OnDecideUsUkFinished(l)}if(p){webphone_api.global.waitingforusukdecide>0&&(webphone_api.global.waitingforusukdecide=-9),webphone_api.global.pgw_decide_finished=!0;var d=GetWsAddressCfg();return void(CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw select finished on allfailed "+PGW_Get(webphone_api.global.pgw_selected,PGW_ADDRESS)+" "+d))}CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw wait for other (tmp is: "+webphone_api.global.pgw_selected.toString()+")..."),setTimeout(function(){if(!webphone_api.global.pgw_decide_finished){
webphone_api.global.waitingforusukdecide>0&&(webphone_api.global.waitingforusukdecide=-11);var e=GetWsAddressCfg(null,null);e.length>0&&SaveParameter("lastwebrtcserver",e),CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw select finished on timeout "+webphone_api.global.pgw_selected.toString()+" "+e),webphone_api.global.pgw_decide_finished=!0,OnDecideUsUkFinished(l)}},1800)}catch(b){PutToDebugLogException(2,"common: decidegw",b)}}function GetSelectedGwIdx(){return webphone_api.global.pgw_selected<0?webphone_api.global.pgw_selected:PGW_Get(webphone_api.global.pgw_selected,PGW_WSLOAD)>=4?-1:webphone_api.global.pgw_selected}function OnDecideUsUkFinished(e){try{if((isNull(e)||e<0)&&(e=webphone_api.global.pgw_selected),e<0)return;var n=PGW_Get(e,PGW_WSLOAD);if(n>=0&&n<=7){SetPresenceIval(n),n<4&&(webphone_api.iswebrtcengineworking=1);var t=GetEngine("webrtc");isNull(t)||t.serversupport_cache==n||(t.serversupport_cache=n,SetEngine("webrtc",t)),webphone_api.global.recwsload!=n&&(webphone_api.global.recwsload=n,SaveParameter("lastrecwsload",n))}var o=PGW_Get(e,PGW_TYPE);if(o>=0&&(webphone_api.global.wsload_type=o),n>2)if(n>3){if(!1===webphone_api.global.usestorage&&!1===Strl(60)&&getuseengine()===webphone_api.global.ENGINE_WEBRTC&&!0===CanIUseService()){GetParameter("lastusedengine").length>0&&"ns"!=GetParameter("lastusedengine")&&SaveParameter("prevusedengine",GetParameter("lastusedengine")),SaveParameter("lastusedengine","ns"),webphone_api.flagrestartwebrtc=!1,ResetEngineClicked();var i=GetEngine("ns");i.clicked=2,SetEngine("ns",i),EngineSelect(1,6),PutToDebugLog(2,"WARNING, common wsload: offer ns engine because webrtc load is too highx: "+n.toString()),EngineForcedInstall("ns",webphone_api.stringres.get("serviceengine_msg"),function(){webphone_api.startInner()})}}else getuseengine()===webphone_api.global.ENGINE_WEBRTC?(SaveParameter("enablepresence","0"),PutToDebugLog(2,"EVENT, disable presence because wsload is highx: "+n.toString())):setTimeout(function(){getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(SaveParameter("enablepresence","0"),PutToDebugLog(2,"EVENT, disable presence because wsload is highx: "+n.toString()))},5e3)}catch(a){PutToDebugLogException(2,"common: OnDecideUsUkFinished",a)}}function getuseengine(){try{if(isNull(webphone_api.global.useengine)||webphone_api.global.useengine.length<1){if(!isNull(webphone_api.global.last_useengine)&&webphone_api.global.last_useengine.length>0)return webphone_api.global.last_useengine;isNull(webphone_api.global.maintimerid)||GetParameter("devicetype")===DEVICE_WIN_SOFTPHONE()||CanLog(2)&&PutToDebugLog(2,"EVENT, useengine is not set")}else webphone_api.global.last_useengine=webphone_api.global.useengine,webphone_api.global.last_last_useengine=webphone_api.global.useengine}catch(e){PutToDebugLogException(2,"common: GetUseengine",e)}return webphone_api.global.useengine}function DisplayPeerDetails(e){try{var n=GetParameter2("displaypeerdetails");(isNull(n)||n.length<1)&&(n="0"),IsNumber(n)?"0"===n&&!0===IsSDK()?isNull(document.getElementById("page_call_additional_info"))||(PutToDebugLog(4,"EVENT, DisplayPeerDetails Display additional call info: "+e),document.getElementById("page_call_additional_info").innerHTML=e):"1"===n&&AlertDialog("Peer details",e):isNull(document.getElementById(n))||(document.getElementById(n).innerHTML=e,document.getElementById(n).value=e)}catch(t){PutToDebugLogException(2,"common: DisplayPeerDetails",t)}}function Beep(e){try{(isNull(e)||e.length<1)&&(e="1");var n=document.getElementById("justbeep_"+e);isNull(n)||n.play()}catch(t){PutToDebugLogException(2,"common: Beep",t)}}function GetCodecsFromApiParam(){GetCodecsAudioFromApiParam(),GetCodecsVideoFromApiParam()}function GetCodecsAudioFromApiParam(){try{if(isNull(webphone_api.parameters.codec))return;var e=webphone_api.parameters.codec;if(e.length<1)return;e=e.toLowerCase();var n=e.split(",");if(isNull(n)||n.length<1)return;for(var t="",o=0;o<n.length;o++)if(!isNull(n[o])){if(n[o]=n[o].replace(".",""),n[o]=Trim(n[o]),"auto"===n[o]){t="-1";break}"g711"===n[o]||"g.711"===n[o]?(t.length>0&&(t+=","),t+="1,2"):"pcmu"===n[o]||"ulaw"===n[o]?(t.length>0&&(t+=","),t+="1"):"pcma"===n[o]||"alaw"===n[o]?(t.length>0&&(t+=","),t+="2"):"gsm"===n[o]?(t.length>0&&(t+=","),t+="3"):"ilbc"===n[o]?(t.length>0&&(t+=","),t+="4"):"speex"===n[o]||"speexnb"===n[o]||"speex-nb"===n[o]?(t.length>0&&(t+=","),t+="5"):"speex-wb"===n[o]||"speexwb"===n[o]?(t.length>0&&(t+=","),t+="6"):"g729"===n[o]||"g.729"===n[o]?(t.length>0&&(t+=","),t+="8"):"opusnb"===n[o]||"opus-nb"===n[o]?(t.length>0&&(t+=","),t+="10"):"opuswb"===n[o]||"opus"===n[o]||"opus-wb"===n[o]?(t.length>0&&(t+=","),t+="11"):"opusswb"===n[o]||"opus-swb"===n[o]?(t.length>0&&(t+=","),t+="12"):"opusuwb"===n[o]||"opus-uwb"===n[o]?(t.length>0&&(t+=","),t+="13"):"g.722"===n[o]||"g722"===n[o]?(t.length>0&&(t+=","),t+="14"):"isac"===n[o]&&(t.length>0&&(t+=","),t+="15")}t.length<1&&(t="-1"),SaveParameter("codec",t)}catch(i){PutToDebugLogException(2,"common: GetCodecsAudioFromApiParam",i)}}function GetCodecsVideoFromApiParam(){try{if(isNull(webphone_api.parameters.vcodec))return;var e=webphone_api.parameters.vcodec;if(e.length<1)return;e=e.toLowerCase();var n=e.split(",");if(isNull(n)||n.length<1)return;for(var t="",o=0;o<n.length;o++)if(!isNull(n[o])){if(n[o]=n[o].replace(".",""),n[o]=Trim(n[o]),"auto"===n[o]){t="-1";break}"h.264"===n[o]||"h264"===n[o]?(t.length>0&&(t+=","),t+="50"):"h.265"===n[o]||"h265"===n[o]?(t.length>0&&(t+=","),t+="51"):"vp8"===n[o]||"vp.8"===n[o]?(t.length>0&&(t+=","),t+="52"):"vp9"===n[o]||"vp.9"===n[o]?(t.length>0&&(t+=","),t+="53"):"vp10"===n[o]||"vp.10"===n[o]?(t.length>0&&(t+=","),t+="54"):"av1"!==n[o]&&"av.1"!==n[o]||(t.length>0&&(t+=","),t+="55")}t.length<1&&(t="-1"),SaveParameter("vcodec",t)}catch(i){PutToDebugLogException(2,"common: GetCodecsVideoAudioFromApiParam",i)}}function GetHttpAPIKey(){try{if(!isNull(apikey_cache))return apikey_cache;var e=GetConfig("serverapikey");if(!(isNull(e)||e.length<2))return apikey_cache=e,e;var n=GetConfigAll(!0);if(isNull(n))return"";for(var t in n)if(!isNull(n[t])&&(e=n[t],e=e.toString(),!(e.indexOf("mvapireq")<1||e.indexOf("authkey=")<1)&&(e=e.substring(e.indexOf("authkey=")+8),e.indexOf("&")>=0&&(e=e.substring(0,e.indexOf("&"))),isNull(e)&&(e=""),"key"!==e&&"KEY"!==e||(e=""),e=Trim(e),e.length>0)))return apikey_cache=e,e}catch(o){PutToDebugLogException(2,"common: GetHttpAPIKey",o)}return apikey_cache="",""}function InitUnregOnIdle(){function e(){PutToDebugLog(2,"EVENT, unregister on idle "+t.toString()),null!=o&&clearTimeout(o),webphone_api.unregister(),webphone_api.global.unregisteredfromidle=1}function n(){null!=o&&clearTimeout(o),o=setTimeout(e,1e3*t),1==webphone_api.global.unregisteredfromidle&&(PutToDebugLog(2,"EVENT, re-register after idle "+t.toString()),webphone_api.global.unregisteredfromidle=0,webphone_api.register())}try{var t=GetParameterInt("unregonidle",0);if(t<2)return;var o=null;window.addEventListener("load",n,!0),window.addEventListener("mousemove",n,!0),window.addEventListener("mousedown",n,!0),window.addEventListener("touchstart",n,!0),window.addEventListener("touchmove",n,!0),window.addEventListener("click",n,!0),window.addEventListener("keydown",n,!0),window.addEventListener("scroll",n,!0)}catch(i){PutToDebugLogException(2,"common: InitUnregOnIdle",i)}}function Wsunreg(){try{var e=GetTickCount();if(unregcalledtime>0&&e-unregcalledtime<1500)return void PutToDebugLog(3,"EVENT, Wsunreg NOT called twice");if(unregcalledtime=e,webphone_api.global.pgw_selected<0)return;if(!IsMizuServerOrGateway())return;if(!1===GetParameterBool("needunregister",!0))return;PutToDebugLog(2,"common: Wsunreg called: "+webphone_api.global.pgw_selected.toString());var n=GetConfig("wsunreg");if(isNull(n)||n.length<3){var t=GetWebrtcSrvAddr(),o=GetSipusername(!0),i=GetParameter("password");(isNull(t)||t.length<2)&&(t=GetWp()),t=t.toLowerCase(),t=NormalizeInput(t,0),t=t.replace("*","");var a=t.indexOf("/");a>0&&(t=t.substring(0,a));var r=PGW_Get(webphone_api.global.pgw_selected,PGW_APIKEY);if(r.length<1&&(r=GetDefAPIKey()),!IsMizuPublicWebRTCGateway()){var l=GetConfig("serverapikey");l.length>0&&(r=l)}if(t.indexOf("rtc.mizu-voip.com:2443")>=0&&(r="1568108399"),isNull(o)||o.length<1||isNull(i)||i.length<1)return void PutToDebugLog(2,"EVENT, common Wsunreg invalid username ("+o+") or invalid password ("+i+")");var s="http://";UseSecureSrvConnection()&&(s="https://"),n=s+t+"/mvapireq/?apientry=wsunreg&authkey="+r+"&authid="+o+"&authpwd="+i+"&sessionid="+GetSessionId()}else 0!==n.indexOf("http")&&(n="http://"+n),UseSecureSrvConnection()&&(n=n.replace("http:","https:"));IsMizuServerOrGateway()&&UriParser(n,"","","","","webrtcunregisteruser")}catch(p){PutToDebugLogException(2,"common: Wsunreg",p)}}function GetWsuserUrl(e,n,t,o){try{if(isNull(e)||e.length<1)return"";if(isNull(o)&&(o=!0),e.indexOf("@")>0&&(e=e.substring(0,e.indexOf("@")),e.length<1))return"";if(!1===UsernameStringIsValidForServer(e)){var i="ERROR, "+webphone_api.stringres.get("username_err")+": "+e;return ShowToast(i,5e3),PutToDebugLog(1,i),""}if(!isNull(n)&&n.length>0&&!1===PasswordStringIsValidForServer(n)){var i="ERROR, "+webphone_api.stringres.get("password_err")+": "+n;return ShowToast(i,5e3),PutToDebugLog(1,i),""}var a=GetWebrtcSrvAddr();if((isNull(a)||a.length<2)&&(a=GetWp(null,o)),a=a.toLowerCase(),a.indexOf("mfstwebsock")<0)return"";var r=GetConfig("brandid"),l=GetBrandName(),s=GetConfig("companyname"),p=GetParameter2("voicerecupload");isNull(p)&&(p=""),p.length<1&&(p=GetParameter2("voicerecftp_addr")),isNull(p)&&(p=""),p=Trim(p);var c=GetParameter("username"),u=GetParameter("displayname"),g=GetParameter("upperproxy");if(isNull(g)||Trim(g).length<1)g=GetProxyaddress();else if(!isNull(g)&&g.length>2&&!AddressHasPort(g)){var h=GetConfigInt("serverport",-1);h>0&&5060!==h&&(g=GetIPEnclosed(g)+":"+h.toString())}isNull(g)&&(g=""),g=Trim(g);var m=GetParameter2("inbounddtmf");isNull(m)&&(m=""),m=Trim(m);var d=GetParameter2("outbounddtmf");isNull(d)&&(d=""),d=Trim(d);var b=GetParameter("dtmfmode");isNull(b)&&(b="");var _=GetParameter("transport");isNull(_)&&(_=""),!0===voice_wasset&&p.length<1&&(p="null"),!0===proxy_wasset&&g.length<1&&(g="null"),p.length>0&&(voice_wasset=!0),g.length>0&&(proxy_wasset=!0),a=NormalizeInput(a,0),a=a.replace("*","");var f=a.indexOf("/");f>0&&(a=a.substring(0,f));var w=webphone_api.global.pgw_selected;w<0&&(o&&CanLog(5)&&PutToDebugLog(5,"EVENT, no selected gw at getwsuserurl. using the first/default"),w=0);var v=PGW_Get(w,PGW_APIKEY);if(v.length<1&&(o&&CanLog(5)&&PutToDebugLog(5,"WARNING, no authkey for gw "+w.toString()+" at getwsuserurl. using default"),v=GetDefAPIKey()),!IsMizuPublicWebRTCGateway()){var E=GetConfig("serverapikey");E.length>0&&(v=E)}a.indexOf("rtc.mizu-voip.com:2443")>=0&&(v="1568108399");var P=NeedRegister(),T=GetParameter("wsuser"),S=!1,N="1";getuseengine()===webphone_api.global.ENGINE_FLASH&&(N="2");var I="https://";!isNull(T)&&T.length>10&&(a=T,f=a.indexOf("://"),f>0&&(a=a.substring(f+3)),f=a.indexOf("?"),f>0&&(a=a.substring(0,f+1)),0==T.indexOf("http:")&&(I="http://"));var C=GetDomainFromAddress(a);if(C.length>3&&IsIPAddrress(C)&&!1===UseSecureSrvConnection()&&(I="http://"),(isNull(t)||t.length<1)&&(t=GetWebrtcUpperServer()),!isNull(T)&&T.length>10&&T.indexOf("?")>0&&T.indexOf("&")>0){a=T,f=a.indexOf("://"),f>0&&(a=a.substring(f+3)),f=a.indexOf("?"),a=a.substring(0,f+1),f=T.indexOf("?");var G=T.substring(f+1);G=G.toLowerCase();var L=G.split("&");if(!isNull(L)&&L.length>0){for(var R=0;R<L.length;R++)if(!(isNull(L[R])||L[R].indexOf("=")<2||0===L[R].indexOf("apientry=")||0===L[R].indexOf("authkey="))){var y=L[R].substring(0,L[R].indexOf("="));if("upperserver"!==y&&"upperserverdomain"!==y)if("transport"!==y)switch(y){case"authid":L[R]="authid="+e;break;case"username":L[R]="username="+e;break;case"authpwd":L[R]="authpwd="+n;break;case"brandid":L[R]="brandid="+r;break;case"brandname":L[R]="brandname="+encodeURIComponent(l);break;case"companyname":L[R]="companyname="+encodeURIComponent(s);break;case"needregister":L[R]="needregister="+P.toString();break;case"callerid":L[R]="callerid="+c;break;case"displayname":L[R]="displayname="+u;break;case"voicerecupload":L[R]="voicerecupload="+p;break;case"engine":L[R]="engine="+N;break;case"proxyaddress":L[R]="proxyaddress="+g}else{var D=L[R].substring(L[R].indexOf("=")+1),O=ParameterIsDefault("transport"),x=GetParameterInt("transport",-1),A="udp";1===x?A="tcp":2===x&&(A="tls"),x<0||(isNull(D)||D.length<1?O||(L[R]=y+"="+A):L[R]=y+"="+A)}else{var D=L[R].substring(L[R].indexOf("=")+1);isNull(D)||D.length<1?L[R]=y+"="+t:"true"===GetParameter("iswebrtcuppersrvfromuser")&&(L[R]=y+"="+t)}}G="";for(var R=0;R<L.length;R++)isNull(L[R])||L[R].indexOf("=")<2||(G.length>0&&(G+="&"),G+=L[R]);T=I+a+G,m.length>0&&(T=T+"&inbounddtmf="+m),d.length>0&&(T=T+"&outbounddtmf="+d)}T.indexOf("authid=")<0&&(T=T+"&authid="+e),T.indexOf("authpwd=")<0&&(T=T+"&authpwd="+n),T.indexOf("upperserver=")<0&&(T=T+"&upperserver="+t),T.indexOf("upperserverdomain=")<0&&(T=T+"&upperserverdomain="+t),T.indexOf("voicerecupload=")<0&&(T=T+"&voicerecupload="+p),T.indexOf("needregister=")<0&&(T=T+"&needregister="+P.toString()),T.indexOf("callerid=")<0&&(T=T+"&callerid="+c),T.indexOf("displayname=")<0&&(T=T+"&displayname="+u),T.indexOf("proxyaddress=")<0&&(T=T+"&proxyaddress="+g),T.indexOf("dtmfmode=")<0&&(T=T+"&dtmfmode="+b),T.indexOf("engine=")<0&&(T=T+"&engine="+N),_.length>0&&"-1"!=_&&T.indexOf("transport=")<0&&(T=T+"&transport="+_),S=!0}if(!1===S){var k="&authpwd="+n;!1===IsMizuWebRTCGatewayAndNotMizuServer()&&a.indexOf("rtc.mizu-voip.com:2443")<0&&(k="&authmd5=MD5VALUE&authsalt=MD5SALT"),T=I+a+"/mvapireq/?apientry=wsuser&authkey="+v+"&authid="+e+k+"&brandid="+r+"&brandname="+encodeURIComponent(l)+"&companyname="+encodeURIComponent(s)+"&upperserver="+t+"&needregister="+P.toString()+"&callerid="+c+"&displayname="+u+"&voicerecupload="+p+"&engine="+N+"&dtmfmode="+b+"&proxyaddress="+g+"&sessionid="+GetSessionId()+"&now=415",m.length>0&&(T=T+"&inbounddtmf="+m),d.length>0&&(T=T+"&outbounddtmf="+d)}if(T.indexOf("appversion=")<0&&(T=T+"&appversion="+webphone_api.global.versionstr),T.indexOf("transport=")<0&&!1===ParameterIsDefault("transport")){var x=GetParameterInt("transport",0),A="udp";1===x?A="tcp":2===x&&(A="tls"),T=T+"&transport="+A}if(!1===Glcr()&&(f=T.indexOf("voicerecupload"))>0){CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, sid init to 8871");var U=T.substring(0,f),V="";V=T.substring(f),f=V.indexOf("&"),V=f>0?V.substring(f+1):"",T=U+V}return T}catch(W){PutToDebugLogException(2,"common: GetWsuserUrl",W)}return""}function GetWsloadUrl(e){try{var n=GetWebrtcSrvAddr(),t=GetConfig("brandid"),o=GetBrandName(),i=GetConfig("companyname"),a="http://";if(UseSecureSrvConnection()&&(a="https://"),(isNull(n)||n.length<2)&&(n=GetWp()),n=n.toLowerCase(),n.indexOf("mfstwebsock")<0)return"";n=NormalizeInput(n,0),n=n.replace("*","");var r=n.indexOf("/");r>0&&(n=n.substring(0,r));var l="";if(webphone_api.global.pgw_selected>0&&(l=PGW_Get(webphone_api.global.pgw_selected,PGW_APIKEY),l.length<1&&CanLog(5)&&PutToDebugLog(5,"WARNING, no authkey for gw "+webphone_api.global.pgw_selected.toString()+" at getwsloadurl. using default")),l.length<1&&(l=GetDefAPIKey()),!IsMizuPublicWebRTCGateway()){var s=GetConfig("serverapikey");s.length>0&&(l=s)}n.indexOf("rtc.mizu-voip.com:2443")>=0&&(l="1568108399"),(isNull(e)||e.length<1)&&(e=GetSipusername(!0));var p=GetConfig("wsload"),c=!1;if(!isNull(p)&&p.length>10&&p.indexOf("?")>0&&p.indexOf("&")>0){n=p,r=n.indexOf("://"),r>0&&(n=n.substring(r+3)),r=n.indexOf("?"),n=n.substring(0,r+1);var u=p.substring(r+1);u=u.toLowerCase();var g=u.split("&");if(!isNull(g)&&g.length>0){for(var h=0;h<g.length;h++)if(!(isNull(g[h])||g[h].indexOf("=")<2||0===g[h].indexOf("apientry=")||0===g[h].indexOf("authkey="))){var m=g[h].substring(0,g[h].indexOf("="));switch(m){case"authid":g[h]="authid="+e;break;case"username":g[h]="username="+e;break;case"brandid":g[h]="brandid="+t;break;case"brandname":g[h]="brandname="+encodeURIComponent(o);break;case"companyname":g[h]="companyname="+encodeURIComponent(i);break;case"upperserver":g[h]="upperserver="+GetWebrtcUpperServer()}}u="";for(var h=0;h<g.length;h++)isNull(g[h])||g[h].indexOf("=")<2||(u.length>0&&(u+="&"),u+=g[h]);p=a+n+u}c=!0}else{var d=GetConfig("wsuser");if(!isNull(d)&&d.length>10){var b=d;if(r=b.indexOf("://"),r>0&&(b=b.substring(r+3)),r=b.indexOf("/"),r>0&&(b=b.substring(0,r)),r=b.indexOf("?"),r>0&&(b=b.substring(0,r)),b.length>0&&(PutToDebugLog(4,"EVENT, GetWsloadUrl guessed domain: "+b),n=b),(r=d.indexOf("authkey="))>0){var _=d.substring(r+8);r=_.indexOf("&"),r>0&&(_=_.substring(0,r)),!isNull(_)&&_.length>2&&(PutToDebugLog(4,"EVENT, GetWsloadUrl guessed apikey: "+_),l=_)}}}return!1===c&&(p=a+n+"/mvapireq/?authkey="+l+"&apientry=wsload&brandid="+t+"&brandname="+encodeURIComponent(o)+"&companyname="+encodeURIComponent(i)+"&upperserver="+GetWebrtcUpperServer()+"&authid="+e+"&now=415"),p}catch(f){PutToDebugLogException(2,"common: GetWsloadUrl",f)}return""}function HandleCalldivert(){try{if(!IsMizuServerOrGateway())return;var e=GetParameter("calldivertchecksum");isNull(e)&&(e="");if("1"===GetParameter("calldivertsuccess"))return;var n=GetParameter2("callforwardonbusy"),t=GetParameter2("callforwardonnoanswer"),o=GetParameter2("callforwardalways"),i=GetParameter2("callforwardonnoanswertimeout"),a=Md5Hash(n+t+o+i);if(e===a)return;PutToDebugLog(2,"EVENT, HandleCalldivert old checksum: "+e+" ; new checksum: "+a),(isNull(n)||n.length<1)&&(n="null"),(isNull(t)||t.length<1)&&(t="null"),(isNull(o)||o.length<1)&&(o="null"),SaveParameter("calldivertsuccess","0");var r=GetWebrtcSrvAddr(),l="http://";UseSecureSrvConnection()&&(l="https://"),(isNull(r)||r.length<2)&&(r=GetWp()),r=r.toLowerCase(),r=NormalizeInput(r,0),r=r.replace("*","");var s=r.indexOf("/");s>0&&(r=r.substring(0,s));var p=PGW_Get(webphone_api.global.pgw_selected,PGW_APIKEY);if(p.length<1&&(CanLog(5)&&PutToDebugLog(5,"EVENT, (warn) no authkey for gw "+webphone_api.global.pgw_selected.toString()+" at handlecalldivert. using default"),p=GetDefAPIKey()),!IsMizuPublicWebRTCGateway()){var c=GetConfig("serverapikey");c.length>0&&(p=c)}var u=GetConfig("wsload"),g=GetConfig("wsuser");if(!isNull(g)&&g.length>10){var h=g;if(s=h.indexOf("://"),s>0&&(h=h.substring(s+3)),s=h.indexOf("/"),s>0&&(h=h.substring(0,s)),s=h.indexOf("?"),s>0&&(h=h.substring(0,s)),h.length>0&&(PutToDebugLog(4,"EVENT, GetCalldivertUrl guessed domain: "+h),r=h),(s=g.indexOf("authkey="))>0){var m=g.substring(s+8);s=m.indexOf("&"),s>0&&(m=m.substring(0,s)),!isNull(m)&&m.length>0&&(PutToDebugLog(4,"EVENT, GetCalldivertUrl guessed apikey: "+m),p=m)}}u=l+r+"/mvapireq/?authkey="+p+"&authid="+GetSipusername(!0)+"&authpwd="+GetParameter("password")+"&apientry=calldivert&callforwardonbusy="+n+"&callforwardonnoanswer="+t+"&callforwardalways="+o+"&callforwardonnoanswertimeout="+i+"&now=415",UriParser(u,"","","","","calldivertapi")}catch(d){PutToDebugLogException(2,"common: HandleCalldivert",d)}}function SetVoiceMailNumber(e){try{var n="";webphone_api.getsipheader("Server",function(e){!isNull(e)&&e.length>0&&(n=e),webphone_api.getsipheader("User-Agent",function(e){!isNull(e)&&e.length>0&&(hua=e),hua.indexOf("Asterisk")>=0||hua.indexOf("FPBX")>=0||hua.indexOf("FreePBX")>=0||hua.indexOf("FreeSWITCH")>=0||hua.indexOf("Asterisk")>=0||n.indexOf("FPBX")>=0||n.indexOf("FreePBX")>=0||n.indexOf("FreeSWITCH"),SetVoiceMailNumberDelayed(null,"*97")})})}catch(t){PutToDebugLogException(2,"common: HandleCalldivert",t)}}function SetVoiceMailNumberDelayed(e,n){try{var t=GetDeviceWidth();t=!isNull(t)&&IsNumber(t)&&t>100?Math.floor(t/1.2):220,t>400?t=400:t<120&&(t=120),void 0!==n&&null!==n||(n=""),n=Trim(n);var o='<div data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+t+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("voicemail_title")+'</h1></div><div role="main" class="ui-content adialog_content"><span>'+webphone_api.stringres.get("voicemail_msg")+'</span><input type="text" id="voicemail_input" name="setting_item" data-theme="a" autocapitalize="off" value="'+n+'"/></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_ok")+'</a><a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_cancel")+"</a></div></div>";webphone_api.$.mobile.activePage.append(o).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#adialog_positive").off("click"),webphone_api.$("#adialog_negative").off("click")}});var i=document.getElementById("voicemail_input");isNull(i)||i.focus(),webphone_api.$("#adialog_positive").on("click",function(n){PutToDebugLog(5,"EVENT, common SetVoiceMailNumber OK click");var t="";isNull(i)||(t=i.value),!isNull(t)&&t.length>0&&(t=Trim(t),SaveParameter("voicemailnum",t)),e&&"function"==typeof e&&e(t)}),webphone_api.$("#adialog_negative").on("click",function(e){})}catch(a){PutToDebugLogException(2,"common: SetVoiceMailNumber",a)}}function CreateConferenceRoom(e,n){var t="";try{webphone_api.global.lastcontarget=n;var o=GetConfigAll(!0);if(!isNull(o)&&t.length<1)for(var i in o){var a=o[i];if(!isNull(a)&&a.toString().indexOf("/mvapireq/?apientry=")>0){var r=a.toString();r.indexOf("authkey=")>0&&(r=r.substring(r.indexOf("authkey=")),r.indexOf("&")>0&&(r=r.substring(0,r.indexOf("&")))),t=a.toString(),t=t.substring(0,t.indexOf("?")+1),t=t+r+"&authid=USERNAME&authmd5=MD5VALUE&authsalt=MD5SALT&target="+n+"&apientry=getconfroom";break}}if(t.length<1){var l=GetConfig("mainaport");l=!isNull(l)&&l.length>0?":"+l:"";var s=GetParameter("serveraddress");if((isNull(s)||s.length<1)&&(s=GetParameter("serveraddress_user")),!isNull(s)&&s.length>0){var p="";if(GetWebrtcSrvAddr().indexOf("rtc.mizu-voip.com:2443")>=0&&(p="1568108399"),isNull(p)||p.length<1){var p=PGW_Get(webphone_api.global.pgw_selected,PGW_APIKEY);p.length<1&&(CanLog(5)&&PutToDebugLog(5,"EVENT, (warn) no authkey for gw "+webphone_api.global.pgw_selected.toString()+" at createconf. using default"),p=GetDefAPIKey()),s=GetDomainFromURL(GetWsuserUrl(GetSipusername(!0),GetParameter("password")))}var c="http://";!0===UseSecureSrvConnection()&&(c="https://"),t=c+GetIPEnclosed(s)+l+"/mvapireq/?authkey="+p+"&authid=USERNAME&authmd5=MD5VALUE&authsalt=MD5SALT&target="+n+"&apientry=getconfroom"}}if(t.length>0){if(!0!==e)return t;!isNull(webphone_api.global.lastconfroom)&&webphone_api.global.lastconfroom.length>2?(PutToDebugLog(3,"EVENT, CreateConferenceRoom returning cached conference room: "+webphone_api.global.lastconfroom),ConferenceRoomReceived(webphone_api.global.lastconfroom)):UriParser(t,"","","","","getconferenceroom")}else PutToDebugLog(1,"ERROR, Cannot create conference room"),PutToDebugLog(2,"ERROR, CreateConferenceRoom invalid uri: "+t)}catch(u){PutToDebugLogException(2,"common: CreateConferenceRoom",u)}return""}function ConferenceRoomReceived(e){try{if(isNull(e))return PutToDebugLog(1,"ERROR, Ivalid conference room"),void PutToDebugLog(2,"ERROR, Ivalid conference room: "+e);var n=e.toLowerCase().indexOf("error:");if(n>=0){return void PutToDebugLog(1,"ERROR, "+e.substring(n+6))}if(e=e.toLowerCase(),n=e.indexOf("ok:"),e.indexOf("error:")>0)e.indexOf("higlhoad")>0&&(webphone_api.global.lastconftargetstate=5);else if(n>=0){webphone_api.global.lastconfroom=e;var t=e.substring(n+3);n=t.indexOf(":"),n>=0&&(t=t.substring(n+1)),t.indexOf(" usr: notexists")>0?webphone_api.global.lastconftargetstate=1:t.indexOf(" usr: registered")>0?webphone_api.global.lastconftargetstate=4:t.indexOf(" usr: push")>0?webphone_api.global.lastconftargetstate=3:t.indexOf(" usr: exists")>0?webphone_api.global.lastconftargetstate=2:webphone_api.global.lastconftargetstate=0,n=t.indexOf(" usr: "),n>0&&(t=t.substring(0,n)),t=Trim(t),PutToDebugLog(2,"EVENT, Received conference room: "+t),webphone_api.global.confanswer_received=!0;var o=GetParameter("received_confrooms");isNull(o)&&(o="");for(var i=o.split(","),a=!1,r=0;r<i.length;r++)if(i[r]===t){a=!0;break}if(i.length>10)for(;i.length>10;)i.shift();!1===a&&i.push(t),o="";for(var r=0;r<i.length;r++)isNull(i[r])||(o.length>0&&(o+=","),o+=i[r]);SaveParameter("received_confrooms",o),currconfroom=t;var l=!1;if(!1===IsSDK()&&!0===webphone_api.global.isDialpadStarted&&(InitiateConference(""),l=!0),!l&&webphone_api.global.confcanfailover&&(3==webphone_api.global.lastconftargetstate||4==webphone_api.global.lastconftargetstate)&&webphone_api.global.lastcontarget.length>0&&(PutToDebugLog(2,"EVENT, Conference failover to DTMF: "+webphone_api.global.lastcontarget),webphone_api.dtmf("*1*"+webphone_api.global.lastcontarget+"#"),l=!0),!l){var s=GetParameterInt("conferencerooms",-1),p=GetParameterInt("conferencetype",-1);p<0&&(p=1==s?5:2==s?6:3==s?7:1);var c="",u=!1,g=10,h=20,m=GetNrOfActiveCalls();if(m>0){if(h=1300,c=GetPeerUsername(),(1==p||5==p)&&c.length>0){g=1200,h=2600;var d=t,b=GetSipHeaderInternal("X-UT",!0);isNull(b)&&(b=""),b=Trim(b),d.indexOf("@")<0&&("g"===b||"b"===b)&&GetWebRTCServerSIPAddress().length>0&&(d=d+"@"+GetWebRTCServerSIPAddress()),PutToDebugLog(2,"EVENT, ConferenceRoom transfer call ("+c+") to conf room number: "+t+" (servertype: "+b+", srv: "+GetWebRTCServerSIPAddress()+", final: "+d+")");var _=GetCallSession(17,!1,webphone_api.global.aline,c);_&&0!=_.transfer(d)&&(u=!0)}setTimeout(function(){PutToDebugLog(2,"EVENT, ConferenceRoom hangup active call ("+c+") and call conf room number: "+t),webphone_api.hangup(!0)},g)}setTimeout(function(){PutToDebugLog(2,"EVENT, ConferenceRoom call room number: "+t),webphone_api.call(t),!isNull(webphone_api.global.waiting_conf_numbers)&&webphone_api.global.waiting_conf_numbers.length>0&&setTimeout(function(){if(!isNull(webphone_api.global.waiting_conf_numbers)&&webphone_api.global.waiting_conf_numbers.length>0){PutToDebugLog(2,"EVENT, ConferenceRoom invite others: "+webphone_api.global.waiting_conf_numbers);var e=webphone_api.global.waiting_conf_numbers.split(",");if(!isNull(e)&&e.length>0)for(var n=0;n<e.length;n++)isNull(e[n])||Trim(e[n]).length<1||(c.length>0&&c==e[n]?u||(SendConferenceInvites(e[n],t),u=!0):SendConferenceInvites(e[n],t));c.length>0&&!u&&SendConferenceInvites(c,t)}},500)},h)}}else PutToDebugLog(1,"ERROR, No conference room received: "+e)}catch(f){PutToDebugLogException(2,"common: ConferenceRoomReceived",f)}}function InitiateConference(e){try{!isNull(e)&&e.length>0&&(conf_ct.length>0&&(conf_ct+=","),conf_ct+=e);var n=GetDeviceWidth();n=!isNull(n)&&IsNumber(n)&&n>100?Math.floor(n/1.2):220,n>400?n=400:n<120&&(n=120);var t=webphone_api.stringres.get("confroom_msg1")+": "+currconfroom+"<br /><br />"+webphone_api.stringres.get("confroom_msg2")+":",o='<div id="conferenceroom_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+n+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("menu_confrooms")+'</h1></div><div role="main" class="ui-content adialog_content adialog_btn_nexttoinput"><span>'+t+'</span><div style="clear: both;">\x3c!--//--\x3e</div><input type="text" id="conferenceroom_input" name="setting_item" data-theme="a" autocapitalize="off"/><button id="btn_pickct" class="btn_nexttoinput ui-btn ui-btn-corner-all ui-btn-b noshadow"><img src="'+GetElementSource()+'images/btn_add_contact_txt.png"></button></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_ok")+'</a><a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_cancel")+"</a></div></div>";webphone_api.$.mobile.activePage.append(o).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#adialog_positive").off("click"),webphone_api.$("#adialog_negative").off("click"),webphone_api.$("#btn_pickct").off("click")}});var i=document.getElementById("conferenceroom_input");!isNull(conf_ct)&&conf_ct.length>1&&(i.value=Trim(conf_ct)),isNull(i)||i.focus(),setTimeout(function(){isNull(i)||i.focus()},150),webphone_api.$("#adialog_positive").on("click",function(e){PutToDebugLog(5,"EVENT, call Conferenceroom ok onclick");var n=Trim(i.value);webphone_api.$("#conferenceroom_popup").on("popupafterclose",function(e){(isNull(n)||n.length<1)&&(n=CanAcceptEmptyNumber()),!isNull(n)&&n.length>0?(conf_ct="",SendConferenceInvites(n,currconfroom),7!==GetParameterInt("conferencetype",1)&&(PutToDebugLog(2,"EVENT, mlogic API_Call InitiateConference"),webphone_api.call(currconfroom))):(ShowToast(webphone_api.stringres.get("err_msg_4")),webphone_api.$.mobile.back())})}),webphone_api.$("#adialog_negative").on("click",function(e){}),webphone_api.$("#btn_pickct").on("click",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),webphone_api.$("#conferenceroom_popup").on("popupafterclose",function(e){webphone_api.$("#conferenceroom_popup").off("popupafterclose"),PickContact(InitiateConference)})})}catch(a){PutToDebugLogException(2,"common: InitiateConference",a)}}function GetWebRTCServerSIPAddress(){try{var e=GetParameter2("webrtcgwsipaddress");if(!isNull(e)&&e.length>2)return e;if(!0===webphone_api.global.pgw_decide_finished&&webphone_api.global.pgw_selected>=0){var n=PGW_Get(webphone_api.global.pgw_selected,PGW_ADDRESS);if(n.length>0){var t=PGW_Get(webphone_api.global.pgw_selected,PGW_SIPPORT);return t.length>0&&5060!=t&&(n=n+":"+t.toString()),n}}var o=GetParameter2("serveraddress_user");if((isNull(o)||o.length<2)&&(o=GetParameter2("serveraddress")),isNull(o)||o.length<2)return"";var i=GetWebrtcSrvAddr();if(isNull(i)||i.length<2)return"";var a=i.indexOf("//");a>0&&(i=i.substr(a+2));var a=i.indexOf("/");if(a>0&&(i=i.substr(0,a)),isNull(i)||i.length<2)return"";if(o.indexOf(i)>=0)return o}catch(r){PutToDebugLogException(2,"common: GetWebRTCServerSIPAddress",r)}return""}function SendConferenceInvites(e,n){try{var t=GetParameterInt("conferencerooms",-1),o=GetParameterInt("conferencetype",-1);o<0&&(o=1==t?5:2==t?6:3==t?7:1);var i=GetSipHeaderInternal("X-UT",!0);isNull(i)&&(i=""),i=Trim(i),n.indexOf("@")<0&&("g"===i||"b"===i)&&GetWebRTCServerSIPAddress().length>0&&(n=n+"@"+GetWebRTCServerSIPAddress()),PutToDebugLog(5,"EVENT, set conf invite. to: "+e+", room: "+n+", typecfg: "+o.toString()+", roomscfg: "+t.toString()+", servertype: "+i+", srv: "+GetWebRTCServerSIPAddress()+", final: "+n);var a="[DONT_START_CHAT_WINDOW][CONFERENCE] You are invited to conference by: "+GetSipusername(!0)+". Call this number to join the conference: "+n,r=e.split(",");if(isNull(r)||r.length<1)return;for(var l=0;l<r.length;)isNull(r[l])||r[l].length<1?r.splice(l,1):l++;var s=Trim(r[0])
;o<6?(PutToDebugLog(2,"EVENT, mlogic API_SendCaht SendConferenceInvites"),webphone_api.sendchat(s,a)):6===o?(PutToDebugLog(2,"EVENT, mlogic API_SendChat SendConferenceInvites 2"),webphone_api.sendchat(s,a)):7===o&&function(){function e(){isNull(cftimer)||clearInterval(cftimer),cftimer=null}try{if(null===cftimer){var t=0,o=0;cftimer=setInterval(function(){if(++cfmaxloop>90)return void e();t<1?(t=1,!0===webphone_api.isincall()&&(PutToDebugLog(2,"EVENT, ConfRoom: hangup active call"),PutToDebugLog(2,"EVENT, mlogic API_Hangup HanleConfTransfer"),webphone_api.hangup(!0))):cfmaxloop>2&&1===t?(PutToDebugLog(2,"EVENT, ConfRoom: call destination: "+s),PutToDebugLog(2,"EVENT, mlogic API_Call HanleConfTransfer: "+s),webphone_api.call(s),t=2):2===t?!0===webphone_api.global.checkIfCallActive&&(PutToDebugLog(2,"EVENT, ConfRoom: destination accepted the call"),t=3,cfmaxloop>40&&(cfmaxloop=10)):3===t?(PutToDebugLog(2,"EVENT, ConfRoom: transfer call: "+n),PutToDebugLog(2,"EVENT, mlogic API_Transfer HanleConfTransfer: "+n),webphone_api.transfer(n),t=5,o=cfmaxloop+5):5===t&&o<cfmaxloop&&(PutToDebugLog(2,"EVENT, ConfRoom: call conf room: "+n),PutToDebugLog(2,"EVENT, mlogic API_Call HanleConfTransfer 2: "+n),webphone_api.call(n),e())},330)}}catch(i){PutToDebugLogException(2,"common: HanleConfTransfer",i)}}()}catch(p){PutToDebugLogException(2,"common: SendConferenceInvites",p)}}function ReceivedConferenceInvite(e,n){try{var t=GetDeviceWidth();t=!isNull(t)&&IsNumber(t)&&t>100?Math.floor(t/1.2):220;var o=n.lastIndexOf(":");o>0&&(n=n.substring(o+1));var i=Trim(n);n=webphone_api.stringres.get("confroom_inv_msg")+": "+e;var a='<div id="conferenceinvite_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+t+'px;"><div data-role="header" data-theme="b"><h1 class="adialog_title">'+webphone_api.stringres.get("confroom_inv_title")+'</h1></div><div role="main" class="ui-content adialog_content"><span>'+n+'</span></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_accept")+'</a><a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_reject")+"</a></div></div>";Beep("1"),webphone_api.$.mobile.activePage.append(a).trigger("create"),webphone_api.$.mobile.activePage.find(".messagePopup").bind({popupbeforeposition:function(){webphone_api.$(".ui-popup-screen").off(),webphone_api.$(this).unbind("popupbeforeposition")}}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#adialog_positive").off("click"),webphone_api.$("#adialog_negative").off("click")}}),PutToDebugLog(2,"EVENT, mlogic API_SendChat ReceivedConferenceInvite"),webphone_api.sendchat(e,"[DONT_START_CHAT_WINDOW][CONFERENCE_ANSWER]"),webphone_api.$("#adialog_positive").on("click",function(e){PutToDebugLog(5,"EVENT, ReceivedConferenceInvite ok onclick"),webphone_api.$("#conferenceinvite_popup").on("popupafterclose",function(e){webphone_api.global.isconfcall=!0,PutToDebugLog(2,"EVENT, mlogic API_Call ReceivedConferenceInvite: "+i),webphone_api.call(i)})}),webphone_api.$("#adialog_negative").on("click",function(e){})}catch(r){PutToDebugLogException(2,"common: ReceivedConferenceInvite",r)}}function IsServiceUpToDate(){try{if(webphone_api.global.nsupdatepending)return;var e=GetParameterInt("autosrvupgrade",1),n=GetParameterInt("nsupgrademode",1);if((e<1||!0===serviceupdatechecked||0===n||-1===n)&&n<2)return;WinAPI("extcmd_version",function(t){if(isNull(t)||t.indexOf("ERROR:")>=0)return void PutToDebugLog(2,"ERROR, IsServiceUpToDate: "+t);var o=GetMinServiceVersion(),i=0,a=t,r=a.indexOf("version:");if(r>0&&(a=a.substring(r+8)),r=a.indexOf("eov"),r>0&&(a=a.substring(0,r)),a=Trim(a),!isNull(a)&&IsNumber(a))(i=StrToInt(a))>0&&SaveParameter("srvupgrade_currversion",i);else if(PutToDebugLog(2,"ERROR, IsServiceUpToDate, received data is ivalid: "+a),n<2)return;var l=GetConfig("confighash");isNull(l)&&(l="");var s="";WinAPI("API_GetConfigHash",function(t){if(isNull(t)&&(t=""),s=Trim(t),serviceupdatechecked=!0,o>i||32===l.length&&32===s.length&&l!==s){var a=!0;if(1===e){var r=GetParameterInt("srvupgrade_count",0);r<3?(a=!1,PutToDebugLog(2,"EVENT, native service upgrade skipped because count: "+r.toString()),r++):r=0,SaveParameter("srvupgrade_count",r)}var p=GetParameter("srvupgrade_version"),c=i.toString()+"_"+o.toString();p===c&&(a=!1),2===n&&(a=!0),PutToDebugLog(2,"EVENT, native service upgrade sv: "+p+" : "+c),!0===a&&(SaveParameter("srvupgrade_version",c),EngineForcedInstall("ns",webphone_api.stringres.get("service_update")),webphone_api.global.nsupdatepending=!0)}})})}catch(t){PutToDebugLogException(2,"common: IsServiceUpToDate",t)}}function GetMinServiceVersion(){try{var e=webphone_api.global.minimumserviceversion,n=webphone_api.parameters.minserviceversion;return!isNull(n)&&IsNumber(n)&&(e=StrToInt(n)),n=GetConfig("minserviceversion"),!isNull(n)&&IsNumber(n)&&StrToInt(n)>e&&(e=StrToInt(n)),e}catch(t){PutToDebugLogException(2,"common: GetMinServiceVersion",t)}return 0}function GetAudioBandwidth(){try{var e=64,n=GetParameter2("audio_bandwidth");if(!isNull(n)&&IsNumber(n)){var t=StrToInt(n);t>=0&&t<2049&&(e=t)}return e}catch(o){PutToDebugLogException(2,"common: GetAudioBandwidth",o)}return 0}function GetVideoBandwidth(){try{var e=256,n=GetParameter2("video_bandwidth");if(!isNull(n)&&IsNumber(n)){var t=StrToInt(n);t>=0&&t<4e3&&(e=t)}return e}catch(o){PutToDebugLogException(2,"common: GetVideoBandwidth",o)}return 0}function GetVideoWidth(){try{var e=320,n=GetParameter2("video_width");if(!isNull(n)&&IsNumber(n)){var t=StrToInt(n);t>0&&t<4e3&&(e=t)}return e}catch(o){PutToDebugLogException(2,"common: GetVideoWidth",o)}return 0}function GetVideoHeight(){try{var e=240,n=GetParameter2("video_height");if(!isNull(n)&&IsNumber(n)){var t=StrToInt(n);t>0&&t<4e3&&(e=t)}return e}catch(o){PutToDebugLogException(2,"common: GetVideoHeight",o)}return 0}function EngineSwitchConference(e,n,t,o){try{SaveParameter("conf_engineswitcheoffered","true"),PutToDebugLog(2,"EVENT, EngineSwitchConference called");var i=GetDeviceWidth();i=!isNull(i)&&IsNumber(i)&&i>100?Math.floor(i/1.2):220;var a="Conferencing is not available for WebRTC. If this functionality is important for you, we recommend to use "+GetEngineDisplayName(e)+" engine.<br /><br />Would you like to switch to "+GetEngineDisplayName(e)+" engine ?",r='<div data-role="popup" id="conf_switch_popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+i+'px;"><div data-role="header" data-theme="b"><h1 class="adialog_title">'+webphone_api.stringres.get("switch_engine")+'</h1></div><div role="main" class="ui-content adialog_content adialog_alert"><span> '+a+' </span></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_ok")+'</a><a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_cancel")+"</a></div></div>";o=o||function(){},webphone_api.$.mobile.activePage.append(r).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").bind({popupbeforeposition:function(){webphone_api.$(".ui-popup-screen").off(),webphone_api.$(this).unbind("popupbeforeposition");var e=Math.floor(.6*GetDeviceHeight());webphone_api.$(this).height()>e+100&&webphone_api.$(".messagePopup .ui-content").height(e)}}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),o()}}),webphone_api.$("#adialog_negative").on("click",function(e){PutToDebugLog(5,"EVENT, EngineSwitchConference cancel click"),t(n)}),webphone_api.$("#adialog_positive").on("click",function(n){PutToDebugLog(5,"EVENT, EngineSwitchConference ok click, engine: "+e),webphone_api.$("#conf_switch_popup").on("popupafterclose",function(n){if(PutToDebugLog(2,"EVENT, EngineSwitchConference hangup active call"),!0===webphone_api.isincall()&&(PutToDebugLog(2,"EVENT, mlogic API_Hangup EngineSwitchConference"),webphone_api.hangup(!0)),"java"===e){webphone_api.flagrestartwebrtc=!1,ResetEngineClicked(),ResetSelEngine();var t=GetEngine("java");t.clicked=2,SetEngine("java",t),OpenSettings(!0,6),setTimeout(function(){InstallJavaPopup(!1)},400)}else{GetParameter("lastusedengine").length>0&&"ns"!=GetParameter("lastusedengine")&&SaveParameter("prevusedengine",GetParameter("lastusedengine")),SaveParameter("lastusedengine","ns"),webphone_api.flagrestartwebrtc=!1,ResetEngineClicked(),ResetSelEngine();var t=GetEngine("ns");t.clicked=2,SetEngine("ns",t),EngineSelect(1,24),EngineForcedInstall("ns","",function(){webphone_api.startInner()})}})})}catch(l){PutToDebugLogException(2,"common: EngineSwitchConference",l)}}function EngineSwitchTransfer(e,n,t,o){try{SaveParameter("transf_engineswitcheoffered","true"),PutToDebugLog(2,"EVENT, EngineSwitchTransfer called");var i=GetDeviceWidth();i=!isNull(i)&&IsNumber(i)&&i>100?Math.floor(i/1.2):220;var a="Transfer with WebRTC works only between WebRTC endpoints. If this functionality is important for you, we recommend to use "+GetEngineDisplayName(e)+" engine.<br /><br />Would you like to switch to "+GetEngineDisplayName(e)+" engine ?",r='<div data-role="popup" id="transf_switch_popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+i+'px;"><div data-role="header" data-theme="b"><h1 class="adialog_title">'+webphone_api.stringres.get("switch_engine")+'</h1></div><div role="main" class="ui-content adialog_content adialog_alert"><span> '+a+' </span></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_ok")+'</a><a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_cancel")+"</a></div></div>";o=o||function(){},webphone_api.$.mobile.activePage.append(r).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").bind({popupbeforeposition:function(){webphone_api.$(".ui-popup-screen").off(),webphone_api.$(this).unbind("popupbeforeposition");var e=Math.floor(.6*GetDeviceHeight());webphone_api.$(this).height()>e+100&&webphone_api.$(".messagePopup .ui-content").height(e)}}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),o()}}),webphone_api.$("#adialog_negative").on("click",function(e){PutToDebugLog(5,"EVENT, EngineSwitchTransfer cancel click"),t(n)}),webphone_api.$("#adialog_positive").on("click",function(n){PutToDebugLog(5,"EVENT, EngineSwitchTransfer ok click, engie: "+e),webphone_api.$("#transf_switch_popup").on("popupafterclose",function(n){if(PutToDebugLog(2,"EVENT, EngineSwitchTransfer hangup active call"),!0===webphone_api.isincall()&&(PutToDebugLog(2,"EVENT, mlogic API_Hangup EngineSwitchTransfer"),webphone_api.hangup(!0)),"java"===e){webphone_api.flagrestartwebrtc=!1,ResetEngineClicked(),ResetSelEngine();var t=GetEngine("java");t.clicked=2,SetEngine("java",t),OpenSettings(!0,7),setTimeout(function(){InstallJavaPopup(!1)},400)}else{webphone_api.flagrestartwebrtc=!1,ResetEngineClicked(),ResetSelEngine();var t=GetEngine("ns");t.clicked=2,SetEngine("ns",t),setTimeout(function(){NPDownloadAndInstall(17)},400);var o=GetNPLocation();!isNull(o)&&o.length>0&&window.open(o)}})})}catch(l){PutToDebugLogException(2,"common: EngineSwitchTransfer",l)}}function HideSettings(e,n,t,o){try{if(isNull(enableoptions)){enableoptions=[];var i="";!isNull(webphone_api.parameters.enableoptions)&&webphone_api.parameters.enableoptions.length>0&&(i=webphone_api.parameters.enableoptions),(isNull(i)||i.length<2)&&(i=GetConfig("enableoptions")),!isNull(i)&&i.length>0&&(i=Trim(i),enableoptions=i.split(",")),isNull(enableoptions)&&(enableoptions=[])}if(isNull(disableoptions)){disableoptions=[];var i="";!isNull(webphone_api.parameters.disableoptions)&&webphone_api.parameters.disableoptions.length>0&&(i=webphone_api.parameters.disableoptions),(isNull(i)||i.length<2)&&(i=GetConfig("disableoptions")),!isNull(i)&&i.length>0&&(i=Trim(i),disableoptions=i.split(",")),isNull(disableoptions)&&(disableoptions=[])}if(isNull(e)&&(e=""),isNull(n)&&(n=""),isNull(t)&&(t=""),isNull(o)&&(o=!1),enableoptions.length>0&&(e.length>0||n.length>0||t.length>0)){e=e.toLowerCase(),n=n.toLowerCase(),t=t.toLowerCase();for(var a=0;a<enableoptions.length;a++){var r=enableoptions[a];if(!(isNull(r)||r.length<1)&&(r=r.toLowerCase(),e.indexOf(r)>=0||r===n||r===t))return!1}return!0}if(disableoptions.length>0&&(e.length>0||n.length>0||t.length>0)){e=e.toLowerCase(),n=n.toLowerCase(),t=t.toLowerCase();for(var a=0;a<disableoptions.length;a++){var r=disableoptions[a];if(!(isNull(r)||r.length<1)&&(r=r.toLowerCase(),e.indexOf(r)>=0||r===n||r===t))return!0!==o||!!StrIsUpperCase(disableoptions[a])}}}catch(l){PutToDebugLogException(2,"common: HideSettings",l)}return!1}function ShowRatingWhyleType(e){try{if(webphone_api.global.showratewhiletype_cache<1||isNull(e)||e.length<1)return;webphone_api.$("#disprate_container").html(e)}catch(n){PutToDebugLogException(2,"common: ShowRatingWhyleType",n)}}function SetLanguage(e){try{if((isNull(e)||e.length<2)&&(e=webphone_api.parameters.language),(isNull(e)||e.length<2)&&(e=GetConfig("language")),(isNull(e)||e.length<2)&&(e=GetParameter("language")),isNull(e))return void PutToDebugLog(2,"EVENT, common: SetLanguage invalid language: "+e);e.length>=2&&(webphone_api.stringres.setlang(e),CanLog(3)&&PutToDebugLog(3,"EVENT, language set to: "+e))}catch(n){PutToDebugLogException(2,"common: SetLanguage",n)}}function SetNotCounter(e,n){try{if(isNull(e)||e.length<1)return;var t=document.getElementById(e);if(isNull(t))return;!isNull(n)&&n.length>0&&IsNumber(n)&&"0"!=n?(t.innerHTML=n,t.style.display="block"):(t.innerHTML="",t.style.display="none")}catch(o){PutToDebugLogException(2,"common: SetNotCounter",o)}}function WebContactGet(e,n){try{if(isNull(webct_url)&&(webct_url=GetParameter2("webcontact_url"),(isNull(webct_url)||webct_url.length<3)&&(webct_url=GetConfig("webcontact_url")),isNull(webct_url)&&(webct_url="")),webct_url.length<3)return;if(isNull(e)||e.length<1)return void PutToDebugLog(3,"WARNING, common WebContactGet invalid number: "+e);if(!n||"function"!=typeof n)return void PutToDebugLog(3,"ERROR, common WebContactGet callback is NULL");var t=webct_url.replace("CALLEDNUMBER",e);webct_cb.push(n),UriParser(t,"","","","","webcontactsearch")}catch(o){PutToDebugLogException(2,"common: WebContactGet",o)}}function WebContactReceived(e){try{if(isNull(webct_cb)||webct_cb.length<1)return void PutToDebugLog(3,"ERROR, common WebContactReceived no callback specified");var n=webct_cb.shift();if(isNull(n)||!n||"function"!=typeof n)return void PutToDebugLog(3,"ERROR, common WebContactReceived invalid callback");if(isNull(e)||e.length<2)return void PutToDebugLog(3,"WARNING, common WebContactReceived invalid data: "+e);var t=[];if(webct_url.toLowerCase().indexOf("tel.search.ch")>=0){var o=e.split("</entry>");if(!isNull(o)&&o.length>0)for(var i=0,a=0;a<o.length;a++)if(!((i=o[a].indexOf("<entry>"))<0)){var r=o[a].substring(i),l="",s="",i=r.indexOf("<tel:name>");i>0&&(l=r.substring(i+10),i=l.indexOf("</tel:name>"),i>0&&(l=l.substring(0,i)),isNull(l)&&(l=""),l=Trim(l)),i=r.indexOf("<tel:phone>"),i>0&&(s=r.substring(i+11),i=s.indexOf("</tel:phone>"),i>0&&(s=s.substring(0,i)),isNull(s)&&(s=""),s=Trim(s)),t.push(l+","+s)}}t.length<1&&t.push(e),n(t)}catch(p){PutToDebugLogException(2,"common: WebContactReceived",p)}}function IsXML(e){try{webphone_api.$.parseXML(e);return!0}catch(n){}return!1}function GetLastRecInvite(){return isNull(saved_lastrecinvite)&&(saved_lastrecinvite=""),saved_lastrecinvite}function GetLastSentInvite(){return isNull(saved_lastsentinvite)&&(saved_lastsentinvite=""),saved_lastsentinvite}function GetSIPHeaderTxt(e){if(isNull(e))return"NULL";if(e.length<1)return"EMPTY";for(var n="",t=0;t<e.length;t++)n=n+e[t].name+":"+e[t].value+", ";return n}function GetEpIdxFromLine(e){for(var n=0;n<webphone_api.global.ep.length;n++)if(!(isNull(webphone_api.global.ep[n])||webphone_api.global.ep[n].length<5)){var t=webphone_api.global.ep[n][EP_LINE];if(!isNull(t)&&!1!==IsNumber(t)&&e===t)return n}return-1}function GetEpState(e){if(isNull(e))return 0;if(e.length<1)return 0;var n=GetCallEpIdx(8471,!1,-1,"",e,null,null,null,!1);if(n<0){if(!isNull(eplinecallid)&&eplinecallid.length>0)for(var t=1;t<eplinecallid.length;t++)if(!isNull(eplinecallid[t])&&eplinecallid[t]==e)return 4;return 0}return GetEpStateIntern(webphone_api.global.ep[n])}function EpStateToStr(e){switch(e){case 0:case 1:case 2:case 3:case 4:break;default:e.toString()}}function GetEpStateIntern(e){return isNull(e)?0:"true"!==e[EP_FLAGDEL]&&"true"!==e[EP_FINISHEDSENT]&&e[EP_DISCONNECTTIME].toString().length<4&&0!=StrToIntDef(e[EP_SETUPTIME],0)&&0!=StrToIntDef(e[EP_CONNECTTIME],0)?3:"true"!==e[EP_FLAGDEL]&&"true"!==e[EP_FINISHEDSENT]&&e[EP_DISCONNECTTIME].toString().length<4&&0!=StrToIntDef(e[EP_SETUPTIME],0)?2:"true"===e[EP_FLAGDEL]||"true"===e[EP_FINISHEDSENT]||e[EP_DISCONNECTTIME].toString().length>=4?4:"true"!==e[EP_FLAGDEL]&&"true"!==e[EP_FINISHEDSENT]&&e[EP_DISCONNECTTIME].toString().length<4?1:0!=StrToIntDef(e[EP_SETUPTIME],0)||0!=StrToIntDef(e[EP_CONNECTTIME],0)?2:4}function SaveCallSession(e,n,t,o,i,a,r,l,s,p,c,u,g,h,m,d,b,_,f){try{var w=-1;IsNumber(n)||(n=-1),o=isNull(o)?"":Trim(o),IsNumber(i)||(i=-1),IsNumber(a)||(a=-1),IsNumber(r)||(r=-1),IsNumber(l)||(l=-1),s=isNull(s)||s.length<1?"":Trim(s),p=isNull(p)||p.length<1?"":Trim(p),p.length>0&&"["==p[0]&&(p=p.substring(1)),p.length>0&&"]"==p[p.length-1]&&(p=p.substring(0,p.length-1)),!isNull(b)&&IsNumber(b)||(b=-1),(isNull(c)||c.length<1)&&(c=""),(isNull(u)||u.length<1)&&(u=""),(isNull(h)||"true"!==h&&"false"!==h)&&(h=""),(isNull(m)||"true"!==m&&"false"!==m)&&(m=""),(isNull(d)||d.length<10)&&(d=""),!isNull(g)&&g.length<1&&(g=null),_=isNull(_)||_.length<1?"":Trim(_),f=isNull(f)?"":Trim(f),d.length>10&&(1==i?saved_lastsentinvite=d:2==i&&(saved_lastrecinvite=d));for(var v=0;v<webphone_api.global.ep.length;v++)(isNull(webphone_api.global.ep[v])||webphone_api.global.ep[v].length<5)&&(PutToDebugLog(2,"ERROR, common: SaveCallSession remove invalid endpoint: "+EpToString(v)),LogLines(),webphone_api.global.ep.splice(v,1),v--);var E="";if(b>0)for(var v=0;v<webphone_api.global.ep.length;v++)if(!(isNull(webphone_api.global.ep[v])||webphone_api.global.ep[v].length<5)){var P=webphone_api.global.ep[v][EP_SESSID];if(P===b){E="webrtcid "+b,w=v;break}}if(w<0&&p.length>0){for(var v=0;v<webphone_api.global.ep.length;v++)if(!(isNull(webphone_api.global.ep[v])||webphone_api.global.ep[v].length<5)){var P=webphone_api.global.ep[v][EP_CALLID];if(!(isNull(P)||P.length<1)&&p.toLowerCase()===P.toLowerCase()){E="callid "+p,w=v;break}}for(var v=0;v<webphone_api.global.ep.length;v++)if(!(isNull(webphone_api.global.ep[v])||webphone_api.global.ep[v].length<5)){var P=webphone_api.global.ep[v][EP_XCALLID];if(!(isNull(P)||P.length<1)&&p.toLowerCase()===P.toLowerCase()){E="callid "+p,w=v;break}}}if(3!=e&&1!=e){if(w<0&&n>0){if(IsNumber(i))for(var v=0;v<webphone_api.global.ep.length;v++)if(!(isNull(webphone_api.global.ep[v])||webphone_api.global.ep[v].length<5)){var T=webphone_api.global.ep[v][EP_LINE];if(!isNull(T)&&!1!==IsNumber(T)&&n===T){var S=webphone_api.global.ep[v][EP_INCOMING];if(IsNumber(S)&&i===S&&"true"!==webphone_api.global.ep[v][EP_FLAGDEL]){E="lineA "+n,w=v;break}}}if(w<0)for(var v=0;v<webphone_api.global.ep.length;v++)if(!(isNull(webphone_api.global.ep[v])||webphone_api.global.ep[v].length<5)){var T=webphone_api.global.ep[v][EP_LINE];if(!isNull(T)&&!1!==IsNumber(T)&&"true"!==webphone_api.global.ep[v][EP_FLAGDEL]&&n===T){E="lineB "+n,w=v;break}}if(w<0)for(var v=0;v<webphone_api.global.ep.length;v++)if(!(isNull(webphone_api.global.ep[v])||webphone_api.global.ep[v].length<5)){var T=webphone_api.global.ep[v][EP_LINE];if(!isNull(T)&&!1!==IsNumber(T)&&n===T){E="lineC "+n,w=v;break}}}if(w<0&&o.length>0){if(IsNumber(i))for(var v=0;v<webphone_api.global.ep.length;v++)if(!(isNull(webphone_api.global.ep[v])||webphone_api.global.ep[v].length<5)){var N=webphone_api.global.ep[v][EP_DESTNR];if(!isNull(N)&&N.toLowerCase()==o){var S=webphone_api.global.ep[v][EP_INCOMING];if(IsNumber(S)&&i===S&&"true"!==webphone_api.global.ep[v][EP_FLAGDEL]){E="destnum1 "+o,w=v;break}}}if(w<0&&o.length>0)for(var v=0;v<webphone_api.global.ep.length;v++)if(!(isNull(webphone_api.global.ep[v])||webphone_api.global.ep[v].length<5)){var N=webphone_api.global.ep[v][EP_DESTNR];if(!isNull(N)&&N.toLowerCase()==o&&"true"!==webphone_api.global.ep[v][EP_FLAGDEL]){E="destnum2 "+o,w=v;break}}if(w<0&&o.length>0)for(var v=0;v<webphone_api.global.ep.length;v++)if(!(isNull(webphone_api.global.ep[v])||webphone_api.global.ep[v].length<5)){var N=webphone_api.global.ep[v][EP_DESTNR];if(!isNull(N)&&N.toLowerCase()==o){E="destnum3 "+o,w=v;break}}}}if(w>-1){if(n>0){var I=webphone_api.global.ep[w][EP_LINE];(isNull(I)||!1===IsNumber(I))&&(I=-5),I<1?(PutToDebugLog(4,"EVENT, common: SaveCallSession set line from "+I+" to "+n+" foundby: "+E+" fromc"+e),webphone_api.global.ep[w][EP_LINE]=n,LogLines()):n===I||isNull(webphone_api.global.ep[w][EP_SESSION])||n!==webphone_api.global.ep[w][EP_SESSION].getLine()||(I>0&&PutToDebugLog(4,"WARNING, common: SaveCallSession change line from "+I+" to "+n+" foundby: "+E+" fromc"+e),webphone_api.global.ep[w][EP_LINE]=n,LogLines())}else n=webphone_api.global.ep[w][EP_LINE],(isNull(n)||!1===IsNumber(n))&&(n=-5);isNull(t)||(webphone_api.global.ep[w][EP_SESSION]=t),o.length>0&&(webphone_api.global.ep[w][EP_DESTNR]=o),i>0&&(webphone_api.global.ep[w][EP_INCOMING]=i),a>0&&(webphone_api.global.ep[w][EP_SETUPTIME]=a),(r>0||r<-2)&&(webphone_api.global.ep[w][EP_CONNECTTIME]=r),(l>0||l<-2)&&(webphone_api.global.ep[w][EP_DISCONNECTTIME]=l),(s.length>0||l<-2)&&(webphone_api.global.ep[w][EP_REASON]=s),p.length>0&&(!isNull(webphone_api.global.ep[w][EP_CALLID])&&webphone_api.global.ep[w][EP_CALLID].length>0&&webphone_api.global.ep[w][EP_CALLID].toLowerCase()!=p.toLowerCase()&&(PutToDebugLog(4,"WARNING, common: SaveCallSession change callid from "+webphone_api.global.ep[w][EP_CALLID]+" to "+p+" foundby: "+E+" fromc"+e),LogLines()),webphone_api.global.ep[w][EP_CALLID]=p),_.length>0&&(webphone_api.global.ep[w][EP_XCALLID]=_),c.length>0&&(webphone_api.global.ep[w][EP_SETUPSENT]=c),u.length>0&&(webphone_api.global.ep[w][EP_FINISHEDSENT]=u),isNull(g)||(webphone_api.global.ep[w][EP_SIPHEADERS]=g.slice()),"true"!==h&&"false"!==h||(webphone_api.global.ep[w][EP_MUTESTATE]=h),"true"!==m&&"false"!==m||(webphone_api.global.ep[w][EP_HOLDSTATE]=m),d.length>10&&(webphone_api.global.ep[w][EP_SIPINVITE]=d),f.length>0&&(webphone_api.global.ep[w][EP_DISPLAYNAME]=f);try{if(b>0){if(!isNull(webphone_api.global.ep[w][EP_SESSID])&&IsNumber(webphone_api.global.ep[w][EP_SESSID])&&webphone_api.global.ep[w][EP_SESSID]!=b&&1!=e){var C="";!isNull(webphone_api.global.ep[w][EP_CALLID])&&webphone_api.global.ep[w][EP_CALLID].length>0&&(C=webphone_api.global.ep[w][EP_CALLID]),PutToDebugLog(4,"WARNING, common: SaveCallSession change sessionid from "+webphone_api.global.ep[w][EP_SESSID]+" to "+b+" foundby: "+E+" / "+C+"/"+p+" fromc"+e),LogLines()}webphone_api.global.ep[w][EP_SESSID]=b}else("undefined"==typeof webphone_api.global.ep[w][EP_SESSID]||null===webphone_api.global.ep[w][EP_SESSID]||webphone_api.global.ep[w][EP_SESSID]<1)&&(void 0!==t&&null!==t&&"undefined"!=typeof t.o_session&&null!==t.o_session&&"undefined"!=typeof t.o_session.__i_session_id&&null!==t.o_session.__i_session_id&&(b=t.o_session.__i_session_id),b>0&&(webphone_api.global.ep[w][EP_SESSID]=b))}catch(R){PutToDebugLogException(2,"common: SaveCallSession inner sessionID 1",R)}webphone_api.global.ep[w][EP_FLAGDEL]="false";var G=d;G.length>50&&(G=G.substring(0,50)),!isNull(webphone_api.global.ep[w][EP_SESSION])&&webphone_api.global.ep[w][EP_LINE]>0&&webphone_api.global.ep[w][EP_LINE]!==webphone_api.global.ep[w][EP_SESSION].getLine()&&(webphone_api.global.ep[w][EP_SESSION].getLine()>0&&PutToDebugLog(4,"EVENT, (warn) change session line to "+webphone_api.global.ep[w][EP_LINE]+" for session "+webphone_api.webrtcapi.SessionToString(webphone_api.global.ep[w][EP_SESSION])+" foundby: "+E+" fromc"+e),webphone_api.global.ep[w][EP_SESSION].setLine(webphone_api.global.ep[w][EP_LINE]),LogLines()),!isNull(webphone_api.global.ep[w][EP_SESSION])&&webphone_api.global.ep[w][EP_CALLID].length>0&&webphone_api.global.ep[w][EP_CALLID]!==webphone_api.global.ep[w][EP_SESSION].getSipcallid()&&(webphone_api.global.ep[w][EP_SESSION].getSipcallid().length>0&&PutToDebugLog(4,"EVENT, (warn) change session sipcallid from to "+webphone_api.global.ep[w][EP_CALLID]+" for session "+webphone_api.webrtcapi.SessionToString(webphone_api.global.ep[w][EP_SESSION])+" foundby: "+E+" fromc"+e),webphone_api.global.ep[w][EP_SESSION].setSipcallid(webphone_api.global.ep[w][EP_CALLID]),LogLines()),p.length>0&&IsNumber(webphone_api.global.ep[w][EP_LINE])&&webphone_api.global.ep[w][EP_LINE]>0&&(eplinecallid[webphone_api.global.ep[w][EP_LINE]]=p),PutToDebugLog(4,"EVENT, common: SaveCallSession endpoint updated, fromc: "+e+", line: "+webphone_api.global.ep[w][EP_LINE]+"; destnr: "+o+"; isincoming: "+i+"; callid: "+p+"; setuptime: "+a+"; connecttime: "+r+"; disctime: "+l+"; setupsent: "+c+"; finishedsent: "+u+"; mutestate: "+h+"; holdstate: "+m+"; sipinvite: "+G+"; webrtcid: "+b+"; xcallid: "+_+"; foundby: "+E+"; session: "+webphone_api.webrtcapi.SessionToString(t))}else{if(n<1&&(n=webphone_api.global.aline,n>0&&GetEpIdxFromLine(n)>=0&&(n=0),n<1&&(n=GetFreeLine())),"true"!==h&&"false"!==h&&(h="false"),"true"!==m&&"false"!==m&&(m="false"),b<1)try{void 0!==t&&null!==t&&"undefined"!=typeof t.o_session&&null!==t.o_session&&"undefined"!=typeof t.o_session.__i_session_id&&null!==t.o_session.__i_session_id&&(b=t.o_session.__i_session_id)}catch(R){PutToDebugLogException(2,"common: SaveCallSession inner sessionID 2",R)}isNull(t)||(n>0&&(n!=t.getLine()&&t.getLine()>0&&PutToDebugLog(4,"EVENT, set session line from "+t.getLine()+" to "+n),t.setLine(n)),p.length>0&&(p!=t.getSipcallid()&&t.getSipcallid().length>0&&PutToDebugLog(4,"EVENT, set session sipcallid from "+t.getSipcallid()+" to "+p),t.setSipcallid(p)));var L=[n,t,o,i,a,r,l,s,p,"false",c,u,g,h,m,d,b,null,_,f];isNull(webphone_api.global.ep)&&(webphone_api.global.ep=[]),webphone_api.global.ep.push(L),p.length>0&&IsNumber(n)&&n>0&&(eplinecallid[n]=p);var G=d;G.length>50&&(G=G.substring(0,50)),PutToDebugLog(4,"EVENT, common: SaveCallSession new endpoint added, fromc: "+e+", line: "+n+"; destnr: "+o+"; isincoming: "+i+"; callid: "+p+"; setuptime: "+a+"; connecttime: "+r+"; disctime: "+l+"; setupsent: "+c+"; finishedsent: "+u+"; mutestate: "+h+"; holdstate: "+m+"; sipinvite: "+G+"; webrtcid: "+b+"; xcallid: "+_+"; session: "+webphone_api.webrtcapi.SessionToString(t))}!1!==IsSDK()||!0!==webphone_api.global.isCallStarted||isNull(webphone_api._call)||webphone_api._call.UpdateLineButtons(19),LogLines()}catch(y){PutToDebugLogException(2,"common: SaveCallSession",y)}return n}function GetLineForJavaAPI(e,n){if(!isNull(e)&&IsNumber(e)){var t=StrToInt(e);if(!isNull(t)&&(-3===t&&(t=-1),t>=-2))return t}if(webphone_api.global.lastalinesetreal>=-2&&webphone_api.global.lastalinesetreal===webphone_api.global.aline)return webphone_api.global.lastalinesetreal;if(webphone_api.global.lastalinesetreal>=-2&&0!=webphone_api.global.lastalinesetrealtick&&GetTickCount()-webphone_api.global.lastalinesetrealtick<300&&GetTickCount()-webphone_api.global.lastalinesetrealtick>=0)return webphone_api.global.lastalinesetreal;if(webphone_api.global.lastalineset>=-2&&0!=webphone_api.global.lastalinesettick&&GetTickCount()-webphone_api.global.lastalinesettick<5e3&&GetTickCount()-webphone_api.global.lastalinesettick>=0)return webphone_api.global.lastalineset;if(webphone_api.global.lastalinesetreal>=-2&&0!=webphone_api.global.lastalinesetrealtick&&GetTickCount()-webphone_api.global.lastalinesetrealtick<600&&GetTickCount()-webphone_api.global.lastalinesetrealtick>=0)return webphone_api.global.lastalinesetreal;if(webphone_api.global.lastalineset>=-2&&webphone_api.global.lastalineset===webphone_api.global.aline&&0!=webphone_api.global.lastalinesettick&&GetTickCount()-webphone_api.global.lastalinesettick<4e4&&GetTickCount()-webphone_api.global.lastalinesettick>=0)return webphone_api.global.lastalineset;if(isNull(n)||-3===n){if((-1===webphone_api.global.lastalineset||-2===webphone_api.global.lastalineset)&&GetTickCount()-webphone_api.global.lastalinesettick<1e4&&GetTickCount()-webphone_api.global.lastalinesettick>=0)return webphone_api.global.lastalineset;if(-1===webphone_api.global.lastalinesetreal||-2===webphone_api.global.lastalinesetreal)return webphone_api.global.lastalinesetreal;if(-1===webphone_api.global.lastalineset||-2===webphone_api.global.lastalineset)return webphone_api.global.lastalineset;if(webphone_api.global.lastalineset>=-2&&0!=webphone_api.global.lastalinesettick&&GetTickCount()-webphone_api.global.lastalinesettick<1e4&&GetTickCount()-webphone_api.global.lastalinesettick>=0)return webphone_api.global.lastalineset}return-2===n||-1===n?n:webphone_api.global.aline}function GetCallSession(e,n,t,o,i,a,r,l,s){var p=GetCallEpIdx(e,n,t,o,i,a,r,l,s);if(p>=0){var c=webphone_api.global.ep[p][EP_SESSION];return isNull(c)||c===l?a:(lastcallsessionepidx=p,c)}return a}function GetIdxFromEp(e){if(isNull(e))return-1;for(var n=0;n<webphone_api.global.ep.length;n++)if(e===webphone_api.global.ep[n])return n;return-1}function GetCallEpIdx(e,n,t,o,i,a,r,l,s){try{var p=GetEndpoint(e,t,o,i,"",n,!1,r,l,!0);if(p){for(var c=0;c<webphone_api.global.ep.length;c++)if(p===webphone_api.global.ep[c])return!1!==IsSDK()||!0!==webphone_api.global.isCallStarted||isNull(webphone_api._call)||webphone_api._call.UpdateLineButtons(12),c;null==l&&PutToDebugLog(2,"WARNING, returned ep not found "+e+" "+p)}if(webphone_api.global.ep.length<1)return null==l&&PutToDebugLog(2,"EVENT, common: GetCallSession no global session found a fromcode "+e),-1;if(isNull(s)&&(s=!0),!s)return-1;var u=0;if(webphone_api.global.loglevel>0&&getuseengine()===webphone_api.global.ENGINE_WEBRTC){for(var g=0,h=-1,c=0;c<webphone_api.global.ep.length;c++){var m=GetEpStateIntern(webphone_api.global.ep[c]);m>0&&(h<0||4==h&&4!=m||0==h&&4!=m&&0!=m||1==h&&1!=m&&4!=m&&0!=m||2==h&&3==m)&&(g=c,h=m)}if(u=g,isNull(webphone_api.global.ep[u][EP_SESSION]))return null==l&&PutToDebugLog(2,"WARNING, common: GetCallSession no global session found for webrtc. fromcode: "+e+", remove: "+n+",line: "+t+",destnr: "+o+",callid: "+i+",session: "+a+",isincoming: "+r+", ret: "+EpToString(u)),u}return null==l&&PutToDebugLog(2,"EVENT, common: GetCallSession returning guessed session. fromcode: "+e+", remove: "+n+",line: "+t+",destnr: "+o+",callid: "+i+",session: "+a+",isincoming: "+r+", canguess: "+s+", ret: "+EpToString(u)),null==l&&LogLines(),u}catch(d){
PutToDebugLogException(2,"common: GetCallSession",d)}try{if(webphone_api.global.ep.length>0)return 0}catch(d){}return-1}function FixSessionId(e,n){return e}function GetEndpoint(e,n,t,o,i,a,r,l,s,p){var c=null,u=0;try{if(u=1,isNull(webphone_api.global.ep)||webphone_api.global.ep.length<1)return u=2,!1!==IsSDK()||!0!==webphone_api.global.isCallStarted||isNull(webphone_api._call)||webphone_api._call.UpdateLineButtons(13),SetALineInternal(1,4,!1),null;u=3,(isNull(n)||!1===IsNumber(n))&&(u=4,n=webphone_api.global.aline,(isNull(n)||!1===IsNumber(n))&&(n=-1)),u=5,isNull(t)?t="":(t=Trim(t),t=t.toLowerCase()),isNull(o)||o.length<1?o="":(o=Trim(o),o=o.toLowerCase()),o.length>0&&"["==o[0]&&(o=o.substring(1)),o.length>0&&"]"==o[o.length-1]&&(o=o.substring(0,o.length-1)),!isNull(i)&&IsNumber(i)||(i=-1),u=6;for(var g=0;g<webphone_api.global.ep.length;g++)(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)&&(null==s&&PutToDebugLog(2,"ERROR, common: GetEndpoint remove invalid endpoint fromcode "+e+": "+EpToString(g)),webphone_api.global.ep.splice(g,1),g--);if(u=30,isNull(webphone_api.global.ep)||webphone_api.global.ep.length<1)return u=31,SetALineInternal(1,41,!1),!1!==IsSDK()||!0!==webphone_api.global.isCallStarted||isNull(webphone_api._call)||webphone_api._call.UpdateLineButtons(14),null;u=7;var h="";if(i>0){u=8,h+="a";for(var g=0;g<webphone_api.global.ep.length;g++)if(!(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)){var m=webphone_api.global.ep[g][EP_SESSID];if(m===i&&(isNull(s)||webphone_api.global.ep[g][EP_SESSION]!==s)){c=webphone_api.global.ep[g];break}}}if(u=9,!c&&o.length>0){u=10,h+="b";for(var g=0;g<webphone_api.global.ep.length;g++)if(!(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)){var m=webphone_api.global.ep[g][EP_CALLID];if(!(isNull(m)||m.length<1)&&o===m.toLowerCase()&&(isNull(s)||webphone_api.global.ep[g][EP_SESSION]!==s)){c=webphone_api.global.ep[g];break}}}if(u=12,!c&&n>0&&(!a||o.length<1)&&(!0!==r||i<1&&o.length<1&&t.length<1)){if(u=13,h+="c",IsNumber(l)){u=14,h+="d";for(var g=0;g<webphone_api.global.ep.length;g++)if(!(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)){var d=webphone_api.global.ep[g][EP_LINE];if(!isNull(d)&&!1!==IsNumber(d)&&n===d){var b=webphone_api.global.ep[g][EP_INCOMING];if(IsNumber(b)&&l===b&&"true"!==webphone_api.global.ep[g][EP_FLAGDEL]){c=webphone_api.global.ep[g];break}}}}if(!c){u=15,h+="e";for(var g=0;g<webphone_api.global.ep.length;g++)if(!(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)){var d=webphone_api.global.ep[g][EP_LINE];if(!isNull(d)&&!1!==IsNumber(d)&&n===d&&(isNull(s)||webphone_api.global.ep[g][EP_SESSION]!==s)&&"true"!==webphone_api.global.ep[g][EP_FLAGDEL]){c=webphone_api.global.ep[g];break}}}if(!c){u=16,h+="f";for(var g=0;g<webphone_api.global.ep.length;g++)if(!(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)){var d=webphone_api.global.ep[g][EP_LINE];if(!isNull(d)&&!1!==IsNumber(d)&&n===d&&(isNull(s)||webphone_api.global.ep[g][EP_SESSION]!==s)){c=webphone_api.global.ep[g];break}}}}if(u=17,!c&&t.length>0&&(!a||o.length<1)){if(u=18,h+="g",IsNumber(l)){u=19,h+="h";for(var g=0;g<webphone_api.global.ep.length;g++)if(!(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)){var _=webphone_api.global.ep[g][EP_DESTNR];if(!isNull(_)&&_.toLowerCase()==t){var b=webphone_api.global.ep[g][EP_INCOMING];if(IsNumber(b)&&l===b&&(isNull(s)||webphone_api.global.ep[g][EP_SESSION]!==s)&&"true"!==webphone_api.global.ep[g][EP_FLAGDEL]){c=webphone_api.global.ep[g];break}}}}if(!c){u=20,h+="i";for(var g=0;g<webphone_api.global.ep.length;g++)if(!(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)){var _=webphone_api.global.ep[g][EP_DESTNR];if(!isNull(_)&&_.toLowerCase()==t&&(isNull(s)||webphone_api.global.ep[g][EP_SESSION]!==s)&&"true"!==webphone_api.global.ep[g][EP_FLAGDEL]){c=webphone_api.global.ep[g];break}}}if(!c){u=21,h+="j";for(var g=0;g<webphone_api.global.ep.length;g++)if(!(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)){var _=webphone_api.global.ep[g][EP_DESTNR];if(!isNull(_)&&_.toLowerCase()==t&&(isNull(s)||webphone_api.global.ep[g][EP_SESSION]!==s)){c=webphone_api.global.ep[g];break}}}}if(u=99,!c&&o.length>0){u=10,h+="b";for(var g=0;g<webphone_api.global.ep.length;g++)if(!(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)){var m=webphone_api.global.ep[g][EP_XCALLID];if(!(isNull(m)||m.length<1)&&o===m.toLowerCase()&&(isNull(s)||webphone_api.global.ep[g][EP_SESSION]!==s)){c=webphone_api.global.ep[g];break}}}if(c){if(!0===a){u=22;for(var g=0;g<webphone_api.global.ep.length;g++)if(c===webphone_api.global.ep[g]&&!(isNull(webphone_api.global.ep[g])||webphone_api.global.ep[g].length<5)){if(webphone_api.global.ep.length<2&&webphone_api.global.ep[g][EP_DISCONNECTTIME].toString().length<4)break;if(LogLines(),c[EP_FLAGDEL]="true",!0===p)PutToDebugLog(3,"EVENT, common: GetEndpoint flagged to remove OLD endpoint_1 fromcode "+e+": "+EpToString(g));else{PutToDebugLog(2,"EVENT, common: GetEndpoint remove OLD endpoint_1 fromcode "+e+": "+EpToString(g));var f=webphone_api.global.ep[g][EP_LINE];webphone_api.global.ep.splice(g,1),isNull(webphone_api.global.ep)||webphone_api.global.ep.length<1?(HideLinesOnSingleLine(),SetALineInternal(1,5,!1)):webphone_api.global.aline>=0&&webphone_api.global.aline==f&&(HideLinesOnSingleLine(),SetALineInternal(GetBestLine(null,!0),102,!1)),LogLines()}break}}return u=23,IsNumber(l)&&2==l&&(c[EP_INCOMING]=l),u=24,!1!==IsSDK()||!0!==webphone_api.global.isCallStarted||isNull(webphone_api._call)||(u=25,webphone_api._call.UpdateLineButtons(15)),c}!0===a?PutToDebugLog(2,"EVENT, common: GetEndpoint no ep to remove fromcode "+e+" / "+n+" / "+t+" / "+o+" / "+h):CanLog(6)&&null==s&&PutToDebugLog(6,"EVENT, common: GetEndpoint no ep found fromcode "+e+" / "+n+" / "+t+" / "+o+" / "+h)}catch(w){PutToDebugLogException(2,"common: GetEndpoint "+u.toString(),w)}return c}function LogLines(){if(CanLog(5)){PutToDebugLog(5,"EVENT, lines (total: "+webphone_api.global.ep.length+", active: "+webphone_api.global.aline+"): ");for(var e=0;e<webphone_api.global.ep.length;e++)isNull(webphone_api.global.ep[e])||PutToDebugLog(5,"EVENT, "+EpToString(e))}}function EpToString(e){if(isNull(webphone_api.global.ep)||e>=webphone_api.global.ep.length||isNull(webphone_api.global.ep[e])||e<0)return"NULL";var n=webphone_api.global.ep[e];return"ep"+e+": line: "+n[EP_LINE]+",peer: "+n[EP_DESTNR]+",state: "+EpStateToStr(GetEpStateIntern(n))+",incoming: "+n[EP_INCOMING]+",setup: "+n[EP_SETUPTIME]+",connect: "+n[EP_CONNECTTIME]+",disc: "+n[EP_DISCONNECTTIME]+",callid: "+n[EP_CALLID]+",xcallid: "+n[EP_XCALLID]+",sess: "+n[EP_SESSID]+",del: "+n[EP_FLAGDEL]}function LineToString(e){if(isNull(webphone_api.global.ep))return"NULL";for(var n=webphone_api.global.ep.length-1;n>=0;n--){var t=webphone_api.global.ep[n];if(!(isNull(t)||t.length<5)&&e===webphone_api.global.ep[n][EP_LINE])return"ep"+n+": line: "+t[EP_LINE]+",destnr: "+t[EP_DESTNR]+",incoming: "+t[EP_INCOMING]+",setup: "+t[EP_SETUPTIME]+",connect: "+t[EP_CONNECTTIME]+",disc: "+t[EP_DISCONNECTTIME]+",callid: "+t[EP_CALLID]+",xcallid: "+t[EP_XCALLID]+",sess: "+t[EP_SESSID]+",del: "+t[EP_FLAGDEL]}return"NULL"}function IsInCallEx(e){try{for(var n=webphone_api.global.ep.length-1;n>=0;n--)if(EpIsInCallEx(webphone_api.global.ep[n],e))return!0;webphone_api.global.checkIfInCall=!1}catch(t){PutToDebugLogException(2,"common: IsInCallEx",t)}return!1}function EpIsInCallEx(e,n){try{if(isNull(e)||e.length<5)return!1;if(n){var t=e[EP_LINE];if(isNull(t)||!1===IsNumber(t))return!1;if(t===n)return!1}if("true"!==e[EP_FLAGDEL]&&"true"!==e[EP_FINISHEDSENT]&&e[EP_DISCONNECTTIME].toString().length<4&&(0!=StrToIntDef(e[EP_SETUPTIME],0)||0!=StrToIntDef(e[EP_CONNECTTIME],0)))return webphone_api.global.checkIfInCall=!0,!0}catch(o){PutToDebugLogException(2,"common: EpIsInCallEx",o)}return!1}function GetFreeLine(){try{for(var e=[],n=[],t=0;t<webphone_api.global.ep.length;t++){var o=webphone_api.global.ep[t][EP_LINE];if(!isNull(o)&&!1!==IsNumber(o)){var i=StrToInt(o);i>0&&(e.push(i),n.push(StrToInt(webphone_api.global.ep[t][EP_SETUPTIME])))}}for(var t=0;t<e.length;t++)for(var a=t+1;a<e.length;a++)if(e[t]>e[a]){var r=e[t];e[t]=e[a],e[a]=r,r=n[t],n[t]=n[a],n[a]=r}for(var l=GetTickCount(),s=1,t=0;t<e.length;t++)e[t]===s&&n[t]>0&&l-n[t]>1500&&s++;return PutToDebugLog(2,"EVENT, GetFreeLine returned: "+s.toString()),s}catch(p){PutToDebugLogException(2,"common: GetFreeLine",p)}return webphone_api.global.aline+1}function IsLineFree(e){try{if(e<1)return!1;for(var n=0;n<webphone_api.global.ep.length;n++){var t=webphone_api.global.ep[n][EP_LINE];if(!isNull(t)&&!1!==IsNumber(t)){var o=StrToInt(t);if(t=t.toString(),e=e.toString(),o>0&&t===e)return!1}}}catch(i){PutToDebugLogException(2,"common: GetFreeLine",i)}return!0}function GetBestLine(e,n,t){var o=1;try{o=webphone_api.global.aline,isNull(e)&&(e=-987),isNull(n)&&(n=!1),isNull(t)&&(t=""),(n||o==e)&&(o=-1);var i=-10,a=0,r=!1,l=null;gestbestline_ep=null;for(var s=GetLineForJavaAPI(),p=webphone_api.global.ep.length-1;p>=0;p--){var c=webphone_api.global.ep[p];if(!(isNull(c)||c.length<5)&&("false"===c[EP_FLAGDEL]&&"true"!==c[EP_FINISHEDSENT]&&c[EP_DISCONNECTTIME].toString().length<4)){var u=StrToInt(c[EP_LINE]);if(isNull(u)||u<1||u==e)continue;var g=0;IsNumber(c[EP_SETUPTIME])&&(g=StrToInt(c[EP_SETUPTIME]));var h=!1;if(0==StrToIntDef(c[EP_SETUPTIME],0)&&0==StrToIntDef(c[EP_CONNECTTIME],0)||(h=!0),h)if(t.length>0){if(c[EP_DESTNR]==t){i=u,l=c;break}}else{if(u===s){i=u,l=c;break}if(s<1&&u===webphone_api.global.aline){i=u,l=c;break}}else;i>0?h&&!r?(i=u,l=c,a=g,r=h):g>=a&&(h||!r)&&(i=u,l=c,a=g,r=h):(i=u,l=c,a=g,r=h)}}if(i>0&&i!=e)return gestbestline_ep=l,i;if(n)return-1;if(webphone_api.global.aline<2&&webphone_api.global.aline!=e)return webphone_api.global.aline;if(1!=e)return 1;if(2!=e)return 2}catch(m){PutToDebugLogException(2,"common: GetBestLine",m)}return o}function GetLastCallEPIdx(){try{for(var e=-10,n=0,t=webphone_api.global.ep.length-1;t>=0;t--){var o=webphone_api.global.ep[t];if(!(isNull(o)||o.length<5)&&("false"===o[EP_FLAGDEL]&&"true"!==o[EP_FINISHEDSENT]&&o[EP_DISCONNECTTIME].toString().length<4)){IsNumber(o[EP_SETUPTIME])&&(n=StrToInt(o[EP_SETUPTIME])),e>0?0>=n&&(e=t,n=0):(e=t,n=0)}}return e}catch(i){PutToDebugLogException(2,"common: GetLastCallEPIdx",i)}return-1}function GetNrOfActiveCalls(){try{for(var e=0,n=0;n<webphone_api.global.ep.length;n++){var t=webphone_api.global.ep[n][EP_DISCONNECTTIME];isNull(t)||(t=t.toString(),t.length<3&&e++)}return e}catch(o){PutToDebugLogException(2,"common: GetNrOfActiveCalls",o)}return webphone_api.global.acallcount}function GetPeerUsername(){try{for(var e=0;e<webphone_api.global.ep.length;e++){var n=webphone_api.global.ep[e][EP_DISCONNECTTIME];if(!isNull(n)){n=n.toString();var t=webphone_api.global.ep[e][EP_DESTNR];if(!isNull(t)&&(t=t.toString(),n.length<3&&t.length>0))return t}}}catch(o){PutToDebugLogException(2,"common: GetPeerUsername",o)}return""}function HideLinesOnSingleLine(){webphone_api.global.ep.length<=1&&wasmultiline&&(PutToDebugLog(2,"EVENT, common: hide lines on single line "+webphone_api.global.ep.length.toString()+" "+webphone_api.global.aline.toString()),wasmultiline=!1,webphone_api.$("#acceptreject_layout").hide(),webphone_api.$("#mline_layout").hide(),1==webphone_api.global.ep.length&&IsInCallEx()?(webphone_api.$("#hangup_layout").show(),webphone_api.$("#callfunctions_layout").show()):webphone_api.global.ep.length<1&&(webphone_api.$("#hangup_layout").hide(),webphone_api.$("#callfunctions_layout").hide()))}function RefreshInfo(e){try{if(isNull(e)&&(e=0),!0===IsSDK()||!1===webphone_api.global.isCallStarted)return;var n=GetEndpoint(1016,webphone_api.global.aline,"","","",!1);if(isNull(n)||n.length<5)return HideLinesOnSingleLine(),void(webphone_api.global.aline>=0&&SetALineInternal(GetBestLine(null,!0),101,!1));webphone_api.global.ep.length>1&&(wasmultiline=!0);var t=n[EP_DESTNR],o="";!isNull(t)&&t.length>0&&(o=GetContactNameFromNumber(t),isNull(o)&&(o="")),o===t&&(o=""),o.length>0?(webphone_api.$("#calledcaller").html(o+"&nbsp;("+t+")&nbsp;"),(webphone_api.$("#page_call_peer_details").html().indexOf(t)<0||webphone_api.$("#page_call_peer_details").html().indexOf(o)<0)&&(PutToDebugLog(5,"EVENT, caller-id display D: "+o+" "+t),webphone_api.$("#page_call_peer_details").html(o+"<br>"+t))):(webphone_api.$("#calledcaller").html(t),webphone_api.$("#page_call_peer_details").html().indexOf(t)<0&&(PutToDebugLog(5,"EVENT, caller-id display E: "+t),webphone_api.$("#page_call_peer_details").html(t)));var i=n[EP_SETUPTIME],a=n[EP_CONNECTTIME];"undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications?isNull(a)||a.length<3?!isNull(i)&&i.toString().length>2&&IsNumber(i)&&webphone_api.notifications.SetCallStartTime(StrToInt(i)):a.toString().length>2&&IsNumber(a)&&webphone_api.notifications.SetCallStartTime(StrToInt(a)):console&&console.log&&console.log("ERROR, common RefreshInfo webphone_api.notifications is not defined");var r=document.getElementById("mute_status"),l=document.getElementById("hold_status");if(isNull(r)||(!0===GetMuteState(StrToInt(n[EP_LINE]))?webphone_api.$(r).hasClass("callfunc_status_on")||webphone_api.$(r).addClass("callfunc_status_on"):webphone_api.$(r).hasClass("callfunc_status_on")&&webphone_api.$(r).removeClass("callfunc_status_on")),isNull(l)||(!0===GetHoldState(StrToInt(n[EP_LINE]))?webphone_api.$(l).hasClass("callfunc_status_on")||webphone_api.$(l).addClass("callfunc_status_on"):webphone_api.$(l).hasClass("callfunc_status_on")&&webphone_api.$(l).removeClass("callfunc_status_on")),!isNull(n)&&n.length>4){var s=!0;a.toString().length>2&&IsNumber(a)&&(s=!1);var p=!1;"2"!=n[EP_INCOMING]&&2!=n[EP_INCOMING]||(p=!0);var c=!1;"true"!=n[EP_FINISHEDSENT]&&1!=n[EP_FINISHEDSENT]||(c=!0),!0===p&&!0===s&&!1===c?(webphone_api.$("#hangup_layout").hide(),webphone_api.$("#callfunctions_layout").hide(),webphone_api.global.ep.length>1?(webphone_api.$("#acceptreject_layout").hide(),webphone_api.$("#mline_layout").show()):(webphone_api.$("#mline_layout").hide(),webphone_api.$("#acceptreject_layout").show())):(webphone_api.$("#acceptreject_layout").hide(),webphone_api.$("#mline_layout").hide(),webphone_api.$("#hangup_layout").show(),webphone_api.$("#callfunctions_layout").show())}}catch(u){PutToDebugLogException(2,"common: RefreshInfo",u)}}function GetRequestId(){try{return reqid_cached>0?(reqid_cached+=1,reqid_cached.toString()):(reqid_cached=RandomInt(5e3,9999999),reqid_cached.toString())}catch(e){PutToDebugLogException(2,"common: GetRequestId",e)}return GetTickCount().toString()}function IsMultiline(){try{var e=GetParameter2("multilinegui");if(isNull(e)||e.length<1)return-1;if(IsNumber(e))return StrToInt(e);if("true"===e.toLowerCase()||"1"==e)return 1;if("false"===e.toLowerCase()||"0"==e)return 0}catch(n){PutToDebugLogException(2,"common: GetRequestId",n)}return-1}function GetTelsearchName(e,n){try{var t=GetParameter2("telsearchurl");if((isNull(t)||t.length<3)&&(t=webphone_api.parameters.telsearchurl),isNull(t)||t.length<3)return PutToDebugLog(2,"ERROR, GetTelsearchName invalid search url: "+t),void n("invalid search url: "+t);var o=NormalizeNumber(e);o=encodeURIComponent(o),t=t.replace("DESTINATION",o),telshearchcb.push(n),UriParser(t,"","","","","telsearchname")}catch(i){PutToDebugLogException(2,"common: GetTelsearchName",i)}}function TelSearchNameReceived(e){try{if(isNull(e)||e.length<10)return void PutToDebugLog(2,"ERROR, TelSearchNameReceived invalid data: "+e);PutToDebugLog(5,"EVENT,TelSearchNameReceived: "+e);var n=e.indexOf("<tel:name>");if(n>0){e=e.substring(n+10),n=e.indexOf("</tel:name>"),n>0&&(e=e.substring(0,n)),isNull(e)&&(e=""),e=Trim(e);var t=telshearchcb.shift();isNull(t)||"function"!=typeof t||(PutToDebugLog(2,"EVENT, TelSearchNameReceived name found: "+e),t(e))}}catch(o){PutToDebugLogException(2,"common: TelSearchNameReceived",o)}}function GetIceTimeout(){try{var e=GetParameter("icetimeout");if(isNull(webphone_api.parameters.icetimeout)||(e=webphone_api.parameters.icetimeout),!isNull(e)&&IsNumber(e)){var n=StrToInt(e);if(!isNull(n)&&n>0)return n<30&&(n*=1e3),n}}catch(t){PutToDebugLogException(2,"common: GetIceTimeout",t)}return 2e3}function ResetIce(){try{webphone_api.global.ice_callaccepted=!1,webphone_api.global.icecompleted=!1,isNull(webphone_api.global.ice_timer)||clearInterval(webphone_api.global.ice_timer),webphone_api.global.ice_timer=null}catch(e){PutToDebugLogException(2,"common: ResetIce",e)}}function GetNativeDialerUrl(e){var n="";try{return isNull(e)||e.length<1?(PutToDebugLog(2,"ERROR, GetNativeDialerUrl invalid OS"),""):("iOS"===e?(n=GetParameter2("ios_nativedialerurl"),(isNull(n)||n.length<3)&&(n="https://itunes.apple.com/us/app/mizuphone/id483685573")):(n=GetParameter2("android_nativedialerurl"),(isNull(n)||n.length<3)&&(n="https://play.google.com/store/apps/details?id=com.mizuvoip.mizudroid.app")),n)}catch(t){PutToDebugLogException(2,"common: ResetIce",t)}return""}function GetSessionId(){try{return isNull(sessionid_cache)?(sessionid_cache=RandomInt(1e3,9999999).toString(),sessionid_cache+=GetTickCount().toString()):sessionid_cache}catch(e){PutToDebugLogException(2,"common: GetSessionId",e)}return"1122334455"}function SetElementsSrc(){try{if(!0===IsSDK())return;var e=document.getElementById("phone_app_main_container");if(isNull(e))return void PutToDebugLog(2,"ERROR, common: SetElementsSrc app container is NULL");var n=webphone_api.getbasedir2();if(isNull(n))return void PutToDebugLog(2,"ERROR, common: SetElementsSrc base dir is NULL");var t=e.getElementsByTagName("img");if(isNull(t)||t.length<1)return void PutToDebugLog(2,"ERROR, common: SetElementsSrc image list is NULL");for(var o=0,i=t.length,a=0;a<i;a++)if(!isNull(t[a])){var r=t[a].src;isNull(r)||r.indexOf("images/")<0||(r=r.substring(r.indexOf("images/")),t[a].src=n+r,o++)}CanLog(2)&&PutToDebugLog(2,"EVENT, common: SetElementsSrc for: "+o.toString()+" images");var l=document.getElementById("android_frame");isNull(l)||isNull(l.style.background)||(l.style.background="url("+n+"images/android_frame.png) no-repeat #ffffff")}catch(s){PutToDebugLogException(2,"common: SetElementsSrc",s)}}function GetElementSource(){try{return isNull(elem_basedir)?(elem_basedir=webphone_api.getbasedir2(),isNull(elem_basedir)&&(elem_basedir=""),elem_basedir):elem_basedir}catch(e){PutToDebugLogException(2,"common: GetElementSource",e)}return""}function PlayDtmfSound(e){function n(){try{t=77;try{if(t=8,p>=s.length)return;t=9,e=s[p],p++,t=10,t=11,audioElem=document.getElementById("dtmfsound"+e),t=12,isNull(audioElem)?(t=13,PutToDebugLog(2,"ERROR, PlayDtmfSound cannot get reference to audio element a")):(t=14,audioElem.load(),t=15,audioElem.play(),t=16,lastdrmfplaybacktick=GetTickCount())}catch(o){PutToDebugLogException(2,"common: PlayDtmfSound inner Timer A ("+t.toString()+")",o)}t=31,t=32,p<s.length&&(t=33,setTimeout(n,c))}catch(o){PutToDebugLogException(2,"common: PlayDtmfSound inner Timer B ("+t.toString()+")",o)}}var t=0;try{if(isNull(e))return;if(playdtmfsound<0&&(playdtmfsound=GetParameterInt("playdtmfsound",1)),playdtmfsound<1)return;e=Trim(e);var o=IsWebphoneInIframe();if(!0===o&&"Edge"===GetBrowser())return;if(e.length>1&&playdtmfsound<2)return;if(!window.HTMLAudioElement)return void PutToDebugLog(2,"WARNING, PlayDtmfSound audio html element not supported in this browser: "+GetBrowser());if(CanLog(7)&&PutToDebugLog(7,"EVENT, play dtmf "+e),"*"===e?e="x":"#"===e&&(e="y"),!0===o){if(isNull(document.getElementById("dtmfsound"+e))){var i=webphone_api.getbasedir2(),a=e;"y"===a&&(a="diez");var r='<audio id="dtmfsound'+e+'"><source src="'+i+"sound/DTMF"+a+'.ogg" type="audio/ogg"><source src="'+i+"sound/DTMF"+a+'.mp3" type="audio/mpeg"></audio>';webphone_api.$("body").append(r)}}else if(isNull(document.getElementById("dtmfsound0"))){var i=webphone_api.getbasedir2(),l='<audio id="dtmfsound0"><source src="'+i+'sound/DTMF0.ogg" type="audio/ogg"><source src="'+i+'sound/DTMF0.mp3" type="audio/mpeg"></audio><audio id="dtmfsound1"><source src="'+i+'sound/DTMF1.ogg" type="audio/ogg"><source src="'+i+'sound/DTMF1.mp3" type="audio/mpeg"></audio><audio id="dtmfsound2"><source src="'+i+'sound/DTMF2.ogg" type="audio/ogg"><source src="'+i+'sound/DTMF2.mp3" type="audio/mpeg"></audio><audio id="dtmfsound3"><source src="'+i+'sound/DTMF3.ogg" type="audio/ogg"><source src="'+i+'sound/DTMF3.mp3" type="audio/mpeg"></audio><audio id="dtmfsound4"><source src="'+i+'sound/DTMF4.ogg" type="audio/ogg"><source src="'+i+'sound/DTMF4.mp3" type="audio/mpeg"></audio><audio id="dtmfsound5"><source src="'+i+'sound/DTMF5.ogg" type="audio/ogg"><source src="'+i+'sound/DTMF5.mp3" type="audio/mpeg"></audio><audio id="dtmfsound6"><source src="'+i+'sound/DTMF6.ogg" type="audio/ogg"><source src="'+i+'sound/DTMF6.mp3" type="audio/mpeg"></audio><audio id="dtmfsound7"><source src="'+i+'sound/DTMF7.ogg" type="audio/ogg"><source src="'+i+'sound/DTMF7.mp3" type="audio/mpeg"></audio><audio id="dtmfsound8"><source src="'+i+'sound/DTMF8.ogg" type="audio/ogg"><source src="'+i+'sound/DTMF8.mp3" type="audio/mpeg"></audio><audio id="dtmfsound9"><source src="'+i+'sound/DTMF9.ogg" type="audio/ogg"><source src="'+i+'sound/DTMF9.mp3" type="audio/mpeg"></audio><audio id="dtmfsoundy"><source src="'+i+'sound/DTMFdiez.ogg" type="audio/ogg"><source src="'+i+'sound/DTMFdiez.mp3" type="audio/mpeg"></audio><audio id="dtmfsoundx"><source src="'+i+'sound/DTMFx.ogg" type="audio/ogg"><source src="'+i+'sound/DTMFx.mp3" type="audio/mpeg"></audio>';webphone_api.$("body").append(l)}t=5,e=ReplaceAll(e," ","");var s=e.split(""),p=0;t=6;var c=300;s.length>10?c=10:s.length>5?c=100:s.length>2&&(c=200),t=7,0==lastdrmfplaybacktick||GetTickCount()-lastdrmfplaybacktick>c||GetTickCount()-lastdrmfplaybacktick<0?n():setTimeout(n,c),t=6}catch(u){PutToDebugLogException(2,"common: PlayDtmfSound",u)}}function GetLogLevel(){var e=1;try{var n=GetParameter("loglevel"),t=webphone_api.parameters.loglevel;return(isNull(n)||1!==n.length&&2!==n.length||!IsNumber(n))&&(n="1"),(isNull(t)||1!==t.toString().length&&2!==t.toString().length||!IsNumber(t))&&(t="1"),StrToInt(n)>e&&(e=StrToInt(n)),(StrToInt(t)>e||0===StrToInt(t))&&(e=StrToInt(t)),e}catch(o){PutToDebugLogException(2,"common: GetLogLevel",o)}return 5}function GetHoldState(e){try{e=StrToInt(e),e<1&&(e=GetBestLine()),e=StrToInt(e);for(var n=0;n<webphone_api.global.ep.length;n++){if(StrToInt(webphone_api.global.ep[n][EP_LINE])===e){var t=webphone_api.global.ep[n][EP_HOLDSTATE];return"true"!=t&&"false"!=t&&!0!==t&&!1!==t?0!=webphone_api.global.ishold&&(0==webphone_api.global.isresume||webphone_api.global.isresume<webphone_api.global.ishold)?(PutToDebugLog(2,"ERROR, GetHoldState invalid state true: "+t.toString()+" "+e.toString()+" "+webphone_api.global.ishold.toString()+" "+webphone_api.global.isresume.toString()),!0):(PutToDebugLog(2,"ERROR, GetHoldState invalid state false: "+t.toString()+" "+e.toString()+" "+webphone_api.global.ishold.toString()+" "+webphone_api.global.isresume.toString()),!1):("true"==t||!0===t)&&(PutToDebugLog(5,"EVENT, GetHoldState: "+t.toString()+" "+e.toString()+" "+webphone_api.global.ishold.toString()+" "+webphone_api.global.isresume.toString()),!0)}}}catch(o){PutToDebugLogException(2,"common: GetHoldState",o)}return!1}function GetMuteState(e){try{e=StrToInt(e),e<1&&(e=GetBestLine()),e=StrToInt(e);for(var n=0;n<webphone_api.global.ep.length;n++){if(StrToInt(webphone_api.global.ep[n][EP_LINE])===e){var t=webphone_api.global.ep[n][EP_MUTESTATE];return"true"!=t&&"false"!=t&&!0!==t&&!1!==t&&PutToDebugLog(2,"ERROR, GetMuteState invalid state: "+t.toString()),"true"==t||!0===t}}}catch(o){PutToDebugLogException(2,"common: GetMuteState",o)}return!1}function StrictLines(){return strictlines>=0?strictlines:(strictlines=webphone_api.common.GetParameterInt("strictlines",4),(strictlines<0||strictlines>10)&&(strictlines=4),strictlines)}function LineExists(e){try{if(isNull(e)&&(e=0),e=StrToInt(e),isNull(e))return null;if(e<1&&(e=GetBestLine(),e=StrToInt(e)),isNull(e))return null;for(var n=0;n<webphone_api.global.ep.length;n++){if(StrToInt(webphone_api.global.ep[n][EP_LINE])===e)return!0}}catch(t){PutToDebugLogException(2,"common: LineExists",t)}return!0}function CheckStrictLine(e){return!(StrictLines()>4&&!LineExists(lineint))||(isNull(e)&&(e=""),PutToDebugLog(3,"WARNING, no such line "+e.toString()),!1)}function SetHoldState(e,n){try{if(isNull(e)&&(e=0),e=StrToInt(e),isNull(e)&&(e=0),e<1&&(e=GetBestLine(),e=StrToInt(e)),isNull(n)&&(n=""),"true"===n.toString()||"false"===n.toString()||(!0===n?n="true":!1===n&&(n="false")),"true"!==(n=n.toString())&&"false"!==n)return PutToDebugLog(2,"ERROR, SetHoldState invalid state value: "+n),!1;for(var t=!1,o=0;o<webphone_api.global.ep.length;o++){StrToInt(webphone_api.global.ep[o][EP_LINE])===e&&(t=!0,webphone_api.global.ep[o][EP_HOLDSTATE]!=n&&(webphone_api.global.ep[o][EP_HOLDSTATE]=n,PutToDebugLog(5,"EVENT, internal line "+e.toString()+" hold state changed to "+n.toString())))}return!1!==t||(PutToDebugLog(2,"ERROR, SetHoldState cannot find endpoint for line: "+e.toString()),LogLines(),!1)}catch(i){PutToDebugLogException(2,"common: SetHoldState",i)}return!0}function SetMuteState(e,n){try{if(isNull(e)&&(e=0),e=StrToInt(e),e<1&&(e=GetBestLine()),e=StrToInt(e),isNull(n)&&(n=""),"true"===n.toString()||"false"===n.toString()||(!0===n?n="true":!1===n&&(n="false")),"true"!==(n=n.toString())&&"false"!==n)return PutToDebugLog(2,"ERROR, SetMuteState invalid state value: "+n),!1;for(var t=!1,o=0;o<webphone_api.global.ep.length;o++){StrToInt(webphone_api.global.ep[o][EP_LINE])===e&&(t=!0,webphone_api.global.ep[o][EP_MUTESTATE]=n)}if(!1===t)return PutToDebugLog(2,"ERROR, SetMuteState cannot find endpoint for line: "+e.toString()),LogLines(),!1}catch(i){PutToDebugLogException(2,"common: SetMuteState",i)}return!0}function IsIncomingCall(e){try{if(e=StrToInt(e),e<1&&(e=GetBestLine()),e=StrToInt(e),1===webphone_api.global.ep.length&&!isNull(webphone_api.global.ep[0])){var n=webphone_api.global.ep[0][EP_INCOMING];if(1==n)return!1;if(2==n)return!0}for(var t=0;t<webphone_api.global.ep.length;t++){var o=webphone_api.global.ep[t];if(!(isNull(o)||o.length<5)){if(StrToInt(o[EP_LINE])===e){var n=o[EP_INCOMING];if(1==n)return!1;if(2==n)return!0}}}for(var t=0;t<webphone_api.global.ep.length;t++){var o=webphone_api.global.ep[t];if(!(isNull(o)||o.length<5)&&("false"===o[EP_FLAGDEL]&&"true"!==o[EP_FINISHEDSENT]&&o[EP_DISCONNECTTIME].toString().length<4)){var n=o[EP_INCOMING];if("1"==n)return!1;if("2"==n)return!0}}}catch(i){PutToDebugLogException(2,"common: IsIncomingCall",i)}return webphone_api.global.incommingCall}function GetDiscReasonFromSignaling(e){function n(e){try{if(isNull(e))return"";var n=e.indexOf("text=");if(n<0&&(n=e.indexOf("description=")),n>=0)return e=e.indexOf("text=")>=0?e.substring(n+5,e.length):e.substring(n+12,e.length),e=Trim(e),n=e.indexOf('"'),n<3&&(e=e.substring(n+1,e.length)),n=e.indexOf('"'),n>0&&(e=e.substring(0,n)),Trim(e);if((n=e.indexOf('"'))>=0)return e=e.substring(n+1,e.length),n=e.indexOf('"'),n>0&&(e=e.substring(0,n)),Trim(e)}catch(t){PutToDebugLogException(2,"notifications: GetText",t)}return""}try{if(webphone_api.global.onunload_flag)return;CanLog(2)&&PutToDebugLog(2,"EVENT, mlogic API_Getsipheader GetDiscReasonFromSignaling 1"),webphone_api.getsipheader("X-reason",function(t){var o=n(t);if(o.length>0)return void e(o);CanLog(2)&&PutToDebugLog(2,"EVENT, mlogic API_Getsipheader GetDiscReasonFromSignaling 2"),webphone_api.getsipheader("Reason",function(t){var o=n(t);if(o.length>0)return void e(o);CanLog(2)&&PutToDebugLog(2,"EVENT, mlogic API_Getsipheader GetDiscReasonFromSignaling 3"),webphone_api.getsipheader("Warning",function(t){var o=n(t);e(o)})})})}catch(t){PutToDebugLogException(2,"common: GetDiscReasonFromSignaling",t),e("")}}function onc(){try{if(!LcAc(!1,!0))return!1;if(Te()){var e=[];e.push("T"),e.push("r"),e.push("i"),e.push("a"),e.push("l"),e.push(" "),e.push("e"),e.push("x"),e.push("p"),e.push("i"),e.push("r"),e.push("e"),e.push("d");var n=e.join("");return setTimeout(function(){PutToDebugLog(1,"ERROR, "+n)},1050),setTimeout(function(){PutToDebugLog(1,"ERROR, "+n),ShowToast("ERROR, "+n,15e3)},2050),!1}if(GtUct()<1&&GtUc().length>0){var e=[];e.push("T"),e.push("r"),e.push("i"),e.push("a"),e.push("l"),e.push(" "),e.push("e"),e.push("x"),e.push("p"),e.push("i"),e.push("r"),e.push("e"),e.push("d"),e.push("_"),e.push("8");var n=e.join("");return setTimeout(function(){PutToDebugLog(1,"ERROR, "+n)},1010),!1}return!0}catch(t){PutToDebugLogException(2,"common: onc",t)}return!1}function HandleScurlSetparameters(){try{if(!0===scurlsp_called)return;if(scurlsp_called=!0,!isNull(webphone_api)&&!isNull(webphone_api.parameters))var e=webphone_api.parameters.scurl_setparameters;!isNull(e)&&e.length>3&&(CallScriptingUrl(webphone_api.parameters.scurl_setparameters,"setParameters","","","","","waitforparameters"),setTimeout(function(){!1===webphone_api.global.startendelayed_wascalled&&(PutToDebugLog(2,"WARNING, StartEngine: waiting for parameters timeout, start engine anyway"),PutToDebugLog(2,"EVENT, mlogic API_Start HandleScurlSetparameters"),webphone_api.start())},10500))}catch(n){PutToDebugLogException(2,"common: HandleScurlSetparameters",n)}}function ParseSipAccounts(){try{webphone_api.global.sipaccounts=[];var e=GetParameter("extraregisteraccounts"),n=e,t=GetExtraRegAccFromAPIparam();if(isNull(t)&&(t=""),isNull(n)||n.length<3)return;var o=null;if(n.indexOf("#")>=0?(t.length>0&&(t="#"+t),n+=t,o=n.split("#")):(t.length>0&&(t=";"+t),n+=t,o=n.split(";")),!isNull(o)&&o.length>0){for(var i=0;i<o.length;i++)o[i].length<1&&(o.splice(i,1),i--);if(isNull(o)||o.length<1)return;if(1===o.length){var a=o[0].split(",");if(!isNull(a)&&a.length>3){var r=GetParameter("serveraddress_user");(isNull(r)||r.length<1)&&(r=GetParameter("serveraddress"));var l=GetSipusername(),s=GetParameter("password"),p=!1;if(!isNull(r)&&r.length>0&&!isNull(a[ACC_SERVER])&&a[ACC_SERVER].length>0&&r!==a[ACC_SERVER]&&"[MAIN]"+r!==a[ACC_SERVER]&&(a[ACC_SERVER]=r,p=!0),!isNull(l)&&l.length>0&&!isNull(a[ACC_USER])&&a[ACC_USER].length>0&&l!==a[ACC_USER]&&(a[ACC_USER]=l,p=!0),!isNull(s)&&s.length>0&&!isNull(a[ACC_PASSWORD])&&a[ACC_PASSWORD].length>0&&s!==B64Dec(a[ACC_PASSWORD])&&(a[ACC_PASSWORD]=s,p=!0),!0===p)return PutToDebugLog(2,"EVENT, ParseSipAccounts handling special case"),n=a.join(","),void SaveParameter("extraregisteraccounts",n)}}for(var c=n,u=!0,g=0;g<o.length;g++)if(!(isNull(o[g])||o[g].length<4)){var h=o[g].split(",");if(!(isNull(h)||h.length<4)){var m=h[ACC_SERVER],d="",b="",_="",f="";if(h.length>ACC_CALLERID-2&&(d=h[ACC_CALLERID-2]),h.length>ACC_DISPLAYNAME-2&&(b=h[ACC_DISPLAYNAME-2]),h.length>ACC_PROXY-2&&(_=h[ACC_PROXY-2]),h.length>ACC_REALM-2&&(f=h[ACC_REALM-2]),isNull(d)&&(d=""),isNull(b)&&(b=""),isNull(_)&&(_=""),isNull(f)&&(f=""),!isNull(m)&&m.indexOf("[MAIN]")>=0){m=m.replace("[MAIN]",""),u=!0,SaveParameter("serveraddress_user",m);var d=GetParameter("username");GetParameter("sipusername");GetParameter("username").length>0&&GetParameter("sipusername").length<1?SaveParameter("username",h[ACC_USER]):SaveParameter("sipusername",h[ACC_USER]),SaveParameter("password",B64Dec(h[ACC_PASSWORD]));for(var i=0;i<webphone_api.global.sipaccounts.length;i++)webphone_api.global.sipaccounts[i].ismain=!1}var w=new ClassSipAccounts,v=!0;!isNull(m)&&m.indexOf("[DISABLED]")>=0?(m=m.replace("[DISABLED]",""),v=!1):h.length>=ACC_ENABLED&&"false"===h[ACC_ENABLED]&&(v=!1),w.enabled=v,w.serveraddress=m,w.username=h[ACC_USER],w.password=B64Dec(h[ACC_PASSWORD]),!CanLog(5)&&!isNull(w.password)&&w.password.length>0&&(c=c.replace(w.password,"***"));var E=3600;h.length>=ACC_IVAL&&!isNull(h[ACC_IVAL])&&IsNumber(h[ACC_IVAL])&&(E=h[ACC_IVAL]),w.ival=StrToInt(E),w.ismain=!0===u,u=!1,w.callerid=d,w.displayname=b,w.proxyaddress=_,w.realm=f,webphone_api.global.sipaccounts.push(w)}}
CanLog(2)&&(webphone_api.global.loglevel>=7||!0===webphone_api.global.isdebugversion&&webphone_api.global.loglevel>=5?PutToDebugLog(2,"EVENT, ParseSipAccounts extraregisteraccounts: "+c):PutToDebugLog(2,"EVENT, ParseSipAccounts extraregisteraccounts "+c.length.toString()))}return}catch(P){PutToDebugLogException(2,"common: ParseSipAccounts",P)}webphone_api.global.sipaccounts=[]}function SaveSipAccounts(){try{if(isNull(webphone_api.global.sipaccounts)||webphone_api.global.sipaccounts.length<1)return void SaveParameter("extraregisteraccounts","");var e=GetExtraRegAccFromAPIparam();isNull(e)&&(e="");var n=[];n=e.indexOf("#")>=0?e.split("#"):e.split(";"),isNull(n)&&(n=[]);for(var t=0;t<n.length;t++)(isNull(n[t])||n[t].length<5)&&(n.splice(t,1),t--);for(var o="",t=0;t<webphone_api.global.sipaccounts.length;t++){var i=webphone_api.global.sipaccounts[t];if(!(isNull(i)||i.length<4)){var a=!1;if(n.length>0)for(var r=0;r<n.length;r++){var l=n[r];if(i.username===l.username&&B64Dec(i.password)===B64Dec(l.password)&&i.ival===l.ival&&i.serveraddress===l.serveraddress){a=!0;break}}if(!0!==a){if(!0===i.ismain&&(o+="[MAIN]"),!1===i.enabled&&(o+="[DISABLED]"),!0===i.ismain){var s=i.serveraddress,p=i.username,c=B64Dec(i.password),u=i.ival,g=i.callerid,h=i.displayname,m=i.proxyaddress,d=i.realm;if(isNull(s)&&(s=""),isNull(p)&&(p=""),isNull(c)&&(c=""),isNull(u)&&(u=""),isNull(g)&&(g=""),isNull(h)&&(h=""),isNull(m)&&(m=""),isNull(d)&&(d=""),s.length>0&&SaveParameter("serveraddress_user",s),c.length>0&&SaveParameter("password",c),u.length>0&&IsNumber(u)&&SaveParameter("registerinterval",u),h.length>0&&SaveParameter("displayname",h),m.length>0&&SaveParameter("proxyaddress",m),d.length>0&&SaveParameter("realm",d),p.length>0){var b=!1;GetParameter("sipusername").length>0&&(SaveParameter("sipusername",p),b=!0),GetParameter("username").length>0&&!isNull(g)&&g.length>0&&(SaveParameter("username",g),b=!0),b||SaveParameter("username",p),g.length>0&&GetParameter("sipusername").length>0&&GetParameter("username").length>0&&SaveParameter("username",g)}}var _=i.password;(_.indexOf(";")>=0||_.indexOf(",")>=0||_.indexOf("#")>=0)&&0!=_.indexOf("_BASE64_")&&(_="_BASE64_"+B64Enc(_));var f=i.serveraddress,w=i.username,v=i.ival.toString(),E=i.callerid,P=i.displayname,T=i.proxyaddress,S=i.realm;f.indexOf(";")>=0&&(f=f.replace(";","")),f.indexOf(",")>=0&&(f=f.replace(",","")),f.indexOf("#")>=0&&(f=f.replace("#","")),w.indexOf(";")>=0&&(w=w.replace(";","")),w.indexOf(",")>=0&&(w=w.replace(",","")),w.indexOf("#")>=0&&(w=w.replace("#","")),v.indexOf(";")>=0&&(v=v.replace(";","")),v.indexOf(",")>=0&&(v=v.replace(",","")),v.indexOf("#")>=0&&(v=v.replace("#","")),E.indexOf(";")>=0&&(E=E.replace(";","")),E.indexOf(",")>=0&&(E=E.replace(",","")),E.indexOf("#")>=0&&(E=E.replace("#","")),P.indexOf(";")>=0&&(P=P.replace(";"," ")),P.indexOf(",")>=0&&(P=P.replace(","," ")),P.indexOf("#")>=0&&(P=P.replace("#"," ")),T.indexOf(";")>=0&&(T=T.replace(";","")),T.indexOf(",")>=0&&(T=T.replace(",","")),T.indexOf("#")>=0&&(T=T.replace("#","")),S.indexOf(";")>=0&&(S=S.replace(";","")),S.indexOf(",")>=0&&(S=S.replace(",","")),S.indexOf("#")>=0&&(S=S.replace("#","")),o=o+f+","+w+","+_+","+v+","+E+","+P+","+T+","+S+",#"}}}SaveParameter("extraregisteraccounts",o)}catch(N){PutToDebugLogException(2,"common: SaveSipAccounts",N)}}function GetExtraRegAccFromAPIparam(){try{if("undefined"!=typeof webphone_api.parameters.extraregisteraccounts&&null!==webphone_api.parameters.extraregisteraccounts&&webphone_api.parameters.extraregisteraccounts.length>5){var e=webphone_api.parameters.extraregisteraccounts;if(e=ReplaceAll(e," ",""),!isNull(e)||e.length>5)return e}}catch(n){PutToDebugLogException(2,"common: GetExtraRegAccFromAPIparam",n)}return""}function AddOneAcc(e,n,t,o,i,a,r,l,s,p,c){try{if(isNull(webphone_api.global.sipaccounts)&&(webphone_api.global.sipaccounts=[]),isNull(n)||n.length<1||isNull(t)||t.length<1)return void PutToDebugLog(2,"ERROR, AddOneAcc invalid username: "+n+"; or password: "+t);if((isNull(o)||!1===IsNumber(o))&&(o="3600"),isNull(l)&&(l=""),isNull(s)&&(s=""),isNull(p)&&(p=""),isNull(c)&&(c=""),l=Trim(l),l.length<1&&(l=n),!0===r&&1===webphone_api.global.sipaccounts.length){webphone_api.global.sipaccounts=[];var u=new ClassSipAccounts;return u.serveraddress=e,u.username=n,u.password=t,u.ival=StrToInt(o),u.enabled=i,u.ismain=!0,u.callerid=l,u.displayname=s,u.proxyaddress=p,u.realm=c,webphone_api.global.sipaccounts.push(u),void SaveSipAccounts()}for(var g=!1,h=0;h<webphone_api.global.sipaccounts.length;h++)if(!isNull(webphone_api.global.sipaccounts[h])&&webphone_api.global.sipaccounts[h].username===n&&webphone_api.global.sipaccounts[h].password===t){var m=webphone_api.global.sipaccounts[h].serveraddress;if(isNull(m)&&(m=""),isNull(e)&&(e=""),m===e){webphone_api.global.sipaccounts[h].serveraddress=e,webphone_api.global.sipaccounts[h].ival=o,webphone_api.global.sipaccounts[h].enabled=i,webphone_api.global.sipaccounts[h].ismain=a,webphone_api.global.sipaccounts[h].callerid=l,webphone_api.global.sipaccounts[h].displayname=s,webphone_api.global.sipaccounts[h].proxyaddress=p,webphone_api.global.sipaccounts[h].realm=c,g=!0;break}}if(!0===g){if(!0===a)for(var h=0;h<webphone_api.global.sipaccounts.length;h++)isNull(webphone_api.global.sipaccounts[h])||webphone_api.global.sipaccounts[h].username===n&&webphone_api.global.sipaccounts[h].password===t||(webphone_api.global.sipaccounts[h].ismain=!1)}else{var u=new ClassSipAccounts;u.serveraddress=e,u.username=n,u.password=t,u.ival=StrToInt(o),u.enabled="true"===i||!0===i,u.ismain="true"===a||!0===a,u.callerid=l,u.displayname=s,u.proxyaddress=p,u.realm=c,webphone_api.global.sipaccounts.push(u),PutToDebugLog(2,"EVENT, AddOneAcc: serveraddress:"+e+" username: "+n+" password: "+t+" regival: "+o+" enabled: "+i+" ismain: "+a)}SaveSipAccounts()}catch(d){PutToDebugLogException(2,"common: AddOneAcc",d)}}function GetOtherPartyName(e,n){e>1||(CanLog(2)&&PutToDebugLog(2,"EVENT, mlogic API_Getsipheader GetOtherPartyName"),webphone_api.getsipheader("Contact",function(e){try{if(isNull(e)||e.length<1)return;var t=e.indexOf("<");t>0&&(e=e.substring(0,t),e=ReplaceAll(e,'"',""),e=Trim(e),e.length>0&&e!==n&&e!==GetParameter("displayname")&&(webphone_api.global.callName=e))}catch(o){PutToDebugLogException(2,"common: GetOtherPartyName",o)}}))}function GetMaxLogLevel(){try{if(!isNull(webphone_api.parameters.maxloglevel)&&IsNumber(webphone_api.parameters.maxloglevel)){var e=StrToInt(webphone_api.parameters.maxloglevel);return e>1e3&&(e=1e3),e<1&&(e=5),e}}catch(n){PutToDebugLogException(2,"common: GetMaxLogLevel",n)}return 1e3}function HandleOfflineMessages(e){try{if(isNull(e)||e.indexOf("XOFFMESSAGE:")<0)return;var n=e.indexOf("XOFFMESSAGE:");e=e.substring(n+12);var t=e.split("XOFFMESSAGE:");if(!isNull(t)&&t.length>0)for(var o=0;o<t.length;o++)if(!(isNull(t[o])||(n=t[o].indexOf(":"))<0)){var i=Trim(t[o].substring(0,n)),a=Trim(t[o].substring(n+1));"undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications?webphone_api.notifications.OnMessageReceived(i,a,-1):console&&console.log&&console.log("ERROR, common HandleOfflineMessages webphone_api.notifications is not defined")}}catch(r){PutToDebugLogException(2,"common: HandleOfflineMessages",r)}}function RequestBrowserNotificationPermission(e,n,t,o,i){try{isNull(i)&&(i=0);var a=GetParameterInt("askfornotifpermission",-1);if(0==(a=webphone_api.common.GetParameterInt("asknotifpermission",a)))return void(CanLog(5)&&PutToDebugLog(5,"EVENT,RequestBrowserNotificationPermission: not needed"));if(4==a&&i>=3&&SaveParameter("asknotifpermission","1"),!window.Notification||!Notification.permission)return void PutToDebugLog(2,"WARNING,RequestBrowserNotificationPermission: Notification not supported in this environment, browser: "+GetBrowser()+"; os: "+GetOs());"granted"!==Notification.permission?Notification.requestPermission(function(r){"granted"===r||"default"===r?(CanLog(3)&&PutToDebugLog(3,"EVENT,RequestBrowserNotificationPermission: granted"),2!=a&&4!=a||SaveParameter("asknotifpermission","1"),e(n,t,o)):"denied"===r?(CanLog(3)&&PutToDebugLog(3,"EVENT,RequestBrowserNotificationPermission: denied"),i<3&&(a<0||2==a)&&SaveParameter("asknotifpermission","4")):(CanLog(3)&&PutToDebugLog(3,"WARNING,RequestBrowserNotificationPermission: "+Notification.permission),i<3&&(a<0||2==a)&&SaveParameter("asknotifpermission","4"),e(n,t,o))}):(e(n,t,o),2!=a&&4!=a||SaveParameter("asknotifpermission","1"))}catch(r){PutToDebugLogException(2,"common: RequestBrowserNotificationPermission",r)}}function CanUseIncomingCallNot(){try{if(!0===IsWindowsSoftphone())return!1;var e=GetParameterInt("incomingcallpopup",1);if(e<1)return!1;if(1===e){var n=!1,t=GetParameterInt("enableautoaccept",1);if(0===t?n=!1:3===t&&(n=!0),!0===(n=GetParameterBool("autoaccept",n)))return!1;if(getuseengine()!==webphone_api.global.ENGINE_JAVA&&!1===BrowserWindowIsActive())return!0}else{if(2!==e)return 3===e||(PutToDebugLog(2,"ERROR, incomingcallpopup invalid value: "+e),!1);if(getuseengine()!==webphone_api.global.ENGINE_JAVA)return!0}}catch(o){PutToDebugLogException(2,"common: CanUseIncomingCallNot",o)}return!1}function ShowIncomingCallNotification(e,n,t,o,i){try{if(!0===o)return CanLog(5)&&PutToDebugLog(5,"EVENT, hide display incoming call notification"),isNull(callnotification)||callnotification.close(),void(callnotification=null);if(!CanUseIncomingCallNot())return void(CanLog(5)&&PutToDebugLog(5,"EVENT, skip display incoming call notification"));CanLog(5)&&(isNull(e)&&(e=""),isNull(n)&&(n=""),PutToDebugLog(5,"EVENT, display incoming call notification: "+e+" "+n)),RequestBrowserNotificationPermission(function(e,n,t){window.Notification&&Notification.permission&&"granted"===Notification.permission&&(isNull(e)&&(e=""),isNull(n)&&(n=""),isNull(t)&&(t=""),isNull(i)&&(i=""),isNull(callnotification)||callnotification.close(),callnotification=null,callnotification=new Notification(e,{icon:t,body:n,image:i}),callnotification.onclick=function(){window.focus(),isNull(callnotification)||callnotification.close(),callnotification=null})},e,n,t,1)}catch(a){PutToDebugLogException(2,"common: ShowIncomingCallNotification",a)}}function WebphoneIsLoaded(){try{HandleBrowserWindowActive(),GetContacts(function(e){PutToDebugLog(4,"EVENT, common: WebphoneIsLoaded GetContacts: "+e)}),webphone_api.global.apistartstate=0,webphone_api.global.apistarttick=0,webphone_api.global.wnotstartedsession=!1}catch(e){PutToDebugLogException(2,"common: WebphoneIsLoaded",e)}}function BrowserWindowIsActive(){return!1!==browserWindowActive}function HandleBrowserWindowActive(){try{webphone_api.$(window).focus(function(){browserWindowActive=!0}).blur(function(){browserWindowActive=!1})}catch(e){PutToDebugLogException(2,"common: HandleBrowserWindowActive",e)}}function DownloadContacts(){try{ShowToast(webphone_api.stringres.get("sync_message"),5e3);var e=GetSipusername(!0),n=GetParameter("serveraddress_user");!isNull(n)&&n.length>0&&(e=e+"_"+n),e+=".dat";var t=GetParameter("contactimport_url");(isNull(t)||t.length<3)&&(t="https://www.mizu-voip.com/G/srvct/"),t.lastIndexOf("/")<t.length-1&&(t+="/"),t+=encodeURIComponent(e),PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("sync_contacts_started")),UriParser(t,"","","","","downloadcontacts"),setTimeout(function(){cleartimer=!0},6e4),reloadtimer=setInterval(function(){!0===cleartimer&&(clearInterval(reloadtimer),reloadtimer=null),!0===webphone_api.global.reloadcontactsaftersync&&(clearInterval(reloadtimer),reloadtimer=null,webphone_api.global.reloadcontactsaftersync=!1,!0===webphone_api.global.isContactslistStarted&&webphone_api._contactslist.PopulateList(!1))})}catch(o){PutToDebugLogException(2,"common: DownloadContacts",o)}}function ArrayBufferToString(e){try{if(isNull(e))return"null";if("string"===typeof e)return e.toString();var n="",t=new Uint8Array(e);if(isNull(t))return"null";for(var o=t.byteLength,i=0;i<o;i++)n+=String.fromCharCode(t[i]);return isNull(n)?"null":n}catch(a){PutToDebugLogException(2,"common: ArrayBufferToString",a)}return"null"}function Translate(e){return webphone_api.translations.Translate(e)}function GetAutostart(){try{var e=GetParameterInt("autostart",1);return!isNull(webphone_api.parameters.autostart)&&webphone_api.parameters.autostart.toString().length>0&&(e=webphone_api.parameters.autostart.toString(),e=Trim(e),"true"===e||"yes"===e?e=1:"false"!==e&&"no"!==e||(e=0)),e=StrToIntDef(e,1)}catch(n){PutToDebugLogException(2,"common: GetAutostart",n)}return 1}function CanIUseVideo(){try{if(!0===HideSettings("video",webphone_api.stringres.get("sett_display_name_video"),"video",!0))return!1;if(!1===Glvd())return!1;if("0"===GetParameter2("video"))return!1;if("1"===GetParameter2("video")||"2"===GetParameter2("video"))return!0;if(getuseengine()===webphone_api.global.ENGINE_WEBRTC||!0===CanIUseWebRTC()||!0===IsWindowsSoftphone())return!0}catch(e){PutToDebugLogException(2,"common: CanIUseVideo",e)}return!1}function CanIUseScreensharing(){try{if(!0===HideSettings("screensharing","","screensharing",!0))return!1;if(!1===Glss())return!1;if("Android"===GetOs()||"iOS"===GetOs())return!1;if(!(navigator.getDisplayMedia||navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia))return!1;var e=GetParameter2("screensharing");if("2"===e||"1"===e&&(getuseengine()===webphone_api.global.ENGINE_WEBRTC||!0===CanIUseWebRTC()||!0===IsWindowsSoftphone()))return!0}catch(n){PutToDebugLogException(2,"common: CanIUseScreensharing",n)}return!1}function SwitchToEngine(e){try{PutToDebugLog(2,"EVENT, common: SwitchToEngine: "+e+"; reset useengine"),ResetEngineClicked(),ResetSelEngine();var n=GetEngine(e);isNull(n)||(n.clicked=2,SetEngine(e,n),ChooseEngineLogic2(e),EngineSelect(1,25)),PutToDebugLog(2,"EVENT, mlogic API_Start SwitchToEngine"),webphone_api.start()}catch(t){PutToDebugLogException(2,"common: SwitchToEngine",t)}}function ExitVideoMode(e){try{if(!1===IsWindowsSoftphone())return;PutToDebugLog(2,"EVENT, ExitVideoMode: "+e),SwitchToEngine(webphone_api.global.ENGINE_SERVICE);1===GetParameterInt("videomode",0)&&SaveParameter("videomode","2");WinSoftphoneHttpReq(AddJscommport(webphone_api.global.WIN_SOFTPHONE_URL)+"?extcmd_exitvideo","GET","","",function(e){PutToDebugLog(2,"EVENT, common: Exit response: "+e)})}catch(n){PutToDebugLogException(2,"common: ExitVideoMode",n)}}function ClassCustomMenus(){this.label,this.action,this.data}function GetCustomMenus(){try{var e=GetParameter("menu_url");if(isNull(e)||e.length<3)return;var n=GetSipusername(!0),t=GetParameter("password");e=e.replace("[USERNAME]",n),e=e.replace("USERNAME",n),e=e.replace("[PASSWORD]",t),e=e.replace("PASSWORD",t),e=e.replace("PWD",t),e=e.replace("DEVICEID",GetDeviceId()),e=e.replace("BRANDNAME",encodeURIComponent(GetBrandName()));var o="http://";IsHttps()&&(o="https://");var i="rtc.mizu-voip.com";if(webphone_api.global.pgw_selected>=0){var a=PGW_Get(webphone_api.global.pgw_selected,PGW_ADDRESS);a.length>0&&(i=a)}var r=GetConfig("mainaport");!isNull(r)&&r.length>0&&(AddressHasPort(i)&&(i=GetIPFromAddressSimple(i)),i=GetIPEnclosed(i)+":"+r),PutToDebugLog(4,"EVENT, GetCustomMenus url: "+e);var l=decodeURIComponent(e);l=encodeURIComponent(l);var s=o+i+"/mvapireq/jppget?url="+l+"&callback=cbf";PutToDebugLog(4,"EVENT, GetCustomMenus url JSONP: "+s),webphone_api.$.getJSON(s,function(e){var n="";isNull(e)?PutToDebugLog(2,"ERROR, HttpRequest GetCustomMenus response is NULL"):n=e.contents,HttpResponseHandler(n,"get_custom_menu")})}catch(p){PutToDebugLogException(2,"common: GetCustomMenus",p)}}function ProcessCustomMenu(e){try{if(webphone_api.global.custmenusL=null,webphone_api.global.custmenusL=[],isNull(e)||e.length<5)return;var n=-1,t=e;if(n=t.indexOf("<ERROR>"),n<0&&(n=t.indexOf("<Error>")),t.toLowerCase().indexOf("disabled")>0&&n>0&&(t=t.substring(n+7),n=t.indexOf("</ERROR>"),n>0&&(t=t.substring(0,n)),isNull(t)&&(t=""),t=Trim(t),t.length>0))return PutToDebugLog(2,"ERROR, ProcessCustomMenu returned error: "+t),PutToDebugLog(1,"ERROR, "+t),void AlertDialog("ERROR",t);if((n=e.indexOf("<PROTOCOL>"))>0){var o=e.substring(n+12);n=o.indexOf("</PROTOCOL>"),n>0&&(o=o.substring(0,n),isNull(o)&&(o=""),o=Trim(o),o.length>0&&(PutToDebugLog(2,"EVENT, ProcessCustomMenu set custom received transport protocol: "+o),"udp"===o.toLowerCase()?SaveParameter("transport","0"):"tcp"===o.toLowerCase()?SaveParameter("transport","1"):"tls"===o.toLowerCase()&&SaveParameter("transport","2")))}if((n=e.indexOf("<SIP_SERVER>"))>0){var i=e.substring(n+12);n=i.indexOf("</SIP_SERVER>"),n>0&&(i=i.substring(0,n),isNull(i)&&(i=""),i=Trim(i),i.length>0&&(PutToDebugLog(2,"EVENT, ProcessCustomMenu set custom received serveraddress: "+i),SaveParameter("serveraddress_user",i)))}if((n=t.indexOf("<BUTTONS>"))<0)return;if(t=t.substring(n+9),(n=t.indexOf("</BUTTONS>"))<1)return;t=t.substring(0,n),t=Trim(t);var a=t.split("<BUTTON");if(isNull(a)||a.length<1)return;for(var r=0;r<a.length;r++)if(null!=a[r]){var l=a[r].toString();if(!(l.length<5)){l=ReplaceAll(l,'="',"=");var s="",p="",c="";n=l.indexOf("label="),n>=0&&(s=l.substring(n+6),s=Trim(s),n=s.indexOf('"'),n<0&&(n=s.indexOf(" ")),s=n>0?Trim(s.substring(0,n)):"");var u=!1;if(n=l.indexOf("action="),n>=0&&(p=l.substring(n+7),p=Trim(p),n=p.indexOf('"'),n<0&&(n=p.indexOf(" ")),n>0?(p=Trim(p.substring(0,n)),u=!0):p=""),n=l.indexOf("data="),n>=0&&(c=l.substring(n+5),c=Trim(c),n=c.indexOf('"'),n<0&&(n=c.indexOf(" ")),n>0?(c=Trim(c.substring(0,n)),u||(0===c.toLowerCase().indexOf("http:")||0===c.toLowerCase().indexOf("https:")?p="link":0==c.indexOf("chat:")?(c=Trim(c.substring(c.indexOf("chat:"))),p="chat"):0==c.indexOf("call:")?(c=Trim(c.substring(c.indexOf("call:"))),p="call"):c.length>0&&(p="call"))):c=""),!isNull(s)&&s.length>0&&!isNull(p)&&p.length>0&&!isNull(c)&&c.length>0){var g=new ClassCustomMenus;g.label=s,g.action=p,g.data=c,webphone_api.global.custmenusL.push(g)}}}}catch(h){PutToDebugLogException(2,"common: ProcessCustomMenu",h)}}function GetTextLengthThatFits(e,n,t,o,i,a){if(isNull(n)||n.length<1)return 0;var r=n.length;try{a===undefined&&(a="normal");var l=webphone_api.$("<div>").addClass("auxdiv").css({position:"absolute",height:"auto",marginLeft:"-1000px",marginTop:"-1000px",fontWeight:a,width:"auto"}).appendTo(webphone_api.$("#"+e)).html(n),s=l.width()+1,p=n;if(s>t){for(var c=1,u=1,g=n.length,h=0;u<=g;)c=u+g>>1,p=n.slice(0,c),l.html(p),s=l.width()+1,s<=t?(h=c,u=c+1):g=c-1;p=n.slice(0,h)}return webphone_api.$(".auxdiv").remove(),l.remove(),p.length}catch(m){PutToDebugLogException(2,"common: GetTextLengthThatFits",m)}return r}function HostToIPQuick(e){var n="";return e=NormalizeInput(GetDomainPart(e)),isNull(dticache)&&LoadDomainToIpCache(),isNull(dticache)||isNull(dticache[e.toLowerCase()])||(n=dticache[e.toLowerCase()],!IsIPAddrress(n))?HostToIPQuickSrv(e):n}function HostToIPQuickSrv(e){var n="";return e=NormalizeInput(GetDomainPart(e)),isNull(dtisrvcache)||isNull(dtisrvcache[e.toLowerCase()])||(n=dtisrvcache[e.toLowerCase()],!IsIPAddrress(n))?e===GetConfig("knowndomain")&&!isNull(GetConfig("knownip"))&&(n=GetConfig("knownip"),IsIPAddrress(n))?n:e!==GetConfig("serveraddress_user")&&e!==GetConfig("serverdomain")&&e!==GetConfig("serveraddress")||isNull(GetConfig("serverip"))||(n=NormalizeInput(GetDomainPart(GetConfig("serverip"))),!IsIPAddrress(n))?"":n:n}function DomainToIpServer(e,n){function t(e,t){if(!isNull(dreqsrvcache[e])){try{for(var o=dreqsrvcache[e];o.length>0;)isNull(o[0])||"function"!=typeof o[0]||o[0](t),o.splice(0,1)}catch(i){PutToDebugLogException(2,"common: domaintoipServer HanleCallback",i);try{n("")}catch(a){}}delete dreqsrvcache[e]}}try{if(isNull(e)||e.length<3)return n(""),"";if(e=NormalizeInput(GetDomainPart(e)),!0===IsIPAddrress(e))return n(e),e;var o=e.lastIndexOf(":");o>0&&(e=e.substring(0,o)),o=e.indexOf("?"),o>0&&(e=e.substring(0,o)),o=e.indexOf("://"),o>0&&(e=e.substring(o+3,e.length)),o=e.indexOf("//"),o>0&&(e=e.substring(o+2,e.length)),o=e.indexOf("/"),o>0&&(e=e.substring(0,o));var i="";if(i=HostToIPQuickSrv(e),i.length>0)return n(i),i;if(!0===IsLocalUpperServer())return n(e),e;if(isNull(dtisrvcache)){dtisrvcache={};var a=null;if((isNull(dtistrSrv)||dtistrSrv.indexOf("mnt.mizu-voip.com")<0)&&(!isNull(dtistrSrv)&&dtistrSrv.length>0&&(dtistrSrv+="##"),dtistrSrv+="www.mizu-voip.com,148.251.28.178##www.webvoipphone.com,159.69.64.139##mnt.mizu-voip.com,148.251.28.180##rtc.mizu-voip.com,148.251.28.181##usrtcx.webvoipphone.com,192.145.38.88##usrtc.webvoipphone.com,107.174.212.78"),!isNull(dtistrSrv)&&dtistrSrv.length>0&&(a=dtistrSrv.split("##")),!isNull(a)&&a.length>0)for(var r=0;r<a.length;r++)if(!(isNull(a[r])||a[r].indexOf(",")<0)){var l=a[r].substring(0,a[r].indexOf(",")),s=a[r].substring(a[r].indexOf(",")+1);!isNull(l)&&l.length>0&&!isNull(s)&&s.length>0&&isNull(dtisrvcache[l.toLowerCase()])&&(dtisrvcache[l.toLowerCase()]=s)}}if(i="",!isNull(dtisrvcache[e.toLowerCase()]))return i=dtisrvcache[e.toLowerCase()],n(i),i;if(e===GetConfig("knowndomain")&&!isNull(GetConfig("knownip"))&&IsIPAddrress(GetConfig("knownip")))return i=GetConfig("knownip"),n(i),i;if(!isNull(dreqsrvcache[e])){var p=dreqsrvcache[e];return p.push(n),dreqsrvcache[e]=p,""}var p=[];if(p.push(n),dreqsrvcache[e]=p,0===GetParameterInt("altexternpublicip",1))return"";var c="http://mnt.mizu-voip.com/mmexreqvitserverjrsktt/xhosttoip/?host=DOMAIN&now=1";!0===IsHttps()&&(c=c.replace("http:","https:")),c=c.replace("DOMAIN",encodeURIComponent(e));var u=new XMLHttpRequest;if("withCredentials"in u)u.open("GET",c,!0);else{if("undefined"==typeof XDomainRequest){u=null,PutToDebugLog(2,"ERROR, common: domaintoipServer, CORS not supported");var i=HostToIPQuick(e);return void(isNull(i)||i.length<1?n(""):t(e,i))}u=new XDomainRequest,u.open("GET",c)}u.onload=function(){try{if(isNull(u)||isNull(u.responseText)||u.responseText.length<1){PutToDebugLog(2,"ERROR, domaintoipServer response is NULL");var o=HostToIPQuick(e);return void(isNull(o)||o.length<1?n(""):t(e,o))}var i=u.responseText;if(i.indexOf("OK:")>=0){i=i.replace("OK:","");var a=i.indexOf(":");a>0&&(i=i.substring(a+1)),isNull(i)&&(i=""),i=Trim(i),CanLog(4)&&PutToDebugLog(4,"EVENT, domaintoipServer response is: "+i),dtisrvcache[e.toLowerCase()]=i,t(e,i);var r="";for(var l in dtisrvcache)!isNull(l)&&l.length>0&&!isNull(dtisrvcache[l.toLowerCase()])&&dtisrvcache[l.toLowerCase()].length>0&&(r.length>0&&(r+="##"),r=r+l+","+dtisrvcache[l.toLowerCase()]);SaveParameter("domaintoip_cache"+webphone_api.global.versionstr,r)}else{PutToDebugLog(2,"ERROR, domaintoipServer response is: "+i),dtisrvcache[e.toLowerCase()]=i;var o=HostToIPQuick(e);(isNull(o)||o.length<1)&&(o="ERROR: "+i),t(e,o)}}catch(s){PutToDebugLogException(2,"common: domaintoipServer.onload inner",s),n("")}},u.onerror=function(n){var o="";isNull(n)||(o=n.toString(),isNull(n.target)||(o=isNull(n.target.status)?o+" "+n.target.toString():o+" "+n.target.status.toString())),PutToDebugLog(2,"ERROR, domaintoipServer request failed: "+o);var i=HostToIPQuick(e);(isNull(i)||i.length<1)&&(i="ERROR, domaintoipServer request failed: "+o),t(e,i)},u.timeout=2e3,u.ontimeout=function(n){PutToDebugLog(2,"ERROR, domaintoipServer: Timeout");var o=HostToIPQuick(e);(isNull(o)||o.length<1)&&(o="ERROR, domaintoipServer: Timeout"),t(e,o)},u.send()}catch(g){PutToDebugLogException(2,"common: domaintoipServer",g),n("ERROR, domaintoipServer failed")}}function LoadDomainToIpCache(){if(isNull(dticache)){dticache={};var e=GetParameter("domaintoip_cache"+webphone_api.global.versionstr),n=null;if((isNull(e)||e.indexOf("mnt.mizu-voip.com")<0)&&(!isNull(e)&&e.length>0&&(e+="##"),e+="www.mizu-voip.com,148.251.28.178##www.webvoipphone.com,178.63.153.107##mnt.mizu-voip.com,148.251.28.180##rtc.mizu-voip.com,148.251.28.181##usrtcx.webvoipphone.com,192.145.38.88##usrtc.webvoipphone.com,107.174.212.78##voip.mizu-voip.com,159.69.64.138##fcm.webvoipphone.com,148.251.28.182"),!isNull(e)&&e.length>0&&(n=e.split("##")),!isNull(n)&&n.length>0)for(var t=0;t<n.length;t++)if(!(isNull(n[t])||n[t].indexOf(",")<0)){var o=n[t].substring(0,n[t].indexOf(",")),i=n[t].substring(n[t].indexOf(",")+1);!isNull(o)&&o.length>0&&!isNull(i)&&i.length>0&&isNull(dticache[o])&&(dticache[o]=i)}}}function DomainToIp(e,n){function t(e,n){if(!isNull(dreqcache[e])){var t=dreqcache[e],o=n;for(0!=n.indexOf("ERROR")&&0!=n.indexOf("WARNING")||(o="");t.length>0;)isNull(t[0])||"function"!=typeof t[0]||t[0](o),t.splice(0,1);delete dreqcache[e]}}try{if(isNull(e))return n(""),"";if(e.length<3)return n(e),"";if(0==e.toLowerCase().indexOf("error"))return n(""),"";if(e.indexOf(".")<0)return n(e),IsIPAddrress(e)?e:"";if(e=NormalizeInput(GetDomainPart(e)),!0===IsIPAddrress(e))return n(e),e;var o=e.lastIndexOf(":");o>0&&(e=e.substring(0,o)),o=e.indexOf("?"),o>0&&(e=e.substring(0,o)),o=e.indexOf("://"),o>0&&(e=e.substring(o+3,e.length)),o=e.indexOf("//"),o>0&&(e=e.substring(o+2,e.length)),o=e.indexOf("/"),o>0&&(e=e.substring(0,o));var i="";if(i=HostToIPQuick(e),i.length>0)return n(i),i;if(!0===IsLocalUpperServer())return n(e),e;if(isNull(dticache)&&LoadDomainToIpCache(),i=dticache[e],!isNull(i))return n(i),t(e,i),i;if(!isNull(dreqcache[e])){var a=dreqcache[e];return a.push(n),dreqcache[e]=a,""}var a=[];if(a.push(n),dreqcache[e]=a,0===GetParameterInt("altexternpublicip",1))return"";var r="http://mnt.mizu-voip.com/mmexreqvitserverjrsktt/xhosttoip/?host=DOMAIN&now=1";!0===IsHttps()&&(r=r.replace("http:","https:")),r=r.replace("DOMAIN",encodeURIComponent(e));var l=new XMLHttpRequest;if("withCredentials"in l)l.open("GET",r,!0);else{if("undefined"==typeof XDomainRequest)return l=null,PutToDebugLog(2,"ERROR, common: domaintoip, CORS not supported"),void n("");l=new XDomainRequest,l.open("GET",r)}l.onload=function(){try{if(isNull(l)||isNull(l.responseText)||l.responseText.length<1)return PutToDebugLog(2,"ERROR, domaintoip response is NULL for "+e),void n("");var o=l.responseText;if(o.indexOf("OK:")>=0){o=o.replace("OK:","");var i=o.indexOf(":");i>0&&(o=o.substring(i+1)),isNull(o)&&(o=""),o=Trim(o),PutToDebugLog(4,"EVENT, domaintoip response is: "+NormalizeInput2(o,3)+" for "+e),dticache[e]=o,n(o),t(e,o);var a="";for(var r in dticache)!isNull(r)&&r.length>0&&!isNull(dticache[r])&&dticache[r].length>0&&(a.length>0&&(a+="##"),a=a+r+","+dticache[r]);SaveParameter("domaintoip_cache"+webphone_api.global.versionstr,a)}else if((isNull(dticache[e])||dticache[e].length<1)&&(dticache[e]=e),o.indexOf("cannotresolve")>=0?PutToDebugLog(2,"EVENT, domaintoip response is: cannotresolve for "+e):PutToDebugLog(2,"WARNING, domaintoip response is: "+NormalizeInput2(o,3)+" for "+e),n(""),t(e,"ERROR: "+o),o.indexOf("cannotresolve")>=0){var a="";for(var r in dticache)!isNull(r)&&r.length>0&&!isNull(dticache[r])&&dticache[r].length>0&&(a.length>0&&(a+="##"),a=a+r+","+dticache[r]);SaveParameter("domaintoip_cache"+webphone_api.global.versionstr,a)}}catch(s){PutToDebugLogException(2,"common: domaintoip.onload inner",s),n("")}},l.onerror=function(o){var i="";isNull(o)||(i=o.toString(),isNull(o.target)||(i=isNull(o.target.status)?i+" "+o.target.toString():i+" "+o.target.status.toString())),PutToDebugLog(2,"ERROR, domaintoip request failed: "+i+" for "+e),n(""),t(e,"ERROR, domaintoip request failed: "+i)},l.timeout=4e3,l.ontimeout=function(o){PutToDebugLog(2,"ERROR, domaintoip: Timeout"),n(""),t(e,"ERROR, domaintoip: Timeout")},l.send()}catch(s){PutToDebugLogException(2,"common: domaintoip",s),n("domaintoip failed")}}function HandleSipProtocol(e){try{if(isNull(e)||e.length<1)return e;if(0!==e.indexOf("REGISTER sip:")&&0!==e.indexOf("INVITE sip"))return e;var n=GetParameterInt("sipprotocol",0);if(0!==n&&(1===n?(e=ReplaceAll(e,"sips:","sip:"),e=ReplaceAll(e,"WSS","WS"),e=ReplaceAll(e,"wss","ws")):2===n&&(e=ReplaceAll(e,"sip:","sips:"),e=ReplaceAll(e,"WS","WSS"),e=ReplaceAll(e,"ws","wss"))),0!==e.indexOf("REGISTER sip:"))return e;if(GetParameterInt("unregall",0)>0){var t=Trim(StrGetBetween(e,"\nContact:","\r"));if(t.length>0&&t.indexOf("expires=0;")>0){e=ReplaceAll(e,t," *\r\nExpires: 0")}}}catch(o){PutToDebugLogException(2,"common: HandleSipProtocol",o)}return e}function HandleOptions(e){try{if(isNull(e)||e.length<1||e.indexOf("OPTIONS sip")<0||null==webphone_api.webrtc_socket)return!1;var n=e,t=GetSipHeaderFromMsg(n,"accept");isNull(t)&&(t=""),t=t.toLowerCase();var o="\r\n";n.indexOf("\r\n")<0&&n.indexOf("\n")>=0&&(o="\n"),n=n.substring(n.indexOf(o)+o.length);var i="SIP/2.0 200 OK"+o+n;i=Trim(i)+o;var a="<sip:"+GetCallerid()+"@"+GetUDPServerAddress()+">";if(i=i.indexOf("Contact:")>0?RewriteSipHeaderInMsg(i,"Contact",a):i+"Contact: "+a+o,i=i.indexOf("User-Agent:")>0?RewriteSipHeaderInMsg(i,"User-Agent","MWWRTC "+webphone_api.global.versionstr):i+"User-Agent: MWWRTC "+webphone_api.global.versionstr+o,t.indexOf("application")>=0&&t.indexOf("sdp")>=0){i.indexOf("Content-Length:")<0&&(i=i+"Content-Length: 0"+o);var r="",l=GetParameter("codec");if(isNull(l)||l.length<1||"-1"==l)r="v=0"+o+"m=audio 80 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 126"+o+"a=mid:0"+o+"a=sendrecv"+o+"a=rtcp-mux"+o+"a=rtpmap:111 opus/48000/2"+o+"a=rtcp-fb:111 transport-cc"+o+"a=fmtp:111 minptime=10;useinband"+o+"a=rtpmap:103 ISAC/16000"+o+"a=rtpmap:104 ISAC/32000"+o+"a=rtpmap:9 G722/8000"+o+"a=rtpmap:0 PCMU/8000"+o+"a=rtpmap:8 PCMA/8000"+o+"a=rtpmap:106 CN/32000"+o+"a=rtpmap:105 CN/16000"+o+"a=rtpmap:13 CN/8000"+o+"a=rtpmap:126 telephone-event/8000"+o;else{var s="m=audio 80 UDP/TLS/RTP/SAVPF";r="a=mid:0"+o+"a=sendrecv"+o+"a=rtcp-mux"+o;var p=l.split(",");(p.indexOf("10")>=0||p.indexOf("11")>=0||p.indexOf("13")>=0)&&(s+=" 111",r=r+"a=rtpmap:111 opus/48000/2"+o+"a=rtcp-fb:111 transport-cc"+o+"a=fmtp:111 minptime=10;useinband"+o),s+=" 103 104 9",r=r+"a=rtpmap:103 ISAC/16000"+o+"a=rtpmap:104 ISAC/32000"+o+"a=rtpmap:9 G722/8000"+o,p.indexOf("1")>=0&&(s+=" 0",r=r+"a=rtpmap:0 PCMU/8000"+o),p.indexOf("2")>=0&&(s+=" 8",r=r+"a=rtpmap:8 PCMA/8000"+o),s+=" 106 105 13 126",r=r+"a=rtpmap:106 CN/32000"+o+"a=rtpmap:105 CN/16000"+o+"a=rtpmap:13 CN/8000"+o+"a=rtpmap:126 telephone-event/8000"+o,r="v=0"+o+s+o+r}i=i+o+r,i=RewriteSipHeaderInMsg(i,"Content-Length",r.length)}else i=i.indexOf("Accept:")>0?RewriteSipHeaderInMsg(i,"Accept","application/sdp,application/dtmf-relay,text/plain"):i+"Accept: application/sdp,application/dtmf-relay,text/plain"+o,i=i.indexOf("Content-Length:")>0?RewriteSipHeaderInMsg(i,"Content-Length","0"):i+"Content-Length: 0"+o,i+=o;return PutToDebugLog(3,"EVENT, HandleOptions OPTIONS sip handled manually: EVENT, SEND: \r\n"+i),webphone_api.webrtc_socket.send(i),!0}catch(c){PutToDebugLogException(2,"common: HandleOptions",c)}return!1}function HandleEdgeSdpIP(e){try{if(isNull(e)||e.length<1)return e;if("Edge"!==GetBrowser())return e;if(0!==e.indexOf("INVITE sip"))return e;var n=e,t=n.indexOf("a=candidate:");if(t<0)return e;var o=n.substring(t+12);if(o=o.substring(0,o.indexOf("\r\n")),isNull(o)||o.length<1)return e;var i="";if(t=o.lastIndexOf("."),t>0&&(i=o.substring(t),o=o.substring(0,t+4),t=o.lastIndexOf(" "),t>o.length-6&&(o=o.substring(0,t)),o=Trim(o),t=o.lastIndexOf(" "),t>0&&(o=o.substring(t+1)),isNull(i)&&(i=""),i=Trim(i),t=i.indexOf(" "),t>0&&(i=i.substring(t+1)),t=i.indexOf(" "),t>0&&(i=i.substring(0,t),!isNull(i)&&IsNumber(i)||(i="")),o=Trim(o),i=Trim(i)),isNull(o)||o.length<1||!IsIPAddrress(o))return e;if((t=n.indexOf("c="))<1)return e;var a=n.substring(0,t);n=n.substring(t),t=n.indexOf("\r\n");var r=n.substring(0,t+2);n=n.substring(t+2);var l=r.replace("127.0.0.1",o);if(l=l.replace("127.0.0.0",o),n=a+l+n,r=r.replace("\r\n",""),l=l.replace("\r\n",""),PutToDebugLog(2,"EVENT, HandleEdgeSdpIP IP addres rewritten in SDP, orig header: "+r+"; rewritten to: "+l),isNull(i)||i.length<1||!IsNumber(i))return n;if((t=n.indexOf("m=audio"))<1)return n;e=n,a=n.substring(0,t+7),n=n.substring(t+7),n=Trim(n),t=n.indexOf(" ");var s=n.substring(0,t);return n=n.substring(t),(isNull(s)&&(s=""),s=Trim(s),s.length<1||!IsNumber(s))?e:n=a+" "+i+n}catch(p){PutToDebugLogException(2,"common: HandleEdgeSdpIP",p)}return e}function HandleIncomingSIPSignaling(e){var n=0;try{if(n=1,isNull(e)||e.length<1)return e;n=2;var t=HandleAmidHeader(e);return n=3,
t=HandleSpecialCharsInHeaders(t),n=4,t=FixVideo(t,!1),n=5,2==webphone_api.global.addrtcpmux&&(n=6,t.indexOf("\na=rtcp-mux")<0&&(n=17,webphone_api.common.PutToDebugLog(5,"EVENT, add sdp rtcp"),t.indexOf("\na=setup:active\r\n")>0?t=t.replace("\na=setup:active\r\n","\na=setup:active\r\na=rtcp-mux\r\n"):t.indexOf("\r\na=rtcp:")>0?t=t.replace("\r\na=rtcp:","\r\na=rtcp-mux\r\na=rtcp:"):t.indexOf("\r\na=ice-ufrag:")>0&&(t=t.replace("\r\na=ice-ufrag:","\r\na=rtcp-mux\r\na=ice-ufrag:")))),t}catch(o){PutToDebugLogException(2,"common: HandleIncomingSIPSignaling "+n.toString(),o)}return e}function HandleSpecialCharsInHeaders(e){try{var n=e,t=n.indexOf("\r\n\r\n"),o=-1,i="";t>0&&(i=n.substring(t),n=n.substring(0,t)),isNull(i)&&(i="");var a=n.split("\r\n");if(isNull(a)||a.length<1)return e;n="";for(var r=0;r<a.length;r++){if(isNull(a[r])&&(a[r]=""),t=a[r].indexOf('"'),o=a[r].lastIndexOf('"'),t>=0&&o>0&&t<o){var l=a[r].substring(t+1,o),s=RemoveSpecialCharaters(l);l!==s&&(PutToDebugLog(2,"EVENT, HandleSpecialCharsInHeaders, rewrite special charaters in header: "+a[r]+"; to: "+s+" because containes invalid charaters"),a[r]=a[r].replace(l,s),(a[r].indexOf("From:")>=0||a[r].indexOf("Contact:")>=0)&&(webphone_api.global.sipunicoderewritefrom=l,webphone_api.global.sipunicoderewriteto=s))}n.length>0&&(n+="\r\n"),n+=a[r]}if(!isNull(n)&&n.length>10)return n+i}catch(p){PutToDebugLogException(2,"common: HandleSpecialCharsInHeaders",p)}return e}function RemoveSpecialCharaters(e){try{if(isNull(e)||e.length<1)return e;for(var n="",t=0;t<e.length;t++)e.charCodeAt(t)>31&&e.charCodeAt(t)<255&&(n+=e.charAt(t));return n}catch(o){PutToDebugLogException(2,"common: RemoveSpecialCharaters",o)}return e}function HandleAmidHeader(e,n){try{if("Firefox"!==GetBrowser())return e;var t=e,o=t.indexOf("INVITE sip");if((o>=0&&o<20||!1===n)&&(o=t.indexOf("a=mid:"))<1)if(PutToDebugLog(5,"EVENT, add a mid for FF"),(o=t.indexOf("m=audio"))>0){var i=t.substring(0,o);t=t.substring(o),o=t.indexOf("\r\n");t=i+t.substring(0,o+2)+"a=mid:1\r\n"+t.substring(o+2),t=RecalculateContentLength(t)}else if((o=t.indexOf("m=video "))>0){var i=t.substring(0,o);t=t.substring(o),o=t.indexOf("\r\n"),t=i+t.substring(0,o+2)+"a=mid:2\r\n"+t.substring(o+2),t=RecalculateContentLength(t)}return t}catch(a){PutToDebugLogException(2,"common: HandleAmidHeader",a)}return e}function AddSIPLine(e,n){if(isNull(e)||e.length<1)return e;if(isNull(n)||n.length<1)return e;var t=n;if(t.indexOf(":")>0&&(t=Trim(StrGetUntill(t,":"))),t.length>0&&e.indexOf("\n"+t+":")>=0)return e;var o=e.indexOf("\r\nCSeq:");return o>0?e=e.replace("\r\nCSeq:","\r\n"+n+"\r\nCSeq:"):(o=e.indexOf("\r\n\r\n"))>0&&(e=e.substring(0,o)+"\r\n"+n+e.substring(o)),e}function RemoveSIPHeader(e,n){return isNull(e)||e.length<1?e:isNull(n)||n.length<1?e:e.indexOf("\r\n"+n)<0?e:(e=StrReplaceBetween(e,"\r\n"+n,"\r","HRPL"),e=ReplaceAll(e,"\r\n"+n+"HRPL",""))}function FixContentLength(e,n){try{if(isNull(e)||e.length<1)return e;if((isNull(n)||!0!==n&&!1!==n)&&(n=!0),!n)return 0==e.indexOf("INVITE sip")&&CatchWebrtcSignaling(e,SIP_INVITE_IN,n),e=RecalculateContentLength(e);var t=e,o=0;if(t.indexOf("\nUser-Agent")<0){var i=GetUA();GetParameter("useragent").length>0&&!1===IsMizuReallyPublicWebRTCGateway()&&(i=GetParameter("useragent")),i.length>0&&(t=AddSIPLine(t,"User-Agent: "+i))}var a=IsMizuServerOrGateway();if(t.indexOf("\nContact:")&&(0==t.indexOf("INVITE sip")||0==t.indexOf("REGISTER sip"))){var r=GetParameter("contact_parameters"),l=GetParameter("contact_uri_parameters");if(r.length>0&&"NULL"!=r||l.length>0&&"NULL"!=l){var s=StrGetBetween(t,"\nContact:","\r"),p=s.indexOf(">");if(p>0){if(r.length>0&&"NULL"!=r){var c,u=r;";"==u[0]?c=s+u:(";"!=u[0]&&(u=";"+u),c=s.substr(0,p+1)+u+s.substr(p+1)),t=ReplaceAll(t,s,c),s=c}if(l.length>0&&"NULL"!=l){var u=l;";"!=u[0]&&";"!=s[p-1]&&(u=";"+u);var c=s.substr(0,p)+u+s.substr(p);t=ReplaceAll(t,s,c)}}}}if(t.indexOf("\nContact:")&&GetParameterInt("contactdomain",0)>0)try{var g=Trim(StrGetBetween(t,"\nFrom:","@")),h=Trim(StrGetBetween(t,"\nContact:","@"));if(g=Trim(StrGetAfter(g,":")),h=Trim(StrGetAfter(h,":")),g===h&&h.length>0){var s=StrGetBetween(t,"\nContact:","\r"),m=StrGetBetween(t,"\nFrom:","\r");m=StrGetAfter(m,"@"),m=StrGetUntill(m,">"),m.indexOf(";")>0&&(m=StrGetUntill(m,";"));var d=StrGetBetween(t,"\nContact:","\r");if(d=StrGetAfter(d,"@"),d=StrGetUntill(d,">"),d.indexOf(";")>0&&(d=StrGetUntill(d,";")),m.length>0&&d.length>0&&s.length>0){s="\nContact:"+s;var c=ReplaceAll(s,d,m);t=ReplaceAll(t,s,c)}}}catch(A){PutToDebugLogException(3,"common: FixContentLength contact",A)}if(a&&t.indexOf("REGISTER sip")<0){var o=t.indexOf("Call-ID:");if(o>0)try{var b=Trim(t.substring(o+8));b.indexOf("\r\n")>0&&(b=b.substring(0,b.indexOf("\r\n")),!isNull(b)&&b.length>0&&(t=t.substring(0,o)+"X-C-Call-ID: "+b+"\r\n"+t.substring(o)))}catch(A){PutToDebugLogException(3,"common: FixContentLength callid",A)}}if(webphone_api.global.fcmIsEnabled>0&&0==(o=t.indexOf("REGISTER sip"))&&!isNull(webphone_api.global.fcmtoken)&&webphone_api.global.fcmtoken.length>3)try{if(t.indexOf("X-MPUSH:")<1){PutToDebugLog(3,"EVENT, (warn) mpush added at register send");t=AddSIPLine(t,"X-MPUSH: "+("w:"+GetFCMPackageName()+":"+webphone_api.global.fcmtoken))}if(t.indexOf("X-PIID:")<1){PutToDebugLog(3,"EVENT, (warn) X-PIID added at register send");t=AddSIPLine(t,"X-PIID: "+Md5Hash(GetSipusername()+":"+webphone_api.global.mRealm+":"+GetParameter("password")))}}catch(A){PutToDebugLogException(3,"common: FixContentLength fcm",A)}if(0==(o=t.indexOf("REFER sip")))try{webphone_api.global.transfer_retryonnotsent="",webphone_api.global.prev_transfer_replaces_tick=0;var _=GetParameterInt("transfertype",-1),f=GetParameterInt("transfwithreplace",-1),w=f;if(f<0&&(-1==_||6==_||7==_)&&(f=1),8==_&&(f=0),f>0&&1!=webphone_api.global.transfer_disablereplaces){CanLog(5)&&PutToDebugLog(5,"EVENT, transferreplace try with transfertype: "+_.toString()+" transfwithreplace: "+f.toString()+" line: "+webphone_api.global.aline.toString());var v=GetSipHeaderFromMsg(t,"Refer-To");if(v.length<1)CanLog(3)&&PutToDebugLog(3,"EVENT, (warn) transferreplace cannot find orig refer-to");else{var E=GetSipHeaderFromMsg(t,"Call-ID"),P=ExtractSIPUsername(v),T=GetLineFromMsg(t);T<1&&(CanLog(3)&&PutToDebugLog(3,"EVENT, (warn) transferreplace cannot find currline from msf. using def."),T=StrToInt(webphone_api.global.aline));var S=GetIdxFromEp(getlinefrommsg_ep);T>0&&CanLog(5)&&(P.length>0&&PutToDebugLog(5,"EVENT, transferreplace transfer target is: "+P),PutToDebugLog(5,"EVENT, transferreplace current line is: "+T.toString()+" idx: "+S.toString()+" callid: "+E+" "+EpToString(S)));var N=GetBestLine(T,!0,P);if(isNull(T)||isNull(N)||T<1||N<1||T==N)CanLog(3)&&PutToDebugLog(3,"EVENT, transferreplace cannot find lines curr: "+T.toString()+", other: "+N.toString()+", calls: "+GetNrOfActiveCalls().toString());else{null==gestbestline_ep&&(gestbestline_ep=GetEndpoint(19913,N));var I=GetIdxFromEp(gestbestline_ep);if(w<2&&null!=gestbestline_ep&&P.length>0&&!isNull(gestbestline_ep[EP_DESTNR])&&gestbestline_ep[EP_DESTNR].length>0&&P!=gestbestline_ep[EP_DESTNR])CanLog(3)&&PutToDebugLog(3,"EVENT, (warn) transferreplace skip because no same peer. other line is: "+N.toString()+" idx: "+I.toString()+" target: "+P.toString()+", vs: "+gestbestline_ep[EP_DESTNR].toString()+" "+EpToString(I));else if(w<2&&GetSIPMsg("",N,0,3,"Supported",!0,!0).indexOf("replace")<0&&GetSIPMsg("",N,0,3,"Require",!0,!0).indexOf("replace")<0)CanLog(3)&&PutToDebugLog(3,"EVENT, (warn) transferreplace skip because no support for replaces. other line is: "+N.toString()+" idx: "+I.toString()+" "+EpToString(I));else{CanLog(5)&&PutToDebugLog(5,"EVENT, transferreplace other line is: "+N.toString()+" idx: "+I.toString()+" "+EpToString(I));var C="";null!=gestbestline_ep&&(C=gestbestline_ep[EP_CALLID]),isNull(C)&&(C="");var G=GetSIPMsg(C,N,-1,0,"Call-ID",!1,!1);G.length<1&&C.length>0&&(G=C),CanLog(5)&&C!=G&&PutToDebugLog(5,"EVENT, transferreplace other ep callid does not match: "+G+" / "+C);var L=GetSIPMsg(G,N,-1,0,"From",!1,!1),R=GetSIPMsg(G,N,-1,0,"To",!1,!1);if(CanLog(5)&&PutToDebugLog(5,"EVENT, transferreplace params callid: "+G+", from: "+L+", to: "+R),L=StrGetAfter(L,"tag="),L.indexOf(";")>=0&&(L=StrGetUntill(L,";")),R=StrGetAfter(R,"tag="),R.indexOf(";")>=0&&(R=StrGetUntill(R,";")),G.length<1||L.length<1||R.length<1)CanLog(3)&&PutToDebugLog(3,"EVENT, (warn) transferreplace cannot find params callid: "+G+", from: "+L+", to: "+R);else if(G==E)CanLog(3)&&PutToDebugLog(3,"EVENT, (warn) transferreplace other line mismatch. callid: "+G+", from: "+L+", to: "+R);else{var y=G+";to-tag="+R+";from-tag="+L;y=encodeURIComponent(y),y="Replaces="+y,CanLog(5)&&PutToDebugLog(5,"EVENT, transferreplace final: "+y),y=v.indexOf("?")>=0?";"+y:"?"+y,v.indexOf(">")>0&&(v=ReplaceAll(v,">",y+">")),t=RewriteSipHeaderInMsg(t,"Refer-To",v),webphone_api.global.prev_transfer_replaces_tick=GetTickCount()}}}}}}catch(A){PutToDebugLogException(3,"common: FixContentLength refer",A)}if(t.indexOf("\r\n\r\nv=0\r\n")>0&&(t=FixVideo(t,n)),0==(o=t.indexOf("INVITE sip")))try{if(webphone_api.global.lastinvitesent=GetTickCount(),a&&(t.indexOf("\nX-Webdomain")<0&&GetWebdomain().length>0&&(PutToDebugLog(3,"EVENT, (warn) add webdomain to sip msg"),t=AddSIPLine(t,"X-Webdomain: "+GetWebdomain())),t.indexOf("\nX-UT")<0&&(PutToDebugLog(3,"EVENT, (warn) add x-ut to sip msg"),t=AddSIPLine(t,"X-UT: r"))),!0===webphone_api.global.add_recall_header&&t.indexOf("X-Autorecall:")<1&&(t=AddSIPLine(t,"X-Autorecall: yes")),!0===webphone_api.global.addauser_header&&t.indexOf("X-AUSR:")<1&&(PutToDebugLog(3,"EVENT, Sipusername added at invite send"),t=AddSIPLine(t,"X-AUSR: "+GetSipusername())),webphone_api.global.sip_referreplace_all.length>0&&(0!=webphone_api.global.transferreplacerectick&&webphone_api.common.GetTickCount()-webphone_api.global.transferreplacerectick<4e4||webphone_api.global.sip_referreplace_sendcallid.length>0&&webphone_api.global.sip_referreplace_sendcallid==GetSipHeaderFromMsg(t,"Call-ID"))&&(webphone_api.global.transferreplacerectick=0,t=AddSIPLine(t,"Replaces: "+webphone_api.global.sip_referreplace_all),webphone_api.global.sip_referreplace_sendcallid=GetSipHeaderFromMsg(t,"Call-ID")),t.indexOf("X-Sy.Upperproxy:")<1){var D=GetUpperProxyHeaderForSignaling();!isNull(D)&&D.length>0&&(PutToDebugLog(3,"EVENT, Proxyaddress added at invite send"),t=AddSIPLine(t,"X-Sy.Upperproxy: "+D))}if(CatchWebrtcSignaling(t,SIP_INVITE_OUT,n),t=t.replace("X-Sy.Uppersrv: rtc.mizu-voip.com:6060\r\n",""),t=t.replace("X-Sy.Uppersrvd: rtc.mizu-voip.com:6060\r\n",""),t.indexOf("X-Sy.Uppersrv:")<1){var O=GetWebrtcSyUpperHeader("invite send");!isNull(O)&&O.length>0&&(PutToDebugLog(3,"EVENT, (warn) Upperserver added at invite send"),t=AddSIPLine(t,"X-Sy.Uppersrv: "+O))}if(t.indexOf("X-Sy.Uppersrvd:")<1){var x=GetWebrtcSyUpperDomainHeader("invite send");!isNull(x)&&x.length>0&&t.indexOf("X-Sy.Uppersrvd:")<1&&(PutToDebugLog(3,"EVENT, (warn) Upperserver domain added at invite send"),t=AddSIPLine(t,"X-Sy.Uppersrvd: "+x))}if(a){4==GetParameterInt("dtmfmode",2)&&t.indexOf("X-MFlag:2")<0&&(PutToDebugLog(3,"EVENT, rfc2833 added at invite send"),t=AddSIPLine(t,"X-MFlag:2"))}t.indexOf(";stereo=1;")>0&&(t=t.replace(";stereo=1;",";stereo=0;")),0!=webphone_api.global.lastholdorresume&&GetTickCount()-webphone_api.global.lastholdorresume<12e3&&(t.indexOf("\na=sendonly\r")>=0||t.indexOf("\na=recvonly\r")>=0||t.indexOf("\na=inactive\r")>=0||t.indexOf("\na=sendrecv\r")>=0)&&(1==webphone_api.global.needholdreinvite&&(webphone_api.global.needholdreinvite=2),webphone_api.global.lastholdinvitesent=GetTickCount()),0!=webphone_api.global.isresume&&webphone_api.common.GetTickCount()-webphone_api.global.isresume<2e3&&webphone_api.common.GetTickCount()-webphone_api.global.isresume>=0&&(t=t.replace("\na=sendonly\r","\na=sendrecv\r"),t=t.replace("\na=recvonly\r","\na=sendrecv\r"),t=t.replace("\na=inactive\r","\na=sendrecv\r"))}catch(A){PutToDebugLogException(3,"common: FixContentLength invite",A)}return t=RecalculateContentLength(t)}catch(A){PutToDebugLogException(2,"common: FixContentLength",A)}return e}function FixVideo(e,n){try{if(e.indexOf("\r\n\r\nv=0\r\n")<=0)return e;var t=!1;0!=GetParameterInt("video",-1)&&0!=GetParameterBool("has_video",!0)||(t=!0);var o=!1;if(e.indexOf("\nm=video ")>0&&(o=!0),t||webphone_api.global.isvideocall||!o?!n&&webphone_api.global.isvideocall&&(t||!o)&&0==e.indexOf("INVITE sip")&&e.indexOf("\nm=audio ")>0&&(webphone_api.global.isvideocall=!1):webphone_api.global.isvideocall=!0,!n&&0!=e.indexOf("INVITE sip"))return e;var i=GetParameterInt("fixvideo",-1);if(i<0&&t&&(webphone_api.global.isvideocall||o)&&(i=7),i<4)return e;var a,r=!1;if(!1===r&&(4==i||5==i)&&(a=e.indexOf("\nprofile-level-id="))>0){webphone_api.common.PutToDebugLog(5,"EVENT, fix sdp profile-level-id A "+i.toString()),a++;var l=e.substring(0,a);e=e.substring(a);var s=e.indexOf("\r\n"),p=e.indexOf(";");p<0&&(p=150),e=s<p?e.substring(e.indexOf("\r\n")):e.substring(e.indexOf(";")),e=l+e,r=!0}if(6==i||7==i||8==i||!1===r&&5==i){a=e.indexOf("\nm=video ");var c=!1;if(a>0)if(a++,e=e.substring(0,a),r=!0,c=!0,8==i||6!=i&&(webphone_api.global.isvideocall||c));else if((a=e.indexOf("a=group:BUNDLE"))>0){webphone_api.common.PutToDebugLog(5,"EVENT, fix sdp remove video C111 "+i.toString());var l=e.substring(0,a);e=e.substring(a),e=e.substring(e.indexOf("\r\n")+2),e=l+e,r=!0}(8==i||6!=i&&(webphone_api.global.isvideocall||c))&&(webphone_api.common.PutToDebugLog(5,"EVENT, fix sdp remove video D1"),e+="m=video 0 UDP/TLS/RTP/SAVPF 13\r\n",e.indexOf("\na=mid:0")>=0&&(e+="a=mid:1\r\n"),r=!0)}r&&!n&&(e=RecalculateContentLength(e))}catch(u){PutToDebugLogException(2,"common: FixVideo",u)}return e}function StrGetUntill(e,n){if(!e||!n||e.length<1||n.length<1)return"";var t=e.indexOf(n);return t<0&&(t=e.toLowerCase().indexOf(n.toLowerCase())),t<0?"":e.substring(0,t)}function StrGetAfter(e,n){if(!e||!n||e.length<1||n.length<1)return"";var t=e.indexOf(n);return t<0&&(t=e.toLowerCase().indexOf(n.toLowerCase())),t<0?"":e.substring(t+n.length)}function StrGetBetween(e,n,t){if(!e||!n||e.length<1||n.length<1)return"";var o=e.indexOf(n);if(o<0&&(o=e.toLowerCase().indexOf(n.toLowerCase())),o<0)return"";if(e=e.substring(o+n.length),!t||e.length<1||t.length<1)return e;var i=e.indexOf(t);return i<0&&(i=e.toLowerCase().indexOf(t.toLowerCase())),i<0?"":e.substring(0,i)}function StrReplaceBetween(e,n,t,o){if(!e||e.length<1)return"";var i=StrGetAfter(e,n);if(i.length<1)return e;if(i.indexOf(t)<0&&i.toLowerCase().indexOf(t.toLowerCase())<0){if("\r"!==t&&"\r\n"!==t)return e}else i=StrGetAfter(i,t);return StrGetUntill(e,n)+n+o+t+i}function GetDomainPart(e,n){if(void 0!==n&&null!==n||void 0!==(n=e)&&null!==n||(n=""),n=Trim(n),null==e||e.length<1)return n;var t=Trim(e);return t.indexOf(",")>=0&&(","==t.charAt(0)?(t=t.substring(1),t.indexOf(",")>0&&(t=Trim(t.substring(0,t.indexOf(","))))):t=Trim(t.substring(0,t.indexOf(",")))),t.indexOf("<")>0&&(t=Trim(t.substring(t.indexOf("<")+1))),0!=t.indexOf('"')&&0!=t.indexOf("'")||(t=Trim(t.substring(1))),t.indexOf(">")>0&&(t=Trim(t.substring(0,t.indexOf(">")))),t.indexOf("\\")>0&&(t=Trim(t.substring(0,t.indexOf("\\")))),t.indexOf("/")>0&&(t=Trim(t.substring(0,t.indexOf("/")))),t.indexOf("sip:")>=0?t=t.substring(t.indexOf("sip:")+4):t.indexOf("tel:")>=0?t=t.substring(t.indexOf("tel:")+4):t.indexOf("sips:")>=0&&(t=t.substring(t.indexOf("sips:")+5)),t.indexOf("@")>0&&(t=Trim(t.substring(t.indexOf("@")+1))),t.indexOf(":")>0&&(t=Trim(t.substring(0,t.indexOf(":")))),t.indexOf('"')>0&&(t=Trim(t.substring(0,t.indexOf('"')))),t.indexOf("'")>0&&(t=Trim(t.substring(0,t.indexOf("'")))),t.length<1?n:t}function RecalculateContentLength(e){try{var n="\nContent-Length:",t=StrGetBetween(e,n,"\r");if(t.length<1&&(n="\nl:",t=StrGetBetween(e,n,"\r")),t.length<1)return e;var o=StrToIntDef(t,0);if(o<1)return e;var i=e.indexOf("\r\n\r\n");if(i<1)return e;var a=e.length-i-4;return a==o?e:StrReplaceBetween(e,n,"\r",a.toString())}catch(r){PutToDebugLogException(2,"common: RecalculateContentLength",r)}return e}function RemoveDuplicateHeaders(e){try{if(isNull(e)||e.length<1)return e;var n=e,t=n.indexOf("REGISTER sip");if(t>=0&&t<20){for(var o=[],i=n.split("\r\n"),a=0;a<i.length;a++)"undefined"!=typeof i[a]&&null!==i[a]&&(i[a].indexOf(":")<0?o.push(i[a]):o.indexOf(i[a])<0&&o.push(i[a]));if(!isNull(o)&&o.length>0){for(var r="",a=0;a<o.length;a++)a>0?r=r+"\r\n"+o[a]:r+=o[a];return r}}}catch(l){PutToDebugLogException(2,"common: RemoveDuplicateHeaders",l)}return e}function AddDtmfConfHeader(e){try{if(!0!==webphone_api.global.isconfdtmf)return e;if(isNull(e)||e.length<1)return e;if(e.indexOf("INFO sip:")<0&&e.indexOf("INFO sips:")<0)return e;var n=e;n.indexOf("Signal=#")>=0&&(webphone_api.global.isconfdtmf=!1);var t=n.indexOf("\r\nCall-ID:");if(t>=0&&n.indexOf("X-MDTFM:")<0){var n=n.substring(0,t)+"\r\nX-MDTFM: y"+n.substring(t);return n}}catch(o){PutToDebugLogException(2,"common: AddDtmfConfHeader",o)}return e}function GetViaRandomAddress(){try{return!isNull(viarandaddr)&&viarandaddr.length>0?viarandaddr:viarandaddr=RandomStr(12,!1,!0)+".invalid"}catch(e){PutToDebugLogException(2,"common: GetViaRandomAddress",e)}return"abcdefg12345.invalid"}function GetBrowserSessionID(){return null==webphone_api||null==webphone_api.global?"":(0==webphone_api.global.browsersessionid&&(webphone_api.global.browsersessionid=Math.floor(999999*Math.random())+1),webphone_api.global.browsersessionid.toString())}function GetPushnotVal(e){var n=GetParameterInt("enablepush",e),t=GetParameterInt("callreceiver",e),o=t;return 1!==t&&-1!==t||(o=0),n>=0&&(o=n),o}function EnableFCM(){try{if(GetParameterInt("fcmtest",0)>0)return!0;var e=GetPushnotVal(-1);if(isNull(e)||e<-1)return!1;if(0===e)return!1;if(!1===IsHttps()&&window.location.href.toLowerCase().indexOf("://localhost")<0&&window.location.href.toLowerCase().indexOf("://127.0.0.1")<0)return!1;if(!1 in navigator||!1 in window)return!1;if(!0===HideSettings("enablepush",webphone_api.stringres.get("sett_display_name_enablepush"),"enablepush",!0))return!1;if(!0===IsLocalServer(!0)||!0===IsLocalUpperServer())return!1;if(1===e||2===e||3===e)return!0;if(-1===e){if(-1==webphone_api.global.recwsload&&(webphone_api.global.recwsload=GetParameter("lastrecwsload",-2)),webphone_api.global.recwsload>1)return PutToDebugLog(2,"WARNING, EnableFCM returned false, because wsload server load is to high: "+webphone_api.global.recwsload),!1;var n=GetParameterInt("lastincalltime",0),t=GetParameterInt("appinstalltime",0);t<1&&SaveParameter("appinstalltime",GetTickCount().toString());var o=GetTickCount(),i=!1;t>0&&o-t<7776e6&&(i=!0);var a=!1;if(n>0&&o-n<7776e6&&(a=!0),"undefined"!=typeof webphone_api.config&&null!==webphone_api.config&&"undefined"!=typeof webphone_api.config.apiKey&&null!==webphone_api.config.apiKey&&webphone_api.config.apiKey.length>3&&(!0===i||!0===a))return!0}}catch(r){PutToDebugLogException(2,"common EnableFCM",r)}return!1}function RegisterServiceWorker(){return navigator.serviceWorker.register("firebase-messaging-sw.js").then(function(e){return PutToDebugLog(2,"WARNING,FCM RegisterServiceWorker successfully registered"),FCMRequestNotidicationPeremission(),e})["catch"](function(e){PutToDebugLogException(2,"FCM, RegisterServiceWorker: Unable to register")})}function FCMRequestNotidicationPeremission(){try{if(!window.Notification||!Notification.permission)return void PutToDebugLog(2,"WARNING,FCMRequestNotidicationPeremission: Notification not supported in this environment, browser: "+GetBrowser()+"; os: "+GetOs())}catch(e){PutToDebugLogException(2,"common FCMRequestNotidicationPeremission",e)}}function StartFCM(e){try{if(!1===EnableFCM())return;return void PutToDebugLog(4,"EVENT, exec StartFCM ("+e+")")}catch(n){PutToDebugLogException(2,"common StartFCM",n)}}function FCMSetToken(){try{var e=GetParameterInt("enablefcm",-1);if(e<1&&(e=1),getuseengine()===webphone_api.global.ENGINE_WEBRTC)webphone_api.global.fcmIsEnabled=1,webphone_api.webrtcapi.SetPushNotifications(e,webphone_api.global.fcmtoken,"","");else if(!0===IsWindowsSoftphone()||getuseengine()===webphone_api.global.ENGINE_SERVICE)webphone_api.global.fcmIsEnabled=1,WinAPI("API_SetPushNotifications",null,e,webphone_api.global.fcmtoken,"","");else{if(getuseengine()!==webphone_api.global.ENGINE_JAVA)return void PutToDebugLog(2,"WARNING, FCM FCMSetToken push notifications are not supported by engine: "+getuseengine());webphone_api.global.fcmIsEnabled=1,webphone_api.webphone.SetPushNotifications(e,webphone_api.global.fcmtoken,"","")}PutToDebugLog(2,"EVENT, FCM FCMSetToken push notifications are ENABLED: "+getuseengine())}catch(n){PutToDebugLogException(2,"common FCMSetToken",n)}}function UserExists(e){try{if(isNull(e))return!0;if(e=e.toLowerCase(),e=Trim(e),e.length<1)return!0;if(e===GetSipusername().toLowerCase()||e===GetSipusername(!0).toLowerCase())return!0;if(!isNull(webphone_api.global.sipaccounts))for(var n=0;n<webphone_api.global.sipaccounts.length;n++)if(!isNull(webphone_api.global.sipaccounts[n].username)&&webphone_api.global.sipaccounts[n].username.toLowerCase()===e)return!0;return!1}catch(t){PutToDebugLogException(2,"common UserExists",t)}return!0}function GetUsernamePart(e){try{if(isNull(e)||e.length<1)return"";e.indexOf("@")>=0&&(e=e.substring(0,e.indexOf("@")),e=Trim(e))}catch(n){PutToDebugLogException(2,"common GetUsernamePart",n)}return e}function GetSipusername(e){var n="";try{n=GetParameter("sipusername"),(isNull(n)||n.length<1)&&(n=GetParameter("username")),isNull(n)&&(n=""),n.indexOf("@")>0&&!isNull(e)&&!0===e&&(n=n.substring(0,n.indexOf("@"))),n=Trim(n)}catch(t){PutToDebugLogException(2,"common GetSipusername",t)}return n}function GetUsername(){return GetCallerid()}function GetCallerid(){var e="";try{e=GetParameter("username"),(isNull(e)||e.length<1)&&(e=GetParameter("sipusername")),e.indexOf("@")>0&&(e=e.substring(0,e.indexOf("@"))),e=Trim(e)}catch(n){PutToDebugLogException(2,"common GetCallerid",n)}return e}function HandleCallerID(){try{var e=GetParameter("previous_sipusername"),n=GetParameter("previous_username");!isNull(e)&&e.length>0&&e!==GetParameter("sipusername")&&!isNull(n)&&n.length>0&&n===GetParameter("username")&&GetParameter("username")!==GetParameter("sipusername")&&(PutToDebugLog(2,"EVENT, HandleCallerID: callerID is reset; old callerid: "+n),SaveParameter("username","")),SaveParameter("previous_username",GetParameter("username")),SaveParameter("previous_sipusername",GetParameter("sipusername"))}catch(t){PutToDebugLogException(2,"common: HandleCallerID",t)}}function GetFCMPackageName(){try{var e=GetParameter("packagename");if(!isNull(e)&&Trim(e).length>0)return e}catch(n){PutToDebugLogException(2,"common GetFCMPackageName",n)}return"com.mizuvoip.mizudroid.app"}function UniqueArray(e){try{if(isNull(e)||e.length<1)return e;for(var n=e,t=0,o=n.length+10,i=0;t<n.length;){if(++i>o)return e;var a=n.indexOf(n[t]);a>=0&&a<t?n.splice(t,1):t++}return n}catch(r){PutToDebugLogException(2,"common UniqueArray",r)}return e}function IsWebphoneInIframe(){try{return window.self!==window.top}catch(e){return!0}}function GetParentIframeUrl(){var e="";try{if(!1===IsWebphoneInIframe())return"";e=document.referrer}catch(n){try{e=window.parent.location}catch(t){e="ERROR, cannot get iframe parent location"}}return isNull(e)&&(e=""),e}function IsCExt(){try{if(iscallerextension>=0)return iscallerextension;var e=window.location.href;void 0!==e&&null!==e||(e=""),e=e.toLowerCase();var n=[];n.push("c"),n.push("a"),n.push("l"),n.push("l"),n.push("e"),n.push("r"),n.push("e"),n.push("x"),n.push("t"),n.push("e"),n.push("n"),n.push("s"),n.push("i"),n.push("o"),n.push("n"),n.push("="),n.push("3"),n.push("4"),n.push("5");var t=n.join("");return e.indexOf(t)>0?(PutToDebugLog(2,"EVENT, IsCExt: 1; "+e),iscallerextension=1):iscallerextension=0,iscallerextension}catch(o){PutToDebugLogException(2,"common IsCExt",o)}return 0}function GetUA(){try{return"MWWRTC "+webphone_api.global.versionstr}catch(e){PutToDebugLogException(2,"common GetUA",e)}return"MWWRTC 1.0"}function StripXML(e){try{if(isNull(e)||e.length<1)return"";var n=Trim(e),t=n.indexOf("<"),o=n.indexOf(">");if(t>=0&&o>=0&&t<o)for(var i=0;t>=0&&o>=0&&t<o&&i<100;)i++,n=n.substring(0,t)+n.substring(o+1),t=n.indexOf("<"),o=n.indexOf(">");return n}catch(a){PutToDebugLogException(2,"common GetUA",a)}return e}function DisplayStartPage(e){try{var n=GetParameter("startpage_url");isNull(n)&&(n="");var t=GetParameter("startpage_text");if(isNull(t)&&(t=""),n.length<2&&t.length<5)return;var o=GetParameter("startpage_title");isNull(o)&&(o="");var i=GetParameterInt("startpage_type",0);if(n.length>0){var a=n.indexOf("stitle=");if(a>0){var r=n.substring(a+7);a=r.indexOf("&"),a>0&&(r=r.substring(0,a)),!isNull(r)&&r.length>0&&(o=r)}if((a=n.indexOf("stype="))>0){var l=n.substring(a+6);a=l.indexOf("&"),a>0&&(l=l.substring(0,a)),!isNull(l)&&l.length>0&&IsNumber(l)&&(i=StrToIntDef(l,0))}}var s=GetParameterInt("startpage_disp_count",0);if(i<2&&s>0)return;if(2==i&&s>0&&"Settings"===e)return;webphone_api.global.intentstartpage[0]="url="+n,webphone_api.global.intentstartpage[1]="lastpage="+webphone_api.$.mobile.activePage.attr("id"),webphone_api.global.intentstartpage[2]="title="+o,webphone_api.global.intentstartpage[3]="text="+t,webphone_api.global.intentstartpage[4]="type="+i.toString(),webphone_api.$.mobile.changePage("#page_startpage",{transition:"pop",role:"page"})}catch(p){PutToDebugLogException(2,"common DisplayStartPage",p)}}function ParseQRcode(e){try{if(isNull(e)||Trim(e).length<1||e.indexOf(":")<1)return void PutToDebugLog(2,"ERROR, ParseQRcode invalid QRcode: "+e);if(e=ReplaceAll(e,"{",""),e=ReplaceAll(e,"}",""),e=ReplaceAll(e,'"',""),e.indexOf("ERROR")>=0)return e=e.replace("ERROR,",""),e=e.replace("ERROR",""),PutToDebugLog(2,"ERROR, ParseQRcode returned error (show toast untill user): "+e),void ShowToast(e);for(var n=e.split(","),t=0;t<n.length;t++)if(!isNull(n[t])){var o=n[t].indexOf(":");if(!(o<1)){var i=n[t].substring(0,o),a=n[t].substring(o+1);if(!(isNull(i)||Trim(i).length<1||isNull(a))){i=Trim(i),a=Trim(a),SaveParameter("QRCODE_"+i,a);var r="";switch(i){case"user":r="sipusername";break;case"server":r="serveraddress_user";break;case"proxy":r="proxyaddress";break;default:r=i}!isNull(r)&&r.length>0&&(PutToDebugLog(5,"ParseQRcode SaveParameter: "+r+"="+a),SaveParameter(r,a)),r=""}}}ShowToast(webphone_api.stringres.get("barcode_success")),setTimeout(function(){try{GetSipusername().length>0&&GetParameter("password").length>0&&"page_settings"!==webphone_api.$.mobile.activePage.attr("id")&&(PutToDebugLog(5,"ParseQRcode autologin because we have received login details"),webphone_api.plhandler.LoginSkin())}catch(e){PutToDebugLogException(2,"ParseQRcode timer inner run",e)}},3e3)}catch(l){PutToDebugLogException(2,"common ParseQRcode",l)}}function GetSrvVersions(){try{if(!0===IsMacLin()||IsWinMacLinNsTest())return;var e=GetTickCount();if(srvVersionMaxLoop>1&&e-srvVersionLastExec<5e3)return;srvVersionMaxLoop++,srvVersionLastExec=e,WinAPI("API_GetExeVersion",function(e){!isNull(e)&&e.length>0&&e.toLowerCase().indexOf("error")<0&&(e=e.replace("OK:",""),e=Trim(e),SaveParameter("srv_exe_version",e))}),setTimeout(function(){WinAPI("API_GetVersion",function(e){!isNull(e)&&e.length>0&&e.toLowerCase().indexOf("error")<0&&(e=e.replace("OK:"),e=Trim(e),SaveParameter("srv_java_version",e))})},500)}catch(n){PutToDebugLogException(2,"common GetSrvVersions",n)}}function IsWinMacLinNsTest(){try{if("undefined"!=typeof webphone_api.parameters.winlinmacnsengine){if(!0===webphone_api.parameters.winlinmacnsengine||"true"===webphone_api.parameters.winlinmacnsengine)return!0;if(!1===webphone_api.parameters.winlinmacnsengine||"false"===webphone_api.parameters.winlinmacnsengine)return!1}}catch(e){PutToDebugLogException(2,"common IsWinMacLinNsTest",e)}return webphone_api.global.winlinmacnsengine}function IsMacLin(){try{return isNull(ismaclin_cached)?ismaclin_cached="Mac"===GetOs()||"Linux"===GetOs():ismaclin_cached}catch(e){PutToDebugLogException(2,"common IsMacLin",e)}return!1}function IsMac(){try{return isNull(ismac_cached)?("Mac"===GetOs()?ismac_cached=!0:ismaclin_cached=!1,ismac_cached):ismac_cached}catch(e){PutToDebugLogException(2,"common IsMac",e)}return!1}function IsWindows(){try{return isNull(iswindows_cached)?iswindows_cached="Windows"===GetOs():iswindows_cached}catch(e){PutToDebugLogException(2,"common IsWindows",e)}return!1}function NSMacLinEnabled(){try{if(!isNull(maclinenabled_cached))return maclinenabled_cached;if("undefined"==typeof webphone_api.parameters.linnsengine||!0!==webphone_api.parameters.linnsengine&&!1!==webphone_api.parameters.linnsengine||(webphone_api.global.linnsengine=webphone_api.parameters.linnsengine),"undefined"==typeof webphone_api.parameters.macnsengine||!0!==webphone_api.parameters.macnsengine&&!1!==webphone_api.parameters.macnsengine||(webphone_api.global.macnsengine=webphone_api.parameters.macnsengine),!0===webphone_api.global.linnsengine&&"Linux"===GetOs())return maclinenabled_cached=!0;if(!0===webphone_api.global.macnsengine&&"Mac"===GetOs())return maclinenabled_cached=!0;if(!0===IsWinMacLinNsTest()&&(!0===IsMacLin()||"Windows"===GetOs()))return maclinenabled_cached=!0}catch(e){PutToDebugLogException(2,"common NSMacLinEnabled",e)}return!1}function TestNSPolling(){try{return null!==flag_testnspolling_cached?flag_testnspolling_cached:flag_testnspolling_cached="undefined"!=typeof webphone_api.parameters.flag_testnspolling&&!0===webphone_api.parameters.flag_testnspolling}catch(e){PutToDebugLogException(2,"common TestNSPolling",e)}return!1}function GetAudioRecList(){return!isNull(webphone_api.global.audio_rec_device_list)&&webphone_api.global.audio_rec_device_list.length>0?webphone_api.global.audio_rec_device_list:GetParameter("cache_audio_rec_device_list")}function GetAudioPlayList(){if(!isNull(webphone_api.global.audio_play_device_list)&&webphone_api.global.audio_play_device_list.length>0)return webphone_api.global.audio_play_device_list;var e=GetParameter("cache_audio_play_device_list");return!isNull(e)&&e.length>0?e:!isNull(webphone_api.global.audio_ring_device_list)&&webphone_api.global.audio_ring_device_list.length>0?webphone_api.global.audio_ring_device_list:""}function GetAudioRingList(){if(!isNull(webphone_api.global.audio_ring_device_list)&&webphone_api.global.audio_ring_device_list.length>0)return webphone_api.global.audio_ring_device_list;var e=GetParameter("cache_audio_ring_device_list");return!isNull(e)&&e.length>0?e:!isNull(webphone_api.global.audio_play_device_list)&&webphone_api.global.audio_play_device_list.length>0?webphone_api.global.audio_play_device_list:""}function GetVideoRecList(){return 0==webphone_api.common.GetParameterInt("video",-1)?"":!isNull(webphone_api.global.video_rec_device_list)&&webphone_api.global.video_rec_device_list.length>0?webphone_api.global.video_rec_device_list:GetParameter("cache_video_rec_device_list")}function GetAudioRecDev(){return!isNull(webphone_api.global.audio_rec_curr_device)&&webphone_api.global.audio_rec_curr_device.length>0?webphone_api.global.audio_rec_curr_device:GetParameter("cache_audio_rec_curr_device")}function GetAudioPlayDev(){return!isNull(webphone_api.global.audio_play_curr_device)&&webphone_api.global.audio_play_curr_device.length>0?webphone_api.global.audio_play_curr_device:GetParameter("cache_audio_play_curr_device")}function GetAudioRingDev(){return!isNull(webphone_api.global.audio_ring_curr_device)&&webphone_api.global.audio_ring_curr_device.length>0?webphone_api.global.audio_ring_curr_device:GetParameter("cache_audio_ring_curr_device")}function GetVideoRecDev(){return 0==webphone_api.common.GetParameterInt("video",-1)?"":!isNull(webphone_api.global.video_rec_curr_device)&&webphone_api.global.video_rec_curr_device.length>0?webphone_api.global.video_rec_curr_device:GetParameter("cache_video_rec_curr_device")}function NuIsWebPage(){try{if(!isNull(webphone_api.global.nuiswebpage))return webphone_api.global.nuiswebpage;var e=GetParameter("newuser");return isNull(e)&&(e=""),
e=Trim(e),0===e.indexOf("*")?webphone_api.global.nuiswebpage=!1:webphone_api.global.nuiswebpage=!0,webphone_api.global.nuiswebpage}catch(n){PutToDebugLogException(2,"common: NuIsWebPage",n)}return!1}function GetMinSrvBuildValue(){try{var e=GetParameterInt("minimumservicebuild",-1);if(e>webphone_api.global.minimumservicebuild)return e}catch(n){PutToDebugLogException(2,"common: GetMinSrvBuildValue",n)}return webphone_api.global.minimumservicebuild}function HandleServiceBuildUpgrade(){GetMinSrvBuildValue()<1||webphone_api.global.nsupdatepending||WinAPI("API_GetBuildNumber",function(e){try{if(!isNull(e)&&IsNumber(e)){var n=StrToIntDef(e,0),t=GetMinSrvBuildValue();if(t>0&&n<t){GetParameterInt("cancelonnsdownload",0)<e&&(HasUsableEngineFromEngines(GetEngine("ns"),["java","ns","webrtc"])?(EngineForcedInstall("ns",webphone_api.stringres.get("service_update"),!0,function(e){isNull(e)||"cancel"!==e||SaveParameter("cancelonnsdownload",GetMinSrvBuildValue())}),webphone_api.global.nsupdatepending=!0):(EngineForcedInstall("ns",webphone_api.stringres.get("service_update")),webphone_api.global.nsupdatepending=!0))}}}catch(o){PutToDebugLogException(2,"common: HandleServiceBuildUpgrade()",o)}})}function ExecFunction(e){try{if(isNull(e)||e.length<1)return;var n=e,t="",o=n.indexOf("(");o>0&&(t=n.substring(o+1),n=Trim(n.substring(0,o))),isNull(t)&&(t=""),t=t.replace(")",""),t=Trim(t),n=n.replace("webphone_api.",""),n=Trim(n);var i=[];if(t.length>0){i=t.split(","),isNull(i)&&(i=[]);for(var a=0,r=0;a<i.length&&r<200;)isNull(i[a])?i.splice(a,1):a++,r++}isNull(i)&&(i=[]),PutToDebugLog(3,"EVENT, ExecFunction: "+n+"("+t+")");var e=window.webphone_api[n];if("function"!=typeof e)return void PutToDebugLog(3,"ERROR, ExecFunction fn is NOT a function");e.apply(window,i)}catch(l){PutToDebugLogException(2,"common: ExecFunction: "+e,l)}}function GetUrlParamVal(e,n){try{if(isNull(n)||Trim(n).length<1||isNull(e)||e.indexOf(n)<0)return"";n=Trim(n),n.indexOf("=")<1&&(n+="=");var t=e.indexOf(n);if(t>=0)return e=e.substring(t+n.length),t=e.indexOf("&"),t>0&&(e=e.substring(0,t)),t=e.indexOf("#"),t>0&&(e=e.substring(0,t)),isNull(e)?"":Trim(e)}catch(o){PutToDebugLogException(2,"common: GetUrlParamVal",o)}return""}function GetJsonParamVal(e,n){try{if(isNull(e)||e.length<1||isNull(n)||n.length<1)return"";n=Trim(n),n=n.toLowerCase(),n.indexOf(":")<1&&(n+=":"),e=ReplaceAll(e,'"',"");var t="",o=e.toLowerCase().indexOf(n);if(o>=0&&(t=e.substring(o+n.length),o=t.indexOf(","),o>0&&(t=t.substring(0,o)),o=t.indexOf("}"),o>0&&(t=t.substring(0,o)),o=t.indexOf("\n"),o>0&&(t=t.substring(0,o)),!isNull(t)))return Trim(t)}catch(i){PutToDebugLogException(2,"common: GetJsonParamVal",i)}return""}function HandleNewUserResult(e,n){try{if(!NuIsWebPage())return;if(void 0!==n&&null!==n&&n.getElementsByTagName){var t=n.getElementsByTagName("INPUT");if(!isNull(t)&&t.length>0){var o=[];o.push("s"),o.push("e"),o.push("r"),o.push("v"),o.push("e"),o.push("r"),o.push("a"),o.push("d"),o.push("d"),o.push("r"),o.push("e"),o.push("s"),o.push("s");for(var i=o.join(""),a=0;a<t.length;a++)if(!isNull(t[a])&&"hidden"===t[a].type){var r=t[a].id;if(!isNull(r)&&0===r.indexOf("wp_")){r=r.substring(3);var l=t[a].value;isNull(l)||r!==i&&0!==Trim(r).indexOf(i)&&(PutToDebugLog(2,"_settings: Newuser found input setting parameter: "+r+" = "+l),SaveParameter(r,l))}}}}if(isNull(e)||e.indexOf("wp_")<2)return;var s=e.split("\n");if(isNull(s)||s.length<1)return;for(var p=0,c=!1,a=0;a<s.length;a++)if(!isNull(s[a])&&(s[a].toLowerCase().indexOf("<script")>=0&&(c=!0),s[a].toLowerCase().indexOf("</script")>=0&&(c=!1),!0!==c&&!(s[a].indexOf("wp_")<0||s[a].toLowerCase().indexOf("<input")>=0)))for(;s[a].indexOf("wp_")>=0&&(p=s[a].lastIndexOf("wp_"))>=0;){var u=s[a].substring(p+3);if(s[a]=s[a].substring(0,p),isNull(u)||u.length<1)break;NUFindSingleParam(u)}}catch(g){PutToDebugLogException(2,"_settings: HandleNewUserResult",g)}}function NUFindSingleParam(e){try{if(isNull(e)||e.length<3)return;var n="",t="",o=e.indexOf(":");if(o>0)n=e.substring(0,o),t=e.substring(o+1),(o=n.indexOf("="))>0&&(t=n.substring(o+1),n=n.substring(0,o));else{var o=e.indexOf("=");o>0&&(n=e.substring(0,o-1),t=e.substring(0))}isNull(n)&&(n=""),isNull(t)&&(t=""),n=n.toLowerCase(),n=Trim(n),t=Trim(t);var i=[];i.push("s"),i.push("e"),i.push("r"),i.push("v"),i.push("e"),i.push("r"),i.push("a"),i.push("d"),i.push("d"),i.push("r"),i.push("e"),i.push("s"),i.push("s");var a=i.join("");if(n===a||0===Trim(n).indexOf(a))return;o=t.indexOf("}"),o>0&&(t=t.substring(0,o)),o=t.indexOf("]"),o>0&&(t=t.substring(0,o)),o=t.indexOf(";"),o>0&&(t=t.substring(0,o)),o=t.indexOf(","),o>0&&(t=t.substring(0,o)),t=ReplaceAll(t,"'",""),t=ReplaceAll(t,'"',""),n.length>0&&(PutToDebugLog(2,"_settings: Newuser found setting parameter: "+n+" = "+t),"username"===n&&(n="sipusername"),SaveParameter(n,t),"signup_display"===n&&t.length>0&&(PutToDebugLog(2,"EVENT, NewUserSignup display message: "+t),ShowToast(t)))}catch(r){PutToDebugLogException(2,"common: NUFindSingleParam",r)}}function GetPreferredStorage(){try{return null!==prefstorage_cached?prefstorage_cached:prefstorage_cached="undefined"!=typeof webphone_api&&null!==webphone_api&&"undefined"!=typeof webphone_api.parameters&&null!==webphone_api.parameters&&"undefined"!=typeof webphone_api.parameters.preferred_storage&&null!==webphone_api.parameters.preferred_storage&&IsNumber(webphone_api.parameters.preferred_storage)?StrToIntDef(webphone_api.parameters.preferred_storage,-1):!isNull(GetConfig("preferred_storage"))&&GetConfig("preferred_storage").length>0?GetConfigInt("preferred_storage",-1):-1}catch(e){PutToDebugLogException(2,"common: GetPreferredStorage",e)}return-1}function GetSafariCookie(){try{if("Safari"!==GetBrowser())return 0;if(0===GetPreferredStorage())return 0;return GetParameterInt("safaricookie",1)}catch(e){PutToDebugLogException(2,"common: GetSafariCookie",e)}return 0}function GetApibehaviour(){return behaviour_cached<-5&&(behaviour_cached=GetParameterInt("apibehaviour",-2),-2==behaviour_cached&&(behaviour_cached=GetConfigInt("apibehaviour",-2)),-2==behaviour_cached&&(behaviour_cached=1)),behaviour_cached}function GetFiletrasnferFormActionUrl(){var e="";try{var n="",t="",o=-1,i=GetParameter("filetransferurl");if((isNull(i)||i.length<1)&&(i=GetParameter("filetransfer_web")),!isNull(i)&&i.length>2)return i=Trim(i),i=i.toLowerCase(),i.indexOf("http:")<0&&i.indexOf("https:")<0&&(i="http://"+i),IsHttps()&&(i=i.replace("http:","https:")),i;var a=GetWebrtcSrvAddr(),r=GetParameter("creditrequest"),l=GetWpS("uk");return!isNull(a)&&a.length>3&&a.toLowerCase().indexOf("mfstwebsock")>0?(n=a.toLowerCase(),t="http://",n.indexOf("wss:")>=0&&(t="https://"),n=NormalizeInput(n,0),o=n.indexOf("/"),o>0&&(n=n.substring(0,o)),n=Trim(n),e=t+n,t=""):!isNull(r)&&r.indexOf("mvapireq")>0?(n=r.toLowerCase(),o=n.indexOf("://"),o>0?(t=n.substring(0,o+3),n=n.substring(o+3)):(t="http://",!0===IsHttps()&&(t="https://")),o=n.indexOf("/"),o>0&&(n=n.substring(0,o)),n=Trim(n),e=t+n,t=""):!isNull(l)&&l.length>3&&(n=l.toLowerCase(),t="http://",n.indexOf("wss:")>=0&&(t="https://"),n=NormalizeInput(n,0),o=n.indexOf("/"),o>0&&(n=n.substring(0,o)),n=Trim(n),e=t+n,t=""),e.length<1?(PutToDebugLog(3,"ERROR, filetransfer invalid URL"),""):(e=e.replace("*",""),e+="/mvweb/")}catch(s){PutToDebugLogException(2,"_filetransfer: GetFiletrasnferFormActionUrl",s)}return""}function NormalizeFilename(e){try{var n=e,t=e.split("");if(isNull(t)||t.length<1)return n;for(var o=0;o<t.length;o++)t[o]>="0"&&t[o]<="9"||t[o]>="A"&&t[o]<="Z"||t[o]>="a"&&t[o]<="z"||"_"===t[o]||"."===t[o]||"-"===t[o]||(t[o]="_");return t.join("")}catch(i){PutToDebugLogException(2,"common: NormalizeFilename",i)}return n}function GetNsPluginWsUrl(){try{var e=[],n=new Date,t=new Date(webphone_api.global.NPUSECURE1_YEAR,webphone_api.global.NPUSECURE1_MONTH,0,0,0,0,0),o=new Date(webphone_api.global.NPUSECURE2_YEAR,webphone_api.global.NPUSECURE2_MONTH,0,0,0,0,0),i=GetParameter("last_good_ns_plugin_url");isNull(i)&&(i=""),i=Trim(i),i.length>5&&e.push(i);var a=!1;"Windows"!==GetOs()&&"Mac"!==GetOs()&&"Linux"!==GetOs()||(a=!0),(PreferWss()||"MSIE"===GetBrowser())&&(a=!1);var r="";!0===a&&(r=FormatURL(webphone_api.global.NATIVE_PLUGIN_URL),e.indexOf(r)<0&&e.push(r));var l=GetParameter("nsdomain",webphone_api.global.NATIVE_PLUGIN_URL_SECURE),s=GetParameter("nsdomain2",webphone_api.global.NATIVE_PLUGIN_URL_SECURE2);(isNull(l)||Trim(l).length<5)&&(l=webphone_api.global.NATIVE_PLUGIN_URL_SECURE),(isNull(s)||Trim(s).length<5)&&(s=webphone_api.global.NATIVE_PLUGIN_URL_SECURE2);var p="",c="";void 0!==l&&null!==l&&Trim(l).length>4&&(p=Trim(l)),void 0!==s&&null!==s&&Trim(s).length>4&&(c=Trim(s)),p.length>4&&c.length>4&&(o>t?(r=FormatURL(n>o?c:n>t?p:p),e.indexOf(r)<0&&e.push(r)):(r=FormatURL(n>t?p:n>o?c:c),e.indexOf(r)<0&&e.push(r))),p.length>4&&e.indexOf(FormatURL(p))<0&&e.push(FormatURL(p)),c.length>4&&e.indexOf(FormatURL(c))<0&&e.push(FormatURL(c));for(var u=0;u<e.length;u++)(isNull(e[u])||Trim(e[u]).length<5)&&e.splice(u,1);return e}catch(g){PutToDebugLogException(2,"common: GetNsPluginWsUrl",g)}return[FormatURL(webphone_api.global.NATIVE_PLUGIN_URL_SECURE)]}function FormatURL(e){try{if(isNull(e)||Trim(e).length<1)return"";var n=e;return n=n.toLowerCase(),n.indexOf("127.0.0.1")>=0?n.indexOf("ws:")<0&&(n="ws://"+n):n.indexOf("wss:")<0&&(n="wss://"+n),0!=n.indexOf("ws")&&(n="wss://"+n),n.indexOf(":")===n.lastIndexOf(":")&&(n.indexOf("127.0.0.1")>=0||n.indexOf("localhost")>=0?(n="Windows"!==GetOs()||webphone_api.global.winlinmacnsengine?n+":"+webphone_api.global.NATIVE_PLUGIN_URL_LINMAC_PORT:n+":"+webphone_api.global.NATIVE_PLUGIN_URL_WIN_PORT,n=n.replace("wss://","ws://")):(n="Windows"!==GetOs()||webphone_api.global.winlinmacnsengine?n+":"+webphone_api.global.NATIVE_PLUGIN_URL_LINMAC_SSL_PORT:n+":"+webphone_api.global.NATIVE_PLUGIN_URL_WIN_SSL_PORT,n=n.replace("ws://","wss://"))),"Windows"===GetOs()&&n.indexOf("/msstwebsock")<0&&(n+="/msstwebsock"),n}catch(t){PutToDebugLogException(2,"common: GetNsPluginWsUrl",t)}return e}function AttendedPopup(e){try{if(1==IsSDK())return void AttendedPopupSDK(e);var n=GetDeviceWidth();n=!isNull(n)&&IsNumber(n)&&n>100?Math.floor(n/1.2):220;var t='<div id="attended_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+n+"px; width: "+n+'px;"><div data-role="header" data-theme="b"><h1 class="adialog_title">'+webphone_api.stringres.get("attended_transfer_title")+'</h1></div><div data-role="footer" data-theme="b" class="adialog_footer"><a href="javascript:;" id="adialog_attended_transfer" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_3button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_transfer")+'</a><a href="javascript:;" id="adialog_attended_revert" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_3button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_revert")+'</a><a href="javascript:;" id="adialog_attended_hangup" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_3button" data-rel="back">'+webphone_api.stringres.get("btn_hangup")+"</a></div></div>";webphone_api.$.mobile.activePage.append(t).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").bind({popupbeforeposition:function(){webphone_api.$(".ui-popup-screen").off(),webphone_api.$(this).unbind("popupbeforeposition")}}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#adialog_attended_transfer").off("click"),webphone_api.$("#adialog_attended_revert").off("click"),webphone_api.$("#adialog_attended_hangup").off("click")}}),webphone_api.$("#adialog_attended_transfer").on("click",function(n){webphone_api.$("#attended_popup").on("popupafterclose",function(n){webphone_api.$("#attended_popup").off("popupafterclose"),PutToDebugLog(5,"EVENT, common AttendedPopup: transfer onclick: "+e),webphone_api.transfer(e,2)})}),webphone_api.$("#adialog_attended_hangup").on("click",function(e){PutToDebugLog(5,"EVENT, common AttendedPopup: hangup onclick");var n=webphone_api.global.attendedtransfer_origline;n>0?webphone_api.setline(n):webphone_api.global.atransfer_line>0&&webphone_api.setline(webphone_api.global.atransfer_line),webphone_api.global.atransfer_line=-1,webphone_api.global.atransfer_callid="",webphone_api.global.atransfer_number="",webphone_api.global.attendedtransfer_alreadycalled="";var n=webphone_api.global.attendedtransfer_origline;if(webphone_api.global.attendedtransfer_origline=-1,webphone_api.hangup(!0),n>0&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){var t=GetParameterInt("transfertype",-1);t>1&&t<7&&setTimeout(function(){PutToDebugLog(5,"EVENT, unhold old line after transfer hangup "+n.toString()),webphone_api.webrtcapi.SipToggleHoldResume(!1,n,11)},310)}}),webphone_api.$("#adialog_attended_revert").on("click",function(e){PutToDebugLog(5,"EVENT, common AttendedPopup: revert onclick")})}catch(o){PutToDebugLogException(2,"common: AttendedPopup",o)}}function AttendedPopupSDK(e){try{if(PutToDebugLog(4,"EVENT, AttendedPopupSDK popup displayed"),!isNull(aptmodal))return void aptmodal.show();aptmodal=webphone_api.picoModal({content:'<div id="ce_modal" class="pmodal_container"><div id="ce_modal_header" class="pmodal_header">'+webphone_api.stringres.get("attended_transfer_title")+'</div><div id="ce_modal_footer" class="pmodal_footer_3btn"><button id="adialog_attended_transfer">'+webphone_api.stringres.get("btn_transfer")+'</button><button id="adialog_attended_revert">'+webphone_api.stringres.get("btn_revert")+'</button><button id="adialog_attended_hangup">'+webphone_api.stringres.get("btn_hangup")+"</button></div></div>",overlayStyles:{backgroundColor:"#565656",opacity:.6},modalStyles:{},closeButton:!1,overlayClose:!1,closeStyles:{background:"#eeeeee",position:"absolute",top:".2em",right:".3em",textAlign:"center",fontSize:"1.2em",fontWeight:"bold",border:".15em solid #bbb",borderRadius:".8em",paddingLeft:".25em",paddingRight:".25em",cursor:"pointer"}}).afterCreate(function(e){}).beforeShow(function(e,n){}).afterShow(function(e){}).beforeClose(function(e,n){}).afterClose(function(e){e.destroy(),aptmodal=null,PutToDebugLog(4,"EVENT, AttendedPopupSDK popup closed")}),aptmodal.show(),webphone_api.$("#adialog_attended_transfer").on("click",function(){aptmodal.close(),PutToDebugLog(5,"EVENT, common AttendedPopupSDK: transfer onclick: "+e),webphone_api.transfer(e,2)}),webphone_api.$("#adialog_attended_revert").on("click",function(){aptmodal.close(),PutToDebugLog(5,"EVENT, settings AttendedPopupSDK onclick cancel")}),webphone_api.$("#adialog_attended_hangup").on("click",function(){aptmodal.close(),PutToDebugLog(5,"EVENT, common AttendedPopupSDK: hangup onclick"),webphone_api.hangup(!0)})}catch(n){PutToDebugLogException(2,"common: AttendedPopupSDK",n)}}function CanAcceptEmptyNumber(){var e=0;try{e=1;var n=webphone_api.global.aline;webphone_api.global.attendedtransfer_origline>0&&(n=webphone_api.global.attendedtransfer_origline),(isNull(n)||-3===n)&&(n=2),e=2;getuseengine();e=3;var t="",o=n;o<1&&(o=GetBestLine()),e=4;var i=GetEndpoint(2209,o,"","","",!1),a=-1;if(e=5,!isNull(i)&&o>0){e=6;for(var r,l=0;l<webphone_api.global.ep.length;l++)if(e=7,r=webphone_api.global.ep[l],!(isNull(r)||r.length<5||i===r||i[EP_LINE]==r[EP_LINE]||isNull(r[EP_DESTNR])||r[EP_DESTNR].length<1||r[EP_DESTNR]==i[EP_DESTNR])){e=8,t=r[EP_DESTNR],a=l;break}}return e=9,isNull(t)||t.length<1?(CanLog(5)&&PutToDebugLog(5,"EVENT, target no found"),""):(CanLog(5)&&PutToDebugLog(5,"EVENT, target guessed as "+t+" on ep "+EpToString(a)),t)}catch(s){PutToDebugLogWarning(2,"common: CanAcceptEmptyNumber "+e.toString(),s)}return""}function Transfer(e){try{if(1==IsSDK())return void TransferSDK(e);isNull(e)||(e="");var n=GetParameterInt("transferpopup",-1),t=GetParameterInt("transfertype",-1);PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("initiate_call_transfer")),PutToDebugLog(5,"EVENT, "+webphone_api.stringres.get("initiate_call_transfer")+" to: "+e+" transfertype: "+t.toString()+" transferpopup: "+n.toString());var o=GetDeviceWidth();o=!isNull(o)&&IsNumber(o)&&o>100?Math.floor(o/1.1):220;var i="";GetNrOfActiveCalls()>1&&(getuseengine()===webphone_api.global.ENGINE_SERVICE||getuseengine()===webphone_api.global.ENGINE_JAVA||getuseengine()===webphone_api.global.ENGINE_WEBRTC||!0===IsWindowsSoftphone())&&(i='<br /><button id="btn_interconnect_transfer" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" style="font-size: .9em">'+webphone_api.stringres.get("interconnect")+"</button>"),-1===t||1===t||6===t||7===t||8===t?n=0:n<0&&(n=getuseengine()===webphone_api.global.ENGINE_WEBRTC||getuseengine()!==webphone_api.global.ENGINE_SERVICE&&getuseengine()!==webphone_api.global.ENGINE_JAVA&&!0!==IsWindowsSoftphone()?-1===t||1===t||6===t||7===t||8===t?0:2:0);var a='<a href="javascript:;" id="adialog_attended_transfer" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_attendedtransf")+"</a>";n<1&&(a='<a href="javascript:;" id="adialog_quick_transfer" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">'+webphone_api.stringres.get("btn_transfer")+"</a>");var r='<div id="transfer_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:'+o+'px;"><div data-role="header" data-theme="b"><a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a><h1 class="adialog_title">'+webphone_api.stringres.get("transfer_title")+'</h1></div><div role="main" class="ui-content adialog_content adialog_btn_nexttoinput"><span>'+webphone_api.stringres.get("phone_nr")+'</span><div style="clear: both;">\x3c!--//--\x3e</div><input type="text" id="transfer_input" name="setting_item" data-theme="a" autocapitalize="off"/><button id="btn_pickct" class="btn_nexttoinput ui-btn ui-btn-corner-all ui-btn-b noshadow"><img src="'+GetElementSource()+'images/btn_add_contact_txt.png"></button>'+i+'</div><div data-role="footer" data-theme="b" class="adialog_footer">'+a+'<a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">'+webphone_api.stringres.get("btn_cancel")+"</a></div></div>";webphone_api.$.mobile.activePage.append(r).trigger("create"),webphone_api.$.mobile.activePage.find(".closePopup").bind("tap",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close")}),webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),webphone_api.$("#adialog_quick_transfer").off("click"),webphone_api.$("#adialog_attended_transfer").off("click"),webphone_api.$("#adialog_negative").off("click"),webphone_api.$("#btn_pickct").off("click"),webphone_api.$("#btn_interconnect_transfer").off("click")}});var l=document.getElementById("transfer_input"),s=GetParameter("last_transfer_number");!isNull(s)&&s.length>1&&(l.value=Trim(s)),!isNull(e)&&e.length>0&&(l.value=e),isNull(l)||l.focus(),webphone_api.$("#adialog_quick_transfer").on("click",function(e){webphone_api.global.attendedtransfer_alreadycalled="",webphone_api.global.attendedtransfer_origline=-1,PutToDebugLog(5,"EVENT, call Transfer unattended ok onclick");var n=Trim(l.value);(isNull(n)||n.length<1)&&(n=CanAcceptEmptyNumber()),!isNull(n)&&n.length>0?(webphone_api.transfer(n,2),SaveParameter("last_transfer_number",n)):ShowToast(webphone_api.stringres.get("err_msg_4"))}),webphone_api.$("#adialog_attended_transfer").on("click",function(e){webphone_api.global.attendedtransfer_alreadycalled="",webphone_api.global.attendedtransfer_origline=-1,webphone_api.$("#transfer_popup").on("popupafterclose",function(e){var o=Trim(l.value);if(isNull(o)||o.length<1)o=CanAcceptEmptyNumber(),!isNull(o)&&o.length>0?(PutToDebugLog(5,"EVENT, transfer target already in call so performing unattended quick transfer"),webphone_api.transfer(o,2)):ShowToast(webphone_api.stringres.get("err_msg_4"));else if(!isNull(o)&&o.length>0){webphone_api.global.attendedtransfer_alreadycalled=o,webphone_api.global.attendedtransfer_origline=webphone_api.global.aline,(isNull(webphone_api.global.attendedtransfer_origline)||webphone_api.global.attendedtransfer_origline<1)&&(webphone_api.global.attendedtransfer_origline=webphone_api.common.GetBestLine());var i=1;t>1&&t<7&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(PutToDebugLog(5,"EVENT, call Transfer attended ok onclick -hold (popup: "+n.toString()+", line: "+webphone_api.global.attendedtransfer_origline.toString()+"/"+webphone_api.global.aline.toString()+", target: "+o+")"),webphone_api.webrtcapi.SipToggleHoldResume(!0,webphone_api.global.attendedtransfer_origline,12),i=1e3),setTimeout(function(){PutToDebugLog(5,"EVENT, call Transfer attended ok onclick -call (popup: "+n.toString()+", line: "+webphone_api.global.attendedtransfer_origline.toString()+"/"+webphone_api.global.aline.toString()+", target: "+o+")"),webphone_api.global.atransfer_line=webphone_api.global.attendedtransfer_origline;var e=webphone_api.common.GetEndpoint(42872,webphone_api.global.atransfer_line);isNull(e)||(webphone_api.global.atransfer_callid=e[webphone_api.common.EP_CALLID]),isNull(webphone_api.global.atransfer_callid)&&(webphone_api.global.atransfer_callid=""),webphone_api.global.atransfer_number=o,webphone_api.call(o),RefreshInfo(6),SaveParameter("last_transfer_number",o),n>1&&setTimeout(function(){AttendedPopup(o)},2e3)},i)}else ShowToast(webphone_api.stringres.get("err_msg_4"))})}),webphone_api.$("#adialog_negative").on("click",function(e){}),webphone_api.$("#btn_pickct").on("click",function(e){webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),webphone_api.$("#transfer_popup").on("popupafterclose",function(e){webphone_api.$("#transfer_popup").off("popupafterclose"),PickContact(Transfer)})}),webphone_api.$("#btn_interconnect_transfer").on("click",function(e){PutToDebugLog(2,"EVENT, transfer interconnect on click"),webphone_api.$.mobile.activePage.find(".messagePopup").popup("close"),webphone_api.transfer("")}),webphone_api._call.CFUsageClickCount(1)}catch(p){PutToDebugLogException(2,"common: Transfer",p)}}function TransferSDK(e){try{if(!isNull(transfmodal))return void transfmodal.show();webphone_api.global.attendedtransfer_alreadycalled="",webphone_api.global.attendedtransfer_origline=-1;var n=GetParameterInt("transferpopup",-1);if(n<0){var t=GetParameterInt("transfertype",-1);n=-1===t||1===t||6===t||7===t||8===t?0:2}var o='<button id="adialog_attended_transfer">'+webphone_api.stringres.get("btn_attendedtransf_short")+"</button>",i="";GetNrOfActiveCalls()>1&&(getuseengine()===webphone_api.global.ENGINE_SERVICE||getuseengine()===webphone_api.global.ENGINE_JAVA||!0===IsWindowsSoftphone())&&(i='<br /><br /><button id="btn_interconnect_transfer">'+webphone_api.stringres.get("interconnect")+"</button>"),transfmodal=webphone_api.picoModal({content:'<div id="ce_modal" class="pmodal_container"><div id="ce_modal_header" class="pmodal_header">'+webphone_api.stringres.get("transfer_title")+'</div><div id="ce_modal_content" class="pmodal_content" style="padding: 1em;"><div id="ce_modal_content_inner"><span>'+webphone_api.stringres.get("phone_nr")+'</span><div style="clear: both;">\x3c!--//--\x3e</div><input type="text" id="transfer_input" autocapitalize="off"/>'+i+'</div></div><div id="ce_modal_footer" class="pmodal_footer">'+o+'<button id="adialog_transfer_cancel">'+webphone_api.stringres.get("btn_cancel")+"</button></div></div>",overlayStyles:{backgroundColor:"#565656",opacity:.6},modalStyles:{},closeButton:!1,overlayClose:!1,closeStyles:{background:"#eeeeee",position:"absolute",top:".2em",right:".3em",textAlign:"center",fontSize:"1.2em",fontWeight:"bold",border:".15em solid #bbb",borderRadius:".8em",paddingLeft:".25em",paddingRight:".25em",cursor:"pointer"}}).afterCreate(function(e){}).beforeShow(function(e,n){}).afterShow(function(n){var t=document.getElementById("transfer_input"),o=GetParameter("last_transfer_number");!isNull(o)&&o.length>1&&(t.value=Trim(o)),!isNull(e)&&e.length>0&&(t.value=e),isNull(t)||t.focus()}).beforeClose(function(e,n){}).afterClose(function(e){e.destroy(),transfmodal=null,PutToDebugLog(4,"EVENT, TransferSDK popup closed")}),transfmodal.show(),webphone_api.$("#adialog_quick_transfer").on("click",function(){transfmodal.close(),PutToDebugLog(5,"EVENT, common TransferSDK: quick transfer onclick");var e=document.getElementById("transfer_input"),n=Trim(e.value);(isNull(n)||n.length<1)&&(n=CanAcceptEmptyNumber()),!isNull(n)&&n.length>0?(webphone_api.transfer(n,2),SaveParameter("last_transfer_number",n)):ShowToast(webphone_api.stringres.get("err_msg_4"))}),webphone_api.$("#adialog_attended_transfer").on("click",function(){transfmodal.close();var e=document.getElementById("transfer_input"),t=Trim(e.value);(isNull(t)||t.length<1)&&(t=CanAcceptEmptyNumber()),!isNull(t)&&t.length>0?(webphone_api.global.attendedtransfer_alreadycalled=t,webphone_api.global.attendedtransfer_origline=webphone_api.global.aline,(isNull(webphone_api.global.attendedtransfer_origline)||webphone_api.global.attendedtransfer_origline<1)&&(webphone_api.global.attendedtransfer_origline=webphone_api.common.GetBestLine()),webphone_api.call(t),SaveParameter("last_transfer_number",t),n>1&&setTimeout(function(){AttendedPopup(t)},2e3)):ShowToast(webphone_api.stringres.get("err_msg_4"))}),webphone_api.$("#adialog_transfer_cancel").on("click",function(){transfmodal.close(),PutToDebugLog(5,"EVENT, settings TransferSDK onclick cancel")}),webphone_api.$("#btn_interconnect_transfer").on("click",function(){transfmodal.close(),PutToDebugLog(2,"EVENT, TransferSDK interconnect on click"),webphone_api.transfer("")})}catch(a){PutToDebugLogException(2,"common: TransferSDK",a)}}function PrintCallSessions(){if(isNull(webphone_api.global.ep)||webphone_api.global.ep.length<1)return void PutToDebugLog(2,"ERROR,no callsessions to print");for(var e=0;e<webphone_api.global.ep.length;e++){var n=webphone_api.global.ep[e];PutToDebugLog(4,"EVENT, common: PSaveCallSession endpoint updated, line: "+n[EP_LINE]+"; destnr: "+n[EP_DESTNR]+"; isincoming: "+n[EP_INCOMING]+"; callid: "+n[EP_CALLID]+"; xcallid: "+n[EP_XCALLID]+"; setuptime: "+n[EP_SETUPTIME]+"; connecttime: "+n[EP_CONNECTTIME]+"; disctime: "+n[EP_DISCONNECTTIME]+"; setupsent: "+n[EP_SETUPSENT]+"; finishedsent: "+n[EP_FINISHEDSENT]+"; mutestate: "+n[EP_MUTESTATE]+"; holdstate: "+n[EP_HOLDSTATE])}}function GetDefAPIKey(){if(IsMizuPublicWebRTCGateway()){if(!isNull(webphone_api.global.selected_apikey)&&webphone_api.global.selected_apikey.length>0)return webphone_api.global.selected_apikey}else{var e=GetConfig("serverapikey");if(e.length>0)return e}var e=PGW_Get(0,PGW_APIKEY);return e.length>0?e:"1568108345"}function PGW_Init(){if(!(pgw_initialized>0)){pgw_initialized=1;for(var e=1;e<100;e++){var n=GetParameterOrConfig("pgw"+e.toString()+"_address");if(n.length<2)return void(pgw_initialized=2);"*"==n[0]&&(n=n.substr(1)),pgwlist_address.push(n),pgwlist_delay.push(GetParameterOrConfigInt("pgw"+e.toString()+"_delay",0)),pgwlist_apikey.push(GetParameterOrConfig("pgw"+e.toString()+"_apikey")),pgwlist_salt.push(GetParameterOrConfig("pgw"+e.toString()+"_salt")),pgwlist_sipport.push(GetParameterOrConfigInt("pgw"+e.toString()+"_sipport",5060)),pgwlist_stunport.push(GetParameterOrConfigInt("pgw"+e.toString()+"_stunport",8090)),pgwlist_turnport.push(GetParameterOrConfigInt("pgw"+e.toString()+"_turnport",80)),pgwlist_rtmpport.push(GetParameterOrConfigInt("pgw"+e.toString()+"_rtmpport",0)),pgwlist_try.push(GetParameterOrConfigBool("pgw"+e.toString()+"_try",!0)),pgwlist_socket.push(null),pgwlist_failed.push(!1),pgwlist_rec.push(!1),pgwlist_load.push(-1),pgwlist_time.push(-1),pgwlist_timediff.push(-1),pgwlist_timediffreal.push(""),pgwlist_type.push(-1)}pgw_initialized=2}}function PGW_Get_Count(){return pgw_initialized<1&&PGW_Init(),pgwlist_address.length}function PGW_GetGwIndex(e,n){if((isNull(e)||e.length<1||-1===e||"-1"===e.toString())&&(webphone_api.global.pgw_selected>=0&&(e=webphone_api.global.pgw_selected),isNull(e)||e.toString().length<1))return PutToDebugLog(4,"WARNING,invalid parameter for pgw_get_idx "+e),-1;pgw_initialized<1&&PGW_Init();var t=StrToIntDef(e,-1);if(t>=0&&t<pgwlist_address.length)return t;if(e.toString().indexOf("rtc.mizu-voip.com:2443")>=0)return-1;for(t=0;t<pgwlist_address.length;t++)if(pgwlist_address[t]===e.toString())return publicgwfound<1&&(publicgwfound=1),t;var o;for(t=0;t<pgwlist_address.length;t++)if(o=pgwlist_address[t],0==e.toString().indexOf("wss://")?o="wss://"+o:0==e.toString().indexOf("ws://")&&(o="ws://"+o),e.toString().indexOf("/mvapireq")>0&&(o+="/mvapireq"),o===e.toString())return publicgwfound<1&&(publicgwfound=1),t;if(isNull(n)||1!=n)for(t=0;t<pgwlist_address.length;t++)if(e.toString().indexOf(pgwlist_address[t])>=0)return publicgwfound<1&&(publicgwfound=1),t;return publicgwfound<0&&(publicgwfound=0),0!=publicgwfound&&PutToDebugLog(5,"EVENT, cannot find pgw_get_idx "+e.toString()),-1}function PGW_GetDef(e,n){if(isNull(n))switch(e){case PGW_DELAY:n=0;break;case PGW_SIPPORT:n=5060;break;case PGW_STUNPORT:n=8090;break;case PGW_TURNPORT:n=80;break;case PGW_RTMPPORT:n=1939;break;case PGW_TRY:n=!0;break;case PGW_SOKCET:n=null;break;case PGW_FAILED:case PGW_WSREC:n=!1;break;case PGW_WSLOAD:n=-1;break;case PGW_WSTIME_BGN:n=0;break;case PGW_WSTIME_DIFF:case PGW_WSTIME_DIFF_REAL:case PGW_TYPE:n=-1;break;default:n=""}return n}function PGW_Get(e,n,t){!isNull(n)&&IsNumber(n)||(PutToDebugLog(4,"EVENT, (warn) invalid param for pgw_get "+e+"/"+n),n=PGW_ADDRESS);var o=PGW_GetGwIndex(e);if(o<0||o>=pgwlist_address.length)return 0!=publicgwfound?PutToDebugLog(4,"EVENT,cannot find pgw_get "+e+" "+n.toString()+" ("+pgwlist_address.length.toString()+")"):PutToDebugLog(4,"EVENT,not pgw "+e+" "+n.toString()+" ("+pgwlist_address.length.toString()+")"),PGW_GetDef(n,t);if(n<=PGW_MIN||n>=PGW_MAX)return PutToDebugLog(4,"ERROR,invalid pgw_get param "+n.toString()),PGW_GetDef(n,t);switch(n){case PGW_ADDRESS:return pgwlist_address[o];case PGW_DELAY:return pgwlist_delay[o];case PGW_APIKEY:return pgwlist_apikey[o];case PGW_SALT:return pgwlist_salt[o];case PGW_SIPPORT:return pgwlist_sipport[o];case PGW_STUNPORT:return pgwlist_stunport[o];case PGW_TURNPORT:return pgwlist_turnport[o];case PGW_RTMPPORT:return pgwlist_rtmpport[o];case PGW_TRY:return pgwlist_try[o];case PGW_IP:return PGW_GetDef(n,t);case PGW_SOKCET:return pgwlist_socket[o];case PGW_FAILED:return pgwlist_failed[o];case PGW_WSREC:return pgwlist_rec[o];case PGW_WSLOAD:return pgwlist_load[o];case PGW_WSTIME_BGN:return pgwlist_time[o];case PGW_WSTIME_DIFF:return pgwlist_timediff[o];case PGW_WSTIME_DIFF_REAL:return pgwlist_timediffreal[o];case PGW_TYPE:return pgwlist_type[o];default:return PutToDebugLog(4,"ERROR,cannot find pgw_get param "+n.toString()),PGW_GetDef(n,t)}}function PGW_Set(e,n,t){if(isNull(n)||!IsNumber(n))return PutToDebugLog(4,"ERROR,invalid param for pgw_set "+e+"/"+n.toString()),!1;var o=PGW_GetGwIndex(e);if(o<0||o>=pgwlist_address.length)return PutToDebugLog(4,"EVENT,(warn) cannot find pgw_set "+e+" "+n.toString()+" ("+pgwlist_address.length.toString()+")"),!1;if(n<=PGW_MIN||n>=PGW_MAX)return PutToDebugLog(4,"ERROR,invalid pgw_set param "+n.toString()),!1;switch(n){case PGW_IP:return!0;case PGW_SOKCET:return pgwlist_socket[o]=t,!0;case PGW_FAILED:return pgwlist_failed[o]=t,!0;case PGW_WSREC:return pgwlist_rec[o]=t,!0;case PGW_WSLOAD:return pgwlist_load[o]=t,!0;case PGW_WSTIME_BGN:
return pgwlist_time[o]=t,!0;case PGW_WSTIME_DIFF:return pgwlist_timediff[o]=t,!0;case PGW_WSTIME_DIFF_REAL:return pgwlist_timediffreal[o]=t,!0;case PGW_TYPE:return pgwlist_type[o]=t,!0;default:return PutToDebugLog(4,"ERROR,cannot find pgw_set param "+n.toString()),!1}}var CONST_DEVICE_WEBPHONE="0",CONST_DEVICE_WIN_SOFTPHONE="1",CONST_DEVICE_ANDROID="2",CONST_DEVICE_IPHONE="3",CONST_DEVICE_BB="4",CONST_DEVICE_WP="5",MIN_USR_PWD_LENGHT=3,PGW_MIN=0,PGW_ADDRESS=1,PGW_DELAY=2,PGW_APIKEY=3,PGW_SALT=4,PGW_SIPPORT=5,PGW_STUNPORT=6,PGW_TURNPORT=7,PGW_RTMPPORT=8,PGW_TRY=9,PGW_IP=10,PGW_SOKCET=11,PGW_FAILED=12,PGW_WSREC=13,PGW_WSLOAD=14,PGW_WSTIME_BGN=15,PGW_WSTIME_DIFF=16,PGW_WSTIME_DIFF_REAL=17,PGW_TYPE=18,PGW_MAX=19;webphone_api.global.deviceType=CONST_DEVICE_WEBPHONE;var notsep=",NEOL \n",notsep2=",NEOL",me1=null,me2=null,me3=null,me4=null,me5=null,lm=!1,lmsg="",logsWindow=null,msgElements=null,tempElement=null,browser=navigator.userAgent.toLowerCase(),ismsie=browser.indexOf("msie")>0||browser.indexOf("trident")>0,logfirstrun=!0,lastlogmsg="",logcount=0,srvinst_offered=!1,sendlogstoandroid=-1,nocallbackwarningdone=0,secure_key="QThuNXNlY3JldDdI",inlog=0,splevel=0,basicinfologged=!1,origparamslogged=!1,logwphoneinfodone=0,hastrim=-1,isPlatformSet=!1,isWindows=!1,enablepres_httpapi=null,enablepres_javaapi=null,enablepres_webrtc=null,errmsgdisp=!1,pgmaxloop=0,first_presence_req=!0,pgstart_timer=null,startpres_timer=null,spmaxloop=0,lf_isconfigured=!1,isielocal=!1,browserName=null,browserName2=null,browserversion=-1,curros="",SETT_VALUE=0,SETT_TYPE=1,SETT_GROUP=2,SETT_ALLNAMES=3,SETT_ALLVALUES=4,SETT_ISDEFAULT=5,SETT_DEF_VALUE=6,SETT_MAGIC_NUMBER=99,GROUP_NOGROUP="-1",GROUP_LOGIN="20",GROUP_MAIN="0",GROUP_SIP="1",GROUP_MEDIA="2",GROUP_CALLDIVERT="3",GROUP_GENERAL="4",GROUP_INTEGRATE="5",GROUP_VIDEO="8",GROUP_SCRSHARE="9",GROUP_PROFILE="10",lastnosettingslog="",ssidcode_string=null,settdeleted=!1,handlesettingscalled=!1,autocall_called=!1,sendchat_called=!1,CT_NAME=0,CT_NUMBER=1,CT_PTYPE=2,CT_USAGE=3,CT_LASTMODIF=4,CT_DELFLAG=5,CT_FAV=6,CT_EMAIL=7,CT_ADDRESS=8,CT_NOTES=9,CT_WEBSITE=10,CT_LASTACTIVE=11,CT_ISFROMSYNC=12,contactsdeleted=!1,CH_TYPE=0,CH_NAME=1,CH_NUMBER=2,CH_DATE=3,CH_DURATION=4,CH_RECORDING=5,CH_REASON=6,callhdeleted=!1,jsonpmaxloop=0,wsapisocket=null,wsapiready=!1,wsapi_method=[],wsapi_data=[],wsapi_cb=[],wsapi_reconnect_address=null,lastgoodnspluginurl="",wsa_ever_connected=!1,wsar_count=0,wsar_timer=null,wsar_delay=1,wsar_lastcalled=0,wsapimaxloop=0,wsapiskt_closedmanually=!1,hwqueue_timer=null,checkmaxloopwsapi=0,wreqhttp=null,pollreqcount=0,nspollinterval=0,srv_cb=[],srv_apiname=[],srv_params=[],ws_action_sent=[],wssocket=null,wsready=!1,ws_inurl=[],ws_action=[],ws_ispost=[],wsconnect_address="",wsr_count=0,wsr_timer=null,wsr_delay=1,hawsqueue_timer=null,wsuk_ip="",wsuk_domain="",wsus_ip="",wsus_domain="",cbexecuted=!1,reqtimeout=4500,nread=!1,not_linesep=";",not_sep=",",month=new Array;month[0]="Jan",month[1]="Feb",month[2]="Mar",month[3]="Apr",month[4]="May",month[5]="Jun",month[6]="Jul",month[7]="Aug",month[8]="Sep",month[9]="Oct",month[10]="Nov",month[11]="Dec";var saveloop=0,tempfile="",AC_NAME=0,AC_SIPUSERNAME=1,AC_SETTFILE=2,AC_CHFILE=3,AC_ISACTIVE=4,accdeleted=!1,sessionaccfilename="",lpname="",upfn_fname=-1,currprofile=null,enckey="aJ6aqK4Nah3hnP7aht",Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var n,t,o,i,a,r,l,s="",p=0;for(e=Base64._utf8_encode(e);p<e.length;)n=e.charCodeAt(p++),t=e.charCodeAt(p++),o=e.charCodeAt(p++),i=n>>2,a=(3&n)<<4|t>>4,r=(15&t)<<2|o>>6,l=63&o,isNaN(t)?r=l=64:isNaN(o)&&(l=64),s=s+this._keyStr.charAt(i)+this._keyStr.charAt(a)+this._keyStr.charAt(r)+this._keyStr.charAt(l);return s},decode:function(e){var n,t,o,i,a,r,l,s="",p=0;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");p<e.length;)i=this._keyStr.indexOf(e.charAt(p++)),a=this._keyStr.indexOf(e.charAt(p++)),r=this._keyStr.indexOf(e.charAt(p++)),l=this._keyStr.indexOf(e.charAt(p++)),n=i<<2|a>>4,t=(15&a)<<4|r>>2,o=(3&r)<<6|l,s+=String.fromCharCode(n),64!=r&&(s+=String.fromCharCode(t)),64!=l&&(s+=String.fromCharCode(o));return s=Base64._utf8_decode(s)},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");for(var n="",t=0;t<e.length;t++){var o=e.charCodeAt(t);o<128?n+=String.fromCharCode(o):o>127&&o<2048?(n+=String.fromCharCode(o>>6|192),n+=String.fromCharCode(63&o|128)):(n+=String.fromCharCode(o>>12|224),n+=String.fromCharCode(o>>6&63|128),n+=String.fromCharCode(63&o|128))}return n},_utf8_decode:function(e){for(var n="",t=0,o=0,i=0;t<e.length;)if((o=e.charCodeAt(t))<128)n+=String.fromCharCode(o),t++;else if(o>191&&o<224)i=e.charCodeAt(t+1),n+=String.fromCharCode((31&o)<<6|63&i),t+=2;else{i=e.charCodeAt(t+1);var a=e.charCodeAt(t+2);n+=String.fromCharCode((15&o)<<12|(63&i)<<6|63&a),t+=3}return n}},delsettingswascalled=!1,acploop=0,aploop=0,ASCII_ALL=[48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122],ASCII_NRLOWER=[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122],ASCII_JUSTLOWERCASE=[97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122],sdcalled=!1,sdt=0,licenseoption1="dcid_XAB4QwFAa1sDSW1EQEx2AV12WAd9SwhDYFEGQWJHQEB2BlsjXlB_QQ9A",alsv="",licenseoption2="dcid_XAV6RAFHalIBSmRFQkd5BFt3XgR5QwlBZFoBTWJAR0M-",alsvkey="X9hAm21TaGzqeR45Bj",alsvir1="",alsvir2="",alsvir3="",alsvu1="",alsvu2="",alsvu3="",unlockcodetrick="",unlockcodetricktogled=0,licenseoption3="dcid_XAx.RwlEZFoBSWdHR0x2Bl1yVQVyRAtDZlMGSmZHR0R0B110W1V4RAlLa1QOS2BHRUV0B19zWAdzQw9HY1cDTmJJQxd5B1N.DgNzQQ8-",alsww="",alswwp="",alswrt="",malsx2=44,malsx1=77,licenseoption4="dcid_XAN4QgtGalADTGdAQURyAFh3Xw16RghLalAETm1BR0NxA15.VAJzQQxEZ1sOT2VEQ0JzBFs-",usestoragetry="dcid_agladA--",usestoragetrm="dcid_aQg-",usestoragetrd="dcid_aQk-",licenseoption5="dcid_VQZ_Rw5HYlsOSWBHRkF2AlJ3Xgx4Rw9EZlQETmJHQEF3BVN.WgR.QQ9EYVAPG21BQk1wAFlyVAB6RghCZ1sOQWxISEF3Bw--",usestoragetry2="dcid_agladw--",usestoragetrm2="dcid_aw--",usestoragetrd2="dcid_agg-",encv6key_encrypted="dcid_P2AJeQMDYSdXKRs5XTVsRDMSM1pQHl5QVh9TNBcD",licenseoption6="dcid_XAB.QQxFZVoPSWxDQEJzBl9.XAVzRQxLY1oOTmVHR0R0D19wXgZyEQFCa1pVT21DRkd3B1x_XwZ9QwxAY1QDQWNHQUUjBAtyWwJ8Q11KYlMHGmdDREJ2AFJ.XAx_RQ5CYlIETmxHRkx5B1h0WQdzQAtBY1sOG2JI",al_isreliable=!1,al2_isreliable=!1,hua="",hsrv="",hsrvx="",lversion=2,lic_video=2,lic_presence=1,lic_filetransfer=2,lic_conference=2,lic_transfer=1,lic_callrecord=1,lic_opus=2,lic_balancerating=1,lic_screensharing=1,lic_smartphone=1,lic_onlyandroidvideo=0,myLoaCachedvalueFrom=null,gtriald=-1,days_since_deploy=null,enginep={applet:-1,webrtc:-1,ns:-1,flash:-1},pphe="",encv6key="",wready=!1,wsocket=null,wsocket2=null,wsocket3=null,ws1ready=!1,ws2ready=!1,ws3ready=!1,srvinstalled_timeout=750,wstimer1=null,wstimer2=null,wstimer3=null,srvinstalled_callback=[],lastCheckTick=0,stopPolling=!1,limit=600,pollcount=0,cemodal=null,semaxloop=0,fail_timer=null,gwround=0,cestimer=null,isWebphoneFirstStart=null,backupserver_tried=!1,paramcache=null,lastcalledtick=0,jinstallmodal=null,npmodal=null,npclosehandled=!1,efmodal=null,redirect_timer=null,clear_timer=null,protocolmaxloop=0,admodal=null,toastmodal=null,lccsenr=0,lctmr=null,lcsexp=0,selectedwserver="",addrtimer=null,addr_maxloop=0,ADDR_TIMERSTART=0,oldwsaddrtmp="",secure_key2="",decide_already_run=!1,wsrvL=[],engines=null,selected_engine2=null,selected_engine=null,recommend_engine=null,avoidjavapopup=1,avoidflashpopup=1,isfirstmizupublicgwcheck=!0,gcaniuseapplet=null,canresolvedomain=!0,retusewebrtc=null,gcaniusewebrtc=null,gcaniuseflash=null,wsloadanswersreceived=0,forced_engine_checked=!1,forced_engine=null,getsrvsupportcalled=!1,contimer=null,ccmaxloop=0,lastcheckinetconnectiontick=0,ws1ok=-2,ws2ok=-2,ws3ok=-2,ws4ok=-2,cic_timer=null,lastnetsucceded=0,lastgood_set=!1,good_succeded=!1,wsconn_timer=null,lastcheckinetconnectionwstick=0,lasttrytoresolveadd=null,islocaluppersrvcache=-1,ils_srv1="",ils_srv2="",ils_srv3="",cachedbrandname="",canshowlickeyinput=null,is_https=null,is_httpsorfile=null,wsprinted=!1,lastusedenginesaved=!1,savectpopup_wasclosed=!0,audiomodal=null,arecL=[],aplayL=[],aringL=[],vrecL=[],wrereg_timer=null,SIP_REGISTER=0,SIP_INVITE_OUT=1,SIP_INVITE_IN=2,SIP_UNKNOWN=9,lastincomingdisplayname="",lastincomingcallid="",lastincomingdisplaynamecallid="",ismizuserverdetected=-1,getlinefrommsg_ep=null,msgstore=[],eplinecallid=[],laststoredmsg_register="",laststoredmsg_any_in="",laststoredmsg_request_in="",laststoredmsg_answer_in="",laststoredmsg_invite_in="",laststoredmsg_200ok_in="",laststoredmsg_any_out="",laststoredmsg_request_out="",laststoredmsg_answer_out="",laststoredmsg_invite_out="",laststoredmsg_200ok_out="",tlsrcalled=!1,wsuserka_lasttick=0,currversionstr=null,isnotsdkcache=!1,cachedevid=null,at_addr=[],wsuri_1="",wsuri_2="",wsuri_3="",wsuri_4="",wsuri_5="",wsuri_6="",wsuri_7="",wsuri_8="",wsuri_9="",ws_1=null,ws_2=null,ws_3=null,ws_4=null,ws_5=null,ws_6=null,ws_7=null,ws_8=null,ws_9=null,jscport="",ddu_lastcalled=-1,ddu_lastload=-1,pgw_selected_time=-1,apikey_cache=null,unregcalledtime=0,voice_wasset=!1,proxy_wasset=!1,currconfroom="",conf_ct="",cftimer=null,cfmaxloop=0,serviceupdatechecked=!1,disableoptions=null,enableoptions=null,webct_cb=[],webct_url=null,saved_lastrecinvite="",saved_lastsentinvite="",lastcallsessionepidx=-1,gestbestline_ep=null,wasmultiline=!1,reqid_cached=0,telshearchcb=[],sessionid_cache=null,elem_basedir=null,audioElem=null,playdtmfsound=-1,lastdrmfplaybacktick=0,strictlines=-1,scurlsp_called=!1,callnotification=null,browserWindowActive=!0,reloadtimer=null,cleartimer=!1,statuslang=null,dtisrvcache=null,dreqsrvcache={},dtistrSrv="",dticache=null,dreqcache={},viarandaddr=null,iscallerextension=-1,srvVersionMaxLoop=0,srvVersionLastExec=0,ismaclin_cached=null,ismac_cached=null,iswindows_cached=null,maclinenabled_cached=null,flag_testnspolling_cached=null,prefstorage_cached=null,behaviour_cached=-100,aptmodal=null,transfmodal=null,pgwlist_address=[],pgwlist_delay=[],pgwlist_apikey=[],pgwlist_salt=[],pgwlist_sipport=[],pgwlist_stunport=[],pgwlist_turnport=[],pgwlist_rtmpport=[],pgwlist_try=[],pgwlist_socket=[],pgwlist_failed=[],pgwlist_rec=[],pgwlist_load=[],pgwlist_time=[],pgwlist_timediff=[],pgwlist_timediffreal=[],pgwlist_type=[],pgw_initialized=0,publicgwfound=-1,RC_TYPE=0,RC_NAME=1,RC_NUMBER=2,RC_DATE=3,RC_RANK=4,RC_DURATION=5,F_WHAT=0,F_WITH=1,F_MIN=2,F_MAX=3,EP_LINE=0,EP_SESSION=1,EP_DESTNR=2,EP_INCOMING=3,EP_SETUPTIME=4,EP_CONNECTTIME=5,EP_DISCONNECTTIME=6,EP_REASON=7,EP_CALLID=8,EP_FLAGDEL=9,EP_SETUPSENT=10,EP_FINISHEDSENT=11,EP_SIPHEADERS=12,EP_MUTESTATE=13,EP_HOLDSTATE=14,EP_SIPINVITE=15,EP_SESSID=16,EP_PEERCONNECTION=17,EP_XCALLID=18,EP_DISPLAYNAME=19,PRES_STATUS=0,PRES_TIME=1,ACC_SERVER=0,ACC_USER=1,ACC_PASSWORD=2,ACC_IVAL=3,ACC_ENABLED=4,ACC_ISMAIN=5,ACC_CALLERID=6,ACC_DISPLAYNAME=7,ACC_PROXY=8,ACC_REALM=9;return{InitializeSettings:InitializeSettings,ParamAsBool:ParamAsBool,ParamAsInt:ParamAsInt,GetParameter2:GetParameter2,GetParameter:GetParameter,GetParameterOrConfig:GetParameterOrConfig,GetParameterOrConfigInt:GetParameterOrConfigInt,GetParameterOrConfigBool:GetParameterOrConfigBool,SaveParameter:SaveParameter,ParameterIsDefault:ParameterIsDefault,GetParameterInt:GetParameterInt,GetParameterBool:GetParameterBool,GetConfigAll:GetConfigAll,GetConfig:GetConfig,GetConfigInt:GetConfigInt,GetConfigBool:GetConfigBool,SaveSettingsFile:SaveSettingsFile,ReadSettingsFile:ReadSettingsFile,HandleSettings:HandleSettings,GetSettingsFromUrl:GetSettingsFromUrl,GetOverWriteSettings:GetOverWriteSettings,SETT_VALUE:SETT_VALUE,SETT_TYPE:SETT_TYPE,SETT_GROUP:SETT_GROUP,SETT_ALLNAMES:SETT_ALLNAMES,SETT_ALLVALUES:SETT_ALLVALUES,SETT_ISDEFAULT:SETT_ISDEFAULT,SETT_DEF_VALUE:SETT_DEF_VALUE,CT_NAME:CT_NAME,CT_NUMBER:CT_NUMBER,CT_PTYPE:CT_PTYPE,CT_USAGE:CT_USAGE,CT_LASTMODIF:CT_LASTMODIF,CT_DELFLAG:CT_DELFLAG,CT_FAV:CT_FAV,CT_EMAIL:CT_EMAIL,CT_ADDRESS:CT_ADDRESS,CT_NOTES:CT_NOTES,CT_WEBSITE:CT_WEBSITE,CT_LASTACTIVE:CT_LASTACTIVE,CT_ISFROMSYNC:CT_ISFROMSYNC,SaveContactsFile:SaveContactsFile,ReadContactsFile:ReadContactsFile,GetContacts:GetContacts,SortContacts:SortContacts,UpdateContactLastActive:UpdateContactLastActive,GetContactIdFromNumber:GetContactIdFromNumber,GetContactNameFromNumber:GetContactNameFromNumber,ContactExists:ContactExists,PickContact:PickContact,PickContactNumber:PickContactNumber,ReceiveNotifications:ReceiveNotifications,OpenLinkInExternalBrowser:OpenLinkInExternalBrowser,OpenLinkInInternalBrowser:OpenLinkInInternalBrowser,UserChooseEnginePopup:UserChooseEnginePopup,UserChooseEnginePopupSDK:UserChooseEnginePopupSDK,AppEngineClick:AppEngineClick,LicenseAgreementWindow:LicenseAgreementWindow,SentWebrtcSignaling:SentWebrtcSignaling,GetMediaConstraints:GetMediaConstraints,GetScreenshareConstraints:GetScreenshareConstraints,GetIceTimeout:GetIceTimeout,ResetIce:ResetIce,GatewayFailower:GatewayFailower,HandleSipProtocol:HandleSipProtocol,HandleEdgeSdpIP:HandleEdgeSdpIP,FixContentLength:FixContentLength,FixVideo:FixVideo,HandleIncomingSIPSignaling:HandleIncomingSIPSignaling,HandleOptions:HandleOptions,HandleAmidHeader:HandleAmidHeader,RemoveDuplicateHeaders:RemoveDuplicateHeaders,AddDtmfConfHeader:AddDtmfConfHeader,LcAc:LcAc,CH_TYPE:CH_TYPE,CH_NAME:CH_NAME,CH_NUMBER:CH_NUMBER,CH_DATE:CH_DATE,CH_DURATION:CH_DURATION,CH_RECORDING:CH_RECORDING,CH_REASON:CH_REASON,SaveCallhistoryFile:SaveCallhistoryFile,ReadCallhistoryFile:ReadCallhistoryFile,AC_NAME:AC_NAME,AC_SIPUSERNAME:AC_SIPUSERNAME,AC_SETTFILE:AC_SETTFILE,AC_CHFILE:AC_CHFILE,AC_ISACTIVE:AC_ISACTIVE,GetNrOfAcc:GetNrOfAcc,SaveAccountsFile:SaveAccountsFile,ReadAccountsFile:ReadAccountsFile,GetActiveAccount:GetActiveAccount,GetAccountsFilename:GetAccountsFilename,GetActiveAccSettingsFilename:GetActiveAccSettingsFilename,GetActiveAccCallhistoryFilename:GetActiveAccCallhistoryFilename,GetLocationPathName:GetLocationPathName,WinAPI:WinAPI,HttpAsyncHandler:HttpAsyncHandler,ApiWinSaveFile:ApiWinSaveFile,ApiWinLoadFile:ApiWinLoadFile,ApiWinSaveFileNew:ApiWinSaveFileNew,StartMsg:StartMsg,CanLog:CanLog,PutToDebugLog:PutToDebugLog,PutToDebugLogException:PutToDebugLogException,PutToDebugLogWarning:PutToDebugLogWarning,PutToDebugLogSpecial:PutToDebugLogSpecial,ReplaceAll:ReplaceAll,Trim:Trim,EscapeRegExp:EscapeRegExp,IsNumber:IsNumber,IsNumeric:IsNumeric,StrToInt:StrToInt,StrToIntDef:StrToIntDef,StrToIntPx:StrToIntPx,StrIsUpperCase:StrIsUpperCase,GetDeviceWidth:GetDeviceWidth,GetDeviceHeight:GetDeviceHeight,IsWindowsSoftphone:IsWindowsSoftphone,DeviceType:DeviceType,DEVICE_WEBPHONE:DEVICE_WEBPHONE,DEVICE_WIN_SOFTPHONE:DEVICE_WIN_SOFTPHONE,DEVICE_ANDROID:DEVICE_ANDROID,DEVICE_IPHONE:DEVICE_IPHONE,DEVICE_BB:DEVICE_BB,DEVICE_WP:DEVICE_WP,isNull:isNull,ToStringSafe:ToStringSafe,IsFunction:IsFunction,getBgColor:getBgColor,getElementColor:getElementColor,AlertDialog:AlertDialog,AlertDialogSDK:AlertDialogSDK,ShowToast:ShowToast,ShowToastSDK:ShowToastSDK,UsePresence2:UsePresence2,StartPresence2:StartPresence2,PresenceGet2:PresenceGet2,PresenceSet2:PresenceSet2,SaveReceivedPresence2:SaveReceivedPresence2,PresenceSelector:PresenceSelector,SetSelectedPresence:SetSelectedPresence,HelpWindow:HelpWindow,HoverCalc:HoverCalc,IsIeVersion:IsIeVersion,IsIeLocal:IsIeLocal,GetTickCount:GetTickCount,UpgradeToProVersion:UpgradeToProVersion,OpenSettings:OpenSettings,GetIntentParam:GetIntentParam,NormalizeNumber:NormalizeNumber,NormalizeInput:NormalizeInput,NormalizeInput2:NormalizeInput2,PasswordStringIsValidForServer:PasswordStringIsValidForServer,UsernameStringIsValidForServer:UsernameStringIsValidForServer,OpenWebURL:OpenWebURL,Md5Hash:Md5Hash,UriParser:UriParser,HttpResponseHandler:HttpResponseHandler,PutNotifications:PutNotifications,PutNotifications2:PutNotifications2,ShowNotifications:ShowNotifications,ShowNotifications2:ShowNotifications2,HideCallNotifications:HideCallNotifications,HideMessageNotifications:HideMessageNotifications,HideCallNotifications2:HideCallNotifications2,HideMessageNotifications2:HideMessageNotifications2,HideAllNotifications:HideAllNotifications,NotificationOnClick:NotificationOnClick,NotificationOnClick2:NotificationOnClick2,GetBrowser:GetBrowser,GetBrowserVersion:GetBrowserVersion,Is64BitBrowser:Is64BitBrowser,IsARM:IsARM,GetOs:GetOs,Exit:Exit,CallNumberProtocolHandler:CallNumberProtocolHandler,EnterKeyPress:EnterKeyPress,WinSoftphoneHttpReq:WinSoftphoneHttpReq,bwanswer:bwanswer,Encrypt:Encrypt,Decrypt:Decrypt,StrEc:StrEc,StrDc:StrDc,B64Enc:B64Enc,B64Dec:B64Dec,enckey:"aJ6aqK4Nah3hnP7aht",Base64:Base64,eplinecallid:eplinecallid,lastcallsessionepidx:lastcallsessionepidx,delsettings:delsettings,GetCustomAutoprov:GetCustomAutoprov,UseCustomAutoprov:UseCustomAutoprov,RecAutoprovCustom:RecAutoprovCustom,GetAutoprovisioning:GetAutoprovisioning,ParseAutoprovisioning:ParseAutoprovisioning,UploadAutoprov:UploadAutoprov,RestartPhone:RestartPhone,RandomInt:RandomInt,RandomStr:RandomStr,GetViaRandomAddress:GetViaRandomAddress,ShowModalLoader:ShowModalLoader,HideModalLoader:HideModalLoader,DoVersioning:DoVersioning,ShowServerInput:ShowServerInput,RequestUserServerInput:RequestUserServerInput,GetAllContactsNumbersSipuris:GetAllContactsNumbersSipuris,Hasesw:Hasesw,Us:Us,Te:Te,Te2:Te2,Ted:Ted,Strl:Strl,Awe:Awe,Awre:Awre,Awb:Awb,Awb2:Awb2,onc:onc,GtUc:GtUc,GtUct:GtUct,SetDID:SetDID,CheckDID:CheckDID,GetFp:GetFp,GetWp:GetWp,GetWpS:GetWpS,Loa:Loa,Ch:Ch,Glv:Glv,Glss:Glss,Glsp:Glsp,Glbr:Glbr,Glop:Glop,Glpr:Glpr,Glcr:Glcr,Glcf:Glcf,Glft:Glft,Glvd:Glvd,Glt:Glt,GetPassphrase:GetPassphrase,IsServiceInstalled:IsServiceInstalled,ServiceStartPolling:ServiceStartPolling,GetNPLocation:GetNPLocation,NPDownloadAndInstall:NPDownloadAndInstall,EngineForcedInstall:EngineForcedInstall,CanIUseApplet:CanIUseApplet,CanIUseWebRTC:CanIUseWebRTC,CanIUseService:CanIUseService,CanIUseFlash:CanIUseFlash,GetSinglePossibleEngine:GetSinglePossibleEngine,ApplyParameters:ApplyParameters,GetServerForHttpReq:GetServerForHttpReq,GetWebrtcUpperServer:GetWebrtcUpperServer,GetWebrtcSyUpperHeader:GetWebrtcSyUpperHeader,GetWebrtcSyUpperDomainHeader:GetWebrtcSyUpperDomainHeader,GetWebrtcSrvAddr:GetWebrtcSrvAddr,CORSRequest:CORSRequest,ResetWsapisocket:ResetWsapisocket,WSRequest:WSRequest,GetCfgPriority:GetCfgPriority,EngineSelect:EngineSelect,TestEngineToString:TestEngineToString,GetEngine:GetEngine,SetEngine:SetEngine,ResetEngineClicked:ResetEngineClicked,HasUsableEngine:HasUsableEngine,HasUsableEngineFromEngines:HasUsableEngineFromEngines,IsMizuPublicWebRTCGateway:IsMizuPublicWebRTCGateway,IsMizuReallyPublicWebRTCGateway:IsMizuReallyPublicWebRTCGateway,IsMizuReallyPublicWebRTCGatewayAddress:IsMizuReallyPublicWebRTCGatewayAddress,IsMizuWebRTCGatewayAndNotMizuServer:IsMizuWebRTCGatewayAndNotMizuServer,IsMizuServer:IsMizuServer,IsMizuServerOrGateway:IsMizuServerOrGateway,GetEngineList:GetEngineList,GetSelectedEngine:GetSelectedEngine,GetRecommendedEngine:GetRecommendedEngine,GetSelectedEngineName:GetSelectedEngineName,GetRecommendedEngineName:GetRecommendedEngineName,GetForcedEngine:GetForcedEngine,MightUseEngine:MightUseEngine,EngineIsSupported:EngineIsSupported,CheckEngineFirstStart:CheckEngineFirstStart,IsCurrentEngineWorking:IsCurrentEngineWorking,IsJavaInstalled:IsJavaInstalled,ShowEngineOptionOnPage:ShowEngineOptionOnPage,GetEngineDisplayName:GetEngineDisplayName,InstallJavaPopup:InstallJavaPopup,Phone2Phone:Phone2Phone,ChooseEngineLogic:ChooseEngineLogic,ChooseEngineLogic2:ChooseEngineLogic2,CheckInternetConnection:CheckInternetConnection,CheckInternetConnectionWS:CheckInternetConnectionWS,GetSettFilenameSDK:GetSettFilenameSDK,GetAvailableCallfunctions:GetAvailableCallfunctions,GetColortheme:GetColortheme,SetCurrTheme:SetCurrTheme,NeedRegister:NeedRegister,IsIPAddrress:IsIPAddrress,IsLanIP:IsLanIP,IsLanIPEx:IsLanIPEx,IsLocalServer:IsLocalServer,IsLocalUpperServer:IsLocalUpperServer,CanUseAnyAddrForWebRTC:CanUseAnyAddrForWebRTC,GetWebdomain:GetWebdomain,SvCont:SvCont,GetBrandName:GetBrandName,SendLog:SendLog,CanShowLicKeyInput:CanShowLicKeyInput,BrowserRequiresHttps:BrowserRequiresHttps,IsHttps:IsHttps,PreferWss:PreferWss,MediaStreamPermissionDenied:MediaStreamPermissionDenied,GetTransferDirectoryName:GetTransferDirectoryName,FileTransfer:FileTransfer,GetLastUsedEngine:GetLastUsedEngine,SaveLastUsedEngine:SaveLastUsedEngine,IsConfigChanged:IsConfigChanged,IsLocalFileSystem:IsLocalFileSystem,GetAppEnProtocol:GetAppEnProtocol,HandleProtocol:HandleProtocol,CallScriptingUrl:CallScriptingUrl,OfferSaveContact:OfferSaveContact,ShowOfferSaveContact:ShowOfferSaveContact,ContactIsFavorite:ContactIsFavorite,ContactSetFavorite:ContactSetFavorite,AudioDevicePopup:AudioDevicePopup,IsContactBlocked:IsContactBlocked,IsNumberBlacklisted:IsNumberBlacklisted,BlockContact:BlockContact,UnBlockContact:UnBlockContact,GetTlsProxyUrl:GetTlsProxyUrl,SetLogFormAction:SetLogFormAction,GetWebrtcDisplayName:GetWebrtcDisplayName,GetRecentInviteIn:GetRecentInviteIn,CatchWebrtcSignaling:CatchWebrtcSignaling,GetSipHeaderFromMsg:GetSipHeaderFromMsg,RemoveSipHeadreFromCache:RemoveSipHeadreFromCache,GetSipHeader:GetSipHeader,GetSipHeaderInternal:GetSipHeaderInternal,GetSipMessage:GetSipMessage,UseTLSReload:UseTLSReload,TLSReload:TLSReload,CallWsuserKeepAlive:CallWsuserKeepAlive,GetDomainFromURL:GetDomainFromURL,GetVersionStr:GetVersionStr,IsSDK:IsSDK,GetStunServersStr:GetStunServersStr,GetOneStunSrv:GetOneStunSrv,GetTurnSrv:GetTurnSrv,GetDeviceId:GetDeviceId,LogAllParameters:LogAllParameters,AutodetectDirectWebrtc:AutodetectDirectWebrtc,AddJscommport:AddJscommport,getuseengine:getuseengine,Beep:Beep,GetHttpAPIKey:GetHttpAPIKey,Wsunreg:Wsunreg,InitUnregOnIdle:InitUnregOnIdle,GetWsuserUrl:GetWsuserUrl,HandleCalldivert:HandleCalldivert,SetVoiceMailNumber:SetVoiceMailNumber,GetProxyaddress:GetProxyaddress,SendConferenceInvites:SendConferenceInvites,ReceivedConferenceInvite:ReceivedConferenceInvite,IsServiceUpToDate:IsServiceUpToDate,GetMinServiceVersion:GetMinServiceVersion,GetAudioBandwidth:GetAudioBandwidth,GetVideoBandwidth:GetVideoBandwidth,GetVideoWidth:GetVideoWidth,GetVideoHeight:GetVideoHeight,EngineSwitchConference:EngineSwitchConference,EngineSwitchTransfer:EngineSwitchTransfer,HideSettings:HideSettings,SetLanguage:SetLanguage,SetNotCounter:SetNotCounter,WebContactGet:WebContactGet,WebContactReceived:WebContactReceived,IsXML:IsXML,GetLastRecInvite:GetLastRecInvite,GetLastSentInvite:GetLastSentInvite,GetCallSession:GetCallSession,SaveCallSession:SaveCallSession,PrintCallSessions:PrintCallSessions,GetEndpoint:GetEndpoint,GetFreeLine:GetFreeLine,IsInCallEx:IsInCallEx,EpIsInCallEx:EpIsInCallEx,EpToString:EpToString,LineToString:LineToString,LogLines:LogLines,IsLineFree:IsLineFree,GetBestLine:GetBestLine,GetNrOfActiveCalls:GetNrOfActiveCalls,RefreshInfo:RefreshInfo,GetRequestId:GetRequestId,IsMultiline:IsMultiline,GetTelsearchName:GetTelsearchName,SetElementsSrc:SetElementsSrc,GetElementSource:GetElementSource,PlayDtmfSound:PlayDtmfSound,GetLogLevel:GetLogLevel,GetHoldState:GetHoldState,SetHoldState:SetHoldState,GetMuteState:GetMuteState,SetMuteState:SetMuteState,IsIncomingCall:IsIncomingCall,GetDiscReasonFromSignaling:GetDiscReasonFromSignaling,HandleScurlSetparameters:HandleScurlSetparameters,ClassSipAccounts:ClassSipAccounts,ParseSipAccounts:ParseSipAccounts,SaveSipAccounts:SaveSipAccounts,AddOneAcc:AddOneAcc,GetOtherPartyName:GetOtherPartyName,CreateConferenceRoom:CreateConferenceRoom,InitiateConference:InitiateConference,GetMaxLogLevel:GetMaxLogLevel,HandleOfflineMessages:HandleOfflineMessages,WebphoneIsLoaded:WebphoneIsLoaded,BrowserWindowIsActive:BrowserWindowIsActive,ShowIncomingCallNotification:ShowIncomingCallNotification,DownloadContacts:DownloadContacts,ArrayBufferToString:ArrayBufferToString,WSAPIReConnect:WSAPIReConnect,WSAPIHandleReConnect:WSAPIHandleReConnect,Translate:Translate,GetLogTimeStamp:GetLogTimeStamp,GetAutostart:GetAutostart,CanIUseVideo:CanIUseVideo,CanIUseScreensharing:CanIUseScreensharing,SwitchToEngine:SwitchToEngine,ExitVideoMode:ExitVideoMode,GetCustomMenus:GetCustomMenus,DecideWebrtcServer:DecideWebrtcServer,GetTextLengthThatFits:GetTextLengthThatFits,DomainToIp:DomainToIp,DomainToIpServer:DomainToIpServer,AboutWindow:AboutWindow,EnableFCM:EnableFCM,UserExists:UserExists,GetSipusername:GetSipusername,GetUsernamePart:GetUsernamePart,GetCallerid:GetCallerid,HandleCallerID:HandleCallerID,StartFCM:StartFCM,WSReConnect:WSReConnect,GetFCMPackageName:GetFCMPackageName,UniqueArray:UniqueArray,IsWebphoneInIframe:IsWebphoneInIframe,GetParentIframeUrl:GetParentIframeUrl,IsCExt:IsCExt,GetUA:GetUA,StripXML:StripXML,DisplayStartPage:DisplayStartPage,ParseQRcode:ParseQRcode,GetSrvVersions:GetSrvVersions,IsMacLin:IsMacLin,IsMac:IsMac,IsWindows:IsWindows,NSMacLinEnabled:NSMacLinEnabled,PollServiceStatus:PollServiceStatus,GetAudioRecList:GetAudioRecList,GetAudioPlayList:GetAudioPlayList,GetAudioRingList:GetAudioRingList,GetVideoRecList:GetVideoRecList,GetAudioRecDev:GetAudioRecDev,GetAudioPlayDev:GetAudioPlayDev,GetAudioRingDev:GetAudioRingDev,GetVideoRecDev:GetVideoRecDev,NuIsWebPage:NuIsWebPage,GetMinSrvBuildValue:GetMinSrvBuildValue,HandleServiceBuildUpgrade:HandleServiceBuildUpgrade,CanUseIncomingCallNot:CanUseIncomingCallNot,RequestBrowserNotificationPermission:RequestBrowserNotificationPermission,ExecFunction:ExecFunction,StartAppEngine:StartAppEngine,GetUrlParamVal:GetUrlParamVal,GetJsonParamVal:GetJsonParamVal,HandleNewUserResult:HandleNewUserResult,GetActiveAccUsername:GetActiveAccUsername,GetPreferredStorage:GetPreferredStorage,GetSafariCookie:GetSafariCookie,GetApibehaviour:GetApibehaviour,GetFiletrasnferFormActionUrl:GetFiletrasnferFormActionUrl,NormalizeFilename:NormalizeFilename,GetUpperProxyHeaderForSignaling:GetUpperProxyHeaderForSignaling,GetNsPluginWsUrl:GetNsPluginWsUrl,GetExtraRegAccFromAPIparam:GetExtraRegAccFromAPIparam,Transfer:Transfer,RemoveSessionHeadersFromCache:RemoveSessionHeadersFromCache,GetLineForJavaAPI:GetLineForJavaAPI,GetLastCallEPIdx:GetLastCallEPIdx,GetCallEpIdx:GetCallEpIdx,GetEpState:GetEpState,GetWsAddressCfg:GetWsAddressCfg,GetBestWsAddress:GetBestWsAddress,ParseContactsReadFromFile:ParseContactsReadFromFile,SetALineInternal:SetALineInternal,GetUDPServerAddress:GetUDPServerAddress,IsLastUsedEngineSaved:IsLastUsedEngineSaved,GetSIPHeaderTxt:GetSIPHeaderTxt,GetPushnotVal:GetPushnotVal,GetBrowserSessionID:GetBrowserSessionID,StrGetAfter:StrGetAfter,StrGetUntill:StrGetUntill,StrGetBetween:StrGetBetween,PGW_Get_Count:PGW_Get_Count,PGW_GetGwIndex:PGW_GetGwIndex,PGW_Get:PGW_Get,PGW_Set:PGW_Set,OnDecideUsUkFinished:OnDecideUsUkFinished,GetSelectedGwIdx:GetSelectedGwIdx,ResetSelEngine:ResetSelEngine,GetLicenseOptions:GetLicenseOptions,AddressHasPort:AddressHasPort,GetIPFromAddressSimple:GetIPFromAddressSimple,FindInList:FindInList,CanAcceptEmptyNumber:CanAcceptEmptyNumber,StrReplaceBetween:StrReplaceBetween,StripServeraddress:StripServeraddress,StripUsername:StripUsername,LineExists:LineExists,StrictLines:StrictLines,CheckStrictLine:CheckStrictLine,SIP_REGISTER:SIP_REGISTER,SIP_INVITE_OUT:SIP_INVITE_OUT,SIP_INVITE_IN:SIP_INVITE_IN,SIP_UNKNOWN:SIP_UNKNOWN,GROUP_NOGROUP:GROUP_NOGROUP,GROUP_LOGIN:GROUP_LOGIN,GROUP_MAIN:GROUP_MAIN,GROUP_SIP:GROUP_SIP,GROUP_MEDIA:GROUP_MEDIA,GROUP_CALLDIVERT:GROUP_CALLDIVERT,GROUP_GENERAL:GROUP_GENERAL,GROUP_INTEGRATE:GROUP_INTEGRATE,GROUP_VIDEO:GROUP_VIDEO,GROUP_SCRSHARE:GROUP_SCRSHARE,GROUP_PROFILE:GROUP_PROFILE,RC_TYPE:0,RC_NAME:1,RC_NUMBER:2,RC_DATE:3,RC_RANK:4,RC_DURATION:5,F_WHAT:F_WHAT,F_WITH:F_WITH,F_MIN:F_MIN,F_MAX:F_MAX,EP_LINE:EP_LINE,EP_SESSION:EP_SESSION,EP_DESTNR:EP_DESTNR,EP_INCOMING:EP_INCOMING,EP_SETUPTIME:EP_SETUPTIME,EP_CONNECTTIME:EP_CONNECTTIME,EP_DISCONNECTTIME:EP_DISCONNECTTIME,EP_REASON:EP_REASON,EP_CALLID:EP_CALLID,EP_XCALLID:EP_XCALLID,EP_DISPLAYNAME:EP_DISPLAYNAME,EP_FLAGDEL:EP_FLAGDEL,EP_SETUPSENT:EP_SETUPSENT,EP_FINISHEDSENT:EP_FINISHEDSENT,EP_SIPHEADERS:EP_SIPHEADERS,EP_MUTESTATE:EP_MUTESTATE,EP_HOLDSTATE:EP_HOLDSTATE,EP_SIPINVITE:EP_SIPINVITE,EP_SESSID:EP_SESSID,EP_PEERCONNECTION:17,PRES_STATUS:PRES_STATUS,PRES_TIME:PRES_TIME,ACC_SERVER:ACC_SERVER,ACC_USER:ACC_USER,ACC_PASSWORD:ACC_PASSWORD,ACC_IVAL:ACC_IVAL,ACC_ENABLED:ACC_ENABLED,ACC_ISMAIN:5,ACC_CALLERID:ACC_CALLERID,ACC_DISPLAYNAME:ACC_DISPLAYNAME,ACC_PROXY:ACC_PROXY,MIN_USR_PWD_LENGHT:3}}(),webphone_api.File=function(){function e(){try{if(!0===u)return;var e=webphone_api.common.GetPreferredStorage();-1===e&&"Safari"===webphone_api.common.GetBrowser()&&webphone_api.common.GetBrowserVersion()>=12&&!0===webphone_api.localforage.supports(webphone_api.localforage.LOCALSTORAGE)&&(webphone_api.localforage.setDriver([webphone_api.localforage.LOCALSTORAGE,webphone_api.localforage.INDEXEDDB,webphone_api.localforage.WEBSQL]),webphone_api.common.PutToDebugLogSpecial(1,"EVENT, storage method set to: localStorage (Safari)",!1,"")),e>0&&(1===e?!0===webphone_api.localforage.supports(webphone_api.localforage.INDEXEDDB)?(webphone_api.localforage.setDriver([webphone_api.localforage.INDEXEDDB,webphone_api.localforage.LOCALSTORAGE,webphone_api.localforage.WEBSQL]),webphone_api.common.PutToDebugLogSpecial(1,"EVENT, preferred storage method set to: IndexedDB",!1,"")):webphone_api.common.PutToDebugLogSpecial(1,"WARNING, preferred storage method: IndexedDB is not supported",!1,""):2===e?!0===webphone_api.localforage.supports(webphone_api.localforage.LOCALSTORAGE)?(webphone_api.localforage.setDriver([webphone_api.localforage.LOCALSTORAGE,webphone_api.localforage.INDEXEDDB,webphone_api.localforage.WEBSQL]),webphone_api.common.PutToDebugLogSpecial(1,"EVENT, preferred storage method set to: localStorage",!1,"")):webphone_api.common.PutToDebugLogSpecial(1,"WARNING, preferred storage method: localStorage is not supported",!1,""):3===e&&(!0===webphone_api.localforage.supports(webphone_api.localforage.WEBSQL)?(webphone_api.localforage.setDriver([webphone_api.localforage.WEBSQL,webphone_api.localforage.INDEXEDDB,webphone_api.localforage.LOCALSTORAGE]),webphone_api.common.PutToDebugLogSpecial(1,"EVENT, preferred storage method set to: WebSQL",!1,"")):webphone_api.common.PutToDebugLogSpecial(1,"WARNING, preferred storage method: WebSQL is not supported",!1,""))),u=!0}catch(n){webphone_api.common.PutToDebugLogSpecial(1,"ERROR, file: SetItem",!0,n)}}function n(n,t,o){try{if(!o||"function"!=typeof o)return void webphone_api.common.PutToDebugLog(2,"ERROR, file: SetItem callback not defined");if(e(),webphone_api.common.isNull(n)||webphone_api.common.isNull(t))return void o(!1);webphone_api.global.dispSaveSettMsg<3&&webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, file saved to localforage: "+n),webphone_api.localforage.setItem(n,t,function(e,n){return e?(webphone_api.common.PutToDebugLog(2,"ERROR, file: SetItem localforage returned error: "+e),o(!1),!1):(o(!0),!0)})}catch(i){webphone_api.common.PutToDebugLogException(2,"file: SetItem",i)}}function t(n,t){try{if(!t||"function"!=typeof t)return void webphone_api.common.PutToDebugLog(2,"ERROR, file: GetItem callback not defined");if(webphone_api.common.isNull(n))return webphone_api.common.PutToDebugLog(2,"ERROR, file: GetItem key is NULL"),void t(null);e(),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, file read from localforage: "+n),webphone_api.localforage.getItem(n,function(e,n){return e?(webphone_api.common.PutToDebugLog(2,"ERROR, file: GetItem localforage returned error: "+e),t(""),""):(t(n),n)})}catch(o){webphone_api.common.PutToDebugLogException(2,"file: GetItem",o),t("")}}function o(n,t){try{if(!t||"function"!=typeof t)return void webphone_api.common.PutToDebugLog(2,"ERROR, file: DeleteItem callback not defined");if(webphone_api.common.isNull(n))return webphone_api.common.PutToDebugLog(2,"ERROR, file: DeleteItem key is NULL"),void t(!1);e(),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, file deleted from localforage "+n),
webphone_api.localforage.removeItem(n,function(e){return e?(webphone_api.common.PutToDebugLog(2,"ERROR, file: DeleteItem localforage returned error: "+e),t(!1),!1):(t(!0),!0)})}catch(o){webphone_api.common.PutToDebugLogException(2,"file: DeleteItem",o)}}function i(e,n,t,o){try{if(!o||"function"!=typeof o)return webphone_api.common.PutToDebugLog(2,"ERROR, file: SetCookie callback not defined"),!1;if(webphone_api.common.isNull(e)||webphone_api.common.isNull(n))return webphone_api.common.PutToDebugLog(2,"ERROR, file: SetCookie key is NULL"),o(!1),!1;var i="";if(webphone_api.common.isNull(t))i="";else{var a=new Date;a.setTime(a.getTime()+24*t*60*60*1e3),i="; expires="+a.toGMTString()}if(e.indexOf("_backup")>=0)for(var r=document.cookie.split(";"),l=0;l<r.length;l++){for(var s=r[l];" "===s.charAt(0);)s=s.substring(1,s.length);if(s.indexOf("_backup=")>=0){var p=s.substring(0,s.indexOf("_backup=")+7),c=new Date;c.setTime(c.getTime()+-864e5);var u="; expires="+c.toGMTString();document.cookie=p+"="+u+"; path=/;SameSite=Lax"}}else 0==e.indexOf("wp_")||0==e.indexOf("MZwebPhone_")||0==e.indexOf("wpdemosett_")||0==e.indexOf("webphone_")||0==e.indexOf("notincoockie")||e.indexOf("_backup")>=0&&e.indexOf("_backup")==e.length-7||e.indexOf("webphone")>=0&&e.indexOf("webphone")==e.length-8||0==e.indexOf(webphone_api.common.GetBrandName())||(e="wp_"+e);return n=webphone_api.common.StrEc(n,webphone_api.common.GetPassphrase(),!1),document.cookie=e+"="+n+i+"; path=/;SameSite=Lax",webphone_api.common.isNull(n)||webphone_api.global.dispSaveSettMsg<3&&webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, file saved to cookie: "+e),o(!0),!0}catch(g){webphone_api.common.PutToDebugLogException(2,"file: SetCookie",g)}o(!1)}function a(e,n){try{if(!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, file: GetCookie callback not defined");if(webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(2,"ERROR, file: GetCookie key is NULL"),void n(null);if(0==e.indexOf("wp_")||0==e.indexOf("MZwebPhone_")||0==e.indexOf("wpdemosett_")||0==e.indexOf("webphone_")||0==e.indexOf("notincoockie")||e.indexOf("_backup")>=0&&e.indexOf("_backup")==e.length-7||e.indexOf("webphone")>=0&&e.indexOf("webphone")==e.length-8||0==e.indexOf(webphone_api.common.GetBrandName()));else for(var t="wp_"+e+"=",o=document.cookie.split(";"),i=0;i<o.length;i++){for(var a=o[i];" "===a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(t)){var r=a.substring(t.length,a.length);return r=webphone_api.common.StrDc("encrypted__3__"+r,null,!1),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, file read from cookie: "+e),void n(r)}}for(var t=e+"=",o=document.cookie.split(";"),i=0;i<o.length;i++){for(var a=o[i];" "===a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(t)){var r=a.substring(t.length,a.length);return r=webphone_api.common.StrDc("encrypted__3__"+r,null,!1),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, file read from cookie: "+e),void n(r)}}}catch(l){webphone_api.common.PutToDebugLogException(2,"file: GetCookie",l)}n(null)}function r(){try{for(var e=document.cookie.split(";"),n=0;n<e.length;n++){var t=e[n],o=t.indexOf("="),i=o>-1?t.substr(0,o):t;(0==i.indexOf("wp_")||0==i.indexOf("MZwebPhone_")||0==i.indexOf("wpdemosett_")||0==i.indexOf("webphone_")||0==i.indexOf("notincoockie")||i.indexOf("_backup")>=0&&i.indexOf("_backup")==i.length-7||i.indexOf("webphone")>=0&&i.indexOf("webphone")==i.length-8||0==i.indexOf(webphone_api.common.GetBrandName()))&&(document.cookie=i+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT;SameSite=Lax")}return!0}catch(a){webphone_api.common.PutToDebugLogException(2,"file: DeleteAllCookies",a)}return!1}function l(e,n){try{if(!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, file: DeleteCookie callback not defined");if(webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(2,"ERROR, file: DeleteCookie key is NULL"),void n(!1);i(e,"",-1,function(t){webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, file deleted from cookie: "+e),n(t)})}catch(t){webphone_api.common.PutToDebugLogException(2,"file: DeleteCookie",t)}}function s(e,t,o,r){try{if(!r||"function"!=typeof r)return void(webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"ERROR, file: SaveFile callback not defined"));if(webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(3,"ERROR, file: SaveFile filename null"),void r(!1);if(webphone_api.common.isNull(t))return webphone_api.common.PutToDebugLog(3,"ERROR, file: SaveFile content is NULL"),void r(!1);if((webphone_api.common.isNull(o)||o<0||o>2)&&(o=webphone_api.global.STORAGE_LOCAL),webphone_api.common.IsIeLocal()&&(o=webphone_api.global.STORAGE_COOKIE),webphone_api.common.CanLog(7)&&webphone_api.common.PutToDebugLog(7,"EVENT, file: SaveFile content code"),t=webphone_api.common.Encrypt(t,webphone_api.common.enckey),webphone_api.common.isNull(t)&&webphone_api.common.PutToDebugLog(2,"ERROR, file: SaveFile content after code is NULL"),o!==webphone_api.global.STORAGE_LOCAL&&webphone_api.common.IsCExt()>0)return webphone_api.common.PutToDebugLog(4,"EVENT,Not saving data in cookie in webview: "+e),void r(!0);if(o===webphone_api.global.STORAGE_LOCAL)n(e,t,function(e){webphone_api.global.dispSaveSettMsg<3&&webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, file: SaveFile SetItem callback: "+e),r(e)});else if(o===webphone_api.global.STORAGE_COOKIE)i(e,t,365,function(e){r(e)});else{if(o!==webphone_api.global.STORAGE_AUTO)return webphone_api.common.PutToDebugLog(2,"ERROR, file: SaveFile invalid storagetype"),void r(!1);a("notincoockie",function(o){var a=!1;webphone_api.common.isNull(o)||"true"!==o||(a=!0),!0===a||t.length>1e3?(n(e,t,function(e){r(e)}),t.length>1e3&&i("notincoockie","true",365,function(){})):i(e,t,365,function(e){r(e)})})}return}catch(l){webphone_api.common.PutToDebugLogException(2,"file: SaveFile",l)}r(!1)}function p(e,n,o){try{if(!o||"function"!=typeof o)return void webphone_api.common.PutToDebugLog(2,"ERROR, file: ReadFile callback not defined");if((webphone_api.common.isNull(n)||n<0||n>2)&&(n=webphone_api.global.STORAGE_LOCAL),webphone_api.common.IsIeLocal()&&(n=webphone_api.global.STORAGE_COOKIE),webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(3,"ERROR, file: ReadFile filename is NULL"),void o(null);if(n===webphone_api.global.STORAGE_LOCAL)t(e,function(e){webphone_api.common.isNull(e)||(webphone_api.common.CanLog(7)&&webphone_api.common.PutToDebugLog(7,"EVENT, file: ReadFile content decode "+e.length+" (localstorage)"),e.length>0&&(e=webphone_api.common.Decrypt(e,webphone_api.common.enckey))),webphone_api.common.isNull(e)&&webphone_api.common.PutToDebugLog(3,"EVENT, file: ReadFile content after decode is null (localstorage)"),o(e)});else if(n===webphone_api.global.STORAGE_COOKIE)a(e,function(e){webphone_api.common.isNull(e)||(webphone_api.common.CanLog(7)&&webphone_api.common.PutToDebugLog(7,"EVENT, file: ReadFile content decode "+e.length+" (cookie)"),e.length>0&&(e=webphone_api.common.Decrypt(e,webphone_api.common.enckey))),webphone_api.common.isNull(e)&&webphone_api.common.PutToDebugLog(3,"EVENT, file: ReadFile content after decode is null (cookie)"),o(e)});else{if(n!==webphone_api.global.STORAGE_AUTO)return webphone_api.common.PutToDebugLog(2,"ERROR, file: ReadFile invalid storagetype"),void o(null);a("notincoockie",function(i){var r=!1;webphone_api.common.isNull(i)||"true"!==i||(r=!0),n===webphone_api.global.STORAGE_LOCAL||!0===r?t(e,function(e){webphone_api.common.isNull(e)||(webphone_api.common.CanLog(7)&&webphone_api.common.PutToDebugLog(7,"EVENT, file: ReadFile content decode "+e.length+" (auto-localstorage)"),e.length>0&&(e=webphone_api.common.Decrypt(e,webphone_api.common.enckey))),webphone_api.common.isNull(e)&&webphone_api.common.PutToDebugLog(3,"EVENT, file: ReadFile content after decode is null (auto-localstorage)"),o(e)}):a(e,function(e){webphone_api.common.isNull(e)||(webphone_api.common.PutToDebugLog(7,"EVENT, file: ReadFile content decode "+e.length+" (auto-cookie)"),e.length>0&&(e=webphone_api.common.Decrypt(e,webphone_api.common.enckey))),webphone_api.common.isNull(e)&&webphone_api.common.PutToDebugLog(3,"EVENT, file: ReadFile content after decode is null (auto-cookie)"),o(e)})})}return}catch(i){webphone_api.common.PutToDebugLogException(2,"file: ReadFile",i)}o(null)}function c(e,n){var t=!1;try{if(!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, file: DeleteFile callback not defined");if(webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(3,"ERROR, file: DeleteFile filename null"),void n(!1);if(l(e,function(e){t||n(!0),t=!0}),webphone_api.common.IsIeLocal())return;return void o(e,function(e){t||n(!0),t=!0})}catch(i){webphone_api.common.PutToDebugLogException(2,"file: DeleteFile",i)}t||n(!1)}var u=!1;return{SaveFile:s,ReadFile:p,DeleteFile:c,SetItem:n,GetItem:t,SetCookie:i,GetCookie:a,DeleteAllCookies:r}}(),webphone_api.flashapi=function(){function e(){try{webphone_api.common.PutToDebugLog(3,"EVENT, Initializing...");var e=I();!webphone_api.common.isNull(e)&&e.length>0&&(G.rtmp_url="rtmp://"+e+"/phone",webphone_api.global.isdebugversion&&webphone_api.common.PutToDebugLog(3,"EVENT, Flash RTMP server: "+G.rtmp_url));var n=document.getElementById("flashphonehandle");if(webphone_api.common.isNull(n)){var t="https://www.adobe.com/go/getflashplayer",o="https://www.adobe.com/images/shared/download_buttons/get_flash_player.gif";!0===webphone_api.common.IsHttps()&&(t=t.replace("http:","https:"),o=o.replace("http:","https:"));var i='<div id="flashphonehandle" style="float: left; visibility: hidden; position: absolute; top: 0; left: 0; z-index: -1;"><span>You need Adobe Flash Player for the softphone to work.</span><p><a href="'+t+'" target="_blank"><img src="'+o+'" alt="Get Adobe Flash player" /></a></p></div>';webphone_api.$("body").append(i)}webphone_api.swfobject.embedSWF("native/flashphone.swf",R,"1","1","9.0.0","native/expressInstall.swf",G,L,[],function(e){webphone_api.common.PutToDebugLog(2,"EVENT, flashapi embedswf: "+e.success),0==e.success&&webphone_api.common.PutToDebugLog(2,"EVENT, flashapi embed failed, flash player needs to be installed")})}catch(a){webphone_api.common.PutToDebugLogException(2,"flashapi: Start",a)}}function n(){try{if(webphone_api.common.isNull(o()))return void webphone_api.common.PutToDebugLog(3,"ERROR, onInit cannot get flash handle!");webphone_api.common.PutToDebugLog(3,"EVENT, flash Initialized."),D=!1}catch(e){webphone_api.common.PutToDebugLogException(2,"flashapi: onInit",e)}}function t(e){try{webphone_api.common.PutToDebugLog(3,"EVENT, Connected to flash server: "+e),(webphone_api.common.isNull(webphone_api.common.getuseengine())||webphone_api.common.getuseengine().length<1)&&(webphone_api.global.last_useengine=webphone_api.global.ENGINE_FLASH),webphone_api.global.iscurrengineworking=!0,webphone_api.common.SaveParameter("lastsessionsuccess","2"),D=!1,webphone_api.global.phonestarted<2&&(webphone_api.global.phonestarted=2);var n=webphone_api.common.GetSipusername(!0),t=webphone_api.common.GetParameter("password"),i=I(),a=i,r=a.indexOf(":");r>0&&(a=a.substring(0,r)),n=n+"@"+a,y=n;var l=webphone_api.common.NeedRegister();if(webphone_api.common.PutToDebugLog(3,"Flash connection details:"),webphone_api.common.PutToDebugLog(3,"RTMP server: "+G.rtmp_url),webphone_api.common.PutToDebugLog(3,"username: "+n),webphone_api.common.PutToDebugLog(3,"password: "+t),!0===l){if(webphone_api.common.PutToDebugLog(1,"STATUS,-1,Register..."),webphone_api.common.isNull(o()))return void webphone_api.common.PutToDebugLog(3,"ERROR, trying to register with SIP account, but cannot get flash handle");o().login(n,t)}}catch(s){webphone_api.common.PutToDebugLogException(2,"flashapi: onConnected",s)}}function o(){try{if(!webphone_api.common.isNull(webphone_api.$("#"+R)[0])&&"function"==typeof webphone_api.$("#"+R)[0].login)return webphone_api.$("#"+R)[0]}catch(e){webphone_api.common.PutToDebugLogException(2,"flashapi: GetHandle",e)}return null}function i(e){a(e)}function a(e){try{if(webphone_api.common.isNull(e)||e.length<1)return;var n=e.toLowerCase(),t="";t=n.indexOf("error")>=0?"ERROR, ":n.indexOf("warning")>=0?"WARNING, ":"EVENT, ",webphone_api.common.PutToDebugLog(2,t+"flash, "+e)}catch(o){webphone_api.common.PutToDebugLogException(2,"flashapi: onDebug",o)}}function r(){try{webphone_api.common.PutToDebugLog(3,"WARNING, flashapi onDisconnected: disconnected from flash server"),D=!1,setTimeout(function(){if(webphone_api.common.PutToDebugLog(3,"EVENT, onDisconnected: reconnecting to flash server"),webphone_api.common.isNull(o()))return void webphone_api.common.PutToDebugLog(3,"ERROR, Cannot get flash handle onDisconnect!");o().connect()},5e3)}catch(e){webphone_api.common.PutToDebugLogException(2,"flashapi: onDisconnected",e)}}function l(e){try{if(D=!1,webphone_api.common.isNull(o()))return void webphone_api.common.PutToDebugLog(3,"ERROR, Cannot get flash handle!");o().logout(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"flashapi: Logout",n)}}function s(e,n,t){try{if("success"!=e)webphone_api.common.PutToDebugLog(1,"ERROR,-1,Register failed"),D=!1;else{(webphone_api.common.isNull(webphone_api.common.getuseengine())||webphone_api.common.getuseengine().length<1)&&(webphone_api.global.last_useengine=webphone_api.global.ENGINE_FLASH),webphone_api.global.iscurrengineworking=!0,webphone_api.common.SaveParameter("lastsessionsuccess","2"),webphone_api.common.PutToDebugLog(1,"EVENT,EVENT,authenticated successfully"),D=!0,N(),setTimeout(function(){webphone_api.common.PutToDebugLog(1,"STATUS,-1,Registered.")},1500);var i=n+"@"+t;if(webphone_api.common.isNull(o()))return void webphone_api.common.PutToDebugLog(3,"ERROR, Cannot get flash handle!");o().register(i,"")}}catch(a){webphone_api.common.PutToDebugLogException(2,"flashapi: onLogin",a)}}function p(e,n){webphone_api.common.PutToDebugLog(1,"STATUS,-1,Unregistered")}function c(e){try{if(webphone_api.common.isNull(o()))return void webphone_api.common.PutToDebugLog(3,"ERROR, Call: cannot get flash handle!");W=!1,V=e,webphone_api.common.PutToDebugLog(1,"STATUS,1,CallSetup,"+e+","+webphone_api.common.GetSipusername(!0)+",1,"+e);var n=y;return webphone_api.common.isNull(n)&&(n=""),webphone_api.common.PutToDebugLog(1,"STATUS,-1,Starting call to "+e),webphone_api.common.PutToDebugLog(1,"STATUS,-1,Call"),o().makeCall(e,n,[]),!0}catch(t){webphone_api.common.PutToDebugLogException(2,"flashapi: Call",t)}return!1}function u(){try{if(webphone_api.common.isNull(o()))return void webphone_api.common.PutToDebugLog(3,"ERROR, Cannot get flash handle!");var e=O;return webphone_api.common.isNull(e)&&(e=""),o().hangup(e),!0}catch(n){webphone_api.common.PutToDebugLogException(2,"flashapi: Hangup",n)}return!1}function g(){try{if(webphone_api.common.isNull(o()))return void webphone_api.common.PutToDebugLog(3,"ERROR, Cannot get flash handle!");var e=O;return webphone_api.common.isNull(e)&&(e=""),o().answer(e),!0}catch(n){webphone_api.common.PutToDebugLogException(2,"flashapi: Accept",n)}return!1}function h(e,n){try{return(webphone_api.common.isNull(n)||n.length<1)&&(n="1500"),webphone_api.common.isNull(o())?void webphone_api.common.PutToDebugLog(3,"ERROR, Cannot get flash handle!"):(o().sendDTMF(e,n),!0)}catch(t){webphone_api.common.PutToDebugLogException(2,"flashapi: sendDTMF",t)}return!1}function m(){try{if(webphone_api.common.isNull(o()))return void webphone_api.common.PutToDebugLog(3,"ERROR, Cannot get flash handle!");var e=O;return webphone_api.common.isNull(e)&&(e=""),o().attach(e),!0}catch(n){webphone_api.common.PutToDebugLogException(2,"flashapi: Attach",n)}return!1}function d(e){try{if(webphone_api.common.isNull(o()))return void webphone_api.common.PutToDebugLog(3,"ERROR, Cannot get flash handle!");var n=O;return webphone_api.common.isNull(n)&&(n=""),o().transfer(n,e),!0}catch(t){webphone_api.common.PutToDebugLogException(2,"flashapi: Transfer",t)}return!1}function b(e,n){try{return webphone_api.common.isNull(o())?void webphone_api.common.PutToDebugLog(3,"ERROR, Cannot get flash handle!"):(o().three_way(e,n),!0)}catch(t){webphone_api.common.PutToDebugLogException(2,"flashapi: ThreeWay",t)}return!1}function _(e,n){try{return webphone_api.common.isNull(o())?void webphone_api.common.PutToDebugLog(3,"ERROR, Cannot get flash handle!"):(o().join(e,n),!0)}catch(t){webphone_api.common.PutToDebugLogException(2,"flashapi: Join",t)}return!1}function f(e,n){try{if(webphone_api.common.isNull(n)||n.length<1)return;O=e;var t=!1;switch(n){case"RINGING":t=!0,webphone_api.common.PutToDebugLog(1,"STATUS,-1,Ringing...");var o="1";W&&(o="2"),webphone_api.common.PutToDebugLog(1,"STATUS,1,Ringing,"+V+","+webphone_api.common.GetSipusername(!0)+","+o+","+V),A=webphone_api.common.GetTickCount();break;case"ACTIVE":t=!0;var o="1";W&&(o="2"),webphone_api.common.PutToDebugLog(1,"STATUS,1,CallConnect,"+V+","+webphone_api.common.GetSipusername(!0)+","+o+","+V),setTimeout(function(){webphone_api.common.PutToDebugLog(1,"STATUS,-1,InCall"),webphone_api.common.PutToDebugLog(1,"STATUS,-1,Speaking")},1300),webphone_api.common.PutToDebugLog(1,"STATUS,-1,Speaking"),k=webphone_api.common.GetTickCount();break;case"HANGUP":if(webphone_api.common.GetTickCount()-x<110)break;t=!0;var o="1";W&&(o="2"),webphone_api.common.PutToDebugLog(1,"STATUS,1,CallDisconnect,"+V+","+webphone_api.common.GetSipusername(!0)+","+o+","+V),webphone_api.common.PutToDebugLog(1,"STATUS,-1,Call Finished"),webphone_api.common.PutToDebugLog(1,"STATUS,1,Finished"),x=webphone_api.common.GetTickCount()}!0!==t&&webphone_api.common.PutToDebugLog(3,"EVENT, onCallState: "+n+"; uuid: "+e)}catch(i){webphone_api.common.PutToDebugLogException(2,"flashapi: onCallState",i)}}function w(e,n,t,o,i){try{O=e,W=!0,V=t,webphone_api.common.PutToDebugLog(1,"STATUS,1,CallSetup,"+t+","+webphone_api.common.GetSipusername(!0)+",2,"+t),webphone_api.common.PutToDebugLog(1,"STATUS,-1,Incoming...");var a=webphone_api.common.GetParameter2("autoignore");(webphone_api.common.isNull(a)||1!==a.length)&&(a="0");var r=webphone_api.common.StrToInt(a);r>1?(webphone_api.common.PutToDebugLog(3,"EVENT, autoignore Flash hangup(reject)"),Reject(7)):1===r&&(webphone_api.common.PutToDebugLog(3,"EVENT, autoignore Flash silent ignore"),Reject(8)),!0!==webphone_api.common.GetParameterBool("autoaccept",!1)&&3!==webphone_api.common.GetParameterInt("enableautoaccept",1)||(webphone_api.common.PutToDebugLog(3,"EVENT, autoaccept Flash accept"),g());var l=webphone_api.common.GetParameter2("calltransferalways");!webphone_api.common.isNull(l)&&l.length>1&&(webphone_api.common.PutToDebugLog(3,"EVENT, call transfer Flash calltransferalways: "+l),d(l));var s=webphone_api.common.GetParameter2("callforwardonbusy");!webphone_api.common.isNull(s)&&s.length>1&&webphone_api.common.PutToDebugLog(3,"EVENT, call foward Flash callforwardonbusy: NOT IMPLEMENTED YET");var p=webphone_api.common.GetParameter2("callforwardalways");!webphone_api.common.isNull(p)&&p.length>1&&webphone_api.common.PutToDebugLog(3,"EVENT, call foward Flash callforwardalways: NOT IMPLEMENTED YET")}catch(c){webphone_api.common.PutToDebugLogException(2,"flashapi: onIncomingCall",c)}}function v(e,n){try{webphone_api.common.PutToDebugLog(1,"STATUS,-1,Hangup"),webphone_api.common.PutToDebugLog(3,"EVENT, onHangup reason: "+n+"; "+e),S(),setTimeout(function(){N()},1500)}catch(t){webphone_api.common.PutToDebugLogException(2,"flashapi: onHangup",t)}}function E(e,n,t){try{webphone_api.common.PutToDebugLog(1,"EVENT, flashapi onDisplayUpdate, name: "+n+", number: "+t+", "+e)}catch(o){webphone_api.common.PutToDebugLogException(2,"flashapi: onDisplayUpdate",o)}}function P(e,n,t){webphone_api.common.PutToDebugLog(4,"EVENT, flashapi onMakeCall: "+n)}function T(e){webphone_api.common.PutToDebugLog(4,"EVENT, flashapi onAttach: "+e)}function S(){try{U=webphone_api.common.GetTickCount();var e=0;!webphone_api.common.isNull(k)&&k>0&&!webphone_api.common.isNull(U)&&U>0&&(e=U-k),V=webphone_api.common.isNull(V)?"":webphone_api.common.Trim(V),webphone_api.common.isNull(k)&&(k=0);var n="",t="",o="NA";!webphone_api.common.isNull(k)&&webphone_api.common.IsNumber(k)&&!webphone_api.common.isNull(A)&&webphone_api.common.IsNumber(A)&&(o=(k-A).toString());W?(n=V,t=webphone_api.common.GetSipusername(!0)):(n=webphone_api.common.GetSipusername(!0),t=V);var i="1";!0===W&&(i="2");var a="CDR,1,"+V+","+n+","+t+",NA,"+o+","+e.toString()+",NA,,"+i;webphone_api.global.lastcallcdr=a,setTimeout(function(){webphone_api.common.PutToDebugLog(1,a)},500),setTimeout(function(){N()},1500),A=0,k=0,U=0,V="",W=!1}catch(r){webphone_api.common.PutToDebugLogException(2,"flashapi: BuildCDR",r)}}function N(){D&&webphone_api.common.PutToDebugLog(1,"STATUS,-1,Registered.")}function I(){var e="";try{if(e=webphone_api.common.GetParameter("rtmpserveraddress"),webphone_api.common.isNull(e)||e.length<2){if(e=webphone_api.common.GetWpS(),webphone_api.common.IsLocalServer())return webphone_api.common.PutToDebugLog(1,"ERROR, no available VoIP engine found in this browser/environment"),webphone_api.common.PutToDebugLog(3,"EVENT, all the included engines are unavailable (WebRTC, NS, Java, Flash). Consider adding WebRTC support. See the 'How to handle WebRTC' FAQ point in the documentation"),"";e=e.toLowerCase(),e=webphone_api.common.NormalizeInput(e,0);var n=e.indexOf("/");n>0&&(e=e.substring(0,n)),n=e.indexOf(":"),n>0&&(e=e.substring(0,n)),e+=":1939"}return e}catch(t){webphone_api.common.PutToDebugLogException(2,"flashapi: GetFlashServerAddress",t)}return""}function C(e,n){}var G={rtmp_url:""},L={allowScriptAccess:"always"},R="flashphonehandle",y="",D=!1,O="",x=0,A=0,k=0,U=0,V="",W=!1;return{Start:e,Call:c,Logout:l,Hangup:u,Accept:g,SendDTMF:h,Attach:m,Transfer:d,ThreeWay:b,Join:_,ShowPermissionRequest:C,onInit:n,onEvent:i,onDebug:a,onConnected:t,onDisconnected:r,onLogin:s,onLogout:p,onCallState:f,onIncomingCall:w,onHangup:v,onDisplayUpdate:E,onMakeCall:P,onAttach:T}}(),webphone_api.init=function(){function e(){webphone_api.$("#loading_bg_txt").hide();var e=window.location.href;e.indexOf("#page_call")>0&&(console&&console.log&&console.log("WARNING, page Call was last started and after browser window reload, go to Settings page"),webphone_api.common.PutToDebugLog(3,"EVENT, page Call was last started and after browser window reload, go to Settings page"),e=e.replace("#page_call",""),window.location.href=e)}function n(){if(!0!==a){if(a=!0,webphone_api.common.SetElementsSrc(),webphone_api.global.domloaded_tick=webphone_api.common.GetTickCount(),webphone_api.global.loglevel=webphone_api.common.GetLogLevel(),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, init: initialize start"),webphone_api.common.Glv()<1)return void(webphone_api.global.webrtcavailable=0);if(!webphone_api.common.IsWindowsSoftphone()){webphone_api.loadwebrtc_timestamp=webphone_api.common.GetTickCount();var e=webphone_api.common.GetForcedEngine();if(e&&"webrtc"!=e.name)return webphone_api.global.webrtcavailable=0,webphone_api.common.PutToDebugLog(2,"webrtc engine not needed"),void(!0===webphone_api.common.UseCustomAutoprov(!0)?webphone_api.common.GetCustomAutoprov(function(e){webphone_api.common.RecAutoprovCustom(e),t()}):t());webphone_api.webrtcapi.WebRtcIsSupported(function(e){var n="";if(n+=e?"A":"b","Windows"===webphone_api.common.GetOs()&&("MSIE"===webphone_api.common.GetBrowser()?(n+="c",e=!1):"Edge"===webphone_api.common.GetBrowser()&&(webphone_api.common.GetBrowserVersion()<14?(n+="d",e=!1):!1===e&&(n+="e",webphone_api.common.PutToDebugLog(2,"ERROR,Init Edge webrtc is not supported, getusermedia: "+typeof navigator.getUserMedia+"; RTCPeerConnection: "+typeof window.RTCPeerConnection)))),"iOS"===webphone_api.common.GetOs()?(("Safari"===webphone_api.common.GetBrowser()||"iPhone"===webphone_api.common.GetBrowser())&&webphone_api.common.GetBrowserVersion()<11&&(e=!1,n+="f"),"Firefox"!==webphone_api.common.GetBrowser()||navigator.mozGetUserMedia||navigator.GetUserMedia||(e=!1,n+="g"),"Chrome"!==webphone_api.common.GetBrowser()||navigator.webkitGetUserMedia||navigator.GetUserMedia||(e=!1,n+="h")):"Windows"===webphone_api.common.GetOs()&&"Safari"===webphone_api.common.GetBrowser()&&(n+="i",e=!1),webphone_api.common.isNull(e)&&(e="",n+="j"),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, Webrtc engine available at init: "+e),!0===e){n+="K",webphone_api.global.webrtcavailable=1;var o=webphone_api.common.GetEngine("webrtc"),i=webphone_api.common.GetParameter2("serveraddress_user");(webphone_api.common.isNull(i)||i.length<2)&&(i=webphone_api.common.GetParameter2("serveraddress")),(webphone_api.common.isNull(i)||i.length<2)&&(i=webphone_api.common.GetConfig("serveraddress")),webphone_api.common.isNull(i)&&(i="");var a=!1;webphone_api.common.CanUseAnyAddrForWebRTC()||(1==webphone_api.common.IsLanIPEx(webphone_api.common.GetWebrtcUpperServer())?a=!0:0==webphone_api.common.IsLanIPEx(webphone_api.common.GetWebrtcUpperServer())||1==webphone_api.common.IsLanIPEx(i)&&(a=!0)),a?webphone_api.common.isNull(o)||(o.issupported_cache=0,o.available=0):!0===webphone_api.common.BrowserRequiresHttps(!0)?webphone_api.common.isNull(o)||(o.issupported_cache=1,o.available=2):webphone_api.common.isNull(o)||(o.issupported_cache=2,o.available=3)}else!1===e&&(webphone_api.global.webrtcavailable=0,webphone_api.common.PutToDebugLog(2,"EVENT, webrtc engine NOT available (a) "+n));!0===webphone_api.common.UseCustomAutoprov(!0)?webphone_api.common.GetCustomAutoprov(function(e){webphone_api.common.RecAutoprovCustom(e),t()}):t()})}}}function t(){if(webphone_api.common.EngineSelect(0,31),webphone_api.common.SetLanguage(),webphone_api.plhandler.ConfigChanged(),!1===webphone_api.global.onloaded_called){webphone_api.global.wploaded=!0,webphone_api.common.PutToDebugLogSpecial(2,"EVENT, init webphone onLoaded",!1,"");try{webphone_api.onAppStateChangeCb("loaded")}catch(e){webphone_api.common.PutToDebugLogException(2,"init: There is an error in onAppStateChange(loaded) callback",e)}try{webphone_api.onLoadedCb()}catch(e){webphone_api.common.PutToDebugLogException(2,"init: There is an error in onLoaded() callback",e)}try{!0===webphone_api.common.IsWebphoneInIframe()&&webphone_api.WebphoneSendMessageToParent("wploadedandready_IFRAME")}catch(e){webphone_api.common.PutToDebugLogException(2,"init: send loaded state message to iframe parent page",e)}webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onload,"onLoad","","","",""),webphone_api.global.onloaded_called=!0,setTimeout(function(){webphone_api.global.onloaded_called=!1},5e3),webphone_api.webphone_loaded=!0,webphone_api.common.WebphoneIsLoaded()}}function o(){try{webphone_api.global.domloaded=!0,webphone_api.$.mobile.pageContainer=webphone_api.$("#android_frame"),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(3,"EVENT, init: mobileinit"),webphone_api.$("body").on("contextmenu",function(e){if(0==webphone_api.common.IsSDK())return i(e)})}catch(e){webphone_api.common.PutToDebugLogException(2,"init: mobileinit",e)}}function i(e){var n="";try{if(n=webphone_api.$.mobile.activePage.attr("id"),webphone_api.common.isNull(n)||n.length<1)return webphone_api.common.PutToDebugLog(2,"ERROR, init: OpenMenu NO PAGE"),!1;n=n.replace("page_","");var t="#btn_"+n+"_menu";if("settings"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("dialpad"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("contactslist"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("contactdetails"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("callhistorylist"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("callhistorydetails"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("call"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("addeditcontact"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("messagelist"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("message"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("internalbrowser"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("newuser"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("filetransfer"===n)return webphone_api.$(t).click(),e.preventDefault(),!1;if("smscodeverify"===n)return webphone_api.$(t).click(),e.preventDefault(),!1}catch(o){webphone_api.common.PutToDebugLogException(2,"init: OpenMenu "+n,o)}}webphone_api.$(document).ready(function(){e()}),webphone_api.$(document).on("mobileinit",function(){o(),webphone_api.$.event.special.tap.emitTapOnTaphold=!1});var a=!1;webphone_api.$(".options_menu").on("popupbeforeposition",function(e,n){webphone_api.$(".all_app_pages").css("overflow","hidden")});var r=!1;return window.onunload=window.onbeforeunload=function(e){try{try{if("undefined"==typeof webphone_api||null===webphone_api)return;if(webphone_api.unregisteredcb=null,webphone_api.global.onunload_flag=!0,!0===r)return;r=!0,webphone_api.common.PutToDebugLog(5,"EVENT, window.onbeforeunload event"),webphone_api.stop();webphone_api.global.useengine;if(webphone_api.global.useengine="",webphone_api.global.last_useengine="","undefined"!=typeof webphone_api.common&&null!==webphone_api.common){if(webphone_api.common.PutToDebugLog(3,"EVENT, Window.OnUnload close or refresh event detected. reset useengine"),webphone_api.global.wasSettModified){var n=webphone_api.common.GetActiveAccSettingsFilename();!webphone_api.common.isNull(n)&&n.length>0&&webphone_api.common.SaveSettingsFile(6,n,function(e){webphone_api.common.CanLog(2)&&(e?webphone_api.common.PutToDebugLog(2,"EVENT, SaveSettingsFile on exit Successfull"):webphone_api.common.PutToDebugLog(2,"ERROR, SaveSettingsFile on exit Failed"))})}webphone_api.global.wasCtModified&&webphone_api.common.SaveContactsFile(function(e){e?webphone_api.common.PutToDebugLog(2,"EVENT, SaveContactsFile on exit Successfull"):webphone_api.common.PutToDebugLog(2,"ERROR, SaveContactsFile on exit Failed")}),webphone_api.global.wasChModified&&webphone_api.common.SaveCallhistoryFile(function(e){e?webphone_api.common.PutToDebugLog(2,"EVENT, SaveCallhistoryFile on exit Successfull"):webphone_api.common.PutToDebugLog(2,"ERROR, SaveCallhistoryFile on exit Failed")})}}catch(t){webphone_api.common.PutToDebugLogException(2,"init: Window.OnUnload",t)}}catch(t){}},webphone_api.$(document).on("pagecontainershow",function(e,n){var t="";try{var o=webphone_api.$.mobile.pageContainer.pagecontainer("getActivePage");t=o[0].id,document.getElementById(t).style.minHeight="auto"}catch(i){webphone_api.common.PutToDebugLogException(2,"init: pagecontainershow "+t,i)}}),webphone_api.$(document).on("pageinit",'[data-role="page"]',function(e){var n="";try{if(n=webphone_api.$(this).attr("id"),webphone_api.common.isNull(n)||n.length<1)return void webphone_api.common.PutToDebugLog(2,"ERROR, init: pageinit NO PAGE");if(n.indexOf("settings")>=0&&!webphone_api.common.isNull(webphone_api._settings))return void webphone_api._settings.onCreate(e);if(n.indexOf("dialpad")>=0&&!webphone_api.common.isNull(webphone_api._dialpad))return void webphone_api._dialpad.onCreate(e);if(n.indexOf("contactslist")>=0&&!webphone_api.common.isNull(webphone_api._contactslist))return void webphone_api._contactslist.onCreate(e);if(n.indexOf("contactdetails")>=0&&!webphone_api.common.isNull(webphone_api._contactdetails))return void webphone_api._contactdetails.onCreate(e);if(n.indexOf("callhistorylist")>=0&&!webphone_api.common.isNull(webphone_api._callhistorylist))return void webphone_api._callhistorylist.onCreate(e);if(n.indexOf("callhistorydetails")>=0&&!webphone_api.common.isNull(webphone_api._callhistorydetails))return void webphone_api._callhistorydetails.onCreate(e);if(n.indexOf("call")>=0&&!webphone_api.common.isNull(webphone_api._call))return void webphone_api._call.onCreate(e)
;if(n.indexOf("addeditcontact")>=0&&!webphone_api.common.isNull(webphone_api._addeditcontact))return void webphone_api._addeditcontact.onCreate(e);if(n.indexOf("messagelist")>=0&&!webphone_api.common.isNull(webphone_api._messagelist))return void webphone_api._messagelist.onCreate(e);if(n.indexOf("message")>=0&&!webphone_api.common.isNull(webphone_api._message))return void webphone_api._message.onCreate(e);if(n.indexOf("internalbrowser")>=0&&!webphone_api.common.isNull(webphone_api._internalbrowser))return void webphone_api._internalbrowser.onCreate(e);if(n.indexOf("startpage")>=0&&!webphone_api.common.isNull(webphone_api._startpage))return void webphone_api._startpage.onCreate(e);if(n.indexOf("logview")>=0&&!webphone_api.common.isNull(webphone_api._logview))return void webphone_api._logview.onCreate(e);if(n.indexOf("newuser")>=0&&!webphone_api.common.isNull(webphone_api._newuser))return void webphone_api._newuser.onCreate(e);if(n.indexOf("filetransfer")>=0&&!webphone_api.common.isNull(webphone_api._filetransfer))return void webphone_api._filetransfer.onCreate(e);if(n.indexOf("filters")>=0&&!webphone_api.common.isNull(webphone_api._filters))return void webphone_api._filters.onCreate(e);if(n.indexOf("accounts")>=0&&!webphone_api.common.isNull(webphone_api._accounts))return void webphone_api._accounts.onCreate(e);if(n.indexOf("smscodeverify")>=0&&!webphone_api.common.isNull(webphone_api._smscodeverify))return void webphone_api._smscodeverify.onCreate(e);if(n.indexOf("extra1")>=0)return void(webphone_api._extra1&&webphone_api._extra1.onCreate&&(webphone_api._extra1.onCreate(e),webphone_api.global.isExtra1Started=!0));if(n.indexOf("extra2")>=0)return void(webphone_api._extra2&&webphone_api._extra2.onCreate&&(webphone_api._extra2.onCreate(e),webphone_api.global.isExtra2Started=!0));if(n.indexOf("extra3")>=0)return void(webphone_api._extra3&&webphone_api._extra3.onCreate&&(webphone_api._extra3.onCreate(e),webphone_api.global.isExtra3Started=!0));if(n.indexOf("extra4")>=0)return void(webphone_api._extra4&&webphone_api._extra4.onCreate&&(webphone_api._extra4.onCreate(e),webphone_api.global.isExtra4Started=!0));if(n.indexOf("extra5")>=0)return void(webphone_api._extra5&&webphone_api._extra5.onCreate&&(webphone_api._extra5.onCreate(e),webphone_api.global.isExtra5Started=!0))}catch(t){webphone_api.common.isNull(n)&&(n=""),webphone_api.common.PutToDebugLogException(2,"init: pageinit "+n,t)}}),webphone_api.$(document).on("pageshow",'[data-role="page"]',function(e){var n="";try{if(n=webphone_api.$(this).attr("id"),webphone_api.common.isNull(n)||n.length<1)return void webphone_api.common.PutToDebugLog(2,"ERROR, init: pageshow NO PAGE");var t="#"+n.substring(n.indexOf("_")+1,n.length)+"_header";if(document.getElementById(n).style.background=webphone_api.common.getBgColor(t),n.indexOf("settings")>=0&&!webphone_api.common.isNull(webphone_api._settings))return void webphone_api._settings.onStart(e);if(n.indexOf("dialpad")>=0&&!webphone_api.common.isNull(webphone_api._dialpad))return void webphone_api._dialpad.onStart(e);if(n.indexOf("contactslist")>=0&&!webphone_api.common.isNull(webphone_api._contactslist))return void webphone_api._contactslist.onStart(e);if(n.indexOf("contactdetails")>=0&&!webphone_api.common.isNull(webphone_api._contactdetails))return void webphone_api._contactdetails.onStart(e);if(n.indexOf("callhistorylist")>=0&&!webphone_api.common.isNull(webphone_api._callhistorylist))return void webphone_api._callhistorylist.onStart(e);if(n.indexOf("callhistorydetails")>=0&&!webphone_api.common.isNull(webphone_api._callhistorydetails))return void webphone_api._callhistorydetails.onStart(e);if(n.indexOf("call")>=0&&!webphone_api.common.isNull(webphone_api._call))return void webphone_api._call.onStart(e);if(n.indexOf("addeditcontact")>=0&&!webphone_api.common.isNull(webphone_api._addeditcontact))return void webphone_api._addeditcontact.onStart(e);if(n.indexOf("messagelist")>=0&&!webphone_api.common.isNull(webphone_api._messagelist))return void webphone_api._messagelist.onStart(e);if(n.indexOf("message")>=0&&!webphone_api.common.isNull(webphone_api._message))return void webphone_api._message.onStart(e);if(n.indexOf("internalbrowser")>=0&&!webphone_api.common.isNull(webphone_api._internalbrowser))return void webphone_api._internalbrowser.onStart(e);if(n.indexOf("startpage")>=0&&!webphone_api.common.isNull(webphone_api._startpage))return void webphone_api._startpage.onStart(e);if(n.indexOf("logview")>=0&&!webphone_api.common.isNull(webphone_api._logview))return void webphone_api._logview.onStart(e);if(n.indexOf("newuser")>=0&&!webphone_api.common.isNull(webphone_api._newuser))return void webphone_api._newuser.onStart(e);if(n.indexOf("filetransfer")>=0&&!webphone_api.common.isNull(webphone_api._filetransfer))return void webphone_api._filetransfer.onStart(e);if(n.indexOf("filters")>=0&&!webphone_api.common.isNull(webphone_api._filters))return void webphone_api._filters.onStart(e);if(n.indexOf("accounts")>=0&&!webphone_api.common.isNull(webphone_api._accounts))return void webphone_api._accounts.onStart(e);if(n.indexOf("smscodeverify")>=0&&!webphone_api.common.isNull(webphone_api._smscodeverify))return void webphone_api._smscodeverify.onStart(e);if(n.indexOf("extra1")>=0)return void(webphone_api._extra1&&webphone_api._extra1.onStart&&(webphone_api._extra1.onStart(e),webphone_api.global.isExtra1Started=!0));if(n.indexOf("extra2")>=0)return void(webphone_api._extra2&&webphone_api._extra2.onStart&&(webphone_api._extra2.onStart(e),webphone_api.global.isExtra2Started=!0));if(n.indexOf("extra3")>=0)return void(webphone_api._extra3&&webphone_api._extra3.onStart&&(webphone_api._extra3.onStart(e),webphone_api.global.isExtra3Started=!0));if(n.indexOf("extra4")>=0)return void(webphone_api._extra4&&webphone_api._extra4.onStart&&(webphone_api._extra4.onStart(e),webphone_api.global.isExtra4Started=!0));if(n.indexOf("extra5")>=0)return void(webphone_api._extra5&&webphone_api._extra5.onStart&&(webphone_api._extra5.onStart(e),webphone_api.global.isExtra5Started=!0))}catch(o){webphone_api.common.isNull(n)&&(n=""),webphone_api.common.PutToDebugLogException(2,"init: pageshow "+n,o)}}),webphone_api.$(document).on("pagebeforehide",'[data-role="page"]',function(e){var n="";try{if(n=webphone_api.$(this).attr("id"),webphone_api.common.isNull(n)||n.length<1)return void webphone_api.common.PutToDebugLog(2,"ERROR, init: pagebeforehide NO PAGE");if(n.indexOf("settings")>=0&&!webphone_api.common.isNull(webphone_api._settings))return void webphone_api._settings.onStop(e);if(n.indexOf("dialpad")>=0&&!webphone_api.common.isNull(webphone_api._dialpad))return void webphone_api._dialpad.onStop(e);if(n.indexOf("contactslist")>=0&&!webphone_api.common.isNull(webphone_api._contactslist))return void webphone_api._contactslist.onStop(e);if(n.indexOf("contactdetails")>=0&&!webphone_api.common.isNull(webphone_api._contactdetails))return void webphone_api._contactdetails.onStop(e);if(n.indexOf("callhistorylist")>=0&&!webphone_api.common.isNull(webphone_api._callhistorylist))return void webphone_api._callhistorylist.onStop(e);if(n.indexOf("callhistorydetails")>=0&&!webphone_api.common.isNull(webphone_api._callhistorydetails))return void webphone_api._callhistorydetails.onStop(e);if(n.indexOf("call")>=0&&!webphone_api.common.isNull(webphone_api._call))return void webphone_api._call.onStop(e);if(n.indexOf("addeditcontact")>=0&&!webphone_api.common.isNull(webphone_api._addeditcontact))return void webphone_api._addeditcontact.onStop(e);if(n.indexOf("messagelist")>=0&&!webphone_api.common.isNull(webphone_api._messagelist))return void webphone_api._messagelist.onStop(e);if(n.indexOf("message")>=0&&!webphone_api.common.isNull(webphone_api._message))return void webphone_api._message.onStop(e);if(n.indexOf("internalbrowser")>=0&&!webphone_api.common.isNull(webphone_api._internalbrowser))return void webphone_api._internalbrowser.onStop(e);if(n.indexOf("startpage")>=0&&!webphone_api.common.isNull(webphone_api._startpage))return void webphone_api._startpage.onStop(e);if(n.indexOf("logview")>=0&&!webphone_api.common.isNull(webphone_api._logview))return void webphone_api._logview.onStop(e);if(n.indexOf("newuser")>=0&&!webphone_api.common.isNull(webphone_api._newuser))return void webphone_api._newuser.onStop(e);if(n.indexOf("filetransfer")>=0&&!webphone_api.common.isNull(webphone_api._filetransfer))return void webphone_api._filetransfer.onStop(e);if(n.indexOf("filters")>=0&&!webphone_api.common.isNull(webphone_api._filters))return void webphone_api._filters.onStop(e);if(n.indexOf("accounts")>=0&&!webphone_api.common.isNull(webphone_api._accounts))return void webphone_api._accounts.onStop(e);if(n.indexOf("smscodeverify")>=0&&!webphone_api.common.isNull(webphone_api._smscodeverify))return void webphone_api._smscodeverify.onStop(e);if(n.indexOf("extra1")>=0)return void(webphone_api._extra1&&webphone_api._extra1.onStop&&(webphone_api._extra1.onStop(e),webphone_api.global.isExtra1Started=!1));if(n.indexOf("extra2")>=0)return void(webphone_api._extra2&&webphone_api._extra2.onStop&&(webphone_api._extra2.onStop(e),webphone_api.global.isExtra2Started=!1));if(n.indexOf("extra3")>=0)return void(webphone_api._extra3&&webphone_api._extra3.onStop&&(webphone_api._extra3.onStop(e),webphone_api.global.isExtra3Started=!1));if(n.indexOf("extra4")>=0)return void(webphone_api._extra4&&webphone_api._extra4.onStop&&(webphone_api._extra4.onStop(e),webphone_api.global.isExtra4Started=!1));if(n.indexOf("extra5")>=0)return void(webphone_api._extra5&&webphone_api._extra5.onStop&&(webphone_api._extra5.onStop(e),webphone_api.global.isExtra5Started=!1))}catch(t){webphone_api.common.isNull(n)&&(n=""),webphone_api.common.PutToDebugLogException(2,"init: pagebeforehide "+n,t)}}),webphone_api.$(document).on("pagehide",'[data-role="page"]',function(e){var n="";try{if(n=webphone_api.$(this).attr("id"),webphone_api.common.isNull(n)||n.length<1)return void webphone_api.common.PutToDebugLog(2,"ERROR, init: pagehide NO PAGE");if(n.indexOf("settings")>=0&&!webphone_api.common.isNull(webphone_api._settings)&&webphone_api._settings.onDestroy)return void webphone_api._settings.onDestroy(e);if(n.indexOf("dialpad")>=0&&!webphone_api.common.isNull(webphone_api._dialpad)&&webphone_api._dialpad.onDestroy)return void webphone_api._dialpad.onDestroy(e);if(n.indexOf("contactslist")>=0&&!webphone_api.common.isNull(webphone_api._contactslist)&&webphone_api._contactslist.onDestroy)return void webphone_api._contactslist.onDestroy(e);if(n.indexOf("contactdetails")>=0&&!webphone_api.common.isNull(webphone_api._contactdetails)&&webphone_api._contactdetails.onDestroy)return void webphone_api._contactdetails.onDestroy(e);if(n.indexOf("callhistorylist")>=0&&!webphone_api.common.isNull(webphone_api._callhistorylist)&&webphone_api._callhistorylist.onDestroy)return void webphone_api._callhistorylist.onDestroy(e);if(n.indexOf("callhistorydetails")>=0&&!webphone_api.common.isNull(webphone_api._callhistorydetails)&&webphone_api._callhistorydetails.onDestroy)return void webphone_api._callhistorydetails.onDestroy(e);if(n.indexOf("call")>=0&&!webphone_api.common.isNull(webphone_api._call)&&webphone_api._call.onDestroy)return void webphone_api._call.onDestroy(e);if(n.indexOf("addeditcontact")>=0&&!webphone_api.common.isNull(webphone_api._addeditcontact)&&webphone_api._addeditcontact.onDestroy)return void webphone_api._addeditcontact.onDestroy(e);if(n.indexOf("messagelist")>=0&&!webphone_api.common.isNull(webphone_api._messagelist)&&webphone_api._messagelist.onDestroy)return void webphone_api._messagelist.onDestroy(e);if(n.indexOf("message")>=0&&!webphone_api.common.isNull(webphone_api._message)&&webphone_api._message.onDestroy)return void webphone_api._message.onDestroy(e);if(n.indexOf("internalbrowser")>=0&&!webphone_api.common.isNull(webphone_api._internalbrowser)&&webphone_api._internalbrowser.onDestroy)return void webphone_api._internalbrowser.onDestroy(e);if(n.indexOf("startpage")>=0&&!webphone_api.common.isNull(webphone_api._startpage)&&webphone_api._startpage.onDestroy)return void webphone_api._startpage.onDestroy(e);if(n.indexOf("logview")>=0&&!webphone_api.common.isNull(webphone_api._logview)&&webphone_api._logview.onDestroy)return void webphone_api._logview.onDestroy(e);if(n.indexOf("newuser")>=0&&!webphone_api.common.isNull(webphone_api._newuser)&&webphone_api._newuser.onDestroy)return void webphone_api._newuser.onDestroy(e);if(n.indexOf("filetransfer")>=0&&!webphone_api.common.isNull(webphone_api._filters)&&webphone_api._filters.onDestroy)return void webphone_api._filetransfer.onDestroy(e);if(n.indexOf("filters")>=0&&!webphone_api.common.isNull(webphone_api._filters)&&webphone_api._filters.onDestroy)return void webphone_api._filters.onDestroy(e);if(n.indexOf("accounts")>=0&&!webphone_api.common.isNull(webphone_api._accounts)&&webphone_api._accounts.onDestroy)return void webphone_api._accounts.onDestroy(e);if(n.indexOf("smscodeverify")>=0&&!webphone_api.common.isNull(webphone_api._smscodeverify)&&webphone_api._smscodeverify.onDestroy)return void webphone_api._smscodeverify.onDestroy(e)}catch(t){webphone_api.common.isNull(n)&&(n=""),webphone_api.common.PutToDebugLogException(2,"init: pagehide "+n,t)}}),{initialize:e,mobileinit:o,SkinLoaded:n}}(),function(e,n,t){1!=webphone_api.parameters.issdk&&"true"!=webphone_api.parameters.issdk&&("function"==typeof define&&define.amd?define(["jquery"],function(o){return t(o,e,n),o.mobile}):t(e.webphone_api.$,e,n))}(this,document,function(e,n,t){!function(e){e.mobile={}}(e),function(e){e.extend(e.mobile,{version:"1.4.2",subPageUrlKey:"ui-page",hideUrlBar:!0,keepNative:":jqmData(role='none'), :jqmData(role='nojs')",activePageClass:"ui-page-active",activeBtnClass:"ui-btn-active",focusClass:"ui-focus",ajaxEnabled:!0,hashListeningEnabled:!0,linkBindingEnabled:!0,defaultPageTransition:"fade",maxTransitionWidth:!1,minScrollBack:0,defaultDialogTransition:"pop",pageLoadErrorMessage:"Error Loading Page",pageLoadErrorMessageTheme:"a",phonegapNavigationEnabled:!1,autoInitializePage:!0,pushStateEnabled:!0,ignoreContentEnabled:!1,buttonMarkup:{hoverDelay:200},dynamicBaseEnabled:!0,pageContainer:e(),allowCrossDomainPages:!1,dialogHashKey:"&ui-state=dialog"})}(e),function(e,n,t){var o={},i=e.find,a=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/;e.extend(e.mobile,{ns:"",getAttribute:function(n,t){var o;(n=n.jquery?n[0]:n)&&n.getAttribute&&(o=n.getAttribute("data-"+e.mobile.ns+t));try{o="true"===o||"false"!==o&&("null"===o?null:+o+""===o?+o:a.test(o)?JSON.parse(o):o)}catch(i){}return o},nsNormalizeDict:o,nsNormalize:function(n){return o[n]||(o[n]=e.camelCase(e.mobile.ns+n))},closestPageData:function(e){return e.closest(":jqmData(role='page'), :jqmData(role='dialog')").data("mobile-page")}}),e.fn.jqmData=function(n,t){var o;return void 0!==n&&(n&&(n=e.mobile.nsNormalize(n)),o=arguments.length<2||void 0===t?this.data(n):this.data(n,t)),o},e.jqmData=function(n,t,o){var i;return void 0!==t&&(i=e.data(n,t?e.mobile.nsNormalize(t):t,o)),i},e.fn.jqmRemoveData=function(n){return this.removeData(e.mobile.nsNormalize(n))},e.jqmRemoveData=function(n,t){return e.removeData(n,e.mobile.nsNormalize(t))},e.find=function(n,t,o,a){return n.indexOf(":jqmData")>-1&&(n=n.replace(/:jqmData\(([^)]*)\)/g,"[data-"+(e.mobile.ns||"")+"$1]")),i.call(this,n,t,o,a)},e.extend(e.find,i)}(e),function(e,n){function o(n,t){var o,a,r,l=n.nodeName.toLowerCase();return"area"===l?(o=n.parentNode,a=o.name,!(!n.href||!a||"map"!==o.nodeName.toLowerCase())&&(!!(r=e("img[usemap=#"+a+"]")[0])&&i(r))):(/input|select|textarea|button|object/.test(l)?!n.disabled:"a"===l?n.href||t:t)&&i(n)}function i(n){return e.expr.filters.visible(n)&&!e(n).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}var a=0,r=/^ui-id-\d+$/;e.ui=e.ui||{},e.extend(e.ui,{version:"c0ab71056b936627e8a7821f03c044aec6280a40",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({focus:function(n){return function(t,o){return"number"==typeof t?this.each(function(){var n=this;setTimeout(function(){e(n).focus(),o&&o.call(n)},t)}):n.apply(this,arguments)}}(e.fn.focus),scrollParent:function(){var n;return n=e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!n.length?e(this[0].ownerDocument||t):n},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++a)})},removeUniqueId:function(){return this.each(function(){r.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(n){return function(t){return!!e.data(t,n)}}):function(n,t,o){return!!e.data(n,o[3])},focusable:function(n){return o(n,!isNaN(e.attr(n,"tabindex")))},tabbable:function(n){var t=e.attr(n,"tabindex"),i=isNaN(t);return(i||t>=0)&&o(n,!i)}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(t,o){function i(n,t,o,i){return e.each(a,function(){t-=parseFloat(e.css(n,"padding"+this))||0,o&&(t-=parseFloat(e.css(n,"border"+this+"Width"))||0),i&&(t-=parseFloat(e.css(n,"margin"+this))||0)}),t}var a="Width"===o?["Left","Right"]:["Top","Bottom"],r=o.toLowerCase(),l={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+o]=function(t){return t===n?l["inner"+o].call(this):this.each(function(){e(this).css(r,i(this,t)+"px")})},e.fn["outer"+o]=function(n,t){return"number"!=typeof n?l["outer"+o].call(this,n):this.each(function(){e(this).css(r,i(this,n,!0,t)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(n){return function(t){return arguments.length?n.call(this,e.camelCase(t)):n.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.support.selectstart="onselectstart"in t.createElement("div"),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(o){if(o!==n)return this.css("zIndex",o);if(this.length)for(var i,a,r=e(this[0]);r.length&&r[0]!==t;){if(("absolute"===(i=r.css("position"))||"relative"===i||"fixed"===i)&&(a=parseInt(r.css("zIndex"),10),!isNaN(a)&&0!==a))return a;r=r.parent()}return 0}}),e.ui.plugin={add:function(n,t,o){var i,a=e.ui[n].prototype;for(i in o)a.plugins[i]=a.plugins[i]||[],a.plugins[i].push([t,o[i]])},call:function(e,n,t,o){var i,a=e.plugins[n];if(a&&(o||e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType))for(i=0;i<a.length;i++)e.options[a[i][0]]&&a[i][1].apply(e.element,t)}}}(e),function(e,n){var o=function(n,t){var o=n.parent(),i=[],a=o.children(":jqmData(role='header')"),r=n.children(":jqmData(role='header')"),l=o.children(":jqmData(role='footer')"),s=n.children(":jqmData(role='footer')");return 0===r.length&&a.length>0&&(i=i.concat(a.toArray())),0===s.length&&l.length>0&&(i=i.concat(l.toArray())),e.each(i,function(n,o){t-=e(o).outerHeight()}),Math.max(0,t)};e.extend(e.mobile,{window:e(n),document:e(t),keyCode:e.ui.keyCode,behaviors:{},silentScroll:function(t){"number"!==e.type(t)&&(t=e.mobile.defaultHomeScroll),e.event.special.scrollstart.enabled=!1,setTimeout(function(){n.scrollTo(0,t),e.mobile.document.trigger("silentscroll",{x:0,y:t})},20),setTimeout(function(){e.event.special.scrollstart.enabled=!0},150)},getClosestBaseUrl:function(n){var t=e(n).closest(".ui-page").jqmData("url"),o=e.mobile.path.documentBase.hrefNoHash;return e.mobile.dynamicBaseEnabled&&t&&e.mobile.path.isPath(t)||(t=o),e.mobile.path.makeUrlAbsolute(t,o)},removeActiveLinkClass:function(n){!e.mobile.activeClickedLink||e.mobile.activeClickedLink.closest("."+e.mobile.activePageClass).length&&!n||e.mobile.activeClickedLink.removeClass(e.mobile.activeBtnClass),e.mobile.activeClickedLink=null},getInheritedTheme:function(e,n){for(var t,o,i=e[0],a="",r=/ui-(bar|body|overlay)-([a-z])\b/;i&&!((t=i.className||"")&&(o=r.exec(t))&&(a=o[2]));)i=i.parentNode;return a||n||"a"},enhanceable:function(e){return this.haveParents(e,"enhance")},hijackable:function(e){return this.haveParents(e,"ajax")},haveParents:function(n,t){if(!e.mobile.ignoreContentEnabled)return n;var o,i,a,r,l=n.length,s=e();for(r=0;l>r;r++){for(i=n.eq(r),a=!1,o=n[r];o;){if("false"===(o.getAttribute?o.getAttribute("data-"+e.mobile.ns+t):"")){a=!0;break}o=o.parentNode}a||(s=s.add(i))}return s},getScreenHeight:function(){return n.innerHeight||e.mobile.window.height()},resetActivePageHeight:function(n){var t=e("."+e.mobile.activePageClass),i=t.height(),a=t.outerHeight(!0);n=o(t,"number"==typeof n?n:e.mobile.getScreenHeight()),t.css("min-height",n-(a-i))},loading:function(){var n=this.loading._widget||e(e.mobile.loader.prototype.defaultHtml).loader(),t=n.loader.apply(n,arguments);return this.loading._widget=n,t}}),e.addDependents=function(n,t){var o=e(n),i=o.jqmData("dependents")||e();o.jqmData("dependents",e(i).add(t))},e.fn.extend({removeWithDependents:function(){e.removeWithDependents(this)},enhanceWithin:function(){var n,t={},o=e.mobile.page.prototype.keepNativeSelector(),i=this;e.mobile.nojs&&e.mobile.nojs(this),e.mobile.links&&e.mobile.links(this),e.mobile.degradeInputsWithin&&e.mobile.degradeInputsWithin(this),e.fn.buttonMarkup&&this.find(e.fn.buttonMarkup.initSelector).not(o).jqmEnhanceable().buttonMarkup(),e.fn.fieldcontain&&this.find(":jqmData(role='fieldcontain')").not(o).jqmEnhanceable().fieldcontain(),e.each(e.mobile.widgets,function(n,a){if(a.initSelector){var r=e.mobile.enhanceable(i.find(a.initSelector));r.length>0&&(r=r.not(o)),r.length>0&&(t[a.prototype.widgetName]=r)}});for(n in t)t[n][n]();return this},addDependents:function(n){e.addDependents(this,n)},getEncodedText:function(){return e("<a>").text(this.text()).html()},jqmEnhanceable:function(){return e.mobile.enhanceable(this)},jqmHijackable:function(){return e.mobile.hijackable(this)}}),e.removeWithDependents=function(n){var t=e(n);(t.jqmData("dependents")||e()).remove(),t.remove()},e.addDependents=function(n,t){var o=e(n),i=o.jqmData("dependents")||e();o.jqmData("dependents",e(i).add(t))},e.find.matches=function(n,t){return e.find(n,null,null,t)},e.find.matchesSelector=function(n,t){return e.find(t,null,null,[n]).length>0}}(e,this),function(e,n){var t=0,o=Array.prototype.slice,i=e.cleanData;e.cleanData=function(n){for(var t,o=0;null!=(t=n[o]);o++)try{e(t).triggerHandler("remove")}catch(a){}i(n)},e.widget=function(n,t,o){var i,a,r,l,s={},p=n.split(".")[0];return n=n.split(".")[1],i=p+"-"+n,o||(o=t,t=e.Widget),e.expr[":"][i.toLowerCase()]=function(n){return!!e.data(n,i)},e[p]=e[p]||{},a=e[p][n],r=e[p][n]=function(e,n){return this._createWidget?void(arguments.length&&this._createWidget(e,n)):new r(e,n)},e.extend(r,a,{version:o.version,_proto:e.extend({},o),_childConstructors:[]}),l=new t,l.options=e.widget.extend({},l.options),e.each(o,function(n,o){return e.isFunction(o)?void(s[n]=function(){var e=function(){return t.prototype[n].apply(this,arguments)},i=function(e){return t.prototype[n].apply(this,e)};return function(){var n,t=this._super,a=this._superApply;return this._super=e,this._superApply=i,n=o.apply(this,arguments),this._super=t,this._superApply=a,n}}()):void(s[n]=o)}),r.prototype=e.widget.extend(l,{widgetEventPrefix:a?l.widgetEventPrefix||n:n},s,{constructor:r,namespace:p,widgetName:n,widgetFullName:i}),a?(e.each(a._childConstructors,function(n,t){var o=t.prototype;e.widget(o.namespace+"."+o.widgetName,r,t._proto)}),delete a._childConstructors):t._childConstructors.push(r),e.widget.bridge(n,r),r},e.widget.extend=function(t){for(var i,a,r=o.call(arguments,1),l=0,s=r.length;s>l;l++)for(i in r[l])a=r[l][i],r[l].hasOwnProperty(i)&&a!==n&&(t[i]=e.isPlainObject(a)?e.isPlainObject(t[i])?e.widget.extend({},t[i],a):e.widget.extend({},a):a);return t},e.widget.bridge=function(t,i){var a=i.prototype.widgetFullName||t;e.fn[t]=function(r){var l="string"==typeof r,s=o.call(arguments,1),p=this;return r=!l&&s.length?e.widget.extend.apply(null,[r].concat(s)):r,this.each(l?function(){var o,i=e.data(this,a);return"instance"===r?(p=i,!1):i?e.isFunction(i[r])&&"_"!==r.charAt(0)?(o=i[r].apply(i,s),o!==i&&o!==n?(p=o&&o.jquery?p.pushStack(o.get()):o,!1):void 0):e.error("no such method '"+r+"' for "+t+" widget instance"):e.error("cannot call methods on "+t+" prior to initialization; attempted to call method '"+r+"'")}:function(){var n=e.data(this,a);n?n.option(r||{})._init():e.data(this,a,new i(r,this))}),p}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(n,o){o=e(o||this.defaultElement||this)[0],this.element=e(o),this.uuid=t++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),n),this.bindings=e(),this.hoverable=e(),this.focusable=e(),o!==this&&(e.data(o,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===o&&this.destroy()}}),this.document=e(o.style?o.ownerDocument:o.document||o),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(t,o){var i,a,r,l=t;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof t)if(l={},i=t.split("."),t=i.shift(),i.length){for(a=l[t]=e.widget.extend({},this.options[t]),r=0;r<i.length-1;r++)a[i[r]]=a[i[r]]||{},a=a[i[r]];if(t=i.pop(),o===n)return a[t]===n?null:a[t];a[t]=o}else{if(o===n)return this.options[t]===n?null:this.options[t];l[t]=o}return this._setOptions(l),this},_setOptions:function(e){var n;for(n in e)this._setOption(n,e[n]);return this},_setOption:function(e,n){return this.options[e]=n,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!n),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(n,t,o){var i,a=this;"boolean"!=typeof n&&(o=t,t=n,n=!1),o?(t=i=e(t),this.bindings=this.bindings.add(t)):(o=t,t=this.element,i=this.widget()),e.each(o,function(o,r){function l(){return n||!0!==a.options.disabled&&!e(this).hasClass("ui-state-disabled")?("string"==typeof r?a[r]:r).apply(a,arguments):void 0}"string"!=typeof r&&(l.guid=r.guid=r.guid||l.guid||e.guid++);var s=o.match(/^(\w+)\s*(.*)$/),p=s[1]+a.eventNamespace,c=s[2];c?i.delegate(c,p,l):t.bind(p,l)})},_off:function(e,n){n=(n||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(n).undelegate(n)},_delay:function(e,n){function t(){return("string"==typeof e?o[e]:e).apply(o,arguments)}var o=this;return setTimeout(t,n||0)},_hoverable:function(n){this.hoverable=this.hoverable.add(n),this._on(n,{mouseenter:function(n){e(n.currentTarget).addClass("ui-state-hover")},mouseleave:function(n){e(n.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(n){this.focusable=this.focusable.add(n),this._on(n,{focusin:function(n){e(n.currentTarget).addClass("ui-state-focus")},focusout:function(n){e(n.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(n,t,o){var i,a,r=this.options[n];if(o=o||{},t=e.Event(t),t.type=(n===this.widgetEventPrefix?n:this.widgetEventPrefix+n).toLowerCase(),t.target=this.element[0],a=t.originalEvent)for(i in a)i in t||(t[i]=a[i]);return this.element.trigger(t,o),!(e.isFunction(r)&&!1===r.apply(this.element[0],[t].concat(o))||t.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(n,t){e.Widget.prototype["_"+n]=function(o,i,a){"string"==typeof i&&(i={effect:i});var r,l=i?!0===i||"number"==typeof i?t:i.effect||t:n;i=i||{},"number"==typeof i&&(i={duration:i}),r=!e.isEmptyObject(i),i.complete=a,i.delay&&o.delay(i.delay),r&&e.effects&&e.effects.effect[l]?o[n](i):l!==n&&o[l]?o[l](i.duration,i.easing,a):o.queue(function(t){e(this)[n](),a&&a.call(o[0]),t()})}})}(e),function(e){var n=function(e){return"-"+e.toLowerCase()};e.extend(e.Widget.prototype,{_getCreateOptions:function(){var t,o,i=this.element[0],a={};if(!e.mobile.getAttribute(i,"defaults"))for(t in this.options)null!=(o=e.mobile.getAttribute(i,t.replace(/[A-Z]/g,n)))&&(a[t]=o);return a}}),e.mobile.widget=e.Widget}(e),function(e){var n="ui-loader",t=e("html");e.widget("mobile.loader",{options:{theme:"a",textVisible:!1,html:"",text:"loading"},defaultHtml:"<div class='"+n+"'><span class='ui-icon-loading'></span><h1></h1></div>",fakeFixLoader:function(){var n=e("."+e.mobile.activeBtnClass).first();this.element.css({top:e.support.scrollTop&&this.window.scrollTop()+this.window.height()/2||n.length&&n.offset().top||100})},checkLoaderPosition:function(){var n=this.element.offset(),t=this.window.scrollTop(),o=e.mobile.getScreenHeight();(n.top<t||n.top-t>o)&&(this.element.addClass("ui-loader-fakefix"),this.fakeFixLoader(),this.window.unbind("scroll",this.checkLoaderPosition).bind("scroll",e.proxy(this.fakeFixLoader,this)))},resetHtml:function(){this.element.html(e(this.defaultHtml).html())},show:function(o,i,a){var r,l,s;this.resetHtml(),"object"===e.type(o)?(s=e.extend({},this.options,o),o=s.theme):(s=this.options,o=o||s.theme),l=i||(!1===s.text?"":s.text),t.addClass("ui-loading"),r=s.textVisible,this.element.attr("class",n+" ui-corner-all ui-body-"+o+" ui-loader-"+(r||i||o.text?"verbose":"default")+(s.textonly||a?" ui-loader-textonly":"")),s.html?this.element.html(s.html):this.element.find("h1").text(l),this.element.appendTo(e.mobile.pageContainer),this.checkLoaderPosition(),this.window.bind("scroll",e.proxy(this.checkLoaderPosition,this))},hide:function(){t.removeClass("ui-loading"),this.options.text&&this.element.removeClass("ui-loader-fakefix"),e.mobile.window.unbind("scroll",this.fakeFixLoader),e.mobile.window.unbind("scroll",this.checkLoaderPosition)}})}(e),function(e,n,o){"$:nomunge";function i(e){return e=e||location.href,"#"+e.replace(/^[^#]*#?(.*)$/,"$1")}var a,r="hashchange",l=t,s=e.event.special,p=l.documentMode,c="on"+r in n&&(p===o||p>7);e.fn[r]=function(e){return e?this.bind(r,e):this.trigger(r)},e.fn[r].delay=50,s[r]=e.extend(s[r],{setup:function(){return!c&&void e(a.start)},teardown:function(){return!c&&void e(a.stop)}}),a=function(){function t(){var o=i(),l=h(p);o!==p?(g(p=o,l),e(n).trigger(r)):l!==p&&(location.href=location.href.replace(/#.*/,"")+l),a=setTimeout(t,e.fn[r].delay)}var a,s={},p=i(),u=function(e){return e},g=u,h=u;return s.start=function(){a||t()},s.stop=function(){a&&clearTimeout(a),a=o},n.attachEvent&&!n.addEventListener&&!c&&function(){var n,o;s.start=function(){n||(o=e.fn[r].src,o=o&&o+i(),n=e('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){o||g(i()),t()}).attr("src",o||"javascript:0").insertAfter("body")[0].contentWindow,
l.onpropertychange=function(){try{"title"===event.propertyName&&(n.document.title=l.title)}catch(e){}})},s.stop=u,h=function(){return i(n.location.href)},g=function(t,o){var i=n.document,a=e.fn[r].domain;t!==o&&(i.title=l.title,i.open(),a&&i.write('<script>document.domain="'+a+'"<\/script>'),i.close(),n.location.hash=t)}}(),s}()}(e,this),function(e){n.matchMedia=n.matchMedia||function(e){var n,t=e.documentElement,o=t.firstElementChild||t.firstChild,i=e.createElement("body"),a=e.createElement("div");return a.id="mq-test-1",a.style.cssText="position:absolute;top:-100em",i.style.background="none",i.appendChild(a),function(e){return a.innerHTML='&shy;<style media="'+e+'"> #mq-test-1 { width: 42px; }</style>',t.insertBefore(i,o),n=42===a.offsetWidth,t.removeChild(i),{matches:n,media:e}}}(t),e.mobile.media=function(e){return n.matchMedia(e).matches}}(e),function(e){var n={touch:"ontouchend"in t};e.mobile.support=e.mobile.support||{},e.extend(e.support,n),e.extend(e.mobile.support,n)}(e),function(e){e.extend(e.support,{orientation:"orientation"in n&&"onorientationchange"in n})}(e),function(e,o){function i(e){var n,t=e.charAt(0).toUpperCase()+e.substr(1),i=(e+" "+p.join(t+" ")+t).split(" ");for(n in i)if(s[i[n]]!==o)return!0}function a(){var t=n,o=!(!t.document.createElementNS||!t.document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect||t.opera&&-1===navigator.userAgent.indexOf("Chrome")),i=function(n){n&&o||e("html").addClass("ui-nosvg")},a=new t.Image;a.onerror=function(){i(!1)},a.onload=function(){i(1===a.width&&1===a.height)},a.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="}var r,l=e("<body>").prependTo("html"),s=l[0].style,p=["Webkit","Moz","O"],c="palmGetResource"in n,u=n.operamini&&"[object OperaMini]"==={}.toString.call(n.operamini),g=n.blackberry&&!i("-webkit-transform");e.extend(e.mobile,{browser:{}}),e.mobile.browser.oldIE=function(){var e=3,n=t.createElement("div"),o=n.all||[];do{n.innerHTML="\x3c!--[if gt IE "+ ++e+"]><br><![endif]--\x3e"}while(o[0]);return e>4?e:!e}(),e.extend(e.support,{pushState:"pushState"in history&&"replaceState"in history&&!(n.navigator.userAgent.indexOf("Firefox")>=0&&n.top!==n)&&-1===n.navigator.userAgent.search(/CriOS/),mediaquery:e.mobile.media("only all"),cssPseudoElement:!!i("content"),touchOverflow:!!i("overflowScrolling"),cssTransform3d:function(){var i,a,r,s="transform-3d",c=e.mobile.media("(-"+p.join("-"+s+"),(-")+"-"+s+"),("+s+")");if(c)return!!c;i=t.createElement("div"),a={MozTransform:"-moz-transform",transform:"transform"},l.append(i);for(r in a)i.style[r]!==o&&(i.style[r]="translate3d( 100px, 1px, 1px )",c=n.getComputedStyle(i).getPropertyValue(a[r]));return!!c&&"none"!==c}(),boxShadow:!!i("boxShadow")&&!g,fixedPosition:function(){var e=n,t=navigator.userAgent,o=navigator.platform,i=t.match(/AppleWebKit\/([0-9]+)/),a=!!i&&i[1],r=t.match(/Fennec\/([0-9]+)/),l=!!r&&r[1],s=t.match(/Opera Mobi\/([0-9]+)/),p=!!s&&s[1];return!((o.indexOf("iPhone")>-1||o.indexOf("iPad")>-1||o.indexOf("iPod")>-1)&&a&&534>a||e.operamini&&"[object OperaMini]"==={}.toString.call(e.operamini)||s&&7458>p||t.indexOf("Android")>-1&&a&&533>a||l&&6>l||"palmGetResource"in n&&a&&534>a||t.indexOf("MeeGo")>-1&&t.indexOf("NokiaBrowser/8.5.0")>-1)}(),scrollTop:("pageXOffset"in n||"scrollTop"in t.documentElement||"scrollTop"in l[0])&&!c&&!u,dynamicBaseTag:function(){var n,t,o=location.protocol+"//"+location.host+location.pathname+"ui-dir/",i=e("head base"),a=null,r="";return i.length?r=i.attr("href"):i=a=e("<base>",{href:o}).appendTo("head"),n=e("<a href='testurl' />").prependTo(l),t=n[0].href,i[0].href=r||location.pathname,a&&a.remove(),0===t.indexOf(o)}(),cssPointerEvents:function(){var e,o=t.createElement("x"),i=t.documentElement,a=n.getComputedStyle;return"pointerEvents"in o.style&&(o.style.pointerEvents="auto",o.style.pointerEvents="x",i.appendChild(o),e=a&&"auto"===a(o,"").pointerEvents,i.removeChild(o),!!e)}(),boundingRect:function(){return"undefined"!=typeof t.createElement("div").getBoundingClientRect}(),inlineSVG:a}),l.remove(),r=function(){var e=n.navigator.userAgent;return e.indexOf("Nokia")>-1&&(e.indexOf("Symbian/3")>-1||e.indexOf("Series60/5")>-1)&&e.indexOf("AppleWebKit")>-1&&e.match(/(BrowserNG|NokiaBrowser)\/7\.[0-3]/)}(),e.mobile.gradeA=function(){return(e.support.mediaquery&&e.support.cssPseudoElement||e.mobile.browser.oldIE&&e.mobile.browser.oldIE>=8)&&(e.support.boundingRect||null!==e.fn.jquery.match(/1\.[0-7+]\.[0-9+]?/))},e.mobile.ajaxBlacklist=n.blackberry&&!n.WebKitPoint||u||r,r&&e(function(){e("head link[rel='stylesheet']").attr("rel","alternate stylesheet").attr("rel","stylesheet")}),e.support.boxShadow||e("html").addClass("ui-noboxshadow")}(e),function(e,n){var t,o=e.mobile.window,i=function(){};e.event.special.beforenavigate={setup:function(){o.on("navigate",i)},teardown:function(){o.off("navigate",i)}},e.event.special.navigate=t={bound:!1,pushStateEnabled:!0,originalEventName:void 0,isPushStateEnabled:function(){return e.support.pushState&&!0===e.mobile.pushStateEnabled&&this.isHashChangeEnabled()},isHashChangeEnabled:function(){return!0===e.mobile.hashListeningEnabled},popstate:function(n){var t=new e.Event("navigate"),i=new e.Event("beforenavigate"),a=n.originalEvent.state||{};i.originalEvent=n,o.trigger(i),i.isDefaultPrevented()||(n.historyState&&e.extend(a,n.historyState),t.originalEvent=n,setTimeout(function(){o.trigger(t,{state:a})},0))},hashchange:function(n){var t=new e.Event("navigate"),i=new e.Event("beforenavigate");i.originalEvent=n,o.trigger(i),i.isDefaultPrevented()||(t.originalEvent=n,o.trigger(t,{state:n.hashchangeState||{}}))},setup:function(){t.bound||(t.bound=!0,t.isPushStateEnabled()?(t.originalEventName="popstate",o.bind("popstate.navigate",t.popstate)):t.isHashChangeEnabled()&&(t.originalEventName="hashchange",o.bind("hashchange.navigate",t.hashchange)))}}}(e),function(e,t){var o,i,a="&ui-state=dialog";e.mobile.path=o={uiStateKey:"&ui-state",urlParseRE:/^\s*(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,getLocation:function(e){var n=e?this.parseUrl(e):location,t=this.parseUrl(e||location.href).hash;return t="#"===t?"":t,n.protocol+"//"+n.host+n.pathname+n.search+t},getDocumentUrl:function(n){return n?e.extend({},o.documentUrl):o.documentUrl.href},parseLocation:function(){return this.parseUrl(this.getLocation())},parseUrl:function(n){if("object"===e.type(n))return n;var t=o.urlParseRE.exec(n||"")||[];return{href:t[0]||"",hrefNoHash:t[1]||"",hrefNoSearch:t[2]||"",domain:t[3]||"",protocol:t[4]||"",doubleSlash:t[5]||"",authority:t[6]||"",username:t[8]||"",password:t[9]||"",host:t[10]||"",hostname:t[11]||"",port:t[12]||"",pathname:t[13]||"",directory:t[14]||"",filename:t[15]||"",search:t[16]||"",hash:t[17]||""}},makePathAbsolute:function(e,n){var t,o,i,a;if(e&&"/"===e.charAt(0))return e;for(e=e||"",n=n?n.replace(/^\/|(\/[^\/]*|[^\/]+)$/g,""):"",t=n?n.split("/"):[],o=e.split("/"),i=0;i<o.length;i++)switch(a=o[i]){case".":break;case"..":t.length&&t.pop();break;default:t.push(a)}return"/"+t.join("/")},isSameDomain:function(e,n){return o.parseUrl(e).domain===o.parseUrl(n).domain},isRelativeUrl:function(e){return""===o.parseUrl(e).protocol},isAbsoluteUrl:function(e){return""!==o.parseUrl(e).protocol},makeUrlAbsolute:function(e,n){if(!o.isRelativeUrl(e))return e;n===t&&(n=this.documentBase);var i=o.parseUrl(e),a=o.parseUrl(n),r=i.protocol||a.protocol,l=i.protocol?i.doubleSlash:i.doubleSlash||a.doubleSlash,s=i.authority||a.authority,p=""!==i.pathname;return r+l+s+o.makePathAbsolute(i.pathname||a.filename,a.pathname)+(i.search||!p&&a.search||"")+i.hash},addSearchParams:function(n,t){var i=o.parseUrl(n),a="object"==typeof t?e.param(t):t,r=i.search||"?";return i.hrefNoSearch+r+("?"!==r.charAt(r.length-1)?"&":"")+a+(i.hash||"")},convertUrlToDataUrl:function(e){var t=o.parseUrl(e);return o.isEmbeddedPage(t)?t.hash.split(a)[0].replace(/^#/,"").replace(/\?.*$/,""):o.isSameDomain(t,this.documentBase)?t.hrefNoHash.replace(this.documentBase.domain,"").split(a)[0]:n.decodeURIComponent(e)},get:function(e){return e===t&&(e=o.parseLocation().hash),o.stripHash(e).replace(/[^\/]*\.[^\/*]+$/,"")},set:function(e){location.hash=e},isPath:function(e){return/\//.test(e)},clean:function(e){return e.replace(this.documentBase.domain,"")},stripHash:function(e){return e.replace(/^#/,"")},stripQueryParams:function(e){return e.replace(/\?.*$/,"")},cleanHash:function(e){return o.stripHash(e.replace(/\?.*$/,"").replace(a,""))},isHashValid:function(e){return/^#[^#]+$/.test(e)},isExternal:function(e){var n=o.parseUrl(e);return!(!n.protocol||n.domain===this.documentUrl.domain)},hasProtocol:function(e){return/^(:?\w+:)/.test(e)},isEmbeddedPage:function(e){var n=o.parseUrl(e);return""!==n.protocol?!this.isPath(n.hash)&&n.hash&&(n.hrefNoHash===this.documentUrl.hrefNoHash||this.documentBaseDiffers&&n.hrefNoHash===this.documentBase.hrefNoHash):/^#/.test(n.href)},squash:function(e,n){var t,i,a,r,l=this.isPath(e),s=this.parseUrl(e),p=s.hash,c="";return n=n||(o.isPath(e)?o.getLocation():o.getDocumentUrl()),i=l?o.stripHash(e):e,i=o.isPath(s.hash)?o.stripHash(s.hash):i,r=i.indexOf(this.uiStateKey),r>-1&&(c=i.slice(r),i=i.slice(0,r)),t=o.makeUrlAbsolute(i,n),a=this.parseUrl(t).search,l?((o.isPath(p)||0===p.replace("#","").indexOf(this.uiStateKey))&&(p=""),c&&-1===p.indexOf(this.uiStateKey)&&(p+=c),-1===p.indexOf("#")&&""!==p&&(p="#"+p),t=o.parseUrl(t),t=t.protocol+"//"+t.host+t.pathname+a+p):t+=t.indexOf("#")>-1?c:"#"+c,t},isPreservableHash:function(e){return 0===e.replace("#","").indexOf(this.uiStateKey)},hashToSelector:function(e){var n="#"===e.substring(0,1);return n&&(e=e.substring(1)),(n?"#":"")+e.replace(/([!"#$%&'()*+,.\/:;<=>?@[\]^`{|}~])/g,"\\$1")},getFilePath:function(n){var t="&"+e.mobile.subPageUrlKey;return n&&n.split(t)[0].split(a)[0]},isFirstPageUrl:function(n){var i=o.parseUrl(o.makeUrlAbsolute(n,this.documentBase)),a=i.hrefNoHash===this.documentUrl.hrefNoHash||this.documentBaseDiffers&&i.hrefNoHash===this.documentBase.hrefNoHash,r=e.mobile.firstPage,l=r&&r[0]?r[0].id:t;return a&&(!i.hash||"#"===i.hash||l&&i.hash.replace(/^#/,"")===l)},isPermittedCrossDomainRequest:function(n,t){return e.mobile.allowCrossDomainPages&&("file:"===n.protocol||"content:"===n.protocol)&&-1!==t.search(/^https?:/)}},o.documentUrl=o.parseLocation(),i=e("head").find("base"),o.documentBase=i.length?o.parseUrl(o.makeUrlAbsolute(i.attr("href"),o.documentUrl.href)):o.documentUrl,o.documentBaseDiffers=o.documentUrl.hrefNoHash!==o.documentBase.hrefNoHash,o.getDocumentBase=function(n){return n?e.extend({},o.documentBase):o.documentBase.href},e.extend(e.mobile,{getDocumentUrl:o.getDocumentUrl,getDocumentBase:o.getDocumentBase})}(e),function(e,n){e.mobile.History=function(e,n){this.stack=e||[],this.activeIndex=n||0},e.extend(e.mobile.History.prototype,{getActive:function(){return this.stack[this.activeIndex]},getLast:function(){return this.stack[this.previousIndex]},getNext:function(){return this.stack[this.activeIndex+1]},getPrev:function(){return this.stack[this.activeIndex-1]},add:function(e,n){n=n||{},this.getNext()&&this.clearForward(),n.hash&&-1===n.hash.indexOf("#")&&(n.hash="#"+n.hash),n.url=e,this.stack.push(n),this.activeIndex=this.stack.length-1},clearForward:function(){this.stack=this.stack.slice(0,this.activeIndex+1)},find:function(e,n,t){n=n||this.stack;var o,i,a,r=n.length;for(i=0;r>i;i++)if(o=n[i],(decodeURIComponent(e)===decodeURIComponent(o.url)||decodeURIComponent(e)===decodeURIComponent(o.hash))&&(a=i,t))return a;return a},closest:function(e){var t,o=this.activeIndex;return t=this.find(e,this.stack.slice(0,o)),t===n&&(t=this.find(e,this.stack.slice(o),!0),t=t===n?t:t+o),t},direct:function(t){var o=this.closest(t.url),i=this.activeIndex;o!==n&&(this.activeIndex=o,this.previousIndex=i),i>o?(t.present||t.back||e.noop)(this.getActive(),"back"):o>i?(t.present||t.forward||e.noop)(this.getActive(),"forward"):o===n&&t.missing&&t.missing(this.getActive())}})}(e),function(e){var o=e.mobile.path,i=location.href;e.mobile.Navigator=function(n){this.history=n,this.ignoreInitialHashChange=!0,e.mobile.window.bind({"popstate.history":e.proxy(this.popstate,this),"hashchange.history":e.proxy(this.hashchange,this)})},e.extend(e.mobile.Navigator.prototype,{squash:function(i,a){var r,l,s=o.isPath(i)?o.stripHash(i):i;return l=o.squash(i),r=e.extend({hash:s,url:l},a),n.history.replaceState(r,r.title||t.title,l),r},hash:function(e,n){var t,i,a,r;return t=o.parseUrl(e),i=o.parseLocation(),i.pathname+i.search===t.pathname+t.search?a=t.hash?t.hash:t.pathname+t.search:o.isPath(e)?(r=o.parseUrl(n),a=r.pathname+r.search+(o.isPreservableHash(r.hash)?r.hash.replace("#",""):"")):a=e,a},go:function(i,a,r){var l,s,p,c,u=e.event.special.navigate.isPushStateEnabled();s=o.squash(i),p=this.hash(i,s),r&&p!==o.stripHash(o.parseLocation().hash)&&(this.preventNextHashChange=r),this.preventHashAssignPopState=!0,n.location.hash=p,this.preventHashAssignPopState=!1,l=e.extend({url:s,hash:p,title:t.title},a),u&&(c=new e.Event("popstate"),c.originalEvent={type:"popstate",state:null},this.squash(i,l),r||(this.ignorePopState=!0,e.mobile.window.trigger(c))),this.history.add(l.url,l)},popstate:function(n){var t,a;if(e.event.special.navigate.isPushStateEnabled())return this.preventHashAssignPopState?(this.preventHashAssignPopState=!1,void n.stopImmediatePropagation()):this.ignorePopState?void(this.ignorePopState=!1):!n.originalEvent.state&&1===this.history.stack.length&&this.ignoreInitialHashChange&&(this.ignoreInitialHashChange=!1,location.href===i)?void n.preventDefault():(t=o.parseLocation().hash,!n.originalEvent.state&&t?(a=this.squash(t),this.history.add(a.url,a),void(n.historyState=a)):void this.history.direct({url:(n.originalEvent.state||{}).url||t,present:function(t,o){n.historyState=e.extend({},t),n.historyState.direction=o}}))},hashchange:function(n){var i,a;if(e.event.special.navigate.isHashChangeEnabled()&&!e.event.special.navigate.isPushStateEnabled()){if(this.preventNextHashChange)return this.preventNextHashChange=!1,void n.stopImmediatePropagation();i=this.history,a=o.parseLocation().hash,this.history.direct({url:a,present:function(t,o){n.hashchangeState=e.extend({},t),n.hashchangeState.direction=o},missing:function(){i.add(a,{hash:a,title:t.title})}})}}})}(e),function(e){e.mobile.navigate=function(n,t,o){e.mobile.navigate.navigator.go(n,t,o)},e.mobile.navigate.history=new e.mobile.History,e.mobile.navigate.navigator=new e.mobile.Navigator(e.mobile.navigate.history);var n=e.mobile.path.parseLocation();e.mobile.navigate.history.add(n.href,{hash:n.hash})}(e),function(e,n){var o={animation:{},transition:{}},i=t.createElement("a"),a=["","webkit-","moz-","o-"];e.each(["animation","transition"],function(t,r){var l=0===t?r+"-name":r;e.each(a,function(t,a){return i.style[e.camelCase(a+l)]!==n?(o[r].prefix=a,!1):void 0}),o[r].duration=e.camelCase(o[r].prefix+r+"-duration"),o[r].event=e.camelCase(o[r].prefix+r+"-end"),""===o[r].prefix&&(o[r].event=o[r].event.toLowerCase())}),e.support.cssTransitions=o.transition.prefix!==n,e.support.cssAnimations=o.animation.prefix!==n,e(i).remove(),e.fn.animationComplete=function(i,a,r){var l,s,p=this,c=a&&"animation"!==a?"transition":"animation";return e.support.cssTransitions&&"transition"===c||e.support.cssAnimations&&"animation"===c?(r===n&&(e(this).context!==t&&(s=3e3*parseFloat(e(this).css(o[c].duration))),(0===s||s===n||isNaN(s))&&(s=e.fn.animationComplete.defaultDuration)),l=setTimeout(function(){e(p).off(o[c].event),i.apply(p)},s),e(this).one(o[c].event,function(){clearTimeout(l),i.call(this,arguments)})):(setTimeout(e.proxy(i,this),0),e(this))},e.fn.animationComplete.defaultDuration=1e3}(e),function(e,n,t,o){function i(e){for(;e&&"undefined"!=typeof e.originalEvent;)e=e.originalEvent;return e}function a(n,t){var a,r,l,s,p,c,u,g,h,m=n.type;if(n=e.Event(n),n.type=t,a=n.originalEvent,r=e.event.props,m.search(/^(mouse|click)/)>-1&&(r=L),a)for(u=r.length,s;u;)s=r[--u],n[s]=a[s];if(m.search(/mouse(down|up)|click/)>-1&&!n.which&&(n.which=1),-1!==m.search(/^touch/)&&(l=i(a),m=l.touches,p=l.changedTouches,c=m&&m.length?m[0]:p&&p.length?p[0]:o))for(g=0,h=C.length;h>g;g++)s=C[g],n[s]=c[s];return n}function r(n){for(var t,o,i={};n;){t=e.data(n,S);for(o in t)t[o]&&(i[o]=i.hasVirtualBinding=!0);n=n.parentNode}return i}function l(n,t){for(var o;n;){if((o=e.data(n,S))&&(!t||o[t]))return n;n=n.parentNode}return null}function s(){U=!1}function p(){U=!0}function c(){M=0,A.length=0,k=!1,p()}function u(){s()}function g(){h(),y=setTimeout(function(){y=0,c()},e.vmouse.resetTimerDuration)}function h(){y&&(clearTimeout(y),y=0)}function m(n,t,o){var i;return(o&&o[n]||!o&&l(t.target,n))&&(i=a(t,n),e(t.target).trigger(i)),i}function d(n){var t,o=e.data(n.target,N);k||M&&M===o||(t=m("v"+n.type,n))&&(t.isDefaultPrevented()&&n.preventDefault(),t.isPropagationStopped()&&n.stopPropagation(),t.isImmediatePropagationStopped()&&n.stopImmediatePropagation())}function b(n){var t,o,a,l=i(n).touches;l&&1===l.length&&(t=n.target,o=r(t),o.hasVirtualBinding&&(M=F++,e.data(t,N,M),h(),u(),x=!1,a=i(n).touches[0],D=a.pageX,O=a.pageY,m("vmouseover",n,o),m("vmousedown",n,o)))}function _(e){U||(x||m("vmousecancel",e,r(e.target)),x=!0,g())}function f(n){if(!U){var t=i(n).touches[0],o=x,a=e.vmouse.moveDistanceThreshold,l=r(n.target);x=x||Math.abs(t.pageX-D)>a||Math.abs(t.pageY-O)>a,x&&!o&&m("vmousecancel",n,l),m("vmousemove",n,l),g()}}function w(e){if(!U){p();var n,t,o=r(e.target);m("vmouseup",e,o),x||(n=m("vclick",e,o))&&n.isDefaultPrevented()&&(t=i(e).changedTouches[0],A.push({touchID:M,x:t.clientX,y:t.clientY}),k=!0),m("vmouseout",e,o),x=!1,g()}}function v(n){var t,o=e.data(n,S);if(o)for(t in o)if(o[t])return!0;return!1}function E(){}var P,T,S="virtualMouseBindings",N="virtualTouchID",I="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),C="clientX clientY pageX pageY screenX screenY".split(" "),G=e.event.mouseHooks?e.event.mouseHooks.props:[],L=e.event.props.concat(G),R={},y=0,D=0,O=0,x=!1,A=[],k=!1,U=!1,V="addEventListener"in t,W=e(t),F=1,M=0;for(e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500},T=0;T<I.length;T++)e.event.special[I[T]]=function(n){var t=n.substr(1);return{setup:function(){v(this)||e.data(this,S,{}),e.data(this,S)[n]=!0,R[n]=(R[n]||0)+1,1===R[n]&&W.bind(t,d),e(this).bind(t,E),V&&(R.touchstart=(R.touchstart||0)+1,1===R.touchstart&&W.bind("touchstart",b).bind("touchend",w).bind("touchmove",f).bind("scroll",_))},teardown:function(){--R[n],R[n]||W.unbind(t,d),V&&(--R.touchstart||W.unbind("touchstart",b).unbind("touchmove",f).unbind("touchend",w).unbind("scroll",_));var o=e(this),i=e.data(this,S);i&&(i[n]=!1),o.unbind(t,E),v(this)||o.removeData(S)}}}(I[T]);V&&t.addEventListener("click",function(n){var t,o,i,a,r,l=A.length,s=n.target;if(l)for(t=n.clientX,o=n.clientY,P=e.vmouse.clickDistanceThreshold,i=s;i;){for(a=0;l>a;a++)if(r=A[a],0,i===s&&Math.abs(r.x-t)<P&&Math.abs(r.y-o)<P||e.data(i,N)===r.touchID)return n.preventDefault(),void n.stopPropagation();i=i.parentNode}},!0)}(e,0,t),function(e,n,o){function i(n,t,i,a){var r=i.type;i.type=t,a?e.event.trigger(i,o,n):e.event.dispatch.call(n,i),i.type=r}var a=e(t),r=e.mobile.support.touch,l="touchmove scroll",s=r?"touchstart":"mousedown",p=r?"touchend":"mouseup",c=r?"touchmove":"mousemove";e.each("touchstart touchmove touchend tap taphold swipe swipeleft swiperight scrollstart scrollstop".split(" "),function(n,t){e.fn[t]=function(e){return e?this.bind(t,e):this.trigger(t)},e.attrFn&&(e.attrFn[t]=!0)}),e.event.special.scrollstart={enabled:!0,setup:function(){function n(e,n){t=n,i(a,t?"scrollstart":"scrollstop",e)}var t,o,a=this;e(a).bind(l,function(i){e.event.special.scrollstart.enabled&&(t||n(i,!0),clearTimeout(o),o=setTimeout(function(){n(i,!1)},50))})},teardown:function(){e(this).unbind(l)}},e.event.special.tap={tapholdThreshold:750,emitTapOnTaphold:!0,setup:function(){var n=this,t=e(n),o=!1;t.bind("vmousedown",function(r){function l(){clearTimeout(c)}function s(){l(),t.unbind("vclick",p).unbind("vmouseup",l),a.unbind("vmousecancel",s)}function p(e){s(),o||u!==e.target?o&&e.stopPropagation():i(n,"tap",e)}if(o=!1,r.which&&1!==r.which)return!1;var c,u=r.target;t.bind("vmouseup",l).bind("vclick",p),a.bind("vmousecancel",s),c=setTimeout(function(){e.event.special.tap.emitTapOnTaphold||(o=!0),i(n,"taphold",e.Event("taphold",{target:u}))},e.event.special.tap.tapholdThreshold)})},teardown:function(){e(this).unbind("vmousedown").unbind("vclick").unbind("vmouseup"),a.unbind("vmousecancel")}},e.event.special.swipe={scrollSupressionThreshold:30,durationThreshold:1e3,horizontalDistanceThreshold:30,verticalDistanceThreshold:30,getLocation:function(e){var t=n.pageXOffset,o=n.pageYOffset,i=e.clientX,a=e.clientY;return 0===e.pageY&&Math.floor(a)>Math.floor(e.pageY)||0===e.pageX&&Math.floor(i)>Math.floor(e.pageX)?(i-=t,a-=o):(a<e.pageY-o||i<e.pageX-t)&&(i=e.pageX-t,a=e.pageY-o),{x:i,y:a}},start:function(n){var t=n.originalEvent.touches?n.originalEvent.touches[0]:n,o=e.event.special.swipe.getLocation(t);return{time:(new Date).getTime(),coords:[o.x,o.y],origin:e(n.target)}},stop:function(n){var t=n.originalEvent.touches?n.originalEvent.touches[0]:n,o=e.event.special.swipe.getLocation(t);return{time:(new Date).getTime(),coords:[o.x,o.y]}},handleSwipe:function(n,t,o,a){if(t.time-n.time<e.event.special.swipe.durationThreshold&&Math.abs(n.coords[0]-t.coords[0])>e.event.special.swipe.horizontalDistanceThreshold&&Math.abs(n.coords[1]-t.coords[1])<e.event.special.swipe.verticalDistanceThreshold){var r=n.coords[0]>t.coords[0]?"swipeleft":"swiperight";return i(o,"swipe",e.Event("swipe",{target:a,swipestart:n,swipestop:t}),!0),i(o,r,e.Event(r,{target:a,swipestart:n,swipestop:t}),!0),!0}return!1},eventInProgress:!1,setup:function(){var n,t=this,o=e(t),i={};n=e.data(this,"mobile-events"),n||(n={length:0},e.data(this,"mobile-events",n)),n.length++,n.swipe=i,i.start=function(n){if(!e.event.special.swipe.eventInProgress){e.event.special.swipe.eventInProgress=!0;var o,r=e.event.special.swipe.start(n),l=n.target,s=!1;i.move=function(n){r&&(o=e.event.special.swipe.stop(n),s||(s=e.event.special.swipe.handleSwipe(r,o,t,l))&&(e.event.special.swipe.eventInProgress=!1),Math.abs(r.coords[0]-o.coords[0])>e.event.special.swipe.scrollSupressionThreshold&&n.preventDefault())},i.stop=function(){s=!0,e.event.special.swipe.eventInProgress=!1,a.off(c,i.move),i.move=null},a.on(c,i.move).one(p,i.stop)}},o.on(s,i.start)},teardown:function(){var n,t;n=e.data(this,"mobile-events"),n&&(t=n.swipe,delete n.swipe,0===--n.length&&e.removeData(this,"mobile-events")),t&&(t.start&&e(this).off(s,t.start),t.move&&a.off(c,t.move),t.stop&&a.off(p,t.stop))}},e.each({scrollstop:"scrollstart",taphold:"tap",swipeleft:"swipe",swiperight:"swipe"},function(n,t){e.event.special[n]={setup:function(){e(this).bind(t,e.noop)},teardown:function(){e(this).unbind(t)}}})}(e,this),function(e){e.event.special.throttledresize={setup:function(){e(this).bind("resize",i)},teardown:function(){e(this).unbind("resize",i)}};var n,t,o,i=function(){t=(new Date).getTime(),o=t-a,o>=250?(a=t,e(this).trigger("throttledresize")):(n&&clearTimeout(n),n=setTimeout(i,250-o))},a=0}(e),function(e,n){function o(){var e=i();e!==a&&(a=e,u.trigger(g))}var i,a,r,l,s,p,c,u=e(n),g="orientationchange",h={0:!0,180:!0};e.support.orientation&&(s=n.innerWidth||u.width(),p=n.innerHeight||u.height(),c=50,r=s>p&&s-p>c,l=h[n.orientation],(r&&l||!r&&!l)&&(h={"-90":!0,90:!0})),e.event.special.orientationchange=e.extend({},e.event.special.orientationchange,{setup:function(){return!(e.support.orientation&&!e.event.special.orientationchange.disabled)&&(a=i(),void u.bind("throttledresize",o))},teardown:function(){return!(e.support.orientation&&!e.event.special.orientationchange.disabled)&&void u.unbind("throttledresize",o)},add:function(e){var n=e.handler;e.handler=function(e){return e.orientation=i(),n.apply(this,arguments)}}}),e.event.special.orientationchange.orientation=i=function(){var o=!0,i=t.documentElement;return o=e.support.orientation?h[n.orientation]:i&&i.clientWidth/i.clientHeight<1.1,o?"portrait":"landscape"},e.fn[g]=function(e){return e?this.bind(g,e):this.trigger(g)},e.attrFn&&(e.attrFn[g]=!0)}(e,this),function(e){var n=e("head").children("base"),t={element:n.length?n:e("<base>",{href:e.mobile.path.documentBase.hrefNoHash}).prependTo(e("head")),linkSelector:"[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]",set:function(n){e.mobile.dynamicBaseEnabled&&e.support.dynamicBaseTag&&t.element.attr("href",e.mobile.path.makeUrlAbsolute(n,e.mobile.path.documentBase))},rewrite:function(n,o){var i=e.mobile.path.get(n);o.find(t.linkSelector).each(function(n,t){var o=e(t).is("[href]")?"href":e(t).is("[src]")?"src":"action",a=e(t).attr(o);a=a.replace(location.protocol+"//"+location.host+location.pathname,""),/^(\w+:|#|\/)/.test(a)||e(t).attr(o,i+a)})},reset:function(){t.element.attr("href",e.mobile.path.documentBase.hrefNoSearch)}};e.mobile.base=t}(e),function(e,n){e.mobile.widgets={};var t=e.widget,o=e.mobile.keepNative;e.widget=function(t){return function(){var o=t.apply(this,arguments),i=o.prototype.widgetName;return o.initSelector=o.prototype.initSelector!==n?o.prototype.initSelector:":jqmData(role='"+i+"')",e.mobile.widgets[i]=o,o}}(e.widget),e.extend(e.widget,t),e.mobile.document.on("create",function(n){e(n.target).enhanceWithin()}),e.widget("mobile.page",{options:{theme:"a",domCache:!1,keepNativeDefault:e.mobile.keepNative,contentTheme:null,enhanced:!1},_createWidget:function(){e.Widget.prototype._createWidget.apply(this,arguments),this._trigger("init")},_create:function(){return!1!==this._trigger("beforecreate")&&(this.options.enhanced||this._enhance(),this._on(this.element,{pagebeforehide:"removeContainerBackground",pagebeforeshow:"_handlePageBeforeShow"}),this.element.enhanceWithin(),void("dialog"===e.mobile.getAttribute(this.element[0],"role")&&e.mobile.dialog&&this.element.dialog()))},_enhance:function(){var t="data-"+e.mobile.ns,o=this;this.options.role&&this.element.attr("data-"+e.mobile.ns+"role",this.options.role),this.element.attr("tabindex","0").addClass("ui-page ui-page-theme-"+this.options.theme),this.element.find("["+t+"role='content']").each(function(){var i=e(this),a=this.getAttribute(t+"theme")||n;o.options.contentTheme=a||o.options.contentTheme||o.options.dialog&&o.options.theme||"dialog"===o.element.jqmData("role")&&o.options.theme,i.addClass("ui-content"),o.options.contentTheme&&i.addClass("ui-body-"+o.options.contentTheme),i.attr("role","main").addClass("ui-content")})},bindRemove:function(n){var t=this.element;!t.data("mobile-page").options.domCache&&t.is(":jqmData(external-page='true')")&&t.bind("pagehide.remove",n||function(n,t){if(!t.samePage){var o=e(this),i=new e.Event("pageremove");o.trigger(i),i.isDefaultPrevented()||o.removeWithDependents()}})},_setOptions:function(t){t.theme!==n&&this.element.removeClass("ui-page-theme-"+this.options.theme).addClass("ui-page-theme-"+t.theme),t.contentTheme!==n&&this.element.find("[data-"+e.mobile.ns+"='content']").removeClass("ui-body-"+this.options.contentTheme).addClass("ui-body-"+t.contentTheme)},_handlePageBeforeShow:function(){this.setContainerBackground()},removeContainerBackground:function(){this.element.closest(":mobile-pagecontainer").pagecontainer({theme:"none"})},setContainerBackground:function(e){this.element.parent().pagecontainer({theme:e||this.options.theme})},keepNativeSelector:function(){var n=this.options,t=e.trim(n.keepNative||""),i=e.trim(e.mobile.keepNative),a=e.trim(n.keepNativeDefault),r=o===i?"":i,l=""===r?a:"";return(t?[t]:[]).concat(r?[r]:[]).concat(l?[l]:[]).join(", ")}})}(e),function(e,o){e.widget("mobile.pagecontainer",{options:{theme:"a"},initSelector:!1,_create:function(){this.setLastScrollEnabled=!0,this._on(this.window,{navigate:"_disableRecordScroll",scrollstop:"_delayedRecordScroll"}),this._on(this.window,{navigate:"_filterNavigateEvents"}),this._on({pagechange:"_afterContentChange"}),this.window.one("navigate",e.proxy(function(){this.setLastScrollEnabled=!0},this))},_setOptions:function(e){e.theme!==o&&"none"!==e.theme?this.element.removeClass("ui-overlay-"+this.options.theme).addClass("ui-overlay-"+e.theme):e.theme!==o&&this.element.removeClass("ui-overlay-"+this.options.theme),this._super(e)},_disableRecordScroll:function(){this.setLastScrollEnabled=!1},_enableRecordScroll:function(){this.setLastScrollEnabled=!0},_afterContentChange:function(){this.setLastScrollEnabled=!0,this._off(this.window,"scrollstop"),this._on(this.window,{scrollstop:"_delayedRecordScroll"})},_recordScroll:function(){if(this.setLastScrollEnabled){var e,n,t,o=this._getActiveHistory();o&&(e=this._getScroll(),n=this._getMinScroll(),t=this._getDefaultScroll(),o.lastScroll=n>e?t:e)}},_delayedRecordScroll:function(){setTimeout(e.proxy(this,"_recordScroll"),100)},_getScroll:function(){return this.window.scrollTop()},_getMinScroll:function(){return e.mobile.minScrollBack},_getDefaultScroll:function(){return e.mobile.defaultHomeScroll},_filterNavigateEvents:function(n,t){var o;n.originalEvent&&n.originalEvent.isDefaultPrevented()||(o=n.originalEvent.type.indexOf("hashchange")>-1?t.state.hash:t.state.url,o||(o=this._getHash()),o&&"#"!==o&&0!==o.indexOf("#"+e.mobile.path.uiStateKey)||(o=location.href),this._handleNavigate(o,t.state))},_getHash:function(){return e.mobile.path.parseLocation().hash},getActivePage:function(){return this.activePage},_getInitialContent:function(){return e.mobile.firstPage},_getHistory:function(){return e.mobile.navigate.history},_getActiveHistory:function(){return e.mobile.navigate.history.getActive()},_getDocumentBase:function(){return e.mobile.path.documentBase},back:function(){this.go(-1)},forward:function(){this.go(1)},go:function(t){if(e.mobile.hashListeningEnabled)n.history.go(t);else{var o=e.mobile.navigate.history.activeIndex,i=o+parseInt(t,10),a=e.mobile.navigate.history.stack[i].url,r=t>=1?"forward":"back";e.mobile.navigate.history.activeIndex=i,e.mobile.navigate.history.previousIndex=o,this.change(a,{direction:r,changeHash:!1,fromHashChange:!0})}},_handleDestination:function(n){var t;return"string"===e.type(n)&&(n=e.mobile.path.stripHash(n)),n&&(t=this._getHistory(),(n=e.mobile.path.isPath(n)?n:e.mobile.path.makeUrlAbsolute("#"+n,this._getDocumentBase()))===e.mobile.path.makeUrlAbsolute("#"+t.initialDst,this._getDocumentBase())&&t.stack.length&&t.stack[0].url!==t.initialDst.replace(e.mobile.dialogHashKey,"")&&(n=this._getInitialContent())),n||this._getInitialContent()},_handleDialog:function(n,t){var o,i,a=this.getActivePage();return a&&!a.hasClass("ui-dialog")?("back"===t.direction?this.back():this.forward(),!1):(o=t.pageUrl,i=this._getActiveHistory(),e.extend(n,{role:i.role,transition:i.transition,reverse:"back"===t.direction}),o)},_handleNavigate:function(n,t){var i=e.mobile.path.stripHash(n),a=this._getHistory(),r=0===a.stack.length?"none":o,l={changeHash:!1,fromHashChange:!0,reverse:"back"===t.direction};e.extend(l,t,{transition:(a.getLast()||{}).transition||r}),a.activeIndex>0&&i.indexOf(e.mobile.dialogHashKey)>-1&&a.initialDst!==i&&!1===(i=this._handleDialog(l,t))||this._changeContent(this._handleDestination(i),l)},_changeContent:function(n,t){e.mobile.changePage(n,t)},_getBase:function(){return e.mobile.base},_getNs:function(){return e.mobile.ns},_enhance:function(e,n){return e.page({role:n})},_include:function(e,n){e.appendTo(this.element),this._enhance(e,n.role),e.page("bindRemove")},_find:function(n){var t,o=this._createFileUrl(n),i=this._createDataUrl(n),a=this._getInitialContent();return t=this.element.children("[data-"+this._getNs()+"url='"+i+"']"),0===t.length&&i&&!e.mobile.path.isPath(i)&&(t=this.element.children(e.mobile.path.hashToSelector("#"+i)).attr("data-"+this._getNs()+"url",i).jqmData("url",i)),0===t.length&&e.mobile.path.isFirstPageUrl(o)&&a&&a.parent().length&&(t=e(a)),t},_getLoader:function(){
return e.mobile.loading()},_showLoading:function(n,t,o,i){this._loadMsg||(this._loadMsg=setTimeout(e.proxy(function(){this._getLoader().loader("show",t,o,i),this._loadMsg=0},this),n))},_hideLoading:function(){clearTimeout(this._loadMsg),this._loadMsg=0,this._getLoader().loader("hide")},_showError:function(){this._hideLoading(),this._showLoading(0,e.mobile.pageLoadErrorMessageTheme,e.mobile.pageLoadErrorMessage,!0),setTimeout(e.proxy(this,"_hideLoading"),1500)},_parse:function(n,t){var o,i=e("<div></div>");return i.get(0).innerHTML=n,o=i.find(":jqmData(role='page'), :jqmData(role='dialog')").first(),o.length||(o=e("<div data-"+this._getNs()+"role='page'>"+(n.split(/<\/?body[^>]*>/gim)[1]||"")+"</div>")),o.attr("data-"+this._getNs()+"url",e.mobile.path.convertUrlToDataUrl(t)).attr("data-"+this._getNs()+"external-page",!0),o},_setLoadedTitle:function(n,t){var o=t.match(/<title[^>]*>([^<]*)/)&&RegExp.$1;o&&!n.jqmData("title")&&(o=e("<div>"+o+"</div>").text(),n.jqmData("title",o))},_isRewritableBaseTag:function(){return e.mobile.dynamicBaseEnabled&&!e.support.dynamicBaseTag},_createDataUrl:function(n){return e.mobile.path.convertUrlToDataUrl(n)},_createFileUrl:function(n){return e.mobile.path.getFilePath(n)},_triggerWithDeprecated:function(n,t,o){var i=e.Event("page"+n),a=e.Event(this.widgetName+n);return(o||this.element).trigger(i,t),this.element.trigger(a,t),{deprecatedEvent:i,event:a}},_loadSuccess:function(n,t,i,a){var r=this._createFileUrl(n),l=this._createDataUrl(n);return e.proxy(function(s,p,c){var u,g=new RegExp("(<[^>]+\\bdata-"+this._getNs()+"role=[\"']?page[\"']?[^>]*>)"),h=new RegExp("\\bdata-"+this._getNs()+"url=[\"']?([^\"'>]*)[\"']?");g.test(s)&&RegExp.$1&&h.test(RegExp.$1)&&RegExp.$1&&(r=e.mobile.path.getFilePath(e("<div>"+RegExp.$1+"</div>").text())),i.prefetch===o&&this._getBase().set(r),u=this._parse(s,r),this._setLoadedTitle(u,s),t.xhr=c,t.textStatus=p,t.page=u,t.content=u,this._trigger("load",o,t)&&(this._isRewritableBaseTag()&&u&&this._getBase().rewrite(r,u),this._include(u,i),n.indexOf("&"+e.mobile.subPageUrlKey)>-1&&(u=this.element.children("[data-"+this._getNs()+"url='"+l+"']")),i.showLoadMsg&&this._hideLoading(),this.element.trigger("pageload"),a.resolve(n,i,u))},this)},_loadDefaults:{type:"get",data:o,reloadPage:!1,reload:!1,role:o,showLoadMsg:!1,loadMsgDelay:50},load:function(n,t){var i,a,r,l,s=t&&t.deferred||e.Deferred(),p=e.extend({},this._loadDefaults,t),c=null,u=e.mobile.path.makeUrlAbsolute(n,this._findBaseWithDefault());return p.reload=p.reloadPage,p.data&&"get"===p.type&&(u=e.mobile.path.addSearchParams(u,p.data),p.data=o),p.data&&"post"===p.type&&(p.reload=!0),i=this._createFileUrl(u),a=this._createDataUrl(u),c=this._find(u),0===c.length&&e.mobile.path.isEmbeddedPage(i)&&!e.mobile.path.isFirstPageUrl(i)?void s.reject(u,p):(this._getBase().reset(),c.length&&!p.reload?(this._enhance(c,p.role),s.resolve(u,p,c),void(p.prefetch||this._getBase().set(n))):(l={url:n,absUrl:u,dataUrl:a,deferred:s,options:p},r=this._triggerWithDeprecated("beforeload",l),r.deprecatedEvent.isDefaultPrevented()||r.event.isDefaultPrevented()?void 0:(p.showLoadMsg&&this._showLoading(p.loadMsgDelay),p.prefetch===o&&this._getBase().reset(),e.mobile.allowCrossDomainPages||e.mobile.path.isSameDomain(e.mobile.path.documentUrl,u)?void e.ajax({url:i,type:p.type,data:p.data,contentType:p.contentType,dataType:"html",success:this._loadSuccess(u,l,p,s),error:this._loadError(u,l,p,s)}):void s.reject(u,p))))},_loadError:function(n,t,o,i){return e.proxy(function(a,r,l){this._getBase().set(e.mobile.path.get()),t.xhr=a,t.textStatus=r,t.errorThrown=l;var s=this._triggerWithDeprecated("loadfailed",t);s.deprecatedEvent.isDefaultPrevented()||s.event.isDefaultPrevented()||(o.showLoadMsg&&this._showError(),i.reject(n,o))},this)},_getTransitionHandler:function(n){return n=e.mobile._maybeDegradeTransition(n),e.mobile.transitionHandlers[n]||e.mobile.defaultTransitionHandler},_triggerCssTransitionEvents:function(n,t,o){var i=!1;o=o||"",t&&(n[0]===t[0]&&(i=!0),this._triggerWithDeprecated(o+"hide",{nextPage:n,samePage:i},t)),this._triggerWithDeprecated(o+"show",{prevPage:t||e("")},n)},_cssTransition:function(n,t,o){var i,a,r=o.transition,l=o.reverse,s=o.deferred;this._triggerCssTransitionEvents(n,t,"before"),this._hideLoading(),i=this._getTransitionHandler(r),a=new i(r,l,n,t).transition(),a.done(function(){s.resolve.apply(s,arguments)}),a.done(e.proxy(function(){this._triggerCssTransitionEvents(n,t)},this))},_releaseTransitionLock:function(){a=!1,i.length>0&&e.mobile.changePage.apply(null,i.pop())},_removeActiveLinkClass:function(n){e.mobile.removeActiveLinkClass(n)},_loadUrl:function(n,t,o){o.target=n,o.deferred=e.Deferred(),this.load(n,o),o.deferred.done(e.proxy(function(e,n,o){a=!1,n.absUrl=t.absUrl,this.transition(o,t,n)},this)),o.deferred.fail(e.proxy(function(){this._removeActiveLinkClass(!0),this._releaseTransitionLock(),this._triggerWithDeprecated("changefailed",t)},this))},_triggerPageBeforeChange:function(n,t,o){var i=new e.Event("pagebeforechange");return e.extend(t,{toPage:n,options:o}),t.absUrl="string"===e.type(n)?e.mobile.path.makeUrlAbsolute(n,this._findBaseWithDefault()):o.absUrl,this.element.trigger(i,t),!i.isDefaultPrevented()},change:function(n,t){if(a)return void i.unshift(arguments);var o=e.extend({},e.mobile.changePage.defaults,t),r={};o.fromPage=o.fromPage||this.activePage,this._triggerPageBeforeChange(n,r,o)&&(n=r.toPage,"string"===e.type(n)?(a=!0,this._loadUrl(n,r,o)):this.transition(n,r,o))},transition:function(n,r,l){var s,p,c,u,g,h,m,d,b,_,f,w,v;if(a)return void i.unshift([n,l]);if(this._triggerPageBeforeChange(n,r,l)&&(v=this._triggerWithDeprecated("beforetransition",r),!v.deprecatedEvent.isDefaultPrevented()&&!v.event.isDefaultPrevented())){if(a=!0,n[0]!==e.mobile.firstPage[0]||l.dataUrl||(l.dataUrl=e.mobile.path.documentUrl.hrefNoHash),s=l.fromPage,p=l.dataUrl&&e.mobile.path.convertUrlToDataUrl(l.dataUrl)||n.jqmData("url"),c=p,e.mobile.path.getFilePath(p),u=e.mobile.navigate.history.getActive(),g=0===e.mobile.navigate.history.activeIndex,h=0,m=t.title,d=("dialog"===l.role||"dialog"===n.jqmData("role"))&&!0!==n.jqmData("dialog"),s&&s[0]===n[0]&&!l.allowSamePageTransition)return a=!1,this._triggerWithDeprecated("transition",r),this.element.trigger("pagechange",r),void(l.fromHashChange&&e.mobile.navigate.history.direct({url:p}));n.page({role:l.role}),l.fromHashChange&&(h="back"===l.direction?-1:1);try{t.activeElement&&"body"!==t.activeElement.nodeName.toLowerCase()?e(t.activeElement).blur():e("input:focus, textarea:focus, select:focus").blur()}catch(E){}b=!1,d&&u&&(u.url&&u.url.indexOf(e.mobile.dialogHashKey)>-1&&this.activePage&&!this.activePage.hasClass("ui-dialog")&&e.mobile.navigate.history.activeIndex>0&&(l.changeHash=!1,b=!0),p=u.url||"",p+=!b&&p.indexOf("#")>-1?e.mobile.dialogHashKey:"#"+e.mobile.dialogHashKey,0===e.mobile.navigate.history.activeIndex&&p===e.mobile.navigate.history.initialDst&&(p+=e.mobile.dialogHashKey)),_=u?n.jqmData("title")||n.children(":jqmData(role='header')").find(".ui-title").text():m,_&&m===t.title&&(m=_),n.jqmData("title")||n.jqmData("title",m),l.transition=l.transition||(h&&!g?u.transition:o)||(d?e.mobile.defaultDialogTransition:e.mobile.defaultPageTransition),!h&&b&&(e.mobile.navigate.history.getActive().pageUrl=c),p&&!l.fromHashChange&&(!e.mobile.path.isPath(p)&&p.indexOf("#")<0&&(p="#"+p),f={transition:l.transition,title:m,pageUrl:c,role:l.role},!1!==l.changeHash&&e.mobile.hashListeningEnabled?e.mobile.navigate(p,f,!0):n[0]!==e.mobile.firstPage[0]&&e.mobile.navigate.history.add(p,f)),t.title=m,e.mobile.activePage=n,this.activePage=n,l.reverse=l.reverse||0>h,w=e.Deferred(),this._cssTransition(n,s,{transition:l.transition,reverse:l.reverse,deferred:w}),w.done(e.proxy(function(t,o,i,a,s){e.mobile.removeActiveLinkClass(),l.duplicateCachedPage&&l.duplicateCachedPage.remove(),s||e.mobile.focusPage(n),this._releaseTransitionLock(),this.element.trigger("pagechange",r),this._triggerWithDeprecated("transition",r)},this))}},_findBaseWithDefault:function(){return this.activePage&&e.mobile.getClosestBaseUrl(this.activePage)||e.mobile.path.documentBase.hrefNoHash}}),e.mobile.navreadyDeferred=e.Deferred();var i=[],a=!1}(e),function(e,t){function o(e){for(;e&&("string"!=typeof e.nodeName||"a"!==e.nodeName.toLowerCase());)e=e.parentNode;return e}var i=e.Deferred(),a=e.Deferred(),r=e.mobile.path.documentUrl,l=null;e.mobile.loadPage=function(n,t){var o;return t=t||{},o=t.pageContainer||e.mobile.pageContainer,t.deferred=e.Deferred(),o.pagecontainer("load",n,t),t.deferred.promise()},e.mobile.back=function(){var t=n.navigator;this.phonegapNavigationEnabled&&t&&t.app&&t.app.backHistory?t.app.backHistory():e.mobile.pageContainer.pagecontainer("back")},e.mobile.focusPage=function(e){var n=e.find("[autofocus]"),t=e.find(".ui-title:eq(0)");return n.length?void n.focus():void(t.length?t.focus():e.focus())},e.mobile._maybeDegradeTransition=e.mobile._maybeDegradeTransition||function(e){return e},e.mobile.changePage=function(n,t){e.mobile.pageContainer.pagecontainer("change",n,t)},e.mobile.changePage.defaults={transition:t,reverse:!1,changeHash:!0,fromHashChange:!1,role:t,duplicateCachedPage:t,pageContainer:t,showLoadMsg:!0,dataUrl:t,fromPage:t,allowSamePageTransition:!1},e.mobile._registerInternalEvents=function(){var i=function(n,t){var o,i,a,s,p=!0;return!(!e.mobile.ajaxEnabled||n.is(":jqmData(ajax='false')")||!n.jqmHijackable().length||n.attr("target"))&&(o=l&&l.attr("formaction")||n.attr("action"),s=(n.attr("method")||"get").toLowerCase(),o||(o=e.mobile.getClosestBaseUrl(n),"get"===s&&(o=e.mobile.path.parseUrl(o).hrefNoSearch),o===e.mobile.path.documentBase.hrefNoHash&&(o=r.hrefNoSearch)),o=e.mobile.path.makeUrlAbsolute(o,e.mobile.getClosestBaseUrl(n)),!(e.mobile.path.isExternal(o)&&!e.mobile.path.isPermittedCrossDomainRequest(r,o))&&(t||(i=n.serializeArray(),l&&l[0].form===n[0]&&(a=l.attr("name"))&&(e.each(i,function(e,n){return n.name===a?(a="",!1):void 0}),a&&i.push({name:a,value:l.attr("value")})),p={url:o,options:{type:s,data:e.param(i),transition:n.jqmData("transition"),reverse:"reverse"===n.jqmData("direction"),reloadPage:!0}}),p))};e.mobile.document.delegate("form","submit",function(n){var t;n.isDefaultPrevented()||(t=i(e(this)))&&(e.mobile.changePage(t.url,t.options),n.preventDefault())}),e.mobile.document.bind("vclick",function(n){var t,a,r=n.target,s=!1;if(!(n.which>1)&&e.mobile.linkBindingEnabled){if(l=e(r),e.data(r,"mobile-button")){if(!i(e(r).closest("form"),!0))return;r.parentNode&&(r=r.parentNode)}else{if(!(r=o(r))||"#"===e.mobile.path.parseUrl(r.getAttribute("href")||"#").hash)return;if(!e(r).jqmHijackable().length)return}~r.className.indexOf("ui-link-inherit")?r.parentNode&&(a=e.data(r.parentNode,"buttonElements")):a=e.data(r,"buttonElements"),a?r=a.outer:s=!0,t=e(r),s&&(t=t.closest(".ui-btn")),t.length>0&&!t.hasClass("ui-state-disabled")&&(e.mobile.removeActiveLinkClass(!0),e.mobile.activeClickedLink=t,e.mobile.activeClickedLink.addClass(e.mobile.activeBtnClass))}}),e.mobile.document.bind("click",function(i){if(e.mobile.linkBindingEnabled&&!i.isDefaultPrevented()){var a,l,s,p,c,u,g=o(i.target),h=e(g),m=function(){n.setTimeout(function(){e.mobile.removeActiveLinkClass(!0)},200)};if(e.mobile.activeClickedLink&&e.mobile.activeClickedLink[0]===i.target.parentNode&&m(),g&&!(i.which>1)&&h.jqmHijackable().length){if(h.is(":jqmData(rel='back')"))return e.mobile.back(),!1;if(a=e.mobile.getClosestBaseUrl(h),l=e.mobile.path.makeUrlAbsolute(h.attr("href")||"#",a),!e.mobile.ajaxEnabled&&!e.mobile.path.isEmbeddedPage(l))return void m();if(-1!==l.search("#")){if(!(l=l.replace(/[^#]*#/,"")))return void i.preventDefault();l=e.mobile.path.isPath(l)?e.mobile.path.makeUrlAbsolute(l,a):e.mobile.path.makeUrlAbsolute("#"+l,r.hrefNoHash)}if(s=h.is("[rel='external']")||h.is(":jqmData(ajax='false')")||h.is("[target]"),s||e.mobile.path.isExternal(l)&&!e.mobile.path.isPermittedCrossDomainRequest(r,l))return void m();p=h.jqmData("transition"),c="reverse"===h.jqmData("direction")||h.jqmData("back"),u=h.attr("data-"+e.mobile.ns+"rel")||t,e.mobile.changePage(l,{transition:p,reverse:c,role:u,link:h}),i.preventDefault()}}}),e.mobile.document.delegate(".ui-page","pageshow.prefetch",function(){var n=[];e(this).find("a:jqmData(prefetch)").each(function(){var t=e(this),o=t.attr("href");o&&-1===e.inArray(o,n)&&(n.push(o),e.mobile.loadPage(o,{role:t.attr("data-"+e.mobile.ns+"rel"),prefetch:!0}))})}),e.mobile.pageContainer.pagecontainer(),e.mobile.document.bind("pageshow",function(){a?a.done(e.mobile.resetActivePageHeight):e.mobile.resetActivePageHeight()}),e.mobile.window.bind("throttledresize",e.mobile.resetActivePageHeight)},e(function(){i.resolve()}),e.mobile.window.load(function(){a.resolve(),a=null}),e.when(i,e.mobile.navreadyDeferred).done(function(){e.mobile._registerInternalEvents()})}(e),function(e,n){e.mobile.Transition=function(){this.init.apply(this,arguments)},e.extend(e.mobile.Transition.prototype,{toPreClass:" ui-page-pre-in",init:function(n,t,o,i){e.extend(this,{name:n,reverse:t,$to:o,$from:i,deferred:new e.Deferred})},cleanFrom:function(){this.$from.removeClass(e.mobile.activePageClass+" out in reverse "+this.name).height("")},beforeDoneIn:function(){},beforeDoneOut:function(){},beforeStartOut:function(){},doneIn:function(){this.beforeDoneIn(),this.$to.removeClass("out in reverse "+this.name).height(""),this.toggleViewportClass(),e.mobile.window.scrollTop()!==this.toScroll&&this.scrollPage(),this.sequential||this.$to.addClass(e.mobile.activePageClass),this.deferred.resolve(this.name,this.reverse,this.$to,this.$from,!0)},doneOut:function(e,n,t,o){this.beforeDoneOut(),this.startIn(e,n,t,o)},hideIn:function(e){this.$to.css("z-index",-10),e.call(this),this.$to.css("z-index","")},scrollPage:function(){e.event.special.scrollstart.enabled=!1,(e.mobile.hideUrlBar||this.toScroll!==e.mobile.defaultHomeScroll)&&n.scrollTo(0,this.toScroll),setTimeout(function(){e.event.special.scrollstart.enabled=!0},150)},startIn:function(n,t,o,i){this.hideIn(function(){this.$to.addClass(e.mobile.activePageClass+this.toPreClass),i||e.mobile.focusPage(this.$to),this.$to.height(n+this.toScroll),o||this.scrollPage()}),this.$to.removeClass(this.toPreClass).addClass(this.name+" in "+t),o?this.doneIn():this.$to.animationComplete(e.proxy(function(){this.doneIn()},this))},startOut:function(n,t,o){this.beforeStartOut(n,t,o),this.$from.height(n+e.mobile.window.scrollTop()).addClass(this.name+" out"+t)},toggleViewportClass:function(){e.mobile.pageContainer.toggleClass("ui-mobile-viewport-transitioning viewport-"+this.name)},transition:function(){var n,t=this.reverse?" reverse":"",o=e.mobile.getScreenHeight(),i=!1!==e.mobile.maxTransitionWidth&&e.mobile.window.width()>e.mobile.maxTransitionWidth;return this.toScroll=e.mobile.navigate.history.getActive().lastScroll||e.mobile.defaultHomeScroll,n=!e.support.cssTransitions||!e.support.cssAnimations||i||!this.name||"none"===this.name||Math.max(e.mobile.window.scrollTop(),this.toScroll)>e.mobile.getMaxScrollForTransition(),this.toggleViewportClass(),this.$from&&!n?this.startOut(o,t,n):this.doneOut(o,t,n,!0),this.deferred.promise()}})}(e,this),function(e){e.mobile.SerialTransition=function(){this.init.apply(this,arguments)},e.extend(e.mobile.SerialTransition.prototype,e.mobile.Transition.prototype,{sequential:!0,beforeDoneOut:function(){this.$from&&this.cleanFrom()},beforeStartOut:function(n,t,o){this.$from.animationComplete(e.proxy(function(){this.doneOut(n,t,o)},this))}})}(e),function(e){e.mobile.ConcurrentTransition=function(){this.init.apply(this,arguments)},e.extend(e.mobile.ConcurrentTransition.prototype,e.mobile.Transition.prototype,{sequential:!1,beforeDoneIn:function(){this.$from&&this.cleanFrom()},beforeStartOut:function(e,n,t){this.doneOut(e,n,t)}})}(e),function(e){var n=function(){return 3*e.mobile.getScreenHeight()};e.mobile.transitionHandlers={sequential:e.mobile.SerialTransition,simultaneous:e.mobile.ConcurrentTransition},e.mobile.defaultTransitionHandler=e.mobile.transitionHandlers.sequential,e.mobile.transitionFallbacks={},e.mobile._maybeDegradeTransition=function(n){return n&&!e.support.cssTransform3d&&e.mobile.transitionFallbacks[n]&&(n=e.mobile.transitionFallbacks[n]),n},e.mobile.getMaxScrollForTransition=e.mobile.getMaxScrollForTransition||n}(e),function(e){e.mobile.transitionFallbacks.flip="fade"}(e),function(e){e.mobile.transitionFallbacks.flow="fade"}(e),function(e){e.mobile.transitionFallbacks.pop="fade"}(e),function(e){e.mobile.transitionHandlers.slide=e.mobile.transitionHandlers.simultaneous,e.mobile.transitionFallbacks.slide="fade"}(e),function(e){e.mobile.transitionFallbacks.slidedown="fade"}(e),function(e){e.mobile.transitionFallbacks.slidefade="fade"}(e),function(e){e.mobile.transitionFallbacks.slideup="fade"}(e),function(e){e.mobile.transitionFallbacks.turn="fade"}(e),function(e){e.mobile.degradeInputs={color:!1,date:!1,datetime:!1,"datetime-local":!1,email:!1,month:!1,number:!1,range:"number",search:"text",tel:!1,time:!1,url:!1,week:!1},e.mobile.page.prototype.options.degradeInputs=e.mobile.degradeInputs,e.mobile.degradeInputsWithin=function(n){n=e(n),n.find("input").not(e.mobile.page.prototype.keepNativeSelector()).each(function(){var n,t,o,i,a=e(this),r=this.getAttribute("type"),l=e.mobile.degradeInputs[r]||"text";e.mobile.degradeInputs[r]&&(n=e("<div>").html(a.clone()).html(),t=n.indexOf(" type=")>-1,o=t?/\s+type=["']?\w+['"]?/:/\/?>/,i=' type="'+l+'" data-'+e.mobile.ns+'type="'+r+'"'+(t?"":">"),a.replaceWith(n.replace(o,i)))})}}(e),function(e,n,t){e.widget("mobile.page",e.mobile.page,{options:{closeBtn:"left",closeBtnText:"Close",overlayTheme:"a",corners:!0,dialog:!1},_create:function(){this._super(),this.options.dialog&&(e.extend(this,{_inner:this.element.children(),_headerCloseButton:null}),this.options.enhanced||this._setCloseBtn(this.options.closeBtn))},_enhance:function(){this._super(),this.options.dialog&&this.element.addClass("ui-dialog").wrapInner(e("<div/>",{role:"dialog","class":"ui-dialog-contain ui-overlay-shadow"+(this.options.corners?" ui-corner-all":"")}))},_setOptions:function(n){var o,i,a=this.options;n.corners!==t&&this._inner.toggleClass("ui-corner-all",!!n.corners),n.overlayTheme!==t&&e.mobile.activePage[0]===this.element[0]&&(a.overlayTheme=n.overlayTheme,this._handlePageBeforeShow()),n.closeBtnText!==t&&(o=a.closeBtn,i=n.closeBtnText),n.closeBtn!==t&&(o=n.closeBtn),o&&this._setCloseBtn(o,i),this._super(n)},_handlePageBeforeShow:function(){this.options.overlayTheme&&this.options.dialog?(this.removeContainerBackground(),this.setContainerBackground(this.options.overlayTheme)):this._super()},_setCloseBtn:function(n,t){var o,i=this._headerCloseButton;n="left"===n?"left":"right"===n?"right":"none","none"===n?i&&(i.remove(),i=null):i?(i.removeClass("ui-btn-left ui-btn-right").addClass("ui-btn-"+n),t&&i.text(t)):(o=this._inner.find(":jqmData(role='header')").first(),i=e("<a></a>",{href:"#","class":"ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-"+n}).attr("data-"+e.mobile.ns+"rel","back").text(t||this.options.closeBtnText||"").prependTo(o)),this._headerCloseButton=i}})}(e),function(e,n,t){e.widget("mobile.dialog",{options:{closeBtn:"left",closeBtnText:"Close",overlayTheme:"a",corners:!0},_handlePageBeforeShow:function(){this._isCloseable=!0,this.options.overlayTheme&&this.element.page("removeContainerBackground").page("setContainerBackground",this.options.overlayTheme)},_handlePageBeforeHide:function(){this._isCloseable=!1},_handleVClickSubmit:function(n){var t,o=e(n.target).closest("vclick"===n.type?"a":"form");o.length&&!o.jqmData("transition")&&(t={},t["data-"+e.mobile.ns+"transition"]=(e.mobile.navigate.history.getActive()||{}).transition||e.mobile.defaultDialogTransition,t["data-"+e.mobile.ns+"direction"]="reverse",o.attr(t))},_create:function(){var n=this.element,t=this.options;n.addClass("ui-dialog").wrapInner(e("<div/>",{role:"dialog","class":"ui-dialog-contain ui-overlay-shadow"+(t.corners?" ui-corner-all":"")})),e.extend(this,{_isCloseable:!1,_inner:n.children(),_headerCloseButton:null}),this._on(n,{vclick:"_handleVClickSubmit",submit:"_handleVClickSubmit",pagebeforeshow:"_handlePageBeforeShow",pagebeforehide:"_handlePageBeforeHide"}),this._setCloseBtn(t.closeBtn)},_setOptions:function(n){var o,i,a=this.options;n.corners!==t&&this._inner.toggleClass("ui-corner-all",!!n.corners),n.overlayTheme!==t&&e.mobile.activePage[0]===this.element[0]&&(a.overlayTheme=n.overlayTheme,this._handlePageBeforeShow()),n.closeBtnText!==t&&(o=a.closeBtn,i=n.closeBtnText),n.closeBtn!==t&&(o=n.closeBtn),o&&this._setCloseBtn(o,i),this._super(n)},_setCloseBtn:function(n,t){var o,i=this._headerCloseButton;n="left"===n?"left":"right"===n?"right":"none","none"===n?i&&(i.remove(),i=null):i?(i.removeClass("ui-btn-left ui-btn-right").addClass("ui-btn-"+n),t&&i.text(t)):(o=this._inner.find(":jqmData(role='header')").first(),i=e("<a></a>",{role:"button",href:"#","class":"ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-"+n}).text(t||this.options.closeBtnText||"").prependTo(o),this._on(i,{click:"close"})),this._headerCloseButton=i},close:function(){var n=e.mobile.navigate.history;this._isCloseable&&(this._isCloseable=!1,e.mobile.hashListeningEnabled&&n.activeIndex>0?e.mobile.back():e.mobile.pageContainer.pagecontainer("back"))}})}(e),function(e,n){var t=function(e){return"ui-btn-icon-"+(null===e?"left":e)};e.widget("mobile.collapsible",{options:{enhanced:!1,expandCueText:null,collapseCueText:null,collapsed:!0,heading:"h1,h2,h3,h4,h5,h6,legend",collapsedIcon:null,expandedIcon:null,iconpos:null,theme:null,contentTheme:null,inset:null,corners:null,mini:null},_create:function(){var n=this.element,t={accordion:n.closest(":jqmData(role='collapsible-set'),:jqmData(role='collapsibleset')"+(e.mobile.collapsibleset?", :mobile-collapsibleset":"")).addClass("ui-collapsible-set")};this._ui=t,this._renderedOptions=this._getOptions(this.options),this.options.enhanced?(t.heading=e(".ui-collapsible-heading",this.element[0]),t.content=t.heading.next(),t.anchor=e("a",t.heading[0]).first(),t.status=t.anchor.children(".ui-collapsible-heading-status")):this._enhance(n,t),this._on(t.heading,{tap:function(){t.heading.find("a").first().addClass(e.mobile.activeBtnClass)},click:function(e){this._handleExpandCollapse(!t.heading.hasClass("ui-collapsible-heading-collapsed")),e.preventDefault(),e.stopPropagation()}})},_getOptions:function(n){var t,o=this._ui.accordion,i=this._ui.accordionWidget;n=e.extend({},n),o.length&&!i&&(this._ui.accordionWidget=i=o.data("mobile-collapsibleset"));for(t in n)n[t]=null!=n[t]?n[t]:i?i.options[t]:o.length?e.mobile.getAttribute(o[0],t.replace(/([A-Z])/g,"-$1").toLowerCase()):null,null==n[t]&&(n[t]=e.mobile.collapsible.defaults[t]);return n},_themeClassFromOption:function(e,n){return n?"none"===n?"":e+n:""},_enhance:function(n,o){var i,a=this._renderedOptions,r=this._themeClassFromOption("ui-body-",a.contentTheme);return n.addClass("ui-collapsible "+(a.inset?"ui-collapsible-inset ":"")+(a.inset&&a.corners?"ui-corner-all ":"")+(r?"ui-collapsible-themed-content ":"")),o.originalHeading=n.children(this.options.heading).first(),o.content=n.wrapInner("<div class='ui-collapsible-content "+r+"'></div>").children(".ui-collapsible-content"),o.heading=o.originalHeading,o.heading.is("legend")&&(o.heading=e("<div role='heading'>"+o.heading.html()+"</div>"),o.placeholder=e("<div>\x3c!-- placeholder for legend --\x3e</div>").insertBefore(o.originalHeading),o.originalHeading.remove()),i=a.collapsed?a.collapsedIcon?"ui-icon-"+a.collapsedIcon:"":a.expandedIcon?"ui-icon-"+a.expandedIcon:"",o.status=e("<span class='ui-collapsible-heading-status'></span>"),o.anchor=o.heading.detach().addClass("ui-collapsible-heading").append(o.status).wrapInner("<a href='#' class='ui-collapsible-heading-toggle'></a>").find("a").first().addClass("ui-btn "+(i?i+" ":"")+(i?t(a.iconpos)+" ":"")+this._themeClassFromOption("ui-btn-",a.theme)+" "+(a.mini?"ui-mini ":"")),o.heading.insertBefore(o.content),this._handleExpandCollapse(this.options.collapsed),o},refresh:function(){this._applyOptions(this.options),this._renderedOptions=this._getOptions(this.options)},_applyOptions:function(e){var o,i,a,r,l,s=this.element,p=this._renderedOptions,c=this._ui,u=c.anchor,g=c.status,h=this._getOptions(e);e.collapsed!==n&&this._handleExpandCollapse(e.collapsed),o=s.hasClass("ui-collapsible-collapsed"),o?h.expandCueText!==n&&g.text(h.expandCueText):h.collapseCueText!==n&&g.text(h.collapseCueText),l=h.collapsedIcon!==n?!1!==h.collapsedIcon:!1!==p.collapsedIcon,(h.iconpos!==n||h.collapsedIcon!==n||h.expandedIcon!==n)&&(u.removeClass([t(p.iconpos)].concat(p.expandedIcon?["ui-icon-"+p.expandedIcon]:[]).concat(p.collapsedIcon?["ui-icon-"+p.collapsedIcon]:[]).join(" ")),l&&u.addClass([t(h.iconpos!==n?h.iconpos:p.iconpos)].concat(o?["ui-icon-"+(h.collapsedIcon!==n?h.collapsedIcon:p.collapsedIcon)]:["ui-icon-"+(h.expandedIcon!==n?h.expandedIcon:p.expandedIcon)]).join(" "))),h.theme!==n&&(a=this._themeClassFromOption("ui-btn-",p.theme),i=this._themeClassFromOption("ui-btn-",h.theme),u.removeClass(a).addClass(i)),h.contentTheme!==n&&(a=this._themeClassFromOption("ui-body-",p.contentTheme),i=this._themeClassFromOption("ui-body-",h.contentTheme),c.content.removeClass(a).addClass(i)),h.inset!==n&&(s.toggleClass("ui-collapsible-inset",h.inset),r=!(!h.inset||!h.corners&&!p.corners)),h.corners!==n&&(r=!(!h.corners||!h.inset&&!p.inset)),r!==n&&s.toggleClass("ui-corner-all",r),h.mini!==n&&u.toggleClass("ui-mini",h.mini)},_setOptions:function(e){this._applyOptions(e),this._super(e),this._renderedOptions=this._getOptions(this.options)},_handleExpandCollapse:function(n){var t=this._renderedOptions,o=this._ui;o.status.text(n?t.expandCueText:t.collapseCueText),o.heading.toggleClass("ui-collapsible-heading-collapsed",n).find("a").first().toggleClass("ui-icon-"+t.expandedIcon,!n).toggleClass("ui-icon-"+t.collapsedIcon,n||t.expandedIcon===t.collapsedIcon).removeClass(e.mobile.activeBtnClass),this.element.toggleClass("ui-collapsible-collapsed",n),o.content.toggleClass("ui-collapsible-content-collapsed",n).attr("aria-hidden",n).trigger("updatelayout"),this.options.collapsed=n,this._trigger(n?"collapse":"expand")},expand:function(){this._handleExpandCollapse(!1)},collapse:function(){this._handleExpandCollapse(!0)},_destroy:function(){var e=this._ui;this.options.enhanced||(e.placeholder?(e.originalHeading.insertBefore(e.placeholder),e.placeholder.remove(),e.heading.remove()):(e.status.remove(),e.heading.removeClass("ui-collapsible-heading ui-collapsible-heading-collapsed").children().contents().unwrap()),e.anchor.contents().unwrap(),e.content.contents().unwrap(),this.element.removeClass("ui-collapsible ui-collapsible-collapsed ui-collapsible-themed-content ui-collapsible-inset ui-corner-all"))}}),e.mobile.collapsible.defaults={expandCueText:" click to expand contents",collapseCueText:" click to collapse contents",collapsedIcon:"plus",contentTheme:"inherit",expandedIcon:"minus",iconpos:"left",inset:!0,corners:!0,theme:"inherit",mini:!1}}(e),function(e){e.mobile.behaviors.addFirstLastClasses={_getVisibles:function(e,n){var t;return n?t=e.not(".ui-screen-hidden"):(t=e.filter(":visible"),0===t.length&&(t=e.not(".ui-screen-hidden"))),t},_addFirstLastClasses:function(e,n,t){e.removeClass("ui-first-child ui-last-child"),n.eq(0).addClass("ui-first-child").end().last().addClass("ui-last-child"),t||this.element.trigger("updatelayout")},_removeFirstLastClasses:function(e){e.removeClass("ui-first-child ui-last-child")}}}(e),function(e,n){var t=":mobile-collapsible, "+e.mobile.collapsible.initSelector;e.widget("mobile.collapsibleset",e.extend({initSelector:":jqmData(role='collapsible-set'),:jqmData(role='collapsibleset')",options:e.extend({enhanced:!1},e.mobile.collapsible.defaults),_handleCollapsibleExpand:function(n){var t=e(n.target).closest(".ui-collapsible");t.parent().is(":mobile-collapsibleset, :jqmData(role='collapsible-set')")&&t.siblings(".ui-collapsible:not(.ui-collapsible-collapsed)").collapsible("collapse")},_create:function(){var n=this.element,t=this.options;e.extend(this,{_classes:""}),t.enhanced||(n.addClass("ui-collapsible-set "+this._themeClassFromOption("ui-group-theme-",t.theme)+" "+(t.corners&&t.inset?"ui-corner-all ":"")),this.element.find(e.mobile.collapsible.initSelector).collapsible()),this._on(n,{collapsibleexpand:"_handleCollapsibleExpand"})},_themeClassFromOption:function(e,n){return n?"none"===n?"":e+n:""},_init:function(){this._refresh(!0),this.element.children(t).filter(":jqmData(collapsed='false')").collapsible("expand")},_setOptions:function(e){var t,o,i=this.element,a=this._themeClassFromOption("ui-group-theme-",e.theme);return a&&i.removeClass(this._themeClassFromOption("ui-group-theme-",this.options.theme)).addClass(a),e.inset!==n&&(o=!(!e.inset||!e.corners&&!this.options.corners)),e.corners!==n&&(o=!(!e.corners||!e.inset&&!this.options.inset)),o!==n&&i.toggleClass("ui-corner-all",o),t=this._super(e),this.element.children(":mobile-collapsible").collapsible("refresh"),t},_destroy:function(){var e=this.element;this._removeFirstLastClasses(e.children(t)),e.removeClass("ui-collapsible-set ui-corner-all "+this._themeClassFromOption("ui-group-theme-",this.options.theme)).children(":mobile-collapsible").collapsible("destroy")},_refresh:function(n){var o=this.element.children(t);this.element.find(e.mobile.collapsible.initSelector).not(".ui-collapsible").collapsible(),this._addFirstLastClasses(o,this._getVisibles(o,n),n)},refresh:function(){this._refresh(!1)}},e.mobile.behaviors.addFirstLastClasses))}(e),function(e){e.fn.fieldcontain=function(){return this.addClass("ui-field-contain")}}(e),function(e){e.fn.grid=function(n){return this.each(function(){var t,o,i=e(this),a=e.extend({grid:null},n),r=i.children(),l={solo:1,a:2,b:3,c:4,d:5},s=a.grid;if(!s)if(r.length<=5)for(o in l)l[o]===r.length&&(s=o);else s="a",i.addClass("ui-grid-duo");t=l[s],i.addClass("ui-grid-"+s),r.filter(":nth-child("+t+"n+1)").addClass("ui-block-a"),t>1&&r.filter(":nth-child("+t+"n+2)").addClass("ui-block-b"),t>2&&r.filter(":nth-child("+t+"n+3)").addClass("ui-block-c"),t>3&&r.filter(":nth-child("+t+"n+4)").addClass("ui-block-d"),t>4&&r.filter(":nth-child("+t+"n+5)").addClass("ui-block-e")})}}(e),function(e,n){e.widget("mobile.navbar",{options:{iconpos:"top",grid:null},_create:function(){var n=this.element,o=n.find("a"),i=o.filter(":jqmData(icon)").length?this.options.iconpos:void 0;n.addClass("ui-navbar").attr("role","navigation").find("ul").jqmEnhanceable().grid({grid:this.options.grid}),o.each(function(){var n=e.mobile.getAttribute(this,"icon"),t=e.mobile.getAttribute(this,"theme"),o="ui-btn";t&&(o+=" ui-btn-"+t),n&&(o+=" ui-icon-"+n+" ui-btn-icon-"+i),e(this).addClass(o)}),n.delegate("a","vclick",function(){var n=e(this);n.hasClass("ui-state-disabled")||n.hasClass("ui-disabled")||n.hasClass(e.mobile.activeBtnClass)||(o.removeClass(e.mobile.activeBtnClass),n.addClass(e.mobile.activeBtnClass),e(t).one("pagehide",function(){n.removeClass(e.mobile.activeBtnClass)}))}),n.closest(".ui-page").bind("pagebeforeshow",function(){o.filter(".ui-state-persist").addClass(e.mobile.activeBtnClass)})}})}(e),function(e){var n=e.mobile.getAttribute;e.widget("mobile.listview",e.extend({options:{theme:null,countTheme:null,dividerTheme:null,icon:"carat-r",splitIcon:"carat-r",splitTheme:null,corners:!0,shadow:!0,inset:!1},_create:function(){var e=this,n="";n+=e.options.inset?" ui-listview-inset":"",e.options.inset&&(n+=e.options.corners?" ui-corner-all":"",n+=e.options.shadow?" ui-shadow":""),e.element.addClass(" ui-listview"+n),e.refresh(!0)},_findFirstElementByTagName:function(e,n,t,o){var i={};for(i[t]=i[o]=!0;e;){if(i[e.nodeName])return e;e=e[n]}return null},_addThumbClasses:function(n){var t,o,i=n.length;for(t=0;i>t;t++)o=e(this._findFirstElementByTagName(n[t].firstChild,"nextSibling","img","IMG")),
o.length&&e(this._findFirstElementByTagName(o[0].parentNode,"parentNode","li","LI")).addClass(o.hasClass("ui-li-icon")?"ui-li-has-icon":"ui-li-has-thumb")},_getChildrenByTagName:function(n,t,o){var i=[],a={};for(a[t]=a[o]=!0,n=n.firstChild;n;)a[n.nodeName]&&i.push(n),n=n.nextSibling;return e(i)},_beforeListviewRefresh:e.noop,_afterListviewRefresh:e.noop,refresh:function(t){var o,i,a,r,l,s,p,c,u,g,h,m,d,b,_,f,w,v,E,P,T=this.options,S=this.element,N=!!e.nodeName(S[0],"ol"),I=S.attr("start"),C={},G=S.find(".ui-li-count"),L=n(S[0],"counttheme")||this.options.countTheme,R=L?"ui-body-"+L:"ui-body-inherit";for(T.theme&&S.addClass("ui-group-theme-"+T.theme),N&&(I||0===I)&&(h=parseInt(I,10)-1,S.css("counter-reset","listnumbering "+h)),this._beforeListviewRefresh(),P=this._getChildrenByTagName(S[0],"li","LI"),i=0,a=P.length;a>i;i++)r=P.eq(i),l="",(t||r[0].className.search(/\bui-li-static\b|\bui-li-divider\b/)<0)&&(u=this._getChildrenByTagName(r[0],"a","A"),g="list-divider"===n(r[0],"role"),d=r.attr("value"),s=n(r[0],"theme"),u.length&&u[0].className.search(/\bui-btn\b/)<0&&!g?(p=n(r[0],"icon"),c=!1!==p&&(p||T.icon),u.removeClass("ui-link"),o="ui-btn",s&&(o+=" ui-btn-"+s),u.length>1?(l="ui-li-has-alt",b=u.last(),_=n(b[0],"theme")||T.splitTheme||n(r[0],"theme",!0),f=_?" ui-btn-"+_:"",w=n(b[0],"icon")||n(r[0],"icon")||T.splitIcon,v="ui-btn ui-btn-icon-notext ui-icon-"+w+f,b.attr("title",e.trim(b.getEncodedText())).addClass(v).empty()):c&&(o+=" ui-btn-icon-right ui-icon-"+c),u.first().addClass(o)):g?(E=n(r[0],"theme")||T.dividerTheme||T.theme,l="ui-li-divider ui-bar-"+(E||"inherit"),r.attr("role","heading")):u.length<=0&&(l="ui-li-static ui-body-"+(s||"inherit")),N&&d&&(m=parseInt(d,10)-1,r.css("counter-reset","listnumbering "+m))),C[l]||(C[l]=[]),C[l].push(r[0]);for(l in C)e(C[l]).addClass(l);G.each(function(){e(this).closest("li").addClass("ui-li-has-count")}),R&&G.addClass(R),this._addThumbClasses(P),this._addThumbClasses(P.find(".ui-btn")),this._afterListviewRefresh(),this._addFirstLastClasses(P,this._getVisibles(P,t),t)}},e.mobile.behaviors.addFirstLastClasses))}(e),function(e){function n(n){var t=e.trim(n.text())||null;return t?t=t.slice(0,1).toUpperCase():null}e.widget("mobile.listview",e.mobile.listview,{options:{autodividers:!1,autodividersSelector:n},_beforeListviewRefresh:function(){this.options.autodividers&&(this._replaceDividers(),this._superApply(arguments))},_replaceDividers:function(){var n,o,i,a,r,l=null,s=this.element;for(s.children("li:jqmData(role='list-divider')").remove(),o=s.children("li"),n=0;n<o.length;n++)i=o[n],a=this.options.autodividersSelector(e(i)),a&&l!==a&&(r=t.createElement("li"),r.appendChild(t.createTextNode(a)),r.setAttribute("data-"+e.mobile.ns+"role","list-divider"),i.parentNode.insertBefore(r,i)),l=a}})}(e),function(e){e.widget("mobile.listview",e.mobile.listview,{options:{hideDividers:!1},_afterListviewRefresh:function(){var e,n,t,o=!0;if(this._superApply(arguments),this.options.hideDividers)for(e=this._getChildrenByTagName(this.element[0],"li","LI"),n=e.length-1;n>-1;n--)t=e[n],t.className.match(/(^|\s)ui-li-divider($|\s)/)?(o&&(t.className=t.className+" ui-screen-hidden"),o=!0):t.className.match(/(^|\s)ui-screen-hidden($|\s)/)||(o=!1)}})}(e),function(e){e.mobile.nojs=function(n){e(":jqmData(role='nojs')",n).addClass("ui-nojs")}}(e),function(e){e.mobile.behaviors.formReset={_handleFormReset:function(){this._on(this.element.closest("form"),{reset:function(){this._delay("_reset")}})}}}(e),function(e,n){var t=e.mobile.path.hashToSelector;e.widget("mobile.checkboxradio",e.extend({initSelector:"input:not( :jqmData(role='flipswitch' ) )[type='checkbox'],input[type='radio']:not( :jqmData(role='flipswitch' ))",options:{theme:"inherit",mini:!1,wrapperClass:null,enhanced:!1,iconpos:"left"},_create:function(){var n=this.element,o=this.options,i=function(e,n){return e.jqmData(n)||e.closest("form, fieldset").jqmData(n)},a=n.closest("label"),r=a.length?a:n.closest("form, fieldset, :jqmData(role='page'), :jqmData(role='dialog')").find("label").filter("[for='"+t(n[0].id)+"']").first(),l=n[0].type,s="ui-"+l+"-on",p="ui-"+l+"-off";("checkbox"===l||"radio"===l)&&(this.element[0].disabled&&(this.options.disabled=!0),o.iconpos=i(n,"iconpos")||r.attr("data-"+e.mobile.ns+"iconpos")||o.iconpos,o.mini=i(n,"mini")||o.mini,e.extend(this,{input:n,label:r,parentLabel:a,inputtype:l,checkedClass:s,uncheckedClass:p}),this.options.enhanced||this._enhance(),this._on(r,{vmouseover:"_handleLabelVMouseOver",vclick:"_handleLabelVClick"}),this._on(n,{vmousedown:"_cacheVals",vclick:"_handleInputVClick",focus:"_handleInputFocus",blur:"_handleInputBlur"}),this._handleFormReset(),this.refresh())},_enhance:function(){this.label.addClass("ui-btn ui-corner-all"),this.parentLabel.length>0?this.input.add(this.label).wrapAll(this._wrapper()):(this.element.wrap(this._wrapper()),this.element.parent().prepend(this.label)),this._setOptions({theme:this.options.theme,iconpos:this.options.iconpos,mini:this.options.mini})},_wrapper:function(){return e("<div class='"+(this.options.wrapperClass?this.options.wrapperClass:"")+" ui-"+this.inputtype+(this.options.disabled?" ui-state-disabled":"")+"' ></div>")},_handleInputFocus:function(){this.label.addClass(e.mobile.focusClass)},_handleInputBlur:function(){this.label.removeClass(e.mobile.focusClass)},_handleInputVClick:function(){this.element.prop("checked",this.element.is(":checked")),this._getInputSet().not(this.element).prop("checked",!1),this._updateAll()},_handleLabelVMouseOver:function(e){this.label.parent().hasClass("ui-state-disabled")&&e.stopPropagation()},_handleLabelVClick:function(e){var n=this.element;return n.is(":disabled")?void e.preventDefault():(this._cacheVals(),n.prop("checked","radio"===this.inputtype&&!0||!n.prop("checked")),n.triggerHandler("click"),this._getInputSet().not(n).prop("checked",!1),this._updateAll(),!1)},_cacheVals:function(){this._getInputSet().each(function(){e(this).attr("data-"+e.mobile.ns+"cacheVal",this.checked)})},_getInputSet:function(){var n,o,i=this.element[0],a=i.name,r=i.form,l=this.element.parents().last().get(0),s=this.element;return a&&"radio"===this.inputtype&&l&&(n="input[type='radio'][name='"+t(a)+"']",r?(o=r.id,o&&(s=e(n+"[form='"+t(o)+"']",l)),s=e(r).find(n).filter(function(){return this.form===r}).add(s)):s=e(n,l).filter(function(){return!this.form})),s},_updateAll:function(){var n=this;this._getInputSet().each(function(){var t=e(this);(this.checked||"checkbox"===n.inputtype)&&t.trigger("change")}).checkboxradio("refresh")},_reset:function(){this.refresh()},_hasIcon:function(){var n,t,o=e.mobile.controlgroup;return!(o&&(n=this.element.closest(":mobile-controlgroup,"+o.prototype.initSelector),n.length>0))||(t=e.data(n[0],"mobile-controlgroup"),"horizontal"!==(t?t.options.type:n.attr("data-"+e.mobile.ns+"type")))},refresh:function(){var n=this._hasIcon(),t=this.element[0].checked,o=e.mobile.activeBtnClass,i="ui-btn-icon-"+this.options.iconpos,a=[],r=[];n?(r.push(o),a.push(i)):(r.push(i),(t?a:r).push(o)),t?(a.push(this.checkedClass),r.push(this.uncheckedClass)):(a.push(this.uncheckedClass),r.push(this.checkedClass)),this.label.addClass(a.join(" ")).removeClass(r.join(" "))},widget:function(){return this.label.parent()},_setOptions:function(e){var t=this.label,o=this.options,i=this.widget(),a=this._hasIcon();e.disabled!==n&&(this.input.prop("disabled",!!e.disabled),i.toggleClass("ui-state-disabled",!!e.disabled)),e.mini!==n&&i.toggleClass("ui-mini",!!e.mini),e.theme!==n&&t.removeClass("ui-btn-"+o.theme).addClass("ui-btn-"+e.theme),e.wrapperClass!==n&&i.removeClass(o.wrapperClass).addClass(e.wrapperClass),e.iconpos!==n&&a?t.removeClass("ui-btn-icon-"+o.iconpos).addClass("ui-btn-icon-"+e.iconpos):a||t.removeClass("ui-btn-icon-"+o.iconpos),this._super(e)}},e.mobile.behaviors.formReset))}(e),function(e,n){e.widget("mobile.button",{initSelector:"input[type='button'], input[type='submit'], input[type='reset']",options:{theme:null,icon:null,iconpos:"left",iconshadow:!1,corners:!0,shadow:!0,inline:null,mini:null,wrapperClass:null,enhanced:!1},_create:function(){this.element.is(":disabled")&&(this.options.disabled=!0),this.options.enhanced||this._enhance(),e.extend(this,{wrapper:this.element.parent()}),this._on({focus:function(){this.widget().addClass(e.mobile.focusClass)},blur:function(){this.widget().removeClass(e.mobile.focusClass)}}),this.refresh(!0)},_enhance:function(){this.element.wrap(this._button())},_button:function(){var n=this.options,t=this._getIconClasses(this.options);return e("<div class='ui-btn ui-input-btn"+(n.wrapperClass?" "+n.wrapperClass:"")+(n.theme?" ui-btn-"+n.theme:"")+(n.corners?" ui-corner-all":"")+(n.shadow?" ui-shadow":"")+(n.inline?" ui-btn-inline":"")+(n.mini?" ui-mini":"")+(n.disabled?" ui-state-disabled":"")+(t?" "+t:"")+"' >"+this.element.val()+"</div>")},widget:function(){return this.wrapper},_destroy:function(){this.element.insertBefore(this.button),this.button.remove()},_getIconClasses:function(e){return e.icon?"ui-icon-"+e.icon+(e.iconshadow?" ui-shadow-icon":"")+" ui-btn-icon-"+e.iconpos:""},_setOptions:function(t){var o=this.widget();t.theme!==n&&o.removeClass(this.options.theme).addClass("ui-btn-"+t.theme),t.corners!==n&&o.toggleClass("ui-corner-all",t.corners),t.shadow!==n&&o.toggleClass("ui-shadow",t.shadow),t.inline!==n&&o.toggleClass("ui-btn-inline",t.inline),t.mini!==n&&o.toggleClass("ui-mini",t.mini),t.disabled!==n&&(this.element.prop("disabled",t.disabled),o.toggleClass("ui-state-disabled",t.disabled)),(t.icon!==n||t.iconshadow!==n||t.iconpos!==n)&&o.removeClass(this._getIconClasses(this.options)).addClass(this._getIconClasses(e.extend({},this.options,t))),this._super(t)},refresh:function(n){var t,o=this.element.prop("disabled");this.options.icon&&"notext"===this.options.iconpos&&this.element.attr("title")&&this.element.attr("title",this.element.val()),n||(t=this.element.detach(),e(this.wrapper).text(this.element.val()).append(t)),this.options.disabled!==o&&this._setOptions({disabled:o})}})}(e),function(e){var n=e("meta[name=viewport]"),t=n.attr("content"),o=t+",maximum-scale=1, user-scalable=no",i=t+",maximum-scale=10, user-scalable=yes",a=/(user-scalable[\s]*=[\s]*no)|(maximum-scale[\s]*=[\s]*1)[$,\s]/.test(t);e.mobile.zoom=e.extend({},{enabled:!a,locked:!1,disable:function(t){a||e.mobile.zoom.locked||(n.attr("content",o),e.mobile.zoom.enabled=!1,e.mobile.zoom.locked=t||!1)},enable:function(t){a||e.mobile.zoom.locked&&!0!==t||(n.attr("content",i),e.mobile.zoom.enabled=!0,e.mobile.zoom.locked=!1)},restore:function(){a||(n.attr("content",t),e.mobile.zoom.enabled=!0)}})}(e),function(e,n){e.widget("mobile.textinput",{initSelector:"input[type='text'],input[type='search'],:jqmData(type='search'),input[type='number'],:jqmData(type='number'),input[type='password'],input[type='email'],input[type='url'],input[type='tel'],textarea,input[type='time'],input[type='date'],input[type='month'],input[type='week'],input[type='datetime'],input[type='datetime-local'],input[type='color'],input:not([type]),input[type='file']",options:{theme:null,corners:!0,mini:!1,preventFocusZoom:/iPhone|iPad|iPod/.test(navigator.platform)&&navigator.userAgent.indexOf("AppleWebKit")>-1,wrapperClass:"",enhanced:!1},_create:function(){var n=this.options,t=this.element.is("[type='search'], :jqmData(type='search')"),o="TEXTAREA"===this.element[0].tagName,i=this.element.is("[data-"+(e.mobile.ns||"")+"type='range']"),a=(this.element.is("input")||this.element.is("[data-"+(e.mobile.ns||"")+"type='search']"))&&!i;this.element.prop("disabled")&&(n.disabled=!0),e.extend(this,{classes:this._classesFromOptions(),isSearch:t,isTextarea:o,isRange:i,inputNeedsWrap:a}),this._autoCorrect(),n.enhanced||this._enhance(),this._on({focus:"_handleFocus",blur:"_handleBlur"})},refresh:function(){this.setOptions({disabled:this.element.is(":disabled")})},_enhance:function(){var e=[];this.isTextarea&&e.push("ui-input-text"),(this.isTextarea||this.isRange)&&e.push("ui-shadow-inset"),this.inputNeedsWrap?this.element.wrap(this._wrap()):e=e.concat(this.classes),this.element.addClass(e.join(" "))},widget:function(){return this.inputNeedsWrap?this.element.parent():this.element},_classesFromOptions:function(){var e=this.options,n=[];return n.push("ui-body-"+(null===e.theme?"inherit":e.theme)),e.corners&&n.push("ui-corner-all"),e.mini&&n.push("ui-mini"),e.disabled&&n.push("ui-state-disabled"),e.wrapperClass&&n.push(e.wrapperClass),n},_wrap:function(){return e("<div class='"+(this.isSearch?"ui-input-search ":"ui-input-text ")+this.classes.join(" ")+" ui-shadow-inset'></div>")},_autoCorrect:function(){"undefined"==typeof this.element[0].autocorrect||e.support.touchOverflow||(this.element[0].setAttribute("autocorrect","off"),this.element[0].setAttribute("autocomplete","off"))},_handleBlur:function(){this.widget().removeClass(e.mobile.focusClass),this.options.preventFocusZoom&&e.mobile.zoom.enable(!0)},_handleFocus:function(){this.options.preventFocusZoom&&e.mobile.zoom.disable(!0),this.widget().addClass(e.mobile.focusClass)},_setOptions:function(e){var t=this.widget();this._super(e),(e.disabled!==n||e.mini!==n||e.corners!==n||e.theme!==n||e.wrapperClass!==n)&&(t.removeClass(this.classes.join(" ")),this.classes=this._classesFromOptions(),t.addClass(this.classes.join(" "))),e.disabled!==n&&this.element.prop("disabled",!!e.disabled)},_destroy:function(){this.options.enhanced||(this.inputNeedsWrap&&this.element.unwrap(),this.element.removeClass("ui-input-text "+this.classes.join(" ")))}})}(e),function(e,o){e.widget("mobile.slider",e.extend({initSelector:"input[type='range'], :jqmData(type='range'), :jqmData(role='slider')",widgetEventPrefix:"slide",options:{theme:null,trackTheme:null,corners:!0,mini:!1,highlight:!1},_create:function(){var i,a,r,l,s,p,c,u,g,h,m=this,d=this.element,b=this.options.trackTheme||e.mobile.getAttribute(d[0],"theme"),_=b?" ui-bar-"+b:" ui-bar-inherit",f=this.options.corners||d.jqmData("corners")?" ui-corner-all":"",w=this.options.mini||d.jqmData("mini")?" ui-mini":"",v=d[0].nodeName.toLowerCase(),E="select"===v,P=d.parent().is(":jqmData(role='rangeslider')"),T=E?"ui-slider-switch":"",S=d.attr("id"),N=e("[for='"+S+"']"),I=N.attr("id")||S+"-label",C=E?0:parseFloat(d.attr("min")),G=E?d.find("option").length-1:parseFloat(d.attr("max")),L=n.parseFloat(d.attr("step")||1),R=t.createElement("a"),y=e(R),D=t.createElement("div"),O=e(D),x=!(!this.options.highlight||E)&&function(){var n=t.createElement("div");return n.className="ui-slider-bg "+e.mobile.activeBtnClass,e(n).prependTo(O)}();if(N.attr("id",I),this.isToggleSwitch=E,R.setAttribute("href","#"),D.setAttribute("role","application"),D.className=[this.isToggleSwitch?"ui-slider ui-slider-track ui-shadow-inset ":"ui-slider-track ui-shadow-inset ",T,_,f,w].join(""),R.className="ui-slider-handle",D.appendChild(R),y.attr({role:"slider","aria-valuemin":C,"aria-valuemax":G,"aria-valuenow":this._value(),"aria-valuetext":this._value(),title:this._value(),"aria-labelledby":I}),e.extend(this,{slider:O,handle:y,control:d,type:v,step:L,max:G,min:C,valuebg:x,isRangeslider:P,dragging:!1,beforeStart:null,userModified:!1,mouseMoved:!1}),E){for(c=d.attr("tabindex"),c&&y.attr("tabindex",c),d.attr("tabindex","-1").focus(function(){e(this).blur(),y.focus()}),a=t.createElement("div"),a.className="ui-slider-inneroffset",r=0,l=D.childNodes.length;l>r;r++)a.appendChild(D.childNodes[r]);for(D.appendChild(a),y.addClass("ui-slider-handle-snapping"),i=d.find("option"),s=0,p=i.length;p>s;s++)u=s?"a":"b",g=s?" "+e.mobile.activeBtnClass:"",h=t.createElement("span"),h.className=["ui-slider-label ui-slider-label-",u,g].join(""),h.setAttribute("role","img"),h.appendChild(t.createTextNode(i[s].innerHTML)),e(h).prependTo(O);m._labels=e(".ui-slider-label",O)}d.addClass(E?"ui-slider-switch":"ui-slider-input"),this._on(d,{change:"_controlChange",keyup:"_controlKeyup",blur:"_controlBlur",vmouseup:"_controlVMouseUp"}),O.bind("vmousedown",e.proxy(this._sliderVMouseDown,this)).bind("vclick",!1),this._on(t,{vmousemove:"_preventDocumentDrag"}),this._on(O.add(t),{vmouseup:"_sliderVMouseUp"}),O.insertAfter(d),E||P||(a=this.options.mini?"<div class='ui-slider ui-mini'>":"<div class='ui-slider'>",d.add(O).wrapAll(a)),this._on(this.handle,{vmousedown:"_handleVMouseDown",keydown:"_handleKeydown",keyup:"_handleKeyup"}),this.handle.bind("vclick",!1),this._handleFormReset(),this.refresh(o,o,!0)},_setOptions:function(e){e.theme!==o&&this._setTheme(e.theme),e.trackTheme!==o&&this._setTrackTheme(e.trackTheme),e.corners!==o&&this._setCorners(e.corners),e.mini!==o&&this._setMini(e.mini),e.highlight!==o&&this._setHighlight(e.highlight),e.disabled!==o&&this._setDisabled(e.disabled),this._super(e)},_controlChange:function(e){return!1!==this._trigger("controlchange",e)&&void(this.mouseMoved||this.refresh(this._value(),!0))},_controlKeyup:function(){this.refresh(this._value(),!0,!0)},_controlBlur:function(){this.refresh(this._value(),!0)},_controlVMouseUp:function(){this._checkedRefresh()},_handleVMouseDown:function(){this.handle.focus()},_handleKeydown:function(n){var t=this._value();if(!this.options.disabled){switch(n.keyCode){case e.mobile.keyCode.HOME:case e.mobile.keyCode.END:case e.mobile.keyCode.PAGE_UP:case e.mobile.keyCode.PAGE_DOWN:case e.mobile.keyCode.UP:case e.mobile.keyCode.RIGHT:case e.mobile.keyCode.DOWN:case e.mobile.keyCode.LEFT:n.preventDefault(),this._keySliding||(this._keySliding=!0,this.handle.addClass("ui-state-active"))}switch(n.keyCode){case e.mobile.keyCode.HOME:this.refresh(this.min);break;case e.mobile.keyCode.END:this.refresh(this.max);break;case e.mobile.keyCode.PAGE_UP:case e.mobile.keyCode.UP:case e.mobile.keyCode.RIGHT:this.refresh(t+this.step);break;case e.mobile.keyCode.PAGE_DOWN:case e.mobile.keyCode.DOWN:case e.mobile.keyCode.LEFT:this.refresh(t-this.step)}}},_handleKeyup:function(){this._keySliding&&(this._keySliding=!1,this.handle.removeClass("ui-state-active"))},_sliderVMouseDown:function(e){return!(this.options.disabled||1!==e.which&&0!==e.which&&e.which!==o)&&(!1!==this._trigger("beforestart",e)&&(this.dragging=!0,this.userModified=!1,this.mouseMoved=!1,this.isToggleSwitch&&(this.beforeStart=this.element[0].selectedIndex),this.refresh(e),this._trigger("start"),!1))},_sliderVMouseUp:function(){return this.dragging?(this.dragging=!1,this.isToggleSwitch&&(this.handle.addClass("ui-slider-handle-snapping"),this.refresh(this.mouseMoved?this.userModified?0===this.beforeStart?1:0:this.beforeStart:0===this.beforeStart?1:0)),this.mouseMoved=!1,this._trigger("stop"),!1):void 0},_preventDocumentDrag:function(e){return!1!==this._trigger("drag",e)&&(this.dragging&&!this.options.disabled?(this.mouseMoved=!0,this.isToggleSwitch&&this.handle.removeClass("ui-slider-handle-snapping"),this.refresh(e),this.userModified=this.beforeStart!==this.element[0].selectedIndex,!1):void 0)},_checkedRefresh:function(){this.value!==this._value()&&this.refresh(this._value())},_value:function(){return this.isToggleSwitch?this.element[0].selectedIndex:parseFloat(this.element.val())},_reset:function(){this.refresh(o,!1,!0)},refresh:function(n,o,i){var a,r,l,s,p,c,u,g,h,m,d,b,_,f,w,v,E,P,T,S,N=this,I=e.mobile.getAttribute(this.element[0],"theme"),C=this.options.theme||I,G=C?" ui-btn-"+C:"",L=this.options.trackTheme||I,R=L?" ui-bar-"+L:" ui-bar-inherit",y=this.options.corners?" ui-corner-all":"",D=this.options.mini?" ui-mini":"";if(N.slider[0].className=[this.isToggleSwitch?"ui-slider ui-slider-switch ui-slider-track ui-shadow-inset":"ui-slider-track ui-shadow-inset",R,y,D].join(""),(this.options.disabled||this.element.prop("disabled"))&&this.disable(),this.value=this._value(),this.options.highlight&&!this.isToggleSwitch&&0===this.slider.find(".ui-slider-bg").length&&(this.valuebg=function(){var n=t.createElement("div");return n.className="ui-slider-bg "+e.mobile.activeBtnClass,e(n).prependTo(N.slider)}()),this.handle.addClass("ui-btn"+G+" ui-shadow"),u=this.element,g=!this.isToggleSwitch,h=g?[]:u.find("option"),m=g?parseFloat(u.attr("min")):0,d=g?parseFloat(u.attr("max")):h.length-1,b=g&&parseFloat(u.attr("step"))>0?parseFloat(u.attr("step")):1,"object"==typeof n){if(l=n,s=8,a=this.slider.offset().left,r=this.slider.width(),p=r/((d-m)/b),!this.dragging||l.pageX<a-s||l.pageX>a+r+s)return;c=p>1?(l.pageX-a)/r*100:Math.round((l.pageX-a)/r*100)}else null==n&&(n=g?parseFloat(u.val()||0):u[0].selectedIndex),c=(parseFloat(n)-m)/(d-m)*100;if(!isNaN(c)&&(_=c/100*(d-m)+m,f=(_-m)%b,w=_-f,2*Math.abs(f)>=b&&(w+=f>0?b:-b),v=100/((d-m)/b),_=parseFloat(w.toFixed(5)),void 0===p&&(p=r/((d-m)/b)),p>1&&g&&(c=(_-m)*v*(1/b)),0>c&&(c=0),c>100&&(c=100),m>_&&(_=m),_>d&&(_=d),this.handle.css("left",c+"%"),this.handle[0].setAttribute("aria-valuenow",g?_:h.eq(_).attr("value")),this.handle[0].setAttribute("aria-valuetext",g?_:h.eq(_).getEncodedText()),this.handle[0].setAttribute("title",g?_:h.eq(_).getEncodedText()),this.valuebg&&this.valuebg.css("width",c+"%"),this._labels&&(E=this.handle.width()/this.slider.width()*100,P=c&&E+(100-E)*c/100,T=100===c?0:Math.min(E+100-P,100),this._labels.each(function(){var n=e(this).hasClass("ui-slider-label-a");e(this).width((n?P:T)+"%")})),!i)){if(S=!1,g?(S=u.val()!==_,u.val(_)):(S=u[0].selectedIndex!==_,u[0].selectedIndex=_),!1===this._trigger("beforechange",n))return!1;!o&&S&&u.trigger("change")}},_setHighlight:function(e){e=!!e,e?(this.options.highlight=!!e,this.refresh()):this.valuebg&&(this.valuebg.remove(),this.valuebg=!1)},_setTheme:function(e){this.handle.removeClass("ui-btn-"+this.options.theme).addClass("ui-btn-"+e);var n=this.options.theme?this.options.theme:"inherit",t=e||"inherit";this.control.removeClass("ui-body-"+n).addClass("ui-body-"+t)},_setTrackTheme:function(e){var n=this.options.trackTheme?this.options.trackTheme:"inherit",t=e||"inherit";this.slider.removeClass("ui-body-"+n).addClass("ui-body-"+t)},_setMini:function(e){e=!!e,this.isToggleSwitch||this.isRangeslider||(this.slider.parent().toggleClass("ui-mini",e),this.element.toggleClass("ui-mini",e)),this.slider.toggleClass("ui-mini",e)},_setCorners:function(e){this.slider.toggleClass("ui-corner-all",e),this.isToggleSwitch||this.control.toggleClass("ui-corner-all",e)},_setDisabled:function(e){e=!!e,this.element.prop("disabled",e),this.slider.toggleClass("ui-state-disabled",e).attr("aria-disabled",e)}},e.mobile.behaviors.formReset))}(e),function(e){function n(){return t||(t=e("<div></div>",{"class":"ui-slider-popup ui-shadow ui-corner-all"})),t.clone()}var t;e.widget("mobile.slider",e.mobile.slider,{options:{popupEnabled:!1,showValue:!1},_create:function(){this._super(),e.extend(this,{_currentValue:null,_popup:null,_popupVisible:!1}),this._setOption("popupEnabled",this.options.popupEnabled),this._on(this.handle,{vmousedown:"_showPopup"}),this._on(this.slider.add(this.document),{vmouseup:"_hidePopup"}),this._refresh()},_positionPopup:function(){var e=this.handle.offset();this._popup.offset({left:e.left+(this.handle.width()-this._popup.width())/2,top:e.top-this._popup.outerHeight()-5})},_setOption:function(e,t){this._super(e,t),"showValue"===e?this.handle.html(t&&!this.options.mini?this._value():""):"popupEnabled"===e&&t&&!this._popup&&(this._popup=n().addClass("ui-body-"+(this.options.theme||"a")).hide().insertBefore(this.element))},refresh:function(){this._super.apply(this,arguments),this._refresh()},_refresh:function(){var e,n=this.options;n.popupEnabled&&this.handle.removeAttr("title"),(e=this._value())!==this._currentValue&&(this._currentValue=e,n.popupEnabled&&this._popup?(this._positionPopup(),this._popup.html(e)):n.showValue&&!this.options.mini&&this.handle.html(e))},_showPopup:function(){this.options.popupEnabled&&!this._popupVisible&&(this.handle.html(""),this._popup.show(),this._positionPopup(),this._popupVisible=!0)},_hidePopup:function(){var e=this.options;e.popupEnabled&&this._popupVisible&&(e.showValue&&!e.mini&&this.handle.html(this._value()),this._popup.hide(),this._popupVisible=!1)}})}(e),function(e,n){e.widget("mobile.flipswitch",e.extend({options:{onText:"On",offText:"Off",theme:null,enhanced:!1,wrapperClass:null,corners:!0,mini:!1},_create:function(){this.options.enhanced?e.extend(this,{flipswitch:this.element.parent(),on:this.element.find(".ui-flipswitch-on").eq(0),off:this.element.find(".ui-flipswitch-off").eq(0),type:this.element.get(0).tagName}):this._enhance(),this._handleFormReset(),this._originalTabIndex=this.element.attr("tabindex"),null!=this._originalTabIndex&&this.on.attr("tabindex",this._originalTabIndex),this.element.attr("tabindex","-1"),this._on({focus:"_handleInputFocus"}),this.element.is(":disabled")&&this._setOptions({disabled:!0}),this._on(this.flipswitch,{click:"_toggle",swipeleft:"_left",swiperight:"_right"}),this._on(this.on,{keydown:"_keydown"}),this._on({change:"refresh"})},_handleInputFocus:function(){this.on.focus()},widget:function(){return this.flipswitch},_left:function(){this.flipswitch.removeClass("ui-flipswitch-active"),"SELECT"===this.type?this.element.get(0).selectedIndex=0:this.element.prop("checked",!1),this.element.trigger("change")},_right:function(){this.flipswitch.addClass("ui-flipswitch-active"),"SELECT"===this.type?this.element.get(0).selectedIndex=1:this.element.prop("checked",!0),this.element.trigger("change")},_enhance:function(){var n=e("<div>"),t=this.options,o=this.element,i=t.theme?t.theme:"inherit",a=e("<a></a>",{href:"#"}),r=e("<span></span>"),l=o.get(0).tagName,s="INPUT"===l?t.onText:o.find("option").eq(1).text(),p="INPUT"===l?t.offText:o.find("option").eq(0).text();a.addClass("ui-flipswitch-on ui-btn ui-shadow ui-btn-inherit").text(s),r.addClass("ui-flipswitch-off").text(p),n.addClass("ui-flipswitch ui-shadow-inset ui-bar-"+i+" "+(t.wrapperClass?t.wrapperClass:"")+" "+(o.is(":checked")||o.find("option").eq(1).is(":selected")?"ui-flipswitch-active":"")+(o.is(":disabled")?" ui-state-disabled":"")+(t.corners?" ui-corner-all":"")+(t.mini?" ui-mini":"")).append(a,r),o.addClass("ui-flipswitch-input").after(n).appendTo(n),e.extend(this,{flipswitch:n,on:a,off:r,type:l})},_reset:function(){this.refresh()},refresh:function(){var e,n=this.flipswitch.hasClass("ui-flipswitch-active")?"_right":"_left";(e="SELECT"===this.type?this.element.get(0).selectedIndex>0?"_right":"_left":this.element.prop("checked")?"_right":"_left")!==n&&this[e]()},_toggle:function(){this[this.flipswitch.hasClass("ui-flipswitch-active")?"_left":"_right"]()},_keydown:function(n){n.which===e.mobile.keyCode.LEFT?this._left():n.which===e.mobile.keyCode.RIGHT?this._right():n.which===e.mobile.keyCode.SPACE&&(this._toggle(),n.preventDefault())},_setOptions:function(e){if(e.theme!==n){var t=e.theme?e.theme:"inherit",o=e.theme?e.theme:"inherit";this.widget().removeClass("ui-bar-"+t).addClass("ui-bar-"+o)}e.onText!==n&&this.on.text(e.onText),e.offText!==n&&this.off.text(e.offText),e.disabled!==n&&this.widget().toggleClass("ui-state-disabled",e.disabled),e.mini!==n&&this.widget().toggleClass("ui-mini",e.mini),e.corners!==n&&this.widget().toggleClass("ui-corner-all",e.corners),this._super(e)},_destroy:function(){this.options.enhanced||(null!=this._originalTabIndex?this.element.attr("tabindex",this._originalTabIndex):this.element.removeAttr("tabindex"),this.on.remove(),this.off.remove(),this.element.unwrap(),this.flipswitch.remove(),this.removeClass("ui-flipswitch-input"))}},e.mobile.behaviors.formReset))}(e),function(e,n){e.widget("mobile.rangeslider",e.extend({options:{theme:null,trackTheme:null,corners:!0,mini:!1,highlight:!0},_create:function(){var n=this.element,t=this.options.mini?"ui-rangeslider ui-mini":"ui-rangeslider",o=n.find("input").first(),i=n.find("input").last(),a=n.find("label").first(),r=e.data(o.get(0),"mobile-slider")||e.data(o.slider().get(0),"mobile-slider"),l=e.data(i.get(0),"mobile-slider")||e.data(i.slider().get(0),"mobile-slider"),s=r.slider,p=l.slider,c=r.handle,u=e("<div class='ui-rangeslider-sliders' />").appendTo(n);o.addClass("ui-rangeslider-first"),i.addClass("ui-rangeslider-last"),n.addClass(t),s.appendTo(u),p.appendTo(u),a.insertBefore(n),c.prependTo(p),e.extend(this,{_inputFirst:o,_inputLast:i,_sliderFirst:s,_sliderLast:p,_label:a,_targetVal:null,_sliderTarget:!1,_sliders:u,_proxy:!1}),this.refresh(),this._on(this.element.find("input.ui-slider-input"),{slidebeforestart:"_slidebeforestart",slidestop:"_slidestop",slidedrag:"_slidedrag",slidebeforechange:"_change",blur:"_change",keyup:"_change"}),this._on({mousedown:"_change"}),this._on(this.element.closest("form"),{reset:"_handleReset"}),this._on(c,{vmousedown:"_dragFirstHandle"})},_handleReset:function(){var e=this;setTimeout(function(){e._updateHighlight()},0)},_dragFirstHandle:function(n){return e.data(this._inputFirst.get(0),"mobile-slider").dragging=!0,e.data(this._inputFirst.get(0),"mobile-slider").refresh(n),!1},_slidedrag:function(n){var t=e(n.target).is(this._inputFirst),o=t?this._inputLast:this._inputFirst;return this._sliderTarget=!1,"first"===this._proxy&&t||"last"===this._proxy&&!t?(e.data(o.get(0),"mobile-slider").dragging=!0,e.data(o.get(0),"mobile-slider").refresh(n),!1):void 0},_slidestop:function(n){var t=e(n.target).is(this._inputFirst);this._proxy=!1,this.element.find("input").trigger("vmouseup"),this._sliderFirst.css("z-index",t?1:"")},_slidebeforestart:function(n){this._sliderTarget=!1,e(n.originalEvent.target).hasClass("ui-slider-track")&&(this._sliderTarget=!0,this._targetVal=e(n.target).val())},_setOptions:function(e){e.theme!==n&&this._setTheme(e.theme),e.trackTheme!==n&&this._setTrackTheme(e.trackTheme),e.mini!==n&&this._setMini(e.mini),e.highlight!==n&&this._setHighlight(e.highlight),this._super(e),this.refresh()},refresh:function(){var e=this.element,n=this.options;(this._inputFirst.is(":disabled")||this._inputLast.is(":disabled"))&&(this.options.disabled=!0),e.find("input").slider({theme:n.theme,trackTheme:n.trackTheme,disabled:n.disabled,corners:n.corners,mini:n.mini,highlight:n.highlight}).slider("refresh"),this._updateHighlight()},_change:function(n){if("keyup"===n.type)return this._updateHighlight(),!1;var t=this,o=parseFloat(this._inputFirst.val(),10),i=parseFloat(this._inputLast.val(),10),a=e(n.target).hasClass("ui-rangeslider-first"),r=a?this._inputFirst:this._inputLast,l=a?this._inputLast:this._inputFirst;if(this._inputFirst.val()>this._inputLast.val()&&"mousedown"===n.type&&!e(n.target).hasClass("ui-slider-handle"))r.blur();else if("mousedown"===n.type)return;return o>i&&!this._sliderTarget?(r.val(a?i:o).slider("refresh"),this._trigger("normalize")):o>i&&(r.val(this._targetVal).slider("refresh"),setTimeout(function(){l.val(a?o:i).slider("refresh"),e.data(l.get(0),"mobile-slider").handle.focus(),t._sliderFirst.css("z-index",a?"":1),t._trigger("normalize")},0),this._proxy=a?"first":"last"),o===i?(e.data(r.get(0),"mobile-slider").handle.css("z-index",1),e.data(l.get(0),"mobile-slider").handle.css("z-index",0)):(e.data(l.get(0),"mobile-slider").handle.css("z-index",""),e.data(r.get(0),"mobile-slider").handle.css("z-index","")),this._updateHighlight(),!(o>=i)&&void 0},_updateHighlight:function(){var n=parseInt(e.data(this._inputFirst.get(0),"mobile-slider").handle.get(0).style.left,10),t=parseInt(e.data(this._inputLast.get(0),"mobile-slider").handle.get(0).style.left,10),o=t-n;this.element.find(".ui-slider-bg").css({"margin-left":n+"%",width:o+"%"})},_setTheme:function(e){this._inputFirst.slider("option","theme",e),this._inputLast.slider("option","theme",e)},_setTrackTheme:function(e){this._inputFirst.slider("option","trackTheme",e),this._inputLast.slider("option","trackTheme",e)},_setMini:function(e){this._inputFirst.slider("option","mini",e),this._inputLast.slider("option","mini",e),this.element.toggleClass("ui-mini",!!e)},_setHighlight:function(e){this._inputFirst.slider("option","highlight",e),this._inputLast.slider("option","highlight",e)},_destroy:function(){this._label.prependTo(this.element),this.element.removeClass("ui-rangeslider ui-mini"),this._inputFirst.after(this._sliderFirst),this._inputLast.after(this._sliderLast),this._sliders.remove(),
this.element.find("input").removeClass("ui-rangeslider-first ui-rangeslider-last").slider("destroy")}},e.mobile.behaviors.formReset))}(e),function(e,n){e.widget("mobile.textinput",e.mobile.textinput,{options:{clearBtn:!1,clearBtnText:"Clear text"},_create:function(){this._super(),(this.options.clearBtn||this.isSearch)&&this._addClearBtn()},clearButton:function(){return e("<a href='#' class='ui-input-clear ui-btn ui-icon-delete ui-btn-icon-notext ui-corner-all' title='"+this.options.clearBtnText+"'>"+this.options.clearBtnText+"</a>")},_clearBtnClick:function(e){this.element.val("").focus().trigger("change"),this._clearBtn.addClass("ui-input-clear-hidden"),e.preventDefault()},_addClearBtn:function(){this.options.enhanced||this._enhanceClear(),e.extend(this,{_clearBtn:this.widget().find("a.ui-input-clear")}),this._bindClearEvents(),this._toggleClear()},_enhanceClear:function(){this.clearButton().appendTo(this.widget()),this.widget().addClass("ui-input-has-clear")},_bindClearEvents:function(){this._on(this._clearBtn,{click:"_clearBtnClick"}),this._on({keyup:"_toggleClear",change:"_toggleClear",input:"_toggleClear",focus:"_toggleClear",blur:"_toggleClear",cut:"_toggleClear",paste:"_toggleClear"})},_unbindClear:function(){this._off(this._clearBtn,"click"),this._off(this.element,"keyup change input focus blur cut paste")},_setOptions:function(e){this._super(e),e.clearBtn===n||this.element.is("textarea, :jqmData(type='range')")||(e.clearBtn?this._addClearBtn():this._destroyClear()),e.clearBtnText!==n&&this._clearBtn!==n&&this._clearBtn.text(e.clearBtnText).attr("title",e.clearBtnText)},_toggleClear:function(){this._delay("_toggleClearClass",0)},_toggleClearClass:function(){this._clearBtn.toggleClass("ui-input-clear-hidden",!this.element.val())},_destroyClear:function(){this.widget().removeClass("ui-input-has-clear"),this._unbindClear(),this._clearBtn.remove()},_destroy:function(){this._super(),this._destroyClear()}})}(e),function(e,n){e.widget("mobile.textinput",e.mobile.textinput,{options:{autogrow:!0,keyupTimeoutBuffer:100},_create:function(){this._super(),this.options.autogrow&&this.isTextarea&&this._autogrow()},_autogrow:function(){this.element.addClass("ui-textinput-autogrow"),this._on({keyup:"_timeout",change:"_timeout",input:"_timeout",paste:"_timeout"}),this._on(!0,this.document,{pageshow:"_handleShow",popupbeforeposition:"_handleShow",updatelayout:"_handleShow",panelopen:"_handleShow"})},_handleShow:function(n){e.contains(n.target,this.element[0])&&this.element.is(":visible")&&("popupbeforeposition"!==n.type&&this.element.addClass("ui-textinput-autogrow-resize").animationComplete(e.proxy(function(){this.element.removeClass("ui-textinput-autogrow-resize")},this),"transition"),this._timeout())},_unbindAutogrow:function(){this.element.removeClass("ui-textinput-autogrow"),this._off(this.element,"keyup change input paste"),this._off(this.document,"pageshow popupbeforeposition updatelayout panelopen")},keyupTimeout:null,_prepareHeightUpdate:function(e){this.keyupTimeout&&clearTimeout(this.keyupTimeout),e===n?this._updateHeight():this.keyupTimeout=this._delay("_updateHeight",e)},_timeout:function(){this._prepareHeightUpdate(this.options.keyupTimeoutBuffer)},_updateHeight:function(){var e,n,t,o,i,a,r,l,s,p=this.window.scrollTop();this.keyupTimeout=0,"onpage"in this.element[0]||this.element.css({height:0,"min-height":0,"max-height":0}),o=this.element[0].scrollHeight,i=this.element[0].clientHeight,a=parseFloat(this.element.css("border-top-width")),r=parseFloat(this.element.css("border-bottom-width")),l=a+r,s=o+l+15,0===i&&(e=parseFloat(this.element.css("padding-top")),n=parseFloat(this.element.css("padding-bottom")),t=e+n,s+=t),this.element.css({height:s,"min-height":"","max-height":""}),this.window.scrollTop(p)},refresh:function(){this.options.autogrow&&this.isTextarea&&this._updateHeight()},_setOptions:function(e){this._super(e),e.autogrow!==n&&this.isTextarea&&(e.autogrow?this._autogrow():this._unbindAutogrow())}})}(e),function(e){e.widget("mobile.selectmenu",e.extend({initSelector:"select:not( :jqmData(role='slider')):not( :jqmData(role='flipswitch') )",options:{theme:null,icon:"carat-d",iconpos:"right",inline:!1,corners:!0,shadow:!0,iconshadow:!1,overlayTheme:null,dividerTheme:null,hidePlaceholderMenuItems:!0,closeText:"Close",nativeMenu:!0,preventFocusZoom:/iPhone|iPad|iPod/.test(navigator.platform)&&navigator.userAgent.indexOf("AppleWebKit")>-1,mini:!1},_button:function(){return e("<div/>")},_setDisabled:function(e){return this.element.attr("disabled",e),this.button.attr("aria-disabled",e),this._setOption("disabled",e)},_focusButton:function(){var e=this;setTimeout(function(){e.button.focus()},40)},_selectOptions:function(){return this.select.find("option")},_preExtension:function(){var n=this.options.inline||this.element.jqmData("inline"),t=this.options.mini||this.element.jqmData("mini"),o="";~this.element[0].className.indexOf("ui-btn-left")&&(o=" ui-btn-left"),~this.element[0].className.indexOf("ui-btn-right")&&(o=" ui-btn-right"),n&&(o+=" ui-btn-inline"),t&&(o+=" ui-mini"),this.select=this.element.removeClass("ui-btn-left ui-btn-right").wrap("<div class='ui-select"+o+"'>"),this.selectId=this.select.attr("id")||"select-"+this.uuid,this.buttonId=this.selectId+"-button",this.label=e("label[for='"+this.selectId+"']"),this.isMultiple=this.select[0].multiple},_destroy:function(){var e=this.element.parents(".ui-select");e.length>0&&(e.is(".ui-btn-left, .ui-btn-right")&&this.element.addClass(e.hasClass("ui-btn-left")?"ui-btn-left":"ui-btn-right"),this.element.insertAfter(e),e.remove())},_create:function(){this._preExtension(),this.button=this._button();var t=this,o=this.options,i=!!o.icon&&(o.iconpos||this.select.jqmData("iconpos")),a=this.button.insertBefore(this.select).attr("id",this.buttonId).addClass("ui-btn"+(o.icon?" ui-icon-"+o.icon+" ui-btn-icon-"+i+(o.iconshadow?" ui-shadow-icon":""):"")+(o.theme?" ui-btn-"+o.theme:"")+(o.corners?" ui-corner-all":"")+(o.shadow?" ui-shadow":""));this.setButtonText(),o.nativeMenu&&n.opera&&n.opera.version&&a.addClass("ui-select-nativeonly"),this.isMultiple&&(this.buttonCount=e("<span>").addClass("ui-li-count ui-body-inherit").hide().appendTo(a.addClass("ui-li-has-count"))),(o.disabled||this.element.attr("disabled"))&&this.disable(),this.select.change(function(){t.refresh(),o.nativeMenu&&this.blur()}),this._handleFormReset(),this._on(this.button,{keydown:"_handleKeydown"}),this.build()},build:function(){var n=this;this.select.appendTo(n.button).bind("vmousedown",function(){n.button.addClass(e.mobile.activeBtnClass)}).bind("focus",function(){n.button.addClass(e.mobile.focusClass)}).bind("blur",function(){n.button.removeClass(e.mobile.focusClass)}).bind("focus vmouseover",function(){n.button.trigger("vmouseover")}).bind("vmousemove",function(){n.button.removeClass(e.mobile.activeBtnClass)}).bind("change blur vmouseout",function(){n.button.trigger("vmouseout").removeClass(e.mobile.activeBtnClass)}),n.button.bind("vmousedown",function(){n.options.preventFocusZoom&&e.mobile.zoom.disable(!0)}),n.label.bind("click focus",function(){n.options.preventFocusZoom&&e.mobile.zoom.disable(!0)}),n.select.bind("focus",function(){n.options.preventFocusZoom&&e.mobile.zoom.disable(!0)}),n.button.bind("mouseup",function(){n.options.preventFocusZoom&&setTimeout(function(){e.mobile.zoom.enable(!0)},0)}),n.select.bind("blur",function(){n.options.preventFocusZoom&&e.mobile.zoom.enable(!0)})},selected:function(){return this._selectOptions().filter(":selected")},selectedIndices:function(){var e=this;return this.selected().map(function(){return e._selectOptions().index(this)}).get()},setButtonText:function(){var n=this,o=this.selected(),i=this.placeholder,a=e(t.createElement("span"));this.button.children("span").not(".ui-li-count").remove().end().end().prepend(function(){return i=o.length?o.map(function(){return e(this).text()}).get().join(", "):n.placeholder,i?a.text(i):a.html("&#160;"),a.addClass(n.select.attr("class")).addClass(o.attr("class")).removeClass("ui-screen-hidden")}())},setButtonCount:function(){var e=this.selected();this.isMultiple&&this.buttonCount[e.length>1?"show":"hide"]().text(e.length)},_handleKeydown:function(){this._delay("_refreshButton")},_reset:function(){this.refresh()},_refreshButton:function(){this.setButtonText(),this.setButtonCount()},refresh:function(){this._refreshButton()},open:e.noop,close:e.noop,disable:function(){this._setDisabled(!0),this.button.addClass("ui-state-disabled")},enable:function(){this._setDisabled(!1),this.button.removeClass("ui-state-disabled")}},e.mobile.behaviors.formReset))}(e),function(e){e.mobile.links=function(n){e(n).find("a").jqmEnhanceable().filter(":jqmData(rel='popup')[href][href!='']").each(function(){var e=this,n=e.getAttribute("href").substring(1);n&&(e.setAttribute("aria-haspopup",!0),e.setAttribute("aria-owns",n),e.setAttribute("aria-expanded",!1))}).end().not(".ui-btn, :jqmData(role='none'), :jqmData(role='nojs')").addClass("ui-link")}}(e),function(e,t){function o(e,n,t,o){return n>e?t+(e-n)/2:Math.min(Math.max(t,o-n/2),t+e-n)}function i(e){return{x:e.scrollLeft(),y:e.scrollTop(),cx:e[0].innerWidth||e.width(),cy:e[0].innerHeight||e.height()}}e.widget("mobile.popup",{options:{wrapperClass:null,theme:null,overlayTheme:null,shadow:!0,corners:!0,transition:"none",positionTo:"origin",tolerance:null,closeLinkSelector:"a:jqmData(rel='back')",closeLinkEvents:"click.popup",navigateEvents:"navigate.popup",closeEvents:"navigate.popup pagebeforechange.popup",dismissible:!0,enhanced:!1,history:!e.mobile.browser.oldIE},_create:function(){var n=this.element,t=n.attr("id"),o=this.options;o.history=o.history&&e.mobile.ajaxEnabled&&e.mobile.hashListeningEnabled,e.extend(this,{_scrollTop:0,_page:n.closest(".ui-page"),_ui:null,_fallbackTransition:"",_currentTransition:!1,_prerequisites:null,_isOpen:!1,_tolerance:null,_resizeData:null,_ignoreResizeTo:0,_orientationchangeInProgress:!1}),0===this._page.length&&(this._page=e("body")),o.enhanced?this._ui={container:n.parent(),screen:n.parent().prev(),placeholder:e(this.document[0].getElementById(t+"-placeholder"))}:(this._ui=this._enhance(n,t),this._applyTransition(o.transition)),this._setTolerance(o.tolerance)._ui.focusElement=this._ui.container,this._on(this._ui.screen,{vclick:"_eatEventAndClose"}),this._on(this.window,{orientationchange:e.proxy(this,"_handleWindowOrientationchange"),resize:e.proxy(this,"_handleWindowResize"),keyup:e.proxy(this,"_handleWindowKeyUp")}),this._on(this.document,{focusin:"_handleDocumentFocusIn"})},_enhance:function(n,t){var o=this.options,i=o.wrapperClass,a={screen:e("<div class='ui-screen-hidden ui-popup-screen "+this._themeClassFromOption("ui-overlay-",o.overlayTheme)+"'></div>"),placeholder:e("<div style='display: none;'>\x3c!-- placeholder --\x3e</div>"),container:e("<div class='ui-popup-container ui-popup-hidden ui-popup-truncate"+(i?" "+i:"")+"'></div>")},r=this.document[0].createDocumentFragment();return r.appendChild(a.screen[0]),r.appendChild(a.container[0]),t&&(a.screen.attr("id",t+"-screen"),a.container.attr("id",t+"-popup"),a.placeholder.attr("id",t+"-placeholder").html("\x3c!-- placeholder for "+t+" --\x3e")),this._page[0].appendChild(r),a.placeholder.insertAfter(n),n.detach().addClass("ui-popup "+this._themeClassFromOption("ui-body-",o.theme)+" "+(o.shadow?"ui-overlay-shadow ":"")+(o.corners?"ui-corner-all ":"")).appendTo(a.container),a},_eatEventAndClose:function(e){return e.preventDefault(),e.stopImmediatePropagation(),this.options.dismissible&&this.close(),!1},_resizeScreen:function(){var e=this._ui.screen,n=this._ui.container.outerHeight(!0),t=e.removeAttr("style").height(),o=this.document.height()-1;o>t?e.height(o):n>t&&e.height(n)},_handleWindowKeyUp:function(n){return this._isOpen&&n.keyCode===e.mobile.keyCode.ESCAPE?this._eatEventAndClose(n):void 0},_expectResizeEvent:function(){var e=i(this.window);if(this._resizeData){if(e.x===this._resizeData.windowCoordinates.x&&e.y===this._resizeData.windowCoordinates.y&&e.cx===this._resizeData.windowCoordinates.cx&&e.cy===this._resizeData.windowCoordinates.cy)return!1;clearTimeout(this._resizeData.timeoutId)}return this._resizeData={timeoutId:this._delay("_resizeTimeout",200),windowCoordinates:e},!0},_resizeTimeout:function(){this._isOpen?this._expectResizeEvent()||(this._ui.container.hasClass("ui-popup-hidden")&&(this._ui.container.removeClass("ui-popup-hidden ui-popup-truncate"),this.reposition({positionTo:"window"}),this._ignoreResizeEvents()),this._resizeScreen(),this._resizeData=null,this._orientationchangeInProgress=!1):(this._resizeData=null,this._orientationchangeInProgress=!1)},_stopIgnoringResizeEvents:function(){this._ignoreResizeTo=0},_ignoreResizeEvents:function(){this._ignoreResizeTo&&clearTimeout(this._ignoreResizeTo),this._ignoreResizeTo=this._delay("_stopIgnoringResizeEvents",1e3)},_handleWindowResize:function(){this._isOpen&&0===this._ignoreResizeTo&&(!this._expectResizeEvent()&&!this._orientationchangeInProgress||this._ui.container.hasClass("ui-popup-hidden")||this._ui.container.addClass("ui-popup-hidden ui-popup-truncate").removeAttr("style"))},_handleWindowOrientationchange:function(){!this._orientationchangeInProgress&&this._isOpen&&0===this._ignoreResizeTo&&(this._expectResizeEvent(),this._orientationchangeInProgress=!0)},_handleDocumentFocusIn:function(n){var t,o=n.target,i=this._ui;if(this._isOpen){if(o!==i.container[0]){if(t=e(o),0===t.parents().filter(i.container[0]).length)return e(this.document[0].activeElement).one("focus",function(){t.blur()}),i.focusElement.focus(),n.preventDefault(),n.stopImmediatePropagation(),!1;i.focusElement[0]===i.container[0]&&(i.focusElement=t)}this._ignoreResizeEvents()}},_themeClassFromOption:function(e,n){return n?"none"===n?"":e+n:e+"inherit"},_applyTransition:function(n){return n&&(this._ui.container.removeClass(this._fallbackTransition),"none"!==n&&(this._fallbackTransition=e.mobile._maybeDegradeTransition(n),"none"===this._fallbackTransition&&(this._fallbackTransition=""),this._ui.container.addClass(this._fallbackTransition))),this},_setOptions:function(e){var n=this.options,o=this.element,i=this._ui.screen;return e.wrapperClass!==t&&this._ui.container.removeClass(n.wrapperClass).addClass(e.wrapperClass),e.theme!==t&&o.removeClass(this._themeClassFromOption("ui-body-",n.theme)).addClass(this._themeClassFromOption("ui-body-",e.theme)),e.overlayTheme!==t&&(i.removeClass(this._themeClassFromOption("ui-overlay-",n.overlayTheme)).addClass(this._themeClassFromOption("ui-overlay-",e.overlayTheme)),this._isOpen&&i.addClass("in")),e.shadow!==t&&o.toggleClass("ui-overlay-shadow",e.shadow),e.corners!==t&&o.toggleClass("ui-corner-all",e.corners),e.transition!==t&&(this._currentTransition||this._applyTransition(e.transition)),e.tolerance!==t&&this._setTolerance(e.tolerance),e.disabled!==t&&e.disabled&&this.close(),this._super(e)},_setTolerance:function(n){var o,i={t:30,r:15,b:30,l:15};if(n!==t)switch(o=String(n).split(","),e.each(o,function(e,n){o[e]=parseInt(n,10)}),o.length){case 1:isNaN(o[0])||(i.t=i.r=i.b=i.l=o[0]);break;case 2:isNaN(o[0])||(i.t=i.b=o[0]),isNaN(o[1])||(i.l=i.r=o[1]);break;case 4:isNaN(o[0])||(i.t=o[0]),isNaN(o[1])||(i.r=o[1]),isNaN(o[2])||(i.b=o[2]),isNaN(o[3])||(i.l=o[3])}return this._tolerance=i,this},_clampPopupWidth:function(e){var n,t=i(this.window),o={x:this._tolerance.l,y:t.y+this._tolerance.t,cx:t.cx-this._tolerance.l-this._tolerance.r,cy:t.cy-this._tolerance.t-this._tolerance.b};return e||this._ui.container.css("max-width",o.cx),n={cx:this._ui.container.outerWidth(!0),cy:this._ui.container.outerHeight(!0)},{rc:o,menuSize:n}},_calculateFinalLocation:function(e,n){var t,i=n.rc,a=n.menuSize;return t={left:o(i.cx,a.cx,i.x,e.x),top:o(i.cy,a.cy,i.y,e.y)},t.top=Math.max(0,t.top),t.top-=Math.min(t.top,Math.max(0,t.top+a.cy-this.document.height())),t},_placementCoords:function(e){return this._calculateFinalLocation(e,this._clampPopupWidth())},_createPrerequisites:function(n,t,o){var i,a=this;i={screen:e.Deferred(),container:e.Deferred()},i.screen.then(function(){i===a._prerequisites&&n()}),i.container.then(function(){i===a._prerequisites&&t()}),e.when(i.screen,i.container).done(function(){i===a._prerequisites&&(a._prerequisites=null,o())}),a._prerequisites=i},_animate:function(n){return this._ui.screen.removeClass(n.classToRemove).addClass(n.screenClassToAdd),n.prerequisites.screen.resolve(),n.transition&&"none"!==n.transition&&(n.applyTransition&&this._applyTransition(n.transition),this._fallbackTransition)?void this._ui.container.addClass(n.containerClassToAdd).removeClass(n.classToRemove).animationComplete(e.proxy(n.prerequisites.container,"resolve")):(this._ui.container.removeClass(n.classToRemove),void n.prerequisites.container.resolve())},_desiredCoords:function(n){var t,o=null,a=i(this.window),r=n.x,l=n.y,s=n.positionTo;if(s&&"origin"!==s)if("window"===s)r=a.cx/2+a.x,l=a.cy/2+a.y;else{try{o=e(s)}catch(p){o=null}o&&(o.filter(":visible"),0===o.length&&(o=null))}return o&&(t=o.offset(),r=t.left+o.outerWidth()/2,l=t.top+o.outerHeight()/2),("number"!==e.type(r)||isNaN(r))&&(r=a.cx/2+a.x),("number"!==e.type(l)||isNaN(l))&&(l=a.cy/2+a.y),{x:r,y:l}},_reposition:function(e){e={x:e.x,y:e.y,positionTo:e.positionTo},this._trigger("beforeposition",t,e),this._ui.container.offset(this._placementCoords(this._desiredCoords(e)))},reposition:function(e){this._isOpen&&this._reposition(e)},_openPrerequisitesComplete:function(){var e=this.element.attr("id");this._ui.container.addClass("ui-popup-active"),this._isOpen=!0,this._resizeScreen(),this._ui.container.attr("tabindex","0").focus(),this._ignoreResizeEvents(),e&&this.document.find("[aria-haspopup='true'][aria-owns='"+e+"']").attr("aria-expanded",!0),this._trigger("afteropen")},_open:function(n){var t=e.extend({},this.options,n),o=function(){var e=navigator.userAgent,n=e.match(/AppleWebKit\/([0-9\.]+)/),t=!!n&&n[1],o=e.match(/Android (\d+(?:\.\d+))/),i=!!o&&o[1],a=e.indexOf("Chrome")>-1;return!(!(null!==o&&"4.0"===i&&t&&t>534.13)||a)}();this._createPrerequisites(e.noop,e.noop,e.proxy(this,"_openPrerequisitesComplete")),this._currentTransition=t.transition,this._applyTransition(t.transition),this._ui.screen.removeClass("ui-screen-hidden"),this._ui.container.removeClass("ui-popup-truncate"),this._reposition(t),this._ui.container.removeClass("ui-popup-hidden"),this.options.overlayTheme&&o&&this.element.closest(".ui-page").addClass("ui-popup-open"),this._animate({additionalCondition:!0,transition:t.transition,classToRemove:"",screenClassToAdd:"in",containerClassToAdd:"in",applyTransition:!1,prerequisites:this._prerequisites})},_closePrerequisiteScreen:function(){this._ui.screen.removeClass("out").addClass("ui-screen-hidden")},_closePrerequisiteContainer:function(){this._ui.container.removeClass("reverse out").addClass("ui-popup-hidden ui-popup-truncate").removeAttr("style")},_closePrerequisitesDone:function(){var n=this._ui.container,o=this.element.attr("id");n.removeAttr("tabindex"),e.mobile.popup.active=t,e(":focus",n[0]).add(n[0]).blur(),o&&this.document.find("[aria-haspopup='true'][aria-owns='"+o+"']").attr("aria-expanded",!1),this._trigger("afterclose")},_close:function(n){this._ui.container.removeClass("ui-popup-active"),this._page.removeClass("ui-popup-open"),this._isOpen=!1,this._createPrerequisites(e.proxy(this,"_closePrerequisiteScreen"),e.proxy(this,"_closePrerequisiteContainer"),e.proxy(this,"_closePrerequisitesDone")),this._animate({additionalCondition:this._ui.screen.hasClass("in"),transition:n?"none":this._currentTransition,classToRemove:"in",screenClassToAdd:"out",containerClassToAdd:"reverse out",applyTransition:!0,prerequisites:this._prerequisites})},_unenhance:function(){this.options.enhanced||(this._setOptions({theme:e.mobile.popup.prototype.options.theme}),this.element.detach().insertAfter(this._ui.placeholder).removeClass("ui-popup ui-overlay-shadow ui-corner-all ui-body-inherit"),this._ui.screen.remove(),this._ui.container.remove(),this._ui.placeholder.remove())},_destroy:function(){return e.mobile.popup.active===this?(this.element.one("popupafterclose",e.proxy(this,"_unenhance")),this.close()):this._unenhance(),this},_closePopup:function(t,o){var i,a,r=this.options,l=!1;t&&t.isDefaultPrevented()||e.mobile.popup.active!==this||(n.scrollTo(0,this._scrollTop),t&&"pagebeforechange"===t.type&&o&&(i="string"==typeof o.toPage?o.toPage:o.toPage.jqmData("url"),i=e.mobile.path.parseUrl(i),a=i.pathname+i.search+i.hash,this._myUrl!==e.mobile.path.makeUrlAbsolute(a)?l=!0:t.preventDefault()),this.window.off(r.closeEvents),this.element.undelegate(r.closeLinkSelector,r.closeLinkEvents),this._close(l))},_bindContainerClose:function(){this.window.on(this.options.closeEvents,e.proxy(this,"_closePopup"))},widget:function(){return this._ui.container},open:function(n){var t,o,i,a,r,l=this,s=this.options;return e.mobile.popup.active||s.disabled?this:(e.mobile.popup.active=this,this._scrollTop=this.window.scrollTop(),s.history?(r=e.mobile.navigate.history,o=e.mobile.dialogHashKey,i=e.mobile.activePage,a=!!i&&i.hasClass("ui-dialog"),this._myUrl=t=r.getActive().url,t.indexOf(o)>-1&&!a&&r.activeIndex>0?(l._open(n),l._bindContainerClose(),this):(-1!==t.indexOf(o)||a?t=e.mobile.path.parseLocation().hash+o:t+=t.indexOf("#")>-1?o:"#"+o,0===r.activeIndex&&t===r.initialDst&&(t+=o),this.window.one("beforenavigate",function(e){e.preventDefault(),l._open(n),l._bindContainerClose()}),this.urlAltered=!0,e.mobile.navigate(t,{role:"dialog"}),this)):(l._open(n),l._bindContainerClose(),l.element.delegate(s.closeLinkSelector,s.closeLinkEvents,function(e){l.close(),e.preventDefault()}),this))},close:function(){return e.mobile.popup.active!==this?this:(this._scrollTop=this.window.scrollTop(),this.options.history&&this.urlAltered?(e.mobile.back(),this.urlAltered=!1):this._closePopup(),this)}}),e.mobile.popup.handleLink=function(n){var t,o=e.mobile.path,i=e(o.hashToSelector(o.parseUrl(n.attr("href")).hash)).first();i.length>0&&i.data("mobile-popup")&&(t=n.offset(),i.popup("open",{x:t.left+n.outerWidth()/2,y:t.top+n.outerHeight()/2,transition:n.jqmData("transition"),positionTo:n.jqmData("position-to")})),setTimeout(function(){n.removeClass(e.mobile.activeBtnClass)},300)},e.mobile.document.on("pagebeforechange",function(n,t){"popup"===t.options.role&&(e.mobile.popup.handleLink(t.options.link),n.preventDefault())})}(e),function(e,n){var o=".ui-disabled,.ui-state-disabled,.ui-li-divider,.ui-screen-hidden,:jqmData(role='placeholder')",i=function(e,n,t){var i=e[t+"All"]().not(o).first();i.length&&(n.blur().attr("tabindex","-1"),i.find("a").first().focus())};e.widget("mobile.selectmenu",e.mobile.selectmenu,{_create:function(){var e=this.options;return e.nativeMenu=e.nativeMenu||this.element.parents(":jqmData(role='popup'),:mobile-popup").length>0,this._super()},_handleSelectFocus:function(){this.element.blur(),this.button.focus()},_handleKeydown:function(e){this._super(e),this._handleButtonVclickKeydown(e)},_handleButtonVclickKeydown:function(n){this.options.disabled||this.isOpen||("vclick"===n.type||n.keyCode&&(n.keyCode===e.mobile.keyCode.ENTER||n.keyCode===e.mobile.keyCode.SPACE))&&(this._decideFormat(),"overlay"===this.menuType?this.button.attr("href","#"+this.popupId).attr("data-"+(e.mobile.ns||"")+"rel","popup"):this.button.attr("href","#"+this.dialogId).attr("data-"+(e.mobile.ns||"")+"rel","dialog"),this.isOpen=!0)},_handleListFocus:function(n){var t="focusin"===n.type?{tabindex:"0",event:"vmouseover"}:{tabindex:"-1",event:"vmouseout"};e(n.target).attr("tabindex",t.tabindex).trigger(t.event)},_handleListKeydown:function(n){var t=e(n.target),o=t.closest("li");switch(n.keyCode){case 38:return i(o,t,"prev"),!1;case 40:return i(o,t,"next"),!1;case 13:case 32:return t.trigger("click"),!1}},_handleMenuPageHide:function(){this.thisPage.page("bindRemove")},_handleHeaderCloseClick:function(){return"overlay"===this.menuType?(this.close(),!1):void 0},build:function(){var t,o,i,a,r,l,s,p,c,u,g,h,m,d,b,_,f,w,v=this.options;return v.nativeMenu?this._super():(w=this,t=this.selectId,o=t+"-listbox",i=t+"-dialog",a=this.label,r=this.element.closest(".ui-page"),l=this.element[0].multiple,s=t+"-menu",p=v.theme?" data-"+e.mobile.ns+"theme='"+v.theme+"'":"",c=v.overlayTheme||v.theme||null,u=c?" data-"+e.mobile.ns+"overlay-theme='"+c+"'":"",g=v.dividerTheme&&l?" data-"+e.mobile.ns+"divider-theme='"+v.dividerTheme+"'":"",h=e("<div data-"+e.mobile.ns+"role='dialog' class='ui-selectmenu' id='"+i+"'"+p+u+"><div data-"+e.mobile.ns+"role='header'><div class='ui-title'>"+a.getEncodedText()+"</div></div><div data-"+e.mobile.ns+"role='content'></div></div>"),m=e("<div id='"+o+"' class='ui-selectmenu'></div>").insertAfter(this.select).popup({theme:v.overlayTheme}),d=e("<ul class='ui-selectmenu-list' id='"+s+"' role='listbox' aria-labelledby='"+this.buttonId+"'"+p+g+"></ul>").appendTo(m),b=e("<div class='ui-header ui-bar-"+(v.theme?v.theme:"inherit")+"'></div>").prependTo(m),_=e("<h1 class='ui-title'></h1>").appendTo(b),this.isMultiple&&(f=e("<a>",{role:"button",text:v.closeText,href:"#","class":"ui-btn ui-corner-all ui-btn-left ui-btn-icon-notext ui-icon-delete"}).appendTo(b)),e.extend(this,{selectId:t,menuId:s,popupId:o,dialogId:i,thisPage:r,menuPage:h,label:a,isMultiple:l,theme:v.theme,listbox:m,list:d,header:b,headerTitle:_,headerClose:f,menuPageContent:void 0,menuPageClose:void 0,placeholder:""}),this.refresh(),this._origTabIndex===n&&(this._origTabIndex=null!==this.select[0].getAttribute("tabindex")&&this.select.attr("tabindex")),this.select.attr("tabindex","-1"),this._on(this.select,{focus:"_handleSelectFocus"}),this._on(this.button,{vclick:"_handleButtonVclickKeydown"}),this.list.attr("role","listbox"),this._on(this.list,{focusin:"_handleListFocus",focusout:"_handleListFocus",keydown:"_handleListKeydown"}),this.list.delegate("li:not(.ui-disabled,.ui-state-disabled,.ui-li-divider)","click",function(n){var t=w.select[0].selectedIndex,o=e.mobile.getAttribute(this,"option-index"),i=w._selectOptions().eq(o)[0];i.selected=!w.isMultiple||!i.selected,w.isMultiple&&e(this).find("a").toggleClass("ui-checkbox-on",i.selected).toggleClass("ui-checkbox-off",!i.selected),(w.isMultiple||t!==o)&&w.select.trigger("change"),w.isMultiple?w.list.find("li:not(.ui-li-divider)").eq(o).find("a").first().focus():w.close(),n.preventDefault()}),this._on(this.menuPage,{pagehide:"_handleMenuPageHide"}),this._on(this.listbox,{popupafterclose:"close"}),this.isMultiple&&this._on(this.headerClose,{click:"_handleHeaderCloseClick"}),this)},_isRebuildRequired:function(){var e=this.list.find("li");return this._selectOptions().not(".ui-screen-hidden").text()!==e.text()},selected:function(){return this._selectOptions().filter(":selected:not( :jqmData(placeholder='true') )")},refresh:function(n){var t,o;return this.options.nativeMenu?this._super(n):(t=this,(n||this._isRebuildRequired())&&t._buildList(),o=this.selectedIndices(),t.setButtonText(),t.setButtonCount(),void t.list.find("li:not(.ui-li-divider)").find("a").removeClass(e.mobile.activeBtnClass).end().attr("aria-selected",!1).each(function(n){if(e.inArray(n,o)>-1){var i=e(this);i.attr("aria-selected",!0),t.isMultiple?i.find("a").removeClass("ui-checkbox-off").addClass("ui-checkbox-on"):i.hasClass("ui-screen-hidden")?i.next().find("a").addClass(e.mobile.activeBtnClass):i.find("a").addClass(e.mobile.activeBtnClass)}}))},close:function(){if(!this.options.disabled&&this.isOpen){var e=this;"page"===e.menuType?(e.menuPage.dialog("close"),e.list.appendTo(e.listbox)):e.listbox.popup("close"),e._focusButton(),e.isOpen=!1}},open:function(){this.button.click()},_focusMenuItem:function(){var n=this.list.find("a."+e.mobile.activeBtnClass);0===n.length&&(n=this.list.find("li:not("+o+") a.ui-btn")),n.first().focus()},_decideFormat:function(){var n=this,t=this.window,o=n.list.parent(),i=o.outerHeight(),a=t.scrollTop(),r=n.button.offset().top,l=t.height();i>l-80||!e.support.scrollTop?(n.menuPage.appendTo(e.mobile.pageContainer).page(),n.menuPageContent=n.menuPage.find(".ui-content"),n.menuPageClose=n.menuPage.find(".ui-header a"),n.thisPage.unbind("pagehide.remove"),0===a&&r>l&&n.thisPage.one("pagehide",function(){e(this).jqmData("lastScroll",r)}),n.menuPage.one({pageshow:e.proxy(this,"_focusMenuItem"),pagehide:e.proxy(this,"close")}),n.menuType="page",n.menuPageContent.append(n.list),n.menuPage.find("div .ui-title").text(n.label.text())):(n.menuType="overlay",n.listbox.one({popupafteropen:e.proxy(this,"_focusMenuItem")}))},_buildList:function(){var n,o,i,a,r,l,s,p,c,u,g,h,m,d,b=this,_=this.options,f=this.placeholder,w=!0,v="data-"+e.mobile.ns,E=v+"option-index",P=v+"icon",T=v+"role",S=v+"placeholder",N=t.createDocumentFragment(),I=!1;for(b.list.empty().filter(".ui-listview").listview("destroy"),n=this._selectOptions(),o=n.length,i=this.select[0],r=0;o>r;r++,I=!1)l=n[r],s=e(l),s.hasClass("ui-screen-hidden")||(p=l.parentNode,c=s.text(),u=t.createElement("a"),g=[],u.setAttribute("href","#"),u.appendChild(t.createTextNode(c)),p!==i&&"optgroup"===p.nodeName.toLowerCase()&&(h=p.getAttribute("label"))!==a&&(m=t.createElement("li"),m.setAttribute(T,"list-divider"),m.setAttribute("role","option"),m.setAttribute("tabindex","-1"),m.appendChild(t.createTextNode(h)),N.appendChild(m),a=h),!w||l.getAttribute("value")&&0!==c.length&&!s.jqmData("placeholder")||(w=!1,I=!0,null===l.getAttribute(S)&&(this._removePlaceholderAttr=!0),l.setAttribute(S,!0),_.hidePlaceholderMenuItems&&g.push("ui-screen-hidden"),f!==c&&(f=b.placeholder=c)),d=t.createElement("li"),l.disabled&&(g.push("ui-state-disabled"),d.setAttribute("aria-disabled",!0)),d.setAttribute(E,r),d.setAttribute(P,"false"),I&&d.setAttribute(S,!0),d.className=g.join(" "),d.setAttribute("role","option"),u.setAttribute("tabindex","-1"),this.isMultiple&&e(u).addClass("ui-btn ui-checkbox-off ui-btn-icon-right"),d.appendChild(u),N.appendChild(d));b.list[0].appendChild(N),this.isMultiple||f.length?this.headerTitle.text(this.placeholder):this.header.addClass("ui-screen-hidden"),b.list.listview()},_button:function(){return this.options.nativeMenu?this._super():e("<a>",{href:"#",role:"button",id:this.buttonId,"aria-haspopup":"true","aria-owns":this.menuId})},_destroy:function(){this.options.nativeMenu||(this.close(),this._origTabIndex!==n&&(!1!==this._origTabIndex?this.select.attr("tabindex",this._origTabIndex):this.select.removeAttr("tabindex")),this._removePlaceholderAttr&&this._selectOptions().removeAttr("data-"+e.mobile.ns+"placeholder"),this.listbox.remove(),this.menuPage.remove()),this._super()}})}(e),function(e,n){function t(e,n){var t=n||[];return t.push("ui-btn"),e.theme&&t.push("ui-btn-"+e.theme),e.icon&&(t=t.concat(["ui-icon-"+e.icon,"ui-btn-icon-"+e.iconpos]),e.iconshadow&&t.push("ui-shadow-icon")),e.inline&&t.push("ui-btn-inline"),e.shadow&&t.push("ui-shadow"),e.corners&&t.push("ui-corner-all"),e.mini&&t.push("ui-mini"),t}function o(e){var t,o,i,r=!1,l=!0,s={icon:"",inline:!1,shadow:!1,corners:!1,iconshadow:!1,mini:!1},p=[];for(e=e.split(" "),t=0;t<e.length;t++)i=!0,o=a[e[t]],o!==n?(i=!1,s[o]=!0):0===e[t].indexOf("ui-btn-icon-")?(i=!1,l=!1,s.iconpos=e[t].substring(12)):0===e[t].indexOf("ui-icon-")?(i=!1,s.icon=e[t].substring(8)):0===e[t].indexOf("ui-btn-")&&8===e[t].length?(i=!1,s.theme=e[t].substring(7)):"ui-btn"===e[t]&&(i=!1,r=!0),i&&p.push(e[t]);return l&&(s.icon=""),{options:s,unknownClasses:p,alreadyEnhanced:r}}function i(e){return"-"+e.toLowerCase()}var a={"ui-shadow":"shadow","ui-corner-all":"corners","ui-btn-inline":"inline","ui-shadow-icon":"iconshadow","ui-mini":"mini"},r=function(){var t=e.mobile.getAttribute.apply(this,arguments);return null==t?n:t};e.fn.buttonMarkup=function(a,l){var s,p,c,u,g,h=e.fn.buttonMarkup.defaults;for(s=0;s<this.length;s++){if(c=this[s],p=l?{alreadyEnhanced:!1,unknownClasses:[]}:o(c.className),u=e.extend({},p.alreadyEnhanced?p.options:{},a),!p.alreadyEnhanced)for(g in h)u[g]===n&&(u[g]=r(c,g.replace(/[A-Z]/g,i)));c.className=t(e.extend({},h,u),p.unknownClasses).join(" "),"button"!==c.tagName.toLowerCase()&&c.setAttribute("role","button")}return this},
e.fn.buttonMarkup.defaults={icon:"",iconpos:"left",theme:null,inline:!1,shadow:!0,corners:!0,iconshadow:!1,mini:!1},e.extend(e.fn.buttonMarkup,{initSelector:"a:jqmData(role='button'), .ui-bar > a, .ui-bar > :jqmData(role='controlgroup') > a, button"})}(e),function(e,n){e.widget("mobile.controlgroup",e.extend({options:{enhanced:!1,theme:null,shadow:!1,corners:!0,excludeInvisible:!0,type:"vertical",mini:!1},_create:function(){var n=this.element,t=this.options;e.fn.buttonMarkup&&this.element.find(e.fn.buttonMarkup.initSelector).buttonMarkup(),e.each(this._childWidgets,e.proxy(function(n,t){e.mobile[t]&&this.element.find(e.mobile[t].initSelector).not(e.mobile.page.prototype.keepNativeSelector())[t]()},this)),e.extend(this,{_ui:null,_initialRefresh:!0}),this._ui=t.enhanced?{groupLegend:n.children(".ui-controlgroup-label").children(),childWrapper:n.children(".ui-controlgroup-controls")}:this._enhance()},_childWidgets:["checkboxradio","selectmenu","button"],_themeClassFromOption:function(e){return e?"none"===e?"":"ui-group-theme-"+e:""},_enhance:function(){var n=this.element,t=this.options,o={groupLegend:n.children("legend"),childWrapper:n.addClass("ui-controlgroup ui-controlgroup-"+("horizontal"===t.type?"horizontal":"vertical")+" "+this._themeClassFromOption(t.theme)+" "+(t.corners?"ui-corner-all ":"")+(t.mini?"ui-mini ":"")).wrapInner("<div class='ui-controlgroup-controls "+(!0===t.shadow?"ui-shadow":"")+"'></div>").children()};return o.groupLegend.length>0&&e("<div role='heading' class='ui-controlgroup-label'></div>").append(o.groupLegend).prependTo(n),o},_init:function(){this.refresh()},_setOptions:function(e){var t,o,i=this.element;return e.type!==n&&(i.removeClass("ui-controlgroup-horizontal ui-controlgroup-vertical").addClass("ui-controlgroup-"+("horizontal"===e.type?"horizontal":"vertical")),t=!0),e.theme!==n&&i.removeClass(this._themeClassFromOption(this.options.theme)).addClass(this._themeClassFromOption(e.theme)),e.corners!==n&&i.toggleClass("ui-corner-all",e.corners),e.mini!==n&&i.toggleClass("ui-mini",e.mini),e.shadow!==n&&this._ui.childWrapper.toggleClass("ui-shadow",e.shadow),e.excludeInvisible!==n&&(this.options.excludeInvisible=e.excludeInvisible,t=!0),o=this._super(e),t&&this.refresh(),o},container:function(){return this._ui.childWrapper},refresh:function(){var n=this.container(),t=n.find(".ui-btn").not(".ui-slider-handle"),o=this._initialRefresh;e.mobile.checkboxradio&&n.find(":mobile-checkboxradio").checkboxradio("refresh"),this._addFirstLastClasses(t,this.options.excludeInvisible?this._getVisibles(t,o):t,o),this._initialRefresh=!1},_destroy:function(){var e,n,t=this.options;return t.enhanced?this:(e=this._ui,n=this.element.removeClass("ui-controlgroup ui-controlgroup-horizontal ui-controlgroup-vertical ui-corner-all ui-mini "+this._themeClassFromOption(t.theme)).find(".ui-btn").not(".ui-slider-handle"),this._removeFirstLastClasses(n),e.groupLegend.unwrap(),void e.childWrapper.children().unwrap())}},e.mobile.behaviors.addFirstLastClasses))}(e),function(e,n){e.widget("mobile.toolbar",{initSelector:":jqmData(role='footer'), :jqmData(role='header')",options:{theme:null,addBackBtn:!1,backBtnTheme:null,backBtnText:"Back"},_create:function(){var n=this.element.is(":jqmData(role='header')")?"header":"footer",t=this.element.closest(".ui-page");0===t.length&&(t=!1,this._on(this.document,{pageshow:"refresh"})),e.extend(this,{role:n,page:t,leftbtn:void 0,rightbtn:void 0}),this.element.attr("role","header"===n?"banner":"contentinfo").addClass("ui-"+n),this.refresh(),this._setOptions(this.options)},_setOptions:function(t){if(t.addBackBtn!==n&&(this.options.addBackBtn&&"header"===this.role&&e(".ui-page").length>1&&this.page[0].getAttribute("data-"+e.mobile.ns+"url")!==e.mobile.path.stripHash(location.hash)&&!this.leftbtn?this._addBackButton():this.element.find(".ui-toolbar-back-btn").remove()),null!=t.backBtnTheme&&this.element.find(".ui-toolbar-back-btn").addClass("ui-btn ui-btn-"+t.backBtnTheme),t.backBtnText!==n&&this.element.find(".ui-toolbar-back-btn .ui-btn-text").text(t.backBtnText),t.theme!==n){var o=this.options.theme?this.options.theme:"inherit",i=t.theme?t.theme:"inherit";this.element.removeClass("ui-bar-"+o).addClass("ui-bar-"+i)}this._super(t)},refresh:function(){"header"===this.role&&this._addHeaderButtonClasses(),this.page||(this._setRelative(),"footer"===this.role&&this.element.appendTo("body")),this._addHeadingClasses(),this._btnMarkup()},_setRelative:function(){e("[data-"+e.mobile.ns+"role='page']").css({position:"relative"})},_btnMarkup:function(){this.element.children("a").filter(":not([data-"+e.mobile.ns+"role='none'])").attr("data-"+e.mobile.ns+"role","button"),this.element.trigger("create")},_addHeaderButtonClasses:function(){var e=this.element.children("a, button");this.leftbtn=e.hasClass("ui-btn-left"),this.rightbtn=e.hasClass("ui-btn-right"),this.leftbtn=this.leftbtn||e.eq(0).not(".ui-btn-right").addClass("ui-btn-left").length,this.rightbtn=this.rightbtn||e.eq(1).addClass("ui-btn-right").length},_addBackButton:function(){var n=this.options,t=n.backBtnTheme||n.theme;e("<a role='button' href='javascript:void(0);' class='ui-btn ui-corner-all ui-shadow ui-btn-left "+(t?"ui-btn-"+t+" ":"")+"ui-toolbar-back-btn ui-icon-carat-l ui-btn-icon-left' data-"+e.mobile.ns+"rel='back'>"+n.backBtnText+"</a>").prependTo(this.element)},_addHeadingClasses:function(){this.element.children("h1, h2, h3, h4, h5, h6").addClass("ui-title").attr({role:"heading","aria-level":"1"})}})}(e),function(e,n){e.widget("mobile.toolbar",e.mobile.toolbar,{options:{position:null,visibleOnPageShow:!0,disablePageZoom:!0,transition:"slide",fullscreen:!1,tapToggle:!0,tapToggleBlacklist:"a, button, input, select, textarea, .ui-header-fixed, .ui-footer-fixed, .ui-flipswitch, .ui-popup, .ui-panel, .ui-panel-dismiss-open",hideDuringFocus:"input, textarea, select",updatePagePadding:!0,trackPersistentToolbars:!0,supportBlacklist:function(){return!e.support.fixedPosition}},_create:function(){this._super(),"fixed"!==this.options.position||this.options.supportBlacklist()||this._makeFixed()},_makeFixed:function(){this.element.addClass("ui-"+this.role+"-fixed"),this.updatePagePadding(),this._addTransitionClass(),this._bindPageEvents(),this._bindToggleHandlers()},_setOptions:function(t){if("fixed"===t.position&&"fixed"!==this.options.position&&this._makeFixed(),"fixed"===this.options.position&&!this.options.supportBlacklist()){var o=this.page?this.page:e(".ui-page-active").length>0?e(".ui-page-active"):e(".ui-page").eq(0);t.fullscreen!==n&&(t.fullscreen?(this.element.addClass("ui-"+this.role+"-fullscreen"),o.addClass("ui-page-"+this.role+"-fullscreen")):(this.element.removeClass("ui-"+this.role+"-fullscreen"),o.removeClass("ui-page-"+this.role+"-fullscreen").addClass("ui-page-"+this.role+"-fixed")))}this._super(t)},_addTransitionClass:function(){var e=this.options.transition;e&&"none"!==e&&("slide"===e&&(e=this.element.hasClass("ui-header")?"slidedown":"slideup"),this.element.addClass(e))},_bindPageEvents:function(){var e=this.page?this.element.closest(".ui-page"):this.document;this._on(e,{pagebeforeshow:"_handlePageBeforeShow",webkitAnimationStart:"_handleAnimationStart",animationstart:"_handleAnimationStart",updatelayout:"_handleAnimationStart",pageshow:"_handlePageShow",pagebeforehide:"_handlePageBeforeHide"})},_handlePageBeforeShow:function(){var n=this.options;n.disablePageZoom&&e.mobile.zoom.disable(!0),n.visibleOnPageShow||this.hide(!0)},_handleAnimationStart:function(){this.options.updatePagePadding&&this.updatePagePadding(this.page?this.page:".ui-page-active")},_handlePageShow:function(){this.updatePagePadding(this.page?this.page:".ui-page-active"),this.options.updatePagePadding&&this._on(this.window,{throttledresize:"updatePagePadding"})},_handlePageBeforeHide:function(n,t){var o,i,a,r,l=this.options;l.disablePageZoom&&e.mobile.zoom.enable(!0),l.updatePagePadding&&this._off(this.window,"throttledresize"),l.trackPersistentToolbars&&(o=e(".ui-footer-fixed:jqmData(id)",this.page),i=e(".ui-header-fixed:jqmData(id)",this.page),a=o.length&&t.nextPage&&e(".ui-footer-fixed:jqmData(id='"+o.jqmData("id")+"')",t.nextPage)||e(),r=i.length&&t.nextPage&&e(".ui-header-fixed:jqmData(id='"+i.jqmData("id")+"')",t.nextPage)||e(),(a.length||r.length)&&(a.add(r).appendTo(e.mobile.pageContainer),t.nextPage.one("pageshow",function(){r.prependTo(this),a.appendTo(this)})))},_visible:!0,updatePagePadding:function(t){var o=this.element,i="header"===this.role,a=parseFloat(o.css(i?"top":"bottom"));this.options.fullscreen||(t=t&&t.type===n&&t||this.page||o.closest(".ui-page"),t=this.page?this.page:".ui-page-active",e(t).css("padding-"+(i?"top":"bottom"),o.outerHeight()+a))},_useTransition:function(n){var t=this.window,o=this.element,i=t.scrollTop(),a=o.height(),r=this.page?o.closest(".ui-page").height():e(".ui-page-active").height(),l=e.mobile.getScreenHeight();return!n&&(this.options.transition&&"none"!==this.options.transition&&("header"===this.role&&!this.options.fullscreen&&i>a||"footer"===this.role&&!this.options.fullscreen&&r-a>i+l)||this.options.fullscreen)},show:function(e){var n="ui-fixed-hidden",t=this.element;this._useTransition(e)?t.removeClass("out "+n).addClass("in").animationComplete(function(){t.removeClass("in")}):t.removeClass(n),this._visible=!0},hide:function(e){var n="ui-fixed-hidden",t=this.element,o="out"+("slide"===this.options.transition?" reverse":"");this._useTransition(e)?t.addClass(o).removeClass("in").animationComplete(function(){t.addClass(n).removeClass(o)}):t.addClass(n).removeClass(o),this._visible=!1},toggle:function(){this[this._visible?"hide":"show"]()},_bindToggleHandlers:function(){var n,t,o=this,i=o.options,a=!0;(this.page?this.page:e(".ui-page")).bind("vclick",function(n){i.tapToggle&&!e(n.target).closest(i.tapToggleBlacklist).length&&o.toggle()}).bind("focusin focusout",function(r){screen.width<1025&&e(r.target).is(i.hideDuringFocus)&&!e(r.target).closest(".ui-header-fixed, .ui-footer-fixed").length&&("focusout"!==r.type||a?"focusin"===r.type&&a&&(clearTimeout(n),a=!1,t=setTimeout(function(){o.hide()},0)):(a=!0,clearTimeout(t),n=setTimeout(function(){o.show()},0)))})},_setRelative:function(){"fixed"!==this.options.position&&e("[data-"+e.mobile.ns+"role='page']").css({position:"relative"})},_destroy:function(){var e=this.element,n=e.hasClass("ui-header");e.closest(".ui-page").css("padding-"+(n?"top":"bottom"),""),e.removeClass("ui-header-fixed ui-footer-fixed ui-header-fullscreen ui-footer-fullscreen in out fade slidedown slideup ui-fixed-hidden"),e.closest(".ui-page").removeClass("ui-page-header-fixed ui-page-footer-fixed ui-page-header-fullscreen ui-page-footer-fullscreen")}})}(e),function(e){e.widget("mobile.toolbar",e.mobile.toolbar,{_makeFixed:function(){this._super(),this._workarounds()},_workarounds:function(){var e=navigator.userAgent,n=navigator.platform,t=e.match(/AppleWebKit\/([0-9]+)/),o=!!t&&t[1],i=null,a=this;if(n.indexOf("iPhone")>-1||n.indexOf("iPad")>-1||n.indexOf("iPod")>-1)i="ios";else{if(!(e.indexOf("Android")>-1))return;i="android"}if("ios"===i)a._bindScrollWorkaround();else{if(!("android"===i&&o&&534>o))return;a._bindScrollWorkaround(),a._bindListThumbWorkaround()}},_viewportOffset:function(){var e=this.element,n=e.hasClass("ui-header"),t=Math.abs(e.offset().top-this.window.scrollTop());return n||(t=Math.round(t-this.window.height()+e.outerHeight())-60),t},_bindScrollWorkaround:function(){var e=this;this._on(this.window,{scrollstop:function(){e._viewportOffset()>2&&e._visible&&e._triggerRedraw()}})},_bindListThumbWorkaround:function(){this.element.closest(".ui-page").addClass("ui-android-2x-fixed")},_triggerRedraw:function(){var n=parseFloat(e(".ui-page-active").css("padding-bottom"));e(".ui-page-active").css("padding-bottom",n+1+"px"),setTimeout(function(){e(".ui-page-active").css("padding-bottom",n+"px")},0)},destroy:function(){this._super(),this.element.closest(".ui-page-active").removeClass("ui-android-2x-fix")}})}(e),function(e,n){function t(){var e=i.clone(),n=e.eq(0),t=e.eq(1),o=t.children();return{arEls:t.add(n),gd:n,ct:t,ar:o}}var o=e.mobile.browser.oldIE&&e.mobile.browser.oldIE<=8,i=e("<div class='ui-popup-arrow-guide'></div><div class='ui-popup-arrow-container"+(o?" ie":"")+"'><div class='ui-popup-arrow'></div></div>");e.widget("mobile.popup",e.mobile.popup,{options:{arrow:""},_create:function(){var e=this._super();return this.options.arrow&&(this._ui.arrow=this._addArrow()),e},_addArrow:function(){var e,n=this.options,o=t();return e=this._themeClassFromOption("ui-body-",n.theme),o.ar.addClass(e+(n.shadow?" ui-overlay-shadow":"")),o.arEls.hide().appendTo(this.element),o},_unenhance:function(){var e=this._ui.arrow;return e&&e.arEls.remove(),this._super()},_tryAnArrow:function(e,n,t,o,i){var a,r,l,s={},p={};return o.arFull[e.dimKey]>o.guideDims[e.dimKey]?i:(s[e.fst]=t[e.fst]+(o.arHalf[e.oDimKey]+o.menuHalf[e.oDimKey])*e.offsetFactor-o.contentBox[e.fst]+(o.clampInfo.menuSize[e.oDimKey]-o.contentBox[e.oDimKey])*e.arrowOffsetFactor,s[e.snd]=t[e.snd],a=o.result||this._calculateFinalLocation(s,o.clampInfo),r={x:a.left,y:a.top},p[e.fst]=r[e.fst]+o.contentBox[e.fst]+e.tipOffset,p[e.snd]=Math.max(a[e.prop]+o.guideOffset[e.prop]+o.arHalf[e.dimKey],Math.min(a[e.prop]+o.guideOffset[e.prop]+o.guideDims[e.dimKey]-o.arHalf[e.dimKey],t[e.snd])),l=Math.abs(t.x-p.x)+Math.abs(t.y-p.y),(!i||l<i.diff)&&(p[e.snd]-=o.arHalf[e.dimKey]+a[e.prop]+o.contentBox[e.snd],i={dir:n,diff:l,result:a,posProp:e.prop,posVal:p[e.snd]}),i)},_getPlacementState:function(e){var n,t,o=this._ui.arrow,i={clampInfo:this._clampPopupWidth(!e),arFull:{cx:o.ct.width(),cy:o.ct.height()},guideDims:{cx:o.gd.width(),cy:o.gd.height()},guideOffset:o.gd.offset()};return n=this.element.offset(),o.gd.css({left:0,top:0,right:0,bottom:0}),t=o.gd.offset(),i.contentBox={x:t.left-n.left,y:t.top-n.top,cx:o.gd.width(),cy:o.gd.height()},o.gd.removeAttr("style"),i.guideOffset={left:i.guideOffset.left-n.left,top:i.guideOffset.top-n.top},i.arHalf={cx:i.arFull.cx/2,cy:i.arFull.cy/2},i.menuHalf={cx:i.clampInfo.menuSize.cx/2,cy:i.clampInfo.menuSize.cy/2},i},_placementCoords:function(n){var t,i,a,r,l,s=this.options.arrow,p=this._ui.arrow;return p?(p.arEls.show(),l={},t=this._getPlacementState(!0),a={l:{fst:"x",snd:"y",prop:"top",dimKey:"cy",oDimKey:"cx",offsetFactor:1,tipOffset:-t.arHalf.cx,arrowOffsetFactor:0},r:{fst:"x",snd:"y",prop:"top",dimKey:"cy",oDimKey:"cx",offsetFactor:-1,tipOffset:t.arHalf.cx+t.contentBox.cx,arrowOffsetFactor:1},b:{fst:"y",snd:"x",prop:"left",dimKey:"cx",oDimKey:"cy",offsetFactor:-1,tipOffset:t.arHalf.cy+t.contentBox.cy,arrowOffsetFactor:1},t:{fst:"y",snd:"x",prop:"left",dimKey:"cx",oDimKey:"cy",offsetFactor:1,tipOffset:-t.arHalf.cy,arrowOffsetFactor:0}},e.each((!0===s?"l,t,r,b":s).split(","),e.proxy(function(e,o){i=this._tryAnArrow(a[o],o,n,t,i)},this)),i?(p.ct.removeClass("ui-popup-arrow-l ui-popup-arrow-t ui-popup-arrow-r ui-popup-arrow-b").addClass("ui-popup-arrow-"+i.dir).removeAttr("style").css(i.posProp,i.posVal).show(),o||(r=this.element.offset(),l[a[i.dir].fst]=p.ct.offset(),l[a[i.dir].snd]={left:r.left+t.contentBox.x,top:r.top+t.contentBox.y}),i.result):(p.arEls.hide(),this._super(n))):this._super(n)},_setOptions:function(e){var t,o=this.options.theme,i=this._ui.arrow,a=this._super(e);if(e.arrow!==n){if(!i&&e.arrow)return void(this._ui.arrow=this._addArrow());i&&!e.arrow&&(i.arEls.remove(),this._ui.arrow=null)}return i=this._ui.arrow,i&&(e.theme!==n&&(o=this._themeClassFromOption("ui-body-",o),t=this._themeClassFromOption("ui-body-",e.theme),i.ar.removeClass(o).addClass(t)),e.shadow!==n&&i.ar.toggleClass("ui-overlay-shadow",e.shadow)),a},_destroy:function(){var e=this._ui.arrow;return e&&e.arEls.remove(),this._super()}})}(e),function(e,t){e.widget("mobile.panel",{options:{classes:{panel:"ui-panel",panelOpen:"ui-panel-open",panelClosed:"ui-panel-closed",panelFixed:"ui-panel-fixed",panelInner:"ui-panel-inner",modal:"ui-panel-dismiss",modalOpen:"ui-panel-dismiss-open",pageContainer:"ui-panel-page-container",pageWrapper:"ui-panel-wrapper",pageFixedToolbar:"ui-panel-fixed-toolbar",pageContentPrefix:"ui-panel-page-content",animate:"ui-panel-animate"},animate:!0,theme:null,position:"left",dismissible:!0,display:"reveal",swipeClose:!0,positionFixed:!1},_closeLink:null,_parentPage:null,_page:null,_modal:null,_panelInner:null,_wrapper:null,_fixedToolbars:null,_create:function(){var n=this.element,t=n.closest(".ui-page, :jqmData(role='page')");e.extend(this,{_closeLink:n.find(":jqmData(rel='close')"),_parentPage:t.length>0&&t,_openedPage:null,_page:this._getPage,_panelInner:this._getPanelInner(),_fixedToolbars:this._getFixedToolbars}),"overlay"!==this.options.display&&this._getWrapper(),this._addPanelClasses(),e.support.cssTransform3d&&this.options.animate&&this.element.addClass(this.options.classes.animate),this._bindUpdateLayout(),this._bindCloseEvents(),this._bindLinkListeners(),this._bindPageEvents(),this.options.dismissible&&this._createModal(),this._bindSwipeEvents()},_getPanelInner:function(){var e=this.element.find("."+this.options.classes.panelInner);return 0===e.length&&(e=this.element.children().wrapAll("<div class='"+this.options.classes.panelInner+"' />").parent()),e},_createModal:function(){var n=this,t=n._parentPage?n._parentPage.parent():n.element.parent();n._modal=e("<div class='"+n.options.classes.modal+"'></div>").on("mousedown",function(){n.close()}).appendTo(t)},_getPage:function(){return this._openedPage||this._parentPage||e("."+e.mobile.activePageClass)},_getWrapper:function(){var e=this._page().find("."+this.options.classes.pageWrapper);0===e.length&&(e=this._page().children(".ui-header:not(.ui-header-fixed), .ui-content:not(.ui-popup), .ui-footer:not(.ui-footer-fixed)").wrapAll("<div class='"+this.options.classes.pageWrapper+"'></div>").parent()),this._wrapper=e},_getFixedToolbars:function(){var n=e("body").children(".ui-header-fixed, .ui-footer-fixed"),t=this._page().find(".ui-header-fixed, .ui-footer-fixed");return n.add(t).addClass(this.options.classes.pageFixedToolbar)},_getPosDisplayClasses:function(e){return e+"-position-"+this.options.position+" "+e+"-display-"+this.options.display},_getPanelClasses:function(){var e=this.options.classes.panel+" "+this._getPosDisplayClasses(this.options.classes.panel)+" "+this.options.classes.panelClosed+" ui-body-"+(this.options.theme?this.options.theme:"inherit");return this.options.positionFixed&&(e+=" "+this.options.classes.panelFixed),e},_addPanelClasses:function(){this.element.addClass(this._getPanelClasses())},_handleCloseClickAndEatEvent:function(e){return e.isDefaultPrevented()?void 0:(e.preventDefault(),this.close(),!1)},_handleCloseClick:function(e){e.isDefaultPrevented()||this.close()},_bindCloseEvents:function(){this._on(this._closeLink,{click:"_handleCloseClick"}),this._on({"click a:jqmData(ajax='false')":"_handleCloseClick"})},_positionPanel:function(n){var t=this,o=t._panelInner.outerHeight(),i=o>e.mobile.getScreenHeight();i||!t.options.positionFixed?(i&&(t._unfixPanel(),e.mobile.resetActivePageHeight(o)),n&&this.window[0].scrollTo(0,e.mobile.defaultHomeScroll)):t._fixPanel()},_bindFixListener:function(){this._on(e(n),{throttledresize:"_positionPanel"})},_unbindFixListener:function(){this._off(e(n),"throttledresize")},_unfixPanel:function(){this.options.positionFixed&&e.support.fixedPosition&&this.element.removeClass(this.options.classes.panelFixed)},_fixPanel:function(){this.options.positionFixed&&e.support.fixedPosition&&this.element.addClass(this.options.classes.panelFixed)},_bindUpdateLayout:function(){var e=this;e.element.on("updatelayout",function(){e._open&&e._positionPanel()})},_bindLinkListeners:function(){this._on("body",{"click a":"_handleClick"})},_handleClick:function(n){var t,o=this.element.attr("id");return n.currentTarget.href.split("#")[1]===o&&void 0!==o?(n.preventDefault(),t=e(n.target),t.hasClass("ui-btn")&&(t.addClass(e.mobile.activeBtnClass),this.element.one("panelopen panelclose",function(){t.removeClass(e.mobile.activeBtnClass)})),this.toggle(),!1):void 0},_bindSwipeEvents:function(){var e=this,n=e._modal?e.element.add(e._modal):e.element;e.options.swipeClose&&("left"===e.options.position?n.on("swipeleft.panel",function(){e.close()}):n.on("swiperight.panel",function(){e.close()}))},_bindPageEvents:function(){var e=this;this.document.on("panelbeforeopen",function(n){e._open&&n.target!==e.element[0]&&e.close()}).on("keyup.panel",function(n){27===n.keyCode&&e._open&&e.close()}),this._parentPage||"overlay"===this.options.display||this._on(this.document,{pageshow:"_getWrapper"}),e._parentPage?this.document.on("pagehide",":jqmData(role='page')",function(){e._open&&e.close(!0)}):this.document.on("pagebeforehide",function(){e._open&&e.close(!0)})},_open:!1,_pageContentOpenClasses:null,_modalOpenClasses:null,open:function(n){if(!this._open){var t=this,o=t.options,i=function(){t.document.off("panelclose"),t._page().jqmData("panel","open"),e.support.cssTransform3d&&o.animate&&"overlay"!==o.display&&(t._wrapper.addClass(o.classes.animate),t._fixedToolbars().addClass(o.classes.animate)),!n&&e.support.cssTransform3d&&o.animate?t.element.animationComplete(a,"transition"):setTimeout(a,0),o.theme&&"overlay"!==o.display&&t._page().parent().addClass(o.classes.pageContainer+"-themed "+o.classes.pageContainer+"-"+o.theme),t.element.removeClass(o.classes.panelClosed).addClass(o.classes.panelOpen),t._positionPanel(!0),t._pageContentOpenClasses=t._getPosDisplayClasses(o.classes.pageContentPrefix),"overlay"!==o.display&&(t._page().parent().addClass(o.classes.pageContainer),t._wrapper.addClass(t._pageContentOpenClasses),t._fixedToolbars().addClass(t._pageContentOpenClasses)),t._modalOpenClasses=t._getPosDisplayClasses(o.classes.modal)+" "+o.classes.modalOpen,t._modal&&t._modal.addClass(t._modalOpenClasses).height(Math.max(t._modal.height(),t.document.height()))},a=function(){"overlay"!==o.display&&(t._wrapper.addClass(o.classes.pageContentPrefix+"-open"),t._fixedToolbars().addClass(o.classes.pageContentPrefix+"-open")),t._bindFixListener(),t._trigger("open"),t._openedPage=t._page()};t._trigger("beforeopen"),"open"===t._page().jqmData("panel")?t.document.on("panelclose",function(){i()}):i(),t._open=!0}},close:function(n){if(this._open){var t=this,o=this.options,i=function(){o.theme&&"overlay"!==o.display&&t._page().parent().removeClass(o.classes.pageContainer+"-themed "+o.classes.pageContainer+"-"+o.theme),t.element.addClass(o.classes.panelClosed),"overlay"!==o.display&&(t._page().parent().removeClass(o.classes.pageContainer),t._wrapper.removeClass(o.classes.pageContentPrefix+"-open"),t._fixedToolbars().removeClass(o.classes.pageContentPrefix+"-open")),e.support.cssTransform3d&&o.animate&&"overlay"!==o.display&&(t._wrapper.removeClass(o.classes.animate),t._fixedToolbars().removeClass(o.classes.animate)),t._fixPanel(),t._unbindFixListener(),e.mobile.resetActivePageHeight(),t._page().jqmRemoveData("panel"),t._trigger("close"),t._openedPage=null};t._trigger("beforeclose"),function(){t.element.removeClass(o.classes.panelOpen),"overlay"!==o.display&&(t._wrapper.removeClass(t._pageContentOpenClasses),t._fixedToolbars().removeClass(t._pageContentOpenClasses)),!n&&e.support.cssTransform3d&&o.animate?t.element.animationComplete(i,"transition"):setTimeout(i,0),t._modal&&t._modal.removeClass(t._modalOpenClasses)}(),t._open=!1}},toggle:function(){this[this._open?"close":"open"]()},_destroy:function(){var n,t=this.options,o=e("body > :mobile-panel").length+e.mobile.activePage.find(":mobile-panel").length>1;"overlay"!==t.display&&(n=e("body > :mobile-panel").add(e.mobile.activePage.find(":mobile-panel")),0===n.not(".ui-panel-display-overlay").not(this.element).length&&this._wrapper.children().unwrap(),this._open&&(this._fixedToolbars().removeClass(t.classes.pageContentPrefix+"-open"),e.support.cssTransform3d&&t.animate&&this._fixedToolbars().removeClass(t.classes.animate),this._page().parent().removeClass(t.classes.pageContainer),t.theme&&this._page().parent().removeClass(t.classes.pageContainer+"-themed "+t.classes.pageContainer+"-"+t.theme))),o||this.document.off("panelopen panelclose"),this._open&&this._page().jqmRemoveData("panel"),this._panelInner.children().unwrap(),this.element.removeClass([this._getPanelClasses(),t.classes.panelOpen,t.classes.animate].join(" ")).off("swipeleft.panel swiperight.panel").off("panelbeforeopen").off("panelhide").off("keyup.panel").off("updatelayout"),this._modal&&this._modal.remove()}})}(e),function(e,n){e.widget("mobile.table",{options:{classes:{table:"ui-table"},enhanced:!1},_create:function(){this.options.enhanced||this.element.addClass(this.options.classes.table),e.extend(this,{headers:n,allHeaders:n}),this._refresh(!0)},_setHeaders:function(){var e=this.element.find("thead tr");this.headers=this.element.find("tr:eq(0)").children(),this.allHeaders=this.headers.add(e.children())},refresh:function(){this._refresh()},rebuild:e.noop,_refresh:function(){var n=this.element,t=n.find("thead tr");this._setHeaders(),t.each(function(){var o=0;e(this).children().each(function(){var i,a=parseInt(this.getAttribute("colspan"),10),r=":nth-child("+(o+1)+")";if(this.setAttribute("data-"+e.mobile.ns+"colstart",o+1),a)for(i=0;a-1>i;i++)o++,r+=", :nth-child("+(o+1)+")";e(this).jqmData("cells",n.find("tr").not(t.eq(0)).not(this).children(r)),o++})})}})}(e),function(e){e.widget("mobile.table",e.mobile.table,{options:{mode:"columntoggle",columnBtnTheme:null,columnPopupTheme:null,columnBtnText:"Columns...",classes:e.extend(e.mobile.table.prototype.options.classes,{popup:"ui-table-columntoggle-popup",columnBtn:"ui-table-columntoggle-btn",priorityPrefix:"ui-table-priority-",columnToggleTable:"ui-table-columntoggle"})},_create:function(){this._super(),"columntoggle"===this.options.mode&&(e.extend(this,{_menu:null}),this.options.enhanced?(this._menu=e(this.document[0].getElementById(this._id()+"-popup")).children().first(),this._addToggles(this._menu,!0)):(this._menu=this._enhanceColToggle(),this.element.addClass(this.options.classes.columnToggleTable)),this._setupEvents(),this._setToggleState())},_id:function(){return this.element.attr("id")||this.widgetName+this.uuid},_setupEvents:function(){this._on(this.window,{throttledresize:"_setToggleState"}),this._on(this._menu,{"change input":"_menuInputChange"})},_addToggles:function(n,t){var o,i=0,a=this.options,r=n.controlgroup("container");t?o=n.find("input"):r.empty(),this.headers.not("td").each(function(){var n=e(this),l=e.mobile.getAttribute(this,"priority"),s=n.add(n.jqmData("cells"));l&&(s.addClass(a.classes.priorityPrefix+l),(t?o.eq(i++):e("<label><input type='checkbox' checked />"+(n.children("abbr").first().attr("title")||n.text())+"</label>").appendTo(r).children(0).checkboxradio({theme:a.columnPopupTheme})).jqmData("cells",s))}),t||n.controlgroup("refresh")},_menuInputChange:function(n){var t=e(n.target),o=t[0].checked;t.jqmData("cells").toggleClass("ui-table-cell-hidden",!o).toggleClass("ui-table-cell-visible",o),t[0].getAttribute("locked")?(t.removeAttr("locked"),this._unlockCells(t.jqmData("cells"))):t.attr("locked",!0)},_unlockCells:function(e){e.removeClass("ui-table-cell-hidden ui-table-cell-visible")},_enhanceColToggle:function(){var n,t,o,i,a=this.element,r=this.options,l=e.mobile.ns,s=this.document[0].createDocumentFragment();return n=this._id()+"-popup",t=e("<a href='#"+n+"' class='"+r.classes.columnBtn+" ui-btn ui-btn-"+(r.columnBtnTheme||"a")+" ui-corner-all ui-shadow ui-mini' data-"+l+"rel='popup'>"+r.columnBtnText+"</a>"),o=e("<div class='"+r.classes.popup+"' id='"+n+"'></div>"),i=e("<fieldset></fieldset>").controlgroup(),this._addToggles(i,!1),i.appendTo(o),s.appendChild(o[0]),s.appendChild(t[0]),a.before(s),o.popup(),i},rebuild:function(){this._super(),"columntoggle"===this.options.mode&&this._refresh(!1)},_refresh:function(e){this._super(e),e||"columntoggle"!==this.options.mode||(this._unlockCells(this.element.find(".ui-table-cell-hidden, .ui-table-cell-visible")),this._addToggles(this._menu,e),this._setToggleState())},_setToggleState:function(){this._menu.find("input").each(function(){var n=e(this);this.checked="table-cell"===n.jqmData("cells").eq(0).css("display"),n.checkboxradio("refresh")})},_destroy:function(){this._super()}})}(e),function(e){e.widget("mobile.table",e.mobile.table,{options:{mode:"reflow",classes:e.extend(e.mobile.table.prototype.options.classes,{reflowTable:"ui-table-reflow",cellLabels:"ui-table-cell-label"})},_create:function(){this._super(),"reflow"===this.options.mode&&(this.options.enhanced||(this.element.addClass(this.options.classes.reflowTable),this._updateReflow()))},rebuild:function(){this._super(),"reflow"===this.options.mode&&this._refresh(!1)},_refresh:function(e){this._super(e),e||"reflow"!==this.options.mode||this._updateReflow()},_updateReflow:function(){var n=this,t=this.options;e(n.allHeaders.get().reverse()).each(function(){var o,i,a=e(this).jqmData("cells"),r=e.mobile.getAttribute(this,"colstart"),l=a.not(this).filter("thead th").length&&" ui-table-cell-label-top",s=e(this).text();""!==s&&(l?(o=parseInt(this.getAttribute("colspan"),10),i="",o&&(i="td:nth-child("+o+"n + "+r+")"),n._addLabels(a.filter(i),t.classes.cellLabels+l,s)):n._addLabels(a,t.classes.cellLabels,s))})},_addLabels:function(e,n,t){e.not(":has(b."+n+")").prepend("<b class='"+n+"'>"+t+"</b>")}})}(e),function(e,t){var o=function(n,t){return-1===(""+(e.mobile.getAttribute(this,"filtertext")||e(this).text())).toLowerCase().indexOf(t)};e.widget("mobile.filterable",{initSelector:":jqmData(filter='true')",options:{filterReveal:!1,filterCallback:o,enhanced:!1,input:null,children:"> li, > option, > optgroup option, > tbody tr, > .ui-controlgroup-controls > .ui-btn, > .ui-controlgroup-controls > .ui-checkbox, > .ui-controlgroup-controls > .ui-radio"},_create:function(){var n=this.options;e.extend(this,{_search:null,_timer:0}),this._setInput(n.input),n.enhanced||this._filterItems((this._search&&this._search.val()||"").toLowerCase())},_onKeyUp:function(){var t,o,i=this._search;if(i){if(t=i.val().toLowerCase(),(o=e.mobile.getAttribute(i[0],"lastval")+"")&&o===t)return;this._timer&&(n.clearTimeout(this._timer),this._timer=0),this._timer=this._delay(function(){this._trigger("beforefilter",null,{input:i}),i[0].setAttribute("data-"+e.mobile.ns+"lastval",t),this._filterItems(t),this._timer=0},250)}},_getFilterableItems:function(){var n=this.element,t=this.options.children,o=t?e.isFunction(t)?t():t.nodeName?e(t):t.jquery?t:this.element.find(t):{length:0};return 0===o.length&&(o=n.children()),o},_filterItems:function(n){var t,i,a,r,l=[],s=[],p=this.options,c=this._getFilterableItems();if(null!=n)for(i=p.filterCallback||o,a=c.length,t=0;a>t;t++)r=i.call(c[t],t,n)?s:l,r.push(c[t]);0===s.length?c[p.filterReveal?"addClass":"removeClass"]("ui-screen-hidden"):(e(s).addClass("ui-screen-hidden"),e(l).removeClass("ui-screen-hidden")),this._refreshChildWidget(),this._trigger("filter",null,{items:c})},_refreshChildWidget:function(){var n,t,o=["collapsibleset","selectmenu","controlgroup","listview"];for(t=o.length-1;t>-1;t--)n=o[t],e.mobile[n]&&(n=this.element.data("mobile-"+n))&&e.isFunction(n.refresh)&&n.refresh()},_setInput:function(t){var o=this._search;this._timer&&(n.clearTimeout(this._timer),this._timer=0),o&&(this._off(o,"keyup change input"),o=null),t&&(o=t.jquery?t:t.nodeName?e(t):this.document.find(t),this._on(o,{keyup:"_onKeyUp",change:"_onKeyUp",input:"_onKeyUp"})),this._search=o},_setOptions:function(e){var n=!(e.filterReveal===t&&e.filterCallback===t&&e.children===t);this._super(e),e.input!==t&&(this._setInput(e.input),n=!0),n&&this.refresh()},_destroy:function(){var e=this.options,n=this._getFilterableItems();e.enhanced?n.toggleClass("ui-screen-hidden",e.filterReveal):n.removeClass("ui-screen-hidden")},refresh:function(){this._timer&&(n.clearTimeout(this._timer),this._timer=0),this._filterItems((this._search&&this._search.val()||"").toLowerCase())}})}(e),function(e,n){var t=function(e,n){return function(t){n.call(this,t),e._syncTextInputOptions(t)}
},o=e.mobile.filterable.prototype.options.filterCallback;e.mobile.filterable.prototype.options.filterCallback=function(e,n){return!this.className.match(/(^|\s)ui-li-divider(\s|$)/)&&o.call(this,e,n)},e.widget("mobile.filterable",e.mobile.filterable,{options:{filterPlaceholder:"Filter items...",filterTheme:null},_create:function(){var n,t,o=this.element,i=["collapsibleset","selectmenu","controlgroup","listview"],a={};for(this._super(),e.extend(this,{_widget:null}),n=i.length-1;n>-1;n--)if(t=i[n],e.mobile[t]){if(this._setWidget(o.data("mobile-"+t)))break;a[t+"create"]="_handleCreate"}this._widget||this._on(o,a)},_handleCreate:function(e){this._setWidget(this.element.data("mobile-"+e.type.substring(0,e.type.length-6)))},_trigger:function(e,n,t){this._widget&&"mobile-listview"===this._widget.widgetFullName&&"beforefilter"===e&&this._widget._trigger("beforefilter",n,t),this._super(e,n,t)},_setWidget:function(e){return!this._widget&&e&&(this._widget=e,this._widget._setOptions=t(this,this._widget._setOptions)),this._widget&&(this._syncTextInputOptions(this._widget.options),"listview"===this._widget.widgetName&&(this._widget.options.hideDividers=!0,this._widget.element.listview("refresh"))),!!this._widget},_isSearchInternal:function(){return this._search&&this._search.jqmData("ui-filterable-"+this.uuid+"-internal")},_setInput:function(n){var t=this.options,o=!0,i={};if(!n){if(this._isSearchInternal())return;o=!1,n=e("<input data-"+e.mobile.ns+"type='search' placeholder='"+t.filterPlaceholder+"'></input>").jqmData("ui-filterable-"+this.uuid+"-internal",!0),e("<form class='ui-filterable'></form>").append(n).submit(function(e){e.preventDefault(),n.blur()}).insertBefore(this.element),e.mobile.textinput&&(null!=this.options.filterTheme&&(i.theme=t.filterTheme),n.textinput(i))}this._super(n),this._isSearchInternal()&&o&&this._search.attr("placeholder",this.options.filterPlaceholder)},_setOptions:function(t){var o=this._super(t);return t.filterPlaceholder!==n&&this._isSearchInternal()&&this._search.attr("placeholder",t.filterPlaceholder),t.filterTheme!==n&&this._search&&e.mobile.textinput&&this._search.textinput("option","theme",t.filterTheme),o},_destroy:function(){this._isSearchInternal()&&this._search.remove(),this._super()},_syncTextInputOptions:function(t){var o,i={};if(this._isSearchInternal()&&e.mobile.textinput){for(o in e.mobile.textinput.prototype.options)t[o]!==n&&(i[o]="theme"===o&&null!=this.options.filterTheme?this.options.filterTheme:t[o]);this._search.textinput("option",i)}}})}(e),function(e,n){function t(){return++i}function o(e){return e.hash.length>1&&decodeURIComponent(e.href.replace(a,""))===decodeURIComponent(location.href.replace(a,""))}var i=0,a=/#.*$/;e.widget("ui.tabs",{version:"fadf2b312a05040436451c64bbfaf4814bc62c56",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var n=this,t=this.options;this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",t.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(n){e(this).is(".ui-state-disabled")&&n.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs(),t.active=this._initialActive(),e.isArray(t.disabled)&&(t.disabled=e.unique(t.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return n.tabs.index(e)}))).sort()),this.active=!1!==this.options.active&&this.anchors.length?this._findActive(t.active):e(),this._refresh(),this.active.length&&this.load(t.active)},_initialActive:function(){var n=this.options.active,t=this.options.collapsible,o=location.hash.substring(1);return null===n&&(o&&this.tabs.each(function(t,i){return e(i).attr("aria-controls")===o?(n=t,!1):void 0}),null===n&&(n=this.tabs.index(this.tabs.filter(".ui-tabs-active"))),(null===n||-1===n)&&(n=!!this.tabs.length&&0)),!1!==n&&-1===(n=this.tabs.index(this.tabs.eq(n)))&&(n=!t&&0),!t&&!1===n&&this.anchors.length&&(n=0),n},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(n){var t=e(this.document[0].activeElement).closest("li"),o=this.tabs.index(t),i=!0;if(!this._handlePageNav(n)){switch(n.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:o++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:i=!1,o--;break;case e.ui.keyCode.END:o=this.anchors.length-1;break;case e.ui.keyCode.HOME:o=0;break;case e.ui.keyCode.SPACE:return n.preventDefault(),clearTimeout(this.activating),void this._activate(o);case e.ui.keyCode.ENTER:return n.preventDefault(),clearTimeout(this.activating),void this._activate(o!==this.options.active&&o);default:return}n.preventDefault(),clearTimeout(this.activating),o=this._focusNextTab(o,i),n.ctrlKey||(t.attr("aria-selected","false"),this.tabs.eq(o).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",o)},this.delay))}},_panelKeydown:function(n){this._handlePageNav(n)||n.ctrlKey&&n.keyCode===e.ui.keyCode.UP&&(n.preventDefault(),this.active.focus())},_handlePageNav:function(n){return n.altKey&&n.keyCode===e.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):n.altKey&&n.keyCode===e.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options.active+1,!0)),!0):void 0},_findNextTab:function(n,t){for(var o=this.tabs.length-1;-1!==e.inArray(function(){return n>o&&(n=0),0>n&&(n=o),n}(),this.options.disabled);)n=t?n+1:n-1;return n},_focusNextTab:function(e,n){return e=this._findNextTab(e,n),this.tabs.eq(e).focus(),e},_setOption:function(e,n){return"active"===e?void this._activate(n):"disabled"===e?void this._setupDisabled(n):(this._super(e,n),"collapsible"===e&&(this.element.toggleClass("ui-tabs-collapsible",n),n||!1!==this.options.active||this._activate(0)),"event"===e&&this._setupEvents(n),void("heightStyle"===e&&this._setupHeightStyle(n)))},_tabId:function(e){return e.attr("aria-controls")||"ui-tabs-"+t()},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var n=this.options,t=this.tablist.children(":has(a[href])");n.disabled=e.map(t.filter(".ui-state-disabled"),function(e){return t.index(e)}),this._processTabs(),!1!==n.active&&this.anchors.length?this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===n.disabled.length?(n.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,n.active-1),!1)):n.active=this.tabs.index(this.active):(n.active=!1,this.active=e()),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var n=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(t,i){var a,r,l,s=e(i).uniqueId().attr("id"),p=e(i).closest("li"),c=p.attr("aria-controls");o(i)?(a=i.hash,r=n.element.find(n._sanitizeSelector(a))):(l=n._tabId(p),a="#"+l,r=n.element.find(a),r.length||(r=n._createPanel(l),r.insertAfter(n.panels[t-1]||n.tablist)),r.attr("aria-live","polite")),r.length&&(n.panels=n.panels.add(r)),c&&p.data("ui-tabs-aria-controls",c),p.attr({"aria-controls":a.substring(1),"aria-labelledby":s}),r.attr("aria-labelledby",s)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.element.find("ol,ul").eq(0)},_createPanel:function(n){return e("<div>").attr("id",n).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(n){e.isArray(n)&&(n.length?n.length===this.anchors.length&&(n=!0):n=!1);for(var t,o=0;t=this.tabs[o];o++)!0===n||-1!==e.inArray(o,n)?e(t).addClass("ui-state-disabled").attr("aria-disabled","true"):e(t).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=n},_setupEvents:function(n){var t={click:function(e){e.preventDefault()}};n&&e.each(n.split(" "),function(e,n){t[n]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,t),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(n){var t,o=this.element.parent();"fill"===n?(t=o.height(),t-=this.element.outerHeight()-this.element.height(),this.element.siblings(":visible").each(function(){var n=e(this),o=n.css("position");"absolute"!==o&&"fixed"!==o&&(t-=n.outerHeight(!0))}),this.element.children().not(this.panels).each(function(){t-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,t-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):"auto"===n&&(t=0,this.panels.each(function(){t=Math.max(t,e(this).height("").height())}).height(t))},_eventHandler:function(n){var t=this.options,o=this.active,i=e(n.currentTarget),a=i.closest("li"),r=a[0]===o[0],l=r&&t.collapsible,s=l?e():this._getPanelForTab(a),p=o.length?this._getPanelForTab(o):e(),c={oldTab:o,oldPanel:p,newTab:l?e():a,newPanel:s};n.preventDefault(),a.hasClass("ui-state-disabled")||a.hasClass("ui-tabs-loading")||this.running||r&&!t.collapsible||!1===this._trigger("beforeActivate",n,c)||(t.active=!l&&this.tabs.index(a),this.active=r?e():a,this.xhr&&this.xhr.abort(),p.length||s.length||e.error("jQuery UI Tabs: Mismatching fragment identifier."),s.length&&this.load(this.tabs.index(a),n),this._toggle(n,c))},_toggle:function(n,t){function o(){a.running=!1,a._trigger("activate",n,t)}function i(){t.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),r.length&&a.options.show?a._show(r,a.options.show,o):(r.show(),o())}var a=this,r=t.newPanel,l=t.oldPanel;this.running=!0,l.length&&this.options.hide?this._hide(l,this.options.hide,function(){t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),i()}):(t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),l.hide(),i()),l.attr({"aria-expanded":"false","aria-hidden":"true"}),t.oldTab.attr("aria-selected","false"),r.length&&l.length?t.oldTab.attr("tabIndex",-1):r.length&&this.tabs.filter(function(){return 0===e(this).attr("tabIndex")}).attr("tabIndex",-1),r.attr({"aria-expanded":"true","aria-hidden":"false"}),t.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(n){var t,o=this._findActive(n);o[0]!==this.active[0]&&(o.length||(o=this.active),t=o.find(".ui-tabs-anchor")[0],this._eventHandler({target:t,currentTarget:t,preventDefault:e.noop}))},_findActive:function(n){return!1===n?e():this.tabs.eq(n)},_getIndex:function(e){return"string"==typeof e&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeUniqueId(),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var n=e(this),t=n.data("ui-tabs-aria-controls");t?n.attr("aria-controls",t).removeData("ui-tabs-aria-controls"):n.removeAttr("aria-controls")}),this.panels.show(),"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(t){var o=this.options.disabled;!1!==o&&(t===n?o=!1:(t=this._getIndex(t),o=e.isArray(o)?e.map(o,function(e){return e!==t?e:null}):e.map(this.tabs,function(e,n){return n!==t?n:null})),this._setupDisabled(o))},disable:function(t){var o=this.options.disabled;if(!0!==o){if(t===n)o=!0;else{if(t=this._getIndex(t),-1!==e.inArray(t,o))return;o=e.isArray(o)?e.merge([t],o).sort():[t]}this._setupDisabled(o)}},load:function(n,t){n=this._getIndex(n);var i=this,a=this.tabs.eq(n),r=a.find(".ui-tabs-anchor"),l=this._getPanelForTab(a),s={tab:a,panel:l};o(r[0])||(this.xhr=e.ajax(this._ajaxSettings(r,t,s)),this.xhr&&"canceled"!==this.xhr.statusText&&(a.addClass("ui-tabs-loading"),l.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){l.html(e),i._trigger("load",t,s)},1)}).complete(function(e,n){setTimeout(function(){"abort"===n&&i.panels.stop(!1,!0),a.removeClass("ui-tabs-loading"),l.removeAttr("aria-busy"),e===i.xhr&&delete i.xhr},1)})))},_ajaxSettings:function(n,t,o){var i=this;return{url:n.attr("href"),beforeSend:function(n,a){return i._trigger("beforeLoad",t,e.extend({jqXHR:n,ajaxSettings:a},o))}}},_getPanelForTab:function(n){var t=e(n).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+t))}})}(e),function(e,n){function t(e){i=e.originalEvent,s=i.accelerationIncludingGravity,a=Math.abs(s.x),r=Math.abs(s.y),l=Math.abs(s.z),!n.orientation&&(a>7||(l>6&&8>r||8>l&&r>6)&&a>5)?o.enabled&&o.disable():o.enabled||o.enable()}e.mobile.iosorientationfixEnabled=!0;var o,i,a,r,l,s,p=navigator.userAgent;/iPhone|iPad|iPod/.test(navigator.platform)&&/OS [1-5]_[0-9_]* like Mac OS X/i.test(p)&&p.indexOf("AppleWebKit")>-1?(o=e.mobile.zoom,e.mobile.document.on("mobileinit",function(){e.mobile.iosorientationfixEnabled&&e.mobile.window.bind("orientationchange.iosorientationfix",o.enable).bind("devicemotion.iosorientationfix",t)})):e.mobile.iosorientationfixEnabled=!1}(e,this),function(e,n){function o(){i.removeClass("ui-mobile-rendering")}var i=e("html"),a=e.mobile.window;e(n.document).trigger("mobileinit"),e.mobile.gradeA()&&(e.mobile.ajaxBlacklist&&(e.mobile.ajaxEnabled=!1),i.addClass("ui-mobile ui-mobile-rendering"),setTimeout(o,5e3),e.extend(e.mobile,{initializePage:function(){var n=e.mobile.path,i=e(":jqmData(role='page'), :jqmData(role='dialog')"),r=n.stripHash(n.stripQueryParams(n.parseLocation().hash));r&&r.length>0&&(h=t.getElementById(r)),i.length||(i=e("body").wrapInner("<div data-"+e.mobile.ns+"role='page'></div>").children(0)),i.each(function(){var n=e(this);n[0].getAttribute("data-"+e.mobile.ns+"url")||n.attr("data-"+e.mobile.ns+"url",n.attr("id")||location.pathname+location.search)}),e.mobile.firstPage=i.first(),e.mobile.pageContainer=e.mobile.firstPage.parent().addClass("ui-mobile-viewport").pagecontainer(),e.mobile.navreadyDeferred.resolve(),a.trigger("pagecontainercreate"),e.mobile.loading("show"),o(),e.mobile.hashListeningEnabled&&e.mobile.path.isHashValid(location.hash)&&(e(h).is(":jqmData(role='page')")||e.mobile.path.isPath(r)||r===e.mobile.dialogHashKey)?e.event.special.navigate.isPushStateEnabled()?(e.mobile.navigate.history.stack=[],e.mobile.navigate(e.mobile.path.isPath(location.hash)?location.hash:location.href)):a.trigger("hashchange",[!0]):(e.mobile.path.isHashValid(location.hash)&&(e.mobile.navigate.history.initialDst=r.replace("#","")),e.event.special.navigate.isPushStateEnabled()&&e.mobile.navigate.navigator.squash(n.parseLocation().href),e.mobile.changePage(e.mobile.firstPage,{transition:"none",reverse:!0,changeHash:!1,fromHashChange:!0}))}}),e(function(){e.support.inlineSVG(),e.mobile.hideUrlBar&&n.scrollTo(0,1),e.mobile.defaultHomeScroll=e.support.scrollTop&&1!==e.mobile.window.scrollTop()?1:0,e.mobile.autoInitializePage&&e.mobile.initializePage(),e.mobile.hideUrlBar&&a.load(e.mobile.silentScroll),e.support.cssPointerEvents||e.mobile.document.delegate(".ui-state-disabled,.ui-disabled","vclick",function(e){e.preventDefault(),e.stopImmediatePropagation()})}))}(e,this)}),webphone_api.webrtcapi=function(){function PutToDebugLogException(e,n,t){webphone_api&&webphone_api.common&&webphone_api.common.PutToDebugLogException&&"function"==typeof webphone_api.common.PutToDebugLogException?webphone_api.common.CanLog(e)&&webphone_api.common.PutToDebugLogException(e,n,t):console.error(n)}function PutToDebugLogExceptionWarning(e,n,t){webphone_api&&webphone_api.common&&webphone_api.common.PutToDebugLogWarning&&"function"==typeof webphone_api.common.PutToDebugLogWarning?webphone_api.common.CanLog(e)&&webphone_api.common.PutToDebugLogWarning(e,n,t):console.error(n)}function PutToDebugLog(e,n,t){webphone_api&&webphone_api.common&&webphone_api.common.PutToDebugLog&&"function"==typeof webphone_api.common.PutToDebugLog?webphone_api.common.CanLog(e)&&webphone_api.common.PutToDebugLog(e,n,t):console.log(n)}function JsObjecSniffer(e,n,t){if(void 0===e)return void console.log("josniffer obj is undefine");if(null===e)return void console.log("josniffer obj is NULL");console.log("=========== JsObjecSniffer ============="),void 0!==n&&null!==n||(n=0),-1===n&&(n=100);var o=e;for(var i in o){0===t?"function"!=typeof o[i]&&console.log("[josniffer] "+i+": "+o[i]):1===t?"function"==typeof o[i]&&console.log("[josniffer] "+i+": "+o[i]):console.log("[josniffer] "+i+": "+o[i]);var a="",r="",l="",s="",p="",c="",u="",g="",h="",m="",d="",b="",_="",f="",w="",v=null,E=null,P=null,T=null,S=null,N=null,I=null,C=null,G=null,L=null,R=null,y=null,D=null,O=null,x=null;if(null!==o&&"undefined"!=typeof o[i]&&null!==o[i]&&(v=o[i],n>0&&null!==v&&"object"==typeof v))for(var a in v)if(0===t?"function"!=typeof v[a]&&console.log("[josniffer] "+i+" - "+a+": "+v[a]):1===t?"function"==typeof v[a]&&console.log("[josniffer] "+i+" - "+a+": "+v[a]):console.log("[josniffer] "+i+" - "+a+": "+v[a]),null!==v&&"undefined"!=typeof v[a]&&null!==v[a]&&(E=v[a],n>1&&null!==E&&"object"==typeof E))for(var r in E)if(0===t?"function"!=typeof E[r]&&console.log("[josniffer] "+i+" - "+a+" - "+r+": "+E[r]):1===t?"function"==typeof E[r]&&console.log("[josniffer] "+i+" - "+a+" - "+r+": "+E[r]):console.log("[josniffer] "+i+" - "+a+" - "+r+": "+E[r]),null!==E&&"undefined"!=typeof E[r]&&null!==E[r]&&(P=E[r],n>2&&null!==P&&"object"==typeof P))for(var l in P)if(0===t?"function"!=typeof P[l]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+": "+P[l]):1===t?"function"==typeof P[l]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+": "+P[l]):console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+": "+P[l]),null!==P&&"undefined"!=typeof P[l]&&null!==P[l]&&(T=P[l],n>3&&null!==T&&"object"==typeof T))for(var s in T)if(0===t?"function"!=typeof T[s]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+": "+T[s]):1===t?"function"==typeof T[s]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+": "+T[s]):console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+": "+T[s]),null!==T&&"undefined"!=typeof T[s]&&null!==T[s]&&(S=T[s],n>4&&null!==S&&"object"==typeof S))for(var p in S)if(0===t?"function"!=typeof S[p]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+": "+S[p]):1===t?"function"==typeof S[p]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+": "+S[p]):console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+": "+S[p]),null!==S&&"undefined"!=typeof S[p]&&null!==S[p]&&(N=S[p],n>5&&null!==N&&"object"==typeof N))for(var c in N)if(0===t?"function"!=typeof N[c]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+": "+N[c]):1===t?"function"==typeof N[c]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+": "+N[c]):console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+": "+N[c]),null!==N&&"undefined"!=typeof N[c]&&null!==N[c]&&(I=N[c],n>6&&null!==I&&"object"==typeof I))for(var u in I)if(0===t?"function"!=typeof I[u]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+": "+I[u]):1===t?"function"==typeof I[u]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+": "+I[u]):console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+": "+I[u]),null!==I&&"undefined"!=typeof I[u]&&null!==I[u]&&(C=I[u],n>7&&null!==C&&"object"==typeof C))for(var g in C)if(0===t?"function"!=typeof C[g]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+": "+C[g]):1===t?"function"==typeof C[g]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+": "+C[g]):console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+": "+C[g]),null!==C&&"undefined"!=typeof C[g]&&null!==C[g]&&(G=C[g],n>8&&null!==G&&"object"==typeof G))for(var h in G)if(0===t?"function"!=typeof G[h]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+" - "+h+": "+G[h]):1===t?"function"==typeof G[h]&&console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+" - "+h+": "+G[h]):console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+" - "+h+": "+G[h]),null!==G&&"undefined"!=typeof G[h]&&null!==G[h]&&(L=G[h],n>9&&null!==L&&"object"==typeof L))for(var m in L)if(console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+" - "+h+" - "+m+": "+L[m]),null!==L&&"undefined"!=typeof L[m]&&null!==L[m]&&(R=L[m],n>10&&null!==R&&"object"==typeof R))for(var d in R)if(console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+" - "+h+" - "+m+" - "+d+": "+R[d]),null!==R&&"undefined"!=typeof R[d]&&null!==R[d]&&(y=R[d],n>11&&null!==y&&"object"==typeof y))for(var b in y)if(console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+" - "+h+" - "+m+" - "+d+" - "+b+": "+y[b]),null!==y&&"undefined"!=typeof y[b]&&null!==y[b]&&(D=y[b],n>12&&null!==D&&"object"==typeof D))for(var _ in D)if(console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+a+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+" - "+h+" - "+m+" - "+d+" - "+b+" - "+_+": "+D[_]),null!==D&&"undefined"!=typeof D[_]&&null!==D[_]&&(O=D[_],n>13&&null!==O&&"object"==typeof O))for(var f in O)if(console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+" - "+h+" - "+m+" - "+d+" - "+b+" - "+_+" - "+f+": "+O[f]),null!==O&&"undefined"!=typeof O[f]&&null!==O[f]&&(x=O[f],n>14&&null!==x&&"object"==typeof x))for(var w in x)console.log("[josniffer] "+i+" - "+a+" - "+r+" - "+l+" - "+s+" - "+p+" - "+c+" - "+u+" - "+g+" - "+h+" - "+m+" - "+d+" - "+b+" - "+_+" - "+f+" - "+w+": "+x[w])}console.log("=========== End JsObjecSniffer =============")}function WebRtcIsSupported(e){try{var n=document.getElementById("dtmfTone"),t=document.getElementById("justbeep_1");webphone_api.common.isNull(n)&&webphone_api.$(document.body).append('<audio id="dtmfTone" src="'+webphone_api.getbasedir2()+'sound/rtc_dtmf.wav" ></audio>'),webphone_api.common.isNull(t)&&webphone_api.$(document.body).append('<audio id="justbeep_1" src="'+webphone_api.getbasedir2()+'sound/beep-01.wav" ></audio>');var o=!1;window.WebSocket&&(o=!0);var i=!1;(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)&&(i=!0);var a=!1;return window.RTCPeerConnection&&(a=!0),!0===o&&!0===i&&!0===a&&(navigator.mediaDevices===undefined&&(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia===undefined&&(navigator.mediaDevices.getUserMedia=function(e){var n=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return n?new Promise(function(t,o){n.call(navigator,e,t,o)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))})),!0===o&&!0===i&&!0===a?("function"==typeof e&&e(!0),!0):(PutToDebugLog(2,"EVENT, WebRtcIsSupported: WebRTC not supported: wssuport: "+o+"; gumSupport: "+i+"; peerconSupport: "+a),"function"==typeof e&&e(!1),!1)}catch(r){PutToDebugLogException(2,"webrtcapi: WebRtcIsSupported",r);try{"function"==typeof e&&e(!1)}catch(r){}}return!1}function LoadScript(e,n,t){try{if(!n||"function"!=typeof n)return void PutToDebugLog(2,"ERROR, webrtcapi: LoadScript success callback NOT set");if(!t||"function"!=typeof t)return void PutToDebugLog(2,"ERROR, webrtcapi: LoadScript error callback NOT set");"undefined"!=typeof webphone_api.jscodeversion&&null!==webphone_api.jscodeversion&&webphone_api.jscodeversion.length>0&&e.indexOf("jscodeversion=")<0&&(e=e.indexOf("?")>0?e+"&jscodeversion="+webphone_api.jscodeversion.toString():e+"?jscodeversion="+webphone_api.jscodeversion.toString()),webphone_api.$.ajax({url:e,dataType:"script",method:"GET",timeout:45e3,success:n,error:t,async:!0})}catch(o){PutToDebugLogException(2,"webrtcapi: LoadScript",o)}}function LoadWebrtc(e,n,t){try{if(initcallback=e,!e||"function"!=typeof e)return void(webphone_api.common.CanLog(2)&&PutToDebugLog(2,"ERROR, webrtcapi: CheckIfSupported callback is NULL"));if(webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, webrtcapi: load webrtc script namespace: "+n+" account: "+t),wen_namespace=n,void 0!==t&&null!==t&&acc_arr.push(t),void 0!==n&&null!==n||"undefined"==typeof webphone_api.webrtcstack||null===webphone_api.webrtcstack||"undefined"==typeof webphone_api.webrtcstack.SIPml||null===webphone_api.webrtcstack.SIPml){var o=webphone_api.getbasedir2()+"js/lib/wen.js";void 0!==n&&null!==n&&n.length>1&&(webphone_api.common.isNull(webphone_api.wen_namespace_arr)&&(webphone_api.wen_namespace_arr=[]),webphone_api.common.isNull(webphone_api.wen_namespaces)&&(webphone_api.wen_namespaces=[]),webphone_api.wen_namespace_arr.push(n),webphone_api.wen_namespaces.push(n)),0==o.indexOf("file")?(webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT, Loading WebRTC engine by file script insert: "+o),webphone_api.LoadScriptFile(o,function(){var e=null;!webphone_api.common.isNull(acc_arr)&&acc_arr.length>0&&!webphone_api.common.isNull(acc_arr[0])&&(e=acc_arr.shift()),(webphone_api.common.isNull(acc_arr)||webphone_api.common.isNull(acc_arr).length<1)&&(acc_arr=[]),LoadWebrtcInner(initcallback,wen_namespace,e)},function(){webphone_api.common.CanLog(2)&&PutToDebugLog(2,"WARNING, LoadWebrtc: failed to load by file script. retry with ajax: "+o),LoadScript(o,function(){var e=null;!webphone_api.common.isNull(acc_arr)&&acc_arr.length>0&&!webphone_api.common.isNull(acc_arr[0])&&(e=acc_arr.shift()),(webphone_api.common.isNull(acc_arr)||webphone_api.common.isNull(acc_arr).length<1)&&(acc_arr=[]),LoadWebrtcInner(initcallback,wen_namespace,e)},function(e,n,t){webphone_api.common.isNull(n)&&(n="");var o="";void 0!==t&&null!==t&&("undefined"!=typeof t.message&&null!==t.message&&t.message.length>0&&(o=o+" ("+t.message+") "),"undefined"!=typeof t.fileName&&null!==t.fileName&&t.fileName.length>0&&(o=o+" class: "+t.fileName),"undefined"!=typeof t.lineNumber&&null!==t.lineNumber&&t.fileName.lineNumber>0&&(o=o+": "+t.lineNumber)),webphone_api.common.CanLog(2)&&PutToDebugLog(2,"WARNING, LoadWebrtc: failed to load script; status: "+n+"; trace: "+o+"; exception: "+t)})})):(webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT, Loading WebRTC engine script by ajax: "+o+" ("+wen_namespace+")"),LoadScript(o,function(){var e=null;!webphone_api.common.isNull(acc_arr)&&acc_arr.length>0&&!webphone_api.common.isNull(acc_arr[0])&&(e=acc_arr.shift()),(webphone_api.common.isNull(acc_arr)||webphone_api.common.isNull(acc_arr).length<1)&&(acc_arr=[]),LoadWebrtcInner(initcallback,wen_namespace,e)},function(e,n,t){webphone_api.common.isNull(n)&&(n="");var i="";void 0!==t&&null!==t&&("undefined"!=typeof t.message&&null!==t.message&&t.message.length>0&&(i=i+" ("+t.message+") "),"undefined"!=typeof t.fileName&&null!==t.fileName&&t.fileName.length>0&&(i=i+" class: "+t.fileName),"undefined"!=typeof t.lineNumber&&null!==t.lineNumber&&t.fileName.lineNumber>0&&(i=i+": "+t.lineNumber)),webphone_api.common.CanLog(2)&&PutToDebugLog(2,"WARNING, LoadWebrtc: failed to load script; status: "+n+"; trace: "+i+"; exception: "+t),webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT, retry Loading WebRTC engine by file script insert: "+o),webphone_api.LoadScriptFile(o,function(){var e=null;!webphone_api.common.isNull(acc_arr)&&acc_arr.length>0&&!webphone_api.common.isNull(acc_arr[0])&&(e=acc_arr.shift()),(webphone_api.common.isNull(acc_arr)||webphone_api.common.isNull(acc_arr).length<1)&&(acc_arr=[]),LoadWebrtcInner(initcallback,wen_namespace,e)})}))}else{var i=null;!webphone_api.common.isNull(acc_arr)&&acc_arr.length>0&&!webphone_api.common.isNull(acc_arr[0])&&(i=acc_arr.shift()),(webphone_api.common.isNull(acc_arr)||webphone_api.common.isNull(acc_arr).length<1)&&(acc_arr=[]),LoadWebrtcInner(e,wen_namespace,i)}}catch(a){PutToDebugLogException(2,"webrtcapi: LoadWebrtc",a),e(!1)}}function LoadWebrtcInner(e,n,t){try{if(void 0!==n&&null!==n||(n="webrtcstack"),"webrtcstack"===n){webphone_api.$(document.body).append('<audio id="audio_remote" autoplay="autoplay" ></audio>');var o=webphone_api.common.GetParameterInt("playring",2);o>0&&webphone_api.$(document.body).append('<audio id="ringtone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringtone.wav" onloadeddata="webphone_api.rt_loaded = true;" oncanplaythrough="webphone_api.rt_canplay = true;" ></audio>'),o>1&&webphone_api.$(document.body).append('<audio id="ringbacktone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringbacktone.wav" onloadeddata="webphone_api.rbt_loaded = true;" oncanplaythrough="webphone_api.rbt_canplay = true;" ></audio>'),webphone_api.$(document.body).append('<audio id="dtmfTone" src="'+webphone_api.getbasedir2()+'sound/rtc_dtmf.wav" ></audio>'),webphone_api.$(document.body).append('<audio id="justbeep_1" src="'+webphone_api.getbasedir2()+'sound/beep-01.wav" ></audio>'),PutToDebugLog(2,"EVENT, LoadWebrtc audio files loaded form url: "+webphone_api.getbasedir2()+"sound/"),AddVideoElemnts(!1),setTimeout(function(){if(AddVideoElemnts(!0),o>1){var e=document.getElementById("ringtone"),n=document.getElementById("ringbacktone");!webphone_api.common.isNull(e)&&!webphone_api.common.isNull(n)&&!0===webphone_api.rt_loaded&&!0===webphone_api.rt_canplay&&!0===webphone_api.rbt_loaded&&!0===webphone_api.rbt_canplay&&e.play&&n.play||(webphone_api.$(document.body).append('<audio id="audio_remote" autoplay="autoplay" ></audio>'),o>0&&webphone_api.$(document.body).append('<audio id="ringtone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringtone.wav" onloadeddata="webphone_api.rt_loaded = true;" oncanplaythrough="webphone_api.rt_canplay = true;" ></audio>'),o>1&&webphone_api.$(document.body).append('<audio id="ringbacktone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringbacktone.wav" onloadeddata="webphone_api.rbt_loaded = true;" oncanplaythrough="webphone_api.rbt_canplay = true;" ></audio>'),webphone_api.$(document.body).append('<audio id="dtmfTone" src="'+webphone_api.getbasedir2()+'sound/rtc_dtmf.wav" ></audio>'),webphone_api.$(document.body).append('<audio id="justbeep_1" src="'+webphone_api.getbasedir2()+'sound/beep-01.wav" ></audio>'),
PutToDebugLog(2,"EVENT, LoadWebrtc audio files loaded again after document ready form url: "+webphone_api.getbasedir2()+"sound/"))}else{var t=document.getElementById("audio_remote");webphone_api.common.isNull(t)&&(webphone_api.$(document.body).append('<audio id="audio_remote" autoplay="autoplay" ></audio>'),o>0&&webphone_api.$(document.body).append('<audio id="ringtone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringtone.wav" onloadeddata="webphone_api.rt_loaded = true;" oncanplaythrough="webphone_api.rt_canplay = true;" ></audio>'),o>1&&webphone_api.$(document.body).append('<audio id="ringbacktone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringbacktone.wav" onloadeddata="webphone_api.rbt_loaded = true;" oncanplaythrough="webphone_api.rbt_canplay = true;" ></audio>'),webphone_api.$(document.body).append('<audio id="dtmfTone" src="'+webphone_api.getbasedir2()+'sound/rtc_dtmf.wav" ></audio>'),webphone_api.$(document.body).append('<audio id="justbeep_1" src="'+webphone_api.getbasedir2()+'sound/beep-01.wav" ></audio>'),PutToDebugLog(2,"EVENT, LoadWebrtc audio files loaded again after document ready form url: "+webphone_api.getbasedir2()+"sound/"))}},5e3),document.onkeyup=onKeyUp,document.body.onkeyup=onKeyUp}var i="error";webphone_api.common.GetLogLevel()>1&&(i="info"),webphone_api[n].SIPml.setDebugLevel(i);var a=function(e){for(var n=window.location.search.substring(1),t=n.split("&"),o=0;o<t.length;o++){var i=t[o].split("=");if(decodeURIComponent(i[0])===e)return decodeURIComponent(i[1])}return null},r=function(){var o=a("wt"),i=a("fps"),r=a("mvs"),l=a("mbwu"),s=a("mbwd"),p=a("za"),c=a("ndb");if(webphone_api[n].SIPml.isInitialized())return void e(!0,n,t);o&&webphone_api[n].SIPml.setWebRtcType(o),"webrtcstack"===n&&"undefined"!=typeof webphone_api.webrtcstack&&null!==webphone_api.webrtcstack?webphone_api.webrtcstack.SIPml.init(CheckIfSupported,function(o){PutToDebugLogException(2,"webrtc: preinit SIPml.init",o),PutToDebugLog(2,"EVENT, WebRTC CheckIfSupported false (10)"),e(!1,n,t)}):webphone_api[n].SIPml.init(CheckIfSupported,function(o){PutToDebugLogException(2,"webrtc: preinit SIPml.init",o),PutToDebugLog(2,"EVENT, WebRTC CheckIfSupported false (10)"),e(!1,n,t)}),i&&webphone_api[n].SIPml.setFps(parseFloat(i)),r&&webphone_api[n].SIPml.setMaxVideoSize(r),l&&webphone_api[n].SIPml.setMaxBandwidthUp(parseFloat(l)),s&&webphone_api[n].SIPml.setMaxBandwidthDown(parseFloat(s)),p&&webphone_api[n].SIPml.setZeroArtifacts("true"===p),"true"==c&&webphone_api[n].SIPml.startNativeDebug()};webphone_api.common.isNull(oReadyStateTimer)||clearInterval(oReadyStateTimer);var l=(webphone_api.common.GetTickCount(),0);oReadyStateTimer=setInterval(function(){l++,webphone_api.common.GetTickCount()-webphone_api.loadwebrtc_timestamp>25e3&&"Edge"===webphone_api.common.GetBrowser()&&(PutToDebugLog(2,"ERROR, reload webphone because window.onload, document.readyState did not fire after 11 sec"),console.log("ERROR, reload webphone because window.onload, document.readyState did not fire after 11 sec"),window.location.reload()),"complete"!==document.readyState&&!0!==webphone_api.document_loaded||(clearInterval(oReadyStateTimer),r())},50)}catch(s){PutToDebugLogException(2,"webrtcapi: LoadWebrtc inner",s),e(!1,n,t)}}function CheckIfSupported(){function e(e){try{var n="";!webphone_api.common.isNull(lw_namespace_arr)&&lw_namespace_arr.length>0&&(n=lw_namespace_arr.shift());var t=null;!webphone_api.common.isNull(lw_account_arr)&&lw_account_arr.length>0&&(t=lw_account_arr.shift()),!webphone_api.common.isNull(n)&&n.indexOf("webrtcstack")>=0&&"webrtcstack"!==n?LoadWebrtcCb(e,n,t):webphone_api.common.isNull(initcallback)||initcallback(e)}catch(o){return PutToDebugLog(2,"EVENT, WebRTC CheckIfSupported HandleCallback false (4)"),PutToDebugLogException(2,"webrtcapi: CheckIfSupported HandleCallback",o),webphone_api.common.isNull(initcallback)||initcallback(!1),!1}}try{return webphone_api.webrtcstack.SIPml.isWebRtcSupported()?(5,webphone_api.webrtcstack.SIPml.isWebSocketSupported()?(10,viewVideoLocal=videoLocal,viewVideoRemote=videoRemote,11,webphone_api.webrtcstack.SIPml.isWebRtcSupported()?(16,postInit(),17,e(!0),20,!0):(12,PutToDebugLog(2,"EVENT, WebRTC CheckIfSupported false (3)"),e(!1),15,!1)):(6,PutToDebugLog(2,"EVENT, WebRTC CheckIfSupported false (2)"),e(!1),9,!1)):(1,PutToDebugLog(2,"EVENT, WebRTC CheckIfSupported false (1)"),e(!1),4,!1)}catch(n){return e(!1),!1}}function postInit(){try{if(isregistered=!1,webphone_api.common.isNull(audioRemote)){var e=webphone_api.common.GetParameterInt("playring",2);webphone_api.$(document.body).append('<audio id="audio_remote" autoplay="autoplay" ></audio>'),e>0&&webphone_api.$(document.body).append('<audio id="ringtone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringtone.wav" onloadeddata="webphone_api.rt_loaded = true;" oncanplaythrough="webphone_api.rt_canplay = true;" ></audio>'),e>1&&webphone_api.$(document.body).append('<audio id="ringbacktone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringbacktone.wav" onloadeddata="webphone_api.rbt_loaded = true;" oncanplaythrough="webphone_api.rbt_canplay = true;" ></audio>'),webphone_api.$(document.body).append('<audio id="dtmfTone" src="'+webphone_api.getbasedir2()+'sound/rtc_dtmf.wav" ></audio>'),webphone_api.$(document.body).append('<audio id="justbeep_1" src="'+webphone_api.getbasedir2()+'sound/beep-01.wav" ></audio>'),audioRemote=document.getElementById("audio_remote"),divVideo=document.getElementById("div_video"),videoLocal=document.getElementById("video_local"),videoRemote=document.getElementById("video_remote"),webphone_api.common.isNull(audioRemote)&&PutToDebugLog(2,"ERROR, Cannot find audio_remote html element (incoming audio will not work without this element!!)")}callsipheaders=RemoveDuplicateHeader(callsipheaders),oConfigCall={audio_remote:audioRemote,video_local:viewVideoLocal,video_remote:viewVideoRemote,screencast_window_id:0,bandwidth:{audio:0,video:undefined},video_size:null,events_listener:{events:"*",listener:onSipEventSession},sip_caps:[],sip_headers:callsipheaders},oConfigMessage={events_listener:{events:"*",listener:onSipEventSession}},oConfigSms={events_listener:{events:"*",listener:onSipEventSession}}}catch(n){PutToDebugLogException(2,"webrtcapi: postInit",n)}}function SetSipHeader(e,n){try{var t=webphone_api.common.IsMizuServerOrGateway(),o=webphone_api.common.GetParameter("customsipheader");if(!webphone_api.common.isNull(o)&&o.length>0){var i=null;if(o.indexOf("\r\n")>0?i=o.split("\r\n"):o.indexOf("\n")>0?i=o.split("\n"):o.indexOf("\r")>0?i=o.split("\r"):o.indexOf("CRLF")>0?i=o.split("CRLF"):o.indexOf(";")>0?i=o.split(";"):o.indexOf(",")>0?i=o.split(","):o.indexOf("LF")>0?i=o.split("LF"):o.indexOf("CR")>0&&(i=o.split("CR")),!webphone_api.common.isNull(i)&&i.length>0)for(var a=0;a<i.length;a++)if(!(webphone_api.common.isNull(i[a])||webphone_api.common.Trim(i[a]).length<1||i[a].indexOf(":")<1)){var r=webphone_api.common.Trim(i[a].substring(0,i[a].indexOf(":"))),l=webphone_api.common.Trim(i[a].substring(i[a].indexOf(":")+1,i[a].length));webphone_api.common.isNull(r)||r.length<1||(webphone_api.common.isNull(l)&&(l=""),!0===t&&0!==r.indexOf("X-")&&(r="X-R-"+r),AddSipHeader(sipheaders,r,l),AddSipHeader(callsipheaders,r,l))}}if(webphone_api.common.isNull(n))return;n=webphone_api.common.Trim(n);var s;if(s=n.indexOf(";")>0?n.split(";"):n.indexOf("\r\n")>0?n.split("\r\n"):n.split("\n"),webphone_api.common.isNull(s)||s.length<1)return;if(!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)&&-1!==e||(e=webphone_api.common.GetBestLine()),n.length<1)if(-2===e||!1===webphone_api.global.checkIfInCall){for(var a=0;a<sipheaders.length;a++){var p=sipheaders[a].name;"User-Agent"!==p&&"Organization"!==p&&p.indexOf("Webdomain")<0&&"P-Sms"!==p&&"X-Sms"!==p&&"Sy.Uppersrv"!==p&&"X-Sy.Uppersrv"!==p&&"Sy.Upperproxy"!==p&&"X-Sy.Upperproxy"!==p&&"X-IMStatus"!==p&&"X-P2P"!==p&&"X-P2PM"!==p&&"X-AUSR"!==p&&"X-Sy.Uppersrvd"!==p&&(sipheaders.splice(a,1),a--)}oSipSessionRegister&&(sipheaders=RemoveDuplicateHeader(sipheaders),oSipSessionRegister.setConfiguration({sip_headers:sipheaders}));for(var a=0;a<webphone_api.global.ep.length;a++)try{var c=webphone_api.global.ep[a][webphone_api.common.EP_SIPHEADERS];if(webphone_api.common.isNull(c)||c.length<1)continue;for(var u=0;u<c.length;u++){var p=c[u].name;"User-Agent"!==p&&"Organization"!==p&&p.indexOf("Webdomain")<0&&"P-Sms"!==p&&"X-Sms"!==p&&"Sy.Uppersrv"!==p&&"X-Sy.Uppersrv"!==p&&"Sy.Upperproxy"!==p&&"X-Sy.Upperproxy"!==p&&"X-IMStatus"!==p&&"X-P2P"!==p&&"X-P2PM"!==p&&"X-AUSR"!==p&&"X-Sy.Uppersrvd"!==p&&(c.splice(u,1),u--)}webphone_api.global.ep[a][webphone_api.common.EP_SIPHEADERS]=c;var g=webphone_api.global.ep[a][webphone_api.common.EP_SESSION];webphone_api.common.isNull(g)||(c=RemoveDuplicateHeader(c),g.setConfiguration({sip_headers:c}))}catch(_){PutToDebugLogException(2,"webrtcapi: SetSipHeader remove from callseesions",_)}}else if(e>0){for(var h=-1,a=0;a<webphone_api.global.ep.length;a++){var m=webphone_api.global.ep[webphone_api.common.EP_LINE];if(m===e){h=a;break}}if(h>-1){var c=webphone_api.global.ep[h][webphone_api.common.EP_SIPHEADERS];if(!webphone_api.common.isNull(c)&&c.length>0){for(var u=0;u<c.length;u++){var p=c[u].name;"User-Agent"!==p&&"Organization"!==p&&p.indexOf("Webdomain")<0&&"P-Sms"!==p&&"X-Sms"!==p&&"Sy.Uppersrv"!==p&&"X-Sy.Uppersrv"!==p&&"Sy.Upperproxy"!==p&&"X-Sy.Upperproxy"!==p&&"X-IMStatus"!==p&&"X-P2P"!==p&&"X-P2PM"!==p&&"X-AUSR"!==p&&"X-Sy.Uppersrvd"!==p&&(c.splice(u,1),u--)}webphone_api.global.ep[h][webphone_api.common.EP_SIPHEADERS]=c;var g=webphone_api.global.ep[h][webphone_api.common.EP_SESSION];webphone_api.common.isNull(g)||(c=RemoveDuplicateHeader(c),g.setConfiguration({sip_headers:c}))}}}for(var a=0;a<s.length;a++)if(!(webphone_api.common.isNull(s[a])||s[a].indexOf(":")<1)){var r=s[a].substring(0,s[a].indexOf(":")),d=s[a].substring(s[a].indexOf(":")+1);if(webphone_api.common.isNull(d)&&(d=""),!0===t&&0!==r.indexOf("X-")&&(r="X-R-"+r),-2===e||!1===webphone_api.global.checkIfInCall){AddSipHeader(sipheaders,r,d),oSipSessionRegister&&(sipheaders=RemoveDuplicateHeader(sipheaders),oSipSessionRegister.setConfiguration({sip_headers:sipheaders}));for(var u=0;u<webphone_api.global.ep.length;u++)try{var c=webphone_api.global.ep[u][webphone_api.common.EP_SIPHEADERS];if(webphone_api.common.isNull(c)||c.length<1)continue;AddSipHeader(c,r,d),webphone_api.global.ep[u][webphone_api.common.EP_SIPHEADERS]=c;var g=webphone_api.global.ep[u][webphone_api.common.EP_SESSION];webphone_api.common.isNull(g)||(c=RemoveDuplicateHeader(c),g.setConfiguration({sip_headers:c}))}catch(_){PutToDebugLogException(2,"webrtcapi: SetSipHeader add OR remove from callseesions",_)}AddSipHeader(callsipheaders,r,d)}else if(e>0){for(var h=-1,b=0;b<webphone_api.global.ep.length;b++){var m=webphone_api.global.ep[webphone_api.common.EP_LINE];if(m===e){h=b;break}}if(h>-1){var c=webphone_api.global.ep[h][webphone_api.common.EP_SIPHEADERS];if(!webphone_api.common.isNull(c)&&c.length>0){AddSipHeader(c,r,d),webphone_api.global.ep[h][webphone_api.common.EP_SIPHEADERS]=c;var g=webphone_api.global.ep[h][webphone_api.common.EP_SESSION];webphone_api.common.isNull(g)||(c=RemoveDuplicateHeader(c),g.setConfiguration({sip_headers:c}))}}}}}catch(_){PutToDebugLogException(2,"webrtcapi: SetSipHeader",_)}}function AddSipHeader(e,n,t){try{if(webphone_api.common.isNull(e)&&(e=[]),webphone_api.common.isNull(n)||n.length<1)return;webphone_api.common.isNull(t)&&(t=""),PutToDebugLog(4,"EVENT, AddSipHeader: "+n+": "+t);for(var o=n.toLowerCase(),i=!1,a=0;a<e.length;a++){var r=e[a].name;if(!(webphone_api.common.isNull(r)||r.length<1)&&(r=r.toLowerCase(),o===r)){"User-Agent"!==n&&"Organization"!==n&&n.indexOf("Webdomain")<0&&"P-Sms"!==n&&"X-Sms"!==n&&"Sy.Uppersrv"!==n&&"X-Sy.Uppersrv"!==n&&"Sy.Upperproxy"!==n&&"X-Sy.Upperproxy"!==n&&"X-P2P"!==n&&"X-P2PM"!==n&&"X-AUSR"!==n&&"X-Sy.Uppersrvd"!==n&&(n.length<1?e[a].splice(a,1):e[a].value=t),i=!0;break}}!1===i&&n.length>0&&(e[e.length]={},e[e.length-1].name=n,e[e.length-1].value=t),e=RemoveDuplicateHeader(e)}catch(l){PutToDebugLogException(2,"webrtcapi: AddSipHeader",l)}}function RemoveDuplicateHeader(e){try{var n=[];if(webphone_api.common.isNull(e)||e.length<1)return e;for(var t=e.length-1;t>=0;t--)if(!webphone_api.common.isNull(e[t])){for(var o=!1,i=0;i<n.length;i++)if(n[i].name===e[t].name){o=!0;break}!1===o&&n.push(e[t])}if(!webphone_api.common.isNull(n))return n}catch(a){PutToDebugLogException(2,"webrtcapi: RemoveDuplicateHeader",a)}return e}function ReStart(e,n){try{if(webphone_api.common.isNull(te2)&&(te2=webphone_api.common.Te2()),te2)return;if(webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT, webrtcapi restart flag: "+webphone_api.flagrestartwebrtc.toString()),!1===webphone_api.flagrestartwebrtc)return;if(webphone_api.global.checkIfInCall&&(webphone_api.global.checkIfInCall=!1,webphone_api.global.hadStartMediaPending=!1,PutToDebugLog(1,"STATUS,-1,Call Finished")),!0===n)return PutToDebugLog(2,"EVENT, restarting webrtc sipstack: forced"),restartdelay=2e3,webphone_api.common.CallWsuserKeepAlive(!0),void Start();var t=webphone_api.common.GetTickCount();if(!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)&&(restartdelay=webphone_api.common.StrToInt(e)),t<=lastrestarttick+restartdelay)return;t-lastrestarttick>8e5&&restartdelay>2e3&&(restartdelay=2e3),t>lastrestarttick+restartdelay&&t-lastrestarttick<512e3&&(restartdelay*=2),lastrestarttick=t;var o=new Date(lastrestarttick),i=o.getHours(),a=o.getMinutes(),r=o.getSeconds();a<10&&(a="0"+a),r<10&&(r="0"+r),restarttimestr=i+":"+a+":"+r,setTimeout(function(){PutToDebugLog(2,"EVENT, restarting webrtc sipstack: "+restarttimestr),webphone_api.common.CallWsuserKeepAlive(!0),Start()},restartdelay)}catch(l){PutToDebugLogException(2,"webrtcapi: ReStart",l)}}function Start(){try{LoadWebrtc(function(e){webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT, webrtcapi: LoadWebrtc returned: "+e),StartInner()})}catch(e){PutToDebugLogException(2,"webrtcapi: Start",e)}}function StartInner(){if(!webphone_api.global.pgw_decide_finished&&webphone_api.global.waitingforusukdecide>0){webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, wait for gw detect before webrtcapi start");var e=0,n=setInterval(function(){e++,(webphone_api.global.pgw_decide_finished||webphone_api.global.waitingforusukdecide<=0||e>20||e>10&&webphone_api.common.GetSelectedGwIdx()>=0)&&(webphone_api.common.CanLog(5)&&(webphone_api.global.pgw_decide_finished?PutToDebugLog(5,"EVENT, wait for gw detect terminated on finished "+e.toString()+"/"+webphone_api.common.GetSelectedGwIdx().toString()+"/"+webphone_api.global.pgw_selected.toString()+"/"+webphone_api.global.waitingforusukdecide.toString()):webphone_api.global.waitingforusukdecide<=0?PutToDebugLog(5,"EVENT, wait for gw detect terminated on nomorewait "+e.toString()+"/"+webphone_api.common.GetSelectedGwIdx().toString()+"/"+webphone_api.global.pgw_selected.toString()+"/"+webphone_api.global.waitingforusukdecide.toString()):webphone_api.global.pgw_selected>=0?PutToDebugLog(5,"EVENT, wait for gw detect terminated on first found "+e.toString()+"/"+webphone_api.common.GetSelectedGwIdx().toString()+"/"+webphone_api.global.pgw_selected.toString()+"/"+webphone_api.global.waitingforusukdecide.toString()):PutToDebugLog(5,"EVENT, wait for gw detect terminated on timeout "+e.toString()+"/"+webphone_api.global.pgw_selected.toString()+"/"+webphone_api.common.GetSelectedGwIdx().toString()+"/"+webphone_api.global.waitingforusukdecide.toString())),clearInterval(n),StartInnerInner())},100)}else StartInnerInner()}function StartInnerInner(){var lastopp=0;try{lastopp=1,webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT, webrtcapi start "+webphone_api.global.pgw_decide_finished.toString()+"/"+webphone_api.global.waitingforusukdecide.toString()),webphone_api.flagrestartwebrtc=!0,webphone_api.global.sipstackstarted=!0,webphone_api.websocketstopped=!1,lastopp=2,extraregsessions=[],StartGetDevices();var ismizuserverorgw=webphone_api.common.IsMizuServerOrGateway();webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT, mlogic API_Setvolume on WebRTC start "+ismizuserverorgw),webphone_api.setvolume(1,webphone_api.common.GetParameter("volumeout"));var chsptr=webphone_api.common.GetParameter2("changesptoring");(webphone_api.common.isNull(chsptr)||chsptr.length<1||!1===webphone_api.common.IsNumber(chsptr))&&(chsptr=2),changesptoring=webphone_api.common.StrToInt(chsptr);var remonco=webphone_api.common.GetParameter2("recheckmediaonconnect");(webphone_api.common.isNull(remonco)||remonco.length<1||!1===webphone_api.common.IsNumber(remonco))&&(remonco=2),recheckmediaonconnect=webphone_api.common.StrToInt(remonco),(recheckmediaonconnect<0||recheckmediaonconnect>3)&&(recheckmediaonconnect=2),webphone_api.global.autoacceptsipheader=webphone_api.common.GetParameter("autoacceptsipheader"),webphone_api.global.nextcallid=webphone_api.common.GetParameter("nextcallid"),!webphone_api.common.isNull(webphone_api.global.nextcallid)&&webphone_api.global.nextcallid.length>0&&webphone_api.common.SaveParameter("nextcallid","");var sipusername=webphone_api.common.GetSipusername(),password=webphone_api.common.GetParameter("password"),callerid=webphone_api.common.GetCallerid();(webphone_api.common.isNull(callerid)||webphone_api.common.Trim(callerid).length<1)&&(callerid=sipusername),lastopp=3;var udpaddr=webphone_api.common.GetUDPServerAddress(),wsaddr=webphone_api.common.GetWebrtcSrvAddr(),displayname=webphone_api.common.GetParameter("displayname");(webphone_api.common.isNull(displayname)||displayname.length<1)&&webphone_api.common.GetUsernamePart(sipusername)!==callerid&&(displayname=sipusername),!0===webphone_api.common.GetParameterBool("hidemyidentity",!1)&&(displayname=""),2===webphone_api.common.GetConfigInt("usemizuwebrtcgateway",1)&&(wsaddr=""),lastopp=4,webphone_api.common.isNull(wsaddr)||wsaddr.length<2?(wsaddr=webphone_api.common.GetWp(),!webphone_api.common.isNull(wsaddr)&&wsaddr.length>0&&(wsaddr.indexOf("//")>=0&&(wsaddr=wsaddr.substring(wsaddr.indexOf("//")+2)),wsaddr.indexOf(":")>0&&(wsaddr=wsaddr.substring(0,wsaddr.indexOf(":"))))):wsaddr=webphone_api.common.Trim(wsaddr.toLowerCase()),lastopp=5,wsaddr=wsaddr.replace("*",""),wsaddr=wsaddr.toLowerCase(),wsaddr=wsaddr.replace("udp://",""),wsaddr=wsaddr.replace("tcp://",""),wsaddr=wsaddr.replace("http://",""),wsaddr=wsaddr.replace("https://","");var sipaddress=udpaddr;sipaddress.indexOf("udp:")<0&&(sipaddress="udp://"+sipaddress);var proxyaddress=webphone_api.common.GetProxyaddress();if(webphone_api.common.isNull(proxyaddress)&&(proxyaddress=""),!0===ismizuserverorgw&&proxyaddress.length<1&&(proxyaddress=sipaddress),lastopp=6,proxyaddress=webphone_api.common.GetProxyaddress(proxyaddress),proxyaddress.length>0)if(ismizuserverorgw)proxyaddress="udp://"+proxyaddress;else{var transport=webphone_api.common.GetParameterInt("transport",0),transpStr="udp";1===transport?transpStr="tcp":2===transport&&(transpStr="tls"),transpStr.indexOf(":")<0&&(transpStr+="://"),proxyaddress=transpStr+proxyaddress}lastopp=7;var wsaddress=wsaddr;wsaddress.indexOf("ws:")<0&&wsaddress.indexOf("wss:")<0&&(wsaddress="ws://"+wsaddress);var hostmp=location.host.toLowerCase();if(!1!==webphone_api.common.IsIPAddrress(wsaddress)&&!0!==webphone_api.common.BrowserRequiresHttps(!0)||(wsaddress=wsaddress.replace("ws:","wss:")),!1===webphone_api.global.pgw_decide_finished){var gwidx=webphone_api.common.PGW_GetGwIndex(wsaddress);if(gwidx>=0){webphone_api.global.pgw_decide_finished=!0,webphone_api.global.pgw_selected=gwidx;var selsrv=webphone_api.common.GetWsAddressCfg();!webphone_api.common.isNull(selsrv)&&selsrv.length>0&&webphone_api.common.SaveParameter("lastwebrtcserver",selsrv),webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, decidegw select finished on start ("+gwidx.toString()+") "+selsrv+" / "+wsaddr),webphone_api.common.OnDecideUsUkFinished()}}lastopp=8;var publicsipaddress=webphone_api.common.GetConfig("publicsipaddress");webphone_api.common.isNull(publicsipaddress)&&(publicsipaddress=""),publicsipaddress.length>0&&webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT, WebRTC publicsipaddress is set to: "+publicsipaddress);var realm=publicsipaddress;realm.length<2&&(realm=webphone_api.common.GetParameter("realm"),(webphone_api.common.isNull(realm)||realm.length<2)&&(realm=udpaddr)),realm=webphone_api.common.NormalizeInput(realm,0),realm.indexOf(":")>0&&(realm=realm.substring(0,realm.indexOf(":"))),realm=webphone_api.common.Trim(realm),webphone_api.global.mRealm=realm,lastopp=9;var sipuri=callerid;if(sipuri.indexOf("sip:")<0&&(sipuri="sip:"+callerid),sipuri.indexOf("@")<0)if(sipuri+="@",publicsipaddress.length>1)sipuri+=publicsipaddress;else if(realm.indexOf(".")>0||sipaddress.length<1)sipuri+=realm;else{var tmpsrv=sipaddress;tmpsrv=webphone_api.common.NormalizeInput(tmpsrv,0),tmpsrv.indexOf(":")>0&&(tmpsrv=tmpsrv.substring(0,tmpsrv.indexOf(":"))),tmpsrv.indexOf("/")>0&&(tmpsrv=tmpsrv.substring(0,tmpsrv.indexOf("/"))),sipuri+=tmpsrv}if(lastopp=10,!webphone_api.common.isNull(sipuri)&&sipuri.indexOf("@")>0&&webphone_api.common.IsMizuReallyPublicWebRTCGatewayAddress(wsaddr)){var addrtmp=sipuri.substr(sipuri.indexOf("@")+1);if(!webphone_api.common.isNull(addrtmp)&&(addrtmp.indexOf(":")>0&&(addrtmp=addrtmp.substring(0,addrtmp.indexOf(":"))),!webphone_api.common.isNull(addrtmp)&&addrtmp.length>0&&1==webphone_api.common.IsLanIPEx(addrtmp)&&webphone_api.common.GetWsAddressCfg(2).length<2))return PutToDebugLog(3,"ERROR, "+webphone_api.stringres.get("webrtc_local_sipserver")+" (2) "+addrtmp),PutToDebugLog(1,"ERROR, "+webphone_api.stringres.get("webrtc_local_sipserver")),(!0===webphone_api.global.usestorage||webphone_api.common.Strl(60))&&alert("ERROR, "+webphone_api.stringres.get("webrtc_local_sipserver")+"\n\n"+webphone_api.stringres.get("all_demo_msg")+" (2)"),!1}lastopp=11;var enableRTCWebBreaker=!0;enableRTCWebBreaker=!(!webphone_api.common.isNull(webphone_api.parameters.rtcbreaker)&&0===webphone_api.parameters.rtcbreaker)&&(!webphone_api.common.isNull(webphone_api.parameters.rtcbreaker)&&1===webphone_api.parameters.rtcbreaker||!ismizuserverorgw),lastopp=12;var organization=webphone_api.common.GetConfig("companyname");(webphone_api.common.isNull(organization)||organization.length<1)&&(organization=webphone_api.common.GetConfig("brandname"),(webphone_api.common.isNull(organization)||organization.length<1)&&(organization="Mizutech"));var ua=webphone_api.common.GetUA();!webphone_api.common.isNull(webphone_api.common.GetParameter("useragent"))&&webphone_api.common.GetParameter("useragent").length>0&&!1===webphone_api.common.IsMizuReallyPublicWebRTCGateway()&&(ua=webphone_api.common.GetParameter("useragent")),lastopp=13,sipheaders=[{name:"User-Agent",value:ua},{name:"Organization",value:organization},{name:"X-Webdomain",value:webphone_api.common.GetWebdomain()}];var xhval="1";!0===webphone_api.common.Hasesw()?xhval="2":!0===webphone_api.common.Us()&&(xhval="0"),sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-LS",sipheaders[sipheaders.length-1].value=xhval,SetSipHeader(0),sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-UT",sipheaders[sipheaders.length-1].value="r";var company=webphone_api.common.GetParameter("companyname");!webphone_api.common.isNull(company)&&company.length>0&&(sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-Company",sipheaders[sipheaders.length-1].value=company);var brand=webphone_api.common.GetParameter("brandname");!webphone_api.common.isNull(brand)&&brand.length>0&&(sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-Brand",sipheaders[sipheaders.length-1].value=brand);var uppsrv=webphone_api.common.GetWebrtcSyUpperHeader("start");uppsrv.length>0&&(sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-Sy.Uppersrv",sipheaders[sipheaders.length-1].value=uppsrv);var uppsrvd=webphone_api.common.GetWebrtcSyUpperDomainHeader("start");uppsrvd.length>0&&(sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-Sy.Uppersrvd",sipheaders[sipheaders.length-1].value=uppsrvd);var dtmfmode=webphone_api.common.GetParameterInt("dtmfmode",2);4==dtmfmode&&ismizuserverorgw&&(sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-MFlag",sipheaders[sipheaders.length-1].value="2"),webphone_api.global.addauser_header=!1,ismizuserverorgw&&!webphone_api.common.isNull(sipusername)&&sipusername.length>0&&!webphone_api.common.isNull(callerid)&&callerid.length>0&&sipusername!==callerid&&(webphone_api.global.addauser_header=!0,sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-AUSR",sipheaders[sipheaders.length-1].value=sipusername);var prxy=webphone_api.common.GetUpperProxyHeaderForSignaling();!webphone_api.common.isNull(prxy)&&prxy.length>0&&(sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-Sy.Upperproxy",sipheaders[sipheaders.length-1].value=prxy),ismizuserverorgw&&!0===webphone_api.common.UsePresence2()&&(sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-IMStatus",sipheaders[sipheaders.length-1].value="Online");var p2psignaling=webphone_api.common.GetParameterInt("p2psignaling",1);if(ismizuserverorgw&&1!==p2psignaling){var valTmp="unknown";0===p2psignaling?valTmp="no":2===p2psignaling?valTmp="proxy":3===p2psignaling&&(valTmp="process"),sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-P2P",sipheaders[sipheaders.length-1].value=valTmp}var use_fast_ice=webphone_api.common.GetParameterInt("use_fast_ice",1);ismizuserverorgw&&-1===use_fast_ice&&(sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-P2PM",sipheaders[sipheaders.length-1].value="1"),sipheaders=RemoveDuplicateHeader(sipheaders),lastopp=14;var loglevel="error";webphone_api.common.GetLogLevel()>1&&(loglevel="info"),webphone_api.webrtcstack.SIPml.setDebugLevel(loglevel),window.webkitNotifications&&0!=window.webkitNotifications.checkPermission()&&window.webkitNotifications.requestPermission(),(webphone_api.common.isNull(sipusername)||sipusername.length<1)&&(PutToDebugLog(2,"ERROR, WebRTC invalid username: "+sipusername),PutToDebugLog(1,"ERROR, Invalid username")),(webphone_api.common.isNull(password)||password.length<1)&&(PutToDebugLog(2,"ERROR, WebRTC invalid password: "+password),PutToDebugLog(1,"ERROR, Invalid password")),(webphone_api.common.isNull(sipuri)||sipuri.length<1)&&PutToDebugLog(2,"ERROR, WebRTC invalid sipuri: "+sipuri),lastopp=15;var stun_turn=[],stun=webphone_api.common.GetStunServersStr(),turn=webphone_api.common.GetTurnSrv();if(!webphone_api.common.isNull(stun)&&stun.length>2){var sarr=stun.split(","),useurls=!1;if(("Chrome"===webphone_api.common.GetBrowser()&&webphone_api.common.GetBrowserVersion()>40||"Firefox"===webphone_api.common.GetBrowser()&&webphone_api.common.GetBrowserVersion()>40)&&(useurls=!0),!webphone_api.common.isNull(sarr))for(var i=0;i<sarr.length;i++)if(!(webphone_api.common.isNull(sarr[i])||sarr[i].length<1))if(!0===useurls){var obj={urls:sarr[i]};stun_turn.push(obj)}else{var obj={url:sarr[i]};stun_turn.push(obj)}}lastopp=16,webphone_api.common.isNull(turn)||webphone_api.common.IsLocalServer()||stun_turn.push(turn),lastopp=17;var ldebug=!1;(webphone_api.common.GetLogLevel()>=7||!0===webphone_api.global.isdebugversion&&webphone_api.common.GetLogLevel()>=5)&&(ldebug=!0);var logparams={};if(!webphone_api.common.isNull(webphone_api.global.settmap2)){lastopp=1701;var val;for(var key in webphone_api.global.settmap2)if(!(webphone_api.common.isNull(key)||key.length<1)){var value=webphone_api.global.settmap2[key];webphone_api.common.isNull(value)||value.length<1||(ldebug||"mclientid"!==key&&"wstestservers"!==key)&&(key.indexOf("server")<0&&key.indexOf("username")<0&&key.indexOf("password")<0&&"1"===value[webphone_api.common.SETT_ISDEFAULT]||"-1"===value[webphone_api.common.SETT_ISDEFAULT]&&(key.indexOf("transfer")>=0||key.indexOf("refer")>=0||key.indexOf("allowreplace")>=0)||(val=value[webphone_api.common.SETT_VALUE],webphone_api.common.isNull(val)||(val=val.toString(),lastopp=1702,!ldebug&&val.length<1||(!ldebug&&(key.indexOf("password")>=0||"extraregisteraccounts"===key)?logparams[key]="*":!ldebug&&(0==key.indexOf("pgw")||val.indexOf("com.mizuvoip.mizudroid")>=0||val.indexOf("app/mizuphone")>=0||key.indexOf("transfwithreplace")>=0&&"-1"==val||key.indexOf("domaintoip_cache")>=0||"get"==key||"getAll"==key)||(logparams[key]=val)))))}lastopp=18;var extraoption=webphone_api.common.GetParameter("extraoption");if(!webphone_api.common.isNull(extraoption)&&extraoption.length>0){extraoption=webphone_api.common.Trim(extraoption);var optionlist=extraoption.split(";");if(!webphone_api.common.isNull(optionlist)&&optionlist.length>0)for(var i=0;i<optionlist.length;i++)if(!(webphone_api.common.isNull(optionlist[i])||optionlist[i].length<1||optionlist[i].indexOf("=")<1)){var key=webphone_api.common.Trim(optionlist[i].substring(0,optionlist[i].indexOf("="))),value=webphone_api.common.Trim(optionlist[i].substring(optionlist[i].indexOf("=")+1));!webphone_api.common.isNull(key)&&key.length>0&&!webphone_api.common.isNull(value)&&(logparams[key]=value)}}}if(lastopp=19,webphone_api.common.IsCExt()>0&&(webphone_api.global.add_recall_header=!0),webphone_api.common.CanLog(4)&&webphone_api.common.LogAllParameters("WebRTC all parameters (just informative):",logparams),webphone_api.common.CanLog(3)){lastopp=1901;var log="";log=log+" sipusername: "+sipusername,webphone_api.common.GetLogLevel()>=7||!0===webphone_api.global.isdebugversion&&webphone_api.common.GetLogLevel()>=5?log=log+", password: "+password:!webphone_api.common.isNull(password)&&password.length>0?log+=" password: *":log+=", password: null",log=log+", sipuri: "+sipuri,log=log+", displayname: "+displayname,log=log+", wsaddress: "+wsaddress,log=log+", proxyaddress: "+proxyaddress,log=log+", realm: "+realm,PutToDebugLog(3,"EVENT, Webrtc connection details: "+log)}if(lastopp=20,webphone_api.common.pgw_selected<0&&webphone_api.common.GetWsAddressCfg(2).length<2){var gwidx=webphone_api.common.PGW_GetGwIndex(wsaddress);gwidx>=0&&(webphone_api.common.CanLog(2)&&PutToDebugLog(2,"WARNING, decidegw webrtcapi Start manually setting pgateway from: "+webphone_api.global.pgw_selected.toString()+" to: "+gwidx.toString()+", because has not yet selected a"),webphone_api.global.pgw_selected=gwidx)}if(mSipuri=sipuri,mDisplayname=displayname,!webphone_api.common.isNull(stun_turn)&&stun_turn.length>0){for(var i=0;i<stun_turn.length;i++)if(!webphone_api.common.isNull(stun_turn[i])){var sobj=stun_turn[i];for(var key in sobj){var msgtmp="turn server";!webphone_api.common.isNull(sobj[key])&&sobj[key].toString().indexOf("stun")>=0&&(msgtmp="stun server"),PutToDebugLog(3,msgtmp+"["+i+"]: "+key+": "+sobj[key])}}}else webphone_api.common.CanLog(3)&&PutToDebugLog(3,"stun server: NOT set");lastopp=21;var iceobj=null,icestr=webphone_api.common.GetParameter("ice");if(!webphone_api.common.isNull(icestr)&&icestr.length>0)try{iceobj=eval(icestr)}catch(eice){iceobj=null,PutToDebugLogException(2,"ERROR, webrtcapi parse ICE servers: "+icestr,eice)}if(!webphone_api.common.isNull(iceobj)){try{PutToDebugLog(2,"EVENT, webrtcapi found ICE (STUN/TURN) server: "+JSON.stringify(iceobj))}catch(eice2){}stun_turn=iceobj}var earlymediaint=webphone_api.common.GetParameterInt("earlymedia",2),earlymedia=!0;earlymediaint<1&&(earlymedia=!1),webphone_api.common.isNull(te2)&&(te2=webphone_api.common.Te2()),te2&&(stun_turn=null),webphone_api.webrtcMicVolume=GetVolume(0)/100,webphone_api.global.minten=!1,lastopp=22;try{sipheaders=RemoveDuplicateHeader(sipheaders),PutToDebugLog(5,"EVENT, create new SIP stack"),oSipStack=new webphone_api.webrtcstack.SIPml.Stack({realm:realm,impi:sipusername,impu:sipuri,password:password,display_name:displayname,websocket_proxy_url:wsaddress,outbound_proxy_url:proxyaddress,ice_servers:stun_turn,enable_rtcweb_breaker:enableRTCWebBreaker,events_listener:{events:"*",
listener:onSipEventStack},enable_early_ims:earlymedia,enable_media_stream_cache:!0,bandwidth:null,video_size:null,sip_headers:sipheaders})}catch(err_reg){var reason="";webphone_api.common.isNull(err_reg)||(reason=err_reg.toString()),!webphone_api.common.isNull(reason)&&reason.indexOf("is not valid as SIP Uri")>=0&&(reason=webphone_api.common.NormalizeInput2(sipusername,1)!==sipusername?"invalid SIP Uri because username contains special characters: "+sipusername:"invalid serveraddress: "+realm),!webphone_api.common.isNull(reason)&&reason.length>0&&(lastregfailreason=reason,PutToDebugLog(1,"ERROR, Register failed: "+reason));try{webphone_api.onRegStateChangeCb("failed",reason)}catch(errin){PutToDebugLogException(2,"webrtcapi: Start: There is an error in onRegisterFailed(failed) callback",errin)}try{webphone_api.onRegisterFailedCb(reason)}catch(errin){PutToDebugLogException(2,"webrtcapi: Start: There is an error in onRegisterFailed() callback",errin)}PutToDebugLogException(2,"webrtcapi: Start failed to create SIPstack",err_reg)}return lastopp=23,webphone_api.common.GetParameterInt("forcereregister",1)>1&&StartReRegister(!0),webphone_api.global.webrtc_regstate=0,webphone_api.common.CallWsuserKeepAlive(!1),setTimeout(function(){lastopp=24;try{if(lastopp=2501,!webphone_api.common.isNull(webphone_api.global.sipaccounts)&&webphone_api.global.sipaccounts.length>1){lastopp=2502;for(var e=0;e<webphone_api.global.sipaccounts.length;e++)if("true"!==webphone_api.global.sipaccounts[e].ismain.toString()){var n=webphone_api.global.sipaccounts[e],t=n.password;!webphone_api.common.isNull(t)&&(t.indexOf(";")>=0||t.indexOf(",")>=0||t.indexOf("#")>=0)&&0!=t.indexOf("_BASE64_")&&(t="_BASE64_"+webphone_api.common.B64Enc(t));var o=n.serveraddress,i=n.username,a=n.ival.toString(),r=n.callerid,l=n.displayname,s=n.proxyaddress,p=n.realm;o.indexOf(";")>=0&&(o=o.replace(";","")),o.indexOf(",")>=0&&(o=o.replace(",","")),o.indexOf("#")>=0&&(o=o.replace("#","")),i.indexOf(";")>=0&&(i=i.replace(";","")),i.indexOf(",")>=0&&(i=i.replace(",","")),i.indexOf("#")>=0&&(i=i.replace("#","")),a.indexOf(";")>=0&&(a=a.replace(";","")),a.indexOf(",")>=0&&(a=a.replace(",","")),a.indexOf("#")>=0&&(a=a.replace("#","")),r.indexOf(";")>=0&&(r=r.replace(";","")),r.indexOf(",")>=0&&(r=r.replace(",","")),r.indexOf("#")>=0&&(r=r.replace("#","")),l.indexOf(";")>=0&&(l=l.replace(";"," ")),l.indexOf(",")>=0&&(l=l.replace(","," ")),l.indexOf("#")>=0&&(l=l.replace("#"," ")),s.indexOf(";")>=0&&(s=s.replace(";","")),s.indexOf(",")>=0&&(s=s.replace(",","")),s.indexOf("#")>=0&&(s=s.replace("#","")),p.indexOf(";")>=0&&(p=p.replace(";","")),p.indexOf(",")>=0&&(p=p.replace(",","")),p.indexOf("#")>=0&&(p=p.replace("#","")),lastopp=2503;var c=o+","+i+","+t+","+a+","+r+","+l+","+s+","+p;lastopp=2504,RegisterEx(c),lastopp=2505}}lastopp=2506;var u=webphone_api.common.GetExtraRegAccFromAPIparam();if(lastopp=2507,!webphone_api.common.isNull(u)&&u.length>5){lastopp=2508;var g=[];if(g=u.indexOf("#")>=0?u.split("#"):u.split(";"),lastopp=2509,!webphone_api.common.isNull(g)&&g.length>0){lastopp=2510;for(var e=0;e<g.length;e++)webphone_api.common.isNull(g[e])||g[e].length<5||(lastopp=2511,RegisterEx(g[e]))}}}catch(h){PutToDebugLogException(2,"webrtcapi: StartInnerInner "+lastopp,h)}},2500),lastopp=25,webphone_api.common.isNull(oSipStack)?(PutToDebugLog(2,"ERROR, webrtcapi: Start, Failed to create the SIP stack"),!1):0!=oSipStack.start()?(PutToDebugLog(2,"ERROR, webrtcapi: Start, Failed to start the SIP stack"),!1):(setTimeout(function(){webphone_api.global.phonestarted<2&&(webphone_api.global.phonestarted=2)},500),!0)}catch(err){PutToDebugLogException(2,"webrtcapi: StartInner "+lastopp,err)}return!1}function SipUnRegister(e){var n=!1;try{if(!1===webphone_api.common.GetParameterBool("needunregister",!0))return webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT,webrtc skip unregister (check: "+e.toString()+")"),!0;webphone_api.common.isNull(e)&&(e=!1),webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT,webrtc unregister (check: "+e.toString()+")");var t=!0;e&&!1===webphone_api.isregistered()&&(t=!1),oSipSessionRegister&&t&&(oSipSessionRegister.unregister(),n=!0,setTimeout(function(){PutToDebugLog(1,"STATUS,-1,Unregistered")},100));try{if(!webphone_api.common.isNull(extraregsessions)&&extraregsessions.length>0){webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT,webrtc unregister extra accounts (count: "+extraregsessions.length.toString()+")");for(var o=0;o<extraregsessions.length;o++)if(!webphone_api.common.isNull(extraregsessions[o])&&extraregsessions[o])try{extraregsessions[o].unregister(),n=!0}catch(i){PutToDebugLogExceptionWarning(5,"webrtcapi: SipStopExtra",i)}}}catch(i){PutToDebugLogExceptionWarning(5,"webrtcapi: SipStopExtraEx",i)}extraregsessions=[]}catch(i){PutToDebugLogException(2,"webrtcapi: SipUnRegister",i)}return n}function SipStop(e){var n=!1;try{if(webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT,SipStack Stopping from "+e),SipUnRegister(!0),webphone_api.websocketstopped=!0,oSipStack)try{oSipStack.stop(),n=!0,webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT,SipStack Stopped from "+e)}catch(o){PutToDebugLogException(2,"webrtcapi: SipStop innerX",o)}try{if(!webphone_api.common.isNull(registerExSipstackArray)&&registerExSipstackArray.length>0)for(var t=0;t<registerExSipstackArray.length;t++)if(!webphone_api.common.isNull(registerExSipstackArray[t])&&registerExSipstackArray[t]&&registerExSipstackArray[t].stop)try{registerExSipstackArray[t].stop()}catch(o){PutToDebugLogExceptionWarning(5,"webrtcapi: SipStopExtra",o)}}catch(o){PutToDebugLogExceptionWarning(5,"webrtcapi: SipStopExtraEx",o)}if(oSipStack)return setTimeout(function(){try{!webphone_api.common.isNull(webphone_api.webrtcstack)&&webphone_api.webrtcstack.WsDisconnect()&&webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT,SipStack DestroyedA")}catch(o){PutToDebugLogException(2,"webrtcapi: SipStop innerA",o)}try{!webphone_api.common.isNull(webphone_api[wen_namespace])&&webphone_api[wen_namespace].WsDisconnect()&&webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT,SipStack DestroyedB")}catch(o){}if(!webphone_api.common.isNull(webphone_api.wen_namespaces)&&webphone_api.wen_namespaces.length>0)try{for(var e=0;e<webphone_api.wen_namespaces.length;e++)webphone_api[webphone_api.wen_namespaces[e]].WsDisconnect()&&webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT,SipStack DestroyedC")}catch(o){PutToDebugLogException(2,"webrtcapi: SipStop innerC",o)}try{"undefined"!=typeof webphone_api.webrtc_socket&&null!==webphone_api.webrtc_socket&&(0!=webphone_api.webrtc_socket.readyState&&1!=webphone_api.webrtc_socket.readyState||(webphone_api.webrtc_socket.close(),webphone_api.common.CanLog(2)&&PutToDebugLog(2,"EVENT,SipStack DestroyedD")),webphone_api.webrtc_socket=null)}catch(o){PutToDebugLogException(2,"webrtcapi: SipStop innerD",o)}},500),!0;uiVideoDisplayEvent(1,!0,!1,!0),uiVideoDisplayEvent(2,!1,!1,!0)}catch(o){PutToDebugLogException(2,"webrtcapi: SipStop",o)}try{registerExSipstackArray=[],extraregsessions=[],webphone_api.common.isNull(webphone_api.wen_namespaces)||(webphone_api.wen_namespaces=[]),webphone_api.common.isNull(webphone_api.wen_namespace_arr)||(webphone_api.wen_namespace_arr=[])}catch(o){}return n}function HandleOconfigCall(e,n){try{var t=e;return!0===webphone_api.isincall()&&webphone_api.common.isNull(document.getElementById("audio_remote_"+n))&&webphone_api.$(document.body).append('<audio id="audio_remote_'+n+'" autoplay="autoplay" ></audio>'),webphone_api.common.isNull(document.getElementById("audio_remote_"+n))?oConfigCall.audio_remote=audioRemote:oConfigCall.audio_remote=document.getElementById("audio_remote_"+n),t}catch(o){PutToDebugLogException(2,"webrtcapi: HandleOconfigCall",o)}return e}function RemoveUnusedAudioElements(){try{for(var e=1;e<15;e++)webphone_api.$("#audio_remote_"+e).remove()}catch(n){PutToDebugLogException(2,"webrtcapi: RemoveUnusedAudioElements",n)}}function SipCall(e,n,t,o){try{if(!oSipStack&&!1===sipstackstarted)return PutToDebugLog(2,"WRTC, ERROR, webrtcapi: SipCall sipstack not started"),PutToDebugLog(1,"ERROR, Reconnecting, try to call again"),PutToDebugLog(1,"EVENT, POPUP, Reconnecting, try to call again"),ReStart(1500),sipstackstarted=!0,setTimeout(function(){SipCall(e,n,t)},2500),!1;if(webphone_api.common.isNull(t)||t.length<1)return PutToDebugLog(2,"WRTC, ERROR, webrtcapi: SipCall number is NULL"),!1;webphone_api.global.rtcincallinit_outgoing=!0,setTimeout(function(){!1===webphone_api.global.webrtcpermissionaccepted&&(PutToDebugLog(2,"ERROR, no permission for outgoing call"),webphone_api.common.AlertDialog(webphone_api.stringres.get("request_permission2_title"),webphone_api.common.ReplaceAll(webphone_api.stringres.get("request_permission2"),"[BRANDNAME]",webphone_api.common.GetBrandName())))},7e3),oConfigCall.bandwidth=undefined,oConfigCall.video_size=undefined;var i=webphone_api.common.GetVideoBandwidth(),a=webphone_api.common.GetAudioBandwidth();if(oConfigCall.bandwidth={audio:a,video:i},"call-audiovideo"===e||"call-screenshare"===e){var r=document.getElementById("video_container");webphone_api.common.isNull(r)&&(PutToDebugLog(2,"ERROR, VideoCall cannot find video container"),(!0===webphone_api.global.usestorage||webphone_api.common.Strl(60))&&webphone_api.common.ShowToast('ERROR, For the video to work, you must add a DIV html element to your page with id="video_container"',1e4)),PutToDebugLog(2,"EVENT, webrtcapi: video bandwidth: "+i),"call-audiovideo"===e&&(oConfigCall.video_size=GetVideoSizeObj()),PutToDebugLog(1,"STATUS,-1,Starting video call to "+t)}else PutToDebugLog(2,"EVENT, webrtcapi: audio bandwidth: "+a),PutToDebugLog(1,"STATUS,-1,Starting call to "+t);if(SetSipHeader(1),!1===webphone_api.global.wsuser_succeded?webphone_api.common.IsMizuServerOrGateway()&&(webphone_api.common.CallWsuserKeepAlive(!0),PutToDebugLog(3,"WARNING, wsuser NOT YET succeeded")):(webphone_api.common.CallWsuserKeepAlive(!1),PutToDebugLog(3,"EVENT, wsuser already succeeded")),webphone_api.common.isNull(o)||!0!==o)try{var l=webphone_api.common.GetEndpoint(1029,n,"","","",!1);if(!webphone_api.common.isNull(l)&&l.length>2&&"false"===l[webphone_api.common.EP_FLAGDEL]){for(var s=webphone_api.common.StrToInt(n)+1,p=0;p<90;p++)l=webphone_api.common.GetEndpoint(1029,s,"","","",!1),!webphone_api.common.isNull(l)&&l.length>2&&"false"===l[webphone_api.common.EP_FLAGDEL]&&(s+=1);PutToDebugLog(2,"EVENT, (warn) webrtc: call to: "+t+" line set to: "+s.toString()+" because we already have a call on line: "+n.toString()),n=s,webphone_api.common.LogLines()}}catch(m){PutToDebugLogException(2,"webrtcapi: detect multiple call on same line",m)}else;var c=webphone_api.common.GetParameter("sel_rtc_audio_out");!webphone_api.common.isNull(c)&&c.length>0&&SetAudioDevice(1,c),calltype=e,callline=n,destnumber=t,webphone_api.global.needholdreinvite=0,oSipSessionCall=oSipStack.newSession(e,HandleOconfigCall(oConfigCall,n)),sipstackstarted=!1;var u=webphone_api.common.GetTickCount();if(0!=oSipSessionCall.call(t,HandleOconfigCall(oConfigCall,n)))return oSipSessionCall=null,PutToDebugLog(2,"WRTC, ERROR, Failed to make call"),webphone_api.global.stacknotstarted_time>0&&u-webphone_api.global.stacknotstarted_time<300&&!0===webphone_api.global.stacknotstarted_retry&&(webphone_api.global.stacknotstarted_retry=!1,setTimeout(function(){PutToDebugLog(2,"WRTC, WARNING, Retry failed webrtc call (Stack not started)"),SipCall(e,n,t)},2500)),webphone_api.global.rtcincallinit_outgoing=!1,!1;webphone_api.global.checkIfInCall=!0,PutToDebugLog(1,"STATUS,-1,Call");var g=1;webphone_api.common.isNull(o)||!0!==o||(g=111),webphone_api.common.SaveCallSession(g,n,oSipSessionCall,t,"1",webphone_api.common.GetTickCount(),-1,-1,"","","","",oConfigCall.sip_headers,"","","",oSipSessionCall.getId()),setTimeout(function(){if(!1===webphone_api.common.Awb()){var e=[];e.push("h"),e.push("a"),e.push("n"),e.push("g"),e.push("u"),e.push("p"),e.push(" "),e.push("c"),e.push("a"),e.push("l"),e.push("l"),e.push(" "),e.push("w"),e.push("e"),e.push("b"),e.push("s"),e.push("r"),e.push("v"),e.push("8");PutToDebugLog(2,"EVENT, "+e.join(""));try{webphone_api.common.GetCallSession(1,!0,n,t).hangup({events_listener:{events:"*",listener:onSipEventSession}})}catch(o){PutToDebugLogException(2,"webrtcapi: callsession a",o)}setTimeout(function(){webphone_api.common.GetEndpoint(102,n,"","","",!0)},400)}},15e3),setTimeout(function(){if(!1===webphone_api.common.Loa()){var e=[];e.push("h"),e.push("a"),e.push("n"),e.push("g"),e.push("u"),e.push("p"),e.push(" "),e.push("c"),e.push("a"),e.push("l"),e.push("l"),e.push(" "),e.push("o"),e.push("n"),e.push("l"),e.push("y"),e.push(" "),e.push("a"),e.push("n"),e.push("d"),e.push("r"),e.push("o"),e.push("i"),e.push("d");var o=e.join("");setTimeout(function(){PutToDebugLog(2,"ERROR, "+o)},1200),setTimeout(function(){try{webphone_api.common.GetCallSession(2,!0,n,t).hangup({events_listener:{events:"*",listener:onSipEventSession}})}catch(e){PutToDebugLogException(2,"webrtcapi: callsession b",e)}},1300),setTimeout(function(){webphone_api.common.GetEndpoint(103,n,"","","",!0)},1700)}},6e3);var h=webphone_api.common.GetIceTimeout()+4500;return!webphone_api.common.isNull(e)&&e.indexOf("video")>0&&(h+=4e3),1===webphone_api.common.GetParameterInt("redialonfail",0)&&(red_line=n,red_sessioncall=oSipSessionCall,red_number=t,red_setuptime=webphone_api.common.GetTickCount(),red_callid=oSipSessionCall.getId(),red_headers=oConfigCall.sip_headers,red_delaytime=h,red_s_type=e),webphone_api.global.rtcincallinit_outgoing=!1,!0}catch(d){PutToDebugLogException(2,"webrtcapi: SipCall",d)}return webphone_api.global.rtcincallinit_outgoing=!1,!1}function RedialOnFail(){try{if(!1===webphone_api.global.redialof)return;redialonfailtimer=setTimeout(function(){try{if(!0===webphone_api.global.redialof){var e=!1;if("Firefox"===webphone_api.common.GetBrowser()){webphone_api.common.GetParameterInt("webrtc_successfulcalls",0)<3&&(e=!0)}!1===webphone_api.global.webrtcpermissionaccepted?(PutToDebugLog(2,"ERROR, initiate outgoing call, but permission not yet accepted"),webphone_api.common.ShowToast(webphone_api.stringres.get("request_permission"),12e3)):(PutToDebugLog(2,"EVENT, webrtcapi, RedialOnFail: "+red_number+"; delay after first attempt: "+red_delaytime.toString()),webphone_api.global.redialof=!1,webphone_api.global.redialhideevt=!0,webphone_api.common.isNull(red_sessioncall)?(PutToDebugLog(2,"EVENT, webrtcapi, RedialOnFail: create new session"),red_sessioncall=oSipStack.newSession(red_s_type,oConfigCall)):(PutToDebugLog(2,"EVENT, webrtcapi, RedialOnFail: hangup previous call"),!0===e?webphone_api.hangup(!0):red_sessioncall.hangup()),setTimeout(function(){PutToDebugLog(2,"EVENT, webrtcapi, RedialOnFail: initiate call again (redial)"),!0===e?webphone_api.call(red_number):red_sessioncall.call(red_number),webphone_api.common.SaveCallSession(2,red_line,red_sessioncall,red_number,"1",red_setuptime,-1,-1,"","","","",red_headers,"","","",red_callid)},1e3))}}catch(n){PutToDebugLogException(2,"webrtcapi: RedialOnFail",n)}},red_delaytime),setTimeout(function(){webphone_api.global.redialhideevt=!1,webphone_api.common.isNull(redialonfailtimer)||clearTimeout(redialonfailtimer),redialonfailtimer=null,red_line=null,red_sessioncall=null,red_number=null,red_setuptime=0,red_callid=null,red_headers=null,red_delaytime=5e3,red_s_type="call-audio"},red_delaytime+2e3)}catch(e){PutToDebugLogException(2,"webrtcapi: RedialOnFail",e)}}function SipHangup(e,n,t,o){var i=0;try{if(webphone_api.global.redialof=!1,webphone_api.global.redialhideevt=!1,webphone_api.global.rtcincallinit_incoming=0,i=1,webphone_api.common.isNull(redialonfailtimer)||clearTimeout(redialonfailtimer),i=2,redialonfailtimer=null,oldtrack=null,settrack=null,i=3,PutToDebugLog(5,"EVENT, webrtc hangup line "+n+" "+webphone_api.global.aline+" "+e),webphone_api.common.isNull(o)&&(o=webphone_api.common.GetCallSession(3,!0,n,"","",null,null,null,t)),i=4,setTimeout(function(){webphone_api.common.GetEndpoint(104,n,"","","",!0)},400),i=5,o||!oSipStack){try{i=6,1===webphone_api.common.GetApibehaviour()&&PutToDebugLog(1,"STATUS,-1,Hangup"),i=7,e&&(i=8,PutToDebugLog(1,"EVENT,Rejected")),i=9,!webphone_api.global.removemultilinestream&&oSipStack&&n>0&&webphone_api.common.GetNrOfActiveCalls()>1&&(i=20,webphone_api.dont_remove_remote_stream=!0,i=21,PutToDebugLog(2,"EVENT, on hangup dont_remove_remote_stream set to true on multi-line"),i=22,setTimeout(function(){webphone_api.dont_remove_remote_stream=!1,PutToDebugLog(2,"EVENT, (warn) after hangup reset dont_remove_remote_stream on multi-line")},300)),i=23}catch(a){PutToDebugLogException(2,"webrtcapi: SipHangup inner ("+i.toString()+")",a)}return i=24,o&&o.hangup({events_listener:{events:"*",listener:onSipEventSession}}),i=25,!0}PutToDebugLog(2,"EVENT, no session to hangup "+n+" "+webphone_api.global.aline+" "+e)}catch(a){PutToDebugLogException(2,"webrtcapi: SipHangup ("+i.toString()+")",a)}return!1}function SipAccept(e,n,t){var o=0;try{if(o=1,webphone_api.global.rtcincallinit_incoming=webphone_api.common.GetTickCount(),webphone_api.common.CanLog(5)&&(webphone_api.common.isNull(e)?PutToDebugLog(5,"EVENT,WebRTC accepting..."):PutToDebugLog(5,"EVENT,WebRTC accepting ("+e.toString()+")...")),webphone_api.common.isNull(t)&&(webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT,WebRTC get session"),t=webphone_api.common.GetCallSession(4,!1,e,"","",null,"2")),o=2,t){o=3;var i=webphone_api.common.GetEndpoint(105,e,"","",t.getId(),!1);if(!webphone_api.common.isNull(i)&&i.length>5){o=4;var a=i[webphone_api.common.EP_CONNECTTIME];if(webphone_api.common.isNull(a)&&(a=-1),(a=webphone_api.common.StrToIntDef(a,-1))>0){o=5,webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT,WebRTC try to change from already connected ep");for(var r=0;r<webphone_api.global.ep.length;r++)if(i=webphone_api.global.ep[r],!webphone_api.common.isNull(i)){var l=i[webphone_api.common.EP_INCOMING];webphone_api.common.isNull(l)&&(l=1);var s=i[webphone_api.common.EP_SETUPTIME];webphone_api.common.isNull(s)&&(s=-1);var p=i[webphone_api.common.EP_CONNECTTIME];if(webphone_api.common.isNull(p)&&(p=-1),2===webphone_api.common.StrToIntDef(l,1)&&webphone_api.common.StrToIntDef(s,-1)>0&&webphone_api.common.StrToIntDef(p,1)<0&&!webphone_api.common.isNull(webphone_api.common.GetCallSession(5,!1,webphone_api.common.StrToInt(i[webphone_api.common.EP_LINE]),""))){o=101,PutToDebugLog(2,"EVENT, API_Accept: call is already connected on line: "+e+"; incoming call found to be accepted on line: "+i[webphone_api.common.EP_LINE]),e=webphone_api.common.StrToInt(i[webphone_api.common.EP_LINE]),t=webphone_api.common.GetCallSession(6,!1,e,"");break}}}else{o=102;var l=i[webphone_api.common.EP_INCOMING];webphone_api.common.isNull(l)&&(l=1);var s=i[webphone_api.common.EP_SETUPTIME];webphone_api.common.isNull(s)&&(s=-1);var p=i[webphone_api.common.EP_CONNECTTIME];if(webphone_api.common.isNull(p)&&(p=-1),2===webphone_api.common.StrToIntDef(l,1)&&webphone_api.common.StrToIntDef(s,-1)>0&&webphone_api.common.StrToIntDef(p,1)<0&&(o=103,!webphone_api.common.isNull(webphone_api.common.GetCallSession(5,!1,webphone_api.common.StrToInt(i[webphone_api.common.EP_LINE]),"")))){o=104;var c=webphone_api.common.StrToInt(i[webphone_api.common.EP_LINE]);c>0&&e!=c&&(webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT,WebRTC accepting line changed from "+e.toString()+" to "+c.toString()),e=c)}}}else webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT,WebRTC accepting cannot find ep");try{o=6;var u=webphone_api.common.GetTickCount()-webphone_api.global.ringstart_time,g=!1;if(1===recheckmediaonconnect&&u>14e3&&webphone_api.common.IsMizuServerOrGateway()?(PutToDebugLog(2,"EVENT, webrtcapi SipAccept recheckmediaonconnect_1: "+u),g=!0):2===recheckmediaonconnect&&u>14e3?(PutToDebugLog(2,"EVENT, webrtcapi SipAccept recheckmediaonconnect_2: "+u),g=!0):3===recheckmediaonconnect&&(PutToDebugLog(2,"EVENT, webrtcapi SipAccept recheckmediaonconnect_3"),g=!0),g){o=7;var h=null;if(o=71,void 0!==wen_namespace&&null!==wen_namespace||(wen_namespace="webrtcstack"),o=72,webphone_api.common.isNull(webphone_api[wen_namespace])||(h=webphone_api[wen_namespace].SIPml.getsavethis()),o=73,webphone_api.common.isNull(h)&&!webphone_api.common.isNull(webphone_api.webrtcstack)&&(h=webphone_api.webrtcstack.SIPml.getsavethis()),o=8,webphone_api.common.isNull(h))PutToDebugLog(2,"EVENT, webrtcapi SipAccept recheckmediaonconnect no savethis");else try{o=9;var m=!1;if(!m)try{o=93,webphone_api.common.isNull(webphone_api[wen_namespace])||webphone_api.common.isNull(webphone_api[wen_namespace].tmedia_session_jsep01)||(o=94,webphone_api[wen_namespace].tmedia_session_jsep01.prototype.__get_lo.call(h,!0),m=!0,PutToDebugLog(5,"EVENT, webrtcapi SipAccept recheckmediaonconnect done B"))}catch(b){PutToDebugLogExceptionWarning(2,"webrtcapi: SipAccept longringinB ("+o.toString()+")",b)}if(!m)try{o=95,webphone_api.common.isNull(webphone_api.webrtcstack)||webphone_api.common.isNull(webphone_api.webrtcstack.tmedia_session_jsep01)||(o=96,webphone_api.webrtcstack.tmedia_session_jsep01.prototype.__get_lo.call(h,!0),m=!0,PutToDebugLog(5,"EVENT, webrtcapi SipAccept recheckmediaonconnect done C"))}catch(b){PutToDebugLogExceptionWarning(2,"webrtcapi: SipAccept longringinB ("+o.toString()+")",b)}if(!m)try{o=91,webphone_api.common.isNull(tmedia_session_jsep01)||(o=92,tmedia_session_jsep01.prototype.__get_lo.call(h,!0),m=!0,PutToDebugLog(5,"EVENT, webrtcapi SipAccept recheckmediaonconnect done A"))}catch(b){PutToDebugLogExceptionWarning(2,"webrtcapi: SipAccept longringinA ("+o.toString()+")",b)}m||PutToDebugLog(2,"EVENT, webrtcapi SipAccept recheckmediaonconnect no tmedia_session_jsep01")}catch(_){PutToDebugLogExceptionWarning(2,"webrtcapi: SipAccept longringA ("+o.toString()+")",_)}}}catch(f){PutToDebugLogException(2,"webrtcapi: SipAccept longringB ("+o.toString()+")",f)}if(o=20,(webphone_api.common.isNull(e)||!webphone_api.common.IsNumber(e)||e<1)&&(e=webphone_api.common.GetBestLine()),o=110,webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT,WebRTC accepting b ("+e.toString()+" "+t.getId().toString()+")..."),webphone_api.global.ice_callaccepted=!0,o=111,CheckPendingStartMedia(),SetSipHeader(e),o=112,t.accept(HandleOconfigCall(oConfigCall,e)),PutToDebugLog(1,"EVENT,Accepted"),!1!==n){o=21;var d=webphone_api.common.GetParameterInt("beeponconnect",0);1!==d&&2!==d&&4!==d||webphone_api.common.Beep("1")}return webphone_api.global.rtcincallinit_incoming=0,!0}o=22,PutToDebugLog(2,"ERROR,webrtcapi session is NULL"),webphone_api.common.LogLines(),PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_nocallinprogress2"))}catch(w){PutToDebugLogException(2,"webrtcapi: SipAccept ("+o.toString()+")",w)}return webphone_api.global.rtcincallinit_incoming=0,!1}function SipIgnore(){try{webphone_api.global.rtcincallinit_incoming=0,stopRingTone()}catch(e){PutToDebugLogException(2,"webrtcapi: SipIgnore",e)}return!1}function SipSendChat(e,n,t,o){try{if(!oSipStack)return PutToDebugLog(2,"WRTC, ERROR, webrtcapi: SipSendChat sipstack not started"),!1;if(webphone_api.common.isNull(n)||n.length<1)return PutToDebugLog(2,"WRTC, ERROR, webrtcapi: SipSendChat number is NULL"),!1;if(webphone_api.common.isNull(t)||t.length<1)return PutToDebugLog(2,"WRTC, ERROR, webrtcapi: SipSendChat message is NULL"),!1;if(!0===o){var i=sipheaders.slice();i[i.length]={},i[i.length-1].name="X-Sms",i[i.length-1].value="Yes",i=RemoveDuplicateHeader(i),oSipSessionMessage=oSipStack.newSession("message",oConfigSms),oSipSessionMessage.setConfiguration({sip_headers:i})}else{var a=sipheaders.slice();a=RemoveDuplicateHeader(a),oSipSessionMessage=oSipStack.newSession("message",oConfigMessage),oSipSessionMessage.setConfiguration({sip_headers:a})}return 0==oSipSessionMessage.send(n,t,"text/plain;charset=utf-8")||(oSipSessionMessage=null,PutToDebugLog(2,"WRTC, ERROR, Failed to send message chat"),!1)}catch(r){PutToDebugLogException(2,"webrtcapi: SipSendChat",r),oSipSessionMessage=null}return!1}function sipShareScreen(){if("w4a"===webphone_api.webrtcstack.SIPml.getWebRtcType()){if(!oSipSessionCall)return void PutToDebugLog(2,"ERROR, sipShareScreen No active session");oSipSessionCall.bfcpSharing?(SetSipHeader(2),0!=oSipSessionCall.stopBfcpShare(oConfigCall)?PutToDebugLog(2,"ERROR, sipShareScreen Failed to stop BFCP share"):oSipSessionCall.bfcpSharing=!1):(SetSipHeader(2),oConfigCall.screencast_window_id=0,0!=oSipSessionCall.startBfcpShare(oConfigCall)?PutToDebugLog(2,"ERROR, sipShareScreen Failed to start BFCP share"):oSipSessionCall.bfcpSharing=!0)}else SipCall("call-screenshare")}function Forward(e,n,t){try{if(webphone_api.common.isNull(e)||e.length<1)return PutToDebugLog(2,"ERROR, webrtcapi Forward, invalid number: "+e),!1;if(0===webphone_api.common.GetParameterInt("allowcallredirect",1))return PutToDebugLog(2,"EVENT, webrtcapi Forward dropped, because allowcallredirect is 0 (disabled)"),!1;if((webphone_api.common.isNull(n)||n.toString().length<10)&&(n=webphone_api.common.GetRecentInviteIn()),webphone_api.common.isNull(n)||n.toString().length<10)return PutToDebugLog(2,"ERROR, webrtcapi Forward, invalid INVITE msg: "+n),!1;if(null==webphone_api.webrtc_socket)return PutToDebugLog(2,"EVENT, webrtcapi Forward dropped, because no websocket connection"),!1;webphone_api.common.GetParameterInt("fwd_msg_displayed",0)<1&&(webphone_api.common.SaveParameter("fwd_msg_displayed","1"),webphone_api.common.ShowToast(webphone_api.stringres.get("call_forward_warn")));var o="<sip:"+webphone_api.common.Trim(e)+"@"+webphone_api.common.GetUDPServerAddress()+">",i="SIP/2.0 302 Moved Temporarily\r\n";return i=i+"Via: "+webphone_api.common.GetSipHeaderFromMsg(n,"Via")+"\r\n",i=i+"From: "+webphone_api.common.GetSipHeaderFromMsg(n,"From")+"\r\n",i=i+"To: "+webphone_api.common.GetSipHeaderFromMsg(n,"To")+";totag=227A1\r\n",i=i+"Call-ID: "+webphone_api.common.GetSipHeaderFromMsg(n,"Call-ID")+"\r\n",i=i+"CSeq: "+webphone_api.common.GetSipHeaderFromMsg(n,"CSeq")+"\r\n",i=i+"Contact: "+o+"\r\n",i+="Content-Length: 0 \r\n",i+="\r\n",PutToDebugLog(3,"EVENT, send Forward SIP message:\r\n"+i),webphone_api.webrtc_socket.send(i),PutToDebugLog(2,"EVENT, Hangup because call Forward: "+e),webphone_api.common.isNull(t)?SipHangup(!0,webphone_api.global.aline):t.hangup(),!0}catch(a){PutToDebugLogException(2,"webrtcapi: Forward",a)}return!1}function SipTransferEx(e,n){var t=0;try{t=1,webphone_api.common.isNull(n)&&(n=-3);var o=webphone_api.common.StrToIntDef(n,-3);webphone_api.global.attendedtransfer_origline>0&&(webphone_api.common.isNull(o)||o<1)&&(o=webphone_api.global.attendedtransfer_origline),webphone_api.global.atransfer_line>0&&(webphone_api.common.isNull(o)||-3===o)&&(o=webphone_api.global.atransfer_line),(webphone_api.common.isNull(o)||-3===o)&&(o=webphone_api.global.aline),(webphone_api.common.isNull(o)||-3===o)&&(o=2),t=2;var i=webphone_api.common.GetCallSession(7,!1,o);if(t=221,!i&&(webphone_api.common.isNull(n)||n<1)){t=222;var a=webphone_api.common.GetBestLine();if((a<0||a==o)&&webphone_api.global.aline>0&&(a=webphone_api.global.aline),a==o&&(a=a>0?-1:1),null!=(i=webphone_api.common.GetCallSession(7,!1,o))&&webphone_api.common.lastcallsessionepidx>=0){var r=webphone_api.global.ep[webphone_api.common.lastcallsessionepidx][webphone_api.common.EP_LINE];o=webphone_api.common.IsNumber(r)&&r>0?r:a}}if(!i)return PutToDebugLog(1,"ERROR,transfer "+webphone_api.stringres.get("err_nocallinprogress")),webphone_api.common.LogLines(),!1;if(t=3,webphone_api.common.isNull(e)||e.length<1)return PutToDebugLog(1,"ERROR,transfer missing target number"),!1;t=4;var l=!1;webphone_api.global.attendedtransfer_alreadycalled==e&&(l=!0),webphone_api.global.prev_transfer_line=o,webphone_api.global.prev_transfer_number=e,webphone_api.global.prev_transfer_replaces_tick=0;var s=webphone_api.common.GetParameterInt("transfertype",-1);PutToDebugLog(2,"EVENT, WEBRTC: Transfer call to: "+e+", type: "+s.toString()+" on line: "+o.toString()+" ("+n.toString()+"/"+webphone_api.global.attendedtransfer_origline.toString()+"/"+webphone_api.global.atransfer_line.toString()+", alreadycalled: "+l.toString()+")"),t=5,webphone_api.global.attendedtransfer_alreadycalled="",webphone_api.global.attendedtransfer_origline=-1,webphone_api.global.atransfer_line=-1,webphone_api.global.atransfer_callid="",webphone_api.global.atransfer_number="";var p=null;if(t=55,1===s)return t=6,0!=i.transfer(e)?(PutToDebugLog(1,"ERROR, Transfer failed ("+s.toString()+")"),!1):(0!=webphone_api.common.GetParameterInt("discontransfer",-1)&&setTimeout(function(){PutToDebugLog(2,"EVENT, WEBRTC: exec Hangup on call Transfer"),SipHangup(!1,o)},1100),!0);if(6===s){t=7;var c=100;return l||(PutToDebugLog(5,"EVENT, WEBRTC: transfer hold 6"),SipToggleHoldResume(!0,o,17),c=1100),t=12,setTimeout(function(){if(PutToDebugLog(5,"EVENT, WEBRTC: transfer now (6)"),0!=i.transfer(e))return t=13,PutToDebugLog(1,"ERROR, Transfer failed ("+s.toString()+")"),PutToDebugLog(2,"EVENT, Transfer failed Unhold-Reload call"),SipToggleHoldResume(!1,o,18),!1},c),!0}if(s<0||7===s)return t=8,PutToDebugLog(5,"EVENT, WEBRTC: transfer now (7)"),0==i.transfer(e)||(PutToDebugLog(1,"ERROR, Transfer failed ("+s.toString()+")"),!1);if(8===s)return t=9,PutToDebugLog(5,"EVENT, WEBRTC: transfer mute 8"),webphone_api.plhandler.MuteEx(!0,-1,!0),setTimeout(function(){t=11,PutToDebugLog(5,"EVENT, WEBRTC: transfer now (conference)"),webphone_api.conference(e,!0)},250),!0;t=10;var c=300;if(p=webphone_api.common.GetEndpoint(4287,o),t=15,webphone_api.common.isNull(p)||(webphone_api.common.isNull(p[webphone_api.common.EP_LINE])||p[webphone_api.common.EP_LINE]<1)&&(webphone_api.common.isNull(p[webphone_api.common.EP_CALLID])||p[webphone_api.common.EP_CALLID].length<1))t=16,p=null,PutToDebugLog(3,"WARNING,cannot find current ep-line for attended transfer"),setTimeout(function(){if(PutToDebugLog(5,"EVENT, WEBRTC: transfer now (unnattended failback) to "+e),0!=i.transfer(e))return t=17,PutToDebugLog(1,"ERROR, Transfer failed ("+s.toString()+")"),PutToDebugLog(2,"EVENT, Transfer failed Unhold-Reload call"),SipToggleHoldResume(!1,o,21),!1},c);else{t=18;var u=0;if(!l){t=1881;var g=null;try{t=188101,g=webphone_api.common.GetEndpoint(8277,-2,e,"","",!1,!0,null,i),t=188102,!g||g!==p&&p[webphone_api.common.EP_LINE]!=g[webphone_api.common.EP_LINE]||(g=null),t=188103,g&&(u=g[webphone_api.common.EP_LINE]),t=188104,u==o&&(u=0)}catch(v){PutToDebugLogExceptionWarning(2,"webrtcapi: cannot check if transfer target is already in call "+t.toString(),v),g=null}g&&(PutToDebugLog(5,"EVENT, WEBRTC: transfer target already in call "+e+" "+webphone_api.common.LineToString(u)),l=!0)}if(t=1883,l){t=181;var h=webphone_api.common.GetParameterInt("discontransfer",-1),m=0,d=0,b=webphone_api.common.GetParameterInt("unholdontransfer",-1),_=webphone_api.common.GetParameterInt("transfwithreplace",-1);if(_<0&&(-1==s||6==s||7==s)&&(_=1),8==s&&(_=0),0!=b&&(b>1||_>0&&webphone_api.common.GetHoldState(o))&&(m=o),u>0&&0!=b&&(b>1||_>0&&webphone_api.common.GetHoldState(u))&&(d=u),m<=0&&d>0&&(m=d,d=0),m>0){PutToDebugLog(5,"EVENT, WEBRTC: transfer unhold before replaces (line: "+m.toString()+", line2: "+d.toString()+", unholdontransfer: "+b.toString()+", transfwithreplace: "+b.toString()+", ttype: "+s.toString()+", holdstate: "+webphone_api.common.GetHoldState(m).toString()+")"),SipToggleHoldResume(!1,m,22),SipToggleMute(!0,0,m,"mute before replaces");var f=1;return d>0&&(f=3e3),setTimeout(function(){d>0&&(PutToDebugLog(5,"EVENT, WEBRTC: transfer unhold2 before replaces (line: "+m.toString()+", line2: "+d.toString()+", unholdontransfer: "+b.toString()+", transfwithreplace: "+b.toString()+", ttype: "+s.toString()+", holdstate: "+webphone_api.common.GetHoldState(d).toString()+")"),SipToggleHoldResume(!1,d,23),SipToggleMute(!0,0,d,"mute before replaces")),setTimeout(function(){return PutToDebugLog(5,"EVENT, WEBRTC: transfer now (after unhold) to "+e),webphone_api.global.transfer_retryonnotsent=e,0!=i.transfer(e)?(webphone_api.global.transfer_retryonnotsent="",
PutToDebugLog(1,"ERROR, Transfer failed ("+s.toString()+")"),!1):(t=182,PutToDebugLog(5,"EVENT, WEBRTC: will verify and might Hangup old line on call Transfer "+h.toString()),setTimeout(function(){if(webphone_api.global.transfer_retryonnotsent.length>0)return e=webphone_api.global.transfer_retryonnotsent,webphone_api.global.transfer_retryonnotsent="",PutToDebugLog(5,"WARNING, WEBRTC: transfer not sent. try again to "+e),0!=i.transfer(e)?(PutToDebugLog(1,"ERROR, Transfer failed B ("+s.toString()+")"),!1):(t=182,0!=h&&(PutToDebugLog(5,"EVENT, WEBRTC: will Hangup old line on call Transfer B"),setTimeout(function(){PutToDebugLog(2,"EVENT, WEBRTC: exec Hangup old line on call Transfer B"),SipHangup(!1,o,!1)},1e3)),!0);0!=h&&(PutToDebugLog(2,"EVENT, WEBRTC: exec Hangup old line on call Transfer X"),SipHangup(!1,o,!1))},1200),!0)},3e3)},f),!0}return PutToDebugLog(5,"EVENT, WEBRTC: transfer no need to unhold before replaces (line: "+o.toString()+", unholdontransfer: "+b.toString()+", transfwithreplace: "+b.toString()+", ttype: "+s.toString()+", holdstate: "+webphone_api.common.GetHoldState(o).toString()+")"),PutToDebugLog(5,"EVENT, WEBRTC: transfer now to "+e),0!=i.transfer(e)?(PutToDebugLog(1,"ERROR, Transfer failed ("+s.toString()+")"),!1):(t=182,0!=h&&(PutToDebugLog(5,"EVENT, WEBRTC: will Hangup old line on call Transfer C"),setTimeout(function(){PutToDebugLog(2,"EVENT, WEBRTC: exec Hangup old line on call Transfer C"),SipHangup(!1,o,!1)},c)),!0)}t=1882,PutToDebugLog(5,"EVENT, WEBRTC: transfer hold attended "+e),SipToggleHoldResume(!0,o,25),c=800,t=1883;var w=e;setTimeout(function(){t=1884,PutToDebugLog(5,"EVENT, WEBRTC: transfer call target "+w),webphone_api.call(w)},c),t=183,t=184,webphone_api.global.atransfer_line=p[webphone_api.common.EP_LINE],webphone_api.global.atransfer_callid=p[webphone_api.common.EP_CALLID],webphone_api.global.atransfer_number=e}return!0}catch(v){PutToDebugLogException(2,"webrtcapi: SipTransferEx oop: "+t,v)}return!1}function SipTransfer(e){try{var n=webphone_api.common.GetCallSession(8,!1,webphone_api.global.aline,e);if(!n)return PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_nocallinprogress")),webphone_api.common.LogLines(),!1;if(!webphone_api.common.isNull(e)&&e.length>0){var t=webphone_api.common.GetParameterInt("transfertype",-1);if(0!=n.transfer(e))return PutToDebugLog(1,"ERROR,Transfer failed."),!1;PutToDebugLog(2,"WRTC, EVENT, SipTransfer ("+t+"): "+e)}}catch(o){PutToDebugLogException(2,"webrtcapi: SipTransfer",o)}return!1}function SipToggleHoldResume(e,n,t){try{if(webphone_api.common.isNull(e)&&(e=!0),webphone_api.common.isNull(n)&&(n=-1),webphone_api.common.isNull(t)&&(t=0),PutToDebugLog(5,"EVENT, toggle hold internal. hold: "+e.toString()+", line: "+n.toString()+", from: "+t.toString()),0!=webphone_api.global.holdorresumeinprogress&&webphone_api.common.GetTickCount()-webphone_api.global.holdorresumeinprogress<4e3||!webphone_api.common.isNull(wcacheh_line)&&wcacheh_line.length>0){PutToDebugLog(5,"EVENT, delay hold because hold in progress "+wcacheh_line.length.toString()),webphone_api.common.isNull(wcacheh_line)&&(wcacheh_line=[]),webphone_api.common.isNull(wcacheh_state)&&(wcacheh_state=[]),wcacheh_line.length>15&&(wcacheh_state=[],wcacheh_line=[],webphone_api.common.PutToDebugLog(5,"WARNING, too many webrtc hold operation queued"));for(var o=wcacheh_line.length-1;o>=0;o--)if(wcacheh_line[o]==n&&wcacheh_state[o]==e)return webphone_api.common.PutToDebugLog(5,"EVENT, webrtc hold operation already queued: "+n.toString()+"; state: "+e.toString()),!0;return wcacheh_state.push(e),wcacheh_line.push(n),wholdtimer&&(clearInterval(wholdtimer),wholdtimer=null),wholdtimer=setInterval(function(){if(0==webphone_api.global.holdorresumeinprogress||webphone_api.common.GetTickCount()-webphone_api.global.holdorresumeinprogress>5e3){if(!(wcacheh_line.length<1)){PutToDebugLog(5,"EVENT, delayed hold");var e=wcacheh_state.shift(),n=wcacheh_line.shift();return wcacheh_line.length<1&&!webphone_api.common.isNull(wholdtimer)&&(clearInterval(wholdtimer),wholdtimer=null),SipToggleHoldResumeInternal(e,n,t)}webphone_api.common.isNull(wholdtimer)||(clearInterval(wholdtimer),wholdtimer=null)}},80),!0}return webphone_api.common.isNull(wholdtimer)||(clearInterval(wholdtimer),wholdtimer=null),SipToggleHoldResumeInternal(e,n,t)}catch(i){PutToDebugLogException(2,"webrtcapi: SipToggleHoldResumeExt",i)}return!1}function SipToggleHoldResumeInternal(e,n,t){try{webphone_api.common.isNull(e)&&(e=!0),webphone_api.common.isNull(n)&&(n=-1),webphone_api.common.isNull(t)&&(t=51),PutToDebugLog(5,"EVENT, toggle hold. hold: "+e.toString()+", line: "+n.toString()+", from: "+t.toString());var o=!0;!webphone_api.common.isNull(n)&&n>=1&&(o=!1),webphone_api.common.isNull(n)&&(n=webphone_api.global.aline);var i=-1;n<1?i=1:n>0&&(i=-1);var a=null,r=webphone_api.common.GetCallEpIdx(9,!1,n,"");if(r>=0&&(a=webphone_api.global.ep[r][webphone_api.common.EP_SESSION]),null==a&&i!=n&&o&&(r=webphone_api.common.GetCallEpIdx(9,!1,i,""))>=0&&(a=webphone_api.global.ep[r][webphone_api.common.EP_SESSION])){n=i,i=n}if(a){"Firefox"===webphone_api.common.GetBrowser()&&webphone_api.global.firefoxholdcount++,e?PutToDebugLog(1,"EVENT,Hold"):PutToDebugLog(1,"EVENT,Reload");var l=-1;webphone_api.global.isholdresume=!0,webphone_api.global.holdresumecount++;var s=webphone_api.common.GetHoldState(n);if(PutToDebugLog(2,"EVENT, Webrtc hold exec hold: "+e.toString()+" on line "+n.toString()+" epidx: "+r.toString()+" session: "+SessionToString(a)+" holdstate: "+s.toString()),webphone_api.global.lastholdline=n,!0!==e&&!webphone_api.common.isNull(lastmuste_mute)&&!1===lastmuste_mute){if(PutToDebugLog(5,"EVENT, webrtcapi: SipToggleHoldResume also unmute call, because user muted when was on hold "+n),!SipToggleMute(!1,lastmuste_direction,n,lastmuste_log,!0,o)){var p=lastmuste_line;null!=p&&n!=p||(p=i),null!=p&&n!=p||(p=-1),0==lastmuste_direction&&n==p||!webphone_api.common.isNull(webphone_api.common.GetCallSession(222,!1,n,""))||(PutToDebugLog(5,"EVENT, webrtcapi: try unmute again "+p.toString()),SipToggleMute(!1,0,p,lastmuste_log,!0,o))}lastmuste_mute=null,lastmuste_direction=null,lastmuste_line=null,lastmuste_log=null}if(webphone_api.global.holdorresumeinprogress=webphone_api.common.GetTickCount(),webphone_api.global.lastholdorresume=webphone_api.common.GetTickCount(),webphone_api.global.lastholdinvitesent=0,webphone_api.global.needholdreinvite=1,!0===e?(webphone_api.global.ishold=webphone_api.common.GetTickCount(),webphone_api.global.isresume=0,PutToDebugLog(5,"EVENT,WebRTC hold A"),l=a.hold()):(webphone_api.global.ishold=0,webphone_api.global.isresume=webphone_api.common.GetTickCount(),PutToDebugLog(5,"EVENT,WebRTC reload A"),l=a.resume()),0==l?o=!1:PutToDebugLog(5,"EVENT, (warn) first toggle hold attempt failed "+l.toString()),o){var c=webphone_api.common.GetCallSession(10,!1,i,"","",null,"0",a);if(c&&c!==a){PutToDebugLog(2,"EVENT, (warn) trying othersession "+SessionToString(c)),a=c,!0===e?(PutToDebugLog(5,"EVENT,WebRTC hold B"),l=a.hold()):(PutToDebugLog(5,"EVENT,WebRTC reload B"),l=a.resume()),o=!0;var u=-5;if(webphone_api.common.lastcallsessionepidx>=0&&(r=webphone_api.common.lastcallsessionepidx,u=webphone_api.global.ep[r][webphone_api.common.EP_LINE]),webphone_api.common.IsNumber(u)&&-5!=u){n=u,i=n}else{n=i,i=n}}}return 0==l?(r>=0&&(webphone_api.global.ep[r][webphone_api.common.EP_HOLDSTATE]=!0===e?"true":"false"),!0===e?PutToDebugLog(5,"EVENT, WebRTC hold initiated successfully"):PutToDebugLog(5,"EVENT, WebRTC reload initiated successfully"),a.setHolded(e),!0):(webphone_api.global.holdorresumeinprogress=0,!0===e?PutToDebugLog(1,"ERROR,Hold failed."):PutToDebugLog(1,"ERROR,Resume failed."),!1)}return webphone_api.global.holdorresumeinprogress=0,PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_nocallinprogress")),webphone_api.common.LogLines(),!1}catch(g){PutToDebugLogException(2,"webrtcapi: SipToggleHoldResume",g)}return webphone_api.global.holdorresumeinprogress=0,!1}function SipMuteVideo(e,n){try{var t=!1,o=webphone_api.common.GetCallSession(11,!1,webphone_api.global.aline,"");if(!o)return PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_nocallinprogress")),webphone_api.common.LogLines(),!1;var i=!e;if((webphone_api.common.isNull(n)||!1===webphone_api.common.IsNumber(n))&&(n=0),n=webphone_api.common.StrToInt(n),(n<0||n>2)&&(n=0),0===n||1===n)if(null!=o.o_session)if(null!=o.o_session.o_stream_remote)if(o.o_session.o_stream_remote.getVideoTracks().length>0){for(var a=0;a<o.o_session.o_stream_remote.getVideoTracks().length;a++)PutToDebugLog(2,"EVENT, webrtcapi MuteVideo REMOTE Setting Video Tracks ["+a+"] to state = "+i.toString()+" "+SessionToString(o)),o.o_session.o_stream_remote.getVideoTracks()[a].enabled=i;o.o_session.o_stream_remote.getVideoTracks().length>0&&(t=!0)}else PutToDebugLog(2,"ERROR, webrtcapi MuteVideo REMOTE oSipSessionCall.o_session.o_stream_remote-> NO VIDEO TRACKS "+SessionToString(o));else PutToDebugLog(2,"ERROR, webrtcapi MuteVideo REMOTE oSipSessionCall.o_session.o_stream_remote is NULL "+SessionToString(o));else PutToDebugLog(2,"ERROR, webrtcapi MuteVideo REMOTE oSipSessionCall.o_session is NULL "+SessionToString(o));if(0===n||2===n)if(null!=o.o_session)if(null!=o.o_session.o_stream_local)if(o.o_session.o_stream_local.getVideoTracks().length>0){for(var a=0;a<o.o_session.o_stream_local.getVideoTracks().length;a++)PutToDebugLog(2,"EVENT, webrtcapi MuteVideo LOCAL Setting Video Tracks ["+a+"] to state = "+i.toString()+" "+SessionToString(o)),o.o_session.o_stream_local.getVideoTracks()[a].enabled=i;o.o_session.o_stream_local.getVideoTracks().length>0&&(t=!0)}else PutToDebugLog(2,"ERROR, webrtcapi MuteVideo LOCAL oSipSessionCall.o_session.o_stream_local-> NO VIDEO TRACKS "+SessionToString(o));else PutToDebugLog(2,"ERROR, webrtcapi MuteVideo LOCAL oSipSessionCall.o_session.o_stream_local is NULL "+SessionToString(o));else PutToDebugLog(2,"ERROR, webrtcapi MuteVideo LOCAL oSipSessionCall.o_session is NULL "+SessionToString(o));return t}catch(r){PutToDebugLogException(2,"webrtcapi: SipMuteVideo",r)}return!1}function SessionToString(e){return webphone_api.common.isNull(e)?"NULL":"session line: "+e.getLine()+" id: "+e.getId()+" peer: "+e.getRemoteName()+" sipcallid: "+e.getSipcallid()}function MuteMic(e,n,t){try{if(n=!n,null===e){if(PutToDebugLog(2,"WARNING, webrtcapi MuteMic session is NULL"),!n)return!0}else if(null!=e.o_session)if(webphone_api.common.isNull(t)&&(t=!1),null!=e.o_session.o_stream_local)if(e.o_session.o_stream_local.getAudioTracks().length>0){for(var o=0;o<e.o_session.o_stream_local.getAudioTracks().length;o++)PutToDebugLog(2,"EVENT, webrtcapi MuteMic Setting Audio Tracks ["+o+"] to state = "+n.toString()+" "+SessionToString(e)),e.o_session.o_stream_local.getAudioTracks()[o].enabled=n;if(e.o_session.o_stream_local.getAudioTracks().length>0)return e.setMuted(2,!n),!0}else{if(!n||t)return PutToDebugLog(2,"EVENT, (warn) webrtcapi MuteMic oSipSessionCall.o_session.o_stream_local-> NO AUDIO TRACKS "+SessionToString(e)),!0;PutToDebugLog(2,"WARNING, webrtcapi MuteMic oSipSessionCall.o_session.o_stream_local-> NO AUDIO TRACKS "+SessionToString(e))}else{if(!n||t)return PutToDebugLog(2,"EVENT, (warn) webrtcapi MuteMic oSipSessionCall.o_session.o_stream_local is NULL "+SessionToString(e)),!0;PutToDebugLog(2,"WARNING, webrtcapi MuteMic oSipSessionCall.o_session.o_stream_local is NULL "+SessionToString(e))}else if(PutToDebugLog(2,"WARNING, webrtcapi MuteMic oSipSessionCall.o_session is NULL "+SessionToString(e)),!n)return!0}catch(i){PutToDebugLogException(2,"webrtcapi: MuteMic",i)}return!1}function MuteSpeaker(e,n,t){try{if(n=!n,null===e){if(PutToDebugLog(2,"WARNING, webrtcapi MuteSpeaker session is NULL"),!n)return!0}else if(null!=e.o_session)if(webphone_api.common.isNull(t)&&(t=!1),null!=e.o_session.o_stream_remote)if(e.o_session.o_stream_remote.getAudioTracks().length>0){for(var o=0;o<e.o_session.o_stream_remote.getAudioTracks().length;o++)PutToDebugLog(2,"EVENT, webrtcapi MuteSpeaker Setting Audio Tracks ["+o+"] to state = "+n.toString()+" "+SessionToString(e)),e.o_session.o_stream_remote.getAudioTracks()[o].enabled=n;if(e.o_session.o_stream_remote.getAudioTracks().length>0)return e.setMuted(1,!n),!0}else{if(!n||t)return PutToDebugLog(4,"EVENT, (warn) webrtcapi MuteSpeaker oSipSessionCall.o_session.o_stream_remote-> NO AUDIO TRACKS "+SessionToString(e)),!0;PutToDebugLog(2,"ERROR, webrtcapi MuteSpeaker oSipSessionCall.o_session.o_stream_remote-> NO AUDIO TRACKS "+SessionToString(e))}else{if(!n||t)return PutToDebugLog(4,"WARNING, webrtcapi MuteSpeaker oSipSessionCall.o_session.o_stream_remote is NULL "+SessionToString(e)),!0;PutToDebugLog(2,"ERROR, webrtcapi MuteSpeaker oSipSessionCall.o_session.o_stream_remote is NULL "+SessionToString(e))}else{if(!n)return PutToDebugLog(4,"WARNING, webrtcapi MuteSpeaker oSipSessionCall.o_session is NULL "+SessionToString(e)),!0;PutToDebugLog(2,"ERROR, webrtcapi MuteSpeaker oSipSessionCall.o_session is NULL "+SessionToString(e))}}catch(i){PutToDebugLogException(2,"webrtcapi: MuteSpeaker",i)}return!1}function SipToggleMuteOld(e,n,t,o,i,a){try{if(0!=webphone_api.global.holdorresumeinprogress&&webphone_api.common.GetTickCount()-webphone_api.global.holdorresumeinprogress<4e3){PutToDebugLog(5,"EVENT, delay mute because hold in progress");var r=webphone_api.common.GetTickCount(),l=setInterval(function(){(webphone_api.common.GetTickCount()-r>5e3||0==webphone_api.global.holdorresumeinprogress||webphone_api.common.GetTickCount()-webphone_api.global.holdorresumeinprogress>5e3)&&(PutToDebugLog(5,"EVENT, delayed mute"),clearInterval(l),SipToggleMuteInternal(e,n,t,o,i,a))},80);return!0}return SipToggleMuteInternal(e,n,t,o,i,a)}catch(s){PutToDebugLogException(2,"webrtcapi: SipToggleMuteExt",s)}return!1}function SipToggleMute(e,n,t,o,i,a){try{if(0!=webphone_api.global.holdorresumeinprogress&&webphone_api.common.GetTickCount()-webphone_api.global.holdorresumeinprogress<4e3||!webphone_api.common.isNull(wcachem_line)&&wcachem_line.length>0){PutToDebugLog(5,"EVENT, delay mute because hold in progress "+wcachem_line.length.toString()),webphone_api.common.isNull(wcachem_line)&&(wcachem_line=[]),webphone_api.common.isNull(wcachem_state)&&(wcachem_state=[]),wcachem_line.length>15&&(wcachem_state=[],wcachem_line=[],webphone_api.common.PutToDebugLog(5,"WARNING, too many webrtc mute operation queued"));for(var r=wcachem_line.length-1;r>=0;r--)if(wcachem_line[r]==t)return wcachem_state[r]==e?(webphone_api.common.PutToDebugLog(5,"EVENT, webrtc mute operation already queued: "+t.toString()+"; state: "+e.toString()),!0):(common.PutToDebugLog(5,"EVENT, webrtc change cached mute operation: "+t.toString()+"; state: "+e.toString()),wcachem_state[r]=e,!0);return wcachem_state.push(e),wcachem_line.push(t),wmutetimer&&(clearInterval(wmutetimer),wmutetimer=null),wmutetimer=setInterval(function(){if(0==webphone_api.global.holdorresumeinprogress||webphone_api.common.GetTickCount()-webphone_api.global.holdorresumeinprogress>5e3){if(!(wcachem_line.length<1)){PutToDebugLog(5,"EVENT, delayed mute");var e=wcachem_state.shift(),t=wcachem_line.shift();return wcachem_line.length<1&&!webphone_api.common.isNull(wmutetimer)&&(clearInterval(wmutetimer),wmutetimer=null),SipToggleMuteInternal(e,n,t,o,i,a)}webphone_api.common.isNull(wmutetimer)||(clearInterval(wmutetimer),wmutetimer=null)}},80),!0}return webphone_api.common.isNull(wmutetimer)||(clearInterval(wmutetimer),wmutetimer=null),SipToggleMuteInternal(e,n,t,o,i,a)}catch(l){PutToDebugLogException(2,"webrtcapi: SipToggleMuteExt",l)}return!1}function SipToggleMuteInternal(e,n,t,o,i,a){try{webphone_api.common.isNull(t)&&(t=webphone_api.global.aline),webphone_api.common.isNull(i)&&(i=!1),webphone_api.common.isNull(a)&&(a=!0),webphone_api.global.needmuteafterreload==t&&(webphone_api.global.needmuteafterreload=0),PutToDebugLog(5,"EVENT, Webrtc mute exec mute: "+e.toString()+" dir: "+n+" on line "+t.toString());var r=webphone_api.common.GetCallSession(12,!1,t,"");if(!r)return PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_nocallinprogress")),webphone_api.common.LogLines(),!1;lastmuste_mute=e,lastmuste_direction=n,lastmuste_line=t,lastmuste_log=o,(webphone_api.common.isNull(n)||"0"!=n&&"1"!=n&&"2"!=n)&&(n="2");var l=!1;if("2"==n){var s=MuteMic(r,e,i);if(!1===s&&a){var p=webphone_api.common.GetCallSession(13,!1,t,"","",null,"0",r);p&&p!==r&&(r=p,(s=MuteMic(r,e,i))&&webphone_api.common.lastcallsessionepidx>=0&&(t=webphone_api.global.ep[webphone_api.common.lastcallsessionepidx][webphone_api.common.EP_LINE],PutToDebugLog(5,"EVENT, mute was applied for line "+t.toString())))}!1===s&&!1!==o&&!1===webphone_api.isonhold()&&(i||PutToDebugLog(1,"ERROR,Mute / Unmute failed."),PutToDebugLog(2,"WARNING,Mute / Unmute failed A. state: "+e+" dir: "+n+" line: "+t+" ret: "+s)),l=s}else if("1"==n){var s=MuteSpeaker(r,e,i);if(!1===s&&a){var p=webphone_api.common.GetCallSession(14,!1,t,"","",null,"0",r);p&&p!==r&&(r=p,(s=MuteSpeaker(r,e,i))&&webphone_api.common.lastcallsessionepidx>=0&&(t=webphone_api.global.ep[webphone_api.common.lastcallsessionepidx][webphone_api.common.EP_LINE],PutToDebugLog(5,"EVENT, mute was applied for line "+t.toString())))}!1===s&&!1!==o&&!1===webphone_api.isonhold()&&(i||PutToDebugLog(1,"ERROR,Mute / Unmute failed."),PutToDebugLog(2,"WARNING,Mute / Unmute failed B. state: "+e+" dir: "+n+" line: "+t+" ret: "+s)),l=s}else if("0"==n){var s=MuteMic(r,e,i),c=MuteSpeaker(r,e,i);if((!1===s||!1===c)&&a){var p=webphone_api.common.GetCallSession(15,!1,t,"","",null,"0",r);p&&p!==r&&(r=p,s=MuteMic(r,e,i),c=MuteSpeaker(r,e,i),(s||c)&&webphone_api.common.lastcallsessionepidx>=0&&(t=webphone_api.global.ep[webphone_api.common.lastcallsessionepidx][webphone_api.common.EP_LINE],PutToDebugLog(5,"EVENT, mute was applied for line "+t.toString())))}!1!==s&&!1!==c||!1!==o&&!1===webphone_api.isonhold()&&(i||PutToDebugLog(1,"ERROR,Mute / Unmute failed."),PutToDebugLog(2,"WARNING,Mute / Unmute failed C state: "+e+" dir: "+n+" line: "+t+", ret: "+s+", ret2: "+c)),l=!1!==s||!1!==c}else i||PutToDebugLog(1,"ERROR,Mute / Unmute failed."),PutToDebugLog(2,"WARNING,Mute / Unmute invalid direction: "+n),l=!1;return l&&(e?webphone_api.common.SetMuteState(t,"true"):webphone_api.common.SetMuteState(t,"false")),l}catch(u){PutToDebugLogException(2,"webrtcapi: SipToggleMute",u)}return!1}function SipSendDTMF(e){try{var n=webphone_api.common.GetCallSession(16,!1,webphone_api.global.aline,"");if(webphone_api.common.isNull(e)||e.length<1)return;e=e.toString();var t=!1;if(0!==webphone_api.common.Trim(e).indexOf("*1*")&&0!==webphone_api.common.Trim(e).indexOf("*6*")||(t=!0),1===e.length)Dtmf(e,n,t);else{var o=e.substring(0,1);if(" "!==o&&Dtmf(o,n,t),e=e.substring(1),!webphone_api.common.isNull(e)&&e.length>0){var i=1;" "===e.substring(0,1)&&(i=1e3),setTimeout(function(){SipSendDTMF(e)},i)}}}catch(a){PutToDebugLogException(2,"webrtcapi: SipSendDTMF",a)}return!1}function Dtmf(e,n,t){try{return n&&e?(!0===t&&(webphone_api.global.isconfdtmf=!0),0==n.dtmf(e)?(PutToDebugLog(3,"EVENT, DTMFsent: "+e),!0):(PutToDebugLog(2,"WRTC, ERROR, webrtcapi Dtmf failed."),!1)):(PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_nocallinprogress")),webphone_api.common.LogLines(),!1)}catch(o){PutToDebugLogException(2,"webrtcapi: Dtmf",o)}}function PresenceSet(e){try{if(!1===isregistered)return void PutToDebugLog(2,"WARNING, webrtcapi cannot set presence, because not registered");if(webphone_api.common.isNull(mSipuri)||mSipuri.length<2)return void PutToDebugLog(2,"ERROR, webrtcapi PresenceSet invalid sipuri: "+mSipuri);if(webphone_api.common.isNull(e)||e.length<2)return void PutToDebugLog(2,"ERROR, webrtcapi PresenceSet invalid status: "+e);webphone_api.common.isNull(mDisplayname)&&(mDisplayname=""),publishSession=oSipStack.newSession("publish",{events_listener:{events:"*",listener:onSipEventSession}});PutToDebugLog(2,"EVENT, PresenceSet: "+e+"; for: "+mSipuri+"; displayname: "+mDisplayname);var n='<?xml version="1.0" encoding="UTF-8"?>\n<presence xmlns="urn:ietf:params:xml:ns:pidf"\n xmlns:im="urn:ietf:params:xml:ns:pidf:im" entity="'+mSipuri+'">\n<tuple id="s8794">\n<status>\n <basic>'+e+"</basic>\n <im:im>"+e+'</im:im>\n</status>\n<contact priority="0.8">tel:'+mDisplayname+'</contact>\n<note xml:lang="en"></note>\n</tuple>\n</presence>';publishSession.publish(n,"application/pidf+xml",{sip_caps:[{name:"+sip.ice"}]})}catch(t){PutToDebugLogException(2,"webrtcapi: PresenceSet",t)}}function PresenceGet(e){try{if(webphone_api.common.isNull(e)||e.length<1)return;if(!1===isregistered&&pgmaxloop<15)return pgmaxloop++,void setTimeout(function(){PresenceGet(e)},1e3);pgmaxloop=0;var n=[];n.push({name:"Event",value:"presence"}),n.push({name:"Accept",value:"application/pidf+xml"});var t=e.split(",");if(t.length>60&&PutToDebugLog(2,"EVENT, PresenceGet skip for too lmany users"),PutToDebugLog(2,"EVENT, PresenceGet for: "+e),!webphone_api.common.isNull(t)&&t.length>0)for(var o=0;o<t.length&&!(o>maxnrofusers);o++)if(!(webphone_api.common.isNull(t[o])||t[o].length<1)){var i=t[o];PutToDebugLog(5,"EVENT, PresenceGet for user: "+i);var a=oSipStack.newSession("subscribe",{events_listener:{events:"*",listener:onSipEventSession},sip_headers:n,sip_caps:[{name:"+g.oma.sip-im",value:null},{name:"+audio",value:null}]});a.subscribe(i)}}catch(r){PutToDebugLogException(2,"webrtcapi: PresenceGet",r)}}function startRingTone(){try{if(webphone_api.common.GetParameterInt("playring",2)<0)return;var e=!1,n=webphone_api.common.GetParameter("sel_rtc_audio_ring");if(!webphone_api.common.isNull(n)&&n.length>0&&!webphone_api.common.isNull(audiooutput_name))try{var t=webphone_api.common.FindInList(audiooutput_name,n);if(t>=0){PutToDebugLog(5,"EVENT, webrtcapi: startRingTone play on ring device "+audiooutput_name[t]);var o=webphone_api.getbasedir2()+"sound/rtc_ringtone.wav";playingringtoneaudio=new Audio(o),playingringtoneaudio.setSinkId(audiooutput_id[t]),playingringtoneaudio.loop=!0,playingringtoneaudio.play()?e=!0:PutToDebugLog(5,"EVENT, webrtcapi: startRingTone failed to play"),playingringtoneaudioplaying=!0}else PutToDebugLog(5,"EVENT, webrtcapi: startRingTone play ring device not found: ("+audiooutput_name.length.toString()+") "+n)}catch(a){PutToDebugLogException(2,"webrtcapi: startRingToneDevice",a)}if(!e){var i=document.getElementById("ringtone");if(webphone_api.common.isNull(i))return void PutToDebugLog(2,"EVENT, webrtcapi: startRingTone is NULL");PutToDebugLog(5,"EVENT, webrtcapi: startRingTone play"),!0!==webphone_api.rt_loaded&&PutToDebugLog(2,"WARNING,webrtcapi: startRingTone cannot load media"),!0!==webphone_api.rt_canplay&&PutToDebugLog(2,"WARNING,webrtcapi: startRingTone cannot play through media"),i.play?i.play():(i=document.getElementById("ringtone"),i&&i.play?i.play():PutToDebugLog(2,"EVENT, webrtcapi: startRingTone play function is not available: "+i.play))}}catch(a){PutToDebugLogException(2,"webrtcapi: startRingTone",a)}}function stopRingTone(){try{if(null!=playingringtoneaudio&&playingringtoneaudioplaying){playingringtoneaudioplaying=!1;try{playingringtoneaudio.pause(),playingringtoneaudio.currentTime=0}catch(n){PutToDebugLogException(2,"webrtcapi: stopRingToneDevice",n)}}if(webphone_api.common.GetParameterInt("playring",2)<0)return;var e=document.getElementById("ringtone");if(webphone_api.common.isNull(e))return void PutToDebugLog(2,"EVENT, webrtcapi: stopRingTone is NULL");!0!==webphone_api.rt_loaded&&PutToDebugLog(2,"WARNING,webrtcapi: stopRingTone cannot load media"),e&&e.pause?e.pause():(e=document.getElementById("ringtone"),e&&e.pause?e.pause():PutToDebugLog(2,"EVENT, webrtcapi: stopRingTone pause function is not available: "+e.pause))}catch(n){PutToDebugLogException(2,"webrtcapi: stopRingTone",n)}}function startRingbackTone(){try{var e=webphone_api.common.GetParameterInt("playring",2);if(e<1)return;var n=document.getElementById("ringbacktone");if(webphone_api.common.isNull(n))return void PutToDebugLog(2,"EVENT, webrtcapi: startRingbackTone is NULL");if(PutToDebugLog(4,"EVENT, webrtcapi: startRingbackTone play"),!0!==webphone_api.rbt_loaded&&PutToDebugLog(2,"WARNING,webrtcapi: startRingbackTone cannot load media"),!0!==webphone_api.rbt_canplay&&PutToDebugLog(2,"WARNING,webrtcapi: startRingbackTone cannot play through media"),n.play)n.play();else{PutToDebugLog(2,"EVENT, webrtcapi: startRingbackTone play function is not available: "+n.play);var t=document.getElementById("ringtone"),n=document.getElementById("ringbacktone");webphone_api.common.isNull(t)||webphone_api.common.isNull(n)||!0!==webphone_api.rt_loaded||!0!==webphone_api.rt_canplay||!0!==webphone_api.rbt_loaded||!0!==webphone_api.rbt_canplay||!t.play||!n.play?(webphone_api.$(document.body).append('<audio id="audio_remote" autoplay="autoplay" ></audio>'),e>0&&webphone_api.$(document.body).append('<audio id="ringtone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringtone.wav" onloadeddata="webphone_api.rt_loaded = true;" oncanplaythrough="webphone_api.rt_canplay = true;" ></audio>'),e>1&&webphone_api.$(document.body).append('<audio id="ringbacktone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringbacktone.wav" onloadeddata="webphone_api.rbt_loaded = true;" oncanplaythrough="webphone_api.rbt_canplay = true;" ></audio>'),webphone_api.$(document.body).append('<audio id="dtmfTone" src="'+webphone_api.getbasedir2()+'sound/rtc_dtmf.wav" ></audio>'),webphone_api.$(document.body).append('<audio id="justbeep_1" src="'+webphone_api.getbasedir2()+'sound/beep-01.wav" ></audio>'),n=document.getElementById("ringbacktone"),n.play?n.play():PutToDebugLog(2,"WARNING, webrtcapi: startRingbackTone play function is not available B: "+n.play)):(webphone_api.$(document.body).append('<audio id="ringbacktone" loop src="'+webphone_api.getbasedir2()+'sound/rtc_ringbacktone.wav" onloadeddata="webphone_api.rbt_loaded = true;" oncanplaythrough="webphone_api.rbt_canplay = true;" ></audio>'),n=document.getElementById("ringbacktone"),n.play?n.play():PutToDebugLog(2,"WARNING, webrtcapi: startRingbackTone play function is not available C: "+n.play))}}catch(o){PutToDebugLogException(2,"webrtcapi: startRingbackTone",o)}}function stopRingbackTone(){try{if(webphone_api.common.GetParameterInt("playring",2)<1)return;var e=document.getElementById("ringbacktone");if(webphone_api.common.isNull(e))return void PutToDebugLog(2,"EVENT, webrtcapi: stopRingBackTone is NULL");!0!==webphone_api.rbt_loaded&&PutToDebugLog(3,"WARNING,webrtcapi: stopRingbackTone cannot load media"),e&&e.pause?e.pause():PutToDebugLog(2,"EVENT, webrtcapi: stopRingbackTone pause function is not available: "+e+" "+e.pause)}catch(n){PutToDebugLogException(2,"webrtcapi: stopRingbackTone",n)}}function toggleFullScreen(){fullScreen(videoRemote.webkitSupportsFullscreen?!videoRemote.webkitDisplayingFullscreen:!0)}function fullScreen(e){function n(){try{document.exitFullscreen&&(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement)&&document.exitFullscreen()}catch(e){PutToDebugLogException(2,"webrtcapi: ExitFullScreen",e)}}if(bFullScreen=e,void 0!==videoRemote&&null!==videoRemote)if(webphone_api.webrtcstack.tsk_utils_have_webrtc4native()&&bFullScreen&&videoRemote.webkitSupportsFullscreen){if(webphone_api.common.isNull(videoRemote))return!1;bFullScreen?videoRemote.webkitEnterFullScreen():videoRemote.webkitExitFullscreen()}else videoRemote.requestFullscreen?bFullScreen?videoRemote.requestFullscreen():n():videoRemote.mozRequestFullScreen?bFullScreen?videoRemote.mozRequestFullScreen():n():videoRemote.webkitRequestFullscreen&&(bFullScreen?videoRemote.webkitRequestFullscreen():n());else if(webphone_api.webrtcstack.tsk_utils_have_webrtc4npapi())try{window.__o_display_remote&&window.__o_display_remote.setFullScreen(e)}catch(t){webphone_api.common.isNull(divVideo)||divVideo.setAttribute("class",e?"full-screen":"normal-screen")}else webphone_api.common.isNull(divVideo)||divVideo.setAttribute("class",e?"full-screen":"normal-screen")}function showNotifICall(e,n){e&&null!=e||(e=""),n&&null!=n||(n=""),e.length<1&&(e=n),n.length<1&&(n=e),e.length<1&&(e="Unknown"),n.length<1&&(n="Unknown"),n.toLowerCase().indexOf(e.toLowerCase())>=0||(e.toLowerCase().indexOf(n.toLowerCase())>=0?n=e:n.toLowerCase()!=e.toLowerCase()&&(n=n+" ("+e+")")),window.webkitNotifications&&0==window.webkitNotifications.checkPermission()&&(oNotifICall&&oNotifICall.cancel(),oNotifICall=window.webkitNotifications.createNotification(webphone_api.common.GetElementSource()+"images/sipml-34x39.png","Incaming call","Incoming call from "+n),oNotifICall.onclose=function(){oNotifICall=null},oNotifICall.show())}function onKeyUp(e){e=e||window.event,27==e.keyCode?fullScreen(!1):e.ctrlKey&&e.shiftKey&&(65!=e.keyCode&&86!=e.keyCode||(bDisableVideo=65==e.keyCode,txtCallStatus.innerHTML="<i>Video "+(bDisableVideo?"disabled":"enabled")+"</i>",window.localStorage.setItem("org.doubango.expert.disable_video",bDisableVideo)))}function onDivCallCtrlMouseMove(e){try{webphone_api.webrtcstack.tsk_utils_have_stream()&&(btnCall.disabled=!webphone_api.webrtcstack.tsk_utils_have_stream()||!oSipSessionRegister||!oSipSessionRegister.is_connected(),document.getElementById("divCallCtrl").onmousemove=null)}catch(n){}}function uiOnConnectionEvent(e,n){}function uiVideoDisplayEvent(e,n,t,o,i){try{if(!1===webphone_api.common.CanIUseVideo())return void PutToDebugLog(5,"EVENT, uiDisplayEvent ret");if(webphone_api.common.isNull(videoRemote))return void PutToDebugLog(2,"EVENT, webrtcapi uiVideoDisplayEvent videoRemote is NULL");var a=!1;!t&&n&&(webphone_api.common.isNull(o)&&(o=!1),!o&&webphone_api.common.IsInCallEx(i)&&(a=!0)),PutToDebugLog(5,"EVENT, webrtcapi uiVideoDisplayEvent from: "+e+", "+(n?"local":"remote")+" "+(t?"add":"remove")+" "+(o?"force":" ")+" "+(a?"ignore":" ")+", line: "+i);var r=n?videoLocal:videoRemote;t?(r.style.opacity=1,uiVideoDisplayShowHide(11,!0,o,i)):(n&&(a||(r.style.opacity=0)),fullScreen(!1))}catch(l){PutToDebugLogException(2,"webrtcapi: uiVideoDisplayEvent",l)}}function uiVideoDisplayShowHide(e,n,t,o){if(!webphone_api.common.isNull(divVideo))if(n)divVideo.style.height="Microsoft Internet Explorer"==navigator.appName?"100%":"340px",webphone_api.$("#contact_details").hide(),webphone_api.$("#video_container").show(),1===webphone_api.common.GetParameterInt("softphonevideomode",0)&&webphone_api.$("#div_video_fullscreen_button").hide(),PutToDebugLog(2,"EVENT, webrtcapi uiVideoDisplayShowHide video container displayed from: "+e);else{var i=!1;webphone_api.common.isNull(t)&&(t=!1),!t&&webphone_api.common.IsInCallEx(o)&&(i=!0),PutToDebugLog(5,"EVENT, webrtcapi uiVideoDisplayShowHide video container hided from: "+e+", "+(t?"force":" ")+" "+(i?"ignore":" ")+", line: "+o),i||(divVideo.style.height="0px",webphone_api.$("#contact_details").show(),webphone_api.$("#video_container").hide())}}function uiBtnCallSetText(e){switch(e){case"Call":var n=window.localStorage&&"true"==window.localStorage.getItem("org.doubango.expert.disable_callbtn_options");btnCall.value=btnCall.innerHTML=n?"Call":'Call <span id="spanCaret" class="caret">',btnCall.setAttribute("class",n?"btn btn-primary":"btn btn-primary dropdown-toggle"),btnCall.onclick=n?function(){SipCall(bDisableVideo?"call-audio":"call-audiovideo")}:null,ulCallOptions.style.visibility=n?"hidden":"visible",n||ulCallOptions.parentNode==divBtnCallGroup?n&&ulCallOptions.parentNode==divBtnCallGroup&&document.body.appendChild(ulCallOptions):divBtnCallGroup.appendChild(ulCallOptions);break;default:btnCall.value=btnCall.innerHTML=e,btnCall.setAttribute("class","btn btn-primary"),btnCall.onclick=function(){SipCall(bDisableVideo?"call-audio":"call-audiovideo")},ulCallOptions.style.visibility="hidden",ulCallOptions.parentNode==divBtnCallGroup&&document.body.appendChild(ulCallOptions)}}function uiCallTerminated(e,n){webphone_api.global.restartice_time=0,oSipSessionCall=null,stopRingbackTone(),stopRingTone(),uiVideoDisplayShowHide(13,!1,!1,n),oNotifICall&&(oNotifICall.cancel(),oNotifICall=null),
uiVideoDisplayEvent(3,!1,!1,!1,n),uiVideoDisplayEvent(4,!0,!1,!1,n);var t=webphone_api.global.aline;void 0!==n&&null!==n&&webphone_api.common.IsNumber(n)&&webphone_api.common.StrToIntDef(n,-5)>0&&(t=n),PutToDebugLog(1,"STATUS,-1,"+e),"Call Finished"===e&&PutToDebugLog(1,"STATUS,"+t.toString()+",Finished")}function GetRegisterivalWebRTC(){try{var e=webphone_api.common.GetParameter2("registerinterval");return(webphone_api.common.isNull(e)||e.length<1||!webphone_api.common.IsNumber(e))&&(e=0),e<5&&(e=webphone_api.common.GetConfigInt("registerinterval",0)),e<5&&(e=200),-1==webphone_api.global.recwsload&&(webphone_api.global.recwsload=webphone_api.common.GetParameter("lastrecwsload",-2)),webphone_api.global.recwsload>1&&e<400&&(e=600),e}catch(n){PutToDebugLogException(2,"webrtcapi: GetRegisterivalWebRTC",n)}return 200}function TerminateRegexTimer(){webphone_api.common.isNull(regextimer)||clearInterval(regextimer),regextimer=null,regex_idx=0}function RegisterEx(e){try{if(webphone_api.common.isNull(e)||e.length<5)return;var n=null,t=";";if(e.indexOf(";")<0&&"#"==e[e.length-1]&&(t="#"),";"==t&&(e+=t),n=e.split(t),webphone_api.common.isNull(n)||n.length<1)return;TerminateRegexTimer();var o=0;regextimer=setInterval(function(){if(++o>25)return void TerminateRegexTimer();if(webphone_api.common.isNull(n)||n.length<1)return void TerminateRegexTimer();var e=n.shift();if(!webphone_api.common.isNull(e)){var t=e.split(",");webphone_api.common.isNull(t)||t.length<3||(webphone_api.common.isNull(lw_namespace_arr)&&(lw_namespace_arr=[]),webphone_api.common.isNull(lw_account_arr)&&(lw_account_arr=[]),lw_namespace_arr.push("webrtcstack"+regex_idx),lw_account_arr.push(t),LoadWebrtc(function(e,n,t){webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, webrtcapi: extra sipstack loaded "+regex_idx.toString()+" "+n)},"webrtcstack"+regex_idx,t),regex_idx++)}},1500)}catch(i){PutToDebugLogException(2,"webrtcapi: RegisterEx",i)}}function LoadWebrtcCb(avail,namespc,oneacc){function onSEventStack(e){function n(n){PutToDebugLog(5,"EVENT, ExSessionEvent_"+authusername+": "+e.type+", "+e.description)}try{if(PutToDebugLog(5,"EVENT, ExStackEvent_"+authusername+": "+e.type+", "+e.description),"started"===e.type){if(PutToDebugLog(2,"EVENT, webrtc stack event: "+e.type+" [extra acount]"),!0===webphone_api.common.NeedRegister()){var t=200;!webphone_api.common.isNull(aival)&&webphone_api.common.IsNumber(aival)&&(t=aival);var o=this.newSession("register",{expires:t,events_listener:{events:"*",listener:n},sip_caps:[{name:"+g.oma.sip-im",value:null},{name:"+audio",value:null}]});o.register(),extraregsessions.push(o)}}else"terminating"===e.type||"terminated"===e.type||"stopping"===e.type||"stopped"===e.type||"failed_to_start"===e.type||"failed_to_stop"===e.type?PutToDebugLog(2,"EVENT, webrtc stack event: "+e.type+" [extra acount]"):"starting"!==e.type||"terminating"!==e.type||"terminated"!==e.type?onSipEventStack(e,!0):PutToDebugLog(2,"EVENT, webrtc stack event: "+e.type+" [extra acount]")}catch(i){PutToDebugLogException(2,"webrtcapi: ExEventStack_"+authusername,i)}}try{if(PutToDebugLog(2,"EVENT, webrtcapi: LoadWebrtc extrareg returned: "+avail+"; namespace: "+namespc),webphone_api.common.isNull(namespc))return void PutToDebugLog(2,"ERROR, webrtcapi: LoadWebrtc extrareg namespace is NULL");if(webphone_api.common.isNull(oneacc)||oneacc.length<3)return void PutToDebugLog(2,"ERROR, webrtcapi: LoadWebrtc extrareg account is NULL");PutToDebugLog(2,"EVENT, RegisterEx: "+oneacc.toString());var asrv=oneacc[0],callerid=oneacc[1],apwd=oneacc[2],aival=180;aival=oneacc.length>3&&!webphone_api.common.isNull(oneacc[3])&&oneacc[3].length>0&&webphone_api.common.IsNumber(oneacc[3])?webphone_api.common.StrToIntDef(oneacc[3],aival):webphone_api.common.GetParameterInt("registerinterval",180);var proxy="",realm="",authusername="",displayname="",transport=-2;if(oneacc.length>4&&!webphone_api.common.isNull(oneacc[4])&&oneacc[4].length>0&&(proxy=oneacc[4]),oneacc.length>5&&!webphone_api.common.isNull(oneacc[5])&&oneacc[5].length>0&&(realm=oneacc[5]),oneacc.length>6&&!webphone_api.common.isNull(oneacc[6])&&oneacc[6].length>0&&(authusername=oneacc[6]),oneacc.length>7&&!webphone_api.common.isNull(oneacc[7])&&oneacc[7].length>0&&(displayname=oneacc[7]),oneacc.length>8&&!webphone_api.common.isNull(oneacc[8])&&oneacc[8].length>0&&(transport=webphone_api.common.StrToIntDef(oneacc[8],transport)),(webphone_api.common.isNull(authusername)||authusername.length<1)&&(authusername=callerid),webphone_api.common.isNull(authusername)||authusername.length<1||webphone_api.common.isNull(apwd)||apwd.length<1)return void PutToDebugLog(2,"ERROR, RegisterEx invalid account");(webphone_api.common.isNull(callerid)||callerid.length<1)&&(callerid=authusername),(webphone_api.common.isNull(displayname)||displayname.length<1)&&(displayname=webphone_api.common.GetUsernamePart(callerid));var password=webphone_api.common.B64Dec(apwd),rawsipaddress=asrv;(webphone_api.common.isNull(rawsipaddress)||rawsipaddress.length<1)&&(rawsipaddress=proxy),(webphone_api.common.isNull(rawsipaddress)||rawsipaddress.length<1)&&(rawsipaddress=webphone_api.common.GetUDPServerAddress());var sipaddress=rawsipaddress;sipaddress.indexOf("udp:")<0&&(sipaddress="udp://"+sipaddress);var proxyaddress=proxy;if((webphone_api.common.isNull(proxyaddress)||proxyaddress.length<1)&&!0===webphone_api.common.IsMizuServerOrGateway()&&(proxyaddress=sipaddress),proxyaddress=webphone_api.common.GetProxyaddress(proxyaddress),proxyaddress.length>0&&0!=proxyaddress.indexOf("udp:")&&0!=proxyaddress.indexOf("udp:")&&0!=proxyaddress.indexOf("tls:"))if(webphone_api.common.IsMizuServerOrGateway())proxyaddress="udp://"+proxyaddress;else{transport<-1&&(transport=webphone_api.common.GetParameterInt("transport",0));var transpStr="udp";1===transport?transpStr="tcp":2===transport&&(transpStr="tls"),transpStr.indexOf(":")<0&&(transpStr+="://"),proxyaddress=transpStr+proxyaddress}var wsaddr=webphone_api.common.GetWebrtcSrvAddr();if(2===webphone_api.common.GetConfigInt("usemizuwebrtcgateway",1)&&(wsaddr=""),webphone_api.common.isNull(wsaddr)||wsaddr.length<2){wsaddr=webphone_api.common.GetWp();var wstmp=wsaddr;wstmp.indexOf("//")>=0&&(wstmp=wstmp.substring(wstmp.indexOf("//")+2,wstmp.length)),wstmp.indexOf(":")>0&&(wstmp=wstmp.substring(0,wstmp.indexOf(":")))}else wsaddr=webphone_api.common.Trim(wsaddr.toLowerCase());wsaddr=wsaddr.replace("*",""),wsaddr=wsaddr.toLowerCase(),wsaddr=wsaddr.replace("udp://",""),wsaddr=wsaddr.replace("tcp://",""),wsaddr=wsaddr.replace("http://",""),wsaddr=wsaddr.replace("https://","");var wsaddress=wsaddr;wsaddress.indexOf("ws:")<0&&wsaddress.indexOf("wss:")<0&&(wsaddress="ws://"+wsaddress);var hostmp=location.host.toLowerCase();!1!==webphone_api.common.IsIPAddrress(wsaddress)&&!0!==webphone_api.common.BrowserRequiresHttps(!0)||(wsaddress=wsaddress.replace("ws:","wss:")),(webphone_api.common.isNull(realm)||realm.length<1)&&(realm=udpaddr,realm=webphone_api.common.NormalizeInput(realm,0),realm.indexOf(":")>0&&(realm=realm.substring(0,realm.indexOf(":"))),realm=webphone_api.common.Trim(realm));var sipuri=callerid;sipuri.indexOf("sip:")<0&&(sipuri="sip:"+callerid),sipuri.indexOf("@")<0&&(sipuri=sipuri+"@"+realm);var enableRTCWebBreaker=!0;enableRTCWebBreaker=!(!webphone_api.common.isNull(webphone_api.parameters.rtcbreaker)&&0===webphone_api.parameters.rtcbreaker)&&(!webphone_api.common.isNull(webphone_api.parameters.rtcbreaker)&&1===webphone_api.parameters.rtcbreaker||!webphone_api.common.IsMizuServerOrGateway());var organization=webphone_api.common.GetConfig("companyname");(webphone_api.common.isNull(organization)||organization.length<1)&&(organization=webphone_api.common.GetConfig("brandname"),(webphone_api.common.isNull(organization)||organization.length<1)&&(organization="Mizutech"));var ua=webphone_api.common.GetUA();webphone_api.common.GetParameter("useragent").length>0&&!1===webphone_api.common.IsMizuReallyPublicWebRTCGateway()&&(ua=webphone_api.common.GetParameter("useragent"));var sheaders=[{name:"User-Agent",value:ua},{name:"Organization",value:organization},{name:"X-Webdomain",value:webphone_api.common.GetWebdomain()}],xhval="1";!0===webphone_api.common.Hasesw()?xhval="2":!0===webphone_api.common.Us()&&(xhval="0"),sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-LS",sipheaders[sipheaders.length-1].value=xhval;var company=webphone_api.common.GetParameter("companyname");!webphone_api.common.isNull(company)&&company.length>0&&(sheaders[sheaders.length]={},sheaders[sheaders.length-1].name="X-Company",sheaders[sheaders.length-1].value=company);var brand=webphone_api.common.GetParameter("brandname");!webphone_api.common.isNull(brand)&&brand.length>0&&(sheaders[sheaders.length]={},sheaders[sheaders.length-1].name="X-Brand",sheaders[sheaders.length-1].value=brand);var uppsrv=webphone_api.common.GetWebrtcSyUpperHeader("RegisterEx");uppsrv.length>0&&(sheaders[sheaders.length]={},sheaders[sheaders.length-1].name="X-Sy.Uppersrv",sheaders[sheaders.length-1].value=uppsrv);var uppsrvd=webphone_api.common.GetWebrtcSyUpperDomainHeader("RegisterEx");uppsrvd.length>0&&(sheaders[sheaders.length]={},sheaders[sheaders.length-1].name="X-Sy.Uppersrvd",sheaders[sheaders.length-1].value=uppsrvd);var dtmfmode=webphone_api.common.GetParameterInt("dtmfmode",2);4==dtmfmode&&(sheaders[sheaders.length]={},sheaders[sheaders.length-1].name="X-MFlag",sheaders[sheaders.length-1].value="2");var p2psignaling=webphone_api.common.GetParameterInt("p2psignaling",1);if(1!==p2psignaling){var valTmp="no";2===p2psignaling?valTmp="proxy":2===p2psignaling&&(valTmp="process"),sipheaders[sipheaders.length]={},sipheaders[sipheaders.length-1].name="X-P2P",sipheaders[sipheaders.length-1].value=valTmp}sheaders=RemoveDuplicateHeader(sheaders),webphone_api.common.CanLog(2)&&((webphone_api.common.isNull(authusername)||authusername.length<1)&&PutToDebugLog(2,"ERROR, WebRTC RegisterEx invalid username: "+authusername),(webphone_api.common.isNull(password)||password.length<1)&&PutToDebugLog(2,"ERROR, WebRTC RegisterEx invalid password: "+password),(webphone_api.common.isNull(sipuri)||sipuri.length<2||sipuri.indexOf("@")<1||sipuri.indexOf(".")<1)&&PutToDebugLog(2,"ERROR, WebRTC RegisterEx invalid sipuri: "+sipuri));var stun_turn=[],stun=webphone_api.common.GetStunServersStr(),turn=webphone_api.common.GetTurnSrv();if(!webphone_api.common.isNull(stun)&&stun.length>2){var sarr=stun.split(","),useurls=!1;if(("Chrome"===webphone_api.common.GetBrowser()&&webphone_api.common.GetBrowserVersion()>40||"Firefox"===webphone_api.common.GetBrowser()&&webphone_api.common.GetBrowserVersion()>40)&&(useurls=!0),!webphone_api.common.isNull(sarr))for(var i=0;i<sarr.length;i++)if(!(webphone_api.common.isNull(sarr[i])||sarr[i].length<1))if(!0===useurls){var obj={urls:sarr[i]};stun_turn.push(obj)}else{var obj={url:sarr[i]};stun_turn.push(obj)}}if(webphone_api.common.isNull(turn)||webphone_api.common.IsLocalServer()||stun_turn.push(turn),webphone_api.common.CanLog(3)){var log="";log=log+" username: "+callerid,log=log+" authusername: "+authusername,webphone_api.common.GetLogLevel()>=7||!0===webphone_api.global.isdebugversion&&webphone_api.common.GetLogLevel()>=5?log=log+", password: "+password:!webphone_api.common.isNull(password)&&password.length>0?log+=" password: *":log+=", password: null",log=log+", sipuri: "+sipuri,log=log+", displayname: "+displayname,log=log+", wsaddress: "+wsaddress,log=log+", proxyaddress: "+proxyaddress,log=log+", realm: "+realm,PutToDebugLog(3,"EVENT, Webrtc RegisterEx connection details: "+log)}if(webphone_api.common.IsMizuServerOrGateway()&&webphone_api.plhandler.CallWsuser(!0,authusername,password,udpaddr),webphone_api.common.pgw_selected<0&&webphone_api.common.GetWsAddressCfg(2).length<2){var gwidx=webphone_api.common.PGW_GetGwIndex(wsaddress);gwidx>=0&&(PutToDebugLog(2,"WARNING, decidegw webrtcapi Start manually setting pgateway from: "+webphone_api.global.pgw_selected.toString()+" to: "+gwidx.toString()+", because has not yet selected b"),webphone_api.global.pgw_selected=gwidx)}if(!webphone_api.common.isNull(stun_turn)&&stun_turn.length>0){for(var i=0;i<stun_turn.length;i++)if(!webphone_api.common.isNull(stun_turn[i])){var sobj=stun_turn[i];for(var key in sobj){var msgtmp="RegisterEx turn server";!webphone_api.common.isNull(sobj[key])&&sobj[key].toString().indexOf("stun")>=0&&(msgtmp="RegisterEx stun server"),PutToDebugLog(3,msgtmp+"["+i+"]: "+key+": "+sobj[key])}}}else PutToDebugLog(3,"EVENT, RegisterEx stun server: NOT set");var iceobj=null,icestr=webphone_api.common.GetParameter("ice");if(!webphone_api.common.isNull(icestr)&&icestr.length>0)try{iceobj=eval(icestr)}catch(eice){iceobj=null,PutToDebugLogException(2,"ERROR, RegisterEx webrtcapi parse ICE servers",eice)}if(!webphone_api.common.isNull(iceobj)){try{PutToDebugLog(2,"EVENT, RegisterEx webrtcapi found ICE (STUN/TURN) server: "+JSON.stringify(iceobj))}catch(eice2){}stun_turn=iceobj}var earlymediaint=webphone_api.common.GetParameterInt("earlymedia",2),earlymedia=!0;earlymediaint<1&&(earlymedia=!1),webphone_api.common.isNull(extraregsessions)&&(extraregsessions=[]);var sStack=new webphone_api[namespc].SIPml.Stack({realm:realm,impi:authusername,impu:sipuri,password:password,display_name:displayname,websocket_proxy_url:wsaddress,outbound_proxy_url:proxyaddress,ice_servers:stun_turn,enable_rtcweb_breaker:enableRTCWebBreaker,events_listener:{events:"*",listener:onSEventStack},enable_early_ims:earlymedia,enable_media_stream_cache:!0,bandwidth:null,video_size:null,sip_headers:sheaders});webphone_api.common.isNull(registerExSipstackArray)&&(registerExSipstackArray=[]),0!=sStack.start()?PutToDebugLog(2,"ERROR, webrtcapi: RegisterEx, Failed to start SIP stack sipuri: "+sipuri+"; password: "+password):registerExSipstackArray.push(sStack)}catch(err){PutToDebugLogException(2,"webrtcapi: LoadWebrtcCb",err)}}function ResendRegister(){try{oSipSessionRegister&&oSipSessionRegister.register?(PutToDebugLog(2,"EVENT, ResendRegister resending..."),sipheaders=RemoveDuplicateHeader(sipheaders),oSipSessionRegister.setConfiguration({sip_headers:sipheaders}),oSipSessionRegister.register()):PutToDebugLog(2,"ERROR, ResendRegister failed, invalid register session"),webphone_api.common.isNull(check_reg_timer)||clearTimeout(check_reg_timer),check_reg_timer=null,check_reg_timer=setTimeout(function(){try{if(webphone_api.common.GetTickCount()-webphone_api.global.webrtclastregsent>3e3){if(PutToDebugLog(2,"WARNING, ResendRegister: restart SipStack, because REGISTER was not resent"),!0===webphone_api.isincall())return void PutToDebugLog(2,"WARNING, ResendRegister: skip SipStack restart, because a call is in progress");ReStart(1,!0)}}catch(e){PutToDebugLogException(2,"webrtcapi: ResendRegister inner timer",e)}},2900)}catch(e){PutToDebugLogException(2,"webrtcapi: ResendRegister",e)}}function GetSIPCallIDFromEvent(e){var n="";try{if(webphone_api.common.isNull(e))return n;var t="recv=\n"+e.o_event.o_message;if(webphone_api.common.isNull(t)||t.length<8)return n;n=webphone_api.common.StrGetBetween(t,"\nCall-ID:","\r").trim(),n.length<3&&(n=webphone_api.common.StrGetBetween(t,"\nXCall-ID:","\r").trim(),n.length<4&&(n=webphone_api.common.StrGetBetween(t,"\nX-C-Call-ID:","\r").trim()),n.length<4&&(n=webphone_api.common.StrGetBetween(t,"\nX-Call-ID:","\r").trim()),n.length<4&&(n=webphone_api.common.StrGetBetween(t,"\ni:","\r").trim()),n.length<4&&(n=webphone_api.common.StrGetBetween(t,"Call-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\nCall-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\nXCall-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\nX-Call-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\nX-C-Call-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\ni:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"Call-ID:","\r").trim()))}catch(o){}return n}function GetSIPXCallIDFromEvent(e){var n="";try{if(webphone_api.common.isNull(e))return n;var t="recv=\n"+e.o_event.o_message;if(webphone_api.common.isNull(t)||t.length<8)return n;n=webphone_api.common.StrGetBetween(t,"\nX-C-Call-ID:","\r").trim(),n.length<3&&(n=webphone_api.common.StrGetBetween(t,"\nX-Call-ID:","\r").trim(),n.length<4&&(n=webphone_api.common.StrGetBetween(t,"\nX-C-Call-ID:","\r").trim()),n.length<4&&(n=webphone_api.common.StrGetBetween(t,"\nXCall-ID:","\r").trim()),n.length<4&&(n=webphone_api.common.StrGetBetween(t,"\nCall-ID:","\r").trim()),n.length<4&&(n=webphone_api.common.StrGetBetween(t,"\ni:","\r").trim()),n.length<4&&(n=webphone_api.common.StrGetBetween(t,"Call-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\nX-C-Call-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\nX-Call-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\nX-C-Call-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\nXCall-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\nCall-ID:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"\ni:","\r").trim()),n.length<1&&(n=webphone_api.common.StrGetBetween(t,"Call-ID:","\r").trim()))}catch(o){}return n}function GetSipHeaderFromEvent(e,n){try{if(webphone_api.common.isNull(e))return"";var t="recv=\n"+e.o_event.o_message;return webphone_api.common.isNull(t)||t.length<8?"":webphone_api.common.GetSipHeaderFromMsg(t,n)}catch(o){}return""}function GetDisplayNameFromURI(e){try{if(webphone_api.common.isNull(e)||e.length<4)return"";if(e=webphone_api.common.Trim(e),e.length<4)return"";if("<"==e[0])return"";if('"'==e[0])return webphone_api.common.Trim(webphone_api.common.StrGetBetween(e,'"','"'));if(0==e.indexOf("sip:")||0==e.indexOf("sips:")||0==e.indexOf("tel:"))return"";if(e.indexOf("<")>=0&&e.indexOf(">")>=0&&e.indexOf("@")>=0)return webphone_api.common.Trim(webphone_api.common.StrGetUntill(e,"<"))}catch(n){}return""}function StartReRegister(e){try{if(webphone_api.common.GetParameterInt("forcereregister",1)<1)return;if(!0===e&&!0===reregstarted)return;if(webphone_api.global.phonestarted<1)return void(reregstarted=!1);reregstarted=!0,webphone_api.common.isNull(rereg_timer)||clearTimeout(rereg_timer),rereg_timer=null,rereg_timer=setTimeout(function(){if(webphone_api.global.phonestarted<1)return webphone_api.common.isNull(rereg_timer)||clearTimeout(rereg_timer),rereg_timer=null,reregstarted=!1,rereg_ival=1e4,void(webphone_api.global.webrtc_regstate=-1);if(1===webphone_api.global.webrtc_regstate)return void StartReRegister(!1);if(0===webphone_api.global.webrtc_regstate){rereg_ival<12e4?rereg_ival*=2:rereg_ival=1e4;var e=webphone_api.common.GetParameterInt("forcereregister",1);0===rereg_action&&oSipSessionRegister&&oSipSessionRegister.register?(PutToDebugLog(2,"ERROR, ReRegister new session (forcereregister: "+e.toString()+")"),rereg_action=1,ResendRegister()):(PutToDebugLog(2,"ERROR, ReRegister restart SipStack (forcereregister: "+e.toString()+")"),rereg_action=0,ReStart(1,!0)),StartReRegister(!1)}},rereg_ival)}catch(n){PutToDebugLogException(2,"webrtcapi: StartReRegister",n)}}function onSipEventStack(e,n){try{switch(webphone_api.global.isdebugversionwebrtc&&console.log("WRTCEVENT_STACK: "+e.type+", "+e.description),webphone_api.common.isNull(n)&&(n=!1),n?PutToDebugLog(2,"EVENT, webrtc stack event: "+e.type+" [extraacount]"):PutToDebugLog(2,"EVENT, webrtc stack event: "+e.type),e.type){case"started":(webphone_api.common.isNull(webphone_api.common.getuseengine())||webphone_api.common.getuseengine().length<1)&&(webphone_api.global.last_useengine=webphone_api.global.ENGINE_WEBRTC),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(webphone_api.global.iscurrengineworking=!0),webphone_api.common.SaveParameter("lastsessionsuccess","2");var t=webphone_api.common.GetParameter("lastwebrtcserver");t.length>0&&webphone_api.common.SaveParameter("lastgoodwebrtcserver",t),t==webphone_api.common.GetParameter("lastbadwebrtcserver")&&webphone_api.common.SaveParameter("lastbadwebrtcserver","");try{!0===webphone_api.common.NeedRegister()?(oSipSessionRegister=this.newSession("register",{expires:GetRegisterivalWebRTC(),events_listener:{events:"*",listener:onSipEventSession},sip_caps:[{name:"+g.oma.sip-im",value:null},{name:"+audio",value:null}]}),oSipSessionRegister&&(sipheaders=RemoveDuplicateHeader(sipheaders),oSipSessionRegister.setConfiguration({sip_headers:sipheaders})),oSipSessionRegister.register()):PutToDebugLog(1,"STATUS,-1,Ready.")}catch(e){PutToDebugLog(2,"ERROR, webrtcapi: onSipEventStack register")}break;case"stopping":case"stopped":case"failed_to_start":case"failed_to_stop":"failed_to_start"==e.type||e.type;if(n||(oSipStack=null,oSipSessionRegister=null,oSipSessionCall=null,uiOnConnectionEvent(!1,!1),stopRingbackTone(),stopRingTone(),uiVideoDisplayShowHide(19,!1,!0,-5)),"failed_to_start"==e.type){if(1==webphone_api.global.sipstackstarted&&!n){PutToDebugLog(1,"ERROR,-1,Register failed"),PutToDebugLog(2,"ERROR, webrtcapi: onSipEventStack failed_to_start");var t=webphone_api.common.GetParameter("lastwebrtcserver");t.length>0&&webphone_api.common.SaveParameter("lastbadwebrtcserver",t),t==webphone_api.common.GetParameter("lastgoodwebrtcserver")&&webphone_api.common.SaveParameter("lastgoodwebrtcserver",""),webphone_api.common.CheckInternetConnection(),webphone_api.common.CheckInternetConnectionWS(),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(webphone_api.global.iscurrengineworking=!1),webphone_api.onRegStateChangeCb("failed","WebRTC failed to start"),ReStart()}}else"failed_to_stop"==e.type?(PutToDebugLog(1,"ERROR,-1,UnRegister failed"),PutToDebugLog(2,"ERROR, webrtcapi: onSipEventStack failed_to_stop")):"stopping"==e.type?PutToDebugLog(2,"EVENT, WebRTC sipstack stopping"):"stopped"==e.type&&(PutToDebugLog(2,"EVENT, WebRTC sipstack stopped"),!0!==webphone_api.global.sipstackstarted||n||(webphone_api.common.CheckInternetConnection(),webphone_api.common.CheckInternetConnectionWS(),webphone_api.global.webrtcsipsignalingreceived=0,ReStart()));n||(webphone_api.global.webrtc_regstate=0);break;case"i_new_call":if(webphone_api.common.RemoveSipHeadreFromCache("X-reason"),webphone_api.common.RemoveSipHeadreFromCache("Reason"),webphone_api.common.RemoveSipHeadreFromCache("Warning"),(webphone_api.common.isNull(webphone_api.common.getuseengine())||webphone_api.common.getuseengine().length<1)&&(webphone_api.global.last_useengine=webphone_api.global.ENGINE_WEBRTC),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(webphone_api.global.iscurrengineworking=!0),e&&null!==e&&e.newSession&&null!==e.newSession?e.newSession.tryingdone=!0:e&&null!==e&&e.session&&null!==e.session&&(e.session.tryingdone=!0),istypeincoming=!0,!0===webphone_api.global.dontSendSignaling&&webphone_api.global.dontSendSignalingTimer>0&&webphone_api.common.GetTickCount()-webphone_api.global.dontSendSignalingTimer<200)return PutToDebugLog(2,"EVENT, webrtcapi, API_Hangup call because retrying with optimized SDP"),void e.newSession.hangup();if(!webphone_api.common.onc()){var o=[];o.push("h"),o.push("a"),o.push("n"),o.push("g"),o.push("u"),o.push("p"),o.push(" "),o.push("5"),o.push(" ");return PutToDebugLog(2,"EVENT, "+o.join("")),SipHangup(!0,-2),void e.newSession.hangup()}webphone_api.common.SaveParameter("lastsessionsuccess","2");var i="";try{i="recv=\n"+e.o_event.o_message}catch(x){PutToDebugLogException(2,"webrtcapi: onSipEventStack i_new_call getmsg",x)}webphone_api.common.isNull(i)&&(i="");var a=GetSIPCallIDFromEvent(e),r="",l="",s="Unknown";if(e.newSession&&null!==e.newSession&&(r=e.newSession.getRemoteName(),l=e.newSession.getRemoteFriendlyName(),webphone_api.common.isNull(r)&&(r=""),webphone_api.common.isNull(l)&&(l=""),r=webphone_api.common.Trim(r),l=webphone_api.common.Trim(l),(l.length<1||l===r)&&(l=GetDisplayNameFromURI(GetSipHeaderFromEvent(e,"From")),l.length>0&&l!=r&&e.newSession.o_session&&null!=e.newSession.o_session&&!e.newSession.o_session.b_local&&e.newSession.o_session.o_uri_from&&null!=e.newSession.o_session.o_uri_from&&(!e.newSession.o_session.o_uri_from.s_display_name||null==e.newSession.o_session.o_uri_from.s_display_name||e.newSession.o_session.o_uri_from.s_display_name.length<1)&&(e.newSession.o_session.o_uri_from.s_display_name=l)),s=r,s.length<1&&(s=l),l!=r&&r.length>0&&l.length>0&&(s=l+" - "+r)),!0===webphone_api.common.UsePresence2()&&"dnd"===webphone_api.common.GetParameter("presencestatus").toLowerCase())return PutToDebugLog(2,"EVENT, webrtcapi hangup incoming call, because presence is DND"),e.newSession.hangup(),"undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications&&webphone_api.notifications.AddToCallLog(r,"2","",0,webphone_api.global.aline,"Rejected on DND",l),setTimeout(function(){SendRegisteredStatus()},500),setTimeout(function(){SendRegisteredStatus()},1e3),void(webphone_api.global.webrtc_regstate=1);var p=webphone_api.common.GetParameter2("autoignore");(webphone_api.common.isNull(p)||1!==p.length)&&(p="0");var c=webphone_api.common.StrToInt(p);if(c>1)return PutToDebugLog(3,"EVENT, autoignore WebRTC hangup(reject)"),e.newSession.hangup(),void("undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications&&webphone_api.notifications.AddToCallLog(r,"2","",0,webphone_api.global.aline,"Ignored",l));if(1===c)return void PutToDebugLog(3,"EVENT, autoignore WebRTC silent ignore");var u=webphone_api.common.GetNrOfActiveCalls();if(u>0&&r.length>0&&r===webphone_api.global.currcallnumber){var g=webphone_api.common.GetParameterInt("dropsameoldcall",0);if(1===g){var h=GetSipHeaderFromEvent(e,"X-Autorecall");if(webphone_api.common.isNull(h)&&(h=""),h=webphone_api.common.Trim(h),"yes"===(h=h.toLowerCase()))return PutToDebugLog(2,"EVENT, webrtcapi hangup incoming call, dropsameoldcall(1) from: "+r),void e.newSession.hangup()}else if(2===g){var h=GetSipHeaderFromEvent(e,"X-Autorecall");if(webphone_api.common.isNull(h)&&(h=""),h=webphone_api.common.Trim(h),h=h.toLowerCase(),!0===webphone_api.global.isvideocall&&"yes"===h)return PutToDebugLog(2,"EVENT, webrtcapi hangup incoming call, dropsameoldcall(2) from: "+r),void e.newSession.hangup()}else if(3===g)return PutToDebugLog(2,"EVENT, webrtcapi hangup incoming call, dropsameoldcall(3) from: "+r),void e.newSession.hangup()}var m=webphone_api.common.GetParameter2("callforwardalways");if(!webphone_api.common.isNull(m)&&m.length>1)return Forward(m,i,e.newSession),void("undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications&&webphone_api.notifications.AddToCallLog(r,"2","",0,webphone_api.global.aline,"Forwarded",l));if(u>0){var d=webphone_api.common.GetParameter2("rejectonbusy");if("true"===d||"1"===d)return PutToDebugLog(2,"EVENT, webrtcapi hangup incoming call, because rejectonbusy is: "+d),e.newSession.hangup(),void("undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications&&webphone_api.notifications.AddToCallLog(r,"2","",0,webphone_api.global.aline,"Rejected on busy",l));if(1!==webphone_api.common.IsMultiline())return webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, not multiline and call already in progress"),e.newSession.hangup(),void("undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications&&webphone_api.notifications.AddToCallLog(r,"2","",0,webphone_api.global.aline,"Rejected on single-line",l));var b=webphone_api.common.GetParameter2("callforwardonbusy");if(!webphone_api.common.isNull(b)&&b.length>1)return Forward(b,i,e.newSession),void("undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications&&webphone_api.notifications.AddToCallLog(r,"2","",0,webphone_api.global.aline,"Forwarded on busy",l))}if(webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, handle webrtc incoming call. cc: "+u.toString()+", ml: "+webphone_api.common.IsMultiline().toString()+" "+webphone_api.common.GetParameter2("multilinegui")+", ln: "+webphone_api.global.aline.toString()),webphone_api.global.rtcincallinit_incoming=webphone_api.common.GetTickCount(),u>0){var _=webphone_api.common.GetFreeLine();webphone_api.common.SetALineInternal(_,20),webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, there are previous calls in progress. using line: "+_.toString()+"/"+webphone_api.global.aline.toString())}else if(1!=webphone_api.global.aline){var _=webphone_api.common.GetFreeLine();webphone_api.common.SetALineInternal(_,20),webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, no previous calls in progress. using line: "+_.toString()+"/"+webphone_api.global.aline.toString())}else webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, no previous calls. using same line: "+webphone_api.global.aline.toString());var f=webphone_api.global.aline;webphone_api.global.restartice_time=webphone_api.common.GetTickCount(),oSipSessionCall=e.newSession,SetSipHeader(1),oSipSessionCall.setConfiguration(HandleOconfigCall(oConfigCall,f));var w=f.toString();webphone_api.common.StrToInt(w)<1&&(f=webphone_api.common.GetFreeLine(),webphone_api.common.SetALineInternal(f,21));var v=null;oSipSessionCall.o_session&&oSipSessionCall.o_session&&oSipSessionCall.o_session.o_stack&&oSipSessionCall.o_session.o_stack.ao_headers&&oSipSessionCall.o_session.o_stack.ao_headers.length>0&&(v=oSipSessionCall.o_session.o_stack.ao_headers),webphone_api.common.SaveCallSession(3,f,oSipSessionCall,r,"2",webphone_api.common.GetTickCount(),-1,-1,"",a,"true","",v,"","","",oSipSessionCall.getId(),GetSIPXCallIDFromEvent(e),l);try{webphone_api.common.CatchWebrtcSignaling(i,webphone_api.common.SIP_INVITE_IN,!0)}catch(x){PutToDebugLogException(2,"webrtcapi: onSipEventStack i_new_call CatchWebrtcSignaling",x)}if(a.length<1){var E=webphone_api.common.GetEndpoint(106,-1,r,a,oSipSessionCall.getId(),!1);!webphone_api.common.isNull(E)&&!webphone_api.common.isNull(E[webphone_api.common.EP_CALLID])&&E[webphone_api.common.EP_CALLID].length>0&&(a=E[webphone_api.common.EP_CALLID])}PutToDebugLog(1,"STATUS,"+f.toString()+",CallSetup,"+r+","+webphone_api.common.GetSipusername(!0)+",2,"+l+",["+a+"],,,,,"),webphone_api.common.SetALineInternal(f,222),showNotifICall(r,l),1===webphone_api.common.GetApibehaviour()&&PutToDebugLog(1,"STATUS,-1,Ringing..."),webphone_api.common.SetALineInternal(f,22),PutToDebugLog(1,"STATUS,"+f.toString()+",Ringing,"+r+","+webphone_api.common.GetSipusername(!0)+",2,"+l+",["+a+"],,,,,"),startRingTone(),PutToDebugLog(1,"STATUS,-1,Incoming..."),webphone_api.common.SetALineInternal(f,23);var P=webphone_api.common.GetParameterBool("autoaccept",!1),T=1;P&&(T=3);var S=webphone_api.common.GetParameterInt("enableautoaccept",T),N=webphone_api.common.GetParameter("autoacceptheader","").toLowerCase(),I=i.toLowerCase();if(3==S||S>0&&N.length>0&&I.indexOf(N)>0||S>=2&&(I.indexOf("auto-answer")>0&&(I.indexOf("auto-answer:normal")>0||I.indexOf("auto-answer: normal")>0||I.indexOf("auto-answer: normal")>0)||I.indexOf("answer-mode")>0&&(I.indexOf("answer-mode:auto")>0||I.indexOf("answer-mode: auto")>0||I.indexOf("answer-mode: auto")>0)||I.indexOf("call-info")>0&&I.indexOf("answer-after")>0||I.indexOf("alert-info")>0&&I.indexOf("alert-autoanswer")>0)){var C=webphone_api.common.GetParameterInt("autoacceptdelay",-1);if(C<0&&I.indexOf("answer-after=")>0){var G=webphone_api.common.StrGetAfter(I,"answer-after=");I.indexOf("\r")>0&&(G=webphone_api.common.StrGetUntill(G,"\r")),I.indexOf(";")>0&&(G=webphone_api.common.StrGetUntill(G,";"));var L=webphone_api.common.StrToIntDef(Trim(G),-1);L>=0&&(C=1e3*L)}return C<800&&(C=800),webphone_api.common.CanLog(4)&&PutToDebugLog(4,"EVENT, autoaccept INVITE sip header: WebRTC will auto-accept call with delay msec: "+C+" on line: "+webphone_api.global.aline.toString()),void setTimeout(function(){webphone_api.common.CanLog(3)&&PutToDebugLog(3,"EVENT, autoaccept INVITE sip header: WebRTC auto-accept with delay msec: "+C),webphone_api.webrtcapi.SipAccept(webphone_api.global.aline,!1,e.newSession)},C)}
var R=webphone_api.common.GetParameter2("calltransferalways");if(!webphone_api.common.isNull(R)&&R.length>1)return webphone_api.common.CanLog(3)&&PutToDebugLog(3,"EVENT, call transfer WebRTC calltransferalways: "+R),webphone_api.global.attendedtransfer_alreadycalled="",webphone_api.global.attendedtransfer_origline=-1,setTimeout(function(){webphone_api.webrtcapi.SipAccept(webphone_api.global.aline,!1,e.newSession),setTimeout(function(){webphone_api.webrtcapi.SipTransferEx(R)},100)},100),void webphone_api.common.PutNotifications2("0","Transfer",s,0);break;case"i_new_message":(webphone_api.common.isNull(webphone_api.common.getuseengine())||webphone_api.common.getuseengine().length<1)&&(webphone_api.global.last_useengine=webphone_api.global.ENGINE_WEBRTC),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(webphone_api.global.iscurrengineworking=!0),webphone_api.common.SaveParameter("lastsessionsuccess","2"),e.newSession.accept();var y=e.newSession.getRemoteName(),o=e.getContentString();if(webphone_api.common.isNull(y)||y.length<1)return void PutToDebugLog(2,"ERROR, webrtcapi: onSipEventStack chat received, from is NULL");if(webphone_api.common.isNull(o)||o.length<1)return void PutToDebugLog(2,"ERROR, webrtcapi: onSipEventStack chat received, from: "+y+"; message is NULL");PutToDebugLog(1,"CHAT,-1,"+y+","+o);break;case"m_permission_requested":PutToDebugLog(5,"EVENT, webrtcapi: permission requested"),webphone_api.global.lastpermreq=webphone_api.common.GetTickCount(),last_event=webphone_api.global.last_event,webphone_api.common.GetNrOfActiveCalls()<1&&(PutToDebugLog(5,"EVENT, webrtcapi: permission requested and will check it soon "),!1===webphone_api.global.webrtcpermissionaccepted&&setTimeout(function(){!1!==webphone_api.global.webrtcpermissionaccepted||1!=webphone_api.global.checkIfCallActive||webphone_api.global.active_incoming_call||PutToDebugLog(1,"STATUS,"+webphone_api.global.aline.toString()+",Waiting for permission")},250),setTimeout(function(){!1!==webphone_api.global.webrtcpermissionaccepted||1!=webphone_api.global.checkIfCallActive||webphone_api.global.active_incoming_call||(PutToDebugLog(5,"EVENT, webrtcapi: no permission yet on request"),PutToDebugLog(1,"STATUS,"+webphone_api.global.aline.toString()+",Waiting for permission"))},3500));break;case"m_permission_accepted":if(PutToDebugLog(5,"EVENT, webrtcapi: MediaStream permission granted "+webphone_api.global.incommingCall.toString()),webphone_api.global.webrtcpermissionaccepted=!0,!webphone_api.common.isNull(last_event)&&last_event.length>0?PutToDebugLog(1,"EVENT,"+last_event):webphone_api.global.laststatusdisplay.indexOf("Waiting for permission")>=0&&PutToDebugLog(1,"STATUS,"+webphone_api.global.aline.toString()+",Permission granted"),RedialOnFail(),!0===webphone_api.global.incommingCall){var D=webphone_api.common.GetTickCount(),O=webphone_api.common.GetParameterInt("acceptcall_onsharedevice",1);2===O?(PutToDebugLog(5,"EVENT, webrtcapi: Accept Call on MediaStream permission granted_1"),SipAccept(webphone_api.global.aline,null,e.session)):1===O&&("Firefox"===webphone_api.common.GetBrowser()&&!1===webphone_api.common.IsHttps()&&webphone_api.common.GetBrowserVersion()<75?(PutToDebugLog(5,"EVENT, webrtcapi: Accept Call on MediaStream permission granted_2"),SipAccept(webphone_api.global.aline,null,e.session)):"Chrome"===webphone_api.common.GetBrowser()&&!0===webphone_api.common.IsLocalFileSystem()?(PutToDebugLog(5,"EVENT, webrtcapi: Accept Call on MediaStream permission granted_3"),SipAccept(webphone_api.global.aline,null,e.session)):webphone_api.global.lastpermreq>0&&D-webphone_api.global.lastpermreq>8e3&&(PutToDebugLog(5,"EVENT, webrtcapi: Accept Call on MediaStream permission granted_4"),SipAccept(webphone_api.global.aline,null,e.session)))}break;case"m_permission_refused":if("m_permission_refused"==e.type){if(webphone_api.global.webrtcpermissionaccepted=!1,PutToDebugLog(5,"EVENT, webrtcapi: MediaStream permission denied"),uiCallTerminated("Media stream permission denied"),!webphone_api.common.isNull(destnumber)&&destnumber.length>0&&"call-audiovideo"===calltype)return PutToDebugLog(2,"WARNING, MediaStream permission denied, retry audio call with no video: "+destnumber),webphone_api.$("#div_video_fullscreen_button").hide(),void SipCall("call-audio",callline,destnumber,!0);PutToDebugLog(2,"EVENT, Hangup incoming call, because MediaStream permission denied: "+destnumber),SipHangup(!0,webphone_api.global.aline),setTimeout(function(){webphone_api.common.MediaStreamPermissionDenied()},150)}}}catch(e){PutToDebugLog(2,"ERROR, webrtcapi: onSipEventStackExtern")}}function IsCallSession(e){var n=-10;try{if(n=-11,webphone_api.common.isNull(e))return-1;if(webphone_api.common.isNull(e.session))return-2;if(e.session==oSipSessionCall)return 1;if(n=-12,!webphone_api.common.isNull(webphone_api.webrtcstack)&&e.session instanceof webphone_api.webrtcstack.SIPml.Session.Call)return 2;if(n=-13,!webphone_api.common.isNull(webphone_api[wen_namespace])&&e.session instanceof webphone_api[wen_namespace].SIPml.Session.Call)return 3;if(n=-14,!webphone_api.common.isNull(webphone_api.wen_namespaces)&&webphone_api.wen_namespaces.length>0){n=-15;for(var t=0;t<webphone_api.wen_namespaces.length;t++)if(n=-16,!webphone_api.common.isNull(webphone_api[webphone_api.wen_namespaces[t]])&&e.session instanceof webphone_api[webphone_api.wen_namespaces[t]].SIPml.Session.Call)return 10+t}return-3}catch(o){PutToDebugLogExceptionWarning(2,"webrtcapi: IsCallSession "+n,o)}return n}function onSipEventSession(e){var n=0;try{if(n=1,webphone_api.common.isNull(e))return void PutToDebugLog(2,"ERROR, invalid session event");webphone_api.global.isdebugversionwebrtc&&console.log("WRTCEVENT_SESSION: "+e.type+", "+e.description),webphone_api.common.SaveParameter("lastsessionsuccess","2");var t=IsCallSession(e);switch(PutToDebugLog(2,"EVENT, webrtc session event: "+e.type+" iscall: "+t.toString()+" "+SessionToString(e.session)),n=2,e.type){case"connecting":case"connected":n=3;var o="connected"==e.type;if(e.session==oSipSessionRegister)n=4,"connecting"==e.type&&PutToDebugLog(1,"STATUS,-1,Registering..."),"connected"==e.type&&(n=5,(webphone_api.common.isNull(webphone_api.common.getuseengine())||webphone_api.common.getuseengine().length<1)&&(webphone_api.global.last_useengine=webphone_api.global.ENGINE_WEBRTC),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(webphone_api.global.iscurrengineworking=!0),isregistered=!0,SendRegisteredStatus(),webphone_api.global.webrtc_regstate=1,e&&null!==e&&e.session&&null!==e.session&&(e.session.tryingdone=!0));else if(e.session==oSipSessionMessage);else if(e.session==oSipSessionTransferCall);else if(t>0){n=6;var i=!1;if(e.session==oSipSessionCall&&(i=!0),!1===i&&!webphone_api.common.isNull(webphone_api.global.ep))for(var a=0;a<webphone_api.global.ep.length;a++){var r=webphone_api.global.ep[a][webphone_api.common.EP_SESSION];if(!webphone_api.common.isNull(r)&&e.session==r){i=!0;break}}if(!0===i){n=7;var l="unknown",s="";e&&null!==e&&e.session&&null!==e.session&&(l=e.session.getRemoteName(),s=e.session.getRemoteFriendlyName());var p="1";istypeincoming&&(p="2");try{if("undefined"!=typeof e.session.o_session&&null!==e.session.o_session&&"undefined"!=typeof e.session.o_session.o_uri_from&&null!==e.session.o_session.o_uri_from&&"undefined"!=typeof e.session.o_session.o_uri_from.s_user_name&&null!==e.session.o_session.o_uri_from.s_user_name&&e.session.o_session.o_uri_from.s_user_name.length>0){var c=e.session.o_session.o_uri_from.s_user_name;!webphone_api.common.isNull(c)&&c.length>0&&(p=webphone_api.common.GetSipusername(!0).toLowerCase()===c.toLowerCase()?"1":"2")}}catch(F){PutToDebugLogException(2,"webrtcapi: onSipEventSession: connecting or connected "+n,F)}n=8;var u=GetSIPCallIDFromEvent(e),g=webphone_api.common.GetEndpoint(107,-1,l,u,e.session.getId(),!1);!webphone_api.common.isNull(g)&&!webphone_api.common.isNull(g[webphone_api.common.EP_CALLID])&&g[webphone_api.common.EP_CALLID].length>0&&(u=g[webphone_api.common.EP_CALLID]);var h=webphone_api.global.aline.toString(),m=webphone_api.common.StrToInt(h);webphone_api.common.isNull(g)||(m=webphone_api.common.StrToIntDef(g[webphone_api.common.EP_LINE],m)),n=9,o?(n=10,stopRingbackTone(),stopRingTone(),oNotifICall&&(oNotifICall.cancel(),oNotifICall=null),PutToDebugLog(1,"STATUS,"+m.toString()+",CallConnect,"+l+","+webphone_api.common.GetSipusername(!0)+","+p+","+s+",["+u+"],,,,,"),webphone_api.common.SaveCallSession(4,webphone_api.global.aline,e.session,l,p,-1,webphone_api.common.GetTickCount(),-1,"",u,"","","","","","",e.session.getId(),GetSIPXCallIDFromEvent(e)),setTimeout(function(){PutToDebugLog(1,"STATUS,-1,In Call"),PutToDebugLog(1,"STATUS,"+m.toString()+",Speaking,"+l+","+webphone_api.common.GetSipusername(!0)+","+p+","+s)},1100),e&&null!==e&&e.session&&null!==e.session&&(e.session.tryingdone=!0),PutToDebugLog(1,"STATUS,-1,Speaking"),"2"===p&&PutToDebugLog(1,"STATUS,"+m.toString()+",InCall,"+l+","+webphone_api.common.GetSipusername(!0)+","+p+","+s)):(n=11,PutToDebugLog(1,"STATUS,"+m.toString()+","+e.description),webphone_api.common.SaveCallSession(5,webphone_api.global.aline,e.session,l,p,webphone_api.common.GetTickCount(),-1,-1,"",u,"","",null,"","","",e.session.getId(),GetSIPXCallIDFromEvent(e))),webphone_api.webrtcstack.SIPml.isWebRtc4AllSupported()&&(n=12,PutToDebugLog(2,"EVENT, webrtc4all supported connect uiVideoDisplayEvent"),uiVideoDisplayEvent(5,!1,!0),uiVideoDisplayEvent(6,!0,!0))}}break;case"terminating":case"terminated":if(n=13,webphone_api.common.isNull(e)||webphone_api.common.isNull(e.session)||e.session!=oSipSessionRegister)if(webphone_api.common.isNull(e)||webphone_api.common.isNull(e.session)||e.session!=oSipSessionMessage)if(webphone_api.common.isNull(e)||webphone_api.common.isNull(e.session)||e.session!=oSipSessionTransferCall)if(t>0){if(n=16,PutToDebugLog(2,"EVENT,EventSession call: "+e.type),webphone_api.global.atransfer_number.length>0&&(-1!=webphone_api.global.atransfer_line||webphone_api.global.atransfer_callid.length>0));else if(e.session===lastsession&&null!=lastsession)return void PutToDebugLog(2,"EVENT, webrtcap: skip terminate because duplicate session received");lastsession=e.session;var l="unknown",s="";e&&null!==e&&e.session&&null!==e.session&&(l=e.session.getRemoteName(),s=e.session.getRemoteFriendlyName());var p="1";istypeincoming&&(p="2"),setTimeout(function(){calltype="",callline=1,destnumber=""},200),n=17;var u=GetSIPCallIDFromEvent(e),d=webphone_api.global.aline,g=webphone_api.common.GetEndpoint(108,webphone_api.global.aline,l,u,e.session.getId(),!1,!0);if(!webphone_api.common.isNull(g)&&!webphone_api.common.isNull(g[webphone_api.common.EP_LINE])&&webphone_api.common.IsNumber(g[webphone_api.common.EP_LINE])&&webphone_api.common.StrToInt(g[webphone_api.common.EP_LINE])>0&&(d=webphone_api.common.StrToIntDef(g[webphone_api.common.EP_LINE],d)),!webphone_api.common.isNull(g)&&!webphone_api.common.isNull(g[webphone_api.common.EP_CALLID])&&g[webphone_api.common.EP_CALLID].length>0&&(u=g[webphone_api.common.EP_CALLID]),n=18,!webphone_api.common.isNull(g)&&"true"===g[webphone_api.common.EP_FINISHEDSENT]||lastsessionid===e.session.getId())PutToDebugLog(3,"EVENT, webrtc finished status already sent for this session");else if(PutToDebugLog(3,"EVENT, finishing webrtc call ("+webphone_api.global.atransfer_number+"/"+webphone_api.global.atransfer_line.toString()+"/"+webphone_api.global.atransfer_callid+")"),webphone_api.common.GetNrOfActiveCalls()<2&&ClearPendingStartMedia(),n=19,lastsessionid=e.session.getId(),setTimeout(function(){lastsessionid=-1e3},150),!1===webphone_api.global.calltransf_completed&&(d=webphone_api.common.SaveCallSession(6,null,e.session,l,p,-1,-1,webphone_api.common.GetTickCount(),"",u,"","true",null,"","","",e.session.getId(),GetSIPXCallIDFromEvent(e))),d<-4&&(d=webphone_api.global.aline),PutToDebugLog(1,"STATUS,"+d.toString()+",CallDisconnect,"+l+","+webphone_api.common.GetSipusername(!0)+","+p+","+s+",["+u+"],,,,,"),uiCallTerminated("Call Finished",d),n=20,BuildCDR(d,l,u,e.session.getId(),e.description),n=21,webphone_api.global.atransfer_number.length>0&&(-1!=webphone_api.global.atransfer_line||webphone_api.global.atransfer_callid.length>0)){n=22,PutToDebugLog(3,"EVENT, completing attended transfer on line: "+webphone_api.global.atransfer_line+" number: "+webphone_api.global.atransfer_number+" callid: "+webphone_api.global.atransfer_callid);var b=webphone_api.common.GetEndpoint(5474,webphone_api.global.atransfer_line,"",webphone_api.global.atransfer_callid,null,!1,!1,null,e.session),_=null;if(n=23,webphone_api.common.isNull(b)||(n=24,_=b[webphone_api.common.EP_SESSION]),webphone_api.common.isNull(b))PutToDebugLog(3,"WANING, orig ep not found for transfer"),w>0&&SipToggleHoldResume(!1,w,27),PutToDebugLog(1,"EVENT, call transfer gone (0x11)");else if(webphone_api.common.isNull(_))PutToDebugLog(3,"WANING, orig ep session not found for transfer"),w>0&&SipToggleHoldResume(!1,w,28),PutToDebugLog(1,"EVENT, call transfer gone (0x12)");else if(b===g)PutToDebugLog(3,"WANING, orig ep mismatch for transfer"),PutToDebugLog(1,"EVENT, call transfer gone (0x14)");else if(_===e.session)PutToDebugLog(3,"WANING, orig ep session mismatch for transfer"),PutToDebugLog(1,"EVENT, call transfer gone (0x15)");else{n=26;var f=webphone_api.global.atransfer_number,w=webphone_api.global.atransfer_line;setTimeout(function(){n=27,0!=_.transfer(f)?(n=28,w>0&&(PutToDebugLog(2,"EVENT, Unhold-Reload call on attended transfer fail"),SipToggleHoldResume(!1,w,29)),PutToDebugLog(1,"EVENT, call transfer failed (0x15)")):PutToDebugLog(1,"EVENT, call transferred")},60)}n=29,webphone_api.global.atransfer_number="",webphone_api.global.atransfer_line=-1,webphone_api.global.atransfer_callid=""}}else webphone_api.common.isNull(e)||webphone_api.common.isNull(e.session)?PutToDebugLog(5,"EVENT,terminating null session"):PutToDebugLog(5,"EVENT,terminating other session");else PutToDebugLog(2,"EVENT,EventSession call transfer: "+e.type);else PutToDebugLog(2,"EVENT,EventSession message: "+e.type);else if(n=14,uiOnConnectionEvent(!1,!1),oSipSessionCall=null,oSipSessionRegister=null,isregistered=!1,webphone_api.global.webrtc_regstate=0,!0===webphone_api.global.onunregistered_flag||!1===webphone_api.flagrestartwebrtc||0==webphone_api.global.sipstackstarted);else{n=15,PutToDebugLog(2,"ERROR,register failed with reason: "+e.description),PutToDebugLog(1,"STATUS,-1,Register failed: "+e.description),!webphone_api.common.isNull(e.description)&&e.description.length>0&&(lastregfailreason=e.description);try{webphone_api.onRegStateChangeCb("failed",e.description)}catch(F){PutToDebugLogException(2,"webrtcapi: There is an error in onRegStateChangeCb(failed) callback",F)}try{webphone_api.onRegisterFailedCb(e.description)}catch(F){PutToDebugLogException(2,"webrtcapi: There is an error in onRegisterFailed() callback",F)}webphone_api.common.CheckInternetConnection(),webphone_api.common.CheckInternetConnectionWS()}break;case"i_notify":if(n=30,PutToDebugLog(4,"EVENT, NOTIFY content-type: "+e.getContentType()),PutToDebugLog(4,"EVENT, NOTIFY content: "+e.getContentString()),"application/pidf+xml"==e.getContentType()&&(n=31,window.DOMParser)){n=32;var v=new DOMParser,E=v?v.parseFromString(e.getContentString(),"text/xml"):null,P=E?E.getElementsByTagName("presence")[0]:null;if(n=33,P){n=34;var T=P.getAttribute("entity"),S=P.getElementsByTagName("tuple")[0];if(T&&S){n=35;var N=S.getElementsByTagName("status")[0];if(N){n=36;var I=N.getElementsByTagName("basic")[0];if(I){n=37;var C=T,G=I.textContent;C=C.toLowerCase(),C=C.replace("sip:","");var L=C.indexOf("@");L>0&&(C=C.substring(0,L));var R=webphone_api.common.SaveReceivedPresence2(C,G);PutToDebugLog(4,"EVENT, Presence notification: number: "+C+" status: "+G),n=38,!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._dialpad)||webphone_api._dialpad.PopulateListRecents(),!0!==webphone_api.global.isContactdetailsStarted||!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._contactdetails)||webphone_api._contactdetails.PopulateData(),!0!==webphone_api.global.isMessageStarted||webphone_api.common.isNull(webphone_api._message)||webphone_api._message.DisplayPresence(R)}}}}}break;case"m_stream_video_local_added":n=39,PutToDebugLog(2,"EVENT, local video stream added"),t>0&&(n=40,uiVideoDisplayEvent(7,!0,!0));break;case"m_stream_video_local_removed":if(n=41,PutToDebugLog(2,"EVENT, local video stream removed"),t>0){n=42;var h=webphone_api.global.aline.toString(),m=webphone_api.common.StrToInt(h),l="unknown";e&&null!==e&&e.session&&null!==e.session&&(l=e.session.getRemoteFriendlyName());var g=webphone_api.common.GetEndpoint(109,-1,l,u,e.session.getId(),!1);webphone_api.common.isNull(g)||(m=webphone_api.common.StrToIntDef(g[webphone_api.common.EP_LINE],m)),uiVideoDisplayEvent(8,!0,!1,!1,m)}break;case"m_stream_video_remote_added":n=43,PutToDebugLog(2,"EVENT, remote video stream added"),t>0&&(n=44,uiVideoDisplayEvent(9,!1,!0));break;case"m_stream_video_remote_removed":n=45,PutToDebugLog(2,"EVENT, remote video stream removed"),t>0&&(n=46,uiVideoDisplayEvent(10,!1,!1));break;case"m_stream_audio_local_added":PutToDebugLog(2,"EVENT, local audio stream added");break;case"m_stream_audio_local_removed":PutToDebugLog(2,"EVENT, local audio stream removed");break;case"m_stream_audio_remote_added":PutToDebugLog(2,"EVENT, remote audio stream added");break;case"m_stream_audio_remote_removed":PutToDebugLog(2,"EVENT, remote audio stream removed");break;case"i_ect_new_call":oSipSessionTransferCall=e.session;break;case"i_ao_request":if(n=47,t>0){n=48;var h=webphone_api.global.aline.toString(),m=webphone_api.common.StrToInt(h);m<1&&webphone_api.common.SetALineInternal(webphone_api.common.GetFreeLine(),24);var l="unknown",s="";e&&null!==e&&e.session&&null!==e.session&&(l=e.session.getRemoteName(),s=e.session.getRemoteFriendlyName());var y=null;e&&null!==e&&e.session&&null!==e.session&&(y=e.session.getId());var u=GetSIPCallIDFromEvent(e),g=webphone_api.common.GetEndpoint(109,-1,l,u,y,!1);n=49,!webphone_api.common.isNull(g)&&!webphone_api.common.isNull(g[webphone_api.common.EP_CALLID])&&g[webphone_api.common.EP_CALLID].length>0&&(u=g[webphone_api.common.EP_CALLID]),!webphone_api.common.isNull(g)&&g.length>webphone_api.common.EP_SETUPSENT&&"true"===g[webphone_api.common.EP_SETUPSENT]?webphone_api.common.isNull(g)||(m=webphone_api.common.StrToIntDef(g[webphone_api.common.EP_LINE],m)):(n=50,1===webphone_api.common.GetApibehaviour()&&(PutToDebugLog(1,"STATUS,-1,Call Initiated"),PutToDebugLog(1,"STATUS,-1,Calling...")),webphone_api.common.SaveCallSession(7,webphone_api.global.aline,e.session,l,"1",webphone_api.common.GetTickCount(),-1,-1,"",u,"true","",null,"","","",y,GetSIPXCallIDFromEvent(e)),webphone_api.common.isNull(g)||(m=webphone_api.common.StrToIntDef(g[webphone_api.common.EP_LINE],m)),PutToDebugLog(1,"STATUS,"+m.toString()+",CallSetup,"+l+","+webphone_api.common.GetSipusername(!0)+",1,"+s+",["+u+"],,,,,"));var D=e.getSipResponseCode();180==D||183==D?(n=51,istypeincoming=!1,PutToDebugLog(1,"STATUS,-1,Ringing..."),PutToDebugLog(1,"STATUS,"+m.toString()+",Ringing,"+l+","+webphone_api.common.GetSipusername(!0)+",1,"+s+",["+u+"]"),e&&null!==e&&e.session&&null!==e.session&&(e.session.tryingdone=!0),0===changesptoring?180==D&&e&&null!==e&&e.session&&null!==e.session&&(webphone_api.common.isNull(e.session.ringdone)||!e.session.ringdone)&&(startRingbackTone(),e.session.ringdone=!0):2!==changesptoring&&5!==changesptoring||e&&null!==e&&e.session&&null!==e.session&&(webphone_api.common.isNull(e.session.ringdone)||!e.session.ringdone)&&(startRingbackTone(),e.session.ringdone=!0)):100==D&&e&&null!==e&&e.session&&null!==e.session&&(webphone_api.common.isNull(e.session.tryingdone)||!e.session.tryingdone)&&(e.session.tryingdone=!0,PutToDebugLog(1,"STATUS,"+m.toString()+",InProgress,"+l+","+webphone_api.common.GetSipusername(!0)+",1,"+s+",["+u+"]"))}break;case"m_early_media":n=52,t>0&&(5!==changesptoring&&setTimeout(function(){stopRingbackTone(),stopRingTone()},100),PutToDebugLog(1,"STATUS,-1,Early media started"));break;case"m_local_hold_ok":n=53,t>0&&(webphone_api.global.holdorresumeinprogress=0,e.session.bTransfering&&(e.session.bTransfering=!1),e.session.bHeld=!0);break;case"m_local_hold_nok":n=54,t>0&&(webphone_api.global.holdorresumeinprogress=0,e.session.bTransfering=!1);break;case"m_local_resume_ok":if(n=55,t>0&&(n=56,webphone_api.global.holdorresumeinprogress=0,e.session.bTransfering=!1,e.session.bHeld=!1,webphone_api.webrtcstack.SIPml.isWebRtc4AllSupported()&&(uiVideoDisplayEvent(11,!1,!0),uiVideoDisplayEvent(12,!0,!0)),webphone_api.global.needmuteafterreload>0)){var O=webphone_api.global.needmuteafterreload,x=webphone_api.global.callaftermute_line,A=webphone_api.global.callaftermute_number,k=webphone_api.global.callaftermute_mode;webphone_api.global.needmuteafterreload=0,webphone_api.global.callaftermute_number="",PutToDebugLog(5,"EVENT,will mute after reload. mute_line: "+O.toString()+", call_line: "+x.toString()+", call_number: "+A.toString()+", call_mode "+k.toString()),setTimeout(function(){PutToDebugLog(5,"EVENT,mute after reload. mute_line: "+O.toString()+", call_line: "+x.toString()+", call_number: "+A.toString()+", call_mode "+k.toString()),webphone_api.getline()!=O&&webphone_api.setline(O,!0),webphone_api.mute(!0),setTimeout(function(){PutToDebugLog(5,"EVENT,call after reload. mute_line: "+O.toString()+", call_line: "+x.toString()+", call_number: "+A.toString()+", call_mode "+k.toString()),webphone_api.setline(x,!0),webphone_api.plhandler.CallDelayed(x,A,k)},90)},90)}break;case"m_local_resume_nok":n=57,t>0&&(webphone_api.global.holdorresumeinprogress=0,e.session.bTransfering=!1,PutToDebugLog(1,"STATUS,-1,Failed to unhold call"));break;case"m_remote_hold":n=58,t>0&&PutToDebugLog(1,"STATUS,-1,Placed on hold by remote party");break;case"m_remote_resume":n=59,t>0&&PutToDebugLog(1,"STATUS,-1,Taken off hold by remote party");break;case"m_bfcp_info":n=60,t>0&&PutToDebugLog(1,"STATUS,-1,BFCP Info: "+e.description);break;case"o_ect_trying":n=61,t>0&&0!=webphone_api.global.last_transfer_tick&&webphone_api.common.GetTickCount()-webphone_api.global.last_transfer_tick<9e4&&(n=62,PutToDebugLog(1,"EVENT,transfer initiated successfully"),1===webphone_api.common.GetApibehaviour()&&PutToDebugLog(1,"STATUS,-1,Transfer"),PutToDebugLog(1,"STATUS,"+webphone_api.global.aline+",Call transfer in progress..._"));break;case"o_ect_accepted":n=63,t>0&&(PutToDebugLog(5,"EVENT,webrtc outgoing transfer accepted"),PutToDebugLog(1,"STATUS,"+webphone_api.global.aline+",Call transfer accepted"));break;case"o_ect_completed":if(n=64,t>0){n=65;var l="unknown",s="";e&&null!==e&&e.session&&null!==e.session&&(l=e.session.getRemoteName(),s=e.session.getRemoteFriendlyName()),PutToDebugLog(5,"EVENT,webrtc outgoing transfer completed "+l);var u=GetSIPCallIDFromEvent(e),g=webphone_api.common.GetEndpoint(1010,-1,l,u,e.session.getId(),!1);!webphone_api.common.isNull(g)&&!webphone_api.common.isNull(g[webphone_api.common.EP_CALLID])&&g[webphone_api.common.EP_CALLID].length>0&&(u=g[webphone_api.common.EP_CALLID]),PutToDebugLog(1,"STATUS,"+webphone_api.global.aline.toString()+",Midcall,"+l+","+webphone_api.common.GetSipusername(!0)+",1,"+s+",["+u+"],,,,,")}break;case"i_ect_completed":if(n=66,t>0){n=67,webphone_api.global.calltransf_completed=!0,setTimeout(function(){webphone_api.global.calltransf_completed=!1,webphone_api.common.RefreshInfo(9)},3e3),PutToDebugLog(5,"EVENT,webrtc incoming transfer completed"),PutToDebugLog(1,"STATUS,"+webphone_api.global.aline+",Call transfer completed"),n=68,oSipSessionTransferCall&&(oSipSessionCall=oSipSessionTransferCall),oSipSessionTransferCall=null;var l="unknown",s="";e&&null!==e&&e.session&&null!==e.session&&(l=e.session.getRemoteName(),s=e.session.getRemoteFriendlyName());var u=GetSIPCallIDFromEvent(e),g=webphone_api.common.GetEndpoint(1011,-1,l,u,e.session.getId(),!1);!webphone_api.common.isNull(g)&&!webphone_api.common.isNull(g[webphone_api.common.EP_CALLID])&&g[webphone_api.common.EP_CALLID].length>0&&(u=g[webphone_api.common.EP_CALLID]),PutToDebugLog(1,"STATUS,"+webphone_api.global.aline.toString()+",Midcall,"+l+","+webphone_api.common.GetSipusername(!0)+",1,"+s+",["+u+"],,,,,")}break;case"o_ect_failed":n=69,PutToDebugLog(1,"ERROR,"+webphone_api.global.aline+",Call transfer failed");break;case"i_ect_failed":n=70,t>0&&(PutToDebugLog(5,"EVENT,webrtc incoming transfer failed"),PutToDebugLog(1,"STATUS,"+webphone_api.global.aline+",Call transfer failed"));break;case"o_ect_notify":if(n=71,PutToDebugLog(2,"STATUS,"+webphone_api.global.aline+",Call Transfer: "+e.getSipResponseCode()+" "+e.description+"_o"),e.getSipResponseCode()>=300)if(481==e.getSipResponseCode()&&0!=webphone_api.global.prev_transfer_replaces_tick&&0==webphone_api.global.transfer_disablereplaces&&webphone_api.common.GetTickCount()-webphone_api.global.prev_transfer_replaces_tick<9e4&&webphone_api.global.prev_transfer_line>0&&webphone_api.global.prev_transfer_number.length>0&&webphone_api.common.GetParameterInt("transfwithreplace",-1)<2&&0!=webphone_api.common.GetParameterInt("transfwithreplace",-1)){PutToDebugLog(1,"EVENT,transfer retry"),PutToDebugLog(5,"EVENT, transfer retry with no replaces_o"),webphone_api.global.transfer_disablereplaces=!0,webphone_api.global.prev_transfer_replaces_tick=0;var U=webphone_api.global.prev_transfer_number;webphone_api.global.prev_transfer_number="",webphone_api.transfer(U,2)}else e.session.bHeld?(PutToDebugLog(1,"EVENT,transfer failed. Call resumed."),e.session.resume()):PutToDebugLog(1,"EVENT,transfer failed");else PutToDebugLog(1,"EVENT,transfer initiated");1===webphone_api.common.GetApibehaviour()&&PutToDebugLog(1,"STATUS,-1,Transfer");break;case"i_ect_notify":if(n=72,t>0){if(n=73,PutToDebugLog(1,"STATUS,"+webphone_api.global.aline+",Call Transfer: "+e.getSipResponseCode()+" "+e.description),e.getSipResponseCode()>=300)if(481==e.getSipResponseCode()&&0!=webphone_api.global.prev_transfer_replaces_tick&&0==webphone_api.global.transfer_disablereplaces&&webphone_api.common.GetTickCount()-webphone_api.global.prev_transfer_replaces_tick<9e4&&webphone_api.global.prev_transfer_line>0&&webphone_api.global.prev_transfer_number.length>0&&webphone_api.common.GetParameterInt("transfwithreplace",-1)<2&&0!=webphone_api.common.GetParameterInt("transfwithreplace",-1)){PutToDebugLog(1,"EVENT,transfer retry"),PutToDebugLog(5,"EVENT, transfer retry with no replaces"),webphone_api.global.transfer_disablereplaces=!0,webphone_api.global.prev_transfer_replaces_tick=0;var U=webphone_api.global.prev_transfer_number;webphone_api.global.prev_transfer_number="",webphone_api.transfer(U,2)}else e.session.bHeld?(PutToDebugLog(1,"EVENT,transfer failed. Call resumed."),e.session.resume()):PutToDebugLog(1,"EVENT,transfer failed");else PutToDebugLog(1,"EVENT,transfer initiated");1===webphone_api.common.GetApibehaviour()&&PutToDebugLog(1,"STATUS,-1,Transfer")}break;case"i_ect_requested":if(n=75,t>0){n=76;if(0===webphone_api.common.GetParameterInt("transfertype",-1))PutToDebugLog(2,"EVENT, incoming SIP REFER transfer rejected."),e.session.rejectTransfer();else{n=77,PutToDebugLog(5,"EVENT,transfer request"),PutToDebugLog(1,"STATUS,"+webphone_api.global.aline+",Call transfer in progress...");var h=webphone_api.global.aline.toString(),m=webphone_api.common.StrToInt(h);m<1&&webphone_api.common.SetALineInternal(webphone_api.common.GetFreeLine(),25);var l="unknown",s="";e&&null!==e&&e.session&&null!==e.session&&(l=e.session.getRemoteName(),s=e.session.getRemoteFriendlyName());var u=GetSIPCallIDFromEvent(e),g=webphone_api.common.GetEndpoint(1012,-1,l,u,e.session.getId(),!1);!webphone_api.common.isNull(g)&&!webphone_api.common.isNull(g[webphone_api.common.EP_CALLID])&&g[webphone_api.common.EP_CALLID].length>0&&(u=g[webphone_api.common.EP_CALLID]),webphone_api.common.isNull(g)||(m=webphone_api.common.StrToIntDef(g[webphone_api.common.EP_LINE],m)),n=78,!webphone_api.common.isNull(g)&&g.length>webphone_api.common.EP_SETUPSENT&&"true"===g[webphone_api.common.EP_SETUPSENT]||(PutToDebugLog(1,"STATUS,"+m.toString()+",CallSetup,"+l+","+webphone_api.common.GetSipusername(!0)+",1,"+s+",["+u+"],,,,,"),webphone_api.common.SaveCallSession(8,webphone_api.global.aline,e.session,l,"1",webphone_api.common.GetTickCount(),-5,-5,"",u,"true","",null,"","","",e.session.getId(),GetSIPXCallIDFromEvent(e)));try{n=7801;var V=webphone_api.common.GetParameterInt("replacetype",-1);if(n=7802,0!=V){n=7803;var W=GetSipHeaderFromEvent(e,"Refer-To");W.length>0&&(W=webphone_api.common.StrGetAfter(W,"Replaces=").trim()),W.length>0&&W.indexOf(">")&&(W=webphone_api.common.StrGetUntill(W,">").trim()),n=7804,W.length>0&&(W=decodeURIComponent(W)),W.length>0&&(n=7805,webphone_api.global.sip_referreplace_all=W,webphone_api.global.transferreplacerectick=webphone_api.common.GetTickCount())}}catch(F){PutToDebugLogException(2,"webrtcapi: onSipEventSession handle refer replace "+n,F)}e.session.acceptTransfer()}}}}catch(F){PutToDebugLogException(2,"webrtcapi: onSipEventSession ex "+n,F)}}function BuildCDR(e,n,t,o,i){try{2===webphone_api.common.GetParameterInt("androidspeaker",1)&&!1===adev_hack_called&&"Android"===webphone_api.common.GetOs()&&(webphone_api.common.isNull(audioinput_id)||audioinput_id.length<1||audioinput_name[0].toLowerCase().indexOf("microphone")>=0&&audioinput_name[0].indexOf("1")>=0)&&(adev_hack_called=!0,StartGetDevices(),setTimeout(function(){webphone_api.plhandler.GetAudioDevicesForMenu(0,!0)},200));var a=!0;!0===webphone_api.global.calltransf_completed&&(a=!1);var r=webphone_api.common.GetEndpoint(1014,e,n,t,o,a);if(webphone_api.common.isNull(r)||r.length<5)return void PutToDebugLog(2,"ERROR, webrtcapi: BuildCDR invalid endpoint");var l=0,s=0,p=0,c="",u=!1,g="";!webphone_api.common.isNull(r[webphone_api.common.EP_SETUPTIME])&&webphone_api.common.IsNumber(r[webphone_api.common.EP_SETUPTIME])&&(l=webphone_api.common.StrToInt(r[webphone_api.common.EP_SETUPTIME])),!webphone_api.common.isNull(r[webphone_api.common.EP_CONNECTTIME])&&webphone_api.common.IsNumber(r[webphone_api.common.EP_CONNECTTIME])&&(s=webphone_api.common.StrToInt(r[webphone_api.common.EP_CONNECTTIME])),!webphone_api.common.isNull(r[webphone_api.common.EP_DESTNR])&&r[webphone_api.common.EP_DESTNR].length>0&&(c=r[webphone_api.common.EP_DESTNR]),webphone_api.common.IsNumber(r[webphone_api.common.EP_INCOMING])&&2==r[webphone_api.common.EP_INCOMING]&&(u=!0),!webphone_api.common.isNull(r[webphone_api.common.EP_DISPLAYNAME])&&r[webphone_api.common.EP_DISPLAYNAME].length>0&&(g=r[webphone_api.common.EP_DISPLAYNAME]),p=webphone_api.common.GetTickCount();var h=0;!webphone_api.common.isNull(s)&&webphone_api.common.IsNumber(s)&&s>0&&(h=p-s)<0&&(h=0),c=webphone_api.common.isNull(c)?"":webphone_api.common.Trim(c),webphone_api.common.isNull(s)&&(s=0);var m="",d="",b="NA",_="NA";!webphone_api.common.isNull(s)&&webphone_api.common.IsNumber(s)&&s>0&&!webphone_api.common.isNull(l)&&webphone_api.common.IsNumber(l)&&l>0?(_=(s-l).toString())<0&&(_=0):!webphone_api.common.isNull(l)&&webphone_api.common.IsNumber(l)&&l>0&&(_=(p-l).toString())<0&&(_=0);u?(m=c,d=webphone_api.common.GetSipusername(!0),g.length>0&&(m=g)):(m=webphone_api.common.GetSipusername(!0),d=c),webphone_api.common.isNull(i)&&(i="");var f=r[webphone_api.common.EP_CALLID];(webphone_api.common.isNull(t)||t.length<1)&&(f=t),webphone_api.common.GetDiscReasonFromSignaling(function(n){!webphone_api.common.isNull(n)&&n.length>0&&(i=n),c=c.replace(","," "),m=m.replace(","," "),d=d.replace(","," "),b=b.replace(","," "),i=i.replace(","," "),f=f.replace(","," ");var t="1";u&&(t="2");var o="CDR,"+e+","+c+","+m+","+d+","+b+","+_+","+h.toString()+",NA,"+i+","+f+","+t;webphone_api.global.lastcallcdr=o,webphone_api.common.RemoveSessionHeadersFromCache(webphone_api.common.StrToIntDef(e,-1)),setTimeout(function(){PutToDebugLog(1,o)},500),setTimeout(function(){SendRegisteredStatus()},1500)})}catch(w){
PutToDebugLogException(2,"webrtcapi: BuildCDR",w)}}function SendRegisteredStatus(){isregistered&&PutToDebugLog(1,"STATUS,-1,Registered.")}function GetWebrtcStats(){try{return}catch(e){PutToDebugLogException(2,"webrtcapi: GetWebrtcStats",e)}}function DumpStats(e){try{var n="";return Object.keys(e).forEach(function(t,o){var i=e[t];n+="<h3>Report ",n+=o,n+="</h3>\n",n+="time "+i.timestamp+"<br>\n",n+="type "+i.type+"<br>\n",Object.keys(i).forEach(function(e){"timestamp"!==e&&"type"!==e&&(n+=e+": "+i[e]+"<br>\n")})}),n}catch(t){PutToDebugLogException(2,"webrtcapi: DumpStats",t)}return""}function JQSetProp(e,n,t){var o=0;try{return o=1,webphone_api.common.isNull(e)?!1:!webphone_api.common.isNull(n)&&(!webphone_api.common.isNull(t)&&(o=11,!webphone_api.common.isNull(webphone_api.$(e))&&(o=2,webphone_api.common.isNull(webphone_api.$(e).prop)||"function"==typeof webphone_api.$(e).prop?(o=3,webphone_api.$(e).prop(n,t),!0):webphone_api.common.isNull(webphone_api.$(e).attr)||"function"==typeof webphone_api.$(e).attr?(o=4,webphone_api.$(e).attr(n,t),!0):(o=5,webphone_api.$(e).prop(n,t),!0))))}catch(i){PutToDebugLogException(2,"webrtcapi: JQSetProp ("+o.toString()+" "+e.toString()+"/"+n.toString()+"="+t.toString()+")",i)}return!1}function JQGetProp(e,n){var t=0;try{return t=1,webphone_api.common.isNull(e)?!1:(t=11,!webphone_api.common.isNull(webphone_api.$(e))&&(t=2,webphone_api.common.isNull(webphone_api.$(e).prop)||"function"==typeof webphone_api.$(e).prop?(t=3,webphone_api.$(e).prop(n)):webphone_api.common.isNull(webphone_api.$(e).attr)||"function"==typeof webphone_api.$(e).attr?(t=4,webphone_api.$(e).attr(n)):(t=5,webphone_api.$(e).prop(n))))}catch(o){PutToDebugLogException(2,"webrtcapi: JQGetProp ("+t.toString()+" "+e.toString()+"/"+n.toString()+")",o)}return null}function SetVolume(e,n){var t=0;try{if(t=1,webphone_api.common.isNull(n)||!webphone_api.common.IsNumber(n))return void PutToDebugLog(2,"ERROR, webrtcapi: SetVolume is NULL: "+n);var o=webphone_api.common.StrToInt(n);if(t=2,o<0||o>100)return void PutToDebugLog(2,"ERROR, webrtcapi: SetVolume invalid value. Accepted varulue range is from 0 - 100: "+o);t=3;var i=document.getElementById("audio_remote");if(webphone_api.common.isNull(i))return PutToDebugLog(2,"ERROR, webrtcapi: SetVolume cannot find audio element"),!1;t=4,0==e||"0"==e?(t=5,o>100&&(o=100),o<0&&(o=0),o/=100,webphone_api.webrtcMicVolume=o):2==e&&"2"==e?(t=6,o>100&&(o=100),JQSetProp("#ringtone","volvalueforgetvolume",o),JQSetProp("#ringtone","volvalueforgetvolume",o),o=o/100*2,o>1&&(o=1),JQSetProp("#ringtone","volume",o),JQSetProp("#ringbacktone","volume",o)):(t=7,o>100&&(o=100),JQSetProp("#audio_remote","volvalueforgetvolume",o),o=o/100*2,o>1&&(o=1),JQSetProp("#audio_remote","volume",o),JQSetProp("#video_remote","volume",o))}catch(a){PutToDebugLogException(2,"webrtcapi: SetVolume ("+t.toString()+")",a)}}function GetVolume(e){var n=0;try{if(n=1,0==e||"0"==e){return webphone_api.common.GetParameterInt("volumein",50)}if(n=2,0!=e){n=3;var t=JQGetProp("#audio_remote","volume");n=4,t=100*t/2,n=5;var o=JQGetProp("#audio_remote","volvalueforgetvolume");return n=6,!webphone_api.common.isNull(o)&&webphone_api.common.IsNumber(o)&&(n=7,t=webphone_api.common.StrToInt(o)),PutToDebugLog(2,"webrtcapi: GetVolume returned: "+t.toString()),t}}catch(i){PutToDebugLogException(2,"webrtcapi: GetVolume ("+n.toString()+")",i)}}function GetAudioDeviceList(e){try{var n=[];n=0==e?audioinput_name:1===e||2===e?audiooutput_name:videoinput_name;var t="";if(!webphone_api.common.isNull(n)&&n.length>0)for(var o=0;o<n.length;o++)t.length>0&&(t+="\r\n"),t+=n[o];return t}catch(i){PutToDebugLogException(2,"webrtcapi: GetAudioDeviceList",i)}return""}function GetAudioDevice(e){try{if(0==e){var n=webphone_api.common.GetParameter("sel_rtc_audio_in");if(!webphone_api.common.isNull(n)&&n.length>0&&!webphone_api.common.isNull(audioinput_name)&&audioinput_name.length>0){var t=webphone_api.common.FindInList(audioinput_name,n);if(t>=0&&!webphone_api.common.isNull(audioinput_name[t])&&audioinput_name[t].length>0)return n!==audioinput_name[t]&&(PutToDebugLog(3,"EVENT, webrtcapi GetAudioDevice sel_rtc_audio_in: device: "+e+" fix device name from: "+n+" to: "+audioinput_name[t]),webphone_api.common.SaveParameter("sel_rtc_audio_in",audioinput_name[t])),audioinput_name[t]}return!webphone_api.common.isNull(audioinput_name)&&audioinput_name.length>0&&!webphone_api.common.isNull(audioinput_name[0])&&audioinput_name[0].length>0?(!webphone_api.common.isNull(n)&&n.length>0&&PutToDebugLog(3,"EVENT, webrtcapi GetAudioDevice sel_rtc_audio_in: device: "+e+" return first device "+audioinput_name[0]+" instead of: "+n),audioinput_name[0]):n}if(1==e){var n=webphone_api.common.GetParameter("sel_rtc_audio_out");if(!webphone_api.common.isNull(n)&&n.length>0&&!webphone_api.common.isNull(audiooutput_name)&&audiooutput_name.length>0){var t=webphone_api.common.FindInList(audiooutput_name,n);if(t>=0&&!webphone_api.common.isNull(audiooutput_name[t])&&audiooutput_name[t].length>0)return n!==audiooutput_name[t]&&(PutToDebugLog(3,"EVENT, webrtcapi GetAudioDevice sel_rtc_audio_out: device: "+e+" fix device name from: "+n+" to: "+audiooutput_name[t]),webphone_api.common.SaveParameter("sel_rtc_audio_out",audiooutput_name[t])),audiooutput_name[t]}return!webphone_api.common.isNull(audiooutput_name)&&audiooutput_name.length>0&&!webphone_api.common.isNull(audiooutput_name[0])&&audiooutput_name[0].length>0?(!webphone_api.common.isNull(n)&&n.length>0&&PutToDebugLog(3,"EVENT, webrtcapi GetAudioDevice sel_rtc_audio_out: device: "+e+" return first device "+audiooutput_name[0]+" instead of: "+n),audiooutput_name[0]):n}if(2==e){var n=webphone_api.common.GetParameter("sel_rtc_audio_ring");if(!webphone_api.common.isNull(n)&&n.length>0&&!webphone_api.common.isNull(audiooutput_name)&&audiooutput_name.length>0){var t=webphone_api.common.FindInList(audiooutput_name,n);if(t>=0&&!webphone_api.common.isNull(audiooutput_name[t])&&audiooutput_name[t].length>0)return n!==audiooutput_name[t]&&(PutToDebugLog(3,"EVENT, webrtcapi GetAudioDevice sel_rtc_audio_ring: device: "+e+" fix device name from: "+n+" to: "+audiooutput_name[t]),webphone_api.common.SaveParameter("sel_rtc_audio_ring",audiooutput_name[t])),audiooutput_name[t]}return!webphone_api.common.isNull(audiooutput_name)&&audiooutput_name.length>0&&!webphone_api.common.isNull(audiooutput_name[0])&&audiooutput_name[0].length>0?(!webphone_api.common.isNull(n)&&n.length>0&&PutToDebugLog(3,"EVENT, webrtcapi GetAudioDevice sel_rtc_audio_ring: device: "+e+" return first device "+audiooutput_name[0]+" instead of: "+n),audiooutput_name[0]):n}if(3==e){var n=webphone_api.common.GetParameter("sel_rtc_video_in");if(!webphone_api.common.isNull(n)&&n.length>0&&!webphone_api.common.isNull(videoinput_name)&&videoinput_name.length>0){var t=webphone_api.common.FindInList(videoinput_name,n);if(t>=0&&!webphone_api.common.isNull(videoinput_name[t])&&videoinput_name[t].length>0)return n!==videoinput_name[t]&&(PutToDebugLog(3,"EVENT, webrtcapi GetAudioDevice sel_rtc_video_in: device: "+e+" fix device name from: "+n+" to: "+videoinput_name[t]),webphone_api.common.SaveParameter("sel_rtc_video_in",videoinput_name[t])),videoinput_name[t]}return!webphone_api.common.isNull(videoinput_name)&&videoinput_name.length>0&&!webphone_api.common.isNull(videoinput_name[0])&&videoinput_name[0].length>0?(!webphone_api.common.isNull(n)&&n.length>0&&PutToDebugLog(3,"EVENT, webrtcapi GetAudioDevice sel_rtc_video_in: device: "+e+" return first device "+videoinput_name[0]+" instead of: "+n),videoinput_name[0]):n}}catch(o){PutToDebugLogException(2,"webrtcapi: GetAudioDevice",o)}return""}function SetAudioDevice(e,n,t){try{if(webphone_api.common.isNull(n)||n.length<0)return void PutToDebugLog(2,"ERROR, webrtcapi SetAudioDevice: invalid devicename: "+n);var o=-1;0===e?(o=webphone_api.common.FindInList(audioinput_name,n))>=0&&(PutToDebugLog(3,"EVENT, webrtcapi SetAudioDevice sel_rtc_audio_in: device: "+e+", devicename: "+n+" / "+audioinput_name[o]),webphone_api.common.SaveParameter("sel_rtc_audio_in",audioinput_name[o]),GetSetDevices(audioinput_id[o],"",t)):1===e?(o=webphone_api.common.FindInList(audiooutput_name,n))>=0&&(PutToDebugLog(3,"EVENT, webrtcapi SetAudioDevice sel_rtc_audio_out: device: "+e+", devicename: "+n+" / "+audiooutput_name[o]),webphone_api.common.SaveParameter("sel_rtc_audio_out",audiooutput_name[o].toString()),webphone_api.common.isNull(videoElement)?webphone_api.common.CanLog(6)&&PutToDebugLog(6,"EVENT, webrtcapi SetAudioDevice videoElement is NULL"):attachSinkId(videoElement,audiooutput_id[o],"audio output_v"),attachSinkId(audioRemoteElement,audiooutput_id[o],"audio output")):2===e?(o=webphone_api.common.FindInList(audiooutput_name,n))>=0&&(PutToDebugLog(3,"EVENT, webrtcapi SetAudioDevice sel_rtc_audio_ring: device: "+e+", devicename: "+n+" / "+audiooutput_name[o]),webphone_api.common.SaveParameter("sel_rtc_audio_ring",audiooutput_name[o].toString())):(o=webphone_api.common.FindInList(videoinput_name,n))>=0&&(PutToDebugLog(3,"EVENT, webrtcapi SetAudioDevice sel_rtc_video_in: device: "+e+", devicename: "+n+" / "+videoinput_name[o]),webphone_api.common.SaveParameter("sel_rtc_video_in",videoinput_name[o]),!0===t&&(webphone_api.common.isNull(videoElement)?PutToDebugLog(2,"EVENT, webrtcapi SetAudioDevice for video videoElement is NULL"):attachSinkId(videoElement,videoinput_id[o],"video"))),o<0&&PutToDebugLog(2,"ERROR, webrtcapi SetAudioDevice device not found. device: "+e+", devicename: "+n)}catch(i){PutToDebugLogException(2,"webrtcapi: SetAudioDevice",i)}}function StartGetDevices(requestpermission){try{if(videoElement=document.getElementById("video_remote"),audioRemoteElement=document.getElementById("audio_remote"),webphone_api.common.isNull(requestpermission)&&(requestpermission=!1),webphone_api.common.isNull(navigator.mediaDevices)||webphone_api.common.isNull(navigator.mediaDevices.enumerateDevices))PutToDebugLog(2,"EVENT, StartGetDevices not supported"),1==webphone_api.global.needaudiodevicepopup&&(webphone_api.global.needaudiodevicepopup=2,webphone_api.common.AudioDevicePopup());else if("MSIE"===webphone_api.common.GetBrowser())webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, StartGetDevices 1"),eval("navigator.mediaDevices.enumerateDevices().then(gotDevices).catch(errorCallback);");else if(requestpermission)if(webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, StartGetDevices 3"),webphone_api.common.CanIUseVideo()){const constraints={audio:!0,video:!0};navigator.mediaDevices.getUserMedia(constraints).then(gotStream).then(gotDevices)["catch"](errorCallback)}else{const constraints={audio:!0,video:!1};navigator.mediaDevices.getUserMedia(constraints).then(gotStream).then(gotDevices)["catch"](errorCallback)}else webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, StartGetDevices 2"),navigator.mediaDevices.enumerateDevices().then(gotDevices)["catch"](errorCallback)}catch(err){PutToDebugLogException(2,"webrtcapi: StartGetDevices",err)}}function gotStream(e){try{return webphone_api.common.CanLog(5)&&PutToDebugLog(5,"EVENT, StartGetDevices MediaStream "+webphone_api.common.ToStringSafe(e)),navigator.mediaDevices.enumerateDevices()}catch(n){PutToDebugLogException(2,"webrtcapi: gotStream",n)}}function GetSetDevices(audioSource,videoSource,setalsovideo,vid_prev_elem){try{window.stream&&window.stream.getTracks().forEach(function(e){e.stop()});var constraints=null;constraints=!0===setalsovideo?{audio:{deviceId:audioSource?{exact:audioSource}:undefined},video:{deviceId:videoSource?{exact:videoSource}:undefined}}:{audio:{deviceId:audioSource?{exact:audioSource}:undefined}},webphone_api.common.isNull(navigator.mediaDevices)||webphone_api.common.isNull(navigator.mediaDevices.getUserMedia)||("MSIE"===webphone_api.common.GetBrowser()?eval("navigator.mediaDevices.getUserMedia(constraints).then(function(stream){window.stream = stream;if(typeof(vid_prev_elem) !== 'undefined' && vid_prev_elem !== null) { attachMediaStream(vid_prev_elem, stream); }}).then(gotDevices).catch(errorCallback);"):navigator.mediaDevices.getUserMedia(constraints).then(function(e){return void 0!==vid_prev_elem&&null!==vid_prev_elem&&attachMediaStream(vid_prev_elem,e),window.stream=e,navigator.mediaDevices.enumerateDevices()}).then(gotDevices)["catch"](errorCallback))}catch(err){PutToDebugLogException(2,"webrtcapi: GetSetDevices",err)}}function SwitchOffAndroidSpeaker(callback){function GUMHandleSuccess(stream){function ENUMgotdevices(e){try{if(!webphone_api.common.isNull(e)&&e.length>0){audioinput_name=[],audioinput_id=[],audiooutput_name=[],audiooutput_id=[],videoinput_name=[],videoinput_id=[];for(var n=0;n!==e.length;++n){var t=e[n],o=t.deviceId;if("audioinput"===t.kind){var i=t.label||"microphone "+(audioinput_name.length+1);audioinput_name.push(i),audioinput_id.push(o)}else if("audiooutput"===t.kind){var i=t.label||"speaker "+(audiooutput_name.length+1);audiooutput_name.push(i),audiooutput_id.push(o)}else if("videoinput"===t.kind){var i=t.label||"camera "+(videoinput_name.length+1);videoinput_name.push(i),videoinput_id.push(o)}else PutToDebugLog(3,"EVENT, webrtcapi GUMgotdevices: Some other kind of source/device: ",t)}PutToDebugLog(2,"EVENT, mlogic API_GetDevicelist WebRTC 0"),webphone_api.getdevicelist(0,function(){}),PutToDebugLog(2,"EVENT, mlogic API_GetDevicelist WebRTC 1"),webphone_api.getdevicelist(1,function(){}),0!=webphone_api.common.GetParameterInt("video",-1)&&(PutToDebugLog(2,"EVENT, mlogic API_GetDevicelist WebRTC 3"),webphone_api.getdevicelist(3,function(){})),PutToDebugLog(3,"EVENT, webrtcapi SwitchOffAndroidSpeaker GUMgotdevices executed successfully"),callback()}else PutToDebugLog(2,"WARNING, webrtrcapi GUMgotdevices: no devices found"),callback()}catch(a){PutToDebugLogException(2,"webrtcapi: ENUMgotdevices",a),callback()}}function ENUMerrorCallback(e){PutToDebugLog(2,"ERROR, GUMerrorCallback webrtcapi navigator.getUserMedia: "+e),callback()}try{eval("navigator.mediaDevices.enumerateDevices().then(ENUMgotdevices).catch(ENUMerrorCallback);")}catch(err){PutToDebugLogException(2,"webrtcapi: GUMHandleSuccess",err),callback()}}function GUMHandleError(e){try{PutToDebugLog(2,"ERROR, GUMHandleError webrtcapi navigator.getUserMedia: "+e),callback()}catch(n){PutToDebugLogException(2,"webrtcapi: GUMHandleError",n),callback()}}try{if(callback&&"function"==typeof callback||(callback=function(){}),"MSIE"===webphone_api.common.GetBrowser())return void callback();if(!0===switchas_called||"Android"!==webphone_api.common.GetOs())return void callback();var as=webphone_api.common.GetParameterInt("androidspeaker",-1);if(-1==as&&(as=webphone_api.global.isvideocall?0:1),as<1)return void callback();switchas_called=!0;var constraints={audio:!0,video:!1};eval("navigator.mediaDevices.getUserMedia(constraints).then(GUMHandleSuccess).catch(GUMHandleError);")}catch(err){PutToDebugLogException(2,"webrtcapi: SwitchOffAndroidSpeaker",err),callback()}}function MyCameraPreview(e){try{if(webphone_api.common.GetParameterInt("displayvideodevice",0)<1)return;PutToDebugLog(2,"EVENT, webrtcapi MyCameraPreview: "+e);var n='<div id="preview_div_video_local" class="previewvideo"><video class="video" width="100%" height="100%" id="preview_video_local" autoplay="autoplay" muted="true"></video><button id="preview_btn_close">'+webphone_api.stringres.get("btn_close")+"</button></div>",t=document.getElementById("preview_div_video_local"),o=document.getElementById("preview_video_local");if(webphone_api.common.isNull(t)||webphone_api.common.isNull(o))if(!1===webphone_api.common.IsSDK()){var i=webphone_api.$.mobile.activePage.attr("id");webphone_api.$("#"+i).append(n)}else webphone_api.$("body").append(n);if(webphone_api.common.isNull(o))return void PutToDebugLog(2,"EVENT, MyCameraPreview video element is NULL");webphone_api.$("#preview_btn_close").on("click",function(){HideVideoPriview()});GetSetDevices(GetAudioVideoInputId(webphone_api.common.GetParameter("sel_rtc_audio_in"),!1),GetAudioVideoInputId(webphone_api.common.GetParameter("sel_rtc_video_in"),!0),!0,o),setTimeout(function(){HideVideoPriview()},1e4)}catch(a){PutToDebugLogException(2,"webrtcapi: MyCameraPreview",a)}}function HideVideoPriview(){try{var e=document.getElementById("preview_video_local");if(webphone_api.common.isNull(e))return;"undefined"!=typeof URL.revokeObjectURL&&URL.revokeObjectURL(e.src),e.src&&(e.src=null),webphone_api.$("#preview_div_video_local").remove()}catch(n){PutToDebugLogException(2,"webrtcapi: HideVideoPriview",n)}}function PrintWebRTCAudioDevices(){try{if(!0===webphone_api.global.printwad_called)return;webphone_api.global.printwad_called=!0,webphone_api.common.isNull(audioinput_name)||webphone_api.common.isNull(audioinput_id)||PutToDebugLog(2,"EVENT, webrtcdevices: audio input devices name: "+audioinput_name.toString()+"; ids: "+audioinput_id.toString()),webphone_api.common.isNull(audiooutput_name)||webphone_api.common.isNull(audiooutput_id)||PutToDebugLog(2,"EVENT, webrtcdevices: audio output devices name: "+audiooutput_name.toString()+"; ids: "+audiooutput_id.toString()),webphone_api.common.isNull(videoinput_name)||webphone_api.common.isNull(videoinput_id)||PutToDebugLog(2,"EVENT, webrtcdevices: video input devices name: "+videoinput_name.toString()+"; ids: "+videoinput_id.toString())}catch(e){PutToDebugLogException(2,"webrtcapi: PrintWebRTCAudioDevices",e)}}function GetAudioVideoInputId(e,n){try{if(webphone_api.common.isNull(e)||e.length<1)return e;if(!0===n){if(webphone_api.common.isNull(videoinput_name)||videoinput_name.length<1||webphone_api.common.isNull(videoinput_id)||videoinput_id.length<1)return e;for(var t=0;t<videoinput_name.length;t++)if(e===videoinput_name[t])return videoinput_id[t]}else{if(webphone_api.common.isNull(audioinput_name)||audioinput_name.length<1||webphone_api.common.isNull(audioinput_id)||audioinput_id.length<1)return e;for(var t=0;t<audioinput_name.length;t++)if(e===audioinput_name[t])return audioinput_id[t]}}catch(o){PutToDebugLogException(2,"webrtcapi: GetAudioInputId",o)}return e}function gotDevices(e){try{if(!webphone_api.common.isNull(e)&&e.length>0){audioinput_name=[],audioinput_id=[],audiooutput_name=[],audiooutput_id=[],videoinput_name=[],videoinput_id=[];for(var n=0;n!==e.length;++n){var t=e[n],o=t.deviceId;if("audioinput"===t.kind){var i=t.label;(webphone_api.common.isNull(i)||i.length<1||"undefined"===i)&&(i="microphone "+(audioinput_name.length+1).toString()),PutToDebugLog(4,"EVENT, gotDevices audioinput: "+i+" id: "+o),audioinput_name.push(i),audioinput_id.push(o)}else if("audiooutput"===t.kind){var i=t.label;(webphone_api.common.isNull(i)||i.length<1||"undefined"===i)&&(i="speaker "+(audioinput_name.length+1).toString()),PutToDebugLog(4,"EVENT, gotDevices audiooutput: "+i+" id: "+o),audiooutput_name.push(i),audiooutput_id.push(o)}else if("videoinput"===t.kind){var i=t.label;(webphone_api.common.isNull(i)||i.length<1||"undefined"===i)&&(i="camera "+(audioinput_name.length+1).toString()),PutToDebugLog(4,"EVENT, gotDevices videoinput: "+i+" id: "+o),videoinput_name.push(i),videoinput_id.push(o)}else PutToDebugLog(4,"EVENT, webrtcapi gotDevices: Some other kind of source/device: ",t)}PrintWebRTCAudioDevices()}else webphone_api.common.isNull(e)?PutToDebugLog(2,"WARNING, webrtrcapi gotDevices: no devices found (null)"):PutToDebugLog(2,"WARNING, webrtrcapi gotDevices: no devices found (0)");1==webphone_api.global.needaudiodevicepopup&&(webphone_api.global.needaudiodevicepopup=2,webphone_api.common.AudioDevicePopup())}catch(a){PutToDebugLogException(2,"webrtcapi: gotDevices",a)}}function attachSinkId(element,sinkId,msg){try{"undefined"!=typeof element.sinkId?eval("element.setSinkId(sinkId).then(function(){PutToDebugLog(3, 'EVENT, webrtcapi attachSinkId: Success, ' + msg + ' device: ' + element.toString() + '; attached: ' + sinkId);}).catch(function(error){var errorMessage = error;if (error.name === 'SecurityError'){errorMessage = 'You need to use HTTPS for selecting audio output device: ' + error;}PutToDebugLog(2, 'ERROR, webrtcapi attachSinkId to: ' + element.toString() + '; sinkId: ' + sinkId + ' error: ' + errorMessage);});"):PutToDebugLog(2,"WARNING, webrtcapi attachSinkId: Browser does not support output device selection.")}catch(err){PutToDebugLogException(2,"webrtcapi: attachSinkId",err)}}function errorCallback(e){PutToDebugLog(2,"ERROR, webrtcapi navigator.getUserMedia: "+webphone_api.common.ToStringSafe(e)),1==webphone_api.global.needaudiodevicepopup&&(webphone_api.global.needaudiodevicepopup=2,webphone_api.common.AudioDevicePopup())}function AddVideoElemnts(e){try{if(0==webphone_api.common.GetParameterInt("video",-1))return;var n='<div id="div_video"><div id="div_video_remote"><video class="video" width="100%" height="100%" id="video_remote" autoplay="autoplay"></video></div><div id="div_video_local_wrapper"><iframe allow="microphone; camera; autoplay" class="previewvideo"> </iframe><div id="div_video_local" class="previewvideo"><video class="video" width="100%" height="100%" id="video_local" autoplay="autoplay" muted="true"></video></div></div><div id="div_video_fullscreen_button"><button id="btn_video_fullscreen" class="ui-btn ui-btn-corner-all ui-btn-b noshadow">'+webphone_api.stringres.get("btn_video_fullscreen")+"</button></div></div>";videocontainer=document.getElementById("video_container"),webphone_api.common.isNull(videocontainer)?!0===e?PutToDebugLog(2,"EVENT, (warn) AddVideoElemnts cannot find video_container DIV"):PutToDebugLog(2,"EVENT, AddVideoElemnts cannot find video_container DIV"):webphone_api.common.isNull(divVideo)&&(PutToDebugLog(2,"EVENT, AddVideoElemnts video elements added"),videocontainer.innerHTML=n),divVideo=document.getElementById("div_video"),videoLocal=document.getElementById("video_local"),videoRemote=document.getElementById("video_remote"),audioRemote=document.getElementById("audio_remote"),webphone_api.common.isNull(webphone_api.$("#btn_video_fullscreen"))?PutToDebugLog(4,"EVENT, (warn) btn_video_fullscreen button doesn not exists"):"function"==typeof webphone_api.$("#btn_video_fullscreen").off?(webphone_api.$("#btn_video_fullscreen").off("click"),webphone_api.$("#btn_video_fullscreen").on("click",function(){toggleFullScreen()})):(webphone_api.$("#btn_video_fullscreen").unbind("click"),webphone_api.$("#btn_video_fullscreen").bind("click",function(){toggleFullScreen()}))}catch(t){PutToDebugLogException(2,"webrtcapi: AddVideoElemnts",t)}}function GetVideoSizeObj(){var e=undefined;try{var n=webphone_api.common.GetParameter2("video_min_width"),t=webphone_api.common.GetParameter2("video_min_height"),o=webphone_api.common.GetParameter2("video_max_width"),i=webphone_api.common.GetParameter2("video_max_height"),a=webphone_api.common.GetParameter2("video_width"),r=webphone_api.common.GetParameter2("video_height"),l=0,s=0,p=0,c=0,u=0,g=0,h=!1;!webphone_api.common.isNull(n)&&n.length>0&&webphone_api.common.IsNumber(n)?(h=!0,l=webphone_api.common.StrToInt(n)):l=100,!webphone_api.common.isNull(t)&&t.length>0&&webphone_api.common.IsNumber(t)?(h=!0,s=webphone_api.common.StrToInt(t)):s=80,!webphone_api.common.isNull(o)&&o.length>0&&webphone_api.common.IsNumber(o)?(h=!0,p=webphone_api.common.StrToInt(o)):p=1920,!webphone_api.common.isNull(i)&&i.length>0&&webphone_api.common.IsNumber(i)?(h=!0,c=webphone_api.common.StrToInt(i)):c=1080,!webphone_api.common.isNull(a)&&a.length>0&&webphone_api.common.IsNumber(a)?(h=!0,u=webphone_api.common.StrToInt(a)):u=960,!webphone_api.common.isNull(r)&&r.length>0&&webphone_api.common.IsNumber(r)?(h=!0,g=webphone_api.common.StrToInt(r)):g=540,71===webphone_api.common.GetConfigInt("brandid",-1)&&(u>0&&(l=u),g>0&&(s=g)),h&&l>0&&s>0&&p>0&&c>0&&(PutToDebugLog(2,"EVENT, webrtcapi: video minw: "+l+"; minh: "+s+"; maxw: "+p+"; maxh: "+c),e={minWidth:l,minHeight:s,maxWidth:p,maxHeight:c,width:u,height:g})}catch(m){PutToDebugLogException(2,"webrtcapi: GetVideoSizeObj",m)}return e}function GetRegFailReason(){return webphone_api.common.isNull(lastregfailreason)&&(lastregfailreason=""),lastregfailreason}function SetPushNotifications(e,n,t,o){try{if(webphone_api.common.isNull(n)||n.length<3)return void PutToDebugLog(2,"ERROR, webrtcapi SetPushNotifications invalid TOKEN: "+n);webphone_api.common.isNull(t)&&(t=""),webphone_api.common.isNull(o)&&(o=""),webphone_api.global.fcmtoken=n;var i="X-MPUSH: w:"+webphone_api.common.GetFCMPackageName()+":"+n,a=webphone_api.common.GetSipusername(!0)+":"+webphone_api.global.mRealm+":"+webphone_api.common.GetParameter("password"),r="X-PIID: "+webphone_api.common.Md5Hash(a);SetSipHeader(0,i),SetSipHeader(0,r),webphone_api.global.phonestarted>2&&ResendRegister()}catch(l){PutToDebugLogException(2,"webrtcapi: SetPushNotifications",l)}}function PlaySound(e,n,t,o){var i=0;try{if(i=1,e>=1&&(webphone_api.common.isNull(n)||n.length<1))return PutToDebugLog(2,"ERROR, playsound: missing file"),!1;if(e<=0&&(webphone_api.common.isNull(o)||!1!==o)){if(!webphone_api.common.isNull(oldtrack))try{i=71,PutToDebugLog(5,"EVENT, playsound stop: restore old track");const a=webphone_api.getrtcpeerconnection();if(!webphone_api.common.isNull(a)){i=72;const r=a.getSenders();if(!webphone_api.common.isNull(r)){i=73;for(var l=!1,s=0;s<r.length;s++)if(i=77,!webphone_api.common.isNull(r[s].track)){r[s].replaceTrack(oldtrack),l=!0;break}if(!l)for(var s=0;s<r.length;s++){i=77,r[s].replaceTrack(oldtrack),l=!0;break}l&&PutToDebugLog(5,"EVENT, playsound stop: restore old track completed")}}}catch(h){PutToDebugLogExceptionWarning(4,"webrtcapi: PlaySound stop track ("+i.toString()+")",h)}oldtrack=null,settrack=null}try{webphone_api.common.isNull(ps_audio)||webphone_api.common.isNull(ps_audio.pause)||(i=2,PutToDebugLog(5,"EVENT, playsound stop: remove audio"),ps_audio.pause())}catch(h){PutToDebugLogExceptionWarning(4,"webrtcapi: PlaySound stop audio ("+i.toString()+")",h)}if(ps_audio=null,e<=0)return!0;if(i=3,!0===o){if(i=4,webphone_api.common.GetNrOfActiveCalls()<1)return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, because there is no active call"),!1;if(i=5,ps_audio=new Audio(n),webphone_api.common.isNull(ps_audio))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, ps_audio is null"),!1;i=6,!webphone_api.common.isNull(t)&&t>0&&!webphone_api.common.isNull(ps_audio.loop)&&(ps_audio.loop=!0),i=13;const p=new AudioContext;if(webphone_api.common.isNull(p))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no audioContext"),!1;i=7;const c=p.createMediaElementSource(ps_audio);if(webphone_api.common.isNull(c))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no audioSource"),!1;i=8;const u=p.createMediaStreamDestination();if(webphone_api.common.isNull(u))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no audioDestination"),!1;i=9,c.connect(u),i=10;const g=u.stream.getAudioTracks()[0];if(webphone_api.common.isNull(g))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no track"),!1;i=11;const a=webphone_api.getrtcpeerconnection();if(webphone_api.common.isNull(a))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no RTCPeerConnection"),!1;i=20;const r=a.getSenders();if(webphone_api.common.isNull(r))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no RTCRtpSender senderList"),!1;i=21;for(var l=!1,s=0;s<r.length;s++)if(i=22,!webphone_api.common.isNull(r[s].track)){i=24,webphone_api.common.isNull(r[s].track)||null!=oldtrack&&oldtrack!=settrack||(oldtrack=r[s].track),i=23,r[s].replaceTrack(g),l=!0;break}if(!l){i=25;for(var s=0;s<r.length;s++){i=26,webphone_api.common.isNull(r[s].track)||null!=oldtrack&&oldtrack!=settrack||(oldtrack=r[s].track),i=27,r[s].replaceTrack(g),l=!0;break}}l?settrack=g:(i=28,PutToDebugLog(2,"EVENT, playsound: add new track"),webphone_api.global.lastaddtrack=webphone_api.common.GetTickCount(),a.addTrack(g)),i=12,i=14,ps_audio.play()}else i=50,i=51,ps_audio=new Audio(n),i=52,!webphone_api.common.isNull(t)&&t>0&&!webphone_api.common.isNull(ps_audio.loop)&&(ps_audio.loop=!0),i=54,ps_audio.play();return!0}catch(m){PutToDebugLogException(2,"webrtcapi: PlaySound ("+i.toString()+")",m)}return!1}function LineToCallID(e){try{var n=webphone_api.common.StrToIntDef(e,-1);n<1&&(n=webphone_api.common.GetBestLine());var t="";if(!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0){var o=webphone_api.common.GetCallEpIdx(4673,!1,e,"","",null,null,null,!1);if(o>=0&&!webphone_api.common.isNull(webphone_api.global.ep[o])&&webphone_api.global.ep[o].length>=9&&(t=webphone_api.global.ep[o][webphone_api.common.EP_CALLID],!webphone_api.common.isNull(t)&&t.length>0))return t;for(var i,a=0;a<webphone_api.global.ep.length;a++)if(i=webphone_api.global.ep[a],!(webphone_api.common.isNull(i)||i.length<9)&&i[webphone_api.common.EP_LINE]==n&&(t=i[webphone_api.common.EP_CALLID],!webphone_api.common.isNull(t)&&t.length>0))return t}if(!webphone_api.common.isNull(webphone_api.common.eplinecallid)&&webphone_api.common.eplinecallid.length>e&&(t=webphone_api.common.eplinecallid[e]),!webphone_api.common.isNull(t)&&t.length>0)return t}catch(r){PutToDebugLogException(2,"webrtcapi: LineToCallID",r)}return""}function CallIDToLine(e){try{if(webphone_api.common.isNull(e))return-5;if(e=e.toString(),e.length<1)return-6;var n=-1;if(!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0){var t=webphone_api.common.GetCallEpIdx(4674,!1,-1,"",e,null,null,null,!1);if(t>=0&&!webphone_api.common.isNull(webphone_api.global.ep[t])&&webphone_api.global.ep[t].length>=2&&(n=webphone_api.global.ep[t][webphone_api.common.EP_LINE],webphone_api.common.IsNumber(n)&&n>0))return n;for(var o,i=0;i<webphone_api.global.ep.length;i++)if(o=webphone_api.global.ep[i],!(webphone_api.common.isNull(o)||o.length<9)&&o[webphone_api.common.EP_CALLID]==e&&(n=o[webphone_api.common.EP_LINE],webphone_api.common.IsNumber(n)&&n>0))return n}if(!webphone_api.common.isNull(webphone_api.common.eplinecallid)&&webphone_api.common.eplinecallid.length>0)for(var i=1;i<webphone_api.common.eplinecallid.length;i++)if(!webphone_api.common.isNull(webphone_api.common.eplinecallid[i])&&webphone_api.common.eplinecallid[i]==e)return i}catch(a){PutToDebugLogException(2,"webrtcapi: CallIDToLine",a)}return-7}function CheckPendingStartMedia(){var e=!1,n=!1;try{webphone_api.common.isNull(webphone_api.webrtcstack)||(n=webphone_api.webrtcstack.ExecPendingStartMedia())&&(e=n)}catch(o){PutToDebugLogException(2,"webrtcapi: CheckPendingStartMedia innerA",o)}try{webphone_api.common.isNull(webphone_api[wen_namespace])||(n=webphone_api[wen_namespace].ExecPendingStartMedia())&&(e=n)}catch(o){PutToDebugLogException(2,"webrtcapi: CheckPendingStartMedia innerB",o)}if(!webphone_api.common.isNull(webphone_api.wen_namespaces)&&webphone_api.wen_namespaces.length>0)try{for(var t=0;t<webphone_api.wen_namespaces.length;t++)(n=webphone_api[webphone_api.wen_namespaces[t]].ExecPendingStartMedia())&&(e=n)}catch(o){PutToDebugLogException(2,"webrtcapi: CheckPendingStartMedia innerC",o)}return e}function ClearPendingStartMedia(){try{webphone_api.common.isNull(webphone_api.webrtcstack)||webphone_api.webrtcstack.ClearPendingStartMedia()}catch(n){PutToDebugLogException(2,"webrtcapi: ClearPendingStartMedia innerA",n)}try{webphone_api.common.isNull(webphone_api[wen_namespace])||webphone_api[wen_namespace].ClearPendingStartMedia()}catch(n){PutToDebugLogException(2,"webrtcapi: ClearPendingStartMedia innerB",n)}if(!webphone_api.common.isNull(webphone_api.wen_namespaces)&&webphone_api.wen_namespaces.length>0)try{for(var e=0;e<webphone_api.wen_namespaces.length;e++)tmpret=webphone_api[webphone_api.wen_namespaces[e]].ClearPendingStartMedia()}catch(n){PutToDebugLogException(2,"webrtcapi: ClearPendingStartMedia innerC",n)}}
var sTransferNumber,oRingTone,oRingbackTone,oSipStack,oSipSessionRegister,oSipSessionCall,oSipSessionMessage,oSipSessionTransferCall,registerExSipstackArray=[],extraregsessions=[],videoRemote,videoLocal,audioRemote,divVideo,bFullScreen=!1,oNotifICall,bDisableVideo=!1,viewVideoLocal,viewVideoRemote,viewLocalScreencast,oConfigCall,oConfigMessage,oConfigSms,oReadyStateTimer,isregistered=!1,sipheaders=[],callsipheaders=[],mSipuri="",mDisplayname="",changesptoring=2,recheckmediaonconnect=2,lastregfailreason="",C={divKeyPadWidth:220},initcallback=null,wen_namespace="",acc_arr=[],lastrestarttick=0,restartdelay=2e3,restarttimestr="",te2=null,sipstackstarted=!1,redialonfailtimer=null,calltype="",callline=1,destnumber="",last_vid_device="",red_line=null,red_sessioncall=null,red_number=null,red_setuptime=0,red_callid=null,red_headers=null,red_delaytime=6e3,red_s_type="call-audio",wholdtimer=null,wcacheh_state=[],wcacheh_line=[],lastmuste_mute=null,lastmuste_direction=null,lastmuste_line=null,lastmuste_log=null,wmutetimer=null,wcachem_state=[],wcachem_line=[],publishSession,maxnrofusers=25,pgmaxloop=0,playingringtoneaudio=null,playingringtoneaudioplaying=!1,regextimer=null,regex_idx=0,lw_namespace_arr=[],lw_account_arr=[],check_reg_timer=null,reregstarted=!1,rereg_timer=null,rereg_ival=1e4,rereg_action=0,last_event="",lastsession=null,lastsessionid=-1e3,istypeincoming=!1,adev_hack_called=!1,videoElement=null,audioRemoteElement=null,switchas_called=!1,audioinput_name=[],audioinput_id=[],audiooutput_name=[],audiooutput_id=[],videoinput_name=[],videoinput_id=[],videocontainer=null,ps_audio=null,oldtrack=null,settrack=null;return{WebRtcIsSupported:WebRtcIsSupported,Start:Start,RegisterEx:RegisterEx,SipUnRegister:SipUnRegister,SipStop:SipStop,SipCall:SipCall,SipHangup:SipHangup,SipAccept:SipAccept,SipIgnore:SipIgnore,SipSendChat:SipSendChat,Forward:Forward,SipTransfer:SipTransfer,SipTransferEx:SipTransferEx,SipMuteVideo:SipMuteVideo,SipToggleHoldResume:SipToggleHoldResume,SipToggleMute:SipToggleMute,SipSendDTMF:SipSendDTMF,PresenceSet:PresenceSet,PresenceGet:PresenceGet,SetSipHeader:SetSipHeader,GetRegFailReason:GetRegFailReason,SetVolume:SetVolume,GetVolume:GetVolume,GetAudioDeviceList:GetAudioDeviceList,GetAudioDevice:GetAudioDevice,SetAudioDevice:SetAudioDevice,SwitchOffAndroidSpeaker:SwitchOffAndroidSpeaker,PlaySound:PlaySound,LineToCallID:LineToCallID,CallIDToLine:CallIDToLine,ReStart:ReStart,GetWebrtcStats:GetWebrtcStats,GetAudioVideoInputId:GetAudioVideoInputId,MyCameraPreview:MyCameraPreview,HideVideoPriview:HideVideoPriview,RemoveUnusedAudioElements:RemoveUnusedAudioElements,JsObjecSniffer:JsObjecSniffer,ResendRegister:ResendRegister,StartReRegister:StartReRegister,GetVideoSizeObj:GetVideoSizeObj,SessionToString:SessionToString,SetPushNotifications:SetPushNotifications,StartGetDevices:StartGetDevices,CheckPendingStartMedia:CheckPendingStartMedia,ClearPendingStartMedia:ClearPendingStartMedia,audiooutput_name:audiooutput_name}}(),webphone_api.plhandler=function(){function e(){if(webphone_api.common.EngineSelect(0,27),webphone_api.common.SetLanguage(),ot(),!1===webphone_api.global.onloaded_called){webphone_api.global.wploaded=!0,webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler webphone onLoaded",!1,"");try{webphone_api.onAppStateChangeCb("loaded")}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: There is an error in onAppStateChange(loaded) callback",e)}try{webphone_api.onLoadedCb()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: There is an error in onLoaded() callback",e)}try{!0===webphone_api.common.IsWebphoneInIframe()&&webphone_api.WebphoneSendMessageToParent("wploadedandready_IFRAME")}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: send loaded state message to iframe parent page",e)}webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onload,"onLoad","","","",""),webphone_api.global.onloaded_called=!0,setTimeout(function(){webphone_api.global.onloaded_called=!1},5e3),webphone_api.webphone_loaded=!0,webphone_api.common.WebphoneIsLoaded()}}function n(e,t){try{Jn("Start");var a=webphone_api.common.GetTickCount(),r=a-webphone_api.global.laststarttick;if(webphone_api.global.laststarttick>0&&r<250)return webphone_api.common.PutToDebugLog(3,"EVENT, plhandler start already called"),!1;webphone_api.global.loglevel=webphone_api.common.GetLogLevel(),webphone_api.common.HandleCallerID(),webphone_api.global.laststarttick=a,webphone_api.global.pres_set_at_start=!1,webphone_api.global.pingpong=0,webphone_api.global.ever_received_pong=!1,webphone_api.common.GetCustomMenus(),webphone_api.global.nuiswebpage=null,0==webphone_api.global.phonestarttick&&(webphone_api.global.phonestarttick=webphone_api.common.GetTickCount());var l=webphone_api.common.GetAutostart();if(!1===t&&0===l)return webphone_api.common.PutToDebugLog(3,"EVENT, plhandler autologin disabled because autostart is FALSE"),!1;webphone_api.global.colorizelog=webphone_api.common.GetParameterInt("colorizelog",0),webphone_api.global.authenticated_displayed=!1,webphone_api.global.applet_started=!1,ut=e,webphone_api.global.lastengine_working_ok="",webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, plhandler onstart"),webphone_api.common.PutToDebugLog(1,"STATUS,-1,"+webphone_api.stringres.get("initializing"));var s=webphone_api.common.GetParameter("serveraddress_user");(webphone_api.common.isNull(s)||s.length<2)&&(s=webphone_api.common.GetParameter("serveraddress")),(webphone_api.common.isNull(s)||s.length<2)&&webphone_api.common.PutToDebugLog(2,"EVENT, plhandler start serveraddress not set");var p=!0,c="",u=[];if(u.push("a"),!1===webphone_api.global.usestorage&&!webphone_api.common.CheckDID(s,!1))if(u.push("b"),webphone_api.common.AddressHasPort(s)&&(s=webphone_api.common.GetIPFromAddressSimple(s)),!webphone_api.common.IsIPAddrress(s)&&s.indexOf(".")>0){u.push("c");var g=webphone_api.common.DomainToIp(s,function(){});if(!(!webphone_api.common.isNull(g)&&g.length>0&&!0===webphone_api.common.IsIPAddrress(g)||""===g))return u.push("f"),mt=e,dt=t,void webphone_api.common.DomainToIp(s,function(e){if(u.push("g"),c=e,p=!1,!webphone_api.common.isNull(e)&&e.length>0&&!0===webphone_api.common.IsIPAddrress(e)&&(u.push("h"),webphone_api.common.CheckDID(e,!1)?p=!0:(u.push("i"),p=!1)),p)webphone_api.global.laststarttick=0,n(mt,dt);else{var t=[];t.push("E"),t.push("R"),t.push("R"),t.push("O"),t.push("R"),t.push(","),t.push("S"),t.push("e"),t.push("r"),t.push("v"),t.push("e"),t.push("r"),t.push(" "),t.push("n"),t.push("o"),t.push("t"),t.push(" "),t.push("a"),t.push("l"),t.push("l"),t.push("o"),t.push("w"),t.push("e"),t.push("d"),t.push("_"),t.push("7");var o=t.join(""),i=u.join("");setTimeout(function(){webphone_api.common.PutToDebugLog(1,o+" "+s+" / "+e+" ("+i+")"),webphone_api.common.ShowToast(o+" "+s)},853)}});u.push("d"),c=g,webphone_api.common.CheckDID(g,!0)||(u.push("e"),p=!1)}else u.push("j"),p=!1;if(!1===p){var h=[];h.push("E"),h.push("R"),h.push("R"),h.push("O"),h.push("R"),h.push(","),h.push("S"),h.push("e"),h.push("r"),h.push("v"),h.push("e"),h.push("r"),h.push(" "),h.push("n"),h.push("o"),h.push("t"),h.push(" "),h.push("a"),h.push("l"),h.push("l"),h.push("o"),h.push("w"),h.push("e"),h.push("d"),h.push("_"),h.push("8");var m=h.join(""),d=u.join("");return setTimeout(function(){webphone_api.common.PutToDebugLog(1,m+" "+s+" / "+c+" ("+d+")"),webphone_api.common.ShowToast(m+" "+s)},851),!1}st=!0,webphone_api.common.isNull(lt)||clearTimeout(lt),lt=setTimeout(function(){st=!1},2e3),webphone_api.common.PutToDebugLog(2,"EVENT, plhandler onstart reset useengine"),webphone_api.global.useengine="",webphone_api.global.readcallhistoryforrecents=!0,webphone_api.common.IsWindowsSoftphone()?webphone_api.common.SaveParameter("devicetype",webphone_api.common.DEVICE_WIN_SOFTPHONE()):webphone_api.common.SaveParameter("devicetype",webphone_api.common.DEVICE_WEBPHONE());var b=window.location.href;webphone_api.common.isNull(b)&&(b=""),b.length>0&&webphone_api.common.SaveParameter("wphoneappurl",b);var _=webphone_api.getbasedir2();if(webphone_api.common.isNull(_)&&(_=""),_.length>0&&_!==b&&webphone_api.common.SaveParameter("wphoneappurl2",_),!webphone_api.common.Glsp()){gt--;var h=[];h.push("E"),h.push("R"),h.push("R"),h.push("O"),h.push("R"),h.push(","),h.push(" "),h.push("U"),h.push("s"),h.push("a"),h.push("g"),h.push("e"),h.push(" "),h.push("o"),h.push("n"),h.push(" "),h.push("t"),h.push("h"),h.push("i"),h.push("s"),h.push(" "),h.push("o"),h.push("p"),h.push("e"),h.push("r"),h.push("a"),h.push("t"),h.push("i"),h.push("n"),h.push("g"),h.push(" "),h.push("s"),h.push("y"),h.push("s"),h.push("t"),h.push("e"),h.push("m"),h.push(" "),h.push("i"),h.push("s"),h.push(" "),h.push("n"),h.push("o"),h.push("t"),h.push(" "),h.push("p"),h.push("e"),h.push("r"),h.push("m"),h.push("i"),h.push("t"),h.push("t"),h.push("e"),h.push("d"),h.push(" "),h.push("b"),h.push("y"),h.push(" "),h.push("t"),h.push("h"),h.push("i"),h.push("s"),h.push(" "),h.push("l"),h.push("i"),h.push("c"),h.push("e"),h.push("n"),h.push("s"),h.push("e"),h.push("."),h.push(" "),h.push("U"),h.push("p"),h.push("g"),h.push("r"),h.push("a"),h.push("d"),h.push("e"),h.push(" "),h.push("t"),h.push("o"),h.push(" "),h.push("t"),h.push("h"),h.push("e"),h.push(" "),h.push("A"),h.push("d"),h.push("v"),h.push("a"),h.push("n"),h.push("c"),h.push("e"),h.push("d"),h.push(" "),h.push("v"),h.push("e"),h.push("r"),h.push("s"),h.push("i"),h.push("o"),h.push("n"),h.push(" "),h.push("t"),h.push("o"),h.push(" "),h.push("e"),h.push("n"),h.push("a"),h.push("b"),h.push("l"),h.push("e"),h.push(" "),h.push("t"),h.push("h"),h.push("e"),h.push(" "),h.push("w"),h.push("e"),h.push("b"),h.push("p"),h.push("h"),h.push("o"),h.push("n"),h.push("e"),h.push(" "),h.push("o"),h.push("n"),h.push(" "),h.push("s"),h.push("m"),h.push("a"),h.push("r"),h.push("t"),h.push("p"),h.push("h"),h.push("o"),h.push("n"),h.push("e"),h.push("s"),h.push(" "),h.push("a"),h.push("n"),h.push("d"),h.push(" "),h.push("t"),h.push("a"),h.push("b"),h.push("l"),h.push("e"),h.push("t"),h.push("s"),h.push(".");var f=[];f.push("E"),f.push("R"),f.push("R"),f.push("O"),f.push("R");var w=f.join(""),m=h.join("");webphone_api.global.dontclosecurrpopup=!0,setTimeout(function(){webphone_api.global.dontclosecurrpopup=!1},3e4),setTimeout(function(){webphone_api.common.PutToDebugLog(1,m)},2e3),setTimeout(function(){webphone_api.common.AlertDialog(w,m,function(){webphone_api.global.dontclosecurrpopup=!1})},759),ht+=10}if(gt<10)return;if(webphone_api.global.sipstackstarted=!0,!0===webphone_api.common.CanUseIncomingCallNot()){var v=webphone_api.common.GetParameterInt("askfornotifpermission",-1);v=webphone_api.common.GetParameterInt("asknotifpermission",v),v>=3&&webphone_api.common.RequestBrowserNotificationPermission(function(){},"","","",3)}return webphone_api.common.IsWindowsSoftphone()?(webphone_api.common.PutToDebugLog(3,"EVENT, plhandler start softphone"),i()):(!0===webphone_api.common.IsSDK()?webphone_api.common.PutToDebugLog(3,"EVENT, plhandler start webphone sdk"):webphone_api.common.PutToDebugLog(3,"EVENT, plhandler start webphone app"),o(1),webphone_api.common.PutToDebugLog(3,"EVENT, plhandler after wait for engine select")),!0}catch(E){webphone_api.common.PutToDebugLogException(2,"plhandler: Start",E)}return!1}function t(e,n,o,i){try{if(!webphone_api.common.IsMizuServerOrGateway())return void(webphone_api.global.isfirstwsu=!1);if(webphone_api.common.IsLocalServer()){var a=webphone_api.common.GetWebrtcSrvAddr();webphone_api.common.isNull(a)&&(a=""),a=a.toLowerCase(),a=a.replace("ws://",""),a=a.replace("wss://","");var r=a.indexOf("/");if(r>0&&(a=a.substring(0,r)),a.length>0&&0==webphone_api.common.IsLanIPEx(a))return webphone_api.common.PutToDebugLog(2,"ERROR, "+webphone_api.stringres.get("webrtc_local_sipserver")+" (4) "+a),void((!0===webphone_api.global.usestorage||webphone_api.common.Strl(60))&&console.log("ERROR, "+webphone_api.stringres.get("webrtc_local_sipserver")+"\n\n"+webphone_api.stringres.get("all_demo_msg")+" (5)"))}if(!webphone_api.common.IsMizuServerOrGateway())return;webphone_api.common.isNull(n)&&(n=webphone_api.common.GetSipusername(!0)),o=webphone_api.common.isNull(o)?webphone_api.common.GetParameter("password"):webphone_api.common.B64Dec(o);var l=webphone_api.common.GetParameter("serveraddress_user");(webphone_api.common.isNull(l)||l.length<2)&&(l=webphone_api.common.GetParameter("serveraddress"));var s=webphone_api.common.GetParameter("mainconfigs"),p=n+":"+o+":"+l+":"+webphone_api.common.GetWebrtcSrvAddr();if((webphone_api.common.isNull(s)||s.length<1||s!==p)&&(bt=!0),n.length<1&&o.length<1&&_t<25)return _t++,void setTimeout(function(){t()},80);if((webphone_api.common.isNull(n)||n.length<1)&&webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"ERROR, will NOT send wsuser, because username is not set: "+n),(webphone_api.common.isNull(o)||o.length<1)&&webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, CallWsuser password is not set: "+o),ft=webphone_api.common.GetWsuserUrl(n,o,i),ft.length<3)return webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, plhandler CallWsuser wsuser not needed"),webphone_api.global.isfirstwsu=!1,bt=!1,void(webphone_api.global.wsuser_succeded=!0);if(webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, plhandler push wsuser "+webphone_api.global.isfirstwsu.toString()+" "+webphone_api.global.wsuser_succeded.toString()),webphone_api.global.isfirstwsu)if(webphone_api.common.isNull(s)||s.length<1||s!==p)wt=!0;else{var c=webphone_api.common.GetParameter("wsusers"),u=c.split(",");if(!webphone_api.common.isNull(u)&&u.length>0&&n.length>0)for(var g=0;g<u.length;g++)if(!webphone_api.common.isNull(u[g])&&u[g]===n){webphone_api.global.isfirstwsu=!1;break}}_t=0,webphone_api.common.isNull(n)||n.length<2||webphone_api.common.isNull(o)||o.length<2?webphone_api.common.PutToDebugLog(2,"WARNING, common CallWsuserKeepAlive invalid username ("+n+") or invalid password ("+o+")"):webphone_api.common.UriParser(ft,"","","","","webrtccreateuser"),!1!==webphone_api.global.wsuser_succeded||!webphone_api.common.isNull(e)&&!0===e||setTimeout(function(){webphone_api.global.webrtcavailable>0&&!1===webphone_api.global.wsuser_succeded&&(webphone_api.common.isNull(e)||1!=e)&&(n=webphone_api.common.GetSipusername(!0),o=webphone_api.common.GetParameter("password"),ft=webphone_api.common.GetWsuserUrl(n,o,i),webphone_api.common.UriParser(ft,"","","","","webrtccreateuser"))},4500)}catch(h){webphone_api.common.PutToDebugLogException(2,"plhandler: CallWsuser",h)}}function o(e){try{webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, wait for engine select from: "+e.toString()),webphone_api.common.isNull(vt)||clearInterval(vt);var n=Tt;Tt=!1,vt=null;var t=80;vt=setInterval(function(){++Et>80&&(webphone_api.common.PutToDebugLog(2,"WARNING, EngineSelect timeout"),clearInterval(vt),webphone_api.common.PutToDebugLog(2,"WARNING, WaitForEngineSelect not ready, but start anyway"),webphone_api.common.ChooseEngineLogic(function(){i()},!0,1));var e=webphone_api.common.GetSipusername(!0),o=!1,a=webphone_api.common.CanIUseWebRTC();if(webphone_api.global.isfirstwsu&&a&&bt){if(Pt<10){var r=webphone_api.common.GetParameter("wsusers"),l=r.split(",");if(1==Et&&webphone_api.common.CanLog(4)&&webphone_api.common.PutToDebugLog(4,"EVENT, wsusers: "+r),!webphone_api.common.isNull(l)&&l.length>0)for(var s=0;s<l.length;s++)if(!webphone_api.common.isNull(l[s])&&e.length>0&&l[s]===e){Pt=webphone_api.common.GetTickCount();break}}Pt>10&&webphone_api.common.GetTickCount()-Pt>2500&&(webphone_api.common.CanLog(4)&&webphone_api.common.PutToDebugLog(4,"EVENT, wsuser can be sent (first time)"),o=!0)}else webphone_api.common.CanLog(4)&&(a?webphone_api.common.PutToDebugLog(4,"EVENT, wsuser can be sent"):webphone_api.common.PutToDebugLog(4,"EVENT, wsuser not neded")),o=!0;if(!1===o&&a)return n||(t=10),void(1==Et&&webphone_api.common.CanLog(4)&&webphone_api.common.PutToDebugLog(4,"EVENT, wait for wsuready"));var p=webphone_api.common.EngineSelect(1,28);p<1?webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, waiting for EngineSelect ("+Et+")"):webphone_api.global.webrtcavailable<0&&(webphone_api.common.isNull(webphone_api.common.GetSelectedEngine())||webphone_api.common.GetSelectedEngine()==webphone_api.common.GetEngine(webphone_api.global.ENGINE_WEBRTC))?webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, waiting for WebRTC to load ("+Et+")"):(clearInterval(vt),webphone_api.common.CanLog(2)&&(webphone_api.common.PutToDebugLog(2,"EVENT, selected engine("+webphone_api.global.engineselectstage+"): "+webphone_api.common.TestEngineToString(webphone_api.common.GetSelectedEngine(),!1)),webphone_api.common.PutToDebugLog(2,"EVENT, recommended engine("+webphone_api.global.engineselectstage+"): "+webphone_api.common.TestEngineToString(webphone_api.common.GetRecommendedEngine(),!1)),webphone_api.common.PutToDebugLog(5,"EVENT, will choose engine logic. ret: "+p.toString()+" wsuready: "+o.toString()+" caniusewebrtc: "+a.toString()+" webrtcavailable: "+webphone_api.global.webrtcavailable.toString())),setTimeout(function(){webphone_api.common.ChooseEngineLogic(function(){i()},!0,2)},1e3))},200)}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: WaitForEngineSelect",o)}}function i(){try{webphone_api.common.IsCurrentEngineWorking(ut),webphone_api.common.CheckEngineFirstStart(ut),webphone_api.common.GatewayFailower(-1,"startUp"),1==webphone_api.common.IsSDK()?(webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler StartUp call HandleSettingsSDK",!1,""),a(function(e){webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler StartUp HandleSettingsSDK FINISHED: "+e,!1,"")})):(webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, plhandler StartUp call StartEngine"),r("x1"))}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: StartUp",e)}return!1}function a(e){try{if(at)return webphone_api.common.PutToDebugLog(3,"EVENT, HandleSettingsSDK call StartEngine"),webphone_api.common.PutToDebugLogSpecial(1,"EVENT, HandleSettingsSDK call StartEngine",!1,""),r("x2"),void e("Already called");if(!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLogSpecial(1,"ERROR, HandleSettingsSDK call StartEngine",!0,"");webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler HandleSettingsSDK called",!1,""),webphone_api.common.PutToDebugLog(3,"EVENT, HandleSettingsSDK called");var n=webphone_api.parameters.serveraddress;!webphone_api.common.isNull(n)&&n.length>1&&(webphone_api.common.SaveParameter("serveraddress",n,!0),webphone_api.common.SaveParameter("serveraddress_user",n,!0),webphone_api.common.SaveParameter("serveraddress_orig",n,!0),webphone_api.common.SaveParameter("iswebrtcuppersrvfromuser","true")),it.length<1&&(it=webphone_api.common.GetSettFilenameSDK()),webphone_api.common.PutToDebugLogSpecial(1,"EVENT, HandleSettingsSDK settfilename: "+it,!1,""),webphone_api.common.PutToDebugLog(3,"EVENT, HandleSettingsSDK settfilename: "+it),webphone_api.common.ReadSettingsFile(it,function(n){webphone_api.common.PutToDebugLog(5,"EVENT, plhandler GetSettings callback"),n||webphone_api.common.PutToDebugLog(5,"EVENT, plhandler GetSettings ReadSettings no content");var t=webphone_api.parameters.serveraddress;!webphone_api.common.isNull(t)&&t.length>1&&(webphone_api.common.SaveParameter("serveraddress",t,!0),webphone_api.common.SaveParameter("serveraddress_user",t,!0),webphone_api.common.SaveParameter("serveraddress_orig",t,!0)),webphone_api.common.isNull(rt)||(clearTimeout(rt),rt=null),webphone_api.common.SaveSettingsFile(3,it,function(n){if(webphone_api.global.loglevel=webphone_api.common.GetLogLevel(),webphone_api.common.PutToDebugLog(3,"EVENT, plhandler: HandleSettingsSDK settings SAVED"),!at){at=!0;var t=webphone_api.common.GetParameter2("register");(webphone_api.common.isNull(t)||t.length<1)&&(t="0");var i=webphone_api.common.StrToInt(t);if(0===webphone_api.common.GetAutostart())return webphone_api.common.PutToDebugLog(2,"EVENT, autostart is disabled, Start must be called manually"),void e("autostart is disabled");i<1?o(2):webphone_api.common.GetSipusername(!0).length>0&&webphone_api.common.GetParameter("password").length>0&&o(3),webphone_api.common.HandleScurlSetparameters(),webphone_api.common.ParseSipAccounts(),e("finished normally")}at=!0})})}catch(t){webphone_api.common.PutToDebugLogSpecial(1,"ERROR, plhandler HandleSettingsSDK",!0,t),webphone_api.common.PutToDebugLogException(2,"plhandler: HandleSettingsSDK",t),e("ERROR,exception")}}function r(e){try{if(St)return;if((webphone_api.common.isNull(e)||e.length<1)&&(e="x"),webphone_api.global.loglevel=webphone_api.common.GetLogLevel(),setTimeout(function(){webphone_api.common.IsLastUsedEngineSaved()||(webphone_api.common.PutToDebugLog(4,"EVENT, reset last used engine"),webphone_api.common.GetParameter("lastusedengine").length>0&&webphone_api.common.SaveParameter("prevusedengine",webphone_api.common.GetParameter("lastusedengine")),webphone_api.common.SaveParameter("lastusedengine",""),webphone_api.global.last_used_engine_cache="")},4e3),!1===Nt&&!0===webphone_api.common.IsSDK()&&webphone_api.common.ReadCallhistoryFile(function(e){e||webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: Load call history failed")}),ht>190)return;!1===webphone_api.common.IsWindowsSoftphone()&&webphone_api.common.CanLog(2)&&(webphone_api.common.PutToDebugLog(4,"EVENT, plhandler StartEngine called"),webphone_api.common.PutToDebugLog(2,"EVENT, starting engine...")),webphone_api.common.HideSettings("voicemail","","voicemail",!0)&&webphone_api.common.SaveParameter("voicemail","0"),(webphone_api.common.HideSettings("chat","","chat",!0)||3==webphone_api.common.GetParameterInt("chatsms",0)||0==webphone_api.common.GetParameterInt("textmessaging",-1))&&(webphone_api.global.textmessaging=0);var n=webphone_api.common.GetParameter("serveraddress_user"),t=webphone_api.common.GetSipusername();(webphone_api.common.isNull(t)||t.length<1)&&(t=webphone_api.common.GetSipusername());var i=webphone_api.common.GetParameter("password"),a=webphone_api.common.GetParameter("registerinterval");if(!webphone_api.common.isNull(t)&&t.length>0&&!webphone_api.common.isNull(i)&&i.length>0){webphone_api.common.isNull(n)&&(n=""),(webphone_api.common.isNull(a)||0==webphone_api.common.IsNumber(a))&&(a="3600");var r=webphone_api.common.StrToInt(a),l=!1;if(webphone_api.global.sipaccounts.length<1)l=!0;else for(var p=0;p<webphone_api.global.sipaccounts.length;p++){var c=webphone_api.global.sipaccounts[p];if(!webphone_api.common.isNull(c)&&((c.username===t||c.username===webphone_api.common.GetUsernamePart(t))&&c.password===i&&c.serveraddress===n)){l=c.ismain;break}}var u=webphone_api.common.GetParameter("username"),g=webphone_api.common.GetParameter("displayname"),h=webphone_api.common.GetParameter("proxyaddress"),m=webphone_api.common.GetParameter("realm");webphone_api.common.AddOneAcc(n,t,i,r,!0,l,!0,u,g,h,m)}St=!0,setTimeout(function(){St=!1},2e3),ut=null,webphone_api.common.IsWindowsSoftphone()?ve("platform","desktop"):webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE()&&ve("platform","web");var d=webphone_api.common.GetParameter("messagepopup");if(!webphone_api.common.isNull(d)&&d.length>1&&setTimeout(function(){(!0===webphone_api.common.IsSDK()||webphone_api.$(".ui-page-active .ui-popup-active").length<1)&&(webphone_api.common.ShowToast(d),webphone_api.common.SaveParameter("messagepopup",""))},4500),webphone_api.common.IsWindowsSoftphone())return webphone_api.common.PutToDebugLog(2,"EVENT, start engine: windows softphone - NS engine"),webphone_api.webphone.StartWin(),!0;var b=webphone_api.common.GetSelectedEngineName(),_=webphone_api.common.GetRecommendedEngineName();if(webphone_api.common.isNull(b)||b.length<1)return webphone_api.common.PutToDebugLog(2,"ERROR, plhandler StartUp no selected engine available"),!1;if(!0===webphone_api.global.isfirststart||webphone_api.common.isNull(webphone_api.global.useengine)||webphone_api.global.useengine.length<2)webphone_api.common.PutToDebugLog(2,"EVENT, StartEngine set useengine: "+b),webphone_api.global.useengine=b,webphone_api.global.last_useengine=b,webphone_api.global.last_last_useengine=b,webphone_api.global.isfirststart=!1;else{if(webphone_api.common.isNull(_)||_.length<1){var f=webphone_api.common.GetEngine(b);return f.failed=1,webphone_api.common.SetEngine(b,f),webphone_api.common.PutToDebugLog(4,"EVENT, WaitForEngineSelect called_3"),webphone_api.common.EngineSelect(1,29),o(4),!1}webphone_api.common.PutToDebugLog(2,"EVENT, StartEngine recommended set useengine: "+_),webphone_api.global.useengine=_,webphone_api.global.last_useengine=_,webphone_api.global.last_last_useengine=_}if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE()&&"flash"===webphone_api.common.getuseengine()){var w=window.location.protocol;!webphone_api.common.isNull(w)&&w.length>0&&w.toLowerCase().indexOf("file")>=0&&("0"===webphone_api.common.GetParameter2("enginepriority_java")&&"0"===webphone_api.common.GetParameter2("enginepriority_webrtc")&&"0"===webphone_api.common.GetParameter2("enginepriority_ns")||"flash"===webphone_api.common.getuseengine())&&(webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_flash_local")),console.log(webphone_api.stringres.get("err_flash_local")))}try{webphone_api.onAppStateChangeCb("started")}catch(P){webphone_api.common.PutToDebugLogException(2,"plhandler: There is an error in onAppStateChange(started) callback",P)}try{webphone_api.onStartCb()}catch(P){webphone_api.common.PutToDebugLogException(2,"There is an error in onStart() callback",P)}if(webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onstart,"onStart","","","",""),!0===webphone_api.common.UseCustomAutoprov(!1)&&webphone_api.common.GetCustomAutoprov(function(e){webphone_api.common.RecAutoprovCustom(e)}),!1===webphone_api.common.Loa()){var v=[];v.push("E"),v.push("R"),v.push("R"),v.push("O"),v.push("R"),v.push(","),v.push(" "),v.push("o"),v.push("n"),v.push("l"),v.push("y"),v.push(" "),v.push("a"),v.push("n"),v.push("d"),v.push("r"),v.push("o"),v.push("i"),v.push("d");var E=v.join("");setTimeout(function(){webphone_api.common.PutToDebugLog(2,E)},1214),setTimeout(function(){s(!1,e+" a")},6e4)}else s(!1,e+" b");yn()}catch(P){webphone_api.common.PutToDebugLogException(2,"plhandler: StartEngine",P)}}function l(e){try{(webphone_api.common.isNull(e)||e.length<1)&&(webphone_api.common.PutToDebugLog(2,"ERROR, ParseReceivedParameters invalid parameters: "+e),s(!0,"c")),e=webphone_api.common.Trim(e),e.indexOf("error")>=0&&(webphone_api.common.PutToDebugLog(2,"ERROR, ParseReceivedParameters error received: "+e),s(!0,"d"));var n=e.split(",");if(!webphone_api.common.isNull(n)&&n.length>0)for(var t=0;t<n.length;t++)if(!(webphone_api.common.isNull(n[t])||n[t].length<3||n[t].indexOf("=")<1)){var o=webphone_api.common.Trim(n[t].substring(0,n[t].indexOf("="))),i=webphone_api.common.Trim(n[t].substring(n[t].indexOf("=")+1,n[t].length));!webphone_api.common.isNull(o)&&o.length>0&&!webphone_api.common.isNull(i)&&(o=o.toLowerCase(),webphone_api.common.SaveParameter(o,i))}}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: ParseReceivedParameters",a)}webphone_api.common.PutToDebugLog(2,"EVENT, scurl_setparameters STOP"),Me(!1,1),setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Start scurl_setparameters START"),webphone_api.start()},1500)}function s(e,n){p(e,n)}function p(e,n){var t=0;try{if(t=1,webphone_api.common.PutToDebugLog(4,"EVENT, start engine delayed "+n+" "+webphone_api.global.useengine),t=2,webphone_api.global.startendelayed_wascalled=!0,e&&(webphone_api.global.flagnsreconnect=!0),t=3,webphone_api.global.phonestarted>1&&!1===webphone_api.global.enstarteddisplayed){t=4,webphone_api.global.enstarteddisplayed=!0;var o="",i=webphone_api.common.getuseengine();o=i===webphone_api.global.ENGINE_JAVA?"jv":i===webphone_api.global.ENGINE_SERVICE?"ns":i===webphone_api.global.ENGINE_WEBRTC?"rtc":i,t=5,!1===webphone_api.common.IsWindowsSoftphone()&&webphone_api.common.PutToDebugLog(1,"EVENT,"+webphone_api.stringres.get("status_enginestarted")+" ("+o+")")}if(t=6,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE||(webphone_api.common.getuseengine(),webphone_api.global.ENGINE_JAVA),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){t=7;var a=1e3;1!==webphone_api.common.GetParameterInt("autoaction",0)&&3!==webphone_api.common.GetParameterInt("autoaction",0)||(a=1e4),h(a)}t=8,webphone_api.common.CanLog(5)&&(webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_java: "+webphone_api.common.GetCfgPriority("java")+" "+webphone_api.common.GetParameter2("enginepriority_java")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_webrtc: "+webphone_api.common.GetCfgPriority("webrtc")+" "+webphone_api.common.GetParameter2("enginepriority_webrtc")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_ns: "+webphone_api.common.GetCfgPriority("ns")+" "+webphone_api.common.GetParameter2("enginepriority_ns")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_flash: "+webphone_api.common.GetCfgPriority("flash")+" "+webphone_api.common.GetParameter2("enginepriority_flash")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_app: "+webphone_api.common.GetCfgPriority("app")+" "+webphone_api.common.GetParameter2("enginepriority_app")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_p2p: "+webphone_api.common.GetCfgPriority("p2p")+" "+webphone_api.common.GetParameter2("enginepriority_p2p")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_accessnum: "+webphone_api.common.GetCfgPriority("accessnum")+" "+webphone_api.common.GetParameter2("enginepriority_accessnum")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_nativedial: "+webphone_api.common.GetCfgPriority("nativedial")+" "+webphone_api.common.GetParameter2("enginepriority_nativedial"))),t=9,webphone_api.common.SaveParameter("lastsessionsuccess","1"),t=10;var o="",i=webphone_api.common.getuseengine();o=i===webphone_api.global.ENGINE_JAVA?"jv":i===webphone_api.global.ENGINE_SERVICE?"ns":i===webphone_api.global.ENGINE_WEBRTC?"rtc":i,!1===webphone_api.common.IsWindowsSoftphone()&&(webphone_api.common.PutToDebugLog(1,"STATUS,-1,"+webphone_api.stringres.get("status_startingengine")+" ("+o+")"),webphone_api.common.PutToDebugLog(3,"EVENT, starting useengine: "+webphone_api.common.getuseengine())),t=11;var r=[];if(r.push("E"),r.push("R"),r.push("R"),r.push("O"),r.push("R"),r.push(","),r.push(" "),r.push("T"),r.push("h"),r.push("e"),r.push(" "),r.push("B"),r.push("a"),r.push("s"),r.push("i"),r.push("c"),r.push(" "),r.push("v"),r.push("e"),r.push("r"),r.push("s"),r.push("i"),r.push("o"),r.push("n"),r.push(" "),r.push("o"),r.push("f"),r.push(" "),r.push("W"),r.push("e"),r.push("b"),r.push("p"),r.push("h"),r.push("o"),r.push("n"),r.push("e"),r.push(" "),r.push("d"),r.push("o"),r.push("e"),r.push("s"),r.push(" "),r.push("n"),r.push("o"),r.push("t"),r.push(" "),r.push("s"),r.push("u"),r.push("p"),r.push("p"),r.push("o"),r.push("r"),r.push("t"),r.push(" "),r.push("["),r.push("B"),r.push("R"),r.push("S"),r.push("]"),r.push(" "),r.push("b"),r.push("r"),r.push("o"),r.push("w"),r.push("s"),r.push("e"),r.push("r"),t=12,webphone_api.common.Glv()<=0&&"Chrome"===webphone_api.common.GetBrowser()){t=13;var l=r.join("");return l=l.replace("[BRS]",webphone_api.common.GetBrowser()),setTimeout(function(){webphone_api.common.PutToDebugLog(1,l)},1500),setTimeout(function(){webphone_api.common.PutToDebugLog(1,l.replace("ERROR","STATUS"))},2500),void setTimeout(function(){webphone_api.common.AlertDialog("",l)},2500)}if(webphone_api.common.Glv()<=0&&!1===webphone_api.common.CanIUseApplet()){t=14;var l=r.join("")
;return l=l.replace("[BRS]",webphone_api.common.GetBrowser()),setTimeout(function(){webphone_api.common.PutToDebugLog(1,l)},1450),setTimeout(function(){webphone_api.common.PutToDebugLog(1,l.replace("ERROR","STATUS"))},2450),void setTimeout(function(){webphone_api.common.AlertDialog("",l)},2450)}t=15;var s=webphone_api.common.GetEngine(webphone_api.global.useengine);t=16,webphone_api.common.isNull(s)||(t=17,webphone_api.global.useengineclicked_cache=s.clicked,t=18,s.clicked=1,t=19,webphone_api.common.SetEngine(webphone_api.global.useengine,s),t=20),t=21,webphone_api.common.AutodetectDirectWebrtc(),t=22,webphone_api.global.lastconfroom="";var p=webphone_api.common.GetParameterInt("handleusernameuri",3);if(4==p||5==p){var m=webphone_api.common.GetParameter("serveraddress");if(m=webphone_api.common.GetParameter("serveraddress_user",m),5==p||webphone_api.common.isNull(m)||m.length<1||"YOURSIPDOMAIN.COM"===m&&"YOURSIPSERVER.COM"===m&&"SIPSERVER"===m&&"VOIPSERVER"===m&&"SERVERADDRESS"===m){var d="",b=webphone_api.common.GetParameter("username"),_=webphone_api.common.GetParameter("sipusername");b.indexOf("@")>0?d=b:_.indexOf("@")>0&&(d=_),d.length>0&&(d=webphone_api.common.StripServeraddress(d),d.length>0&&"YOURSIPDOMAIN.COM"!==d&&"YOURSIPSERVER.COM"!==d&&"SIPSERVER"!==d&&"VOIPSERVER"!==d&&"SERVERADDRESS"!==d&&(webphone_api.common.SaveParameter("serveraddress",d),webphone_api.common.SaveParameter("serveraddress_user",d)))}}t=25;var f=webphone_api.common.GetParameter2("serveraddress");if((webphone_api.common.isNull(f)||f.length<2||"YOURSIPDOMAIN.COM"===f||"YOURSIPSERVER.COM"===f||"SIPSERVER"===f||"VOIPSERVER"===f||"SERVERADDRESS"===f)&&(t=26,webphone_api.common.SaveParameter("serveraddress",""),f=webphone_api.common.GetParameter2("serveraddress_user"),webphone_api.common.isNull(f)||f.length<2||"YOURSIPDOMAIN.COM"===f||"YOURSIPSERVER.COM"===f||"SIPSERVER"===f||"VOIPSERVER"===f||"SERVERADDRESS"===f))return t=27,webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("error_noserver")),webphone_api.common.PutToDebugLog(2,"ERROR,"+webphone_api.stringres.get("error_noserver")+"; srv: "+webphone_api.common.GetParameter("serveraddress")+"; srv_user: "+webphone_api.common.GetParameter("serveraddress_user")),webphone_api.common.AlertDialog("ERROR","ERROR,"+webphone_api.stringres.get("error_noserver")),"undefined"!=typeof webphone_api.global.worktimer&&null!==webphone_api.global.worktimer&&clearTimeout(webphone_api.global.worktimer),webphone_api.global.worktimer=null,webphone_api.common.SaveParameter("upperserverfromuser",3),void $e();t=28;var w=webphone_api.common.GetSipusername(!0),v=webphone_api.common.GetParameter2("password");t=29,"USERNAME"===w&&"PASSWORD"===v&&(t=30,"USERNAME"===webphone_api.common.GetParameter("username")&&webphone_api.common.SaveParameter("username",""),"USERNAME"===webphone_api.common.GetParameter("sipusername")&&webphone_api.common.SaveParameter("sipusername",""),webphone_api.common.SaveParameter("password",""));var E=webphone_api.common.GetParameter("username");if(E.length>0){var P=webphone_api.common.StripUsername(E,!0);P!==E&&webphone_api.common.SaveParameter("username",P)}var T=webphone_api.common.GetParameter("sipusername");if(T.length>0){var S=webphone_api.common.GetParameterInt("handlesipusernameuri",-2);S<-1&&0===webphone_api.common.GetParameterInt("allowsipuriasusername",1)&&(S=1);var N="";N=S>0?webphone_api.common.StripUsername(T,!0):webphone_api.common.StripUsername(T,!1),N!==T&&webphone_api.common.SaveParameter("sipusername",N)}if(t=31,webphone_api.common.StartFCM(webphone_api.common.getuseengine()),t=32,"java"===webphone_api.common.getuseengine()){t=33,webphone_api.common.ResetWsapisocket("plhandler start java"),t=34;var I=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_java")),C=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_webrtc")),G=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_ns")),L=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_flash")),R=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_app")),y=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_p2p")),D=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_accessnum")),O=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_nativedial"));return t=35,(5===I||I>0&&C<1&&G<1&&L<1&&R<1&&y<1&&D<1&&O<1)&&0===webphone_api.common.IsJavaInstalled()&&webphone_api.common.EngineForcedInstall("java"),t=36,webphone_api.common.IsCurrentEngineWorking(ut),webphone_api.common.PutToDebugLog(2,"EVENT, start engine: java"),webphone_api.global.dispregfailed<1&&(webphone_api.global.dispregfailed=1),t=37,g(),t=38,webphone_api.webphone.Start()}if("ns"===webphone_api.common.getuseengine())return t=39,5===webphone_api.common.GetParameterInt("enginepriority_ns",2)&&(t=40,webphone_api.common.IsServiceInstalled(function(e){!1===e&&(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: StartEngineDelayed, service upgrade: "+webphone_api.common.GetMinServiceVersion().toString()),webphone_api.common.EngineForcedInstall("ns"))},!0)),t=41,void webphone_api.common.IsServiceInstalled(function(e){if(t=42,!0===e){t=43,webphone_api.common.PutToDebugLog(2,"EVENT, start engine: service");var n=!1,o=webphone_api.common.GetParameterInt("lnsengine",-1);!1===webphone_api.global.usestorage&&!1===webphone_api.common.Strl(60)&&0===o&&(t=44,n=!0,webphone_api.common.SaveParameter("lnsengine","1")),t=45;var i=6e3;n&&(t=46,webphone_api.common.PutToDebugLog(2,"EVENT, Force NS engine upgrade because release version changed"),webphone_api.common.EngineForcedInstall("ns",webphone_api.stringres.get("service_update")),webphone_api.global.nsupdatepending=!0,i=18e4),t=47,setTimeout(function(){webphone_api.common.IsServiceUpToDate()},i),webphone_api.global.dispregfailed<1&&(webphone_api.global.dispregfailed=1),t=48,g(),t=49,webphone_api.webphone.StartService()}else t=50,webphone_api.common.isNull(webphone_api.global.worktimer)||clearTimeout(webphone_api.global.worktimer),t=51,webphone_api.common.PutToDebugLog(2,"EVENT, start engine: service; NOT starting because it is not installed")},!0);if("webrtc"===webphone_api.common.getuseengine()){t=52;var x=0;x=webphone_api.common.GetParameterInt("autoprovisioning",1);var A=Ee("serveraddress_user");if(webphone_api.common.isNull(A)&&(A=""),t=53,0===x||A.length<1||1===x&&A.indexOf(".")>0)t=54,c();else{t=55;var k=webphone_api.common.GetParameterInt("lastautoprov",0);k<1?(t=56,webphone_api.common.GetAutoprovisioning("",function(e){t=57,webphone_api.common.ParseAutoprovisioning(e),t=58,c()})):(t=59,c(),t=60,webphone_api.common.GetAutoprovisioning("",function(e){t=61,webphone_api.common.ParseAutoprovisioning(e)}))}return}if("flash"===webphone_api.common.getuseengine()){t=62;var x=0;x=webphone_api.common.GetParameterInt("autoprovisioning",1);var A=Ee("serveraddress_user");if(webphone_api.common.isNull(A)&&(A=""),t=63,0===x||A.length<1||1===x&&A.indexOf(".")>0)t=64,u();else{t=65;var k=webphone_api.common.GetParameterInt("lastautoprov",0);k<1?webphone_api.common.GetAutoprovisioning("",function(e){t=66,webphone_api.common.ParseAutoprovisioning(e),u()}):(t=67,u(),webphone_api.common.GetAutoprovisioning("",function(e){webphone_api.common.ParseAutoprovisioning(e)}))}return}if("app"===webphone_api.common.getuseengine()){t=68,t=69;var U=webphone_api.common.GetParameterInt("appengine_startat",2);1===U||2===U&&!1===webphone_api.common.IsSDK()?webphone_api.common.StartAppEngine(!0,"EVENT, start engine: app HandleProtocol, open native app"):(webphone_api.common.PutToDebugLog(2,"EVENT, start engine: skip APP engine start, appengine_startat: "+U+"; isSDK: "+webphone_api.common.IsSDK()),webphone_api.common.PutToDebugLog(1,"EVENT, Ready."))}else webphone_api.common.PutToDebugLog(2,"ERROR, start engine: invalid engine: "+webphone_api.common.getuseengine());t=70,setTimeout(function(){t=71,webphone_api.global.startendelayed_wascalled=!1},12e3)}catch(V){webphone_api.common.PutToDebugLogException(2,"plhandler: StartEngineDelayedEx ("+t.toString()+")",V)}}function c(){try{if(Ct<0&&(Ct=webphone_api.common.GetTickCount()),!1===webphone_api.global.pgw_decide_finished&&(webphone_api.common.isNull(It)||clearTimeout(It),It=null,It=setTimeout(function(){c()},150)),webphone_api.common.isNull(It)||clearTimeout(It),It=null,Ct>0&&webphone_api.common.GetTickCount()-Ct>6500&&!0===webphone_api.common.GetParameterBool("firststart_webrtc",!0)&&!0===webphone_api.common.CanIUseService()){webphone_api.common.PutToDebugLog(2,"WARNING, StartEngineWebRTC Failover to NS engine, because no response received from Websocket wsload"),webphone_api.common.SaveParameter("prevusedengine","webrtc"),webphone_api.common.SaveParameter("lastusedengine","ns"),webphone_api.flagrestartwebrtc=!1,webphone_api.common.ResetEngineClicked();var e=webphone_api.common.GetEngine("ns");e.clicked=2,webphone_api.common.SetEngine("ns",e),webphone_api.common.EngineSelect(1,30),webphone_api.common.PutToDebugLog(2,"WARNING, plhandler: offer ns engine because webrtc not received"),webphone_api.common.IsServiceInstalled(function(e){!1===e?webphone_api.common.EngineForcedInstall("ns",webphone_api.stringres.get("serviceengine_msg"),null,function(){webphone_api.startInner()}):webphone_api.startInner()},!0)}Ct=-1,webphone_api.common.ResetWsapisocket("plhandler start webrtc");var n=webphone_api.common.GetParameter("password");(webphone_api.common.isNull(n)||n.length<1)&&!1===webphone_api.common.NeedRegister()||t(),!0===webphone_api.common.UseTLSReload()&&webphone_api.common.TLSReload(),webphone_api.common.Ch(),webphone_api.common.PutToDebugLog(2,"EVENT, start engine: webrtc"),webphone_api.common.CheckEngineFirstStart(ut),webphone_api.common.GatewayFailower(-1,"starten");var o=webphone_api.common.GetWebrtcSrvAddr();if(2===webphone_api.common.GetConfigInt("usemizuwebrtcgateway",1)&&(o=""),(webphone_api.common.isNull(o)||o.length<2)&&(o=webphone_api.common.GetWp()),o.indexOf("mfstwebsock")<0){var i=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_java")),a=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_webrtc")),r=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_ns")),l=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_flash")),s=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_app")),p=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_p2p")),u=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_accessnum")),h=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_nativedial"));i<3&&a<3&&r<3&&l<3&&s<3&&p<3&&u<3&&h<3&&(a=3,webphone_api.common.SaveParameter("enginepriority_webrtc",a),webphone_api.common.PutToDebugLog(2,"EVENT,WebRtc engine priority set to higher, because not Mgateway: "+a))}return"Android"===webphone_api.common.GetOs()&&3===webphone_api.common.GetParameterInt("androidspeaker",1)&&setTimeout(function(){webphone_api.webrtcapi.SwitchOffAndroidSpeaker()},500),webphone_api.global.dispregfailed<1&&(webphone_api.global.dispregfailed=1),g(),webphone_api.webrtcapi.Start()}catch(m){webphone_api.common.PutToDebugLogException(2,"plhandler: StartEngineWebRTC",m)}}function u(){try{return webphone_api.common.PutToDebugLog(2,"EVENT, start engine: flash"),webphone_api.global.dispregfailed<1&&(webphone_api.global.dispregfailed=1),g(),webphone_api.flashapi.Start()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: StartEngineFlash",e)}}function g(){try{var e=webphone_api.common.GetAutostart();if(!0===webphone_api.common.IsSDK()||0!==e)return!1;setTimeout(function(){if("page_settings"===webphone_api.$.mobile.activePage.attr("id")){webphone_api.common.PutToDebugLog(2,"EVENT, plhandler LoginSkin exec");var e=webphone_api.common.GetSipusername(!0),n=webphone_api.common.GetParameter("password");return!webphone_api.common.isNull(e)&&e.length>0&&!webphone_api.common.isNull(n)&&n.length>0?(webphone_api.global.laststarttick=webphone_api.common.GetTickCount()+100,void(webphone_api.common.isNull(webphone_api._settings)||webphone_api._settings.SaveSettings())):void 0}},600)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: LoginSkin",n)}}function h(e,n){try{if(0!=Gt&&webphone_api.common.GetTickCount()-Gt<3e3&&webphone_api.common.GetTickCount()-Gt>=0)return;Gt=webphone_api.common.GetTickCount(),(webphone_api.common.isNull(e)||!1===webphone_api.common.IsNumber(e)||e<0)&&(e=2e3);var t=200;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(t=150),webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu called delay: "+e+"; delayaddition: "+t),!0===n)return setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist 0"),webphone_api.getdevicelist(0,function(e){}),webphone_api.getdevice(0,function(e){})},e),setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist 1"),webphone_api.getdevicelist(1,function(e){}),webphone_api.getdevice(1,function(e){})},e+150),webphone_api.common.CanIUseVideo()&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist 2"),webphone_api.getdevicelist(2,function(e){}),webphone_api.getdevice(2,function(e){})},e+300),void webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu return forced");(webphone_api.common.isNull(webphone_api.global.audio_rec_device_list)||webphone_api.global.audio_rec_device_list.length<1)&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist mic"),webphone_api.getdevicelist(0,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec mic 1")}),webphone_api.getdevice(0,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec mic 2")})},e+t),(webphone_api.common.isNull(webphone_api.global.audio_play_device_list)||webphone_api.global.audio_play_device_list.length<1)&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist play"),webphone_api.getdevicelist(1,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec play 1")}),webphone_api.getdevice(1,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec play 2")})},e+2*t),(webphone_api.common.isNull(webphone_api.global.audio_ring_device_list)||webphone_api.global.audio_ring_device_list.length<1)&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist ring"),webphone_api.getdevicelist(2,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec ring 1")}),webphone_api.getdevice(2,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec ring 2")})},e+3*t),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.common.CanIUseVideo()&&(webphone_api.common.isNull(webphone_api.global.video_rec_device_list)||webphone_api.global.video_rec_device_list.length<1)&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist video"),webphone_api.getdevicelist(3,function(e){}),webphone_api.getdevice(3,function(e){})},e+4*t),setTimeout(function(){if(webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu START checking audio_rec_device_list: "+webphone_api.global.audio_rec_device_list+"; audio_play_device_list: "+webphone_api.global.audio_play_device_list),!webphone_api.common.isNull(webphone_api.global.audio_rec_device_list)&&webphone_api.global.audio_rec_device_list.length>0&&!webphone_api.common.isNull(webphone_api.global.audio_play_device_list)&&webphone_api.global.audio_play_device_list.length>0){var n=webphone_api.common.GetTickCount()-Gt;webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu READY on first try after delay: "+n),webphone_api.global.audio_devices_loaded=!0}else setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist delayed 0"),webphone_api.getdevicelist(0,function(e){}),webphone_api.getdevice(0,function(e){})},e+2e4+t),setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist delayed 1"),webphone_api.getdevicelist(1,function(e){}),webphone_api.getdevice(1,function(e){})},e+2e4+2*t),setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist delayed 2"),webphone_api.getdevicelist(2,function(e){}),webphone_api.getdevice(2,function(e){})},e+2e4+3*t),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.common.CanIUseVideo()&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist delayed 3"),webphone_api.getdevicelist(3,function(e){}),webphone_api.getdevice(3,function(e){})},e+2e4+4*t),setTimeout(function(){if(!webphone_api.common.isNull(webphone_api.global.audio_rec_device_list)&&webphone_api.global.audio_rec_device_list.length>0&&!webphone_api.common.isNull(webphone_api.global.audio_play_device_list)&&webphone_api.global.audio_play_device_list.length>0){var e=webphone_api.common.GetTickCount()-Gt;webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu READY on second try after delay: "+e),webphone_api.global.audio_devices_loaded=!0}},e+4*t)},e+3*t+500)}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: GetAudioDevicesForMenu",o)}}function m(e){try{Jn("Register");var t=webphone_api.common.GetParameterInt("register",1);if(webphone_api.parameters.register=2,webphone_api.common.SaveParameter("register","2"),webphone_api.common.PutToDebugLog(2,"EVENT, user, register (API_Register) called"),st)return void webphone_api.common.PutToDebugLog(3,"EVENT, plhandler register, Start already called");ct=!0,webphone_api.common.isNull(pt)||clearTimeout(pt),pt=setTimeout(function(){ct=!1},6e3);var o=webphone_api.common.IsConfigChanged();!0===o&&!0===webphone_api.isregistered()||!0===webphone_api.global.pres_unreg_called||0===t||0!=Lt&&webphone_api.common.GetTickCount()-Lt>12e3&&!webphone_api.isregistered()?(!0===o&&!0===webphone_api.isregistered()?webphone_api.common.PutToDebugLog(5,"EVENT, rst on config changhe"):!0===webphone_api.global.pres_unreg_called?webphone_api.common.PutToDebugLog(5,"EVENT, rst on after unreg"):0===t?webphone_api.common.PutToDebugLog(5,"EVENT, rst on no orig reg"):0!=Lt&&webphone_api.common.GetTickCount()-Lt>12e3&&!webphone_api.isregistered()?webphone_api.common.PutToDebugLog(5,"EVENT, rst on not registered"):webphone_api.common.PutToDebugLog(5,"EVENT, rst on unknown"),Lt=webphone_api.common.GetTickCount(),n(e)):0==Lt||ct||d()}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: Register",i)}}function d(){try{if(webphone_api.common.PutToDebugLog(3,"EVENT, Reregister ..."),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void(webphone_api.webrtcapi&&webphone_api.webrtcapi.ResendRegister());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_RegisterNoParam",null,-1);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE()&&webphone_api.webphone&&webphone_api.webphone.applethandle)return webphone_api.webphone.ReRegister()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: ReRegister",e)}}function b(e){try{Jn("RegisterEx");var n=25;if(webphone_api.common.Glv()<2&&(n=13),webphone_api.common.isNull(e)||e.length<4)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler RegisterEx no acocunts passed: "+e);if(e=e.toString(),e=webphone_api.common.ReplaceAll(e," ",""),webphone_api.common.isNull(e)||e.length<4)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler RegisterEx no acocunts passed: "+e);if(n<21){var t=[];t.push("E"),t.push("R"),t.push("R"),t.push("O"),t.push("R"),t.push(","),t.push("R"),t.push("e"),t.push("g"),t.push("i"),t.push("s"),t.push("t"),t.push("e"),t.push("r"),t.push("E"),t.push("x"),t.push(" "),t.push("n"),t.push("o"),t.push("t"),t.push(" "),t.push("a"),t.push("l"),t.push("l"),t.push("o"),t.push("w"),t.push("e"),t.push("d"),t.push(" "),t.push("b"),t.push("y"),t.push(" "),t.push("l"),t.push("i"),t.push("c"),t.push("e"),t.push("n"),t.push("s"),t.push("e");var o=t.join("");return void setTimeout(function(){webphone_api.common.PutToDebugLog(1,o)},851)}if("null"==e&&(e=""),webphone_api.common.SaveParameter("extraregisteraccounts",e),webphone_api.common.PutToDebugLog(2,"EVENT, plhandler RegisterEx: "+e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){if(e.length<1)return;webphone_api.webrtcapi.RegisterEx(e)}if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH){if(e.length<1)return;webphone_api.common.PutToDebugLog(2,"ERROR, RegisterEx is not supported by flash engine")}webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_RegisterEx",null,e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.RegisterEx(e)}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: RegisterEx",i)}}function _(e,n){try{if(Jn("CheckPresence"),webphone_api.common.isNull(e)||e.length<1)return"";if(webphone_api.global.phonestarted<2)return void Yn("CheckPresence",[e,n]);if(webphone_api.common.PutToDebugLog(2,"EVENT, user, checkpresence (API_CheckPresence), userlist: "+e),n&&"function"==typeof n&&(webphone_api.common.isNull(webphone_api.global.checkpres_callback)&&(webphone_api.global.checkpres_callback=[]),webphone_api.global.checkpres_callback.push(n)),webphone_api.common.PresenceGet2(e),!webphone_api.common.isNull(webphone_api.global.presenceHM)){var t={5:"online",4:"DND",3:"pending",2:"idle",1:"invisible",0:"offline","-1":"not exists"},o="";for(var i in webphone_api.global.presenceHM)webphone_api.common.isNull(i)||i.length<1||webphone_api.common.isNull(webphone_api.global.presenceHM.num)||(o.length>1&&(o+=";"),o=o+i+","+t[o.num[webphone_api.common.PRES_STATUS]]);return webphone_api.common.isNull(o)&&(o=""),o}}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: CheckPresence",a)}return""}function f(e){if(Jn("SetPresenceStatus"),webphone_api.global.phonestarted<2)return void Yn("SetPresenceStatus",[e]);webphone_api.common.PutToDebugLog(2,"EVENT, user, setpresencestatus (API_SetPresenceStatus), status: "+e),webphone_api.common.PresenceSet2(e)}function w(e){Jn("CheckBLF");try{if(webphone_api.common.isNull(e)||e.length<1)return webphone_api.common.PutToDebugLog(2,"ERROR, plhandler checkblf empty userkist"),!1;if(webphone_api.global.phonestarted<2)return Yn("CheckBLF",[e]),!0;if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler API_CheckBLF: "+e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.common.PutToDebugLog(2,"WARNING, BLF is not yet supported on WebRTC"),!1;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"WARNING, BLF is not yet supported on flash"),!1;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_CheckBLF",null,e),!0;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.CheckBLF(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: CheckBLF",n)}return!1}function v(e){Jn("GetVersionNS");try{if(!e||"function"!=typeof e)return webphone_api.common.PutToDebugLog(2,"ERROR, plhandler GetVersionNS: no callback function specified"),"ERROR, no callback function specified";if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler getversionns"),webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_GetExeVersion",function(n){webphone_api.common.isNull(n)&&(n=""),n=n.toString(),n=n.replace("OK:",""),n=webphone_api.common.Trim(n),e(n)}),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){var n=webphone_api.webphone.GetVersionNS();n=n.toString(),n=n.replace("OK:",""),n=webphone_api.common.Trim(n),e(n)}}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetVersionNS",t)}}function E(e){Jn("GetVersionNSNum");try{if(!e||"function"!=typeof e)return webphone_api.common.PutToDebugLog(2,"ERROR, plhandler GetVersionNSNum: no callback function specified"),"ERROR, no callback function specified";if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler getversionnsnum"),webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_GetExeVersionNumber",function(n){webphone_api.common.isNull(n)&&(n=""),n=n.toString(),n=n.replace("OK:",""),n=webphone_api.common.Trim(n),e(n)}),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){var n=webphone_api.webphone.GetVersionNSNum();webphone_api.common.isNull(n)&&(n=""),n=n.toString(),n=n.replace("OK:",""),n=webphone_api.common.Trim(n),e(n)}}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetVersionNS",t)}}function P(e){Jn("GetVersionJava");try{if(!e||"function"!=typeof e)return webphone_api.common.PutToDebugLog(2,"ERROR, plhandler GetVersionJava: no callback function specified"),"ERROR, no callback function specified";if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler getversionjava"),webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_GetExeVersion",function(n){webphone_api.common.isNull(n)&&(n=""),e(n)}),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return void e(webphone_api.webphone.GetVersionJava())}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: GetVersionJava",n)}}function T(){try{if(Jn("IsEncrypted"),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return 3;if(webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.global.useengine!==webphone_api.global.ENGINE_SERVICE&&webphone_api.global.useengine!==webphone_api.global.ENGINE_JAVA)return 0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_IsEncrypted",function(e){!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)&&(webphone_api.global.isencrypted=e)}),0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.IsEncrypted()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: IsEncrypted",e)}return 0}function S(e,n){try{if(Jn("SetSipHeader"),webphone_api.common.isNull(e))return void webphone_api.common.PutToDebugLog(2,"ERROR, SetSipHeader invalid header. A valid SIP header consists of a name/value pair separated by a colon, ex. Headername: Value");if(webphone_api.global.phonestarted<2)return void Yn("SetSipHeader",[e]);webphone_api.common.PutToDebugLog(2,"EVENT, setsipheader: "+e);var t=webphone_api.global.aline;if(!webphone_api.common.isNull(n)&&webphone_api.common.IsNumber(n)&&(t=n),(webphone_api.common.isNull(t)||-3===t)&&(t=-1),e=webphone_api.common.Trim(e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.SetSipHeader(t,e);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void webphone_api.common.PutToDebugLog(2,"ERROR, setsipheader is not supported by flash engine");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_SetSIPHeader",null,webphone_api.common.GetLineForJavaAPI(n),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.SetSipHeader(webphone_api.common.GetLineForJavaAPI(n),e)}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: SetSipHeader",o)}}function N(e,n){try{if(Jn("GetSipHeaderInternal"),!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetSipHeaderInternal callback is not defined");var t=webphone_api.global.aline;if((webphone_api.common.isNull(t)||-3===t)&&(t=-1),webphone_api.common.isNull(e)||e.length<1)return webphone_api.common.PutToDebugLog(2,"ERROR, Invalid header: "+e),void n("ERROR, Invalid header: "+e);if(e=e.toString(),e=e.replace(":",""),webphone_api.global.phonestarted<2)return void Yn("GetSipHeaderInternal",[e,n]);if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: GetSipHeaderInternal: "+e+"; ("+webphone_api.common.getuseengine()+")"),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void n(webphone_api.common.GetSipHeaderInternal(e));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, GetSipHeaderInternal is not supported by flash engine"),void n("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetSipHeaderInternal",function(e){n(e)},webphone_api.common.GetLineForJavaAPI(t,1),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void n(webphone_api.webphone.GetSipHeaderInternal(webphone_api.common.GetLineForJavaAPI(t,1),e,n))}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: GetSipHeaderInternal",o)}}function I(e,n,t){var o=0;try{if(o=1,Jn("GetSipHeader"),!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetSipHeader callback is not defined");o=2;var i=webphone_api.global.aline;if((webphone_api.common.isNull(i)||-3===i)&&(i=-1),webphone_api.common.isNull(e)||e.length<1)return webphone_api.common.PutToDebugLog(2,"ERROR, Invalid header: "+e),void n("ERROR, Invalid header: "+e);if(o=3,e=e.toString(),e=e.replace(":",""),o=4,webphone_api.global.phonestarted<2)return o=5,void Yn("GetSipHeader",[e,n]);if(webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: getsipheader: "+e+"; ("+webphone_api.common.getuseengine()+")"),o=6,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return o=7,void n(webphone_api.common.GetSipHeader(e,!1,-1,t));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return o=8,webphone_api.common.PutToDebugLog(2,"ERROR, getsipheader is not supported by flash engine"),void n("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return o=9,void webphone_api.common.WinAPI("API_GetSIPHeader",function(e){n(e)},webphone_api.common.GetLineForJavaAPI(),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return o=10,
void n(webphone_api.webphone.GetSipHeader(webphone_api.common.GetLineForJavaAPI(),e,n))}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: GetSipHeader ("+o.toString()+")",a)}}function C(e,n,t,o){try{if(Jn("GetSipMessage"),!t||"function"!=typeof t)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetSipMessage callback is not defined");var i=webphone_api.global.aline;if((webphone_api.common.isNull(i)||-3===i)&&(i=-1),webphone_api.global.phonestarted<2)return void Yn("GetSipMessage",[e,n,t,o]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void t(webphone_api.common.GetSipMessage(i,e,n,o));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, GetSipMessage is not supported by flash engine"),void t("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetSIPMessage",function(e){t(e)},webphone_api.common.GetLineForJavaAPI(),e,n);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void t(webphone_api.webphone.GetSipMessage(webphone_api.common.GetLineForJavaAPI(),e,n))}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: GetSipMessage",a)}}function G(e){try{if(Jn("GetSipMessage"),webphone_api.common.isNull(e)||!webphone_api.common.IsNumber(e))return!1;var n=webphone_api.common.StrToInt(e);if(n<0||n>45)return!1;if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler changetheme to: "+n.toString()),webphone_api.common.SaveParameter("theme",n.toString()),webphone_api.common.SetCurrTheme(),webphone_api.common.IsWindowsSoftphone()){var t=webphone_api.common.AddJscommport(webphone_api.global.WIN_SOFTPHONE_URL)+"?extcmd_theme="+e;webphone_api.common.WinSoftphoneHttpReq(t,"GET","","",function(e){webphone_api.common.PutToDebugLog(2,"EVENT, plhandler, send theme to softphone response: "+e)})}return!0}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: ChangeTheme",o)}return!1}function L(e){try{if(Jn("GetWorkDir"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetWorkDir callback is not definaed");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.common.PutToDebugLog(2,"ERROR, getworkdir: only for ns and java"),void e("ERROR, etworkdir: only for ns and java");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, getworkdir: only for ns and java"),void e("ERROR, etworkdir: only for ns and java");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetWorkdir",function(n){e(n)});if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void e(webphone_api.webphone.GetWorkDir())}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: GetWorkDir",n)}}function R(e){Jn("VideoCall"),!1!==webphone_api.common.Glvd()&&x(e,1)}function y(e,n){try{return Jn("MuteVideo"),!1===webphone_api.global.checkIfCallActive?(webphone_api.common.PutToDebugLog(2,"WARNING, MuteVideo there is no active call at the moment."),!1):!1===webphone_api.global.isvideocall?(webphone_api.common.PutToDebugLog(2,"WARNING, MuteVideo this is not a video call."),!1):webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC?(webphone_api.common.PutToDebugLog(2,"ERROR, MuteVideo this is not WebRTC engine."),!1):(e?webphone_api.common.PutToDebugLog(1,"STATUS, "+webphone_api.stringres.get("muted_video")):webphone_api.common.PutToDebugLog(1,"STATUS, "+webphone_api.stringres.get("unmuted_video")),webphone_api.common.PutToDebugLog(2,"EVENT, USER, mutevideo (API_MuteVideo), "+e+", "+n),webphone_api.webrtcapi.SipMuteVideo(e,n))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: MuteVideo",t)}return!1}function D(e,n){function t(){x(e,2)}try{if(Jn("ScreenShare"),!1===webphone_api.common.Glss())return;webphone_api.common.IsWindowsSoftphone(),t()}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: ScreenShare",o)}}function O(){try{if(!webphone_api.global.usestorage)return;webphone_api.common.isNull(Rt)||(clearTimeout(Rt),Rt=null)}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: Cfin",e)}}function x(e,n){try{Jn("Call"),webphone_api.global.ringstart_time=0,webphone_api.global.callstart_time=0,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_APP&&!1===webphone_api.global.isappenginestarted&&webphone_api.common.StartAppEngine(!0,"EVENT, start engine: because initiating call",!0,e),Dt=!1;var t=115e3;if((webphone_api.common.isNull(n)||!1===webphone_api.common.IsNumber(n))&&(n=0),webphone_api.common.SvCont()&&(t=23e4),webphone_api.global.usestorage&&(Rt=setTimeout(function(){clearTimeout(Rt),Rt=null;var e=[];e.push("L"),e.push("i"),e.push("c"),e.push("e"),e.push("n"),e.push("s"),e.push("e"),e.push(" "),e.push("o"),e.push("r"),e.push(" "),e.push("d"),e.push("e"),e.push("m"),e.push("o "),e.push("l"),e.push("i"),e.push("m"),e.push("i"),e.push("t"),e.push(". "),e.push("R"),e.push("e"),e.push("s"),e.push("t"),e.push("a"),e.push("r"),e.push("t "),e.push("r"),e.push("e"),e.push("q"),e.push("u"),e.push("i"),e.push("r"),e.push("e"),e.push("d"),e.push(" "),e.push("h"),e.push("a"),e.push("n"),e.push("g"),e.push("u"),e.push("p"),e.push(" "),e.push("9");var n=e.join("");V(null,!0),setTimeout(function(){webphone_api.common.PutToDebugLog(1,"ERROR,"+n)},100),setTimeout(function(){webphone_api.common.PutToDebugLog(1,"ERROR,"+n),webphone_api.common.ShowToast("ERROR,"+n,15e3)},250)},t)),!webphone_api.common.onc())return!1;webphone_api.common.GetNrOfActiveCalls()<1&&webphone_api.notifications.SetCallStartTime(webphone_api.common.GetTickCount());var o=webphone_api.global.aline;if((webphone_api.common.isNull(o)||-3===o)&&(o=-1),webphone_api.common.IsLineFree(o)||(o=webphone_api.common.GetFreeLine(),Pe(o,!1,500)),webphone_api.common.isNull(e)||webphone_api.common.Trim(e).length<1)return webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_msg_4")+": "+e),!1;if(e=webphone_api.common.Trim(e),webphone_api.common.PutToDebugLog(2,"EVENT, plhandler initiate Call with engine: "+webphone_api.global.useengine+", to number: "+e),webphone_api.global.sipstackstarted=!0,!0===webphone_api.common.CanUseIncomingCallNot()){var i=webphone_api.common.GetParameterInt("askfornotifpermission",-1);i=webphone_api.common.GetParameterInt("asknotifpermission",i),i>=3&&webphone_api.common.RequestBrowserNotificationPermission(function(){},"","","",3)}if(webphone_api.common.RemoveSipHeadreFromCache("X-reason"),webphone_api.common.RemoveSipHeadreFromCache("Reason"),webphone_api.common.RemoveSipHeadreFromCache("Warning"),"p2p"===webphone_api.common.getuseengine())return void webphone_api.common.Phone2Phone("",e);if("accessnum"===webphone_api.common.getuseengine())var a=webphone_api.common.GetParameter("accessnumber"),r="tel://"+a;else if("nativedial"===webphone_api.common.getuseengine()||"app"===webphone_api.common.getuseengine()){var r="tel://"+encodeURIComponent(e),l='<a href="'+r+'" id="make_native_call" style="display: none;">call</a>';return webphone_api.$("body").append(l),webphone_api.$("#make_native_call").on("click",function(){var e=webphone_api.$("#make_native_call").attr("href");webphone_api.$("#make_native_call").remove(),window.location=e}),webphone_api.$("#make_native_call").click(),void webphone_api.common.ShowToast(webphone_api.stringres.get("native_call"))}var s=!1,p=webphone_api.common.GetParameterInt("multilineoop",2),c=webphone_api.common.GetNrOfActiveCalls();if(c<1&&webphone_api.notifications.SetCallStartTime(webphone_api.common.GetTickCount()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(-1==p||c>0&&(p<2||p<3&&"Firefox"===webphone_api.common.GetBrowser()))&&!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0)for(var u=0;u<webphone_api.global.ep.length;u++)if(!webphone_api.common.isNull(webphone_api.global.ep[u])&&"true"==webphone_api.global.ep[u][webphone_api.common.EP_HOLDSTATE]){var g=webphone_api.global.ep[u][webphone_api.common.EP_LINE];Pe(g,!0,501),webphone_api.common.PutToDebugLog(2,"EVENT, API_Hold mainlogic resume call from pl and mute because webrtc multiline call; peer: "+webphone_api.global.ep[u][webphone_api.common.EP_DESTNR]+" on line: "+g),s=!0,webphone_api.global.wasmultilineoop=1,-1!=p&&(webphone_api.hold(!1),webphone_api.global.needmuteafterreload=g,webphone_api.global.callaftermute_line=o,webphone_api.global.callaftermute_number=e,webphone_api.global.callaftermute_mode=n);var h=6500;-1==p&&(h=90),setTimeout(function(){if(g<1||webphone_api.global.needmuteafterreload>0||-1==p){if(webphone_api.common.PutToDebugLog(5,"EVENT, mute after reload timeout"),-1!=p){Te()!=g&&Pe(g,!0,502)}return J(!0,null,!0)}(g<1||-1==p)&&webphone_api.global.callaftermute_number.length>0&&(webphone_api.common.PutToDebugLog(5,"EVENT, call after reload timeout"),Pe(o,!0,505),A(o,e,n))},h)}c<1&&webphone_api.notifications.SetCallStartTime(webphone_api.common.GetTickCount()),s||A(o,e,n)}catch(m){webphone_api.common.PutToDebugLogException(2,"plhandler: Call",m)}return!1}function A(e,t,o){try{webphone_api.common.isNull(yt)||clearTimeout(yt),yt=null,webphone_api.global.sipstackstarted=!0,webphone_api.global.phonestarted<1&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_APP&&(webphone_api.global.phonestarted=1,n(webphone_api.parameters));var i=webphone_api.common.NeedRegister(),a=webphone_api.common.GetTickCount();if(0==Ot&&(Ot=a),!0===webphone_api.common.GetParameterBool("mustconnect",!1)&&webphone_api.global.phonestarted<3)return webphone_api.common.PutToDebugLog(1,"ERROR, "+webphone_api.stringres.get("warning_notreg")),void webphone_api.common.ShowToast(webphone_api.stringres.get("warning_notreg"));if(i&&webphone_api.global.phonestarted<3&&a-Ot<4e3||webphone_api.global.phonestarted<2){var r=webphone_api.common.GetParameterInt("register",1);return r>1&&!1===Dt&&a-Ot>3500&&(Dt=!0,!1===i?(webphone_api.common.PutToDebugLog(2,"WARNING, Cannot initiate call because SipStack is not started ("+r.toString()+" "+(a-Ot).toString()+" "+Ot.toString()+")"),webphone_api.common.ShowToast(webphone_api.stringres.get("warning_notstarted"))):(webphone_api.common.PutToDebugLog(2,"WARNING, "+webphone_api.stringres.get("warning_notreg")+" ("+r.toString()+" "+(a-Ot).toString()+" "+Ot.toString()+")"),2===r&&webphone_api.common.ShowToast(webphone_api.stringres.get("warning_notreg")))),void(yt=setTimeout(function(){A(e,t,o)},250))}var l="audio";1===o&&(l="video"),2===o&&(l="screenshare"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_Call ("+webphone_api.global.useengine+"), to: "+t+", on line: "+e.toString()+", type: "+l+", engine: "+webphone_api.common.getuseengine()+" / "+webphone_api.common.GetParameter("devicetype")),Dt=!1,Ot=0,0==webphone_api.common.IsSDK()&&(webphone_api.global.intentcall[0]="number="+t,webphone_api.global.intentcall[1]="calltype=outgoing",webphone_api.global.intentcall[2]="name=",webphone_api.global.intentcall[3]="callmode="+o,setTimeout(function(){webphone_api.$.mobile.changePage("#page_call",{transition:"pop",role:"page"})},10));var s=webphone_api.common.GetParameterInt("androidspeaker",-1);-1==s&&(s=webphone_api.global.isvideocall?0:1),!0===webphone_api.global.isfirstcall&&"Android"===webphone_api.common.GetOs()&&1===s&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?(webphone_api.common.PutToDebugLog(2,"EVENT, call handle SwitchOffAndroidSpeaker"),webphone_api.webrtcapi.SwitchOffAndroidSpeaker(function(){webphone_api.common.PutToDebugLog(2,"EVENT, call SwitchOffAndroidSpeaker handled"),k(e,t,o)})):k(e,t,o)}catch(p){webphone_api.common.PutToDebugLogException(2,"plhandler: CallDelayed",p)}}function k(e,n,t){try{if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.global.stacknotstarted_retry=!0,0===t?webphone_api.webrtcapi.SipCall("call-audio",e,n):1===t?(webphone_api.global.isvideocall=!0,webphone_api.webrtcapi.SipCall("call-audiovideo",e,n)):2===t?(webphone_api.isscreensharecall=!0,webphone_api.webrtcapi.SipCall("call-screenshare",e,n)):webphone_api.webrtcapi.SipCall("call-audio",e,n);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.flashapi.Call(n);if(!0===webphone_api.common.IsWindowsSoftphone())return 0===t?void webphone_api.common.WinAPI("API_Call",null,webphone_api.common.GetLineForJavaAPI(e),n):1===t?(webphone_api.global.isvideocall=!0,void webphone_api.common.WinAPI("API_SoftphoneVideoCall",null,n)):2===t?(webphone_api.isscreensharecall=!0,void webphone_api.common.WinAPI("API_SoftphoneScreenshare",null,n)):void webphone_api.common.WinAPI("API_Call",null,webphone_api.common.GetLineForJavaAPI(e),n);if(t>0&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE&&!0===webphone_api.common.CanIUseWebRTC())return webphone_api.common.SwitchToEngine(webphone_api.global.ENGINE_WEBRTC),void setTimeout(function(){A(e,n,t)},3e3);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_Call",null,webphone_api.common.GetLineForJavaAPI(e),n);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.Call(webphone_api.common.GetLineForJavaAPI(e),n)}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: CallDelayedSecond",o)}}function U(){try{Jn("StopScreenShare");var e=webphone_api.global.aline;(webphone_api.common.isNull(e)||-3===e)&&(e=-1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, stopscreenshare (API_StopScreenShare) ("+webphone_api.global.useengine+") on line: "+e.toString());var n=webphone_api.common.GetCallSession(21,!0,e,"");if(webphone_api.common.isNull(n)&&(webphone_api.global.checkIfInCall=!1,webphone_api.global.checkIfCallActive=!1,webphone_api.global.active_incoming_call=!1,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.ClearPendingStartMedia()),webphone_api.global.hadStartMediaPending=!1,setTimeout(function(){webphone_api.common.GetEndpoint(1017,e,"","","",!0)},400),setTimeout(function(){if(webphone_api.common.GetNrOfActiveCalls()>0){Pe(webphone_api.common.GetBestLine(),!1,506),!1!==webphone_api.common.IsSDK()||!0!==webphone_api.global.isCallStarted||webphone_api.common.isNull(webphone_api._call)||webphone_api._call.UpdateLineButtons(16)}},350),-2===e&&!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0){for(var t=0;t<webphone_api.global.ep.length;t++){var o=webphone_api.global.ep[t][webphone_api.common.EP_LINE];webphone_api.common.isNull(o)||!0!==webphone_api.common.IsNumber(o)||W(webphone_api.common.StrToInt(o))}return!0}return W(e)}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: StopScreenShare",i)}return!1}function V(e,n){try{Jn("Hangup");var t=-10;t=!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)?webphone_api.common.StrToInt(e):webphone_api.global.aline,(webphone_api.common.isNull(t)||-3===t)&&(t=-1);var o="USER";!0!==n&&"true"!==n||(o="INTERNAL"),webphone_api.common.PutToDebugLog(2,"EVENT, "+o+", hangup (API_Hangup) ("+webphone_api.global.useengine+") on line: "+t.toString()),webphone_api.common.GetNrOfActiveCalls()<2&&(webphone_api.global.CLOSE_CALL_TIMER=webphone_api.common.GetParameterInt("closecall_timeout",3e3));var i=webphone_api.common.GetCallSession(22,!0,t,"");if(webphone_api.common.isNull(i)&&(webphone_api.common.GetNrOfActiveCalls()<2&&(webphone_api.global.checkIfInCall=!1,webphone_api.global.checkIfCallActive=!1,webphone_api.global.active_incoming_call=!1,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.ClearPendingStartMedia()),webphone_api.global.hadStartMediaPending=!1),setTimeout(function(){webphone_api.common.GetEndpoint(1018,t,"","","",!0)},400),setTimeout(function(){if(webphone_api.global.aline>1||webphone_api.common.GetNrOfActiveCalls()>0){var e=webphone_api.common.GetBestLine();webphone_api.global.aline==t?Pe(e,!1,507):Pe(e,!0,508),!1!==webphone_api.common.IsSDK()||!0!==webphone_api.global.isCallStarted||webphone_api.common.isNull(webphone_api._call)||webphone_api._call.UpdateLineButtons(17)}},350),-2===t&&!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0){if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE||webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())W(-2,-2);else for(var a=0;a<webphone_api.global.ep.length;a++){var r=webphone_api.global.ep[a][webphone_api.common.EP_LINE];webphone_api.common.isNull(r)||!0!==webphone_api.common.IsNumber(r)||(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?function(){var e=350*a+1,n=r;setTimeout(function(){W(webphone_api.common.StrToInt(n))},e)}():W(webphone_api.common.StrToInt(r)))}return!0}return W(t,e)}catch(l){webphone_api.common.PutToDebugLogException(2,"plhandler: Hangup",l)}return!1}function W(e,n){try{Jn("HangupLine"),webphone_api.common.PutToDebugLog(3,"EVENT, hangupline: "+e.toString());try{"undefined"!=typeof AndroidWebphoneJsInterface&&null!==AndroidWebphoneJsInterface&&"undefined"!=typeof AndroidWebphoneJsInterface.jstoandroidEvents&&null!==AndroidWebphoneJsInterface.jstoandroidEvents&&AndroidWebphoneJsInterface.jstoandroidEvents("[HANGUP]_BUTTON")}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: HangupLine inner AndroidWebphoneJsInterface",t)}if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.SipHangup(!1,e);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.flashapi.Hangup();if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_Hangup",null,webphone_api.common.GetLineForJavaAPI(n));if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.Hangup(webphone_api.common.GetLineForJavaAPI(n))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: HangupLine",t)}return!1}function F(e){var n=0;try{n=1,Jn("Accept");var t=-10;if(n=2,t=!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)?webphone_api.common.StrToInt(e):webphone_api.global.aline,(webphone_api.common.isNull(t)||-3===t)&&(t=-2),n=3,webphone_api.common.PutToDebugLog(2,"EVENT, USER, accept (API_Accept) ("+webphone_api.global.useengine+") on line: "+t.toString()),webphone_api.global.active_incoming_call=!1,!0===webphone_api.common.CanUseIncomingCallNot()&&(n=4,webphone_api.common.RequestBrowserNotificationPermission(function(){},"","","",2)),n=5,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){if(!1===webphone_api.global.webrtcpermissionaccepted){if(webphone_api.webrtcapi.CheckPendingStartMedia()){setTimeout(function(){!1===webphone_api.global.webrtcpermissionaccepted&&(webphone_api.common.CanLog(4)&&webphone_api.common.PutToDebugLog(4,"EVENT, wait for webrtc media permission"),setTimeout(function(){!1===webphone_api.global.webrtcpermissionaccepted&&1==webphone_api.global.checkIfCallActive&&webphone_api.common.PutToDebugLog(1,"STATUS,"+webphone_api.global.aline.toString()+",Waiting for permission")},350),setTimeout(function(){!1===webphone_api.global.webrtcpermissionaccepted&&1==webphone_api.global.checkIfCallActive&&(webphone_api.common.PutToDebugLog(2,"ERROR, call accepted, but permission not yet accepted (a2)"),webphone_api.common.AlertDialog(webphone_api.stringres.get("request_permission2_title"),webphone_api.common.ReplaceAll(webphone_api.stringres.get("request_permission2"),"[BRANDNAME]",webphone_api.common.GetBrandName())))},3500))},200),n=7;return!!webphone_api.common.GetCallSession(4,!1,t,"","",null,"2")||(n=8,PutToDebugLog(2,"ERROR,webrtcapi session is NULL x"),webphone_api.common.LogLines(),PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_nocallinprogress2")),!1)}return webphone_api.webrtcapi.SipAccept(t)}return webphone_api.webrtcapi.SipAccept(t)}if(n=10,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return n=11,webphone_api.flashapi.Accept();if(n=12,webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return n=13,webphone_api.common.WinAPI("API_Accept",null,webphone_api.common.GetLineForJavaAPI(e)),!0;if(n=14,webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return n=15,webphone_api.webphone.Accept(webphone_api.common.GetLineForJavaAPI(e))}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: Accept ("+n.toString()+")",o)}return!1}function M(e,n){try{Jn("Reject"),webphone_api.common.isNull(n)&&(n="");var t=-10;if(t=!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)?webphone_api.common.StrToInt(e):webphone_api.global.aline,(webphone_api.common.isNull(t)||-3===t)&&(t=-2),webphone_api.common.PutToDebugLog(2,"EVENT, USER, reject (API_Reject) ("+webphone_api.global.useengine+") on line: "+t.toString()+", because: "+n.toString()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.SipHangup(!0,t);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.flashapi.Hangup();if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_Reject",null,webphone_api.common.GetLineForJavaAPI(e));if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.Reject(webphone_api.common.GetLineForJavaAPI(e))}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: Reject",o)}return!1}function H(){try{Jn("Ignore");var e=webphone_api.global.aline;(webphone_api.common.isNull(e)||-3===e)&&(e=-2),webphone_api.common.PutToDebugLog(2,"EVENT, USER, ignore (API_Ignore) ("+webphone_api.global.useengine+") on line: "+e.toString());try{!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||"page_call"!==webphone_api.$.mobile.activePage.attr("id")||webphone_api._call.CloseCall()}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: Ignore inner",n)}if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.SipIgnore();if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_Ignore",null,webphone_api.common.GetLineForJavaAPI());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.Ignore(webphone_api.common.GetLineForJavaAPI())}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: Ignore",t)}return!1}function B(e,n,t){var o=0;try{!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)&&(o=webphone_api.common.StrToInt(e));var i=0,a=0;!webphone_api.common.isNull(n)&&webphone_api.common.IsNumber(n)&&(i=webphone_api.common.StrToInt(n)),!webphone_api.common.isNull(t)&&webphone_api.common.IsNumber(t)&&(a=webphone_api.common.StrToInt(t)),i>0&&(1===o?(webphone_api.common.PutToDebugLog(5,"EVENT, USER SetVideoSize remote width: "+n+"; height: "+t),webphone_api.$("#div_video_remote").width(i),a>0&&webphone_api.$("#div_video_remote").height(a)):2===o&&(webphone_api.common.PutToDebugLog(5,"EVENT, USER SetVideoSize local width: "+n+"; height: "+t),webphone_api.$("#div_video_remote").width(i),a>0&&webphone_api.$(".previewvideo").height(a)))}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: SetVideoSize",r)}}function j(){try{Jn("GetAvailableCallfunc");var e="conference,transfer,mute,hold,chat";return webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?e="transfer,chat":webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH&&(e="transfer,chat"),e}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: GetAvailableCallfunc",n)}return""}function $(e){try{if(Jn("Forward"),!1===webphone_api.common.Glt())return;var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, forward (API_Forward), "+e+" on line: "+n.toString()),webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_msg_4")),!1;if(e=webphone_api.common.Trim(e),!0===webphone_api.common.GetParameterBool("isfirstcallfwd",!0)&&(webphone_api.common.SaveParameter("isfirstcallfwd","false"),(!0===webphone_api.global.usestorage||webphone_api.common.Strl(60))&&webphone_api.common.ShowToast("Call forward will work only if the remote peer has support for it.",6e3)),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.Forward(e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_Forward",null,webphone_api.common.GetLineForJavaAPI(),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.Forward(webphone_api.common.GetLineForJavaAPI(),e)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: Forward",t)}return!1}function q(){webphone_api.common.isNull(xt)||clearInterval(xt),xt=null,At=0}function z(e,n){try{if(Jn("Conference"),!1===webphone_api.common.Glcf())return!1;if(webphone_api.common.isNull(e)&&(e=""),e.length>0&&(webphone_api.global.lastcontarget=e),!webphone_api.global.checkIfInCall&&e.length>0)return x(e);var t=webphone_api.common.GetParameterInt("conferencetype",1);if(0===t)return webphone_api.common.PutToDebugLog(1,"ERROR, conference is disabled"),!1;if(webphone_api.common.PutToDebugLog(2,"EVENT, USER, conference (API_Conf) ("+webphone_api.global.useengine+"), "+e),webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_msg_4")),!1;if(webphone_api.common.isNull(n)&&(n=!0,webphone_api.common.PutToDebugLog(2,"EVENT, plhandler Conference add is NULL, used as true")),e=webphone_api.common.Trim(e),!0===webphone_api.global.active_incoming_call&&(webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Accept Conf"),webphone_api.accept()),!0===n&&webphone_api.common.GetParameterInt("multilinegui",0)<1){if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.global.isconfcall=!0,webphone_api.common.WinAPI("API_Conf",null,e),!1;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.global.isconfcall=!0,webphone_api.webphone.Conference(e)}else{if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.global.isconfcall=!0,webphone_api.common.WinAPI("API_ConfEx",null,webphone_api.common.GetLineForJavaAPI(),e,n);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.global.isconfcall=!0,webphone_api.webphone.ConferenceEx(webphone_api.common.GetLineForJavaAPI(),e,n)}var o=webphone_api.common.GetSipHeaderInternal("X-UT",!0);if(webphone_api.common.isNull(o)&&(o=""),o=webphone_api.common.Trim(o),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(webphone_api.common.isNull(e)||e.length<1)&&(e=webphone_api.common.CanAcceptEmptyNumber()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&e.length>0){var i=!1,a=!1;if(2!=t&&4!=t&&("g"===o||"s"===o||"b"===o||webphone_api.common.IsMizuServerOrGateway())){for(var r=!0,l=0;l<e.length;l++)if(!(e.charAt(l)>="0"&&e.charAt(l)<="9"||e.charAt(l)>="A"&&e.charAt(l)<="D"||"*"==e.charAt(l)||"#"==e.charAt(l))){r=!1;break}if(n&&(1===t||t>=5)){a=!0,!r||"g"!==o&&"b"!==o||(webphone_api.global.confcanfailover=!0);var s=webphone_api.common.CreateConferenceRoom(!1,e);webphone_api.common.isNull(s)||s.length<3?webphone_api.common.PutToDebugLog(2,"WARNING, plhandler Conference webrtc invalid URL: "+s):(webphone_api.common.UriParser(s,"","","","","getconferenceroom"),webphone_api.common.PutToDebugLog(1,"EVENT,conference created"),webphone_api.common.isNull(webphone_api.global.waiting_conf_numbers)&&(webphone_api.global.waiting_conf_numbers=""),webphone_api.global.waiting_conf_numbers.length>0&&(webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+","),webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+e,i=!0)}if(!i&&t<5&&("g"===o||"s"===o||"b"===o)&&r&&(!0===n?!1===webphone_api.global.checkIfInCall||(webphone_api.common.PutToDebugLog(2,"EVENT, Add to DTMF conference: "+e),webphone_api.dtmf("*1*"+e+"#")):webphone_api.dtmf("*6*"+e+"#"),i=!0),!i&&!a&&n){!r||"g"!==o&&"b"!==o||(webphone_api.global.confcanfailover=!0);var s=webphone_api.common.CreateConferenceRoom(!1,e);webphone_api.common.isNull(s)||s.length<3?webphone_api.common.PutToDebugLog(2,"WARNING, plhandler Conference webrtc invalid URL: "+s):(webphone_api.common.UriParser(s,"","","","","getconferenceroom"),webphone_api.common.PutToDebugLog(1,"EVENT,conference created"),webphone_api.common.isNull(webphone_api.global.waiting_conf_numbers)&&(webphone_api.global.waiting_conf_numbers=""),webphone_api.global.waiting_conf_numbers.length>0&&(webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+","),webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+e,i=!0)}}if(!i&&n&&e.length>0&&!0===webphone_api.common.CanIUseApplet()&&(r&&(webphone_api.global.confcanfailover=!1),webphone_api.common.SwitchToEngine(webphone_api.global.ENGINE_JAVA),i=!0),!i&&n&&!0===webphone_api.common.CanIUseService()&&(r&&(webphone_api.global.confcanfailover=!1),webphone_api.common.IsServiceInstalled(function(n){try{i=!0,!0===n?(webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup because Conference engine switch to NS(1)"),V(null,!0),!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api.common.PutToDebugLog(4,"EVENT, Close call page because Conference engine switch to NS(1)"),webphone_api._call.CloseCall()),webphone_api.common.SwitchToEngine(webphone_api.global.ENGINE_SERVICE),webphone_api.common.PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("switch_conf")),webphone_api.common.ShowToast(webphone_api.stringres.get("switch_conf")),setTimeout(function(){if(!webphone_api.common.isNull(xt))return q(),!0;var n=!1,t=0;xt=setInterval(function(){return++At>50?(q(),!0):(t<1&&!1===n&&!0===webphone_api.isregistered()&&(t=webphone_api.common.GetTickCount()),t>0&&webphone_api.common.GetTickCount()-t>1e3&&!1===n&&(n=!0,webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Call Conf switch: "+webphone_api.global.currcallnumber),webphone_api.call(webphone_api.global.currcallnumber)),!0===webphone_api.global.checkIfInCall?(webphone_api.global.isconfcall=!0,
webphone_api.common.WinAPI("API_Conf",null,e),q(),!0):void 0)},500)},4e3)):(webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup because Conference engine switch to NS(2)"),V(null,!0),!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api.common.PutToDebugLog(4,"EVENT, Close call page because Conference engine switch to NS(2)"),webphone_api._call.CloseCall()),setTimeout(function(){webphone_api.common.AlertDialog(webphone_api.stringres.get("switch_conf_title"),webphone_api.stringres.get("switch_confmessage"),function(e){if(!0===e){var n=webphone_api.common.GetNPLocation();!webphone_api.common.isNull(n)&&n.length>0&&window.open(n),setTimeout(function(){return webphone_api.common.SwitchToEngine(webphone_api.global.ENGINE_SERVICE),!0},1e3)}},webphone_api.stringres.get("btn_ok"))},500))}catch(t){i=!1,webphone_api.common.PutToDebugLogException(2,"plhandler: Conference InnerService",t)}},!0)),!i&&!a&&n&&("g"===o||"s"===o||"b"===o||webphone_api.common.IsMizuServerOrGateway())){r&&(webphone_api.global.confcanfailover=!1);var s=webphone_api.common.CreateConferenceRoom(!1,e);webphone_api.common.isNull(s)||s.length<3?webphone_api.common.PutToDebugLog(2,"WARNING, plhandler Conference webrtc invalid URL: "+s):(webphone_api.common.UriParser(s,"","","","","getconferenceroom"),webphone_api.common.PutToDebugLog(1,"EVENT,conference created"),webphone_api.common.isNull(webphone_api.global.waiting_conf_numbers)&&(webphone_api.global.waiting_conf_numbers=""),webphone_api.global.waiting_conf_numbers.length>0&&(webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+","),webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+e,i=!0)}return i||(r&&(webphone_api.global.confcanfailover=!1),n?e.length>0?webphone_api.common.PutToDebugLog(1,"ERROR, Conference not available in this environment"):webphone_api.common.PutToDebugLog(1,"ERROR, No target number for conference"):webphone_api.common.PutToDebugLog(1,"EVENT, conference stop skipped")),i}}catch(p){webphone_api.common.PutToDebugLogException(2,"plhandler: Conference",p)}return!1}function K(e){var n=0;try{if(n=1,Jn("Transfer"),!1===webphone_api.common.Glt())return!1;var t=webphone_api.global.aline;webphone_api.global.attendedtransfer_origline>0&&(t=webphone_api.global.attendedtransfer_origline),(webphone_api.common.isNull(t)||-3===t)&&(t=2),n=2,e=webphone_api.common.isNull(e)?"":webphone_api.common.Trim(e),webphone_api.common.PutToDebugLog(2,"EVENT, USER, transfer (API_Transfer) to "+e+" on line: "+t.toString()+" ("+webphone_api.global.aline.toString()+"/"+webphone_api.global.attendedtransfer_origline.toString()+")"),webphone_api.global.attendedtransfer_origline=-1,webphone_api.common.CanLog(5)&&webphone_api.common.LogLines();var o=webphone_api.common.getuseengine();if(n=3,e.length<1&&(o===webphone_api.global.ENGINE_WEBRTC||o===webphone_api.global.ENGINE_FLASH)){n=4;var i=t;i<1&&(i=webphone_api.common.GetBestLine());var a=webphone_api.common.GetEndpoint(2219,i,"","","",!1),r=-1;if(!webphone_api.common.isNull(a)&&i>0){n=5;for(var l,s=webphone_api.global.ep.length-1;s>=0;s--)if(l=webphone_api.global.ep[s],!(webphone_api.common.isNull(l)||l.length<5)&&a!==l&&a[webphone_api.common.EP_LINE]!=l[webphone_api.common.EP_LINE]&&!(webphone_api.common.isNull(l[webphone_api.common.EP_DESTNR])||l[webphone_api.common.EP_DESTNR].length<1)&&l[webphone_api.common.EP_DESTNR]!=a[webphone_api.common.EP_DESTNR]&&webphone_api.common.EpIsInCallEx(l)){e=l[webphone_api.common.EP_DESTNR],r=s;break}}if(n=6,webphone_api.common.isNull(e)||e.length<1)return webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_msg_4")),!1;webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, transfer target guessed as "+e+" on ep "+webphone_api.common.EpToString(r))}if(n=7,o===webphone_api.global.ENGINE_WEBRTC||o===webphone_api.global.ENGINE_FLASH){n=71;var i=t;i<1&&(i=webphone_api.common.GetBestLine());var a=webphone_api.common.GetEndpoint(2219,i,"","","",!1);if(a&&a[webphone_api.common.EP_DESTNR]==e){n=72;for(var l,s=webphone_api.global.ep.length-1;s>=0;s--)if(l=webphone_api.global.ep[s],!(webphone_api.common.isNull(l)||l.length<5)&&l[webphone_api.common.EP_DESTNR]!=e&&webphone_api.common.EpIsInCallEx(l)){var p=webphone_api.common.StrToIntDef(l[webphone_api.common.EP_LINE],0);if(!(p<1)){webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, transfer change source (current line) from "+t.toString()+" to "+p.toString()+"/"+l[webphone_api.common.EP_DESTNR]),t=p,webphone_api.global.aline=p;break}}}}if(webphone_api.global.last_transfer_tick=webphone_api.common.GetTickCount(),o===webphone_api.global.ENGINE_WEBRTC)return n=8,webphone_api.webrtcapi.SipTransferEx(e,t);if(o===webphone_api.global.ENGINE_FLASH)return n=9,webphone_api.flashapi.Transfer(e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||o===webphone_api.global.ENGINE_SERVICE)return n=10,webphone_api.common.WinAPI("API_Transfer",null,webphone_api.common.GetLineForJavaAPI(),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return n=11,webphone_api.webphone.Transfer(webphone_api.common.GetLineForJavaAPI(),e)}catch(c){webphone_api.common.PutToDebugLogException(2,"plhandler: Transfer ("+n.toString()+")",c)}return!1}function X(e){try{Jn("Dtmf");var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, dtmf (API_Dtmf), "+e+" on line: "+n.toString()),webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_msg_4")),!1;if(e=webphone_api.common.Trim(e),webphone_api.common.PlayDtmfSound(e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.common.PutToDebugLog(1,"EVENT,Send DTMF "+e),webphone_api.webrtcapi.SipSendDTMF(e);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(1,"EVENT,Send DTMF "+e),webphone_api.flashapi.SendDTMF(e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_Dtmf",null,webphone_api.common.GetLineForJavaAPI(),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.Dtmf(n,e)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: Dtmf",t)}return!1}function J(e,n,t){try{Jn("MuteEx");var o=[];o.push("h"),o.push("a"),o.push("s"),o.push("m"),o.push("u"),o.push("t"),o.push("e");var i=o.join("");if(!1===webphone_api.common.GetParameterBool(i,!0)){var a="N";return a+="o",a+=" ",webphone_api.common.PutToDebugLog(2,"WARNING, "+a+i),!1}var r=webphone_api.global.aline;(webphone_api.common.isNull(r)||-3===r)&&(r=-1);var l=webphone_api.common.ParamAsBool(e),s=webphone_api.common.GetParameterInt("muteholdalllines",0);!0===webphone_api.global.isconfcall&&s>1&&(r=-2,webphone_api.common.SetALineInternal(-2,10),webphone_api.global.lastalineset=-2,webphone_api.global.lastalinesettick=webphone_api.common.GetTickCount()),webphone_api.common.isNull(t)&&(t=!1);var p="USER";if(!0!==t&&"true"!==t||(p="INTERNAL"),(webphone_api.common.isNull(n)||n.length<1)&&(n=webphone_api.common.GetParameterInt("defmute",2)),n=webphone_api.common.StrToIntDef(n,0),-1==n&&(n=0),5===n)return webphone_api.common.PutToDebugLog(2,"WARNING, "+p+", mute (API_MutEx), "+l+", "+n+" on line: "+r.toString()+" Mute is disabled!"),!1;if(3!==n&&4!==n||(n=0),l?webphone_api.common.PutToDebugLog(1,"STATUS,"+r.toString()+","+webphone_api.stringres.get("muted")):webphone_api.common.PutToDebugLog(1,"STATUS,"+r.toString()+","+webphone_api.stringres.get("unmuted")),webphone_api.common.PutToDebugLog(2,"EVENT, "+p+", API_MutEx, "+l+", "+n+" on line: "+r.toString()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return!!webphone_api.webrtcapi.SipToggleMute(l,n)&&(webphone_api.common.SetMuteState(r,l),!0);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_MuteEx",null,webphone_api.common.GetLineForJavaAPI(),l,n),webphone_api.common.SetMuteState(r,l),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return!!webphone_api.webphone.MuteEx(webphone_api.common.GetLineForJavaAPI(),l,n)&&(webphone_api.common.SetMuteState(r,l),!0)}catch(c){webphone_api.common.PutToDebugLogException(2,"plhandler: MuteEx",c)}return!1}function Y(){try{Jn("IsMuted");var e=webphone_api.global.aline;return(webphone_api.common.isNull(e)||-3===e)&&(e=-1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, ismuted (API_IsMuted) on line: "+e.toString()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA?webphone_api.webphone.IsMuted(e):webphone_api.common.GetMuteState(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: IsMuted",n)}return!1}function Q(e,n,t){try{Jn("Hold");var o=[];o.push("h"),o.push("a"),o.push("s"),o.push("h"),o.push("o"),o.push("l"),o.push("d");var i=o.join("");if(!1===webphone_api.common.GetParameterBool(i,!0)){var a="N";return a+="o",a+=" ",webphone_api.common.PutToDebugLog(2,"WARNING, "+a+i),webphone_api.global.wasmuteinsteadhold=3,!1}var r=-10;r=!webphone_api.common.isNull(n)&&webphone_api.common.IsNumber(n)?webphone_api.common.StrToInt(n):webphone_api.global.aline,(webphone_api.common.isNull(r)||-3===r)&&(r=-1);var l=webphone_api.common.ParamAsBool(e);webphone_api.common.isNull(t)&&(t=!1),webphone_api.common.PutToDebugLog(5,"EVENT, toggle hold api. hold: "+l.toString()+", line: "+r.toString()+", from: "+t.toString());var s=webphone_api.common.GetParameterInt("muteholdalllines",0);!0===webphone_api.global.isconfcall&&s>1&&(r=-2,webphone_api.common.SetALineInternal(-2,11),webphone_api.global.lastalineset=-2,webphone_api.global.lastalinesettick=webphone_api.common.GetTickCount());var p=webphone_api.common.ParamAsInt(webphone_api.common.GetParameter2("fasthold"),-1);if(1===p)return webphone_api.global.wasmuteinsteadhold=2,webphone_api.global.wasmultilineoop=1,webphone_api.common.PutToDebugLog(2,"EVENT, fasthold: "+l),J(l,0,!0);if(-1===p&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&"Firefox"===webphone_api.common.GetBrowser())return webphone_api.common.PutToDebugLog(2,"EVENT, fasthold firefox: "+l),webphone_api.global.wasmuteinsteadhold=2,webphone_api.global.wasmultilineoop=1,J(l,0,!0);var c=webphone_api.common.GetHoldState(r),u="USER";if(!0!==t&&"true"!==t||(u="INTERNAL"),webphone_api.common.PutToDebugLog(2,"EVENT, "+u+", hold (API_Hold), "+l+" on line: "+r.toString()+" holdstate: "+c.toString()),!webphone_api.common.CheckStrictLine(r))return!1;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){if(l===c&&webphone_api.common.GetParameterInt("ignoreprevholdstate",0)<1)return webphone_api.global.wasmultilineoop>0&&!l&&webphone_api.common.GetMuteState(r)?(webphone_api.global.wasmuteinsteadhold=2,webphone_api.common.PutToDebugLog(2,"EVENT, unmute instead of unhold on multilineoop"),J(!1,0,!0)):(webphone_api.global.wasmuteinsteadhold=3,!0===l?webphone_api.common.PutToDebugLog(2,"WARNING, hold (API_Hold), skip putting call on hold, because it is already on hold"):webphone_api.common.PutToDebugLog(2,"WARNING, hold (API_Hold), skip reloading call , because it is not on hold"),!1);var g=webphone_api.common.GetParameterInt("holdtype",-1);if(-2===g||0===g)return webphone_api.global.wasmuteinsteadhold=3,webphone_api.common.PutToDebugLog(2,"EVENT, API_Hold ignored because holdtype is: "+g.toString()),!1;var h=webphone_api.common.GetParameterInt("multilineoop",2);l&&(-1==h||webphone_api.common.GetNrOfActiveCalls()>1&&(h<2||h<3&&"Firefox"===webphone_api.common.GetBrowser()))&&(webphone_api.global.usemutemutiline=!0);var m=!1;if((-1==h||webphone_api.common.GetNrOfActiveCalls()>1&&h<1)&&(m=!0),!l&&m&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){var d=webphone_api.common.GetCallSession(51,!1,r,"");!webphone_api.common.isNull(d)&&d.getHolded()>0&&(m=!1)}if(m){webphone_api.common.PutToDebugLog(2,"EVENT, API_Hold mute instead because multiline call ("+webphone_api.common.GetNrOfActiveCalls()+")"),webphone_api.global.wasmuteinsteadhold=2,webphone_api.global.wasmultilineoop=1;return J(l,webphone_api.common.GetParameterInt("defmute",0),!0)}return webphone_api.global.wasmuteinsteadhold=1,Z(l,r,30)?(webphone_api.common.SetHoldState(r,l),!0):(webphone_api.global.wasmuteinsteadhold=4,!1)}if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.global.wasmuteinsteadhold=1,webphone_api.common.WinAPI("API_Hold",null,webphone_api.common.GetLineForJavaAPI(),l),webphone_api.common.SetHoldState(r,l),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.global.wasmuteinsteadhold=1,webphone_api.webphone.Hold(webphone_api.common.GetLineForJavaAPI(),l)?(webphone_api.common.SetHoldState(r,l),!0):(webphone_api.global.wasmuteinsteadhold=4,!1)}catch(b){webphone_api.common.PutToDebugLogException(2,"plhandler: Hold",b)}return webphone_api.global.wasmuteinsteadhold<1&&(webphone_api.global.wasmuteinsteadhold=4),!1}function Z(e,n,t){function o(){webphone_api.common.isNull(Ut)||(clearInterval(Ut),Ut=null)}var i=!1;try{webphone_api.common.isNull(e)&&(e=!0),webphone_api.common.isNull(n)&&(n=-1),webphone_api.common.isNull(t)&&(t=50),webphone_api.common.PutToDebugLog(5,"EVENT, toggle hold delayed. hold: "+e.toString()+", line: "+n.toString()+", from: "+t.toString());var a=webphone_api.common.GetTickCount();if(kt>0&&a-kt<1e3||!webphone_api.common.isNull(Wt)&&Wt.length>0){webphone_api.common.isNull(Vt)&&(Vt=[]),webphone_api.common.isNull(Wt)&&(Wt=[]),Wt.length>15&&(Vt=[],Wt=[],webphone_api.common.PutToDebugLog(5,"WARNING, too many hold operation queued"));for(var r=Wt.length-1;r>=0;r--)if(Wt[r]==n&&Vt[r]==e)return webphone_api.common.PutToDebugLog(5,"EVENT, hold operation already queued: "+n.toString()+"; state: "+e.toString()),!0;Vt.push(e),Wt.push(n),o(),Ut=setInterval(function(){if(webphone_api.common.isNull(Vt)&&(Vt=[]),webphone_api.common.isNull(Wt)&&(Wt=[]),Vt.length<1)o();else if(webphone_api.common.GetTickCount()-kt>950){kt=webphone_api.common.GetTickCount();var e=Vt.shift(),n=Wt.shift();webphone_api.common.PutToDebugLog(2,"EVENT, execute API_Hold delayed on line: "+n.toString()+"; state: "+e.toString()),webphone_api.webrtcapi.SipToggleHoldResume(e,n,t),Vt.length<1&&o()}},100),i=!0}else webphone_api.common.isNull(Ut)||(clearInterval(Ut),Ut=null),i=webphone_api.webrtcapi.SipToggleHoldResume(e,n,t);kt=a}catch(l){webphone_api.common.PutToDebugLogException(2,"plhandler: HoldDelayedWebrtc",l)}return i}function ee(){try{Jn("IsOnHold");var e=webphone_api.global.aline;(webphone_api.common.isNull(e)||-3===e)&&(e=-1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, isonhold (API_IsOnHold) on line: "+e.toString());return webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA?webphone_api.webphone.IsOnHold(e):webphone_api.common.GetHoldState(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: IsOnHold",n)}return!1}function ne(e,n,t,o){try{if(Jn("SendChat"),!webphone_api.common.isNull(e)&&e.indexOf(",")>0){webphone_api.common.isNull(t)&&(t="");var i=e.split(","),a=t.split("|");if(webphone_api.common.isNull(t)||t.length<1||webphone_api.common.isNull(a)||a.length<i.length){t="";for(var r=0;r<i.length;r++)webphone_api.common.isNull(i[r])||webphone_api.common.Trim(i[r]).length<1||(t.length>0&&(t+="|"),t+=webphone_api.common.Trim(i[r]))}for(var r=0;r<i.length;r++)webphone_api.common.isNull(i[r])||webphone_api.common.Trim(i[r]).length<1||te(i[r],n,t,o)}else te(e,n,o)}catch(l){webphone_api.common.PutToDebugLogException(2,"SendChatProcesser: IsOnHold",l)}}function te(e,t,o,i){try{Jn("SendChatAction");var a=webphone_api.global.aline;if((webphone_api.common.isNull(a)||-3===a)&&(a=1),webphone_api.global.phonestarted<2)return void Yn("SendChatAction",[e,t,o,i]);if(webphone_api.common.PutToDebugLog(2,"EVENT, USER, sendchat (API_Chat), "+e+", "+t),webphone_api.common.isNull(e)||webphone_api.common.Trim(e).length<1)return webphone_api.common.PutToDebugLog(1,"ERROR, "+webphone_api.stringres.get("err_msg_6")),!1;webphone_api.common.isNull(o)&&(o=""),o=webphone_api.common.Trim(o),webphone_api.common.isNull(Ft)||clearTimeout(Ft),Ft=null,webphone_api.global.phonestarted<1&&(webphone_api.global.phonestarted=1,n(webphone_api.parameters));if(webphone_api.common.NeedRegister()&&webphone_api.global.phonestarted<3||webphone_api.global.phonestarted<2)return void(Ft=setTimeout(function(){ne(e,t,i)},250));if(!webphone_api.common.LcAc(!1,!1))return!1;if(webphone_api.common.Te()){var r=[];r.push("T"),r.push("r"),r.push("i"),r.push("a"),r.push("l"),r.push(" "),r.push("e"),r.push("x"),r.push("p"),r.push("i"),r.push("r"),r.push("e"),r.push("d");var l=r.join("");return setTimeout(function(){webphone_api.common.PutToDebugLog(1,"ERROR, "+l)},1150),setTimeout(function(){webphone_api.common.PutToDebugLog(1,"ERROR, "+l)},2150),!1}webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_Chat, "+e);var s=!1;if(0===webphone_api.common.Trim(t).indexOf("[DONT_START_CHAT_WINDOW]")&&(t=t.replace("[DONT_START_CHAT_WINDOW]",""),s=!0),webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutchat,"outChat","",e,e,t),!1!==webphone_api.common.IsSDK()||webphone_api.global.isMessageStarted||!1!==s||(webphone_api.global.intentmsg[0]="action=chat",webphone_api.global.intentmsg[1]="to="+e,webphone_api.global.intentmsg[2]="message="+t,webphone_api.$.mobile.changePage("#page_message",{transition:"slide",role:"page"})),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.SipSendChat(a,e,t,i);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_SendChat",null,webphone_api.common.GetLineForJavaAPI(),e,o,t);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(1,"EVENT, Chat not supported by flash engine"),!1;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.SendChat(webphone_api.common.GetLineForJavaAPI(),e,o,t)}catch(p){webphone_api.common.PutToDebugLogException(2,"plhandler: SendChat",p)}return!1}function oe(e,n,t){try{if(Jn("SendSms"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, sendsms (API_Sms), "+e+", "+n+", "+t),webphone_api.common.isNull(e)||webphone_api.common.Trim(e).length<1)return webphone_api.common.PutToDebugLog(1,"ERROR, Sms "+webphone_api.stringres.get("err_msg_6")),!1;if(webphone_api.global.phonestarted<2)return void Yn("SendSms",[e,n,t]);var o=webphone_api.common.GetParameter2("sms");(webphone_api.common.isNull(o)||o.length<2)&&(o=webphone_api.common.GetConfig("sms")),!webphone_api.common.isNull(o)&&o.length>2?((webphone_api.common.isNull(t)||t.length<1)&&(t=webphone_api.common.GetSipusername(!0)),webphone_api.common.UriParser(o,"",t,e,n,"sendsms")):ne(e,n,"",!0)}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: SendSms",i)}return!1}function ie(e,n){try{if(Jn("Voicerecord"),!1===webphone_api.common.Glcr())return;if(webphone_api.global.phonestarted<2)return void Yn("Voicerecord",[e,n]);if(webphone_api.common.isNull(n)&&(n=""),!1===e&&(n="null"),!0===e&&(n.length<1||"null"===n||"NULL"===n))return void webphone_api.common.PutToDebugLog(2,"WARNING, voicerecord (API_Voicerecord) skipped start with no url, "+e+", "+n);webphone_api.common.PutToDebugLog(2,"EVENT, voicerecord (API_Voicerecord), "+e+", "+n);var t=!1;if((!1===e||webphone_api.common.isNull(n)||n.length<1||"null"===n||"NULL"===n)&&(n="null",t=!0),webphone_api.common.SaveParameter("voicerecupload",n),webphone_api.common.isNull(webphone_api.parameters.voicerecupload)||(webphone_api.parameters.voicerecupload=n),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.common.IsMizuServerOrGateway()||webphone_api.common.PutToDebugLog(3,"WARNING, voicerecord (API_Voicerecord), unknown WebRTC server. Voice recording should be implemented on your server instead. See the How to activate voice recording FAQ point in the documentation"),void webphone_api.common.CallWsuserKeepAlive(!0);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void(!1===t?webphone_api.common.WinAPI("API_VoiceRecord",null,4,2,n,webphone_api.common.GetLineForJavaAPI()):webphone_api.common.WinAPI("API_VoiceRecord",null,0,2,n,webphone_api.common.GetLineForJavaAPI()));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return void(!1===t?webphone_api.webphone.VoiceRecord(4,2,n,webphone_api.common.GetLineForJavaAPI()):webphone_api.webphone.VoiceRecord(0,2,n,webphone_api.common.GetLineForJavaAPI()))}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: Voicerecord",o)}}function ae(){try{if("undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications)return webphone_api.notifications.GetStatus();console&&console.log&&console.log("ERROR, plhandler GetStatus webphone_api.notifications is not defined")}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: GetStatus",e)}return""}function re(e,n){try{if(Jn("GetRegFailReason"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetRegFailReason callback is not definaed");var t=!0;if((webphone_api.common.isNull(n)||"true"!=n&&"false"!=n||"false"==n||0==n)&&(t=!1),webphone_api.global.phonestarted<2)return void Yn("GetRegFailReason",[e,n]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void e(webphone_api.webrtcapi.GetRegFailReason());if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, GetRegFailReason is not supported by flash engine"),void e("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetRegFailReason",function(n){e(n)},t);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.GetRegFailReason(e,t)}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: GetRegFailReason",o)}return""}function le(){try{if(Jn("DevicePopup"),webphone_api.common.isNull(Mt)||clearTimeout(Mt),Mt=null,webphone_api.global.phonestarted<1&&(webphone_api.global.phonestarted=1,n(webphone_api.parameters)),webphone_api.global.phonestarted<2)return void(Mt=setTimeout(function(){le()},250));if(webphone_api.common.PutToDebugLog(2,"EVENT, USER, devicepopup (API_DevicePopup)"),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.AudioDevice();webphone_api.common.AudioDevicePopup()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: DevicePopup",e)}return!1}function se(e,n){try{if(Jn("SetVolume"),webphone_api.common.isNull(e)||e.length<1||webphone_api.common.isNull(n)||n.length<1||!webphone_api.common.IsNumber(e)||!webphone_api.common.IsNumber(n))return webphone_api.common.PutToDebugLog(3,"ERROR, wphone: setvolume device or volume is NULL"),!1;if(webphone_api.global.phonestarted<2)return void Yn("SetVolume",[e,n]);webphone_api.common.PutToDebugLog(2,"EVENT, plhandler setvolume engine: "+webphone_api.common.getuseengine()+" / "+webphone_api.common.GetParameter("devicetype")+"; dev: "+e+"; volume: "+n);var t=webphone_api.common.StrToInt(e),o=webphone_api.common.StrToInt(n);if(t<0||t>2)return webphone_api.common.PutToDebugLog(3,"ERROR, wphone: setvolume invalid device"),!1;if(o<0||o>100)return webphone_api.common.PutToDebugLog(3,"ERROR, wphone: setvolume invalid valume value"),!1;if(webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_SetVolume, "+e+", "+n),0==e?webphone_api.common.SaveParameter("volumein",n):webphone_api.common.SaveParameter("volumeout",n),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void webphone_api.common.PutToDebugLog(2,"EVENT, setvolume is not supported by flash engine");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void webphone_api.webrtcapi.SetVolume(e,n);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_SetVolume",null,e,n);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.SetVolume(e,n)}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: SetVolume",i)}return!1}function pe(e,n){try{if(Jn("GetVolume"),!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetVolume callback is not defined");if(webphone_api.common.isNull(e)||e.length<1||!webphone_api.common.IsNumber(e))return webphone_api.common.PutToDebugLog(3,"ERROR, wphone: getvolume device is NULL"),n(-1),!1;var t=webphone_api.common.StrToInt(e);if(t<0||t>2)return webphone_api.common.PutToDebugLog(3,"ERROR, wphone: getvolume invalid device"),!1;if(webphone_api.global.phonestarted<2)return void Yn("GetVolume",[e,n]);if(webphone_api.common.PutToDebugLog(2,"EVENT, USER, getvolume (API_GetVolume), "+e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void webphone_api.common.PutToDebugLog(2,"EVENT, getvolume is not supported by flash engine");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void n(webphone_api.webrtcapi.GetVolume(e));if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetVolume",function(e){var t=50;webphone_api.common.isNull(e)||e.length<1||!1===webphone_api.common.IsNumber(e)?webphone_api.common.PutToDebugLog(2,"ERROR, plhandler GetVolume invalid return value: "+e):t=webphone_api.common.StrToInt(e),webphone_api.common.PutToDebugLog(2,"plhandler: GetVolume NS returned: "+t.toString()),n(t)},e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void n(webphone_api.webphone.GetVolume(e))}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: GetVolume",o)}return!1}function ce(e){try{if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void(!0===e||"true"===e?webphone_api.common.SaveParameter("androidspeaker","0"):webphone_api.common.SaveParameter("androidspeaker","1"));webphone_api.common.PutToDebugLog(2,"WARNING, setloudspeaker not iplemented for this engine: "+webphone_api.common.getuseengine())}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: SetLoudspeaker",n)}return!1}function ue(e,n,t,o){try{if(Jn("PlaySound"),webphone_api.global.phonestarted<2)return void Yn("PlaySound",[e,n,t,o]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.PlaySound(e,n,t,o);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_PlaySound",null,e,n,t,!1,!1,o,webphone_api.common.GetLineForJavaAPI()),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.PlaySound(e,n,t,!1,!1,o,webphone_api.common.GetLineForJavaAPI());webphone_api.common.PutToDebugLog(2,"ERROR, plhandler API_PlaySuond is not supported by "+webphone_api.common.getuseengine()+" engine")}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: PlaySound",i)}return!1}function ge(e,n,t,o,i,a,r,l){try{if(Jn("AddContact"),webphone_api.common.isNull(n)||webphone_api.common.Trim(n).length<1)return webphone_api.common.PutToDebugLog(3,"ERROR, plhandler AddContact invalid number: "+n),!1;n=webphone_api.common.Trim(n),webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e);var s=webphone_api.common.GetParameterInt("normalize_contact",1);s>0&&n.indexOf("|")<0&&(n=webphone_api.common.NormalizeInput2(n,3)),s>0&&(e=webphone_api.common.NormalizeInput2(e,2)),webphone_api.common.isNull(t)&&(t=""),s>0&&(t=webphone_api.common.NormalizeInput2(t,3),t=webphone_api.common.Trim(t)),webphone_api.common.isNull(o)&&(o=""),s>0&&(o=webphone_api.common.NormalizeInput2(o,3),o=webphone_api.common.Trim(o)),webphone_api.common.isNull(i)&&(i=""),s>0&&(i=webphone_api.common.NormalizeInput2(i,3),i=webphone_api.common.Trim(i)),webphone_api.common.isNull(a)&&(a=""),s>0&&(a=webphone_api.common.NormalizeInput2(a,2),a=webphone_api.common.Trim(a));return webphone_api.common.PutToDebugLog(2,"EVENT, AddContact name: "+e+"; number: "+n+"; email: "+t+"; address: "+o+"; notes: "+i+"; website: "+a+"; isfromsync: 0"),he(e,n,l,r,webphone_api.common.GetTickCount(),t,o,i,a,"0"),!0}catch(p){webphone_api.common.PutToDebugLogException(2,"plhandler: AddContact",p)}return!1}function he(e,n,t,o,i,a,r,l,s,p){try{if(webphone_api.common.isNull(webphone_api.global.ctlist)&&(webphone_api.global.ctlist=[]),n=n.indexOf("|")>=0?n.split("|"):[n],o=webphone_api.common.isNull(o)||o.length<1?webphone_api.common.IsNumber(n)?["phone"]:["sip"]:o.indexOf("|")>=0?o.split("|"):[o],o.length==n.length);else if(o.length>n.length)o.splice(n.length);else for(var c=o.length;c<n.length;c++)o.push("other");if(webphone_api.common.isNull(t))t="0";else if("0"==t)t="0";else if("1"==t)t="1";else{var u=webphone_api.common.StrToIntDef(t);t=0==u?"0":1==u?"1":"0"}var g=[];g[webphone_api.common.CT_NAME]=e,g[webphone_api.common.CT_NUMBER]=n,g[webphone_api.common.CT_PTYPE]=o,g[webphone_api.common.CT_USAGE]="0",g[webphone_api.common.CT_LASTMODIF]=i,g[webphone_api.common.CT_DELFLAG]="0",g[webphone_api.common.CT_FAV]=t,g[webphone_api.common.CT_EMAIL]=a,g[webphone_api.common.CT_ADDRESS]=r,g[webphone_api.common.CT_NOTES]=l,g[webphone_api.common.CT_WEBSITE]=s,g[webphone_api.common.CT_LASTACTIVE]=webphone_api.common.GetTickCount().toString(),g[webphone_api.common.CT_ISFROMSYNC]=p;for(var c=0;c<webphone_api.global.ctlist.length;c++){if(webphone_api.global.ctlist[c][webphone_api.common.CT_NUMBER].toString()===n.toString()){webphone_api.global.ctlist.splice(c,1);break}}webphone_api.global.ctlist.push(g),webphone_api.global.wasCtModified=!0,webphone_api.common.SortContacts()}catch(h){webphone_api.common.PutToDebugLogException(2,"plhandler: SaveTheContact",h)}}function me(e,n){try{return Jn("DeleteContact"),(webphone_api.common.isNull(e)&&(e=""),e=e.toString(),webphone_api.common.isNull(n)&&(n=""),n=n.toString(),e.length<0&&n.length<0)?(webphone_api.common.PutToDebugLog(2,"ERROR, plhandler DeleteContact invalid name and number"),!1):(webphone_api.common.isNull(webphone_api.global.ctlist)&&(webphone_api.global.ctlist=[]),be(e,n),!0)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: DeleteContact",t)}return!1}function de(){try{return Jn("DeleteAllContacts"),webphone_api.global.ctlist=[],!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: DeleteAllContacts",e)}return!1}function be(e,n){try{
if(webphone_api.common.isNull(webphone_api.global.ctlist)||webphone_api.global.ctlist.length<1)return void webphone_api.common.PutToDebugLog(2,"WARNING, plhandler RemoveTheContact no contacts in list");if(e.length>0&&n.length>0)for(var t=0;t<webphone_api.global.ctlist.length;t++){var o=webphone_api.global.ctlist[t];if(o[webphone_api.common.CT_NAME]===e||o[webphone_api.common.CT_NAME]===n){webphone_api.global.ctlist.splice(t,1),webphone_api.global.wasCtModified=!0;break}for(var i=0;i<o[webphone_api.common.CT_NUMBER].length;i++)if(o[webphone_api.common.CT_NUMBER][i]===e||o[webphone_api.common.CT_NUMBER][i]===n){webphone_api.global.ctlist.splice(t,1),webphone_api.global.wasCtModified=!0;break}}else if(e.length>0)for(var t=0;t<webphone_api.global.ctlist.length;t++){var o=webphone_api.global.ctlist[t];if(o[webphone_api.common.CT_NAME]===e){webphone_api.global.ctlist.splice(t,1),webphone_api.global.wasCtModified=!0;break}for(var i=0;i<o[webphone_api.common.CT_NUMBER].length;i++)if(o[webphone_api.common.CT_NUMBER][i]===e){webphone_api.global.ctlist.splice(t,1),webphone_api.global.wasCtModified=!0;break}}else if(n.length>0)for(var t=0;t<webphone_api.global.ctlist.length;t++){var o=webphone_api.global.ctlist[t];if(o[webphone_api.common.CT_NAME]===n){webphone_api.global.ctlist.splice(t,1),webphone_api.global.wasCtModified=!0;break}for(var i=0;i<o[webphone_api.common.CT_NUMBER].length;i++)if(o[webphone_api.common.CT_NUMBER][i]===n){webphone_api.global.ctlist.splice(t,1),webphone_api.global.wasCtModified=!0;break}}}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: RemoveTheContact",a)}}function _e(e,n){try{return Jn("GetContact"),(webphone_api.common.isNull(e)&&(e=""),e=e.toString(),webphone_api.common.isNull(n)&&(n=""),n=n.toString(),e.length<0&&n.length<0)?(webphone_api.common.PutToDebugLog(2,"ERROR, plhandler GetContact invalid name and number"),null):(webphone_api.common.PutToDebugLog(4,"EVENT, plhandler getcontact with name: "+e+" and number: "+n),webphone_api.common.isNull(webphone_api.global.ctlist)&&(webphone_api.global.ctlist=[]),function(e,n){try{var t="";if(e.length>0)for(var o=0;o<webphone_api.global.ctlist.length;o++){var i=webphone_api.global.ctlist[o];i[webphone_api.common.CT_NAME]===e&&(t=i[webphone_api.common.CT_NAME]+"\t"+i[webphone_api.common.CT_NUMBER].join("|")+"\t"+i[webphone_api.common.CT_FAV]+"\t"+i[webphone_api.common.CT_EMAIL]+"\t"+i[webphone_api.common.CT_ADDRESS]+"\t"+i[webphone_api.common.CT_NOTES]+"\t"+i[webphone_api.common.CT_WEBSITE]+"\t"+i[webphone_api.common.CT_PTYPE].join("|"))}else if(n.length>0)for(var o=0;o<webphone_api.global.ctlist.length;o++){var i=webphone_api.global.ctlist[o];i[webphone_api.common.CT_NAME]===n&&(t=i[webphone_api.common.CT_NAME]+"\t"+i[webphone_api.common.CT_NUMBER].join("|")+"\t"+i[webphone_api.common.CT_FAV]+"\t"+i[webphone_api.common.CT_EMAIL]+"\t"+i[webphone_api.common.CT_ADDRESS]+"\t"+i[webphone_api.common.CT_NOTES]+"\t"+i[webphone_api.common.CT_WEBSITE]+"\t"+i[webphone_api.common.CT_PTYPE].join("|"));for(var a=0;a<i[webphone_api.common.CT_NUMBER].length;a++)i[webphone_api.common.CT_NUMBER][a]===n&&(t=i[webphone_api.common.CT_NAME]+"\t"+i[webphone_api.common.CT_NUMBER].join("|")+"\t"+i[webphone_api.common.CT_FAV]+"\t"+i[webphone_api.common.CT_EMAIL]+"\t"+i[webphone_api.common.CT_ADDRESS]+"\t"+i[webphone_api.common.CT_NOTES]+"\t"+i[webphone_api.common.CT_WEBSITE]+"\t"+i[webphone_api.common.CT_PTYPE].join("|"))}if(!webphone_api.common.isNull(t))return t}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: FindContactInList",r)}return null}(e,n))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetContact",t)}return null}function fe(e){try{return Jn("ListContacts"),webphone_api.common.isNull(webphone_api.global.ctlist)&&(webphone_api.global.ctlist=[]),webphone_api.common.PutToDebugLog(4,"EVENT, plhandler listcontacts called"),function(e){try{for(var n="",t=0;t<webphone_api.global.ctlist.length;t++){var o=webphone_api.global.ctlist[t];if(1==e||"Echo delayed"!==o[webphone_api.common.CT_NAME]&&"Echo"!==o[webphone_api.common.CT_NAME]&&"Funny"!==o[webphone_api.common.CT_NAME]&&"Music"!==o[webphone_api.common.CT_NAME]&&"Playback"!==o[webphone_api.common.CT_NAME]&&"Record"!==o[webphone_api.common.CT_NAME]&&"Redial"!==o[webphone_api.common.CT_NAME]&&"Voicemail"!==o[webphone_api.common.CT_NAME]){!webphone_api.common.isNull(n)&&n.length>0&&(n+="\r\n");for(var i="",a=0;a<o[webphone_api.common.CT_NUMBER].length;a++)webphone_api.common.isNull(o[webphone_api.common.CT_NUMBER][a])||o[webphone_api.common.CT_NUMBER][a].length<1||(i.length>0&&(i+="|"),i+=o[webphone_api.common.CT_NUMBER][a]);for(var r="",a=0;a<o[webphone_api.common.CT_PTYPE].length;a++)webphone_api.common.isNull(o[webphone_api.common.CT_PTYPE][a])||o[webphone_api.common.CT_PTYPE][a].length<1||(r.length>0&&(r+="|"),r+=o[webphone_api.common.CT_PTYPE][a]);n+=o[webphone_api.common.CT_NAME]+"\t"+i+"\t"+o[webphone_api.common.CT_FAV]+"\t"+o[webphone_api.common.CT_EMAIL]+"\t"+o[webphone_api.common.CT_ADDRESS]+"\t"+o[webphone_api.common.CT_NOTES]+"\t"+o[webphone_api.common.CT_WEBSITE]+"\t"+r}}if(!webphone_api.common.isNull(n)&&n.length>0)return n}catch(l){webphone_api.common.PutToDebugLogException(2,"plhandler: BuildCtList",l)}return null}(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: ListContacts",n)}return null}function we(){try{Jn("ListCallhistory"),webphone_api.common.isNull(webphone_api.global.chlist)&&(webphone_api.global.chlist=[]),webphone_api.common.PutToDebugLog(4,"EVENT, plhandler listcallhistory called");for(var e="",n=0;n<webphone_api.global.chlist.length;n++){var t=webphone_api.global.chlist[n];!webphone_api.common.isNull(e)&&e.length>0&&(e+="\r\n");e+=t[webphone_api.common.CH_TYPE]+"\t"+t[webphone_api.common.CH_NAME]+"\t"+t[webphone_api.common.CH_NUMBER]+"\t"+t[webphone_api.common.CH_DATE]+"\t"+t[webphone_api.common.CH_DURATION]+"\t"+t[webphone_api.common.CH_REASON]}if(!webphone_api.common.isNull(e)&&e.length>0)return e}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: ListCallhistory",o)}return null}function ve(e,n){try{var t=n;if("password"!==e&&"sippassword"!==e||webphone_api.common.CanLog(5)||(t="*****"),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLogSpecial(2,"EVENT, SetParameter user, "+e+": "+t,!1,""),Jn("SetParameter: "+e+": "+t),webphone_api.common.isNull(e)||e.length<1)return!1;if(e=e.toLowerCase(),webphone_api.common.isNull(n)&&(n="null"),n=webphone_api.common.Trim(n),0===n.indexOf("encrypted__")&&(n=webphone_api.common.StrDc(n)),e.indexOf("server")>=0){if("YOURSIPDOMAIN.COM"===n||"YOURSIPSERVER.COM"===n||"SIPSERVER"===n||"VOIPSERVER"===n||"SERVERADDRESS"===n||"yoursipdomain.com"===n||"SERVER_ADDRESS"===n||"serveraddress"===n||"YOURSIPDOMAIN"===n)return!1}else if(e.indexOf("username")>=0){if("USERNAME"===n||"SIPUSERNAME"===n)return!1}else if(e.indexOf("password")>=0){if("PASSWORD"===n||"SIPPASSWORD"===n||"SIPASSWORD"===n)return!1}else if(e.indexOf("callto")>=0&&("DESTINATION"===n||"CALLTO"===n))return!1;"webrtcserver"!==e&&"webrtcaddress"!==e&&"rtcserver"!==e&&"rtcaddress"!==e||(e="webrtcserveraddress");try{window.location.href.indexOf("isdemopage=true")>0&&!webphone_api.common.isNull(n)&&n.toString().length>0&&("sipusername"===e||"username"===e||"password"===e||"sippassword"===e||"serveraddress_user"===e||"serveraddress_orig"===e||"serveraddress"===e||"upperserver"===e||"callto"===e||"destination"===e)&&webphone_api.SetCookie("wpdemosett_"+e,n,365)}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: SetParameter inner",a)}t=n,"password"!==e&&"sippassword"!==e||webphone_api.common.CanLog(5)||(t="*****"),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLogSpecial(2,"EVENT, SetParameter "+e+": "+t,!1,""),"serveraddress"===e&&n.length>0?webphone_api.common.SaveParameter("serveraddress_user",n):"theme"===e&&n.length>0?webphone_api.common.SaveParameter("colortheme",n):"colortheme"===e&&n.length>0&&webphone_api.common.SaveParameter("theme",n),webphone_api.common.SaveParameter(e,n),webphone_api.common.isNull(webphone_api.parameters)||webphone_api.common.isNull(webphone_api.parameters[e])||(webphone_api.parameters[e]=n),"loglevel"==e&&(webphone_api.global.loglevel=webphone_api.common.StrToIntDef(n,webphone_api.global.loglevel));var o=webphone_api.common.GetParameter("devicetype");if(o===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_SetParameter",null,e,n);if(o===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.SetParameter(e,n)}catch(r){var i=e;i=webphone_api.common.isNull(i)?"":": "+i,webphone_api.common.PutToDebugLogException(2,"plhandler: SetParameter"+i,r)}return!1}function Ee(e){try{if(webphone_api.common.isNull(e)||e.length<1)return null;e=e.toLowerCase();var n=webphone_api.common.GetParameter(e);try{if(window.location.href.indexOf("isdemopage=true")>0&&("sipusername"===e||"username"===e||"password"===e||"sippassword"===e||"serveraddress_user"===e||"serveraddress_orig"===e||"serveraddress"===e||"upperserver"===e||"callto"===e||"destination"===e)){var t=webphone_api.GetCookie("wpdemosett_"+e);if(!webphone_api.common.isNull(t)&&t.length>0&&(webphone_api.common.isNull(n)||n.length<1))return t}}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: GetParameter inner",o)}return n}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: GetParameter",i)}return null}function Pe(e,n,t){try{if(Jn("SetLine"),webphone_api.common.isNull(e)||e.toString().length<1)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: SetLine invalid line (A)");webphone_api.common.PutToDebugLog(2,"EVENT, USER, setline (API_SetLine), "+e.toString());var o=!1,i=-10;if(webphone_api.common.IsNumber(e)&&e.toString().length<3){var a=webphone_api.common.StrToInt(webphone_api.common.Trim(e));a<-2||a>99||(i=a)}if(e=e.toString(),i<-5){o=!0;for(var r=0;r<webphone_api.global.ep.length;r++)if(!webphone_api.common.isNull(webphone_api.global.ep[r])){var l=webphone_api.global.ep[r][webphone_api.common.EP_DESTNR];!webphone_api.common.isNull(l)&&l.length>1&&e===l&&(i=webphone_api.common.StrToInt(webphone_api.global.ep[r][webphone_api.common.EP_LINE]))}}if(i<-5)for(var r=0;r<webphone_api.global.ep.length;r++)if(!webphone_api.common.isNull(webphone_api.global.ep[r])){var s=webphone_api.global.ep[r][webphone_api.common.EP_CALLID];!webphone_api.common.isNull(l)&&l.length>1&&e===s&&(i=webphone_api.common.StrToInt(webphone_api.global.ep[r][webphone_api.common.EP_LINE]))}if(0===webphone_api.common.IsMultiline())return void setTimeout(function(){var e=[];e.push("E"),e.push("R"),e.push("R"),e.push("O"),e.push("R"),e.push(","),e.push("M"),e.push("u"),e.push("l"),e.push("t"),e.push("i"),e.push("l"),e.push("i"),e.push("n"),e.push("e"),e.push(" "),e.push("f"),e.push("e"),e.push("a"),e.push("t"),e.push("u"),e.push("r"),e.push("e"),e.push(" "),e.push("i"),e.push("s"),e.push("d"),e.push("i"),e.push("s"),e.push("a"),e.push("b"),e.push("l"),e.push("e"),e.push("d");var n=e.join("");webphone_api.common.PutToDebugLog(1,n)},550);if(a>=-2&&a<=99){var p=i;-1===i&&(i=webphone_api.common.GetBestLine()),webphone_api.global.lastalineset=p,webphone_api.global.lastalinesettick=webphone_api.common.GetTickCount(),(webphone_api.common.isNull(n)||!0!==n)&&(webphone_api.global.lastalinesetreal=p,webphone_api.global.lastalinesetrealtick=webphone_api.common.GetTickCount())}if(webphone_api.common.isNull(t)&&(t=14),webphone_api.common.SetALineInternal(i,t),!1===Ht&&webphone_api.common.IsNumber(e)&&e>0&&(webphone_api.common.SaveParameter("multilinegui","1"),Ht=!0),webphone_api.common.RefreshInfo(8),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void webphone_api.common.PutToDebugLog(2,"WARNING, SetLine method not available for engine: "+webphone_api.common.GetEngineDisplayName(webphone_api.global.useengine));if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return!0===o?webphone_api.common.WinAPI("API_SetLine",null,e):webphone_api.common.WinAPI("API_SetLine",null,i),void webphone_api.common.SaveParameter("line",i.toString());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return!0===o?webphone_api.webphone.SetLineEx(e):webphone_api.webphone.SetLine(i),void webphone_api.common.SaveParameter("line",i.toString())}catch(c){webphone_api.common.PutToDebugLogException(2,"plhandler: SetLine",c)}return null}function Te(){var e=webphone_api.global.aline;try{if(Jn("GetLine"),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.common.PutToDebugLog(2,"EVENT, USER, getline (API_getLine) a "+e),e;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"WARNING, GetLine method not available for engine: "+webphone_api.common.GetEngineDisplayName(webphone_api.global.useengine)),webphone_api.common.PutToDebugLog(2,"EVENT, USER, getline (API_getLine) b "+e),e;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.PutToDebugLog(2,"EVENT, USER, getline (API_getLine) c "+e),e;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.common.SetALineInternal(webphone_api.webphone.GetLine(),15,!1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, getline (API_getLine) d "+webphone_api.global.aline),webphone_api.global.aline;webphone_api.common.PutToDebugLog(2,"EVENT, USER, getline (API_getLine) e "+e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLine",n)}return e}function Se(e,n){try{if(Jn("LineToCallID"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, linetocallid (API_LineToCallID)"),webphone_api.common.isNull(e)||!webphone_api.common.IsNumber(e))return void n("ERROR, linetocallid: Invalid line");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void n(webphone_api.webrtcapi.LineToCallID(e));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void webphone_api.common.PutToDebugLog(2,"WARNING, LineToCallID method not available for engine: "+webphone_api.common.GetEngineDisplayName(webphone_api.global.useengine));if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_LineToCallID",function(e){n(e)},e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void n(webphone_api.webphone.LineToCallID(e))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: LineToCallID",t)}}function Ne(e,n){try{if(Jn("CallIDToLine"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, callidtoline (API_CallIDToLine)"),webphone_api.common.isNull(e)||e.length<1)return void n("ERROR, CallIDToLine: Invalid callid");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void n(webphone_api.webrtcapi.CallIDToLine(e));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"WARNING, CallIDToLine method not available for engine: "+webphone_api.common.GetEngineDisplayName(webphone_api.global.useengine)),"";if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_CallIDToLine",function(e){n(e)},e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void n(webphone_api.webphone.CallIDToLine(e))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: CallIDToLine",t)}}function Ie(e){for(var n=1;n<arguments.length;n++){var t=new RegExp("\\{"+(n-1)+"\\}","gi");e=e.replace(t,arguments[n])}return e}function Ce(){var e="0123456789abcdef";return Ie("{0}-{1}-{2}-{3}-{4}",tsk_string_random_from_dict(8,e),tsk_string_random_from_dict(4,e),tsk_string_random_from_dict(4,e),tsk_string_random_from_dict(4,e),tsk_string_random_from_dict(12,e))}function Ge(e){try{if(Jn("NextCallID"),(webphone_api.common.isNull(e)||e.length<1)&&(e=Ce()),webphone_api.common.PutToDebugLog(2,"EVENT, USER, nextcallid (API_NextCallID) "+e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.global.nextcallid=e,e;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"WARNING, NextCallID method not available for engine: "+webphone_api.common.GetEngineDisplayName(webphone_api.global.useengine)),"";if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_NextCallID",null,e),e;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.NextCallID(e),e}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: NextCallID",n)}return""}function Le(e){try{var n=-5;if(!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)&&(n=webphone_api.common.StrToInt(e)),n<1&&(n=webphone_api.common.GetBestLine()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){var t=webphone_api.webphone.GetLineDetails(n);if(!webphone_api.common.isNull(t)&&t.length>0){var o=t.split(",");if(!webphone_api.common.isNull(o)&&o.length>0){t="";for(var i=0;i<o.length;i++)webphone_api.common.isNull(o[i])&&(o[i]=""),o[i]=webphone_api.common.Trim(o[i]),0===o[i].indexOf("_BASE64_")&&(o[i]=webphone_api.common.B64Dec(o[i]),webphone_api.common.isNull(o[i])&&(o[i]=""),o[i]=webphone_api.common.Trim(o[i])),t.length>0&&(t+=","),t+=o[i]}}return t}var a=n.toString(),r="Unused line",l="",s="",p="",c="-1",u=webphone_api.common.GetParameter("serveraddress_user"),g="",h="false",m="false",d="",b=webphone_api.common.GetTickCount(),_=webphone_api.global.lnstat[n];if(!webphone_api.common.isNull(_)&&_.length>1){var f=webphone_api.common.GetConfigInt("registerinterval",0);f<1&&(f=90),f*=6e4,!webphone_api.common.isNull(_[0])&&webphone_api.common.IsNumber(_[0])&&b-_[0]<=f&&!webphone_api.common.isNull(_[1]&&_[1].length)&&(r=_[1])}var w=webphone_api.common.GetEndpoint(1019,n,"","","",!1);!webphone_api.common.isNull(w)&&w.length>2&&(l=w[webphone_api.common.EP_CALLID],s=w[webphone_api.common.EP_DESTNR],p=webphone_api.common.GetSipusername(!0),c=w[webphone_api.common.EP_INCOMING],u=webphone_api.common.GetParameter("serveraddress_user"),g="",h=w[webphone_api.common.EP_MUTESTATE],m=w[webphone_api.common.EP_HOLDSTATE],d="");var v="LINEDETAILS,"+a+","+r+","+l+","+s+","+p+","+c+","+u+","+g+","+h+","+m+","+d;return webphone_api.common.PutToDebugLog(4,"EVENT, GetLineDetails user: "+v),v}catch(E){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLineDetails",E)}return""}function Re(){try{Jn("GetLastCallDetails");var e=webphone_api.global.lastcalldetails;if(webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e),webphone_api.global.phonestarted<2)return void Yn("GetLastCallDetails",[]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return e;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return e;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return e;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.GetLastCallDetails()}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLastCallDetails",n)}return""}function ye(e){try{if(Jn("GetIcomingDisplay"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetIncomingDisplay callback is not definaed");if(webphone_api.global.phonestarted<2)return void Yn("GetIncomingDisplay",[e]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void e(webphone_api.common.GetWebrtcDisplayName());if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void e("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetIncomingDisplay",function(n){webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n),0===n.indexOf("_BASE64_")&&(n=webphone_api.common.B64Dec(n),webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n)),e(n)},webphone_api.common.GetLineForJavaAPI());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE()){var n=webphone_api.webphone.GetIncomingDisplay();return webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n),0===n.indexOf("_BASE64_")&&(n=webphone_api.common.B64Dec(n),webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n)),void e(n)}}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetIncomingDisplay",t)}return""}function De(){try{webphone_api.global.printwad_called=!1,webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_Unregister"),webphone_api.global.authenticated_displayed=!1,webphone_api.global.sipstackstarted=!1,webphone_api.global.dispSaveSettMsg=0,webphone_api.global.unregisteredfromidle=0,webphone_api.global.pres_unreg_called=!0,webphone_api.global.last_presence_enabled=webphone_api.common.UsePresence2(),webphone_api.global.onregisteredcalled=!1;var e=webphone_api.global.dispregfailed;if(webphone_api.global.dispregfailed=2,setTimeout(function(){webphone_api.global.dispregfailed=e},500),!1===webphone_api.global.onunregistered_flag){webphone_api.global.onunregistered_flag=!0,setTimeout(function(){webphone_api.global.onunregistered_flag=!1},2e3);try{webphone_api.onRegStateChangeCb("unregistered",null)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: There is an error in onUnRegistered(unregistered) callback",t)}try{webphone_api.onUnRegisteredCb()}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: There is an error in onUnRegistered() callback",t)}}var n=webphone_api.common.getuseengine();if((webphone_api.common.isNull(n)||n.length<1)&&(n=webphone_api.global.last_last_useengine),n===webphone_api.global.ENGINE_WEBRTC)return webphone_api.flagrestartwebrtc=!1,webphone_api.webrtcapi.SipUnRegister(),webphone_api.common.Wsunreg(),webphone_api.global.phonestarted>2&&(webphone_api.global.phonestarted=2),void(webphone_api.global.webrtcsipsignalingreceived=0);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||n===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_Unregister",null),void(webphone_api.global.phonestarted>2&&(webphone_api.global.phonestarted=2));if(n===webphone_api.global.ENGINE_FLASH)return webphone_api.flashapi.Logout(null),void(webphone_api.global.phonestarted>2&&(webphone_api.global.phonestarted=2));if(n===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.Unregister(),void(webphone_api.global.phonestarted>2&&(webphone_api.global.phonestarted=2))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: Unregister",t)}}function Oe(e){try{return webphone_api.global.onregisteredcalled=!1,(webphone_api.global.sipstackstarted=!1,webphone_api.common.isNull(e)&&(e=webphone_api.common.getuseengine()),webphone_api.common.isNull(e)&&(e=webphone_api.common.GetSelectedEngineName()),e===webphone_api.global.ENGINE_WEBRTC)?(!0===webphone_api.global.checkIfInCall&&(webphone_api.common.PutToDebugLog(3,"EVENT, Window.OnUnload close or refresh: hangup active call_1: "+e),webphone_api.webrtcapi.SipHangup(!1,-2)),webphone_api.flagrestartwebrtc=!1,webphone_api.webrtcapi.SipStop(1),webphone_api.common.Wsunreg(),void(webphone_api.global.phonestarted=2)):e===webphone_api.global.ENGINE_FLASH?(!0===webphone_api.global.checkIfInCall&&(webphone_api.common.PutToDebugLog(3,"EVENT, Window.OnUnload close or refresh: hangup active call_2: "+e),webphone_api.flashapi.Hangup()),webphone_api.flashapi.Logout(null),void(webphone_api.global.phonestarted=2)):e===webphone_api.global.ENGINE_JAVA?(!0===webphone_api.global.checkIfInCall&&(webphone_api.common.PutToDebugLog(3,"EVENT, Window.OnUnload close or refresh: hangup active call_3: "+e),webphone_api.webphone.Hangup(-2)),webphone_api.webphone.Unregister(),void(webphone_api.global.phonestarted=2)):(!0===webphone_api.global.checkIfInCall||webphone_api.common.WinAPI("API_Unregister",null),void(webphone_api.global.phonestarted=2))}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: UnregisterEngine",n)}}function xe(){try{if(Jn("HTTPKeepAlive"),webphone_api.common.PutToDebugLog(5,"EVENT, httpkeepalive (API_HTTPKeepAlive)"),webphone_api.global.useengine!==webphone_api.global.ENGINE_JAVA)return;return webphone_api.webphone.HTTPKeepAlive()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: HTTPKeepAlive",e)}}function Ae(){Jn("IsRegistered");try{if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){var e=webphone_api.webphone.IsRegistered();return webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_IsRegistered: wp "+e.toString()),e}if(webphone_api.global.phonestarted>2)return webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_IsRegistered: true"),!0;webphone_api.common.PutToDebugLog(2,"EVENT, USER, isregistered (API_IsRegistered)")}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: IsRegistered",n)}return!1}function ke(){Jn("IsInCall");try{webphone_api.common.PutToDebugLog(4,"EVENT, isincall: "+webphone_api.global.checkIfInCall.toString())}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: IsInCall",e)}return webphone_api.global.checkIfInCall}function Ue(e,n,t){var o=0;try{if(webphone_api.common.isNull(e)||e<-2)return void webphone_api.common.PutToDebugLog(2,"WARNING, plhandler: GetDeviceList dev is null "+e);if(!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetDeviceList callback is not defined");if(!0!==t){Jn("GetDeviceList");for(var i=!1,a=Bt.length-1;a>=0;a--)if(Bt[a]===e&&jt[a]===n){i=!0;break}i||(Bt.push(e),jt.push(n))}if(Bt.length<1&&(Bt.push(e),jt.push(n)),Bt.length<1)return void webphone_api.common.PutToDebugLog(2,"WARNING, plhandler: GetDeviceList no request is waiting a");if(jt.length<1)return void webphone_api.common.PutToDebugLog(2,"WARNING, plhandler: GetDeviceList no request is waiting b");if(!jt[0]||"function"!=typeof jt[0])return void webphone_api.common.PutToDebugLog(2,"WARNING, plhandler: GetDeviceList no request is waiting c");if(webphone_api.common.getuseengine().length<1&&webphone_api.global.phonestarted<2){webphone_api.common.isNull($t)||clearTimeout($t),$t=null;var r=Bt[0],l=jt[0];return void($t=setTimeout(function(){webphone_api.common.isNull(r)&&(r="-41"),Ue(r,l,!0)},300))}if(webphone_api.common.isNull($t)||clearTimeout($t),$t=null,webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetAudioDeviceList",function(e){try{if(o=1,webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e),webphone_api.common.CanLog(7)&&webphone_api.common.PutToDebugLog(7,"PROCESSING_AUDIOLIST ("+e.length.toString()+") : "+e),Bt.length<1)null!=e&&e.length>0&&webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist unexpected answer: "+e);else{o=2;var n=jt.shift();o=3;var t=Bt.shift();if(o=4,0===e.indexOf("_BASE64_")&&(e=webphone_api.common.B64Dec(e),webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e)),e=e.replace("EOFLINE","\r\n"),o=5,0==e.indexOf("ERROR")||0==e.indexOf("APIREQUEST")?webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist invaid answer: "+e+" (for "+t+")"):0==t?(o=6,webphone_api.global.audio_rec_device_list=e,webphone_api.common.SaveParameter("cache_audio_rec_device_list",e),o=7,n(e)):1==t?(o=8,webphone_api.global.audio_play_device_list=e,webphone_api.common.SaveParameter("cache_audio_play_device_list",e),webphone_api.global.audio_ring_device_list.length<1&&!webphone_api.common.isNull(e)&&e.length>0&&(!webphone_api.common.isNull(e)&&e.length>0&&e.indexOf("\r\nAll")<1&&(e+="\r\nAll"),webphone_api.global.audio_ring_device_list=e,webphone_api.common.SaveParameter("cache_audio_ring_device_list",e)),o=9,n(e)):2==t?(o=10,webphone_api.global.audio_play_device_list.length<1&&!webphone_api.common.isNull(e)&&e.length>0&&(webphone_api.global.audio_play_device_list=e,webphone_api.common.SaveParameter("cache_audio_play_device_list",e)),!webphone_api.common.isNull(e)&&e.length>0&&e.indexOf("\r\nAll")<1&&(e+="\r\nAll"),webphone_api.global.audio_ring_device_list=e,webphone_api.common.SaveParameter("cache_audio_ring_device_list",e),o=11,n(e)):3==t?(o=12,webphone_api.global.video_rec_device_list=e,webphone_api.common.SaveParameter("cache_video_rec_device_list",e),n(e)):webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist answer with unknow dev: "+e),o=13,!webphone_api.common.isNull(jt)&&jt.length>0){o=14;var i=Bt[0];o=15;var a=jt[0];o=16,setTimeout(function(){o=17,webphone_api.common.isNull(i)&&(i="-42"),Ue(i,a,!0)},8)}}}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: GetDeviceListInner "+o,r)}},Bt[0]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){var s="",p=Bt.shift(),c=jt.shift();if(s=webphone_api.webphone.GetAudioDeviceList(p),webphone_api.common.isNull(s)&&(s=""),s=webphone_api.common.Trim(s),0===s.indexOf("_BASE64_")&&(s=webphone_api.common.B64Dec(s),webphone_api.common.isNull(s)&&(s=""),s=webphone_api.common.Trim(s)),0==s.indexOf("ERROR")||0==s.indexOf("APIREQUEST")?webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist invaid answer: "+s+" (for "+p+")"):0==p?(webphone_api.global.audio_rec_device_list=s,webphone_api.common.SaveParameter("cache_audio_rec_device_list",s)):1==p?(webphone_api.global.audio_play_device_list=s,webphone_api.common.SaveParameter("cache_audio_play_device_list",s)):2==p?(!webphone_api.common.isNull(s)&&s.length>0&&s.indexOf("\r\nAll")<1&&(s+="\r\nAll"),webphone_api.global.audio_ring_device_list=s,webphone_api.common.SaveParameter("cache_audio_ring_device_list",s)):(webphone_api.global.video_rec_device_list=s,webphone_api.common.SaveParameter("cache_video_rec_device_list",s)),c(s),!webphone_api.common.isNull(jt)&&jt.length>0){var r=Bt[0],l=jt[0];setTimeout(function(){webphone_api.common.isNull(r)&&(r="-43"),Ue(r,l,!0)},8)}return}if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){var s="",p=Bt.shift(),c=jt.shift();if(0==p?(s=webphone_api.webrtcapi.GetAudioDeviceList(p),webphone_api.global.audio_rec_device_list=s,webphone_api.common.SaveParameter("cache_audio_rec_device_list",s)):1==p?(s=webphone_api.webrtcapi.GetAudioDeviceList(p),webphone_api.global.audio_play_device_list=s,webphone_api.common.SaveParameter("cache_audio_play_device_list",s),(webphone_api.common.isNull(webphone_api.global.audio_ring_device_list)||webphone_api.global.audio_ring_device_list.length<1)&&!webphone_api.common.isNull(s)&&s.length>0&&(webphone_api.global.audio_ring_device_list=s,webphone_api.common.SaveParameter("cache_audio_ring_device_list",s))):2==p?(s=webphone_api.webrtcapi.GetAudioDeviceList(p),
webphone_api.global.audio_ring_device_list=s,webphone_api.common.SaveParameter("cache_audio_ring_device_list",s),(webphone_api.common.isNull(webphone_api.global.audio_play_device_list)||webphone_api.global.audio_play_device_list.length<1)&&!webphone_api.common.isNull(s)&&s.length>0&&(webphone_api.global.audio_play_device_list=s,webphone_api.common.SaveParameter("cache_audio_play_device_list",s))):(s=webphone_api.webrtcapi.GetAudioDeviceList(p),webphone_api.global.video_rec_device_list=s,webphone_api.common.SaveParameter("cache_video_rec_device_list",s)),c(s),!webphone_api.common.isNull(jt)&&jt.length>0){var r=Bt[0],l=jt[0];setTimeout(function(){webphone_api.common.isNull(r)&&(r="-44"),Ue(r,l,!0)},8)}return}var c=jt.shift();Bt.shift(),c("ERROR, Cannot get device list because no engine is started at the moment")}catch(u){webphone_api.common.PutToDebugLogException(2,"plhandler: GetDeviceList",u)}}function Ve(e,n,t){var o=0;try{if(o=1,!0!==t||zt.length<1){if(o=2,Jn("GetDevice"),!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(4,"WARNING, plhandler: GetDevice callback is not defined");o=3,qt.push(e),o=3001,zt.push(n)}if(o=4,webphone_api.common.getuseengine().length<1||webphone_api.global.phonestarted<2){o=5,webphone_api.common.isNull(Kt)||clearTimeout(Kt),Kt=null;var i=qt[0];return o=6,void(Kt=setTimeout(function(){o=7,Ve(i,null,!0)},250))}if(o=8,webphone_api.common.isNull(Kt)||clearTimeout(Kt),Kt=null,o=9,webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return o=10,void webphone_api.common.WinAPI("API_GetAudioDevice",function(e){if(o=11,webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e),webphone_api.common.CanLog(7)&&webphone_api.common.PutToDebugLog(7,"PROCESSING_AUDIODEV ("+e.length.toString()+") : "+e),o=12,qt.length<1)o=13,null!=e&&e.length>0&&webphone_api.common.PutToDebugLog(3,"WARNING, audidevice unexpected answer: "+e);else{o=14;var n=qt.shift();0===e.indexOf("_BASE64_")&&(o=15,e=webphone_api.common.B64Dec(e),webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e)),o=16,0==e.indexOf("ERROR")||0==e.indexOf("APIREQUEST")?webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist invaid answer: "+e+" (for "+n+")"):0==n?(webphone_api.global.audio_rec_curr_device=e,webphone_api.common.SaveParameter("cache_audio_rec_curr_device",e)):1==n?(webphone_api.global.audio_play_curr_device=e,webphone_api.common.SaveParameter("cache_audio_play_curr_device",e)):2==n?(webphone_api.global.audio_ring_curr_device=e,webphone_api.common.SaveParameter("cache_audio_ring_curr_device",e)):3==n?(webphone_api.global.video_rec_curr_device=e,webphone_api.common.SaveParameter("cache_video_rec_curr_device",e)):webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist answer with unknow dev: "+e),o=17;var t=zt.shift();if(o=18,webphone_api.common.PutToDebugLog(4,"EVENT, GetDevice (1), res: "+e),t(e),o=19,!webphone_api.common.isNull(zt)&&zt.length>0){o=20;var i=qt[0];o=21,setTimeout(function(){o=22,Ve(i,null,!0)},8)}}},e);if(o=23,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){o=24;var a="",r=qt.shift();o=25,a=webphone_api.webphone.GetAudioDevice(e),o=26,webphone_api.common.isNull(a)&&(a=""),a=webphone_api.common.Trim(a),0===a.indexOf("_BASE64_")&&(o=27,a=webphone_api.common.B64Dec(a),webphone_api.common.isNull(a)&&(a=""),a=webphone_api.common.Trim(a)),o=28,0==a.indexOf("ERROR")||0==a.indexOf("APIREQUEST")?webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist invaid answer: "+a+" (for "+r+")"):0==r?(webphone_api.global.audio_rec_curr_device=a,webphone_api.common.SaveParameter("cache_audio_rec_curr_device",a)):1==r?(webphone_api.global.audio_play_curr_device=a,webphone_api.common.SaveParameter("cache_audio_play_curr_device",a)):2==r?(webphone_api.global.audio_ring_curr_device=a,webphone_api.common.SaveParameter("cache_audio_ring_curr_device",a)):(webphone_api.global.video_rec_curr_device=a,webphone_api.common.SaveParameter("cache_video_rec_curr_device",a)),o=29;var l=zt.shift();if(o=30,webphone_api.common.PutToDebugLog(4,"EVENT, GetDevice (2), dev: "+r+"; res: "+a),l(a),o=31,!webphone_api.common.isNull(zt)&&zt.length>0){o=32;var i=qt[0];setTimeout(function(){o=33,Ve(i,null,!0)},8)}return}if(o=34,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){o=35;var a="",r=qt.shift();o=36,0==r?(o=37,a=webphone_api.webrtcapi.GetAudioDevice(e),webphone_api.global.audio_rec_curr_device=a,webphone_api.common.SaveParameter("cache_audio_rec_curr_device",a)):1==r?(o=38,a=webphone_api.webrtcapi.GetAudioDevice(e),webphone_api.global.audio_play_curr_device=a,webphone_api.common.SaveParameter("cache_audio_play_curr_device",a)):2==r?(a=webphone_api.webrtcapi.GetAudioDevice(e),webphone_api.global.audio_ring_curr_device=a,webphone_api.common.SaveParameter("cache_audio_ring_curr_device",a)):(a=webphone_api.webrtcapi.GetAudioDevice(e),webphone_api.global.video_rec_curr_device=a,webphone_api.common.SaveParameter("cache_video_rec_curr_device",a)),o=40;var l=zt.shift();if(o=41,webphone_api.common.PutToDebugLog(4,"EVENT, GetDevice (3), dev: "+r+"; res: "+a),o=42,l(a),o=43,!webphone_api.common.isNull(zt)&&zt.length>0){o=44;var i=qt[0];o=45,setTimeout(function(){o=46,Ve(i,null,!0)},100)}return}}catch(s){webphone_api.common.PutToDebugLogException(2,"plhandler: GetDevice "+o,s)}}function We(e,n,t,o,i,a){try{if(webphone_api.common.isNull(e)&&(e=0),!0!==a&&(Jn("SetDevice"),Xt.push(e),Jt.push(n),Yt.push(t),Qt.push(o),Zt.push(i)),webphone_api.common.getuseengine().length<1||webphone_api.global.phonestarted<2)return webphone_api.common.isNull(eo)||clearTimeout(eo),eo=null,void(eo=setTimeout(function(){We(null,null,null,null,null,!0)},250));if(webphone_api.common.isNull(eo)||clearTimeout(eo),eo=null,null===n&&!webphone_api.common.isNull(Jt)&&Jt.length>0&&(e=Xt.shift(),n=Jt.shift(),t=Yt.shift(),o=Qt.shift(),i=Zt.shift()),null===n&&null===t)return;if(webphone_api.common.isNull(e)&&(e=0),webphone_api.common.PutToDebugLog(4,"EVENT, setdevice, dev: "+n+"; devicename: "+t+"; immediate: "+o+"; from: "+e.toString()),webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_SetAudioDevice",null,n,t,o),void(!webphone_api.common.isNull(Jt)&&Jt.length>0&&setTimeout(function(){We(e+1e3,null,null,null,null)},100));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.SetAudioDevice(n,t,o),!webphone_api.common.isNull(Jt)&&Jt.length>0&&setTimeout(function(){We(e+2e3,null,null,null,null)},100),!0;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.SetAudioDevice(n,t,i),!webphone_api.common.isNull(Jt)&&Jt.length>0&&setTimeout(function(){We(e+3e3,null,null,null,null)},100),!0}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: SetDevice",r)}}function Fe(e,n){try{if(webphone_api.global.isappenginestarted=!1,webphone_api.global.sipstackstarted=!1,(webphone_api.common.isNull(e)||e.length<1)&&(e=webphone_api.common.getuseengine()),(webphone_api.common.isNull(e)||e.length<1)&&(e=webphone_api.global.last_last_useengine),webphone_api.common.isNull(e)||e.length<1)return void webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: StopEngine engine is not defined");webphone_api.global.webrtc_regstate=0,webphone_api.common.PutToDebugLog(2,"EVENT, USER, stopengine (API_StopEngine)");if(!1===webphone_api.common.GetParameterBool("needunregister",!0)&&!0!==n)return void webphone_api.common.PutToDebugLog(2,"EVENT, API_StopEngine needunregister is FALSE");if(webphone_api.common.Glsp()){if(e===webphone_api.global.ENGINE_SERVICE)return webphone_api.global.apistartstate=0,webphone_api.global.apistarttick=0,webphone_api.global.wnotstartedsession=!1,void(!1===webphone_api.common.NSMacLinEnabled()&&webphone_api.common.WinAPI("API_Exit",null,"1"));if(e===webphone_api.global.ENGINE_JAVA)return webphone_api.global.apistartstate=0,webphone_api.global.apistarttick=0,webphone_api.global.wnotstartedsession=!1,webphone_api.webphone.Exit()}}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: StopEngine",t)}}function Me(e,n){try{webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_Stop (force: "+e+" from: "+n+")"),webphone_api.flagrestartwebrtc=!1,webphone_api.global.laststarttick=0,webphone_api.global.webrtc_regstate=0,webphone_api.global.sipstackstarted=!1,webphone_api.global.unregisteredfromidle=0,webphone_api.global.apistartstate=0,webphone_api.global.apistarttick=0,webphone_api.global.webrtcsipsignalingreceived=0,webphone_api.global.wnotstartedsession=!1,webphone_api.global.isappenginestarted=!1,webphone_api.global.onunload_flag&&(e=!0),Oe(),setTimeout(function(){Fe(webphone_api.common.getuseengine(),e)},900),setTimeout(function(){webphone_api.common.isNull(webphone_api.global.maintimerid)||(clearInterval(webphone_api.global.maintimerid),webphone_api.global.maintimerid=null,webphone_api.common.isNull(webphone_api.global.initcalled)||(webphone_api.global.initcalled=!1)),webphone_api.global.apistartstate=0,webphone_api.global.apistarttick=0,webphone_api.global.webrtcsipsignalingreceived=0,webphone_api.global.wnotstartedsession=!1},1100),setTimeout(function(){try{webphone_api.onAppStateChangeCb("stopped")}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: There is an error in onAppStateChange(stopped) callback",e)}try{webphone_api.onStopCb()}catch(e){webphone_api.common.PutToDebugLogException(2,"There is an error in onStop() callback",e)}},1250),webphone_api.common.isNull(webphone_api.global.serviceStatusPollTimer)||clearInterval(webphone_api.global.serviceStatusPollTimer),webphone_api.common.isNull(webphone_api.global.polltimerid)||clearInterval(webphone_api.global.polltimerid),webphone_api.common.isNull(webphone_api.global.worktimer)||clearTimeout(webphone_api.global.worktimer),webphone_api.global.worktimer=null;if(!1===webphone_api.common.GetParameterBool("needunregister",!0)&&!0!==e)return void webphone_api.common.PutToDebugLog(2,"EVENT, API_Stop needunregister is FALSE");webphone_api.common.Glsp()&&(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?webphone_api.global.phonestarted>2&&(webphone_api.webrtcapi.SipStop(2),webphone_api.common.Wsunreg()):webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE?!1===webphone_api.common.NSMacLinEnabled()&&webphone_api.common.WinAPI("API_Exit",null,"2"):webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.Exit()),webphone_api.global.onunload_flag&&Fe(webphone_api.common.getuseengine(),e)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: Stop",t)}webphone_api.global.phonestarted=0}function He(e){try{if(Jn("SendChatIsComposing"),webphone_api.common.isNull(e)||e.length<1)return void webphone_api.common.PutToDebugLog(2,"ERROR, SendChatIsComposing invalid destination");var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_SendChatIsComposing",null,webphone_api.common.GetLineForJavaAPI(),e);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.SendChatIsComposing(n,e)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: SendChatIsComposing",t)}}function Be(){return webphone_api.common.BrowserWindowIsActive()}function je(){try{return Jn("HelpWindow"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, helpwindow (API_HelpWindow)"),webphone_api.common.HelpWindow()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: HelpWindow",e)}return!1}function $e(){try{return Jn("SettingsPage"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, settingspage (API_SettingsPage)"),webphone_api.common.OpenSettings(!0,9),!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: SettingsPage",e)}return!1}function qe(){try{return Jn("DialPage"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, dialpage (API_DialPage)"),webphone_api.$.mobile.changePage("#page_dialpad",{transition:"pop",role:"page"}),!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: DialPage",e)}return!1}function ze(){try{return Jn("MessageInboxPage"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, messageinboxpage (API_MessageInboxPage)"),webphone_api.$.mobile.changePage("#page_messagelist",{transition:"none",role:"page"}),!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: MessageInboxPage",e)}return!1}function Ke(){try{return Jn("MessagePage"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, messagepage (API_MessagePage)"),webphone_api.global.intentmsg[0]="action=",webphone_api.global.intentmsg[1]="to=",webphone_api.global.intentmsg[2]="message=",webphone_api.$.mobile.changePage("#page_message",{transition:"none",role:"page"}),!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: MessagePage",e)}return!1}function Xe(){try{return Jn("AddContactPage"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, addcontactpage (API_AddContactPage)"),webphone_api.global.intentaddeditct[0]="action=add",webphone_api.$.mobile.changePage("#page_addeditcontact",{transition:"pop",role:"page"}),!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: AddContactPage",e)}return!1}function Je(e){try{webphone_api.webphone.InsertApplet(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: InsertApplet",n)}}function Ye(){try{return webphone_api.common.EnterKeyPress()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: EnterKeyPress",e)}return!1}function Qe(e){ne(e,"FILETRANSFER_DELIVERED:"+e)}function Ze(e,n){try{if(Jn("GetTelSearchName"),!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetTelsearchName callback is not definaed");if(webphone_api.common.isNull(e)||e.length<2)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetTelsearchName invalid number: "+e);webphone_api.common.GetTelsearchName(e,n)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: EnterKeyPress",t)}}function en(e){try{webphone_api.common.bwanswer(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: bwanswer",n)}}function nn(){try{if(webphone_api.global.wasSettModified){var e=webphone_api.common.GetActiveAccSettingsFilename();!webphone_api.common.isNull(e)&&e.length>0&&webphone_api.common.SaveSettingsFile(5,e,function(e){webphone_api.common.CanLog(2)&&(e?webphone_api.common.PutToDebugLog(2,"EVENT, SaveSettingsFile from onappexit Successfull"):webphone_api.common.PutToDebugLog(2,"ERROR, SaveSettingsFile from onappexit Failed"))})}}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: onappexit",n)}}function tn(){Jn("getlogs"),webphone_api.common.PutToDebugLog(2,"EVENT, getlogs called");var e=webphone_api.global.logs;return webphone_api.global.logs="",e}function on(){try{Jn("getlogsex"),webphone_api.common.PutToDebugLog(2,"EVENT, getlogsex called"),webphone_api.common.WinAPI("API_SetLogs",null,webphone_api.global.logs)}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: getlogsex",e)}}function an(e){try{webphone_api.common.isNull(e)&&(e=""),webphone_api.common.PutToDebugLog(2,"APILOGS: "+e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: putlogs",n)}}function rn(){try{Jn("ImportContacts"),webphone_api.common.PutToDebugLog(2,"EVENT, importcontacts called"),webphone_api.common.DownloadContacts()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: ImportContacts",e)}}function ln(e,n){try{Jn("delsettings"),webphone_api.common.isNull(e)&&(e=0),no&&e<1&&webphone_api.common.PutToDebugLog(3,"EVENT, ignore delsettings because it was already executed A"),no=!0,webphone_api.global.phonestarted<2&&e>0&&(webphone_api.common.PutToDebugLog(2,"EVENT, resetsettings set to TRUE"),webphone_api.common.SaveParameter("resetsettings","true")),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE?webphone_api.common.WinAPI("API_DelSettings",null,e):webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.DelSettings(e),!0!==n&&webphone_api.common.delsettings(e),webphone_api.global.loglevel=webphone_api.common.GetLogLevel()}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: delsettings",t)}}function sn(e){try{if(Jn("needratingrequest"),!e||"function"!=typeof e)return!1;if(webphone_api.global.phonestarted<2)return void Yn("needratingrequest",[e]);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_IsEncrypted",function(n){e(webphone_api.common.isNull(n)?"true"===n||!0===n?!0:!1:!1)});webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.NeedRatingRequest(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: needratingrequest",n),e(!1)}}function pn(){try{if(!webphone_api.common.isNull(platform)&&!webphone_api.common.isNull(platform.name)){var e=webphone_api.platform.name.toString();if(e=e.toLowerCase(),e.indexOf("mobile")>=0)return!0}var n=!1;return function(e){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(n=!0)}(navigator.userAgent||navigator.vendor||window.opera),n}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: IsMobileBrowser",t)}return!1}function cn(){try{return webphone_api.common.isNull(webphone_api.global.useengine)?"":webphone_api.global.useengine}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: Getenginename",e)}}function un(e){try{if(Jn("GetLastInvite"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: getlastinvite callback is not defined");if(webphone_api.global.phonestarted<2)return void Yn("GetLastInvite",[e]);var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){n<1&&(n=webphone_api.common.GetBestLine());var t=webphone_api.common.GetEndpoint(1020,n,"","","",!1),o="";return webphone_api.common.isNull(t)||(o=t[webphone_api.common.EP_SIPINVITE]),void e(o)}if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, getlastinvite is not supported by flash engine"),void e("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetLastInvite",function(n){e(n)},webphone_api.common.GetLineForJavaAPI());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void e(webphone_api.webphone.GetGetLastInvite(webphone_api.common.GetLineForJavaAPI(),e))}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLastInvite",i)}}function gn(e){try{if(Jn("GetLastRecInvite"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: getlastrecinvite callback is not defined");if(webphone_api.global.phonestarted<2)return void Yn("GetLastRecInvite",[e]);var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void e(webphone_api.common.GetLastRecInvite());if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, getlastrecinvite is not supported by flash engine"),void e("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetLastRecInvite",function(n){e(n)},webphone_api.common.GetLineForJavaAPI());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void e(webphone_api.webphone.GetGetLastRecInvite(webphone_api.common.GetLineForJavaAPI(),e))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLastRecInvite",t)}}function hn(e){try{if(Jn("GetLastSentInvite"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: getlastsentinvite callback is not defined");if(webphone_api.global.phonestarted<2)return void Yn("GetLastSentInvite",[e]);var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void e(webphone_api.common.GetLastSentInvite());if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, getlastsentinvite is not supported by flash engine"),void e("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetLastSentInvite",function(n){e(n)},webphone_api.common.GetLineForJavaAPI());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void e(webphone_api.webphone.GetLastSentInvite(webphone_api.common.GetLineForJavaAPI(),e))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLastSentInvite",t)}}function mn(){try{if(Jn("API_RecFiles_Upload"),webphone_api.global.phonestarted<2)return void Yn("API_RecFiles_Upload",[]);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_RecFiles_Upload",null),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.API_RecFiles_Upload();webphone_api.common.PutToDebugLog(2,"WARNING, API_RecFiles_Upload not supported by engine: "+webphone_api.common.getuseengine())}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: API_RecFiles_Upload",e)}return!1}function dn(e,n){try{if(Jn("API_RecFiles_UploadEx"),webphone_api.global.phonestarted<2)return void Yn("API_RecFiles_UploadEx",[e,n]);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_RecFiles_UploadEx",null,e,n),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.API_RecFiles_UploadEx(e,n);webphone_api.common.PutToDebugLog(2,"WARNING, API_RecFiles_UploadEx not supported by engine: "+webphone_api.common.getuseengine())}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: API_RecFiles_UploadEx",t)}return!1}function bn(){try{if(Jn("API_RecFiles_Clear"),webphone_api.global.phonestarted<2)return void Yn("API_RecFiles_Clear",[]);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_RecFiles_Clear",null),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.API_RecFiles_Clear();webphone_api.common.PutToDebugLog(2,"WARNING, API_RecFiles_Clear not supported by engine: "+webphone_api.common.getuseengine())}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: API_RecFiles_Clear",e)}return!1}function _n(){try{if(Jn("API_RecFiles_Del"),webphone_api.global.phonestarted<2)return void Yn("API_RecFiles_Del",[]);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_RecFiles_Del",null),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.API_RecFiles_Del();webphone_api.common.PutToDebugLog(2,"WARNING, API_RecFiles_Del not supported by engine: "+webphone_api.common.getuseengine())}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: API_RecFiles_Del",e)}return!1}function fn(e){try{return webphone_api.stringres.get(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: getstringresource",n)}return""}function wn(e,n){try{Jn("Jvoip-"+e);var t=cn();if(webphone_api.common.isNull(t)||t.length<2)return void webphone_api.common.PutToDebugLog(2,"ERROR, Jvoip no engine available at the moment");if(t!==webphone_api.global.ENGINE_JAVA&&t!==webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.PutToDebugLog(2,"ERROR, Jvoip not applicable for engine: "+webphone_api.common.GetEngineDisplayName(t));if(webphone_api.common.isNull(e)||e.length<3)return void webphone_api.common.PutToDebugLog(2,"ERROR, Jvoip invalid api function name: "+e);var o=e.indexOf("(");o>0&&(e=e.substring(0,o)),e=webphone_api.common.Trim(e),webphone_api.common.isNull(n)&&(n=[]);for(var i="",a=0;a<n.length;a++)a>0&&(i+=","),i+=n[a];webphone_api.common.PutToDebugLog(2,"EVENT, USER, jvoip (API_Jvoip): "+e+"; arguments: ["+i+"]"),webphone_api.webphone.Jvoip(e,n)}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: Jvoip",r)}}function vn(){return webphone_api.common.GetOneStunSrv()}function En(e,n){try{Jn("RemoveCodecFromMediaLine");var t=e;if(webphone_api.common.isNull(n)||!1===webphone_api.common.IsNumber(n))return webphone_api.common.PutToDebugLog(2,"ERROR, RemoveCodecFromMediaLine invalid codec: "+n),e;if(webphone_api.common.isNull(t))return webphone_api.common.PutToDebugLog(2,"WARNING, RemoveCodecFromMediaLine invalid m line"),e;if(e.indexOf("m=audio")<0&&e.indexOf("m=video")<0)return webphone_api.common.PutToDebugLog(5,"EVENT, (warn) RemoveCodecFromMediaLine codec line not found: "+webphone_api.common.Trim(t)+" / "+n.toString()),e;var o=t.indexOf("/");if(o<0)return webphone_api.common.PutToDebugLog(2,"ERROR, RemoveCodecFromMediaLine cannot parse m: "+webphone_api.common.Trim(t)),e;var i=t.substring(0,o);if(t=t.substring(o),t.indexOf(" "+n+" ")>=0)t=t.replace(" "+n+" "," ");else{if(!(t.indexOf(" "+n+"\r")>=0))return webphone_api.common.PutToDebugLog(5,"EVENT, (warn) RemoveCodecFromMediaLine codec number not found: "+webphone_api.common.Trim(t)+" / "+n.toString()),e;t=t.replace(" "+n+"\r","\r")}return i+t}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: RemoveCodecFromMediaLine",a)}return e}function Pn(e,n){try{Jn("SetPrefCodec");var t=e;if(webphone_api.common.isNull(n)||!1===webphone_api.common.IsNumber(n))return webphone_api.common.PutToDebugLog(2,"ERROR, SetPrefCodec invalid codec: "+n),e;if(webphone_api.common.isNull(t))return webphone_api.common.PutToDebugLog(2,"ERROR, SetPrefCodec invalid m line"),e;if(e.indexOf("m=audio")<0&&e.indexOf("m=video")<0)return webphone_api.common.PutToDebugLog(5,"EVENT, (warn) SetPrefCodec codec line not found: "+webphone_api.common.Trim(t)+" / "+n.toString()),e;var o=t.indexOf("/");if(o<0)return webphone_api.common.PutToDebugLog(2,"ERROR, SetPrefCodec cannot parse m=audio: "+webphone_api.common.Trim(t)),e;var i=t.substring(0,o);if(t=t.substring(o),(o=t.indexOf(" "))>0)return i+=t.substring(0,o),t=t.substring(o),t.indexOf(" "+n+" ")>=0?(t=t.replace(" "+n+" "," "),t=" "+n+t):t.indexOf(" "+n+"\r")>=0&&(t=t.replace(" "+n+"\r","\r"),t=" "+n+t),i+t}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: RemoveCodecFromMediaLine",a)}return e}function Tn(e){return webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcCodecs start sdp: \r\n"+e),e=Sn(Nn(e)),webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcCodecs end sdp: \r\n"+e),e}function Sn(e){try{var n=e,t=webphone_api.common.GetParameter("codec");if(webphone_api.common.isNull(t)||t.length<1||"-1"===t||","===t)return e;var o=t.split(",");if(webphone_api.common.isNull(o)||o.length<1)return e;var i=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_pcmu")),a=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_pcma")),r=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_speexwb")),l=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_opuswb"));l||(l=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_opus"))),l||(l=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_opusswb"))),l||(l=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_opusuwb")));for(var s=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_isac")),p=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_g722")),c=0;c<o.length;c++)if(!webphone_api.common.isNull(o[c])){var u=o[c].toLowerCase().trim();"1"===u?i=!0:"2"===u?a=!0:"5"===u||"6"===u?r=!0:"10"===u||"11"===u||"12"===u||"13"===u?l=!0:"14"===u?p=!0:"15"===u?s=!0:"pcmu"===u||"ulaw"===u?i=!0:"pcma"===u||"alaw"===u?a=!0:"g.711"===u||"g711"===u?(i=!0,a=!0):"speex"===u||"speexwb"===u||"speex-wb"===u||"speexswb"===u||"speex-swb"===u||"speexuwb"===u||"speex-uwb"===u?r=!0:"opus"===u||"opuswb"===u||"opusswb"===u||"opusuwb"===u||"opus-wb"===u||"opus-swb"===u||"opus-uwb"===u?l=!0:"isac"===u?s=!0:"g.722"!==u&&"g722"!==u&&"g.722.1"!==u&&"g7221"!==u||(p=!0)}!1===webphone_api.common.Glop()&&(l=!1);var g=!1;if((i||a||r||l||s||p)&&(g=!0),
webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, HandleWebrtcCodecsAudio keep codecs: use_pcmu: "+i.toString()+", use_pcma: "+a.toString()+", use_speex: "+r.toString()+", use_opus: "+l.toString()+", use_isac: "+s.toString()+", use_g722: "+p.toString()),!g)return webphone_api.common.PutToDebugLog(2,"EVENT, HandleWebrtcCodecs skip setting disabling all audio codec"),e;var h=n.split("\n");if(webphone_api.common.isNull(h)&&h.length<10)return e;for(var m=-1,c=0;c<h.length;c++)if(!webphone_api.common.isNull(h[c])&&0==h[c].indexOf("m=audio ")){m=c;break}if(m<0)return webphone_api.common.PutToDebugLog(2,"WARNING, HandleWebrtcCodecs m=audio not found"),e;for(var d=-1,c=0;c<h.length;c++)if(!webphone_api.common.isNull(h[c])&&0==h[c].indexOf("m=video ")){d=c;break}d>=0&&d<=m&&(d=-1);var b=!1;!l&&n.indexOf("opus")>=0&&n.indexOf("red")>=0&&(b=!1);for(var _=n.toLowerCase(),t="",f="",w=0;w<7;w++){switch(t="",w){case 0:i||(t="pcmu");break;case 1:a||(t="pcma");break;case 2:r||(t="speex");break;case 3:l||(t="opus");break;case 4:s||(t="isac");break;case 5:p||(t="g722");break;case 6:b||(t="red")}if(!(t.length<1)&&!(_.indexOf(t)<0))for(var c=h.length-1;c>m;c--)if(d>=0&&c>=d&&(c=d),c>=h.length&&(c=h.length-1),!webphone_api.common.isNull(h[c])&&0==h[c].indexOf("a=rtpmap:")&&h[c].toLowerCase().indexOf(t)>0&&(f=webphone_api.common.Trim(webphone_api.common.StrGetBetween(h[c],"a=rtpmap:"," ")),f.length>0&&webphone_api.common.IsNumber(f))){webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcCodecsAudio remove "+t+" "+f),h[m]=En(h[m],f);for(var v=h.length-1;v>m;v--)!webphone_api.common.isNull(h[v])&&(h[v].indexOf("a=rtpmap:"+f+" ")>=0||h[v].indexOf("a=rtcp-fb:"+f+" ")>=0||h[v].indexOf("a=fmtp:"+f+" ")>=0)&&(h.splice(v,1),d--)}}n="";for(var c=0;c<h.length;c++)n.length>0&&(n+="\n"),n+=h[c];return n}catch(E){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcCodecsAudio",E)}return e}function Nn(e){try{var n=e,t=webphone_api.common.GetParameter("vcodec");if(webphone_api.common.isNull(t)||t.length<1||"-1"===t||","===t)return e;var o=t.split(",");if(webphone_api.common.isNull(o)||o.length<1)return e;for(var i=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_h264")),a=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_h265")),r=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_vp8")),l=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_vp9")),s=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_vp10")),p=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_av1")),c=0;c<o.length;c++)if(!webphone_api.common.isNull(o[c])){var u=o[c].toLowerCase().trim();"50"===u?i=!0:"51"===u?a=!0:"52"===u?r=!0:"53"===u?l=!0:"54"===u?s=!0:"55"===u?p=!0:"h.264"===u||"h264"===u?i=!0:"h.265"===u||"h265"===u?a=!0:"vp8"===u||"vp.8"===u?r=!0:"vp9"===u||"vp.9"===u?l=!0:"vp10"===u||"vp.10"===u?s=!0:"av1"!==u&&"av.1"!==u||(p=!0)}var g=!1;if((i||a||r||l||p)&&(g=!0),!g)return webphone_api.common.PutToDebugLog(2,"EVENT, HandleWebrtcCodecs skip setting disabling all video codec"),e;webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, HandleWebrtcCodecsVideo keep codecs: use_h264: "+i.toString()+", use_h265: "+a.toString()+", use_vp8: "+r.toString()+", use_vp9: "+l.toString()+", use_vp10: "+s.toString()+", use_av1: "+p.toString());var h=n.split("\n");if(webphone_api.common.isNull(h)&&h.length<10)return e;for(var m=-1,c=0;c<h.length;c++)if(!webphone_api.common.isNull(h[c])&&0==h[c].indexOf("m=video ")){m=c;break}if(m<0)return webphone_api.common.PutToDebugLog(2,"EVENT, HandleWebrtcCodecs m=video not found"),e;for(var d,b=n.toLowerCase(),_="",f="",t="",w=0;w<6;w++){switch(t="",w){case 0:i||(t="h264");break;case 1:a||(t="h265");break;case 2:r||(t="vp8");break;case 3:l||(t="vp9");break;case 4:s||(t="vp10");break;case 5:p||(t="av1")}if(!(t.length<1)&&!(b.indexOf(t)<0))for(var c=h.length-1;c>m;c--)if(c>=h.length&&(c=h.length-1),!webphone_api.common.isNull(h[c])&&0==h[c].indexOf("a=rtpmap:")&&h[c].toLowerCase().indexOf(t)>0&&(_=webphone_api.common.Trim(webphone_api.common.StrGetBetween(h[c],"a=rtpmap:"," ")),_.length>0&&webphone_api.common.IsNumber(_))){webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcCodecsVideo remove "+t+" "+_),h[m]=En(h[m],_);for(var v=h.length-1;v>m;v--)if(v>=h.length&&(v=h.length-1),!webphone_api.common.isNull(h[v])&&(0==h[v].indexOf("a=rtpmap:"+_+" ")||0==h[v].indexOf("a=rtcp-fb:"+_+" ")||0==h[v].indexOf("a=fmtp:"+_+" ")||0==h[v].indexOf("a=fmtp:")&&h[v].indexOf(" apt="+_)>=0)&&(d=h[v],h.splice(v,1),0==d.indexOf("a=fmtp:")&&d.indexOf(" apt="+_)>=0)){var f=webphone_api.common.Trim(webphone_api.common.StrGetBetween(d,"a=fmtp:","apt="+_));if(f.length>0){webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcCodecsVideo remove rtx "+f),h[m]=En(h[m],f);for(var E=h.length-1;E>m;E--)E>=h.length&&(E=h.length-1),!webphone_api.common.isNull(h[E])&&(h[E].indexOf("a=rtpmap:"+f+" ")>=0||h[E].indexOf("a=rtcp-fb:"+f+" ")>=0||h[E].indexOf("a=fmtp:"+f+" ")>=0)&&h.splice(E,1)}}}}n="";for(var c=0;c<h.length;c++)n.length>0&&(n+="\n"),n+=h[c];return n}catch(P){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcCodecsVideo",P)}return e}function In(e){return Cn(Gn(e))}function Cn(e){try{var n=e,t=webphone_api.common.GetParameter("prefcodec");if(webphone_api.common.isNull(t)||t.length<1||"-1"===t||","===t)return e;var o=!1,i=!1,a=!1,r=!1,l=!1,s=!1,p=t.toLowerCase().trim();if("1"===p?o=!0:"2"===p?i=!0:"5"===p||"6"===p?a=!0:"10"===p||"11"===p||"12"===p||"13"===p?r=!0:"14"===p?s=!0:"15"===p?l=!0:"pcmu"===p?o=!0:"pcma"===p?i=!0:"g.711"===p||"g711"===p?o=!0:"speex"===p||"speexwb"===p?a=!0:"opus"===p||"opuswb"===p||"opusswb"===p||"opusuwb"===p?r=!0:"isac"===p?l=!0:"g.722"!==p&&"g722"!==p||(s=!0),!1===webphone_api.common.Glop()&&(r=!1),!(o||i||a||r||l||s))return e;var c=n.split("\n");if(webphone_api.common.isNull(c)&&c.length<10)return e;for(var u=-1,g=0;g<c.length;g++)if(!webphone_api.common.isNull(c[g])&&0==c[g].indexOf("m=audio ")){u=g;break}if(u<0)return webphone_api.common.PutToDebugLog(2,"ERROR, HandleWebrtcPrefCodecAudio m=audio not found"),e;for(var h=-1,g=0;g<c.length;g++)if(!webphone_api.common.isNull(c[g])&&0==c[g].indexOf("m=video ")){h=g;break}h>=0&&h<=u&&(h=-1);for(var m=n.toLowerCase(),d="",b="",_=0;_<6;_++){switch(d="",b="",_){case 0:o&&(d="pcmu",b="0");break;case 1:i&&(d="pcma",b="8");break;case 2:a&&(d="speex");break;case 3:r&&(d="opus");break;case 4:l&&(d="isac");break;case 5:s&&(d="g722")}if(!(d.length<1&&b.length<1)&&!(d.length>0&&b.length<1&&m.indexOf(d)<0))if(webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcPrefCodecAudio set "+d+" "+b),b.length>0){c[u]=Pn(c[u],b);for(var f=c.length-1;f>u;f--)f>=c.length&&(f=c.length-1),webphone_api.common.isNull(c[f])||0!=c[f].indexOf("a=rtpmap:"+b+" ")&&0!=c[f].indexOf("a=rtcp-fb:"+b+" ")&&0!=c[f].indexOf("a=fmtp:"+b+" ")||c.splice(f,1)}else if(d.length>0)for(var g=c.length-1;g>u;g--)h>=0&&g>=h&&(g=h),g>=c.length&&(g=c.length-1),!webphone_api.common.isNull(c[g])&&0==c[g].indexOf("a=rtpmap:")&&c[g].toLowerCase().indexOf(d)>0&&(b=webphone_api.common.Trim(webphone_api.common.StrGetBetween(c[g],"a=rtpmap:"," ")),b.length>0&&webphone_api.common.IsNumber(b)&&(c[u]=Pn(c[u],b)))}n="";for(var g=0;g<c.length;g++)n.length>0&&(n+="\n"),n+=c[g];return n}catch(w){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcPrefCodecAudio",w)}return e}function Gn(e){try{var n=e,t=webphone_api.common.GetParameter("prefvcodec");if(webphone_api.common.isNull(t)||t.length<1||"-1"===t||","===t)return e;var o=!1,i=!1,a=!1,r=!1,l=!1,s=!1,p=t.toLowerCase().trim();if("50"===p?o=!0:"51"===p?i=!0:"52"===p?a=!0:"53"===p?r=!0:"54"===p?l=!0:"55"===p?s=!0:"h.264"===p||"h264"===p?o=!0:"h.265"===p||"h265"===p?i=!0:"vp8"===p||"vp.8"===p?a=!0:"vp9"===p||"vp.9"===p?r=!0:"vp10"===p||"vp.10"===p?l=!0:"av1"!==p&&"av.1"!==p||(s=!0),!(o||i||a||r||l||s))return e;var c=n.split("\n");if(webphone_api.common.isNull(c)&&c.length<10)return e;for(var u=-1,g=0;g<c.length;g++)if(!webphone_api.common.isNull(c[g])&&0==c[g].indexOf("m=video ")){u=g;break}if(u<0)return webphone_api.common.PutToDebugLog(5,"EVENT, HandleWebrtcPrefCodecVideo no m=video offer"),e;for(var h=n.toLowerCase(),m="",d="",b=0;b<6;b++){switch(m="",b){case 0:o&&(m="h264");break;case 1:i&&(m="h265");break;case 2:a&&(m="vp8");break;case 3:r&&(m="vp9");break;case 4:l&&(m="vp10");break;case 5:s&&(m="av1")}if(!(m.length<1)&&!(h.indexOf(m)<0)){webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcPrefCodecVideo set "+m+" "+d);for(var g=c.length-1;g>u;g--)g>=c.length&&(g=c.length-1),!webphone_api.common.isNull(c[g])&&0==c[g].indexOf("a=rtpmap:")&&c[g].toLowerCase().indexOf(m)>0&&(d=webphone_api.common.Trim(webphone_api.common.StrGetBetween(c[g],"a=rtpmap:"," ")),d.length>0&&webphone_api.common.IsNumber(d)&&(c[u]=Pn(c[u],d)))}}n="";for(var g=0;g<c.length;g++)n.length>0&&(n+="\n"),n+=c[g];return n}catch(_){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcPrefCodecVideo",_)}return e}function Ln(e){try{if("Firefox"!==webphone_api.common.GetBrowser()||webphone_api.common.GetBrowserVersion()<75)return e;if(void 0===e||null===e||e.indexOf("\r\n\r\n")<0)return e;var n=e.toLowerCase();if(n.indexOf("invite sip:")<0&&n.indexOf("invite sips:")<0)return e;var t=e,o=t.split("\n");if(webphone_api.common.isNull(o)&&o.length<10)return e;t="";for(var i=0,a=-1,r=-1,l=0;l<o.length;l++)o[l].indexOf("a=sendrecv")>=0&&(i++,a=l),o[l].indexOf("a=sendonly")>=0&&(i++,r=l);if(i>1&&a>0){r>0&&(o[a]=o[a].replace("a=sendrecv","a=sendonly")),o.splice(a,1),webphone_api.common.PutToDebugLog(2,"EVENT, HandleWebrtcFirefoxHold sendrecv removed_2");for(var l=0;l<o.length;l++)t.length>0&&(t+="\n"),t+=o[l];return t}}catch(s){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcFirefoxHold",s)}return e}function Rn(e){try{if(void 0===e||null===e)return e;if("Firefox"!==webphone_api.common.GetBrowser())return e;var n=e,t=n.split("\n");if(webphone_api.common.isNull(t)&&t.length<10)return e;n="";for(var o=0,i=-1,a=0;a<t.length;a++)t[a].indexOf("a=msid:")>=0&&(o++,i=a);if(o>1&&i>0){t.splice(i,1),webphone_api.common.PutToDebugLog(2,"EVENT, HandleWebrtcFirefoxHold_RemoveDuplicateHeader removed");for(var a=0;a<t.length;a++)n.length>0&&(n+="\n"),n+=t[a];return n}}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcFirefoxHold_RemoveDuplicateHeader",r)}return e}function yn(e){try{var n=!1,t=webphone_api.common.GetParameter("serveraddressbook_url");if(webphone_api.common.isNull(t)||t.length<1)return;if(webphone_api.common.isNull(e)||1!=e||(n=!0),!n){var o=webphone_api.common.GetParameterInt("serveraddressbook_sync",0),i=webphone_api.common.GetParameterInt("serveraddressbook_status",2);i<1?n=!0:1===i&&o>0&&(n=!0),o>1&&(n=!0)}if(!n)return;webphone_api.common.IsHttps()&&(t=t.replace("http:","https:")),webphone_api.common.PutToDebugLog(3,"EVENT, DownloadServerAddressbook url: "+t);var a=new XMLHttpRequest;if("withCredentials"in a)a.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return void webphone_api.common.PutToDebugLog(2,"ERROR, common: DownloadServerAddressbook, CORS not supported");a=new XDomainRequest,a.open("GET",t)}var r=0;a.onload=function(){try{webphone_api.common.PutToDebugLog(4,"EVENT, DownloadServerAddressbook.onload"),r=19;var e=a.responseText;return r=20,webphone_api.common.PutToDebugLog(2,"EVENT, DownloadServerAddressbook response: "+e),r=21,webphone_api.common.isNull(e)||e.length<1?(r=23,void webphone_api.common.PutToDebugLog(2,"ERROR, DownloadServerAddressbook response is NULL")):void Dn(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"DownloadServerAddressbook.onload inner ("+r+")",n)}},a.onerror=function(e){var n="";webphone_api.common.isNull(e)||(n=e.toString(),webphone_api.common.isNull(e.target)||(n=webphone_api.common.isNull(e.target.status)?n+" "+e.target.toString():n+" "+e.target.status.toString())),webphone_api.common.PutToDebugLog(2,"ERROR, common: DownloadServerAddressbook: onerror: "+n)},a.timeout=9e3,a.ontimeout=function(e){webphone_api.common.PutToDebugLog(2,"ERROR, common: DownloadServerAddressbook: Timeout")},a.send()}catch(l){webphone_api.common.PutToDebugLogException(2,"plhandler: DownloadServerAddressbook",l)}}function Dn(e){try{if(webphone_api.common.isNull(e)||e.length<1)return;var n=e.split("\r\n"),t=0;if(webphone_api.common.isNull(n))return void webphone_api.common.PutToDebugLog(2,"ERROR, ParserServerAddressbook list is NULL: "+e);if(n.length<1)return;1==webphone_api.common.GetParameterInt("serveraddressbook_clear",-1)&&(webphone_api.global.ctlist=[]);for(var o=0;o<n.length;o++)if(!(webphone_api.common.isNull(n[o])||n[o].length<3||n[o].indexOf("\t")<1)){var i=n[o].split("\t");if(!(webphone_api.common.isNull(i)||i.length<2)){var a=i[0],r=i[1],l=0,s="",p="",c="",u="";if(!(webphone_api.common.isNull(a)||a.length<1||webphone_api.common.isNull(r)||r.length<1)){i.length>2&&(webphone_api.common.isNull(i[2])||"1"!==webphone_api.common.Trim(i[2])||(l=1)),i.length>3&&!webphone_api.common.isNull(i[3])&&webphone_api.common.Trim(i[3]).length>3&&(s=webphone_api.common.Trim(i[3])),i.length>4&&!webphone_api.common.isNull(i[4])&&webphone_api.common.Trim(i[4]).length>3&&(p=webphone_api.common.Trim(i[4])),i.length>5&&!webphone_api.common.isNull(i[5])&&webphone_api.common.Trim(i[5]).length>0&&(c=webphone_api.common.Trim(i[5])),i.length>6&&!webphone_api.common.isNull(i[6])&&webphone_api.common.Trim(i[6]).length>3&&(u=webphone_api.common.Trim(i[6]));var g=r.replace("+",""),h="sip";webphone_api.common.IsNumber(g)&&(h="phone"),i.length>7&&!webphone_api.common.isNull(i[7])&&webphone_api.common.Trim(i[7]).length>0&&(h=webphone_api.common.Trim(i[7])),t++;he(a,r,l,h,webphone_api.common.GetTickCount(),s,p,c,u,"1")}}}webphone_api.common.PutToDebugLog(4,"EVENT, ParserServerAddressbook: "+t.toString()+" contacts added sucessfully")}catch(m){webphone_api.common.PutToDebugLogException(2,"plhandler: ParserServerAddressbook",m)}}function On(e,n){Jn("IsServiceInstalled"),webphone_api.common.IsServiceInstalled(e,n)}function xn(){return Jn("CanIUseWebrtc"),webphone_api.common.CanIUseWebRTC()}function An(e,n,t){Jn("ShowToast-"+e),webphone_api.common.ShowToast(e,n,t)}function kn(e,n,t){Jn("AlertDialog-"+n),webphone_api.common.AlertDialog(e,n,t)}function Un(e,n,t,o,i){webphone_api.webphone.API_SetCredentials(e,n,t,o,i)}function Vn(e,n,t,o){webphone_api.webphone.API_SetCredentialsMD5(e,n,t,o)}function Wn(e){webphone_api.webphone.API_CheckVoicemail(e)}function Fn(e){webphone_api.webphone.API_SetLine(e)}function Mn(e){webphone_api.webphone.API_GetLine(e)}function Hn(e){webphone_api.webphone.API_GetLineStatus(e)}function Bn(e,n){webphone_api.webphone.API_Forward(e,n)}function jn(e){webphone_api.webphone.API_IsMuted(e)}function $n(e){webphone_api.webphone.API_IsOnHold(e)}function qn(e){webphone_api.webphone.API_GetAudioDeviceList(e)}function zn(e){webphone_api.webphone.API_GetAudioDevice(e)}function Kn(e){webphone_api.webphone.API_SetAudioDevice(e)}function Xn(e){webphone_api.webphone.API_GetVolume(e)}function Jn(e){try{if(!0===webphone_api.common.IsWindowsSoftphone())return;if(!1===webphone_api.global.wploaded){var n="WARNING,WapiTouced API called before webphone loaded ("+webphone_api.global.phonestarted.toString()+"): "+e;if(webphone_api.common.PutToDebugLog(2,n),"undefined"!=typeof console&&null!==console)if("delsettings"===e&&"undefined"!=typeof console.log&&null!==console.log)try{console.log(n)}catch(t){}else if("undefined"!=typeof console.error&&null!==console.error)try{console.error(n)}catch(t){}else if("undefined"!=typeof console.log&&null!==console.log)try{console.log(n)}catch(t){}}}catch(o){webphone_api.common.PutToDebugLogSpecial(2,"EVENT, plhandler WapiTouced",!0,o)}}function Yn(e,n){webphone_api.common.isNull(e)||e.length<1||(Qn(),webphone_api.common.isNull(to)&&(to=[]),webphone_api.common.isNull(n)&&(n=[]),webphone_api.common.PutToDebugLog(2,"EVENT,AddToQueueEn cached for execution after engine start ("+webphone_api.global.phonestarted.toString()+" "+webphone_api.global.wploaded.toString()+") : "+e.toLowerCase()+"("+n.toString()+")"),n.unshift(e),n.unshift(webphone_api.common.GetTickCount().toString()),to.push(n))}function Qn(){webphone_api.common.isNull(oo)&&(oo=setInterval(function(){if(++io>1e5||io>1e5&&(webphone_api.common.isNull(to)||to.length<1||webphone_api.global.phonestarted>=2))return void 0!==oo&&null!==oo&&clearInterval(oo),oo=null,to=[],void(io=0);if(!(webphone_api.common.isNull(to)||to.length<1)&&webphone_api.global.phonestarted>=2){var e=to.shift();if(webphone_api.common.isNull(e)||e.length<2)return;var n=0;try{n=webphone_api.common.StrToInt(e[0])}catch(i){}e.shift();var t=e[0];if(webphone_api.common.isNull(t)||t.length<1)return void webphone_api.common.PutToDebugLog(2,"ERROR, handle API function queue invalid name(engine: "+webphone_api.common.getuseengine()+"): "+t);if(webphone_api.common.GetTickCount()-n>6e5)return void webphone_api.common.PutToDebugLog(2,"ERROR, handle API function queue(engine: "+webphone_api.common.getuseengine()+"): "+t+" (too late)");e.shift();var o="";webphone_api.common.isNull(e)||(o=e.toString()),webphone_api.common.PutToDebugLog(2,"EVENT, handle API function queue(engine: "+webphone_api.common.getuseengine()+"): "+t+" ("+o+");"),Zn(t,e)}},15))}function Zn(e,n){var t=window.webphone_api.plhandler[e];"function"==typeof t&&t.apply(window,n)}function et(e){try{if(webphone_api.common.isNull(e)||e.length<1||webphone_api.common.isNull(webphone_api.origparameters))return"";if("undefined"!=typeof webphone_api.origparameters[e]&&null!=webphone_api.origparameters[e]&&webphone_api.origparameters[e].toString().length>0){var n=webphone_api.origparameters[e];return!webphone_api.common.isNull(n)&&n.toString().length>0&&n.toString().indexOf("dcid_")>=0&&(n=webphone_api.common.StrDc(n.toString(),"X9hAm21TaGzqeR45Bj")),webphone_api.common.isNull(n)?"":n}}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetOrigConfigParam ("+e+")",t)}return""}function nt(e){var n=0;try{if(n=1,webphone_api.common.isNull(e)||e.length<1)return"";n=2;var t=webphone_api.common.GetConfig(e);n=3;var o=webphone_api.common.GetConfigAll(!0);if(n=4,!webphone_api.common.isNull(o)){n=5;var i="overwrite_"+e;n=21,"undefined"!=typeof o[i]&&null!==o[i]&&o[i].toString().length>0&&(n=22,t=o[i].toString())}n=6,"undefined"!=typeof webphone_api.parameters[e]&&null!=webphone_api.parameters[e]&&webphone_api.parameters[e].toString().length>0&&(n=23,t=webphone_api.parameters[e]),n=7;var a=window.location.href;if(!webphone_api.common.isNull(a)){n=8;var r=webphone_api.common.GetUrlParamVal(a,e);n=24,!webphone_api.common.isNull(r)&&r.toString().length>0&&(n=25,t=r)}return n=9,(!webphone_api.common.isNull(t)&&t.toString().length>0&&t.toString().indexOf("dcid_")>=0&&(n=10,t=webphone_api.common.StrDc(t.toString(),"X9hAm21TaGzqeR45Bj")),n=11,webphone_api.common.isNull(t))?"":(n=12,t)}catch(l){webphone_api.common.PutToDebugLogException(2,"plhandler GetCCParam "+n+" ("+e+")",l)}return""}function tt(){try{var e=nt("serveraddress"),n=nt("webrtcserveraddress"),t=nt("proxyaddress"),o=nt("transport"),i=nt("realm"),a=et("serveraddress"),r=et("webrtcserveraddress"),l=et("proxyaddress"),s=et("transport"),p=et("realm");webphone_api.common.isNull(e)&&(e=""),webphone_api.common.isNull(n)&&(n=""),webphone_api.common.isNull(t)&&(t=""),webphone_api.common.isNull(o)&&(o=""),webphone_api.common.isNull(i)&&(i=""),webphone_api.common.isNull(a)&&(a=""),webphone_api.common.isNull(r)&&(r=""),webphone_api.common.isNull(l)&&(l=""),webphone_api.common.isNull(s)&&(s=""),webphone_api.common.isNull(p)&&(p=""),e=e.toString().toLowerCase(),n=n.toString().toLowerCase(),t=t.toString().toLowerCase(),o=o.toString().toLowerCase(),i=i.toString().toLowerCase(),a=a.toString().toLowerCase(),r=r.toString().toLowerCase(),l=l.toString().toLowerCase(),s=s.toString().toLowerCase(),p=p.toString().toLowerCase();return e+n+i+t+o+a+r+p+l+s}catch(c){webphone_api.common.PutToDebugLogException(2,"plhandler: GetMainConfigsAsString",c)}return""}function ot(){try{if(ao)return;var e=webphone_api.common.GetParameter("lastwpapixxx"),n=Ee("configversion"),t=Ee("prevconfigversion");if(webphone_api.common.isNull(t)||!webphone_api.common.IsNumber(t)){var o=n;!webphone_api.common.isNull(o)&&webphone_api.common.IsNumber(o)||(o=0),webphone_api.common.SaveParameter("prevconfigversion",o)}var i=tt();!webphone_api.common.isNull(n)&&webphone_api.common.IsNumber(n)&&n>0&&!webphone_api.common.isNull(t)&&webphone_api.common.IsNumber(t)&&n!==t?(ao=!0,webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"WARNING, DelSettings on start because configversion new: "+n+", old: "+t),ln(0,!1)):!webphone_api.common.isNull(e)&&e.length>0&&!webphone_api.common.isNull(i)&&i.length>0?(ao=!0,e!==i?(webphone_api.common.CanLog(2)&&(webphone_api.common.PutToDebugLog(2,"WARNING, DelSettings on start because main configs changed x"),webphone_api.common.PutToDebugLog(4,"EVENT, DelSettings old config: "+e),webphone_api.common.PutToDebugLog(4,"EVENT, DelSettings new config: "+i)),ln(0,!1),webphone_api.common.CanLog(2)&&(webphone_api.common.PutToDebugLog(4,"EVENT, DelSettings new2 config: "+tt()),webphone_api.common.PutToDebugLog(4,"EVENT, DelSettings new3 config: "+Ee("serveraddress")+Ee("webrtcserveraddress")+Ee("realm")+Ee("proxyaddress")+Ee("transport")))):webphone_api.common.CanLog(6)&&webphone_api.common.PutToDebugLog(6,"EVENT, check config change old: "+e+", new: "+i)):webphone_api.common.CanLog(5)&&(!webphone_api.common.isNull(i)&&i.length>0?webphone_api.common.PutToDebugLog(5,"EVENT, check config change old: null, new: "+i):!webphone_api.common.isNull(e)&&e.length>0&&webphone_api.common.PutToDebugLog(5,"EVENT, check config change old: "+e+", new: null")),!webphone_api.common.isNull(i)&&i.length>0&&webphone_api.common.SaveParameter("lastwpapixxx",i)}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: ConfigChanged",a)}}var it="",at=!1,rt=null;webphone_api.global.isfirststart=!0,1==webphone_api.common.IsSDK()&&(webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler call HandleSettingsSDK",!1,""),webphone_api.global.domloaded_tick=webphone_api.common.GetTickCount(),a(function(n){if(webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler onload HandleSettingsSDK FINISHED: "+n,!1,""),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: initialize start"),webphone_api.common.Glv()<1)return void(webphone_api.global.webrtcavailable=0);webphone_api.$(document).ready(function(){webphone_api.loadwebrtc_timestamp=webphone_api.common.GetTickCount();var n=webphone_api.common.GetForcedEngine();if(n&&"webrtc"!=n.name)return webphone_api.global.webrtcavailable=0,webphone_api.common.PutToDebugLog(2,"webrtc engine not needed"),void(!0===webphone_api.common.UseCustomAutoprov(!0)?webphone_api.common.GetCustomAutoprov(function(n){webphone_api.common.RecAutoprovCustom(n),e()}):e());webphone_api.webrtcapi.WebRtcIsSupported(function(n){var t="";if(t+=n?"A":"b","Windows"===webphone_api.common.GetOs()&&("MSIE"===webphone_api.common.GetBrowser()?(t+="c",n=!1):"Edge"===webphone_api.common.GetBrowser()&&(webphone_api.common.GetBrowserVersion()<14?(t+="d",n=!1):!1===n&&(t+="e",webphone_api.common.PutToDebugLog(2,"ERROR,plhandler Edge webrtc is not supported, getusermedia: "+typeof navigator.getUserMedia+"; RTCPeerConnection: "+typeof window.RTCPeerConnection)))),"iOS"===webphone_api.common.GetOs()?(("Safari"===webphone_api.common.GetBrowser()||"iPhone"===webphone_api.common.GetBrowser())&&webphone_api.common.GetBrowserVersion()<11&&(n=!1,t+="f"),"Firefox"!==webphone_api.common.GetBrowser()||navigator.mozGetUserMedia||navigator.GetUserMedia||(n=!1,t+="g"),"Chrome"!==webphone_api.common.GetBrowser()||navigator.webkitGetUserMedia||navigator.GetUserMedia||(n=!1,t+="h")):"Windows"===webphone_api.common.GetOs()&&"Safari"===webphone_api.common.GetBrowser()&&(t+="i",n=!1),webphone_api.common.isNull(n)&&(n="",t+="j"),webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: Webrtc engine available at plh: "+n+" "+t),!0===n){webphone_api.global.webrtcavailable=1;var o=webphone_api.common.GetEngine("webrtc"),i=webphone_api.common.GetParameter2("serveraddress_user");(webphone_api.common.isNull(i)||i.length<2)&&(i=webphone_api.common.GetParameter2("serveraddress")),(webphone_api.common.isNull(i)||i.length<2)&&(i=webphone_api.common.GetConfig("serveraddress")),webphone_api.common.isNull(i)&&(i="");var a=!1;webphone_api.common.CanUseAnyAddrForWebRTC()||(1==webphone_api.common.IsLanIPEx(webphone_api.common.GetWebrtcUpperServer())?a=!0:0==webphone_api.common.IsLanIPEx(webphone_api.common.GetWebrtcUpperServer())||1==webphone_api.common.IsLanIPEx(i)&&(a=!0)),a?webphone_api.common.isNull(o)||(o.issupported_cache=0,o.available=0):!0===webphone_api.common.BrowserRequiresHttps(!0)?webphone_api.common.isNull(o)||(o.issupported_cache=1,o.available=2):webphone_api.common.isNull(o)||(o.issupported_cache=2,o.available=3)}else!1===n&&(webphone_api.global.webrtcavailable=0,webphone_api.common.PutToDebugLog(2,"EVENT, webrtc engine NOT available (b) "+t));!0===webphone_api.common.UseCustomAutoprov(!0)?webphone_api.common.GetCustomAutoprov(function(n){webphone_api.common.RecAutoprovCustom(n),e()}):e()})})}));var lt=null,st=!1,pt=null,ct=!1,ut=null,gt=10,ht=185,mt=null,dt=null,bt=!1,_t=0,ft="",wt=!1,vt=null,Et=0,Pt=0,Tt=!0,St=!1,Nt=!1,It=null,Ct=-1,Gt=0,Lt=0,Rt=null,yt=null,Dt=!1,Ot=0,xt=null,At=0,kt=0,Ut=null,Vt=[],Wt=[],Ft=null,Mt=null,Ht=!1,Bt=[],jt=[],$t=null,qt=[],zt=[],Kt=null,Xt=[],Jt=[],Yt=[],Qt=[],Zt=[],eo=null,no=!1,to=[],oo=null,io=0,ao=!1;return{Start:n,StartUp:i,Register:m,RegisterEx:b,CheckPresence:_,SetPresenceStatus:f,CheckBLF:w,GetVersionNS:v,GetVersionNSNum:E,GetVersionJava:P,IsEncrypted:T,SetSipHeader:S,GetSipHeader:I,GetSipHeaderInternal:N,GetSipMessage:C,ChangeTheme:G,GetWorkDir:L,Call:x,CallDelayed:A,VideoCall:R,MuteVideo:y,ScreenShare:D,StopScreenShare:U,Hangup:V,Accept:F,Reject:M,Ignore:H,SetVideoSize:B,GetAvailableCallfunc:j,Forward:$,Conference:z,Transfer:K,Dtmf:X,MuteEx:J,IsMuted:Y,Hold:Q,IsOnHold:ee,SendChat:ne,SendSms:oe,Voicerecord:ie,DevicePopup:le,SetVolume:se,GetVolume:pe,SetLoudspeaker:ce,PlaySound:ue,AddContact:ge,SaveTheContact:he,DeleteContact:me,DeleteAllContacts:de,DownloadServerAddressbook:yn,GetContact:_e,ListContacts:fe,ListCallhistory:we,SetParameter:ve,GetParameter:Ee,SetLine:Pe,GetLine:Te,LineToCallID:Se,CallIDToLine:Ne,NextCallID:Ge,IsRegistered:Ae,IsInCall:ke,GetDeviceList:Ue,GetDevice:Ve,SetDevice:We,StopEngine:Fe,Stop:Me,HelpWindow:je,BrowserWindowIsActive:Be,SettingsPage:$e,DialPage:qe,MessageInboxPage:ze,MessagePage:Ke,AddContactPage:Xe,InsertApplet:Je,EnterKeyPress:Ye,FileTransferCallback:Qe,GetTelsearchName:Ze,CallWsuser:t,Cfin:O,bwanswer:en,onappexit:nn,getlogs:tn,getlogsex:on,putlogs:an,ImportContacts:rn,delsettings:ln,needratingrequest:sn,IsMobileBrowser:pn,Getenginename:cn,GetLastInvite:un,GetLastRecInvite:gn,GetLastSentInvite:hn,getstringresource:fn,Jvoip:wn,GetStatus:ae,GetRegFailReason:re,Unregister:De,UnregisterEngine:Oe,HTTPKeepAlive:xe,GetLineDetails:Le,GetLastCallDetails:Re,GetIncomingDisplay:ye,ParseReceivedParameters:l,GetOneStunSrv:vn,HandleWebrtcCodecs:Tn,HandleWebrtcCodecsAudio:Sn,HandleWebrtcCodecsVideo:Nn,HandleWebrtcPrefCodec:In,HandleWebrtcPrefCodecAudio:Cn,HandleWebrtcPrefCodecVideo:Gn,HandleWebrtcFirefoxHold:Ln,HandleWebrtcFirefoxHold_RemoveDuplicateHeader:Rn,IsServiceInstalled:On,CanIUseWebrtc:xn,API_SetCredentials:Un,API_SetCredentialsMD5:Vn,API_CheckVoicemail:Wn,API_SetLine:Fn,API_GetLine:Mn,API_GetLineStatus:Hn,API_Forward:Bn,API_IsMuted:jn,API_IsOnHold:$n,API_GetAudioDeviceList:qn,API_GetAudioDevice:zn,API_SetAudioDevice:Kn,API_GetVolume:Xn,API_RecFiles_Upload:mn,API_RecFiles_UploadEx:dn,API_RecFiles_Clear:bn,API_RecFiles_Del:_n,SendChatIsComposing:He,ShowToast:An,AlertDialog:kn,LoginSkin:g,GetAudioDevicesForMenu:h,ConfigChanged:ot}}(),webphone_api.webphone=function(){function e(){try{webphone_api.common.PutToDebugLog(2,"EVENT, webphone Init called"),Me=!1,He=null,Be=0,je=!1,$e=!0,qe=!1,ze=!1,Qe=!1,Ze=0,webphone_api.webphone_pollstatus=!0,webphone_api.global.apppletloaded=!1}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: Init",e)}}function n(){try{webphone_api.common.PutToDebugLog(2,"EVENT, webphone: CheckWebphonetojs called"),void 0!==Ye&&null!==Ye&&clearTimeout(Ye),Ye=setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, webphone: CheckWebphonetojs starting timer"),!0===webphone_api.webphone_pollstatus&&(webphone_api.common.PutToDebugLog(2,"EVENT, webphone: CheckWebphonetojs starting status polling"),qe=!0,webphone_api.global.polltimerid=setInterval(function(){webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE()&&He&&He.API_Poll&&webphonetojs(He.API_Poll())},Xe))},Je),setTimeout(function(){!0===qe&&webphone_api.common.WinAPI("API_RegisterNoParam",function(){webphone_api.common.PutToDebugLog(2,"ERROR, webphone API_RegisterNoParam called")})},Je+1e3)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: CheckWebphonetojs",e)}}function t(){try{webphone_api.common.PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("initializing")),e();try{if(!webphone_api.common.isNull(webphone_api.global.settmap2)){for(var n in webphone_api.global.settmap2){var t=webphone_api.global.settmap2[n];if(!webphone_api.common.isNull(t)&&!(n.indexOf("server")<0&&n.indexOf("username")<0&&n.indexOf("password")<0&&"1"===t[webphone_api.common.SETT_ISDEFAULT])){if("username"===n||"sipusername"===n||"password"===n){var i=t[webphone_api.common.SETT_VALUE];if(!webphone_api.common.isNull(i)&&i.length>0){i=o(i),Ke[n]=i;continue}}if("serveraddress"===n){var i=t[webphone_api.common.SETT_VALUE],a=Ke.serveraddress;if((webphone_api.common.isNull(i)||i.length<1)&&a.length>1)continue;if((webphone_api.common.isNull(a)||a.length<1)&&(webphone_api.common.isNull(i)||i.length<1)){Ke.serveraddress=webphone_api.common.GetParameter("serveraddress_user");continue}}else if("serveraddress_orig"===n)n="serveraddress";else if("upperserver"===n){var i=t[webphone_api.common.SETT_VALUE],a=webphone_api.common.GetParameter("serveraddress_orig");i===a||i.length<1?Ke[n]="":Ke[n]=webphone_api.common.GetParameter("serveraddress_orig")}else"aec"===n?n="aec_orig":"agc"===n?n="agc_orig":"denoise"===n?n="denoise_orig":"plc"===n?n="plc_orig":"has_video"===n?"0"===webphone_api.common.GetParameter2("video")?Ke[n]="false":Ke[n]="true":Ke[n]=t[webphone_api.common.SETT_VALUE]}}var r=webphone_api.common.GetParameter("extraoption");if(!webphone_api.common.isNull(r)&&r.length>0){r=webphone_api.common.Trim(r);var l=r.split(";");if(!webphone_api.common.isNull(l)&&l.length>0)for(var s=0;s<l.length;s++)if(!(webphone_api.common.isNull(l[s])||l[s].length<1||l[s].indexOf("=")<1)){var n=webphone_api.common.Trim(l[s].substring(0,l[s].indexOf("="))),t=webphone_api.common.Trim(l[s].substring(l[s].indexOf("=")+1));!webphone_api.common.isNull(n)&&n.length>0&&!webphone_api.common.isNull(t)&&(Ke[n]=t)}}}webphone_api.common.GetConfig("upperserverip").length>0&&(Ke.upperserverip=webphone_api.common.GetConfig("upperserverip")),webphone_api.common.GetConfig("upperserverdomain").length>0&&(Ke.upperserverdomain=webphone_api.common.GetConfig("upperserverdomain")),Ke.jsscriptevent=3,(webphone_api.common.isNull(Ke.serveraddress_orig)||Ke.serveraddress_orig.length<1)&&(Ke.serveraddress_orig=Ke.serveraddress);var p=webphone_api.parameters.customsipheader;if(!webphone_api.common.isNull(p)&&p.length>0&&(p=webphone_api.common.Trim(p),
!webphone_api.common.isNull(Ke.customsipheader)&&Ke.customsipheader.toString().length>0?Ke.customsipheader.lastIndexOf(";")<Ke.customsipheader.length-1&&(Ke.customsipheader=Ke.customsipheader+";"):Ke.customsipheader="",Ke.customsipheader=Ke.customsipheader+p),Ke.extraregisteraccounts="",!webphone_api.common.isNull(webphone_api.global.sipaccounts)&&webphone_api.global.sipaccounts.length>0){for(var s=0;s<webphone_api.global.sipaccounts.length;s++){var c=webphone_api.global.sipaccounts[s];if(!(webphone_api.common.isNull(c)||c.length<4)&&(!0!==c.ismain&&!1!==c.enabled)){var u=c.serveraddress,g=c.username,h=webphone_api.common.B64Dec(c.password),m=c.callerid,d=c.displayname,b=c.proxyaddress,_=c.realm;void 0!==u&&null!==u||(u=""),void 0!==g&&null!==g||(g=""),void 0!==h&&null!==h||(h=""),void 0!==m&&null!==m||(m=""),void 0!==d&&null!==d||(d=""),void 0!==b&&null!==b||(b=""),void 0!==_&&null!==_||(_=""),webphone_api.common.Trim(m).length<1&&(m=g),Ke.extraregisteraccounts.length>0&&(Ke.extraregisteraccounts=Ke.extraregisteraccounts+";"),Ke.extraregisteraccounts=Ke.extraregisteraccounts+u+","+m+","+h+","+c.ival+","+b+","+_+","+g}}var f=webphone_api.common.GetExtraRegAccFromAPIparam();!webphone_api.common.isNull(f)&&f.length>5&&(Ke.extraregisteraccounts.length>0&&(Ke.extraregisteraccounts=Ke.extraregisteraccounts+";"),Ke.extraregisteraccounts=Ke.extraregisteraccounts+f)}Ke.autohold="0",Ke.automute="0",webphone_api.common.CanLog(4)&&webphone_api.common.LogAllParameters("Webphone all parameters:",Ke)}catch(w){webphone_api.common.PutToDebugLogException(2,"webphone: Start Setting parameters",w)}de(),setTimeout(function(){on=webphone_api.common.GetTickCount(),_e()},1e3)}catch(w){webphone_api.common.PutToDebugLogException(2,"webphone: Start",w)}}function o(e){try{if(webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(2,"ERROR, wp B4 invalid extracted value"),"";if(e.length<1)return"";var n=e;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){if(n.indexOf("=")>=0)return n="Bb7Sb2VVVVV_"+webphone_api.common.B64Enc(n)}else if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE||!0===webphone_api.common.IsWindowsSoftphone()){var t=webphone_api.common.GetParameterInt("srvupgrade_currversion",0);if(t>18&&(n.indexOf("%")>=0||n.indexOf("^")>=0||n.indexOf("&")>=0||n.indexOf("<")>=0||n.indexOf(">")>=0||n.indexOf("|")>=0||n.indexOf("'")>=0||n.indexOf("`")>=0||n.indexOf(",")>=0||n.indexOf(";")>=0||n.indexOf("=")>=0||n.indexOf("(")>=0||n.indexOf(")")>=0||n.indexOf("!")>=0||n.indexOf('"')>=0||n.indexOf("\\")>=0||n.indexOf("[")>=0||n.indexOf("]")>=0||n.indexOf('"')>=0||n.indexOf(".")>=0||n.indexOf("*")>=0||n.indexOf("?")>=0))return n="Bb7Sb2VVVVV_"+webphone_api.common.B64Enc(n)}}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: B64EncUserPwd",o)}return e}function i(){function t(e){S&&(webphone_api.common.PutToDebugLog(2,"EVENT, webphone: StartWin: API_SetParameters called"),webphone_api.common.PutToDebugLog(4,"EVENT, webphone: StartWin: API_SetParameters paramlist: "+l)),i=37,webphone_api.common.WinAPI("API_SetParameters",function(e){Qe=!0,Ze=0,i=41,webphone_api.common.isNull(e)&&(e=""),e=e.toString(),e=e.toLowerCase(),e.indexOf("ok:")<0&&e.indexOf("true")<0&&webphone_api.common.PutToDebugLog(2,"ERROR, webphone: StartWin: API_SetParameters callback: failed to save settings"),i=42,webphone_api.global.apistartstate=1,webphone_api.global.apistarttick=webphone_api.common.GetTickCount(),webphone_api.common.WinAPI("API_Start",function(e){i=43,webphone_api.common.SetDID(),ze=!0,i=44,webphone_api.common.isNull(e)&&(e=""),e=e.toString(),e=e.toLowerCase(),e.indexOf("ok:")<0&&e.indexOf("true")<0?(i=45,webphone_api.common.PutToDebugLog(2,"ERROR, webphone: StartWin: API_Start callback: failed to start webphone (1), answ: "+e)):(i=46,r(),setTimeout(function(){webphone_api.global.phonestarted<2&&(webphone_api.global.phonestarted=2)},1e3))},webphone_api.common.GetBrowserSessionID()),i=47,n()},e),setTimeout(function(){webphone_api.common.GetSrvVersions()},1e3)}var i=0;webphone_api.common.PutToDebugLog(2,"EVENT, webphone: StartWin called"),webphone_api.common.PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("initializing"));try{e(),i=1;var a="",l="",s=[];if(!webphone_api.common.isNull(webphone_api.global.settmap2)){i=2;for(var p in webphone_api.global.settmap2)if(!(webphone_api.common.isNull(p)||p.length<1)){var c=webphone_api.global.settmap2[p];"has_video"===p&&("0"===webphone_api.common.GetParameter2("video")?c[0]="false":c[0]="true"),p.indexOf("server")<0&&p.indexOf("username")<0&&p.indexOf("password")<0&&"1"===c[webphone_api.common.SETT_ISDEFAULT]||(s[p]=c[0])}i=3}var u=webphone_api.common.GetParameterInt("nsloglevel",webphone_api.common.GetLogLevel());i=4;for(var p in Ke)if(!(webphone_api.common.isNull(p)||p.length<1||"username"===p&&!webphone_api.common.isNull(s[p])&&s[p].length>0&&(webphone_api.common.isNull(Ke[p])||Ke[p].length<1)||0==p.indexOf("pgw"))){if("loglevel"===p)try{s.jsscriptevent=u>1?"3":"2"}catch(L){}s[p]=Ke[p]}i=5,!webphone_api.common.isNull(webphone_api.common.GetConfig("upperserverip"))&&webphone_api.common.GetConfig("upperserverip").length>0&&(s.upperserverip=webphone_api.common.GetConfig("upperserverip")),i=11,!webphone_api.common.isNull(webphone_api.common.GetConfig("upperserverdomain"))&&webphone_api.common.GetConfig("upperserverdomain").length>0&&(s.upperserverdomain=webphone_api.common.GetConfig("upperserverdomain")),i=12,webphone_api.common.isNull(s.serveraddress_orig||s.serveraddress_orig.length<1)&&(s.serveraddress_orig=s.serveraddress),i=13;var g=webphone_api.parameters.customsipheader;if(!webphone_api.common.isNull(g)&&g.length>0&&(i=14,g=webphone_api.common.Trim(g),!webphone_api.common.isNull(s.customsipheader)&&s.customsipheader.toString().length>0?(i=15,s.customsipheader.lastIndexOf(";")<s.customsipheader.length-1&&(s.customsipheader=s.customsipheader+";",i=16)):(i=17,s.customsipheader=""),s.customsipheader=s.customsipheader+g),i=21,s.extraregisteraccounts="",!webphone_api.common.isNull(webphone_api.global.sipaccounts)&&webphone_api.global.sipaccounts.length>0){for(var h=0;h<webphone_api.global.sipaccounts.length;h++){var m=webphone_api.global.sipaccounts[h];if(!(webphone_api.common.isNull(m)||m.length<4)&&(!0!==m.ismain&&!1!==m.enabled)){var d=m.serveraddress,b=m.username,_=webphone_api.common.B64Dec(m.password),f=m.callerid,w=m.displayname,v=m.proxyaddress,E=m.realm;void 0!==d&&null!==d||(d=""),void 0!==b&&null!==b||(b=""),void 0!==_&&null!==_||(_=""),void 0!==f&&null!==f||(f=""),void 0!==w&&null!==w||(w=""),void 0!==v&&null!==v||(v=""),void 0!==E&&null!==E||(E=""),webphone_api.common.Trim(f).length<1&&(f=b),s.extraregisteraccounts.length>0&&(s.extraregisteraccounts=s.extraregisteraccounts+";"),s.extraregisteraccounts=s.extraregisteraccounts+d+","+f+","+_+","+m.ival+","+v+","+E+","+b}}var P=webphone_api.common.GetExtraRegAccFromAPIparam();!webphone_api.common.isNull(P)&&P.length>5&&(Ke.extraregisteraccounts.length>0&&(s.extraregisteraccounts=s.extraregisteraccounts+";"),s.extraregisteraccounts=s.extraregisteraccounts+P)}s.loglevel=u.toString(),s.jsscriptevent=u>1?"3":"2";var T=!1;(webphone_api.common.GetLogLevel()>=7||!0===webphone_api.global.isdebugversion&&webphone_api.common.GetLogLevel()>=5)&&(T=!0);var S=!1;webphone_api.common.CanLog(2)&&(S=!0);for(var p in s)if(!(webphone_api.common.isNull(p)||p.length<1||"callto"===p||"platform"===p)){if(p.length>9){if(0==p.indexOf("transfertype")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("transfwithreplace")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("allowreplace")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("discontransfer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("disconincomingrefer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("inversetransfer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("transferdelay")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("newdialogforrefer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("useserverdomainforrefer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("holdontransfer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue}"autohold"!==p&&"automute"!==p||(s[p]="0"),"sippassword"===p&&(p="password");var N=s[p];webphone_api.common.isNull(N)||(N=N.toString()),"password"===p&&!webphone_api.common.isNull(N)&&N.length>0&&(N=o(N)),webphone_api.common.isNull(N)||N.length<=0||(a.length>0&&(a+="\r\n"),a=a+p+"="+N,S&&(!T&&(p.indexOf("password")>=0||"extraregisteraccounts"===p)||"passphrase"==p||"serverapikey"==p?(l.length>0&&(l+="\r\n"),l=l+p+"= *"):!T&&(0==p.indexOf("pgw")||N.indexOf("com.mizuvoip.mizudroid")>=0||N.indexOf("app/mizuphone")>=0||p.indexOf("transfwithreplace")>=0&&"-1"==N||p.indexOf("log_email")>=0&&N.indexOf("mizu")>=0||p.indexOf("domaintoip_cache")>=0||"get"==p||"getAll"==p||"usingmizuserveronly"==p||p.indexOf("supportend")>=0||"demoversion"==p||"demoyear"==p||"demomonth"==p||"demoday"==p)||(l.length>0&&(l+="\r\n"),l=l+p+"="+N)))}i=22;var I="";I=I+"\r\nminserviceversion="+webphone_api.common.GetMinServiceVersion(),i=27,"rigitel"===webphone_api.common.GetConfig("brandname").toLowerCase()&&(I+="\r\nhasincomingcall=false");var C=webphone_api.common.GetNPLocation();i=31,webphone_api.common.isNull(C)&&(C=""),i=32;var G=C.indexOf("native/");G>0&&(C=C.substr(0,G)),i=33,I=I+"\r\nlanguage="+webphone_api.stringres.getlang(),I+="\r\ntranslatemode=2",I=I+"\r\nwebphoneurl="+C,i=34,I+="\r\ndummy=3",i=35,I="akarmidw=true\r\n"+I,i=36,a+=I,S&&(l+=I),t(a),en=setInterval(function(){return!0===Qe?(webphone_api.common.isNull(en)||clearInterval(en),en=null,void(Ze=0)):++Ze>15?(webphone_api.common.PutToDebugLog(2,"ERROR, API_Setparameters timer reached maxloop"),webphone_api.common.isNull(en)||clearInterval(en),void(en=null)):(webphone_api.common.PutToDebugLog(2,"ERROR, API_Setparameters try to send parameters again, because earlier send failed"),void t(a))},1e3),i=51,setTimeout(function(){i=52,ze||!0!==Qe||(i=53,webphone_api.global.apistartstate=1,webphone_api.global.apistarttick=webphone_api.common.GetTickCount(),webphone_api.common.WinAPI("API_Start",function(e){i=54,webphone_api.common.SetDID(),webphone_api.common.isNull(e)&&(e=""),e=e.toString(),e=e.toLowerCase(),e.indexOf("ok:")<0&&e.indexOf("true")<0?(i=55,webphone_api.common.PutToDebugLog(2,"ERROR, webphone: StartWin: API_Start callback: failed to start webphone (2) answ: "+e)):(i=56,r())},webphone_api.common.GetBrowserSessionID())),i=57,ze=!1},2500),webphone_api.common.GetCustomMenus(),i=58}catch(R){webphone_api.common.PutToDebugLogException(2,"webphone: StartWin ("+i.toString()+")",R)}}function a(){try{webphone_api.common.PutToDebugLog(3,"EVENT, StartService"),i()}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: StartService",e)}}function r(){}function l(){try{return fe()?He.API_Restart():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Restart(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: Restart",e)}}function s(e){try{return fe()?He.API_PushContactlist(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: PushContactlist(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: PushContactlist",n)}}function p(e){try{return fe()?He.API_CheckPresence(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: CheckPresence(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: CheckPresence",n)}}function c(e){try{return fe()?He.API_SetPresenceStatus(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetPresenceStatus(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: SetPresenceStatus",n)}}function u(e){try{return fe()?He.API_CheckBLF(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: CheckBLF(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: CheckBLF",n)}return!1}function g(){try{return fe()?He.API_GetExeVersion():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetVersionNS(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: GetVersionNS",e)}return 0}function h(){try{return fe()?He.API_GetExeVersionNumber():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetVersionNSNum(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: GetVersionNSNum",e)}return 0}function m(){try{return fe()?He.API_GetVersion():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetVersionJava(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: GetVersionJava",e)}return 0}function d(){try{return fe()?He.API_IsEncrypted():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: IsEncrypted(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: IsEncrypted",e)}return 0}function b(e){try{return fe()?He.RegisterEx(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: RegisterEx(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: RegisterEx",n)}}function _(e,n){try{return fe()?He.API_SetSIPHeader(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetSipHeader(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: SetSipHeader",t)}}function f(e,n){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetSipHeader(), no applethandle "),"ERROR, webphone: GetSipHeader(), no applethandle";return He.API_GetSIPHeader(e,n)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: GetSipHeader",t)}return""}function w(e,n){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetSipHeaderInternal(), no applethandle "),"ERROR, webphone: GetSipHeader(), no applethandle";return He.API_GetSipHeaderInternal(e,n)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: GetSipHeaderInternal",t)}return""}function v(e,n,t){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetSipMessage(), no applethandle "),"ERROR, webphone: GetSipMessage(), no applethandle";return He.API_GetSIPMessage(e,n,t)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: GetSipMessage",o)}return""}function E(e,n){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetGetLastInvite(), no applethandle "),"";n(He.API_GetLastInvite(e))}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: GetGetLastInvite",t)}n("")}function P(e,n){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetGetLastRecInvite(), no applethandle "),"";n(He.API_GetGetLastRecInvite(e))}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: GetGetLastRecInvite",t)}n("")}function T(e,n){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetGetLastSentInvite(), no applethandle "),"";n(He.API_GetGetLastSentInvite(e))}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: GetGetLastSentInvite",t)}n("")}function S(){try{return fe()?He.API_GetWorkdir():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetWorkDir(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: GetWorkDir",e)}return""}function N(){try{return fe()?He.API_Unregister():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Unregister(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: Unregister",e)}}function I(){try{return fe()?He.API_ReRegister():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: ReRegister(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: ReRegister",e)}}function C(){try{return fe()?He.API_HTTPKeepAlive():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: HTTPKeepAlive(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: HTTPKeepAlive",e)}}function G(e,n){try{return fe()?He.API_Call(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Call(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: Call",t)}}function L(e){try{return fe()?He.API_Hangup(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Hangup(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Hangup",n)}}function R(e){try{return fe()?He.API_Accept(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Accept(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Accept",n)}}function y(e){try{return fe()?He.API_Reject(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Reject(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Reject",n)}}function D(e){try{return fe()?He.API_Ignore(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Ignore(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Ignore",n)}}function O(e,n){try{return fe()?He.API_Forward(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Forward(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: Forward",t)}}function x(e){try{return fe()?He.API_Conf(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Conference(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Conference",n)}}function A(e,n,t){try{return fe()?He.API_ConfEx(e,n,t):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: ConferenceEx(), no applethandle "),!1)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: ConferenceEx",o)}}function k(e,n){try{return fe()?He.API_Transfer(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Transfer(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: Transfer",t)}}function U(e,n){try{return fe()?He.API_Dtmf(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Dtmf(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: Dtmf",t)}}function V(e,n,t){try{return fe()?He.API_MuteEx(e,n,t):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: MuteEx(), no applethandle "),!1)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: MuteEx",o)}}function W(e){try{return fe()?He.API_IsMuted(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: IsMuted(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: IsMuted",n)}}function F(e,n){try{return fe()?He.API_Hold(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Hold(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: Hold",t)}}function M(e){try{return fe()?He.API_IsOnHold(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: IsOnHold(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: IsOnHold",n)}}function H(e,n,t,o){try{return fe()?He.API_SendChat(e,n,t,o):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SendChat(), no applethandle "),!1)}catch(i){webphone_api.common.PutToDebugLogException(2,"webphone: SendChat",i)}}function B(e,n,t){try{return fe()?He.API_VoiceRecord(e,n,t):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: VoiceRecord(), no applethandle "),!1)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: VoiceRecord",o)}}function j(){try{return fe()?He.API_AudioDevice():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: AudioDevice(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: AudioDevice",e)}}function $(e,n){try{return fe()?He.API_SetVolume(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetVolume(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: SetVolume",t)}}function q(e){try{return fe()?He.API_GetVolume(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetVolume(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: GetVolume",n)}}function z(e,n,t,o,i,a,r){try{return fe()?He.API_PlaySound(e,n,t,o,i,a,r):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: PlaySound(), no applethandle "),!1)}catch(l){webphone_api.common.PutToDebugLogException(2,"webphone: PlaySound",l)}return!1}function K(e,n){var t="";try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetRegFailReason(), no applethandle "),!1;t=He.API_GetRegFailReason(n)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: GetVolume",o)}e(t)}function X(e,n){try{if(!je)return;return webphone_api.common.isNull(webphone_api.global.maintimerid)?(webphone_api.common.PutToDebugLog(3,"EVENT, webphone: SetParameter: cannot set parameter, because webphone is not running"),!1):"callto"!==e&&(fe()?He.API_SetParameter(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetParameter(), no applethandle "),!1))}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: SetParameter",t)}}function J(e){try{if(webphone_api.common.isNull(e)||e<-4||e>35)return webphone_api.common.PutToDebugLog(3,"EVENT, webphone: SetLine: invalid line"),!1;if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetLine(), no applethandle "),!1;He.API_SetLine(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: SetLine",n)}}function Y(e){try{if(webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(3,"EVENT, webphone: SetLineEx: invalid line"),!1;if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetLineEx(), no applethandle "),!1;He.API_SetLineEx(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: SetLine",n)}}function Q(){try{return fe()?He.API_GetLine():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetLine(), no applethandle "),-1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: GetLine",e)}return-1}function Z(e){try{return fe()?He.API_LineToCallID(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: LineToCallID(), no applethandle "),-1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: LineToCallID",n)}return""}function ee(e){try{return fe()?He.API_CallIDToLine(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: CallIDToLine(), no applethandle "),-1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: CallIDToLine",n)}return-10}function ne(e){try{return fe()?He.API_NextCallID(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: NextCallID(), no applethandle "),-1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: NextCallID",n)}return""}function te(e){try{return fe()?He.API_GetLineDetails(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetLineDetails(), no applethandle "),"")}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: GetLineDetails",n)}return""}function oe(){try{return fe()?He.API_IsRegistered():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: IsRegistered(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: IsRegistered",e)}}function ie(e){try{return fe()?He.API_GetAudioDeviceList(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetAudioDeviceList(), no applethandle "),"")}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: GetAudioDeviceList",n)}}function ae(e){try{return fe()?He.API_GetAudioDevice(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetAudioDevice(), no applethandle "),"")}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: GetAudioDevice",n)}}function re(e,n,t){try{return fe()?He.API_SetAudioDevice(e,n,t):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetAudioDevice(), no applethandle "),!1)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: SetAudioDevice",o)}}function le(e,n,t,o){try{return fe()?He.API_SetPushNotifications(e,n,t,o):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetPushNotifications(), no applethandle "),!1)}catch(i){webphone_api.common.PutToDebugLogException(2,"webphone: SetPushNotifications",i)}}function se(){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Exit(), no applethandle "),!1;var e=He.API_Exit();return webphone_api.common.isNull(e)&&(e=!1),webphone_api.common.PutToDebugLog(3,"EVENT, webphone: Exit result: "+e.toString()),e}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Exit",n)}}function pe(e,n){try{return fe()?He.API_SendChatIsComposing(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SendChatIsComposing(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: SendChatIsComposing",t)}}function ce(e){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: NeedRatingRequest(), no applethandle "),e(!1),!1;e(He.API_NeedRatingRequest())}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: NeedRatingRequest",n)}}function ue(){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetLastCallDetails(), no applethandle "),webphone_api.global.lastcalldetails;var e=He.API_GetLastCallDetails();if(!webphone_api.common.isNull(e)&&e.length>0){var n=e.split(",");webphone_api.common.isNull(n)&&(n="");for(var t="",o=0;o<n.length;o++)webphone_api.common.isNull(n[o])||n[o].length<1||(t.length>0&&(t+="<br>"),t+=webphone_api.common.Trim(n[o]));if(t.length>0)return t}}catch(i){webphone_api.common.PutToDebugLogException(2,"webphone: GetLastCallDetails",i)}return webphone_api.global.lastcalldetails}function ge(){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetIncomingDisplay(), no applethandle "),"";var e=He.API_GetIncomingDisplay();return webphone_api.common.PutToDebugLog(5,"EVENT, webphone: API_GetIncomingDisplay: "+e),e}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: GetIncomingDisplay",n)}return""}function he(e){try{return fe()?He.API_DelSettings(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: DelSettings(), no applethandle "),"")}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: DelSettings",n)}return""}function me(e,n){try{if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Jvoip(), no applethandle "),!1;He[e].apply(He,n)}else if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE){var t=null,o=null,i=null,a=null,r=null,l=null,s=null,p=null,c=null;if(!webphone_api.common.isNull(n)&&n.length>0)for(var u=0;u<n.length;u++)0===u&&(t=n[0]),1===u&&(o=n[1]),2===u&&(i=n[2]),3===u&&(a=n[3]),4===u&&(r=n[4]),5===u&&(l=n[5]),6===u&&(s=n[6]),7===u&&(p=n[7]),8===u&&(c=n[8]);webphone_api.common.WinAPI(e,null,t,o,i,a,r,l,s,p,c)}}catch(g){webphone_api.common.PutToDebugLogException(2,"webphone: Jvoip",g)}}function de(){try{if(webphone_api.global.apppletloaded)return;return webphone_api.global.apppletloaded=!0,webphone_api.common.PutToDebugLog(2,"EVENT, webphone LoadApplet called"),window.attributes=Ue,window.parameters=Ke,mwpdeploy.runApplet(Ue,Ke,"1.5"),$e=webphone_api.common.GetParameterBool("isfirststart",!0),Me=!0,!0}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: LoadApplet",e)}}function be(e){try{webphone_api.common.PutToDebugLog(2,"EVENT, webphone LoadApplet InsertApplet called"),webphone_api.$("#wpappletconatiner").remove();var n='<div id="wpappletconatiner" style="z-index:10000; position:absolute; float:left; top:0; left:0; line-height: 1px; font-size: 1px;">'+e+"</div>";webphone_api.$("body").append(n),webphone_api.common.PutToDebugLog(2,"EVENT, webphone LoadApplet InsertApplet inserted")}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: InsertApplet",t)}}function _e(){if(Be>20)return void webphone_api.common.PutToDebugLog(2,"ERROR, waitForWebphone maxloop elapsed");if(webphone_api.global.useengine.length>0&&"java"!==webphone_api.global.useengine)return void webphone_api.common.PutToDebugLog(2,"ERROR, waitForWebphone useengine not set or incorrect: "+webphone_api.global.useengine);if(webphone_api.common.GetTickCount()-on>45e3&&webphone_api.global.phonestarted<3){var e=100;if(!1===webphone_api.common.IsSDK()){var t=webphone_api.$.mobile.activePage.attr("id");if(!webphone_api.common.isNull(t)&&t.indexOf("_settings")>0)return void setTimeout(function(){_e()},1e3);e=webphone_api.common.GetDeviceWidth(),!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)||(e=200)}webphone_api.common.PutToDebugLog(2,"WARNING, waitForWebphone display Applet, because no handle found_1");var o=webphone_api.common.GetDeviceHeight();webphone_api.common.isNull(o)&&(o=200),webphone_api.$("#webphone").css("position","absolute"),webphone_api.$("#webphone").css("top","100px"),webphone_api.$("#webphone").width(e),webphone_api.$("#webphone").height(o-100)}if(!1===webphone_api.global.applet_started&&webphone_api.global.phonestarted<3)return void setTimeout(function(){_e()},250);if((webphone_api.common.isNull(nn)||webphone_api.common.isNull(tn)||nn<10||tn<10)&&(nn=webphone_api.common.GetDeviceWidth(),(webphone_api.common.isNull(nn)||webphone_api.common.isNull(tn)||nn<50||tn<50)&&(nn=150,tn=100)),Be++,je=fe())setTimeout(function(){webphone_api.$("#webphone").width(1),webphone_api.$("#webphone").height(1)},10),webphone_api.global.phonestarted<2&&(webphone_api.global.phonestarted=2),webphone_api.common.isNull(document.getElementById("javaerrormsg"))||(document.getElementById("javaerrormsg").style.display="none"),Be=0,webphone_api.common.SaveParameter("isfirststart","false"),n(),webphone_api.common.PutToDebugLog(2,"EVENT, appletAvailable: "+je),r();else{var i=0;if(i=!0===$e?25:50,Be>=i&&webphone_api.global.phonestarted<3){webphone_api.common.PutToDebugLog(2,"WARNING, waitForWebphone display Applet, because no handle found_2");var o=webphone_api.common.GetDeviceHeight();webphone_api.common.isNull(o)&&(o=200),webphone_api.$("#webphone").css("position","absolute"),webphone_api.$("#webphone").css("top","100px"),webphone_api.$("#webphone").width(nn-1),webphone_api.$("#webphone").height(o-100),webphone_api.common.isNull(document.getElementById("javaerrormsg"))||(document.getElementById("javaerrormsg").style.display="block")}setTimeout(function(){_e()},450)}}function fe(){if(!1===webphone_api.global.applet_started)return!1;if(null===He||void 0===He){try{He=document.getElementById("webphone")}catch(r){}if(null==He){var e=null;try{e=document.applets,0==e.length&&(e=document.getElementsByTagName("object")),0==e.length&&(e=document.getElementsByTagName("applet"));for(var n=0;n<e.length;++n)try{if("undefined"!=typeof e[n].API_Call){He=e[n];break}}catch(r){}}catch(r){}if(null==He)try{He=document.applets[0]}catch(r){}null==He&&webphone_api.common.PutToDebugLog(3,"ERROR, webphone: initcheck(), cannot find applet handle")}if(null!=He)try{var t=He.getSubApplet();null!=t&&(He=t)}catch(r){}}var o="",i=navigator.userAgent.toLowerCase();try{if(null==He)return!1;if(void 0!==He&&(o=He.toString()),i.indexOf("msie")>0||i.indexOf("trident")>0)for(var a in He)if("contentDocument"===a){if(null==He)return!1;o=He[a].toString();break}}catch(r){webphone_api.common.PutToDebugLogException(2,"ERROR, webphone: initcheck",r)}return null==o||""==o||o.toLowerCase().indexOf("[object")>=0&&o.toLowerCase().indexOf("[object")<5?(He=null,!1):(webphone_api.webphone_handle=He,!0)}function we(e,n,t,o,i){try{return fe()?He.API_SetCredentials(e,n,t,o,i):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_SetCredentials(), no applethandle "),!1)}catch(a){
webphone_api.common.PutToDebugLogException(2,"webphone: API_SetCredentials",a)}}function ve(e,n,t,o){try{return fe()?He.API_SetCredentials(e,n,t,o):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_SetCredentialsMD5(), no applethandle "),!1)}catch(i){webphone_api.common.PutToDebugLogException(2,"webphone: API_SetCredentialsMD5",i)}}function Ee(e){try{return fe()?He.API_CheckVoicemail(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_CheckVoicemail(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_CheckVoicemail",n)}}function Pe(e){try{return fe()?He.API_SetLine(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_SetLine(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_SetLine",n)}}function Te(e){try{return fe()?He.API_GetLine(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_GetLine(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_GetLine",n)}}function Se(e){try{return fe()?He.API_GetLineStatus(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_GetLineStatus(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_GetLineStatus",n)}}function Ne(e,n){try{return fe()?He.API_Forward(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_Forward(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: API_Forward",t)}}function Ie(e){try{return fe()?He.API_IsMuted(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_IsMuted(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_IsMuted",n)}}function Ce(e){try{return fe()?He.API_IsOnHold(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_IsOnHold(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_IsOnHold",n)}}function Ge(e){try{return fe()?He.API_GetAudioDeviceList(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_GetAudioDeviceList(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_GetAudioDeviceList",n)}}function Le(e){try{return fe()?He.API_GetAudioDevice(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_GetAudioDevice(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_GetAudioDevice",n)}}function Re(e){try{return fe()?He.API_SetAudioDevice(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_SetAudioDevice(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_SetAudioDevice",n)}}function ye(e){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_GetVolume(), no applethandle "),!1;var n=He.API_GetVolume(e);return webphone_api.common.PutToDebugLog(2,"webphone: GetVolume java returned: "+n.toString()),n}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: API_GetVolume",t)}}function De(){try{return fe()?He.API_RecFiles_Upload():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_RecFiles_Upload(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: API_RecFiles_Upload",e)}return!1}function Oe(e,n){try{return fe()?He.API_RecFiles_UploadEx(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_RecFiles_UploadEx(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: API_RecFiles_UploadEx",t)}return!1}function xe(){try{return fe()?He.API_RecFiles_Clear():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_RecFiles_Clear(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: API_RecFiles_Clear",e)}return!1}function Ae(){try{return fe()?He.API_RecFiles_Del():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_RecFiles_Del(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: API_RecFiles_Del",e)}return!1}var ke=webphone_api.getbasedir2()+"native",Ue={id:"webphone",code:"webphone.webphone.class",name:"webphone",archive:"webphone.jar",codebase:ke,width:1,height:1,MAYSCRIPT:!0},Ve="X-Webdomain: "+webphone_api.common.GetWebdomain(),We=webphone_api.common.GetParameter("companyname");!webphone_api.common.isNull(We)&&We.length>0&&(Ve=Ve+"\r\nX-Company: "+We);var Fe=webphone_api.common.GetParameter("brandname");!webphone_api.common.isNull(Fe)&&Fe.length>0&&(Ve=Ve+"\r\nX-Brand: "+Fe);var Me,He,Be,je,$e,qe,ze,Ke={serveraddress:"",username:"",MAYSCRIPT:!0,mayscript:"yes",scriptable:!0,jsscriptevent:3,autocfgsave:3,align:"middle",customsipheader:Ve,loglevel:3,canopenlogview:!1,hasincomingcall:!1,textmessaging:-1,pluginspage:"https://java.com/download/",permissions:"all-permissions",alt:"Enable or install java: https://www.java.com/en/download/index.jsp",java_arguments:"-Dsun.net.maxDatagramSockets=256"},Xe=300,Je=8e3,Ye=null,Qe=!1,Ze=0,en=null,nn=0,tn=0,on=0;return webphone_api.webphone_handle=He,webphone_api.webphone_pollstatus=!0,{InsertApplet:be,Start:t,StartWin:i,StartService:a,LoadApplet:de,Restart:l,PushContactlist:s,StartPresence:r,CheckPresence:p,SetPresenceStatus:c,CheckBLF:u,GetVersionNS:g,GetVersionNSNum:h,GetVersionJava:m,IsEncrypted:d,RegisterEx:b,SetSipHeader:_,GetSipHeader:f,GetSipHeaderInternal:w,GetSipMessage:v,GetGetLastInvite:E,GetGetLastRecInvite:P,GetGetLastSentInvite:T,GetWorkDir:S,Unregister:N,ReRegister:I,HTTPKeepAlive:C,Call:G,Hangup:L,Accept:R,Reject:y,Ignore:D,Forward:O,Conference:x,ConferenceEx:A,Transfer:k,Dtmf:U,MuteEx:V,IsMuted:W,Hold:F,IsOnHold:M,SendChat:H,VoiceRecord:B,AudioDevice:j,SetVolume:$,GetVolume:q,PlaySound:z,GetRegFailReason:K,SetParameter:X,SetLine:J,SetLineEx:Y,GetLine:Q,LineToCallID:Z,CallIDToLine:ee,NextCallID:ne,GetLineDetails:te,IsRegistered:oe,GetAudioDeviceList:ie,GetAudioDevice:ae,SetAudioDevice:re,SetPushNotifications:le,Exit:se,NeedRatingRequest:ce,Jvoip:me,GetLastCallDetails:ue,GetIncomingDisplay:ge,DelSettings:he,API_SetCredentials:we,API_SetCredentialsMD5:ve,API_CheckVoicemail:Ee,API_SetLine:Pe,API_GetLine:Te,API_GetLineStatus:Se,API_Forward:Ne,API_IsMuted:Ie,API_IsOnHold:Ce,API_GetAudioDeviceList:Ge,API_GetAudioDevice:Le,API_SetAudioDevice:Re,API_GetVolume:ye,API_RecFiles_Upload:De,API_RecFiles_UploadEx:Oe,API_RecFiles_Clear:xe,API_RecFiles_Del:Ae,SendChatIsComposing:pe}}(),webphone_api.notifications=function(){function e(){var e=0;try{e=1,webphone_api.global.creditRequestIval=100,webphone_api.global.closeCallAtivity=!1,_=!1,g=0,e=2;var n=webphone_api.common.GetTickCount();S=n,N=n,I=n,h=0,m=!1,d=!1,Ne="",b="",webphone_api.global.last_event="",L=n,webphone_api.global.httpkatimer=n,webphone_api.global.audio_devices_loaded=!1,e=3;var t=webphone_api.common.GetAudioRecList();!webphone_api.common.isNull(t)&&t.length>5&&(webphone_api.global.audio_devices_loaded=!0),e=4,webphone_api.global.lastcallduration=0,y=-1,D=n,x=n,j=null,$="",q="",z="",K="",X="";var o=webphone_api.common.GetParameter2("ringtimeout"),i=webphone_api.common.GetParameter2("ringtimeoutin"),a=webphone_api.common.GetParameter2("ringtimeoutout"),r=webphone_api.common.GetParameter2("calltimeout");if(e=5,(webphone_api.common.isNull(o)||o.length<2||!1===webphone_api.common.IsNumber(o))&&(o=9e4),(webphone_api.common.isNull(i)||i.length<2||!1===webphone_api.common.IsNumber(i))&&(i=0),(webphone_api.common.isNull(a)||a.length<2||!1===webphone_api.common.IsNumber(a))&&(a=0),(webphone_api.common.isNull(r)||r.length<2||!1===webphone_api.common.IsNumber(r))&&(o=108e5),e=6,k=webphone_api.common.StrToInt(o),U=webphone_api.common.StrToInt(i),V=webphone_api.common.StrToInt(a),W=webphone_api.common.StrToInt(r),e=7,webphone_api.global.ringstart_time=0,webphone_api.global.callstart_time=0,webphone_api.global.useajax_forservice=!1,webphone_api.global.wsuser_succeded=!1,F=!1,webphone_api.global.acallcount=0,webphone_api.global.enstarteddisplayed=!1,M=!1,Se=0,webphone_api.global.httpheaderslogged=!1,webphone_api.global.onregisteredcalled=!1,webphone_api.global.wsc_contimeout=0,webphone_api.global.wsc_reqtimeout=0,webphone_api.global.firstregister_sessiontick=0,e=8,webphone_api.common.isNull(document.getElementById("loader")))if(e=9,webphone_api.common.PutToDebugLog(2,"EVENT, init adding loader iframe, because not found in page"),webphone_api.common.isNull(document.body))webphone_api.common.PutToDebugLog(2,"ERROR, init adding loader iframe, document.body is NULL");else{e=10;var l=document.createElement("iframe");l.style.display="none",l.style.height="0",l.style.width="0",l.id="loader",l.setAttribute("allow","microphone; camera; autoplay"),e=11,document.body.appendChild(l)}}catch(s){webphone_api.common.PutToDebugLogException(2,"notifications: Init "+e,s)}}function n(t){var s=0;try{if(webphone_api.common.CanLog(7)&&webphone_api.common.PutToDebugLog(7,"PROCESSING_NOTIFICATIONS: "+t),webphone_api.global.initcalled||(webphone_api.global.initcalled=!0,e()),!webphone_api.common.isNull(t)&&t.length>0)try{t=t.toString();var g=t.split(",");if(!webphone_api.common.isNull(g)&&g.length>0){for(var h="",S=0;S<g.length;S++)webphone_api.common.isNull(g[S])&&(g[S]=""),g[S]=webphone_api.common.Trim(g[S]),0===g[S].indexOf("_BASE64_")&&(g[S]=webphone_api.common.B64Dec(g[S]),webphone_api.common.isNull(g[S])&&(g[S]=""),g[S]=webphone_api.common.Trim(g[S])),h.length>0&&(h+=","),h+=g[S];!webphone_api.common.isNull(h)&&h.length>0&&(t=h)}}catch(rt){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications base64 decode",rt)}if(le<0&&(le=webphone_api.common.IsCExt()),webphone_api.common.isNull(te)&&webphone_api.common.getuseengine().length>0&&(te=webphone_api.common.Te2(),webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC&&(te=!1),te)){var N=[];N.push("L"),N.push("i"),N.push("m"),N.push("i"),N.push("t"),N.push(" "),N.push("f"),N.push("u"),N.push("n"),N.push("c");var I=N.join("");setTimeout(function(){webphone_api.common.PutToDebugLog(3,"EVENT, "+I)},920),N=[],N.push("S"),N.push("T"),N.push("A"),N.push("T"),N.push("U"),N.push("S"),re=N.join("")}if(te&&!webphone_api.common.isNull(re)&&re.length>0){var L="";if(!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0)for(var S=0;S<webphone_api.global.ep.length;S++)if(!webphone_api.common.isNull(webphone_api.global.ep[S][webphone_api.common.EP_CALLID])&&webphone_api.global.ep[S][webphone_api.common.EP_CALLID].length>3){L=webphone_api.global.ep[S][webphone_api.common.EP_CALLID];break}!webphone_api.common.isNull(L)&&L.length>3&&!1===p(L)&&!webphone_api.common.isNull(t)&&t.indexOf(re)>=0&&(t=t.toString(),t=t.replace(re,""),t=webphone_api.common.Trim(t),t=t.substring(1),t=webphone_api.common.Trim(t))}if(s=10,!_){webphone_api.global.presence_started=!1,_=!0,webphone_api.common.isNull(webphone_api.global.maintimerid)||clearInterval(webphone_api.global.maintimerid),webphone_api.global.maintimerid=null,webphone_api.global.maintimerid=setInterval(function(){o()},C),webphone_api.common.LcAc(!0,!1),s=14;try{if(0==webphone_api.common.IsSDK()){var D=webphone_api.common.GetColortheme(),O=webphone_api.themes.gettheme("theme_"+D);if(webphone_api.common.isNull(O))R="#ffffff";else{var x=O.fontcstatus;R=webphone_api.common.isNull(x.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?"#ffffff":x}}}catch(lt){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications at init 1",lt)}}if(s=20,webphone_api.common.isNull(t))return;if(t=t.toString(),t=webphone_api.common.Trim(t),t.length<1)return;if(t=t.replace("NORETRY",""),Q=t,0===Q.indexOf("START")&&(Q.indexOf("api")>0||Q.indexOf("sip")>0)&&(webphone_api.global.apistartstate=2,webphone_api.plhandler.GetAudioDevicesForMenu(100)),!1===webphone_api.global.applet_started&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&"START,api"===Q){webphone_api.global.applet_started=!0,s=24;var A=webphone_api.common.GetParameter2("serveraddress_user");if((webphone_api.common.isNull(A)||A.length<2)&&(A=webphone_api.common.GetParameter2("serveraddress")),(webphone_api.common.isNull(A)||A.length<2)&&webphone_api.common.PutToDebugLog(2,"EVENT, notifications ProcessNotifications serveraddress not set"),!1===webphone_api.global.usestorage&&!webphone_api.common.CheckDID(A,!1)){var N=[];N.push("E"),N.push("R"),N.push("R"),N.push("O"),N.push("R"),N.push(","),N.push("S"),N.push("e"),N.push("r"),N.push("v"),N.push("e"),N.push("r"),N.push(" "),N.push("n"),N.push("o"),N.push("t"),N.push(" "),N.push("a"),N.push("l"),N.push("l"),N.push("o"),N.push("w"),N.push("e"),N.push("d"),N.push("_"),N.push("3");var I=N.join("");return s=26,void setTimeout(function(){webphone_api.common.PutToDebugLog(1,I+" "+A)},1251)}}if(s=30,Q.indexOf("CHATCOMPOSING")>=0){var k=0,U="",V=Q.indexOf(",");if(V>0&&(s=32,Q=Q.substring(V+1),(V=Q.indexOf(","))>0&&(s=34,k=webphone_api.common.Trim(Q.substring(0,V)),Q=Q.substring(V+1),(V=Q.indexOf(","))>0))){s=36,U=webphone_api.common.Trim(Q.substring(0,V));var W=webphone_api.common.Trim(Q.substring(V+1));!webphone_api.common.isNull(W)&&webphone_api.common.IsNumber(W)&&1===webphone_api.common.StrToInt(W)&&(s=39,l(U+" "+webphone_api.stringres.get("composing")+"...","EVENT",1,-1))}return}if(s=40,Q.indexOf("SERVERCONTACTS")>=0){if(webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, notifications: "+Q),Q.toLowerCase().indexOf("error")>=0)return void webphone_api.common.PutToDebugLog(2,"ERROR, notifications: "+Q);s=44;var M="",V=0;V=Q.indexOf(","),V>0&&(M=webphone_api.common.Trim(Q.substring(V+1,Q.length))),s=48,webphone_api.common.SaveParameter("servercontacts",M),!webphone_api.common.isNull(M)&&M.length>0&&webphone_api.common.PutToDebugLog(2,"EVENT, servercontacts list: "+M)}if(s=50,Q.indexOf("PRESENCE")>=0&&!0===webphone_api.common.UsePresence2()){if(webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, notifications: "+Q),Q.toLowerCase().indexOf("error")>=0)return void webphone_api.common.PutToDebugLog(2,"ERROR, notifications: "+Q);var H="",V=0;if(V=Q.indexOf(","),s=54,V>0){H=webphone_api.common.Trim(Q.substring(V+1,Q.length));var B="",X="",se="",pe="",ce="",he=H.split(",");if(!webphone_api.common.isNull(he)&&he.length>1){B=webphone_api.common.Trim(he[0]),X=webphone_api.common.Trim(he[1]),he.length>2&&(se=webphone_api.common.Trim(he[2])),he.length>3&&(pe=webphone_api.common.Trim(he[3])),he.length>4&&(ce=webphone_api.common.Trim(he[4]));var me="-1";(webphone_api.common.isNull(se)||se.length<1)&&(se=X),me=webphone_api.common.SaveReceivedPresence2(B,se),"-2"===me&&X.length>1&&se!==X&&(me=webphone_api.common.SaveReceivedPresence2(B,X));try{webphone_api.onPresenceCb(B,X,pe,ce)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onPresenceStateChange() callback",st)}s=58,!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._dialpad)||webphone_api._dialpad.PopulateListRecents(),s=59,!0!==webphone_api.global.isContactdetailsStarted||!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._contactdetails)||webphone_api._contactdetails.PopulateData(),!0===webphone_api.global.isMessageStarted&&webphone_api._message.DisplayPresence(me)}}}if(Q.indexOf("BLF")>=0&&webphone_api.common.GetParameterInt("enableblf",1)>0){if(webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, notifications: "+Q),Q.toLowerCase().indexOf("error")>=0)return void webphone_api.common.PutToDebugLog(2,"ERROR, notifications: "+Q);var de="",V=0;if(V=Q.indexOf(","),s=54,V>0){de=webphone_api.common.Trim(Q.substring(V+1,Q.length));var B="",_e="",X="",fe="",we=de.split(",");if(!webphone_api.common.isNull(we)&&we.length>1){B=webphone_api.common.Trim(we[0]),_e=webphone_api.common.Trim(we[1]),we.length>2&&(X=webphone_api.common.Trim(we[2])),we.length>3&&(fe=webphone_api.common.Trim(we[3]));try{webphone_api.onBLFCb(B,_e,X,fe)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onBLFStateChange() callback",st)}}}}s=60,J="",Y="";var V=0;if("["===Q.charAt(0)&&(V=Q.indexOf("]"))>0&&(Q=webphone_api.common.Trim(Q.substring(V+1,Q.length))),s=63,V=Q.indexOf(","),V>0?(J=webphone_api.common.Trim(Q.substring(0,V)),Q=webphone_api.common.Trim(Q.substring(V+1,Q.length))):J="EVENT",s=65,"ANSWER"===J)return s=69,void webphone_api.common.HttpAsyncHandler(Q);if(s=70,"DTMF"===J){var ve=-1,Ee=t,Pe=Ee.indexOf(",");Pe>0&&(Ee=Ee.substring(Pe+1),(Pe=Ee.indexOf(","))>0&&(Ee=webphone_api.common.Trim(Ee.substring(0,Pe)),!webphone_api.common.isNull(Ee)&&webphone_api.common.IsNumber(Ee)&&(ve=webphone_api.common.StrToInt(Ee))));try{webphone_api.onDTMFCb(Q,ve)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onDTMF() callback",st)}}if("STATUS"===J||"CDR"===J||"CHAT"===J||"SUBSCRIBE"===J||"NOTIFY"===J||"EVENT"===J||"ERROR"===J||"WARNING"===J||"POPUP"===J||"CREDIT"===J||"RATING"===J||"MWI"===J||"START"===J||"VREC"===J||"DTMF"===J||"REGISTER"===J||"PRESENCE"===J||"CHATREPORT"===J||"CHATCOMPOSING"===J||"BLF"===J||"LINE"===J||"STOP"===J||"LINEDETAILS"===J||"QRCODE"===J||"NOTIFICATION"===J||"GROUP"===J||"RTPSTAT"===J||"INFO"===J||"SHOULDRESET"===J||"PLAYREADY"===J||"VAD"===J||"SERVERCONTACTS"===J||"NEWUSER"===J||"ANSWER"===J||"LICKEY"===J||"USSD"===J||"SIP"===J||"BLOCK"===J||"RTPE"===J||"SRS"===J||"VIDEO"===J||"XXX"===J||"XXX"===J||"XXX"===J){s=71;try{webphone_api.onEventCb("event",t,null)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an ERROR in onEvent() callback at notification: "+t,st)}try{webphone_api.RecEvt(t)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an ERROR at the onEvents() callback in your code (triggered by notification: "+t+")",st)}try{le>0&&"undefined"!=typeof AndroidWebphoneJsInterface&&null!==AndroidWebphoneJsInterface&&"undefined"!=typeof AndroidWebphoneJsInterface.jstoandroidEvents&&null!==AndroidWebphoneJsInterface.jstoandroidEvents&&AndroidWebphoneJsInterface.jstoandroidEvents(t)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications AndroidWebphoneJsInterface send",st)}}else if("LOG"!==J)return s=74,void(!1===te&&webphone_api.common.PutToDebugLog(5,"EVENT, unknown notification a: "+t));if(t.indexOf("-1,Stop")>=0&&webphone_api.global.phonestarted>0&&webphone_api.common.OpenSettings(!0,8),"GROUP"===J&&Q.toLowerCase().indexOf("error")<0&&!1===webphone_api.common.IsSDK())try{var Te=Q.split(",");if(!webphone_api.common.isNull(Te)&&Te.length>2){var Se=Te[2];!webphone_api.common.isNull(Se)&&Se.length>0&&webphone_api.global.isCallStarted&&(webphone_api.common.PutToDebugLog(2,"EVENT, Group conference update peers to: "+Se),webphone_api.$("#page_call_additional_info").html(Se),webphone_api.$("#page_call_peer_details").html(""),webphone_api.$("#page_call_peer_details").hide(),webphone_api.$("#display_notmain_account").html(""),webphone_api.$("#display_notmain_account").hide(),webphone_api.$("#contact_image_img").attr("src",webphone_api.common.GetElementSource()+"images/default_contact_conf.png"))}}catch(pt){webphone_api.common.PutToDebugLogException(2,"notifications ProcessNotifications handle group conference",pt)}if("QRCODE"===J)webphone_api.common.ParseQRcode(Q);else if("LOG"===J)Q.indexOf("mzserver detected")>=0&&(Q.indexOf("gw")>=0?2==webphone_api.common.ismizuserverdetected?webphone_api.common.ismizuserverdetected=3:webphone_api.common.ismizuserverdetected=1:Q.indexOf("both")>=0?webphone_api.common.ismizuserverdetected=3:1==webphone_api.common.ismizuserverdetected?webphone_api.common.ismizuserverdetected=3:webphone_api.common.ismizuserverdetected=2);else if("CHATREPORT"===J){var Ne=Q.split(",");if(!webphone_api.common.isNull(Ne)&&Ne.length>5){var Ie=Ne[1],Ce=Ne[2],Ge=Ne[5];if(webphone_api.common.isNull(Ie)&&(Ie=""),Ie=webphone_api.common.Trim(Ie),Ie=Ie.toLowerCase(),webphone_api.common.isNull(Ce)&&(Ce=""),Ce=webphone_api.common.Trim(Ce),webphone_api.common.isNull(Ge)&&(Ge=""),Ge=webphone_api.common.Trim(Ge),"2"==Ce||"4"==Ce){var Le="chat_"+webphone_api.common.GetSipusername(!0)+"_"+Ie;Ie.length>0&&Ce.length>0&&Ge.length>0&&(Ge=Ge.toLowerCase(),webphone_api.common.IsWindowsSoftphone()?webphone_api.common.ApiWinLoadFile(Le,function(e){webphone_api.common.isNull(e)&&(e=""),r(Le,Ce,Ge,e,Ie)}):webphone_api.File.ReadFile(Le,webphone_api.global.STORAGE_LOCAL,function(e){webphone_api.common.isNull(e)&&(e=""),r(Le,Ce,Ge,e,Ie)}))}}}else if("LINEDETAILS"===J){var Re=Q.split(",");if(!webphone_api.common.isNull(Re)&&Re.length>10){webphone_api.common.PutToDebugLog(2,"EVENT, update ep from received LINEDETAILS notification");var ye=Re[0],De=Re[3],Oe=Re[2],xe=Re[5],Ae=Re[8],ke=Re[9],Ue="";Re.length>10&&(Ue=Re[10]),webphone_api.common.SaveCallSession(11,ye,null,De,xe,-1,-1,-1,null,Oe,"","","",Ae,ke,null,null,null,Ue)}}else if("LINE"===J){var Ve=-20,We=Q,V=We.indexOf(",");if(V>0&&(We=We.substring(0,V)),We=webphone_api.common.Trim(We),webphone_api.common.IsNumber(We)&&(Ve=webphone_api.common.StrToInt(We)),Ve>-5)return void webphone_api.common.SetALineInternal(Ve,1)}else if("STATUS"===J){webphone_api.global.apistartstate=2,b=Q;var Fe=c(t,-1);webphone_api.global.lnstat[Fe]=[webphone_api.common.GetTickCount(),Q]}else("STATUS"===J||"EVENT"===J)&&Q.toLowerCase().indexOf("permission")<0&&(webphone_api.global.last_event=Q);if(!0===webphone_api.common.Glbr()&&"CREDIT"===J)T=!0,webphone_api.global.credit=" "+Q;else if(!0===webphone_api.common.Glbr()&&"RATING"===J)s=82,webphone_api.global.rating=" ("+webphone_api.common.Trim(Q)+")";else if("MWI"===J&&(s=83,!webphone_api.common.isNull(Q)&&Q.length>0&&Q.indexOf(",")>=0)){var Me=Q.split(",");if(!webphone_api.common.isNull(Me)&&Me.length>=2)if("no"===Me[0])s=85,60===webphone_api.common.GetConfigInt("brandid",-1)?webphone_api.common.SetNotCounter("dialpad_message_counter","0"):webphone_api.common.SetNotCounter("dialpad_voicemail_counter","0");else{s=87;var He=Me[3];webphone_api.common.isNull(He)&&(He=""),He=webphone_api.common.Trim(He),He.length>0&&webphone_api.common.IsNumber(He)&&(s=88,webphone_api.common.PutToDebugLog(3,"EVENT, New voicemail messages found: "+He),60===webphone_api.common.GetConfigInt("brandid",-1)?webphone_api.common.SetNotCounter("dialpad_message_counter",He):webphone_api.common.SetNotCounter("dialpad_voicemail_counter",He))}}s=90;var Be=Q.indexOf("POPUP");if(Be>=0){var je=Q.substring(Be+5);je=webphone_api.common.Trim(je),Be=je.indexOf(","),Be>=0&&(je=je.substring(Be+1)),s=94,!webphone_api.common.isNull(je)&&je.length>0&&webphone_api.common.ShowToast(je,5e3)}if(V=Q.indexOf(","),Q=webphone_api.common.Trim(Q),V>0&&(Q=webphone_api.common.Trim(Q.substring(V+1,Q.length))),s=96,V=Q.indexOf(","),V>0?(Y=webphone_api.common.Trim(Q.substring(0,V)),Q=webphone_api.common.Trim(Q.substring(V+1,Q.length))):Y=Q,s=100,V=Y.indexOf("("),V>0&&Y.indexOf(ie)<0&&Y.indexOf(ae)<0&&(Y=webphone_api.common.Trim(Y.substring(0,V))),Y.length<1&&!1===te)return void webphone_api.common.PutToDebugLog(5,"WARNING, unknown notification b: "+t);if(Q.length<1&&!1===te)return void webphone_api.common.PutToDebugLog(5,"WARNING, unknown notification c: "+t);if(s=110,"CDR"===J&&(webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, notifications: ProcessNotifications CDR received: "+t),webphone_api.global.lastcallcdr=t,(V=t.indexOf(","))>0))try{s=115;var $e=t.split(","),qe=$e[1],B=$e[2],ze=$e[3],Ke=$e[4],Xe=($e[5],$e[6]),Je=$e[7],Ye=$e[8],Qe=$e[9],fe="";$e.length>10&&(fe=$e[10]);$e.length>11&&$e[11],Ye.length<1&&(Ye="0");var Ze=2;"1"==_e?Ze=1:"2"==_e?Ze=2:B===Ke&&(Ze=1);var _e="incoming";1===Ze&&(_e="outgoing");var en="";en=1==Ze?Ke:ze,webphone_api.common.isNull(Qe)&&(Qe=""),Qe.indexOf("[")>0&&(Qe=Qe.substring(0,Qe.indexOf("["))),s=120,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.common.GetDiscReasonFromSignaling(function(e){(webphone_api.common.isNull(e)||e.length<2)&&(e=Qe),!0===webphone_api.global.dontshowdiscreason?webphone_api.common.PutToDebugLog(2,"EVENT, "+webphone_api.stringres.get("disc_reason")+": "+e):(webphone_api.common.PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("disc_reason")+": "+e),l(webphone_api.stringres.get("disc_reason")+": "+e,"EVENT",0,webphone_api.common.StrToIntDef(qe,-1),2)),webphone_api.common.RemoveSessionHeadersFromCache(webphone_api.common.StrToIntDef(qe,-1))}),webphone_api.common.RemoveSessionHeadersFromCache(webphone_api.common.StrToInt(qe)),webphone_api.global.lastcalldetails="",webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_GetLastCallDetails",null),s=124;var nn="<br>";if(webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Line: "+qe+", Direction: "+_e+nn,webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Auth Username: "+webphone_api.common.GetSipusername()+nn,2===Ze?(webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Caller: "+ze+nn,ze!==B?webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Caller Name: "+B+nn:ze!==en&&(webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Caller Name: "+en+nn)):webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Caller ID: "+webphone_api.common.GetCallerid()+nn,s=128,webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Connecttime: "+Xe+" msec"+nn,webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Duration: "+Je+" msec"+nn,webphone_api.global.lastcalldetails="1"===Ye?webphone_api.global.lastcalldetails+"Disconnect By: Local"+nn:webphone_api.global.lastcalldetails+"Disconnect By: Remote"+nn,webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Reason: "+Qe+nn,webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"CDR: "+webphone_api.global.lastcallcdr+nn,webphone_api.common.getuseengine===webphone_api.global.ENGINE_WEBRTC){var tn=webphone_api.common.ReplaceAll(webphone_api.global.lastcalldetails,nn,"\n");setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, Call details:\n"+tn)},1)}webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC&&(!0===webphone_api.global.dontshowdiscreason?webphone_api.common.PutToDebugLog(2,"EVENT, "+webphone_api.stringres.get("disc_reason")+": "+Qe):(webphone_api.common.PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("disc_reason")+": "+Qe),l(webphone_api.stringres.get("disc_reason")+": "+Qe,"EVENT",0,webphone_api.common.StrToIntDef(qe,-1),3))),s=122;try{webphone_api.onCdrCb(ze,Ke,Xe,Je,Ze,B,Qe,webphone_api.common.StrToInt(qe),fe,Ye)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCdr() callback",st)}if(!0===webphone_api.common.UsePresence2()&&!webphone_api.common.isNull(Je)&&webphone_api.common.IsNumber(Je)){if(webphone_api.common.StrToInt(Je)<=0)webphone_api.common.PutToDebugLog(4,"EVENT,notifications CDR 0 duration get presence status for: "+B),!1===webphone_api.common.IsSDK()&&webphone_api.common.PresenceGet2(B);else{if(!webphone_api.common.isNull(webphone_api.global.presenceHM))var on=webphone_api.global.presenceHM[B];if(!webphone_api.common.isNull(on)){var an=on[webphone_api.common.PRES_STATUS];webphone_api.common.isNull(an)||"0"!==an||(webphone_api.common.PutToDebugLog(4,"EVENT,notifications CDR connected call but presence was offline, so set it to online for: "+B),webphone_api.common.SaveReceivedPresence2(B,"online"))}}}s=130,!webphone_api.common.isNull($e[9])&&$e[9].length>0&&webphone_api.common.PutToDebugLog(1,"EVENT, "+$e[9]);var rn=0;try{rn=webphone_api.common.StrToInt($e[7])/1e3}catch(ct){}webphone_api.global.lastcallduration=rn,s=132;var ln="recfile";if(2===Ze?(f=!1,!1===webphone_api.global.acceptReject?(s=136,i(B,"2",ln,rn,qe,Qe,en)):(s=137,i(B,"1",ln,rn,qe,Qe,en)),webphone_api.global.acceptReject=!1):(s=138,i(B,"0",ln,rn,qe,Qe,en)),w="",ln="",rn>60){var sn=webphone_api.common.GetParameterInt("successfulcalls",0),pn=webphone_api.common.GetParameterInt("webrtc_successfulcalls",0);sn<0&&(sn=0),pn<0&&(pn=0),sn++,webphone_api.common.SaveParameter("successfulcalls",sn.toString()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(pn++,webphone_api.common.SaveParameter("webrtc_successfulcalls",pn.toString()));var cn=4;sn===cn&&"Android"===webphone_api.common.GetOs()&&(!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api.common.PutToDebugLog(4,"EVENT, Close call page because trying to display Add to Home Screen popup"),webphone_api._call.CloseCall()),setTimeout(function(){var e=webphone_api.$(".ui-page-active .ui-popup-active").length;!0===webphone_api.common.IsSDK()||e<1?(webphone_api.common.PutToDebugLog(2,"EVENT, Offer pin to desktop Home Screen Android"),webphone_api.common.AlertDialog(webphone_api.stringres.get("add_to_home_title"),webphone_api.stringres.get("add_to_home_msg"))):(cn-=1,webphone_api.common.SaveParameter("successfulcalls",cn.toString()))},500))}}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications CDR and save to call history",st)}if(s=140,"STATUS"===J){if("Registered."===Y||"Registered"===Y){webphone_api.global.phonestarted=3,webphone_api.common.SaveParameter("firststart_webrtc","false"),webphone_api.common.SaveParameter("last_login_failed","false");var un=webphone_api.common.GetParameter("profilepicture");if(!webphone_api.common.isNull(un)&&un.length>10&&webphone_api.plhandler.SetSipHeader("X-Profile: "+un,-1),webphone_api.global.firstregister_sessiontick<1&&(webphone_api.global.firstregister_sessiontick=webphone_api.common.GetTickCount()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.global.pgw_selected>=0&&webphone_api.common.SaveParameter("last_good_webrtc_gw",webphone_api.global.pgw_selected),!1===webphone_api.common.IsSDK()&&("undefined"!=typeof webphone_api._dialpad&&null!==webphone_api._dialpad?webphone_api._dialpad.HandleAutoaction():console&&console.log&&console.log("ERROR, notifications ProcessNotifications webphone_api._dialpad is not defined")),s=141,!0===webphone_api.common.UsePresence2()&&!1===webphone_api.global.pres_set_at_start&&(s=142,setTimeout(function(){webphone_api.global.pres_set_at_start=!0,webphone_api.common.PutToDebugLog(2,"EVENT,SetSelectedPresence to Online on notification reg"),webphone_api.common.SetSelectedPresence("Online"),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.common.IsMizuServerOrGateway()&&webphone_api.webrtcapi.SetSipHeader(-2,"X-IMStatus:"+webphone_api.common.GetParameter("presencestatus"))},200)),s=143,!1===webphone_api.global.onregisteredcalled){webphone_api.global.onregisteredcalled=!0;try{webphone_api.onRegStateChangeCb("registered",null)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onRegStateChangeCb(registered) callback",st)}try{webphone_api.onRegisteredCb()}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onRegistered() callback",st)}webphone_api.common.InitUnregOnIdle()}if(webphone_api.$("#webphone").width(1),webphone_api.$("#webphone").height(1),s=145,s=147,!0===webphone_api.common.Glbr()&&!T){var gn=webphone_api.common.GetParameter("creditrequest");!webphone_api.common.isNull(gn)&&gn.length>0&&(s=148,webphone_api.common.UriParser(gn,"","","","","creditrequest"))}}else if(Y.toLowerCase().indexOf("unregistered")>=0){if(s=150,webphone_api.global.authenticated_displayed=!1,!1===webphone_api.global.onunregistered_flag){webphone_api.global.onunregistered_flag=!0,webphone_api.global.onregisteredcalled=!1,setTimeout(function(){webphone_api.global.onunregistered_flag=!1},2e3),s=152;try{webphone_api.onRegStateChangeCb("unregistered",null)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onRegStateChangeCb(unregistered) callback",st)}try{webphone_api.onUnRegisteredCb()}catch(st){
webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onUnRegistered() callback",st)}}}else if("InProgress"===Y||"Routed"===Y||"Calling"===Y||"Calling..."===Y){s=160;var hn=Q.split(",");if(webphone_api.common.isNull(hn)||hn.length<3)return void webphone_api.common.PutToDebugLog(3,"EVENT, ProcessNotifications, skip InProgress event, because not enough parameters: "+Q);var mn="",B="",_e="",dn=t.replace(" ",""),bn="";if(!webphone_api.common.isNull(hn)&&hn.length>4&&(bn=hn[4]),!webphone_api.common.isNull(hn)&&hn.length>2&&(!webphone_api.common.isNull(hn[0])&&hn[0].length>1?mn=webphone_api.common.Trim(hn[0]):!webphone_api.common.isNull(hn[1])&&hn[1].length>1&&(mn=webphone_api.common.Trim(hn[1])),!webphone_api.common.isNull(hn[2])&&hn[2].length>0&&(_e=webphone_api.common.Trim(hn[2])),hn.length>3&&(B=hn[3],(webphone_api.common.isNull(B)||B.length<1)&&(B=mn))),webphone_api.common.isNull(mn)&&(mn=""),!webphone_api.common.isNull(z)&&z===bn&&z.length>0)return;z=bn;var Ve=webphone_api.global.aline;if(webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC){var _n=webphone_api.common.Trim(t),fn=_n.indexOf(",");fn>0&&(_n=_n.substring(fn+1),_n=webphone_api.common.Trim(_n),(fn=_n.indexOf(","))>0&&(_n=_n.substring(0,fn),_n=webphone_api.common.Trim(_n),!webphone_api.common.isNull(_n)&&webphone_api.common.IsNumber(_n)&&(Ve=webphone_api.common.StrToInt(_n),webphone_api.common.SetALineInternal(Ve,2,!1),webphone_api.global.lastalinesettick=0)))}if(1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callTrying",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callTrying",st)}try{webphone_api.onCallStateChangeCb("trying",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback trying",st)}}else if("Midcall"===Y){var hn=Q.split(",");if(webphone_api.common.isNull(hn)||hn.length<3)return void webphone_api.common.PutToDebugLog(3,"EVENT, ProcessNotifications, skip Midcall event, because not enough parameters: "+Q);var mn="",B="",_e="",dn=t.replace(" ",""),bn="";!webphone_api.common.isNull(hn)&&hn.length>4&&(bn=hn[4]),!webphone_api.common.isNull(hn)&&hn.length>2&&(!webphone_api.common.isNull(hn[0])&&hn[0].length>1?mn=webphone_api.common.Trim(hn[0]):!webphone_api.common.isNull(hn[1])&&hn[1].length>1&&(mn=webphone_api.common.Trim(hn[1])),!webphone_api.common.isNull(hn[2])&&hn[2].length>0&&(_e=webphone_api.common.Trim(hn[2])),hn.length>3&&(B=hn[3],(webphone_api.common.isNull(B)||B.length<1)&&(B=mn))),webphone_api.common.isNull(mn)&&(mn="");var Ve=webphone_api.global.aline;if(webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC){var _n=webphone_api.common.Trim(t),fn=_n.indexOf(",");fn>0&&(_n=_n.substring(fn+1),_n=webphone_api.common.Trim(_n),(fn=_n.indexOf(","))>0&&(_n=_n.substring(0,fn),_n=webphone_api.common.Trim(_n),!webphone_api.common.isNull(_n)&&webphone_api.common.IsNumber(_n)&&(Ve=webphone_api.common.StrToInt(_n))))}if(1===webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("midcall",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback midcall",st)}}else if(Y===webphone_api.stringres.get("muted")||Y===webphone_api.stringres.get("unmuted")){var dn=t.replace(" ",""),hn=dn.split(","),Ve=webphone_api.global.aline;if(!webphone_api.common.isNull(hn)&&hn.length>1&&webphone_api.common.IsNumber(hn[1])&&(Ve=webphone_api.common.StrToInt(hn[1])),1===webphone_api.common.GetApibehaviour())if(Y===webphone_api.stringres.get("muted"))try{webphone_api.onCallStateChangeCb("muted","","","",Ve,"")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback muted",st)}else try{webphone_api.onCallStateChangeCb("unmuted","","","",Ve,"")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback unmuted",st)}}else if("Transfer"===Y){if(1===webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("transfer","","","",-1,"")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback transfer",st)}}else"Exit"===Y&&webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, exit status received "+(webphone_api.common.GetTickCount()-webphone_api.global.httpkatimer).toString()+" / "+be.toString()+" / "+_?"true":(webphone_api.common.isNull(webphone_api.global.maintimerid),"true"));if(t.indexOf("EVENT,Hold")>=0){if(1===webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("hold","","","","","")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback hold",st)}}else if(t.indexOf("EVENT,Reload")>=0&&1===webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("reload","","","","","")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback reload",st)}if(t.indexOf("EVENT,conference created")>=0&&1===webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("conference","","","","","")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback conference",st)}if("CallSetup"===Y||"Ringing"===Y){!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api._call.MeasureCall(),setTimeout(function(){webphone_api._call.MeasureCall()},200));var hn=Q.split(",");if(webphone_api.common.isNull(hn)||hn.length<3)return void webphone_api.common.PutToDebugLog(3,"EVENT, ProcessNotifications, skip ringing event, because not enough parameters: "+Q);var mn="",B="",_e="",dn=t.replace(" ","");!webphone_api.common.isNull(hn)&&hn.length>1&&hn[1];var bn="";!webphone_api.common.isNull(hn)&&hn.length>4&&(bn=hn[4]),!webphone_api.common.isNull(hn)&&hn.length>2&&(!webphone_api.common.isNull(hn[0])&&hn[0].length>1?mn=webphone_api.common.Trim(hn[0]):!webphone_api.common.isNull(hn[1])&&hn[1].length>1&&(mn=webphone_api.common.Trim(hn[1])),s=163,!webphone_api.common.isNull(hn[2])&&hn[2].length>0&&(_e=webphone_api.common.Trim(hn[2])),s=164,hn.length>3&&(B=hn[3],(webphone_api.common.isNull(B)||B.length<1)&&(B=mn))),s=167,webphone_api.common.isNull(mn)&&(mn="");var Ve=webphone_api.global.aline;if(s=3221,webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC){var _n=webphone_api.common.Trim(t),fn=_n.indexOf(",");s=169,fn>0&&(_n=_n.substring(fn+1),_n=webphone_api.common.Trim(_n),(fn=_n.indexOf(","))>0&&(s=172,_n=_n.substring(0,fn),_n=webphone_api.common.Trim(_n),!webphone_api.common.isNull(_n)&&webphone_api.common.IsNumber(_n)&&(s=175,Ve=webphone_api.common.StrToInt(_n),webphone_api.common.SetALineInternal(Ve,3,!1),webphone_api.global.lastalinesettick=0)))}if(s=3223,!webphone_api.common.isNull($)&&$===bn&&$.length>0||!webphone_api.common.isNull(q)&&q===bn&&q.length>0){if(s=3224,!webphone_api.common.isNull(q)&&q===bn||"Ringing"!==Y&&"Ringing..."!==Y&&"Incoming"!==Y&&"Incoming..."!==Y)webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, Skip "+Y+" handling, because already handled for this call: "+bn+" ("+q+")");else{if(1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callRinging",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callSetup",st)}try{webphone_api.onCallStateChangeCb("ringing",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback setup",st)}"1"==_e?(s=271,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutcallringing,"callRinging",_e,mn,mn,"")):(s=272,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onincallringing,"callRinging",_e,mn,mn,""))}return}s=3225;var wn=!1,vn=webphone_api.global.aline,En=webphone_api.common.GetParameterInt("multilineoop",2);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(-1==En||webphone_api.common.GetNrOfActiveCalls()>0&&(En<2||En<3&&"Firefox"===webphone_api.common.GetBrowser()))&&!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0)for(var S=0;S<webphone_api.global.ep.length;S++)if(!webphone_api.common.isNull(webphone_api.global.ep[S])&&"true"==webphone_api.global.ep[S][webphone_api.common.EP_HOLDSTATE]){webphone_api.global.wasmultilineoop=1;var Pn=webphone_api.global.ep[S][webphone_api.common.EP_LINE];webphone_api.setline(Pn,!0),webphone_api.common.PutToDebugLog(2,"EVENT, API_Hold mainlogic resume call from nt; peer: "+webphone_api.global.ep[S][webphone_api.common.EP_DESTNR]+" on line: "+Pn),webphone_api.hold(!1),webphone_api.mute(!0),wn=!0}wn&&webphone_api.setline(vn,!0),"CallSetup"===Y||"Setup"===Y||"setup"===Y||"Call"===Y||"Starting Call"===Y||"Call Initiated"===Y?$=bn:($=bn,q=bn),webphone_api.common.isNull(j)||clearTimeout(j),j=null,webphone_api.global.acallcount++,F=!1,s=161,webphone_api.common.RemoveSipHeadreFromCache("X-reason"),webphone_api.common.RemoveSipHeadreFromCache("Reason"),webphone_api.common.RemoveSipHeadreFromCache("Warning"),webphone_api.global.ringstart_time=webphone_api.common.GetTickCount(),s=176;var ve=webphone_api.common.StrToInt(Ve);if(ve>0&&webphone_api.common.GetOtherPartyName(ve,mn),E=webphone_api.common.GetTickCount(),w=mn,webphone_api.global.currcallnumber=w,webphone_api.global.checkIfInCall=!0,webphone_api.global.checkIfCallActive=!1,webphone_api.common.SaveCallSession(12,Ve,null,mn,_e,webphone_api.common.GetTickCount(),-1,-1,"",bn,"","",null,null,null,null,null,null,B),!0!==webphone_api.common.GetParameterBool("voicerecording",!1)||webphone_api.common.isNull(webphone_api._call)||!1===webphone_api._call.IsRecStarted(mn)&&webphone_api._call.StartRecording(mn),s=177,1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callSetup",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callSetup",st)}try{webphone_api.onCallStateChangeCb("setup",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback setup",st)}if("1"==_e?(s=178,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutcallsetup,"callSetup",_e,mn,mn,"","additional_info")):(s=179,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onincallsetup,"callSetup",_e,mn,mn,"","additional_info"),0!=webphone_api.common.GetParameterInt("beeponincoming",1)&&0!=webphone_api.common.GetParameterBool("beeponincoming",!0)&&0!=webphone_api.common.GetParameterBool("useaudiodeviceplayback",!0)&&webphone_api.common.Beep("1")),"Ringing"===Y||"Ringing..."===Y||"Incoming"===Y||"Incoming..."===Y){if(1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callRinging",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callRinging",st)}try{webphone_api.onCallStateChangeCb("ringing",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback ringing",st)}"1"==_e?(s=271,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutcallringing,"callRinging",_e,mn,mn,"")):(s=272,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onincallringing,"callRinging",_e,mn,mn,""))}if(webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_displaypeerdetails,"callSetup",_e,mn,mn,"","scurl_displaypeerdetails"),webphone_api.common.PutToDebugLog(5,"EVENT, currevent: "+dn+"; isIcomingCall: "+_e+"; line: "+ne+", lastRingEvent: "+webphone_api.global.lastRingEvenet),webphone_api.common.UpdateContactLastActive(mn),"2"==_e){if(!1===webphone_api.common.IsSDK()&&!webphone_api.common.isNull(document.getElementById("display_notmain_account"))&&webphone_api.common.GetNrOfAcc()>1){var Tn="",Sn=hn[1];if(!webphone_api.common.isNull(webphone_api.global.sipaccounts)&&webphone_api.global.sipaccounts.length>0){for(var S=0;S<webphone_api.global.sipaccounts.length;S++){var Nn=webphone_api.global.sipaccounts[S];if(!0===Nn.ismain){if(!webphone_api.common.isNull(Sn)&&Sn.length>0&&Sn!=Nn.username)for(var In=0;In<webphone_api.global.sipaccounts.length;In++)if(webphone_api.global.sipaccounts[In].username===Sn){Tn=webphone_api.global.sipaccounts[In].username,!webphone_api.common.isNull(webphone_api.global.sipaccounts[In].serveraddress)&&webphone_api.global.sipaccounts[In].serveraddress.length>0&&(Tn=Tn+"@"+webphone_api.global.sipaccounts[In].serveraddress);break}break}}!webphone_api.common.isNull(Tn)&&Tn.length>0&&(webphone_api.$("#display_notmain_account").html(Tn),webphone_api.$("#display_notmain_account").show())}}var Cn=webphone_api.common.GetParameter("callnot_title"),Gn=webphone_api.common.GetParameter("callnot_body"),Ln=webphone_api.common.GetParameter("callnot_icon"),Rn=webphone_api.common.GetParameter("callnot_image");(webphone_api.common.isNull(Cn)||Cn.length<1)&&(Cn=webphone_api.common.GetBrandName()),(webphone_api.common.isNull(Gn)||Gn.length<1)&&(Gn=webphone_api.stringres.get("notification_message")),Gn+=": ",B.length>0&&B!==mn?Gn=Gn+B+" ("+mn+")":Gn+=mn,(webphone_api.common.isNull(Ln)||Ln.length<1)&&(Ln=webphone_api.common.GetElementSource()+"images/notification_icon.png"),webphone_api.common.isNull(Rn)&&(Rn=""),webphone_api.common.ShowIncomingCallNotification(Cn,Gn,Ln,!1,Rn)}if(!webphone_api.common.isNull(_e)&&"2"==_e&&dn!==webphone_api.global.lastRingEvenet){if(s=280,webphone_api.common.IsContactBlocked(w,null))return s=281,webphone_api.common.PutToDebugLog(4,"EVENT, call dropped (hangup) because blocked contact: "+w),webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup blocked contact: "+w),void webphone_api.hangup(!0);if(webphone_api.common.IsNumberBlacklisted(w,null))return s=282,webphone_api.common.PutToDebugLog(4,"EVENT, call dropped (hangup) because blacklisted number: "+w),webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup blacklisted number: "+w),void webphone_api.hangup(!0);if(webphone_api.global.active_incoming_call=!0,webphone_api.global.incommingCall=!0,f=!0,webphone_api.global.checkIfInCall=!0,webphone_api.global.checkIfCallActive=!1,s=285,webphone_api.common.SaveParameter("redial",w),webphone_api.common.SaveParameter("lastincalltime",webphone_api.common.GetTickCount()),webphone_api.global.intentcall[0]="number="+w,webphone_api.global.intentcall[1]="calltype=incoming",webphone_api.global.intentcall[2]="name=",s=286,!0===webphone_api.common.UsePresence2()&&!0===webphone_api.global.incommingCall&&"dnd"===webphone_api.common.GetParameter("presencestatus").toLowerCase())return webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup incoming call from: "+mn+", because presence is DND"),void webphone_api.hangup(!0);0==webphone_api.common.IsSDK()&&setTimeout(function(){s=290,!1===webphone_api.global.isCallStarted?webphone_api.$.mobile.changePage("#page_call",{transition:"pop",role:"page"}):(s=292,webphone_api.common.isNull(webphone_api._call)||webphone_api._call.OnNewIncomingCall())},500)}s=297,(webphone_api.common.isNull(webphone_api.global.lastRingEvenet)||webphone_api.global.lastRingEvenet.length<1)&&(webphone_api.global.lastRingEvenet=dn)}if(s=180,"CallConnect"===Y){!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api._call.MeasureCall(),setTimeout(function(){webphone_api._call.MeasureCall()},200));var mn="",B="",_e="",hn=Q.split(","),yn="";if(hn.length>4&&!webphone_api.common.isNull(hn[4])&&(yn=hn[4]),!webphone_api.common.isNull(K)&&K===yn&&K.length>0)return;K=yn;if(!webphone_api.common.isNull(hn)&&hn.length>1&&hn[1],le>0&&u(),webphone_api.common.PutToDebugLog(5,"EVENT, callConnected event received"),"Android"===webphone_api.common.GetOs()&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_GetDevice Callconnect"),webphone_api.getdevice(0,function(e){try{var n=webphone_api.common.GetParameterInt("androidspeaker",-1);-1==n&&(n=webphone_api.global.isvideocall?0:1);var t=e;if(-2==n);else if(n>0){if("Default"===e){var o=webphone_api.common.GetAudioRecList();if(!webphone_api.common.isNull(o)&&o.length>0)for(var i=o.split("\r\n"),a=0;a<i.length;a++)!webphone_api.common.isNull(i[a])&&(i[a].toLowerCase().indexOf("earpiece")>=0||i[a].toLowerCase().indexOf("headset")>=0)&&(e=i[a],webphone_api.common.SaveParameter("sel_rtc_audio_in",e),webphone_api.global.audio_rec_curr_device=e,webphone_api.common.SaveParameter("cache_audio_rec_curr_device",e))}!webphone_api.common.isNull(e)&&e.length>0&&(webphone_api.common.PutToDebugLog(4,"EVENT, Set input device id for Android loudspeaker: "+e),webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_SetDevice Callconnect"),webphone_api.setdevice(0,e,2,10))}else{if(e.toLowerCase().indexOf("earpiece")>=0||e.toLowerCase().indexOf("headset")>=0){var o=webphone_api.common.GetAudioRecList();if(!webphone_api.common.isNull(o)&&o.length>0)for(var i=o.split("\r\n"),a=0;a<i.length;a++)!webphone_api.common.isNull(i[a])&&i[a].toLowerCase().indexOf("default")>=0&&(e=i[a],webphone_api.common.SaveParameter("sel_rtc_audio_in",e),webphone_api.global.audio_rec_curr_device=e,webphone_api.common.SaveParameter("cache_audio_rec_curr_device",e))}!webphone_api.common.isNull(e)&&e.length>0&&(webphone_api.common.PutToDebugLog(4,"EVENT, Set input device id for Android loudspeaker: "+e),webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_SetDevice Callconnect"),webphone_api.setdevice(0,e,2,11))}webphone_api.common.PutToDebugLog(5,"EVENT, set android loudspeaker/speakerphone: "+n+" from: "+t+" to: "+e)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: getdevice loudspeaker 2",st)}})),webphone_api.common.ShowIncomingCallNotification("","","",!0,""),webphone_api.global.checkIfInCall=!0,webphone_api.global.callstart_time=webphone_api.common.GetTickCount(),s=182,!webphone_api.common.isNull(hn)&&hn.length>2&&(!webphone_api.common.isNull(hn[0])&&hn[0].length>1?mn=webphone_api.common.Trim(hn[0]):!webphone_api.common.isNull(hn[1])&&hn[1].length>1&&(mn=webphone_api.common.Trim(hn[1])),s=184,!webphone_api.common.isNull(hn[2])&&hn[2].length>0&&(_e=webphone_api.common.Trim(hn[2])),hn.length>3&&(B=hn[3],(webphone_api.common.isNull(B)||B.length<1)&&(B=mn)),s=188),webphone_api.common.isNull(mn)&&(mn=""),s=190,1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callConnected",webphone_api.common.StrToInt(_e),mn,B,webphone_api.common.StrToInt(webphone_api.global.aline),yn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callConnected",st)}try{webphone_api.common.PutToDebugLog(5,"EVENT, call connected event sent"),webphone_api.onCallStateChangeCb("connected",webphone_api.common.StrToInt(_e),mn,B,webphone_api.common.StrToInt(webphone_api.global.aline),yn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback connected",st)}if(1===webphone_api.common.StrToInt(_e)){if(s=205,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutcallconnected,"callConnected",_e,mn,mn,""),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){var Dn=webphone_api.common.GetParameterInt("beeponconnect",0);3!==Dn&&4!==Dn||webphone_api.common.Beep("1")}}else s=206,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onincallconnected,"callConnected",_e,mn,mn,"");s=207,webphone_api.common.SaveCallSession(13,webphone_api.global.aline,null,mn,_e,-1,webphone_api.common.GetTickCount(),-1,"",yn,"","",null,null,null,null,null,null,B),setTimeout(function(){webphone_api.common.RefreshInfo(7)},400),1==webphone_api.global.addrtcpmux&&(webphone_api.global.addrtcpmux=2)}if(s=200,"CallDisconnect"===Y){webphone_api.common.PutToDebugLog(2,"EVENT, ProcessNotifications call disc received");var On=0;try{var hn=Q.split(","),yn="";hn.length>4&&!webphone_api.common.isNull(hn[4])&&(yn=hn[4]);var xn=webphone_api.common.Trim(t).split(",");!webphone_api.common.isNull(xn)&&xn.length>3&&xn[4],On=2,webphone_api.common.ShowIncomingCallNotification("","","",!0,"");var k=webphone_api.global.aline,An="";On=3,!webphone_api.common.isNull(xn)&&xn.length>3&&(!webphone_api.common.isNull(xn[1])&&webphone_api.common.IsNumber(xn[1])&&(k=webphone_api.common.StrToInt(xn[1])),webphone_api.common.isNull(xn[3])||(An=webphone_api.common.Trim(xn[3]))),On=4,webphone_api.common.RemoveSessionHeadersFromCache(k);var mn="",B="",_e="",yn="";if(hn.length>4&&!webphone_api.common.isNull(hn[4])&&(yn=hn[4]),setTimeout(function(){webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, notifications delete/remove endpoint on call disconnected for number: "+An+"; line: "+k.toString());var e=!0;!0===webphone_api.global.calltransf_completed&&(e=!1),(!0!==webphone_api.global.checkIfInCall||webphone_api.common.isNull(webphone_api.global.ep)||1!==webphone_api.global.ep.length)&&webphone_api.common.GetEndpoint(1021,k,An,yn,"",e)},350),On=5,On=7,s=202,!webphone_api.common.isNull(hn)&&hn.length>2&&(!webphone_api.common.isNull(hn[0])&&hn[0].length>1?mn=webphone_api.common.Trim(hn[0]):!webphone_api.common.isNull(hn[1])&&hn[1].length>1&&(mn=webphone_api.common.Trim(hn[1])),s=204,!webphone_api.common.isNull(hn[2])&&hn[2].length>0&&(_e=webphone_api.common.Trim(hn[2])),s=206,hn.length>3&&(B=hn[3],(webphone_api.common.isNull(B)||B.length<1)&&(B=mn))),webphone_api.global.CLOSE_CALL_TIMER<0){var kn=0,Un=webphone_api.common.GetEndpoint(1022,k,An,yn,"",!1);if(!webphone_api.common.isNull(Un)&&Un.length>5){var Vn=Un[webphone_api.common.EP_CONNECTTIME];!webphone_api.common.isNull(Vn)&&webphone_api.common.IsNumber(Vn)&&(Vn=webphone_api.common.StrToIntDef(Vn,0))>0&&(kn=webphone_api.common.GetTickCount()-Vn)}webphone_api.global.CLOSE_CALL_TIMER=webphone_api.common.GetParameterInt("closecall_timeout",3e3),(1==_e||"1"==_e)&&kn<4e3&&(webphone_api.global.CLOSE_CALL_TIMER=webphone_api.common.GetParameterInt("closecall_timeout_err",7e3))}if(webphone_api.common.GetNrOfActiveCalls()<2&&(webphone_api.global.checkIfInCall=!1,webphone_api.global.isconfcall=!1),webphone_api.global.hadStartMediaPending=!1,On=6,s=201,webphone_api.common.ResetIce(),On=8,s=213,webphone_api.common.isNull(mn)&&(mn=""),!1===webphone_api.common.IsSDK()&&(s=215),On=9,!0!==webphone_api.common.GetParameterBool("voicerecording",!1)||webphone_api.common.isNull(webphone_api._call)||!0===webphone_api._call.IsRecStarted(mn)&&webphone_api._call.StopRecording(mn),On=10,s=218,1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callDisconnected",webphone_api.common.StrToInt(_e),mn,B,k,yn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callDisconnected",st)}try{webphone_api.onCallStateChangeCb("disconnected",webphone_api.common.StrToInt(_e),mn,B,k,yn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback disconnected",st)}!1===webphone_api.global.calltransf_completed&&webphone_api.common.SaveCallSession(14,null,null,mn,webphone_api.common.StrToInt(_e),-1,-1,webphone_api.common.GetTickCount(),"",yn,"","",null),On=11,webphone_api.global.acallcount--,webphone_api.common.GetNrOfActiveCalls()<1&&(webphone_api.global.usemutemutiline=!1),On=12}catch(st){webphone_api.common.PutToDebugLogException(2,"ProcessNotifications CallDisconnect error: "+On.toString(),st)}}if(s=220,"Call Finished"===Y){if(oe=!1,webphone_api.global.bothpartyhold=!1,webphone_api.global.authenticated_displayed=!1,webphone_api.global.ringstart_time=0,webphone_api.global.callstart_time=0,webphone_api.isscreensharecall=!1,webphone_api.global.rating="",webphone_api.global.isholdresume=!1,webphone_api.global.needholdreinvite=0,webphone_api.global.isresume=0,webphone_api.global.ishold=0,webphone_api.global.holdresumecount=0,webphone_api.global.add_recall_header=!1,le>0)try{"undefined"!=typeof AndroidWebphoneJsInterface&&null!==AndroidWebphoneJsInterface&&"undefined"!=typeof AndroidWebphoneJsInterface.jstoandroidEvents&&null!==AndroidWebphoneJsInterface.jstoandroidEvents&&AndroidWebphoneJsInterface.jstoandroidEvents("[HANGUP]_NOTIFICATION")}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications inner AndroidWebphoneJsInterface",st)}s=222,webphone_api.common.ResetIce(),v=webphone_api.common.GetTickCount(),webphone_api.common.GetNrOfActiveCalls()<1&&(webphone_api.global.closeCallAtivity=!0),webphone_api.global.isCallStarted&&webphone_api.common.GetNrOfActiveCalls()<1&&(webphone_api.common.isNull(webphone_api.global.waiting_conf_numbers)||webphone_api.global.waiting_conf_numbers.length<1)&&!1===webphone_api.global.dontshow_closecall&&(webphone_api.$("#btn_hangup_img").attr("src",webphone_api.common.GetElementSource()+"images/btn_close_txt.png"),webphone_api.$("#btn_hangup").attr("title",webphone_api.stringres.get("hint_closecall")),webphone_api.$("#acceptreject_layout").hide(),webphone_api.$("#callfunctions_layout").hide(),webphone_api.$("#hangup_layout").show()),webphone_api.common.IsMultiline()||(webphone_api.global.hangupPressedCount=1),s=232,webphone_api.common.GetNrOfActiveCalls()<1&&(webphone_api.global.checkIfInCall=!1,webphone_api.global.checkIfCallActive=!1,webphone_api.global.isconfcall=!1,F=!1,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.ClearPendingStartMedia()),webphone_api.global.hadStartMediaPending=!1,webphone_api.global.callTypeInOut="",webphone_api.global.creditRequestTimer=webphone_api.global.CREDIT_REQUEST_IVAL_DEFVAL-50,webphone_api.global.lastRingEvenet="",webphone_api.global.isfirstcall=!1,d=!1}if(s=240,"Finished"===Y){!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api._call.MeasureCall(),setTimeout(function(){webphone_api._call.MeasureCall()},200)),oe=!1,webphone_api.global.bothpartyhold=!1,webphone_api.global.ringstart_time=0,webphone_api.global.callstart_time=0,webphone_api.global.rating="",webphone_api.global.firefoxholdcount=0,webphone_api.global.isholdresume=!1,webphone_api.global.needholdreinvite=0,webphone_api.global.isresume=0,webphone_api.global.ishold=0,webphone_api.global.holdresumecount=0,webphone_api.global.add_recall_header=!1,s=242,webphone_api.common.ResetIce(),!0===webphone_api.global.incommingCall&&!1===webphone_api.global.acceptReject&&webphone_api.global.isCallStarted&&(s=245,!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||webphone_api._call.OnCallerHangup()),webphone_api.common.GetNrOfActiveCalls()<1&&(webphone_api.global.checkIfInCall=!1,webphone_api.global.checkIfCallActive=!1,webphone_api.global.isconfcall=!1,F=!1,webphone_api.global.incommingCall=!1,webphone_api.global.speakerState=!0,webphone_api.global.bluetoothState=!0,webphone_api.global.lastBTclicktick=0,webphone_api.global.callTypeInOut="",webphone_api.global.lastRingEvenet="",webphone_api.global.isfirstcall=!1,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.ClearPendingStartMedia()),webphone_api.global.hadStartMediaPending=!1,d=!1;var Wn=webphone_api.common.GetParameterInt("vdnr",0);if(webphone_api.global.isvideocall||webphone_api.isscreensharecall){Wn+=1,webphone_api.common.SaveParameter("vdnr",Wn);4===webphone_api.common.GetParameterInt("videomode",0)&&webphone_api.common.ExitVideoMode("Auto, on call finished")}if(webphone_api.global.isvideocall=!1,webphone_api.isscreensharecall=!1,s=247,!1===webphone_api.global.usestorage&&!1===webphone_api.common.Strl(60)&&Wn<2&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&!0===webphone_api.common.CanIUseService()){if(!0===(!0===webphone_api.common.IsWindows()&&!0===webphone_api.common.IsMizuReallyPublicWebRTCGateway())){s=248;var Fn=webphone_api.common.GetParameterInt("lccnr",0);if(Fn>0&&Fn<46){var Mn=webphone_api.common.GetParameterInt("closecall_timeout_err",7e3);Mn<webphone_api.common.GetParameterInt("closecall_timeout",4e3)&&(Mn=webphone_api.common.GetParameterInt("closecall_timeout",4e3)),Mn+=1500,setTimeout(function(){function e(){webphone_api.common.GetParameter("lastusedengine").length>0&&"ns"!=webphone_api.common.GetParameter("lastusedengine")&&webphone_api.common.SaveParameter("prevusedengine",webphone_api.common.GetParameter("lastusedengine")),webphone_api.common.SaveParameter("lastusedengine","ns"),webphone_api.flagrestartwebrtc=!1,s=253,webphone_api.common.ResetEngineClicked();var e=webphone_api.common.GetEngine("ns");e.clicked=2,webphone_api.common.SetEngine("ns",e),webphone_api.common.EngineSelect(1,1),s=257,webphone_api.common.PutToDebugLog(2,"EVENT, notifications: offer ns engine instead of WebRTC: "+webphone_api.common.GetMinServiceVersion().toString()),s=259,webphone_api.common.EngineForcedInstall("ns",webphone_api.stringres.get("serviceengine_msg"),null,function(){webphone_api.startInner()})}var n=webphone_api.$.mobile.activePage.find(".messagePopup");!webphone_api.common.isNull(n)&&n.length>0&&!0!==webphone_api.global.dontclosecurrpopup?webphone_api.$.mobile.activePage.find(".messagePopup").popup("close").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),e()}}):e()},Mn)}}}}if(s=260,s=300,"Starting call"===Y&&(!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api._call.MeasureCall(),setTimeout(function(){webphone_api._call.MeasureCall()},200)),webphone_api.global.checkIfInCall=!0,webphone_api.global.checkIfCallActive=!1,webphone_api.global.hadStartMediaPending=!1,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.ClearPendingStartMedia()),s=304,"InCall"!==Y&&"In Call"!==Y||(webphone_api.global.checkIfInCall=!0,f&&(s=307,!1===webphone_api.common.IsSDK()&&webphone_api.common.GetNrOfActiveCalls()<2&&!webphone_api.common.isNull(webphone_api._call)&&webphone_api._call.AcceptCall(!1))),s=310,"Speaking"===Y){!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api._call.MeasureCall(),setTimeout(function(){webphone_api._call.MeasureCall()},200));var hn=Q.split(",");if(!webphone_api.common.isNull(hn)&&hn.length>1&&hn[1],webphone_api.global.apistartstate=2,!1===oe&&(s=312,oe=!0,!1===webphone_api.common.IsSDK()&&webphone_api.common.GetNrOfActiveCalls()<2&&!webphone_api.common.isNull(webphone_api._call)&&webphone_api._call.AcceptCall(!1)),!1===webphone_api.common.IsSDK()&&!1===webphone_api.global.isCallStarted&&webphone_api.common.isNull(j)&&(j=setTimeout(function(){!1===webphone_api.global.isCallStarted&&(webphone_api.global.intentcall[0]="number=",webphone_api.global.intentcall[1]="calltype=outgoing",webphone_api.global.intentcall[2]="name=",webphone_api.global.intentcall[3]="callmode=0",webphone_api.$.mobile.changePage("#page_call",{transition:"pop",role:"page"}))},1e3)),G=!0,webphone_api.global.incommingCall&&(webphone_api.global.incommingCall=!1),webphone_api.global.checkIfCallActive=!0,webphone_api.global.checkIfInCall=!0,webphone_api.global.lastRingEvenet="",s=314,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){s=315;var Hn=location.hostname;webphone_api.common.isNull(Hn)&&(Hn=""),Hn+=" / ",Hn+=window.location.href,Hn+=" / ",Hn+=webphone_api.getbasedir2();var Bn=1;if(!1===webphone_api.common.Awb2()){var N=[];N.push("L"),N.push("i"),N.push("c"),N.push("e"),N.push("n"),N.push("s"),
N.push("e "),N.push("e"),N.push("r"),N.push("r"),N.push("o"),N.push("r"),N.push(", "),N.push("w"),N.push("e"),N.push("b"),N.push("s"),N.push("e"),N.push("r"),N.push("v"),N.push("e"),N.push("r"),N.push(" "),N.push("n"),N.push("o"),N.push("t"),N.push(" "),N.push("a"),N.push("l"),N.push("l"),N.push("o"),N.push("w"),N.push("e"),N.push("d"),N.push(" "),N.push("(");var jn=[];jn.push(")"),jn.push(" "),jn.push("h"),jn.push("a"),jn.push("n"),jn.push("g"),jn.push("u"),jn.push("p");var I=N.join(""),$n=jn.join("");s=320,setTimeout(function(){webphone_api.common.PutToDebugLog(1,"ERROR,"+I+Hn+$n)},3576),setTimeout(function(){webphone_api.common.ShowToast(I+Hn+$n)},4235),Bn=10}if(Bn>5&&setTimeout(function(){webphone_api.hangup(!0)},1180),y<0){if(!0===webphone_api.common.Ch())y=1;else{y=0;var N=[];N.push("L"),N.push("i"),N.push("c"),N.push("e"),N.push("n"),N.push("s"),N.push("e "),N.push("e"),N.push("r"),N.push("r"),N.push("o"),N.push("r"),N.push(", "),N.push("i"),N.push("n"),N.push("v"),N.push("a"),N.push("l"),N.push("i"),N.push("d "),N.push("s"),N.push("e"),N.push("r"),N.push("v"),N.push("e"),N.push("r"),N.push("a"),N.push("d"),N.push("d"),N.push("r"),N.push("e"),N.push("s"),N.push("s"),N.push(" "),N.push("h"),N.push("a"),N.push("n"),N.push("g"),N.push("u"),N.push("p");var I=N.join("");s=320,setTimeout(function(){webphone_api.common.PutToDebugLog(1,"ERROR,"+I)},351),setTimeout(function(){webphone_api.common.ShowToast(I)},391)}}0===y&&setTimeout(function(){webphone_api.hangup(!0)},123)}if(s=322,webphone_api.common.GetNrOfActiveCalls()>1&&!1===F){F=!0;var qn=webphone_api.common.StrToInt(webphone_api.common.GetParameter("automute")),zn=webphone_api.common.StrToInt(webphone_api.common.GetParameter("autohold")),Kn=webphone_api.common.GetParameterInt("defmute",0);if(3!==Kn&&4!==Kn||(Kn=0),(webphone_api.common.isNull(qn)||qn<1)&&(webphone_api.common.isNull(zn)||zn<1));else for(var S=0;S<webphone_api.global.ep.length;S++){var Xn=webphone_api.global.ep[S];if(!(webphone_api.common.isNull(Xn)||Xn.length<1)){if(!webphone_api.common.isNull(Xn[webphone_api.common.EP_DISCONNECTTIME])&&webphone_api.common.IsNumber(Xn[webphone_api.common.EP_DISCONNECTTIME])){var Jn=webphone_api.common.StrToInt(Xn[webphone_api.common.EP_DISCONNECTTIME]);if(Jn>10)continue}var Yn=Xn[webphone_api.common.EP_LINE];if(!(webphone_api.common.isNull(Yn)||Yn.length<1||!1===webphone_api.common.IsNumber(Yn))){var Qn=webphone_api.common.StrToInt(Yn);if(webphone_api.global.aline!=Qn){var Zn=Xn[webphone_api.common.EP_MUTESTATE],et=Xn[webphone_api.common.EP_HOLDSTATE];"false"==Zn&&(3===qn||6===qn||(2===qn||5===qn)&&!1===f||1===qn&&!0===f)&&(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?webphone_api.webrtcapi.SipToggleMute(!0,Kn,Qn)&&(webphone_api.global.ep[S][webphone_api.common.EP_MUTESTATE]="true"):webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE?(webphone_api.common.WinAPI("API_MuteEx",null,Qn,!0,Kn),webphone_api.global.ep[S][webphone_api.common.EP_MUTESTATE]="true"):webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&(webphone_api.webphone.MuteEx(Qn,!0,Kn),webphone_api.global.ep[S][webphone_api.common.EP_MUTESTATE]="true")),"false"==et&&(3===zn||6===zn||(2===zn||5===zn)&&!1===f||1===zn&&!0===f)&&(webphone_api.common.PutToDebugLog(2,"EVENT, API_Hold mainlogic hold call because autohold "+zn.toString()+" ; peer: "+webphone_api.global.ep[S][webphone_api.common.EP_DESTNR]+" on line: "+webphone_api.global.ep[S][webphone_api.common.EP_LINE]),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?webphone_api.webrtcapi.SipToggleHoldResume(!0,Qn,10)&&(webphone_api.global.ep[S][webphone_api.common.EP_HOLDSTATE]="true"):webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE?(webphone_api.common.WinAPI("API_Hold",null,Qn,!0),webphone_api.global.ep[S][webphone_api.common.EP_HOLDSTATE]="true"):webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&(webphone_api.webphone.Hold(Qn,!0),webphone_api.global.ep[S][webphone_api.common.EP_HOLDSTATE]="true"))}}}}}d||(d=!0,s=338,webphone_api.global.isencrypted=webphone_api.isencrypted(),setTimeout(function(){webphone_api.global.isencrypted>0?webphone_api.$(".img_encrypt").show():webphone_api.$(".img_encrypt").hide()},1e3))}s=340,Y.toLowerCase().indexOf("registered")>=0&&Y.toLowerCase().indexOf("unregistered")<0&&(P<4&&(P=4),s=342,webphone_api.global.phonestarted=3,webphone_api.common.SaveParameter("lastsucc","1"),m||(m=!0),s=344,setTimeout(function(){webphone_api.global.isencrypted>0?webphone_api.$(".img_encrypt").show():webphone_api.$(".img_encrypt").hide()},1e3)),s=360}else if("CHAT"===J){var ve=-1,Ee=webphone_api.common.Trim(t),Pe=Ee.indexOf(",");if(Pe>0&&(Ee=Ee.substring(Pe+1),(Pe=Ee.indexOf(","))>0&&(Ee=webphone_api.common.Trim(Ee.substring(0,Pe)),!webphone_api.common.isNull(Ee)&&webphone_api.common.IsNumber(Ee)&&(ve=webphone_api.common.StrToInt(Ee)))),Q.indexOf("[PRESENCE")>=0)return Q=Q.replace("[",""),Q=Q.replace("]",""),void n(Q);s=361,a(Y,Q,ve)}"Rejected"===Y&&f&&(s=364,!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||webphone_api._call.RejectCall(!1)),V=Q.indexOf(","),V>=0&&(V>0||Q.substring(1).indexOf(",")>=0)&&(Q=Y),s=366,V=Y.indexOf("[ep"),V>0&&(Y=webphone_api.common.Trim(Y.substring(0,V)),Q=Y),s=370;var nt="";if(("EVENT"===J||"ERROR"===J||"WARNING"===J||"STATUS"===J)&&(s=371,V=Q.indexOf("("),nt=V>0&&Y.indexOf(ie)<0&&Y.indexOf(ae)<0?webphone_api.common.Trim(Q.substring(0,V)):Q,s=374,!webphone_api.common.IsNumber(nt.charAt(0)))){if(nt=nt.substring(0,1).toUpperCase()+nt.substring(1),"STATUS"===J){if("Deletable"!==nt&&nt.indexOf("Chat")<0){ue=nt,ge=-1;var tt=t.split(",");if(!webphone_api.common.isNull(tt)&&tt.length>1&&!webphone_api.common.isNull(tt[1])&&webphone_api.common.IsNumber(tt[1])&&(ge=webphone_api.common.StrToIntDef(tt[1],-1)),webphone_api.common.isNull(webphone_api.global.callPageStatusCachePerLine)&&(webphone_api.global.callPageStatusCachePerLine={}),!1===webphone_api.common.IsSDK()&&("page_call"===webphone_api.$.mobile.activePage.attr("id")||t.indexOf("CallSetup")>0)){var ot=webphone_api.common.StrToIntDef(tt[1],-1);if(ot>0){var it=R;t.indexOf("ERROR")>=0?it="#FF0000":t.indexOf("WARNING")>=0&&(it="#D28F00"),"undefined"!=typeof webphone_api.global.callPageStatusCachePerLine[ot]&&null!==webphone_api.global.callPageStatusCachePerLine[ot]&&"undefined"!=typeof webphone_api.global.callPageStatusCachePerLine[ot][0]&&null!==webphone_api.global.callPageStatusCachePerLine[ot][0]&&"Muted"===webphone_api.global.callPageStatusCachePerLine[ot][0]&&"Speaking"===nt||(webphone_api.global.callPageStatusCachePerLine[ot]=[nt,it])}}}}else{Z=nt,ee=J,ne=-1;var tt=t.split(",");!webphone_api.common.isNull(tt)&&tt.length>1&&!webphone_api.common.isNull(tt[1])&&webphone_api.common.IsNumber(tt[1])&&(ne=webphone_api.common.StrToIntDef(tt[1],-1))}if(s=377,"Register failed"===nt){ue=nt,ge=-1;var tt=t.split(",");!webphone_api.common.isNull(tt)&&tt.length>1&&!webphone_api.common.isNull(tt[1])&&webphone_api.common.IsNumber(tt[1])&&(ge=webphone_api.common.StrToIntDef(tt[1],-1))}if(s=379,(nt.indexOf("Register failed")>=0||nt.indexOf("Connection lost")>=0||nt.indexOf("No network")>=0||nt.indexOf("Network is down")>=0||nt.indexOf("No response from server")>=0||nt.indexOf("Server lost")>=0||nt.indexOf("Authentication failed")>=0||nt.indexOf("Rejected by server")>=0||nt.indexOf("Register rejected")>=0||nt.indexOf("Register expired")>=0||nt.indexOf("Register failed")>=0)&&(webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_GetRegFailReason",function(e){try{webphone_api.onRegStateChangeCb("failed",e)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onRegStateChangeCb(failed) callback service",st)}try{webphone_api.onRegisterFailedCb(e)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onRegisterFailed() callback service",st)}},!0),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.GetRegFailReason(function(e){try{webphone_api.onRegStateChangeCb("failed",e)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onRegStateChangeCb(failed) callback webphone",st)}try{webphone_api.onRegisterFailedCb(e)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onRegisterFailed() callback webphone",st)}},!0),!0===webphone_api.global.onunregistered_flag||!1===webphone_api.flagrestartwebrtc||webphone_api.common.SaveParameter("lastsucc","0"),webphone_api.global.dispregfailed<2&&(webphone_api.global.laststarttick<1||webphone_api.common.GetTickCount()-webphone_api.global.laststarttick>2500))){s=382,webphone_api.global.dispregfailed=2;var at=nt;at=at.indexOf("Register failed")<0?"Register failed_: "+at:at.replace("Register failed","Register failed_"),webphone_api.common.PutToDebugLog(2,"EVENT, notification ProcessNotifications display: Register failed_: "+at),webphone_api.common.ShowToast(at,6e3)}}s=400}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications ("+s.toString()+"), not: "+t,st)}}function t(e){Ee=e}function o(){function e(e){try{webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup EarlyHangup: "+e),webphone_api.hangup(!0)}catch(n){webphone_api.common.PutToDebugLogException(2,"notifications: EarlyHangup",n)}}var n=0;try{n=444101;var t=webphone_api.common.GetTickCount();if(n=444102,webphone_api.global.ever_received_pong&&webphone_api.global.pingpong>2){n=444103;!0===webphone_api.common.WSReConnect()?webphone_api.common.PutToDebugLog(2,"EVENT, WSReConnect from timer succeded"):webphone_api.common.PutToDebugLog(2,"ERROR, WSReConnect from timer failed")}n=444104,webphone_api.global.wsc_contimeout>10&&t-webphone_api.global.wsc_contimeout>5e3&&(webphone_api.global.wsc_contimeout=0,webphone_api.common.PutToDebugLog(2,"ERROR, WSReConnect websocketAPI connection timed out (from timer)"),webphone_api.common.WSReConnect()),webphone_api.global.wsc_reqtimeout>10&&t-webphone_api.global.wsc_reqtimeout>5e3&&(webphone_api.global.wsc_reqtimeout=0,webphone_api.common.PutToDebugLog(2,"ERROR, WSReConnect websocketAPI request timed out (from timer)"),webphone_api.common.WSReConnect()),!0===webphone_api.global.dontshowdiscreason&&H>25&&(H=0,webphone_api.global.dontshowdiscreason=!1),1===webphone_api.global.dispregfailed&&++Se>330&&(Se=0,n=444105,webphone_api.global.dispregfailed=2,webphone_api.global.phonestarted<2&&!0===webphone_api.common.NeedRegister()&&(webphone_api.common.PutToDebugLog(2,"EVENT, notification OnTimerCycle display: Register failed"),webphone_api.common.ShowToast("Register failed"))),n=444106,pe<5e3&&pe++,Z.length>0?(n=444107,Z.toLowerCase().indexOf("authenticated successfully")>=0&&(ue="Registered.",ge=-1),he=Z,me=ee,de=ne,pe=0,Z="",ee="",ne=-1):pe>ce?(he=ue,me="STATUS",de=ge):ue.indexOf("Registered.")>=0&&"ERROR"!==me&&"WARNING"!==me&&(n=444108,(webphone_api.global.firstregister_sessiontick<1||webphone_api.global.firstregister_sessiontick>0&&t-webphone_api.global.firstregister_sessiontick<5e3)&&(he=ue,me="STATUS",de=ge));try{var o=he.indexOf("[");o>0&&(he=he.substring(0,o)),he=webphone_api.common.Trim(he),o=he.indexOf("]"),o>0&&(he=he.substring(o+1)),he=webphone_api.common.Trim(he)}catch(w){webphone_api.common.PutToDebugLogException(3,"notifications OnTimerCycle parse displayed status",w)}if("Registered."!==he&&"Registered"!==he||(he+=webphone_api.global.credit),(he.indexOf("Registered")>=0||"Not Found"===he||he.indexOf("Ringing")>=0||he.indexOf("Incoming")>=0||he.indexOf("In Call")>=0||he.indexOf("Ringing")>=0||"Ringing"===he||"CallConnect"===he||"InCall"===he||"Speaking"===he)&&Ne!==webphone_api.global.useengine&&(Ne=webphone_api.global.useengine,webphone_api.common.SaveLastUsedEngine()),0!==he.indexOf("Credit:")&&1!==he.indexOf("Credit:")&&he.indexOf("Outband")<0&&he.indexOf("Deletable")<0&&he.indexOf("Outbound")<0&&he.toLowerCase().indexOf("subscribe")<0&&(he.toLowerCase().indexOf("hide")>=0&&(he=" "),"Finished"==he&&(he="Finished"),l(he,me,0,de,1)),n=40,webphone_api.global.ringstart_time>0&&webphone_api.global.callstart_time<1&&webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE){n=41,(webphone_api.common.isNull(k)||!1===webphone_api.common.IsNumber(k))&&(k=90001),(webphone_api.common.isNull(U)||!1===webphone_api.common.IsNumber(U))&&(U=0),(webphone_api.common.isNull(V)||!1===webphone_api.common.IsNumber(V))&&(V=0);var i=k;!0===webphone_api.global.incommingCall?U>0&&(i=U):V>0&&(i=V);var a=webphone_api.common.GetParameter2("cutincoming"),r=0;"-1"===a?r=-1:"0"===a?r=0:"1"===a&&(r=1),n=51,t-webphone_api.global.ringstart_time>i&&(0==webphone_api.global.lastringtimeouttick||t-webphone_api.global.ringstart_time>3e3)&&(webphone_api.global.lastringtimeouttick=t,e("Hangup because ringtimeout limit reached: "+i)),-1===r?!0===webphone_api.global.incommingCall&&t-webphone_api.global.ringstart_time>14e3&&"Chrome"===webphone_api.common.GetBrowser()&&e("Hangup because ringtimeout in Chrome browser limit reached: 14000"):1===r&&!0===webphone_api.global.incommingCall&&t-webphone_api.global.ringstart_time>14e3&&e("Hangup because ringtimeout in ALL browsers limit reached: 14000")}if(n=55,webphone_api.global.callstart_time>0&&webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE&&(n=56,(webphone_api.common.isNull(W)||!1===webphone_api.common.IsNumber(W))&&(n=57,W=108e5),n=58,t-webphone_api.global.callstart_time>W&&(n=67,webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup because calltimeout limit reached: "+W),n=68,webphone_api.hangup(!0),n=69)),n=70,!0===webphone_api.common.Glbr()&&!T&&0===webphone_api.global.creditRequestTimer&&P>2){var s=webphone_api.common.GetParameter("creditrequest");!webphone_api.common.isNull(s)&&s.length>0&&webphone_api.common.UriParser(s,"","","","","creditrequest")}if(webphone_api.global.creditRequestTimer++,webphone_api.global.creditRequestTimer>webphone_api.global.creditRequestIval&&(webphone_api.global.creditRequestTimer=0),t-L>webphone_api.global.presenceinterval&&(L=t,!1===webphone_api.common.IsSDK()&&!0===(M=webphone_api.common.UsePresence2())&&webphone_api.common.PresenceGet2(webphone_api.common.GetParameter("srvcontacts"))),!0===M&&!0===webphone_api.global.isMessageStarted&&++webphone_api.global.msg_presence_timer>200&&(webphone_api.global.msg_presence_timer=0,!1===webphone_api.common.IsSDK()&&webphone_api._message.RefreshPresence()),n=444110,t-D>O&&(D=t,webphone_api.common.CallWsuserKeepAlive(!1)),t-x>A&&webphone_api.global.phonestarted>2&&(x=t,webphone_api.common.PutToDebugLog(2,"EVENT, wsuser keepalive hourly"),webphone_api.common.CallWsuserKeepAlive(!0)),webphone_api.global.closeCallAtivity&&(webphone_api.global.CLOSE_CALL_TIMER<0&&(webphone_api.global.CLOSE_CALL_TIMER=webphone_api.common.GetParameterInt("closecall_timeout",3e3)),t-v>webphone_api.global.CLOSE_CALL_TIMER&&(n=444111,webphone_api.global.CLOSE_CALL_TIMER=-100,webphone_api.global.closeCallAtivity=!1,v=0,!1===webphone_api.global.incommingCall&&!1===webphone_api.global.checkIfInCall&&webphone_api.global.isCallStarted&&(!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||webphone_api._call.CloseCall()))),t-S>5e3&&!0===webphone_api.global.wasSettModified){n=444112,S=t,webphone_api.global.wasSettModified=!1;var p="";p=1==webphone_api.common.IsSDK()?webphone_api.common.GetSettFilenameSDK():webphone_api.common.GetActiveAccSettingsFilename(),webphone_api.common.SaveSettingsFile(1,p,function(e){webphone_api.common.CanLog(2)&&(e?webphone_api.common.PutToDebugLog(3,"EVENT, SaveSettingsFile from timer Successfull"):webphone_api.common.PutToDebugLog(3,"ERROR, SaveSettingsFile from timer Failed"))})}if(t-N>200&&(N=t,!0===webphone_api.global.wasCtModified&&(n=444113,webphone_api.global.wasCtModified=!1,webphone_api.common.SaveContactsFile(function(e){e?webphone_api.common.PutToDebugLog(2,"EVENT, SaveContactsFile from timer Successfull"):webphone_api.common.PutToDebugLog(2,"ERROR, SaveContactsFile from timer Failed")}))),t-I>400&&(I=t,webphone_api.global.wasChModified&&(n=444114,webphone_api.global.wasChModified=!1,webphone_api.common.SaveCallhistoryFile(function(e){e?webphone_api.common.PutToDebugLog(2,"EVENT, SaveCallhistoryFile from timer Successfull"):webphone_api.common.PutToDebugLog(2,"ERROR, SaveCallhistoryFile from timer Failed")}))),n=444115,"Ringing"===Y&&!0===fe&&(Ee=webphone_api.common.GetTickCount(),fe=!1,ve=!0),"Speaking"===Y&&!0===we&&(Ee=webphone_api.common.GetTickCount(),we=!1,ve=!0),!1===webphone_api.common.IsSDK()&&webphone_api.global.isCallStarted&&!0===ve&&++Pe>=3){n=444116,Te=!0===webphone_api.common.GetHoldState(-1)?webphone_api.stringres.get("in_hold")+" ":"";var t=webphone_api.common.GetTickCount(),c=webphone_api.common.GetTickCount()-Ee,u=Math.floor(c/1e3),g=Math.floor(u/60);u%=60,u<10&&(u="0"+u),webphone_api.global.isCallStarted&&webphone_api.$("#call_duration").html(Te+g+":"+u+"&nbsp;"),Pe=0}if("Call Finished"!==Y&&"Finished"!==Y||webphone_api.common.GetNrOfActiveCalls()<1&&(ve=!1,fe=!0,we=!0,webphone_api.webrtcapi.RemoveUnusedAudioElements()),Q.indexOf(":")>0){n=444117;if("Call duration"===webphone_api.common.Trim(Q.substring(0,Q.indexOf(":")))){ve=!1,Te=webphone_api.stringres.get("duration")+" ";var h=webphone_api.common.Trim(Q.substring(Q.indexOf(":")+1,Q.length)),m=0,g=0,u=0;if(h.indexOf(":")<0?u=webphone_api.common.Trim(h.substring(0,h.indexOf(" "))):(m=webphone_api.common.Trim(h.substring(0,h.indexOf(":"))),h=webphone_api.common.Trim(h.substring(h.indexOf(":")+1,h.length)),g=webphone_api.common.Trim(h.substring(0,h.indexOf(":"))),h=webphone_api.common.Trim(h.substring(h.indexOf(":")+1,h.length)),u=webphone_api.common.Trim(h.substring(0,h.length))),!webphone_api.common.isNull(m)&&m.length>0&&webphone_api.common.IsNumber(m)){var d=webphone_api.common.StrToInt(m);d*=60,g=webphone_api.common.StrToInt(g)+d}if(webphone_api.global.isCallStarted&&webphone_api.$("#call_duration").html(Te+g+":"+u+"&nbsp;"),G&&!1===webphone_api.common.GetParameterBool("customizedversion",!0)){var b=webphone_api.common.StrToInt(g),_=webphone_api.common.StrToInt(u);if(b>0||_>30){var f=0;try{f=webphone_api.common.StrToInt(webphone_api.common.GetParameter("proversioncallcount"))}catch(E){webphone_api.common.SaveParameter("proversioncallcount","0")}f<25&&f++,webphone_api.common.SaveParameter("proversioncallcount",f.toString()),G=!1}}}}(t-webphone_api.global.httpkatimer>be||t-webphone_api.global.httpkatimer<0)&&webphone_api.global.phonestarted>1&&(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)&&(n=444118,webphone_api.global.httpkatimer=t,webphone_api.common.WinAPI("API_HTTPKeepAlive",function(e){webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, notifications OnTimerCycle API_HTTPKeepAlive response: "+e)}),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE&&webphone_api.global.service_last_life_signal>10&&t-webphone_api.global.service_last_life_signal>8e3&&(webphone_api.common.WinAPI("API_HTTPKeepAlive",function(e){webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, notifications OnTimerCycle API_HTTPKeepAlive responseB: "+e)}),webphone_api.common.isNull(B)||clearTimeout(B),B=null,B=setTimeout(function(){webphone_api.common.GetTickCount()-webphone_api.global.service_last_life_signal>8e3&&(webphone_api.global.service_last_life_signal=webphone_api.common.GetTickCount(),webphone_api.common.PutToDebugLog(2,"WARNING, call Handle WSAPIReConnect from timer"),webphone_api.common.WSAPIHandleReConnect()),webphone_api.common.isNull(B)||clearTimeout(B),B=null},2e3))),t-webphone_api.global.httpkatimer>_e&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&(webphone_api.global.httpkatimer=t,webphone_api.HTTPKeepAlive())}catch(C){webphone_api.common.PutToDebugLogException(2,"notifications: OnTimerCycle ("+n.toString()+")",C)}}function i(e,n,t,o,i,a,r){try{if(webphone_api.common.CanLog(4)&&webphone_api.common.PutToDebugLog(4,"EVENT, notifications CDR added; AddToCallLog(); number: "+e+"; type: "+n+"; recorded: "+t+"; duration: "+o+"; callDateTime = "+E+"; line: "+i),webphone_api.common.isNull(e)&&e.length<1)return;webphone_api.common.isNull(a)&&(a=""),a=webphone_api.common.ReplaceAll(a,","," "),a=webphone_api.common.Trim(a),webphone_api.global.refreshrecents=!0;var l=0;l=E>0?E:webphone_api.common.GetTickCount(),E=0,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE&&!webphone_api.common.isNull(o)&&webphone_api.common.IsNumber(o)&&o>0&&(webphone_api.common.SaveParameter("nsupdate","-1"),o>30&&(!0===webphone_api.global.usestorage||webphone_api.common.Strl(60))?webphone_api.common.SaveParameter("lnsengine","0"):webphone_api.common.SaveParameter("lnsengine","1"));var s=0,p=0,c="";try{o=Math.floor(o),s=Math.floor(o/60),p=o%60,s<10&&(c+="0"),c+=0===s?"0:":s+":",p<10&&(c+="0"),c+=p}catch(P){webphone_api.common.PutToDebugLogException(3,"notifications AddToCallLog calc duration",P)}webphone_api.common.isNull(webphone_api.global.callName)&&(webphone_api.global.callName=""),webphone_api.common.isNull(n)&&(n=""),webphone_api.common.isNull(t)&&(t=""),webphone_api.common.isNull(r)&&(r="");var u=r;u.length<1&&(1===webphone_api.common.IsMultiline()||!webphone_api.common.isNull(i)&&webphone_api.common.StrToInt(i)>1)&&(u=webphone_api.common.GetContactNameFromNumber(e));var g=webphone_api.common.GetContactIdFromNumber(e);if(g>=0){var h=webphone_api.global.ctlist[g];if(webphone_api.common.IsNumber(h[webphone_api.common.CT_USAGE])){var m=webphone_api.common.StrToInt(h[webphone_api.common.CT_USAGE]);m++,h[webphone_api.common.CT_USAGE]=m.toString(),webphone_api.global.ctlist[g]=h}}u==r||u===e&&(u=!webphone_api.common.isNull(webphone_api.global.telsearchname)&&webphone_api.global.telsearchname.length>0?webphone_api.common.Trim(webphone_api.global.telsearchname):webphone_api.global.callName),webphone_api.global.telsearchname="",(webphone_api.common.isNull(u)||u.length<1)&&(u=e);var d=1;"0"!==n&&(d=2),1==d?webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutcalldisconnected,"callDisconnected",d,e,u,"",l,o,webphone_api.global.lastcallcdr):webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onincalldisconnected,"callDisconnected",d,e,u,"","","",webphone_api.global.lastcallcdr);var b=[n,u,e,""+l,""+o,t,a];if(webphone_api.global.chlist.unshift(b),webphone_api.global.wasChModified=!0,"2"===n){var _=e;_.length<1&&(_=u),u!=e&&e.length>0&&u.length>0&&(_=u+" - "+e),webphone_api.common.PutNotifications2("0",a,_,0)}if(webphone_api.common.isNull(u)||u.length<1||!1===webphone_api.common.ContactExists(u,"")){var f=null,w=!1;if(!webphone_api.common.isNull(webphone_api.global.alreadyCalledNrs)&&webphone_api.global.alreadyCalledNrs.length>0&&(f=webphone_api.global.alreadyCalledNrs.split(",")),!webphone_api.common.isNull(f))for(var v=0;v<f.length;v++)if(f[v]===e){w=!0;break}!1===w&&(webphone_api.global.alreadyCalledNrs.length<=0?webphone_api.global.alreadyCalledNrs=e:webphone_api.global.alreadyCalledNrs=webphone_api.global.alreadyCalledNrs+","+e,webphone_api.global.contactExists=!1,webphone_api.global.contactExistsNr=e)}!1===webphone_api.isincall()&&(webphone_api.global.sipunicoderewritefrom="",webphone_api.global.sipunicoderewriteto="")}catch(T){webphone_api.common.PutToDebugLogException(2,"notifications: AddToCallLog",T)}}function a(e,n,t){try{if(webphone_api.common.CanLog(4)&&webphone_api.common.PutToDebugLog(4,"EVENT, notifications: OnMessageReceived from: "+e+"; message: "+n),webphone_api.common.IsContactBlocked(e,null))return void webphone_api.common.PutToDebugLog(4,"EVENT, chat message dropped because blocked contact: "+e);if(webphone_api.common.IsNumberBlacklisted(e,null))return void webphone_api.common.PutToDebugLog(4,"EVENT, chat message dropped because blacklisted number: "+e);n.indexOf("MULTIPART:")>=0&&(n=n.substring(n.indexOf("MULTIPART:")+6),n=webphone_api.common.Trim(n.substring(n.indexOf(":")+1)));var o="";if(n.indexOf("GROUP:")>=0&&(o=n.substring(n.indexOf("GROUP:")+6),o=webphone_api.common.Trim(o.substring(0,o.indexOf(":"))),webphone_api.common.isNull(o)&&(o=""),n=n.substring(n.indexOf("GROUP:")+6),n=webphone_api.common.Trim(n.substring(n.indexOf(":")+1))),webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n),0===n.indexOf("_BASE64_")&&(n=webphone_api.common.B64Dec(n),webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n)),n===webphone_api.stringres.get("composing")||n===webphone_api.stringres.get("composing")+"...")return void webphone_api.common.PutToDebugLog(2,"CHATCOMPOSING,"+t+","+e+",1");if(n.indexOf("FILETRANSFER_DELIVERED:")>=0)return void(!0===webphone_api.global.isFiletransferStarted&&webphone_api.$("#ftranf_status").html(webphone_api.stringres.get("ftrnasf_status_delivered")));if(n.indexOf("[CONFERENCE]")>=0)return void webphone_api.common.ReceivedConferenceInvite(e,n);if(n.indexOf("[CONFERENCE_ANSWER]")>=0)return void(webphone_api.global.confanswer_received=!0);var i=n.indexOf("[PRESENCE,");if(i>=0){if(n=n.substring(i+10),(i=n.indexOf(","))>0){var a=webphone_api.common.Trim(n.substring(0,i)),r=webphone_api.common.Trim(n.substring(i));i=r.indexOf(","),i>0&&(r=r.substring(0,i)),r=webphone_api.common.Trim(r),webphone_api.common.SaveReceivedPresence2(a,r)}return}try{webphone_api.onChatCb(e,n,t,o)}catch(s){webphone_api.common.PutToDebugLogException(2,"There is an error in onChat() callback",s)}if(webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_oninchat,"inChat","",e,e,n),0==webphone_api.common.IsSDK()){if(!0===webphone_api.common.UsePresence2()&&"dnd"===webphone_api.common.GetParameter("presencestatus").toLowerCase()){webphone_api.common.PutToDebugLog(2,"EVENT, dont show incoming chat from: "+e+", because presence is DND");var l=webphone_api.common.GetContactNameFromNumber(e);webphone_api.common.PutNotifications2("1","",l+" - "+e,0),!1===webphone_api.common.IsSDK()&&webphone_api._message.SaveMissedIncomingMessage("chat",e,l,n)}if(3==webphone_api.common.GetParameterInt("chatsms",0)||0==webphone_api.common.GetParameterInt("textmessaging",-1)||1==webphone_api.common.GetParameterInt("textmessaging",-1))return void webphone_api.common.PutToDebugLog(4,"ERROR, OnMessageReceived message dropped because chat is disabled by user");if(webphone_api.global.isMessageStarted)!1===webphone_api.common.IsSDK()&&webphone_api._message.ShowIncomingMessage("chat",e,n);else if(webphone_api.global.checkIfInCall){var l=webphone_api.common.GetContactNameFromNumber(e);webphone_api.common.PutNotifications2("1","",l+" - "+e,0),!1===webphone_api.common.IsSDK()&&webphone_api._message.SaveMissedIncomingMessage("chat",e,l,n)}else webphone_api.global.intentmsg[0]="action=chat",webphone_api.global.intentmsg[1]="to="+e,webphone_api.global.intentmsg[2]="message="+n,webphone_api.$.mobile.changePage("#page_message",{transition:"slide",role:"page"})}}catch(s){webphone_api.common.PutToDebugLogException(2,"notifications: OnMessageReceived",s)}}function r(e,n,t,o,i){var a='border="0"/>';try{if(e.length<1||n.length<1||t.length<1||o<1)return;if("2"!=n&&"4"!=n)return;var r=!1,l=o.split(a);if(webphone_api.common.isNull(l)||l.length<1)return;for(var s=l.length-1;s>=0;s--)if(!(webphone_api.common.isNull(l[s])||l[s].length<1)){var p=l[s].indexOf("<p>"),c=l[s].indexOf("</p>");if(!(p<0||c<p)){var u=l[s].substring(p+3,c);if(!(webphone_api.common.isNull(u)||u.length<1)&&webphone_api.common.Md5Hash(u)===t){if((p=l[s].indexOf('<img class="sent_status"'))>0){l[s]=l[s].substring(0,p);var g="spacer.png";"2"==n?g="icon_chat_status_green.png":"4"==n&&(g="icon_chat_status_black.png");var h='<img class="sent_status" src="'+webphone_api.common.GetElementSource()+"images/"+g+'" ';l[s]=l[s]+h,r=!0}break}}}if(!0===r){for(var m="",s=0;s<l.length;s++)if(!(webphone_api.common.isNull(l[s])||l[s].length<1)){var p=l[s].indexOf("<p>"),c=l[s].indexOf("</p>");p<0||c<p||(m=m+l[s]+a)}webphone_api.common.IsWindowsSoftphone()?webphone_api.common.ApiWinSaveFile(e,m,function(e){e&&webphone_api.common.PutToDebugLog(2,"ERROR, _message: AddMessage cannot save message file (1) WinApi"),!0===webphone_api.global.isMessageStarted&&webphone_api.global.mto===i&&webphone_api._message.LoadMessage()}):webphone_api.File.SaveFile(e,m,webphone_api.global.STORAGE_LOCAL,function(e){e||webphone_api.common.PutToDebugLog(2,"ERROR, _message: AddMessage cannot save message file (1)"),!0===webphone_api.global.isMessageStarted&&webphone_api.global.mto===i&&webphone_api._message.LoadMessage()})}}catch(d){webphone_api.common.PutToDebugLogException(2,"notifications: SaveChatReport",d)}}function l(e,n,t,o,i){var a=0;try{if(a=1,webphone_api.common.isNull(e))return;if(webphone_api.common.isNull(i)&&(i=0),e.toLowerCase().indexOf("subscribe")>=0)return;if("Authenticated successfully"===e){if(a=2,!0===webphone_api.global.authenticated_displayed)return;webphone_api.global.authenticated_displayed=!0}if(webphone_api.global.flagWaitforautoprov)return;a=3,webphone_api.common.Trim(e).length<1&&(e="&nbsp"),e.indexOf(Ue)<0&&"ERROR"!==n&&"WARNING"!==n&&(a=4,webphone_api.global.last_good_status=e),a=5,webphone_api.global.laststatusdisplay=e;var r=webphone_api.common.GetTickCount();if(r-xe<5e3)return;!webphone_api.common.isNull(Ae)&&Ae.length>0&&e.indexOf(Ae)>=0&&(a=6,xe=r),a=7,e=e.replace("DISPLAY",""),a=8,e.toLowerCase().indexOf("demo")>=0&&(a=9,ye=r,Oe=e,De=n),r-ye<15e3?(e=Oe,n=De):(Oe="",De=""),a=10;var l=R;if(a=11,(webphone_api.common.isNull(n)||n.length<1)&&(a=12,n="EVENT"),a=13,"ERROR"===n&&(l="#FF0000"),"WARNING"===n&&(l="#D28F00"),e.toLowerCase().indexOf("success")>=0&&(l="#4EC200"),a=14,1===t?(a=15,webphone_api.common.isNull(Re)&&(Re=document.getElementById("status_message"))):(a=16,webphone_api.common.isNull(Ie)&&(Ie=document.getElementById("status_dialpad")),webphone_api.common.isNull(Ce)&&(Ce=document.getElementById("status_contactslist")),webphone_api.common.isNull(Ge)&&(Ge=document.getElementById("status_callhistorylist")),webphone_api.common.isNull(Le)&&(Le=document.getElementById("status_call")),webphone_api.common.isNull(Re)&&(Re=document.getElementById("status_message"))),a=17,!0===webphone_api.global.last_presence_enabled&&!0===webphone_api.global.pres_unreg_called){a=18;var s=e.toLowerCase();(s.indexOf("unregister")>=0||s.indexOf("register failed")>=0||s.indexOf("disconnected")>=0)&&(e="Offline")}a=19;var p=webphone_api.common.Translate(e);if(a=20,webphone_api.common.isNull(Ie)||-1!==o||(a=21,Ie.innerHTML=p,Ie.style.color=l),webphone_api.common.isNull(Ce)||-1!==o||(a=22,Ce.innerHTML=p,Ce.style.color=l),webphone_api.common.isNull(Ge)||-1!==o||(a=23,Ge.innerHTML=p,Ge.style.color=l),a=24,!webphone_api.common.isNull(Le)&&p.indexOf("uthenticated successfully")<1&&e.indexOf("uthenticated successfully")<1){a=25;var c=webphone_api.common.StrToIntDef(webphone_api.global.aline,-1),u="";if(a=26,c>=0&&"undefined"!=typeof webphone_api.global.callPageStatusCachePerLine[c]&&null!==webphone_api.global.callPageStatusCachePerLine[c]&&webphone_api.global.callPageStatusCachePerLine[c].length>=2&&(a=27,u=webphone_api.global.callPageStatusCachePerLine[c][0],webphone_api.common.isNull(u)&&(u="")),a=28,o>0||u.length>0&&c>0){a=29,webphone_api.common.isNull(webphone_api.global.rating)||!webphone_api.global.rating.length||"STATUS"!==n&&"EVENT"!==n||(a=30,
p+=webphone_api.global.rating);try{if(a=31,"Finished"==u){a=32;0==e.indexOf("disc_reason: ")?(a=33,!0,u=webphone_api.common.Translate("Disconnected")+"<br>"+webphone_api.common.Translate(webphone_api.common.StrGetAfter(e,"disc_reason: ").trim())):0==e.indexOf(webphone_api.stringres.get("disc_reason")+": ")&&(a=34,!0,u=webphone_api.common.Translate("Disconnected")+"<br>"+webphone_api.common.Translate(webphone_api.common.StrGetAfter(e,webphone_api.stringres.get("disc_reason")+": ").trim())),a=35,null==ke&&(a=36,ke=setTimeout(function(){a=37;try{a=371,"Finished"!=Le.innerHTML&&0!=Le.innerHTML.indexOf("Disconnected")&&Le.innerHTML!=webphone_api.common.Translate("Finished")&&0!=Le.innerHTML.indexOf(webphone_api.common.Translate("Disconnected"))||(a=38,Le.innerHTML="")}catch(n){webphone_api.common.PutToDebugLogException(2,"notifications: DisplayStatus hidedisconnecttimer "+a.toString()+" "+i.toString()+" "+e,n)}},5e3))}else a=39,null!=ke&&(a=40,clearTimeout(ke),ke=null);if(a=41,(0==Le.innerHTML.indexOf("Disconnected")||0==Le.innerHTML.indexOf(webphone_api.common.Translate("Disconnected")))&&u.length>0&&"Finished"==u||u.length<1&&"Finished"==e)a=42;else if(u.length>0){a=43;var g=webphone_api.global.callPageStatusCachePerLine[c][1];a=44,u=webphone_api.common.Translate(u),a=45,Le.innerHTML=u,Le.style.color=g}else a=46,Le.innerHTML=p,Le.style.color=l}catch(m){try{webphone_api.common.PutToDebugLogException(2,"ERROR, DisplayStatus per line on call page "+a.toString(),m),Le.innerHTML=p,Le.style.color=l}catch(d){}}}}a=47,!webphone_api.common.isNull(Re)&&o>0&&(a=48,Re.innerHTML=p,Re.style.color=l),a=49;var h='<span style="color: '+l+';">'+p+"</span>";try{a=50,webphone_api.RecDisplayableNotifications(h)}catch(d){webphone_api.common.PutToDebugLogException(2,"notifications: DisplayStatus RecDisplayableNotifications",d)}}catch(d){webphone_api.common.PutToDebugLogException(2,"notifications: DisplayStatus "+a.toString()+" "+i.toString()+" "+e,d)}}function s(){try{return webphone_api.common.isNull(b)&&(b="STATUS,-1,Ready."),b}catch(e){webphone_api.common.PutToDebugLogException(2,"notifications: GetStatus",e)}return""}function p(e){try{if(webphone_api.common.isNull(e)||e.length<1)return!0;var n=[];n.push("C"),n.push("a"),n.push("l"),n.push("l"),n.push("-"),n.push("I"),n.push("D"),n.push(":");var t=n.join(""),o=e.indexOf(t);if(o>0){var e=webphone_api.common.Trim(e.substring(o+8));e.indexOf("\r\n")>0&&(e=webphone_api.common.Trim(e.substring(0,e.indexOf("\r\n"))))}var i=0;e=e.toString();for(var a=0;a<e.length;a++)i+=e.charCodeAt(a);return i%webphone_api.global.testmessagevalidity!=0}catch(r){webphone_api.common.PutToDebugLogException(2,"notifications: IsGoodCRC",r)}return!0}function c(e,n){try{if(webphone_api.common.isNull(e)||e.length<4||e.indexOf(",")<0)return n;var t=e.split(",");if(webphone_api.common.isNull(t)||t.length<2)return n;if(!webphone_api.common.isNull(t[1])||webphone_api.common.IsNumber(t[1])){var o=webphone_api.common.StrToInt(t[1]);if(o>-3&&o<100)return o}}catch(i){webphone_api.common.PutToDebugLogException(2,"notifications: GetLineFromNot",i)}return n}function u(){try{le>0&&(webphone_api.$(document).mousemove(function(e){Ve=webphone_api.common.GetTickCount()}),webphone_api.$(document).keypress(function(e){Ve=webphone_api.common.GetTickCount()}),webphone_api.$(document).scroll(function(e){Ve=webphone_api.common.GetTickCount()}),webphone_api.common.isNull(se)||clearInterval(se),se=setInterval(function(){try{webphone_api.common.GetTickCount()-Ve<2e3&&"undefined"!=typeof AndroidWebphoneJsInterface&&null!==AndroidWebphoneJsInterface&&"undefined"!=typeof AndroidWebphoneJsInterface.jstoandroidEvents&&null!==AndroidWebphoneJsInterface.jstoandroidEvents&&AndroidWebphoneJsInterface.jstoandroidEvents("[USERINTERACTION]_NOTIFICATION")}catch(e){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications inner AndroidWebphoneJsInterface userinteraction",e)}},500))}catch(e){webphone_api.common.PutToDebugLogException(2,"notifications: HandleAndroidUserInteraction",e)}}var g,h,m,d,b,_=!1,f=!1,w="",v=0,E=0,P=0,T=!1,S=0,N=0,I=0,C=100,G=!1,L=0,R="#ffffff",y=-1,D=0,O=18e4,x=0,A=36e5,k=0,U=0,V=0,W=0,F=!1,M=!1,H=0,B=null,j=null,$="",q="",z="",K="",X="",J="",Y="",Q="",Z="",ee="",ne=-1,te=null,oe=!1,ie=webphone_api.stringres.get("status_startingengine"),ae=webphone_api.stringres.get("status_enginestarted"),re="",le=-1,se=null,pe=0,ce=35,ue="",ge=-1,he="",me="",de=-1,be=9e3,_e=24e3,fe=!0,we=!0,ve=!1,Ee=0,Pe=0,Te="",Se=0,Ne="",Ie=null,Ce=null,Ge=null,Le=null,Re=null,ye=0,De="",Oe="",xe=0,Ae=webphone_api.stringres.get("disc_reason"),ke=null,Ue=webphone_api.stringres.get("ns_engine_unreachable"),Ve=0;return{ProcessNotifications:n,GetStatus:s,AddToCallLog:i,SetCallStartTime:t,IsGoodCRC:p,OnMessageReceived:a}}();