function ISKeyValueList(){function u(){var t=0;for(var i in n)t+=1;return t}function f(t){t=t.toUpperCase();for(var i in n)if(i.toUpperCase()==t)return!0;return!1}function e(t){n={};i(t)}function i(t){var i,e;if(t!="undefined"){t+="";t.substring(0,1)=="?"&&(t=t.substr(1));var u=t.split("&"),r,f;for(i=0;i<u.length;i++)e=u[i].indexOf("="),e>0?(r=u[i].substring(0,e),f=u[i].substr(e+1)):(r=u[i],f=""),r=decodeURIComponent(r),f=decodeURIComponent(f),r&&(n[r]=f)}}function o(n){if(n)for(var t in n)r(t,n[t])}function t(t,i){i===undefined&&(i=null);t=t.toUpperCase();for(var r in n)if(r.toUpperCase()===t)return n[r];return i}function s(n,i){return i===undefined&&(i=!1),(t(n,i)+"").toUpperCase()=="TRUE"}function h(n,i){i===undefined&&(i=0);var r=parseInt(t(n,i));return isNaN(r)&&(r=0),r}function c(n,i){return i===undefined&&(i=""),t(n,i)+""}function r(t,i){for(var r in n)if(r.toUpperCase()===t.toUpperCase()){n[r]=i;return}n[t]=i}function l(n,t){r(n,t)}function a(t){var i="",r;t=t.toUpperCase();for(r in n)if(r.toUpperCase()==t){i=r;break}i&&delete n[i]}function v(){var t={};for(var i in n)t[i]=n[i];return t}function y(){var t="";for(var i in n)t!=""&&(t+="&"),typeof n[i]=="object"||(t+=encodeURIComponent(i)+"="+encodeURIComponent(n[i]));return t}var n={};return{TypeName:"ISKeyValueList",Count:u,Exists:f,FromUrlString:e,AppendFromUrlString:i,AppendFromJavaScriptObject:o,GetBoolean:s,GetInteger:h,GetItem:t,GetString:c,SetString:l,Remove:a,ToJavaScriptObject:v,ToUrlString:y}}function ISRanges(n,t){function f(n,t){var r=new ISRange;i.push(r);r.RangeType="Single";r.RangeBegin=n;r.RangeExclude=t}function e(){return i.length}function u(t){var f=0,e="",c=!1,u,h,o,r,s;for(i=[],t=t.replace(/!\"/g,'"{NOT}'),u=n.ArrayFromCsvString(t,",",!0),f=0;f<u.length;f++)u[f].startsWith("{NOT}")&&(u[f]="!"+u[f].substr(5)),u[f].startsWith('"{NOT}')&&(u[f]='!"'+u[f].substr(6));for(h=0;h<u.length;h++)o=u[h],o.startsWith("!")?(c=!0,o=o.slice(1)):c=!1,e=n.Trim(o),e&&(r=new ISRange,r.RangeExclude=c,s=n.ArrayFromCsvString(e,"-"),s.length>0&&(r.RangeBegin=s[0]),s.length>1&&(r.RangeEnd=s[1]),r.RangeEnd||e.endsWith("-")?r.RangeBegin==r.RangeEnd?(r.RangeType="Single",r.RangeEnd=""):r.RangeType="Range":r.RangeType=r.RangeBegin.toUpperCase()=="<NULL>"?"Null":e.startsWith('"')&&!r.RangeEnd?"Single":r.RangeBegin.indexOf("*")==-1&&r.RangeBegin.indexOf("?")==-1?"Single":"Wildcard",i.push(r))}function o(n,t,r){var f,e,u;r||(r={});r.matchedIndex=-1;t==undefined&&(t=!1);r.matchedIndex=0;var o=!1,s=!1,h=!1;if(i.length==0)return!t;for(f=0;f<i.length;f++){e=!1;u=i[f];switch(u.RangeType){case"Null":n&&(n+"").toUpperCase()!="<NULL>"||(r.matchedIndex=f,e=!0);break;case"Single":(n+"").toUpperCase()==u.RangeBegin.toUpperCase()&&(r.matchedIndex=f,e=!0);break;case"Range":(n+"").toUpperCase()>=u.RangeBegin.toUpperCase()&&(!u.RangeEnd||(n+"").toUpperCase()<=u.RangeEnd.toUpperCase())&&(r.matchedIndex=f,e=!0);break;case"Wildcard":(n+"").like(u.RangeBegin)&&(r.matchedIndex=f,e=!0);break;default:console.warn("Unhandled range type '"+u.RangeType+"' in ISRanges.IsValueInRange.")}if(e)if(u.RangeExclude){o=!0;break}else s=!0;else u.RangeExclude||(h=!0)}return o?t:s?!t:t?!1:!h}function s(n){return n>-1&&n<i.length?i[n]:null}function h(n){n>-1&&n<i.length&&i.splice(n,1)}function c(){for(var n,t,u="",f=0;f<i.length;f++){n=i[f];t="";switch(n.RangeType){case"Null":t="<NULL>";break;case"Single":t=r(n.RangeBegin);break;case"Wildcard":t=r(n.RangeBegin)+"-"+r(n.RangeEnd);break;default:console.warn("Unhandled range type '"+n.RangeType+"' in ISRanges.ToRangeString.")}n.RangeExclude&&(t="!"+t);u&&(u+=",");u+=t}return u}function r(t){return t.indexOf("'")==-1&&t.indexOf(",")==-1&&t.indexOf("-")==-1&&t.indexOf("*")==-1&&t.indexOf("?")==-1&&n.Trim(t)==t?t:"'"+t.replace(/\'\"/g,"''")+"'"}var i=[];return t&&u(t),{AddSingle:f,Count:e,FromRangeString:u,IsValueInRange:o,Item:s,RemoveAt:h,ToRangeString:c}}function ISRange(){return{RangeType:"",RangeBegin:"",RangeEnd:"",RangeExclude:!1}}function ISUrlFragments(n,t){function f(){var n=0;for(var t in i)n+=1;return n}function e(n){n=n.toUpperCase();for(var t in i)if(t.toUpperCase()==n)return!0;return!1}function o(n){var t=0;for(var r in i){if(t==n)return i[r];t+=1}}function u(t){var f,u,s;for(r=t?t.substring(0,1)=="?"?t.substr(1):t.substring(0,1)=="#"?t.substr(1):t:"",i={},f=r.split("/"),u=0;u<f.length;u++){var h=f[u].split("?"),e=decodeURIComponent(h[0]),o=decodeURIComponent(h[1]);e&&(s=n.CreateKeyValueList(),o&&s.FromUrlString(o),i[e.toUpperCase()]={actionId:e,paramsRaw:o,params:s})}}function s(n){var t="",r;n=n.toUpperCase();for(r in i)if(r.toUpperCase()==n){t=r;break}t&&delete i[t]}function h(){var n="",r,t;for(r in i)t=i[r],n!=""&&(n+="/"),n+=encodeURIComponent(t.actionId),t.params.Count()!=0&&(n+="?"+t.params.ToUrlString());return n}function c(t,r){var u,e;for(var f in i)f.toUpperCase()==t.toUpperCase()&&(u=i[f]);if(u||(e=n.CreateKeyValueList(),u={actionId:t,paramsRaw:r,params:e},i[t.toUpperCase()]=u),r)for(f in r)u.params.SetString(f,r[f])}var r,i={};return u(t),{Count:f,Exists:e,FromUrlString:u,Item:o,Remove:s,ToUrlString:h,Update:c}}function ISWidgetProxy(n){function i(n){return t.ActionNotificationHandle(n)}function r(n,i,r,u){return t.ActionNotificationSend(n,i,r,u)}function u(n,i){return t.Generic().ArrayAllowLookupById(n,i)}function f(n,i){return t.Generic().ArrayRemove(n,i)}function e(n){return t.Generic().ArrayToCodeDescriptionList(n)}function o(){return t.CanClose()}function s(n,i){return t.Chain(n,i)}function h(){return t.Close()}function c(){return $Runtime.CurrencyDecimals()}function l(){return $Runtime.CurrencySymbol()}function a(){return $Runtime.DayMonthYearOrder()}function v(){t.DisableCloseButton()}function y(n,i,r,u){t.DownloadFile(n,i,r,u)}function p(n){return t.ExecuteApplicationShortcutUrl(n)}function w(n){return t.Generic().FormatCardExpiryDate(n)}function b(n,i,r){return t.Generic().FormatCurrency(n,i,r)}function k(n){return t.Generic().FormatDate(n)}function d(n,i,r){return t.Generic().FormatDateInternal(n,i,r)}function g(n,i){return t.Generic().FormatDateTime(n,i)}function nt(n,i,r){return t.Generic().FormatDateForGrid(n,i,r)}function tt(n){return t.Generic().FormatUtcDate(n)}function it(n){return t.Generic().FormatUtcDateTime(n)}function rt(n,i,r,u){return t.Generic().FormatNumber(n,i,r,u)}function ut(n,t,i,r){return $Api.GetIconUrl(n,t,i,r)}function ft(n,t,i){return $Api.GetResourceImageUrl(n,t,i)}function et(){return t.Generic().GetHostingContext()}function ot(n,i){return t.Generic().GetWeekDayName(n,i)}function st(n,i){return t.Generic().GetWeekDayNameFromDate(n,i)}function ht(n,i,r,u){t.GetString(n,i,r,u)}function ct(n,i,r,u){t.SystemDownloadFile(n,i,r,u)}function lt(n,i,r,u){t.SystemGetString(n,i,r,u)}function at(){return t.IsAuthenticated()}function vt(){return t.NotifyBusy()}function yt(n,i,r,u,f,e){t.NotificationAdd(n,i,r,u,f,e)}function pt(n,i){t.ParentNotify(n,i)}function wt(n){return $Runtime.ParseNumber(""+n,-1)}function bt(n,t){var i=$Runtime.ParseDate(n,t,!1);return i?new Date(Date.UTC(i.getFullYear(),i.getMonth(),i.getDate(),0,0,0)):null}function kt(n,t){return $Runtime.ParseNumber(""+n,t)}function dt(n,i){t.RefreshParent(n,i)}function gt(n,i){t.RegisterError(n,i)}function ni(n,i,r,u){return t.RequestFormInternal(n,i,r,u)}function ti(){t.Reset()}function ii(n,i){t.ResetScheduled(n,i)}function ri(n){t.ResetHandle(n)}function ui(n){t.SetHeading(n)}function fi(n){t.SetHeadingIcon(n)}function ei(n){t.SetHeadingStyle(n)}function oi(n){t.SizeToFit(n)}function si(n,i,r,u,f){t.UploadFiles(n,i,r,u,f)}function hi(n){return t.Generic().Trim(n)}function ci(n){return t.Generic().LTrim(n)}function li(n){return t.Generic().RTrim(n)}function ai(n,i,r){return t.Generic().SplitWordsAtCapitals(n,i,r)}function vi(n){return t.Generic().ArrayFromCsvString(n)}function yi(n){return t.Generic().ArrayToCsvString(n)}function pi(){return t.Generic().Version()}function wi(n,i){return t.Generic().Round(n,i)}function bi(n){return t.Generic().RoundCurrency(n)}function ki(n){return t.Generic().RoundCurrencyDown(n)}function di(n){return t.Generic().RoundCurrencyUp(n)}function gi(n,i){return t.Generic().CompareDates(n,i)}function nr(){return t.Generic().ThemeContrastColourBackground()}function tr(){return t.Generic().ThemeContrastColourForeground()}function ir(){return t.Generic().ThemeMainColourBackground()}function rr(){return t.Generic().ThemeMainColourForeground()}var t=n;return{ActionNotificationHandle:i,ActionNotificationSend:r,ArrayAllowLookupById:u,ArrayRemove:f,ArrayToCodeDescriptionList:e,CanClose:o,Chain:s,Close:h,CompareDates:gi,CurrencyDecimals:c,CurrencySymbol:l,DayMonthYearOrder:a,DisableCloseButton:v,DownloadFile:y,ExecuteApplicationShortcutUrl:p,FormatCardExpiryDate:w,FormatCurrency:b,FormatDate:k,FormatDateTime:g,FormatDateForGrid:nt,FormatUtcDate:tt,FormatUtcDateTime:it,FormatNumber:rt,GetHostingContext:et,GetIconUrl:ut,GetResourceImageUrl:ft,GetString:ht,GetWeekDayName:ot,GetWeekDayNameFromDate:st,UploadFiles:si,NotificationAdd:yt,IsAuthenticated:at,NotifyBusy:vt,ParseCurrency:wt,ParseDate:bt,ParseNumber:kt,ParentNotify:pt,Round:wi,RoundCurrency:bi,RoundCurrencyDown:ki,RoundCurrencyUp:di,RegisterError:gt,RefreshParent:dt,Reset:ti,ResetScheduled:ii,ResetHandle:ri,SetHeading:ui,SetHeadingIcon:fi,SetHeadingStyle:ei,SizeToFit:oi,ThemeContrastColourBackground:nr,ThemeContrastColourForeground:tr,ThemeMainColourBackground:ir,ThemeMainColourForeground:rr,_SystemDownloadFile:ct,_SystemGetString:lt,Options:n.Options,Trim:hi,LTrim:ci,RTrim:li,SplitWordsAtCapitals:ai,ArrayFromCsvString:vi,ArrayToCsvString:yi,Version:pi,IsHighDpi:function(){return $Runtime.IsHighDpi()},FormatDateInternal:d,__requestForm:ni,__modal:n.__modal,__widget:n}}var __UIExtDates,__UIExtGrid,__UIExtFinC,__UIExtNavigation,__UIExtPreviewPane,__UIExtRecordForm,__UIExtRecordTabs,__UIExtWidget,__UIExtParametersHost,__UIExtDocumentManager,__UIExtTreeView,__UIExtSmartList,widget,__WidgetUI;(function(n,t){typeof module=="object"&&typeof module.exports=="object"?module.exports=n.document?t(n,!0):function(n){if(!n.document)throw new Error("jQuery requires a window with a document");return t(n)}:t(n)})(typeof window!="undefined"?window:this,function(n,t){function ri(n){var t="length"in n&&n.length,r=i.type(n);return r==="function"||i.isWindow(n)?!1:n.nodeType===1&&t?!0:r==="array"||t===0||typeof t=="number"&&t>0&&t-1 in n}function ui(n,t,r){if(i.isFunction(t))return i.grep(n,function(n,i){return!!t.call(n,i,n)!==r});if(t.nodeType)return i.grep(n,function(n){return n===t!==r});if(typeof t=="string"){if(ef.test(t))return i.filter(t,n,r);t=i.filter(t,n)}return i.grep(n,function(n){return ft.call(t,n)>=0!==r})}function ur(n,t){while((n=n[t])&&n.nodeType!==1);return n}function of(n){var t=fi[n]={};return i.each(n.match(c)||[],function(n,i){t[i]=!0}),t}function ht(){u.removeEventListener("DOMContentLoaded",ht,!1);n.removeEventListener("load",ht,!1);i.ready()}function v(){Object.defineProperty(this.cache={},0,{get:function(){return{}}});this.expando=i.expando+v.uid++}function fr(n,t,r){var u;if(r===undefined&&n.nodeType===1)if(u="data-"+t.replace(hf,"-$1").toLowerCase(),r=n.getAttribute(u),typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:sf.test(r)?i.parseJSON(r):r}catch(f){}e.set(n,t,r)}else r=undefined;return r}function lt(){return!0}function k(){return!1}function hr(){try{return u.activeElement}catch(n){}}function vr(n,t){return i.nodeName(n,"table")&&i.nodeName(t.nodeType!==11?t:t.firstChild,"tr")?n.getElementsByTagName("tbody")[0]||n.appendChild(n.ownerDocument.createElement("tbody")):n}function bf(n){return n.type=(n.getAttribute("type")!==null)+"/"+n.type,n}function kf(n){var t=pf.exec(n.type);return t?n.type=t[1]:n.removeAttribute("type"),n}function ei(n,t){for(var i=0,u=n.length;i<u;i++)r.set(n[i],"globalEval",!t||r.get(t[i],"globalEval"))}function yr(n,t){var f,c,o,s,h,l,a,u;if(t.nodeType===1){if(r.hasData(n)&&(s=r.access(n),h=r.set(t,s),u=s.events,u)){delete h.handle;h.events={};for(o in u)for(f=0,c=u[o].length;f<c;f++)i.event.add(t,o,u[o][f])}e.hasData(n)&&(l=e.access(n),a=i.extend({},l),e.set(t,a))}}function o(n,t){var r=n.getElementsByTagName?n.getElementsByTagName(t||"*"):n.querySelectorAll?n.querySelectorAll(t||"*"):[];return t===undefined||t&&i.nodeName(n,t)?i.merge([n],r):r}function df(n,t){var i=t.nodeName.toLowerCase();i==="input"&&er.test(n.type)?t.checked=n.checked:(i==="input"||i==="textarea")&&(t.defaultValue=n.defaultValue)}function pr(t,r){var f,u=i(r.createElement(t)).appendTo(r.body),e=n.getDefaultComputedStyle&&(f=n.getDefaultComputedStyle(u[0]))?f.display:i.css(u[0],"display");return u.detach(),e}function si(n){var r=u,t=oi[n];return t||(t=pr(n,r),t!=="none"&&t||(at=(at||i("<iframe frameborder='0' width='0' height='0'/>")).appendTo(r.documentElement),r=at[0].contentDocument,r.write(),r.close(),t=pr(n,r),at.detach()),oi[n]=t),t}function it(n,t,r){var e,o,s,u,f=n.style;return r=r||vt(n),r&&(u=r.getPropertyValue(t)||r[t]),r&&(u!==""||i.contains(n.ownerDocument,n)||(u=i.style(n,t)),hi.test(u)&&wr.test(t)&&(e=f.width,o=f.minWidth,s=f.maxWidth,f.minWidth=f.maxWidth=f.width=u,u=r.width,f.width=e,f.minWidth=o,f.maxWidth=s)),u!==undefined?u+"":u}function br(n,t){return{get:function(){if(n()){delete this.get;return}return(this.get=t).apply(this,arguments)}}}function gr(n,t){if(t in n)return t;for(var r=t[0].toUpperCase()+t.slice(1),u=t,i=dr.length;i--;)if(t=dr[i]+r,t in n)return t;return u}function nu(n,t,i){var r=ne.exec(t);return r?Math.max(0,r[1]-(i||0))+(r[2]||"px"):t}function tu(n,t,r,u,f){for(var e=r===(u?"border":"content")?4:t==="width"?1:0,o=0;e<4;e+=2)r==="margin"&&(o+=i.css(n,r+p[e],!0,f)),u?(r==="content"&&(o-=i.css(n,"padding"+p[e],!0,f)),r!=="margin"&&(o-=i.css(n,"border"+p[e]+"Width",!0,f))):(o+=i.css(n,"padding"+p[e],!0,f),r!=="padding"&&(o+=i.css(n,"border"+p[e]+"Width",!0,f)));return o}function iu(n,t,r){var o=!0,u=t==="width"?n.offsetWidth:n.offsetHeight,e=vt(n),s=i.css(n,"boxSizing",!1,e)==="border-box";if(u<=0||u==null){if(u=it(n,t,e),(u<0||u==null)&&(u=n.style[t]),hi.test(u))return u;o=s&&(f.boxSizingReliable()||u===n.style[t]);u=parseFloat(u)||0}return u+tu(n,t,r||(s?"border":"content"),o,e)+"px"}function ru(n,t){for(var e,u,s,o=[],f=0,h=n.length;f<h;f++)(u=n[f],u.style)&&(o[f]=r.get(u,"olddisplay"),e=u.style.display,t?(o[f]||e!=="none"||(u.style.display=""),u.style.display===""&&tt(u)&&(o[f]=r.access(u,"olddisplay",si(u.nodeName)))):(s=tt(u),e==="none"&&s||r.set(u,"olddisplay",s?e:i.css(u,"display"))));for(f=0;f<h;f++)(u=n[f],u.style)&&(t&&u.style.display!=="none"&&u.style.display!==""||(u.style.display=t?o[f]||"":"none"));return n}function s(n,t,i,r,u){return new s.prototype.init(n,t,i,r,u)}function fu(){return setTimeout(function(){d=undefined}),d=i.now()}function wt(n,t){var r,u=0,i={height:n};for(t=t?1:0;u<4;u+=2-t)r=p[u],i["margin"+r]=i["padding"+r]=n;return t&&(i.opacity=i.width=n),i}function eu(n,t,i){for(var u,f=(rt[t]||[]).concat(rt["*"]),r=0,e=f.length;r<e;r++)if(u=f[r].call(i,t,n))return u}function fe(n,t,u){var f,a,p,v,o,w,h,b,l=this,y={},s=n.style,c=n.nodeType&&tt(n),e=r.get(n,"fxshow");u.queue||(o=i._queueHooks(n,"fx"),o.unqueued==null&&(o.unqueued=0,w=o.empty.fire,o.empty.fire=function(){o.unqueued||w()}),o.unqueued++,l.always(function(){l.always(function(){o.unqueued--;i.queue(n,"fx").length||o.empty.fire()})}));n.nodeType===1&&("height"in t||"width"in t)&&(u.overflow=[s.overflow,s.overflowX,s.overflowY],h=i.css(n,"display"),b=h==="none"?r.get(n,"olddisplay")||si(n.nodeName):h,b==="inline"&&i.css(n,"float")==="none"&&(s.display="inline-block"));u.overflow&&(s.overflow="hidden",l.always(function(){s.overflow=u.overflow[0];s.overflowX=u.overflow[1];s.overflowY=u.overflow[2]}));for(f in t)if(a=t[f],re.exec(a)){if(delete t[f],p=p||a==="toggle",a===(c?"hide":"show"))if(a==="show"&&e&&e[f]!==undefined)c=!0;else continue;y[f]=e&&e[f]||i.style(n,f)}else h=undefined;if(i.isEmptyObject(y))(h==="none"?si(n.nodeName):h)==="inline"&&(s.display=h);else{e?"hidden"in e&&(c=e.hidden):e=r.access(n,"fxshow",{});p&&(e.hidden=!c);c?i(n).show():l.done(function(){i(n).hide()});l.done(function(){var t;r.remove(n,"fxshow");for(t in y)i.style(n,t,y[t])});for(f in y)v=eu(c?e[f]:0,f,l),f in e||(e[f]=v.start,c&&(v.end=v.start,v.start=f==="width"||f==="height"?1:0))}}function ee(n,t){var r,f,e,u,o;for(r in n)if(f=i.camelCase(r),e=t[f],u=n[r],i.isArray(u)&&(e=u[1],u=n[r]=u[0]),r!==f&&(n[f]=u,delete n[r]),o=i.cssHooks[f],o&&"expand"in o){u=o.expand(u);delete n[f];for(r in u)r in n||(n[r]=u[r],t[r]=e)}else t[f]=e}function ou(n,t,r){var e,o,s=0,l=pt.length,f=i.Deferred().always(function(){delete c.elem}),c=function(){if(o)return!1;for(var s=d||fu(),t=Math.max(0,u.startTime+u.duration-s),h=t/u.duration||0,i=1-h,r=0,e=u.tweens.length;r<e;r++)u.tweens[r].run(i);return f.notifyWith(n,[u,i,t]),i<1&&e?t:(f.resolveWith(n,[u]),!1)},u=f.promise({elem:n,props:i.extend({},t),opts:i.extend(!0,{specialEasing:{}},r),originalProperties:t,originalOptions:r,startTime:d||fu(),duration:r.duration,tweens:[],createTween:function(t,r){var f=i.Tween(n,u.opts,t,r,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(f),f},stop:function(t){var i=0,r=t?u.tweens.length:0;if(o)return this;for(o=!0;i<r;i++)u.tweens[i].run(1);return t?f.resolveWith(n,[u,t]):f.rejectWith(n,[u,t]),this}}),h=u.props;for(ee(h,u.opts.specialEasing);s<l;s++)if(e=pt[s].call(u,n,h,u.opts),e)return e;return i.map(h,eu,u),i.isFunction(u.opts.start)&&u.opts.start.call(n,u),i.fx.timer(i.extend(c,{elem:n,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function pu(n){return function(t,r){typeof t!="string"&&(r=t,t="*");var u,f=0,e=t.toLowerCase().match(c)||[];if(i.isFunction(r))while(u=e[f++])u[0]==="+"?(u=u.slice(1)||"*",(n[u]=n[u]||[]).unshift(r)):(n[u]=n[u]||[]).push(r)}}function wu(n,t,r,u){function e(s){var h;return f[s]=!0,i.each(n[s]||[],function(n,i){var s=i(t,r,u);if(typeof s!="string"||o||f[s]){if(o)return!(h=s)}else return t.dataTypes.unshift(s),e(s),!1}),h}var f={},o=n===ci;return e(t.dataTypes[0])||!f["*"]&&e("*")}function ai(n,t){var r,u,f=i.ajaxSettings.flatOptions||{};for(r in t)t[r]!==undefined&&((f[r]?n:u||(u={}))[r]=t[r]);return u&&i.extend(!0,n,u),n}function ae(n,t,i){for(var e,u,f,o,s=n.contents,r=n.dataTypes;r[0]==="*";)r.shift(),e===undefined&&(e=n.mimeType||t.getResponseHeader("Content-Type"));if(e)for(u in s)if(s[u]&&s[u].test(e)){r.unshift(u);break}if(r[0]in i)f=r[0];else{for(u in i){if(!r[0]||n.converters[u+" "+r[0]]){f=u;break}o||(o=u)}f=f||o}if(f)return f!==r[0]&&r.unshift(f),i[f]}function ve(n,t,i,r){var h,u,f,s,e,o={},c=n.dataTypes.slice();if(c[1])for(f in n.converters)o[f.toLowerCase()]=n.converters[f];for(u=c.shift();u;)if(n.responseFields[u]&&(i[n.responseFields[u]]=t),!e&&r&&n.dataFilter&&(t=n.dataFilter(t,n.dataType)),e=u,u=c.shift(),u)if(u==="*")u=e;else if(e!=="*"&&e!==u){if(f=o[e+" "+u]||o["* "+u],!f)for(h in o)if(s=h.split(" "),s[1]===u&&(f=o[e+" "+s[0]]||o["* "+s[0]],f)){f===!0?f=o[h]:o[h]!==!0&&(u=s[0],c.unshift(s[1]));break}if(f!==!0)if(f&&n.throws)t=f(t);else try{t=f(t)}catch(l){return{state:"parsererror",error:f?l:"No conversion from "+e+" to "+u}}}return{state:"success",data:t}}function vi(n,t,r,u){var f;if(i.isArray(t))i.each(t,function(t,i){r||pe.test(n)?u(n,i):vi(n+"["+(typeof i=="object"?t:"")+"]",i,r,u)});else if(r||i.type(t)!=="object")u(n,t);else for(f in t)vi(n+"["+f+"]",t[f],r,u)}function ku(n){return i.isWindow(n)?n:n.nodeType===9&&n.defaultView}var w=[],a=w.slice,bi=w.concat,ti=w.push,ft=w.indexOf,et={},nf=et.toString,ii=et.hasOwnProperty,f={},u=n.document,ki="2.1.4",i=function(n,t){return new i.fn.init(n,t)},tf=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,rf=/^-ms-/,uf=/-([\da-z])/gi,ff=function(n,t){return t.toUpperCase()},y,ot,nr,tr,ir,rr,c,fi,st,l,b,at,oi,oe,su,g,hu,bt,cu,kt,dt,yi,ni,pi,wi,du,gu;i.fn=i.prototype={jquery:ki,constructor:i,selector:"",length:0,toArray:function(){return a.call(this)},get:function(n){return n!=null?n<0?this[n+this.length]:this[n]:a.call(this)},pushStack:function(n){var t=i.merge(this.constructor(),n);return t.prevObject=this,t.context=this.context,t},each:function(n,t){return i.each(this,n,t)},map:function(n){return this.pushStack(i.map(this,function(t,i){return n.call(t,i,t)}))},slice:function(){return this.pushStack(a.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(n){var i=this.length,t=+n+(n<0?i:0);return this.pushStack(t>=0&&t<i?[this[t]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:ti,sort:w.sort,splice:w.splice};i.extend=i.fn.extend=function(){var e,f,r,t,o,s,n=arguments[0]||{},u=1,c=arguments.length,h=!1;for(typeof n=="boolean"&&(h=n,n=arguments[u]||{},u++),typeof n=="object"||i.isFunction(n)||(n={}),u===c&&(n=this,u--);u<c;u++)if((e=arguments[u])!=null)for(f in e)(r=n[f],t=e[f],n!==t)&&(h&&t&&(i.isPlainObject(t)||(o=i.isArray(t)))?(o?(o=!1,s=r&&i.isArray(r)?r:[]):s=r&&i.isPlainObject(r)?r:{},n[f]=i.extend(h,s,t)):t!==undefined&&(n[f]=t));return n};i.extend({expando:"jQuery"+(ki+Math.random()).replace(/\D/g,""),isReady:!0,error:function(n){throw new Error(n);},noop:function(){},isFunction:function(n){return i.type(n)==="function"},isArray:Array.isArray,isWindow:function(n){return n!=null&&n===n.window},isNumeric:function(n){return!i.isArray(n)&&n-parseFloat(n)+1>=0},isPlainObject:function(n){return i.type(n)!=="object"||n.nodeType||i.isWindow(n)?!1:n.constructor&&!ii.call(n.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(n){for(var t in n)return!1;return!0},type:function(n){return n==null?n+"":typeof n=="object"||typeof n=="function"?et[nf.call(n)]||"object":typeof n},globalEval:function(n){var t,r=eval;n=i.trim(n);n&&(n.indexOf("use strict")===1?(t=u.createElement("script"),t.text=n,u.head.appendChild(t).parentNode.removeChild(t)):r(n))},camelCase:function(n){return n.replace(rf,"ms-").replace(uf,ff)},nodeName:function(n,t){return n.nodeName&&n.nodeName.toLowerCase()===t.toLowerCase()},each:function(n,t,i){var u,r=0,f=n.length,e=ri(n);if(i){if(e){for(;r<f;r++)if(u=t.apply(n[r],i),u===!1)break}else for(r in n)if(u=t.apply(n[r],i),u===!1)break}else if(e){for(;r<f;r++)if(u=t.call(n[r],r,n[r]),u===!1)break}else for(r in n)if(u=t.call(n[r],r,n[r]),u===!1)break;return n},trim:function(n){return n==null?"":(n+"").replace(tf,"")},makeArray:function(n,t){var r=t||[];return n!=null&&(ri(Object(n))?i.merge(r,typeof n=="string"?[n]:n):ti.call(r,n)),r},inArray:function(n,t,i){return t==null?-1:ft.call(t,n,i)},merge:function(n,t){for(var u=+t.length,i=0,r=n.length;i<u;i++)n[r++]=t[i];return n.length=r,n},grep:function(n,t,i){for(var u,f=[],r=0,e=n.length,o=!i;r<e;r++)u=!t(n[r],r),u!==o&&f.push(n[r]);return f},map:function(n,t,i){var u,r=0,e=n.length,o=ri(n),f=[];if(o)for(;r<e;r++)u=t(n[r],r,i),u!=null&&f.push(u);else for(r in n)u=t(n[r],r,i),u!=null&&f.push(u);return bi.apply([],f)},guid:1,proxy:function(n,t){var u,f,r;return(typeof t=="string"&&(u=n[t],t=n,n=u),!i.isFunction(n))?undefined:(f=a.call(arguments,2),r=function(){return n.apply(t||this,f.concat(a.call(arguments)))},r.guid=n.guid=n.guid||i.guid++,r)},now:Date.now,support:f});i.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(n,t){et["[object "+t+"]"]=t.toLowerCase()});y=function(n){function r(n,t,i,r){var p,s,a,c,w,y,d,v,nt,g;if((t?t.ownerDocument||t:h)!==o&&k(t),t=t||o,i=i||[],c=t.nodeType,typeof n!="string"||!n||c!==1&&c!==9&&c!==11)return i;if(!r&&l){if(c!==11&&(p=hr.exec(n)))if(a=p[1]){if(c===9)if(s=t.getElementById(a),s&&s.parentNode){if(s.id===a)return i.push(s),i}else return i;else if(t.ownerDocument&&(s=t.ownerDocument.getElementById(a))&&et(t,s)&&s.id===a)return i.push(s),i}else{if(p[2])return b.apply(i,t.getElementsByTagName(n)),i;if((a=p[3])&&u.getElementsByClassName)return b.apply(i,t.getElementsByClassName(a)),i}if(u.qsa&&(!e||!e.test(n))){if(v=d=f,nt=t,g=c!==1&&n,c===1&&t.nodeName.toLowerCase()!=="object"){for(y=ft(n),(d=t.getAttribute("id"))?v=d.replace(cr,"\\$&"):t.setAttribute("id",v),v="[id='"+v+"'] ",w=y.length;w--;)y[w]=v+vt(y[w]);nt=dt.test(n)&&ti(t.parentNode)||t;g=y.join(",")}if(g)try{return b.apply(i,nt.querySelectorAll(g)),i}catch(tt){}finally{d||t.removeAttribute("id")}}}return oi(n.replace(lt,"$1"),t,i,r)}function gt(){function n(r,u){return i.push(r+" ")>t.cacheLength&&delete n[i.shift()],n[r+" "]=u}var i=[];return n}function c(n){return n[f]=!0,n}function v(n){var t=o.createElement("div");try{return!!n(t)}catch(i){return!1}finally{t.parentNode&&t.parentNode.removeChild(t);t=null}}function ni(n,i){for(var u=n.split("|"),r=n.length;r--;)t.attrHandle[u[r]]=i}function wi(n,t){var i=t&&n,r=i&&n.nodeType===1&&t.nodeType===1&&(~t.sourceIndex||li)-(~n.sourceIndex||li);if(r)return r;if(i)while(i=i.nextSibling)if(i===t)return-1;return n?1:-1}function lr(n){return function(t){var i=t.nodeName.toLowerCase();return i==="input"&&t.type===n}}function ar(n){return function(t){var i=t.nodeName.toLowerCase();return(i==="input"||i==="button")&&t.type===n}}function tt(n){return c(function(t){return t=+t,c(function(i,r){for(var u,f=n([],i.length,t),e=f.length;e--;)i[u=f[e]]&&(i[u]=!(r[u]=i[u]))})})}function ti(n){return n&&typeof n.getElementsByTagName!="undefined"&&n}function bi(){}function vt(n){for(var t=0,r=n.length,i="";t<r;t++)i+=n[t].value;return i}function ii(n,t,i){var r=t.dir,u=i&&r==="parentNode",e=ki++;return t.first?function(t,i,f){while(t=t[r])if(t.nodeType===1||u)return n(t,i,f)}:function(t,i,o){var s,h,c=[a,e];if(o){while(t=t[r])if((t.nodeType===1||u)&&n(t,i,o))return!0}else while(t=t[r])if(t.nodeType===1||u){if(h=t[f]||(t[f]={}),(s=h[r])&&s[0]===a&&s[1]===e)return c[2]=s[2];if(h[r]=c,c[2]=n(t,i,o))return!0}}}function ri(n){return n.length>1?function(t,i,r){for(var u=n.length;u--;)if(!n[u](t,i,r))return!1;return!0}:n[0]}function vr(n,t,i){for(var u=0,f=t.length;u<f;u++)r(n,t[u],i);return i}function yt(n,t,i,r,u){for(var e,o=[],f=0,s=n.length,h=t!=null;f<s;f++)(e=n[f])&&(!i||i(e,r,u))&&(o.push(e),h&&t.push(f));return o}function ui(n,t,i,r,u,e){return r&&!r[f]&&(r=ui(r)),u&&!u[f]&&(u=ui(u,e)),c(function(f,e,o,s){var l,c,a,p=[],y=[],w=e.length,k=f||vr(t||"*",o.nodeType?[o]:o,[]),v=n&&(f||!t)?yt(k,p,n,o,s):k,h=i?u||(f?n:w||r)?[]:e:v;if(i&&i(v,h,o,s),r)for(l=yt(h,y),r(l,[],o,s),c=l.length;c--;)(a=l[c])&&(h[y[c]]=!(v[y[c]]=a));if(f){if(u||n){if(u){for(l=[],c=h.length;c--;)(a=h[c])&&l.push(v[c]=a);u(null,h=[],l,s)}for(c=h.length;c--;)(a=h[c])&&(l=u?nt(f,a):p[c])>-1&&(f[l]=!(e[l]=a))}}else h=yt(h===e?h.splice(w,h.length):h),u?u(null,e,h,s):b.apply(e,h)})}function fi(n){for(var o,u,r,s=n.length,h=t.relative[n[0].type],c=h||t.relative[" "],i=h?1:0,l=ii(function(n){return n===o},c,!0),a=ii(function(n){return nt(o,n)>-1},c,!0),e=[function(n,t,i){var r=!h&&(i||t!==ht)||((o=t).nodeType?l(n,t,i):a(n,t,i));return o=null,r}];i<s;i++)if(u=t.relative[n[i].type])e=[ii(ri(e),u)];else{if(u=t.filter[n[i].type].apply(null,n[i].matches),u[f]){for(r=++i;r<s;r++)if(t.relative[n[r].type])break;return ui(i>1&&ri(e),i>1&&vt(n.slice(0,i-1).concat({value:n[i-2].type===" "?"*":""})).replace(lt,"$1"),u,i<r&&fi(n.slice(i,r)),r<s&&fi(n=n.slice(r)),r<s&&vt(n))}e.push(u)}return ri(e)}function yr(n,i){var u=i.length>0,f=n.length>0,e=function(e,s,h,c,l){var y,d,w,k=0,v="0",g=e&&[],p=[],nt=ht,tt=e||f&&t.find.TAG("*",l),it=a+=nt==null?1:Math.random()||.1,rt=tt.length;for(l&&(ht=s!==o&&s);v!==rt&&(y=tt[v])!=null;v++){if(f&&y){for(d=0;w=n[d++];)if(w(y,s,h)){c.push(y);break}l&&(a=it)}u&&((y=!w&&y)&&k--,e&&g.push(y))}if(k+=v,u&&v!==k){for(d=0;w=i[d++];)w(g,p,s,h);if(e){if(k>0)while(v--)g[v]||p[v]||(p[v]=gi.call(c));p=yt(p)}b.apply(c,p);l&&!e&&p.length>0&&k+i.length>1&&r.uniqueSort(c)}return l&&(a=it,ht=nt),g};return u?c(e):e}var it,u,t,st,ei,ft,pt,oi,ht,w,rt,k,o,s,l,e,d,ct,et,f="sizzle"+1*new Date,h=n.document,a=0,ki=0,si=gt(),hi=gt(),ci=gt(),wt=function(n,t){return n===t&&(rt=!0),0},li=-2147483648,di={}.hasOwnProperty,g=[],gi=g.pop,nr=g.push,b=g.push,ai=g.slice,nt=function(n,t){for(var i=0,r=n.length;i<r;i++)if(n[i]===t)return i;return-1},bt="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",i="[\\x20\\t\\r\\n\\f]",ut="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",vi=ut.replace("w","w#"),yi="\\["+i+"*("+ut+")(?:"+i+"*([*^$|!~]?=)"+i+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+vi+"))|)"+i+"*\\]",kt=":("+ut+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+yi+")*)|.*)\\)|)",tr=new RegExp(i+"+","g"),lt=new RegExp("^"+i+"+|((?:^|[^\\\\])(?:\\\\.)*)"+i+"+$","g"),ir=new RegExp("^"+i+"*,"+i+"*"),rr=new RegExp("^"+i+"*([>+~]|"+i+")"+i+"*"),ur=new RegExp("="+i+"*([^\\]'\"]*?)"+i+"*\\]","g"),fr=new RegExp(kt),er=new RegExp("^"+vi+"$"),at={ID:new RegExp("^#("+ut+")"),CLASS:new RegExp("^\\.("+ut+")"),TAG:new RegExp("^("+ut.replace("w","w*")+")"),ATTR:new RegExp("^"+yi),PSEUDO:new RegExp("^"+kt),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+i+"*(even|odd|(([+-]|)(\\d*)n|)"+i+"*(?:([+-]|)"+i+"*(\\d+)|))"+i+"*\\)|)","i"),bool:new RegExp("^(?:"+bt+")$","i"),needsContext:new RegExp("^"+i+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+i+"*((?:-\\d)?\\d*)"+i+"*\\)|)(?=[^-]|$)","i")},or=/^(?:input|select|textarea|button)$/i,sr=/^h\d$/i,ot=/^[^{]+\{\s*\[native \w/,hr=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,dt=/[+~]/,cr=/'|\\/g,y=new RegExp("\\\\([\\da-f]{1,6}"+i+"?|("+i+")|.)","ig"),p=function(n,t,i){var r="0x"+t-65536;return r!==r||i?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,r&1023|56320)},pi=function(){k()};try{b.apply(g=ai.call(h.childNodes),h.childNodes);g[h.childNodes.length].nodeType}catch(pr){b={apply:g.length?function(n,t){nr.apply(n,ai.call(t))}:function(n,t){for(var i=n.length,r=0;n[i++]=t[r++];);n.length=i-1}}}u=r.support={};ei=r.isXML=function(n){var t=n&&(n.ownerDocument||n).documentElement;return t?t.nodeName!=="HTML":!1};k=r.setDocument=function(n){var a,c,r=n?n.ownerDocument||n:h;return r===o||r.nodeType!==9||!r.documentElement?o:(o=r,s=r.documentElement,c=r.defaultView,c&&c!==c.top&&(c.addEventListener?c.addEventListener("unload",pi,!1):c.attachEvent&&c.attachEvent("onunload",pi)),l=!ei(r),u.attributes=v(function(n){return n.className="i",!n.getAttribute("className")}),u.getElementsByTagName=v(function(n){return n.appendChild(r.createComment("")),!n.getElementsByTagName("*").length}),u.getElementsByClassName=ot.test(r.getElementsByClassName),u.getById=v(function(n){return s.appendChild(n).id=f,!r.getElementsByName||!r.getElementsByName(f).length}),u.getById?(t.find.ID=function(n,t){if(typeof t.getElementById!="undefined"&&l){var i=t.getElementById(n);return i&&i.parentNode?[i]:[]}},t.filter.ID=function(n){var t=n.replace(y,p);return function(n){return n.getAttribute("id")===t}}):(delete t.find.ID,t.filter.ID=function(n){var t=n.replace(y,p);return function(n){var i=typeof n.getAttributeNode!="undefined"&&n.getAttributeNode("id");return i&&i.value===t}}),t.find.TAG=u.getElementsByTagName?function(n,t){return typeof t.getElementsByTagName!="undefined"?t.getElementsByTagName(n):u.qsa?t.querySelectorAll(n):void 0}:function(n,t){var i,r=[],f=0,u=t.getElementsByTagName(n);if(n==="*"){while(i=u[f++])i.nodeType===1&&r.push(i);return r}return u},t.find.CLASS=u.getElementsByClassName&&function(n,t){if(l)return t.getElementsByClassName(n)},d=[],e=[],(u.qsa=ot.test(r.querySelectorAll))&&(v(function(n){s.appendChild(n).innerHTML="<a id='"+f+"'><\/a><select id='"+f+"-\f]' msallowcapture=''><option selected=''><\/option><\/select>";n.querySelectorAll("[msallowcapture^='']").length&&e.push("[*^$]="+i+"*(?:''|\"\")");n.querySelectorAll("[selected]").length||e.push("\\["+i+"*(?:value|"+bt+")");n.querySelectorAll("[id~="+f+"-]").length||e.push("~=");n.querySelectorAll(":checked").length||e.push(":checked");n.querySelectorAll("a#"+f+"+*").length||e.push(".#.+[+~]")}),v(function(n){var t=r.createElement("input");t.setAttribute("type","hidden");n.appendChild(t).setAttribute("name","D");n.querySelectorAll("[name=d]").length&&e.push("name"+i+"*[*^$|!~]?=");n.querySelectorAll(":enabled").length||e.push(":enabled",":disabled");n.querySelectorAll("*,:x");e.push(",.*:")})),(u.matchesSelector=ot.test(ct=s.matches||s.webkitMatchesSelector||s.mozMatchesSelector||s.oMatchesSelector||s.msMatchesSelector))&&v(function(n){u.disconnectedMatch=ct.call(n,"div");ct.call(n,"[s!='']:x");d.push("!=",kt)}),e=e.length&&new RegExp(e.join("|")),d=d.length&&new RegExp(d.join("|")),a=ot.test(s.compareDocumentPosition),et=a||ot.test(s.contains)?function(n,t){var r=n.nodeType===9?n.documentElement:n,i=t&&t.parentNode;return n===i||!!(i&&i.nodeType===1&&(r.contains?r.contains(i):n.compareDocumentPosition&&n.compareDocumentPosition(i)&16))}:function(n,t){if(t)while(t=t.parentNode)if(t===n)return!0;return!1},wt=a?function(n,t){if(n===t)return rt=!0,0;var i=!n.compareDocumentPosition-!t.compareDocumentPosition;return i?i:(i=(n.ownerDocument||n)===(t.ownerDocument||t)?n.compareDocumentPosition(t):1,i&1||!u.sortDetached&&t.compareDocumentPosition(n)===i)?n===r||n.ownerDocument===h&&et(h,n)?-1:t===r||t.ownerDocument===h&&et(h,t)?1:w?nt(w,n)-nt(w,t):0:i&4?-1:1}:function(n,t){if(n===t)return rt=!0,0;var i,u=0,o=n.parentNode,s=t.parentNode,f=[n],e=[t];if(o&&s){if(o===s)return wi(n,t)}else return n===r?-1:t===r?1:o?-1:s?1:w?nt(w,n)-nt(w,t):0;for(i=n;i=i.parentNode;)f.unshift(i);for(i=t;i=i.parentNode;)e.unshift(i);while(f[u]===e[u])u++;return u?wi(f[u],e[u]):f[u]===h?-1:e[u]===h?1:0},r)};r.matches=function(n,t){return r(n,null,null,t)};r.matchesSelector=function(n,t){if((n.ownerDocument||n)!==o&&k(n),t=t.replace(ur,"='$1']"),u.matchesSelector&&l&&(!d||!d.test(t))&&(!e||!e.test(t)))try{var i=ct.call(n,t);if(i||u.disconnectedMatch||n.document&&n.document.nodeType!==11)return i}catch(f){}return r(t,o,null,[n]).length>0};r.contains=function(n,t){return(n.ownerDocument||n)!==o&&k(n),et(n,t)};r.attr=function(n,i){(n.ownerDocument||n)!==o&&k(n);var f=t.attrHandle[i.toLowerCase()],r=f&&di.call(t.attrHandle,i.toLowerCase())?f(n,i,!l):undefined;return r!==undefined?r:u.attributes||!l?n.getAttribute(i):(r=n.getAttributeNode(i))&&r.specified?r.value:null};r.error=function(n){throw new Error("Syntax error, unrecognized expression: "+n);};r.uniqueSort=function(n){var r,f=[],t=0,i=0;if(rt=!u.detectDuplicates,w=!u.sortStable&&n.slice(0),n.sort(wt),rt){while(r=n[i++])r===n[i]&&(t=f.push(i));while(t--)n.splice(f[t],1)}return w=null,n};st=r.getText=function(n){var r,i="",u=0,t=n.nodeType;if(t){if(t===1||t===9||t===11){if(typeof n.textContent=="string")return n.textContent;for(n=n.firstChild;n;n=n.nextSibling)i+=st(n)}else if(t===3||t===4)return n.nodeValue}else while(r=n[u++])i+=st(r);return i};t=r.selectors={cacheLength:50,createPseudo:c,match:at,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(n){return n[1]=n[1].replace(y,p),n[3]=(n[3]||n[4]||n[5]||"").replace(y,p),n[2]==="~="&&(n[3]=" "+n[3]+" "),n.slice(0,4)},CHILD:function(n){return n[1]=n[1].toLowerCase(),n[1].slice(0,3)==="nth"?(n[3]||r.error(n[0]),n[4]=+(n[4]?n[5]+(n[6]||1):2*(n[3]==="even"||n[3]==="odd")),n[5]=+(n[7]+n[8]||n[3]==="odd")):n[3]&&r.error(n[0]),n},PSEUDO:function(n){var i,t=!n[6]&&n[2];return at.CHILD.test(n[0])?null:(n[3]?n[2]=n[4]||n[5]||"":t&&fr.test(t)&&(i=ft(t,!0))&&(i=t.indexOf(")",t.length-i)-t.length)&&(n[0]=n[0].slice(0,i),n[2]=t.slice(0,i)),n.slice(0,3))}},filter:{TAG:function(n){var t=n.replace(y,p).toLowerCase();return n==="*"?function(){return!0}:function(n){return n.nodeName&&n.nodeName.toLowerCase()===t}},CLASS:function(n){var t=si[n+" "];return t||(t=new RegExp("(^|"+i+")"+n+"("+i+"|$)"))&&si(n,function(n){return t.test(typeof n.className=="string"&&n.className||typeof n.getAttribute!="undefined"&&n.getAttribute("class")||"")})},ATTR:function(n,t,i){return function(u){var f=r.attr(u,n);return f==null?t==="!=":t?(f+="",t==="="?f===i:t==="!="?f!==i:t==="^="?i&&f.indexOf(i)===0:t==="*="?i&&f.indexOf(i)>-1:t==="$="?i&&f.slice(-i.length)===i:t==="~="?(" "+f.replace(tr," ")+" ").indexOf(i)>-1:t==="|="?f===i||f.slice(0,i.length+1)===i+"-":!1):!0}},CHILD:function(n,t,i,r,u){var s=n.slice(0,3)!=="nth",o=n.slice(-4)!=="last",e=t==="of-type";return r===1&&u===0?function(n){return!!n.parentNode}:function(t,i,h){var v,k,c,l,y,w,b=s!==o?"nextSibling":"previousSibling",p=t.parentNode,g=e&&t.nodeName.toLowerCase(),d=!h&&!e;if(p){if(s){while(b){for(c=t;c=c[b];)if(e?c.nodeName.toLowerCase()===g:c.nodeType===1)return!1;w=b=n==="only"&&!w&&"nextSibling"}return!0}if(w=[o?p.firstChild:p.lastChild],o&&d){for(k=p[f]||(p[f]={}),v=k[n]||[],y=v[0]===a&&v[1],l=v[0]===a&&v[2],c=y&&p.childNodes[y];c=++y&&c&&c[b]||(l=y=0)||w.pop();)if(c.nodeType===1&&++l&&c===t){k[n]=[a,y,l];break}}else if(d&&(v=(t[f]||(t[f]={}))[n])&&v[0]===a)l=v[1];else while(c=++y&&c&&c[b]||(l=y=0)||w.pop())if((e?c.nodeName.toLowerCase()===g:c.nodeType===1)&&++l&&(d&&((c[f]||(c[f]={}))[n]=[a,l]),c===t))break;return l-=u,l===r||l%r==0&&l/r>=0}}},PSEUDO:function(n,i){var e,u=t.pseudos[n]||t.setFilters[n.toLowerCase()]||r.error("unsupported pseudo: "+n);return u[f]?u(i):u.length>1?(e=[n,n,"",i],t.setFilters.hasOwnProperty(n.toLowerCase())?c(function(n,t){for(var r,f=u(n,i),e=f.length;e--;)r=nt(n,f[e]),n[r]=!(t[r]=f[e])}):function(n){return u(n,0,e)}):u}},pseudos:{not:c(function(n){var t=[],r=[],i=pt(n.replace(lt,"$1"));return i[f]?c(function(n,t,r,u){for(var e,o=i(n,null,u,[]),f=n.length;f--;)(e=o[f])&&(n[f]=!(t[f]=e))}):function(n,u,f){return t[0]=n,i(t,null,f,r),t[0]=null,!r.pop()}}),has:c(function(n){return function(t){return r(n,t).length>0}}),contains:c(function(n){return n=n.replace(y,p),function(t){return(t.textContent||t.innerText||st(t)).indexOf(n)>-1}}),lang:c(function(n){return er.test(n||"")||r.error("unsupported lang: "+n),n=n.replace(y,p).toLowerCase(),function(t){var i;do if(i=l?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return i=i.toLowerCase(),i===n||i.indexOf(n+"-")===0;while((t=t.parentNode)&&t.nodeType===1);return!1}}),target:function(t){var i=n.location&&n.location.hash;return i&&i.slice(1)===t.id},root:function(n){return n===s},focus:function(n){return n===o.activeElement&&(!o.hasFocus||o.hasFocus())&&!!(n.type||n.href||~n.tabIndex)},enabled:function(n){return n.disabled===!1},disabled:function(n){return n.disabled===!0},checked:function(n){var t=n.nodeName.toLowerCase();return t==="input"&&!!n.checked||t==="option"&&!!n.selected},selected:function(n){return n.parentNode&&n.parentNode.selectedIndex,n.selected===!0},empty:function(n){for(n=n.firstChild;n;n=n.nextSibling)if(n.nodeType<6)return!1;return!0},parent:function(n){return!t.pseudos.empty(n)},header:function(n){return sr.test(n.nodeName)},input:function(n){return or.test(n.nodeName)},button:function(n){var t=n.nodeName.toLowerCase();return t==="input"&&n.type==="button"||t==="button"},text:function(n){var t;return n.nodeName.toLowerCase()==="input"&&n.type==="text"&&((t=n.getAttribute("type"))==null||t.toLowerCase()==="text")},first:tt(function(){return[0]}),last:tt(function(n,t){return[t-1]}),eq:tt(function(n,t,i){return[i<0?i+t:i]}),even:tt(function(n,t){for(var i=0;i<t;i+=2)n.push(i);return n}),odd:tt(function(n,t){for(var i=1;i<t;i+=2)n.push(i);return n}),lt:tt(function(n,t,i){for(var r=i<0?i+t:i;--r>=0;)n.push(r);return n}),gt:tt(function(n,t,i){for(var r=i<0?i+t:i;++r<t;)n.push(r);return n})}};t.pseudos.nth=t.pseudos.eq;for(it in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})t.pseudos[it]=lr(it);for(it in{submit:!0,reset:!0})t.pseudos[it]=ar(it);return bi.prototype=t.filters=t.pseudos,t.setFilters=new bi,ft=r.tokenize=function(n,i){var e,f,s,o,u,h,c,l=hi[n+" "];if(l)return i?0:l.slice(0);for(u=n,h=[],c=t.preFilter;u;){(!e||(f=ir.exec(u)))&&(f&&(u=u.slice(f[0].length)||u),h.push(s=[]));e=!1;(f=rr.exec(u))&&(e=f.shift(),s.push({value:e,type:f[0].replace(lt," ")}),u=u.slice(e.length));for(o in t.filter)(f=at[o].exec(u))&&(!c[o]||(f=c[o](f)))&&(e=f.shift(),s.push({value:e,type:o,matches:f}),u=u.slice(e.length));if(!e)break}return i?u.length:u?r.error(n):hi(n,h).slice(0)},pt=r.compile=function(n,t){var r,u=[],e=[],i=ci[n+" "];if(!i){for(t||(t=ft(n)),r=t.length;r--;)i=fi(t[r]),i[f]?u.push(i):e.push(i);i=ci(n,yr(e,u));i.selector=n}return i},oi=r.select=function(n,i,r,f){var s,e,o,a,v,c=typeof n=="function"&&n,h=!f&&ft(n=c.selector||n);if(r=r||[],h.length===1){if(e=h[0]=h[0].slice(0),e.length>2&&(o=e[0]).type==="ID"&&u.getById&&i.nodeType===9&&l&&t.relative[e[1].type]){if(i=(t.find.ID(o.matches[0].replace(y,p),i)||[])[0],i)c&&(i=i.parentNode);else return r;n=n.slice(e.shift().value.length)}for(s=at.needsContext.test(n)?0:e.length;s--;){if(o=e[s],t.relative[a=o.type])break;if((v=t.find[a])&&(f=v(o.matches[0].replace(y,p),dt.test(e[0].type)&&ti(i.parentNode)||i))){if(e.splice(s,1),n=f.length&&vt(e),!n)return b.apply(r,f),r;break}}}return(c||pt(n,h))(f,i,!l,r,dt.test(n)&&ti(i.parentNode)||i),r},u.sortStable=f.split("").sort(wt).join("")===f,u.detectDuplicates=!!rt,k(),u.sortDetached=v(function(n){return n.compareDocumentPosition(o.createElement("div"))&1}),v(function(n){return n.innerHTML="<a href='#'><\/a>",n.firstChild.getAttribute("href")==="#"})||ni("type|href|height|width",function(n,t,i){if(!i)return n.getAttribute(t,t.toLowerCase()==="type"?1:2)}),u.attributes&&v(function(n){return n.innerHTML="<input/>",n.firstChild.setAttribute("value",""),n.firstChild.getAttribute("value")===""})||ni("value",function(n,t,i){if(!i&&n.nodeName.toLowerCase()==="input")return n.defaultValue}),v(function(n){return n.getAttribute("disabled")==null})||ni(bt,function(n,t,i){var r;if(!i)return n[t]===!0?t.toLowerCase():(r=n.getAttributeNode(t))&&r.specified?r.value:null}),r}(n);i.find=y;i.expr=y.selectors;i.expr[":"]=i.expr.pseudos;i.unique=y.uniqueSort;i.text=y.getText;i.isXMLDoc=y.isXML;i.contains=y.contains;var di=i.expr.match.needsContext,gi=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,ef=/^.[^:#\[\.,]*$/;i.filter=function(n,t,r){var u=t[0];return r&&(n=":not("+n+")"),t.length===1&&u.nodeType===1?i.find.matchesSelector(u,n)?[u]:[]:i.find.matches(n,i.grep(t,function(n){return n.nodeType===1}))};i.fn.extend({find:function(n){var t,u=this.length,r=[],f=this;if(typeof n!="string")return this.pushStack(i(n).filter(function(){for(t=0;t<u;t++)if(i.contains(f[t],this))return!0}));for(t=0;t<u;t++)i.find(n,f[t],r);return r=this.pushStack(u>1?i.unique(r):r),r.selector=this.selector?this.selector+" "+n:n,r},filter:function(n){return this.pushStack(ui(this,n||[],!1))},not:function(n){return this.pushStack(ui(this,n||[],!0))},is:function(n){return!!ui(this,typeof n=="string"&&di.test(n)?i(n):n||[],!1).length}});nr=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/;tr=i.fn.init=function(n,t){var r,f;if(!n)return this;if(typeof n=="string"){if(r=n[0]==="<"&&n[n.length-1]===">"&&n.length>=3?[null,n,null]:nr.exec(n),r&&(r[1]||!t)){if(r[1]){if(t=t instanceof i?t[0]:t,i.merge(this,i.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:u,!0)),gi.test(r[1])&&i.isPlainObject(t))for(r in t)i.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return f=u.getElementById(r[2]),f&&f.parentNode&&(this.length=1,this[0]=f),this.context=u,this.selector=n,this}return!t||t.jquery?(t||ot).find(n):this.constructor(t).find(n)}return n.nodeType?(this.context=this[0]=n,this.length=1,this):i.isFunction(n)?typeof ot.ready!="undefined"?ot.ready(n):n(i):(n.selector!==undefined&&(this.selector=n.selector,this.context=n.context),i.makeArray(n,this))};tr.prototype=i.fn;ot=i(u);ir=/^(?:parents|prev(?:Until|All))/;rr={children:!0,contents:!0,next:!0,prev:!0};i.extend({dir:function(n,t,r){for(var u=[],f=r!==undefined;(n=n[t])&&n.nodeType!==9;)if(n.nodeType===1){if(f&&i(n).is(r))break;u.push(n)}return u},sibling:function(n,t){for(var i=[];n;n=n.nextSibling)n.nodeType===1&&n!==t&&i.push(n);return i}});i.fn.extend({has:function(n){var t=i(n,this),r=t.length;return this.filter(function(){for(var n=0;n<r;n++)if(i.contains(this,t[n]))return!0})},closest:function(n,t){for(var r,f=0,o=this.length,u=[],e=di.test(n)||typeof n!="string"?i(n,t||this.context):0;f<o;f++)for(r=this[f];r&&r!==t;r=r.parentNode)if(r.nodeType<11&&(e?e.index(r)>-1:r.nodeType===1&&i.find.matchesSelector(r,n))){u.push(r);break}return this.pushStack(u.length>1?i.unique(u):u)},index:function(n){return n?typeof n=="string"?ft.call(i(n),this[0]):ft.call(this,n.jquery?n[0]:n):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(n,t){return this.pushStack(i.unique(i.merge(this.get(),i(n,t))))},addBack:function(n){return this.add(n==null?this.prevObject:this.prevObject.filter(n))}});i.each({parent:function(n){var t=n.parentNode;return t&&t.nodeType!==11?t:null},parents:function(n){return i.dir(n,"parentNode")},parentsUntil:function(n,t,r){return i.dir(n,"parentNode",r)},next:function(n){return ur(n,"nextSibling")},prev:function(n){return ur(n,"previousSibling")},nextAll:function(n){return i.dir(n,"nextSibling")},prevAll:function(n){return i.dir(n,"previousSibling")},nextUntil:function(n,t,r){return i.dir(n,"nextSibling",r)},prevUntil:function(n,t,r){return i.dir(n,"previousSibling",r)},siblings:function(n){return i.sibling((n.parentNode||{}).firstChild,n)},children:function(n){return i.sibling(n.firstChild)},contents:function(n){return n.contentDocument||i.merge([],n.childNodes)}},function(n,t){i.fn[n]=function(r,u){var f=i.map(this,t,r);return n.slice(-5)!=="Until"&&(u=r),u&&typeof u=="string"&&(f=i.filter(u,f)),this.length>1&&(rr[n]||i.unique(f),ir.test(n)&&f.reverse()),this.pushStack(f)}});c=/\S+/g;fi={};i.Callbacks=function(n){n=typeof n=="string"?fi[n]||of(n):i.extend({},n);var u,h,o,c,f,e,t=[],r=!n.once&&[],l=function(i){for(u=n.memory&&i,h=!0,e=c||0,c=0,f=t.length,o=!0;t&&e<f;e++)if(t[e].apply(i[0],i[1])===!1&&n.stopOnFalse){u=!1;break}o=!1;t&&(r?r.length&&l(r.shift()):u?t=[]:s.disable())},s={add:function(){if(t){var r=t.length;(function e(r){i.each(r,function(r,u){var f=i.type(u);f==="function"?n.unique&&s.has(u)||t.push(u):u&&u.length&&f!=="string"&&e(u)})})(arguments);o?f=t.length:u&&(c=r,l(u))}return this},remove:function(){return t&&i.each(arguments,function(n,r){for(var u;(u=i.inArray(r,t,u))>-1;)t.splice(u,1),o&&(u<=f&&f--,u<=e&&e--)}),this},has:function(n){return n?i.inArray(n,t)>-1:!!(t&&t.length)},empty:function(){return t=[],f=0,this},disable:function(){return t=r=u=undefined,this},disabled:function(){return!t},lock:function(){return r=undefined,u||s.disable(),this},locked:function(){return!r},fireWith:function(n,i){return t&&(!h||r)&&(i=i||[],i=[n,i.slice?i.slice():i],o?r.push(i):l(i)),this},fire:function(){return s.fireWith(this,arguments),this},fired:function(){return!!h}};return s};i.extend({Deferred:function(n){var u=[["resolve","done",i.Callbacks("once memory"),"resolved"],["reject","fail",i.Callbacks("once memory"),"rejected"],["notify","progress",i.Callbacks("memory")]],f="pending",r={state:function(){return f},always:function(){return t.done(arguments).fail(arguments),this},then:function(){var n=arguments;return i.Deferred(function(f){i.each(u,function(u,e){var o=i.isFunction(n[u])&&n[u];t[e[1]](function(){var n=o&&o.apply(this,arguments);n&&i.isFunction(n.promise)?n.promise().done(f.resolve).fail(f.reject).progress(f.notify):f[e[0]+"With"](this===r?f.promise():this,o?[n]:arguments)})});n=null}).promise()},promise:function(n){return n!=null?i.extend(n,r):r}},t={};return r.pipe=r.then,i.each(u,function(n,i){var e=i[2],o=i[3];r[i[1]]=e.add;o&&e.add(function(){f=o},u[n^1][2].disable,u[2][2].lock);t[i[0]]=function(){return t[i[0]+"With"](this===t?r:this,arguments),this};t[i[0]+"With"]=e.fireWith}),r.promise(t),n&&n.call(t,t),t},when:function(n){var t=0,u=a.call(arguments),r=u.length,e=r!==1||n&&i.isFunction(n.promise)?r:0,f=e===1?n:i.Deferred(),h=function(n,t,i){return function(r){t[n]=this;i[n]=arguments.length>1?a.call(arguments):r;i===o?f.notifyWith(t,i):--e||f.resolveWith(t,i)}},o,c,s;if(r>1)for(o=new Array(r),c=new Array(r),s=new Array(r);t<r;t++)u[t]&&i.isFunction(u[t].promise)?u[t].promise().done(h(t,s,u)).fail(f.reject).progress(h(t,c,o)):--e;return e||f.resolveWith(s,u),f.promise()}});i.fn.ready=function(n){return i.ready.promise().done(n),this};i.extend({isReady:!1,readyWait:1,holdReady:function(n){n?i.readyWait++:i.ready(!0)},ready:function(n){(n===!0?--i.readyWait:i.isReady)||(i.isReady=!0,n!==!0&&--i.readyWait>0)||(st.resolveWith(u,[i]),i.fn.triggerHandler&&(i(u).triggerHandler("ready"),i(u).off("ready")))}});i.ready.promise=function(t){return st||(st=i.Deferred(),u.readyState==="complete"?setTimeout(i.ready):(u.addEventListener("DOMContentLoaded",ht,!1),n.addEventListener("load",ht,!1))),st.promise(t)};i.ready.promise();l=i.access=function(n,t,r,u,f,e,o){var s=0,c=n.length,h=r==null;if(i.type(r)==="object"){f=!0;for(s in r)i.access(n,t,s,r[s],!0,e,o)}else if(u!==undefined&&(f=!0,i.isFunction(u)||(o=!0),h&&(o?(t.call(n,u),t=null):(h=t,t=function(n,t,r){return h.call(i(n),r)})),t))for(;s<c;s++)t(n[s],r,o?u:u.call(n[s],s,t(n[s],r)));return f?n:h?t.call(n):c?t(n[0],r):e};i.acceptData=function(n){return n.nodeType===1||n.nodeType===9||!+n.nodeType};v.uid=1;v.accepts=i.acceptData;v.prototype={key:function(n){if(!v.accepts(n))return 0;var r={},t=n[this.expando];if(!t){t=v.uid++;try{r[this.expando]={value:t};Object.defineProperties(n,r)}catch(u){r[this.expando]=t;i.extend(n,r)}}return this.cache[t]||(this.cache[t]={}),t},set:function(n,t,r){var f,e=this.key(n),u=this.cache[e];if(typeof t=="string")u[t]=r;else if(i.isEmptyObject(u))i.extend(this.cache[e],t);else for(f in t)u[f]=t[f];return u},get:function(n,t){var i=this.cache[this.key(n)];return t===undefined?i:i[t]},access:function(n,t,r){var u;return t===undefined||t&&typeof t=="string"&&r===undefined?(u=this.get(n,t),u!==undefined?u:this.get(n,i.camelCase(t))):(this.set(n,t,r),r!==undefined?r:t)},remove:function(n,t){var u,r,f,o=this.key(n),e=this.cache[o];if(t===undefined)this.cache[o]={};else for(i.isArray(t)?r=t.concat(t.map(i.camelCase)):(f=i.camelCase(t),t in e?r=[t,f]:(r=f,r=r in e?[r]:r.match(c)||[])),u=r.length;u--;)delete e[r[u]]},hasData:function(n){return!i.isEmptyObject(this.cache[n[this.expando]]||{})},discard:function(n){n[this.expando]&&delete this.cache[n[this.expando]]}};var r=new v,e=new v,sf=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,hf=/([A-Z])/g;i.extend({hasData:function(n){return e.hasData(n)||r.hasData(n)},data:function(n,t,i){return e.access(n,t,i)},removeData:function(n,t){e.remove(n,t)},_data:function(n,t,i){return r.access(n,t,i)},_removeData:function(n,t){r.remove(n,t)}});i.fn.extend({data:function(n,t){var o,f,s,u=this[0],h=u&&u.attributes;if(n===undefined){if(this.length&&(s=e.get(u),u.nodeType===1&&!r.get(u,"hasDataAttrs"))){for(o=h.length;o--;)h[o]&&(f=h[o].name,f.indexOf("data-")===0&&(f=i.camelCase(f.slice(5)),fr(u,f,s[f])));r.set(u,"hasDataAttrs",!0)}return s}return typeof n=="object"?this.each(function(){e.set(this,n)}):l(this,function(t){var r,f=i.camelCase(n);if(u&&t===undefined)return(r=e.get(u,n),r!==undefined)?r:(r=e.get(u,f),r!==undefined)?r:(r=fr(u,f,undefined),r!==undefined)?r:void 0;this.each(function(){var i=e.get(this,f);e.set(this,f,t);n.indexOf("-")!==-1&&i!==undefined&&e.set(this,n,t)})},null,t,arguments.length>1,null,!0)},removeData:function(n){return this.each(function(){e.remove(this,n)})}});i.extend({queue:function(n,t,u){var f;if(n)return t=(t||"fx")+"queue",f=r.get(n,t),u&&(!f||i.isArray(u)?f=r.access(n,t,i.makeArray(u)):f.push(u)),f||[]},dequeue:function(n,t){t=t||"fx";var r=i.queue(n,t),e=r.length,u=r.shift(),f=i._queueHooks(n,t),o=function(){i.dequeue(n,t)};u==="inprogress"&&(u=r.shift(),e--);u&&(t==="fx"&&r.unshift("inprogress"),delete f.stop,u.call(n,o,f));!e&&f&&f.empty.fire()},_queueHooks:function(n,t){var u=t+"queueHooks";return r.get(n,u)||r.access(n,u,{empty:i.Callbacks("once memory").add(function(){r.remove(n,[t+"queue",u])})})}});i.fn.extend({queue:function(n,t){var r=2;return(typeof n!="string"&&(t=n,n="fx",r--),arguments.length<r)?i.queue(this[0],n):t===undefined?this:this.each(function(){var r=i.queue(this,n,t);i._queueHooks(this,n);n==="fx"&&r[0]!=="inprogress"&&i.dequeue(this,n)})},dequeue:function(n){return this.each(function(){i.dequeue(this,n)})},clearQueue:function(n){return this.queue(n||"fx",[])},promise:function(n,t){var u,e=1,o=i.Deferred(),f=this,s=this.length,h=function(){--e||o.resolveWith(f,[f])};for(typeof n!="string"&&(t=n,n=undefined),n=n||"fx";s--;)u=r.get(f[s],n+"queueHooks"),u&&u.empty&&(e++,u.empty.add(h));return h(),o.promise(t)}});var ct=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,p=["Top","Right","Bottom","Left"],tt=function(n,t){return n=t||n,i.css(n,"display")==="none"||!i.contains(n.ownerDocument,n)},er=/^(?:checkbox|radio)$/i;(function(){var i=u.createDocumentFragment(),n=i.appendChild(u.createElement("div")),t=u.createElement("input");t.setAttribute("type","radio");t.setAttribute("checked","checked");t.setAttribute("name","t");n.appendChild(t);f.checkClone=n.cloneNode(!0).cloneNode(!0).lastChild.checked;n.innerHTML="<textarea>x<\/textarea>";f.noCloneChecked=!!n.cloneNode(!0).lastChild.defaultValue})();b=typeof undefined;f.focusinBubbles="onfocusin"in n;var cf=/^key/,lf=/^(?:mouse|pointer|contextmenu)|click/,or=/^(?:focusinfocus|focusoutblur)$/,sr=/^([^.]*)(?:\.(.+)|)$/;i.event={global:{},add:function(n,t,u,f,e){var v,y,w,p,k,h,s,l,o,d,g,a=r.get(n);if(a)for(u.handler&&(v=u,u=v.handler,e=v.selector),u.guid||(u.guid=i.guid++),(p=a.events)||(p=a.events={}),(y=a.handle)||(y=a.handle=function(t){return typeof i!==b&&i.event.triggered!==t.type?i.event.dispatch.apply(n,arguments):undefined}),t=(t||"").match(c)||[""],k=t.length;k--;)(w=sr.exec(t[k])||[],o=g=w[1],d=(w[2]||"").split(".").sort(),o)&&(s=i.event.special[o]||{},o=(e?s.delegateType:s.bindType)||o,s=i.event.special[o]||{},h=i.extend({type:o,origType:g,data:f,handler:u,guid:u.guid,selector:e,needsContext:e&&i.expr.match.needsContext.test(e),namespace:d.join(".")},v),(l=p[o])||(l=p[o]=[],l.delegateCount=0,s.setup&&s.setup.call(n,f,d,y)!==!1||n.addEventListener&&n.addEventListener(o,y,!1)),s.add&&(s.add.call(n,h),h.handler.guid||(h.handler.guid=u.guid)),e?l.splice(l.delegateCount++,0,h):l.push(h),i.event.global[o]=!0)},remove:function(n,t,u,f,e){var p,k,h,v,w,s,l,a,o,b,d,y=r.hasData(n)&&r.get(n);if(y&&(v=y.events)){for(t=(t||"").match(c)||[""],w=t.length;w--;){if(h=sr.exec(t[w])||[],o=d=h[1],b=(h[2]||"").split(".").sort(),!o){for(o in v)i.event.remove(n,o+t[w],u,f,!0);continue}for(l=i.event.special[o]||{},o=(f?l.delegateType:l.bindType)||o,a=v[o]||[],h=h[2]&&new RegExp("(^|\\.)"+b.join("\\.(?:.*\\.|)")+"(\\.|$)"),k=p=a.length;p--;)s=a[p],(e||d===s.origType)&&(!u||u.guid===s.guid)&&(!h||h.test(s.namespace))&&(!f||f===s.selector||f==="**"&&s.selector)&&(a.splice(p,1),s.selector&&a.delegateCount--,l.remove&&l.remove.call(n,s));k&&!a.length&&(l.teardown&&l.teardown.call(n,b,y.handle)!==!1||i.removeEvent(n,o,y.handle),delete v[o])}i.isEmptyObject(v)&&(delete y.handle,r.remove(n,"events"))}},trigger:function(t,f,e,o){var w,s,c,b,a,v,l,p=[e||u],h=ii.call(t,"type")?t.type:t,y=ii.call(t,"namespace")?t.namespace.split("."):[];if((s=c=e=e||u,e.nodeType!==3&&e.nodeType!==8)&&!or.test(h+i.event.triggered)&&(h.indexOf(".")>=0&&(y=h.split("."),h=y.shift(),y.sort()),a=h.indexOf(":")<0&&"on"+h,t=t[i.expando]?t:new i.Event(h,typeof t=="object"&&t),t.isTrigger=o?2:3,t.namespace=y.join("."),t.namespace_re=t.namespace?new RegExp("(^|\\.)"+y.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=undefined,t.target||(t.target=e),f=f==null?[t]:i.makeArray(f,[t]),l=i.event.special[h]||{},o||!l.trigger||l.trigger.apply(e,f)!==!1)){if(!o&&!l.noBubble&&!i.isWindow(e)){for(b=l.delegateType||h,or.test(b+h)||(s=s.parentNode);s;s=s.parentNode)p.push(s),c=s;c===(e.ownerDocument||u)&&p.push(c.defaultView||c.parentWindow||n)}for(w=0;(s=p[w++])&&!t.isPropagationStopped();)t.type=w>1?b:l.bindType||h,v=(r.get(s,"events")||{})[t.type]&&r.get(s,"handle"),v&&v.apply(s,f),v=a&&s[a],v&&v.apply&&i.acceptData(s)&&(t.result=v.apply(s,f),t.result===!1&&t.preventDefault());return t.type=h,o||t.isDefaultPrevented()||(!l._default||l._default.apply(p.pop(),f)===!1)&&i.acceptData(e)&&a&&i.isFunction(e[h])&&!i.isWindow(e)&&(c=e[a],c&&(e[a]=null),i.event.triggered=h,e[h](),i.event.triggered=undefined,c&&(e[a]=c)),t.result}},dispatch:function(n){n=i.event.fix(n);var o,s,e,u,t,h=[],c=a.call(arguments),l=(r.get(this,"events")||{})[n.type]||[],f=i.event.special[n.type]||{};if(c[0]=n,n.delegateTarget=this,!f.preDispatch||f.preDispatch.call(this,n)!==!1){for(h=i.event.handlers.call(this,n,l),o=0;(u=h[o++])&&!n.isPropagationStopped();)for(n.currentTarget=u.elem,s=0;(t=u.handlers[s++])&&!n.isImmediatePropagationStopped();)(!n.namespace_re||n.namespace_re.test(t.namespace))&&(n.handleObj=t,n.data=t.data,e=((i.event.special[t.origType]||{}).handle||t.handler).apply(u.elem,c),e!==undefined&&(n.result=e)===!1&&(n.preventDefault(),n.stopPropagation()));return f.postDispatch&&f.postDispatch.call(this,n),n.result}},handlers:function(n,t){var e,u,f,o,h=[],s=t.delegateCount,r=n.target;if(s&&r.nodeType&&(!n.button||n.type!=="click"))for(;r!==this;r=r.parentNode||this)if(r.disabled!==!0||n.type!=="click"){for(u=[],e=0;e<s;e++)o=t[e],f=o.selector+" ",u[f]===undefined&&(u[f]=o.needsContext?i(f,this).index(r)>=0:i.find(f,this,null,[r]).length),u[f]&&u.push(o);u.length&&h.push({elem:r,handlers:u})}return s<t.length&&h.push({elem:this,handlers:t.slice(s)}),h},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(n,t){return n.which==null&&(n.which=t.charCode!=null?t.charCode:t.keyCode),n}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(n,t){var e,i,r,f=t.button;return n.pageX==null&&t.clientX!=null&&(e=n.target.ownerDocument||u,i=e.documentElement,r=e.body,n.pageX=t.clientX+(i&&i.scrollLeft||r&&r.scrollLeft||0)-(i&&i.clientLeft||r&&r.clientLeft||0),n.pageY=t.clientY+(i&&i.scrollTop||r&&r.scrollTop||0)-(i&&i.clientTop||r&&r.clientTop||0)),n.which||f===undefined||(n.which=f&1?1:f&2?3:f&4?2:0),n}},fix:function(n){if(n[i.expando])return n;var f,e,o,r=n.type,s=n,t=this.fixHooks[r];for(t||(this.fixHooks[r]=t=lf.test(r)?this.mouseHooks:cf.test(r)?this.keyHooks:{}),o=t.props?this.props.concat(t.props):this.props,n=new i.Event(s),f=o.length;f--;)e=o[f],n[e]=s[e];return n.target||(n.target=u),n.target.nodeType===3&&(n.target=n.target.parentNode),t.filter?t.filter(n,s):n},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==hr()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===hr()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if(this.type==="checkbox"&&this.click&&i.nodeName(this,"input"))return this.click(),!1},_default:function(n){return i.nodeName(n.target,"a")}},beforeunload:{postDispatch:function(n){n.result!==undefined&&n.originalEvent&&(n.originalEvent.returnValue=n.result)}}},simulate:function(n,t,r,u){var f=i.extend(new i.Event,r,{type:n,isSimulated:!0,originalEvent:{}});u?i.event.trigger(f,null,t):i.event.dispatch.call(t,f);f.isDefaultPrevented()&&r.preventDefault()}};i.removeEvent=function(n,t,i){n.removeEventListener&&n.removeEventListener(t,i,!1)};i.Event=function(n,t){if(!(this instanceof i.Event))return new i.Event(n,t);n&&n.type?(this.originalEvent=n,this.type=n.type,this.isDefaultPrevented=n.defaultPrevented||n.defaultPrevented===undefined&&n.returnValue===!1?lt:k):this.type=n;t&&i.extend(this,t);this.timeStamp=n&&n.timeStamp||i.now();this[i.expando]=!0};i.Event.prototype={isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k,preventDefault:function(){var n=this.originalEvent;this.isDefaultPrevented=lt;n&&n.preventDefault&&n.preventDefault()},stopPropagation:function(){var n=this.originalEvent;this.isPropagationStopped=lt;n&&n.stopPropagation&&n.stopPropagation()},stopImmediatePropagation:function(){var n=this.originalEvent;this.isImmediatePropagationStopped=lt;n&&n.stopImmediatePropagation&&n.stopImmediatePropagation();this.stopPropagation()}};i.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(n,t){i.event.special[n]={delegateType:t,bindType:t,handle:function(n){var u,f=this,r=n.relatedTarget,e=n.handleObj;return r&&(r===f||i.contains(f,r))||(n.type=e.origType,u=e.handler.apply(this,arguments),n.type=t),u}}});f.focusinBubbles||i.each({focus:"focusin",blur:"focusout"},function(n,t){var u=function(n){i.event.simulate(t,n.target,i.event.fix(n),!0)};i.event.special[t]={setup:function(){var i=this.ownerDocument||this,f=r.access(i,t);f||i.addEventListener(n,u,!0);r.access(i,t,(f||0)+1)},teardown:function(){var i=this.ownerDocument||this,f=r.access(i,t)-1;f?r.access(i,t,f):(i.removeEventListener(n,u,!0),r.remove(i,t))}}});i.fn.extend({on:function(n,t,r,u,f){var e,o;if(typeof n=="object"){typeof t!="string"&&(r=r||t,t=undefined);for(o in n)this.on(o,t,r,n[o],f);return this}if(r==null&&u==null?(u=t,r=t=undefined):u==null&&(typeof t=="string"?(u=r,r=undefined):(u=r,r=t,t=undefined)),u===!1)u=k;else if(!u)return this;return f===1&&(e=u,u=function(n){return i().off(n),e.apply(this,arguments)},u.guid=e.guid||(e.guid=i.guid++)),this.each(function(){i.event.add(this,n,u,r,t)})},one:function(n,t,i,r){return this.on(n,t,i,r,1)},off:function(n,t,r){var u,f;if(n&&n.preventDefault&&n.handleObj)return u=n.handleObj,i(n.delegateTarget).off(u.namespace?u.origType+"."+u.namespace:u.origType,u.selector,u.handler),this;if(typeof n=="object"){for(f in n)this.off(f,t,n[f]);return this}return(t===!1||typeof t=="function")&&(r=t,t=undefined),r===!1&&(r=k),this.each(function(){i.event.remove(this,n,r,t)})},trigger:function(n,t){return this.each(function(){i.event.trigger(n,t,this)})},triggerHandler:function(n,t){var r=this[0];if(r)return i.event.trigger(n,t,r,!0)}});var cr=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,lr=/<([\w:]+)/,af=/<|&#?\w+;/,vf=/<(?:script|style|link)/i,yf=/checked\s*(?:[^=]|=\s*.checked.)/i,ar=/^$|\/(?:java|ecma)script/i,pf=/^true\/(.*)/,wf=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,h={option:[1,"<select multiple='multiple'>","<\/select>"],thead:[1,"<table>","<\/table>"],col:[2,"<table><colgroup>","<\/colgroup><\/table>"],tr:[2,"<table><tbody>","<\/tbody><\/table>"],td:[3,"<table><tbody><tr>","<\/tr><\/tbody><\/table>"],_default:[0,"",""]};h.optgroup=h.option;h.tbody=h.tfoot=h.colgroup=h.caption=h.thead;h.th=h.td;i.extend({clone:function(n,t,r){var u,c,s,e,h=n.cloneNode(!0),l=i.contains(n.ownerDocument,n);if(!f.noCloneChecked&&(n.nodeType===1||n.nodeType===11)&&!i.isXMLDoc(n))for(e=o(h),s=o(n),u=0,c=s.length;u<c;u++)df(s[u],e[u]);if(t)if(r)for(s=s||o(n),e=e||o(h),u=0,c=s.length;u<c;u++)yr(s[u],e[u]);else yr(n,h);return e=o(h,"script"),e.length>0&&ei(e,!l&&o(n,"script")),h},buildFragment:function(n,t,r,u){for(var f,e,y,l,p,a,s=t.createDocumentFragment(),v=[],c=0,w=n.length;c<w;c++)if(f=n[c],f||f===0)if(i.type(f)==="object")i.merge(v,f.nodeType?[f]:f);else if(af.test(f)){for(e=e||s.appendChild(t.createElement("div")),y=(lr.exec(f)||["",""])[1].toLowerCase(),l=h[y]||h._default,e.innerHTML=l[1]+f.replace(cr,"<$1><\/$2>")+l[2],a=l[0];a--;)e=e.lastChild;i.merge(v,e.childNodes);e=s.firstChild;e.textContent=""}else v.push(t.createTextNode(f));for(s.textContent="",c=0;f=v[c++];)if((!u||i.inArray(f,u)===-1)&&(p=i.contains(f.ownerDocument,f),e=o(s.appendChild(f),"script"),p&&ei(e),r))for(a=0;f=e[a++];)ar.test(f.type||"")&&r.push(f);return s},cleanData:function(n){for(var f,t,o,u,h=i.event.special,s=0;(t=n[s])!==undefined;s++){if(i.acceptData(t)&&(u=t[r.expando],u&&(f=r.cache[u]))){if(f.events)for(o in f.events)h[o]?i.event.remove(t,o):i.removeEvent(t,o,f.handle);r.cache[u]&&delete r.cache[u]}delete e.cache[t[e.expando]]}}});i.fn.extend({text:function(n){return l(this,function(n){return n===undefined?i.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=n)})},null,n,arguments.length)},append:function(){return this.domManip(arguments,function(n){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var t=vr(this,n);t.appendChild(n)}})},prepend:function(){return this.domManip(arguments,function(n){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var t=vr(this,n);t.insertBefore(n,t.firstChild)}})},before:function(){return this.domManip(arguments,function(n){this.parentNode&&this.parentNode.insertBefore(n,this)})},after:function(){return this.domManip(arguments,function(n){this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling)})},remove:function(n,t){for(var r,f=n?i.filter(n,this):this,u=0;(r=f[u])!=null;u++)t||r.nodeType!==1||i.cleanData(o(r)),r.parentNode&&(t&&i.contains(r.ownerDocument,r)&&ei(o(r,"script")),r.parentNode.removeChild(r));return this},empty:function(){for(var n,t=0;(n=this[t])!=null;t++)n.nodeType===1&&(i.cleanData(o(n,!1)),n.textContent="");return this},clone:function(n,t){return n=n==null?!1:n,t=t==null?n:t,this.map(function(){return i.clone(this,n,t)})},html:function(n){return l(this,function(n){var t=this[0]||{},r=0,u=this.length;if(n===undefined&&t.nodeType===1)return t.innerHTML;if(typeof n=="string"&&!vf.test(n)&&!h[(lr.exec(n)||["",""])[1].toLowerCase()]){n=n.replace(cr,"<$1><\/$2>");try{for(;r<u;r++)t=this[r]||{},t.nodeType===1&&(i.cleanData(o(t,!1)),t.innerHTML=n);t=0}catch(f){}}t&&this.empty().append(n)},null,n,arguments.length)},replaceWith:function(){var n=arguments[0];return this.domManip(arguments,function(t){n=this.parentNode;i.cleanData(o(this));n&&n.replaceChild(t,this)}),n&&(n.length||n.nodeType)?this:this.remove()},detach:function(n){return this.remove(n,!0)},domManip:function(n,t){n=bi.apply([],n);var h,v,s,c,u,y,e=0,l=this.length,w=this,b=l-1,a=n[0],p=i.isFunction(a);if(p||l>1&&typeof a=="string"&&!f.checkClone&&yf.test(a))return this.each(function(i){var r=w.eq(i);p&&(n[0]=a.call(this,i,r.html()));r.domManip(n,t)});if(l&&(h=i.buildFragment(n,this[0].ownerDocument,!1,this),v=h.firstChild,h.childNodes.length===1&&(h=v),v)){for(s=i.map(o(h,"script"),bf),c=s.length;e<l;e++)u=h,e!==b&&(u=i.clone(u,!0,!0),c&&i.merge(s,o(u,"script"))),t.call(this[e],u,e);if(c)for(y=s[s.length-1].ownerDocument,i.map(s,kf),e=0;e<c;e++)u=s[e],ar.test(u.type||"")&&!r.access(u,"globalEval")&&i.contains(y,u)&&(u.src?i._evalUrl&&i._evalUrl(u.src):i.globalEval(u.textContent.replace(wf,"")))}return this}});i.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(n,t){i.fn[n]=function(n){for(var u,f=[],e=i(n),o=e.length-1,r=0;r<=o;r++)u=r===o?this:this.clone(!0),i(e[r])[t](u),ti.apply(f,u.get());return this.pushStack(f)}});oi={};var wr=/^margin/,hi=new RegExp("^("+ct+")(?!px)[a-z%]+$","i"),vt=function(t){return t.ownerDocument.defaultView.opener?t.ownerDocument.defaultView.getComputedStyle(t,null):n.getComputedStyle(t,null)};(function(){function h(){t.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute";t.innerHTML="";e.appendChild(r);var i=n.getComputedStyle(t,null);s=i.top!=="1%";o=i.width==="4px";e.removeChild(r)}var s,o,e=u.documentElement,r=u.createElement("div"),t=u.createElement("div");t.style&&(t.style.backgroundClip="content-box",t.cloneNode(!0).style.backgroundClip="",f.clearCloneStyle=t.style.backgroundClip==="content-box",r.style.cssText="border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;position:absolute",r.appendChild(t),n.getComputedStyle&&i.extend(f,{pixelPosition:function(){return h(),s},boxSizingReliable:function(){return o==null&&h(),o},reliableMarginRight:function(){var f,i=t.appendChild(u.createElement("div"));return i.style.cssText=t.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",i.style.marginRight=i.style.width="0",t.style.width="1px",e.appendChild(r),f=!parseFloat(n.getComputedStyle(i,null).marginRight),e.removeChild(r),t.removeChild(i),f}}))})();i.swap=function(n,t,i,r){var f,u,e={};for(u in t)e[u]=n.style[u],n.style[u]=t[u];f=i.apply(n,r||[]);for(u in t)n.style[u]=e[u];return f};var gf=/^(none|table(?!-c[ea]).+)/,ne=new RegExp("^("+ct+")(.*)$","i"),te=new RegExp("^([+-])=("+ct+")","i"),ie={position:"absolute",visibility:"hidden",display:"block"},kr={letterSpacing:"0",fontWeight:"400"},dr=["Webkit","O","Moz","ms"];i.extend({cssHooks:{opacity:{get:function(n,t){if(t){var i=it(n,"opacity");return i===""?"1":i}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{float:"cssFloat"},style:function(n,t,r,u){if(n&&n.nodeType!==3&&n.nodeType!==8&&n.style){var o,h,e,s=i.camelCase(t),c=n.style;if(t=i.cssProps[s]||(i.cssProps[s]=gr(c,s)),e=i.cssHooks[t]||i.cssHooks[s],r!==undefined){if(h=typeof r,h==="string"&&(o=te.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(i.css(n,t)),h="number"),r==null||r!==r)return;h!=="number"||i.cssNumber[s]||(r+="px");f.clearCloneStyle||r!==""||t.indexOf("background")!==0||(c[t]="inherit");e&&"set"in e&&(r=e.set(n,r,u))===undefined||(c[t]=r)}else return e&&"get"in e&&(o=e.get(n,!1,u))!==undefined?o:c[t]}},css:function(n,t,r,u){var f,s,e,o=i.camelCase(t);return(t=i.cssProps[o]||(i.cssProps[o]=gr(n.style,o)),e=i.cssHooks[t]||i.cssHooks[o],e&&"get"in e&&(f=e.get(n,!0,r)),f===undefined&&(f=it(n,t,u)),f==="normal"&&t in kr&&(f=kr[t]),r===""||r)?(s=parseFloat(f),r===!0||i.isNumeric(s)?s||0:f):f}});i.each(["height","width"],function(n,t){i.cssHooks[t]={get:function(n,r,u){if(r)return gf.test(i.css(n,"display"))&&n.offsetWidth===0?i.swap(n,ie,function(){return iu(n,t,u)}):iu(n,t,u)},set:function(n,r,u){var f=u&&vt(n);return nu(n,r,u?tu(n,t,u,i.css(n,"boxSizing",!1,f)==="border-box",f):0)}}});i.cssHooks.marginRight=br(f.reliableMarginRight,function(n,t){if(t)return i.swap(n,{display:"inline-block"},it,[n,"marginRight"])});i.each({margin:"",padding:"",border:"Width"},function(n,t){i.cssHooks[n+t]={expand:function(i){for(var r=0,f={},u=typeof i=="string"?i.split(" "):[i];r<4;r++)f[n+p[r]+t]=u[r]||u[r-2]||u[0];return f}};wr.test(n)||(i.cssHooks[n+t].set=nu)});i.fn.extend({css:function(n,t){return l(this,function(n,t,r){var f,e,o={},u=0;if(i.isArray(t)){for(f=vt(n),e=t.length;u<e;u++)o[t[u]]=i.css(n,t[u],!1,f);return o}return r!==undefined?i.style(n,t,r):i.css(n,t)},n,t,arguments.length>1)},show:function(){return ru(this,!0)},hide:function(){return ru(this)},toggle:function(n){return typeof n=="boolean"?n?this.show():this.hide():this.each(function(){tt(this)?i(this).show():i(this).hide()})}});i.Tween=s;s.prototype={constructor:s,init:function(n,t,r,u,f,e){this.elem=n;this.prop=r;this.easing=f||"swing";this.options=t;this.start=this.now=this.cur();this.end=u;this.unit=e||(i.cssNumber[r]?"":"px")},cur:function(){var n=s.propHooks[this.prop];return n&&n.get?n.get(this):s.propHooks._default.get(this)},run:function(n){var t,r=s.propHooks[this.prop];return this.pos=this.options.duration?t=i.easing[this.easing](n,this.options.duration*n,0,1,this.options.duration):t=n,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),r&&r.set?r.set(this):s.propHooks._default.set(this),this}};s.prototype.init.prototype=s.prototype;s.propHooks={_default:{get:function(n){var t;return n.elem[n.prop]!=null&&(!n.elem.style||n.elem.style[n.prop]==null)?n.elem[n.prop]:(t=i.css(n.elem,n.prop,""),!t||t==="auto"?0:t)},set:function(n){i.fx.step[n.prop]?i.fx.step[n.prop](n):n.elem.style&&(n.elem.style[i.cssProps[n.prop]]!=null||i.cssHooks[n.prop])?i.style(n.elem,n.prop,n.now+n.unit):n.elem[n.prop]=n.now}}};s.propHooks.scrollTop=s.propHooks.scrollLeft={set:function(n){n.elem.nodeType&&n.elem.parentNode&&(n.elem[n.prop]=n.now)}};i.easing={linear:function(n){return n},swing:function(n){return.5-Math.cos(n*Math.PI)/2}};i.fx=s.prototype.init;i.fx.step={};var d,yt,re=/^(?:toggle|show|hide)$/,uu=new RegExp("^(?:([+-])=|)("+ct+")([a-z%]*)$","i"),ue=/queueHooks$/,pt=[fe],rt={"*":[function(n,t){var f=this.createTween(n,t),s=f.cur(),u=uu.exec(t),e=u&&u[3]||(i.cssNumber[n]?"":"px"),r=(i.cssNumber[n]||e!=="px"&&+s)&&uu.exec(i.css(f.elem,n)),o=1,h=20;if(r&&r[3]!==e){e=e||r[3];u=u||[];r=+s||1;do o=o||".5",r=r/o,i.style(f.elem,n,r+e);while(o!==(o=f.cur()/s)&&o!==1&&--h)}return u&&(r=f.start=+r||+s||0,f.unit=e,f.end=u[1]?r+(u[1]+1)*u[2]:+u[2]),f}]};i.Animation=i.extend(ou,{tweener:function(n,t){i.isFunction(n)?(t=n,n=["*"]):n=n.split(" ");for(var r,u=0,f=n.length;u<f;u++)r=n[u],rt[r]=rt[r]||[],rt[r].unshift(t)},prefilter:function(n,t){t?pt.unshift(n):pt.push(n)}});i.speed=function(n,t,r){var u=n&&typeof n=="object"?i.extend({},n):{complete:r||!r&&t||i.isFunction(n)&&n,duration:n,easing:r&&t||t&&!i.isFunction(t)&&t};return u.duration=i.fx.off?0:typeof u.duration=="number"?u.duration:u.duration in i.fx.speeds?i.fx.speeds[u.duration]:i.fx.speeds._default,(u.queue==null||u.queue===!0)&&(u.queue="fx"),u.old=u.complete,u.complete=function(){i.isFunction(u.old)&&u.old.call(this);u.queue&&i.dequeue(this,u.queue)},u};i.fn.extend({fadeTo:function(n,t,i,r){return this.filter(tt).css("opacity",0).show().end().animate({opacity:t},n,i,r)},animate:function(n,t,u,f){var s=i.isEmptyObject(n),o=i.speed(t,u,f),e=function(){var t=ou(this,i.extend({},n),o);(s||r.get(this,"finish"))&&t.stop(!0)};return e.finish=e,s||o.queue===!1?this.each(e):this.queue(o.queue,e)},stop:function(n,t,u){var f=function(n){var t=n.stop;delete n.stop;t(u)};return typeof n!="string"&&(u=t,t=n,n=undefined),t&&n!==!1&&this.queue(n||"fx",[]),this.each(function(){var s=!0,t=n!=null&&n+"queueHooks",o=i.timers,e=r.get(this);if(t)e[t]&&e[t].stop&&f(e[t]);else for(t in e)e[t]&&e[t].stop&&ue.test(t)&&f(e[t]);for(t=o.length;t--;)o[t].elem===this&&(n==null||o[t].queue===n)&&(o[t].anim.stop(u),s=!1,o.splice(t,1));(s||!u)&&i.dequeue(this,n)})},finish:function(n){return n!==!1&&(n=n||"fx"),this.each(function(){var t,e=r.get(this),u=e[n+"queue"],o=e[n+"queueHooks"],f=i.timers,s=u?u.length:0;for(e.finish=!0,i.queue(this,n,[]),o&&o.stop&&o.stop.call(this,!0),t=f.length;t--;)f[t].elem===this&&f[t].queue===n&&(f[t].anim.stop(!0),f.splice(t,1));for(t=0;t<s;t++)u[t]&&u[t].finish&&u[t].finish.call(this);delete e.finish})}});i.each(["toggle","show","hide"],function(n,t){var r=i.fn[t];i.fn[t]=function(n,i,u){return n==null||typeof n=="boolean"?r.apply(this,arguments):this.animate(wt(t,!0),n,i,u)}});i.each({slideDown:wt("show"),slideUp:wt("hide"),slideToggle:wt("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(n,t){i.fn[n]=function(n,i,r){return this.animate(t,n,i,r)}});i.timers=[];i.fx.tick=function(){var r,n=0,t=i.timers;for(d=i.now();n<t.length;n++)r=t[n],r()||t[n]!==r||t.splice(n--,1);t.length||i.fx.stop();d=undefined};i.fx.timer=function(n){i.timers.push(n);n()?i.fx.start():i.timers.pop()};i.fx.interval=13;i.fx.start=function(){yt||(yt=setInterval(i.fx.tick,i.fx.interval))};i.fx.stop=function(){clearInterval(yt);yt=null};i.fx.speeds={slow:600,fast:200,_default:400};i.fn.delay=function(n,t){return n=i.fx?i.fx.speeds[n]||n:n,t=t||"fx",this.queue(t,function(t,i){var r=setTimeout(t,n);i.stop=function(){clearTimeout(r)}})},function(){var n=u.createElement("input"),t=u.createElement("select"),i=t.appendChild(u.createElement("option"));n.type="checkbox";f.checkOn=n.value!=="";f.optSelected=i.selected;t.disabled=!0;f.optDisabled=!i.disabled;n=u.createElement("input");n.value="t";n.type="radio";f.radioValue=n.value==="t"}();g=i.expr.attrHandle;i.fn.extend({attr:function(n,t){return l(this,i.attr,n,t,arguments.length>1)},removeAttr:function(n){return this.each(function(){i.removeAttr(this,n)})}});i.extend({attr:function(n,t,r){var u,f,e=n.nodeType;if(n&&e!==3&&e!==8&&e!==2){if(typeof n.getAttribute===b)return i.prop(n,t,r);if(e===1&&i.isXMLDoc(n)||(t=t.toLowerCase(),u=i.attrHooks[t]||(i.expr.match.bool.test(t)?su:oe)),r!==undefined)if(r===null)i.removeAttr(n,t);else return u&&"set"in u&&(f=u.set(n,r,t))!==undefined?f:(n.setAttribute(t,r+""),r);else return u&&"get"in u&&(f=u.get(n,t))!==null?f:(f=i.find.attr(n,t),f==null?undefined:f)}},removeAttr:function(n,t){var r,u,e=0,f=t&&t.match(c);if(f&&n.nodeType===1)while(r=f[e++])u=i.propFix[r]||r,i.expr.match.bool.test(r)&&(n[u]=!1),n.removeAttribute(r)},attrHooks:{type:{set:function(n,t){if(!f.radioValue&&t==="radio"&&i.nodeName(n,"input")){var r=n.value;return n.setAttribute("type",t),r&&(n.value=r),t}}}}});su={set:function(n,t,r){return t===!1?i.removeAttr(n,r):n.setAttribute(r,r),r}};i.each(i.expr.match.bool.source.match(/\w+/g),function(n,t){var r=g[t]||i.find.attr;g[t]=function(n,t,i){var u,f;return i||(f=g[t],g[t]=u,u=r(n,t,i)!=null?t.toLowerCase():null,g[t]=f),u}});hu=/^(?:input|select|textarea|button)$/i;i.fn.extend({prop:function(n,t){return l(this,i.prop,n,t,arguments.length>1)},removeProp:function(n){return this.each(function(){delete this[i.propFix[n]||n]})}});i.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(n,t,r){var f,u,o,e=n.nodeType;if(n&&e!==3&&e!==8&&e!==2)return o=e!==1||!i.isXMLDoc(n),o&&(t=i.propFix[t]||t,u=i.propHooks[t]),r!==undefined?u&&"set"in u&&(f=u.set(n,r,t))!==undefined?f:n[t]=r:u&&"get"in u&&(f=u.get(n,t))!==null?f:n[t]},propHooks:{tabIndex:{get:function(n){return n.hasAttribute("tabindex")||hu.test(n.nodeName)||n.href?n.tabIndex:-1}}}});f.optSelected||(i.propHooks.selected={get:function(n){var t=n.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null}});i.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){i.propFix[this.toLowerCase()]=this});bt=/[\t\r\n\f]/g;i.fn.extend({addClass:function(n){var o,t,r,u,s,f,h=typeof n=="string"&&n,e=0,l=this.length;if(i.isFunction(n))return this.each(function(t){i(this).addClass(n.call(this,t,this.className))});if(h)for(o=(n||"").match(c)||[];e<l;e++)if(t=this[e],r=t.nodeType===1&&(t.className?(" "+t.className+" ").replace(bt," "):" "),r){for(s=0;u=o[s++];)r.indexOf(" "+u+" ")<0&&(r+=u+" ");f=i.trim(r);t.className!==f&&(t.className=f)}return this},removeClass:function(n){var o,t,r,u,s,f,h=arguments.length===0||typeof n=="string"&&n,e=0,l=this.length;if(i.isFunction(n))return this.each(function(t){i(this).removeClass(n.call(this,t,this.className))});if(h)for(o=(n||"").match(c)||[];e<l;e++)if(t=this[e],r=t.nodeType===1&&(t.className?(" "+t.className+" ").replace(bt," "):""),r){for(s=0;u=o[s++];)while(r.indexOf(" "+u+" ")>=0)r=r.replace(" "+u+" "," ");f=n?i.trim(r):"";t.className!==f&&(t.className=f)}return this},toggleClass:function(n,t){var u=typeof n;return typeof t=="boolean"&&u==="string"?t?this.addClass(n):this.removeClass(n):i.isFunction(n)?this.each(function(r){i(this).toggleClass(n.call(this,r,this.className,t),t)}):this.each(function(){if(u==="string")for(var t,e=0,f=i(this),o=n.match(c)||[];t=o[e++];)f.hasClass(t)?f.removeClass(t):f.addClass(t);else(u===b||u==="boolean")&&(this.className&&r.set(this,"__className__",this.className),this.className=this.className||n===!1?"":r.get(this,"__className__")||"")})},hasClass:function(n){for(var i=" "+n+" ",t=0,r=this.length;t<r;t++)if(this[t].nodeType===1&&(" "+this[t].className+" ").replace(bt," ").indexOf(i)>=0)return!0;return!1}});cu=/\r/g;i.fn.extend({val:function(n){var t,r,f,u=this[0];return arguments.length?(f=i.isFunction(n),this.each(function(r){var u;this.nodeType===1&&(u=f?n.call(this,r,i(this).val()):n,u==null?u="":typeof u=="number"?u+="":i.isArray(u)&&(u=i.map(u,function(n){return n==null?"":n+""})),t=i.valHooks[this.type]||i.valHooks[this.nodeName.toLowerCase()],t&&"set"in t&&t.set(this,u,"value")!==undefined||(this.value=u))})):u?(t=i.valHooks[u.type]||i.valHooks[u.nodeName.toLowerCase()],t&&"get"in t&&(r=t.get(u,"value"))!==undefined)?r:(r=u.value,typeof r=="string"?r.replace(cu,""):r==null?"":r):void 0}});i.extend({valHooks:{option:{get:function(n){var t=i.find.attr(n,"value");return t!=null?t:i.trim(i.text(n))}},select:{get:function(n){for(var o,t,s=n.options,r=n.selectedIndex,u=n.type==="select-one"||r<0,h=u?null:[],c=u?r+1:s.length,e=r<0?c:u?r:0;e<c;e++)if(t=s[e],(t.selected||e===r)&&(f.optDisabled?!t.disabled:t.getAttribute("disabled")===null)&&(!t.parentNode.disabled||!i.nodeName(t.parentNode,"optgroup"))){if(o=i(t).val(),u)return o;h.push(o)}return h},set:function(n,t){for(var u,r,f=n.options,e=i.makeArray(t),o=f.length;o--;)r=f[o],(r.selected=i.inArray(r.value,e)>=0)&&(u=!0);return u||(n.selectedIndex=-1),e}}}});i.each(["radio","checkbox"],function(){i.valHooks[this]={set:function(n,t){if(i.isArray(t))return n.checked=i.inArray(i(n).val(),t)>=0}};f.checkOn||(i.valHooks[this].get=function(n){return n.getAttribute("value")===null?"on":n.value})});i.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(n,t){i.fn[t]=function(n,i){return arguments.length>0?this.on(t,null,n,i):this.trigger(t)}});i.fn.extend({hover:function(n,t){return this.mouseenter(n).mouseleave(t||n)},bind:function(n,t,i){return this.on(n,null,t,i)},unbind:function(n,t){return this.off(n,null,t)},delegate:function(n,t,i,r){return this.on(t,n,i,r)},undelegate:function(n,t,i){return arguments.length===1?this.off(n,"**"):this.off(t,n||"**",i)}});kt=i.now();dt=/\?/;i.parseJSON=function(n){return JSON.parse(n+"")};i.parseXML=function(n){var t,r;if(!n||typeof n!="string")return null;try{r=new DOMParser;t=r.parseFromString(n,"text/xml")}catch(u){t=undefined}return(!t||t.getElementsByTagName("parsererror").length)&&i.error("Invalid XML: "+n),t};var se=/#.*$/,lu=/([?&])_=[^&]*/,he=/^(.*?):[ \t]*([^\r\n]*)$/mg,ce=/^(?:GET|HEAD)$/,le=/^\/\//,au=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,vu={},ci={},yu="*/".concat("*"),li=n.location.href,nt=au.exec(li.toLowerCase())||[];i.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:li,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(nt[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":yu,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",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":i.parseJSON,"text xml":i.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(n,t){return t?ai(ai(n,i.ajaxSettings),t):ai(i.ajaxSettings,n)},ajaxPrefilter:pu(vu),ajaxTransport:pu(ci),ajax:function(n,t){function p(n,t,h,c){var v,it,tt,p,nt,l=t;e!==2&&(e=2,b&&clearTimeout(b),s=undefined,w=c||"",u.readyState=n>0?4:0,v=n>=200&&n<300||n===304,h&&(p=ae(r,u,h)),p=ve(r,p,u,v),v?(r.ifModified&&(nt=u.getResponseHeader("Last-Modified"),nt&&(i.lastModified[f]=nt),nt=u.getResponseHeader("etag"),nt&&(i.etag[f]=nt)),n===204||r.type==="HEAD"?l="nocontent":n===304?l="notmodified":(l=p.state,it=p.data,tt=p.error,v=!tt)):(tt=l,(n||!l)&&(l="error",n<0&&(n=0))),u.status=n,u.statusText=(t||l)+"",v?d.resolveWith(o,[it,l,u]):d.rejectWith(o,[u,l,tt]),u.statusCode(y),y=undefined,a&&k.trigger(v?"ajaxSuccess":"ajaxError",[u,r,v?it:tt]),g.fireWith(o,[u,l]),a&&(k.trigger("ajaxComplete",[u,r]),--i.active||i.event.trigger("ajaxStop")))}typeof n=="object"&&(t=n,n=undefined);t=t||{};var s,f,w,v,b,h,a,l,r=i.ajaxSetup({},t),o=r.context||r,k=r.context&&(o.nodeType||o.jquery)?i(o):i.event,d=i.Deferred(),g=i.Callbacks("once memory"),y=r.statusCode||{},tt={},it={},e=0,rt="canceled",u={readyState:0,getResponseHeader:function(n){var t;if(e===2){if(!v)for(v={};t=he.exec(w);)v[t[1].toLowerCase()]=t[2];t=v[n.toLowerCase()]}return t==null?null:t},getAllResponseHeaders:function(){return e===2?w:null},setRequestHeader:function(n,t){var i=n.toLowerCase();return e||(n=it[i]=it[i]||n,tt[n]=t),this},overrideMimeType:function(n){return e||(r.mimeType=n),this},statusCode:function(n){var t;if(n)if(e<2)for(t in n)y[t]=[y[t],n[t]];else u.always(n[u.status]);return this},abort:function(n){var t=n||rt;return s&&s.abort(t),p(0,t),this}};if(d.promise(u).complete=g.add,u.success=u.done,u.error=u.fail,r.url=((n||r.url||li)+"").replace(se,"").replace(le,nt[1]+"//"),r.type=t.method||t.type||r.method||r.type,r.dataTypes=i.trim(r.dataType||"*").toLowerCase().match(c)||[""],r.crossDomain==null&&(h=au.exec(r.url.toLowerCase()),r.crossDomain=!!(h&&(h[1]!==nt[1]||h[2]!==nt[2]||(h[3]||(h[1]==="http:"?"80":"443"))!==(nt[3]||(nt[1]==="http:"?"80":"443"))))),r.data&&r.processData&&typeof r.data!="string"&&(r.data=i.param(r.data,r.traditional)),wu(vu,r,t,u),e===2)return u;a=i.event&&r.global;a&&i.active++==0&&i.event.trigger("ajaxStart");r.type=r.type.toUpperCase();r.hasContent=!ce.test(r.type);f=r.url;r.hasContent||(r.data&&(f=r.url+=(dt.test(f)?"&":"?")+r.data,delete r.data),r.cache===!1&&(r.url=lu.test(f)?f.replace(lu,"$1_="+kt++):f+(dt.test(f)?"&":"?")+"_="+kt++));r.ifModified&&(i.lastModified[f]&&u.setRequestHeader("If-Modified-Since",i.lastModified[f]),i.etag[f]&&u.setRequestHeader("If-None-Match",i.etag[f]));(r.data&&r.hasContent&&r.contentType!==!1||t.contentType)&&u.setRequestHeader("Content-Type",r.contentType);u.setRequestHeader("Accept",r.dataTypes[0]&&r.accepts[r.dataTypes[0]]?r.accepts[r.dataTypes[0]]+(r.dataTypes[0]!=="*"?", "+yu+"; q=0.01":""):r.accepts["*"]);for(l in r.headers)u.setRequestHeader(l,r.headers[l]);if(r.beforeSend&&(r.beforeSend.call(o,u,r)===!1||e===2))return u.abort();rt="abort";for(l in{success:1,error:1,complete:1})u[l](r[l]);if(s=wu(ci,r,t,u),s){u.readyState=1;a&&k.trigger("ajaxSend",[u,r]);r.async&&r.timeout>0&&(b=setTimeout(function(){u.abort("timeout")},r.timeout));try{e=1;s.send(tt,p)}catch(ut){if(e<2)p(-1,ut);else throw ut;}}else p(-1,"No Transport");return u},getJSON:function(n,t,r){return i.get(n,t,r,"json")},getScript:function(n,t){return i.get(n,undefined,t,"script")}});i.each(["get","post"],function(n,t){i[t]=function(n,r,u,f){return i.isFunction(r)&&(f=f||u,u=r,r=undefined),i.ajax({url:n,type:t,dataType:f,data:r,success:u})}});i._evalUrl=function(n){return i.ajax({url:n,type:"GET",dataType:"script",async:!1,global:!1,throws:!0})};i.fn.extend({wrapAll:function(n){var t;return i.isFunction(n)?this.each(function(t){i(this).wrapAll(n.call(this,t))}):(this[0]&&(t=i(n,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var n=this;n.firstElementChild;)n=n.firstElementChild;return n}).append(this)),this)},wrapInner:function(n){return i.isFunction(n)?this.each(function(t){i(this).wrapInner(n.call(this,t))}):this.each(function(){var t=i(this),r=t.contents();r.length?r.wrapAll(n):t.append(n)})},wrap:function(n){var t=i.isFunction(n);return this.each(function(r){i(this).wrapAll(t?n.call(this,r):n)})},unwrap:function(){return this.parent().each(function(){i.nodeName(this,"body")||i(this).replaceWith(this.childNodes)}).end()}});i.expr.filters.hidden=function(n){return n.offsetWidth<=0&&n.offsetHeight<=0};i.expr.filters.visible=function(n){return!i.expr.filters.hidden(n)};var ye=/%20/g,pe=/\[\]$/,bu=/\r?\n/g,we=/^(?:submit|button|image|reset|file)$/i,be=/^(?:input|select|textarea|keygen)/i;i.param=function(n,t){var r,u=[],f=function(n,t){t=i.isFunction(t)?t():t==null?"":t;u[u.length]=encodeURIComponent(n)+"="+encodeURIComponent(t)};if(t===undefined&&(t=i.ajaxSettings&&i.ajaxSettings.traditional),i.isArray(n)||n.jquery&&!i.isPlainObject(n))i.each(n,function(){f(this.name,this.value)});else for(r in n)vi(r,n[r],t,f);return u.join("&").replace(ye,"+")};i.fn.extend({serialize:function(){return i.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var n=i.prop(this,"elements");return n?i.makeArray(n):this}).filter(function(){var n=this.type;return this.name&&!i(this).is(":disabled")&&be.test(this.nodeName)&&!we.test(n)&&(this.checked||!er.test(n))}).map(function(n,t){var r=i(this).val();return r==null?null:i.isArray(r)?i.map(r,function(n){return{name:t.name,value:n.replace(bu,"\r\n")}}):{name:t.name,value:r.replace(bu,"\r\n")}}).get()}});i.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(n){}};var ke=0,gt={},de={0:200,1223:204},ut=i.ajaxSettings.xhr();return n.attachEvent&&n.attachEvent("onunload",function(){for(var n in gt)gt[n]()}),f.cors=!!ut&&"withCredentials"in ut,f.ajax=ut=!!ut,i.ajaxTransport(function(n){var t;if(f.cors||ut&&!n.crossDomain)return{send:function(i,r){var f,u=n.xhr(),e=++ke;if(u.open(n.type,n.url,n.async,n.username,n.password),n.xhrFields)for(f in n.xhrFields)u[f]=n.xhrFields[f];n.mimeType&&u.overrideMimeType&&u.overrideMimeType(n.mimeType);n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(f in i)u.setRequestHeader(f,i[f]);t=function(n){return function(){t&&(delete gt[e],t=u.onload=u.onerror=null,n==="abort"?u.abort():n==="error"?r(u.status,u.statusText):r(de[u.status]||u.status,u.statusText,typeof u.responseText=="string"?{text:u.responseText}:undefined,u.getAllResponseHeaders()))}};u.onload=t();u.onerror=t("error");t=gt[e]=t("abort");try{u.send(n.hasContent&&n.data||null)}catch(o){if(t)throw o;}},abort:function(){t&&t()}}}),i.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(n){return i.globalEval(n),n}}}),i.ajaxPrefilter("script",function(n){n.cache===undefined&&(n.cache=!1);n.crossDomain&&(n.type="GET")}),i.ajaxTransport("script",function(n){if(n.crossDomain){var r,t;return{send:function(f,e){r=i("<script>").prop({async:!0,charset:n.scriptCharset,src:n.url}).on("load error",t=function(n){r.remove();t=null;n&&e(n.type==="error"?404:200,n.type)});u.head.appendChild(r[0])},abort:function(){t&&t()}}}}),yi=[],ni=/(=)\?(?=&|$)|\?\?/,i.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var n=yi.pop()||i.expando+"_"+kt++;return this[n]=!0,n}}),i.ajaxPrefilter("json jsonp",function(t,r,u){var f,o,e,s=t.jsonp!==!1&&(ni.test(t.url)?"url":typeof t.data=="string"&&!(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&ni.test(t.data)&&"data");if(s||t.dataTypes[0]==="jsonp")return f=t.jsonpCallback=i.isFunction(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,s?t[s]=t[s].replace(ni,"$1"+f):t.jsonp!==!1&&(t.url+=(dt.test(t.url)?"&":"?")+t.jsonp+"="+f),t.converters["script json"]=function(){return e||i.error(f+" was not called"),e[0]},t.dataTypes[0]="json",o=n[f],n[f]=function(){e=arguments},u.always(function(){n[f]=o;t[f]&&(t.jsonpCallback=r.jsonpCallback,yi.push(f));e&&i.isFunction(o)&&o(e[0]);e=o=undefined}),"script"}),i.parseHTML=function(n,t,r){if(!n||typeof n!="string")return null;typeof t=="boolean"&&(r=t,t=!1);t=t||u;var f=gi.exec(n),e=!r&&[];return f?[t.createElement(f[1])]:(f=i.buildFragment([n],t,e),e&&e.length&&i(e).remove(),i.merge([],f.childNodes))},pi=i.fn.load,i.fn.load=function(n,t,r){if(typeof n!="string"&&pi)return pi.apply(this,arguments);var u,o,s,f=this,e=n.indexOf(" ");return e>=0&&(u=i.trim(n.slice(e)),n=n.slice(0,e)),i.isFunction(t)?(r=t,t=undefined):t&&typeof t=="object"&&(o="POST"),f.length>0&&i.ajax({url:n,type:o,dataType:"html",data:t}).done(function(n){s=arguments;f.html(u?i("<div>").append(i.parseHTML(n)).find(u):n)}).complete(r&&function(n,t){f.each(r,s||[n.responseText,t,n])}),this},i.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(n,t){i.fn[t]=function(n){return this.on(t,n)}}),i.expr.filters.animated=function(n){return i.grep(i.timers,function(t){return n===t.elem}).length},wi=n.document.documentElement,i.offset={setOffset:function(n,t,r){var e,o,s,h,u,c,v,l=i.css(n,"position"),a=i(n),f={};l==="static"&&(n.style.position="relative");u=a.offset();s=i.css(n,"top");c=i.css(n,"left");v=(l==="absolute"||l==="fixed")&&(s+c).indexOf("auto")>-1;v?(e=a.position(),h=e.top,o=e.left):(h=parseFloat(s)||0,o=parseFloat(c)||0);i.isFunction(t)&&(t=t.call(n,r,u));t.top!=null&&(f.top=t.top-u.top+h);t.left!=null&&(f.left=t.left-u.left+o);"using"in t?t.using.call(n,f):a.css(f)}},i.fn.extend({offset:function(n){if(arguments.length)return n===undefined?this:this.each(function(t){i.offset.setOffset(this,n,t)});var r,f,t=this[0],u={top:0,left:0},e=t&&t.ownerDocument;if(e)return(r=e.documentElement,!i.contains(r,t))?u:(typeof t.getBoundingClientRect!==b&&(u=t.getBoundingClientRect()),f=ku(e),{top:u.top+f.pageYOffset-r.clientTop,left:u.left+f.pageXOffset-r.clientLeft})},position:function(){if(this[0]){var n,r,u=this[0],t={top:0,left:0};return i.css(u,"position")==="fixed"?r=u.getBoundingClientRect():(n=this.offsetParent(),r=this.offset(),i.nodeName(n[0],"html")||(t=n.offset()),t.top+=i.css(n[0],"borderTopWidth",!0),t.left+=i.css(n[0],"borderLeftWidth",!0)),{top:r.top-t.top-i.css(u,"marginTop",!0),left:r.left-t.left-i.css(u,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var n=this.offsetParent||wi;n&&!i.nodeName(n,"html")&&i.css(n,"position")==="static";)n=n.offsetParent;return n||wi})}}),i.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,r){var u="pageYOffset"===r;i.fn[t]=function(i){return l(this,function(t,i,f){var e=ku(t);if(f===undefined)return e?e[r]:t[i];e?e.scrollTo(u?n.pageXOffset:f,u?f:n.pageYOffset):t[i]=f},t,i,arguments.length,null)}}),i.each(["top","left"],function(n,t){i.cssHooks[t]=br(f.pixelPosition,function(n,r){if(r)return r=it(n,t),hi.test(r)?i(n).position()[t]+"px":r})}),i.each({Height:"height",Width:"width"},function(n,t){i.each({padding:"inner"+n,content:t,"":"outer"+n},function(r,u){i.fn[u]=function(u,f){var e=arguments.length&&(r||typeof u!="boolean"),o=r||(u===!0||f===!0?"margin":"border");return l(this,function(t,r,u){var f;return i.isWindow(t)?t.document.documentElement["client"+n]:t.nodeType===9?(f=t.documentElement,Math.max(t.body["scroll"+n],f["scroll"+n],t.body["offset"+n],f["offset"+n],f["client"+n])):u===undefined?i.css(t,r,o):i.style(t,r,u,o)},t,e?u:undefined,e,null)}})}),i.fn.size=function(){return this.length},i.fn.andSelf=i.fn.addBack,typeof define=="function"&&define.amd&&define("jquery",[],function(){return i}),du=n.jQuery,gu=n.$,i.noConflict=function(t){return n.$===i&&(n.$=gu),t&&n.jQuery===i&&(n.jQuery=du),i},typeof t===b&&(n.jQuery=n.$=i),i});!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.moment=t()}(this,function(){"use strict";function i(){return kf.apply(null,arguments)}function pe(n){kf=n}function ui(n){return"[object Array]"===Object.prototype.toString.call(n)}function fi(n){return n instanceof Date||"[object Date]"===Object.prototype.toString.call(n)}function we(n,t){for(var r=[],i=0;i<n.length;++i)r.push(t(n[i],i));return r}function ft(n,t){return Object.prototype.hasOwnProperty.call(n,t)}function ei(n,t){for(var i in t)ft(t,i)&&(n[i]=t[i]);return ft(t,"toString")&&(n.toString=t.toString),ft(t,"valueOf")&&(n.valueOf=t.valueOf),n}function kt(n,t,i,r){return gu(n,t,i,r,!0).utc()}function be(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function e(n){return null==n._pf&&(n._pf=be()),n._pf}function iu(n){if(null==n._isValid){var t=e(n);n._isValid=!(isNaN(n._d.getTime())||!(t.overflow<0)||t.empty||t.invalidMonth||t.invalidWeekday||t.nullInput||t.invalidFormat||t.userInvalidated);n._strict&&(n._isValid=n._isValid&&0===t.charsLeftOver&&0===t.unusedTokens.length&&void 0===t.bigHour)}return n._isValid}function ru(n){var t=kt(NaN);return null!=n?ei(e(t),n):e(t).userInvalidated=!0,t}function ki(n,t){var u,i,r;if("undefined"!=typeof t._isAMomentObject&&(n._isAMomentObject=t._isAMomentObject),"undefined"!=typeof t._i&&(n._i=t._i),"undefined"!=typeof t._f&&(n._f=t._f),"undefined"!=typeof t._l&&(n._l=t._l),"undefined"!=typeof t._strict&&(n._strict=t._strict),"undefined"!=typeof t._tzm&&(n._tzm=t._tzm),"undefined"!=typeof t._isUTC&&(n._isUTC=t._isUTC),"undefined"!=typeof t._offset&&(n._offset=t._offset),"undefined"!=typeof t._pf&&(n._pf=e(t)),"undefined"!=typeof t._locale&&(n._locale=t._locale),cr.length>0)for(u in cr)i=cr[u],r=t[i],"undefined"!=typeof r&&(n[i]=r);return n}function dt(n){ki(this,n);this._d=new Date(null!=n._d?n._d.getTime():NaN);lr===!1&&(lr=!0,i.updateOffset(this),lr=!1)}function nt(n){return n instanceof dt||null!=n&&null!=n._isAMomentObject}function v(n){return 0>n?Math.ceil(n):Math.floor(n)}function s(n){var t=+n,i=0;return 0!==t&&isFinite(t)&&(i=v(t)),i}function uu(n,t,i){for(var f=Math.min(n.length,t.length),e=Math.abs(n.length-t.length),u=0,r=0;f>r;r++)(i&&n[r]!==t[r]||!i&&s(n[r])!==s(t[r]))&&u++;return u+e}function fu(){}function eu(n){return n?n.toLowerCase().replace("_","-"):n}function ke(n){for(var i,t,f,r,u=0;u<n.length;){for(r=eu(n[u]).split("-"),i=r.length,t=eu(n[u+1]),t=t?t.split("-"):null;i>0;){if(f=ou(r.slice(0,i).join("-")))return f;if(t&&t.length>=i&&uu(r,t,!0)>=i-1)break;i--}u++}return null}function ou(n){var t=null;if(!ct[n]&&"undefined"!=typeof module&&module&&module.exports)try{t=li._abbr;require("./locale/"+n);gt(t)}catch(i){}return ct[n]}function gt(n,t){var i;return n&&(i="undefined"==typeof t?et(n):su(n,t),i&&(li=i)),li._abbr}function su(n,t){return null!==t?(t.abbr=n,ct[n]=ct[n]||new fu,ct[n].set(t),gt(n),ct[n]):(delete ct[n],null)}function et(n){var t;if(n&&n._locale&&n._locale._abbr&&(n=n._locale._abbr),!n)return li;if(!ui(n)){if(t=ou(n))return t;n=[n]}return ke(n)}function l(n,t){var i=n.toLowerCase();ii[i]=ii[i+"s"]=ii[t]=n}function p(n){if("string"==typeof n)return ii[n]||ii[n.toLowerCase()]}function hu(n){var i,t,r={};for(t in n)ft(n,t)&&(i=p(t),i&&(r[i]=n[t]));return r}function yt(n,t){return function(r){return null!=r?(cu(this,n,r),i.updateOffset(this,t),this):oi(this,n)}}function oi(n,t){return n._d["get"+(n._isUTC?"UTC":"")+t]()}function cu(n,t,i){return n._d["set"+(n._isUTC?"UTC":"")+t](i)}function lu(n,t){var i;if("object"==typeof n)for(i in n)this.set(i,n[i]);else if(n=p(n),"function"==typeof this[n])return this[n](t);return this}function di(n,t,i){var r=""+Math.abs(n),u=t-r.length,f=n>=0;return(f?i?"+":"":"-")+Math.pow(10,Math.max(0,u)).toString().substr(1)+r}function r(n,t,i,r){var u=r;"string"==typeof r&&(u=function(){return this[r]()});n&&(wt[n]=u);t&&(wt[t[0]]=function(){return di(u.apply(this,arguments),t[1],t[2])});i&&(wt[i]=function(){return this.localeData().ordinal(u.apply(this,arguments),n)})}function de(n){return n.match(/\[[\s\S]/)?n.replace(/^\[|\]$/g,""):n.replace(/\\/g,"")}function ge(n){for(var i=n.match(df),t=0,r=i.length;r>t;t++)i[t]=wt[i[t]]?wt[i[t]]:de(i[t]);return function(u){var f="";for(t=0;r>t;t++)f+=i[t]instanceof Function?i[t].call(u,n):i[t];return f}}function gi(n,t){return n.isValid()?(t=au(t,n.localeData()),ar[t]=ar[t]||ge(t),ar[t](n)):n.localeData().invalidDate()}function au(n,t){function r(n){return t.longDateFormat(n)||n}var i=5;for(ai.lastIndex=0;i>=0&&ai.test(n);)n=n.replace(ai,r),ai.lastIndex=0,i-=1;return n}function no(n){return"function"==typeof n&&"[object Function]"===Object.prototype.toString.call(n)}function t(n,t,i){pr[n]=no(t)?t:function(n){return n&&i?i:t}}function to(n,t){return ft(pr,n)?pr[n](t._strict,t._locale):new RegExp(io(n))}function io(n){return n.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(n,t,i,r,u){return t||i||r||u}).replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function c(n,t){var i,r=t;for("string"==typeof n&&(n=[n]),"number"==typeof t&&(r=function(n,i){i[t]=s(n)}),i=0;i<n.length;i++)wr[n[i]]=r}function ni(n,t){c(n,function(n,i,r,u){r._w=r._w||{};t(n,r._w,r,u)})}function ro(n,t,i){null!=t&&ft(wr,n)&&wr[n](t,i._a,i,n)}function nr(n,t){return new Date(Date.UTC(n,t+1,0)).getUTCDate()}function uo(n){return this._months[n.month()]}function fo(n){return this._monthsShort[n.month()]}function eo(n,t,i){var r,u,f;for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),r=0;12>r;r++)if((u=kt([2e3,r]),i&&!this._longMonthsParse[r]&&(this._longMonthsParse[r]=new RegExp("^"+this.months(u,"").replace(".","")+"$","i"),this._shortMonthsParse[r]=new RegExp("^"+this.monthsShort(u,"").replace(".","")+"$","i")),i||this._monthsParse[r]||(f="^"+this.months(u,"")+"|^"+this.monthsShort(u,""),this._monthsParse[r]=new RegExp(f.replace(".",""),"i")),i&&"MMMM"===t&&this._longMonthsParse[r].test(n))||i&&"MMM"===t&&this._shortMonthsParse[r].test(n)||!i&&this._monthsParse[r].test(n))return r}function vu(n,t){var i;return"string"==typeof t&&(t=n.localeData().monthsParse(t),"number"!=typeof t)?n:(i=Math.min(n.date(),nr(n.year(),t)),n._d["set"+(n._isUTC?"UTC":"")+"Month"](t,i),n)}function yu(n){return null!=n?(vu(this,n),i.updateOffset(this,!0),this):oi(this,"Month")}function oo(){return nr(this.year(),this.month())}function tr(n){var i,t=n._a;return t&&-2===e(n).overflow&&(i=t[d]<0||t[d]>11?d:t[k]<1||t[k]>nr(t[b],t[d])?k:t[a]<0||t[a]>24||24===t[a]&&(0!==t[lt]||0!==t[at]||0!==t[vt])?a:t[lt]<0||t[lt]>59?lt:t[at]<0||t[at]>59?at:t[vt]<0||t[vt]>999?vt:-1,e(n)._overflowDayOfYear&&(b>i||i>k)&&(i=k),e(n).overflow=i),n}function pu(n){i.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+n)}function w(n,t){var i=!0;return ei(function(){return i&&(pu(n+"\n"+(new Error).stack),i=!1),t.apply(this,arguments)},t)}function so(n,t){te[n]||(pu(t),te[n]=!0)}function wu(n){var t,i,r=n._i,u=fa.exec(r);if(u){for(e(n).iso=!0,t=0,i=br.length;i>t;t++)if(br[t][1].exec(r)){n._f=br[t][0];break}for(t=0,i=kr.length;i>t;t++)if(kr[t][1].exec(r)){n._f+=(u[6]||" ")+kr[t][0];break}r.match(bi)&&(n._f+="Z");ur(n)}else n._isValid=!1}function ho(n){var t=ea.exec(n._i);return null!==t?void(n._d=new Date(+t[1])):(wu(n),void(n._isValid===!1&&(delete n._isValid,i.createFromInputFallback(n))))}function co(n,t,i,r,u,f,e){var o=new Date(n,t,i,r,u,f,e);return 1970>n&&o.setFullYear(n),o}function ir(n){var t=new Date(Date.UTC.apply(null,arguments));return 1970>n&&t.setUTCFullYear(n),t}function bu(n){return ku(n)?366:365}function ku(n){return n%4==0&&n%100!=0||n%400==0}function lo(){return ku(this.year())}function ot(n,t,i){var u,f=i-t,r=i-n.day();return r>f&&(r-=7),f-7>r&&(r+=7),u=o(n).add(r,"d"),{week:Math.ceil(u.dayOfYear()/7),year:u.year()}}function ao(n){return ot(n,this._week.dow,this._week.doy).week}function vo(){return this._week.dow}function yo(){return this._week.doy}function po(n){var t=this.localeData().week(this);return null==n?t:this.add(7*(n-t),"d")}function wo(n){var t=ot(this,1,4).week;return null==n?t:this.add(7*(n-t),"d")}function bo(n,t,i,r,u){var f,o=6+u-r,s=ir(n,0,1+o),e=s.getUTCDay();return u>e&&(e+=7),i=null!=i?1*i:u,f=1+o+7*(t-1)-e+i,{year:f>0?n:n-1,dayOfYear:f>0?f:bu(n-1)+f}}function ko(n){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==n?t:this.add(n-t,"d")}function pt(n,t,i){return null!=n?n:null!=t?t:i}function go(n){var t=new Date;return n._useUTC?[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]:[t.getFullYear(),t.getMonth(),t.getDate()]}function rr(n){var t,i,r,u,f=[];if(!n._d){for(r=go(n),n._w&&null==n._a[k]&&null==n._a[d]&&ns(n),n._dayOfYear&&(u=pt(n._a[b],r[b]),n._dayOfYear>bu(u)&&(e(n)._overflowDayOfYear=!0),i=ir(u,0,n._dayOfYear),n._a[d]=i.getUTCMonth(),n._a[k]=i.getUTCDate()),t=0;3>t&&null==n._a[t];++t)n._a[t]=f[t]=r[t];for(;7>t;t++)n._a[t]=f[t]=null==n._a[t]?2===t?1:0:n._a[t];24===n._a[a]&&0===n._a[lt]&&0===n._a[at]&&0===n._a[vt]&&(n._nextDay=!0,n._a[a]=0);n._d=(n._useUTC?ir:co).apply(null,f);null!=n._tzm&&n._d.setUTCMinutes(n._d.getUTCMinutes()-n._tzm);n._nextDay&&(n._a[a]=24)}}function ns(n){var t,e,u,r,i,f,s;t=n._w;null!=t.GG||null!=t.W||null!=t.E?(i=1,f=4,e=pt(t.GG,n._a[b],ot(o(),1,4).year),u=pt(t.W,1),r=pt(t.E,1)):(i=n._locale._week.dow,f=n._locale._week.doy,e=pt(t.gg,n._a[b],ot(o(),i,f).year),u=pt(t.w,1),null!=t.d?(r=t.d,i>r&&++u):r=null!=t.e?t.e+i:i);s=bo(e,u,r,f,i);n._a[b]=s.year;n._dayOfYear=s.dayOfYear}function ur(n){if(n._f===i.ISO_8601)return void wu(n);n._a=[];e(n).empty=!0;for(var t,u,s,r=""+n._i,c=r.length,h=0,o=au(n._f,n._locale).match(df)||[],f=0;f<o.length;f++)u=o[f],t=(r.match(to(u,n))||[])[0],t&&(s=r.substr(0,r.indexOf(t)),s.length>0&&e(n).unusedInput.push(s),r=r.slice(r.indexOf(t)+t.length),h+=t.length),wt[u]?(t?e(n).empty=!1:e(n).unusedTokens.push(u),ro(u,t,n)):n._strict&&!t&&e(n).unusedTokens.push(u);e(n).charsLeftOver=c-h;r.length>0&&e(n).unusedInput.push(r);e(n).bigHour===!0&&n._a[a]<=12&&n._a[a]>0&&(e(n).bigHour=void 0);n._a[a]=ts(n._locale,n._a[a],n._meridiem);rr(n);tr(n)}function ts(n,t,i){var r;return null==i?t:null!=n.meridiemHour?n.meridiemHour(t,i):null!=n.isPM?(r=n.isPM(i),r&&12>t&&(t+=12),r||12!==t||(t=0),t):t}function is(n){var t,f,u,r,i;if(0===n._f.length)return e(n).invalidFormat=!0,void(n._d=new Date(NaN));for(r=0;r<n._f.length;r++)i=0,t=ki({},n),null!=n._useUTC&&(t._useUTC=n._useUTC),t._f=n._f[r],ur(t),iu(t)&&(i+=e(t).charsLeftOver,i+=10*e(t).unusedTokens.length,e(t).score=i,(null==u||u>i)&&(u=i,f=t));ei(n,f||t)}function rs(n){if(!n._d){var t=hu(n._i);n._a=[t.year,t.month,t.day||t.date,t.hour,t.minute,t.second,t.millisecond];rr(n)}}function us(n){var t=new dt(tr(du(n)));return t._nextDay&&(t.add(1,"d"),t._nextDay=void 0),t}function du(n){var t=n._i,i=n._f;return n._locale=n._locale||et(n._l),null===t||void 0===i&&""===t?ru({nullInput:!0}):("string"==typeof t&&(n._i=t=n._locale.preparse(t)),nt(t)?new dt(tr(t)):(ui(i)?is(n):i?ur(n):fi(t)?n._d=t:fs(n),n))}function fs(n){var t=n._i;void 0===t?n._d=new Date:fi(t)?n._d=new Date(+t):"string"==typeof t?ho(n):ui(t)?(n._a=we(t.slice(0),function(n){return parseInt(n,10)}),rr(n)):"object"==typeof t?rs(n):"number"==typeof t?n._d=new Date(t):i.createFromInputFallback(n)}function gu(n,t,i,r,u){var f={};return"boolean"==typeof i&&(r=i,i=void 0),f._isAMomentObject=!0,f._useUTC=f._isUTC=u,f._l=i,f._i=n,f._f=t,f._strict=r,us(f)}function o(n,t,i,r){return gu(n,t,i,r,!1)}function nf(n,t){var r,i;if(1===t.length&&ui(t[0])&&(t=t[0]),!t.length)return o();for(r=t[0],i=1;i<t.length;++i)(!t[i].isValid()||t[i][n](r))&&(r=t[i]);return r}function es(){var n=[].slice.call(arguments,0);return nf("isBefore",n)}function os(){var n=[].slice.call(arguments,0);return nf("isAfter",n)}function si(n){var t=hu(n),i=t.year||0,r=t.quarter||0,u=t.month||0,f=t.week||0,e=t.day||0,o=t.hour||0,s=t.minute||0,h=t.second||0,c=t.millisecond||0;this._milliseconds=+c+1e3*h+6e4*s+36e5*o;this._days=+e+7*f;this._months=+u+3*r+12*i;this._data={};this._locale=et();this._bubble()}function fr(n){return n instanceof si}function tf(n,t){r(n,0,0,function(){var n=this.utcOffset(),i="+";return 0>n&&(n=-n,i="-"),i+di(~~(n/60),2)+t+di(~~n%60,2)})}function er(n){var i=(n||"").match(bi)||[],u=i[i.length-1]||[],t=(u+"").match(fe)||["-",0,0],r=+(60*t[1])+s(t[2]);return"+"===t[0]?r:-r}function or(n,t){var r,u;return t._isUTC?(r=t.clone(),u=(nt(n)||fi(n)?+n:+o(n))-+r,r._d.setTime(+r._d+u),i.updateOffset(r,!1),r):o(n).local()}function sr(n){return 15*-Math.round(n._d.getTimezoneOffset()/15)}function ss(n,t){var r,u=this._offset||0;return null!=n?("string"==typeof n&&(n=er(n)),Math.abs(n)<16&&(n=60*n),!this._isUTC&&t&&(r=sr(this)),this._offset=n,this._isUTC=!0,null!=r&&this.add(r,"m"),u!==n&&(!t||this._changeInProgress?ef(this,tt(n-u,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,i.updateOffset(this,!0),this._changeInProgress=null)),this):this._isUTC?u:sr(this)}function hs(n,t){return null!=n?("string"!=typeof n&&(n=-n),this.utcOffset(n,t),this):-this.utcOffset()}function cs(n){return this.utcOffset(0,n)}function ls(n){return this._isUTC&&(this.utcOffset(0,n),this._isUTC=!1,n&&this.subtract(sr(this),"m")),this}function as(){return this._tzm?this.utcOffset(this._tzm):"string"==typeof this._i&&this.utcOffset(er(this._i)),this}function vs(n){return n=n?o(n).utcOffset():0,(this.utcOffset()-n)%60==0}function ys(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function ps(){var n,t;return"undefined"!=typeof this._isDSTShifted?this._isDSTShifted:(n={},(ki(n,this),n=du(n),n._a)?(t=n._isUTC?kt(n._a):o(n._a),this._isDSTShifted=this.isValid()&&uu(n._a,t.toArray())>0):this._isDSTShifted=!1,this._isDSTShifted)}function ws(){return!this._isUTC}function bs(){return this._isUTC}function rf(){return this._isUTC&&0===this._offset}function tt(n,t){var u,f,e,i=n,r=null;return fr(n)?i={ms:n._milliseconds,d:n._days,M:n._months}:"number"==typeof n?(i={},t?i[t]=n:i.milliseconds=n):(r=ee.exec(n))?(u="-"===r[1]?-1:1,i={y:0,d:s(r[k])*u,h:s(r[a])*u,m:s(r[lt])*u,s:s(r[at])*u,ms:s(r[vt])*u}):(r=oe.exec(n))?(u="-"===r[1]?-1:1,i={y:st(r[2],u),M:st(r[3],u),d:st(r[4],u),h:st(r[5],u),m:st(r[6],u),s:st(r[7],u),w:st(r[8],u)}):null==i?i={}:"object"==typeof i&&("from"in i||"to"in i)&&(e=ks(o(i.from),o(i.to)),i={},i.ms=e.milliseconds,i.M=e.months),f=new si(i),fr(n)&&ft(n,"_locale")&&(f._locale=n._locale),f}function st(n,t){var i=n&&parseFloat(n.replace(",","."));return(isNaN(i)?0:i)*t}function uf(n,t){var i={milliseconds:0,months:0};return i.months=t.month()-n.month()+12*(t.year()-n.year()),n.clone().add(i.months,"M").isAfter(t)&&--i.months,i.milliseconds=+t-+n.clone().add(i.months,"M"),i}function ks(n,t){var i;return t=or(t,n),n.isBefore(t)?i=uf(n,t):(i=uf(t,n),i.milliseconds=-i.milliseconds,i.months=-i.months),i}function ff(n,t){return function(i,r){var u,f;return null===r||isNaN(+r)||(so(t,"moment()."+t+"(period, number) is deprecated. Please use moment()."+t+"(number, period)."),f=i,i=r,r=f),i="string"==typeof i?+i:i,u=tt(i,r),ef(this,u,n),this}}function ef(n,t,r,u){var o=t._milliseconds,f=t._days,e=t._months;u=null==u?!0:u;o&&n._d.setTime(+n._d+o*r);f&&cu(n,"Date",oi(n,"Date")+f*r);e&&vu(n,oi(n,"Month")+e*r);u&&i.updateOffset(n,f||e)}function ds(n,t){var r=n||o(),f=or(r,this).startOf("day"),i=this.diff(f,"days",!0),u=-6>i?"sameElse":-1>i?"lastWeek":0>i?"lastDay":1>i?"sameDay":2>i?"nextDay":7>i?"nextWeek":"sameElse";return this.format(t&&t[u]||this.localeData().calendar(u,this,o(r)))}function gs(){return new dt(this)}function nh(n,t){var i;return t=p("undefined"!=typeof t?t:"millisecond"),"millisecond"===t?(n=nt(n)?n:o(n),+this>+n):(i=nt(n)?+n:+o(n),i<+this.clone().startOf(t))}function th(n,t){var i;return t=p("undefined"!=typeof t?t:"millisecond"),"millisecond"===t?(n=nt(n)?n:o(n),+n>+this):(i=nt(n)?+n:+o(n),+this.clone().endOf(t)<i)}function ih(n,t,i){return this.isAfter(n,i)&&this.isBefore(t,i)}function rh(n,t){var i;return t=p(t||"millisecond"),"millisecond"===t?(n=nt(n)?n:o(n),+this==+n):(i=+o(n),+this.clone().startOf(t)<=i&&i<=+this.clone().endOf(t))}function uh(n,t,i){var r,u,f=or(n,this),e=6e4*(f.utcOffset()-this.utcOffset());return t=p(t),"year"===t||"month"===t||"quarter"===t?(u=fh(this,f),"quarter"===t?u/=3:"year"===t&&(u/=12)):(r=this-f,u="second"===t?r/1e3:"minute"===t?r/6e4:"hour"===t?r/36e5:"day"===t?(r-e)/864e5:"week"===t?(r-e)/6048e5:r),i?u:v(u)}function fh(n,t){var r,f,u=12*(t.year()-n.year())+(t.month()-n.month()),i=n.clone().add(u,"months");return 0>t-i?(r=n.clone().add(u-1,"months"),f=(t-i)/(i-r)):(r=n.clone().add(u+1,"months"),f=(t-i)/(r-i)),-(u+f)}function eh(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function of(){var n=this.clone().utc();return 0<n.year()&&n.year()<=9999?"function"==typeof Date.prototype.toISOString?this.toDate().toISOString():gi(n,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):gi(n,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")}function oh(n){var t=gi(this,n||i.defaultFormat);return this.localeData().postformat(t)}function sh(n,t){return this.isValid()?tt({to:this,from:n}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function hh(n){return this.from(o(),n)}function ch(n,t){return this.isValid()?tt({from:this,to:n}).locale(this.locale()).humanize(!t):this.localeData().invalidDate()}function lh(n){return this.to(o(),n)}function sf(n){var t;return void 0===n?this._locale._abbr:(t=et(n),null!=t&&(this._locale=t),this)}function hf(){return this._locale}function ah(n){switch(n=p(n)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===n&&this.weekday(0),"isoWeek"===n&&this.isoWeekday(1),"quarter"===n&&this.month(3*Math.floor(this.month()/3)),this}function vh(n){return n=p(n),void 0===n||"millisecond"===n?this:this.startOf(n).add(1,"isoWeek"===n?"week":n).subtract(1,"ms")}function yh(){return+this._d-6e4*(this._offset||0)}function ph(){return Math.floor(+this/1e3)}function wh(){return this._offset?new Date(+this):this._d}function bh(){var n=this;return[n.year(),n.month(),n.date(),n.hour(),n.minute(),n.second(),n.millisecond()]}function kh(){var n=this;return{years:n.year(),months:n.month(),date:n.date(),hours:n.hours(),minutes:n.minutes(),seconds:n.seconds(),milliseconds:n.milliseconds()}}function dh(){return iu(this)}function gh(){return ei({},e(this))}function nc(){return e(this).overflow}function hi(n,t){r(0,[n,n.length],0,t)}function cf(n,t,i){return ot(o([n,11,31+t-i]),t,i).week}function tc(n){var t=ot(this,this.localeData()._week.dow,this.localeData()._week.doy).year;return null==n?t:this.add(n-t,"y")}function ic(n){var t=ot(this,1,4).year;return null==n?t:this.add(n-t,"y")}function rc(){return cf(this.year(),1,4)}function uc(){var n=this.localeData()._week;return cf(this.year(),n.dow,n.doy)}function fc(n){return null==n?Math.ceil((this.month()+1)/3):this.month(3*(n-1)+this.month()%3)}function ec(n,t){return"string"!=typeof n?n:isNaN(n)?(n=t.weekdaysParse(n),"number"==typeof n?n:null):parseInt(n,10)}function oc(n){return this._weekdays[n.day()]}function sc(n){return this._weekdaysShort[n.day()]}function hc(n){return this._weekdaysMin[n.day()]}function cc(n){var t,i,r;for(this._weekdaysParse=this._weekdaysParse||[],t=0;7>t;t++)if(this._weekdaysParse[t]||(i=o([2e3,1]).day(t),r="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[t]=new RegExp(r.replace(".",""),"i")),this._weekdaysParse[t].test(n))return t}function lc(n){var t=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=n?(n=ec(n,this.localeData()),this.add(n-t,"d")):t}function ac(n){var t=(this.day()+7-this.localeData()._week.dow)%7;return null==n?t:this.add(n-t,"d")}function vc(n){return null==n?this.day()||7:this.day(this.day()%7?n:n-7)}function lf(n,t){r(n,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}function af(n,t){return t._meridiemParse}function yc(n){return"p"===(n+"").toLowerCase().charAt(0)}function pc(n,t,i){return n>11?i?"pm":"PM":i?"am":"AM"}function wc(n,t){t[vt]=s(1e3*("0."+n))}function bc(){return this._isUTC?"UTC":""}function kc(){return this._isUTC?"Coordinated Universal Time":""}function dc(n){return o(1e3*n)}function gc(){return o.apply(null,arguments).parseZone()}function nl(n,t,i){var r=this._calendar[n];return"function"==typeof r?r.call(t,i):r}function tl(n){var t=this._longDateFormat[n],i=this._longDateFormat[n.toUpperCase()];return t||!i?t:(this._longDateFormat[n]=i.replace(/MMMM|MM|DD|dddd/g,function(n){return n.slice(1)}),this._longDateFormat[n])}function il(){return this._invalidDate}function rl(n){return this._ordinal.replace("%d",n)}function vf(n){return n}function ul(n,t,i,r){var u=this._relativeTime[i];return"function"==typeof u?u(n,t,i,r):u.replace(/%d/i,n)}function fl(n,t){var i=this._relativeTime[n>0?"future":"past"];return"function"==typeof i?i(t):i.replace(/%s/i,t)}function el(n){var t;for(var i in n)t=n[i],"function"==typeof t?this[i]=t:this["_"+i]=t;this._ordinalParseLenient=new RegExp(this._ordinalParse.source+"|"+/\d{1,2}/.source)}function yf(n,t,i,r){var u=et(),f=kt().set(r,t);return u[i](f,n)}function ti(n,t,i,r,u){if("number"==typeof n&&(t=n,n=void 0),n=n||"",null!=t)return yf(n,t,i,u);for(var e=[],f=0;r>f;f++)e[f]=yf(n,f,i,u);return e}function ol(n,t){return ti(n,t,"months",12,"month")}function sl(n,t){return ti(n,t,"monthsShort",12,"month")}function hl(n,t){return ti(n,t,"weekdays",7,"day")}function cl(n,t){return ti(n,t,"weekdaysShort",7,"day")}function ll(n,t){return ti(n,t,"weekdaysMin",7,"day")}function al(){var n=this._data;return this._milliseconds=g(this._milliseconds),this._days=g(this._days),this._months=g(this._months),n.milliseconds=g(n.milliseconds),n.seconds=g(n.seconds),n.minutes=g(n.minutes),n.hours=g(n.hours),n.months=g(n.months),n.years=g(n.years),this}function pf(n,t,i,r){var u=tt(t,i);return n._milliseconds+=r*u._milliseconds,n._days+=r*u._days,n._months+=r*u._months,n._bubble()}function vl(n,t){return pf(this,n,t,1)}function yl(n,t){return pf(this,n,t,-1)}function wf(n){return 0>n?Math.floor(n):Math.ceil(n)}function pl(){var u,f,e,s,o,r=this._milliseconds,n=this._days,t=this._months,i=this._data;return r>=0&&n>=0&&t>=0||0>=r&&0>=n&&0>=t||(r+=864e5*wf(hr(t)+n),n=0,t=0),i.milliseconds=r%1e3,u=v(r/1e3),i.seconds=u%60,f=v(u/60),i.minutes=f%60,e=v(f/60),i.hours=e%24,n+=v(e/24),o=v(bf(n)),t+=o,n-=wf(hr(o)),s=v(t/12),t%=12,i.days=n,i.months=t,i.years=s,this}function bf(n){return 4800*n/146097}function hr(n){return 146097*n/4800}function wl(n){var t,r,i=this._milliseconds;if(n=p(n),"month"===n||"year"===n)return t=this._days+i/864e5,r=this._months+bf(t),"month"===n?r:r/12;switch(t=this._days+Math.round(hr(this._months)),n){case"week":return t/7+i/6048e5;case"day":return t+i/864e5;case"hour":return 24*t+i/36e5;case"minute":return 1440*t+i/6e4;case"second":return 86400*t+i/1e3;case"millisecond":return Math.floor(864e5*t)+i;default:throw new Error("Unknown unit "+n);}}function bl(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*s(this._months/12)}function it(n){return function(){return this.as(n)}}function kl(n){return n=p(n),this[n+"s"]()}function ht(n){return function(){return this._data[n]}}function dl(){return v(this.days()/7)}function gl(n,t,i,r,u){return u.relativeTime(t||1,!!i,n,r)}function na(n,t,i){var r=tt(n).abs(),h=bt(r.as("s")),f=bt(r.as("m")),e=bt(r.as("h")),o=bt(r.as("d")),s=bt(r.as("M")),c=bt(r.as("y")),u=h<ut.s&&["s",h]||1===f&&["m"]||f<ut.m&&["mm",f]||1===e&&["h"]||e<ut.h&&["hh",e]||1===o&&["d"]||o<ut.d&&["dd",o]||1===s&&["M"]||s<ut.M&&["MM",s]||1===c&&["y"]||["yy",c];return u[2]=t,u[3]=+n>0,u[4]=i,gl.apply(null,u)}function ta(n,t){return void 0===ut[n]?!1:void 0===t?ut[n]:(ut[n]=t,!0)}function ia(n){var t=this.localeData(),i=na(this,!n,t);return n&&(i=t.pastFuture(+this,i)),t.postformat(i)}function ci(){var n,e,o,t=tu(this._milliseconds)/1e3,a=tu(this._days),i=tu(this._months);n=v(t/60);e=v(n/60);t%=60;n%=60;o=v(i/12);i%=12;var s=o,h=i,c=a,r=e,u=n,f=t,l=this.asSeconds();return l?(0>l?"-":"")+"P"+(s?s+"Y":"")+(h?h+"M":"")+(c?c+"D":"")+(r||u||f?"T":"")+(r?r+"H":"")+(u?u+"M":"")+(f?f+"S":""):"P0D"}var kf,li,cr=i.momentProperties=[],lr=!1,ct={},ii={},df=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,ai=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,ar={},wt={},gf=/\d/,y=/\d\d/,ne=/\d{3}/,vr=/\d{4}/,vi=/[+-]?\d{6}/,h=/\d\d?/,yi=/\d{1,3}/,yr=/\d{1,4}/,pi=/[+-]?\d{1,6}/,wi=/[+-]?\d+/,bi=/Z|[+-]\d\d:?\d\d/gi,ri=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,pr={},wr={},b=0,d=1,k=2,a=3,lt=4,at=5,vt=6,dr,ie,re,ue,fe,ee,oe,se,he,gr,nu,ce,le,ae,ve,rt,ye,n;r("M",["MM",2],"Mo",function(){return this.month()+1});r("MMM",0,0,function(n){return this.localeData().monthsShort(this,n)});r("MMMM",0,0,function(n){return this.localeData().months(this,n)});l("month","M");t("M",h);t("MM",h,y);t("MMM",ri);t("MMMM",ri);c(["M","MM"],function(n,t){t[d]=s(n)-1});c(["MMM","MMMM"],function(n,t,i,r){var u=i._locale.monthsParse(n,r,i._strict);null!=u?t[d]=u:e(i).invalidMonth=n});var ra="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ua="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),te={};i.suppressDeprecationWarnings=!1;var fa=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,br=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],kr=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],ea=/^\/?Date\((\-?\d+)/i;i.createFromInputFallback=w("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(n){n._d=new Date(n._i+(n._useUTC?" UTC":""))});r(0,["YY",2],0,function(){return this.year()%100});r(0,["YYYY",4],0,"year");r(0,["YYYYY",5],0,"year");r(0,["YYYYYY",6,!0],0,"year");l("year","y");t("Y",wi);t("YY",h,y);t("YYYY",yr,vr);t("YYYYY",pi,vi);t("YYYYYY",pi,vi);c(["YYYYY","YYYYYY"],b);c("YYYY",function(n,t){t[b]=2===n.length?i.parseTwoDigitYear(n):s(n)});c("YY",function(n,t){t[b]=i.parseTwoDigitYear(n)});i.parseTwoDigitYear=function(n){return s(n)+(s(n)>68?1900:2e3)};dr=yt("FullYear",!1);r("w",["ww",2],"wo","week");r("W",["WW",2],"Wo","isoWeek");l("week","w");l("isoWeek","W");t("w",h);t("ww",h,y);t("W",h);t("WW",h,y);ni(["w","ww","W","WW"],function(n,t,i,r){t[r.substr(0,1)]=s(n)});ie={dow:0,doy:6};r("DDD",["DDDD",3],"DDDo","dayOfYear");l("dayOfYear","DDD");t("DDD",yi);t("DDDD",ne);c(["DDD","DDDD"],function(n,t,i){i._dayOfYear=s(n)});i.ISO_8601=function(){};re=w("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(){var n=o.apply(null,arguments);return this>n?this:n});ue=w("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(){var n=o.apply(null,arguments);return n>this?this:n});tf("Z",":");tf("ZZ","");t("Z",bi);t("ZZ",bi);c(["Z","ZZ"],function(n,t,i){i._useUTC=!0;i._tzm=er(n)});fe=/([\+\-]|\d\d)/gi;i.updateOffset=function(){};ee=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;oe=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;tt.fn=si.prototype;se=ff(1,"add");he=ff(-1,"subtract");i.defaultFormat="YYYY-MM-DDTHH:mm:ssZ";gr=w("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(n){return void 0===n?this.localeData():this.locale(n)});r(0,["gg",2],0,function(){return this.weekYear()%100});r(0,["GG",2],0,function(){return this.isoWeekYear()%100});hi("gggg","weekYear");hi("ggggg","weekYear");hi("GGGG","isoWeekYear");hi("GGGGG","isoWeekYear");l("weekYear","gg");l("isoWeekYear","GG");t("G",wi);t("g",wi);t("GG",h,y);t("gg",h,y);t("GGGG",yr,vr);t("gggg",yr,vr);t("GGGGG",pi,vi);t("ggggg",pi,vi);ni(["gggg","ggggg","GGGG","GGGGG"],function(n,t,i,r){t[r.substr(0,2)]=s(n)});ni(["gg","GG"],function(n,t,r,u){t[u]=i.parseTwoDigitYear(n)});r("Q",0,0,"quarter");l("quarter","Q");t("Q",gf);c("Q",function(n,t){t[d]=3*(s(n)-1)});r("D",["DD",2],"Do","date");l("date","D");t("D",h);t("DD",h,y);t("Do",function(n,t){return n?t._ordinalParse:t._ordinalParseLenient});c(["D","DD"],k);c("Do",function(n,t){t[k]=s(n.match(h)[0],10)});nu=yt("Date",!0);r("d",0,"do","day");r("dd",0,0,function(n){return this.localeData().weekdaysMin(this,n)});r("ddd",0,0,function(n){return this.localeData().weekdaysShort(this,n)});r("dddd",0,0,function(n){return this.localeData().weekdays(this,n)});r("e",0,0,"weekday");r("E",0,0,"isoWeekday");l("day","d");l("weekday","e");l("isoWeekday","E");t("d",h);t("e",h);t("E",h);t("dd",ri);t("ddd",ri);t("dddd",ri);ni(["dd","ddd","dddd"],function(n,t,i){var r=i._locale.weekdaysParse(n);null!=r?t.d=r:e(i).invalidWeekday=n});ni(["d","e","E"],function(n,t,i,r){t[r]=s(n)});var oa="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),sa="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),ha="Su_Mo_Tu_We_Th_Fr_Sa".split("_");for(r("H",["HH",2],0,"hour"),r("h",["hh",2],0,function(){return this.hours()%12||12}),lf("a",!0),lf("A",!1),l("hour","h"),t("a",af),t("A",af),t("H",h),t("h",h),t("HH",h,y),t("hh",h,y),c(["H","HH"],a),c(["a","A"],function(n,t,i){i._isPm=i._locale.isPM(n);i._meridiem=n}),c(["h","hh"],function(n,t,i){t[a]=s(n);e(i).bigHour=!0}),ce=/[ap]\.?m?\.?/i,le=yt("Hours",!0),r("m",["mm",2],0,"minute"),l("minute","m"),t("m",h),t("mm",h,y),c(["m","mm"],lt),ae=yt("Minutes",!1),r("s",["ss",2],0,"second"),l("second","s"),t("s",h),t("ss",h,y),c(["s","ss"],at),ve=yt("Seconds",!1),r("S",0,0,function(){return~~(this.millisecond()/100)}),r(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),r(0,["SSS",3],0,"millisecond"),r(0,["SSSS",4],0,function(){return 10*this.millisecond()}),r(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),r(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),r(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),r(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),r(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),l("millisecond","ms"),t("S",yi,gf),t("SS",yi,y),t("SSS",yi,ne),rt="SSSS";rt.length<=9;rt+="S")t(rt,/\d+/);for(rt="S";rt.length<=9;rt+="S")c(rt,wc);ye=yt("Milliseconds",!1);r("z",0,0,"zoneAbbr");r("zz",0,0,"zoneName");n=dt.prototype;n.add=se;n.calendar=ds;n.clone=gs;n.diff=uh;n.endOf=vh;n.format=oh;n.from=sh;n.fromNow=hh;n.to=ch;n.toNow=lh;n.get=lu;n.invalidAt=nc;n.isAfter=nh;n.isBefore=th;n.isBetween=ih;n.isSame=rh;n.isValid=dh;n.lang=gr;n.locale=sf;n.localeData=hf;n.max=ue;n.min=re;n.parsingFlags=gh;n.set=lu;n.startOf=ah;n.subtract=he;n.toArray=bh;n.toObject=kh;n.toDate=wh;n.toISOString=of;n.toJSON=of;n.toString=eh;n.unix=ph;n.valueOf=yh;n.year=dr;n.isLeapYear=lo;n.weekYear=tc;n.isoWeekYear=ic;n.quarter=n.quarters=fc;n.month=yu;n.daysInMonth=oo;n.week=n.weeks=po;n.isoWeek=n.isoWeeks=wo;n.weeksInYear=uc;n.isoWeeksInYear=rc;n.date=nu;n.day=n.days=lc;n.weekday=ac;n.isoWeekday=vc;n.dayOfYear=ko;n.hour=n.hours=le;n.minute=n.minutes=ae;n.second=n.seconds=ve;n.millisecond=n.milliseconds=ye;n.utcOffset=ss;n.utc=cs;n.local=ls;n.parseZone=as;n.hasAlignedHourOffset=vs;n.isDST=ys;n.isDSTShifted=ps;n.isLocal=ws;n.isUtcOffset=bs;n.isUtc=rf;n.isUTC=rf;n.zoneAbbr=bc;n.zoneName=kc;n.dates=w("dates accessor is deprecated. Use date instead.",nu);n.months=w("months accessor is deprecated. Use month instead",yu);n.years=w("years accessor is deprecated. Use year instead",dr);n.zone=w("moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779",hs);var ca=n,u=fu.prototype;u._calendar={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"};u.calendar=nl;u._longDateFormat={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};u.longDateFormat=tl;u._invalidDate="Invalid date";u.invalidDate=il;u._ordinal="%d";u.ordinal=rl;u._ordinalParse=/\d{1,2}/;u.preparse=vf;u.postformat=vf;u._relativeTime={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};u.relativeTime=ul;u.pastFuture=fl;u.set=el;u.months=uo;u._months=ra;u.monthsShort=fo;u._monthsShort=ua;u.monthsParse=eo;u.week=ao;u._week=ie;u.firstDayOfYear=yo;u.firstDayOfWeek=vo;u.weekdays=oc;u._weekdays=oa;u.weekdaysMin=hc;u._weekdaysMin=ha;u.weekdaysShort=sc;u._weekdaysShort=sa;u.weekdaysParse=cc;u.isPM=yc;u._meridiemParse=ce;u.meridiem=pc;gt("en",{ordinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(n){var t=n%10,i=1===s(n%100/10)?"th":1===t?"st":2===t?"nd":3===t?"rd":"th";return n+i}});i.lang=w("moment.lang is deprecated. Use moment.locale instead.",gt);i.langData=w("moment.langData is deprecated. Use moment.localeData instead.",et);var g=Math.abs,la=it("ms"),aa=it("s"),va=it("m"),ya=it("h"),pa=it("d"),wa=it("w"),ba=it("M"),ka=it("y"),da=ht("milliseconds"),ga=ht("seconds"),nv=ht("minutes"),tv=ht("hours"),iv=ht("days"),rv=ht("months"),uv=ht("years"),bt=Math.round,ut={s:45,m:45,h:22,d:26,M:11},tu=Math.abs,f=si.prototype;return f.abs=al,f.add=vl,f.subtract=yl,f.as=wl,f.asMilliseconds=la,f.asSeconds=aa,f.asMinutes=va,f.asHours=ya,f.asDays=pa,f.asWeeks=wa,f.asMonths=ba,f.asYears=ka,f.valueOf=bl,f._bubble=pl,f.get=kl,f.milliseconds=da,f.seconds=ga,f.minutes=nv,f.hours=tv,f.days=iv,f.weeks=dl,f.months=rv,f.years=uv,f.humanize=ia,f.toISOString=ci,f.toString=ci,f.toJSON=ci,f.locale=sf,f.localeData=hf,f.toIsoString=w("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",ci),f.lang=gr,r("X",0,0,"unix"),r("x",0,0,"valueOf"),t("x",wi),t("X",/[+-]?\d+(\.\d{1,3})?/),c("X",function(n,t,i){i._d=new Date(1e3*parseFloat(n,10))}),c("x",function(n,t,i){i._d=new Date(s(n))}),i.version="2.10.6",pe(o),i.fn=ca,i.min=es,i.max=os,i.utc=kt,i.unix=dc,i.months=ol,i.isDate=fi,i.locale=gt,i.invalid=ru,i.duration=tt,i.isMoment=nt,i.weekdays=hl,i.parseZone=gc,i.localeData=et,i.isDuration=fr,i.monthsShort=sl,i.weekdaysMin=ll,i.defineLocale=su,i.weekdaysShort=cl,i.normalizeUnits=p,i.relativeTimeThreshold=ta,i});console.log("Loading fincwsapi.js");$fincwsapi=function(){function r(){s=new Date}function l(){return s?(new Date-s)/1e3:-1}function o(){return window.$Runtime?{"X-is-web-id":$Runtime.WebId()}:null}function a(f,s,h){var a,l,c;a=!0;c=$.extend({},e,h);s||(s={});!t||h&&h.fail||(c.fail=t);h&&h.error&&console.warn("  options.error is specified. This is deprecated. Specify options.fail instead.");h&&h.success&&console.warn("  options.success is specified. This is deprecated. Specify options.done instead.");r();l=i+"/"+f;$.ajax({method:"GET",headers:o(),url:l,cache:!1,data:s,timeout:u}).fail(function(t,i,r){c.fail(t,i,r);n&&t.status==401&&n(t)}).done(function(n,t,i){c.done(n,t,i)}).always(function(){c.always&&c.always()})}function v(f,s,h,c){var v,a,l;v=!0;l=$.extend({},e,c);h||(h={});!t||c&&c.fail||(l.fail=t);c&&c.error&&console.warn("  options.error is specified. This is deprecated. Specify options.fail instead.");c&&c.success&&console.warn("  options.success is specified. This is deprecated. Specify options.done instead.");r();a=i+"/"+s;$.ajax({method:"GET",headers:o(),url:a,data:h,timeout:u}).fail(function(t,i,r){l.fail(t,i,r);n&&t.status==401&&n(t)}).done(function(n,t,i){l.done(n,t,i)}).always(function(){l.always&&l.always()})}function y(t,i,f){var h,s;h=!0;s=$.extend({},e,f);i||(i={});f&&f.error&&console.warn("  options.error is specified. This is deprecated. Specify options.fail instead.");f&&f.success&&console.warn("  options.success is specified. This is deprecated. Specify options.done instead.");r();$.ajax({method:"GET",headers:o(),url:t,cache:!1,data:i,timeout:u}).fail(function(t,i,r){s.fail?s.fail(t,i,r):window.alert("No fail handler supplied for fincwapi.GetDirect. The 'Global' handlers are NOT used for 'direct' requests.");n&&t.status==401&&n(t)}).done(function(n,t,i){s.done(n,t,i)}).always(function(){s.always&&s.always()})}function p(n,t,i){var e,u,f;if(console.log("fincwapi.GetDirectDownload - Begin"),e=!0,t||(t={}),Object.keys(t).length!=0){u="";for(f in t)u&&(u+="&"),u+=f+"="+encodeURIComponent(t[f]);t&&(n+="?"+u)}r();i&&i.location?i.location.href=n:window.open(n);console.log("fincwapi.GetDirectDownload - End")}function w(f,s,h,c){var v,a,l;v=!0;l=$.extend({},e,c);s||(s={});h||(h={});!t||c&&c.fail||(l.fail=t);c&&c.error&&console.warn("  options.error is specified. This is deprecated. Specify options.fail instead.");c&&c.success&&console.warn("  options.success is specified. This is deprecated. Specify options.done instead.");a=i+"/"+f;Object.keys(s).length!=0&&window.alert("WARNING: Passing parameters to a POST-based Web Service is not yet implemented in fincwsapi.js.");r();$.ajax({method:"POST",headers:o(),url:a,cache:!1,contentType:"application/json;charset=utf-8",data:JSON.stringify(h),timeout:u}).fail(function(t,i,r){l.fail(t,i,r);n&&t.status==401&&n(t)}).done(function(n,t,i){l.done(n,t,i)}).always(function(){l.always&&l.always()})}function b(i,f,s,h){var v,c,l,a;if(v=!0,c=$.extend({},e,h),f||(f={}),s||(s={}),!t||h&&h.fail||(c.fail=t),h&&h.error&&console.warn("  options.error is specified. This is deprecated. Specify options.fail instead."),h&&h.success&&console.warn("  options.success is specified. This is deprecated. Specify options.done instead."),Object.keys(f).length!==0){l="";for(a in f)l&&(l+="&"),l+=a+"="+encodeURIComponent(f[a]);f&&(i+="?"+l)}r();$.ajax({method:"POST",headers:o(),url:i,cache:!1,contentType:c.contentType,data:JSON.stringify(s),timeout:u}).fail(function(t,i,r){c.fail(t,i,r);n&&t.status===401&&n(t)}).done(function(n,t,i){c.done(n,t,i)}).always(function(){c.always&&c.always()})}function k(n,t,i,r){t||(t=16);i||(i="");var u=n.indexOf("|");return u!=-1&&(i=n.substr(u+1),n=n.substr(0,u)),r==undefined&&(r=!0),r&&window.devicePixelRatio>1.25&&(t*=2),f+encodeURI("Icon/GetIcon?icon="+n+"&size="+t+"&overlay="+i)}function d(n,t){var i="",r=16;t==undefined&&(t=!0);t&&window.devicePixelRatio>1.25&&(r*=2);switch(n){case 0:i="Account";break;case 1:i="Client";break;case 2:i="SecurityStmt";break;case 3:i="SecurityStmt";break;case 4:i="User";break;case 5:i="AccountApp"}return f+encodeURI("Icon/GetIcon?icon="+i+"&size="+r)}function g(n,t,i){return t||(t=0),i==undefined&&(i=!0),i&&window.devicePixelRatio>1.25&&(t*=2),f+encodeURI("Resource/GetImage?resourceId="+n+"&maxWidth="+t)}function nt(n){return i+n}var u=12e4,i=null,f=null,h={},t=null,n=null,s=null,c=function(r){var u;return console.log("fincwapi.Initialise - Begin"),u=!0,r?r.BaseUrl||(u=!1,window.alert("No configuration BaseUrl supplied.")):(u=!1,window.alert("No configuration object supplied.")),u&&(h=r,i=r.BaseUrl,f=r.BaseUrlIcon?r.BaseUrlIcon:i,t=r.GlobalAjaxFail?r.GlobalAjaxFail:null,n=r.GlobalAjaxFail401?r.GlobalAjaxFail401:null),console.log("fincwapi.Initialise - End"),u},e={always:function(){},done:function(n){window.alert("done: "+n+"\n\nNOTE: To handle this event, pass a 'done' function callback as part of the options object supplied to all Web Service calls.")},fail:function(n){window.alert("status: "+n.status+"\nerror: "+n.responseText+"\n\nNOTE: To handle this event, pass a 'fail' function callback as part of the options object supplied to all Web Service calls.\n\nAlternatively, you can define a global handler when configuring the Web Services API by specifying a 'GlobalAjaxFail' entry in the configuration supplied to the Initialise method.")},contentType:"application/json;charset=utf-8"};return{Version:"1.01",Initialise:c,ResolveUrl:nt,CACHE_SHORT:30,CACHE_MEDIUM:300,CACHE_LONG:1200,CACHE_INDEFINITE:-1,Get:a,GetCached:v,GetDirect:y,GetDirectDownload:p,GetIconUrl:k,GetResourceImageUrl:g,GetLogClassIconUrl:d,Post:w,PostDirect:b,LastRequestSeconds:l}}();console.log("  $fincwsapi: "+typeof $fincwsapi);console.log("    .Version: "+$fincwsapi.Version);console.log("Loading lib/isruntime.js");$Runtime=function(){function at(n){n.currencyDecimals&&(r=n.currencyDecimals);n.currencySymbol&&(s=n.currencySymbol);n.dateFormat&&(u=n.dateFormat);n.timeFormat&&(g=n.timeFormat);n.dateFormatGrids&&(f=n.dateFormatGrids);n.timeFormatGrids&&(ut=n.timeFormatGrids);n.dayMonthYearOrder&&(i=n.dayMonthYearOrder);n.webRoot&&(et=n.webRoot);n.webId&&(ft=n.webId);n.themeContrastColourBackground&&(nt=n.themeContrastColourBackground);n.themeMainColourForeground&&(tt=n.themeMainColourForeground);n.themeMainColourBackground&&(it=n.themeMainColourBackground);n.themeMainColourForeground&&(rt=n.themeMainColourForeground);$(window).mousemove(function(n){w=n.clientX;b=n.clientY});$(document.body).bind("keydown keyup",function(n){k=n.shiftKey});String.prototype.endsWith||(String.prototype.endsWith=function(n,t){var i=this.toString(),r;return(typeof t!="number"||!isFinite(t)||Math.floor(t)!==t||t>i.length)&&(t=i.length),t-=n.length,r=i.indexOf(n,t),r!==-1&&r===t},String.prototype.startsWith||(String.prototype.startsWith=function(n,t){return t=t||0,this.substr(t,n.length)===n}));Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{enumerable:!1,value:function(n){var t=this.filter(function(t){return t==n});return t.length>0}})}function vt(n,t,i){var u,f,r,o,e=[];if(n=""+n,t||(t=","),i=i===!0,n.length==0)return[];for(f=0,u=0;u<n.length;u++)switch(n.substr(u,1)){case t:o||(r=n.substr(f,u-f),!i&&r.length>2&&r.charAt(0)=='"'&&r.charAt(r.length-1)=='"'&&(r=r.substr(1,r.length-2)),r=r.replace(/\"\"/g,'"'),e.push(r),f=u+1);break;case'"':o=!o}return f<=n.length?(r=n.substr(f),!i&&r.length>2&&r.charAt(0)=='"'&&r.charAt(r.length-1)=='"'&&(r=r.substr(1,r.length-2)),r=r.replace(/\"\"/g,'"'),e.push(r)):n.charAt(n.length-1)==t&&e.push(""),e}function yt(n){for(var i,t="",r=0;r<n.length;r++)i=n[r],t&&(t+=","),t+=i.indexOf(",")!=-1?'"'+i+'"':i;return t}function pt(n){return"xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var r=Math.random()*16|0,u=t==="x"?r:r&3|8,i=u.toString(16);return n&&(i=i.replace(/-/g,"")),i})}function wt(n){return new ISRanges(this,n)}function bt(n){return new ISUrlFragments(this,n)}function kt(){return new ISKeyValueList(this)}function dt(n,t){return n?t?new Date(n.getFullYear(),n.getMonth(),n.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()):new Date(n.getFullYear(),n.getMonth(),n.getDate()):null}function gt(n,t){return n?t?new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())):new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate())):null}function ni(){return s}function ti(){return i}function ii(n){return n?new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate())):null}function h(n){return window.alert("$ISRuntime.ConvertUtcToLocal: Not yet implemented!"),n}function ri(n){return window.alert("$ISRuntime.ConvertLocalToUtc: Not yet implemented!"),n}function c(t,i,r,f){return t?(r&&(t=h(t)),i?n(t,u+" "+g,f):n(t,u,f)):""}function ui(t,i,r,u,e){return t?(r&&(t=h(t)),i?(e||(e=!1),e?n(t,f+" HH:mm:ss",u):n(t,f+" "+ut,u)):n(t,f,u)):""}function n(n,t,i){var r,u,o,s,f,e;return n?(typeof n=="string"&&(n=new Date(n)),r=t,i?(r=r.replace("dd",("0"+n.getUTCDate()).slice(-2)),r=r.replace("d",n.getUTCDate()),r=r.replace("MM",("0"+(n.getUTCMonth()+1)).slice(-2)),r=r.replace("M",n.getUTCMonth()+1),u=n.getUTCFullYear(),r=r.replace("yyyy",u),r=r.replace("yy",(u+"").substr(2))):(r=r.replace("dd",("0"+n.getDate()).slice(-2)),r=r.replace("d",n.getDate()),r=r.replace("MM",("0"+(n.getMonth()+1)).slice(-2)),r=r.replace("M",n.getMonth()+1),u=n.getFullYear(),r=r.replace("yyyy",u),r=r.replace("yy",(u+"").substr(2))),i?(o=n.getUTCSeconds(),s=n.getUTCMinutes(),f=n.getUTCHours()):(o=n.getSeconds(),s=n.getMinutes(),f=n.getHours()),e=f,e>12&&(e-=12),r=r.replace("HH",("0"+f).slice(-2)),r=r.replace("H",f),r=r.replace("hh",("0"+e).slice(-2)),r=r.replace("h",e),r=r.replace("mm",("0"+s).slice(-2)),r=r.replace("m",s),r=r.replace("ss",("0"+o).slice(-2)),r=r.replace("s",o),f<12?(r=r.replace("tt","a.m."),r=r.replace("t","a")):(r=r.replace("tt","p.m."),r=r.replace("t","p")),r):""}function ot(t,i,r){return t?r?i&&t.getUTCHours()===0&&t.getUTCMinutes()===0&&t.getUTCSeconds()===0?"":n(t,"HH:mm:ss",r):i&&t.getHours()===0&&t.getMinutes()===0&&t.getSeconds()===0?"":n(t,"HH:mm:ss"):""}function fi(){var n=new Date;return new Date(n.getFullYear(),n.getMonth(),n.getDate())}function ei(){var n=new Date;return new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()))}function oi(){var n=new Date;return new Date(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds())}function si(){var n=new Date;return new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds()))}function hi(n,t){var i=function(n,t){var i=(""+n).split("e");return+(i[0]+"e"+(i[1]?+i[1]+t:t))};return i(Math.round(i(n,+t)),-t)}function ci(n){return n&&(n.GetPage=function(t){var i,r;if(n.Pages)for(t=t.toUpperCase(),i=0;i<n.Pages.length;i++)if(r=n.Pages[i],r.PageId.toUpperCase()===t)return r;return null},n.ClearPage=function(t){var i,r;if(n.Pages)for(t=t.toUpperCase(),i=0;i<n.Pages.length;i++)if(r=n.Pages[i],r.PageId.toUpperCase()==t){r.ContentLoaded=!1;break}return null}),n}function li(n,t,i){if(n==0&&i)return"";var r=l(n,-1,!0,!1);return n<0&&(r=r.substr(1)),t&&(r=s+r),n<0&&(r="("+r+")"),r}function l(n,t,i,u){var h=!1,f;if(n==0&&u)return"";if(t==-1&&(t=r,h=!0),(n==null||n==""||isNaN(n))&&(n=0),n=parseFloat(n),f=n.toFixed(t)+"",i){f+="";for(var o=f.split("."),e=o[0],c=o.length>1?"."+o[1]:"",s=/(\d+)(\d{3})/;s.test(e);)e=e.replace(s,"$1,$2");f=e+c}return f==0&&u?"":f}function ai(n,t){var i=t?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];try{return i[n]}catch(r){return t?"Un":"Unknown"}}function st(n,t){var i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][n%7];return t?i.substring(0,3):i}function vi(n,t){return!n||!n.getDay?"":st(n.getDay(),t)}function yi(n,t){var i=t?["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]:["January","February","March","April","May","June","July","August","September","October","November","December"];try{return i[n]}catch(r){return t?"Un":"Unknown"}}function pi(n,t,i){n=$.extend({},{},n);t=t.toUpperCase();for(var r in n)if(r.toUpperCase()==t)return n[r];return i}function wi(n,t){for(var r,u,f=[],e=0,i=0;i<n.length;i++)r=new FileReader,u=n[i],r.readAsDataURL(u),r.onload=function(i){return function(r){e+=1;f.push({name:i.name,data:r.target.result});e==n.length&&t(f)}}(u)}function bi(n){var i="",t;if(n&&n.statusText==="timeout")return{Code:"timeout",Message:"The call to Web Services timed out indicating that the server-side process has taken more than 120 seconds and may still be running.",InternalMessage:""};typeof n=="string"?i=n:n&&n.responseText&&(i=n.responseText);t={};try{t=$.parseJSON(i);dat.statusText==="timeout"&&window.alert("timeout")}catch(r){}return t.Code||(t.Code=""),t.Message||(t.Message="An unknown error occurred."),t.InternalMessage||(t.InternalMessage=""),t}function ki(n,t){return n+="",n=n.replace(/\n/g,"~br~"),n=$("<div/>").text(n).html(),t&&(n=n.replace(/ /g,"&nbsp;")),n.replace(/~br~/g,"<br/>")}function ht(n){try{var t=parseInt("0x"+n.substr(1,2)),i=parseInt("0x"+n.substr(3,2)),r=parseInt("0x"+n.substr(5,2))}catch(u){return!1}return 299*t+587*i+114*r<128e3}function di(n){return!ht(n)}function gi(){return window.devicePixelRatio>1.25}function nr(){return e}function tr(){return v}function ir(){return y}function rr(){return p}function ur(){return o}function fr(){return d}function er(n){var t=window.document,i=t.documentElement,r=i.requestFullscreen||i.mozRequestFullScreen||i.webkitRequestFullScreen||i.msRequestFullscreen,u=t.exitFullscreen||t.mozCancelFullScreen||t.webkitExitFullscreen||t.msExitFullscreen;if(n===undefined)return!t.fullscreenElement&&!t.mozFullScreenElement&&!t.webkitFullscreenElement&&!t.msFullscreenElement;n?r.call(i):u.call(t)}function or(n){var i=0,t=n.split(".");return t.length>=0&&(i+=parseInt(t[0])*1e7),t.length>=1&&(i+=parseInt(t[1])*1e4),t.length>=2&&(i+=parseInt(t[2])*100),t.length>=3&&(i+=parseInt(t[3])*1),i}function sr(n){if(typeof n=="string"&&(n=$("#"+n)),n)try{return n.prop("checked")}catch(n){return!1}else return!1}function hr(n,t){var i,r;typeof n=="string"?(i=n,n=$("#"+n)):i=$(n).attr("id");r=$(n);r.length===0?console.warn("runtime.SetBoolean: Element '"+i+"' not found."):(t=t===!0||t==="True"||t==="true",r.prop("checked",t))}function cr(n){if(typeof n=="string"&&(n=$("#"+n)),n)try{var t=ct(n.val(),0);return isNaN(t)?0:t}catch(n){return 0}else return 0}function lr(n,t){var r,i,u,f;typeof n=="string"?(r=n,n=$("#"+n)):r=$(n).attr("id");i=$(n);i.length===0?console.warn("runtime.SetInteger: Element '"+r+"' not found."):(u=i[0].getAttribute("is:blank-if-zero")=="true"?!0:!1,f=i[0].getAttribute("is:show-separators")=="false"?!1:!0,i.val(l(t,0,f,u)))}function ar(n,t){if(typeof t=="undefined"&&(t=!0),typeof n=="string"&&(n=$("#"+n)),n)try{var i=$(n).val();return t&&(i=a(i)),i}catch(n){return""}else return""}function vr(n,t){var i,r;typeof n=="string"?(i=n,n=$("#"+n)):i=$(n).attr("id");t===null&&(t="");r=$(n);r.length==0?console.warn("runtime.SetString: Element '"+i+"' not found."):r.val(t)}function yr(n,t,i){var f="",r,o,e,u;if(t==undefined&&(t=!0),i==undefined&&(i=!0),n)n=a(n);else return"";for(r=!0,o="",e=0;e<n.length;e++){u=n[e];switch(u){case" ":r=!0;break;default:i&&"0123456789".indexOf(u)!=-1&&!"0123456789".indexOf(o)==-1?(r||(f+=" "),r=!0):u==u.toUpperCase()?(r||(f+=" "),r=!0):r=!1}t?(t=!1,f+=u.toUpperCase()):f+=u}return f}function pr(n,t){var u,r,i;for(t?t+="":t="",u=t.toUpperCase(),r=!1,i=0;i<n.length;i++)if(n[i].toUpperCase()==u){r=!0;break}r||n.push(t)}function wr(n,t){var i=n.indexOf(t);i!=-1&&n.splice(i,1)}function ct(n,t){t==-1&&(t=r);n+="";n=n.replace(/\,/g,"");n.startsWith("(")&&n.endsWith(")")&&(n=n.substr(1,n.length-2),n="-"+n);var i=parseFloat(parseFloat(n).toFixed(t));return i?i:0}function br(n,t){var e,o,r;if(n){var i=0,u=0,f=0;n=n.toUpperCase();e=n.indexOf("A")!==-1;o=n.indexOf("P")!==-1;(n==="NOW"||n==="TODAY")&&(n=ot(new Date,!1,!1));r=n.split(":");r.length>0&&(i=parseFloat(r[0]));r.length>1&&(u=parseFloat(r[1]));r.length>2&&(f=parseFloat(r[2]));o&&i<12?i+=12:e&&i===12&&(i-=12);try{return isNaN(i)||isNaN(u)||isNaN(f)?null:t?new Date(Date.UTC(2e3,0,1,i,u,f)):new Date(2e3,0,1,i,u,f)}catch(s){return null}}else return null}function lt(n){return n.replace(/^\s+|\s+$/g,"")}function a(n){return n.replace(/\s+$/,"")}function kr(){return ft}function dr(){return et}var e=!1,v=!1,y=!1,p=!1,o=!1,w=0,b=0,k=!1,d=!1,r=2,s="$",i="DMY",u="dd/MM/yyyy",g="hh:mmtt",nt="pink",tt="yellow",it="darkcyan",rt="purple",f="dd/MM/yyyy",ut="HH:mm",ft,et;return screen.width<=640?(e=!0,v=!0):/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(e=!0),y=navigator.userAgent.toLocaleLowerCase().indexOf("android")>-1,p=/iPad|iPhone|iPod/.test(navigator.userAgent),o=/Windows/.test(navigator.userAgent),d=o,ParseAjaxError=function(n){var t,i="",u="",r="";try{t=$.parseJSON(n.responseText);t.Message&&(u=t.Message);t.InternalMessage&&(r=t.InternalMessage);i=u;r&&(i+="\n\n"+r)}catch(f){}return i||t||(i="An error occurred communicating with the server.\n\nStatus: "+n.status+"\n\nResponse: "+n.responseText),i},ParseDate=function(n,t,r){var s,f=0,u=0,e=0,v,h,a,o,l,y;if(n&&(n=n.toUpperCase()),!n)return null;if((n=="NOW"||n=="TODAY")&&(n=c(new Date,!1,!1,!1)),n.match(/[a-zA-Z]/)!=null)if("0123456789".indexOf(n.substr(n.length-1,1))==-1&&(n+=" "+(new Date).getFullYear()),f=Date.parse(n),f)n=c(new Date(f),!1,!1,!1);else return null;if(/^\d+$/.test(n)){if(h=new Date,o=parseFloat(n),a=h.getFullYear(),a-=Math.floor(a/100)*100,o==0)f=0,u=0,e=0;else if(o<100)f=o,u=h.getMonth()+1,e=h.getFullYear();else if(o<1e4)i.indexOf("D")<i.indexOf("M")?(f=Math.floor(o/100),u=Math.floor(o-f*100)):(u=Math.floor(o/100),f=Math.floor(o-u*100)),e=h.getFullYear(),h.getMonth()<2&&u>10?e-=1:h.getMonth()>9&&u<3&&(e+=1);else if(o<1e5)switch(i){case"DMY":u=Math.floor(o/100);e=Math.floor(o-u*100);e<100&&(l=Math.floor(h.getFullYear()/100)*100,t&&e>a&&(l-=100),e+=l);f=Math.floor(u/100);u-=f*100;break;case"MDY":f=Math.floor(o/100);e=Math.floor(o-f*100);e<100&&(l=Math.floor(h.getFullYear()/100)*100,t&&e>a&&(l-=100),e+=l);u=Math.floor(f/100);f-=u*100;break;case"YMD":window.alert("YMD date order not implemented")}else if(o<1e8)switch(i){case"DMY":u=Math.floor(o/1e4);e=Math.floor(o-u*1e4);f=Math.floor(u/100);u-=f*100;break;case"MDY":f=Math.floor(o/1e4);e=Math.floor(o-f*1e4);u=Math.floor(f/100);f-=u*100;break;case"YMD":window.alert("YMD date order not implemented")}else f=0,u=0,e=0;return(f>31||u>12)&&(f=0,u=0,e=0),f==0&&u==0&&e==0?null:r?new Date(Date.UTC(e,u-1,f)):new Date(e,u-1,f)}s=n.indexOf("/")!=-1?n.split("/"):n.indexOf("-")!=-1?n.split("-"):n.split(" ");i=="DMY"?(s.length>0&&(f=parseFloat(s[0])),s.length>1&&(u=parseFloat(s[1])),s.length>2&&(e=parseFloat(s[2]))):(s.length>0&&(u=parseFloat(s[0])),s.length>1&&(f=parseFloat(s[1])),s.length>2&&(e=parseFloat(s[2])));u==0&&(u=(new Date).getMonth()+1);u>12&&f<13&&(v=u,u=f,f=v);e==0&&(e=(new Date).getFullYear());e<100&&(t?(y=parseFloat(((new Date).getFullYear()+"").substr(2,2)),e+=e<y?2e3:1900):e+=2e3);e>9999&&(e=9999);try{return isNaN(e)||isNaN(u)||isNaN(f)?null:r?new Date(Date.UTC(e,u-1,f)):new Date(e,u-1,f)}catch(p){return null}},ParseJsonDate=function(n){return n?moment(n).toDate():null},{ArrayFromCsvString:vt,ArrayToCsvString:yt,CombineDateTime:dt,CombineDateTimeUtc:gt,ConvertUtcToLocal:h,ConvertLocalToUtc:ri,GetDateUtc:ii,CreateRanges:wt,CreateGuid:pt,CreateUrlFragments:bt,CreateKeyValueList:kt,CurrencySymbol:ni,DayMonthYearOrder:ti,FormHeaderInfoExtend:ci,FormatCurrency:li,FormatDate:c,FormatDateForGrid:ui,FormatNumber:l,FormatTime:ot,CurrencyDecimals:function(){return r},Round:hi,GetDayOfWeekName:ai,GetMonthName:yi,GetWeekDayName:st,GetWeekDayNameFromDate:vi,GetBoolean:sr,GetInteger:cr,GetString:ar,GetCurrentDate:fi,GetCurrentDateUtc:ei,GetCurrentDateTime:oi,GetCurrentDateTimeUtc:si,GetFileData:wi,GetProperty:pi,GetWsError:bi,HtmlEncode:ki,IsShiftPressed:function(){return k},MouseX:function(){return w},MouseY:function(){return b},SetBoolean:hr,SetInteger:lr,SetString:vr,SplitWordsAtCapitals:yr,StringArrayAddUnique:pr,ArrayRemove:wr,Initialise:at,IsColourDark:ht,IsColourLight:di,IsHighDpi:gi,IsMobileBrowser:nr,IsSmallMobileBrowser:tr,IsPlatformAndroid:ir,IsPlatformIOS:rr,IsPlatformWindows:ur,SupportsDragDrop:fr,FullScreen:er,VersionToInt:or,WebId:kr,WebRoot:dr,ParseAjaxError:ParseAjaxError,ParseDate:ParseDate,ParseJsonDate:ParseJsonDate,ParseNumber:ct,ParseTime:br,LTrim:lt,RTrim:a,Trim:lt,ThemeContrastColourBackground:function(){return nt},ThemeContrastColourForeground:function(){return tt},ThemeMainColourBackground:function(){return it},ThemeMainColourForeground:function(){return rt},FormatDateInternal:n,DateFormat:function(){return u}}}();console.log("  $Runtime: "+typeof $Runtime);console.log("    .IsMobileBrowser: "+$Runtime.IsMobileBrowser());Date.prototype.Date=function(){return new Date(this.getFullYear(),this.getMonth(),this.getDate())};String.prototype.like=function(n){return typeof n!="string"||this===null?!1:(n=n.replace(new RegExp("([\\.\\\\\\+\\\\[\\^\\]\\$\\(\\)\\{\\}\\=\\!\\<\\>\\|\\:\\-])","g"),"\\$1"),n=n.replace(/\*/g,".*").replace(/\?/g,"."),RegExp("^"+n+"$","gi").test(this))};console.log("Loading lib/isuserinterface.js");$UI=function(){function wt(t){t.iconResolver&&(w=t.iconResolver);ut=$("div#themecolourtester").css("background-color");at($Runtime.IsMobileBrowser());$(document.body).bind("keydown",function(t){if(t.keyCode==27&&n.length>0){var i=n[n.length-1];i.CloseOnEscape()&&i.Close()}})}function bt(){}function k(n){v=n?n.ModalId():"ADHOC"+$Runtime.CreateGuid()}function d(){v=""}function kt(n,t){var i,r,f,e,u;if(n.removeClass("is-filtered-out"),t&&(i=t.toUpperCase().split(" "),i.length>0))for(r=0;r<n.length;r++){for(f=$(n[r]),e=!0,u=0;u<i.length;u++){var s=i[u],h=!1,o=f.text();if(s&&o!=" "&&o&&o.toUpperCase().indexOf(s)!=-1&&(h=!0),!h){e=!1;break}}e||f.addClass("is-filtered-out")}}function dt(n){var i=$("label.is-label-heading",n),t,r;for(i.removeClass("first"),t=0;t<i.length;t++)if(r=$(i[t]),r.is(":visible")){r.addClass("first");break}}function gt(n){var t=n.prop("id"),i=t.indexOf("ENDMODAL"),r;if(i==-1)console.warn("userinterface.FindParentModal: Element '"+t+"' does not contain a valid Modal identifier.");else return r=t.substr(0,i+8),ot(r);return null}function y(n,t){return et("#"+n,t)}function r(n,t,i){if(w){if(!i){var r=n.indexOf("|");r==-1&&(r=n.indexOf(","));r!=-1&&(i=n.substr(r+1),n=n.substr(0,r))}return w(n,t,i,!0)}return console.warn("$UI.GetIconUrl: No iconresolver has been configured for isuserinterface. Icons cannot not be displayed."),""}function ni(n,t){if($Runtime.IsPlatformIOS()){n.off("touchstart.contextmenu");var i=null;n.on("touchstart.contextmenu",function(r){r.target===n[0]&&(popped=!1,i=window.setTimeout(function(){popped=!0;var n=r.originalEvent.touches[0],i={clientX:n.pageX,clientY:n.pageY};t(i)},750))});n.on("touchend.contextmenu",function(t){t.target===n[0]&&popped&&(t.preventDefault(),t.stopPropagation());window.clearTimeout(i);i=null})}else n.on("contextmenu",t)}function et(n,t){return t&&(n=n.replace(/#/g,"#"+t.ModalId())),$(n)}function i(n){return v+n}function ti(t){t=t.toUpperCase();for(var i=0;i<n.length;i++)if(n[i].FormKey().toUpperCase()==t)return n[i];return null}function ot(t){for(var i=0;i<f.length;i++)if(f[i].ModalId()==t)return f[i];for(i=0;i<n.length;i++)if(n[i].ModalId()==t)return n[i];return null}function ii(t){t=t.toUpperCase();for(var i=0;i<n.length;i++)if(n[i].FormKey().toUpperCase()==t)return!0;return!1}function ri(){return h,h}function ui(){for(var i=0,t=0;t<n.length;t++)n[t].AllowCloseWithoutWarning()||(i+=1);return i}function st(n,t){return h>1?($App.NotificationsAddWarning("Cannot minimise form since more than one form is open."),!1):(l===n||($("body").addClass("has-minimised-modal"),l=n,g=t,window.setTimeout(function(){n.ModalElement().bind("click.unminimise",function(){ht()})},10)),!0)}function ht(){return l?($("body").removeClass("has-minimised-modal"),l.ModalElement().unbind("click.unminimise"),l=null,g=null,window.setTimeout(function(){$(window).trigger("resize.modal1")},500),!0):!1}function ct(n,t){return l?(n&&$App.NotificationsAddInfo("Cannot perform this action since a minimised form is currently open.","",!0,"",[{text:"Show minimised form",link:"app://WebUI?showMinimisedForm"}]),t?t===g:!0):!1}function fi(t,i){n.length==0?window.alert("Failed to execute action '"+t+"' against the current modal form since no modal form is open."):n[n.length-1].ExecuteAction(t,i)}function lt(t,i){for(var r=0;r<f.length;r++)f[r].ExecuteNotificationAction(t,i);for(r=0;r<n.length;r++)n[r].ExecuteNotificationAction(t,i)}function at(n){if(n===undefined)return nt;nt=n;nt?$("body").addClass("always-use-pickers"):$("body").removeClass("always-use-pickers")}function c(){return tt||(tt=new $UI.PickerPanel),tt}function ei(n,t,i){lt("BookmarkedStateChanged",{recordType:n,pk:t,bookmarked:i})}function vt(n,t,i){var u,f,p,s,k="",d,e,a,h,w,c,b,v,y,l,o;for(n.children().remove(),e=$("<div class='is-no-select showing' tabindex='-1'><\/div>"),n.append(e),a=$("<div class='caption'><\/div>"),h=$("<a><span class='is-symbol-close'><\/span><\/a>"),h.click(function(){n.off("click");n.hide()}),a.append(h),e.append(a),w=$("<div><\/div>"),e.append(w),c=$("<ul><\/ul>"),b=0,w.append(c),v=0;v<t.Actions().length;v++)u=t.Actions()[v],y=u.visible,!y&&u.repeatInGroupId&&u.repeatInGroupId.toUpperCase()=="[BUTTONSOTHER]"&&u.contextPageId&&u.enabled&&(y=!0),y&&(b+=1,u.groupId.substr(0,1)!="["&&(u.groupId!=k&&(k=u.groupId,f=$("<li class='heading'><\/li>"),f.text(u.groupId),c.append(f)),f=$("<li class='action'><\/li>"),u.system?f.addClass("system"):f.addClass("custom"),l=$("<button><\/button>"),f.append(l),u.enabled||(f.addClass("disabled"),l.attr("disabled","disabled")),u.icon&&(p=$("<img/>"),l.append(p),d=window.innerWidth>=1024?r(u.icon,32):r(u.icon,16),p.attr("src",d)),s=$("<span><\/span>"),u.caption.indexOf("<small>")!=-1?s.html(u.caption):s.text(u.caption),s.attr("fincc_actionid",u.actionId),l.append(s),c.append(f),u.enabled&&(u.handler?function(t){f.click(function(){n.hide();t.handler()})}(u):function(t){f.click(function(){n.hide();i(t.actionId,t.applicationShortcutUrl?t.applicationShortcutUrl:t.data)})}(u))));!0&&(o=$("<input type='text' placeholder='Search actions for this record'/>"),a.append(o),o.bind("keyup",function(n){switch(n.keyCode){case 27:o.val("")}$UI.FilterElements($("li",c),o.val())}));n.show();n.on("click",function(n){n.target===this&&h.trigger("click")});e.bind("keyup",function(n){n.keyCode==27&&(n.target.tagName=="INPUT"||h.trigger("click"))});e.focus();!$Runtime.IsMobileBrowser()&&b>5&&o.focus();window.setTimeout(function(){e.removeClass("showing")},50)}function oi(n){for(var i=$("a, button, input, select, textarea",n),t=0;t<i.length;t++)n=$(i[t]),n.attr("disabled")||(n.attr("ISFormDisabled",!0),n.attr("disabled",!0))}function si(n){for(var i=$("a, button, input, select, textarea",n),t=0;t<i.length;t++)n=$(i[t]),n.attr("ISFormDisabled")&&(n.removeAttr("ISFormDisabled"),n.attr("disabled",!1))}function hi(n,t){var u,i,r;for(u in n)i=n[u],i&&i.TypeName&&i.ReadOnly&&(r=!0,i.AutoReadOnly&&!i.AutoReadOnly()&&(r=!1),r&&i.ReadOnly(t))}function p(n,t,i){var u,r;t=$.extend({},MsgBoxDefaults,t);t.title==null&&(t.title="Alert");t.icon==null&&(t.icon="Warning");t.captionOk==null&&(t.captionOk="OK");t.focusActionId||(t.focusActionId="Ok");t.width||(t.width="80%");t.height||(t.height="80%");n.length<100&&n.indexOf("\n")==-1&&n.indexOf("<br/>")==-1&&!t.heading?(t.maxWidth==null&&(t.maxWidth=320),t.maxHeight==null&&(t.maxHeight=200)):n.length<200&&n.indexOf("\n")==-1&&n.indexOf("<br/>")==-1?(t.maxWidth==null&&(t.maxWidth=480),t.maxHeight==null&&(t.maxHeight=320)):n.length<500&&n.indexOf("\n")==-1&&n.indexOf("<br/>")==-1?(t.maxWidth==null&&(t.maxWidth=520),t.maxHeight==null&&(t.maxHeight=480)):(t.maxWidth==null&&(t.maxWidth=800),t.maxHeight==null&&(t.maxHeight=800));u=$UI.Modal(t);u.Actions().Define([{groupId:"[buttons]",actionId:"Ok",caption:t.captionOk},]);u.OnAction(function(n){switch(n){case"Ok":u.Hide(!0);i&&i()}});r="";r+="<div class='is-msgbox'>";t.icon!=null&&(r+="<img src='"+$UI.GetIconUrl(t.icon,32)+"'/>");t.heading&&(r+="<h1>"+$Runtime.HtmlEncode(t.heading)+"<\/h1>");r+=t.messageIsHtml?"<p>"+n+"<p>":"<p>"+$Runtime.HtmlEncode(n)+"<\/p>";r+="<\/div>";u.Show({content:r})}function yt(n,t,i,r){var e,o,u;t=$.extend({},MsgBoxDefaults,t);t.title==null&&(t.title="Confirm");t.icon==null&&(t.icon="Help");t.captionOk==null&&(t.captionOk="OK");t.captionCancel==null&&(t.captionCancel="Cancel");t.focusActionId||(t.focusActionId="Ok");t.closeOnEscape==undefined&&(t.closeOnEscape=!0);t.width||(t.width="80%");t.height||(t.height="80%");n.length<100&&n.indexOf("\n")==-1&&!t.heading?(t.maxWidth==null&&(t.maxWidth=320),t.maxHeight==null&&(t.maxHeight=200)):n.length<200&&n.indexOf("\n")==-1?(t.maxWidth==null&&(t.maxWidth=480),t.maxHeight==null&&(t.maxHeight=320)):n.length<500&&n.indexOf("\n")==-1?(t.maxWidth==null&&(t.maxWidth=520),t.maxHeight==null&&(t.maxHeight=480)):(t.maxWidth==null&&(t.maxWidth=800),t.maxHeight==null&&(t.maxHeight=800));var h=t.icon=="Trash"?"danger":"",f=$UI.Modal(t),s=[{groupId:"[buttons]",actionId:"Ok",caption:t.captionOk,buttonStyle:h},{groupId:"[buttons]",actionId:"Cancel",caption:t.captionCancel},];if(t.additionalButtons)for(e=0;e<t.additionalButtons.length;e++)o=t.additionalButtons[e],o.groupId="[buttons]",s.unshift(o);f.Actions().Define(s);f.OnAction(function(n){switch(n){case"Cancel":f.Hide(!0);r&&r(n);break;default:f.Hide(!0);i&&i(n)}});u="";u+="<div class='is-msgbox'>";t.icon!=null&&(u+="<img src='"+$UI.GetIconUrl(t.icon,32)+"'/>");t.heading&&(u+="<h1>"+$Runtime.HtmlEncode(t.heading)+"<\/h1>");u+=t.messageIsHtml?"<p>"+n+"<p>":$Runtime.HtmlEncode(n);u+="<\/div>";f.Show({content:u})}function ci(n,t,i,r){t=$.extend({},MsgBoxDefaults,t);t.title==null&&(t.title="Confirm");t.heading==null&&(t.heading="Delete");t.icon==null&&(t.icon="Trash");t.captionOk==null&&(t.captionOk="Delete");t.focusActionId="Cancel";yt(n,t,i,r)}function li(n,t,i){t=$.extend({},MsgBoxDefaults,t);t.icon||(t.icon="Information");t.title||(t.title="Information");p(n,t,i)}function ai(n,i,u,f){var s,a,e,v,h,o,c,p,l;if(u=$.extend({},{closeOnEscape:!1,showClose:!1,width:480,height:"auto"},u),s=new t.Modal(u),k(s),s.Show({content:""}),s.ModalElement().css("display","block"),i&&i.length!=0&&i[0].Code&&i[0].Description){for(a=[],h=0;h<i.length;h++)o=i[h],a.push({key:o.Code,caption:o.Description});i=a}for(e="",v=!1,e+="<div id='divList' class='is-msgbox-list' tabindex='-1'>",n&&(e+="<label id='message'>"+$Runtime.HtmlEncode(n)+"<\/label>"),e+="<ul id='ulList'>",h=0;h<i.length;h++)o=$.extend({},{bold:!0,caption:"",details:"",enabled:!0,icon:"",disabledWarning:""},i[h]),c="",e+="<li key='"+o.key+"' index='"+h+"'",!v&&o.enabled?(v=!0,c+="is-sel "):o.enabled||(c+="disabled "),o.icon&&(c+="icon ",e+=" style=\"background-image:url('"+r(o.icon,32)+"')\""),c&&(e+=" class='"+c+"'"),e+=">",e+="<h1 style='",o.bold||(e+="font-weight:normal;"),e+="'>",e+=$Runtime.HtmlEncode(o.caption)+"<\/h1>",o.details&&(e+="<div>"+$Runtime.HtmlEncode(o.details)+"<\/div>"),!o.enabled&&o.disabledWarning&&(e+="<div class='warning'>"+$Runtime.HtmlEncode(o.disabledWarning)+"<\/div>"),e+="<\/li>";e+="<\/ul>";e+="<\/div>";s.RenderView(e);p=y("divList",s);l=y("ulList",s);p.focus();p.bind("keyup",function(n){var t=$("li.is-sel",l),r=parseInt(t.attr("index"));switch(n.keyCode){case 13:s.Close();try{if(t.hasClass("disabled"))return;f&&f(t.attr("key"))}catch(e){}return!1;case 27:return u.allowEscape&&s.Close(),!1;case 38:return r>0&&(t.removeClass("is-sel"),$($("li",l)[r-1]).addClass("is-sel")),!1;case 40:return r<i.length-1&&(t.removeClass("is-sel"),$($("li",l)[r+1]).addClass("is-sel")),!1}});$("li",l).click(function(){$("li",l).removeClass("is-sel");var n=$(this);n.addClass("is-sel");s.Close();try{if(n.hasClass("disabled"))return;f&&f(n.attr("key"))}catch(t){}});d()}function vi(n,t,i){var r,u="",f="",e="";try{r=$.parseJSON(n.responseText);r.Message&&(f=r.Message);r.InternalMessage&&(e=r.InternalMessage);u=f;e&&(u+="\n\n"+e)}catch(o){}if(r&&f){if(!i&&n.status==401){$App.NotificationsAddAjaxError(n);return}t?p(u,{}):p(u,{})}else u="An error occurred communicating with the server.\n\nStatus: "+n.status+"\n\nResponse: "+n.responseText,p(u,{})}function yi(n,i,u){var f,e,h,o,s,c;for(typeof n=="string"&&(n=$Runtime.ArrayFromCsvString(n)),f=new t.Modal({title:"Select Flag Colour",height:"80%",maxWidth:"420px",maxHeight:"420px",minWidth:"320px",minHeight:"320px",closeOnEscape:!0}),k(f),f.Show({content:""}),f.RenderView("<div id='divContainer' tabindex='-1' class='is-select-flag-colour'><\/div>"),e=y("divContainer",f),h=$("<div title='Clear Flag'><img src='"+r("Flag[Gray]",32,"Clear")+"'/><\/div>"),e.append(h),h.click(function(){f.Hide(!0);u("")}),o=0;o<n.length;o++)s=n[o],c=$("<div title='"+s+"'><img src='"+r("Flag["+s+"]",32)+"'/><\/div>"),e.append(c),function(n){c.click(function(){f.Hide(!0);u(n)})}(s);e.focus();d()}function pi(n,i,r){var f,e,o,u;n||(n="Select a User");f=new t.Modal({title:n,height:"80%",maxWidth:"640px",maxHeight:"1024px",minWidth:"320px",minHeight:"320px",closeOnEscape:!0});k(f);f.Show({content:""});f.RenderView("<div id='divContainer' tabindex='-1' class='is-dock-fill'><\/div>");e=y("divContainer",f);o=$("<div class='is-dock-fill'><\/div>");e.append(o);u=$UI.Grid(e,{stickyHeader:!0,onRowDrilldown:function(n){var t=$App.Users()[n.row.listIndex];f.Hide(!0);r(t.UserId)},onInitialiseRow:function(n){var t=$App.Users()[n.row.listIndex];n.row.cells.UserId.value=t.UserId;n.row.cells.Name.value=t.Name}});u.AddColumnDrilldown();u.AddColumnString("UserId",{caption:"Code",width:"8em"});u.AddColumnString("Name",{caption:"Name"});u.Refresh();$App.UsersLoad(function(){u.VirtualDataRefresh($App.Users());u.Focus()});d()}function wi(n){var s,c,i,t,f,r,u,e,h,o;for(r=!0,n.TypeName&&n.TypeName=="Tabs"&&(f=n,n=f.Element()),s=$("input,select,textarea",n),e=0;e<s.length;e++){if(c=s[e],t=$(c),t.css("display")=="none")u=!1;else if(t.attr("readonly")=="readonly")u=!1;else for(u=!0,i=t;i;)if(i=i.parent(),h=i.prop("tagName"),h=="BODY")break;else if(h=="DIV"){if(i.hasClass("is-tab-page"))break}else if(i.css("display")=="none"){u=!1;break}if(u&&!t.attr("id")&&(u=!1),u&&(r&&t.hasClass("is-mandatory")&&(t.val()||(r=!1)),r&&(o=t.prop("is-control"),o&&o.Validate&&(r=o.Validate()))),!r){f&&f.SelectTabFromChildElement(t);t.focus();break}}return r}function bi(n,t,i){if(t=$.extend({},{maxFiles:1},t),!s){var r="cmd"+$Runtime.CreateGuid(!0);s=$("<input id='"+r+"' type='file' multiple='true' style='display:none'/>");$("body").append(s)}t.maxFiles==1?s.removeAttr("multiple"):s.attr("multiple",!0);s.off("change");s.change(function(){ki(t,i)});s.val("");s.click()}function ki(n,t){var i=s[0].files;i.length<=0||t(i)}function di(n){o||(n||(n=""),o=$("<div class='is-modal-overlay top is-wait-block' style='display:none'><div class='is-wait'><div class='is-wait1'><\/div><div class='is-wait2'><\/div><div class='is-wait3'><\/div><\/div><label>"+$Runtime.HtmlEncode(n)+"<\/label><\/div>"),$("body").append(o),o.fadeIn(100))}function gi(n){o&&($("label",o).text(n),o.show())}function nr(){o&&(o.remove(),o=null)}function tr(n,t){function o(){r.text(u.caption);switch(u.style.toUpperCase()){case"HYPERLINK":break;default:u.cssClass=="is-button"&&r.addClass("is-button-styled")}u.cssClass&&r.addClass(u.cssClass);u.style&&r.addClass(u.style);u.icon&&window.$Api&&r.css("background-image","url("+$Api.GetIconUrl(u.icon,16)+")");u.checked?r.addClass("checked"):r.removeClass("checked");r.attr("title",u.tooltipText);u.visible?r.show():r.hide();f?r.removeAttr("disabled"):r.attr("disabled",!0)}function h(n){if(n===undefined)return r.text();r.text(n)}function c(n){if(n===undefined)return u.checked;u.checked=n==!0;o()}function l(){return r}function a(n){if(n===undefined)return f;n!=f&&(f=n==!0,o())}function v(){r.focus();r.select()}function y(n){if(n===undefined)return u.visible;u.visible=n;o()}var r,f=!0,u,e,s;if(ButtonDefaults={caption:"",cssClass:"is-button normal",checked:!1,style:"",icon:"",tooltipText:"",width:"auto",visible:!0,onClick:null},u=$.extend({},ButtonDefaults,t),typeof n=="string"?(e=i(n),n=$("#"+e)):e=$(n).attr("id"),s=$(n),s.length==0){console.warn("userinterface.Button: Element '"+e+"' not found.");return}return r=$(s[0]),r.click(u.onClick),o(),{TypeName:"Button",Caption:h,Checked:c,Element:l,Enabled:a,Focus:v,Visible:y}}function ir(n,t){function b(){r.cssClass&&f.addClass(r.cssClass);r.allowBlank?(f.removeClass("is-mandatory"),o&&o.removeClass("is-mandatory")):(f.addClass("is-mandatory"),o&&o.addClass("is-mandatory"));f.attr("placeholder",r.blankTip);r.readOnly?(f.addClass("is-readonly"),f.attr("readonly","readonly")):(f.removeClass("is-readonly"),f.removeAttr("readonly"));r.autoReadOnly?f.attr("autoreadonly","true"):f.removeAttr("autoreadonly");f.attr("maxLength",r.maxLength==0?"":r.maxLength);f.attr("spellcheck","false");r.width!="auto"&&(f.css({width:r.width}),r.width&&r.width.endsWith("%")&&h.css({width:r.width}));r.visible?(h.show(),o&&o.show()):(o&&o.hide(),h.hide())}function wt(){var i,o=f.val(),n,t,u;for(s.Clear(),i="<ul>",n=0;n<e.length;n++)if(r.onFormatItem){t=e[n];u={value:t,listIndex:n,displayValue:t,displayValueIsHtml:!0};r.onFormatItem(et,u);t=u.displayValue;u.displayValueIsHtml||(t=widget.UI.HtmlEncode(t));i+="<li class='is-selectable' style='min-height:20px' value='"+$Runtime.HtmlEncode(e[n])+"'>"+t+"<\/li>"}else i+="<li class='is-selectable' style='min-height:20px'>"+$Runtime.HtmlEncode(e[n])+"<\/li>";i+="<\/ul>";y=$(i);$("li",y).bind("click",function(){f.val($(this).attr("value")||$(this).text());r.usePicker||it(!0);k(!0);r.usePicker&&(v(),c().Hide(!0))});r.usePicker||s.Append(y);g=!1}function v(){var n=rt(f.val(),!1),t;$("li.is-sel",y).removeClass("is-sel");n>=0&&n<e.length&&(t=$($("li",y)[n]),t.addClass("is-sel"),t.ScrollElementIntoView(!0))}function at(){if(g&&wt(),r.usePicker){var n=r.pickerCaption;!n&&o&&(n=o.text(),n&&(n="Select "+n,n.endsWith(":")&&(n=n.substr(0,n.length-1))));n||(n="Select Item");c().Toggle({closeFocusElement:et,sourceButtonElement:d,caption:n,contentElement:y,onKeyDown:function(n){switch(n.keyCode){case 35:ut(e.length-1);v();break;case 36:ut(0);v();break;case 38:ft(-1);v();break;case 40:ft(1);v()}}})}else s.Show(),f.focus(),f.select();v()}function it(n){r.usePicker?c().Hide():(s.Hide(),n&&(f.focus(),f.select()))}function ot(){return f.val()!=nt}function k(n){r.limitToList&&!st(f.val())&&f.val("");var t={ChangeHandled:!1,TextOriginal:nt,ChangedFromPopup:n};if(r.onChange)r.onChange(et,t);t.ChangeHandled&&(nt=f.val())}function bt(n){if(n===undefined)return r.allowBlank;n!=r.allowBlank&&(r.allowBlank=n==!0,b())}function kt(n){if(n===undefined)return r.blankTip;r.blankTip=n;b()}function dt(n){if(n===undefined)return o?o.text():"";o&&o.text(n)}function gt(){return f}function ni(){f.focus();f.select()}function rt(n,t){if(t&&n.length==0)return-1;for(var i=0;i<e.length;i++)if(t){if(e[i].substr(0,n.length).toUpperCase()==n.toUpperCase())return i}else if(e[i]==n)return i;return-1}function ut(n){if(n===undefined)return rt(f.val(),!1);n<0||n>e.length-1?ct(""):ct(e[n]);nt=f.val()}function ft(n){var t=ut()+n;t<0?t=0:t>e.length-1&&(t=e.length-1);lt(e[t],!1,!0)}function ti(n){n!=r.allowBlank&&(r.limitToList=n==!0)}function st(n,t){var i;if(t=t?!0:!1,n+="",t){for(n=n.toUpperCase(),i=0;i<e.length;i++)if(e[i].toUpperCase()==n)return!0}else for(i=0;i<e.length;i++)if(e[i]==n)return!0;return!1}function ii(n){e=n;g=!0}function ri(n){typeof n=="string"&&(n=JSON.parse(n));ht(n,"Description")}function ht(n,t){var r,i;if(e=[],g=!0,n!=undefined&&t)for(r=0;r<n.length;r++)i=n[r][t],(i==null||i==undefined)&&(i=""),e.push(i)}function vt(n){e=$Runtime.ArrayFromCsvString(n);g=!0}function ui(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,b())}function fi(n){if(n===undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,b())}function ct(n){if(n===undefined)return $Runtime.GetString(f);n!=f.val()&&(tt+=1,f.val(n),tt-=1);nt=n}function lt(n,t,i){(n!=f.val()||t)&&(tt+=1,f.val(n),tt-=1,k(i))}function ei(n){if(n===undefined)return r.visible;r.visible=n;b()}function oi(n){if(!l&&(l=f.closest("tr"),l.length==0))return console.warn("ComboBox.VisibleRow: no parent row element found."),l=null,!1;if(n===undefined)return l.css("visibility").toUpperCase()=="HIDDEN";n?(l.css("display","table-row"),l.css("visibility","")):(l.css("display","none"),l.css("visibility","hidden"))}function yt(n){var u,t,i;h.hide();u=h.parent().innerWidth();h.show();t=r.width;i="";r.maxLength==0||r.maxLength>100||n?t="100%":(i=r.maxLength<=3?r.maxLength*.8+3+"em":r.maxLength*.8+"em",t="100%");h.css({width:t,maxWidth:i});f.css({width:t,maxWidth:i});r.visible||h.hide()}function si(n,t,i,f,e,o){var s,h,l,a,c,v;if(n){s={standardRangeName:n};t&&(s.sqlWhere=t);i&&(s.includeInactive=i);f&&(s.alwaysIncludeId=f);e&&(s.displayColumns=e);for(h in u)l=u[h],l&&(new Date-l.time)/1e3>10&&(console.log("ComboBox purging cached data (more than 10 minutes old) for '"+h+"'"),u[h]=null);if(a=JSON.stringify(s).toUpperCase(),c=u[a],c&&r.cacheMinutes&&(v=(new Date-c.time)/6e4,v<r.cacheMinutes)){pt(c.data,e);console.log("ComboBox refreshed from cached data for Standard Range '"+n+"'");o&&o();return}$App.HtmlWidget_SystemGetString("GetStandardRange",s,function(n){n&&(n=JSON.parse(n),pt(n,e),r.cacheMinutes&&(u[a]={data:n,time:new Date}));o&&o()},function(n){$App.NotificationsAddError(n,"",!0,"Error");o&&o()})}}function pt(n,t){for(var f,e,i,r=[],u=0;u<n.Rows.length;u++){for(f={},e=n.Rows[u],i=0;i<n.Columns.length;i++)f[n.Columns[i].Name]=e[i];r.push(f)}t||r.length==0||(t=r[0][0]);ht(r,t)}var d,s,f,l,tt=0,o,e=[],g=!0,y,nt="",h,r,p,w,et;if(ComboBoxDefaults={blankTip:"",captionElement:"auto",cssClass:"is-combobox",allowBlank:!0,limitToList:!1,listCsv:"",maxLength:0,readOnly:!1,autoReadOnly:!0,visible:!0,width:"auto",onChange:null,onFormatItem:null,usePicker:!1,pickerCaption:"",widgetDocument:null},r=$.extend({},ComboBoxDefaults,t),$UI.AlwaysUsePickerControls()&&(r.usePicker=!0),typeof n=="string"?(p=i(n),n=$("#"+p)):p=$(n).attr("id"),w=$(n),w.length==0){console.warn("userinterface.ComboBox: Element '"+p+"' not found.");return}return f=$(w[0]),f.wrap("<span style='display:inline-block; padding:0; position:relative; margin:0' controlType='combobox'/>"),h=$(f.parent()),d=$("<button type='button' tabindex='-1' class='is-combobox-button' style='position:absolute; right:0'/>"),r.usePicker&&d.addClass("is-picker"),h.append(d),s=new a(h,{minWidthElement:f,widgetDocument:r.widgetDocument}),f.attr("autocomplete","off"),f.attr("spellcheck","false"),w=r.widgetDocument?$("label[for='"+p+"']",r.widgetDocument):$("label[for='"+p+"']"),o=w.length==0?null:$(w[0]),r.width=="auto"&&r.maxLength!=0&&yt(),b(),vt(r.listCsv),f.bind("blur",function(){!r.readOnly&&r.limitToList&&ot()&&(st(f.val())||f.val(""))}),f.bind("keydown",function(n){switch(n.keyCode){case 13:s.Visible()&&it(!0);break;case 27:s.Visible()&&it(!1);break;case 38:s.Visible()&&(ft(-1),s.Visible()&&v());break;case 40:s.Visible()?(ft(1),v()):at()}}),f.bind("keyup",function(n){var u=0,t,i;switch(n.keyCode){case 46:r.limitToList||(u=-1);break;case 8:u=-1;break;default:if(n.keyCode<48)return}t=rt(f.val(),!1);s.Visible()&&v();t==-1&&r.limitToList&&n.keyCode==46?(lt("",!1,!1),k(!1)):t==-1&&(i=f[0].selectionStart+u,i<0&&(i=0),t=rt(f.val(),!0),t!=-1?((r.limitToList||n.keyCode!=46&&n.keyCode!=8)&&(f.val(e[t]),f[0].selectionStart=i,f[0].selectionEnd=1e3),k(!1)):r.limitToList?(lt("",!1,!1),k(!1)):ot()&&k(!1))}),d.bind("click",function(){r.readOnly||(s.Visible()?it(!0):at())}),et={TypeName:"ComboBox",AllowBlank:bt,AutoReadOnly:fi,BlankTip:kt,Caption:dt,Changed:ot,Element:gt,Focus:ni,LimitToList:ti,ListExists:st,ListFromArray:ii,ListFromCodeDescriptionList:ri,ListFromCollection:ht,ListFromCsvString:vt,ListIndex:ut,ReadOnly:ui,RefreshFromStandardRange:si,Text:ct,Visible:ei,VisibleRow:oi,WidthResizeFromParent:yt,WrapperElement:function(){return h}}}function rr(n,t){function k(){f.cssClass&&o.addClass(f.cssClass);u.attr("readonly","readonly");f.readOnly?o.addClass("is-readonly"):o.removeClass("is-readonly");f.autoReadOnly?u.attr("autoreadonly","true"):u.removeAttr("autoreadonly");f.width!="auto"&&o.css({width:f.width});f.visible?o.show():o.hide()}function c(){var t,h=u.val(),i,n;if(s&&(s.remove(),s=null),e=JSON.parse(JSON.stringify(r)),b&&e.sort(),l.length!=0){for(i=[],n=0;n<e.length;n++)l.indexOf(e[n])==-1&&i.push(e[n]);e=JSON.parse(JSON.stringify(i))}for(t="<ul class='is-no-select'>",n=0;n<e.length;n++)t+="<li class='is-selectable'>"+$Runtime.HtmlEncode(e[n])+"<\/li>";t+="<\/ul>";s=$(t);$("li",s).bind("click",function(){u.val($(this).text());tt(!0);d()});f.onItemDblClick&&$("li",s).bind("dblclick",function(){f.onItemDblClick(nt)});d();o.append(s);mListDirty=!1}function d(){var n=it(u.val(),!1),t;$("li.is-sel",s).removeClass("is-sel");n>=0&&n<r.length&&(t=$($("li",s)[n]),t.addClass("is-sel"),t.ScrollElementIntoView(!0))}function ot(){return u.val()!=y}function tt(n){f.limitToList&&!ft(u.val())&&u.val("");var t={ChangeHandled:!1,TextOriginal:y,ChangedFromPopup:n};if(f.onChange)f.onChange(nt,t);t.ChangeHandled&&(y=u.val())}function st(n){if(n===undefined)return v?v.text():"";v&&v.text(n)}function ht(){return u}function ct(){u.focus();u.select()}function it(n,t){var u,i;if(t&&n.length==0)return-1;for(u=e,u||(u=r),i=0;i<u.length;i++)if(t){if(u[i].substr(0,n.length).toUpperCase()==n.toUpperCase())return i}else if(u[i]==n)return i;return-1}function lt(n){for(var i=!1,t=0;t<r.length;t++)if(r[t]==n){i=!0;break}i||(r.push(n),c())}function at(n){$Runtime.ArrayRemove(r,n);c()}function vt(n){var t=r.indexOf(n),i;t>0&&(i=r[t-1],r[t-1]=r[t],r[t]=i,c())}function yt(n){var t=r.indexOf(n),i;t<r.length-1&&(i=r[t+1],r[t+1]=r[t],r[t]=i,c())}function pt(){return e.length}function wt(n){for(var i=!1,t=0;t<l.length;t++)if(l[t]==n){i=!0;break}i||(l.push(n),c())}function bt(n){$Runtime.ArrayRemove(l,n);c()}function rt(n){if(n===undefined)return it(u.val(),!1);n<0||n>e.length-1?g(""):g(e[n]);y=u.val();d()}function ut(n){var t=rt()+n;t<0?t=0:t>r.length-1&&(t=r.length-1);ii(r[t],!1,!0);d()}function ft(n,t){var i;if(t=t?!0:!1,n+="",t){for(n=n.toUpperCase(),i=0;i<r.length;i++)if(r[i].toUpperCase()==n)return!0}else for(i=0;i<r.length;i++)if(r[i]==n)return!0;return!1}function kt(n){r=n;c()}function et(n){r=$Runtime.ArrayFromCsvString(n);c()}function dt(){return $Runtime.ArrayToCsvString(e)}function gt(n){if(n===undefined)return f.readOnly;n!=f.readOnly&&(f.readOnly=n==!0,k())}function ni(n){if(n===undefined)return b;n!=b&&(b=n==!0,c())}function ti(n){if(n===undefined)return f.autoReadOnly;n!=f.autoReadOnly&&(f.autoReadOnly=n==!0,k())}function g(n){if(n===undefined)return $Runtime.GetString(u);n!=u.val()&&(w+=1,u.val(n),w-=1);y=n}function ii(n,t,i){(n!=u.val()||t)&&(w+=1,u.val(n),w-=1,tt(i))}function ri(n){if(n===undefined)return f.visible;f.visible=n;k()}function ui(n){if(!h&&(h=u.closest("tr"),h.length==0))return console.warn("ComboBox.VisibleRow: no parent row element found."),h=null,!1;if(n===undefined)return h.css("visibility").toUpperCase()=="HIDDEN";n?(h.css("display","table-row"),h.css("visibility","")):(h.css("display","none"),h.css("visibility","hidden"))}function fi(){}function ei(){window.alert("HeightResizeFromParent not implemented!");s&&s.hide();window.setTimeout(function(){var n;n=h?$("td,th",h).innerHeight():o.parent().innerHeight();o.css({height:n+0+"px",overflow:"auto"});f.visible&&s.show()},100)}var u,h,w=0,v,r=[],l=[],e,s,b=!1,y="",o,f,p,a,nt;if(ListBoxDefaults={captionElement:"auto",cssClass:"is-listbox",listCsv:"",readOnly:!1,autoReadOnly:!0,visible:!0,width:"auto",onChange:null,onItemDblClick:null},f=$.extend({},ListBoxDefaults,t),typeof n=="string"?(p=i(n),n=$("#"+p)):p=$(n).attr("id"),a=$(n),a.length==0){console.warn("userinterface.ListBox: Element '"+p+"' not found.");return}return u=$(a[0]),u.wrap("<span style='display:inline-block; padding:0; position:relative; margin:0' controlType='listbox'/>"),o=$(u.parent()),a=$("label[for='"+p+"']"),v=a.length==0?null:$(a[0]),o.attr("tabindex","-1"),k(),et(f.listCsv),o.bind("keydown",function(n){switch(n.keyCode){case 38:ut(-1);break;case 40:ut(1)}}),nt={TypeName:"ListBox",AutoReadOnly:ti,Caption:st,Changed:ot,Element:ht,Focus:ct,HeightResizeFromParent:ei,ListAdd:lt,ListRemove:at,ListMoveUp:vt,ListMoveDown:yt,ListExists:ft,ListFromArray:kt,ListFromCsvString:et,ListToCsvString:dt,ListHiddenAdd:wt,ListHiddenRemove:bt,ListIndex:rt,ListVisibleCount:pt,ReadOnly:gt,Sorted:ni,Text:g,Visible:ri,VisibleRow:ui,WidthResizeFromParent:fi,WrapperElement:function(){return o}}}function ur(n,t){function nt(){r.cssClass&&f.addClass(r.cssClass);r.allowBlank?(f.removeClass("is-mandatory"),k&&k.removeClass("is-mandatory")):(f.addClass("is-mandatory"),k&&k.addClass("is-mandatory"));f.attr("placeholder",r.blankTip);ui?(f.addClass("is-readonly"),f.attr("readonly","readonly"),f.addClass("fetchingdata"),w.addClass("fetchingdata")):r.readOnly?(f.addClass("is-readonly"),f.attr("readonly","readonly"),f.removeClass("fetchingdata"),w.removeClass("fetchingdata")):(f.removeClass("is-readonly"),f.removeAttr("readonly"),f.removeClass("fetchingdata"),w.removeClass("fetchingdata"));r.autoReadOnly?f.attr("autoreadonly","true"):f.removeAttr("autoreadonly");r.showDropdown?w.show():w.hide();e&&(r.showDescription?e.show():e.hide());r.hyperlinkContent?(f.addClass("is-hyperlink"),f.addClass("is-hyperlink")):f.removeClass("is-hyperlink");f.attr("maxLength",r.maxLength==0?"":r.maxLength);f.css({width:r.width});f.attr("spellcheck","false")}function p(){var n,t;if(e){e.removeClass("is-invalid");switch(ut){case"Array":ai?e.html(ti):e.text(ti);li&&e.addClass("is-invalid");break;case"Unbound":e.text(o);break;default:l?(n=wt(),n!=oi&&(e.text(""),oi="",ei="",n&&(si&&(window.clearTimeout(si),si=null),window.setTimeout(function(){var t={standardRangeName:l,id:n};$App.HtmlWidget_SystemGetString("GetStandardRangeRecordDescription",t,function(t){t&&(t=JSON.parse(t),wt()==n&&(oi=n,ei=t.Description,e.text(ei),r.limitToList&&!t.Description&&(e.addClass("is-invalid"),e.text("!")),t.Id&&n!=t.Id&&(it+=1,f.val(t.Id),it-=1)))},function(n){$App.NotificationsAddError(n,"",!0,"Error")})},500)))):(t=yt(f.val()),f.val()==""?e.text(""):t==-1||t>=et.length?et.length==0?e.text(""):(e.text("!"),e.addClass("is-invalid")):e.text(et[t]))}}}function dt(){v.Clear();h=[];et=[];switch(ut){case"":break;case"Array":nr();break;case"Collection":l?rr():ir();break;case"CodeDescriptionList":tr();break;default:window.alert("userinterface.DBCombo.UpdateList: Unsupported Data Source format")}s&&(h.length===0?$("tbody",s).before("<div style='color:#a0a0a0;font-style:italic'>No items<\/div>"):h.length>10&&(fi=$("<caption class='is-table-filter'><input type='search' placeholder='Type to filter list' style='width:100%' autocomplete='off' spellcheck='false'/><\/caption>"),$("tbody",s).before(fi),window.setInterval(function(){var n=$("input",fi);n.val()!=kt&&or(n.val())},200)));p();st=!1}function nr(){var n,t,i,u;for(n="<table style='width:100%'>",n+="<tbody>",t=0;t<o.length;t++){if(h[t]=o[t],et[t]="",n+="<tr class='is-selectable'>",o[t]){if(i=o[t],r.onFormatArrayItem){u={value:i,listIndex:t,displayValue:i,displayValueIsHtml:!0};r.onFormatArrayItem(ni,u);i=u.displayValue;u.displayValueIsHtml||(i=$Runtime.HtmlEncode(i))}else i=$Runtime.HtmlEncode(i);n+="<td>"+i+"<\/td>"}else n+="<td>&nbsp;<\/td>";n+="<\/tr>"}n+="<\/tbody>";n+="<\/table>";s=$(n);$("tbody > tr",s).bind("click",function(n){var t=$("tbody > tr",s).index(n.delegateTarget);t>=0&&t<h.length&&(f.val(h[t]),r.usePicker||ft(!0),rt(!0),r.usePicker&&(d(),c().Hide(!0)))});r.usePicker||v.Append(s)}function tr(){var n,t;for(n="<table style='width:100%'>",r.showColumnHeadings&&ii&&(n+="<thead>",n+="<tr><th>"+$Runtime.HtmlEncode(ii)+"<\/th><th>"+$Runtime.HtmlEncode(vi)+"<\/th><\/tr>",n+="<\/thead>"),n+="<tbody>",t=0;t<o.length;t++)h[t]=o[t].Code,et[t]=o[t].Description,n+="<tr class='is-selectable'>",n+="<td>"+$Runtime.HtmlEncode(o[t].Code)+"<\/td>",n+="<td>"+$Runtime.HtmlEncode(o[t].Description)+"<\/td>",n+="<\/tr>";n+="<\/tbody>";n+="<\/table>";s=$(n);$("tbody > tr",s).bind("click",function(n){var t=$("tbody > tr",s).index(n.delegateTarget);t>=0&&t<h.length&&(f.val(h[t]),p(),r.usePicker||ft(!0),ft(!0),rt(!0),r.usePicker&&(d(),c().Hide(!0)))});r.usePicker||v.Append(s)}function ir(){var i,u,l,b,w,t,a,n,e,y;for(ot?i=ot.split(","):(i=[],console.warn("mDataSourceDisplayColumns not set!")),l=[i.length],n=0;n<i.length;n++)for(l[n]="",e=0;e<o.length;e++)if(b=o[e][i[n]],w="",w=typeof b=="boolean"?"Boolean":i[n]&&i[n].toUpperCase().indexOf("DATE")!=-1?"Date":"",w!=l[n])if(l[n]=="")l[n]=w;else{l[n]="";break}if(u="<table style='width:100%'>",r.showColumnHeadings&&i.length!=0){for(u+="<thead><tr>",n=0;n<i.length;n++){t=i[n];a="";t==bt&&t!="Value"?t="Code":t.endsWith("Resolved")?(t=t.substr(0,t.length-8),a="+"):t.endsWith("Full")?(t=t.substr(0,t.length-4),a="+"):t.endsWith("TypeText")?t=t.substr(0,t.length-4):t.startsWith("Master")&&t.endsWith("Id")&&(t="Master");switch(l[n]){case"Boolean":u+="<th align='center' style='width:1em'><nobr>"+$Runtime.HtmlEncode($Runtime.SplitWordsAtCapitals(t))+a+"<\/nobr><\/th>";break;case"Date":u+="<th align='right'>"+$Runtime.HtmlEncode($Runtime.SplitWordsAtCapitals(t))+a+"<\/th>";break;default:u+="<th>"+$Runtime.HtmlEncode($Runtime.SplitWordsAtCapitals(t))+a+"<\/th>"}}u+="<\/tr><\/thead>"}for(u+="<tbody>",n=0;n<o.length;n++){for(h[n]=o[n][bt],et[n]=o[n][ri],u+="<tr class='is-selectable'>",e=0;e<i.length;e++)switch(l[e]){case"Boolean":u+=o[n][i[e]]?"<td align='center' class='is-symbol-tick' style='color:green'><\/td>":"<td align='center' class='is-symbol-cross' style='color:red'><\/td>";break;case"Date":o[n][i[e]]?(y=o[n][i[e]],u+=typeof y=="string"&&(y.indexOf(" ")!=-1||y.indexOf("M")!=-1||y.indexOf("/")!=-1)?"<td>"+$Runtime.HtmlEncode(y)+"<\/td>":"<td>"+$Runtime.FormatDate(o[n][i[e]])+"<\/td>"):u+="<td>&nbsp;<\/td>";break;default:u+=o[n][i[e]]?"<td>"+$Runtime.HtmlEncode(o[n][i[e]])+"<\/td>":"<td>&nbsp;<\/td>"}u+="<\/tr>"}u+="<\/tbody>";u+="<\/table>";s=$(u);$("tbody > tr",s).bind("click",function(n){var t=$("tbody > tr",s).index(n.delegateTarget);t>=0&&t<h.length&&(f.val(h[t]),p(),r.usePicker||ft(!0),rt(!0),r.usePicker&&(d(),c().Hide(!0)))});r.usePicker||v.Append(s)}function rr(){var n;s=$("<div style='min-height:120px; min-width:320px'><\/div>");var t=$("<input type='text' style='position:absolute !important; top:0; left:0; width:100%;border:1px solid transparent !important; border-bottom:1px solid rgba(0,0,0,0.2) !important'/>"),i=$("<button class='is-button dbcombo-search' style='min-width:0; width:22px; height:22px; margin:0; position:absolute; right:2px; top:0;'/>"),u=$("<div style='position:absolute; top:22px;left:0;right:0;bottom:0;overflow:auto'><\/div>");switch(l.toUpperCase()){case"CLIENTS":t.attr("placeholder","e.g. code, name, date of birth, email, phone");break;case"SECURITYSTMTS":t.attr("placeholder","e.g. code, name, serial number, registration");break;default:t.attr("placeholder","e.g. code, name")}s.append(t);s.append(i);s.append(u);y=$UI.Grid(u,{showColumnHeaders:!1,stickyHeader:!1,onAfterRowActivate:fr,onRowDrilldown:er,onInitialiseRow:ur});y.AddColumnString("Id",{caption:"Code",width:"6em"});y.AddColumnString("Name",{caption:"Description"});y.AddColumnString("Info",{caption:"Information",align:"right",colour:"gray"});y.Refresh();n=pt(t,{width:"100%",onEnterKey:function(){yi(n.Text())}});n.Element().keydown(function(t){switch(t.which){case 27:return n.Text()?n.Text(""):ft(!0),!1;case 40:return g&&g.Results.length!=0&&(y.Focus(),y.ActiveDataRowIndex()==-1&&y.ActiveDataRowIndex(0)),!1}});y.Element().keydown(function(n){switch(n.which){case 13:return y.ActiveDataRowIndex()!=-1&&y.PerformRowDrilldown(),!1}});i.click(function(){n.Focus();yi(n.Text())});r.usePicker||v.Append(s)}function yi(n){if(n)y.Visible(!0);else{y.Visible(!1);return}var t={standardRangeName:l,query:n,sqlWhere:ct};$App.HtmlWidget_SystemGetString("GetStandardRangeQuickSearchResults",t,function(n){var i,t;if(n){for(g=JSON.parse(n),i=!1,t=0;t<g.Results.length;t++)if(g.Results[t].Info){i=!0;break}y.ColumnVisible("Info",i);y.Refresh();y.VirtualDataRefresh(g.Results)}},function(n){$App.NotificationsAddError(n,"",!0,"Error")})}function ur(n){var t=g.Results[n.row.listIndex];n.row.cells.Id.value=t.Id;n.row.cells.Name.value=t.Name;n.row.cells.Info.value=t.Info}function fr(){if(g&&g.Results&&y.ActiveDataRowIndex()!=-1){var n=g.Results[y.ActiveDataRowIndex()];n&&f.val(n.Id);p();rt(!0)}}function er(){v.Hide();f.focus()}function or(n){var u,t,v,c,f,e,a,h,r,i;if(kt=n,o&&s&&($("tbody > tr",s).removeClass("is-filtered-out"),kt)){if(u=kt.toUpperCase().split(" "),u.length>0)for(t=$("tbody > tr",s),i=0;i<t.length;i++){for(v=t[i],c=!0,f=0;f<u.length;f++){var l=u[f],y=!1,p=$("td",v);if(l&&l!=" ")for(e=0;e<p.length;e++)if(a=$(p[e]).text(),a&&a.toUpperCase().indexOf(l)!=-1){y=!0;break}if(!y){c=!1;break}}c||$(t[i]).addClass("is-filtered-out")}if(h=vt(),h>=0&&h<t.length&&$(t[h]).hasClass("is-filtered-out")){for(r=-1,i=0;i<t.length;i++)if(!$(t[i]).hasClass("is-filtered-out")){r=i;break}$("tr.is-sel",s).removeClass("is-sel");r>=0&&r<t.length&&$(t[r]).addClass("is-sel")}}}function d(){var n=yt(f.val(),!1),t;$("tr.is-sel",s).removeClass("is-sel");n>=0&&n<h.length&&(t=$($("tbody > tr",s)[n]),t.addClass("is-sel"),t.ScrollElementIntoView(!0))}function pi(){if(st&&dt(),r.usePicker){var n=r.pickerCaption;!n&&k?(n=k.text(),n&&(n="Select "+n,n.endsWith(":")&&(n=n.substr(0,n.length-1)))):l&&(n="Search for Record");n||(n="Select Item");c().Toggle({closeFocusElement:ni,sourceButtonElement:w,caption:n,contentElement:s,onKeyDown:function(n){switch(n.keyCode){case 35:vt(h.length-1);d();break;case 36:vt(0);d();break;case 38:gt(-1);d();break;case 40:gt(1);d()}}});l&&$("input",s).focus()}else l?(v.Show(0,!0),v.WidthResizeFromParent(800)):v.Show(),l?$("input",s).focus():(f.focus(),f.select());d()}function ft(n){v.Hide();n&&(f.focus(),f.select())}function hi(){return f.val()!=ht}function sr(n,t,i){i||(i=!1);ti=n;ai=t;li=i;p()}function rt(n){if(!it){it+=1;l||r.limitToList&&!wi(f.val())&&(f.val(""),e&&e.text(""));var t={ChangeHandled:!1,TextOriginal:ht,ChangedFromPopup:n};if(r.onChange)r.onChange(ni,t);t.ChangeHandled&&(ht=f.val());it-=1}}function hr(n){if(n===undefined)return r.allowBlank;n!=r.allowBlank&&(r.allowBlank=n==!0,nt())}function cr(n){if(n===undefined)return r.blankTip;r.blankTip=n;nt()}function lr(n){if(n===undefined)return k?k.text():"";k&&k.text(n)}function ar(){return f}function vr(){f.focus();f.select()}function yr(){var n=vt();if(n!=-1&&o&&n<o.length)switch(ut){case"Array":return o[n];case"Collection":return o[n]}return null}function pr(){return e?e.text():""}function yt(n,t){if(t&&n.length==0)return-1;for(var i=0;i<h.length;i++)if(t){if(h[i].substr(0,n.length).toUpperCase()==n.toUpperCase())return i}else if(h[i]==n)return i;return-1}function vt(n){if(n===undefined)return yt(f.val(),!1);n<0||n>h.length-1?wt(""):wt(h[n]);ht=f.val()}function gt(n){var t=vt()+n;t<0?t=0:t>h.length-1&&(t=h.length-1);di(h[t],!1,!0)}function wr(n){if(n===undefined)return r.limitToList;n!=r.limitToList&&(r.limitToList=n==!0)}function wi(n,t){var i;if(t=t?!0:!1,n+="",t){for(n=n.toUpperCase(),i=0;i<h.length;i++)if(h[i].toUpperCase()==n)return!0}else for(i=0;i<h.length;i++)if(h[i]==n)return!0;return!1}function br(n){ut="Array";o=$Runtime.ArrayFromCsvString(n);dt()}function kr(n){if(n===undefined)return r.maxLength;r.maxLength=n;nt()}function dr(n){if(n===undefined)return r.hyperlinkContent;n!=r.hyperlinkContent&&(r.hyperlinkContent=n==!0,nt())}function gr(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,nt())}function nu(n){if(n===undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,nt())}function tu(n,t,i){n!=undefined&&(ut="CodeDescriptionList",o=n,t!=undefined&&(ii=t),i!=undefined&&(vi=i),dt())}function bi(n,t,i,r){n!=undefined&&(ut="Collection",o=n,bt=t,ri=i,r?ot=r:(ot=t,i&&(ot+=","+i)),l="",dt())}function iu(n,t,i,f,e,s){var a,c,h,v,w,b,y,k;if(n){if(ut="Collection",o=null,bt="",ri="",ot="",l="",ct="",a=!1,n.startsWith("@")?(a=!0,n=n.substr(1)):r.forceDropdown&&(a=!0),!a){if(c=n.toUpperCase(),c.substr(0,8)=="ACCOUNTS"){l=n;ct=t;st=!0;p();s&&s();return}if(c.substr(0,11)=="ACCOUNTAPPS"){l=n;ct=t;st=!0;p();s&&s();return}if(c.substr(0,7)=="CLIENTS"){l=n;ct=t;st=!0;p();s&&s();return}if(c.substr(0,13)=="SECURITYSTMTS"){l=n;ct=t;st=!0;p();s&&s();return}}ci(!0);h={standardRangeName:n};t&&(h.sqlWhere=t);i&&(h.includeInactive=i);f&&(h.alwaysIncludeId=f);e&&(h.displayColumns=e);for(v in u)w=u[v],w&&(new Date-w.time)/1e3>10&&(console.log("DBCombo purging cached data (more than 10 minutes old) for '"+v+"'"),u[v]=null);if(b=JSON.stringify(h).toUpperCase(),y=u[b],y&&r.cacheMinutes&&(k=(new Date-y.time)/6e4,k<r.cacheMinutes)){ki(y.data,e);console.log("DBCombo refreshed from cached data for Standard Range '"+n+"'");s&&s();return}$App.HtmlWidget_SystemGetString("GetStandardRange",h,function(n){n&&(n=JSON.parse(n),ki(n,e),r.cacheMinutes&&(u[b]={data:n,time:new Date}));s&&s()},function(n){$App.NotificationsAddError(n,"",!0,"Error");s&&s()})}}function ki(n,t){for(var f,e,i,o,r=[],u=0;u<n.Rows.length;u++){for(f={},e=n.Rows[u],i=0;i<n.Columns.length;i++)f[n.Columns[i].Name]=e[i];r.push(f)}if(!t&&r.length!=0){t="";for(o in r[0])t&&(t+=","),t+=o}bi(r,n.IdColumn,n.DescriptionColumn,t);ci(!1)}function ru(n,t){t||(t="");ut="Unbound";o=t;f.val(n);p();ht=n}function ci(n){ui=n;nt()}function uu(n){if(n===undefined)return r.showDescription;r.showDescription=n;nt()}function wt(n){if(n===undefined)return $Runtime.GetString(f);n!=f.val()&&(it+=1,f.val(n),it-=1,p());ht=n}function di(n,t,i){(n!=f.val()||t)&&(it+=1,f.val(n),it-=1,rt(i))}function gi(n){var t=r.width;r.showDescription?e.show():(b.css("width","100%"),e.hide());n||r.maxLength==0||r.maxLength>=50&&!r.showDescription?t="100%":t&&t!="auto"||r.maxLength&&(t=r.maxLength<=4?r.maxLength*.8+2+"em":r.maxLength*.8+"em");f.css({width:t});t!="100%"||r.showDescription?b.css("width",""):b.css("width","100%");e&&r.showDescription&&r.descriptionElement=="auto"&&(b.css("width","100%"),b.css("position","relative"),b.css("display","flex"),b.css("flex-direction","row"),b.css("white-space",""),f.css("flex-grow","0"),f.css("max-width",t),w.css("flex-grow","0"),e.css("flex-grow","1"),e.css("overflow","hidden"),e.css("position","relative"),e.css("height","22px"),e.css("line-height","22px"))}function fu(n){if(n===undefined)return r.visible;r.visible=n;nt()}function eu(n){if(!tt&&(tt=f.closest("tr"),tt.length==0))return console.warn("DbComboBox.VisibleRow: no parent row element found."),tt=null,!1;if(n===undefined)return tt.css("visibility").toUpperCase()=="HIDDEN";n?(tt.css("display","table-row"),tt.css("visibility","")):(tt.css("display","none"),tt.css("visibility","hidden"))}var ti="",li=!1,ai=!1,w,ii="",vi="",o,ut="",bt="",ri="",ot="",e,v,f,tt,ui=!1,fi,kt="",it=0,k,h=[],et=[],st=!1,s,ht="",b,g=null,y=null,l="",ct="",ei="",oi="",si=null,r,lt,at,ni;if(ComboBoxDefaults={blankTip:"",captionElement:"auto",cssClass:"is-combobox",descriptionElement:"auto",cacheMinutes:10,allowBlank:!0,limitToList:!1,maxLength:10,readOnly:!1,showColumnHeadings:!0,showDescription:!0,autoReadOnly:!0,changeWhileTyping:!1,showDropdown:!0,forceDropdown:!1,width:"auto",onChange:null,onFormatArrayItem:null,hyperlinkContent:!1,onContentHyperlink:null,usePicker:!1,pickerCaption:"",widgetDocument:null},r=$.extend({},ComboBoxDefaults,t),$UI.AlwaysUsePickerControls()&&(r.usePicker=!0),typeof n=="string"?(lt=i(n),n=$("#"+lt)):lt=$(n).attr("id"),at=$(n),at.length==0){console.warn("userinterface.DBCombo: Element '"+lt+"' not found.");return}if(f=$(at[0]),f.wrap("<span style='white-space:nowrap; display:flex; padding:0; margin:0; position:relative;' controlType='dbcombo'/>"),b=$(f.parent()),w=$("<button type='button' tabindex='-1' class='is-combobox-button'/>"),r.usePicker&&w.addClass("is-picker"),w.insertAfter(f),typeof r.descriptionElement=="string")switch(r.descriptionElement){case"":case"none":break;case"auto":e=$("<label class='is-combobox' style='display:none'><\/label>");e.insertAfter(w);break;default:console.warn("userinterface.DBCombo: options.descriptionElement must be a jQuery element or one of the following: '', 'none', 'auto'.")}else e=r.descriptionElement;if(v=r.showColumnHeadings?new a(b,{widgetDocument:r.widgetDocument}):new a(b,{minWidthElement:f,widgetDocument:r.widgetDocument}),f.attr("autocomplete","off"),f.attr("spellcheck","false"),at=r.widgetDocument?$("label[for='"+lt+"']",r.widgetDocument):$("label[for='"+lt+"']"),k=at.length==0?null:$(at[0]),r.width=="auto"&&r.maxLength!=0&&gi(),nt(),f.bind("keydown",function(n){switch(n.keyCode){case 13:v.Visible()&&ft(!0);break;case 27:v.Visible()&&ft(!1);break;case 38:v.Visible()&&(gt(-1),v.Visible()&&d());break;case 40:v.Visible()?(gt(1),d()):r.readOnly||pi()}l||p()}),f.bind("blur",function(){l&&p()}),f.bind("keyup",function(n){var u=0,t,i;switch(n.keyCode){case 46:r.limitToList||(u=-1);break;case 8:u=-1;break;default:if(n.keyCode<48)return}f.bind("blur",function(){r.readOnly||hi()&&rt(!1)});r.changeWhileTyping&&f.bind("input",function(){r.readOnly||hi()&&rt(!1)});l||(t=yt(f.val(),!1),v.Visible()&&d(),t==-1&&r.limitToList&&n.keyCode==46?(di("",!1,!1),rt(!1)):t==-1&&(i=f[0].selectionStart+u,i<0&&(i=0),t=yt(f.val(),!0),t!=-1?(f.val(h[t]),f[0].selectionStart=i,f[0].selectionEnd=1e3,rt(!1)):r.limitToList),p())}),r.onContentHyperlink)f.on("click",function(){r.readOnly&&r.hyperlinkContent&&r.onContentHyperlink&&r.onContentHyperlink()});return w.bind("click",function(){r.readOnly||ui||(v.Visible()?ft(!0):pi())}),ni={TypeName:"DBCombo",AllowBlank:hr,AutoReadOnly:nu,BlankTip:cr,Caption:lr,Changed:hi,DescriptionUpdate:sr,Element:ar,Focus:vr,GetCurrentListRecord:yr,GetDescription:pr,HyperlinkContent:dr,LimitToList:wr,ListExists:wi,ListFromCsvString:br,ListIndex:vt,MaxLength:kr,ReadOnly:gr,RefreshFromCodeDescriptionList:tu,RefreshFromCollection:bi,RefreshFromStandardRange:iu,RefreshUnbound:ru,SetFetchingData:ci,ShowDescription:uu,Text:wt,Visible:fu,VisibleRow:eu,WidthResizeFromParent:gi,WrapperElement:function(){return b}}}function fr(n,t){function v(){var e,t,n,i;r.cssClass&&u.addClass(r.cssClass);switch(r.width.toUpperCase()){case"AUTO":e=9999999999;t=-9999999999;r.maxValue!=null&&(e=r.maxValue);r.minValue!=null&&(t=r.minValue);e=$Runtime.FormatNumber(e,r.decimals,!1,!1);t=$Runtime.FormatNumber(t,r.decimals,!1,!1);n=e.length;t.length>n&&(n=t.length);n<2&&(n=2);r.percentage&&(n+=1);u.removeClass("date");u.css("max-width",n*.8+"em");u.css("width","100%");break;case"DATE":u.addClass("date");u.css("width","");break;default:u.removeClass("date");r.width&&u.css({width:r.width})}f&&(r.indentLevel?f.addClass("is-indent-"+r.indentLevel):(f.removeClass("is-indent-1"),f.removeClass("is-indent-2")));r.allowBlank?(u.removeClass("is-mandatory"),f&&f.removeClass("is-mandatory")):(u.addClass("is-mandatory"),f&&f.addClass("is-mandatory"));r.readOnly?(u.addClass("is-readonly"),u.attr("readonly","readonly")):(u.removeClass("is-readonly"),u.removeAttr("readonly"));r.autoReadOnly?u.attr("autoreadonly","true"):u.removeAttr("autoreadonly");u.attr("maxLength",r.maxLength==0?"":r.maxLength);r.width!="auto"&&u.css({width:r.width});u.attr("spellcheck","false");k?(h.css({display:"none"}),u.removeClass("is-invalid")):(u.addClass("is-invalid"),y?(nt?h.html(y):h.text(y),h.css({display:"inline-block"})):h.css({display:"none"}));b;i="";(r.maxValue!=null||r.minValue!=null)&&(i=ht(),i&&(i="Valid range "+i));u.attr("title",i)}function ut(text){r.readOnly||(text&&text.startsWith("=")&&(text=""+eval(text.substr(1))),text==""?(o=!0,e=0):(o=!1,e=$Runtime.ParseNumber(text,r.decimals)));w()}function w(){var n,t;o?c&&!r.readOnly?u.val(""):u.val(""):c&&!r.readOnly?e==0?u.val("0"):b||(n=r.decimals,n==-1&&(n=$Runtime.CurrencyDecimals()),u.val($Runtime.FormatNumber(e,n,!1,!1))):r.blankIfZero&&e==0?u.val(""):b||(t=$Runtime.FormatNumber(e,r.decimals,r.showSeparators,r.blankIfZero),r.percentage&&(t+="%"),u.val(t))}function ct(n){n!=r.allowBlank&&(r.allowBlank=n==!0,v())}function lt(n){if(n===undefined)return f?f.text():"";f&&f.text(n)}function ft(){return!(e==d&&o==tt)}function at(){var n={ChangeHandled:!1,ValueOriginal:d};if(r.onChange)r.onChange(g,n);n.ChangeHandled&&(mTextOriginal=u.val());k||st()}function vt(){return u}function yt(){u.focus();u.select()}function pt(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,v())}function wt(n){if(n===undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,v())}function it(n){if(n===undefined)return c&&ut(u.val()),e;n==null?r.allowBlank?(e=0,o=!0):e=0:(o=!1,n=r.decimals==-1?$Runtime.Round(n,$Runtime.CurrencyDecimals()):$Runtime.Round(n,r.decimals),e=n);d=e;tt=o;w()}function et(n){if(n===undefined)return o;n?(o=!0,e=0):o=!1;w()}function ot(n){var f,t,i;(n||r.width.toUpperCase()!="AUTO")&&(l.hide(),f=l.parent().innerWidth(),l.show(),t=r.width,i="",n?t="100%":(t=r.maxValue!=null&&r.minValue!=null?"6em":"6em",i=f+"px"),l.css({width:t,maxWidth:i}),u.css({width:t,maxWidth:i}))}function bt(){return k?!0:!1}function st(){var n=!0,t;return(r.minValue!=null||r.maxValue!=null)&&(t=it(),n&&r.minValue!=null&&t<r.minValue&&(n=!1),n&&r.maxValue!=null&&t>r.maxValue&&(n=!1)),n?rt(!0,"",!1):rt(!1,"Valid range "+ht(),!1),n}function ht(){var n="";return r.minValue!=null&&(n+=r.minValue==0?"0":$Runtime.FormatNumber(r.minValue,r.decimals,!0,!1)),r.maxValue!=null&&(n&&(n+=" "),n+="to "+$Runtime.FormatNumber(r.maxValue,r.decimals,!0,!1)),n}function rt(n,t,i){k=n;y=t==undefined?"":t;nt=i==undefined?!1:i;v()}function kt(n){r.onChange=n}function dt(n){if(n===undefined)return r.visible;r.visible=n;v()}function gt(n){if(!s&&(s=u.closest("tr"),s.length==0))return console.warn("ComboBox.VisibleRow: no parent row element found."),s=null,!1;if(n===undefined)return s.css("visibility").toUpperCase()=="HIDDEN";n?(s.css("display","table-row"),s.css("visibility","")):(s.css("display","none"),s.css("visibility","hidden"))}var u,s,c=!1,b=!1,k=!0,f,h,y="",nt=!1,e=0,o=!0,d=0,tt=!0,l,r,p,a,g;if(NumberBoxDefaults={captionElement:"auto",cssClass:"is-numberbox",allowBlank:!0,blankIfZero:!1,showSeparators:!0,indentLevel:0,decimals:-1,percentage:!1,maxValue:null,minValue:null,readOnly:!1,autoReadOnly:!0,width:"auto",onChange:null},r=$.extend({},NumberBoxDefaults,t),typeof n=="string"?(p=i(n),n=$("#"+p)):p=$(n).attr("id"),a=$(n),a.length==0){console.warn("userinterface.NumberBox: Element '"+p+"' not found.");return}return u=$(a[0]),u.wrap("<span style='white-space:normal; display:inline; padding:0; margin:0;' controlType='numberbox'/>"),l=$(u.parent()),h=$("<label style='display:none' class='is-validation-tip'><\/label>"),l.append(h),a=$("label[for='"+p+"']"),f=a.length==0?null:$(a[0]),v(),r.width=="auto"&&ot(),b?u.focus(function(){c=!0}):u.focus(function(){c=!0;w();u.select()}),u.blur(function(){c=!1;ut(u.val());ft()&&at();d=it();tt=et();w()}),g={TypeName:"NumberBox",AllowBlank:ct,AutoReadOnly:wt,Caption:lt,Changed:ft,Element:vt,Focus:yt,ReadOnly:pt,Value:it,ValueIsBlank:et,Visible:dt,VisibleRow:gt,WidthResizeFromParent:ot,IsValid:bt,Validate:st,ValidationSet:rt,OnChange:kt},u.prop("is-control",g),g}function er(n,t){function rt(){e.addClass("is-no-select");f.cssClass&&(o.addClass(f.cssClass),e.addClass(f.cssClass));f.style&&(o.addClass(f.style),e.addClass(f.style));e.addClass("scrollbars-thin");f.width&&o.css({width:f.width});ut()}function g(){var i=0,n,t;for(e.children().remove(),n=0;n<u.length;n++)t=$("<li class='is-selectable'><a><\/a><\/li>"),e.append(t),u[n].element=t,u[n].cssClass&&t.addClass(u[n].cssClass),u[n].tooltipText&&t.attr("title",u[n].tooltipText),f.specialTabs&&f.specialTabs.includes&&f.specialTabs.includes(u[n].tabId)&&t.css("font-weight","bold"),u[n].hidden&&(i+=1),function(n){$("a",t).click(function(){var t=ot(n),i,r;if(t.selectable===!1){if(f.onNonSelectableTabClick)f.onNonSelectableTabClick(n);return}if(n===s&&t.states){for(t.pageElement.removeClass("hold-animation"),i=0;i<t.states.length;i++)t.pageElement.removeClass(t.states[i]);t.stateIndex+=1;t.stateIndex>=t.states.length&&(t.stateIndex=0);t.pageElement.addClass(t.states[t.stateIndex])}r=n==s;p(n);r&&t.pageElement.removeClass("hold-animation")})}(u[n].tabId),f.pageShortcutForm&&function(n){$UI.HandleContextMenuEvent($("a",t),function(t){return ht(n,t),t.preventDefault(),!1})}(u[n].tabId);i&&(t=$("<li class='toggle-hidden'><a>&nbsp;<\/a><\/li>"),e.append(t),t.click(function(){e.toggleClass("hidden-visible")}));y()}function ht(n,t){var r=l(n),i;w||(w=new $UI.MenuPopup(o,{}));w.OnAction(function(t){ct(n,t)});i=[];$App.IsApp()||i.push({ItemId:"CreatePageLink",Caption:"Show this Page in a new Web Browser Tab",IconClass:"is-symbol-open-window"});i.push({ItemId:"CopyPageLink",Caption:"Copy link to Show this Page",IconClass:"is-symbol-copy"});w.Define(i);i.length!=0&&w.Show(t.clientX,t.clientY)}function ct(n,t){switch(t){case"CopyPageLink":case"CreatePageLink":var i="formshow?form="+f.pageShortcutForm;i+="&id="+encodeURI(f.pageShortcutId);i+="&page="+encodeURI(n);t=="CopyPageLink"?window.prompt("Link to show this Page",$App.GetAppShortcutForNewBrowserWindow(i)):$App.RunAppShortcutInNewBrowserWindow(i);break;default:window.alert("Unhandled context menu action: "+t)}}function y(){var c,n,t,i,h,v,y,l,p;for(a=null,o.css("border-color",""),window.setTimeout(function(){e.addClass("added")},10),c=0;c<u.length;c++){if(n=u[c],t=n.element,$(".state",t).remove(),n.pageElement&&$(".is-split-container",n.pageElement).removeClass("has-state"),i=$Runtime.HtmlEncode(n.caption),n.icon){h="";switch(f.style.toUpperCase()){case"BUBBLE":h=r(n.icon,32);i="<div><img src='"+h+"'/><\/div><span>"+i+"<\/span>";break;case"SLIDER":h=r(n.icon,16);i="<div><img src='"+h+"'/><\/div><span>"+i+"<\/span>";break;default:h=r(n.icon,16);i="<img src='"+h+"'/>"+i}}if($("a",t).html(i),n.bulletText&&(v=$("<span class='bullettext'><\/span>"),v.text(n.bulletText),$("a",t).append(v)),n.colour&&(t.css("background-color",n.colour),$Runtime.IsColourLight(n.colour)?t.addClass("light"):t.addClass("dark")),n.visible?t.css({display:""}):t.css({display:"none"}),n.hidden&&t.addClass("hidden"),n.tabId.toUpperCase()==s.toUpperCase()){if(t.addClass("is-sel"),n.colour&&o.css("border-color",n.colour),n.states&&n.states.length>0){for(y=$("<ul class='state' title='Click tab to switch between states'><\/ul>"),l=0;l<n.states.length;l++)p=$("<li><\/li>"),l==n.stateIndex&&(p.addClass("current"),n.pageElement&&n.states[n.stateIndex].toUpperCase()!="NORMAL"&&$(".is-split-container",n.pageElement).addClass("has-state")),y.append(p);t.append(y)}}else t.removeClass("is-sel");n.summaryPage&&n.element.addClass("summarypage");n.noContent&&n.element.addClass("nocontent");n.pageElement&&(n.tabId.toUpperCase()==s.toUpperCase()?(n.pageElement&&(n.pageElement.css({display:""}),a=n.pageElement),n.pageElement.addClass("hold-animation")):n.pageElement.css({display:"none"}))}ut()}function ut(){var t,n;if(f.visible){for(t=0,n=0;n<u.length;n++)u[n].visible&&(t+=1);f.hideTabs?(e.hide(),o.hide()):t<2&&!f.alwaysShowTabs?(e.hide(),o.css("border","4px solid red !important"),console.log("hide: "+o.prop("id")+", "+e.length),e.attr("iwashere","hide")):(e.show(),o.show(),console.log("show: "+o.prop("id")+", "+e.length))}else e.hide(),o.hide()}function lt(n,t){n.FailedMessage?$UI.MsgBoxAlert(n.FailedMessage,{},function(){n.FailedControlId&&t[n.FailedControlId].Focus()}):n.FailedControlId&&t[n.FailedControlId].Focus()}function at(n,t,i){var l,a,c,y,h,v;for(t||(t=o),ft(),s=i==undefined?"":i,l=$("> div",t),c=0;c<l.length;c++)h=l[c],a=b+"page",h.id.substr(0,a.length)==a&&$(h).hide();if(n&&n.Pages)for(c=0;c<n.Pages.length;c++){var f=n.Pages[c],r=new it,p=$("<li><\/li>");e.append(p);r.caption=f.Caption;r.tabId=f.PageId;f.SummaryPageScriptId&&(r.summaryPage=!0);f.NoContent&&(r.noContent=!0);f.BulletText&&(r.bulletText=f.BulletText);f.Colour&&(r.colour=f.Colour);f.Icon&&(r.icon=f.Icon);f.Visible==!1&&(r.hidden=!0);f.PageId.startsWith("__")&&(r.cssClass="System_"+f.PageId.substr(2));switch(f.PageId){case"Audit":case"XPAudit":r.icon="Audit"}y=b+"page"+r.tabId;h=$("#"+y);h.length==0?(h=$("<div class='is-tab-page'><\/div>"),t.append(h),f.pageElement=h,r.pageElement=h,r.pageElementDynamic=!0,console.log("userinterface.Tabs: Dynamically created page for tab '"+r.tabId+"'."),r.summaryPage&&h.addClass("summarypage")):(r.pageElement=$(h[0]),r.pageElement.addClass("is-tab-page"),!1&&$Runtime.IsSmallMobileBrowser()||(v=r.pageElement.attr("states"),v&&(r.states=v.split(","),r.states.length>0&&(r.state=r.states[0],r.pageElement.addClass(r.state)))));u.push(r);s||(s=r.tabId)}g()}function ft(){for(var t,n=0;n<u.length;n++)t=u[n],t.pageElementDynamic&&(t.pageElement.remove(),t.pageElement=null);u=[];g()}function vt(n,t){t=$.extend({},{caption:"",cssClass:null},t);var i=new it,r=$("<li><\/li>");return e.append(r),i.tabId=n,i.pageElement=t.pageElement,i.caption=t.caption,t.colour&&(i.color=t.colour),i.cssClass=t.cssClass,t.icon&&(i.icon=t.icon),t.tooltipText&&(i.tooltipText=t.tooltipText),i.selectable=t.selectable===!1?!1:!0,u.push(i),s||(s=i.tabId),g(),i}function it(){return{element:null,bulletText:"",caption:"",cssClass:"",noContent:!1,pageElement:null,pageElementDynamic:!1,pageElementDynamicPreviewPane:null,summaryPage:!1,tabId:"",visible:!0,hidden:!1,states:null,stateIndex:0}}function yt(){return o}function pt(){return nt}function wt(n){n.TypeName&&(n=n.Element());for(var t=0;t<u.length;t++)if(u[t].pageElement.find(n).length!=0){p()!=u[t].tabId&&p(u[t].tabId);n.focus();break}}function bt(n){if(n||(n=!1),s){var t=l(s);t&&(!n&&$Runtime.IsMobileBrowser()||$("input:visible,select:visible,textarea:visible,div[tabindex=-1]",t.pageElement).first().focus().select())}}function kt(n){return n>=0&&n<u.length?u[n].tabId:""}function dt(n){var t=o.parent(),i,r;n||(i=t.width(),r=t.height(),o.css({width:Math.floor(i)+"px",height:Math.floor(r)+"px"}));t.hasClass("is-modal-body")&&t.addClass("no-scroll");a&&(i=a.parent().width(),r=a.parent().height(),a.css({width:Math.floor(i)+"px",height:Math.floor(r)+"px",overflow:"auto"}))}function p(n){if(n==undefined)return s;s=n;y();f.onSelectedTabChanged&&f.onSelectedTabChanged()}function et(n){if(n==undefined){for(var t=0;t<u.length;t++)if(u[t].tabId==s)return t;return-1}s=u[n].tabId;y();f.onSelectedTabChanged&&f.onSelectedTabChanged()}function gt(n){n=n.toUpperCase();for(var t=0;t<u.length;t++)if(u[t].tabId.toUpperCase()==n){et(t);return}}function ni(n,t,i){var r=l(n),u;if(t.indexOf("ISSectionedBlocks")!=-1&&(t="<div class='is-summarypage-2' style='padding:8px'><div class='is-template-message-error' style='color:darkred'>Summary Page (verson 1) content cannot be reliably viewed from a Web browser.<\/div><\/div>"),i==undefined&&t.indexOf("is-summarypage-column-fixed")!=-1&&(i=!0),r)if(i){if(!r.pageElement.pageElementDynamicPreviewPane)if($UI.PreviewPane)u=$("<div class='is-dock-fill'><\/div>"),r.pageElement.append(u),r.pageElement.pageElementDynamicPreviewPane=$UI.PreviewPane(u,{});else{window.alert("WARNING: Could not set Page IFRAME content since $UI.PreviewPane is unavailable.");return}r.pageElement.pageElementDynamicPreviewPane.SetContent(t,!1,{})}else{if(r.pageElement.pageElementDynamicPreviewPane){window.alert("WARNING: Page already has a dynamic preview pane.");return}r.pageElement.html(t)}else window.alert("userinterface.Tabs.SetPageHtml: tab '"+n+"' does not exist.")}function ot(n){return l(n)}function ti(n){return u[n]}function l(n){n=n.toUpperCase();for(var t=0;t<u.length;t++)if(u[t].tabId.toUpperCase()==n)return u[t];return null}function ii(){return e}function ri(n,t){var i=l(n);if(i===null&&console.warn("TabCaption: Cannot find tab '"+n+"'."),t==undefined)return i.caption;i.caption=t;$("a",i.element).text(i.caption)}function ui(){return u.length}function fi(n){return l(n)!=null}function ei(n,t){var i=l(n);if(i==null&&console.warn("TabBulletText: Cannot find tab '"+n+"'."),t==undefined)return i.bulletText;i.bulletText=t;y()}function oi(n,t){var i=l(n);if(i==null&&console.warn("TabIcon: Cannot find tab '"+n+"'."),t==undefined)return i.icon;i.icon=t;y()}function si(n,t){var i=null;if(typeof n=="string"?i=l(n):n>=0&&n<u.length&&(i=u[n]),i==null&&console.warn("TabVisible: Cannot find tab '"+tabId+"'."),t==undefined)return i.visible;i.visible=t;y()}function hi(n){f.onSelectedTabChanged=n}function ci(n){for(var t=0;t<u.length;t++)if(u[t].pageElement.find(n).length!=0){p(u[t].tabId);break}}function li(n){if(n){var t=l(s);return t?$UI.ValidateContainer(t.pageElement):(window.alert("Tabs.Validate: No current tab."),!1)}return $UI.ValidateContainer(st)}function ai(n){if(n===undefined)return f.visible;f.visible=n;rt()}var o,nt,w,s="",a,u,e,b,f,k,c,d,h,tt,st;if(TabsDefaults={cssClass:"is-tabs",style:"horizontal",alwaysShowTabs:!1,width:"auto",pageShortcutForm:"",pageShortcutId:"",selectedTabId:"",specialTabs:[],onSelectedTabChanged:null,onNonSelectableTabClick:null,visible:!0,hideTabs:!1},f=$.extend({},TabsDefaults,t),b=v,typeof n=="string"?(k=i(n),n=$("#"+k)):k=$(n).attr("id"),c=$(n),c.length==0){console.warn("userinterface.Tabs: Element '"+k+"' not found.");return}if(o=$(c[0]),u=[],c=o.children(),c.length!=0&&c[0].nodeName.toLowerCase()==="ul"){for(e=$(c[0]),c=$("li",e),d=0;d<c.length;d++)h=new it,n=$(c[d]),h.caption=n.text(),h.tabId=n.attr("tabId"),h.cssClass=n.attr("class"),h.icon=n.attr("icon"),n.attr("summaryPage")&&(h.summaryPage=!0),tt=$("#"+b+"page"+h.tabId),tt.length==0?console.warn("userinterface.Tabs: No related page found for tab '"+h.tabId+"'."):(h.pageElement=$(tt[0]),h.pageElement.addClass("is-tab-page"),s||(s=h.tabId)),u.push(h);e.children().remove()}else e=$("<ul><\/ul>"),o.prepend(e);return nt=$("<div class='element-right'><\/div>"),o.append(nt),f.visible||(o.hide(),e.hide()),g(),rt(),s&&p(s),st={TypeName:"Tabs",Element:yt,ElementRight:pt,FocusChild:wt,FocusFirst:bt,GetTabIdByIndex:kt,HandleValidatePageFailedResponse:lt,OnSelectedTabChanged:hi,RefreshFromFormHeaderInfo:at,ResizeFromParent:dt,SelectedTabId:p,SelectedTabIndex:et,SelectTabFromChildElement:ci,GotoPage:gt,SetPageHtml:ni,GetTabById:ot,GetTabByIndex:ti,TabsAdd:vt,TabsClear:ft,TabsElement:ii,TabBulletText:ei,TabExists:fi,TabCaption:ri,TabCount:ui,TabIcon:oi,TabVisible:si,Validate:li,Visible:ai}}function or(n,t){function h(){r.cssClass&&(u.addClass(r.cssClass),o.addClass(r.cssClass));r.readOnly?(u.addClass("is-readonly"),u.attr("disabled","disabled")):(u.removeClass("is-readonly"),u.removeAttr("disabled"));r.autoReadOnly?u.attr("autoreadonly","true"):u.removeAttr("autoreadonly");r.visible?s.css("display","unspecified"):s.css("display","none")}function a(n){if(n===undefined)return o?o.text():"";o&&o.text(n)}function v(){return u}function y(){return s}function p(){u.focus()}function w(){if(!r.readOnly)if(r.onChange)r.onChange(l,{})}function b(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,h())}function k(n){if(n===undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,h())}function d(n){if(n===undefined)return $Runtime.GetBoolean(u);$Runtime.SetBoolean(u,n)}function g(n){if(n===undefined)return r.visible;r.visible=n;h()}function nt(n){if(!f&&(f=u.closest("tr"),f.length==0))return console.warn("Checkbox.VisibleRow: no parent row element found."),f=null,!1;if(n===undefined)return f.css("visibility").toUpperCase()=="HIDDEN";n?(f.css("display","table-row"),f.css("visibility","")):(f.css("display","none"),f.css("visibility","hidden"))}var u,f,o,s,r,e,c,l;if(CheckBoxDefaults={caption:"",cssClass:"is-checkbox",readOnly:!1,autoReadOnly:!0,visible:!0,onChange:null},r=$.extend({},CheckBoxDefaults,t),typeof n=="string"?(e=i(n),n=$("#"+e)):(e=$(n).attr("id"),e||(e="chk"+$Runtime.CreateGuid(!0),$(n).attr("id",e))),c=$(n),c.length==0){console.warn("userinterface.CheckBox: Element '"+e+"' not found.");return}return u=$(c[0]),(u.attr("type")+"").toUpperCase()!="CHECKBOX"&&console.warn("userinterface.CheckBox: Element '"+e+"' does not have a type attribute of 'checkbox'."),u.wrap("<span style='white-space:nowrap' class='is-checkbox' controlType='checkbox'/>"),s=$(u.parent()),o=$("<label for='"+e+"' class='is-no-select'>"+$Runtime.HtmlEncode(r.caption)+"<\/label>").insertAfter(u),h(),u.bind("click",w),l={TypeName:"CheckBox",AutoReadOnly:k,Caption:a,Element:v,Focus:p,ReadOnly:b,Value:d,Visible:g,VisibleRow:nt,WrapperElement:y}}function sr(n,t){function p(){r.cssClass&&f.addClass(r.cssClass);f.addClass("is-no-select");u.attr("readonly","readonly");r.readOnly?f.addClass("is-readonly"):f.removeClass("is-readonly");r.autoReadOnly?u.attr("autoreadonly","true"):u.removeAttr("autoreadonly");r.width!="auto"&&f.css({width:r.width});r.visible?f.show():f.hide()}function w(){var t="",i=u.val(),n;for(o.children().remove(),h=JSON.parse(JSON.stringify(s)),n=0;n<h.length;n++)t+="<li class='is-selectable'>"+$Runtime.HtmlEncode(h[n])+"<\/li>";o.append(t);$("li",o).bind("click",function(){r.readOnly||(tt($(this).text()),d(!0),k())});k();mListDirty=!1}function tt(n){for(var f,i=$Runtime.ArrayFromCsvString(u.val()),e=!1,r=[],t=0;t<i.length;t++)n.toUpperCase()==i[t].toUpperCase()?e=!0:r.push(i[t]);e||r.push(n);f=$Runtime.ArrayToCsvString(r);f!=u.val()&&at(f,!0)}function k(){var r=$("li",o),i,t,f,n,e;for(r.removeClass("checked"),i=$Runtime.ArrayFromCsvString(u.val()),t=0;t<i.length;t++)for(f=i[t].toUpperCase(),n=0;n<h.length;n++)e=h[n].toUpperCase(),f==e&&$(r[n]).addClass("checked")}function it(){return u.val()!=y}function d(){var n={ChangeHandled:!1,TextOriginal:y};if(r.onChange)r.onChange(nt,n);n.ChangeHandled&&(y=u.val())}function rt(n){if(n===undefined)return l?l.text():"";l&&l.text(n)}function ut(){return u}function ft(){u.focus();u.select()}function et(n){s=n;w()}function g(n){s=$Runtime.ArrayFromCsvString(n);w()}function ot(){return $Runtime.ArrayToCsvString(h)}function st(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,p())}function ht(n){if(n===undefined)return b;n!=b&&(b=n==!0,w())}function ct(n){if(n===undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,p())}function lt(n){if(n===undefined)return $Runtime.GetString(u);n!=u.val()&&(v+=1,u.val(n),v-=1,k());y=n}function at(n,t){(n!=u.val()||t)&&(v+=1,u.val(n),v-=1,d())}function vt(n){if(n===undefined)return r.visible;r.visible=n;p()}function yt(n){if(!e&&(e=u.closest("tr"),e.length==0))return console.warn("CheckList.VisibleRow: no parent row element found."),e=null,!1;if(n===undefined)return e.css("visibility").toUpperCase()=="HIDDEN";n?(e.css("display","table-row"),e.css("visibility","")):(e.css("display","none"),e.css("visibility","hidden"))}function pt(){}function wt(){window.alert("HeightResizeFromParent not implemented!");o&&o.hide();window.setTimeout(function(){var n;n=e?$("td,th",e).innerHeight():f.parent().innerHeight();f.css({height:n+0+"px",overflow:"auto"});r.visible&&o.show()},100)}function bt(){return f}function kt(n){r.onChange=n}var u,e,v=0,l,s=[],h,o,b=!1,y="",f,r,a,c,nt;if(ListBoxDefaults={captionElement:"auto",cssClass:"is-checklist",listCsv:"",readOnly:!1,autoReadOnly:!0,visible:!0,width:"auto",onChange:null},r=$.extend({},ListBoxDefaults,t),typeof n=="string"?(a=i(n),n=$("#"+a)):a=$(n).attr("id"),c=$(n),c.length==0){console.warn("userinterface.CheckList: Element '"+a+"' not found.");return}return u=$(c[0]),u.wrap("<span style='display:inline-block; padding:0; position:relative; margin:0' controlType='checklist'/>"),f=$(u.parent()),c=$("label[for='"+a+"']"),l=c.length==0?null:$(c[0]),f.attr("tabindex","-1"),o=$("<ul><\/ul>"),f.append(o),p(),g(r.listCsv),w(),f.bind("keydown",function(n){switch(n.keyCode){case 38:ListIndexChange(-1);break;case 40:ListIndexChange(1)}}),nt={TypeName:"CheckList",AutoReadOnly:ct,Caption:rt,Changed:it,Element:ut,Focus:ft,HeightResizeFromParent:wt,ListFromArray:et,ListFromCsvString:g,ListToCsvString:ot,ReadOnly:st,Sorted:ht,Text:lt,Visible:vt,VisibleRow:yt,WidthResizeFromParent:pt,WrapperElement:bt,OnChange:kt,WrapperElement:function(){return f}}}function hr(n,t){function o(){u.html($Runtime.HtmlEncode(r.text));u.removeClass();switch(r.style.toUpperCase()){case"HEADING":u.addClass("is-label-heading");break;case"HYPERLINK":u.addClass("is-label-hyperlink");break;case"INFORMATION":u.addClass("is-label-information");break;case"NORMAL":u.addClass("is-label-normal");break;case"PAGEHEADING":u.addClass("is-label-pageheading");break;case"WARNING":u.addClass("is-label-warning");break;default:console.warn("userinterface.Label: style '"+r.style+"' not supported.")}r.tooltipHtml||r.tooltipText?u.addClass("is-tooltip"):u.removeClass("is-tooltip");r.readOnly;r.visible?u.show():u.hide()}function v(n){if(n===undefined)return r.tooltipHtml;r.tooltipHtml=n;o()}function y(n){if(n===undefined)return r.tooltipText;r.tooltipText=n;o()}function p(n){if(n===undefined)return r.text;r.text=n;o()}function w(){return u}function b(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,o())}function c(){e.Hide()}function l(){e.Clear();r.tooltipHtml?e.Append("<span>"+r.tooltipHtml+"<\/span>"):e.Append("<span>"+$Runtime.HtmlEncode(r.tooltipText)+"<\/span>");e.Show()}function k(n){if(n===undefined)return r.visible;r.visible=n;o()}function d(n){if(!f&&(f=u.closest("tr"),f.length==0))return console.warn("DbComboBox.VisibleRow: no parent row element found."),f=null,!1;if(n===undefined)return f.css("visibility").toUpperCase()=="HIDDEN";n?(f.css("display","table-row"),f.css("visibility","")):(f.css("display","none"),f.css("visibility","hidden"))}var e,u,f,r,s,h;if(LabelDefaults={style:"Heading",text:null,readOnly:!1,tooltipText:"",tooltipHtml:"",visible:!0},r=$.extend({},LabelDefaults,t),typeof n=="string"?(s=i(n),n=$("#"+s)):s=$(n).attr("id"),h=$(n),h.length==0){console.warn("userinterface.Label: Element '"+s+"' not found.");return}return u=$(h[0]),r.text==null&&(r.text=u.text()),e=new a(u,{cssClass:"is-tooltip"}),o(),u.bind("click",function(){(r.tooltipHtml||r.tooltipText)&&(e.Visible()?c():l())}),{TypeName:"Label",Element:w,ReadOnly:b,Text:p,TooltipHtml:v,TooltipText:y,TooltipHide:c,TooltipShow:l,Visible:k,VisibleRow:d}}function pt(n,t){function o(){u.cssClass&&f.addClass(u.cssClass);u.multiLine?f.css({minHeight:u.minHeight}):f.css({minHeight:""});u.allowBlank?(f.removeClass("is-mandatory"),h&&h.removeClass("is-mandatory")):(f.addClass("is-mandatory"),h&&h.addClass("is-mandatory"));f.attr("placeholder",u.blankTip);u.readOnly?(f.addClass("is-readonly"),f.attr("readonly","readonly")):(f.removeClass("is-readonly"),f.removeAttr("readonly"));u.autoReadOnly?f.attr("autoreadonly","true"):f.removeAttr("autoreadonly");u.hyperlinkContent?(f.addClass("is-hyperlink"),f.addClass("is-hyperlink")):f.removeClass("is-hyperlink");f.attr("maxLength",u.maxLength==0?"":u.maxLength);u.width!="auto"&&f.css({width:u.width});u.spellCheck?f.attr("spellcheck","true"):f.attr("spellcheck","false");u.multiLine&&u.rows&&f.attr("rows",u.rows);u.actionsButtonVisible?(e.addClass("is-control-actions-button"),c.show()):(e.removeClass("is-control-actions-button"),c.hide());tt?(a.css({display:"none"}),f.removeClass("is-invalid")):(f.addClass("is-invalid"),w?(it?a.html(w):a.text(w),a.css({display:"inline-block"})):a.css({display:"none"}))}function at(n){n!=u.allowBlank&&(u.allowBlank=n==!0,o())}function vt(n){if(n===undefined)return u.blankTip;u.blankTip=n;o()}function yt(n){if(n===undefined)return h?h.text():"";h&&h.text(n)}function ct(){return f.val()!=y}function d(){var n={ChangeHandled:!1,TextOriginal:y};if(u.onChange)u.onChange(st,n);n.ChangeHandled&&(y=f.val())}function pt(){return f}function g(){f.focus();f.select()}function wt(){return nt}function bt(n){if(n===undefined)return u.hyperlinkContent;n!=u.hyperlinkContent&&(u.hyperlinkContent=n==!0,o())}function kt(n){if(n===undefined)return u.readOnly;n!=u.readOnly&&(u.readOnly=n==!0,o())}function dt(n){if(n===undefined)return u.autoReadOnly;n!=u.autoReadOnly&&(u.autoReadOnly=n==!0,o())}function gt(n){if(n===undefined)return u.readOnly;n!=u.maxLength&&(u.maxLength=n,o())}function ni(n){if(n===undefined)return $Runtime.GetString(f,!0);f.val(n);y=n}function ot(n){var r,t,i;e.hide();r=e.parent().innerWidth();e.show();t=u.width;i="";u.maxLength==0||u.maxLength>=100||n?t="100%":(t=u.maxLength*.8+"em",i=r<=0?"100%":r+"px");e.css({width:t,maxWidth:i});f.css({width:t,maxWidth:i})}function ti(n,t,i){i&&g();try{f[0].setSelectionRange(n,n+t)}catch(r){console.warn(r)}}function ii(){u.multiLine?(e.css({width:"100%",height:"100%",overflow:"visible",display:"inline-block"}),f.css({width:"100%",height:"100%",overflow:"auto"})):ot()}function ri(n){var t,i,u,r;if(k=n,k&&k.length!=0){for(l=$("<div class='is-textbox-tagslist' style='display:none'><\/div>"),e.prepend(l),t=$("<ul><\/ul>"),i=0;i<n.length;i++)u=k[i],r=$("<li><\/li>"),r.text(u.caption),r.attr("value",u.value),t.append(r);l.append(t);$("li",t).click(function(){f.focus();ei($(this).attr("value"))})}else l=null}function ui(){l&&!u.readOnly&&(v?(window.clearTimeout(v),v=null):l.slideDown("fast"))}function fi(){l&&(v&&window.clearTimeout(v),v=window.setTimeout(function(){l.slideUp("fast");v=null},100))}function ei(n){u.readOnly||lt(n)}function lt(n,t){var r=f[0],i=r.selectionStart,u=r.selectionEnd-i,e=f.val();f.val(e.substring(0,i)+n+e.substring(i+u));t&&g();u?(r.selectionStart=i,r.selectionEnd=i+n.length):(r.selectionStart=i+n.length,r.selectionEnd=i+n.length);d()}function oi(){return tt?!0:!1}function si(n,t,i){tt=n;w=t==undefined?"":t;it=i==undefined?!1:i;o()}function hi(n){if(n===undefined)return u.actionsButtonVisible;n!=u.actionsButtonVisible&&(u.actionsButtonVisible=n==!0,o())}function ci(){return c}function li(n){if(n===undefined)return u.visible;u.visible=n;o()}function ai(n){if(!s&&(s=f.closest("tr"),s.length==0))return console.warn("DbComboBox.VisibleRow: no parent row element found."),s=null,!1;if(n===undefined)return s.css("visibility").toUpperCase()=="HIDDEN";n?(s.css("display","table-row"),s.css("visibility","")):(s.css("display","none"),s.css("visibility","hidden"))}var c,f,s,nt=!1,tt=!0,h,k=[],l,v,y="",a,w="",it=!1,e,u,b,p,rt,ut,ht,ft,et,st;if(TextBoxDefaults={captionElement:"auto",cssClass:"is-textbox",allowBlank:!0,blankTip:"",maxLength:0,multiLine:!1,minHeight:"32px",spellCheck:!1,readOnly:!1,autoReadOnly:!0,width:"auto",rows:1,password:!1,onChange:null,changeWhileTyping:!1,onEnterKey:null,hyperlinkContent:!1,onContentHyperlink:null,actionsButtonIcon:null,actionsButtonVisible:!1,onActionsButtonClick:null},u=$.extend({},TextBoxDefaults,t),typeof n=="string"?(b=i(n),n=$("#"+b)):b=$(n).attr("id"),p=$(n),p.length==0){console.warn("userinterface.TextBox: Element '"+b+"' not found.");return}if(f=$(p[0]),u.blankTip||(u.blankTip=f.attr("placeholder")),u.multiLine?(rt=$("<textarea id='"+f.attr("id")+"' style='resize:none'><\/textarea>"),f.replaceWith(rt),f=rt):u.password&&(ut=$("<input type='password' id='"+f.attr("id")+"' autocomplete='new-password' value=''/>"),f.replaceWith(ut),f=ut),f.wrap("<span style='white-space:normal; display:inline; padding:0; margin:0;' controlType='textbox'/>"),e=$(f.parent()),c=$("<button class='is-control-actions-button' type='button'><\/button>"),u.actionsButtonIcon&&(ht=r(u.actionsButtonIcon,16),c.addClass("icon"),c.append("<img src='"+ht+"'/>")),e.append(c),c.click(function(){if(u.actionsButtonVisible)if(u.onActionsButtonClick)u.onActionsButtonClick(st);else window.alert("onActionsButtonClick is not handled!")}),a=$("<label style='display:none' class='is-validation-tip'><\/label>"),e.append(a),p=$("label[for='"+b+"']"),h=p.length==0?null:$(p[0]),u.width=="auto"&&u.maxLength!=0&&ot(),f.blur(function(){ct()&&d();y=f.val();nt=!1;fi()}),f.focus(function(){nt=!0;ui()}),u.changeWhileTyping){ft="keyup paste";et=f.attr("type");et&&et.toLowerCase()=="search"&&(ft+=" input");f.on(ft,function(){d();y!=f.val()&&console.warn("userinterface.TextBox: changeWhileTyping is enabled but no onChange handler is setting e.changeHandled to true. Ignore if by design but this may mean code is called multiple times needlessly.")})}if(u.onEnterKey)f.on("keydown",function(n){if(n.keyCode==13)return u.onEnterKey(),!1});if(u.onContentHyperlink)f.on("click",function(){u.readOnly&&u.hyperlinkContent&&u.onContentHyperlink&&u.onContentHyperlink()});return a.click(function(){g()}),o(),st={TypeName:"TextBox",ActionsButtonElement:ci,ActionsButtonVisible:hi,AllowBlank:at,AutoReadOnly:dt,BlankTip:vt,Caption:yt,Changed:ct,Element:pt,Focus:g,HasFocus:wt,HyperlinkContent:bt,MaxLength:gt,ReadOnly:kt,ResizeFromParent:ii,SetSelection:ti,InsertAtCaret:lt,TagsListDefine:ri,Text:ni,Visible:li,VisibleRow:ai,WidthResizeFromParent:ot,IsValid:oi,ValidationSet:si,NotifyChange:d}}function cr(n,t){function h(){r.cssClass&&u.addClass(r.cssClass);r.multiLine?u.css({minHeight:r.minHeight}):u.css({minHeight:""});r.allowBlank?(u.removeClass("is-mandatory"),f&&f.removeClass("is-mandatory")):(u.addClass("is-mandatory"),f&&f.addClass("is-mandatory"));u.attr("placeholder",r.blankTip);r.readOnly?(u.addClass("is-readonly"),u.attr("readonly","readonly")):(u.removeClass("is-readonly"),u.removeAttr("readonly"));r.autoReadOnly?u.attr("autoreadonly","true"):u.removeAttr("autoreadonly");r.hyperlinkContent?(u.addClass("is-hyperlink"),u.addClass("is-hyperlink")):u.removeClass("is-hyperlink");u.attr("maxLength",r.maxLength==0?"":r.maxLength);r.width!="auto"&&u.css({width:r.width})}function v(n){n!=r.allowBlank&&(r.allowBlank=n==!0,h())}function y(n){if(n===undefined)return f?f.text():"";f&&f.text(n)}function p(){return u.val()!=mTextOriginal}function w(){return u}function b(){u.focus();u.select()}function k(n){if(n===undefined)return r.hyperlinkContent;n!=r.hyperlinkContent&&(r.hyperlinkContent=n==!0,h())}function d(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,h())}function g(n){if(n===undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,h())}function nt(){return u[0].files}function tt(n){for(var r,f,t=u[0].files,e=[],o=0,i=0;i<t.length;i++)r=new FileReader,f=t[i],r.readAsDataURL(f),r.onload=function(i){return function(r){o+=1;e.push({name:i.name,data:r.target.result});o==t.length&&n(e)}}(f)}function l(n){var f,t,i;e.hide();f=e.parent().innerWidth();e.show();t=r.width;i="";r.maxLength==0||r.maxLength>100||n?t="100%":(t=r.maxLength*.8+"em",i=f+"px");e.css({width:t,maxWidth:i});u.css({width:t,maxWidth:i})}var u,f,e,r,s,o,c,a;if(FileBoxDefaults={captionElement:"auto",cssClass:"is-textbox",allowBlank:!0,blankTip:"",maxFiles:1,readOnly:!1,autoReadOnly:!0,width:"auto",onChange:null,hyperlinkContent:!1,onContentHyperlink:null},r=$.extend({},FileBoxDefaults,t),typeof n=="string"?(s=i(n),n=$("#"+s)):s=$(n).attr("id"),o=$(n),o.length==0){console.warn("userinterface.FileBox: Element '"+s+"' not found.");return}return u=$(o[0]),r.blankTip||(r.blankTip=u.attr("placeholder")),c=$("<input type='file' id='"+u.attr("id")+"' value=''/>"),u.replaceWith(c),u=c,u.wrap("<span style='white-space:normal; display:inline; padding:0; margin:0;' controlType='filebox'/>"),e=$(u.parent()),mValidationElement=$("<label style='display:none' class='is-validation-tip'><\/label>"),e.append(mValidationElement),o=$("label[for='"+s+"']"),f=o.length==0?null:$(o[0]),r.width=="auto"&&r.maxLength!=0&&l(),h(),a={TypeName:"FileBox",AllowBlank:v,AutoReadOnly:g,Caption:y,Changed:p,Element:w,Focus:b,HyperlinkContent:k,ReadOnly:d,Files:nt,WidthResizeFromParent:l,GetFileData:tt}}function lr(t){function ti(){return c}function ii(){return i.allowCloseWithoutWarning}function ut(n){if(i.hideOnClose){et(!1);return}wt();n?window.setTimeout(function(){ft()},100):ft()}function wt(){var i,r,t;if(o===n[n.length-1])h>0&&(h-=1),i=n.pop(),n.length>0?n[n.length-1].NotifyChildClosed(i):o.ParentModal()&&o.ParentModal().NotifyChildClosed&&o.ParentModal().NotifyChildClosed(i);else if(o.ForcedClose){for(r=[],t=0;t<n.length;t++)n[t]===o?(h-=1,console.warn("Modal forcibly removed from the stack even though it was not the top-level modal.")):r.push(n[t]);n=r}else window.alert("userinterface.Modal.Close: Could not remove modal from stack since it is not the top-most item. Modals should always be closed last to first.")}function ft(){f&&(u.remove(),u=null,f.remove(),f=null,$(window).unbind("resize.modal"+p),h<=0&&$("body").removeClass("is-has-modal"));i.onAfterClose&&i.onAfterClose()}function ri(){f;i.onAfterHide&&i.onAfterHide()}function ui(){return d}function fi(n){if(n===undefined)return i.dialogResult;i.dialogResult=n}function et(n){tt?(tt=!1,f.fadeOut(100),n?(wt(),u.fadeOut(100,function(){ft()})):u.fadeOut(100,function(){ri()})):n&&ut()}function ei(){st(o)}function ot(n,t){var r=!1;if($App&&$App.ExecuteGlobalFormAction&&(r=$App.ExecuteGlobalFormAction(n,t,o)),!r)if(i.onAction)i.onAction(n,t);else console.warn("$UI.Modal.ExecuteAction: No OnAction defined for this Modal object to handle action '"+n+"'.")}function oi(n,t){if(i.onActionNotification)i.onActionNotification(n,t)}function si(){for(var t=$("a, button, input, select, textarea",u),n=0;n<t.length;n++)e=$(t[n]),e.attr("disabled")||(e.attr("autoreadonly")==undefined||e.attr("autoreadonly")!="false")&&(e.attr("ISFormDisabled",!0),e.attr("disabled",!0))}function ci(){for(var t=$("a, button, input, select, textarea",u),n=0;n<t.length;n++)e=$(t[n]),e.attr("ISFormDisabled")&&(e.removeAttr("ISFormDisabled"),e.attr("disabled",!1))}function li(n){if(n===undefined)return i.formKey;i.formKey=n}function ai(n){if(n===undefined)return i.formType;i.formType=n}function vi(n){if(i.onChildClosed)i.onChildClosed({child:n})}function yi(){i.onRefresh?i.onRefresh():i.appShortcutUrl&&$App&&(ut(),$Ash.ExecuteUrl(i.appShortcutUrl))}function pi(n){if(n==undefined)return i.onAction;i.onAction=n}function wi(n){i.onActionNotification=n}function bi(n){i.onChildClosed=n}function ki(n){i.onClose=n}function di(n){i.onRefresh=n}function gi(n){i.onResize=n}function nr(n){if(n===undefined)return i.parentModal;i.parentModal=modal}function tr(n){n=n.replace(/ id=\"/g,' id="'+l);n=n.replace(/ id=\'/g," id='"+l);n=n.replace(/ for=\"/g,' for="'+l);n=n.replace(/ for=\'/g," for='"+l);d.html(n);(i.width=="auto"||i.height=="auto")&&ht()}function ir(n){a?(typeof n=="string"&&(n=$("#"+n)),n.detach(),a.append(n),a.show()):window.alert("userinterface.Modal.SetFooterElement: Cannot set until form has been shown.")}function rr(n){g?(typeof n=="string"&&(n=$("#"+n)),n.detach(),g.append(n),g.show()):window.alert("userinterface.Modal.SetHeaderElement: Cannot set until form has been shown.")}function ur(n){var t=$.extend({},ModalShowDefaults,n);(t.title!=undefined&&(i.title=t.title),t.titleIcon!=undefined&&(i.titleIcon=t.titleIcon),f||(rt+=1,p=rt,f=$("<div class='is-modal-overlay' style='display:none'><\/div>"),$("#pageBody").hasClass("blur")&&f.css("background-color","rgba(0,0,0,0.6)"),f.css("z-index",2+(p-1)*11),i.allowMinimise&&f.addClass("allows-minimise"),$("body").append(f),u=$("<div id='"+l+"' class='is-modal showing' style='display:none'><div class='is-modal-title-buttons'><div class='is-modal-minimise is-symbol-minimise-window' title='Temporarily minimise this form to view information underneath'><\/div><div class='is-modal-open-window is-symbol-open-window' title='Open in a new Web Browser Tab\n\nThis provides a URL that can be bookmarked in your browser or sent to someone'><\/div><div class='is-modal-close is-symbol-close' title='Close'><\/div><\/div><div class='is-form-actions-menu' style='display:none'><\/div><div class='is-modal-title-icon is-no-select'><\/div><div class='is-modal-title is-no-select'><\/div><div class='is-modal-header' style='display:none'><\/div><div class='is-modal-body'><\/div><div class='is-modal-footer' style='display:none'><ul class='is-modal-dialog-buttons main' style='display:none'><\/ul><ul class='is-modal-dialog-buttons other' style='display:none'><\/ul><\/div><\/div><\/div>"),i.specialCssClass&&u.addClass(i.specialCssClass),i.tool&&u.addClass("tool"),$("body").append(u),u.css("z-index",10+(p-1)*11),nt=$(".is-modal-minimise",u),b=$(".is-modal-open-window",u),k=$(".is-modal-close",u),y=$(".is-modal-title-icon",u),v=$(".is-modal-title",u),g=$(".is-modal-header",u),d=$(".is-modal-body",u),a=$(".is-modal-footer",u),lt=$(".main",u),at=$(".other",u),ct=$(".is-form-actions-menu",u),nt.click(function(n){n.preventDefault();$UI.ModalMinimise(o,i.parentModal)}),b.click(function(n){n.preventDefault();$App&&$App.RunAppShortcutInNewBrowserWindow(i.appShortcutUrl)}),k.click(function(n){n.preventDefault();i.onClose?i.onClose():pt?yt.ActionNotificationSend("FormClose"):et(i.deleteOnClose)}),$(window).bind("resize.modal"+p,function(){ht();i.onResize&&i.onResize()})),t.content!=null&&d.html(t.content),ni(i.title),i.allowMinimise?(nt.show(),u.addClass("allows-minimise")):(nt.hide(),u.removeClass("allows-minimise")),window.$App&&$App.IsApp()?b.hide():i.appShortcutUrl?b.show():b.hide(),i.showClose?k.show():k.hide(),ht(),t.noShow)||(tt=!0,f.css({display:""}),u.show(),kt(),i.tool||(h+=1),h==1&&$("body").addClass("is-has-modal"),i.focusActionId&&window.setTimeout(function(){gt(i.focusActionId)},10))}function bt(){vt(ct,c,ot)}function ht(){var e=parseInt(i.minHeight),o=parseInt(i.minWidth),t,r,f,n;if(e||(e=460),o||(o=620),t=!1,r=!1,(window.innerWidth<=640||window.innerHeight<=480)&&(t=!0),!t){u.removeClass("is-modal-full");f={width:i.width};i.height==="auto"||(f.height=i.height);u.css(f);n=i.width+"";n&&n.substr(n.length-1,1)==="%"&&(i.minWidth&&u.css({minWidth:i.minWidth}),i.maxWidth&&u.css({maxWidth:i.maxWidth}));n=i.height+"";n&&n.substr(n.length-1,1)=="%"&&(i.minHeight&&u.css({minHeight:i.minHeight}),i.maxHeight&&u.css({maxHeight:i.maxHeight}));var s=u.outerHeight(),h=u.outerWidth(),c=Math.max($(window).height()-s,0)/3,l=Math.max($(window).width()-h,0)/2;u.css({top:c,left:l});u.outerWidth()>=window.innerWidth-20?r=!0:u.outerHeight()>=window.innerHeight-20&&(r=!0)}u.removeClass("forced-windowed");t?i.forceWindowed?(u.css({top:8,left:8,bottom:8,right:8,width:"",height:"",minWidth:"",minHeight:"",maxWidth:"",maxHeight:""}),u.addClass("forced-windowed")):(u.addClass("is-modal-full"),u.css({top:0,left:0,width:"100%",height:"100%",minWidth:"",minHeight:"",maxWidth:"",maxHeight:""})):r}function fr(){return l}function er(){return u}function kt(){var n=!1;f&&(dt("[buttons]",lt)>0&&(n=!0),dt("[buttonsOther]",at)>0&&(n=!0),n?a.show():a.hide())}function dt(n,t){var s=0,h=!1,i,u,f,o,e;for(t.children().remove(),e=0;e<c.Actions().length;e++)if(i=c.Actions()[e],(i.groupId.toUpperCase()==n.toUpperCase()||i.repeatInGroupId&&i.repeatInGroupId.toUpperCase()==n.toUpperCase())&&i.visible){if(s+=1,f=$("<li><button class='is-button'><\/button><\/li>"),t.append(f),u=$("button",f),u.attr("action-id",i.actionId),o=i.caption+"",o=o.replace(/(<([^>]+)>)/ig,""),n=="[buttonsOther]"&&i.icon&&w?(u.addClass("action-other"),i.alwaysShowCaption&&u.text(o),iconUrl=iconUrl=r(i.icon,16),u.css("background-image","url("+iconUrl+")"),u.attr("title",i.tooltipText||o)):(u.text(o),u.attr("title",i.tooltipText)),i.enabled||u.attr("disabled","disabled"),i.buttonStyle)u.addClass(i.buttonStyle);else switch(i.actionId.toUpperCase()){case"ADD":u.addClass("positive");break;case"CANCEL":case"CLOSE":u.addClass("cancel");break;case"CUSTOMISE":u.addClass("customise");f.addClass("system");u.attr("title","Customise");break;case"DELETE":u.addClass("danger");break;case"FINISH":case"OK":case"SAVE":u.addClass("ok");break;case"REFRESH":u.addClass("refresh");f.addClass("system");u.attr("title","Refresh");break;default:u.addClass("normal")}i.enabled&&(i.handler?function(n){u.click(function(){n.handler()})}(i):function(n){u.click(function(){ot(n.actionId,n.data?n.data:n.applicationShortcutUrl)})}(i))}if(n=="[buttonsOther]"){for(e=0;e<c.Actions().length;e++)if(i=c.Actions()[e],i.groupId.substr(0,1)!="["&&i.visible){h=!0;s+=1;break}h&&(f=$("<li class='system'><button class='is-button actions' title='Actions'><\/button><\/li>"),t.append(f),u=$("button",f),function(){u.click(function(){bt()})}())}return s>0?t.show():t.hide(),s}function gt(n){window.setTimeout(function(){var t=$("button[action-id='"+n+"']",u);t.focus()},10)}function ni(n){if(n===undefined)return i.title;n?(n.startsWith("<HTML>")?v.html(n.substr(6)):v.text(n),v.show()):(v.text(""),v.hide())}function or(n){if(n===undefined)return i.titleIcon;n?(n.indexOf("<")==-1?y.html("<img src='"+$UI.GetIconUrl(n)+"' style='width:16px; height:16px'/>"):y.html(n),y.show()):(y.text(""),y.hide())}function sr(n){s||(n||(n=""),s=$("<div class='is-modal-overlay top is-wait-block' style='display:none'><div class='is-wait'><div class='is-wait1'><\/div><div class='is-wait2'><\/div><div class='is-wait3'><\/div><\/div><label>"+$Runtime.HtmlEncode(n)+"<\/label><\/div>"),u.append(s),s.show())}function hr(n){s&&($("label",s).text(n),s.show())}function cr(){s&&(s.remove(),s=null)}function lr(n){pt=!0;yt=n}var c,ct,k,d,lt,a,g,u,p,l,v,y,nt,b,at,f,tt=!1,s,yt=null,pt=!1,i,o;return ModalDefaults={formKey:"",formType:"",dialogResult:"Cancel",content:"",title:"",titleIcon:"",width:"50%",height:"50%",minWidth:620,minHeight:460,maxWidth:"",maxHeight:"",forceWindowed:!0,showClose:!0,deleteOnClose:!0,closeOnEscape:!1,actionCaption:"",onAction:null,onActionNotification:null,onChildClosed:null,onClose:null,onRefresh:null,onResize:null,onAfterClose:null,onAfterHide:null,hideOnClose:!1,appShortcutUrl:"",parentModal:null,allowMinimise:!1,allowCloseWithoutWarning:!1,tool:!1,specialCssClass:""},i=$.extend({},ModalDefaults,t),l="MODAL"+$Runtime.CreateGuid(!0)+"ENDMODAL",c=new it,ModalShowDefaults={content:null,title:null},o={TypeName:"Modal",Actions:ti,AllowCloseWithoutWarning:ii,Close:ut,ContentElement:ui,DialogResult:fi,ExecuteAction:ot,ExecuteNotificationAction:oi,FocusActionButton:gt,FormDisable:si,FormEnable:ci,FormReadOnly:hi,FormKey:li,FormType:ai,Hide:et,Minimise:ei,ModalId:fr,ModalElement:er,ParentModal:nr,Refresh:kt,RenderView:tr,SetFooterElement:ir,SetHeaderElement:rr,Show:ur,ShowActions:bt,Title:ni,TitleIcon:or,HeaderHide:function(){},HeaderShow:function(){},NotifyChildClosed:vi,NotifyRefresh:yi,OnAction:pi,OnActionNotification:wi,OnChildClosed:bi,OnClose:ki,OnRefresh:di,OnResize:gi,WaitShow:sr,WaitUpdate:hr,WaitHide:cr,CloseOnEscape:function(){return i.closeOnEscape},Tag:{},WidgetDisabledCloseButton:lr},n.push(o),o}function ar(n){function ut(){return c}function g(){var r,n;if(a){for(a.children().remove(),r=[],n=0;n<f.length;n++)i===f[n]||r.push(f[n]);f=r}t.onAfterClose&&t.onAfterClose()}function ft(){return v}function y(n,r){if(r&&(r+"").toUpperCase().startsWith("APP:"))window.$Ash?$Ash.ExecuteUrl(r,i,null,null,{rerunApplicationShortcutUrl:"-"}):window.alert("Action cannot handle Application Shortcuts since no handler ($Ash) is available.");else{var u=!1;if($App&&$App.ExecuteGlobalFormAction&&(u=$App.ExecuteGlobalFormAction(n,r,i)),!u)if(t.onAction)t.onAction(n,r);else console.warn("$UI.Modal.ExecuteAction: No OnAction defined for this NonModal object to handle action '"+n+"'.")}}function et(n,i){if(t.onActionNotification)t.onActionNotification(n,i)}function ot(){for(var t=$("a, button, input, select, textarea",u),n=0;n<t.length;n++)e=$(t[n]),e.attr("disabled")||(e.attr("autoreadonly")==undefined||e.attr("autoreadonly")!="false")&&(e.attr("ISFormDisabled",!0),e.attr("disabled",!0))}function st(){for(var t=$("a, button, input, select, textarea",u),n=0;n<t.length;n++)e=$(t[n]),e.attr("ISFormDisabled")&&(e.removeAttr("ISFormDisabled"),e.attr("disabled",!1))}function ht(n,t){var u,i,r;for(u in n)i=n[u],i&&i.TypeName&&i.ReadOnly&&(r=!0,i.AutoReadOnly&&!i.AutoReadOnly()&&(r=!1),r&&i.ReadOnly(t))}function ct(n){if(n===undefined)return t.formKey;t.formKey=n}function lt(){g()}function at(n){if(t.onActivate)t.onActivate(n)}function yt(n){if(t.onChildClosed)t.onChildClosed({child:n})}function pt(n){if(n==undefined)return t.onAction;t.onAction=n}function wt(n){t.onActionNotification=n}function bt(n){t.onActivate=n}function kt(n){t.onChildClosed=n}function dt(n){t.onClose=n}function gt(n){t.onResize=n}function ni(n){n=n.replace(/ id=\"/g,' id="'+l);n=n.replace(/ id=\'/g," id='"+l);n=n.replace(/ for=\"/g,' for="'+l);n=n.replace(/ for=\'/g," for='"+l);v.html(n)}function ti(n){o?(typeof n=="string"&&(n=$("#"+n)),n.detach(),o.append(n),o.show()):window.alert("userinterface.NonModal.SetFooterElement: Cannot set until form has been shown.")}function ii(n){h?(typeof n=="string"&&(n=$("#"+n)),n.detach(),h.append(n),h.show()):window.alert("userinterface.NonModal.SetHeaderElement: Cannot set until form has been shown.")}function ri(){h&&h.hide()}function ui(){h&&h.show()}function fi(n){if(!k){k=!0;var i=$.extend({},NonModalShowDefaults,n);if(!i.parentElement){window.alert("ISUserInterface.NonModal.Show: parentElement not specified.");return}i.title!=undefined&&(t.title=i.title);a=i.parentElement;a.children().remove();u=$("<div id='"+l+"' class='is-nonmodal' style='display:none'><div class='is-form-actions-menu' style='display:none'><\/div><div class='is-nonmodal-header' style='display:none'><\/div><div class='is-nonmodal-body'><\/div><div class='is-nonmodal-footer' style='display:none'><ul class='is-modal-dialog-buttons main' style='display:none'><\/ul><ul class='is-modal-dialog-buttons other' style='display:none'><\/ul><div class='footer-hide' tabindex='-1' title='Collapse'><\/div><\/div><\/div><\/div>");a.append(u);h=$(".is-nonmodal-header",u);v=$(".is-nonmodal-body",u);o=$(".is-nonmodal-footer",u);b=$(".footer-hide",o);b.on("click",function(){o.hasClass("collapsed")?(u.removeClass("actions-collapsed"),o.removeClass("collapsed")):(u.addClass("actions-collapsed"),o.addClass("collapsed"))});w=$(".main",u);d=$(".other",u);p=$(".is-form-actions-menu",u);t.width&&(u.css("width",t.width),t.maxWidth&&u.css("maxWidth",t.maxWidth),t.minWidth&&u.css("minWidth",t.minWidth));i.content!=null&&v.html(i.content)}u.fadeIn(100);tt()}function nt(){vt(p,c,y)}function ei(){return l}function tt(){var n=!1;rt("[buttons]",w)>0&&(n=!0);rt("[buttonsOther]",d)>0&&(n=!0);n?o.show():o.hide()}function rt(n,t){var s=0,l=!1,i,u,f,e,o,a,h;if(t.children().remove(),n=="[buttonsOther]"){for(e=0;e<c.Actions().length;e++)if(i=c.Actions()[e],i.groupId.substr(0,1)!="["&&i.visible){l=!0;s+=1;break}l&&(f=$("<li class='system'><button class='is-button actions' title='Actions'><\/button><\/li>"),t.append(f),u=$("button",f),function(){u.click(function(){nt()})}())}for(e=0;e<c.Actions().length;e++)if(i=c.Actions()[e],(i.groupId.toUpperCase()==n.toUpperCase()||i.repeatInGroupId&&i.repeatInGroupId.toUpperCase()==n.toUpperCase())&&i.visible){if(s+=1,f=$("<li><button class='is-button'><\/button><\/li>"),t.append(f),u=$("button",f),o=i.caption+"",o=o.replace(/(<([^>]+)>)/ig,""),n=="[buttonsOther]"&&i.icon?(u.addClass("action-other"),a=r(i.icon,16),u.css("background-image","url("+a+")"),u.attr("title",i.tooltipText||o),(i.buttonCaption||o&&i.alwaysShowCaption)&&(i.buttonCaption?u.text(i.buttonCaption):u.text(o),u.addClass("icon-and-caption")),i.context&&u.addClass("contextual")):(u.text(i.caption),u.attr("title",i.tooltipText)),i.enabled||u.attr("disabled","disabled"),i.buttonStyle)u.addClass(i.buttonStyle);else{h=i.actionId.toUpperCase();switch(h){case"ADD":u.addClass("positive");break;case"CANCEL":case"CLOSE":u.addClass("cancel");break;case"CUSTOMISE":u.addClass("customise");f.addClass("system");u.attr("title","Customise");break;case"DELETE":u.addClass("danger");break;case"OK":case"SAVE":u.addClass("ok");break;case"REFRESH":u.addClass("refresh");f.addClass("system");u.attr("title","Refresh");break;default:h.substring(0,5)=="EDIT."?u.addClass("normal"):h.substring(0,5)=="ADD."?u.addClass("positive"):u.addClass("normal")}}i.enabled&&(i.handler?function(n){u.click(function(){n.handler()})}(i):function(n){u.click(function(){y(n.actionId,n.data?n.data:n.applicationShortcutUrl)})}(i))}return s>0?t.show():t.hide(),s}function oi(n){s||(n||(n=""),s=$("<div class='is-nonmodal-overlay is-wait-block' style='display:none'><div class='is-wait'><div class='is-wait1'><\/div><div class='is-wait2'><\/div><div class='is-wait3'><\/div><\/div><label>"+$Runtime.HtmlEncode(n)+"<\/label><\/div>"),u.append(s),s.fadeIn(100))}function si(n){s&&($("label",s).text(n),s.show())}function hi(){s&&(s.remove(),s=null)}function ci(n){if(n===undefined)return i._Tabs?i._Tabs.TabCaption(i._Tab.tabId):"";i._Tabs&&i._Tabs.TabCaption(i._Tab.tabId,n)}function li(n){if(n===undefined)return i._Tabs?i._Tabs.TabIcon(i._Tab.tabId):"";i._Tabs&&i._Tabs.TabIcon(i._Tab.tabId,n)}function ai(n){if(n===undefined)return i._Tabs?i._Tab.tabId:"";i._Tabs&&(i._Tab.tabId=n)}var c,p,v,w,o,b,h,k=!1,u,l,a,d,s,t,i;return NonModalDefaults={formKey:"",content:"",title:"",actionCaption:"",onAction:null,onActionNotification:null,onActivate:null,onChildClosed:null,onClose:null,onAfterClose:null},t=$.extend({},NonModalDefaults,n),l="NONMODAL"+$Runtime.CreateGuid(!0)+"ENDMODAL",c=new it,NonModalShowDefaults={parentElement:null,content:null,title:null},i={TypeName:"NonModal",Actions:ut,Close:g,ContentElement:ft,ExecuteAction:y,ExecuteNotificationAction:et,FormDisable:ot,FormEnable:st,FormKey:ct,FormReadOnly:ht,Hide:lt,ModalId:ei,Refresh:tt,RenderView:ni,SetFooterElement:ti,SetHeaderElement:ii,Show:fi,ShowActions:nt,HeaderHide:ri,HeaderShow:ui,OnAction:pt,OnActionNotification:wt,OnActivate:bt,OnChildClosed:kt,OnClose:dt,OnResize:gt,WaitShow:oi,WaitUpdate:si,WaitHide:hi,Tag:{},NotifyActivate:at,NotifyChildClosed:yt,TabCaption:ci,TabIcon:li,TabId:ai},f.push(i),i}function it(n){function u(){return t}function r(n){var r,u;for(t=n,r=0;r<t.length;r++)u=$.extend({},i,t[r]),t[r]=u}function f(n){var f,u,r;if(n&&n.Actions)for(f=0;f<n.Actions.length;f++){if(u=n.Actions[f],r=$.extend({},i,{}),r.actionId=u.ActionId,r.buttonCaption=u.ButtonCaption,r.caption=u.Caption,r.alwaysShowCaption=u.AlwaysShowCaption,r.context=u.ContextPageId?!0:!1,r.contextPageId=u.ContextPageId,r.groupId=u.GroupId,r.icon=u.Icon,r.repeatInGroupId=u.RepeatInGroupId,r.system=u.System,r.applicationShortcutUrl=u.ApplicationShortcutUrl,u.ParametersJson)if(r.applicationShortcutUrl)console.warn("$UI.ActionsCollection.AppendFromFormHeaderInfo: Action '"+r.actionId+"' defined both an Application Shortcut URL and JSON Parameters. JSON Parameters were ignored.");else try{r.data=JSON.parse(u.ParametersJson)}catch(e){window.alert("$UI.ActionsCollection.AppendFromFormHeaderInfo: Action '"+r.actionId+"'\n\nFailed to parse ParametersJson.\n\n"+e)}t.push(r)}}function e(n){var i,r;for(n=n.toUpperCase(),i=0;i<t.length;i++)if(r=t[i],r.actionId&&r.actionId.toUpperCase()==n)return r;return null}function o(n){var i,r;for(n=n.toUpperCase(),r=0;r<t.length;r++)if(i=t[r],i.actionId&&i.actionId.toUpperCase()==n)return i.applicationShortcutUrl;return!1}function s(n,i){var r,u;for(n=n.toUpperCase(),u=0;u<t.length;u++)r=t[u],r.actionId&&r.actionId.toUpperCase()==n&&(r.caption=i)}function h(n,i){var r,u;for(n=n.toUpperCase(),u=0;u<t.length;u++)r=t[u],r.actionId&&r.actionId.toUpperCase()==n&&(r.checked=i)}function c(n,i,r){var u,f;for(n=n.toUpperCase(),f=0;f<t.length;f++)u=t[f],u.actionId&&u.actionId.toUpperCase()==n&&(u.enabled=i,r!=undefined&&(u.tooltipText=r))}function l(n){var i,r;for(n=n.toUpperCase(),r=0;r<t.length;r++)if(i=t[r],i.actionId&&i.actionId.toUpperCase()==n)return i.enabled;return!1}function a(n,i){var r,u;for(n=n.toUpperCase(),u=0;u<t.length;u++)r=t[u],r.actionId&&r.actionId.toUpperCase()==n&&(r.visible=i)}var t=[],i={buttonStyle:"",caption:"",alwaysShowCaption:!1,applicationShortcutUrl:"",data:null,checked:!1,context:!1,contextPageId:"",enabled:!0,icon:"",groupId:"",repeatInGroupId:"",system:!0,tooltipText:"",visible:!0};return n&&r(n),{TypeName:"ActionCollection",Actions:u,Define:r,AppendFromFormHeaderInfo:f,GetAction:e,GetApplicationShortcutUrl:o,GetEnabled:l,SetCaption:s,SetChecked:h,SetEnabled:c,SetVisible:a}}function a(n,t){function y(n){r.append(n)}function p(){return e}function w(){r.children().remove()}function b(){return r}function k(n,t){var a,l,i,o,c;if(s=!0,a=!1,u.popupTip)l=0,i=0,r.css({left:l,top:i});else{var h=e.offset(),l=h.left,i=h.top+e.outerHeight(),v=0,p=e[0].ownerDocument,y=!0,f=n;f||(f=200);i+=u.offsetTop;v=$(p).innerHeight()-i-4;v>=f?y=!0:h.top>=f?y=!1:(i=$(p).innerHeight()-f-16,i<0&&(i=0),r.css("min-height",f));y?r.css({bottom:"",left:l,top:i,"max-height":v,height:""}):(a=!0,o=r.height()+2,n&&n>o&&(o=n),c=h.top-o,c<0&&(o+=c,c=0),r.css({left:l,maxHeight:o,height:"100%",bottom:h.top,top:c}));u.minWidthElement&&r.css({minWidth:u.minWidthElement.outerWidth()});t&&(a||r.css("bottom",0));u.widgetDocument||$("body").append(r)}r.removeClass("active");r.show();window.setTimeout(function(){r.addClass("active")},10)}function d(){s&&(s=!1,r.hide(),r.css({"max-height":"",height:"",top:"auto",bottom:"auto"}),u.widgetDocument||e.append(r))}function g(){return s}function nt(){return u.closeOnClickOutside}function tt(n){if(s){n?r.css("max-width",n+"px"):r.css("max-width","");var i=r.offset(),f=i.left,t=0;t=u.widgetDocument?$(u.widgetDocument).innerWidth():$("body").innerWidth();r.css("width",t-f-4+"px")}}var e,r,s=!1,o,f,u,c,a,v,l,h,n;if(DropdownPanelDefaults={animate:!0,cssClass:"is-dropdown",offsetTop:0,minWidthElement:null,popupTip:!1,width:"auto",closeOnClickOutside:!0,widgetDocument:null},u=$.extend({},DropdownPanelDefaults,t),typeof n=="string"?(c=i(n),n=$("#"+c)):c=$(n).attr("id"),a=$(n),a.length==0){console.warn("userinterface.DropdownPanel: Attached Element '"+c+"' not found.");return}if(e=$(a[0]),u.widgetDocument?(o=u.widgetDocument,f=u.widgetDocument.parentWindow||u.widgetDocument.defaultView):(o=document,f=window),u.popupTip?(r=$("<div style='display:none; position:absolute; z-index:999999999999' class='"+u.cssClass+"' controlType='dropdownPanel'><\/div>"),e.append(r)):(r=$("<div style='display:none; position:fixed; z-index:999999999999' class='"+u.cssClass+"' controlType='dropdownPanel'><\/div>"),e.after(r)),v={TypeName:"DropdownPanel",Append:y,AttachedElement:p,Clear:w,Element:b,Hide:d,Show:k,Visible:g,WidthResizeFromParent:tt,CloseOnClickOutside:nt},f.__ISDropdownHandler)for(l=0;l<f.__ISDropdownHandler.length;l++)h=f.__ISDropdownHandler[l],h!=undefined&&(n=h.AttachedElement(),$.contains(o,n[0])||(h.Element().remove(),delete h));return f.__ISDropdownHandler||(f.__ISDropdownHandler=[],$(f).bind("resize scroll",function(){var n,t;if(!$Runtime.IsPlatformIOS())for(n=0;n<f.__ISDropdownHandler.length;n++)t=f.__ISDropdownHandler[n],t!=undefined&&t.CloseOnClickOutside()&&t.Hide()}),$(o).bind("click",function(n){for(var t,i=0;i<f.__ISDropdownHandler.length;i++)t=f.__ISDropdownHandler[i],t!=undefined&&t.CloseOnClickOutside()&&(t.AttachedElement()[0]===n.target||t.AttachedElement().has(n.target).length==0&&t.Element().has(n.target).length==0&&t.Hide())}),$(document).bind("focusout focusin",function(){var t,n;switch(o.activeElement.tagName){case"BUTTON":case"INPUT":for(t=0;t<f.__ISDropdownHandler.length;t++)n=f.__ISDropdownHandler[t],n!=undefined&&n.AttachedElement().has(o.activeElement).length==0&&n.Element().has(o.activeElement).length==0&&n.Hide()}})),f.__ISDropdownHandler.push(v),v}function vr(n,t){function s(){r.html||r.text?f.addClass("is-tooltip"):f.removeClass("is-tooltip")}function h(){u.Hide()}function c(){u.Clear();r.html?u.Append("<span>"+r.html+"<\/span>"):u.Append("<span>"+$Runtime.HtmlEncode(r.text)+"<\/span>");u.Show()}function l(n){if(n===undefined)return r.html;r.html=n;r.text="";s()}function v(n){if(n===undefined)return r.text;r.text=n;r.html="";s()}var f,u,r,e,o;if(PopupTipDefaults={closeOnClickOutside:!1,text:"",html:""},r=$.extend({},PopupTipDefaults,t),typeof n=="string"?(e=i(n),n=$("#"+e)):e=$(n).attr("id"),o=$(n),o.length==0){console.warn("userinterface.PopupTip: Attached Element '"+e+"' not found.");return}return f=$(o[0]),u=new a(f,{cssClass:"is-tooltip"}),s(),f.bind("click",function(){(r.html||r.text)&&(u.Visible()?h():c())}),u.Element().bind("click",function(n){$(n.target).prop("tagName")==="A"&&u.Visible()&&h()}),{TypeName:"PopupTip",Html:l,Text:v,Hide:h,Show:c}}function yr(n){function h(){i.focus()}function c(){var t,n,e;i.children().remove();t=$("<div><\/div>");(r.caption||r.showCloseButton)&&(n=$("<div class='caption is-no-select'><\/div>"),r.captionHtml?n.html(r.captionHtml):n.text(r.caption),r.showCloseButton&&(e=$("<a><span class='is-symbol-close'><\/span><\/a>"),e.click(function(){u(!0)}),n.append(e)),i.append(n),t.addClass("hascaption"));f&&t.append(f);i.append(t)}function l(n){e?u():s(n)}function s(n){e||(n||(n={}),t=n.sourceButtonElement,o=n.closeFocusElement,r.caption=n.caption,f=n.contentElement,r.onKeyDown=n.onKeyDown,t,t&&(t.addClass("active"),!t||!$UI.AlwaysUsePickerControls()||t.prop("ownerDocument")===document||(t.css("background-color",ut),t.css("color","white"),window.setTimeout(function(){$(t.prop("ownerDocument")).on("click.widgetsidepanel",function(){u()})},10))),c(),n.context?i.addClass(n.context):i.removeClass("calendar"),e=!0,i.show(),i.focus())}function u(n){t&&t.removeClass("active");n&&o&&($Runtime.IsMobileBrowser()||o.Focus());f&&(f.detach(),f=null);o=null;!t||!$UI.AlwaysUsePickerControls()||t.prop("ownerDocument")===document||(t.css("background-color",""),t.css("color",""),$(t.prop("ownerDocument")).off("click.widgetsidepanel"));e=!1;i.hide()}var o,f,i,t,e=!1,r;PickerPanelDefaults={caption:"",captionHtml:"",autoClose:!0,autoCloseIgnoreElements:null,showCloseButton:!0,onClose:null,onKeyDown:null};r=$.extend({},PickerPanelDefaults,n);i=$("<div class='is-picker-panel is-no-select'><\/div>");$("body").append(i);i.attr("tabindex","-1");i.on("contextmenu",function(){return!1});if(r.autoClose)i.on("mousedownoutside",function(n){e&&($(n.target).hasClass("active")||u())});return i.bind("keydown",function(n){switch(n.keyCode){case 27:u(!0);break;case 13:u(!0);break;default:if(r.onKeyDown)r.onKeyDown(n)}}),{TypeName:"PickerPanel",Focus:h,Show:s,Hide:u,Toggle:l}}function pr(){function u(n,i,u){var u=$.extend({},GetPasswordDefaults,u),e,o,s,f;console.log("$UI.CommonDialog().GetPassword - Begin");e={};u.reAuthenticate?(e.formKey="_REAUTHENTICATE",e.width=480,e.height="80%",$Runtime.IsMobileBrowser()||(e.maxHeight=400),e.title="",e.specialCssClass="reauthenticate",u.message="",e.allowCloseWithoutWarning=!0,o=new t.Modal(e),o.Actions().Define([{groupId:"[buttons]",actionId:"Cancel",caption:"Return to Sign In Form"},{groupId:"[buttons]",actionId:"Ok",caption:"Sign In Again"},])):(e.formKey=u.formKey,e.width=320,e.height="280px",e.title=n,o=new t.Modal(e),o.Actions().Define([{groupId:"[buttons]",actionId:"Ok",caption:"OK"},{groupId:"[buttons]",actionId:"Cancel",caption:"Cancel"}]));t.CreateContextSet(o);u.reAuthenticate&&$("body > div").addClass("blur");o.Show({content:f});s=$Runtime.CreateGuid(!0);f="";u.reAuthenticate?(f+="<div class='is-form reauthenticate' style='position:absolute; top:0; left:0; right:0; bottom:0; height:100%; width:100%'>",f+="<form action='xxx' autocomplete='off' id='"+s+"' style='padding:0;margin:0'>",f+="<table class='is-form' style='position:absolute; top:0; left:0; right:0; bottom:0; height:100%; width:100%'>",f+="<tr><td style='text-align:center; vertical-align:middle; padding-bottom:40px;'>",f+="<div class='reauthenticate-icon'><img src='"+r("Clock",64)+"'/><\/div>",f+=u.potentialExpiry?"<h1>You have been signed out due to inactivity!<\/h1><p>Please re-enter your password below.<\/p>":"<h1>You have been signed out due to inactivity!<\/h1><p>Alternatively, you may have been attempting to access a resource that you are not authorised for.<\/p><p>Please re-enter your password below.<\/p>",f+="<input name='username' value='"+$Runtime.HtmlEncode($App.UserId())+"' readonly='readonly' style='display:none'/>",f+="<input type='password' name='a-fake-password-for-chrome' style='display:none'/><input id='txtPassword"+s+"' name='xxx"+s+"' value='' placeholder='Password'/>",f+="<\/td><\/tr>",f+="<\/table>",f+="<\/form>",f+="<\/div>"):(f+="<div class='is-form'>",f+="<form action='xxx' autocomplete='off' id='"+s+"' style='padding:0;margin:0'>",f+="<table class='is-form'>",f+="<tr><td><label id='lblPassword'>Enter Password<\/label><\/td><\/tr>",u.message&&(f+="<tr><td style='padding-bottom:8px'><label id='lblMessage'><\/label><\/td><\/tr>"),f+="<tr>",f+="<td><input type='password' name='a-fake-password-for-chrome' style='display:none'/><input id='txtPassword"+s+"' name='xxx"+s+"' value='' placeholder='Password'/><\/td>",f+="<\/tr>",f+="<\/table>",f+="<\/form>",f+="<\/div>");o.RenderView(f);u.reAuthenticate||(lblPassword=new t.Label("lblPassword",{}));txtPassword=new t.TextBox("txtPassword"+s,{password:!0,allowBlank:!1,maxLength:50,width:u.reAuthenticate?"80%":"100%",onEnterKey:function(){o.ExecuteAction("Ok")}});u.message&&(lblMessage=new t.Label("lblMessage",{text:u.message,style:"normal"}));txtPassword.Focus();t.CreateContextClear();o.OnAction(function(n){switch(n.toUpperCase()){case"CANCEL":u.reAuthenticate?$App.Actions.Execute("SIGNOUT"):o.Hide(!0);break;case"OK":txtPassword.Text()?(o.Close(),i(txtPassword.Text())):txtPassword.Focus()}});console.log("$UI.CommonDialog().GetPassword - End")}function f(n,i,r,u,f){var f=$.extend({},GetInputDefaults,f),o,e,h,s;console.log("$UI.CommonDialog().GetInput - Begin");o=new t.Modal({width:480,height:"240px",title:n,formKey:f.formKey});o.Actions().Define([{groupId:"[buttons]",actionId:"Ok",caption:f.okCaption},{groupId:"[buttons]",actionId:"Cancel",caption:"Cancel"}]);t.CreateContextSet(o);o.Show({content:""});e="";e+="<div class='is-form'>";e+="<table class='is-form'>";e+="<colgroup><col style='width:3em' /><col /><\/colgroup>";e+="<tr><th colspan='2'><label id='lblHeading'>"+$Runtime.HtmlEncode(i)+"<\/label><\/th><\/tr>";e+="<tr>";e+="<th><label for='txtInput'><nobr>"+$Runtime.HtmlEncode(r)+":<\/nobr>&nbsp;<\/label><\/th>";e+="<td><input id='txtInput'/><\/td>";e+="<\/tr>";f.message&&(e+="<tr><th colspan='2'><label id='lblMessage'>"+$Runtime.HtmlEncode(f.message)+"<\/label><\/th><\/tr>");e+="<\/table>";e+="<\/div>";o.RenderView(e);h=new t.Label("lblHeading",{});s=new t.TextBox("txtInput",{allowBlank:!1,maxLength:f.maxLength,width:"100%",onEnterKey:function(){o.ExecuteAction("Ok")}});f.defaultValue&&s.Text(f.defaultValue);f.message&&(lblMessage=new t.Label("lblMessage",{style:"Information"}));s.Focus();(f.selStart!==0||f.selLength!==0)&&s.SetSelection(f.selStart,f.selLength);t.CreateContextClear();o.OnAction(function(n){switch(n.toUpperCase()){case"CANCEL":o.Hide(!0);break;case"OK":s.Text()?(o.Close(),u(s.Text())):s.Focus()}});console.log("$UI.CommonDialog().GetInput - End")}function e(r,u,f){var f,e;if(!ct(!0))return f=$.extend({},ShowHtmlDefaults,f),console.log("$UI.CommonDialog().ShowHtml - Begin"),f.height||(f.height=f.popup?"480px":"90%"),f.width||(f.width=f.popup?"480px":"90%"),e=new t.Modal({formType:"HtmlViewer",width:f.width,maxWidth:f.maxWidth,minWidth:f.minWidth,allowMinimise:n.length==0,height:f.height,maxHeight:f.maxHeight,minHeight:f.minHeight,title:r,formKey:f.formKey,appShortcutUrl:f.appShortcutUrl,onAfterClose:f.onAfterClose,parentModal:f.parentModal}),e.Show({content:""}),f.showWait?(e.ContentElement().children().remove(),e.ContentElement().append("<div class='is-wait-block'><div class='is-wait'><div class='is-wait1'><\/div><div class='is-wait2'><\/div><div class='is-wait3'><\/div><\/div><label>Please wait...<\/label><\/div>")):i(u,e,f),e.UpdateHtml=function(n){i(n,e,f)},e}function i(n,t,i){var e=!1,f=!1,o=n.toUpperCase(),u,r;if(o.indexOf("<HTML")==-1)switch(i.popupStyle.toUpperCase()){case"":o.indexOf('<DIV CLASS="IS-SUMMARYPAGE-2"')!=-1||o.indexOf("IS-SUMMARYPAGE-BLOCKS")!=-1||(n="<div class='is-summarypage-2'>"+n+"<\/div>");break;case"NOTE":n="<div style='position:absolute;left:0;top:0;right:0;bottom:0;overflow:auto;-webkit-overflow-scrolling:touch;background-color:#FFF5A1'><div style='padding:8px'>"+n+"<\/div><\/div>"}else e=!0,f=!0;f=f||i.forceIFrame;f?(t.ContentElement().children().remove(),u=$("<iframe style='position:absolute;width:100%;height:100%;border:0'/>"),t.ContentElement().append(u),!0&&n.indexOf("is-summarypage-blocks")!=-1&&u.css({"background-color":"#808080"}),r=u[0].contentDocument,r.open(),e||(r.write("<!doctype html>"),r.write("<html>"),r.write("<head>"),r.write("<link rel='stylesheet' type='text/css' href='"+$Runtime.WebRoot()+"Content/SummaryPage2/summarypage_2.css'><\/link>"),r.write("<link rel='stylesheet' type='text/css' href='"+$Runtime.WebRoot()+"Content/SummaryPage2/summarypage_2_web.css'><\/link>"),r.write("<\/head>"),r.write("<body style='margin:0;padding:0'>")),r.write(n),e||(r.write("<\/body>"),r.write("<\/html>")),r.close(),window.$Ash?$Ash.HandleIframe(u[0]):window.alert("Show HTML cannot handle Application Shortcuts since no handler ($Ash) is available.")):t.ContentElement().html(n)}return GetPasswordDefaults={formKey:"",message:"",reAuthenticate:!1},GetInputDefaults={defaultValue:"",formKey:"",message:"",maxLength:0,multiLine:!1,okCaption:"OK",selStart:0,selLength:0},ShowHtmlDefaults={height:"",width:"",maxWidth:"1024px",popup:!1,popupStyle:"",showWait:!1,forceWindowed:!0,appShortcutUrl:"",onAfterClose:null},{GetInput:f,GetPassword:u,ShowHtml:e}}function wr(n,t){function c(){r.visible?i.Visible(!0):i.Visible(!1)}function l(n){o=null;e=n;f="";u&&u.hide();s&&window.clearInterval(s);s=window.setInterval(function(){i.Text()!=f&&h(i.Text())},200);i.ReadOnly(!1)}function a(n){l($("table",n.Element()));o=n}function v(){h(f)}function h(n){var s,t,i,a,v,h,c,y,p,l,w,b;if(f=n,mFilteredOutCount=0,r.restrictToTbody?$("tbody > tr",e).removeClass("is-filtered-out is-filtered-in"):$("tr",e).removeClass("is-filtered-out is-filtered-in"),u&&u.hide(),f){if(s=f.toUpperCase().split(" "),s.length>0)for(t=r.restrictToTbody?$("tbody > tr",e):$("tr",e),i=0;i<t.length;i++){for(a=t[i],v=!0,h=0;h<s.length;h++){if(c=s[h],y=!1,p=r.restrictToTbody?$("td",a):$("td,th",a),c&&c!=" ")for(l=0;l<p.length;l++)if(w=$(p[l]).text(),w&&w.toUpperCase().indexOf(c)!=-1){y=!0;break}if(!y){v=!1;break}}v?r.applyFilteredInClass&&$(t[i]).addClass("is-filtered-in"):(mFilteredOutCount+=1,$(t[i]).addClass("is-filtered-out"))}u&&(b=u.text($Runtime.FormatNumber(t.length-mFilteredOutCount,0)+" of "+$Runtime.FormatNumber(t.length,0)),u.show())}r.onFilterApplied&&r.onFilterApplied();o&&o.NotifyTableFilterApplied()}function y(){return mFilteredOutCount}function p(n){if(n===undefined)return r.visible;r.visible=n;c()}var u,e,f,o,i,s,r;return TableFilterTextBoxDefaults={autoReadOnly:!1,maxLength:20,blankTip:"Type to filter list",restrictToTbody:!0,showFilterCount:!0,applyFilteredInClass:!1,visible:!0,onFilterApplied:null},r=$.extend({},TableFilterTextBoxDefaults,t),r.readOnly=!0,i=$UI.TextBox(n,t),r.showFilterCount&&(u=$("<div class='is-table-filter-count' style='display:none'><\/div>"),u.click(function(){i.Focus();i.Text("");h(i.Text())}),i.Element().after(u),i.Element().addClass("is-has-table-filter-count")),c(),_self={TypeName:"TableFilterTextBox",Initialise:l,InitialiseGrid:a,FilteredOutCount:y,AutoReadOnly:i.AutoReadOnly,BlankTip:i.BlankTip,Element:i.Element,Focus:i.Focus,HasFocus:i.HasFocus,ReadOnly:i.ReadOnly,ReapplyFilter:v,Text:i.Text,Visible:p,VisibleRow:i.VisibleRow,WidthResizeFromParent:i.WidthResizeFromParent}}var u={},v="",w=null,l=null,g=null,rt=0,h=0,n=[],f=[],nt,tt,o=null,s=null,ut="green",b=!1,ft=!0,t;return navigator.appVersion.indexOf("MSIE")!=-1?b=!0:navigator.appVersion.indexOf("Trident/")!=-1&&(b=!0),b&&(ft=!1),window.devicePixelRatio&&window.devicePixelRatio>1.25&&$("html").addClass("is-highdpi"),b?$("html").addClass("browser-ie"):/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream&&$("html").addClass("browser-ios"),MsgBoxDefaults={title:null,maxWidth:null,maxHeight:null,minWidth:null,minHeight:null,heading:null,icon:null,messageIsHtml:!1,captionOk:null,captionCancel:null},t={ActionsCollection:it,CreateContextClear:d,CreateContextSet:k,CurrentModalExecuteAction:fi,GetElement:y,jQuerySelect:et,CommonDialog:pr,DropdownPanel:a,PickerPanel:yr,FormDisable:oi,FormEnable:si,FilterElements:kt,Initialise:wt,GetFilesForUpload:bi,MsgBoxAlert:p,MsgBoxConfirm:yt,MsgBoxConfirmDelete:ci,MsgBoxInfo:li,MsgBoxList:ai,SelectFlagColour:yi,SelectUser:pi,Modal:lr,ModalExists:ii,ModalMinimise:st,ModalUnminimise:ht,HasMinimisedModal:ct,ModalOpenCount:ri,ModalOpenCountUnsavedData:ui,NonModal:ar,FindParentModal:gt,FixSectionHeadingGaps:dt,GetFormByModalId:ot,GetModalByFormKey:ti,ExecuteNotificationAction:lt,NotifyBookmarkedStateChanged:ei,Button:tr,CheckBox:or,CheckList:sr,ComboBox:ir,DBCombo:ur,FileBox:cr,Label:hr,ListBox:rr,NumberBox:fr,PopupTip:vr,Tabs:er,TextBox:pt,TableFilterTextBox:wr,ShowAjaxError:vi,ValidateContainer:wi,WaitShow:di,WaitHide:nr,WaitUpdate:gi,GetIconUrl:r,HandleContextMenuEvent:ni,AlwaysUsePickerControls:at,ExtUtils:{TranslateElementId:i},SharedPickerPanel:c,SupportsStickyHeaders:ft,RealignLayouts:bt}}();console.log("  $UI: "+typeof $UI),function(n,t,i){function r(r,u){function o(t){n(f).each(function(){var i=n(this);this===t.target||i.has(t.target).length||i.triggerHandler(u,[t.target])})}u=u||r+i;var f=n(),e=r+"."+u+"-special-event";n.event.special[u]={setup:function(){f=f.add(this);f.length===1&&n(t).bind(e,o)},teardown:function(){f=f.not(this);f.length===0&&n(t).unbind(e)},add:function(n){var t=n.handler;n.handler=function(n,i){n.target=i;t.apply(this,arguments)}}}}n.map("click dblclick mousemove mousedown mouseup mouseover mouseout change select submit keydown keypress keyup".split(" "),function(n){r(n)});r("focusin","focus"+i);r("focusout","blur"+i);n.addOutsideEvent=r}(jQuery,document,"outside"),function(n){n.fn.ScrollElementIntoView=function(t,i,r){var u=n.extend({},{instant:!1,duration:null,step:null,inViewAmount:0},r),f;if(t==!0&&(u.instant=!0),u.complete&&window.alert("ScrollElementIntoView: o.complete not yet implemented!"),f=this,f.length==0){console.warn("ScrollElementIntoView has not been passed an element.");return}if(f.length!=1){console.warn("ScrollElementIntoView is designed only to work on a single element.");return}return setTimeout(function(){for(var i=f[0].offsetTop,s=f[0].offsetHeight,t=n(f[0].parentElement),r,e,o;t.length!=0;){if(t[0].tagName=="BODY")break;if(t[0].tagName=="DIV"&&t[0].scrollHeight>n(t[0]).height())break;if(t[0].tagName=="DIV"&&(r=n(t[0]).css("overflow").toUpperCase(),r=="AUTO"||r=="SCROLL"))break;t=n(t[0].parentElement)}t.length==1&&(e=t.height(),o=t[0].scrollTop,u.instant&&t.stop(!0,!0),i-u.inViewAmount<o?t.animate({scrollTop:i-u.inViewAmount},u):i+s+u.inViewAmount>o+e&&t.animate({scrollTop:i-e+s},u))},10),this}}(jQuery);console.log("Loading lib/isuserinterface_dates.js");__UIExtDates=function(n){return n.DateBox=function(t,i){function b(){r.cssClass&&u.addClass(r.cssClass);r.allowBlank?(u.removeClass("is-mandatory"),o&&o.removeClass("is-mandatory")):(u.addClass("is-mandatory"),o&&o.addClass("is-mandatory"));r.readOnly?(u.addClass("is-readonly"),u.attr("readonly","readonly"),h.hide(),f&&(f.addClass("is-readonly"),f.attr("readonly","readonly"))):(u.removeClass("is-readonly"),u.removeAttr("readonly"),h.show(),h.css("display","inline-block"),f&&(f.removeClass("is-readonly"),f.removeAttr("readonly","readonly")));r.autoReadOnly?(u.attr("autoreadonly","true"),f&&f.attr("autoreadonly","true")):(u.removeAttr("autoreadonly"),f&&f.removeAttr("autoreadonly"));u.attr("maxLength",r.maxLength==0?"":r.maxLength);r.width!="auto"&&u.css({width:r.width});u.attr("spellcheck","false");r.showWeekDayName?v.show():v.hide();ft?(a.css({display:"none"}),u.removeClass("is-invalid")):(u.addClass("is-invalid"),d?(et?a.html(d):a.text(d),a.css({display:"inline-block"})):a.css({display:"none"}));r.visible?(s.show(),f&&f.show()):(s.hide(),f&&f.hide())}function vt(){var i,t;l||(i=$("<div><\/div>"),l=new n.Calendar(i,{onChange:function(t,i){var u=i.CloseDropdown||i.CloseDropdown==undefined;l.Value()?it($Runtime.FormatDate(l.Value(),!1,!1,!1)):it("");r.usePicker||u&&lt(!0);st()&&ht();r.usePicker&&n.SharedPickerPanel().Hide(!0)}}),r.usePicker||k.Append(l.Element()));r.usePicker?(t=r.pickerCaption,!t&&o&&(t=o.text(),t&&(t="Select "+t,t.endsWith(":")&&(t=t.substr(0,t.length-1)))),t||(t="Select Date"),n.SharedPickerPanel().Toggle({closeFocusElement:tt,sourceButtonElement:h,caption:t,contentElement:l.Element(),context:"calendar"})):(k.Show(310,!1),u.focus(),u.select());e==null&&u[0].value&&it(u[0].value);l.Value(e);l.GotoValue()}function lt(t){r.usePicker?n.SharedPickerPanel().Hide():(k.Hide(),t&&(u.focus(),u.select()))}function it(n){r.readOnly||(e=n==""?null:$Runtime.ParseDate(n,r.historic,!r.valueIsUtc));ot()}function ot(){ut?u[0].valueAsDate=e:u.val($Runtime.FormatDate(e,!1,!1,!r.valueIsUtc));r.showWeekDayName&&(e?v.text($Runtime.GetWeekDayNameFromDate(e)):v.text(""))}function yt(n){n!=r.allowBlank&&(r.allowBlank=n==!0,b())}function pt(n){if(n==undefined)return o?o.text():"";o&&o.text(n)}function st(){return $Runtime.FormatDate(e)!=$Runtime.FormatDate(g)}function ht(){var n={ChangeHandled:!1,ValueOriginal:g};if(f&&(n.TimeValueOriginal=$Runtime.ParseTime(nt,!0)),r.onChange)r.onChange(tt,n);n.ChangeHandled&&(g=e,f&&(nt=f.val()))}function wt(){return u}function bt(){u.focus();u.select()}function kt(n){if(n==undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,b())}function dt(n){if(n==undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,b())}function ct(n){var t,i;if(n===undefined)return t=e,t&&f&&(i=$Runtime.ParseTime(f.val(),!0),i?t.setUTCHours(i.getUTCHours(),i.getUTCMinutes(),i.getUTCSeconds(),0):t.setUTCHours(0,0,0,0)),t;e=typeof n=="string"?$Runtime.ParseJsonDate(n):n;ot();f&&(f.val($Runtime.FormatTime(e,!0,!0)),e=$Runtime.ParseDate(u.val()));g=e}function gt(){return e?e.toISOString():""}function ni(n){if(n==undefined)return r.maxValue;r.maxValue=n}function ti(n){if(n==undefined)return r.minValue;r.minValue=n}function ii(n){if(n==undefined)return r.visible;r.visible=n;b()}function ri(n){if(!c&&(c=u.closest("tr"),c.length==0))return console.warn("ComboBox.VisibleRow: no parent row element found."),c=null,!1;if(n==undefined)return c.css("visibility").toUpperCase()=="HIDDEN";n?(c.css("display","table-row"),c.css("visibility","")):(c.css("display","none"),c.css("visibility","hidden"))}function at(n){var i,t,u;s.hide();i=s.parent().innerWidth();s.show();t=r.width;u="";n&&(t="100%")}function ui(){return ft?!0:!1}function fi(){var n=!0,t;return!r.allowBlank&&!ct()?(rt(!0,"",!1),!1):(typeof r.minValue=="string"&&(r.minValue=$Runtime.ParseJsonDate(r.minValue)),typeof r.maxValue=="string"&&(r.maxValue=$Runtime.ParseJsonDate(r.maxValue)),(r.minValue!=null||r.maxValue!=null)&&(t=ct(),n&&r.minValue!=null&&t<r.minValue&&(n=!1),n&&r.maxValue!=null&&t>r.maxValue&&(n=!1)),n?rt(!0,"",!1):rt(!1,"Valid range "+ei(),!1),n)}function ei(){var n="";return r.minValue!=null&&(n+=$Runtime.FormatDate(r.minValue)),r.maxValue!=null&&(n&&(n+=" "),n+="to "+$Runtime.FormatDate(r.maxValue)),n}function rt(n,t,i){ft=n;d=t==undefined?"":t;et=i==undefined?!1:i;b()}function oi(n){r.onChange=n}var h,l,v,k,u,c,f,y=!1,ut=!1,ft=!0,o,r,a,d="",et=!1,e=null,g=null,nt="",s,p,w,tt;if(DateBoxDefaults={captionElement:"auto",cssClass:"is-datebox",allowBlank:!0,allowTime:!1,historic:!1,valueIsUtc:!1,maxValue:null,minValue:null,readOnly:!1,autoReadOnly:!0,showWeekDayName:!1,width:"auto",visible:!0,onChange:null,usePicker:!1,pickerCaption:"",widgetDocument:null},r=$.extend({},DateBoxDefaults,i),n.AlwaysUsePickerControls()&&(r.usePicker=!0),typeof t=="string"?(p=n.ExtUtils.TranslateElementId(t),t=$("#"+p)):p=$(t).attr("id"),w=$(t),w.length==0){console.warn("userinterface.DateBox: Element '"+p+"' not found.");return}return u=$(w[0]),u[0].tagName!="INPUT"&&console.warn("userinterface.DateBox: Element '"+p+"' must be an INPUT type Element."),u.wrap("<span style='display:inline-block; padding:0; position:relative; margin:0' controlType='datebox'/>"),s=$(u.parent()),h=$("<button type='button' tabindex='-1' class='is-combobox-button' style='position:absolute; margin-left:-20px'/>"),r.usePicker&&h.addClass("is-picker"),s.append(h),r.allowTime&&(f=$("<input class='is-timebox' style='display:inline-block;width:6em;margin-left:4px;text-align:right' placeholder='Time'/>"),s.append(f)),a=$("<label style='display:none' class='is-validation-tip'><\/label>"),s.append(a),k=new n.DropdownPanel(s,{minWidthElement:u,widgetDocument:r.widgetDocument}),v=$("<label class='is-combobox' style='display:none'><\/label>"),v.insertAfter(h),u.attr("autocomplete","off"),u.attr("spellcheck","false"),w=$("label[for='"+p+"']"),o=w.length==0?null:$(w[0]),b(),r.width=="auto"&&at(),ut?(u.blur(function(){y=!1}),u.focus(function(){y=!0})):(u.blur(function(){y=!1}),u.focus(function(){y=!0})),u.blur(function(){r.readOnly||(ut?e=u[0].valueAsDate:it(u.val()));st()&&ht();g=e;ot()}),h.bind("click",function(){r.readOnly||(k.Visible()?lt(!0):vt())}),f&&(f.focus(function(){y=!0;nt=f.val()}),f.blur(function(){if(y=!1,!r.readOnly){var n=$Runtime.ParseTime(f.val(),!0);f.val($Runtime.FormatTime(n,!0,!0));nt!==f.val()&&ht();nt=f.val()}})),tt={TypeName:"DateBox",AllowBlank:yt,AutoReadOnly:dt,Caption:pt,Changed:st,Element:wt,Focus:bt,MaxValue:ni,MinValue:ti,ReadOnly:kt,Value:ct,ValueAsISOString:gt,Visible:ii,VisibleRow:ri,WidthResizeFromParent:at,IsValid:ui,Validate:fi,ValidationSet:rt,OnChange:oi},u.prop("is-control",tt),tt},n.TimeBox=function(t,i){function l(){r.cssClass&&u.addClass(r.cssClass);r.allowBlank?(u.removeClass("is-mandatory"),f&&f.removeClass("is-mandatory")):(u.addClass("is-mandatory"),f&&f.addClass("is-mandatory"));r.readOnly?(u.addClass("is-readonly"),u.attr("readonly","readonly"),s.hide()):(u.removeClass("is-readonly"),u.removeAttr("readonly"),s.show());r.autoReadOnly?u.attr("autoreadonly","true"):u.removeAttr("autoreadonly");u.attr("maxLength",r.maxLength==0?"":r.maxLength);r.width!="auto"&&u.css({width:r.width});u.attr("spellcheck","false");k?(h.css({display:"none"}),u.removeClass("is-invalid")):(u.addClass("is-invalid"),y?(d?h.html(y):h.text(y),h.css({display:"inline-block"})):h.css({display:"none"}));r.visible?o.show():o.hide();b}function ot(){var h,i,e,o,t;if(!v){for(h="<ul>",h+=r.usePicker?"<li class='is-selectable' style='text-align:right; font-weight:bold' h='*' m='0'>Current&nbsp;Time<\/li>":"<li class='is-selectable' style='text-align:right; font-weight:bold' h='*' m='0'>Current<\/li>",i=0;i<24;i++)e="",o="",i<13?(e=i,o=i):(e=i-12,o=i-12),e+=":00 ",o+=":30 ",i>=12?(e+=" p.m.",o+=" p.m."):(e+=" a.m.",o+=" a.m."),h+="<li class='is-selectable' style='text-align:right' h='"+i+"' m='0'>"+e+"<\/li>",h+="<li class='is-selectable' style='text-align:right' h='"+i+"' m='30'>"+o+"<\/li>";h+="<\/ul>";v=$(h);$("li",v).bind("click",function(){var i=$(this).attr("h"),u=$(this).attr("m"),t;i=="*"?(t=new Date,tt(new Date(Date.UTC(2e3,1,1,parseInt(t.getHours()),parseInt(t.getMinutes()),0,0)))):tt(new Date(Date.UTC(2e3,1,1,parseInt(i),parseInt(u),0,0)));r.usePicker||rt(!0);ft(!0);r.usePicker&&n.SharedPickerPanel().Hide(!0)});r.usePicker||a.Append(v)}r.usePicker?(t=r.pickerCaption,!t&&f&&(t=f.text(),t&&(t="Select "+t,t.endsWith(":")&&(t=t.substr(0,t.length-1)))),t||(t="Select Time"),n.SharedPickerPanel().Toggle({closeFocusElement:it,sourceButtonElement:s,caption:t,contentElement:v,context:"calendar"})):(a.Show(),u.focus(),u.select())}function rt(t){r.usePicker?n.SharedPickerPanel().Hide():(a.Hide(),t&&(u.focus(),u.select()))}function st(n){r.readOnly||(e=n==""?null:$Runtime.ParseTime(n,!r.valueIsUtc));nt()}function nt(){b?u[0].valueAsDate=e:u.val($Runtime.FormatTime(e,!0,!r.valueIsUtc))}function ht(n){n!=r.allowBlank&&(r.allowBlank=n==!0,l())}function ct(n){if(n==undefined)return f?f.text():"";f&&f.text(n)}function ut(){return!(e==g)}function ft(){var n={ChangeHandled:!1,ValueOriginal:g};if(r.onChange)r.onChange(it,n);n.ChangeHandled&&(mTextOriginal=u.val())}function lt(){return u}function at(){u.focus();u.select()}function vt(n){if(n==undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,l())}function yt(n){if(n==undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,l())}function tt(n){if(n===undefined)return e;e=typeof n=="string"?$Runtime.ParseJsonDate(n):n;nt()}function pt(n){if(n==undefined)return r.visible;r.visible=n;l()}function et(n){var i,t,u;o.hide();i=o.parent().innerWidth();o.show();t=r.width;u="";n&&(t="100%")}function wt(){return k?!0:!1}function bt(n,t,i){k=n;y=t==undefined?"":t;d=i==undefined?!1:i;l()}var s,a,u,w=!1,b=!1,k=!0,f,v,h,y="",d=!1,e=null,g=null,o,r,p,c,it;if(TimeBoxDefaults={captionElement:"auto",cssClass:"is-timebox",allowBlank:!0,historic:!1,valueIsUtc:!1,maxValue:null,minValue:null,readOnly:!1,autoReadOnly:!0,width:"auto",visible:!0,onChange:null,usePicker:!1,pickerCaption:""},r=$.extend({},TimeBoxDefaults,i),n.AlwaysUsePickerControls()&&(r.usePicker=!0),typeof t=="string"?(p=n.ExtUtils.TranslateElementId(t),t=$("#"+p)):p=$(t).attr("id"),c=$(t),c.length==0){console.warn("userinterface.TimeBox: Element '"+p+"' not found.");return}return u=$(c[0]),u.wrap("<span style='display:inline-block; padding:0; position:relative; margin:0' controlType='timebox'/>"),o=$(u.parent()),s=$("<button type='button' tabindex='-1' class='is-combobox-button' style='position:absolute; right:0'/>"),o.append(s),n.AlwaysUsePickerControls()&&s.addClass("always-use-pickers"),a=new n.DropdownPanel(o,{minWidthElement:u}),u.attr("autocomplete","off"),u.attr("spellcheck","false"),h=$("<label style='display:none' class='is-validation-tip'><\/label>"),o.append(h),c=$("label[for='"+p+"']"),f=c.length==0?null:$(c[0]),l(),r.width=="auto"&&et(),b?(u.blur(function(){w=!1}),u.focus(function(){w=!0})):(u.blur(function(){w=!1}),u.focus(function(){w=!0})),u.blur(function(){r.readOnly||(b?e=u[0].valueAsDate:st(u.val()));ut()&&ft();g=e;nt()}),s.bind("click",function(){r.readOnly||(a.Visible()?rt(!0):ot())}),it={TypeName:"TimeBox",AllowBlank:ht,AutoReadOnly:yt,Caption:ct,Changed:ut,Element:lt,Focus:at,ReadOnly:vt,Value:tt,Visible:pt,WidthResizeFromParent:et,IsValid:wt,ValidationSet:bt,WrapperElement:function(){return o}}},n.Calendar=function(t,i){function s(n){var g,rt,at,vt,ft,yt,pt,st,wt,bt,kt,ht,ui,fi,ei,ct,dt,b,gt,ni,ti,ii,ri,i,lt,t,v;if(n){for(ot=!0,u.children().remove(),g=$("<div class='is-calendar-header'><\/div>"),it=$("<div class='dayname'><\/div>"),rt=$("<div><\/div>"),at=$("<div class='left month' title='Back a month'/>"),p=$("<select class='month'><\/select>"),t=0;t<12;t++)p.append("<option>"+$Runtime.GetMonthName(t)+"<\/option>");for(vt=$("<div class='right month' title='Forward a month'/>"),rt.append(at),rt.append(p),rt.append(vt),ft=$("<div><\/div>"),yt=$("<div class='left day' title='Back a day'/>"),y=$("<select class='day'><\/select>"),t=1;t<32;t++)y.append("<option>"+t+"<\/option>");for(pt=$("<div class='right day' title='Forward a day'/>"),ft.append(yt),ft.append(y),ft.append(pt),st=$("<div><\/div>"),wt=$("<div class='left year' title='Back a year'/>"),w=$("<select class='year'><\/select>"),t=0;t<200;t++)w.append("<option>"+(1900+t)+"<\/option>");for(bt=$("<div class='right year' title='Forward a year'/>"),st.append(wt),st.append(w),st.append(bt),g.append(it),g.append(ft),g.append(rt),g.append(st),kt=$("<div class='is-calendar-body'><\/div>"),ht=$("<table style='width:100%'><thead><tr><\/tr><\/thead><tbody><\/tbody><\/table>"),kt.append(ht),ui=$(">thead>tr",ht),b=0;b<7;b++)fi=$("<th>"+$Runtime.GetDayOfWeekName(b).substr(0,3)+"<\/th>"),ui.append(fi);for(ei=$(">tbody",ht),ct=0;ct<6;ct++){for(dt=$("<tr><\/tr>"),b=0;b<7;b++)tt[b+ct*7]=$("<td><\/td>"),dt.append(tt[b+ct*7]);ei.append(dt)}y.bind("change",function(){e=parseInt(y.val());l();u.focus();u.select()});w.bind("change",function(){o=parseInt(w.val());l();u.focus();u.select()});p.bind("change",function(){f=p[0].selectedIndex;l();u.focus();u.select()});wt.bind("click",function(){o-=1;l()});at.bind("click",function(){f-=1;f<0&&(f=11,o-=1);l()});yt.bind("click",function(){e-=1;e<1&&(e=31);l()});vt.bind("click",function(){f+=1;f>11&&(f=0,o+=1);l()});bt.bind("click",function(){o+=1;l()});pt.bind("click",function(){e+=1;e>31&&(e=1);l()});$("td",ht).bind("click",function(n){if(!c.readOnly){var i=parseInt($(n.delegateTarget).attr("dateOffset")),t=new Date(a.getFullYear(),a.getMonth(),a.getDate()+i);(r===null||r.valueOf()!=t.valueOf())&&(r=t,s(!1),k())}});h=$("<div class='is-calendar-footer'><\/div>");gt=$("<button>Clear<\/button>");gt.on("click",function(){nt(null);s(!1);k()});ni=$("<button>Today<\/button>");ni.on("click",function(){nt((new Date).Date());s(!1);d();k()});ti=$("<button>+Week<\/button>");ti.on("click",function(){r||(r=(new Date).Date());r=new Date(r.getFullYear(),r.getMonth(),r.getDate()+7);s(!1);d();u.focus();u.select();k(!1)});ii=$("<button>+Month<\/button>");ii.on("click",function(){r||(r=(new Date).Date());r=new Date(r.getFullYear(),r.getMonth()+1,r.getDate());s(!1);d();u.focus();u.select();k(!1)});ri=$("<button class='ok'>Done<\/button>");ri.on("click",function(){nt(new Date(o,f,e));s(!1);k()});h.append(gt);h.append(ni);h.append(ti);h.append(ii);h.append(ri);u.append(g);u.append(kt);u.append(h)}for(it.text($Runtime.GetDayOfWeekName(new Date(o,f,e).getDay())),w.val(o+""),p.val($Runtime.GetMonthName(f)),y.val(e),c.readOnly?h.hide():h.show(),a=new Date(o,f);a.getDay()!=0;)a.setDate(a.getDate()-1);for(i=new Date(a.valueOf()),lt=new Date,t=0;t<42;t++)v=tt[t],v.text(i.getDate()),v.attr("dateOffset",t),v.removeClass(),v.attr("title",null),c.readOnly||v.addClass("is-selectable"),i.getMonth()!=f&&v.addClass("notcurrent"),i.getFullYear()==lt.getFullYear()&&i.getMonth()==lt.getMonth()&&i.getDate()==lt.getDate()&&(v.addClass("today"),v.attr("title","Today")),r!=null&&i.getFullYear()==r.getFullYear()&&i.getMonth()==r.getMonth()&&i.getDate()==r.getDate()&&v.addClass("is-sel"),et[t]=i,i.setDate(i.getDate()+1);u.addClass("is-calendar");ut(y);ut(p);ut(w)}function ut(n){v||(v=$("<select style='position:fixed; left:-1000px; top:-1000px' tabindex='-1' />"),u.append(v));v.children().remove();v.append("<option>"+$Runtime.HtmlEncode(n.val())+"<\/option>");n.after(v);v.attr("class",n.attr("class"));var t=v.width()+4;t&&n.css("width",t+"px")}function l(){r=new Date(o,f,e);s(!1)}function k(n){var t={ChangeHandled:!1,ValueOriginal:b,CloseDropdown:n};if(c.onChange)c.onChange(ft,t);t.ChangeHandled&&(b=r?new Date(r.valueOf()):null)}function st(){return r!=b}function ht(){return u}function ct(){u.focus();u.select()}function d(){if(r instanceof Date)o=r.getFullYear(),f=r.getMonth(),e=r.getDate();else{var n=new Date;o=n.getFullYear();f=n.getMonth();e=n.getDate()}s()}function lt(n){if(n==undefined)return c.readOnly;n!=c.readOnly&&(c.readOnly=n==!0,s())}function nt(n){if(typeof n=="undefined")return r;n===null?(r=null,b=n):n instanceof Date?(r=n,b=n):console.warn("Attempted to set ISCalendar value to a value that is not a Date or null.");s();r!=null&&d()}var e=(new Date).getDate(),f=(new Date).getMonth(),o=(new Date).getFullYear(),a,et=new Array(42),u,tt=new Array(42),h,y,it,p,v,w,ot=!1,r,b,c,g,rt,ft;if(CalendarDefaults={width:"auto",readOnly:!1,autoReadOnly:!0,onChange:null},c=$.extend({},CalendarDefaults,i),r=$Runtime.ParseDate("Now",!1,!1),b=new Date(r.valueOf()),typeof t=="string"?(g=n.ExtUtils.TranslateElementId(t),t=$("#"+g)):g=$(t).attr("id"),rt=$(t),rt.length==0){console.warn("userinterface.Calendar: Element '"+g+"' not found.");return}return u=$(rt[0]),u.attr("tabindex","-1"),u.addClass("is-no-select"),s(!0),ft={Changed:st,Element:ht,Focus:ct,GotoValue:d,ReadOnly:lt,Value:nt}},n.DateTimeZone=function(t,i){function c(){if(r.allowBlank?f&&f.removeClass("is-mandatory"):f&&f.addClass("is-mandatory"),e.AllowBlank(r.allowBlank),o.AllowBlank(!0),e.ReadOnly(r.readOnly),e.AutoReadOnly(r.autoReadOnly),o.ReadOnly(r.readOnly),o.AutoReadOnly(r.autoReadOnly),u.ReadOnly(r.readOnly),u.AutoReadOnly(r.autoReadOnly),o.Visible(r.timeVisible),r.timeZoneVisible)if($App&&!$App.TimeZoneUse()){var n=tt();n&&$App.TimeZoneId()==n?(u.Visible(!1),v=!1):n?(u.Visible(!0),v=!0):(u.Visible(!1),v=!1)}else u.Visible(!0),v=!0;else u.Visible(!1),v=!1;u.WrapperElement().css("max-width","360px");b?(s.css({display:"none"}),l.removeClass("is-invalid")):(l.addClass("is-invalid"),y?(k?s.html(y):s.text(y),s.css({display:"inline-block"})):s.css({display:"none"}));r.visible?h.show():h.hide()}function et(n){n!=r.allowBlank&&(r.allowBlank=n==!0,c())}function ot(n){if(n==undefined)return f?f.text():"";f&&f.text(n)}function st(){return!(rt==g)}function d(n,t){t&&(t.ChangeHandled=!0);var i={ChangeHandled:!1,ValueOriginal:g};if(r.onChange)r.onChange(it,i);t.ChangeHandled&&(mTextOriginal=l.val())}function ht(){return l}function ct(){e.Focus()}function lt(n){if(n==undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,c())}function at(n){if(n==undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,c())}function tt(n){if(n==undefined){var t=$App.TimeZones().GetTimeZoneIdFromDescription(u.Text());return t||(t=$App.TimeZoneId()),t}n?$App&&$App.TimeZones&&u.Text($App.TimeZones().GetDescription(n)):u.Text("");c()}function vt(n){if(n===undefined)return r.timeVisible?$Runtime.CombineDateTimeUtc(e.Value(),o.Value()):$Runtime.GetDateUtc(e.Value());typeof n=="string"&&(n=$Runtime.ParseJsonDate(n));e.Value($Runtime.ParseDate($Runtime.FormatDate(n,!1,!1,!0),!1,!0));o.Value(n)}function yt(n){if(n==undefined)return r.visible;r.visible=n;c()}function pt(){return b?!0:!1}function wt(n,t,i){b=n;y=t==undefined?"":t;k=i==undefined?!1:i;c()}var e,l,b=!0,f,o,u,v=!1,s,y="",k=!1,rt=null,g=null,h,r,p,a,w,it;if(DateTimeZoneDefaults={allowBlank:!0,historic:!1,maxValue:null,minValue:null,readOnly:!1,autoReadOnly:!0,visible:!0,timeZoneVisible:!0,timeVisible:!0,onChange:null},r=$.extend({},DateTimeZoneDefaults,i),typeof t=="string"?(p=n.ExtUtils.TranslateElementId(t),t=$("#"+p)):p=$(t).attr("id"),a=$(t),a.length==0){console.warn("userinterface.DateTimeZone: Element '"+p+"' not found.");return}l=$(a[0]);h=l;h.css("margin","0");h.css("padding","0");w=$("<table class='is-datetimezone' style='width:100%'><tr><td style='width:1px'><input class='d'/><\/td><td style='width:1px'><input class='t'/><td><input class='tz'/><\/td><\/td><\/tr><\/table>");h.append(w);var ut=$("input.d",w),ft=$("input.t",w),nt=$("input.tz",w);return e=new n.DateBox(ut,{valueIsUtc:!1,onChange:d}),o=new n.TimeBox(ft,{valueIsUtc:!1,onChange:d}),o.WrapperElement().css("margin-right","4px"),o.WrapperElement().css("margin-left","4px"),u=new n.ComboBox(nt,{limitToList:!0,pickerCaption:"Select Time Zone",maxLength:255,onChange:d}),$App&&$App.TimeZones?(u.ListFromArray($App.TimeZones().GetDescriptionsList()),nt.attr("placeholder",$App.TimeZones().DefaultTimeZoneDescription())):console.warn("userinterface.DateTimeZone: $App or $App.TimeZones not available."),s=$("<label style='display:none' class='is-validation-tip'><\/label>"),h.append(s),a=$("label[for='"+p+"']"),f=a.length==0?null:$(a[0]),f.click(function(){e.Focus()}),c(),it={TypeName:"DateTimeZone",AllowBlank:et,AutoReadOnly:at,Caption:ot,Changed:st,Element:ht,Focus:ct,ReadOnly:lt,TimeZoneId:tt,Value:vt,Visible:yt,IsValid:pt,ValidationSet:wt}},n}($UI||{});console.log("  $UI (dates extension)");console.log("Loading lib/isuserinterface_grid.js");__UIExtGrid=function(n){return n.Grid=function(t,i){function ki(t){var w=0,lt=null,bt="",v,b,k,vt,yt,i,f,dt,g,gt,nt,c,o,y,ut,ct;if(t){er=!0;s.addClass("is-grid-container");r.autoShiftButtons?s.removeClass("hold-buttons"):s.addClass("hold-buttons");r.stickyHeader?s.addClass("is-sticky-header"):s.removeClass("is-sticky-header");p=null;s.children().remove();r.allowSearchBox&&(st=$("<div class='is-grid-search'><input type='search' style=''/><\/div>"),s.append(st),wt=n.TableFilterTextBox($("input",st),{allowBlank:!0,blankTip:"Type to filter list",maxLength:100}),ht||st.addClass("hidden"));kt=$("<div class='is-grid'><\/div>");s.append(kt);a=$("<table><thead class='is-no-select'><tr><\/tr><\/thead><tbody><\/tbody><\/table>");kt.append(a);r.fixedWidth&&a.addClass("fixedwidth");a.addClass("is-grid");d=$("<div class='is-grid-caption'><span><\/span><div class='close is-symbol-close'><\/div><\/div>");vi=$("span",d);vi.text(rt);fr=$(".close",d);s.append(d);fr.on("click",function(n){d.slideUp("fast");n.stopPropagation()});d.on("click",nu);it=$("<div class='is-grid-buttons'><\/div>");s.append(it)}for(v=$(">thead>tr",a),v.children().remove(),fi=!1,b=0,(r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors)&&(k=$("<th class='rowselector'><\/th>"),v.append(k),r.rowSelectorColumnIcon&&(vt=n.GetIconUrl(r.rowSelectorColumnIcon,16),vt&&k.css({backgroundImage:"url("+vt+")"})),ui=null,r.allowMultiRowSelect&&(yt=$("<input type='checkbox'/>"),k.append(yt),ui=new n.CheckBox(yt,{onChange:function(){gr(ui.Value(),!0)}}))),o=0;o<e.length;o++)i=e[o],i.elementCreatedIndex=-1,i.visible&&(i.doNotCreateBelowScreenWidth===0||screen.width>i.doNotCreateBelowScreenWidth)&&(f=$("<th><\/th>"),i.elementCreatedIndex=b,b+=1,i.caption.substr(0,6).toUpperCase()==="<HTML>"?f.html(i.caption.substr(6)):f.text(i.caption),i.width&&f.css("width",i.width),f.addClass("is-grid-col-"+i.type.toLowerCase()),i.autoHideWidth!==0&&(fi=!0),i.align&&f.css("text-align",i.align),i.backgroundColour&&(f.css("background-color",i.backgroundColour),i.backgroundColour!==bt&&(i.verticalSeparatorColour=i.backgroundColour,bt=i.backgroundColour)),i.foregroundColour&&f.css("color",i.foregroundColour),i.sortable&&(f.addClass("sortable"),i.sorterElement=$("<div class='sorter'><\/div>"),f.append(i.sorterElement),function(n){n.sorterElement.click(function(t){return ci(n.key),t.preventDefault(),!1})}(i),r.sortByColumn===i.key&&(f.addClass("sorted"),r.sortByDesc&&f.addClass("sorted-desc"))),v.append(f));if(r.showColumnHeaders||v.css({display:"none",visibility:"hidden"}),ot?a.addClass("show-row-actions"):a.removeClass("show-row-actions"),dt=b,l=[],p=null,$("tbody",a).children().remove(),u){for(g=[],gt=$(">tbody",a),r.sortByColumn||r.groupByColumns&&r.groupByDesc?(r.groupByColumns?(nt=r.groupByColumns,r.groupByDesc&&(nt="-"+nt),c=r.sortByColumn,r.sortByDesc&&(c="-"+c),u.sort(sr([nt,c]))):(c=r.sortByColumn,r.sortByDesc&&(c="-"+c),u.sort(sr([c]))),wi=!0):wi&&(wi=!1,ir(h,!0)),o=0;o<u.length;o++)if(y=u[o],y){if(r.groupByColumns&&(ut=y.cells[r.groupByColumns].value,lt===null||lt!==ut)){var ft=$("<tr listIndex='-1' class='group-header'><\/tr>"),pt=$("<td><\/td>"),ni=dt;(r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors)&&(ni+=1);pt.attr("colspan",ni);pt.text(ut);ft.append(pt);g.push(ft);lt=ut}ct=$("<tr listIndex='"+y.listIndex+"' class='datarow'><\/tr>");l.push(ct);tu(o,ct);y.hidden&&!et?w+=1:ft&&ft.removeClass("hidden");g.push(ct)}gt.append(g)}iu();w!==0&&r.showHiddenRowsPopup?(rt=w===1?"1 row is hidden":w+" rows are hidden",rt+=". Click to show.",vi.text(rt)):rt="";rt?d.show():d.hide();tt();r.stripe&&hr();oi&&(clearInterval(oi),oi=null);fi&&($Runtime.IsMobileBrowser()?console.warn("Grid has auto-hide columns but these will not be checked at intervals to avoid potential performance issues."):oi=setInterval(tr,2e3),yi=-1,tr());ei&&(at&&at.remove(),at=$("<div class='is-grid-layout-tip' title='Select grid layout'><\/div>"),at.click(function(n){or("",n)}),s.append(at),at.html(ei));r.stickyHeader?s.addClass("is-sticky-header"):s.removeClass("is-sticky-header");n.HandleContextMenuEvent($("> thead",a),function(n){return or("",n),n.preventDefault(),!1})}function iu(){$(">tbody>tr.datarow",a).bind("click",function(n){var o=$(n.target).closest("tr.datarow"),f=$(n.target).closest("td"),s=o.attr("listIndex"),e,i,t,u;if(!r.showRowSelectors||!n||!n.target||!$(n.target).closest("td").hasClass("rowselector")){for(b&&ni(!1),e=f.hasClass("is-sel"),i=0;i<l.length;i++)if(l[i][0]===n.delegateTarget){y(i);break}t=pr(f.attr("key"));u=-1;t&&(u=cf(t.key));ii(u);ft&&t&&e&&(t.allowEdit&&t.type.toUpperCase()!="BOOLEAN"?ni(!1)&&bt():ni(!1))}});r.onRowSelectorClick&&$(">tbody>tr>td.rowselector",a).bind("click",function(n){var t=parseInt($(n.delegateTarget).closest("tr").attr("listIndex"));u&&t>=0&&t<u.length&&hu(t)});$("a.is-drilldown, a.is-drilldown-button",a).bind("click",function(n){var t=$(n.delegateTarget).closest("tr").attr("listIndex"),i=e[$(n.delegateTarget).closest("td").index()].key;u&&t>=0&&t<u.length&&ti(t,i)});$(">tbody>tr.datarow",a).bind("dblclick",function(n){var t=parseInt($(n.delegateTarget).attr("listIndex"));u&&t>=0&&t<u.length&&ti(t,"");r.onRowDrilldown&&window.getSelection&&window.getSelection().removeAllRanges()});n.HandleContextMenuEvent($(">tbody>tr.datarow td",a),function(n){var t=parseInt($(n.delegateTarget).closest("tr").attr("listIndex")),i,u;if(ct(t),r.showContextMenu){try{if(i=$(this).html(),i.toUpperCase().indexOf("APP://FORMSHOW?")>0)return n.preventDefault(),!1}catch(n){}u={contextMenuEventArgs:n,row:{listIndex:t}};ru(n,u)}return n.preventDefault(),!1})}function ru(t,i){dt||(dt=new n.MenuPopup(s,{}));dt.OnAction(uu);var u=[];if(r.sortByColumn&&u.push({ItemId:"SortClear",Caption:"Clear Sorting",Icon:"Sort_Ascending|Clear"}),u.push({ItemType:"SubMenu",Caption:"Export Grid"}),u.push({ItemId:"Export_MSEXCELWORKBOOK",Caption:"MS Excel",Icon:"Application_Excel"}),u.push({ItemId:"Export_CSV",Caption:"CSV",Icon:"Export_Csv"}),u.push({ItemId:"Export_PDF",Caption:"PDF",Icon:"DocumentType_PDF"}),u.push({ItemId:"Export_HTML",Caption:"HTML",Icon:"Control_Html"}),i.handled=!1,i.items=u,r.onContextMenuShow)r.onContextMenuShow(i);dt.Define(u);i.handled||u.length===0||dt.Show(t.clientX,t.clientY)}function uu(n){if(n.startsWith("GridAction:"))lr(n.substr(11));else switch(n){case"Export_CSV":nt("CSV");break;case"Export_HTML":nt("HtmlTable");break;case"Export_MSEXCELWORKBOOK":nt("MSEXCELWORKBOOK");break;case"Export_PDF":nt("PDF");break;case"SortClear":ci("",!1)}}function or(t,i){var u,f,e,o;if(yt||(yt=new n.MenuPopup(yt,{})),yt.OnAction(function(n){fu(t,n)}),u=[],(pt||w&&w.length!==0)&&(u.push({ItemType:"SubMenu",Caption:"Layouts"}),si==""?u.push({ItemId:"Layout:",Caption:"(default)",IconClass:"is-symbol-tick"}):u.push({ItemId:"Layout:",Caption:"(default)",IconClass:"is-symbol-blank"}),w))for(f=0;f<w.length;f++)e=w[f],o={ItemId:"Layout:"+e.LayoutId,Caption:e.LayoutCaption},o.IconClass=e.LayoutId==si?"is-symbol-tick":"is-symbol-blank",u.push(o);r.sortByColumn&&u.push({ItemId:"SortClear",Caption:"Clear Sorting",Icon:"Sort_Ascending|Clear"});r.allowSearchBox&&u.push({ItemId:"SearchBoxToggle",Caption:(ht?"Hide":"Show")+" Filter Box",Icon:"Filter",Checked:ht});u.push({ItemType:"SubMenu",Caption:"Export Grid"});u.push({ItemId:"Export_MSEXCELWORKBOOK",Caption:"MS Excel",Icon:"Application_Excel"});u.push({ItemId:"Export_CSV",Caption:"CSV",Icon:"Export_Csv"});u.push({ItemId:"Export_PDF",Caption:"PDF",Icon:"DocumentType_PDF"});u.push({ItemId:"Export_HTML",Caption:"HTML",Icon:"Control_Html"});$App.UserLevel()==="Administrator"&&(u.push({ItemType:"SubMenu",Caption:"Tools"}),u.push({ItemId:"GridInfo",Caption:"Show Grid Information",Icon:"Grid|Information"}));yt.Define(u);u.length!==0&&yt.Show(i.clientX,i.clientY)}function fu(n,t){switch(t){case"Export_CSV":nt("CSV");break;case"Export_HTML":nt("HtmlTable");break;case"Export_MSEXCELWORKBOOK":nt("MSEXCELWORKBOOK");break;case"Export_PDF":nt("PDF");break;case"GridInfo":su();break;case"SearchBoxToggle":st&&(ht=!ht,ht?st.removeClass("hidden"):st.addClass("hidden"));break;case"SortClear":ci("",!1);break;default:if(t.startsWith("Layout:")){var i=t.substr(7);i!==si&&(vr(i),ir(h,!1,{}),ki())}else window.alert("Unhandled context menu action: "+t)}}function eu(t,i){for(var s,r,o,c,h,f=0;f<u.length;f++)if(u[f].listIndex==t){h=u[f];break}for(vt||(vt=new n.MenuPopup(vt,{})),vt.OnAction(function(n){ou(t,n)}),s=!1,r=[],f=0;f<e.length;f++)o=e[f],c=h.cells[o.key],o.type==="Action"&&c.enabled&&(r.push({ItemId:o.key,Caption:o.actionCaption,IconClass:o.iconClass,Icon:o.icon}),(o.iconClass||o.icon)&&(s=!0));if(s)for(f=0;f<r.length;f++)r[f].IconClass||r[f].Icon||(r[f].IconClass="is-glyph-blank");r.length>0&&r[r.length-1].ItemType==="Separator"&&(r[r.length-1].Visible=!1);r.length===0&&r.push({ItemId:"",Caption:"(no actions available for this row)"});vt.Define(r);r.length!==0&&vt.Show(i.clientX,i.clientY)}function ou(n,t){switch(t){case"Drilldown":ti(n,t);break;default:cr(n,t)}}function su(){var t="",i,u;for(t+="<div style='padding:4px'>",t+="<h1>Grid Information<\/h1>",t+=r.layoutCustomisable||pi?"<div class='is-info-text info'>This Grid can be customised via a finPOWER Connect Cloud Actions Script.<\/div>":"<div class='is-info-text info warning'>This Grid CANNOT be customised via a finPOWER Connect Cloud Actions Script.<\/div>",t+="<h3>Columns<\/h3>",t+="<table class='is-table-data'>",t+="<thead>",t+="<th>Key<\/th>",t+="<th>Type<\/th>",t+="<th>Caption<\/th>",t+="<\/thead>",t+="<tbody>",i=0;i<e.length;i++)u=e[i],t+="<tr>",t+="<td>"+$Runtime.HtmlEncode(u.key)+"<\/td>",t+="<td>"+$Runtime.HtmlEncode(u.type)+"<\/td>",t+="<td>"+$Runtime.HtmlEncode(u.caption)+"<\/td>",t+="<\/tr>";t+="<tbody>";t+="<\/table>";t+="<\/div>";n.CommonDialog().ShowHtml("Grid Information",t)}function ci(n,t,i){if(u){var f=ct();n?t==undefined&&n==r.sortByColumn?r.sortByDesc=!r.sortByDesc:(r.sortByColumn=n,r.sortByDesc=t):(r.sortByColumn="",r.sortByDesc=!1);r.sortByColumn&&r.sortByColumn==r.groupByColumns&&(r.groupByDesc=r.sortByDesc);ki(!1);ct(f);!i&&r.onAfterColumnSort&&r.onAfterColumnSort()}}function sr(n){return function(t,i){return n.map(function(n){var f=1,r,u;return(n[0]=="-"&&(f=-1,n=n.substring(1)),r=t.cells[n].sortValue||t.cells[n].value,u=i.cells[n].sortValue||i.cells[n].value,(r===undefined||r===null)&&(r=""),(u===undefined||u===null)&&(u=""),typeof r=="string"&&(r=r.toUpperCase()),typeof u=="string"&&(u=u.toUpperCase()),r>u)?f:r<u?-f:0}).reduce(function(n,t){return n?n:t},0)}}function hr(){for(var n,i,t=!1,u=$("tbody>tr",a),r=0;r<u.length;r++)n=$(u[r]),i=!0,n.removeClass("odd"),n.removeClass("even"),n.hasClass("group-header")&&(i=!1,t=!1),!et&&n.hasClass("hidden")&&(i=!1),i&&(t?n.addClass("even"):n.addClass("odd"),t=!t)}function bt(){var t,i,e,n,o;if(!r.readOnly){if(b&&ni(),t=yr(v),!t||!t.allowEdit)return!1;if(i=u[f],e=i.cells[k],!i.readOnly&&!e.readOnly){i.newRow&&(i.newRow=!1);n={};switch(t.type.toUpperCase()){case"BOOLEAN":return;case"CURRENCY":n.type="numberbox";n.decimals=-1;break;case"DATE":n.type="datebox";n.historic=!1;break;case"INTEGER":n.type="numberbox";n.decimals=0;break;case"STRING":case"CODE":t.listCsv?(n.type="listbox",n.canLimitToList=!0,n.limitToList=t.limitToList?!0:!1,n.listCsv=t.listCsv):t.collection?(n.type="dbcombo",n.canLimitToList=!0,n.limitToList=t.limitToList?!0:!1,n.collection=t._collection):t.list?(n.type="dbcombo",n.canLimitToList=t._collection.loaded,n.limitToList=t.limitToList?!0:!1,n.collection=t._collection):n.type="textbox";n.maxLength=t.maxLength?t.maxLength:0;break;default:window.alert("No default editor defined for column type '"+t.type+"'.")}if(r.onBeforeCellEdit){o={row:{listIndex:f},columnKey:k,cancel:!1,editorInfo:n};r.onBeforeCellEdit(o);if(o.cancel)return!1}return b=!0,c=n,n.valueOriginal=e.value,di(!0),!0}}}function ni(n){if(!b)return!0;if(n)return b=!1,di(),!0;b=!1;var t;switch(c.type.toUpperCase()){case"DATEBOX":t=Runtime_ParseDate(o.textbox.Text(),c.historic,!0);break;case"DBCOMBO":t=o.dbcombo.Text();c.canLimitToList&&(o.dbcombo.ListExists(t)||(t=""));break;case"LISTBOX":t=o.listbox.Text();break;case"NUMBERBOX":t=o.numberbox.Value();break;case"TEXTBOX":t=o.textbox.Text();break;default:window.alert("No editor handled for exiting edit mode for editorInfo type '"+c.type+"'.");t=undefined}return t===undefined?window.alert("cannot update!"):gi(f,k,t,!0),di(!1),!0}function di(n,t){var e,h,r,u,i;if(f<0||f>l.length-1?b=!1:ft&&v!=-1&&f!=-1||(b=!1),b||(ut=null,lt.hide()),!b){t||(e=mTableWrapper.scrollTop(),s.focus(),mTableWrapper.scrollTop(e));return}if(h=l[f],r=$("td[key='"+k+"']",h),ut=r.length==1?r:null,ut){if(u=ut.position(),lt.css({left:u.left+"px",top:u.top+"px",height:ut.outerHeight()+"px",width:ut.outerWidth()+"px"}),lt.show(),n){o.dbcombo.Visible(!1);o.listbox.Visible(!1);o.numberbox.Visible(!1);o.textbox.Visible(!1);switch(c.type.toUpperCase()){case"DATEBOX":o.textbox.Visible(!0);typeof c.valueOriginal=="string"&&(c.valueOriginal=Runtime_ParseJsonDate(c.valueOriginal));c.valueOriginal||(c.valueOriginal=null);o.textbox.Text(Runtime_FormatDate(c.valueOriginal,!1,!0));o.textbox.Element().css("text-align","right");o.textbox.Focus();break;case"DBCOMBO":o.dbcombo.Visible(!0);o.dbcombo.Element().css({height:lt.innerHeight()+"px",backgroundColor:"white !important",border:"none",borderRadius:0});c.valueOriginal||(c.valueOriginal="");o.dbcombo.Text(c.valueOriginal);o.dbcombo.LimitToList(c.limitToList);o.dbcombo.RefreshFromCollection(c.collection.data,c.collection.idColumn,c.collection.displayColumns);o.dbcombo.Focus();window.setTimeout(function(){o.dbcombo.DropdownShow()},10);break;case"LISTBOX":o.listbox.Visible(!0);o.listbox.Element().css({height:lt.innerHeight()+"px",backgroundColor:"white !important",border:"none",borderRadius:0});c.valueOriginal||(c.valueOriginal="");o.listbox.Text(c.valueOriginal);o.listbox.LimitToList(c.limitToList);o.listbox.ListFromCsvString(c.listCsv);o.listbox.Focus();window.setTimeout(function(){o.listbox.DropdownShow()},10);break;case"NUMBERBOX":o.numberbox.Visible(!0);c.valueOriginal||(c.valueOriginal=0);o.numberbox.Value(c.valueOriginal);o.numberbox.Focus();break;case"TEXTBOX":o.textbox.Visible(!0);o.textbox.MaxLength(c.maxLength);c.valueOriginal||(c.valueOriginal="");o.textbox.Text(c.valueOriginal);i=pr(k);i&&i.align?o.textbox.Element().css("text-align",i.align):o.textbox.Element().css("text-align","left");o.textbox.Focus();break;default:window.alert("No editor defined for editorInfo type '"+c.type+"'.")}}}else s.focus(),lt.hide()}function tt(){var f,t,o,y=!1,l=!1,p=!1,h,c,w,s,i,v;if(it.children().remove(),f=$("<ul><\/ul>"),it.append(f),f.addClass("group"),u&&u.length!==0)for(h=0;h<e.length;h++)if(e[h].type==="Action")for(s=0;s<u.length;s++)u[s]&&(p=!0);else if(e[h].type==="ActionsList"){y=!0;break}if(p&&!y&&!r.alwaysShowRowActions){l=!0;o=$("<li><button class='is-button normal'><\/button><\/li>");f.append(o);t=$("button",o);ot?t.text(r.hideRowActionsCaption):t.text(r.showRowActionsCaption);t.on("click",ar)}for(ot||r.alwaysShowRowActions?a.addClass("show-row-actions"):a.removeClass("show-row-actions"),c=null,w=!1,s=0;s<ri.Actions().length;s++)if(i=ri.Actions()[s],i.visible)if(i.actionId){if(o=$("<li><button class='is-button'><\/button><\/li>"),f.append(o),t=$("button",o),c||(c=o),l=!0,i.autoHideCaption!==!1&&t.addClass("auto-hide-caption"),i.caption&&t.text(i.caption),i.tooltipText&&t.attr("title",i.tooltipText),i.enabled||t.attr("disabled","disabled"),i.icon&&(v=n.GetIconUrl(i.icon,16),v&&t.css({backgroundImage:"url("+v+")"}),t.addClass("icon")),i.checked&&t.addClass("checked"),i.buttonStyle)t.addClass(i.buttonStyle);else switch(i.actionId.toUpperCase()){case"ADD":t.addClass("positive");break;case"REFRESH":t.addClass("refresh");o.addClass("system");t.attr("title","Refresh");break;default:t.addClass("normal")}i.handler?function(n){t.click(function(){n.handler()})}(i):function(n){t.click(function(){lr(n.actionId)})}(i)}else c&&(w=!0,c=null,f.addClass("group"),f=$("<ul><\/ul>"),f.addClass("group"),it.append(f));l?it.show():it.hide()}function gi(n,t,i){if(r.onBeforeCellUpdate){var e=u[n],o=e.cells[t],f={row:{listIndex:e.listIndex},columnKey:t,oldValue:o.value,newValue:i,refreshRow:!1,cancel:!1};r.onBeforeCellUpdate(f);f.cancel||(o.value=i);(f.refreshRow||f.cancel)&&rr(e.listIndex)}}function cr(n,t){if(r.onCellAction){var i={row:{listIndex:n},columnKey:t};r.onCellAction(i)}else window.alert("No onCellAction defined to handle cell action '"+t+"' for row "+n+".")}function ti(n,t){if(r.onRowDrilldown){n==undefined&&(n=f);var i={row:{listIndex:n},columnKey:t};r.onRowDrilldown(i)}}function hu(n){if(r.onRowSelectorClick){var t={row:{listIndex:n}};r.onRowSelectorClick(t)}}function cu(){return ri}function lr(n){if(r.onAction)r.onAction(n);else window.alert("$UI.Grid.ExecuteAction: No OnAction defined for this Grid object.")}function lu(){ot=!1;tt()}function au(){ot=!0;tt()}function ar(){ot=!ot;tt()}function vu(n,t){var i=$("tr[listIndex='"+n+"']",a);i.remove();t&&(h[n]=null,u[n]=null);tt()}function yu(n){var e,i,o,t;if(n<0||n>h.length-1)return console.warn("Grid.RemoveRowAndCollectionItem: listIndex is outside of the bounds of the virtual class."),!1;for(n==f&&(p=null),e=l[n],$Runtime.ArrayRemove(l,l[n]),e.remove(),$Runtime.ArrayRemove(u,u[n]),$Runtime.ArrayRemove(h,h[n]),t=0;t<l.length;t++)i=l[t],i.attr("listIndex",t),u[t].listIndex=t,r.rowNumbering&&(o=$("td.rowselector span.rownumber",i),o.text(t+1));return f!=-1&&n<=f&&(t=f,t<0&&(t=0),t>u.length-1&&(t=u.length-1),y(t)),!0}function pu(){if(!(f<1)&&!(f>=h.length)){var n=$("tr[listIndex='"+f+"']",a),t=n.prev();t.before(n);n.attr("listIndex",f-1);t.attr("listIndex",f);n=l[f];t=l[f-1];l[f]=t;l[f-1]=n;n=h[f];t=h[f-1];h[f]=t;h[f-1]=n;n=u[f];t=u[f-1];u[f]=t;u[f-1]=n;y(y()-1);tt()}}function wu(){if(!(f<0)&&!(f>=h.length-1)){var n=$("tr[listIndex='"+f+"']",a),t=n.next();t.after(n);n.attr("listIndex",f+1);t.attr("listIndex",f);n=l[f];t=l[f+1];l[f]=t;l[f+1]=n;n=h[f];t=h[f+1];h[f]=t;h[f+1]=n;n=u[f];t=u[f+1];u[f]=t;u[f+1]=n;y(y()+1);tt()}}function bu(){h=null;nr(!1)}function ku(n){n>=0&&n<l.length&&(l[n].addClass("flash"),window.setTimeout(function(){l[n].removeClass("flash")},500))}function du(n){f!==-1&&n||y(0)}function gu(n){f!==-1&&n||h&&y(h.length-1)}function ii(n){var i,t;if(n===undefined)return v;n=parseInt(n);i=v;p&&$("td",p).removeClass("is-sel");n>=0&&n<e.length?(v=n,t=k=yr(v),k=t?t.key:"",r.allowCellSelect&&$("td[key='"+k+"']",p).addClass("is-sel")):(v=-1,k="")}function y(n){if(n==undefined)return f;n=parseInt(n);p&&(p.removeClass("is-sel"),p=null);n>=0&&n<l.length?(f=n,p=l[f],p.addClass("is-sel"),p.removeClass("hidden")):f=-1;v!=-1&&ii(v);g();r.onAfterRowActivate&&r.onAfterRowActivate()}function ct(n){if(n==undefined)return f!==-1&&u?u[f].listIndex:-1;n=parseInt(n);f===-1;for(var t=0;t<u.length;t++)if(u[t].listIndex==n){y(t);break}}function nf(){if(u&&f>0){var t=s.height(),i=s.scrollTop,n=f;n-=10;n<0&&(n=0);y(n);g(!0)}}function tf(){if(u&&f<u.length-1){var t=s.height(),i=s.scrollTop,n=f;n+=10;n>u.length-1&&(n=u.length-1);y(n);g(!0)}}function rf(){var t,n;if(u&&f<u.length-1){for(t=f,n=f+1;n<u.length;n++)if(u[n]!==null&&(et||!u[n].hidden)){t=n;break}y(t);g(!0)}}function uf(){var t,n;if(u&&f>0){for(t=f,n=f-1;n>=0;n--)if(u[n]!==null&&(et||!u[n].hidden)){t=n;break}y(t);g(!0)}}function g(n){if((n==undefined&&(n=!1),r.visible)&&p){var t=0;r.stickyHeader&&(t=32);p.ScrollElementIntoView(n,!1,{inViewAmount:t})}}function ff(n,t){var i,r;if(u)for(i=0;i<u.length;i++)if(r=u[i].cells[n],r&&r.value==t)return y(i),!0;return console.warn("Grid could not locate a row with "+n+" = "+t),!1}function ef(n,t){n||t?(pi=!0,pt=n,w=t):(pt=null,w=null)}function vr(n){var r,s,u,f,o,i,t;if(pt||w){if(!pt&&!gt)for(gt={},gt.Columns=[],i=0;i<e.length;i++)t=e[i],(t.visible||t.type==="Action"||t.type==="ActionsList")&&gt.Columns.push({Key:t.key,OriginalAutoHideBelowWidth:t.autoHideBelowWidth});if(n=="")r=pt;else if(w)for(i=0;i<w.length;i++)if(w[i].LayoutId==n){r=w[i];break}if(!r&&n){window.alert("Grid Layout '"+n+"' not found.");return}if(si=n,w&&w.length!==0?(s="(default)",r&&r.LayoutCaption&&(s=r.LayoutCaption),ei="<span>"+$Runtime.HtmlEncode(s)+"<\/span>"):ei="",r||(r=gt),r.Columns.length!==0){for(u=e,e=[],i=0;i<r.Columns.length;i++)for(f=r.Columns[i],o=0;o<u.length;o++)if(t=u[o],t&&f.Key.toUpperCase()==t.key.toUpperCase()){if(e.push(t),t.visible=!0,f.OriginalAutoHideBelowWidth)t.autoHideBelowWidth=f.OriginalAutoHideBelowWidth;else if(f.Priority!==undefined)switch(f.Priority){case 0:t.autoHideBelowWidth=0;break;case 1:t.autoHideBelowWidth=640;break;case 2:t.autoHideBelowWidth=800;break;case 3:t.autoHideBelowWidth=1024}u[o]=null;break}for(i=0;i<u.length;i++)t=u[i],t&&(t.type==="Action"||t.type==="ActionsList"||(t.visible=!1),t.type==="ActionsList"?e.unshift(t):e.push(t))}}}function of(){e=[]}function sf(){return e.length}function hf(n,t){var i,r;for(n=n.toUpperCase(),i=0;i<e.length;i++)if(r=e[i],r.key.toUpperCase()==n){r.visible=t;break}}function yr(n){return n>=0&&n<e.length?e[n]:null}function pr(n){if(!n)return null;n=n.toUpperCase();for(var t=0;t<e.length;t++)if(n==e[t].key.toUpperCase())return e[t];return null}function cf(n){n=n.toUpperCase();for(var t=0;t<e.length;t++)if(n==e[t].key.toUpperCase())return t;return-1}function lf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Action";i.width||(i.width="1em");e.push(i)}function af(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="ActionsList";i.width||(i.width="1em");e.push(i)}function vf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Boolean";i.width||(i.width="1em");e.push(i)}function yf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Currency";i.width||(i.width="4em");e.push(i)}function pf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Date";i.width||(i.width="4em");e.push(i)}function wf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="DateTime";i.width||(i.width="6em");e.push(i)}function bf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Drilldown";i.width="20px";i.allowDrilldown=!0;e.push(i)}function kf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="HTML";e.push(i)}function df(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Icon";e.push(i)}function gf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Integer";i.width||(i.width="4em");e.push(i)}function ne(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Percentage";i.width||(i.width="4em");i.decimals||(i.decimals=4);i.decimalsFixed||(i.decimalsFixed=!1);e.push(i)}function te(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="String";i.noBreak||(i.noBreak=!1);e.push(i)}function ie(n){if(n===undefined)return r.autoShiftButtons;n!==r.autoShiftButtons&&(r.autoShiftButtons=n,r.autoShiftButtons?s.removeClass("hold-buttons"):s.addClass("hold-buttons"))}function re(){}function ue(){return s}function fe(){s.focus()}function ee(n){var r,i,t,e;if(n=$.extend({},{retainActiveRow:!0,retainSelectedRows:!0,retainExpiredRows:!0,retainExpiredGenerationsCount:5},n),h){if(!h.GetCacheKey)return window.alert("userinterface.Grid.GetRetainableCacheKeyDetails: mVirtualClass does not support a 'GetCacheKey' method."),{}}else return window.alert("userinterface.Grid.GetRetainableCacheKeyDetails: mVirtualClass does not have a value."),{};if(r={},n.retainActiveRow&&f!==-1&&(r.activeDataRow=h.GetCacheKey(ct())),n.retainSelectedRows)for(i=wr(),r.selectedRows=[],t=0;t<i.length;t++)r.selectedRows.push(h.GetCacheKey(i[t]));if(n.retainExpiredRows)for(i=br(),r.expiredRows=[],t=0;t<i.length;t++)r.expiredRows.push(h.GetCacheKey(i[t]));if(n.retainExpiredGenerationsCount)for(i=kr(),r.expiredGenerationRows=[],t=0;t<i.length;t++)e=u[i[t]],r.expiredGenerationRows.push({key:h.GetCacheKey(i[t]),generation:e.expiredGeneration});return r}function oe(n,t){var e,f,u,i,r;if(t=$.extend({},{restoreActiveRow:!0,restoreSelectedRows:!0,restoreExpiredRows:!1,markExpiredRows:!0,markExpiredGenerations:!0,incrementExpiredGenerations:!0},t),h){if(!h.GetCacheKey)return window.alert("userinterface.Grid.GetRetainableCacheKeyDetails: mVirtualClass does not support a 'GetCacheKey' method."),{}}else return window.alert("userinterface.Grid.GetRetainableCacheKeyDetails: mVirtualClass does not have a value."),{};if(t.restoreSelectedRows&&n.selectedRows){for(e=[],i=0;i<n.selectedRows.length;i++)r=li(n.selectedRows[i]),r&&e.push(r.listIndex);e.length>0&&dr(e)}if(t.restoreExpiredRows|t.markExpiredRows&&n.expiredRows){for(u=[],i=0;i<n.expiredRows.length;i++)r=li(n.expiredRows[i]),r&&u.push(r.listIndex);u.length>0&&(f=t.restoreExpiredRows?0:1,ai(u,f))}if(t.markExpiredGenerations&&n.expiredGenerationRows)for(f=1;f<10;f++){for(u=[],i=0;i<n.expiredGenerationRows.length;i++){var o=n.expiredGenerationRows[i].key,s=n.expiredGenerationRows[i].generation,r=li(o);r&&f==s&&u.push(r.listIndex)}u.length>0&&(t.incrementExpiredGenerations?ai(u,f+1):ai(u,f))}t.restoreActiveRow&&n.activeDataRow&&(r=li(n.activeDataRow),r&&ct(r.listIndex))}function li(n){for(var i,t=0;t<u.length;t++)if(i=h.GetCacheKey(u[t].listIndex),i==n)return u[t];return null}function wr(n,t){var e=[],o,i;if(r.allowMultiRowSelect)for(o=0;o<u.length;o++)i=u[o],i&&i.rowSelectorCheckBox&&i.rowSelectorCheckBox.Value()&&(t&&i.expired||e.push(i.listIndex));return n&&e.length===0&&f>=0&&(t&&u[f].expired||e.push(f)),e}function br(){for(var t,i=[],n=0;n<u.length;n++)t=u[n],t.expired&&i.push(t.listIndex);return i}function kr(n){var r=[],t,i;for(n||(n=5),t=0;t<u.length;t++)i=u[t],i.expiredGeneration&&i.expiredGeneration<=n&&r.push(i.listIndex);return r}function ai(n,t){for(var i,f,r=0;r<n.length;r++)i=u[n[r]],i&&(f=l[i.listIndex],t?(i.expiredGeneration=t,f.addClass("expiredGeneration"+t)):(i.expired=!0,f.addClass("expired")))}function dr(n){for(var t,i=0;i<n.length;i++)t=u[n[i]],t&&t.rowSelectorCheckBox&&(t.rowSelectorCheckBox.Value(!0),l[t.listIndex].addClass("selected"))}function se(n){$("tr",a).removeClass("related");for(var t=0;t<n.length;t++)$("tr[listIndex='"+n[t]+"']",a).addClass("related")}function gr(n,t){var f,i,e;if(r.allowMultiRowSelect){for(f=0;f<u.length;f++)i=u[f],i&&i.rowSelectorCheckBox&&(e=l[i.listIndex],t&&e.hasClass("is-filtered-out")||(i.rowSelectorCheckBox.Value(n),n?e.addClass("selected"):e.removeClass("selected")));ui.Value(n);r.onAfterRowActivate&&r.onAfterRowActivate()}}function he(n){if(n===undefined)return r.groupByColumns;r.groupByColumns=n}function nr(){ki(!0)}function ce(){s.css({width:"100%",height:"100%",overflow:"auto"});tr()}function le(n,t,i,r){for(var f,o,e=0;e<u.length;e++)if(u[e].listIndex==n){f=u[e];o=e;break}f&&(f.rowSelectorIcon=t,i!==undefined&&(f.details=i),r&&r.rowExpired!==undefined&&(f.expired=r.rowExpired),rr(n,o))}function tr(){var t,i,n,u;if(fi&&s.is(":visible")&&(t=s.outerWidth(),t!=yi))for(yi=t,$("tr>td,tr>th",a).removeClass("cellhidden"),i=0;i<e.length;i++)n=e[i],u=r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors?1:0,n.elementCreatedIndex!==-1&&(n.autoHideBelowWidth>0&&t<=n.autoHideBelowWidth||n.autoHideAboveWidth>0&&t>n.autoHideAboveWidth)&&$("tr>td:nth-child("+(u+n.elementCreatedIndex+1)+"),tr>th:nth-child("+(u+n.elementCreatedIndex+1)+")",a).addClass("cellhidden")}function nu(){$("tr.hidden",a).removeClass("hidden");d.slideUp("fast");g();et=!0;r.stripe&&hr()}function ir(n,t){var l,i,s,o,c,a;n&&(h=n);u=[];et=!1;l=f;r.onInitialiseRow||window.alert("userinterface.Grid.VirtualDataRefresh: options.onInitialiseRow handler not specified.");try{for(i=0;i<h.length;i++)if(h[i]!==null){for(s={},o=0;o<e.length;o++)s[e[o].key]={key:e[o].key,value:null,drilldownUrl:"",enabled:!0,hyperlink:"",colour:"",small:!1,strike:!1,tooltipText:""};c={listIndex:i,cells:s,colour:"",bold:!1,inactive:!1,special1:!1,special2:!1,strike:!1,expired:"",rowSelectorIcon:"",details:""};a={row:c};u.push(c);r.onInitialiseRow(a)}}catch(v){window.alert("userinterface.Grid.VirtualDataRefresh: "+v.message)}nr(!er);t&&y(l);wt&&(wt.Initialise($("table",kt)),wt.BlankTip("Type to filter list ("+u.length+" items)"))}function rr(n,t){if(t==undefined)for(var i=0;i<u.length;i++)if(u[i].listIndex==n){t=i;break}ae(n,t);r.allowCellSelect&&ii(v)}function ae(n,t){var f={row:u[t]},i;r.onInitialiseRow(f);i=$("tr[listindex="+n+"]",kt);tu(t,i,!0)}function tu(t,i,f){var k,c,v,d,g,nt,y,o,h,s,l,p,a,tt,w,b,t;for(f&&(i.children().remove(),i.removeClass("hidden inactive strike special1 special2 expired selected"),i.attr("style","")),c=u[t],(r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors)&&(v=$("<td class='rowselector is-no-select'><\/td>"),r.allowMultiRowSelect&&(d=c.rowSelectorCheckBox&&c.rowSelectorCheckBox.Value(),g=$("<input type='checkbox'/>"),v.append(g),c.rowSelectorCheckBox=new n.CheckBox(g,{onChange:function(){c.rowSelectorCheckBox.Value()?i.addClass("selected"):i.removeClass("selected")}}),c.rowSelectorCheckBox.Value(d),d&&i.addClass("selected")),r.rowNumbering&&v.append("<span class='rownumber'>"+(t+1)+"<\/span>"),c.rowSelectorIcon&&(nt=n.GetIconUrl(c.rowSelectorIcon,16),nt&&(v.css({backgroundImage:"url("+nt+")"}),v.addClass("icon"))),c.details&&v.attr("title",c.details),i.append(v)),y=0;y<e.length;y++)if(o=e[y],o.elementCreatedIndex!==-1){if(h=$("<td><\/td>"),h.attr("key",o.key),!r.showColumnHeaders&&o.width&&h.css("width",o.width),ve(o,h,""),o.align&&h.css("text-align",o.align),o.colour?h.css("color",o.colour):h.css("color",""),o.noLineBreak&&h.addClass("nobreak"),s=c.cells[o.key],s){if(s.value!=null||o.type==="Action"||o.type==="ActionsList"||o.type==="Drilldown"||o.allowEdit){h.addClass("is-grid-col-"+o.type.toLowerCase());switch(o.type){case"Action":if(s.enabled){l=$("<button class='is-action-button'/>");l.addClass(o.key);h.append(l);switch(o.key.toUpperCase()){case"DELETE":case"MOVEDOWN":case"MOVEUP":l.attr("title",o.actionCaption);break;default:o.actionIcon?(l.append("<img src='"+$Api.GetIconUrl(o.actionIcon,16)+"'/>"),l.attr("title",o.actionCaption)):(console.warn("No grid action button CSS class defined for action '"+o.key+"'."),l.text(o.actionCaption))}l.attr("actionId",o.key)}break;case"ActionsList":s.enabled&&(l=$("<button class='is-actionslist-button'/>"),l.addClass(o.key),h.append(l));break;case"Boolean":o.allowEdit&&!s.readOnly?(p=$("<input type='checkbox' class='is-grid-checkbox'/>"),p.prop("checked",s.value),function(n,t,i){i.click(function(){gi(n,t,i.prop("checked"))})}(t,o.key,p),h.append(p)):s.value?h.addClass("is-grid-col-boolean-true is-symbol-tick"):(h.addClass("is-grid-col-boolean-false"),o.alwaysShowValue&&h.addClass("is-symbol-cross"));break;case"Currency":s.value==null||s.value==0&&o.blankIfZero?h.text(""):h.text($Runtime.FormatCurrency(s.value));break;case"Date":s.value&&h.text($Runtime.FormatDateForGrid(s.value));break;case"DateTime":s.value&&h.text($Runtime.FormatDateForGrid(s.value,!0,!1,o.showUtcValues,o.longTime));break;case"Drilldown":!s.value&&o.drilldownHideIfBlank||s.enabled&&h.html("<a class='is-drilldown-button'><\/a>");break;case"HTML":s.value&&typeof s.value=="string"?h.html(s.value):h.append(s.value);break;case"Icon":s.value&&(a=s.value,a.indexOf("/")===-1&&$fincwsapi&&(tt="",w=a.indexOf("|"),w!==-1&&(tt=a.substr(w+1),a=a.substr(0,w)),a=$fincwsapi.GetIconUrl(a,16,tt)),h.html("<img src='"+a+"'/>"));break;case"Percentage":if(s.value==null||s.value==0&&o.blankIfZero)h.text("");else{if(b=o.decimals,!o.decimalsFixed)for(b=0,t=0;t<o.decimals;t++){if(s.value*Math.pow(10,t)==Math.floor(s.value*Math.pow(10,t)))break;b+=1}h.text($Runtime.FormatNumber(s.value,b,!0,!1)+"%")}break;default:o.truncate?(h.html("<div style='display:table;table-layout:fixed;width:100%'><div style='overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap'>"+$Runtime.HtmlEncode(s.value)+"<\/div><\/div>"),h.attr("title",s.value)):h.html($Runtime.HtmlEncode(s.value))}s.hyperlink&&h.wrapInner('<a href="'+s.hyperlink+"\" target='_blank'><\/a>");(c.readOnly||s&&s.readOnly)&&(h.addClass("readonly"),h.removeClass("editable"));s.small&&h.css("font-size","0.85em");s.strike&&h.css("text-decoration","line-through");s.colour?h.css("color",s.colour):h.css("color","")}}else{window.alert("Invalid column key '"+o.key+"'");break}o.allowDrilldown&&o.type!=="Drilldown"&&h.wrapInner("<a class='is-drilldown'><\/a>");o.verticalSeparatorColour&&k&&k.css("border-right","1px solid "+o.verticalSeparatorColour);s.tooltipText&&h.attr("title",s.tooltipText);i.append(h);k=h}c.bold?i.css({"font-weight":"bold"}):i.css({"font-weight":"normal"});c.colour?i.css("color",c.colour):i.css("color","");c.hidden&&!et&&i.addClass("hidden");c.inactive&&i.addClass("inactive");c.strike&&i.addClass("strike");c.special1&&i.addClass("special1");c.special2&&i.addClass("special2");c.expired&&i.addClass("expired");c.expiredGeneration&&c.expiredGeneration>0&&i.addClass("expiredGeneration"+c.expiredGeneration);$("button.is-action-button",i).bind("click",function(n){var t=$(n.delegateTarget).closest("tr").attr("listIndex"),i=$(n.delegateTarget).attr("actionId");u&&t>=0&&t<u.length&&cr(t,i)});$("button.is-actionslist-button",i).bind("click",function(n){var t=$(n.delegateTarget).closest("tr").attr("listIndex");eu(t,n)})}function ve(n,t){n.allowEdit?t.addClass("editable"):t.removeClass("editable")}function ye(n){if(n===undefined)return r.visible;r.visible!==n&&(r.visible=n,r.visible?(s.show(),g(!0)):s.hide())}function pe(){}function we(){}function be(){return a}function nt(n){for(var f,s,l,c,t,o,r={columns:[],data:[]},i=0;i<e.length;i++)if(t=e[i],t.visible)switch(t.type.toUpperCase()){case"ACTION":case"ACTIONSLIST":case"DRILLDOWN":case"HTML":break;default:f=t.caption;f&&f.toUpperCase().startsWith("<HTML>")&&(f=t.key);r.columns.push({key:t.key,caption:f,dataType:t.type})}if(u)for(s=0;s<u.length;s++)if(l=[],c=u[s],c)for(r.data.push(l),i=0;i<r.columns.length;i++)t=r.columns[i],o=c.cells[t.key].value,t.dataType==="html"&&(o=h[c.listIndex][t.key]),o===undefined&&(o=null),l.push(o);$App.DownloadExportedGridData(n,r)}var ri,f=-1,v=-1,k,it,d,vi,fr,rt="",e=[],l=[],ut,b=!1,lt,o,ft=!1,c,s,yi=-1,ui,kt,fi=!1,pi=!1,et=!1,er=!1,ei,at,dt,r,oi=null,ot=!1,vt,p,yt,wi=!1,a,h,u,pt,w,si,gt,st,wt,ht=!1,hi,bi,ur;if(GridDefaults={width:"auto",showRowSelectors:!1,stripe:!0,rowNumbering:!1,visible:!0,autoShiftButtons:!0,allowCellSelect:!0,allowMultiRowSelect:!1,groupByColumns:"",layoutCustomisable:!1,onAction:null,onAfterColumnSort:null,onAfterRowActivate:null,onBeforeCellUpdate:null,onCellAction:null,onContextMenuShow:null,onInitialiseRow:null,onRowDrilldown:null,onRowSelectorClick:null,rowSelectorColumnIcon:"",showColumnHeaders:!0,stickyHeader:!0,sortByColumn:"",sortByDesc:!1,showContextMenu:!0,showHiddenRowsPopup:!0,fixedWidth:!1,allowSearchBox:!0,showSearchBox:!1,alwaysShowRowActions:!1,showRowActionsCaption:"Show Row Actions",hideRowActionsCaption:"Hide Row Actions"},r=$.extend({},GridDefaults,i),ri=new n.ActionsCollection,ht=r.allowSearchBox&&r.showSearchBox,GridColumnDefaults={key:"",actionCaption:"",actionIcon:"",align:"",allowDrilldown:!1,allowEdit:!1,alwaysShowValue:!1,caption:"",colour:"",type:"String",readOnly:!1,sortable:!1,visible:!0,width:"",truncate:!1,noLineBreak:!1,doNotCreateBelowScreenWidth:0,autoHideBelowWidth:0,autoHideAboveWidth:0,drilldownHideIfBlank:!1,elementCreatedIndex:-1},typeof t=="string"?(hi=n.ExtUtils.TranslateElementId(t),t=$("#"+hi)):hi=$(t).attr("id"),bi=$(t),bi.length===0){console.warn("userinterface.Grid: Element '"+hi+"' not found.");return}return s=$(bi[0]),s.attr("tabindex","-1"),s.bind("keyup",function(n){if(!b)switch(n.keyCode){case 13:if(ft)return bt(),!1}}),s.bind("keydown",function(n){var t,i;if(!b&&(!wt||!wt.HasFocus()))switch(n.keyCode){case 13:u&&f>=0&&f<u.length&&ti(ct(),"");break;case 27:y(-1);break;case 32:if(ft&&!r.readOnly&&f!=-1&&v!=-1&&(t=e[v],t.type=="Boolean"&&t.allowEdit))return i=$("td.is-sel > input.is-grid-checkbox",s),i.trigger("click"),!1;break;case 35:return u&&(y(u.length-1),g()),!1;case 36:return u&&(y(0),g()),!1;case 33:return nf(),!1;case 34:return tf(),!1;case 38:return uf(),!1;case 40:return rf(),!1;case 46:if(ft&&v==-1&&f!=-1){if(r.onAction)r.onAction("DeleteRow")}else switch(e[v].type){case"Currency":case"Integer":gi(f,k,null,!0);break;default:bt();window.setTimeout(function(){ni(!1)},10)}break;case 113:ft&&bt();break;default:if(ft)if(n.keyCode>=32&&n.keyCode<=111||n.keyCode==189)bt();else switch(n.keyCode){case 187:case 191:bt()}}}),r.visible||s.hide(),ur={TypeName:"Grid",ClearColumns:of,ColumnCount:sf,AddColumnAction:lf,AddColumnActionsList:af,AddColumnBoolean:vf,AddColumnCurrency:yf,AddColumnDate:pf,AddColumnDateTime:wf,AddColumnDrilldown:bf,AddColumnHtml:kf,AddColumnIcon:df,AddColumnInteger:gf,AddColumnPercentage:ne,AddColumnString:te,ColumnVisible:hf,Actions:cu,ActivateFirstDataRow:du,ActivateLastDataRow:gu,ActiveDataRowIndex:y,ActiveDataRowIndexFromProperty:ff,ActiveDataRowListIndex:ct,LayoutsDefine:ef,LayoutApply:vr,ShowHiddenRows:nu,RowActionsHide:lu,RowActionsShow:au,RowActionsToggle:ar,RowDelete:vu,RemoveRowAndCollectionItem:yu,RowMoveUp:pu,RowMoveDown:wu,RowsClear:bu,FlashRow:ku,PerformRowDrilldown:ti,AutoShiftButtons:ie,Caption:re,Element:ue,Focus:fe,GroupByColumns:he,Refresh:nr,RefreshButtons:tt,RefreshRow:rr,ResizeFromParent:ce,VirtualDataRefresh:ir,Visible:ye,Sort:ci,GetSelectedRowIndexes:wr,SetSelectedRowIndexes:dr,SetRowSelectorIcon:le,SelectAllRows:gr,ExportData:nt,GetExpiredRowIndexes:br,SetExpiredRowIndexes:ai,GetExpiredGenerationsRowIndexes:kr,GetRetainableCacheKeyDetails:ee,RestoreRetainedCacheKeyDetails:oe,SetRelatedRowIndexes:se,Tag:{},Columns:function(){return e},GetDataRowElements:function(){return l},NotifyTableFilterApplied:pe,RealignLayout:we,VirtualClass:function(){return h},VirtualData:function(){return u},GetTableElement:be},s.prop("is-control",ur),ur},n.ShowGridRearrange=function(t,i,r){function nt(n){s.WaitHide();n?s.Close():f.focus()}function o(){var t=$("tbody > tr.datarow",f),n,i;for(t.removeClass("is-sel odd even moveDown moveUp"),u!==-1&&$(t[u]).addClass("is-sel"),n=0;n<t.length;n++)i=$(t[n]),n%2==0?i.addClass("odd"):i.addClass("even");u!==-1&&$("tbody > tr.is-sel",f).ScrollElementIntoView(!1,!1,{inViewAmount:0})}function y(n){for(var i=$("tbody > tr.datarow",f),t=0;t<i.length;t++)if(n===i[t]){u=t;break}}function tt(n){for(var u,i=$("tbody > tr",f),r=!1,t=0;t<i.length;t++){if(u=$(i[t]),r)return u.hasClass("datarow")?!0:!1;i[t]===n&&(r=!0)}return!1}function it(n){for(var u,i=$("tbody > tr",f),r=!1,t=i.length-1;t>=0;t--){if(u=$(i[t]),r)return u.hasClass("datarow")?!0:!1;i[t]===n&&(r=!0)}return!1}function p(){if(u>0){var i=$("tbody > tr.datarow",f),n=$(i[u]),t=$(i[u-1]);it(n[0])&&(t.before(n),u-=1,o(),n.addClass("moveUp"),t.addClass("moveDown"),window.setTimeout(function(){n.removeClass("moveUp");t.removeClass("moveDown")},300))}}function w(){if(u<h-1){var i=$("tbody > tr.datarow",f),n=$(i[u]),t=$(i[u+1]);tt(n[0])&&(n.before(t),u+=1,o(),n.addClass("moveDown"),t.addClass("moveUp"),window.setTimeout(function(){n.removeClass("moveDown");t.removeClass("moveUp")},300))}}var e,c,v,b,k,d;ShowGridRearrangeDefaults={title:"Rearrange Items",height:"95%",width:"95%",maxWidth:1e3,maxHeight:2e3,primaryKeyColumn:"Pk",commitMessage:"Committing changes, please wait..."};var l=$.extend({},ShowGridRearrangeDefaults,i),g=t.GetTableElement(),s=n.Modal(l);s.Actions().Define([{groupId:"[buttons]",actionId:"Cancel",caption:"Cancel"},{groupId:"[buttons]",actionId:"Ok",caption:"Commit"},{groupId:"[buttonsOther]",actionId:"MoveUp",icon:"Move_Up",tooltipText:"Move selected item up (Ctrl+Up)"},{groupId:"[buttonsOther]",actionId:"MoveDown",icon:"Move_Down",tooltipText:"Move selected item down (Ctrl+Down)"}]);s.OnAction(function(n){var i,e,o,u;switch(n){case"MoveDown":w();f.focus();break;case"MoveUp":p();f.focus();break;case"Ok":if(!r){window.alert("No doneCallback parameter specified.");return}if(i={},i.primaryKeyList="",i.commitComplete=nt,e=$("tbody > tr.datarow",f),o=t.VirtualClass(),!o){window.alert("This grid does not hava a Virtual Class that it is bound to.");return}for(u=0;u<e.length;u++){var c=$(e[u]),a=c.attr("listIndex"),v=o[a],h;try{h=v[l.primaryKeyColumn]}catch(y){window.alert("The collection this grid is bound to does not contain a '"+l.primaryKeyColumn+"' property.\n\nUse the intialisation option 'primaryKeyColumn' to specify the property name to use.");return}i.primaryKeyList.length!==0&&(i.primaryKeyList+=",");i.primaryKeyList+=h}s.WaitShow(l.commitMessage);r(i);break;case"Cancel":s.Close()}});s.Show();e=$("<div class='is-grid-rearrange is-no-select'><\/div>");e.append(g.parent()[0].outerHTML);$("div.is-grid",e).addClass("is-dock-fill");$("span.is-checkbox",e).remove();$("div.sorter",e).remove();$("table.is-sticky-header",e).remove();$(".selected",e).removeClass("selected");$("tr",e).removeClass("hidden");$("td.rowselector",e).css("background-image","");$("a",e).css("cursor","default");$("a",e).removeAttr("href");var a=$("table > tbody > tr.datarow",e),h=a.length,f=$("table",e),u=a.length>0?0:-1;for($("table > thead > tr > th:first-child",e).before("<th class='is-updown'><\/th>"),c=0;c<a.length;c++)v=$(a[c]),b=$("<td class='is-updown'><nobr><a class='is-up'><\/a><a class='is-down'><\/nobr><\/td>"),$("td:first-child",v).before(b),v.hasClass("is-sel")&&(u=c);k=$("tr.group-header > td",f);d=$("thead > tr > th",f).length;k.attr("colspan",d);s.ContentElement().append(e);f.bind("keydown",function(n){switch(n.keyCode){case 35:return u=h-1,o(),!1;case 36:return u=0,o(),!1;case 33:return u-=10,u<0&&(u=0),o(),!1;case 34:return u+=10,u>h-1&&(u=h-1),o(),!1;case 38:return u>0&&(n.ctrlKey?p():(u-=1,o())),!1;case 40:return u<h-1&&(n.ctrlKey?w():(u+=1,o())),!1}});$("a.is-up",f).on("click",function(n){n.stopPropagation();var t=$(n.delegateTarget).closest("tr.datarow");y(t[0]);p()});$("a.is-down",f).on("click",function(n){n.stopPropagation();var t=$(n.delegateTarget).closest("tr.datarow");y(t[0]);w()});$("tbody > tr.datarow",f).on("click",function(n){var t=$(n.delegateTarget).closest("tr.datarow");y(t[0]);o()});o();f.attr("tabindex","-1");window.setTimeout(function(){f.focus()},100)},n}($UI||{});console.log("  $UI (grid extension)");console.log("Loading lib/isuserinterface_finc.js");__UIExtFinC=function(n){var t={};return n.ContactDetailsComboBox=function(t,i){function u(t,i){for(var u,f="Value,Description",e="",s=!1,h=!1,o=0;o<t.length;o++)u=t[o],u.Current||(s=!0),u.Warning&&(h=!0),u.Current&&!e&&(e=u.Value);s&&(n.AlwaysUsePickerControls()||(f+=",Current"));h&&(n.AlwaysUsePickerControls()||(f+=",Warning"));r.RefreshFromCollection(t,"Value","Description",f);i&&!r.Text()&&r.Text(e)}var r;return i.maxLength=100,i.width="18em",r=n.DBCombo(t,i),_self={TypeName:"ContactDetailsComboBox",AllowBlank:r.AllowBlank,AutoReadOnly:r.AutoReadOnly,Focus:r.Focus,ReadOnly:r.ReadOnly,SetComboFromContactDetailsList:u,Text:r.Text,WidthResizeFromParent:r.WidthResizeFromParent}},n.DateCycleComboBox=function(t,i){function s(){r.ListFromCsvString(i.list)}function h(){var n=r.Text();n?u===n||(r.DescriptionUpdate(""),$App.HtmlWidget_SystemGetString("GetDateCycleDescription",{dateCycle:n,isFrequency:f.isFrequency},function(n){var e;if(n){var s=n.indexOf("|"),t=n,f="";s!==-1&&(f=t.substr(s+1),t=t.substr(0,s),t.toUpperCase()==f.toUpperCase()&&(t=""));r.DescriptionUpdate(t);f&&(r.Text(f),u=f)}else if(r.ListExists(o()))r.DescriptionUpdate("");else if(i.listOther){var h=$Runtime.ArrayFromCsvString(i.listOther),c=!1,l=o().toUpperCase();for(e=0;e<h.length;e++)if(l===h[e].toUpperCase()){c=!0;break}c?r.DescriptionUpdate(""):r.DescriptionUpdate("Invalid",!1,!0)}else r.DescriptionUpdate("Invalid",!1,!0)},function(n){console.warn("userinterface.DateCycleComboBox: Failed to retrieve Date Cycle Description: "+n)})):r.DescriptionUpdate("")}function c(n){f.list=n;s()}function l(n){f.listOther=n;s()}function o(n){if(n==undefined)return r.Text();n!=u&&(r.Text(n),h());u=n}var r,f=i,u="",e=null;return i.showColumnHeadings=!1,i.showDescription===!1?i.showDescription=!1:i.showDecription=!0,i.maxLength=20,i.isFrequency=i.isFrequency?!0:!1,i.width===undefined&&(i.width="12em"),i.list===undefined&&(i.list=""),i.listOther===undefined&&(i.listOther=""),e=i.onChange,i.onChange=function(n,t){h();e?e(n,t):t&&(t.ChangeHandled=!0);u=r.Text()},r=n.DBCombo(t,i),r.ListFromCsvString(""),r.WidthResizeFromParent(),_self={TypeName:"DateCycleComboBox",ListFromCsvString:c,ListOtherFromCsvString:l,AllowBlank:r.AllowBlank,AutoReadOnly:r.AutoReadOnly,BlankTip:r.BlankTip,Caption:r.Caption,Element:r.Element,Focus:r.Focus,LimitToList:r.LimitToList,ReadOnly:r.ReadOnly,Text:o,Visible:r.Visible,VisibleRow:r.VisibleRow,WidthResizeFromParent:r.WidthResizeFromParent}},n.HtmlColourComboBox=function(t,i){function s(){r.ListFromCsvString("Pink,LightPink,HotPink,DeepPink,PaleVioletRed,MediumVioletRed,LightSalmon,Salmon,DarkSalmon,LightCoral,IndianRed,Crimson,FireBrick,DarkRed,Red,OrangeRed,Tomato,Coral,DarkOrange,Orange,Yellow,LightYellow,LemonChiffon,LightGoldenrodYellow,PapayaWhip,Moccasin,PeachPuff,PaleGoldenrod,Khaki,DarkKhaki,Gold,Cornsilk,BlanchedAlmond,Bisque,NavajoWhite,Wheat,BurlyWood,Tan,RosyBrown,SandyBrown,Goldenrod,DarkGoldenrod,Peru,Chocolate,SaddleBrown,Sienna,Brown,Maroon,DarkOliveGreen,Olive,OliveDrab,YellowGreen,LimeGreen,Lime,LawnGreen,Chartreuse,GreenYellow,SpringGreen,MediumSpringGreen,LightGreen,PaleGreen,DarkSeaGreen,MediumSeaGreen,SeaGreen,ForestGreen,Green,DarkGreen,MediumAquamarine,Aqua,Cyan,LightCyan,PaleTurquoise,Aquamarine,Turquoise,MediumTurquoise,DarkTurquoise,LightSeaGreen,CadetBlue,DarkCyan,Teal,LightSteelBlue,PowderBlue,LightBlue,SkyBlue,LightSkyBlue,DeepSkyBlue,DodgerBlue,CornflowerBlue,SteelBlue,RoyalBlue,Blue,MediumBlue,DarkBlue,Navy,MidnightBlue,Lavender,Thistle,Plum,Violet,Orchid,Fuchsia,Magenta,MediumOrchid,MediumPurple,BlueViolet,DarkViolet,DarkOrchid,DarkMagenta,Purple,Indigo,DarkSlateBlue,RebeccaPurple,SlateBlue,MediumSlateBlue,White,Snow,Honeydew,MintCream,Azure,AliceBlue,GhostWhite,WhiteSmoke,Seashell,Beige,OldLace,FloralWhite,Ivory,AntiqueWhite,Linen,LavenderBlush,MistyRose,Gainsboro,LightGrey,Silver,DarkGray,Gray,DimGray,LightSlateGray,SlateGray,DarkSlateGray,Black")}function o(){var n=r.Text(),t;u==n||(n||e.blankTip?(t=n||e.blankTip,r.DescriptionUpdate("<div style='background-color:"+$Runtime.HtmlEncode(t)+";border:1px solid rgba(0,0,0,0.1); width:20px; height:20px; overflow:hidden; position:relative; top:1px'><\/div>",!0)):r.DescriptionUpdate(""))}function h(n){if(n==undefined)return r.Text();n!=u&&(r.Text(n),o());u=n}var r,e=i,u="",f=null;return i.showColumnHeadings=!1,i.showDescription=!0,i.maxLength=50,i.changeWhileTyping=!0,i.width==undefined&&(i.width="16em"),i.list==undefined&&(i.list=""),f=i.onChange,i.onChange=function(n,t){o();f?f(n,t):t&&(t.ChangeHandled=!0);u=r.Text()},i.onFormatArrayItem=function(n,t){t.displayValue="<div style='background-color:"+$Runtime.HtmlEncode(t.displayValue)+";border:1px solid rgba(0,0,0,0.1); width:20px; height:20px; overflow:hidden; display:inline-block; vertical-align:middle'><\/div>&nbsp;"+t.displayValue},r=n.DBCombo(t,i),r.ListFromCsvString(""),r.WidthResizeFromParent(),s(),_self={TypeName:"HtmlColourComboBox",AllowBlank:r.AllowBlank,AutoReadOnly:r.AutoReadOnly,BlankTip:r.BlankTip,Caption:r.Caption,Element:r.Element,Focus:r.Focus,ReadOnly:r.ReadOnly,Text:h,Visible:r.Visible,VisibleRow:r.VisibleRow,WidthResizeFromParent:r.WidthResizeFromParent}},n.InformationListComboBox=function(t,i){function e(n,t,i,e){t===undefined&&(t=!1);n?(r.SetFetchingData(!0),r.ShowDescription(!1),f.width||r.WidthResizeFromParent(),$App.GetInformationList(n,function(n){var s,o;if(n){if(n.ValuesAlt){for(s=[],o=0;o<n.Values.length;o++)s.push({Value:n.Values[o],Description:n.ValuesAlt[o]});r.RefreshFromCollection(s,"Value","Description","Value,Description");r.ShowDescription(!0);r.WidthResizeFromParent(!1)}else{for(s=[],o=0;o<n.Values.length;o++)s.push({Value:n.Values[o]});r.RefreshFromCollection(s,"Value","","Value");s.length===0&&f.blankList&&r.ListFromCsvString(f.blankList);r.ShowDescription(!1)}u=n;t&&r.AllowBlank(!u.Mandatory);r.LimitToList(u.LimitToList);r.MaxLength(u.MaxLength);e&&!r.Text()&&u.DefaultValue&&r.Text(u.DefaultValue);i&&i()}else i&&i();r.SetFetchingData(!1);f.width||r.WidthResizeFromParent(n.ValuesAlt?!1:!0)})):(r.LimitToList(!1),r.ListFromCsvString(f.blankList),r.ShowDescription(!1),r.WidthResizeFromParent())}function o(n,t,i){var f="",o;if(t){for(o=0;o<t.length;o++)f+=t[o]+"|";f=f.toUpperCase()}e(n,!1,function(){for(var n,c,t,h,o,e=[],s=0;s<u.Values.length;s++)if(n=u.Values[s],f?(c=n.toUpperCase(),c.substr(0,f.length)==f?(n=n.substr(f.length),t=n.indexOf("|"),t!=-1&&(n=n.substr(0,t))):n=null):(t=n.indexOf("|"),t!=-1&&(n=n.substr(0,t))),n){for(h=!1,o=0;o<e.length;o++)if(n.toUpperCase()==e[o].Value.toUpperCase()){h=!0;break}h||e.push({Value:n})}r.RefreshFromCollection(e,"Value","","Value");i&&i()},!1)}function s(n,t,i,f){var o=[],s=[];e(n,!0,function(){var e,h,l,c,n;if(u){for(n=0;n<u.Values.length;n++)e=u.Values[n],h=e.indexOf("|"),h==-1?s.push(e):(l=e.substr(0,h),l.toUpperCase()==t.toUpperCase()&&o.push(e.substr(h+1)));o.length==0&&(o=s);i&&$Runtime.StringArrayAddUnique(o,i);switch(f){case 510:case 500:list.push("Completed");list.push("Deleted")}for(c=[],n=0;n<o.length;n++)c.push({Value:o[n]});r.RefreshFromCollection(c,"Value","","Value")}})}var r,u=null,f=i;return i.showColumnHeadings=!1,i.showDescription=!1,i.maxLength||(i.maxLength=50),i.blankList||(i.blankList=""),r=n.DBCombo(t,i),_self={TypeName:"InformationListComboBox",SetComboFromInformationList:e,SetComboFromSectionedInformationList:o,SetLogOutcomeComboFromSectionedInformationList:s,AllowBlank:r.AllowBlank,AutoReadOnly:r.AutoReadOnly,BlankTip:r.BlankTip,Caption:r.Caption,Focus:r.Focus,ReadOnly:r.ReadOnly,Text:r.Text,Visible:r.Visible,VisibleRow:r.VisibleRow,WidthResizeFromParent:r.WidthResizeFromParent}},n.LogSeveritiesDBCombo=function(t,i){var r;return i.width=FIELD_WIDTH_CODE_5,r=n.DBCombo(t,i),r.RefreshFromCollection($App.LogSeverities(),"LogSeverityId","Description","LogSeverityId,Description"),_self={TypeName:"LogSeveritiesDBCombo",AllowBlank:r.AllowBlank,AutoReadOnly:r.AutoReadOnly,Focus:r.Focus,ReadOnly:r.ReadOnly,Text:r.Text,WidthResizeFromParent:r.WidthResizeFromParent}},n.UsersDBCombo=function(t,i){var r;if(i.width=FIELD_WIDTH_CODE_20,i.maxLength||(i.maxLength=20),i.filter){i.filter=i.filter.toUpperCase();switch(i.filter){case"":case"ACCOUNTAUTHORISER":break;default:console.warn("UsersDBCombo: Invalid filter '"+i.filter+"'")}}else i.filter="";return r=n.DBCombo(t,i),!$App.UsersLoad(function(){var n,u,t,f;if($App.Users()){n=$App.Users();switch(i.filter){case"ACCOUNTAUTHORISER":for(u=[],t=0;t<n.length;t++)f=n[t],f.IsAccountAuthoriser&&u.push(f);n=u}r.RefreshFromCollection(n,"UserId","Name","UserId,Name,Active")}}),_self={TypeName:"UsersDBCombo",AllowBlank:r.AllowBlank,AutoReadOnly:r.AutoReadOnly,Focus:r.Focus,ReadOnly:r.ReadOnly,Text:r.Text,Visible:r.Visible,VisibleRow:r.VisibleRow,WidthResizeFromParent:r.WidthResizeFromParent}},n.ExternalPartyEmployeesDBCombo=function(i,r){function o(n,i){if(e="",n){if(f=t[n.toUpperCase()],f){console.info("ExternalPartyEmployeesDBCombo: Employees for '"+n+"' retrieved from cache.");u.RefreshFromCollection(f,"ClientEmploymentId","IndividualName","ClientEmploymentId,IndividualName");i&&i();return}u.SetFetchingData(!0);u.WidthResizeFromParent();$App.HtmlWidget_SystemGetString("GetExternalPartyEmployees",{id:n},function(r){var h,s,c,l,o;for(r=JSON.parse(r),h=[],s=0;s<r.Rows.length;s++){for(c={},l=r.Rows[s],o=0;o<r.Columns.length;o++)c[r.Columns[o].Name]=l[o];h.push(c)}f=h;t[n.toUpperCase()]=f;u.RefreshFromCollection(f,"ClientEmploymentId","IndividualName","ClientEmploymentId,IndividualName");e=n;u.SetFetchingData(!1);u.WidthResizeFromParent();i&&i()},function(n){$App.NotificationsAddError(n,"",!0,"Error");u.SetFetchingData(!1)})}else u.LimitToList(!1),u.RefreshFromCollection([],"ClientEmploymentId","IndividualName","ClientEmploymentId,IndividualName")}var u,f=null,e="";return r.width=FIELD_WIDTH_CODE_20,r.maxLength||(r.maxLength=20),r.LimitToList=!1,u=n.DBCombo(i,r),_self={TypeName:"ExternalPartyEmployeesDBCombo",ExernalPartyId:function(){return e},RefreshForExternalParty:o,AllowBlank:u.AllowBlank,AutoReadOnly:u.AutoReadOnly,Focus:u.Focus,ReadOnly:u.ReadOnly,Text:u.Text,Visible:u.Visible,VisibleRow:u.VisibleRow,WidthResizeFromParent:u.WidthResizeFromParent}},n.AccountWarnings=function(t){function o(){var t,n,r;if(i){for(t=0,n=0;n<i.length;n++)r=i[n],r.Severity=="Error"&&(t+=1);return t}return 0}function s(){var t,n,r;if(i){for(t=0,n=0;n<i.length;n++)r=i[n],r.Severity!="Alert"||r.Accept||(t+=1);return t}return 0}function h(){return f}function c(n){i=n;r.VirtualDataRefresh(i)}function l(n){var t=i[n.row.listIndex];n.row.cells.Accept.value=t.Accept;n.row.cells.ClientId.value=t.ClientId;n.row.cells.ClientName.value=t.ClientName;n.row.cells.Summary.value=t.Summary;switch(t.Severity){case"Alert":n.row.cells.Icon.value="Warning";n.row.cells.Accept.readOnly=!1;break;case"Error":n.row.cells.Icon.value="Error";n.row.cells.Accept.readOnly=!0;break;case"Information":n.row.cells.Icon.value="Information";n.row.cells.Accept.readOnly=!0}t.ClientId&&(n.row.cells.ClientId.hyperlink="app://formshow?form=Client&id="+encodeURI(t.ClientId))}function a(n){var t=i[n.row.listIndex];switch(n.columnKey){case"Accept":t.Accept=n.newValue;break;default:window.alert("Column '"+n.columnKey+"' not handled.")}n.refreshRow=!1}var i,f,r,u,e;if(typeof t=="string"?(u=n.ExtUtils.TranslateElementId(t),t=$("#"+u)):u=$(t).attr("id"),e=$(t),e.length==0){console.warn("userinterface.AccountWarnings: Element '"+u+"' not found.");return}return f=$(e[0]),r=n.Grid(f,{rowNumbering:!0,onBeforeCellUpdate:a,onInitialiseRow:l}),r.AddColumnIcon("Icon",{}),r.AddColumnBoolean("Accept",{caption:"Accept",width:"3em",allowEdit:!0}),r.AddColumnString("ClientId",{caption:"Client",width:"6em"}),r.AddColumnString("ClientName",{caption:"Name",width:"16em",truncate:!0}),r.AddColumnString("Summary",{caption:"Summary"}),_self={TypeName:"AccountWarnings",CountErrors:o,CountToAccept:s,Element:h,Focus:r.Focus,Refresh:c}},n.RangeTextBox=function(t,i){function u(){$App.FormOpen("RangeLookup","",{caption:i.lookupCaption,rangeSource:i.rangeSource,rangeType:i.rangeType,rangeLookupSql:i.RangeLookupSql,idField:i.RangeLookupIdField,fieldList:i.RangeLookupFieldList,sourceControl:r},null)}var r;return i.actionsButtonVisible=!0,i.actionsButtonIcon="Find",i.onActionsButtonClick=u,i.rangeType||(i.rangeType="Standard"),i.lookupCaption||(i.lookupCaption="Lookup"),r=n.TextBox(t,i),_self={TypeName:"RangeTextBox",AllowBlank:r.AllowBlank,AutoReadOnly:r.AutoReadOnly,Focus:r.Focus,ReadOnly:r.ReadOnly,Text:r.Text,Visible:r.Visible,VisibleRow:r.VisibleRow,WidthResizeFromParent:r.WidthResizeFromParent}},n.SavedParametersGrid=function(t,i){function o(n){u=n;n?r.VirtualDataRefresh(u):r.VirtualDataRefresh([])}function s(n){var t=u[n.row.listIndex];n.row.cells.Name.value=t.Name;n.row.cells.ParameterType.value=t.ParameterType;n.row.cells.Value.value=t.Value;n.row.cells.DefaultValueExpression.value=t.DefaultValueExpression;n.row.cells.Visible.value=t.Visible;n.row.cells.Name.readOnly=!0;n.row.cells.ParameterType.readOnly=!0}function h(n){var t=u[n.row.listIndex];switch(n.columnKey){case"DefaultValueExpression":t.DefaultValueExpression=n.newValue;break;case"Value":t.Value=n.newValue;break;case"Visible":t.Visible=n.newValue}n.refreshRow=!1}function c(n){if(f.onAction)f.onAction(n)}function l(n){var t=u[n.row.listIndex];switch(n.columnKey){case"Drilldown_Expression":$App.FormOpen("ExpressionBuilder","",{caption:"Formula to Calculate Parameter",expression:t.DefaultValueExpression,callback:function(i){t.DefaultValueExpression=i;r.RefreshRow(n.row.listIndex)}})}}var r,f,u,e;return f=$.extend({},{showLoadDefaultParametersAction:!0},i),r=n.WidgetGrid(t,{rowNumbering:!0,allowEdit:!0,allowMultiRowSelect:!1,autoShiftButtons:!1,onAction:c,onBeforeCellUpdate:h,onInitialiseRow:s,onRowDrilldown:l}),r.ClearColumns(),r.AddColumnString("Name",{caption:"Name",width:"8em",allowEdit:!1,readOnly:!0}),r.AddColumnString("ParameterType",{caption:"Type",width:"5em",allowEdit:!1,readOnly:!0}),r.AddColumnString("Value",{caption:"Value",allowEdit:!0}),r.AddColumnString("DefaultValueExpression",{caption:"Formula",allowEdit:!0}),r.AddColumnDrilldown("Drilldown_Expression",{icon:"Expression"}),r.AddColumnBoolean("Visible",{caption:"Visible",width:"1em",allowEdit:!0}),e=[],f.showLoadDefaultParametersAction&&e.push({actionId:"LoadDefaultParameters",caption:"Load Default Parameters",icon:"ParameterSet|Import"}),r.Actions().Define(e),_self={TypeName:"SavedParametersGrid",Initialise:o,Focus:r.Focus,ReadOnly:r.ReadOnly,Visible:r.Visible,ResizeFromParent:r.ResizeFromParent}},n.ExtendedAuditInformation=function(t,i){function l(t){e=t;var r=$(".eaicreated",f),i="";if(i+="<table class='is-table-info'>",i+="<tr><td class='is-heading' colspan='2'><h2>Creation and Last Updated details<\/h2><\/td><\/tr>",i+="<tr><td colspan='2'>",i+=t.CreationDetails+"<br/>",i+=t.UpdatedDetails,i+="<\/td><\/tr>",i+="<\/table>",t.ShowUserDataDetails&&(t.UserDataXml||t.UserDataWebXml)&&(i+="<tr><td class='is-heading' colspan='2'><h2>User Data<\/h2><\/td><\/tr>",i+="<tr><td colspan='2'>",t.UserDataXml&&(i+="<button class='is-button normal cmduserdata'>User Data<\/button>"),t.UserDataWebXml&&(i+="<button class='is-button normal cmduserdataweb'>Web Data<\/button>"),i+="<\/td><\/tr>"),r.html(i),t.ShowUserDataDetails){if(t.UserDataXml)$(".cmduserdata",f).on("click",function(){n.CommonDialog().ShowHtml("User Data",$Runtime.HtmlEncode(t.UserDataXml))});if(t.UserDataWebXml)$(".cmduserdataweb",f).on("click",function(){n.CommonDialog().ShowHtml("Web User Data",$Runtime.HtmlEncode(t.UserDataWebXml))})}e?u.VirtualDataRefresh(e.AuditItems):u.VirtualDataRefresh([]);s.Initialise($("table",u.Element()));s.BlankTip("Type to filter list ("+e.AuditItems.length+" items)")}function a(n){var t=e.AuditItems[n.row.listIndex];n.row.cells.Date.value=t.D;n.row.cells.UserId.value=t.U;n.row.cells.Action.value=t.A;n.row.cells.Key.value=t.K;n.row.cells.SubKey.value=t.S;n.row.cells.ValueOriginal.value=t.O;n.row.cells.ValueNew.value=t.N}var f,u,c,e,s,o,h,r;if(c=$.extend({},{},i),typeof t=="string"?(o=n.ExtUtils.TranslateElementId(t),t=$("#"+o)):o=$(t).attr("id"),h=$(t),h.length==0){console.warn("userinterface.ExtendedAuditInformation: Element '"+o+"' not found.");return}return f=$(h[0]),r="",r+="<div style='display:flex; flex-direction:column; position:absolute; top:0; left:0; right:0; bottom:0; padding:8px'>",r+="  <div class='is-summarypage-2 is-embedded' style='flex-grow:0'>",r+="    <div class='is-sectioned-page'>",r+="      <div class='is-page-section'>",r+="        <div class='is-page-section-header is-no-select is-locked'>Audit<\/div>",r+="        <div class='eaicreated'><\/div>",r+="      <\/div>",r+="    <\/div>",r+="  <\/div>",r+="  <div style='flex-grow:0'><h1 class='is-section-heading'>Audited Changes<\/h1><\/div>",r+="  <div style='flex-grow:0; padding-left:8px'>",r+="    <div style='margin-bottom:4px; max-width:620px'>",r+="      <input type='search' style=''/>",r+="    <\/div>",r+="  <\/div>",r+="  <div style='flex-grow:1; border-left:8px solid transparent; position:relative'>",r+="    <div class='is-grid is-dock-fill'><\/div>",r+="  <\/div>",r+="<\/div>",f.append(r),u=n.Grid($(".is-grid",f),{allowSearchBox:!1,rowNumbering:!0,onInitialiseRow:a}),u.ClearColumns(),u.AddColumnDateTime("Date",{caption:"Date"}),u.AddColumnString("UserId",{caption:"User",width:"5em"}),u.AddColumnString("Action",{caption:"Action",width:"5em"}),u.AddColumnString("Key",{caption:"Key",width:"5em"}),u.AddColumnString("SubKey",{caption:"Sub Key",width:"5em"}),u.AddColumnString("ValueOriginal",{caption:"Original",width:"50%"}),u.AddColumnString("ValueNew",{caption:"New",width:"50%"}),s=n.TableFilterTextBox($("input",f),{allowBlank:!0,blankTip:"Type to filter list",maxLength:100}),_self={TypeName:"ExtendedAuditInformation",Initialise:l}},n}($UI||{});console.log("  $UI (finPOWER Connect extension)");console.log("Loading lib/isuserinterface_navigation.js");__UIExtNavigation=function(n){function t(n){for(var r,u,i=0;i<n.length;i++)n[i]=$.extend({},MenuItemDefaults,n[i]),r=n[i],r.Action&&r.Action.toUpperCase().substr(0,4)=="APP:"&&(u=$Ash.ParseUrl(r.Action),r.AllowMultiInstance=u.Parameters.GetBoolean("allowMultiInstance")),n[i].MenuItems&&n[i].MenuItems.length!=0&&t(n[i].MenuItems)}return MenuItemDefaults={ItemId:"",ItemType:"Normal",Caption:"",Icon:"",IconUrl:"",IconClass:"",MenuItems:[],Enabled:!0,Visible:!0,AllowMultiInstance:!1,System:!1,Indent:!1},n.MenuItemFind=function(t,i){var r,u;for(i=i.toUpperCase(),r=0;r<t.length;r++){if(t[r].ItemId&&t[r].ItemId.toUpperCase()==i)return t[r];if(t[r].MenuItems&&t[r].MenuItems.length!=0&&(u=n.MenuItemFind(t[r].MenuItems,i),u))return u}return null},n.MenuItemSetEnabled=function(t,i,r){var u=n.MenuItemFind(t,i);u&&(u.Enabled=r)},n.MenuItemSetVisible=function(t,i,r){var u=n.MenuItemFind(t,i);u&&(u.Visible=r)},n.MenuPanel=function(i){function b(){return c}function k(n){o=n;t(o)}function d(){var e,t,i,h,s;u.children().remove();t=$("<div><\/div>");r.collapsibleGroups&&t.addClass("collapsible-groups");(r.caption||r.showCloseButton)&&(i=$("<div class='caption is-no-select'><\/div>"),r.captionHtml?i.html(r.captionHtml):i.text(r.caption),r.showCloseButton&&(h=$("<a><span class='is-symbol-close'><\/span><\/a>"),h.click(function(){p()}),i.append(h)),u.append(i),t.addClass("hascaption"));f=="-"||(f?(s=n.MenuItemFind(o,f),s?(e=a(s.MenuItems,!1,s.Priority==999),t.append(e)):console.warn("$UI.MenuPanel: Could not find sub-menu '"+f+"'.")):(e=a(o,!1,!1),t.append(e)));r.collapsibleGroups&&$("li.collapsible",t).click(function(){var n=$(this);n.hasClass("expanded")?(n.removeClass("expanded"),$("ul.collapsible",t).slideUp("fast")):($("li.expanded",t).removeClass("expanded"),n.addClass("expanded"),$("ul.collapsible",t).slideUp("fast"),$("ul.collapsible",n).slideDown("fast"))});c=$("<div><\/div>");t.append(c);u.append(t);v()}function a(t,i,u){var h=$("<ul class='is-no-select'><\/ul>"),l,f,p,v,o,s,tt,k,d;for(i&&r.collapsibleGroups&&(h.addClass("collapsible"),u&&h.addClass("system"),h.css("display","none")),l=0;l<t.length;l++){if(f=t[l],p=!0,e&&e.length>0)for(v=0;v<e.length;v++)if(f.ItemId==e[v]){p=!1;break}if(p){if(o=$("<li itemtype='"+f.ItemType+"' itemId='"+f.ItemId+"'><\/li>"),s=$("<a><\/a>"),o.attr("itemid",f.ItemId),s.text(f.Caption),o.append(s),r.collapsibleGroups&&f.ItemType=="SubMenu"&&(o.addClass("collapsible"),f.Priority==999&&o.addClass("system")),f.Icon&&$Api){var c=f.Icon,nt="",b=c.indexOf("|");b!=-1&&(nt=c.substr(b+1),c=c.substr(0,b));tt="<img src='"+$Api.GetIconUrl(c,16,nt,!0)+"' />";s.prepend(tt)}f.Visible||o.css("display","none");o.attr("Enabled",""+f.Enabled);f.Enabled&&f.AllowMultiInstance&&(k=$("<a class='multi-instance' title='Open a new instance'><a>"),s.append(k),function(n){k.click(function(t){t.stopPropagation();y(n,!0)})}(f));f.System&&o.addClass("system");f.Indent&&o.addClass("indent");h.append(o);f.MenuItems&&f.MenuItems.length!=0?(d=a(f.MenuItems,!0,f.Priority==999),o.addClass("is-menu-sub"),o.append(d)):function(t,i){s.click(function(n){n.stopPropagation();r.selectableItems&&w(t.ItemId);y(t,!1)});r.showContextMenu&&n.HandleContextMenuEvent(i,function(n){return g(t.ItemId,n),n.preventDefault(),!1})}(f,o)}}return h}function g(t,i){if(!r.onDefineContextMenuItems){window.alert("onDefineContextMenuItems is not handled.");return}var f=[];r.onDefineContextMenuItems(t,f);f.length!=0&&(s||(s=new n.MenuPopup(u,{onClose:function(){$("li",u).removeClass("right-clicked")}})),s.OnAction(function(n){r.onContextMenuItemAction(t,n)}),s.Define(f),f.length!=0&&($("li[itemId='"+t+"']",u).addClass("right-clicked"),s.Show(i.clientX,i.clientY)))}function v(){r.selectableItems&&($("li",u).removeClass("selected"),$("li[itemId='"+l+"']",u).addClass("selected"))}function y(n,t){if(n.Enabled)if(n.Action)if(r.onAction)r.onAction(n.Action,n.ItemId,t);else window.alert("No onAction handler specified for this menu.");else if(r.selectableItems&&r.onAction)r.onAction(n.Action,n.ItemId,t)}function nt(n){if(n==undefined)return h;h=n}function tt(n){if(n==undefined)return r.caption;n&&(r.captionHtml="");r.caption=n}function it(n){if(n==undefined)return r.captionHtml;n&&(r.caption="");r.captionHtml=n}function p(){r.onClose?r.onClose():(u.hide(),h=!1)}function rt(n){if(n==undefined)return r.collapsibleGroups;r.collapsibleGroups=n}function ut(n){if(n==undefined)return f;f=n}function ft(n){if(n==undefined)return e;e=n}function w(n){if(n==undefined)return l;l=n;v()}var h=!0,c,u,o=[],s,f="",l="",e=[],r;MenuPanelDefaults={menuElement:null,selectableItems:!1,caption:"",captionHtml:"",collapsibleGroups:!1,autoClose:!0,autoCloseIgnoreElements:null,showCloseButton:!0,showContextMenu:!1,onAction:null,onClose:null,onContextMenuItemAction:null,onDefineContextMenuItems:null};r=$.extend({},MenuPanelDefaults,i);u=r.menuElement;u.on("contextmenu",function(){return!1});if(r.autoClose)u.on("mousedownoutside",function(n){if(h){if(r.autoCloseIgnoreElements)for(var t=0;t<r.autoCloseIgnoreElements.length;t++)if(r.autoCloseIgnoreElements[t]==n.target||$.contains(n.target,r.autoCloseIgnoreElements[t])||$.contains(r.autoCloseIgnoreElements[t],n.target))return!1;p()}});return{TypeName:"MenuPanel",Active:nt,Caption:tt,CaptionHtml:it,CollapsibleGroups:rt,Items:o,Define:k,ExcludeSubItemIds:ft,RenderSubItemsId:ut,Refresh:d,SelectedItemId:w,AdditionalContentElement:b}},n.MenuPopup=function(n,i){function a(n){s=n;t(s)}function v(n,t){var i,n;if(!h){if(h=!0,n!=undefined?r.css({left:n,top:t}):(i=c.offset(),r.css({left:i.left,top:i.top})),s&&y(r,u,s),u.forceOverlay){if(!f){f=$("<div class='is-modal-overlay top' style='background-color:rgba(0,0,0,0.2)' tabindex='-1'><\/div>");$("body").append(f);$("body").on("keydown.contextmenu",function(n){switch(n.keyCode){case 27:e()}})}f.mousedown(e)}r.removeClass("active");$("body").append(r);r.show();window.setTimeout(function(){r.addClass("active")},10);u.forceOverlay?f.focus():(o&&(window.clearInterval(o),o=null),document.activeElement&&document.activeElement.tagName=="IFRAME"&&(navigator.userAgent.toLowerCase().indexOf("firefox")>-1||(document.activeElement.blur(),r[0].focus(),o=window.setInterval(function(){document.activeElement&&document.activeElement.tagName=="IFRAME"&&e()},250))));var l=$(document).innerWidth(),v=r.offset(),a=r.innerWidth();v.left+a>l-4&&(n=l-a-4,r.css("left",n))}}function e(){r.remove();o&&(window.clearInterval(o),o=null);h&&(h=!1,r.hide());f&&($("body").off("keydown.contextmenu"),f.remove(),f=null);u.onClose&&u.onClose()}function y(){var f,n,t,i;r.children().remove();n=$("<div><\/div>");(u.caption||u.showCloseButton)&&(t=$("<div class='caption is-no-select'><\/div>"),t.text(u.caption),u.showCloseButton&&(i=$("<a><span class='is-symbol-close'><\/span><\/a>"),i.click(function(){u.onClose?u.onClose():e()}),t.append(i)),r.append(t),n.addClass("hascaption"));f=l(u,s,!1);n.append(f);r.append(n)}function l(n,t){for(var i,r,u,s,h,c,o=$("<ul class='is-no-select'><\/ul>"),f=0;f<t.length;f++)i=t[f],r=$("<li itemtype='"+i.ItemType+"'><\/li>"),u=$("<a><\/a>"),r.attr("itemid",i.ItemId),u.text(i.Caption),r.append(u),i.Icon&&$Api&&(i.IconUrl=$Api.GetIconUrl(i.Icon)),i.IconUrl?(h="<img src='"+i.IconUrl+"' />",u.prepend(h)):i.IconClass&&(c="<div class='is-menu-item-glyph "+i.IconClass+"'><\/div>",u.prepend(c)),i.Visible||r.css("display","none"),r.attr("Enabled",""+i.Enabled),o.append(r),i.MenuItems&&i.MenuItems.length!=0?(s=l(n,i.MenuItems,!0),r.addClass("is-menu-sub"),r.append(s)):function(t){u.click(function(){if(t.Action||t.ItemId){if((t.Action||t.ItemId)&&t.Enabled)if(e(),n.onAction)n.onAction(t.Action||t.ItemId,t.ItemId);else window.alert("No onAction handler specified for this menu.")}else e()})}(i);return o}function p(n){if(n==undefined)return u.caption;u.caption=n}function w(n){u.onAction=n}function b(){r.focus()}var r,s=[],f=null,c,h=!1,o=null,u;MenuPopupDefaults={onAction:null,caption:"",autoClose:!0,showCaption:!1,showCloseButton:!1,onClose:null,forceOverlay:!0};u=$.extend({},MenuPopupDefaults,i);$Runtime.IsPlatformIOS()&&(u.forceOverlay=!0);c=n;r=$("<div style='display:none; position:fixed; min-width:200px; top:0; left:0;' class='is-popup-menu'><\/div>");r.on("contextmenu",function(){return!1});if(!u.forceOverlay)r.on("mousedownoutside focusoutside selectoutside keydownoutside",function(){e()});return{TypeName:"MenuPopup",Caption:p,Items:s,Define:a,Show:v,Hide:e,Focus:b,OnAction:w}},n}($UI||{});console.log("  $UI (navigation extension)");console.log("Loading lib/isuserinterface_previewpane.js");__UIExtPreviewPane=function(n){return n.PreviewPane=function(t,i){function g(){f.addClass("is-preview-pane");c.visible?f.show():f.hide()}function rt(){return f}function k(n,t){a[n]=t}function ut(){a={}}function p(n){return a[n]!=undefined}function ft(n){p(n)&&delete a[n]}function v(){r="";var n=e[0].contentDocument;n.open();n.write("");n.close();h=!1}function et(){return h}function ot(){return s}function st(n,t){v();s=!0;u.attr("available",!1);$Api.GetDirect(n,t,{done:function(n){var t=n;l(t,!1,{});h=!0},fail:function(n){w(n)},always:function(){s=!1;u.attr("available",!0)}})}function ht(n,t,i){var r,f;if(t.GetCacheKey){if(!t.GetPreviewFetchParameters){window.alert("Grid.PreviewFromGridCollection: Collection does not provide a GetPreviewFetchParameters method.");return}}else{window.alert("Grid.PreviewFromGridCollection: Collection does not provide a GetCacheKey method.");return}if(r=n.ActiveDataRowListIndex(),r==-1){v();return}if(f=t.GetCacheKey(r),p(f)){d(f,!1,{});return}v();setTimeout(function(){r==n.ActiveDataRowListIndex()&&(s=!0,u.attr("available",!1),$Api.GetDirect(i,t.GetPreviewFetchParameters(r),{done:function(i){var r=i;k(f,r);f==t.GetCacheKey(n.ActiveDataRowListIndex())&&(l(r,!1,{}),h=!0)},fail:function(n){w(n)},always:function(){s=!1;u.attr("available",!0)}}))},150)}function ct(n,t){var i,r;if(n.NodeList().GetCacheKey){if(!n.NodeList().GetPreviewFetchParameters){window.alert("PreviewPane.PreviewFromTreeViewNode: TreeView node list does not provide a GetPreviewFetchParameters method.");return}}else{window.alert("PreviewPane.PreviewFromTreeViewNode: TreeView node list does not provide a GetCacheKey method.");return}if(i=n.SelectedNode(),!i){v();return}if(r=n.NodeList().GetCacheKey(i),p(r)){d(r,!1,{});return}v();setTimeout(function(){i.NodeId==n.SelectedNodeId()&&(s=!0,u.attr("available",!1),$Api.GetDirect(t,n.NodeList().GetPreviewFetchParameters(i),{done:function(t){var u=t,i;k(r,u);i=n.SelectedNode();i&&r==n.NodeList().GetCacheKey(i)&&(l(u,!1,{}),h=!0)},fail:function(n){w(n)},always:function(){s=!1;u.attr("available",!0)}}))},150)}function lt(){f.css({width:"100%",height:"100%",overflow:"visible",display:"block"});e.css({width:"100%",height:"100%",overflow:"auto"})}function l(n,t,i){var l=$.extend({},nt,i),o,a,v,f;h=!0;s=!1;u.attr("available",!0);r="";o="";l.cssSummaryPage2&&(a="",$App&&$App.Version&&(a="?v="+$App.Version()),o+="<link rel='stylesheet' type='text/css' href='"+$Runtime.WebRoot()+"Content/SummaryPage2/summarypage_2.css"+a+"'><\/link>",o+="<link rel='stylesheet' type='text/css' href='"+$Runtime.WebRoot()+"Content/SummaryPage2/summarypage_2_web.css"+a+"'><\/link>");$App&&(n=$App.NormaliseHtmlPreview(n));c.smartBackgroundColour&&n.indexOf("is-summarypage-blocks")!=-1&&e.css({"background-color":"#808080"});v=e[0].contentWindow;t||(r+="<!doctype html>",r+="<html>",r+="<head>",o||console.warn("No Resources!\n\no.cssSummaryPage2="+l.cssSummaryPage2),r+=o,r+="<\/head>",r+="<!-- body tag written in PreviewPane.SetContent -->",r+="<body style='margin:0;padding:0'>",l.formatAsSummaryPage2&&(r+="<div class='is-summarypage-2'>"));r+=n;t||(l.formatAsSummaryPage2&&(r+="<\/div>"),r+="<\/body>",r+="<\/html>");f=e[0].contentDocument;f&&(f.open(),f.write(r),f.close());f&&c.handleApplicationShortcuts&&(window.$Ash?$Ash.HandleIframe(e[0]):window.alert("Preview Pane cannot handle Application Shortcuts since no handler ($Ash) is available."))}function tt(n,t){var i="";i+="<div class='is-summarypage-2'>";i+="<div class='is-template-message'>";i+="<div class='is-template-message-error'>";i+=$Runtime.HtmlEncode(n);t&&(i+="<p>"+$Runtime.HtmlEncode(t)+"<\/p>");i+="<\/div>";i+="<\/div>";i+="<\/div>";l(i,!1)}function w(n){var t,i="",r="";try{t=$.parseJSON(n.responseText);t.Message&&(i=t.Message);t.InternalMessage&&(r=t.InternalMessage)}catch(u){}tt(i,r)}function d(n,t,i){a[n]==undefined?l("Item '"+n+"' does not exist in the Content Cache.",!1,{}):l(a[n],t,i)}function it(){if(!s&&h&&r){var i=n.CommonDialog().ShowHtml("Preview",r,{forceWindowed:!0,popup:!1}),t=n.FindParentModal(f);t&&t.OnAction()&&i.OnAction(t.OnAction())}}function at(n){if(n==undefined)return c.visible;c.visible=n;g()}function vt(n){if(!o&&(o=f.closest("tr"),o.length==0))return console.warn("PreviewPane.VisibleRow: no parent row element found."),o=null,!1;if(n==undefined)return o.css("visibility").toUpperCase()=="HIDDEN";n?(o.css("display","table-row"),o.css("visibility","")):(o.css("display","none"),o.css("visibility","hidden"))}var a={},r="",e,o,h=!1,s=!1,u,c,y,b,f,nt;if(PreviewPaneDefaults={handleApplicationShortcuts:!0,smartBackgroundColour:!0,collapsedCaption:"Preview",visible:!0},c=$.extend({},PreviewPaneDefaults,i),typeof t=="string"?(y=n.ExtUtils.TranslateElementId(t),t=$("#"+y)):y=$(t).attr("id"),b=$(t),b.length==0){console.warn("userinterface.PreviewPane: Parent element '"+y+"' not found.");return}return f=$(b[0]),u=$("<div class='collapsed-caption is-no-select' available='false'><\/div>"),u.html("<a>"+$Runtime.HtmlEncode(c.collapsedCaption)+"<\/a>"),f.append(u),$("a",u).click(function(){it()}),e=$("<iframe/>"),f.append(e),$Runtime.IsPlatformIOS()&&e.attr("scrolling","no"),g(),nt={cssSummaryPage2:!0,formatAsSummaryPage2:!1},_self={TypeName:"PreviewPane",CacheAdd:k,CacheClear:ut,CacheExists:p,CacheRemove:ft,Clear:v,Element:rt,Loaded:et,Loading:ot,PreviewFromGridCollection:ht,PreviewFromWebService:st,PreviewFromTreeViewNode:ct,ResizeFromParent:lt,SetContent:l,SetContentError:tt,SetContentErrorAjax:w,SetContentFromCache:d,ShowPreviewInPopup:it,Visible:at,VisibleRow:vt}},n}($UI||{});console.log("  $UI (preview pane extension)");console.log("Loading lib/isuserinterface_recordform.js");__UIExtRecordForm=function(n){return n.FormHeader=function(t,i){function y(){f.addClass("is-form-header");u&&(a?u.attr("bookmarked","true"):u.removeAttr("bookmarked"),e&&!e.NotFound&&e.Pk!=0?u.show():u.hide())}function tt(n){if(n==undefined)return a;a=n;y()}function k(){e=null;o("");p("");nt("");l("","");d("","");y()}function it(){return f}function rt(n,t,i,r){k();o(n);p(t);i?l(i,r):l("","")}function ut(n){n?(e=n,n.DisplayCode||n.Code?n.DisplayCode?o(n.DisplayCode+": "+n.Description):o(n.Code+": "+n.Description):o(n.Description),p(n.SummaryText),nt(n.BackgroundColour),l(n.StatusIcon,n.StatusIconTooltipText),d(n.IconOther1,n.IconOther1TooltipText),a=n.Bookmarked,y()):k()}function ft(){return e}function o(n){r.heading=n;w.text(n)}function nt(n){f.css({"background-color":n})}function l(t,i){var f,u,e;r.statusIcon=t;r.statusIconTooltipText=i;t?(f="",u=t.indexOf("|"),u!=-1&&(f=t.substr(u+1),t=t.substring(0,u)),e=n.GetIconUrl(t,16,f),s.css({"background-image":"url("+e+")"}),s.attr("title",r.statusIconTooltipText),s.show()):s.hide()}function d(t,i){var f,u,e;r.IconOther1=t;r.IconOther1TooltipText=i;t?(f="",u=t.indexOf("|"),u!=-1&&(f=t.substr(u+1),t=t.substring(0,u)),e=n.GetIconUrl(t,16,f),h.css({"background-image":"url("+e+")"}),h.attr("title",r.IconOther1TooltipText),h.show()):h.hide()}function p(n){r.summaryText=n;n&&n.toUpperCase().startsWith("<HTML>")?c.html(n.substr(6)):c.text(n)}function g(){if(r.statusIconTooltipText){var t={closeOnEscape:!0};e&&e.StatusIcon&&(t.icon=e.StatusIcon);n.MsgBoxInfo(r.statusIconTooltipText,t)}}var a=!1,u,w,f,e=null,r,c,s,h,v,b;if(FormHeadingDefaults={heading:"",summaryText:"",statusIcon:"",statusIconTooltipText:"",iconOther1:"",iconOther1TooltipText:"",showBookmark:!0,bookmarkEnabled:!0,onBookmarkClick:null},r=$.extend({},FormHeadingDefaults,i),typeof t=="string"?(v=n.ExtUtils.TranslateElementId(t),t=$("#"+v)):v=$(t).attr("id"),b=$(t),b.length==0){console.warn("userinterface.FormHeader: Parent element '"+v+"' not found.");return}if(f=$(b[0]),w=$("<header><\/header>"),s=$("<div class='statusicon'><\/div>"),h=$("<div class='statusicon'><\/div>"),c=$("<div class='summarytext'><\/div>"),f.append(w),f.append(s),f.append(h),f.append(c),r.showBookmark){if(u=$("<div class='bookmark'><\/div>"),r.bookmarkEnabled){if(u.attr("title","Toggle Bookmark"),r.onBookmarkClick)u.on("click",r.onBookmarkClick)}else u.addClass("disabled");f.append(u)}return o(r.heading),o(r.summaryText),s.click(g),h.click(g),c.click(g),y(),_self={TypeName:"FormHeader",Element:it,Bookmarked:tt,Clear:k,RefreshFromFormHeaderInfo:ut,RefreshHeading:rt,FormHeaderInfo:ft,SetHeading:o,SetIconOther1:d,SetStatusIcon:l,SetSummaryText:p}},n}($UI||{});console.log("  $UI (record form extension)");console.log("Loading lib/isuserinterface_recordtabs.js");__UIExtRecordTabs=function(n){return n.RecordTabs=function(t,i){function fi(){c.attr("viewsidebyside",o)}function k(){for(var n,i,t=0;t<r.length;t++)n=r[t],n.pageElement.is(":visible")&&(i=n.pageElement.outerWidth(),i<800?n.pageElement.addClass("is-container-small"):n.pageElement.removeClass("is-container-small"))}function v(t){var i,f;if(e.children().remove(),!ct&&$Runtime.SupportsDragDrop()){e.on("dragover",function(n){n.preventDefault();at(n,"")});e.on("drop",function(n){vt(n)})}for(f=0;f<r.length;f++)i=$("<li class='is-selectable' draggable='"+($Runtime.SupportsDragDrop()?"true":"false")+"'><a><\/a><div class='button hide is-symbol-dash' title='Hide (temporarily until you exit Side by Side View)'><\/div><div class='button pinned is-symbol-pin' title='Pinned'><\/div><\/div><div class='button close is-symbol-close' title='Close'><\/div><\/li>"),e.append(i),r[f].element=i,function(t,r){if($("a",i).click(function(){d(t)}),u.showTabContextMenu&&n.HandleContextMenuEvent($("a",i),function(n){return yt(t,n),n.preventDefault(),!1}),$Runtime.SupportsDragDrop()){r.on("dragstart",function(n){ei(n,t)});r.on("dragover",function(n){at(n,t)});r.on("drop",function(n){vt(n)})}$("div.close",i).click(function(){b(t)});$("div.hide",i).click(function(){dt(t)});$("div.pinned",i).click(function(){gt(t)})}(r[f].tabId,i);t&&(l.children().remove(),u.showRecentButton&&(i=$("<li class='recent' title='Recent'><\/li>"),l.append(i),i.click(function(){if(u.onRecentButtonClick)u.onRecentButtonClick(i);else window.alert("Recent button not handled.")})),u.showBookmarkedButton&&(i=$("<li class='bookmarked' title='Bookmarked'><\/li>"),l.append(i),i.click(function(){if(u.onBookmarkedButtonClick)u.onBookmarkedButtonClick(i);else window.alert("Bookmarked button not handled.")})),u.showSideBySideButton&&(i=$("<li class='sidebyside' title='View Side by Side'><\/li>"),i.attr("checked",o),l.append(i),i.click(function(){pt()})));u.emptyHtml&&r.length===0&&(e.children().remove(),e.append("<div class='emptytext'><span class='is-tooltip'>"+u.emptyHtml+"<\/span><\/div>"),u.emptyTooltipHtml&&(ui=n.PopupTip($("div.emptytext > span",e),{html:u.emptyTooltipHtml})));e.attr("tabcount",r.length);l.attr("tabcount",r.length);y(!0);ct=!0}function ei(n,t){n.stopPropagation();ut=t;n&&n.originalEvent&&n.originalEvent.dataTransfer&&n.originalEvent.dataTransfer.setData&&n.originalEvent.dataTransfer.setData("text/plain",t);ft=-2}function at(n){var f,t,i,u;for(n.preventDefault(),n.stopPropagation(),n.originalEvent.dataTransfer.dropEffect="move",f=n.originalEvent.pageX-e.offset().left,t=-1,rt="",i=r.length-1;i>=0;i--){var s=r[i].element.offset(),o=s.left,h=r[i].element.outerWidth(),c=e.offset();o-=c.left;f<o+h&&(t=i,rt=r[i].tabId)}u=p(ut);ft!=t&&(w||(w=$("<li class='drop-tab'><\/li>")),w.detach(),w.removeClass("showing"),u===t||t===u+1||(t===-1?u==r.length-1||w.insertAfter(r[r.length-1].element):w.insertBefore(r[t].element)),window.setTimeout(function(){w.addClass("showing")},5),ft=t)}function oi(n){n.preventDefault();n.stopPropagation()}function vt(n){n.preventDefault();n.stopPropagation();di(ut,rt);oi(n)}function yt(t,i){var e=h(t),u,f;if(g||(g=new n.MenuPopup(c,{})),g.OnAction(function(n){si(t,n)}),u=[],t&&o&&(u.push({ItemId:"Hide",Caption:"Hide"}),u.push({ItemType:"Separator"})),t&&u.push({ItemId:"Close",Caption:"Close Tab",IconClass:"is-symbol-close"}),t&&r.length>1&&u.push({ItemId:"CloseAllOther",Caption:"Close All Tabs But This",IconClass:"is-glyph-blank"}),(!t&&r.length>0||r.length>1)&&u.push({ItemId:"CloseAll",Caption:"Close All Tabs",IconClass:"is-glyph-blank"}),wt()!==0&&bt()!==0&&u.push({ItemId:"CloseUnpinned",Caption:"Close Unpinned Tabs",IconClass:"is-glyph-blank"}),t&&!e.temp&&(u.push({ItemType:"Separator"}),e.pinned?u.push({ItemId:"TabUnpin",Caption:"Unpin Tab",IconClass:"is-glyph-unpin"}):u.push({ItemId:"TabPin",Caption:"Pin Tab",IconClass:"is-glyph-pin"})),t&&u.push({ItemType:"Separator"}),t&&u.push({ItemId:"MoveLeft",Caption:"Move Left",Enabled:p(t)>0,IconClass:"is-glyph-moveleft"}),t&&u.push({ItemId:"MoveRight",Caption:"Move Right",Enabled:p(t)<r.length-1,IconClass:"is-glyph-moveright"}),t&&!e.temp&&(!$App.IsApp()||$Runtime.IsPlatformWindows()&&$App.MessageHandlerPort()&&$App.SettingsDevice().AllowOpenLinksInConnect)&&(u.push({ItemType:"Separator"}),$App.IsApp()||u.push({ItemId:"ShowInNewBrowserWindow",Caption:"Show in a new Web Browser Tab",IconClass:"is-symbol-open-window"}),$Runtime.IsPlatformWindows()&&$App.MessageHandlerPort()&&$App.SettingsDevice().AllowOpenLinksInConnect&&u.push({ItemId:"OpenInDesktop",Caption:"Open in finPOWER Connect (Desktop)",IconClass:"is-glyph-openfincc"})),s.length!=0)for(u.length!=0&&u.push({ItemType:"Separator"}),u.push({ItemType:"SubMenu",Caption:"Recently Closed Tabs"}),f=s.length-1;f>=0;f--)u.push({ItemId:"Reopen:"+s[f].tabId,Caption:s[f].caption,IconUrl:s[f].iconUrl});t&&$App.UserLevel()==="Administrator"&&(u.push({ItemType:"SubMenu",Caption:"Tools"}),u.push({ItemId:"FormInfo",Caption:"Show Form Information",Icon:"Form|Information"}));g.Define(u);u.length!==0&&g.Show(i.clientX,i.clientY)}function si(n,t){switch(t){case"Close":b(n);break;case"CloseAll":kt(n);break;case"CloseAllOther":bi(n);break;case"CloseUnpinned":ki(n);break;case"FormInfo":hi(n);break;case"Hide":dt(n);break;case"MoveLeft":ni(n);break;case"MoveRight":ti(n);break;case"ShowInNewBrowserWindow":var i=n.indexOf("."),u=n.substr(0,i),r=n.substr(i+1);$App.ShowRecordViewInNewBrowserWindow(u,r);break;case"OpenInDesktop":var i=n.indexOf("."),u=n.substr(0,i),r=n.substr(i+1);$App.OpenRecordInConnect(u,r);break;case"TabPin":ht(n);break;case"TabUnpin":gt(n);break;default:if(t.substr(0,7)=="Reopen:"){var f=t.substr(7),i=f.indexOf("."),u=f.substr(0,i),r=f.substr(i+1);switch(u.toUpperCase()){case"HTMLWIDGET":$App.RecordViewShowHtmlWidget(r);break;case"MENUCOMMAND":$App.ExecuteMenuItem(r);break;default:$App.FormOpen(u,r)}}else window.alert("Unhandled context menu action: "+t)}}function hi(t){var e=t.indexOf("."),u=t.substr(0,e),r=t.substr(e+1),i="",f;i+="<div style='padding:4px'>";i+="<h1>Form Information<\/h1>";switch(u.toUpperCase()){case"MENUCOMMAND":i+="<h3>Application Shortcut<\/h3>";i+="<p>Summary Pages and HTML Widgets can create Application Shortcuts to run this Menu Command, e.g.:<\/p>";f="app://menucommand?id="+r;i+="<div class='is-info-text code'>"+$Runtime.HtmlEncode(f)+"<\/div>";r.indexOf("|")!=-1&&(i+="<br/>",i+="<div class='is-info-text info small'>NOTE: The part of the id after the pipe (|) character is an index number used to open multiple instances of this menu command.<\/div>");break;default:i+="<h3>General<\/h3>";i+="<table class='is-table-info'>";i+="<tbody>";i+="<tr><th>Form Key:<\/th><td><b>"+$Runtime.HtmlEncode(u)+"<\/b><\/td><\/tr>";r&&(i+="<tr><th>Record ID:<\/th><td><b>"+$Runtime.HtmlEncode(r)+"<\/b><\/td><\/tr>");i+="<tbody>";i+="<\/table>";switch(u.toUpperCase()){case"ACCOUNT":case"ACCOUNTAPP":case"CLIENT":case"EXTERNALPARTY":case"POOL":case"SECURITYSTMT":case"WORKFLOW":i+="<div class='is-info-text info small'>NOTE: This Form Key can also be specified in the plural, e.g., <b>"+u+"s<\/b> for compatibility with the desktop version of finPOWER Connect.<\/div>"}i+="<h3>Application Shortcut<\/h3>";i+="<p>Summary Pages and HTML Widgets can create Application Shortcuts to open this form, e.g.:<\/p>";f="app://formshow?form="+u;r&&(f+="&id="+encodeURIComponent(r));i+="<div class='is-info-text code'>"+$Runtime.HtmlEncode(f)+"<\/div>"}i+="<\/div>";n.CommonDialog().ShowHtml("Form Information",i)}function it(n){var t,i;if(n===undefined)return o;if(n!=o){if(o=n,!o)for(t=0;t<r.length;t++)r[t].hidden=!1;i=$("li.sidebyside",l);i.attr("checked",o);y();k();u.onStateChanged&&u.onStateChanged()}}function pt(){it(!o)}function ci(n,t){var i=h(n);if(i===null&&console.warn("TabCaption: Cannot find tab '"+n+"'."),t===undefined)return i.caption;i.caption!==t&&(i.caption=t,y())}function li(){return r.length}function wt(){for(var t=0,n=0;n<r.length;n++)r[n].pinned&&(t+=1);return t}function bt(){for(var t=0,n=0;n<r.length;n++)r[n].pinned||(t+=1);return t}function ai(t,i){var r=h(t),u;if(r===null&&console.warn("TabIcon: Cannot find tab '"+t+"'."),i===undefined)return r.iconUrl;u=n.GetIconUrl(i);r.iconUrl!==u&&(r.iconUrl=u,y())}function y(t){var s,u;for(mSelectedPageElement=null,s=-1,u=r.length-1;u>=0;u--)if(!r[u].hidden){s=u;break}for(u=0;u<r.length;u++){var i=r[u],v=i.element,l=$Runtime.HtmlEncode(i.caption);i.iconUrl&&(l="<img src='"+i.iconUrl+"' />"+l);$("a",v).html(l);i.element.removeClass("lastselected");i.tabId.toUpperCase()===f.toUpperCase()?i.element.addClass("is-sel"):(i.element.removeClass("is-sel"),i.tabId.toUpperCase()==a.toUpperCase()&&i.tabId.toUpperCase()!=f.toUpperCase()&&(t?(i.element.addClass("is-sel"),ot&&clearTimeout(ot),function(n){ot=setTimeout(function(){var t=h(n);n.toUpperCase()!=f.toUpperCase()&&t.element.removeClass("is-sel");n.toUpperCase()==a.toUpperCase()&&($("li",e).removeClass("lastselected"),t.element.addClass("lastselected"))},10)}(i.tabId)):i.element.addClass("lastselected")));o&&u===s?i.element.addClass("lastvisible"):i.element.removeClass("lastvisible");i.pinned?i.element.addClass("pinned"):i.element.removeClass("pinned");i.element.removeClass("hidden");o?i.hidden?(i.element.css({display:"none"}),i.element.addClass("hidden"),i.pageElement.css({display:"none"})):(i.pageElement.css({display:""}),n.RealignLayouts(i.pageElement)):(i.element.css({display:""}),i.tabId.toUpperCase()==f.toUpperCase()?(i.pageElement.css({display:""}),n.RealignLayouts(i.pageElement)):i.pageElement.css({display:"none"}))}r.length==0?nt.show():nt.hide();c.attr("viewsidebyside",o)}function vi(){return{element:null,caption:"",iconUrl:"",nonModal:null,pageElement:null,pinned:!1,tabId:"",temp:!1}}function yi(n,t,i,e){var o=h(n),s,l;if(o===null){if(r.length>=u.maxTabs)if(u.autoClose){for(s=0;s<r.length;s++)if(o=r[s],!o.pinned&&(!o.nonModal||o.nonModal.ModalId()!=e)){b(o.tabId,!0);break}}else return null;if(r.length>=u.maxTabs)return null;o=new vi;o.caption=t;o.tabId=n;o.iconUrl=i?i:"";wi(n);r.push(o);l=$("<div class='is-record-tab-page' style='display:none;'><\/div>");c.append(l);o.pageElement=l}return f&&f!==n&&(a=f),f=n,v(),k(),o}function b(t,i){var e=h(t),c,l,s;if(e&&e.nonModal&&n.HasMinimisedModal(!1,e.nonModal)){n.MsgBoxAlert("This record cannot be closed since it has a minimised form that is currently open",{heading:"Cannot Close Tab"});return}if(e!=null){for(e.element.hasClass("record-preview")&&$App.PreviewRecordTabHide(),pi(e),e.pageElement.remove(),r.length===1?c="":(s=r.indexOf(e),c=s==r.length-1?r[s-1].tabId:r[s+1].tabId),l=[],s=0;s<r.length;s++)r[s].tabId!=t&&l.push(r[s]);r=l;!i&&r.length<2&&o&&it(!1);f&&f!==t&&(a=f);f=c;v();e.nonModal&&e.nonModal.Close();u.onStateChanged&&u.onStateChanged();k()}}function pi(n){var i,t;if(s>4){for(i=[],t=1;t<s.length;t++)i.push(s[t]);s=i}n.temp||s.push({tabId:n.tabId,caption:n.caption,iconUrl:n.iconUrl})}function wi(n){for(var i=[],t=0;t<s.length;t++)n.toUpperCase()===s[t].tabId.toUpperCase()||i.push(s[t]);s=i}function kt(){for(var n=r.length-1;n>=0;n--)b(r[n].tabId,!1)}function bi(n){for(var t=r.length-1;t>=0;t--)r[t].tabId===n||b(r[t].tabId,!1);d(n)}function ki(){for(var n=r.length-1;n>=0;n--)r[n].pinned||b(r[n].tabId,!1)}function p(n){for(var t=0;t<r.length;t++)if(n.toUpperCase()==r[t].tabId.toUpperCase())return t;return-1}function dt(n){var t=h(n);t&&o&&(t.hidden=!0,y())}function ht(n){var t=h(n);t&&(t.pinned=!0,y(),u.onStateChanged&&u.onStateChanged())}function gt(n){var t=h(n);t&&(t.pinned=!1,y(),u.onStateChanged&&u.onStateChanged())}function ni(n){var t=p(n),i,e,o;t>0&&(i=r[t-1],r[t-1]=r[t],r[t]=i,e=r[t-1].pageElement,o=r[t].pageElement,o.insertAfter(e),f&&f!=n&&(a=f),f=n,v(!1),u.onStateChanged&&u.onStateChanged())}function di(n,t){var o,e,s,h,c,i;if(!(r.length<2)&&n!==t){for(o=p(n),e=-1,t&&(e=p(t)),console.log("Move "+o+" to before "+e),s=r[o],e===-1?(r.splice(o,1),r.push(s)):(r.splice(o,1),e<o?r.splice(e,0,s):r.splice(e-1,0,s)),h=[],c=$(r[0].pageElement.parent()),i=0;i<r.length;i++)h.push(r[i].pageElement),r[i].pageElement.detach();for(i=0;i<r.length;i++)c.append(h[i]);f&&f!=n&&(a=f);f=n;v(!1);u.onStateChanged&&u.onStateChanged()}}function ti(n){var t=p(n),i,e,o;t>=0&&t<r.length-1&&(i=r[t+1],r[t+1]=r[t],r[t]=i,e=r[t+1].pageElement,o=r[t].pageElement,e.insertAfter(o),f&&f!=n&&(a=f),f=n,v(!1),u.onStateChanged&&u.onStateChanged())}function gi(){return c}function nr(){return nt}function ii(){for(var i,n="",t=0;t<r.length;t++)n!=""&&(n+=","),i=r[t],i.temp||(n+=i.tabId);return n}function ri(){for(var n="",t=0;t<r.length;t++)r[t].pinned&&(n!=""&&(n+=","),n+=r[t].tabId);return n}function d(n){if(n==undefined)return f;f&&f!==n&&(a=f);f=n;y();$("html").hasClass("record-preview")&&($App.PreviewRecordTabHide(),$App.ViewShow("Records"));k();u.onStateChanged&&u.onStateChanged()}function tr(n,t){var i=h(n);i?i.pageElement.html(t):window.alert("userinterface.RecordTabs.SetPageHtml: tab '"+n+"' does not exist.")}function h(n){n=n.toUpperCase();for(var t=0;t<r.length;t++)if(r[t].tabId.toUpperCase()===n)return r[t];return null}function ir(){return e}function rr(n){u.onStateChanged=n}function ur(){var n={};return n.list=ii(),n.sel=d(),n.sbs=o?"y":"n",n.p=ri(),n}function fr(n){var i,t,r;if(n.p)for(i=$Runtime.ArrayFromCsvString(n.p),t=0;t<i.length;t++)r=h(i[t]),r&&ht(r.tabId);n.sbs&&it(n.sbs=="y");n.sel&&d(n.sel);v(!1)}function er(n,t,i){for(var e,s=n+"."+t,o=0;o<r.length;o++)if(e=r[o],e.tabId.toUpperCase()==s.toUpperCase()){e.caption=i;e.tabId=n+"."+i;f.toUpperCase()==s.toUpperCase()&&(f=e.tabId);v();k();break}u.onStateChanged&&u.onStateChanged()}var l,rt="",ut="",w,ft=-2,c,et,ct=!1,a="",ot,g,nt,u,ui,s=[],f="",r,e,o=!1,tt,st,lt;if(TabsDefaults={maxTabs:4,autoClose:!0,emptyHtml:"",emptyTooltipHtml:"",showRecentButton:!0,showBookmarkedButton:!0,showSideBySideButton:!0,showTabContextMenu:!0,onBookmarkedButtonClick:null,onRecentButtonClick:null,onStateChanged:null},u=$.extend({},TabsDefaults,i),typeof t=="string"?(tt=n.ExtUtils.TranslateElementId(t),t=$("#"+tt)):tt=$(t).attr("id"),st=$(t),st.length==0){console.warn("userinterface.RecordTabs: Parent element '"+tt+"' not found.");return}lt=$(st[0]);c=$("<div class='is-record-tabs'><\/div>");lt.append(c);et=$("<div class='is-tabs-container scrollbars-thin is-no-select'><\/div>");c.append(et);e=$("<ul class='tabs is-no-select'><\/ul>");et.append(e);l=$("<ul class='buttons is-no-select'><\/ul>");c.append(l);nt=$("<div class='is-record-tab-page notabs' style='display:none;'><\/div>");c.append(nt);r=[];v(!0);fi();$(window).on("resize",function(){k()});return u.showTabContextMenu&&n.HandleContextMenuEvent(e,function(n){return yt("",n),n.preventDefault(),!1}),f&&d(f),{TypeName:"RecordTabs",Element:gi,NoTabsElement:nr,AddTab:yi,CloseTab:b,CloseAllTabs:kt,GetTabIdsList:ii,GetPinnedTabIdsList:ri,IndexOfTab:p,NotifyRecordIdChanged:er,SelectedTabId:d,SideBySideMode:it,SideBySideModeToggle:pt,TabCaption:ci,TabCount:li,TabCountPinned:wt,TabCountUnpinned:bt,TabIcon:ai,Tabs:h,TabMoveLeft:ni,TabMoveRight:ti,PinTab:ht,OnStateChanged:rr,SetPageHtml:tr,TabsElement:ir,StateToObject:ur,StateFromObject:fr}},n}($UI||{});console.log("  $UI (record tabs extension)");console.log("Loading lib/isuserinterface_widget.js");__UIExtWidget=function(n){return n.WidgetsActionNotificiationSend=function(t,i,r,u){var e,s,f,h,o;if(u&&n.ExecuteNotificationAction(t,i),typeof i=="object")try{i=JSON.stringify(i)}catch(c){console.warn("$UI.WidgetsActionNotificiationSend: Failed to serialise data object to JSON string for passing to widgets.")}for(e=$("div.is-widget"),s=!1,f=0;f<e.length;f++)h=$(e[f]),o=h.data("_widget"),r&&r!==o.WidgetId()||(o.NotifyAction(t,i,r),r&&(s=!0))},n.Widget=function(t,i){function ri(){switch(r.height.toUpperCase()){case"":case"AUTO":u.css("min-height","100%");break;default:u.css("min-height",r.height)}r.standalone&&(s.addClass("standalone"),s.addClass("is-dock-fill"));r.showHeading&&!r.standalone?(c.show(),f.addClass("has-heading")):(c.hide(),f.removeClass("has-heading"))}function ui(){return s}function fi(){document.activeElement===u[0]?ct():ei()}function ct(){r.allowFocus&&(f.addClass("sel"),o&&o.removeClass("dark"),et||$("body").trigger("mousedown"),et=!0)}function ei(){r.allowFocus&&(f.removeClass("sel"),o&&o.addClass("dark"),et=!1)}function oi(){u[0].focus();ct()}function si(n){n?f.addClass("selected"):f.removeClass("selected")}function kt(n,t){var i,u,f;h=n;t||(t={});e=typeof t=="string"?t:JSON.stringify(t);i=n.lastIndexOf("/");i!==-1&&(nt=n.substr(i+1));u={eventId:"",hostingContext:"WebInternal",target:"WebInternal",highDpi:$Runtime.IsHighDpi()};f={};e&&encodeURIComponent(e).length>1700?f.startupParametersJson=e:u.startupParametersJson=e;$Api.PostDirect(n,u,f,{done:function(n,t,i){switch(i.status){case 200:r.heading||ti(n.Heading);r.modal&&r.modal._Tabs&&(r.icon||n.Icon&&r.modal._Tabs.TabIcon(r.modal._Tab.tabId,n.Icon));ut(n.Html,n);break;default:var n=$Runtime.GetWsError(i);window.alert(n.Message+"\n\n"+n.InternalMessage)}},fail:function(n){var t=$Runtime.GetWsError(n);l(t.Message,t.InternalMessage)},always:function(){it="URL";yt=n;pt=e}})}function ut(t,i){var o=$.extend({},dt,i),a,v,h,s,y,p,f,e,c;it="SETCONTENT";at=t;vt=i;s=t.toUpperCase();a=s.indexOf("<HTML")!=-1;v=s.indexOf("<HEAD>")!=-1||s.indexOf("<HEAD ")!=-1;h=s.indexOf("<BODY")!=-1;i="";o.cssWidget&&(i+="<link rel='stylesheet' type='text/css' href='"+$Runtime.WebRoot()+"Content/widget_controls.css?v="+$App.Version()+"'><\/link>",i+="<link rel='stylesheet' type='text/css' href='"+$Runtime.WebRoot()+"Content/widget.css?v="+$App.Version()+"'><\/link>");o.cssSummaryPage2&&(i+="<link rel='stylesheet' type='text/css' href='"+$Runtime.WebRoot()+"Content/SummaryPage2/summarypage_2.css?v="+$App.Version()+"'><\/link>",i+="<link rel='stylesheet' type='text/css' href='"+$Runtime.WebRoot()+"Content/SummaryPage2/summarypage_2_web.css?v="+$App.Version()+"'><\/link>");o.jQuery&&(i+=o.jQueryVersion?"<script src='https://ajax.googleapis.com/ajax/libs/jquery/"+o.jQueryVersion+"/jquery.min.js'><\/script>":"<script src='"+$Runtime.WebRoot()+"Scripts/lib/jquery-"+$.fn.jquery+".js'><\/script>");$App.AppTitle().startsWith("finPOWER Connect Web Services")?(y=$Runtime.WebRoot()+"External/widget.js",p=$Runtime.WebRoot()+"External/widget_ui.js"):(y=$Runtime.WebRoot()+"Scripts/lib/widget.js",p=$Runtime.WebRoot()+"Scripts/lib/widget_ui.js");i+="<script src='"+y+"?v="+$App.Version()+"'><\/script>";i+="<script src='"+p+"?v="+$App.Version()+"'><\/script>";o.useWidgetStyling&&(i+="<script>widget.UI.LoadStyle('*', { includeOtherCss: true });<\/script>");try{f=u[0].contentWindow;f.widget=b;tt=f}catch(w){console.warn("Failed to get Widget's content window.\n\n"+w.message)}o.app&&(f.$App=$App);e=u[0].contentDocument;e.open();a||(e.write("<!doctype html>"),e.write("<html>"));v?(c=s.indexOf("<HEAD>"),c==-1?l("HTML returned by HTML Widget contains an opening <head> element but not a closing element. Could not inject required resources into HTML."):t=t.substring(0,c-8)+i+t.substr(c+7)):(e.write("<head>"),e.write("<meta http-equiv='X-UA-Compatible' content='IE=edge'/>"),e.write(i));v||e.write("<\/head>");h||(e.write("<!-- body tag written in widget.SetContent -->"),e.write("<body style='margin:0;padding:0'>"));h||e.write("<div style='margin:0;padding:0;border-bottom:1px solid transparent;position:relative;width:100%;height:100%;'>");try{e.write(t)}catch(w){window.$App&&$App.NotificationsAddError("Failed to write Widget HTML.",w,!0,"Widget Load Error")}h||e.write("<\/div>");h||e.write("<\/body>");a||e.write("<\/html>");e.close();f&&f.widget||(f=u[0].contentWindow,f.widget=b,tt=f);f&&f.widget&&(f.widget=b,o.app&&(f.$App=$App,f.$Api=$Api,f.$UI=n));n.AlwaysUsePickerControls()&&(f.__alwaysUsePickerControls=!0);r.handleApplicationShortcuts&&(window.$Ash?$Ash.HandleIframe(u[0]):window.alert("Widget cannot handle Application Shortcuts since no handler ($Ash) is available."))}function hi(n){u.attr("src",n)}function ci(n,t,i,r){var u=t==""?n:t+"/"+n;require(["views/"+u],function(n){ut(n,i)});h=r}function lt(n,t){ft&&ft(n,t)}function li(n,t){r.__widgetNotifyParentCallback?r.__widgetNotifyParentCallback(n,t):console.warn("widget.NotifyParent: Parent failed to process the notification. Use widget.UI.Forms.ShowHtmlWidgetModal (and provide a callback function) to open an HTML Widget from within another and enable the notification process.")}function ai(n){ft=n}function vi(t,i,r,u){n.WidgetsActionNotificiationSend(t,i,r,u)}function yi(){return r.standalone&&r.modal?!0:!1}function pi(n,t){r.standalone&&r.modal?r.modal.Close(!0):l("Widgets cannot be closed in this context.","Consider using the widget.CanClose() method and resetting the widget instead.");t!==undefined&&typeof t!="string"&&(t=JSON.stringify(t));var i="app://HtmlWidget?id="+encodeURIComponent(n);t&&(i+="&startupParametersJson="+encodeURIComponent(t));gt(i)}function wi(){return r.standalone&&r.modal?(r.modal._Tabs?r.modal._Tabs.CloseTab(r.modal._Tab.tabId):r.modal.Close(!0),!0):(l("Widgets cannot be closed in this context.","Consider using the widget.CanClose() method and resetting the widget instead."),!1)}function bi(){return f}function ki(){r.modal?r.modal.WidgetDisabledCloseButton(w):console.warn("widget.DisableCloseButton was called on an HTML Widget that is not hosted in a Modal form.")}function di(n,t,i,r){var s,u,l,a,y;if(!h){window.alert("Only Widgets initialised via 'InitialiseFromUrl' can use the DownloadFile method.");return}t||(t={});s=nt;s||(s="URL:"+h);var c={widgetId:s,eventId:n,hostingContext:"WebInternal",startupParametersJson:e,target:"WebInternal",highDpi:$Runtime.IsHighDpi(),parameters:t},f=$App.WebServicesUrl(),o,v=!1;a=JSON.stringify(c);a.length>2e3?(o=f+"HtmlWidget/DownloadFile",v=!0):o=f+"HtmlWidget/DownloadFile?p="+a;v?ni(o,{p:JSON.stringify(c)}):y=window.open(o);(i||r)&&gi(y,i,r)}function gi(n,t,i){var r=!1,u=0,f=function(){if(!r&&n)var f=window.setInterval(function(){var s,e,o;if(!r){try{n&&n.document&&(n.document.readyState.toUpperCase()==="COMPLETE"||n.document.body&&n.document.body.innerText)&&(r=!0,n.document.body&&(s=(""+n.document.body.innerText).toUpperCase(),s.indexOf("FAILED TO EXECUTE")!==-1?(e=JSON.parse(n.document.body.innerText),o=e.Message,e.InternalMessage&&(o+="\n\n"+e.InternalMessage),i&&i(o,!0)):t&&t()))}catch(h){console.warn("Exception checking for downloaded document: "+h)}r||(u+=1,u>20&&(r=!0,console.warn("Failed to get downloaded state for document. Assuming failure."),i&&i("Failed to get downloaded state for document. Assuming failure.",!0)));r&&window.clearInterval(f)}},500)};f();n.onabort=function(){i&&i("Download aborted by user.")}}function ui(){return s}function nr(){return c}function gt(n){return $Ash?$Ash.ExecuteUrl(n,r.modal):(l("Failed to execute Application Shortcut URL.","No Application Shortcut Handler ($Ash) is available."),!1)}function tr(n,t,i,r){if(!h){window.alert("Only Widgets initialised via 'InitialiseFromUrl' can use the GetString method.");return}t||(t={});d+=1;var u={eventId:n,hostingContext:"WebInternal",target:"WebInternal",highDpi:$Runtime.IsHighDpi()};e&&encodeURIComponent(e).length>1700?(t||(t={}),typeof t=="string"?window.alert("Unhandled string parameters with large JSON Startupup Parameters."):t.__startupParametersJson=e):u.startupParametersJson=e;$Api.PostDirect(h,u,t,{done:function(n,t,u){switch(u.status){case 200:i&&i(""+n);break;default:r&&r(""+n)}},fail:function(n){var t=$Runtime.GetWsError(n);l(t.Message,t.InternalMessage);r&&r(t.Message+"\n\n"+t.InternalMessage)},always:function(){d-=1}})}function ir(){return $App.IsAuthenticated()}function rr(){return $App.WidgetNotifyBusy(),!0}function ur(n,t){if(!h){window.alert("Only Widgets initialised via 'InitialiseFromUrl' can use the SystemDownloadFile method.");return}t||(t={});var i={eventId:n,hostingContext:"WebInternal",target:"WebInternal",highDpi:$Runtime.IsHighDpi(),parameters:t},r=$App.WebServicesUrl()+"HtmlWidget/SystemDownloadFile?";ni(r,{p:JSON.stringify(i)})}function ni(n,t){var i=document.createElement("form"),u,r;i.target="_blank";i.method="POST";i.action=n;i.style.display="none";for(u in t)r=document.createElement("input"),r.type="hidden",r.name=u,r.value=t[u],i.appendChild(r);document.body.appendChild(i);i.submit();document.body.removeChild(i)}function fr(n,t,i,r){$App.HtmlWidget_SystemGetString(n,t,i,r)}function er(n,t){var i,u,f;t===undefined?t="":typeof t!="string"&&(t=JSON.stringify(t));r.modal?r.modal.ParentModal()?(i=$("div.is-widget",r.modal.ParentModal().ContentElement()),i.length!==0&&(u=$(i[0]),f=u.data("_widget"),f.ParentNotificationReceived(n,t))):console.warn("widget.NotifyParent: Failed since this HTML Widget does not have a modal form."):console.warn("widget.NotifyParent: Failed since this HTML Widget does not have a parent modal form. Use widget.UI.Forms.ShowHtmlWidgetModal to open an HTML Widget from within another.")}function or(n,t,i,r,u,f){$App.NotificationsAddAdHoc(n,i,r,!0,t,u,f)}function sr(n,t){r.refreshParentCallback?r.refreshParentCallback():r.modal?r.modal.ParentModal()?t?(t.recordId=n,r.modal.ParentModal().ExecuteAction("Refresh",t)):r.modal.ParentModal().ExecuteAction("Refresh",n):console.info("Widget.RefreshParent: 'modal' does not have a ParentModal() to refresh."):console.info("Widget.RefreshParent: Widget does not have a 'modal'.")}function l(n,t){a.show();v.length>=20&&(v=v.slice(1,19));v.push({message:n,details:t});$App&&$App.NotificationsAddError&&(n=r.heading?"WIDGET '"+r.heading+"': "+n:"WIDGET: "+n,$App.NotificationsAddError(n,t))}function hr(){for(var n="",t=v.length-1;t>=0;t--)n&&(n+="\n"),n+=v[t].message+"\n",n+=v[t].details+"\n";window.alert(n);a.hide()}function cr(n,t,i,r){if(!h)return window.alert("Only Widgets initialised via 'InitialiseFromUrl' can use the RequestForm method."),!1;if(t||(t={}),$App.WidgetRequestForm)$App.WidgetRequestForm(n,t,i,r);else return window.alert("$App does not support a 'WidgetRequestForm' method."),!1;return!0}function k(){if(y&&(clearTimeout(y),y=null),p&&(clearInterval(p),p=null),st+=1,ot&&st==1)try{ot()}catch(n){l("Widget's Reset handler failed.",n.message)}else{!0&&(u.remove(),u=$("<iframe/>"),g.append(u));switch(it){case"SETCONTENT":ut(at,vt);break;case"URL":kt(yt,pt);break;default:window.alert("Unhandled HTML Widget Reset Type '"+it+"'.")}}st-=1}function lr(n,t){var i=!1;n||t?$(s).is(":visible")&&(t||(i=!0)):i=!0;y&&(clearTimeout(y),y=null);p&&(clearInterval(p),p=null);i?k():n?p=setInterval(function(){$(s).is(":visible")&&k()},2e3):y=setTimeout(function(){k()},t*1e3)}function ar(n){ot=n}function ti(n){r.heading=n;r.tabs?r.tabs.TabCaption(r.tabId,n):r.standalone&&r.modal?r.modal._Tabs?r.modal._Tabs.TabCaption(r.modal._Tab.tabId,n):r.modal.Title&&r.modal.Title(n):c.text(n)}function vr(n){r.headingIcon=n;r.tabs?r.tabs.TabIcon(r.tabId,n):r.standalone&&r.modal}function yr(n){c.removeClass();n&&(c.addClass(n.toLowerCase()),n.toUpperCase()=="HIDDEN"?(a&&a.hide(),o&&o.hide()):o&&o.show())}function pr(n){if(r.allowSizeToFit){var t;t=$Runtime.IsPlatformIOS()?$(u[0]).outerHeight():$(u[0].contentWindow.document.body).outerHeight();!n&&n>0&&t>n&&(t=n);r.standalone||($Runtime.IsPlatformIOS()?f.css("min-height",t+"px"):u.css("min-height",t+"px"))}}function wr(n,t,i,r,u){var f,o,s,e,c,l;if(!h){window.alert("Only Widgets initialised via 'InitialiseFromUrl' can use the UploadFile method.");return}if(!window.FileReader){u?u("UploadFiles cannot be used by this Web browser since it does not support 'window.FileReader'."):window.alert("UploadFiles cannot be used by this Web browser since it does not support 'window.FileReader'.");return}if(t||(t={}),i&&(f=i.GetFiles?i.GetFiles():i.files?i.files:i),f&&f.length!==0)for(o=[],s=0,e=0;e<f.length;e++)c=new FileReader,l=f[e],c.readAsDataURL(l),c.onload=function(i){return function(e){s+=1;o.push({name:i.name,data:e.target.result,tag:i.tag});s==f.length&&ii(n,t,o,r,u)}}(l);else ii(n,t,"",r,u)}function ii(n,t,i,r,u){t.__fileDataJson=i;d+=1;$Api.PostDirect(h,{eventId:n,hostingContext:"WebInternal",startupParametersJson:e,target:"WebInternal",highDpi:$Runtime.IsHighDpi()},t,{done:function(n,t,i){switch(i.status){case 200:r&&r(""+n);break;default:u&&u(""+n)}},fail:function(n){var t=$Runtime.GetWsError(n);l(t.Message,t.InternalMessage);u&&u(t.Message+"\n\n"+t.InternalMessage)},always:function(){d-=1}})}function br(){return nt}var ft=null,d=0,f,g,u,a,c,s,et=!1,r,v=[],o,ot=null,e="",h="",nt="",b,tt=null,at="",vt=null,yt="",pt,it="",y,p,st=0,rt,ht,wt,bt,dt,w;if(WidgetDefaults={heading:"",showHeading:!0,showRefreshButton:!0,height:"auto",allowSizeToFit:!0,allowFocus:!0,standalone:!1,modal:null,handleApplicationShortcuts:!0,widgetId:"",widgetOptions:{},__widgetNotifyParentCallback:""},r=$.extend({},WidgetDefaults,i),nt=r.widgetId,r.widgetOptions=$App.WidgetOptions(),typeof t=="string"?(rt=n.ExtUtils.TranslateElementId(t),t=$("#"+rt)):rt=$(t).attr("id"),ht=$(t),ht.length===0){console.warn("userinterface.Widget: Parent element '"+rt+"' not found.");return}return wt=$(ht[0]),s=$("<div class='is-widget'><\/div>"),wt.append(s),f=$("<div class='container'><\/div>"),s.append(f),a=$("<div class='error' title='HTML Widget Errors'><\/div>"),r.showRefreshButton&&!r.standalone&&(o=$("<button class='is-button refresh dark' title='Refresh'><\/div>")),c=$("<header class='is-no-select'><\/header>"),r.heading&&c.text(r.heading),g=$("<div class='content'><\/div>"),f.append(a),r.showRefreshButton&&f.append(o),f.append(c),f.append(g),u=$("<iframe/>"),g.append(u),$Runtime.IsPlatformIOS()&&u.attr("scrolling","no"),a.click(hr),f.click(function(){u.focus();ct()}),o&&o.click(k),r.allowFocus&&window.setInterval(function(){fi()},250),ri(),window.IntersectionObserver&&(bt=new IntersectionObserver(function(n){n[0].intersectionRatio?lt("WidgetVisible",{}):lt("WidgetHidden",{})},{root:document.body}),bt.observe(f[0])),dt={cssSummaryPage2:!1,cssWidget:!0,jQuery:!0,jQueryVersion:"",useWidgetStyling:!0,app:!1},w={TypeName:"Widget",Element:ui,HeadingElement:nr,ActionNotificationHandle:ai,ActionNotificationSend:vi,CanClose:yi,Chain:pi,Close:wi,ContainerElement:bi,DisableCloseButton:ki,DownloadFile:di,ExecuteApplicationShortcutUrl:gt,Focus:oi,GetString:tr,InitialiseFromUrl:kt,NotificationAdd:or,NotifyAction:lt,IsAuthenticated:ir,NotifyBusy:rr,ParentNotificationReceived:li,RefreshParent:sr,RegisterError:l,RequestFormInternal:cr,Reset:k,ResetScheduled:lr,ResetHandle:ar,Select:si,SetContent:ut,SetContentFromUrl:hi,SetContentFromView:ci,SetHeading:ti,SetHeadingIcon:vr,SetHeadingStyle:yr,SizeToFit:pr,UploadFiles:wr,WidgetId:br,SystemDownloadFile:ur,SystemGetString:fr,ParentNotify:er,Options:r.widgetOptions,Window:function(){return tt},Generic:function(){return tt.__widgetGeneric},OptionsExtend:function(n){r=$.extend({},i,n)},__modal:r.modal,__SetWidgetNotifyParentCallback:function(n){r.__widgetNotifyParentCallback=n},__GetWidgetNotifyParentCallback:function(){return r.__widgetNotifyParentCallback}},b=new ISWidgetProxy(w),s.data("_widget",w),w.WidgetProxy=b,w},n}($UI||{});console.log("  $UI (widget extension)");console.log("Loading lib/isuserinterface_parametershost.js");__UIExtParametersHost=function(n){return n.ParametersHost=function(t,i){function y(n){n&&(v=!0,f.addClass("is-parametershost-container"),f.children().remove(),r=$("<table class='is-form'><\/table>"),f.append(r))}function ot(n,t){var e,i;if(u=n,o=t,o||(o={}),h=u?JSON.stringify(n):null,y(!v),r.children().remove(),r.append("<colgroup><col style='width:1px'/><col/><\/colgroup>"),n&&n.length!==0)for(e=0;e<n.length;e++)if(i=n[e],i.Visible&&(o.alwaysCreateControls||!i.Control)){switch(i.ParameterType){case"Boolean":p(i);break;case"CheckList":ct(i);break;case"Date":lt(i);break;case"DateRange":at(i);break;case"GroupingList":vt(i);break;case"List":yt(i);break;case"Number":pt(i);break;case"NumberRange":wt(i);break;case"Range":i.RangeSingle?bt(i):gt(i);break;case"PageStart":st(i,n)&&kt(i);break;case"SectionStart":ht(i,n)&&dt(i);break;case"Text":ti(i);break;default:ii(i)}i.Control&&(i.Control.toJSON=function(){return undefined})}if(o.onEnterKey)f.on("keydown",function(n){if(n.keyCode==13)switch(n.target.tagName){case"INPUT":$(n.target).trigger("blur");$(n.target).focus();o.onEnterKey()}})}function st(n,t){for(var r,u=-1,i=0;i<t.length;i++)if(t[i]===n){u=i;break}if(u==-1)window.alert("Parameter not found!");else for(i=u+1;i<t.length;i++)if(r=t[i],r.Visible&&!r.Control)switch(r.ParameterType){case"SectionStart":break;case"PageStart":return!1;default:return!0}return!1}function ht(n,t){for(var r,u=-1,i=0;i<t.length;i++)if(t[i]===n){u=i;break}if(u==-1)window.alert("Parameter not found!");else for(i=u+1;i<t.length;i++)if(r=t[i],r.Visible&&!r.Control)switch(r.ParameterType){case"SectionStart":case"PageStart":return!1;default:return!0}return!1}function p(t){var i,o,f,e,u;t.Name.endsWith("Desc")&&(i=ei(t.Name.substr(0,t.Name.length-4)));i&&i.Control?(o=i.Control.Element().closest("td,th"),f=$("<input type='checkbox'/>"),o.append(f),checkBox=new n.CheckBox(f,{caption:t.Caption,readOnly:t.ReadOnly,onChange:function(n){n.Parameter.Value=n.Value()}})):(e=$("<tr><\/tr>"),u=$("<th colspan='2'><input type='checkbox'/><\/th>"),e.append(u),checkBox=new n.CheckBox($("input",u),{caption:t.Caption,onChange:function(n){n.Parameter.Value=n.Value()}}),t.IndentLevel&&u.css("border-left",t.IndentLevel*32+"px solid transparent"),r.append(e));checkBox.Parameter=t;checkBox.Value(t.Value);t.Control=checkBox}function ct(t){var e=$("<tr><\/tr>"),u="lst"+$Runtime.CreateGuid(!0),f=$("<th><label for='"+u+"'>"+$Runtime.HtmlEncode(t.Caption,!0)+":<\/label><\/th><th><input id='"+u+"'/><\/th>"),i;e.append(f);r.append(e);i=new n.CheckList($("#"+u,f),{allowBlank:!t.Mandatory,readOnly:t.ReadOnly,listCsv:t.List});i.Parameter=t;t.Control=i;t.Value&&i.Text(t.Value);i.OnChange(function(){t.Value=i.Text()});t.IndentLevel&&f.css("border-left",t.IndentLevel*32+"px solid transparent")}function lt(t){var o=$("<tr><\/tr>"),u="date"+$Runtime.CreateGuid(!0),f=$("<th><label for='"+u+"'>"+$Runtime.HtmlEncode(t.Caption,!0)+":<\/label><\/th><th><input id='"+u+"'/><\/th>"),i;o.append(f);r.append(o);i=new n.DateBox($("#"+u,f),{allowBlank:!t.Mandatory,readOnly:t.ReadOnly,widgetDocument:e.widgetDocument});i.Parameter=t;t.Control=i;t.Value&&i.Value($Runtime.ParseJsonDate(t.Value));i.OnChange(function(n,r){r&&(r.ChangeHandled=!0);t.Value=i.Value()});t.IndentLevel&&f.css("border-left",t.IndentLevel*32+"px solid transparent")}function at(t){var s=rt(t.Value),h=$("<tr><\/tr>"),f="date"+$Runtime.CreateGuid(!0),o=$("<th><label for='"+f+"From'>"+$Runtime.HtmlEncode(t.Caption,!0)+":<\/label><\/th><th><input id='"+f+"From'/> <small style='display:inline-block'>to<\/small> <input id='"+f+"To'/><\/th>"),i,u;h.append(o);r.append(h);i=new n.DateBox($("#"+f+"From",o),{allowBlank:!t.Mandatory,readOnly:t.ReadOnly,widgetDocument:e.widgetDocument});i.Parameter=t;i.Value(s.DateFrom);u=new n.DateBox($("#"+f+"To",o),{allowBlank:!t.Mandatory,readOnly:t.ReadOnly,widgetDocument:e.widgetDocument});u.Parameter=t;u.Value(s.DateTo);i.OnChange(function(){t.Value=it(i.Value(),u.Value())});u.OnChange(function(){t.Value=it(i.Value(),u.Value())});t.Control=[i,u];t.IndentLevel&&o.css("border-left",t.IndentLevel*32+"px solid transparent")}function vt(n){var a=fi(n.List),f,t,o;if(n.Name==="Groupings")for(f=0;f<u.length;f++)if(t=u[f],t.Name==="GroupingsSummary"&&!t.Control){t.Caption="Summarise Groupings?";p(t);break}var s=$("<tr><\/tr>"),i="list"+$Runtime.CreateGuid(!0),e=$("<th colspan='2'><span id='"+i+"' class='is-groupinglist'><div id='"+i+"Left' class='left'/><div id='"+i+"Right' class='right'/><\/span><\/th>");s.append(e);var h=$("#"+i+"Left",e),c=$("#"+i+"Right",e),l=$("<ul tabindex='-1' class='is-no-select'><\/ul>");h.append(l);o=$("<ul tabindex='-1' class='is-no-select'><\/ul>");c.append(o);n.Control={lstLeft:h,lstRight:c,ulLeft:l,ulRight:o,groupingItems:a,groupedItems:[]};w(n,n.Value);n.IndentLevel&&e.css("border-left",n.IndentLevel*32+"px solid transparent");r.append(s)}function w(n,t){var o=n.Control.groupingItems,s=n.Control.groupedItems,e,r,f,i;if(n.Value=t,t)for(e=t.split("|"),r=0;r<e.length;r++){var u=e[r],h=u.indexOf(";"),c=!1;for(h!==-1&&(c=!0,u=u.substr(0,h)),f=0;f<o.length;f++)i=o[f],u.toUpperCase()===i.name.toUpperCase()&&(i.groupBy=!0,i.pageBreakAfter=c,s.includes(i)||s.push(i))}b(n);k(n)}function b(n){var t,i,r;for(n.Control.ulLeft.children().remove(),t=0;t<n.Control.groupingItems.length;t++)i=n.Control.groupingItems[t],i.groupBy||(r=$("<li index='"+i.index+"'><\/li>"),r.text(i.caption),r.append("<button action='add'><\/button>"),n.Control.ulLeft.append(r));g(n,!1)}function k(t,i){var f,r,u,e;for(t.Control.ulRight.children().remove(),f=0;f<t.Control.groupedItems.length;f++)r=t.Control.groupedItems[f],u=$("<li index='"+r.index+"'><span><\/span>"+$Runtime.HtmlEncode(r.caption)+"<\/li>"),u.append("<button action='remove' tabindex='0'><\/button>"),t.GroupingListShowPageBreakButton&&(e=$("<button action='pagebreak' tabindex='0' title='Page break before'><\/button>"),e.css("background-image","url("+n.GetIconUrl("PageBreak",16)+")"),r.pageBreakAfter&&e.addClass("checked"),u.append(e)),i===r.index&&u.addClass("selected"),t.Control.ulRight.append(u);d(t);g(t,!0)}function d(n){for(var r,i=$("li > span",n.Control.ulRight),t=0;t<i.length;t++)r=$(i[t]),n.NoIndent||r.css("padding-left",t*8+"px")}function g(n,t){if(!n.readOnly){var i=t?n.Control.ulRight:n.Control.ulLeft,r=$("li",i);r.click(function(){s(n,i,$(this).attr("index"))});t?($("button",r).click(function(){var i=$(this).parent().attr("index"),t;switch($(this).attr("action")){case"remove":tt(n,i);break;case"pagebreak":t=n.Control.groupingItems[i];t.pageBreakAfter=!t.pageBreakAfter;t.pageBreakAfter?$(this).addClass("checked"):$(this).removeClass("checked");a(n)}}),r.bind("dblclick",function(){tt(n,$(this).attr("index"))})):($("button",r).click(function(){nt(n,$(this).parent().attr("index"))}),r.bind("dblclick",function(){nt(n,$(this).attr("index"))}));i.unbind("keydown.list");i.bind("keydown.list",function(t){for(var l,r,e=$("li",i),o=-1,u=-1,f=-1,h=-1,a=-1,c=0;c<e.length;c++)l=$(e[c]),r=l.attr("index"),o===-1&&(o=r),a=r,f===-1&&u!=-1&&(f=r),u===-1&&l.hasClass("selected")&&(u=r),u===-1&&(h=r);switch(t.keyCode){case 35:return e.length>0&&s(n,i,a,!0),t.preventDefault(),!1;case 36:return s(n,i,o,!0),t.preventDefault(),!1;case 38:return h!==-1&&s(n,i,h,!0),t.preventDefault(),!1;case 40:return f!==-1&&s(n,i,f,!0),t.preventDefault(),!1}})}}function nt(n,t){var r=$("li[index='"+t+"']",n.Control.ulLeft),i;r.remove();i=n.Control.groupingItems[t];i.groupBy=!0;i.pageBreakAfter=!1;n.Control.groupedItems.push(i);k(n,t);a(n)}function tt(n,t){var f=$("li[index='"+t+"']",n.Control.ulRight),u,r,i;for(f.remove(),i=n.Control.groupingItems[t],i.groupBy=!1,u=[],r=0;r<n.Control.groupingItems.length;r++)i=n.Control.groupingItems[r],i.groupBy&&u.push(i);n.Control.groupedItems=u;b(n,t);d(n);a(n);s(n,n.Control.ulLeft,t)}function s(n,t,i,r){$("li",t).removeClass("selected");var u=$("li[index='"+i+"']",t);u.addClass("selected");r&&u.ScrollElementIntoView(!0)}function a(n){for(var r,t="",i=0;i<n.Control.groupedItems.length;i++)r=n.Control.groupedItems[i],t&&(t+="|"),t+=r.name,r.pageBreakAfter&&(t+=";True");console.log(t);n.Value=t}function yt(t){var f=$("<tr><\/tr>"),o="cbo"+$Runtime.CreateGuid(!0),u=$("<th><label for='"+o+"'>"+$Runtime.HtmlEncode(t.Caption,!0)+":<\/label><\/th><th><input id='"+o+"'/><\/th>"),i;f.append(u);i=new n.ComboBox($("input",u),{allowBlank:!t.Mandatory,readOnly:t.ReadOnly,caption:t.Caption,maxLength:t.MaxLength,listCsv:t.List,onChange:function(n,t){t&&(t.ChangeHandled=!0);n.Parameter.Value=n.Text()},widgetDocument:e.widgetDocument});i.Parameter=t;i.Text(t.Value);t.Control=i;t.IndentLevel&&u.css("border-left",t.IndentLevel*32+"px solid transparent");r.append(f)}function pt(t){var e=parseFloat(t.Value),s=isNaN(e)?null:e,o=$("<tr><\/tr>"),u="num"+$Runtime.CreateGuid(!0),f=$("<th><label for='"+u+"'>"+$Runtime.HtmlEncode(t.Caption,!0)+":<\/label><\/th><th><input id='"+u+"'/><\/th>"),i;o.append(f);r.append(o);i=new n.NumberBox($("#"+u,f),{allowBlank:!0,readOnly:t.ReadOnly,width:"10em",decimals:t.DecimalPlaces});i.Parameter=t;i.Value(s);i.OnChange(function(){t.Value=i.Value()});t.Control=i;t.IndentLevel&&f.css("border-left",t.IndentLevel*32+"px solid transparent")}function wt(t){var o=ft(t.Value),s="10em",h=$("<tr><\/tr>"),f="num"+$Runtime.CreateGuid(!0),e=$("<th><label for='"+f+"From'>"+$Runtime.HtmlEncode(t.Caption,!0)+":<\/label><\/th><th><input id='"+f+"From'/> <small style='display:inline-block'>to<\/small> <input id='"+f+"To'/><\/th>"),i,u;h.append(e);r.append(h);i=new n.NumberBox($("#"+f+"From",e),{allowBlank:!0,readOnly:t.ReadOnly,width:s,decimals:t.DecimalPlaces});i.Parameter=t;i.Value(o.ValueFrom);u=new n.NumberBox($("#"+f+"To",e),{allowBlank:!0,readOnly:t.ReadOnly,width:s,decimals:t.DecimalPlaces});u.Parameter=t;u.Value(o.ValueTo);i.OnChange(function(){t.Value=ut(i.Value(),u.Value())});u.OnChange(function(){t.Value=ut(i.Value(),u.Value())});t.Control=[i,u];t.IndentLevel&&e.css("border-left",t.IndentLevel*32+"px solid transparent")}function bt(t){var u=$("<tr><\/tr>"),f="cbo"+$Runtime.CreateGuid(!0),o=$("<th><label for='"+f+"'>"+$Runtime.HtmlEncode(t.Caption,!0)+":<\/label><\/th><th><input id='"+f+"'/><\/th>"),i;u.append(o);i=new n.DBCombo($("input",o),{allowBlank:!t.Mandatory,readOnly:t.ReadOnly,caption:t.Caption,maxLength:t.MaxLength,onChange:function(n,t){t&&(t.ChangeHandled=!0);n.Parameter.Value=n.Text()},widgetDocument:e.widgetDocument});i.Parameter=t;i.RefreshFromCollection(t.DataSource,t.DataSourceIdField,t.DataSourceDescriptionField,t.DataSourceFieldList);i.Text(t.Value);t.Control=i;r.append(u)}function kt(t){var e=$("<tr><\/tr>"),i=t.Caption,u,o,f;i&&i.endsWith(".")&&(i=i.substring(0,i.length-1));u=$("<th colspan='2'><label>"+$Runtime.HtmlEncode(i)+"<\/label><\/th>");e.append(u);o=new n.Label($("label",u),{style:"PageHeading"});t.TooltipText&&(f=$("<p><\/p>"),f.text(t.TooltipText),o.Element().insertAfter(f));r.append(e)}function dt(t){var f=$("<tr><\/tr>"),i=t.Caption,u,e;i&&i.endsWith(".")&&(i=i.substring(0,i.length-1));u=$("<th colspan='2'><label>"+$Runtime.HtmlEncode(i)+"<\/label><\/th>");f.append(u);e=new n.Label($("label",u),{tooltipText:t.TooltipText});r.append(f)}function gt(t){var e=$("<tr><\/tr>"),o="txt"+$Runtime.CreateGuid(!0),u=$("<th><label for='"+o+"'>"+$Runtime.HtmlEncode(t.Caption,!0)+":<\/label><\/th><th><input id='"+o+"'/><\/th>"),f,i;e.append(u);f={allowBlank:!t.Mandatory,caption:t.Caption,multiLine:t.Rows&&t.Rows>1,readOnly:t.ReadOnly,rows:t.Rows,onChange:function(n,t){t&&(t.ChangeHandled=!0);n.Parameter.Value=n.Text()},actionsButtonIcon:"Find",actionsButtonVisible:!0,onActionsButtonClick:function(){ni(t)}};f.width="100%";i=new n.TextBox($("input",u),f);i.Parameter=t;i.Text(t.Value);t.Control=i;t.IndentLevel&&u.css("border-left",t.IndentLevel*32+"px solid transparent");r.append(e)}function ni(n){$App.FormOpen("RangeLookup","",{caption:"Lookup "+n.Caption,rangeSource:n.RangeLookupSource,rangeType:n.RangeType,rangeLookupSql:n.RangeLookupSql,sqlWhere:n.RangeLookupSqlWhere,idField:n.RangeLookupIdField,fieldList:n.RangeLookupFieldList,sourceControl:n.Control},null)}function ti(t){var e=$("<tr><\/tr>"),o="txt"+$Runtime.CreateGuid(!0),f=$("<th><label for='"+o+"'>"+$Runtime.HtmlEncode(t.Caption,!0)+":<\/label><\/th><th><input id='"+o+"'/><\/th>"),i,u;e.append(f);i={allowBlank:!t.Mandatory,caption:t.Caption,maxLength:t.MaxLength,multiLine:t.Rows&&t.Rows>1,readOnly:t.ReadOnly,rows:t.Rows,onChange:function(n,t){t&&(t.ChangeHandled=!0);n.Parameter.Value=n.Text()}};i.multiLine&&(i.width="100%");u=new n.TextBox($("input",f),i);u.Parameter=t;u.Text(t.Value);t.Control=u;t.IndentLevel&&f.css("border-left",t.IndentLevel*32+"px solid transparent");r.append(e)}function ii(n){console.warn("$UI.ParametersHost: Parameter Type '"+n.ParameterType+"' not implemented.");var t=$("<tr><\/tr>"),i=$("<th colspan='2' style='color:red;'>'"+n.ParameterType+"' type parameter not implemented.<\/th>");t.append(i);r.append(t)}function it(n,t){var i="";return n&&(i+=$Runtime.FormatDateInternal(n,"yyyy-MM-dd",!0)),i+="|",t&&(i+=$Runtime.FormatDateInternal(t,"yyyy-MM-dd",!0)),i}function rt(n){var u=null,f=null,t,i,r;return n&&(t=n.indexOf("|"),t!=-1&&(i=Date.parse(n.substring(0,t)),i&&(u=new Date(i)),r=Date.parse(n.substring(t+1)),r&&(f=new Date(r)))),{DateFrom:u,DateTo:f}}function ut(n,t){var i="";return(n||n==0)&&(i+=n),i+="|",(t||t==0)&&(i+=t),i}function ft(n){var r=null,u=null,i,t;return n&&(i=n.indexOf("|"),i!=-1&&(t=n.substring(0,i),t&&(r=parseFloat(t)),t=n.substring(i+1),t&&(u=parseFloat(t)))),{ValueFrom:r,ValueTo:u}}function ri(){return f}function ui(){var t,n;if(f.focus(),u&&u.length!=0)for(t=0;t<u.length;t++)if(n=u[t],n.Visible&&n.Control&&n.Control.Focus){n.Control.Focus();break}}function fi(n){for(var u=[],n=$Runtime.ArrayFromCsvString(n),i=0;i<n.length;i++){var t=n[i],r=t.indexOf("["),f=t;r!=-1&&(f=t.substr(0,r),t=t.substr(r+1),t=t.substr(0,t.length-1));u.push({index:i,name:t,caption:f,groupBy:!1,pageBreakAfter:!1,selected:!1})}return u}function ei(n){var t,i;for(n=n.toUpperCase(),t=0;t<u.length;t++)if(i=u[t],n===i.Name.toUpperCase())return i;return null}function oi(){for(var n,i={},t=0;t<u.length;t++)n=u[t],n.ReadOnly||(i[n.Name]=n.Value);return i}function et(n){var i,r,t,f,e;for(i in n)for(r=0;r<u.length;r++)if(t=u[r],t.Name.toUpperCase()===i.toUpperCase())switch(t.ParameterType){case"Boolean":t.Value=n[i]&&(n[i]+"").toLowerCase()=="true";t.Control&&t.Control.Value(t.Value);break;case"Date":t.Value=n[i];t.Control.Value($Runtime.ParseJsonDate(t.Value));break;case"DateRange":t.Value=n[i];f=rt(t.Value);t.Control&&(t.Control[0].Value(f.DateFrom),t.Control[1].Value(f.DateTo));break;case"CheckList":case"List":case"Range":case"Text":t.Value=n[i]?n[i]+"":"";t.Control&&t.Control.Text(t.Value);break;case"GroupingList":w(t,n[i]);break;case"Number":t.Value=n[i];t.Control.Value($Runtime.ParseNumber(t.Value,t.DecimalPlaces));break;case"NumberRange":t.Value=n[i];e=ft(t.Value);t.Control&&(t.Control[0].Value(e.ValueFrom),t.Control[1].Value(e.ValueTo));break;default:console.warn("ParametersHost.UpdateParameterValues: Parameter Type '"+t.ParameterType+"' not handled")}}function si(n,t){var f={},r,i;for(f[n]=t,et(f),n=n.toUpperCase(),r=0;r<u.length;r++)if(i=u[r],i.Name.toUpperCase()===n&&i.Control&&i.Control.Element){i.Control.Element().addClass("is-parameter-highlight");break}}function hi(){y(!0)}function ci(n){var i,t;if(n&&h)for(i=JSON.parse(h),n.splice(0,n.length),t=0;t<i.length;t++)n.push(i[t])}function li(){f.hide();f.css({width:"100%",height:"100%",overflow:"auto"});e.visible&&f.show()}function ai(n){if(n==undefined)return e.visible;n!=e.visible&&(e.visible=n==!0,e.visible?f.show():f.hide())}var f,v=!1,e,u,o,h,r,c,l;if(ParametersHostDefaults={width:"auto",onEnterKey:null,visible:!0,widgetDocument:null},e=$.extend({},ParametersHostDefaults,i),typeof t=="string"?(c=n.ExtUtils.TranslateElementId(t),t=$("#"+c)):c=$(t).attr("id"),l=$(t),l.length===0){console.warn("userinterface.ParametersHost: Element '"+c+"' not found.");return}return f=$(l[0]),e.visible?f.show():f.hide(),{TypeName:"ParametersHost",Element:ri,Focus:ui,Initialise:ot,Refresh:hi,ResizeFromParent:li,RestoreParametersFromSnapshot:ci,Visible:ai,GetParameterValues:oi,UpdateParameterValues:et,SetParameterValueByName:si,Tag:{}}},n}($UI||{});console.log("  $UI (parameters host extension)");console.log("Loading lib/isuserinterface_documentmanager.js");__UIExtDocumentManager=function(n){return n.DocumentManager=function(t,i){function a(t){var f,s,i;t&&(nt=!0,e.addClass("is-documentmanager"),e.children().remove(),h=$("<div class='is-documentmanager-title'><\/title>"),e.append(h),p=$("<div class='is-documentmanager-body is-no-select'><\/title>"),e.append(p),h.hide(),r.allowUpload&&(f="cmd"+$Runtime.CreateGuid(!0),o=$("<input id='"+f+"' type='file' multiple='true' style='display:none'/>"),d=$("<label for='"+f+"' class='is-button is-glyph-upload upload' style='margin-left:8px' title='Upload File(s)'><\/label>"),h.append(o),h.append(d),o.change(function(){ui()})),s=$("<div id='grid"+$Runtime.CreateGuid(!0)+"' class='is-dock-fill force-auto-shift-buttons'><\/div>"),u=n.Grid(s,{stickyHeader:!0,onAction:at,onAfterRowActivate:ot,onContextMenuShow:st,onInitialiseRow:ct,onRowDrilldown:lt}),u.AddColumnIcon("FileTypeIcon",{}),u.AddColumnString("FileCategory",{caption:"Category",visible:!1}),u.AddColumnDateTime("FileDate",{caption:"Date",sortable:!0}),u.AddColumnString("FileName",{caption:"File Name",sortable:!0}),u.AddColumnString("FileSize",{caption:"Size",width:"5em",align:"right",sortable:!0}),p.append(s),i=[],r.allowUpload&&i.push({actionId:"Upload",tooltipText:"Upload file(s)",icon:"Upload",caption:"Upload"}),r.allowDownload&&i.push({actionId:"Download",tooltipText:"Download a copy of the selected file",icon:"Download",caption:"Download"}),i.push({}),r.allowUpload&&i.push({actionId:"Rename",tooltipText:"Rename the selected file",icon:"Control_Text",caption:"Rename"}),i.push({}),r.allowDelete&&i.push({actionId:"Delete",tooltipText:"Delete selected file",icon:"Delete"}),u.Actions().Define(i))}function v(n){var i,r,t;if(f=n,y=!1,n&&s.length>0){for(i=-1,r=s[s.length-1].updatedFileName,t=0;t<f.length;t++)if(f[t].FileName===r){i=t;break}i!==-1&&u.ActiveDataRowListIndex(i);s=[]}ut()}function ut(){a(!nt);y||(y=!0,et())}function ft(n){var t="";switch(n.toUpperCase()){case"BMP":case"GIF":case"JPG":case"JPEG":case"PNG":case"PSD":case"TIF":case"TIFF":t="Image";break;case"DOC":case"DOCX":case"DOT":case"DOTX":t="DocumentType_Word";break;case"HTM":case"HTML":t="DocumentType_XML";break;case"PDF":t="DocumentType_PDF";break;case"TXT":t="DocumentType_Text";break;case"XLS":case"XLW":case"XLT":case"XLSX":case"XLTX":t="DocumentType_Excel";break;case"XML":t="DocumentType_XML";break;default:t="Document"}return t}function et(){var t,n;for(u.GroupByColumns(""),n=0;n<f.length;n++)if(f[n]&&f[n].FileCategory){u.GroupByColumns("FileCategory");break}if(u.VirtualDataRefresh(f),t=!1,c){for(n=0;n<f.length;n++)f[n]&&f[n].FileNameWithCategoryAndExtension===c&&(t=!0,u.ActiveDataRowListIndex(n));c=!1}t||u.ActivateLastDataRow(!1)}function ot(){ht()}function st(n){if(n.row&&n.row.listIndex!==-1){var t=n.items;(r.allowUpload||r.allowDownload)&&(r.allowUpload&&t.unshift({ItemId:"GridAction:Rename",Icon:"Control_Text",Caption:"Rename"}),r.allowDownload&&t.unshift({ItemId:"GridAction:Download",Icon:"Download",Caption:"Download"}),t.unshift({ItemType:"SubMenu",Caption:"File"}))}}function ht(){var n=u.GetSelectedRowIndexes(!0,!0);u.Actions().SetEnabled("Download",n.length!==0);u.Actions().SetEnabled("Rename",n.length!==0);u.Actions().SetEnabled("Delete",n.length!==0);u.RefreshButtons()}function ct(n){var t=f[n.row.listIndex],i=t.FileName,r="",u=i.lastIndexOf(".");u!==-1&&(r=i.substring(u+1));n.row.cells.FileCategory.value=t.FileCategory?t.FileCategory:"(no category)";n.row.cells.FileTypeIcon.value=ft(r);n.row.cells.FileName.value=i;n.row.cells.FileDate.value=t.FileDate;t.FileSize&&(n.row.cells.FileSize.value=Math.ceil(t.FileSize/1024)+"KB",n.row.cells.FileSize.sortValue=t.FileSize);n.row.inactive=t.Missing;n.row.hidden=t.Missing}function lt(n){u.ActiveDataRowListIndex(n.row.listIndex);b(!0)}function at(n){switch(n){case"Delete":ii(!1);break;case"Download":b(!1);break;case"Rename":ti();break;case"Upload":tt();break;default:window.alert(n)}}function vt(){}function yt(n,t,i,u,e){r=$.extend({},DocumentManagerDefaults,{adHoc:!0,itemType:n,itemId:t,itemPk:i,allowDownload:!0});f=[];f.push({Missing:!1,FileName:u});b(e)}function b(t){var i=u?u.ActiveDataRowListIndex():-1,e;if(!r.adHoc){if(i<0||i>f.length-1)return;if(!r.allowDownload)return}if(e=r.adHoc?f[0]:f[i],e.Missing){n.MsgBoxAlert("This file is missing and cannot be downloaded.");return}(!t||window.confirm("Download a copy of this file?"))&&pt(e)}function pt(n){var t={itemType:r.itemType,itemId:r.itemId,fileName:n.FileNameWithCategoryAndExtension||n.FileName};r.itemPk!=-1&&(t.itemPk=r.itemPk);$App.IsApp_Android()&&kt(n,t);$App.IsApp_iOS()?gt(n,t):wt(n,t)}function wt(t,i){g+=1;var r=window.open("","download"+g),u=$App.WebServicesUrl()+"/DocumentManager/GetFileDownloadUrl";$Api.GetDirect(u,i,{done:function(n){bt(n,r,t.FileNameWithCategoryAndExtension||t.FileName)},fail:function(t){n.ShowAjaxError(t)},always:function(){n.WaitHide()}})}function bt(n,t){n=$App.WebServicesUrl()+"/DocumentManager/DownloadFileFromUrl&fileDownloadUrl="+n;t.location=n}function kt(t,i){var r=t.FileNameWithCategoryAndExtension||t.FileName,u=$App.WebServicesUrl()+"/DocumentManager/GetFileDownloadUrl";i.AppType="android";$Api.GetDirect(u,i,{done:function(n){dt(n,r)},fail:function(t){n.ShowAjaxError(t)},always:function(){n.WaitHide()}})}function dt(n){n=$App.WebServicesUrl()+"/DocumentManager/DownloadFileFromUrl2&fileDownloadUrl="+n;document.location.href=n+"[download]"}function gt(t,i){var r=t.FileNameWithCategoryAndExtension||t.FileName,u=$App.WebServicesUrl()+"/DocumentManager/GetFileDownloadUrl";i.AppType="ios";$Api.GetDirect(u,i,{done:function(n){ni(n,r)},fail:function(t){n.ShowAjaxError(t)},always:function(){n.WaitHide()}})}function ni(n){n=$App.WebServicesUrl()+"/DocumentManager/DownloadFileFromUrl2&fileDownloadUrl="+n;document.location.href=n+"[download]"}function ti(){var e=u.ActiveDataRowListIndex(),t;if(!(e<0)&&!(e>f.length-1)&&r.allowUpload){if(t=f[e],!t||t.Missing||t.Deleted){n.MsgBoxAlert("This file is missing or has been deleted.");return}var i=t.FileNameWithCategoryAndExtension,o=0,s=0;i.indexOf("\\")>0&&(o=i.indexOf("\\")+1);i.lastIndexOf(".")>0&&(s=i.lastIndexOf(".")-o);n.CommonDialog().GetInput("Rename File","Specify a new file name","File Name",function(u){if(u!==i){n.WaitShow("Renaming file ("+t.FileName+")");var s=$App.WebServicesUrl()+"/DocumentManager/Rename"+r.itemType+"File",o={originalFileName:t.FileNameWithCategoryAndExtension,newFileName:u};o[r.itemType.toLowerCase()+"Id"]=r.itemId;$Api.GetDirect(s,o,{done:function(){var t=f[e],n;if(t.FileNameWithCategoryAndExtension=u,$App.NotificationsAddInfo("Renamed file "+i+" to "+u,"",!0,"File Renamed"),r.onUploadComplete){n={uploadedFiles:[]};r.onUploadComplete(n);c=u}},fail:function(t){n.ShowAjaxError(t)},always:function(){n.WaitHide()}})}},{defaultValue:i,maxLength:100,message:"If this file is linked to any items for this record such as Logs, these will be updated to reflect the new file name.",okCaption:"Rename",selStart:o,selLength:s})}}function ii(){var i=u.ActiveDataRowListIndex(),t;if(!(i<0)&&!(i>f.length-1)&&r.allowDelete){if(t=f[i],!t||t.Missing||t.Deleted){n.MsgBoxAlert("This file is missing or has already been deleted.");return}n.MsgBoxConfirmDelete("PERMANENTLY DELETE file '"+t.FileName+"'?",{},function(){var o=$App.WebServicesUrl()+"/DocumentManager/Delete"+r.itemType+"File",e={fileName:t.FileNameWithCategoryAndExtension};e[r.itemType.toLowerCase()+"Id"]=r.itemId;n.WaitShow("Deleting file ("+t.FileName+")");$Api.GetDirect(o,e,{done:function(){$Runtime.ArrayRemove(f,f[i]);u.ActiveDataRowListIndex(u.ActiveDataRowListIndex()+1);v(f);$App.NotificationsAddInfo("Deleted file "+t.FileName,"",!0,"File Deleted")},fail:function(t){n.ShowAjaxError(t)},always:function(){n.WaitHide()}})})}}function tt(){h||(a(!0),v([]));o.attr("accept","");o.removeAttr("capture");o.val("");o.click()}function ri(){h||(a(!0),v([]));o.attr("accept","audio");o.attr("capture","microphone");o.val("");o.click()}function ui(){var i=o[0].files,t;if(s=[],!(i.length<=0)){switch(i.length){case 1:t="Upload selected file?";r.itemType&&r.itemId&&(t+="\n\nYou can optionally create a Log to link this file to.");break;default:t="Upload "+i.length+" selected files?";r.itemType&&r.itemId&&(t+="\n\nYou can optionally create a Log to link each of these files to.")}n.MsgBoxConfirm(t,{heading:"File Upload",additionalButtons:[{actionId:"OkLog",caption:"Upload & Create Logs",buttonStyle:"ok"}]},function(t){n.WaitShow("");it(i,0,t==="OkLog",-1)})}}function it(t,i,r,u){if(i>=t.length){n.WaitHide();k();return}n.WaitUpdate("Uploading file "+(i+1)+" of "+t.length+" ("+t[i].name+")");$Runtime.IsMobileBrowser()?ei(t,i,r,u):fi(t,i,r,u)}function rt(t,i,u,f,e){var h=t[i],o=new XMLHttpRequest,c=$App.WebServicesUrl()+"/DocumentManager/Upload"+r.itemType+"File"+("?"+r.itemType.toLowerCase()+"Id="+encodeURI(r.itemId)+"&fileName="+encodeURI(h.name)+"&overwrite=false&createLog="+f+"&parentLogPk="+e);try{o.open("POST",c,!0);o.onload=function(){if(this.status===200){var r=JSON.parse(o.responseText);s.push({fileName:h.name,updatedFileName:r.UpdatedFileName,logPk:r.LogPk});e&&e!==-1||(e=r.LogPk);it(t,i+1,f,e)}else $App.NotificationsAddError("An error occurred uploading file '"+h.name+"'.",$Runtime.ParseAjaxError(o)),n.WaitHide(),i>0&&k()};o.send(u)}catch(l){$App.NotificationsAddError("An error occurred uploading file '"+h.name+"'.",$Runtime.ParseAjaxError(o));i>0&&k()}}function fi(n,t,i,r){var u=n[t],f=new FormData;f.append("fileData",u,u.name);rt(n,t,f,i,r)}function ei(t,i,r,u){var e=t[i],f=new FileReader;f.onloadend=function(){oi(t,i,f,r,u)};f.onerror=function(){window.alert("There was an error reading the file.");n.WaitHide()};f.readAsDataURL(e)}function oi(n,t,i,r,u){var e=n[t],f=new FormData;f.append("fileData",i.result);rt(n,t,f,r,u)}function k(){var u="",t,i,n,f;switch(s.length){case 1:u="1 file was uploaded.";break;default:u=s.length+" files were uploaded."}for(t="",i=0;i<s.length;i++)n=s[i],t&&(t+="\n"),t+=n.fileName===n.updatedFileName?n.fileName:n.fileName+" (renamed to "+n.updatedFileName+")";if($App.NotificationsAddInfo(u,t,!0,"Upload Complete"),r.onUploadComplete){f={uploadedFiles:s};r.onUploadComplete(f)}}function si(){return e}function hi(n){if(n===undefined)return r.itemId;r.itemId=n}function ci(){e.focus()}function li(){a(!0)}function ai(){e.hide();e.css({width:"100%",height:"100%",overflow:"auto"});r.visible&&e.show()}function vi(n){if(n===undefined)return r.visible;n!==r.visible&&(r.visible=n===!0,r.visible?e.show():e.hide())}var o,d,g=1,e,u,y,nt=!1,r,f,h,p,c,s=[],l,w;if(DocumentManagerDefaults={itemType:"",itemId:"",itemPk:-1,adHoc:!1,allowDelete:!1,allowDownload:!1,allowUpload:!1,visible:!0,onUploadComplete:null},r=$.extend({},DocumentManagerDefaults,i),typeof t=="string"?(l=n.ExtUtils.TranslateElementId(t),t=$("#"+l)):l=$(t).attr("id"),w=$(t),w.length===0){console.warn("userinterface.DocumentManager: Element '"+l+"' not found.");return}return e=$(w[0]),r.visible?e.show():e.hide(),{TypeName:"DocumentManager",Element:si,Focus:ci,Initialise:v,ItemId:hi,Refresh:li,ResizeFromParent:ai,Visible:vi,DownloadAdHocFile:yt,DownloadExportedGridData:vt,ShowFileUploadDialog:tt,ShowFileUploadDialogForAudio:ri,Tag:{}}},n}($UI||{});console.log("  $UI (document manager extension)");console.log("Loading lib/isuserinterface_treeview.js");__UIExtTreeView=function(n){return n.TreeView=function(t,i){function v(n){if(n){if(w=!0,r.addClass("is-treeview"),r.addClass("is-no-select"),r.children().remove(),e=$("<ul><\/ul>"),r.append(e),s&&s.length!=0)for(var t=0;t<s.length;t++)l(e,s[t]);f.visible?r.show():r.hide()}}function l(t,i){var r=$("<li><\/li>"),e,u,h,s;if(r.attr("nodeid",i.NodeId),r.data("node",i),r.addClass("collapsed"),i.Active||r.addClass("inactive"),i.HasUnfetchedChildNodes||i.ChildNodes&&i.ChildNodes.length!=0?(e=$("<span class='expander'><\/span>"),r.append(e),e.click(function(n){n.stopPropagation();r.hasClass("collapsed")?$("> ul",r).slideDown("fast"):$("> ul",r).slideUp("fast");r.toggleClass("collapsed");a(i)})):(e=$("<span class='expander none'><\/span>"),r.append(e)),u=$("<span>"+$Runtime.HtmlEncode(i.Text)+"<\/span>"),r.append(u),i.Icon&&(i.IconExpanded?(u.prepend("<img state='collapsed' src='"+n.GetIconUrl(i.Icon,16)+"'/>"),u.prepend("<img state='expanded' src='"+n.GetIconUrl(i.IconExpanded,16)+"'/>")):u.prepend("<img src='"+n.GetIconUrl(i.Icon,16)+"'/>")),i.BulletText&&u.append("<span class='bullettext'>"+$Runtime.HtmlEncode(i.BulletText)+"<\/span>"),t.append(r),r.click(function(n){n.stopPropagation();r.hasClass("selected")&&(r.hasClass("collapsed")?$("> ul",r).slideDown("fast"):$("> ul",r).slideUp("fast"),r.toggleClass("collapsed"));o(i.NodeId);a(i)}),f.onNodeDblClick&&r.dblclick(function(n){n.stopPropagation();f.onNodeDblClick(i)}),i.ChildNodes&&i.ChildNodes.length!=0)for(h=$("<ul style='display:none'><\/ul>"),r.append(h),s=0;s<i.ChildNodes.length;s++)l(h,i.ChildNodes[s])}function b(n){s=y(n);v(!0)}function y(n){if(n)for(var t=0;t<n.length;t++)n[t]=$.extend({},NodeDefaults,n[t]);return n}function a(n){var t,i;if(n.HasUnfetchedChildNodes&&!n._fetching)if(t=$("li[nodeid='"+n.NodeId+"']",e),n._fetching=!0,t.addClass("fetching"),f.onFetchChildNodes){i={node:n};f.onFetchChildNodes(p,i)}else window.alert("onFetchChildNodes function not defined.")}function k(n,t){var u=$("li[nodeid='"+n.NodeId+"']",e),i,r;if(u.removeClass("fetching"),u.removeClass("collapsed"),n.ChildNodes=y(t),n.HasUnfetchedChildNodes=!1,n.ChildNodes&&n.ChildNodes.length!=0){for(i=$("<ul style='display:none'><\/ul>"),u.append(i),r=0;r<n.ChildNodes.length;r++)l(i,n.ChildNodes[r]);i.slideDown("fast")}}function d(){for(var r,n,t=!1,f=$("li",e),s="",i=0;i<f.length;i++)if(r=$(f[i]),r.is(":visible"))if(n=r.data("node"),u)if(n.NodeId==u)t=!0;else if(t){o(n.NodeId);break}else s=n.NodeId;else{t=!0;o(n.NodeId);break}}function g(){for(var f,s,i=!1,r=$("li",e),n="",t=0;t<r.length;t++)if(f=$(r[t]),f.is(":visible")){if(s=f.data("node"),s.NodeId==u)i=!0;else if(i){n&&o(n);break}else n=s.NodeId;i&&n&&t==r.length-1&&o(n)}}function nt(n){if((n==undefined&&(n=!1),f.visible)&&u){var i=$("li[nodeid='"+u+"']",e),t=i;do{t=t.parent();switch(t.prop("tagName")){case"UL":break;case"LI":t.hasClass("collapsed")&&(t.removeClass("collapsed"),$("> ul",t).slideDown("fast"));break;default:t=null}}while(t);window.setTimeout(function(){var t=$("li[nodeid='"+u+"'] > span:first-child",e);t.ScrollElementIntoView(n,!1,{})},10)}}function tt(){return r}function it(){r.focus()}function rt(){v(!0)}function o(n){if(n==undefined)return u;u!=n&&(u=n,$("li",e).removeClass("selected"),u&&$("li[nodeid='"+u+"']",e).addClass("selected"),f.onNodeSelect&&f.onNodeSelect());u&&nt(!0)}function ut(){if(u){var n=$("li[nodeid='"+u+"']",e);return n.data("node")}return null}function ft(){r.hide();r.css({width:"100%",height:"100%",overflow:"auto"});f.visible&&r.show()}function et(n){if(n==undefined)return f.visible;n!=f.visible&&(f.visible=n==!0,f.visible?r.show():r.hide())}var r,w=!1,e,s=[],f,u,h,c,p;if(NodeDefaults={NodeId:null,Active:!0,Expanded:!0,HasUnfetchedChildNodes:!1,Icon:"",IconExpanded:"",Text:"",BulletText:"",ChildNodes:null,Tag:null},TreeviewDefaults={itemType:"",itemId:"",itemPk:-1,visible:!0,onNodeDblClick:null,onNodeSelect:null,onFetchChildNodes:null},f=$.extend({},TreeviewDefaults,i),typeof t=="string"?(h=n.ExtUtils.TranslateElementId(t),t=$("#"+h)):h=$(t).attr("id"),c=$(t),c.length==0){console.warn("userinterface.TreeView: Element '"+h+"' not found.");return}return r=$(c[0]),r.attr("tabindex","-1"),r.bind("keydown",function(n){var t;switch(n.keyCode){case 27:o("");break;case 35:return!1;case 36:return!1;case 37:return u&&(t=$("li[nodeid='"+u+"']",e),t.hasClass("collapsed")||($("> ul",t).slideUp("fast"),t.addClass("collapsed"))),!1;case 38:return g(),!1;case 39:return u&&(t=$("li[nodeid='"+u+"']",e),a(t.data("node")),t.hasClass("collapsed")&&($("> ul",t).slideDown("fast"),t.removeClass("collapsed"))),!1;case 40:return d(),!1}}),f.visible?r.show():r.hide(),p={TypeName:"TreeView",Element:tt,Focus:it,Initialise:b,NodeSetChildNodes:k,Refresh:rt,ResizeFromParent:ft,SelectedNode:ut,SelectedNodeId:o,Visible:et,NodeList:function(){return s}}},n}($UI||{});console.log("  $UI (tree view extension)");console.log("Loading lib/isuserinterface_smartlist.js");__UIExtSmartList=function(n){return n.SmartList=function(t,i){function ht(n,t,i){if(e=n,y=t,r=null,vt=i,e&&e.UserParameters){if(w.Initialise(e.UserParameters,{alwaysCreateControls:!0,onEnterKey:function(){ct(!0)}}),w.Element()[0].scrollHeight>w.Element()[0].clientHeight?ot.show():ot.hide(),vt)try{w.UpdateParameterValues(JSON.parse(vt))}catch(o){console.warn("Failed to set smart list initialisation parameters:\n\n"+o)}var u=$("<button class='smart-list-go is-button ok'/>");a.append(u);u.click(function(){ct(!0)});e.ParametersHideByDefault?c.addClass("parameters-hidden"):c.removeClass("parameters-hidden");f.showHeading&&nt.show();a.show()}else a.hide(),f.showHeading&&nt.hide(),c.removeClass("parameters-hidden");if(kt(),f.onInitialised)f.onInitialised(_self,{});e&&ct(!1)}function hi(t,i,r,u){o=t;l=i;s=r?r:"";h=u?u:"";k=$App.WebServicesUrl()+"/ISFormTasks/ExecuteSmartList";tt=$App.WebServicesUrl()+"/ISFormTasks/ExecuteRowAction";b=$App.WebServicesUrl()+"/ISFormTasks/GetSmartListRowSummary";var c={taskGroupId:t,itemId:i,userId:r,platform:$App.SettingsDevice().Platform};$Api.GetDirect($App.WebServicesUrl()+"/ISFormTasks/GetTaskItemSmartList",c,{done:function(n){e=n},fail:function(t){n.ShowAjaxError(t,f.modal);e=null},always:function(){ht(e,"Tasks","")}})}function ci(t){o=t;l="";s="";h="";k=$App.WebServicesUrl()+"/Search/ExecuteQuickList";tt=$App.WebServicesUrl()+"/Search/ExecuteQuickListRowAction";b=$App.WebServicesUrl()+"/Search/GetQuickListRowSummary";var i={quickListId:o,quickListType:l,platform:$App.SettingsDevice().Platform};$Api.GetDirect($App.WebServicesUrl()+"/Search/GetQuickList",i,{done:function(n){e=n},fail:function(t){n.ShowAjaxError(t,f.modal);e=null},always:function(){ht(e,"QuickList","")}})}function li(t,i){o=t;l="";s="";h="";k=$App.WebServicesUrl()+"/ISSmartList/Execute";tt=$App.WebServicesUrl()+"/ISSmartList/ExecuteRowAction";b=$App.WebServicesUrl()+"/ISSmartList/GetRowSummary";var r={smartListId:o,platform:$App.SettingsDevice().Platform};$Api.GetDirect($App.WebServicesUrl()+"/ISSmartList/GetSmartList",r,{done:function(n){e=n},fail:function(t){n.ShowAjaxError(t,f.modal);e=null},always:function(){ht(e,"SmartList",i)}})}function kt(){var v,n,i,p,t,a;if(r){for(v=$("header",c),f.showHeading?(v.text(e.Caption),v.show()):v.hide(),u.ClearColumns(),t=0;t<r.Columns.length;t++){n=r.Columns[t];i="";n.Width&&n.Width!==-1&&(i=n.Width+"em");n.Id==="RowActions"&&(rt=n.DataSourceIndex);switch(n.DataType){case"Drilldown":u.AddColumnDrilldown("Drilldown",{drilldownHideIfBlank:!0});break;case"Code":case"String":n.DataType!=="Code"||i||(i="6em");switch(n.SpecialType){case"ColourBlock":case"ColourFlag":u.AddColumnIcon(n.Id,{caption:n.Caption,visible:n.Visible,backgroundColour:n.BackgroundColour,foregroundColour:n.ForegroundColour,sortable:!0});break;case"LogSeverityIcon":u.AddColumnHtml(n.Id,{caption:n.Caption,align:"center",width:"16px",visible:n.Visible,backgroundColour:n.BackgroundColour,foregroundColour:n.ForegroundColour,sortable:!0});break;default:u.AddColumnString(n.Id,{caption:n.Caption,visible:n.Visible,width:i,backgroundColour:n.BackgroundColour,foregroundColour:n.ForegroundColour,sortable:!0})}break;case"Currency":u.AddColumnCurrency(n.Id,{caption:n.Caption,visible:n.Visible,width:i,backgroundColour:n.BackgroundColour,foregroundColour:n.ForegroundColour,sortable:!0});break;case"Date":u.AddColumnDate(n.Id,{caption:n.Caption,visible:n.Visible,backgroundColour:n.BackgroundColour,foregroundColour:n.ForegroundColour,sortable:!0});break;case"DateTime":u.AddColumnDateTime(n.Id,{caption:n.Caption,visible:n.Visible,backgroundColour:n.BackgroundColour,foregroundColour:n.ForegroundColour,sortable:!0});break;case"Integer":switch(n.SpecialType){case"ClientStatus":u.AddColumnIcon(n.Id,{caption:n.Caption,visible:n.Visible,backgroundColour:n.BackgroundColour,foregroundColour:n.ForegroundColour,sortable:!0});break;default:u.AddColumnInteger(n.Id,{caption:n.Caption,visible:n.Visible,width:i,backgroundColour:n.BackgroundColour,foregroundColour:n.ForegroundColour,sortable:!0})}break;case"Hidden":u.AddColumnString(n.Id,{caption:n.Caption,visible:!1});break;default:console.warn("Unhandled Smart List Column Date Type '"+n.DataType+"'.");u.AddColumnString(n.Id,{caption:n.Caption,visible:n.Visible})}}if(r.DataView.GetSummaryColumns=function(n){for(var t,e=r.DataView[n],u=$Runtime.ArrayFromCsvString(r.SummaryColumns.toUpperCase()),f=[],i=0;i<u.length;i++)for(t=0;t<r.Columns.length;t++)if(r.Columns[t].Id.toUpperCase()===u[i]){f.push(e[r.Columns[t].DataSourceIndex]);break}return f},r.DataView.GetCacheKey=function(n){return r&&r.DataView&&r.DataView.GetSummaryColumns?JSON.stringify(r.DataView.GetSummaryColumns(n)):""},r.ShowSummary?it.show():it.hide(),r.DataView.GetPreviewFetchParameters=function(n){var t={},i;if(n!==-1){i=r.DataView[n];switch(y){case"QuickList":t.quickListId=o;break;case"SmartList":t.smartListId=o;break;case"Tasks":t.pageId=o;t.itemId=l;t.userId=s;t.dateAsAt=h}t.summaryColumnsJson=JSON.stringify(r.DataView.GetSummaryColumns(n));t.target="WebInternal";t.highDpi=$Runtime.IsHighDpi()}return t},p=[],r.Actions)for(t=0;t<r.Actions.length;t++)if(a=r.Actions[t],a.Row)switch(a.ActionType){case"RowRefreshNotification":break;default:p.push({actionId:a.Id,caption:a.Caption,tooltipText:a.Description,icon:a.Icon})}else window.alert("Non-grid-based Actions not yet supported.");u.Actions().Define(p)}}function ai(n,t){var e,o,f,s,h,a,i,c,l;if(r&&(e=r.DataView,r.Actions))for(o=0;o<r.Actions.length;o++){f=r.Actions[o];s=JSON.parse(f.ParametersJson);switch(f.ActionType){case"RowRefreshNotification":if(f.Id.toUpperCase()===n&&t)for(h=si(s.IdField),a=f.Mn,i=0;i<e.length;i++)c=e[i],l=!1,(rt===-1||c[rt].indexOf(f.Mn)!==-1)&&(h!==-1&&c[h]===$Runtime.GetProperty(t,s.NotificationIdField)&&(u.SetExpiredRowIndexes([i]),l=!0),l&&v&&(v.CacheRemove(e.GetCacheKey(i)),i===u.ActiveDataRowIndex()&&v.PreviewFromGridCollection(u,r.DataView,b)))}}}function ct(t){var r,i;if(!t||n.ValidateContainer(w.Element())){v.CacheClear();ei("Fetching list...");r="";e&&e.UserParameters&&(r=JSON.stringify(w.GetParameterValues()));i={parametersJson:r,highDpi:$Runtime.IsHighDpi()};yt=o+"|"+l+"|"+s+"|"+h+"|"+(e?e.ScriptId:"")+"|"+r;switch(y){case"QuickList":i.quickListId=o;$Api.GetDirect(k,i,{done:function(n){y==="QuickList"&&i.quickListId===o?dt(n):console.warn("Smart list returned for a different item.")},fail:function(t){n.ShowAjaxError(t,f.modal)},always:function(){if(d(),f.onAfterExecute)f.onAfterExecute(_self,{})}});break;case"SmartList":i.smartListId=o;$Api.GetDirect(k,i,{done:function(n){y==="SmartList"&&i.smartListId===o?dt(n):console.warn("Smart list returned for a different item.")},fail:function(t){n.ShowAjaxError(t,f.modal)},always:function(){if(d(),f.onAfterExecute)f.onAfterExecute(_self,{})}});break;case"Tasks":s||(s="");h||(h="");i.pageId=o;i.itemId=l;i.userId=s;i.dateAsAt=h;$Api.GetDirect(k,i,{done:function(n){y==="Tasks"&&i.pageId===o&&i.itemId===l&&i.userId===s&&i.dateAsAt===h?dt(n):console.warn("Smart list returned for a different item.")},fail:function(t){n.ShowAjaxError(t,f.modal)},always:function(){if(d(),f.onAfterExecute)f.onAfterExecute(_self,{})}});break;default:window.alert("Unhandled source '"+y+"' for Smart List.")}}}function dt(n){var t,i;if(gt===yt?t=u.GetRetainableCacheKeyDetails({}):gt=yt,r=n,kt(),r){u.Sort("");u.VirtualDataRefresh(r.DataView);ut();p.Text("");p.InitialiseGrid(u);i="Type to filter list";switch(r.DataView.length){case 0:case 1:break;default:i+=" ("+r.DataView.length+" items)"}p.BlankTip(i);t&&u.RestoreRetainedCacheKeyDetails(t,{})}}function vi(){return et}function yi(){return e}function pi(n){for(var t,f,i,u,c,h,l,e,s=r.DataView[n.row.listIndex],o=0;o<r.Columns.length;o++){t=r.Columns[o];f=t.DataSourceIndex==-1?"?":s[t.DataSourceIndex];switch(t.SpecialType){case"ClientStatus":if(i="",u="",s[o]){switch(f){case 5:i="ClientStatus_Excellent";u="Excellent";break;case 10:i="ClientStatus_Good";u="Good";break;case 20:i="ClientStatus_Caution";u="Caution";break;case 30:i="ClientStatus_Bad";u="Bad";break;case 40:i="ClientStatus_Adverse";u="Adverse";break;case 45:i="ClientStatus_Bankrupt";u="Bankrupt"}n.row.cells[t.Id].value=i;n.row.cells[t.Id].tooltipText=u}break;case"ColourFlag":s[o]&&(n.row.cells[t.Id].value="Flag["+f+"]",n.row.cells[t.Id].tooltipText=f);break;case"LogSeverityIcon":n.row.cells[t.Id].value=$App.LogSeverities().GetHtmlIcon(f,!0);break;default:n.row.cells[t.Id].value=f}t.Small&&(n.row.cells[t.Id].small=!0);t.FormKey?(c=f,h=t.FormKey,$.isNumeric(h)&&(l=parseInt(h),h=s[l]),c&&(n.row.cells[t.Id].hyperlink="app://formshow?form="+h+"&id="+encodeURI(c))):(e=null,t.Id.endsWith("ClientId")?e="Client":t.Id.endsWith("AccountId")?e="Account":t.Id.endsWith("AccountAppId")?e="AccountApp":t.Id.endsWith("WorkflowId")&&(e="Workflow"),e&&(n.row.cells[t.Id].hyperlink="app://formshow?form="+e+"&id="+encodeURI(s[o])))}}function lt(t,i,f){var h,c,e,s,l,o,a;if(!n.HasMinimisedModal(!0)){for(h=r.Actions,c=u,s=0;s<h.length;s++)if(h[s].Id==t){e=h[s];break}if(e){if(!i&&!f&&e.SpecialType)switch(e.SpecialType){case"FileUpload":l={};n.GetFilesForUpload("Select Document to Upload",l,function(n){for(var r,u,f=[],e=0,i=0;i<n.length;i++)r=new FileReader,u=n[i],r.readAsDataURL(u),r.onload=function(i){return function(r){e+=1;f.push({name:i.name,data:r.target.result});e===n.length&&lt(t,{},f)}}(u)});return;case"FlagList":n.SelectFlagColour(JSON.parse(e.ParametersJson).List,{},function(n){lt(t,{colour:n})});return;case"UserList":n.SelectUser(JSON.parse(e.ParametersJson).Title,{},function(n){lt(t,{userId:n})});return;default:window.alert("SpecialType '"+e.SpecialType+"' not handled.");return}(e.SpecialParams=i?i:null,e.FileData=f?f:null,o=c.GetSelectedRowIndexes(!0,!0),o.length!==0)&&(a=e.Prompt||o.length>1&&e.PromptIfMultiple,a?di(e,o,function(){ri(e,o)}):ri(e,o))}}}function ri(n,t){ei("Actioning, please wait...");at(n,t,0)}function at(n,t,i){var b=!1,k=r,v,f,nt,p,it,u,w,e;switch(n.ActionType){case"RowFormOpen":b=!0;var c=JSON.parse(n.ParametersJson),g=oi(t,i,c.IdField),a=c.ParametersJson?JSON.parse(c.ParametersJson):{};for(v in a)f=a[v],f.startsWith("[")&&f.endsWith("]")&&(nt=t[i],f=f.substr(1,f.length-2),p=oi(t,i,f),p===null?console.warn("Smart List row action as replaceable parameter ["+f+"] but no corresponding field was found in the row data."):a[v]=p);$App.FormOpen(c.Form,g,a)}if(b){i<t.length-1?at(n,t,i+1):(ut(),d());return}ki("Actioning item "+(i+1)+" of "+t.length+", please wait...");it=k.DataView[t[i]];u={};switch(y){case"QuickList":u.quickListId=o;break;case"SmartList":u.smartListId=o;break;case"Tasks":s||(s="");h||(h="");u.pageId=o;u.itemId=l;u.userId=s;u.dateAsAt=h}u.actionId=n.Id;u.summaryColumnsJson=JSON.stringify(k.DataView.GetSummaryColumns(t[i]));u.parametersJson=n.ParametersJson;u.target="WebInternal";u.highDpi=$Runtime.IsHighDpi();n.SpecialParams&&(e=JSON.parse(u.parametersJson),e||(e={}),e=$.extend({},n.SpecialParams,e),u.parametersJson=JSON.stringify(e));n.FileData&&(w=n.FileData,n.FileData=null);w?$Api.PostDirect(tt,u,{__fileDataJson:w},{done:function(r){ui(r,n,t,i)},fail:function(r){fi(r,n,t,i)},always:function(){i<t.length-1?at(n,t,i+1):(ut(),d())}}):$Api.GetDirect(tt,u,{done:function(r){ui(r,n,t,i)},fail:function(r){fi(r,n,t,i)},always:function(){i<t.length-1?at(n,t,i+1):(ut(),d())}})}function wi(){p&&p.Text()&&p.ReapplyFilter()}function ui(n,t,i,f){u.SetRowSelectorIcon(i[f],"Check","Item processed. Refresh grid to view updated details.",{rowExpired:n.Expired});r.ShowSummary&&(v.CacheRemove(r.DataView.GetCacheKey(i[f])),i[f]===u.ActiveDataRowIndex()&&v.PreviewFromGridCollection(u,r.DataView,b))}function fi(n,t,i,r){u.SetRowSelectorIcon(i[r],"Error",$Runtime.ParseAjaxError(n),{rowExpired:!1})}function bi(){r.ShowSummary&&v.PreviewFromGridCollection(u,r.DataView,b);ut()}function ut(){var e=r.Actions,t,i,n,o,f,s,h;if(e){for(t=u.GetSelectedRowIndexes(!0,!0),i=0;i<e.length;i++)if(n=e[i],!n.AllowMultiple&&t.length>1)u.Actions().SetEnabled(n.Id,!1);else{if(o=t.length!==0,n.Row&&rt!==-1)for(f=0;f<t.length;f++)if(s=r.DataView[t[f]],h=s[rt],h.indexOf(n.Mn)===-1){o=!1;break}u.Actions().SetEnabled(n.Id,o)}u.RefreshButtons()}}function ei(t){f.modal?f.modal.WaitShow(t):n.WaitShow(t)}function ki(t){f.modal?f.modal.WaitUpdate(t):n.WaitUpdate(t)}function d(){f.modal?f.modal.WaitHide():n.WaitHide()}function oi(n,t,i){var u=si(i);return u!==-1?r.DataView[n[t]][u]:null}function si(n){var i=r.Columns,u=-1,t;for(n&&(n=n.toUpperCase()),t=0;t<i.length;t++)if(n===i[t].Id.toUpperCase()){u=i[t].DataSourceIndex;break}return u}function di(t,i,r){var f={heading:t.Description},u;t.Icon&&(f.icon=t.Icon);u="";i.length===1?u="Perform this action for the selected item?":(u="Perform this action for the <b>"+i.length+"<\/b> selected items?",f.messageIsHtml=!0);n.MsgBoxConfirm(u,f,r,null)}function gi(){return r&&r.DataView?r.DataView.length:-1}function nr(n,t,i){return i||(i=""),o==n&&l==t&&s==i}var g,c,nt,ft,r,et,a,tt,b,k,p,vt,yt,gt,u,w,ot,it,v,f,rt=-1,e,y,h="",o="",l="",s="",st,pt,ni,wt,ti,ii,bt;if(SmartListDefaults={modal:null,showHeading:!0,onInitialised:null,onAfterExecute:null},f=$.extend({},SmartListDefaults,i),typeof t=="string"?(st=n.ExtUtils.TranslateElementId(t),t=$("#"+st)):st=$(t).attr("id"),pt=$(t),pt.length===0){console.warn("userinterface.SmartList: Parent element '"+st+"' not found.");return}return ni=$(pt[0]),et=$("<div class='is-smart-list'><\/div>"),ni.append(et),g=$("<div class='content'><\/div>"),et.append(g),c=$("<div class='header'><header><\/header><\/div>"),g.append(c),f.showHeading&&(nt=$("<div class='parameters-toggle' title='Toggle parameters view' style='display:none'><\/div>"),c.append(nt),nt.click(function(){c.toggleClass("parameters-hidden");u&&u.RealignLayout()})),ft=$("<div class='results is-split-container side-by-side auto-collapse'><\/div>"),g.append(ft),a=$("<div class='smart-list-parameters'><span class='expand' title='Show all parameters'><\/span><div class='inner'><\/div><\/div>"),c.append(a),w=n.ParametersHost($(".inner",a),{}),ot=$(".expand",a),ot.click(function(){a.toggleClass("expanded");u&&u.RealignLayout()}),wt=$("<input type='search'/>"),c.append(wt),p=n.TableFilterTextBox(wt,{width:"100%"}),bt=$("<div class='panel'><div class='grid is-dock-fill'><\/div><\/div>"),it=$("<div class='panel'><div class='is-dock-fill pp'><\/div><\/div>"),ft.append(bt),ft.append(it),ti=$(".grid",bt),ii=$(".pp",it),u=n.Grid(ti,{rowNumbering:!0,allowMultiRowSelect:!0,autoShiftButtons:!0,allowSearchBox:!1,onAction:lt,onAfterColumnSort:wi,onAfterRowActivate:bi,onInitialiseRow:pi}),v=n.PreviewPane(ii,{}),kt(),_self={TypeName:"SmartList",Element:vi,Execute:ct,ExecuteActionNotification:ai,Initialise:ht,InitialiseQuickList:ci,InitialiseSmartList:li,InitialiseTaskGroupItem:hi,IsShowingTaskGroupItem:nr,ResultCount:gi,SmartList:yi}},n}($UI||{});console.log("  $UI (smart list extension)");$BrowserInfo=function(){function a(i){return n.iOS()?"In Safari tap <span class='ios_actions'>&#xE003;<\/span> then 'Add to Home Screen'":n.Chrome()&&n.Android()?t.indexOf("samsungbrowser")!=-1?"Click the menu icon on the bottom right then 'Add page to', 'Home screen'":t.indexOf("edga")!=-1?"Click the <span>...<\/span> icon at the bottom of the screen then 'Add to screen'":"Click the <span>&vellip;<\/span> button to the right of the Chrome address bar then 'Add to Home Screen'":n.Chrome()&&document.location.protocol.toUpperCase()=="HTTPS:"?t.indexOf("edg/")!=-1?"Open in Chrome and click the <span>&vellip;<\/span> button to the right of the address bar then 'Install "+i+"'":"Click the <span>&vellip;<\/span> button to the right of the Chrome address bar then 'Install "+i+"'":""}function v(){if(console.log("PWA_WEB_ROOT: "+window.PWA_WEB_ROOT),document.location.protocol.toUpperCase()!="HTTPS:"){console.warn("PWA: Application is not served over HTTPS. The ability to add as a PWA may not be available.");return}"serviceWorker"in navigator&&(navigator.serviceWorker.register(window.PWA_WEB_ROOT+"sw.js?v=3",{scope:window.PWA_WEB_ROOT}).then(()=>{console.info("IS Online-Only Service Worker Registered")},n=>console.error("IS Online-Only Service Worker registration failed: ",n)),navigator.serviceWorker.ready.then(()=>{console.info("IS Online-Only Service Worker Ready")}))}var e,u=document.createElement("canvas"),r,f,s,i,n;u!=null&&(r=u.getContext("webgl")||u.getContext("experimental-webgl"),r&&(f=r.getExtension("WEBGL_debug_renderer_info"),f&&(e=r.getParameter(f.UNMASKED_RENDERER_WEBGL))));var t=window.navigator.userAgent.toLowerCase(),h=/safari/.test(t),o=e=="Apple GPU"||/iphone|ipod|ipad/.test(t),c=!1,l=!1;return o?h||(l=!0):t.indexOf("wv")!=-1&&(c=!0),s=!0,i=!1,window.navigator.standalone&&(i=!0),window.matchMedia&&window.matchMedia("(display-mode: standalone)").matches&&(i=!0),i||t.indexOf("samsungbrowser")==-1||screen.height-window.innerHeight<50&&(i=!0),n={IsDesktop:function(){return!n.IsMobile()},IsMobile:function(){return n.Android()||n.iOS()},GetPwaMessage:a,IsPwa:function(){return i},SupportsPwa:function(){return s},StartOnlineOnlyServiceWorker:v,Android:function(){return navigator.userAgent.match(/Android/i)},Chrome:function(){return window.chrome!==undefined},iOS:function(){return o}}}();console.log("Loading widget.js (generic)");window.__widgetGeneric=function(){function it(n,t){n.GetItem=function(i){i=(""+i).toUpperCase();for(var r=0;r<n.length;r++)if(i===n[r][t].toUpperCase())return n[r];return null}}function rt(n,t){var i=n.indexOf(t);i!==-1&&n.splice(i,1)}function f(n,t){return!n&&!t?0:!n||!t?2:(n=new Date(n),t=new Date(t),!n.getFullYear()&&!t.getFullYear())?0:!n.getFullYear()||!t.getFullYear()?2:n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()?0:n.getTime()>t.getTime()?1:-1}function ut(n){n&&Array.isArray(n)&&(n.ToDescriptionCsvList=function(){for(var t="",i=0;i<n.length;i++)t&&(t+=","),t+=n[i].Description;return t},n.CodeToDescription=function(t){for(var i=0;i<n.length;i++)if(n[i].Code.toUpperCase()==t.toUpperCase())return n[i].Description;return""},n.DescriptionToCode=function(t){for(var i=0;i<n.length;i++)if(n[i].Description.toUpperCase()===t.toUpperCase())return n[i].Code;return""})}function p(n,t){var i=function(n,t){var i=(""+n).split("e");return+(i[0]+"e"+(i[1]?+i[1]+t:t))};return i(Math.round(i(n,+t)),-t)}function ft(t){var r=n?n.CurrencyDecimals():_config.currencyDecimals,i;switch(r){case 0:return i=1,t<0?-Math.floor(-t*i+.5):Math.floor(t*i+.5);case 2:return i=100,t<0?-Math.floor(-t*i+.5)/i:Math.floor(t*i+.5)/i;default:return console.warn("widget.RoundCurrency: Only designed to be used with currency decimals of 0 or 2."),p(t,currencyDecimals)}}function i(t){var r=n?n.CurrencyDecimals():_config.currencyDecimals,i;switch(r){case 0:return i=1,t<0?-Math.floor(-t*i):Math.floor(t*i);case 2:return i=100,t<0?-Math.floor(-t*i)/i:Math.floor(t*i)/i;default:return console.warn("widget.RoundCurrencyDown: Only designed to be used with currency decimals of 0 or 2."),i=Math.pow(10,r),t<0?-Math.floor(-t*i)/i:Math.floor(t*i)/i}}function et(t){var r=n?n.CurrencyDecimals():_config.currencyDecimals,u=i(t);if(u==t)return u;switch(r){case 0:return i(t+1);case 2:return i(t+1/100);default:return console.warn("widget.RoundCurrency: Only designed to be used with currency decimals of 0 or 2."),i(t+1/Math.pow(10,r))}}function ot(n,t){var i=new Date(n);return i.setDate(i.getDate()+t),i}function st(n){var e=(new Date).getFullYear(),o=(new Date).getMonth()+1,r,u,t,f,i;if(n+="",t=n.indexOf("/"),t==-1&&(t=n.indexOf("\\")),t==-1&&(t=n.indexOf("-")),t==-1&&(t=n.indexOf(" ")),t==-1&&(n.length==4||n.length==6))r=n.substr(0,2),u=n.substr(2);else{if(t==-1)return"";r=parseInt(n.substr(0,t));u=parseInt(n.substr(t+1))}return r<0||r>12||u<0||u>9999?"":(f=""+r,i=""+u,i.length==1?i=(""+e).substr(0,2)+"0"+i:i.length==2&&(i=(""+e).substr(0,2)+i),f.length==1&&(f="0"+f),f+"/"+i)}function ht(t,i,r){if(n)return n.FormatCurrency(t,i,r);if(t==0&&r)return"";var u=w(t,-1,!0,!1);return t<0&&(u=u.substr(1)),i&&(u=_config.currencySymbol+u),t<0&&(u="("+u+")"),u}function c(i){return n?n.FormatDate(i,!1,!1,!1):t(i)}function ct(i){return n?n.FormatDate(i,!1,!1,!0):t(i,null,!0)}function lt(i){return n?n.FormatDate(i,!0,!1,!1):t(i,_config.dateFormat+" "+_config.timeFormat)}function at(i){return n?n.FormatDate(i,!0,!1,!0):t(i,_config.dateFormat+" "+_config.timeFormat,!0)}function vt(i,r,u){return u||(u=!1),n?n.FormatDateForGrid(i,r,!1,!0,u):r?u?t(i,_config.dateFormatGrid+" HH:mm:ss",!0):t(i,_config.dateFormatGrid+" "+_config.timeFormatGrid,!0):t(i,_config.dateFormatGrid,!0)}function yt(t,i,r,u){return n?n.FormatNumber(t,i,r,u):w(t,i,r,u)}function w(n,t,i,r){var s=!1,u;if(n===0&&r)return"";if(t===-1&&(t=_config.currencyDecimals,s=!0),(n===null||n===""||isNaN(n))&&(n=0),n=parseFloat(n),u=n.toFixed(t)+"",i){u+="";for(var e=u.split("."),f=e[0],h=e.length>1?"."+e[1]:"",o=/(\d+)(\d{3})/;o.test(f);)f=f.replace(o,"$1,$2");u=f+h}return u===0&&r?"":u}function b(n,i,r){return n?r?i&&n.getUTCHours()===0&&n.getUTCMinutes()===0&&n.getUTCSeconds()===0?"":t(n,"HH:mm:ss",r):i&&n.getHours()===0&&n.getMinutes()===0&&n.getSeconds()===0?"":t(n,"HH:mm:ss"):""}function t(t,i,r){var u,f,s,h,e,o;return t?(typeof t=="string"&&(t=new Date(t)),u=i,u||(u=n?n.DateFormat():_config.dateFormat),r?(u=u.replace("dd",("0"+t.getUTCDate()).slice(-2)),u=u.replace("d",t.getUTCDate()),u=u.replace("MM",("0"+(t.getUTCMonth()+1)).slice(-2)),u=u.replace("M",t.getUTCMonth()+1),f=t.getUTCFullYear(),u=u.replace("yyyy",f),u=u.replace("yy",(f+"").substr(2))):(u=u.replace("dd",("0"+t.getDate()).slice(-2)),u=u.replace("d",t.getDate()),u=u.replace("MM",("0"+(t.getMonth()+1)).slice(-2)),u=u.replace("M",t.getMonth()+1),f=t.getFullYear(),u=u.replace("yyyy",f),u=u.replace("yy",(f+"").substr(2))),r?(s=t.getUTCSeconds(),h=t.getUTCMinutes(),e=t.getUTCHours()):(s=t.getSeconds(),h=t.getMinutes(),e=t.getHours()),o=e,o>12&&(o-=12),u=u.replace("HH",("0"+e).slice(-2)),u=u.replace("H",e),u=u.replace("hh",("0"+o).slice(-2)),u=u.replace("h",o),u=u.replace("mm",("0"+h).slice(-2)),u=u.replace("m",h),u=u.replace("ss",("0"+s).slice(-2)),u=u.replace("s",s),e<12?(u=u.replace("tt","a.m."),u=u.replace("t","a")):(u=u.replace("tt","p.m."),u=u.replace("t","p")),u):""}function pt(){return n?"WebInternal":window._config&&_config.desktop?"HtmlViewer":"WebExternal"}function k(n,t){var i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][n%7];return t?i.substring(0,3):i}function wt(n,t){return(n&&typeof n=="string"&&(n=new Date(n)),!n||!n.getDay)?"":k(n.getDay(),t)}function bt(n,t,i){var e,r,u;return!n||!n.getDay?"":(t||(e=new Date,t=new Date(e.getFullYear(),e.getMonth(),e.getDate())),f(n,t)>=0)?"":(r=d(n,t),u="",(r.years>0||i)&&(u+=r.years===1?"1 year":r.years+" years"),r.months!==0&&(r.years<5||i)&&(u&&(u+=" "),u+=r.months===1?"1 month":r.months+" months"),r.days!==0&&(r.years<1||i)&&(u&&(u+=" "),u+=r.days===1?"1 day":r.days+" days"),u)}function d(n,t){for(var i=(t.getFullYear()-n.getFullYear())*12+(t.getMonth()-n.getMonth())-1,e,o,s,r=-1,u=0;;){if(e=new Date(n.getUTCFullYear(),n.getUTCMonth()+i,n.getUTCDate()),f(e,t)===1){if(i-=1,r!==-1)break;console.warn("widget.CalculateAgeInternal: Unexpectedly reached block A!");i-=1}if(r=Math.floor((t-e)/864e5),r>=0&&r<28)break;if(i+=1,u+=1,u>100){console.warn("widget.CalculateAgeInternal: Unexpectedly reached block B!");break}}return o=Math.floor(i/12),s=i-o*12,{years:o,months:s,days:r}}function kt(n,t){var i,r;return!n||!n.getDay?0:(t||(i=new Date,t=new Date(i.getFullYear(),i.getMonth(),i.getDate())),f(n,t)>=0)?0:(r=d(n,t),r.years)}function g(n){try{var t=parseInt("0x"+n.substr(1,2)),i=parseInt("0x"+n.substr(3,2)),r=parseInt("0x"+n.substr(5,2))}catch(u){return!1}return 299*t+587*i+114*r<128e3}function dt(n){return!g(n)}function gt(){return window.devicePixelRatio>1.25}function ni(n,t,i){var o,u=0,r=0,f=0,a,s,l,e,h,v;if(n&&(n=n.toUpperCase()),!n)return null;if((n==="NOW"||n==="TODAY")&&(n=c(new Date,!1,!1,!1)),n.match(/[a-zA-Z]/)!=null)if("0123456789".indexOf(n.substr(n.length-1,1))==-1&&(n+=" "+(new Date).getFullYear()),u=Date.parse(n),u)n=c(new Date(u),!1,!1,!1);else return null;if(/^\d+$/.test(n)){if(s=new Date,e=parseFloat(n),l=s.getFullYear(),l-=Math.floor(l/100)*100,e===0)u=0,r=0,f=0;else if(e<100)u=e,r=s.getMonth()+1,f=s.getFullYear();else if(e<1e4)_config.dayMonthYearOrder.indexOf("D")<_config.dayMonthYearOrder.indexOf("M")?(u=Math.floor(e/100),r=Math.floor(e-u*100)):(r=Math.floor(e/100),u=Math.floor(e-r*100)),f=s.getFullYear(),s.getMonth()<2&&r>10?f-=1:s.getMonth()>9&&r<3&&(f+=1);else if(e<1e5)switch(_config.dayMonthYearOrder){case"DMY":r=Math.floor(e/100);f=Math.floor(e-r*100);f<100&&(h=Math.floor(s.getFullYear()/100)*100,t&&f>l&&(h-=100),f+=h);u=Math.floor(r/100);r-=u*100;break;case"MDY":u=Math.floor(e/100);f=Math.floor(e-u*100);f<100&&(h=Math.floor(s.getFullYear()/100)*100,t&&f>l&&(h-=100),f+=h);r=Math.floor(u/100);u-=r*100;break;case"YMD":window.alert("YMD date order not implemented")}else if(e<1e8)switch(_config.dayMonthYearOrder){case"DMY":r=Math.floor(e/1e4);f=Math.floor(e-r*1e4);u=Math.floor(r/100);r-=u*100;break;case"MDY":u=Math.floor(e/1e4);f=Math.floor(e-u*1e4);r=Math.floor(u/100);u-=r*100;break;case"YMD":window.alert("YMD date order not implemented")}else u=0,r=0,f=0;return(u>31||r>12)&&(u=0,r=0,f=0),u==0&&r==0&&f==0?null:i?new Date(Date.UTC(f,r-1,u)):new Date(f,r-1,u)}o=n.indexOf("/")!=-1?n.split("/"):n.indexOf("-")!=-1?n.split("-"):n.split(" ");_config.dayMonthYearOrder=="DMY"?(o.length>0&&(u=parseFloat(o[0])),o.length>1&&(r=parseFloat(o[1])),o.length>2&&(f=parseFloat(o[2]))):(o.length>0&&(r=parseFloat(o[0])),o.length>1&&(u=parseFloat(o[1])),o.length>2&&(f=parseFloat(o[2])));r===0&&(r=(new Date).getMonth()+1);r>12&&u<13&&(a=r,r=u,u=a);f===0&&(f=(new Date).getFullYear());f<100&&(t?(v=parseFloat(((new Date).getFullYear()+"").substr(2,2)),f+=f<v?2e3:1900):f+=2e3);f>9999&&(f=9999);try{return isNaN(f)||isNaN(r)||isNaN(u)?null:i?new Date(Date.UTC(f,r-1,u)):new Date(f,r-1,u)}catch(y){return null}}function ti(n,t){var e,o,r;if(n){var i=0,u=0,f=0;n=n.toUpperCase();e=n.indexOf("A")!==-1;o=n.indexOf("P")!==-1;(n==="NOW"||n==="TODAY")&&(n=b(new Date,!1,!1));r=n.split(":");r.length>0&&(i=parseFloat(r[0]));r.length>1&&(u=parseFloat(r[1]));r.length>2&&(f=parseFloat(r[2]));o&&i<12?i+=12:e&&i===12&&(i-=12);try{return isNaN(i)||isNaN(u)||isNaN(f)?null:t?new Date(Date.UTC(2e3,0,1,i,u,f)):new Date(2e3,0,1,i,u,f)}catch(s){return null}}else return null}function ii(t){return n?n.ParseNumber(t,-1):nt(""+t,-1)}function ri(t,i){return n?n.ParseNumber(t,i):nt(""+t,i)}function nt(n,t){t==-1&&(t=_config.currencyDecimals);n+="";n=n.replace(/\,/g,"");n.startsWith("(")&&n.endsWith(")")&&(n=n.substr(1,n.length-2),n="-"+n);var i=parseFloat(parseFloat(n).toFixed(t));return i?i:0}function ui(){return n?n.ThemeContrastColourBackground():_config.themeContrastColourBackground}function fi(){return n?n.ThemeContrastColourForeground():_config.themeContrastColourForeground}function ei(){return n?n.ThemeMainColourBackground():_config.themeMainColourBackground}function oi(){return n?n.ThemeMainColourForeground():_config.themeMainColourForeground}function si(n){return n.replace(/^\s+|\s+$/g,"")}function hi(n){return n.replace(/^\s+/,"")}function tt(n){return n.replace(/\s+$/,"")}function ci(n,t,i){var f="",r,o,e,u;if(t===undefined&&(t=!0),i===undefined&&(i=!0),n)n=tt(n);else return"";for(r=!0,o="",e=0;e<n.length;e++){u=n[e];switch(u){case" ":r=!0;break;default:i&&"0123456789".indexOf(u)!=-1&&!"0123456789".indexOf(o)==-1?(r||(f+=" "),r=!0):u==u.toUpperCase()?(r||(f+=" "),r=!0):r=!1}t?(t=!1,f+=u.toUpperCase()):f+=u}return f}function li(n){var i,r,t,f,u=[];if(n=""+n,n.length==0)return[];for(r=0,i=0;i<n.length;i++)switch(n.substr(i,1)){case",":f||(t=n.substr(r,i-r),t.length>2&&t.charAt(0)=='"'&&t.charAt(t.length-1)=='"'&&(t=t.substr(1,t.length-2)),t=t.replace(/\"\"/g,'"'),u.push(t),r=i+1);break;case'"':f=!f}return r<=n.length?(t=n.substr(r),t.length>2&&t.charAt(0)=='"'&&t.charAt(t.length-1)=='"'&&(t=t.substr(1,t.length-2)),t=t.replace(/\"\"/g,'"'),u.push(t)):n.charAt(n.length-1)==","&&u.push(""),u}function ai(n){for(var i,t="",r=0;r<n.length;r++)i=n[r],t&&(t+=","),t+=i.indexOf(",")!=-1?'"'+i+'"':i;return t}function vi(){return"1.23"}var l="",a=!1,e=!1,o=!1,v=!1,n=null,s=document.createElement("canvas"),r,h,u,y;if(s!=null&&(r=s.getContext("webgl")||s.getContext("experimental-webgl"),r&&(h=r.getExtension("WEBGL_debug_renderer_info"),h&&(l=r.getParameter(h.UNMASKED_RENDERER_WEBGL)))),u=window.navigator.userAgent.toLowerCase(),y=/safari/.test(u),v=l=="Apple GPU"||/iphone|ipod|ipad/.test(u),v?y||(o=!0):u.indexOf("wv")!=-1&&(e=!0),a=o||e,window.parent)try{if(n=window.parent.$Runtime,n&&window.parent.$App)$(window).on("mousedown keydown mousemove",function(){window.parent.$App.WidgetNotifyBusy(!0)})}catch(yi){}return{ArrayAllowLookupById:it,ArrayFromCsvString:li,ArrayRemove:rt,ArrayToCodeDescriptionList:ut,ArrayToCsvString:ai,CompareDates:f,CurrencyDecimals:function(){return _config.currencyDecimals},CurrencySymbol:function(){return _config.currencySymbol},DateAddDays:ot,DayMonthYearOrder:function(){return _config.dayMonthYearOrder},FormatCardExpiryDate:st,FormatCurrency:ht,FormatDate:c,FormatDateForGrid:vt,FormatDateTime:lt,FormatTime:b,FormatUtcDate:ct,FormatUtcDateTime:at,FormatNumber:yt,GetHostingContext:pt,GetAgeInYears:kt,GetAgeText:bt,GetWeekDayName:k,GetWeekDayNameFromDate:wt,IsColourDark:g,IsColourLight:dt,IsHighDpi:gt,ParseCurrency:ii,ParseDate:ni,ParseNumber:ri,ParseTime:ti,Round:p,RoundCurrency:ft,RoundCurrencyDown:i,RoundCurrencyUp:et,ThemeContrastColourBackground:ui,ThemeContrastColourForeground:fi,ThemeMainColourBackground:ei,ThemeMainColourForeground:oi,Trim:si,LTrim:hi,RTrim:tt,SplitWordsAtCapitals:ci,Version:vi,IsApp:function(){return a},IsApp_Android:function(){return e},IsApp_iOS:function(){return o},FormatDateInternal:t}}();console.log("  widget (generic)");window.console||(console={log:function(){},warn:function(){}});String.prototype.endsWith||(String.prototype.endsWith=function(n,t){return t<this.length?t|=0:t=this.length,this.substr(t-n.length,n.length)===n});String.prototype.startsWith||(String.prototype.startsWith=function(n,t){return this.substr(t||0,n.length)===n});Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(n,t){function e(n,t){return n===t||typeof n=="number"&&typeof t=="number"&&isNaN(n)&&isNaN(t)}var f,i,r,u;if(this==null)throw new TypeError('"this" is null or not defined');if(f=Object(this),i=f.length>>>0,i===0)return!1;for(r=t|0,u=Math.max(r>=0?r:i-Math.abs(r),0);u<i;){if(e(f[u],n))return!0;u++}return!1}});console.log("Loading lib/widget_compatibility.js");widget=window.__widgetGeneric;$(function(){function n(){widget.Options={googleMapsApiKey:"",countryCode:"",dateFormatTooltip:""}}widget&&widget.UI&&(widget.GetIconUrl||(widget.GetIconUrl=$UI.GetIconUrl),widget.RegisterError||(widget.RegisterError=function(n){console.warn("widget_compatibility: "+n)}),$UI.WidgetGrid=function(t,i){n();typeof t=="string"&&(t=$UI.ExtUtils.TranslateElementId(t));i.showContextMenu=!1;var r=widget.UI.Grid(t,i);return r.Element().addClass("widget-control-compatibility"),r},console.log("  $UI.WidgetGrid initialised"))});console.log("Loading widget_ui.js (extension)");__WidgetUI=function(n){function d(n){for(var r,t,i,o,f=$("input,button,textarea,select,label.is-checkbox"),e=!1,u=0;u<f.length;u++)if(r=f[u],r===n[0])e=!0;else if(e&&(t=$(r),t.is(":visible")&&(i=!1,r.tagName=="BUTTON"?(t.attr("tabIndex")==-1&&(i=!0),t.attr("disabled")=="disabled"&&(i=!0)):t.attr("for")==n.prop("id")&&(i=!0),!i))){t.hasClass("is-checkbox")?(o=$("#"+t.attr("for")),o.focus()):(t.focus(),t.select());break}}function fr(n,t){if(ot){n.off("touchstart.contextmenu");var i=null;n.on("touchstart.contextmenu",function(r){r.target===n[0]&&(popped=!1,i=window.setTimeout(function(){popped=!0;var n=r.originalEvent.touches[0],i={clientX:n.pageX,clientY:n.pageY};t(i)},750))});n.on("touchend.contextmenu",function(t){t.target===n[0]&&popped&&(t.preventDefault(),t.stopPropagation());window.clearTimeout(i);i=null})}else n.on("contextmenu",t)}function pi(n){for(var i={ItemId:"",ItemType:"Normal",Caption:"",Icon:"",IconUrl:"",IconClass:"",MenuItems:[],Enabled:!0,Visible:!0,AllowMultiInstance:!1,System:!1,Indent:!1},t=0;t<n.length;t++)n[t]=$.extend({},i,n[t]),n[t].MenuItems&&n[t].MenuItems.length!=0&&pi(n[t].MenuItems)}function ni(t){var i,r,u,f;if(t)for(t.addClass("icon"),i=0;i<t.length;i++)r=$(t[i]),u=$(t[i]).attr("icon"),u&&(f=n.GetIconUrl(u),u?(f=f.replace(/\\/g,"/"),r.css("background-image","url("+f+")")):(r.removeClass("icon"),r.css("background-image","")))}function yt(n){n||(n="");y?$("label",y).text(t(n)):(y=$("<div class='is-wait-block'><div class='is-wait'><div class='is-wait1'><\/div><div class='is-wait2'><\/div><div class='is-wait3'><\/div><\/div><label>"+t(n)+"<\/label><\/div>"),$("body").append(y));y.fadeIn("fast")}function st(){y&&(y.remove(),y=null)}function er(){return it}function or(n,i){var r=$.extend({},{title:null,animate:!0,showClose:!1,hideOnClose:!0,tool:!1},i),u,e,f;if(typeof n=="string"?(u=n,n=$("#"+u)):u=$(n).attr("id"),e=$(n),e.length==0){console.warn("widget_ui.StyleAsModal: Element '"+u+"' not found.");return}if(n.addClass("is-modal"),r.animate&&n.css("animation","pop 0.2s"),r.tool&&n.addClass("tool"),n.wrapInner("<div class='is-modal-body'><\/div>"),r.title)if($("div.is-modal-body",n).before("<div class='is-modal-title'>"+t(r.title)+"<div class='is-modal-title-buttons'><div class='is-modal-close is-symbol-close' title='Close'><\/div><\/div><\/div>"),f=$("div.is-modal-title-buttons > div.is-modal-close",n),r.showClose)f.on("click",function(){r.hideOnClose&&n.hide()});else f.hide()}function sr(n){for(var i,t=0;t<o.length;t++)if(i=o[t],i.ModalId()==n)return i;return null}function hr(n,t){var n=ut(n),i;n&&(i=$("<option><\/option>"),i.text(t),n.append(i))}function wi(n,t,i){var n=ut(n),f,u,r;if(n){for(n.children().remove(),f=!1,u=0;u<t.length;u++)r=$("<option><\/option>"),r.attr("value",t[u]),r.text(t[u]),n.append(r),i&&!f&&t[u]==i&&(f=!0);i&&!f&&(r=$("<option><\/option>"),r.attr("value",i),r.text(i),n.append(r))}}function cr(n,t,i,r){var n=ut(n),u,e,f;if(n)for(n.children().remove(),u=0;u<t.length;u++)e=t[u],f=$("<option><\/option>"),f.text(e[i]),r&&f.attr("value",e[r]),n.append(f)}function lr(n,t,i){t=""+t;wi(n,t.split(","),i)}function ar(n){if(n===undefined)return r;r=n==!0}function ut(n){var i,t;return(typeof n=="string"?n=$("#"+n):i=$(n).attr("id"),t=$(n),t.length==0)?(console.warn("widget.UI: Element '"+i+"' not found."),null):$(t[0])}function t(n,t){return wt||(wt=$("<div/>")),n+="",n=n.replace(/\n/g,"~br~"),n=wt.text(n).html(),t&&(n=n.replace(/ /g,"&nbsp;")),n.replace(/~br~/g,"<br/>")}function vr(t){t=$.extend({},{service:"default",propertyName:null,streetAddress:null,suburb:null,city:null,state:null,postcode:null,country:null,onAfterAddressAutoComplete:null},t);t.service=="default"&&(t.service="google-maps-3");t.streetAddress&&t.streetAddress.Text||(t.propertyName&&$("#"+t.propertyName).attr("maxlength",50),t.streetAddress&&$("#"+t.streetAddress).attr("maxlength",130),t.suburb&&$("#"+t.suburb).attr("maxlength",50),t.city&&$("#"+t.city).attr("maxlength",50),t.postcode&&$("#"+t.postcode).attr("maxlength",10));switch(t.service){case"google-maps-3":yr(t);break;default:n.RegisterError("widget_ui.InitialiseAddressAutoComplete: service '"+t.service+"' is not a valid service.")}}function yr(t){var r=n.Options.googleMapsApiKey,i;if(!r){console.warn("widget_ui.InitialiseAddressAutoComplete: No Browser API Key is defined for the Google Maps API. This must be defined under Global Settings, Clients, Addressing within finPOWER Connect.");return}fi?ht?kt.push(t):ti(t):(fi=!0,ht=!0,i=document.createElement("script"),i.setAttribute("type","text/javascript"),i.setAttribute("src","https://maps.googleapis.com/maps/api/js?v=3.exp&key="+r+"&libraries=places&callback=gMapsLoadedCallback&region="+n.Options.countryCode),(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(i),window.gMapsLoadedCallback=function(){ti(t)})}function ti(n){var i,r,t;if(ht)for(ht=!1,i=0;i<kt.length;i++)ti(kt[i]);n.streetAddress&&n.streetAddress.Text?(t=n.streetAddress.Element()[0],r=new google.maps.places.Autocomplete(t,{types:["geocode"]})):(t=document.getElementById(n.streetAddress),r=new google.maps.places.Autocomplete(t,{types:["geocode"]}));google.maps.event.addListener(r,"place_changed",function(){var e=r.getPlace(),o,h,v,a,i,c,l,u,f,s;for(n.streetAddress&&n.streetAddress.Text&&n.streetAddress.ReadOnly()&&n.streetAddress.Text(n.streetAddress.TextOriginal()),o="",h=0;h<e.address_components.length;h++)if(v=e.address_components[h].types[0],a=e.address_components[h].long_name,v=="country")switch(a.toUpperCase()){case"AUSTRALIA":o="Australia";break;case"NEW ZEALAND":o="New Zealand";break;case"UNITED KINGDOM":o="United Kingdom";break;default:o=a}switch(o){case"Australia":i=wr(n,e);break;case"New Zealand":i=br(n,e,$(t).val());break;case"United Kingdom":i=kr(n,e);break;default:i=pr(n,e)}if(i.propertyName||(i.propertyName=""),i.streetAddress||(i.streetAddress=""),i.suburb||(i.suburb=""),i.city||(i.city=""),i.state||(i.state=""),i.postcode||(i.postcode=""),i.country||(i.country=""),n.streetAddress&&n.streetAddress.Text&&i.streetAddress.toUpperCase()!=n.streetAddress.Text().toUpperCase())c=n.streetAddress.Text(),l=c.indexOf(" "),l!=-1&&(u=c.substr(0,l),f=i.streetAddress.indexOf(" "),f!=-1&&(s=i.streetAddress.substr(0,f),(u.endsWith("/"+s)||u.startsWith(s+"/"))&&(i.streetAddress=u+i.streetAddress.substr(f))));else if(typeof n.streetAddress=="string"){var y=$("#"+n.streetAddress),c=y.val(),l=c.indexOf(" ");l!=-1&&(u=c.substr(0,l),f=i.streetAddress.indexOf(" "),f!=-1&&(s=i.streetAddress.substr(0,f),(u.endsWith("/"+s)||u.startsWith(s+"/"))&&(i.streetAddress=u+i.streetAddress.substr(f))))}n.streetAddress&&n.streetAddress.Text?n.streetAddress&&n.streetAddress.ReadOnly()||(n.propertyName&&n.propertyName.Text(i.propertyName),n.streetAddress&&n.streetAddress.Text(i.streetAddress),n.suburb&&n.suburb.Text(i.suburb),n.city&&n.city.Text(i.city),n.state&&n.state.Text(i.state),n.postcode&&n.postcode.Text(i.postcode),n.country&&n.country.Text(i.country)):($("#"+n.propertyName).val(i.propertyName),$("#"+n.streetAddress).val(i.streetAddress),$("#"+n.suburb).val(i.suburb),$("#"+n.city).val(i.city),$("#"+n.state).val(i.state),$("#"+n.postcode).val(i.postcode),$("#"+n.country).val(i.country),$("#"+n.streetAddress).trigger("blur"),$("#"+n.streetAddress).val(i.streetAddress),n.suburb?$("#"+n.suburb).focus():$("#"+n.city).focus());n.onAfterAddressAutoComplete&&n.onAfterAddressAutoComplete()})}function pr(n,t){for(var f,r,i={},u=0;u<t.address_components.length;u++){f=t.address_components[u].types[0];r=t.address_components[u].long_name;switch(f){case"premise":i.propertyName=r;break;case"street_number":i.streetAddress=r;break;case"route":i.streetAddress||(i.streetAddress="");i.streetAddress+=" "+r;break;case"locality":i.suburb||(i.suburb=r);break;case"neighborhood":i.suburb=r;break;case"locality":i.city=r;break;case"administrative_area_level_1":i.state=r;break;case"postal_code":i.postcode=r;break;case"country":i.country=r}}return i}function wr(n,t){for(var f,r,i={},u=0;u<t.address_components.length;u++){f=t.address_components[u].types[0];r=t.address_components[u].long_name;switch(f){case"premise":i.propertyName=r;break;case"street_number":i.streetAddress=r;break;case"route":i.streetAddress||(i.streetAddress="");i.streetAddress+=" "+r;break;case"locality":i.suburb=r;break;case"administrative_area_level_2":i.city=r;break;case"administrative_area_level_1":i.state=r;break;case"postal_code":i.postcode=r;break;case"country":i.country=r}}return i}function br(n,t,i){for(var o,u,e,r={},f=0;f<t.address_components.length;f++){o=t.address_components[f].types[0];u=t.address_components[f].long_name;switch(o){case"premise":r.propertyName=u;break;case"street_number":r.streetAddress=u;break;case"route":r.streetAddress||(r.streetAddress="");r.streetAddress+=" "+u;break;case"sublocality_level_1":r.suburb=u;break;case"locality":r.city=u;break;case"administrative_area_level_1":r.state=u;break;case"postal_code":r.postcode=u;break;case"country":r.country=u}}return r.streetAddress&&!/\d/.test(r.streetAddress)&&(e=parseInt(i),e&&(r.streetAddress=e+r.streetAddress)),r}function kr(n,t){for(var f,r,i={},u=0;u<t.address_components.length;u++){f=t.address_components[u].types[0];r=t.address_components[u].long_name;switch(f){case"premise":i.propertyName=r;break;case"street_number":i.streetAddress=r;break;case"route":i.streetAddress||(i.streetAddress="");i.streetAddress+=" "+r;break;case"administrative_area_level_2":i.state=r;break;case"locality":i.suburb||(i.suburb=r);break;case"neighborhood":i.suburb=r;break;case"postal_town":i.city=r;break;case"postal_code_prefix":i.postcode||(i.postcode=r);break;case"postal_code":i.postcode=r;break;case"administrative_area_level_1":i.country=r}}return i.suburb==i.city&&(i.suburb=""),i}function dr(){return ei}function gr(n){if(n){n=ut(n);var t=n.offset().top+$("body").scrollTop();window.setTimeout(function(){$("body").animate({scrollTop:t})},10)}else window.setTimeout(function(){$("html,body").animate({scrollTop:0})},10)}function nu(n,t,i,r){var o,h,f,y,s,c,l,u,e,v,a;if(n=ut(n),n&&t&&t.length!=0){if(n.prop("tagName")=="TBODY"?(h=n.parent(),h&&h.prop("tagName")=="TABLE"&&(o=$("thead > tr > th",h))):n.prop("tagName")=="TABLE"&&(o=$("thead > tr > th",n)),i)f=i.split(",");else{f=[];for(y in t[0])f.push(t[y])}for(s=0;s<t.length;s++){for(c=t[s],l=$("<tr><\/tr>"),u=0;u<f.length;u++)if(e=$("<td><\/td>"),e.text(c[f[u]]),o&&u<o.length&&(v=$(o[u]).css("text-align"),v&&e.css("text-align",v)),l.append(e),r){a={rowIndex:s,record:c,field:c[f[u]],fieldName:f[u],row:l,cellIndex:u,cell:e,html:null};try{r(a);a.html!=null&&e.html(a.html)}catch(n){}}n.append(l)}}}function ii(n,t,i,r){var c,p,e,f,t,l,o,a,h,s,v,u,y;for(l=!0,a=!1,c=$("input,select,textarea,div.is-grid-container,span[controlType='radiobuttonlist'],span[controlType='checklist']",n),h=0;h<c.length;h++){if(s=!0,p=c[h],f=$(p),f.css("display")=="none")o=!1;else if(f.attr("readonly")=="readonly")o=!1;else for(o=!0,e=f;e;)if(e=e.parent(),v=e.prop("tagName"),v=="BODY")break;else if(v=="DIV"){if(e.hasClass("is-tab-page"))break}else if(e.css("display")=="none"||e.css("visibility")=="hidden"){o=!1;break}if(u=f?f.prop("is-control"):null,!o||u||f.attr("id")||(o=!1),o&&(s&&u&&u.Validate&&(s=u.Validate()),s&&!u&&f.hasClass("is-mandatory")&&(f.val()||(s=!1))),!s&&(l=!1,y=f.attr("id"),!y&&u&&u.Caption&&(y=u.Caption()),t&&t.SelectedTabIndex(i),a||(a=!0,u&&u.Focus?u.Focus():f.focus()),!r))break}return l}function bi(n,t){var a,r,v,p,w,o,b,u,k,d;t=$.extend({},{context:null},t);n||(n=$(document));typeof n=="string"?n=$("#"+n):id=$(n).attr("id");var g=$("*[ng-show],*[ng-hide],*[ng-bind],*[ng-bind-html],*[ng-if],*[ng-class],*[ng-repeat],*[ng-bind-attribute-name]",n),f=eval,i="";for(a=0;a<g.length;a++){if(r=$(g[a]),i=r.attr("ng-show"),i)try{f(i)?r.show():r.hide()}catch(e){console.warn("widget.UI.Evaluate: Failed to evaluate ng-show expression '"+i+"'.\n\n"+e)}if(i=r.attr("ng-hide"),i)try{f(i)?r.hide():r.show()}catch(e){console.warn("widget.UI.Evaluate: Failed to evaluate ng-hide expression '"+i+"'.\n\n"+e)}if(i=r.attr("ng-if"),i)try{f(i)||r.remove()}catch(e){console.warn("widget.UI.Evaluate: Failed to evaluate ng-if expression '"+i+"'.\n\n"+e)}if(i=r.attr("ng-bind"),i)try{i=f(i);try{v=r.attr("ng-bind-format")||"";switch(v.toLowerCase()){case"":case"string":break;case"currency":i=ci(i);break;case"currency$":i=ci(i,!0);break;case"date":i=l(i);break;default:console.warn("widget.UI.Evaluate: Unrecognised ns-bind-format '"+v+"'.")}}catch(e){console.warn("widget.UI.Evaluate: Failed to evaluate ns-bind-format '"+v+"' for value '"+i+"'.\n\n"+e)}r.text(i)}catch(e){console.warn("widget.UI.Evaluate: Failed to evaluate ng-bind expression '"+i+"'.\n\n"+e)}if(i=r.attr("ng-bind-attribute-name"),i){p=r.attr("ng-bind-attribute-value");try{r.attr(i,f(p))}catch(e){console.warn("widget.UI.Evaluate: Failed to evaluate ng-bind-attribute-value expression '"+p+"'.\n\n"+e)}}if(i=r.attr("ng-bind-html"),i)try{r.html(f(i))}catch(e){console.warn("widget.UI.Evaluate: Failed to evaluate ng-bind-html expression '"+i+"'.\n\n"+e)}if(i=r.attr("ng-class"),i)try{r.attr("class",f(i))}catch(e){console.warn("widget.UI.Evaluate: Failed to evaluate ng-class expression '"+i+"'.\n\n"+e)}if(i=r.attr("ng-repeat"),i){w=r.attr("ng-repeat-filter");r.prop("ng-repeat-template")||r.prop("ng-repeat-template",r.html());r.children().remove();var nt=r.prop("ng-repeat-template"),s="",y=null,h=!0,c;if(h&&(i.startsWith("for ")?(s=i.substr(4),c=s.indexOf(" "),c!=-1&&(s=s.substr(0,c))):h=!1),h&&(c=i.indexOf(" in "),c==-1?h=!1:y=i.substr(c+4)),!h||s&&y||(h=!1),h)try{if(o=f(y),w){for(b=[],u=0;u<o.length;u++)window[s]=o[u],f(w)&&b.push(o[u]);o=b}for(u=0;u<o.length;u++)window.$index=u,window.$first=$index==0,window.$last=$index==o.length-1,window.$middle=!window.$first&&!window.$last,window[s]=o[u],k=$(nt),d=$("<div><\/div>"),d.append(k),bi(d),r.append(k)}catch(e){console.warn("widget.UI.Evaluate: Failed to iterate array variable '"+y+"' in ng-repeat expression '"+i+"'.\n\n"+e)}else console.warn("widget.UI.Evaluate: ng-repeat format of '"+i+"' is incorrect. It should be 'for loopVariableName in array'.")}}}function ki(r,u){function c(i){var u,r,s;if(k&&(i||!f.cboPaymentMethod.Text())&&(window.clearTimeout(k),k=null),o.visible?p.show():p.hide(),d||f.trPaymentMethod.hide(),y&&f.cboPaymentMethod.Text()||f.trWarning.hide(),d){f.trPaymentMethod.show();u="";r=null;f.cboPaymentMethod.ListIndex()!=-1&&(r=v[f.cboPaymentMethod.ListIndex()],u=r.PaymentTypeCategory);s=r&&r.CscRequired;r&&f.txtCardSecurityCode.BlankTip(r.CscDescription);switch(u.toUpperCase()){case"":f.trAccountSortCode.hide();f.trAccountNumber.hide();f.trName.hide();f.trCardExpiry.hide();f.trReference.hide();f.trCashRegister.hide();break;case"BANK":f.trCardExpiry.hide();f.trCashRegister.hide();e&&e.BankSortCodeCaption?(f.txtAccountSortCode.Caption(e.BankSortCodeCaption+":"),f.trAccountSortCode.show()):f.trAccountSortCode.hide();f.trAccountNumber.show();f.txtAccountNumber.Caption("Account No:");f.txtAccountNumber.WidthResizeFromParent();f.trName.show();f.txtName.Caption("Name:");f.txtName.WidthResizeFromParent();f.trReference.show();e&&f.txtReference1.BlankTip(e.Reference1Caption);e&&f.txtReference1.MaxLength(e.ReferenceMaxLength);f.txtReference1.WidthResizeFromParent();f.txtReference1.Visible(e&&e.Reference1Caption);e&&f.txtReference2.BlankTip(e.Reference2Caption);e&&f.txtReference2.MaxLength(e.ReferenceMaxLength);f.txtReference2.WidthResizeFromParent();f.txtReference2.Visible(e&&e.Reference2Caption!=null);e&&f.txtReference3.BlankTip(e.Reference3Caption);e&&f.txtReference3.MaxLength(e.ReferenceMaxLength);f.txtReference3.WidthResizeFromParent();f.txtReference3.Visible(e&&e.Reference3Caption!=null);e.Reference1Caption&&e.Reference2Caption?f.txtReference1.Caption("References:"):(f.txtReference1.Caption("Reference:"),f.txtReference1.BlankTip(""));f.txtAccountSortCode.AllowBlank(!r.HasExportService);f.txtAccountNumber.AllowBlank(!r.HasExportService);f.txtName.AllowBlank(!0);break;case"CASH":f.trAccountSortCode.hide();f.trAccountNumber.hide();f.trName.hide();f.trCardExpiry.hide();f.trReference.hide();o.showCashRegister&&r.IsCashRegisterUsed?(f.trCashRegister.show(),f.cboCashRegister.AllowBlank(!r.IsCashRegisterRequired)):f.trCashRegister.hide();break;case"CHEQUE":f.trAccountSortCode.hide();f.trAccountNumber.hide();f.trCardExpiry.hide();f.trReference.hide();o.showCashRegister&&r.IsCashRegisterUsed?(f.trCashRegister.show(),f.cboCashRegister.AllowBlank(!r.IsCashRegisterRequired)):f.trCashRegister.hide();f.trName.show();f.txtName.Caption("Drawer:");f.txtName.WidthResizeFromParent();o.paymentEntry?f.txtName.AllowBlank(!r.HasExportService):f.txtName.AllowBlank(!0);break;case"CREDITCARD":f.trAccountSortCode.hide();f.trCashRegister.hide();f.trAccountNumber.show();f.txtAccountNumber.Caption("Card No:");f.txtAccountNumber.WidthResizeFromParent();f.trName.show();f.txtName.Caption("Card Name:");f.txtName.WidthResizeFromParent();f.trCardExpiry.show();f.txtCardSecurityCode.Visible(s);f.trReference.show();f.txtReference1.BlankTip("");f.txtReference1.Caption("Reference:");f.txtReference1.MaxLength(50);f.txtReference1.WidthResizeFromParent();f.txtReference1.Visible(!0);f.txtReference2.Visible(!1);f.txtReference3.Visible(!1);f.txtAccountNumber.AllowBlank(!r.HasExportService);f.txtName.AllowBlank(!0);f.cboCardExpiryMonth.AllowBlank(!r.HasExportService);f.cboCardExpiryYear.AllowBlank(!r.HasExportService);break;case"POSCARD":f.trAccountSortCode.hide();f.trReference.hide();f.trCashRegister.hide();f.trAccountNumber.show();f.txtAccountNumber.Caption("Card No:");f.txtAccountNumber.WidthResizeFromParent();f.trName.show();f.txtName.Caption("Card Name:");f.txtName.WidthResizeFromParent();f.trCardExpiry.show();f.txtCardSecurityCode.Visible(s);f.txtAccountNumber.AllowBlank(!r.HasExportService);f.txtName.AllowBlank(!0);f.cboCardExpiryMonth.AllowBlank(!r.HasExportService);f.cboCardExpiryYear.AllowBlank(!r.HasExportService);break;case"TOKEN":f.trAccountSortCode.hide();f.trCardExpiry.hide();f.trCashRegister.hide();f.trAccountNumber.show();f.txtAccountNumber.Caption("Token:");f.txtAccountNumber.WidthResizeFromParent();f.trName.show();f.txtName.Caption("Name:");f.txtName.WidthResizeFromParent();f.trReference.show();e&&f.txtReference1.BlankTip(e.Reference1Caption);e&&f.txtReference1.MaxLength(e.ReferenceMaxLength);f.txtReference1.WidthResizeFromParent();f.txtReference1.Visible(e&&e.Reference1Caption);e&&f.txtReference2.BlankTip(e.Reference2Caption);e&&f.txtReference2.MaxLength(e.ReferenceMaxLength);f.txtReference2.WidthResizeFromParent();f.txtReference2.Visible(e&&e.Reference2Caption!=null);e&&f.txtReference3.BlankTip(e.Reference3Caption);e&&f.txtReference3.MaxLength(e.ReferenceMaxLength);f.txtReference3.WidthResizeFromParent();f.txtReference3.Visible(e&&e.Reference3Caption!=null);e.Reference1Caption&&e.Reference2Caption?f.txtReference1.Caption("References:"):(f.txtReference1.Caption("Reference:"),f.txtReference1.BlankTip(""));f.txtAccountNumber.AllowBlank(!r.HasExportService);f.txtName.AllowBlank(!0);break;default:f.trAccountSortCode.hide();f.trAccountNumber.hide();f.trName.hide();f.trCardExpiry.hide();f.trReference.hide();f.trCashRegister.hide();window.alert("Unhandled Payment Type Category '"+u+"'.")}e;f.cboPaymentMethod.ReadOnly(o.readOnly);f.txtAccountSortCode.ReadOnly(o.readOnly);f.txtAccountNumber.ReadOnly(o.readOnly);f.txtName.ReadOnly(o.readOnly);f.cboCardExpiryMonth.ReadOnly(o.readOnly);f.cboCardExpiryYear.ReadOnly(o.readOnly);f.txtCardSecurityCode.ReadOnly(o.readOnly);f.txtReference1.ReadOnly(o.readOnly);f.txtReference2.ReadOnly(o.readOnly);f.txtReference3.ReadOnly(o.readOnly);f.cboCashRegister.ReadOnly(o.readOnly);i&&e&&f.cboPaymentMethod.Text()?k=window.setTimeout(function(){k=null;var i={bankingDetailsJson:pt()};b&&(i.AccountId=b);tt&&(i.TransactionDate=tt);n._SystemGetString("AccountPaymentDetails_GetValidationDetails",i,function(n){n?(n=JSON.parse(n),y=n.Message,o.readOnly||(f.txtAccountNumber.Text()&&f.txtAccountNumber.Text()==n.AccountNumberOriginal&&n.AccountNumberFormatted&&f.txtAccountNumber.Text(n.AccountNumberFormatted),f.txtAccountSortCode.Text()&&f.txtAccountSortCode.Text()==n.AccountSortCodeOriginal&&n.AccountSortCodeFormatted&&f.txtAccountSortCode.Text(n.AccountSortCodeFormatted))):y="";f.divWarning.html(t(y));y?f.trWarning.show():f.trWarning.hide();n.Warning?f.divWarning.css("color","darkred"):f.divWarning.css("color","green")},function(i){y=i;n.RegisterError("widget_ui.AccountIncomingPaymentDetails: Failed to retrieve validation details: "+i);f.divWarning.html(t(y));y?f.trWarning.show():f.trWarning.hide()})},750):f.cboPaymentMethod.Text()&&(f.divWarning.html(t(y)),y?f.trWarning.show():f.trWarning.hide())}else y?f.divWarning.html(t(y)):(f.divWarning.css("color","darkred"),f.divWarning.text("Initialising, please wait...")),f.trWarning.show()}function at(t,i){var r,u;i=$.extend({},{applyDefaultPaymentMethod:!1,applyDefaultCashRegister:!1,branchId:"",defaultValuesOnPaymentMethodChange:!1},i);b=t;d=!1;ct=i.defaultValuesOnPaymentMethodChange;y="";k&&(window.clearTimeout(k),k=null);c(!1);r=[];b===undefined||o.readOnly||(r=[{caption:"Account ID",value:"[AccId]"},{caption:"Name",value:"[AccName]"},{caption:"External ID",value:"[ExtId]"},{caption:"Main Client ID",value:"[ClientId]"},{caption:"Last Name",value:"[LastName]"},{caption:"Account Type ID",value:"[ATId]"},{caption:"Bank Ref Code",value:"[ATCode]"},]);f.txtReference1.TagsListDefine(r);f.txtReference2.TagsListDefine(r);f.txtReference3.TagsListDefine(r);o.showCashRegister?f.cboCashRegister.RefreshFromStandardRange("CashRegisters"):f.cboCashRegister.VisibleRow(!1);u={accountId:b,branchId:i.branchId,paymentFlowDirection:"incoming"};n._SystemGetString("AccountPaymentDetails_Initialise",u,function(n){if(n){if(n=JSON.parse(n),e=n,nt=n.PaymentMethodsList,v=nt,wt(g),i.applyDefaultPaymentMethod){f.cboPaymentMethod.Text(n.DefaultPaymentMethodId);if(o.onPaymentMethodChange)o.onPaymentMethodChange(ht,{})}i.applyDefaultCashRegister&&f.cboCashRegister.Text(n.DefaultCashRegisterId);d=!0;c(!0);i.defaultValuesOnPaymentMethodChange&&n.DefaultPaymentMethodId&&o.paymentEntry&&ot()}},function(t){y=t;n.RegisterError("widget_ui.AccountIncomingPaymentDetails: Failed to retrieve initialisation details: "+t);c(!1)})}function kt(){f.cboPaymentMethod.Focus()}function dt(n){if(n===undefined)return o.visible;o.visible=n;c(!1)}function gt(n){if(n===undefined)return o.showCashRegister;o.showCashRegister=n;c(!1)}function ni(){return v&&f.cboPaymentMethod.ListIndex()!=-1?v[f.cboPaymentMethod.ListIndex()].HasFee:!1}function ti(){return v&&f.cboPaymentMethod.ListIndex()!=-1?v[f.cboPaymentMethod.ListIndex()].IsDirectCredit:!1}function ii(){return v&&f.cboPaymentMethod.ListIndex()!=-1?v[f.cboPaymentMethod.ListIndex()].IsDirectDebit:!1}function ri(n){if(n===undefined)return o.readOnly;n!=o.readOnly&&(o.readOnly=n,c())}function ui(n){if(n===undefined)return f.cboPaymentMethod.AllowBlank();f.cboPaymentMethod.AllowBlank(n)}function fi(n){if(n===undefined)return f.cboPaymentMethod.Text();n!=f.cboPaymentMethod.Text()&&(f.cboPaymentMethod.Text(n),c(!0))}function ei(n){if(n===undefined)return f.txtAccountSortCode.Text();n!=f.txtAccountSortCode.Text()&&(f.txtAccountSortCode.Text(n),c(!0))}function oi(n){if(n===undefined)return f.txtAccountNumber.Text();n!=f.txtAccountNumber.Text()&&(f.txtAccountNumber.Text(n),c(!0))}function si(n){if(n===undefined)return f.txtName.Text();n!=f.txtName.Text()&&(f.txtName.Text(n),c(!0))}function et(n){if(n===undefined)return f.cboCardExpiryMonth.ListIndex();f.cboCardExpiryMonth.ListIndex(n);c(!0)}function hi(n){if(n===undefined)return a(f.cboCardExpiryYear.Text());f.cboCardExpiryYear.Text(a(n));c(!0)}function ci(n){if(n===undefined)return f.txtCardSecurityCode.Text();f.txtCardSecurityCode.Text(n);c(!0)}function li(n){if(n===undefined)return f.cboCashRegister.Text();f.cboCashRegister.Text(n);c(!0)}function ai(n){if(n===undefined)return f.txtReference1.Text();n!=f.txtReference1.Text()&&(f.txtReference1.Text(n),c(!0))}function vi(n){if(n===undefined)return f.txtReference2.Text();n!=f.txtReference2.Text()&&(f.txtReference2.Text(n),c(!0))}function yi(n){if(n===undefined)return f.txtReference3.Text();n!=f.txtReference3.Text()&&(f.txtReference3.Text(n),c(!0))}function vt(n){if(n)try{var t=JSON.parse(n);f.cboPaymentMethod.Text(t.PaymentMethodId);f.txtAccountSortCode.Text(t.AccountSortCode);f.txtAccountNumber.Text(t.AccountNumber);f.txtName.Text(t.AccountName);et(t.CardExpiryMonthIndex);t.CardExpiryYear&&t.CardExpiryYear!=-1?f.cboCardExpiryYear.Text(t.CardExpiryYear):f.cboCardExpiryYear.Text("");f.txtCardSecurityCode.Text(t.CardSecurityCode);f.txtReference1.Text(t.Reference1);f.txtReference2.Text(t.Reference2);f.txtReference3.Text(t.Reference3);t.AccountId?b!=t.AccountId?at(t.AccountId,!1):c(!0):c(!0)}catch(i){console.warn("widget.UI.AccountIncomingPaymentDetails: Error calling FromBankingDetailsJson: "+i)}}function ot(t,i){var r,u,e;if(!o.readOnly){if(d){if(!f.cboPaymentMethod.Text()){n.RegisterError("widget_ui.AccountIncomingPaymentDetails: LoadAccountDetailsSmart failed since no Payment Method is entered.");i&&i("No Payment Method is entered.");return}}else{n.RegisterError("widget_ui.AccountIncomingPaymentDetails: LoadAccountDetailsSmart failed since the control has not been initialised.");i&&i("Control has not been initialised.");return}(r="",u=null,f.cboPaymentMethod.ListIndex()!=-1&&(u=v[f.cboPaymentMethod.ListIndex()],r=u.PaymentTypeCategory),r.toUpperCase()!="CASH")&&(yt("Looking up payment details, please wait..."),e={accountId:b,paymentFlowDirection:"incoming",paymentMethodId:f.cboPaymentMethod.Text(),resolveReference:o.resolveReference,paymentEntry:o.paymentEntry},n._SystemGetString("AccountPaymentDetails_LoadAccountDetailsSmart",e,function(n){n=JSON.parse(n);n.AccountId==b&&n.PaymentMethodId==f.cboPaymentMethod.Text()&&n.BankingDetailsJson&&vt(n.BankingDetailsJson);st()},function(t){n.RegisterError("widget_ui.AccountIncomingPaymentDetails: Failed to load smart details: "+t);st()}))}}function pt(){var n={};return n.PaymentMethodId=f.cboPaymentMethod.Text(),n.AccountSortCode=f.txtAccountSortCode.Text(),n.AccountNumber=f.txtAccountNumber.Text(),n.AccountName=f.txtName.Text(),n.CardExpiryMonthIndex=et(),n.CardExpiryYear=f.cboCardExpiryYear.Text()?f.cboCardExpiryYear.Text(n.CardExpiryYear):-1,n.CardSecurityCode=f.txtCardSecurityCode.Text(),n.Reference1=f.txtReference1.Text(),n.Reference2=f.txtReference2.Text(),n.Reference3=f.txtReference3.Text(),JSON.stringify(n)}function wt(n){var i,t;if(n===undefined)return g;if(n||(n=""),g=n,v=[],nt)for(i=0;i<nt.length;i++){t=nt[i];switch(g.toUpperCase()){case"":v.push(t);break;case"DIRECTCREDIT":t.IsDirectCredit&&v.push(t);break;default:t.PaymentTypeCategory==g&&v.push(t)}}f.cboPaymentMethod.RefreshFromCollection(v,"PaymentMethodId","Description")}function pi(t){if(t===undefined)return tt;n.CompareDates(t,tt)!=0&&(tt=t,c(!0))}function wi(){f.txtName.WidthResizeFromParent();f.txtAccountNumber.WidthResizeFromParent()}var b,ct=!1,p,d=!1,o,g="",nt,v,e,tt=null,y="",k,f={trPaymentMethod:null,cboPaymentMethod:null,trAccountSortCode:null,txtAccountSortCode:null,trAccountNumber:null,txtAccountNumber:null,trName:null,txtName:null,trCardExpiry:null,cboCardExpiryMonth:null,cboCardExpiryYear:null,txtCardSecurityCode:null,trReference:null,divReferenceTagsList:null,txtReference1:null,txtReference2:null,txtReference3:null,trCashRegister:null,cboCashRegister:null,trWarning:null,divWarning:null},it,ut,l,rt,ht;if(AccountPaymentDetailsDefaults={allowBlank:!1,readOnly:!1,autoReadOnly:!0,visible:!0,paymentEntry:!1,historic:!1,resolveReference:!1,showCashRegister:!1,onPaymentMethodChange:null},o=$.extend({},AccountPaymentDetailsDefaults,u),typeof r=="string"?(it=r,r=$("#"+it)):it=$(r).attr("id"),ut=$(r),ut.length==0){console.warn("widget_ui.AccountIncomingPaymentDetails: Element '"+it+"' not found.");return}p=$(ut[0]);switch(p.prop("tagName")){case"TBODY":break;default:console.warn("widget_ui.AccountIncomingPaymentDetails: Element '"+it+"' must be a TBODY element.");return}l=h(!0);f.trPaymentMethod=$("<tr style='display:none'><th><label for='"+l+"'>Method:<\/label><\/th><td><input id='"+l+"'/><\/td>");p.append(f.trPaymentMethod);f.cboPaymentMethod=w($("input",f.trPaymentMethod),{allowBlank:o.allowBlank,maxLength:10,onChange:function(n,t){t.ChangeHandled=!0;c(!0);ct&&ot();var t={};if(o.onPaymentMethodChange)o.onPaymentMethodChange(ht,t)}});l+="X";f.trAccountSortCode=$("<tr style='display:none'><th><nobr><label for='"+l+"'>Sort Code:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+l+"'/><\/td>");p.append(f.trAccountSortCode);f.txtAccountSortCode=i($("input",f.trAccountSortCode),{allowBlank:!1,maxLength:10,width:"8em",onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});l+="X";f.trAccountNumber=$("<tr style='display:none'><th><nobr><label for='"+l+"'>Account No.:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+l+"'/><\/td>");p.append(f.trAccountNumber);f.txtAccountNumber=i($("input",f.trAccountNumber),{allowBlank:!1,maxLength:30,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});l+="X";f.trName=$("<tr style='display:none'><th><label for='"+l+"'>Name:<\/label><\/th><td><input id='"+l+"'/><\/td>");p.append(f.trName);f.txtName=i($("input",f.trName),{allowBlank:!0,maxLength:100,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});l+="X";f.trCardExpiry=$("<tr style='display:none'><th><nobr><label for='"+l+"'>Card Expiry:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+l+"'/> <input id='"+l+"2'/>  <input id='"+l+"3'/><\/td>");p.append(f.trCardExpiry);f.cboCardExpiryMonth=s($($("input",f.trCardExpiry)[0]),{allowBlank:!0,listCsv:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",limitToList:!1,maxLength:3,width:"4em",onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});f.cboCardExpiryMonth.Element().blur(function(){if(f.cboCardExpiryMonth.Text()){var n=a(f.cboCardExpiryMonth.Text());n>0?f.cboCardExpiryMonth.ListIndex(n-1):f.cboCardExpiryMonth.ListExists(f.cboCardExpiryMonth.Text())||f.cboCardExpiryMonth.Text("")}});f.cboCardExpiryYear=s($($("input",f.trCardExpiry)[1]),{allowBlank:!0,limitToList:!1,maxLength:4,width:"5em",onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});f.cboCardExpiryYear.Element().blur(function(){if(f.cboCardExpiryYear.Text()){var n=a(f.cboCardExpiryYear.Text());n<100&&(n+=2e3);n>9999&&(n=9999);f.cboCardExpiryYear.Text(n)}});var lt=[],ft=(new Date).getFullYear(),bt=ft+10;for(o.historic&&(ft-=10),rt=ft;rt<bt;rt++)lt.push(rt+"");return f.cboCardExpiryYear.ListFromArray(lt),f.txtCardSecurityCode=i($($("input",f.trCardExpiry)[2]),{allowBlank:!1,maxLength:10,width:"7em"}),l+="X",f.trReference=$("<tr style='display:none'><th><label for='"+l+"P'>Reference:<\/label><\/th><td><div id='"+l+"TL'><\/div><input id='"+l+"P'/> <input id='"+l+"C'/> <input id='"+l+"R'/><\/td>"),p.append(f.trReference),f.divReferenceTagsList=$("div",f.trReference),f.txtReference1=i($($("input",f.trReference)[0]),{allowBlank:!0,maxLength:10,tagsListElement:f.divReferenceTagsList,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}}),f.txtReference2=i($($("input",f.trReference)[1]),{allowBlank:!0,maxLength:10,tagsListElement:f.divReferenceTagsList,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}}),f.txtReference3=i($($("input",f.trReference)[2]),{allowBlank:!0,maxLength:10,tagsListElement:f.divReferenceTagsList,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}}),l+="X",f.trCashRegister=$("<tr style='display:none'><th><label for='"+l+"'>Cash&nbsp;Register:&nbsp;<\/label><\/th><td><input id='"+l+"'/><\/td>"),p.append(f.trCashRegister),f.cboCashRegister=w($("input",f.trCashRegister),{allowBlank:!0,maxLength:10,width:n.UI.FIELD_WIDTH_CODE_10}),l+="X",f.trWarning=$("<tr style='display:none'><th colspan='2'><div class='is-info-text info' style='color:darkred; margin-bottom:0 !important; margin-top:0 !important; width:100%'><\/div><\/th>"),p.append(f.trWarning),f.divWarning=$("div",f.trWarning),c(!1),ht={TypeName:"AccountIncomingPaymentDetails",Focus:kt,Initialise:at,ReadOnly:ri,Visible:dt,LoadAccountDetailsSmart:ot,FromBankingDetailsJson:vt,ToBankingDetailsJson:pt,PaymentMethodId:fi,PaymentMethodAllowBlank:ui,PaymentTypeCategoryFilter:wt,AccountSortCode:ei,AccountNumber:oi,AccountName:si,CardExpiryMonthIndex:et,CardExpiryYear:hi,CardSecurityCode:ci,CashRegisterId:li,Reference1:ai,Reference2:vi,Reference3:yi,ShowCashRegister:gt,TransactionDate:pi,SelectedPaymentMethodHasFee:ni,SelectedPaymentMethodIsDirectCredit:ti,SelectedPaymentMethodIsDirectDebit:ii,WidthResizeFromParent:wi}}function tu(n,t){return console.warn("Use widget.UI.AccountIncomingPaymentDetails instead of widget.UI.AccountPaymentDetails."),ki(n,t)}function iu(r,u){function c(i){var s,r,h,u;if(k&&(i||!f.cboPaymentMethod.Text())&&(window.clearTimeout(k),k=null),o.visible?p.show():p.hide(),d||f.trPaymentMethod.hide(),y&&f.cboPaymentMethod.Text()||f.trWarning.hide(),d){f.trPaymentMethod.show();s="";r=null;f.cboPaymentMethod.ListIndex()!=-1&&(r=v[f.cboPaymentMethod.ListIndex()],s=r.PaymentTypeCategory);h=r&&r.CscRequired;r&&f.txtCardSecurityCode.BlankTip(r.CscDescription);switch(s.toUpperCase()){case"":f.trAccountSortCode.hide();f.trAccountNumber.hide();f.trName.hide();f.trCardExpiry.hide();f.trReference.hide();f.trCashRegister.hide();break;case"BANK":f.trCardExpiry.hide();f.trCashRegister.hide();e&&e.BankSortCodeCaption?(f.txtAccountSortCode.Caption(e.BankSortCodeCaption+":"),f.trAccountSortCode.show()):f.trAccountSortCode.hide();f.trAccountNumber.show();f.txtAccountNumber.Caption("Account No:");f.txtAccountNumber.WidthResizeFromParent();f.trName.show();f.txtName.Caption("Name:");f.txtName.WidthResizeFromParent();f.trReference.show();e&&f.txtReference1.BlankTip(e.Reference1Caption);e&&f.txtReference1.MaxLength(e.ReferenceMaxLength);f.txtReference1.WidthResizeFromParent();f.txtReference1.Visible(e&&e.Reference1Caption);e&&f.txtReference2.BlankTip(e.Reference2Caption);e&&f.txtReference2.MaxLength(e.ReferenceMaxLength);f.txtReference2.WidthResizeFromParent();f.txtReference2.Visible(e&&e.Reference2Caption!=null);e&&f.txtReference3.BlankTip(e.Reference3Caption);e&&f.txtReference3.MaxLength(e.ReferenceMaxLength);f.txtReference3.WidthResizeFromParent();f.txtReference3.Visible(e&&e.Reference3Caption!=null);e.Reference1Caption&&e.Reference2Caption?f.txtReference1.Caption("References:"):(f.txtReference1.Caption("Reference:"),f.txtReference1.BlankTip(""));f.txtAccountSortCode.AllowBlank(!r.HasExportService);f.txtAccountNumber.AllowBlank(!r.HasExportService);f.txtName.AllowBlank(!0);break;case"CASH":f.trAccountSortCode.hide();f.trAccountNumber.hide();f.trName.hide();f.trCardExpiry.hide();f.trReference.hide();o.showCashRegister&&r.IsCashRegisterUsed?(f.trCashRegister.show(),f.cboCashRegister.AllowBlank(!r.IsCashRegisterRequired)):f.trCashRegister.hide();break;case"CHEQUE":f.trAccountSortCode.hide();f.trAccountNumber.hide();f.trCardExpiry.hide();f.trReference.hide();o.showCashRegister&&r.IsCashRegisterUsed?(f.trCashRegister.show(),f.cboCashRegister.AllowBlank(!r.IsCashRegisterRequired)):f.trCashRegister.hide();f.trName.show();f.txtName.Caption("Drawer:");f.txtName.WidthResizeFromParent();o.paymentEntry?f.txtName.AllowBlank(!r.HasExportService):f.txtName.AllowBlank(!0);break;case"CREDITCARD":f.trAccountSortCode.hide();f.trCashRegister.hide();f.trAccountNumber.show();f.txtAccountNumber.Caption("Card No:");f.txtAccountNumber.WidthResizeFromParent();f.trName.show();f.txtName.Caption("Card Name:");f.txtName.WidthResizeFromParent();f.trCardExpiry.show();f.txtCardSecurityCode.Visible(h);f.trReference.show();f.txtReference1.BlankTip("");f.txtReference1.Caption("Reference:");f.txtReference1.MaxLength(50);f.txtReference1.WidthResizeFromParent();f.txtReference1.Visible(!0);f.txtReference2.Visible(!1);f.txtReference3.Visible(!1);f.txtAccountNumber.AllowBlank(!r.HasExportService);f.txtName.AllowBlank(!0);f.cboCardExpiryMonth.AllowBlank(!r.HasExportService);f.cboCardExpiryYear.AllowBlank(!r.HasExportService);break;case"POSCARD":f.trAccountSortCode.hide();f.trReference.hide();f.trCashRegister.hide();f.trAccountNumber.show();f.txtAccountNumber.Caption("Card No:");f.txtAccountNumber.WidthResizeFromParent();f.trName.show();f.txtName.Caption("Card Name:");f.txtName.WidthResizeFromParent();f.trCardExpiry.show();f.txtCardSecurityCode.Visible(h);f.txtAccountNumber.AllowBlank(!r.HasExportService);f.txtName.AllowBlank(!0);f.cboCardExpiryMonth.AllowBlank(!r.HasExportService);f.cboCardExpiryYear.AllowBlank(!r.HasExportService);break;case"TOKEN":f.trAccountSortCode.hide();f.trCardExpiry.hide();f.trCashRegister.hide();f.trAccountNumber.show();f.txtAccountNumber.Caption("Token:");f.txtAccountNumber.WidthResizeFromParent();f.trName.show();f.txtName.Caption("Name:");f.txtName.WidthResizeFromParent();f.trReference.show();e&&f.txtReference1.BlankTip(e.Reference1Caption);e&&f.txtReference1.MaxLength(e.ReferenceMaxLength);f.txtReference1.WidthResizeFromParent();f.txtReference1.Visible(e&&e.Reference1Caption);e&&f.txtReference2.BlankTip(e.Reference2Caption);e&&f.txtReference2.MaxLength(e.ReferenceMaxLength);f.txtReference2.WidthResizeFromParent();f.txtReference2.Visible(e&&e.Reference2Caption!=null);e&&f.txtReference3.BlankTip(e.Reference3Caption);e&&f.txtReference3.MaxLength(e.ReferenceMaxLength);f.txtReference3.WidthResizeFromParent();f.txtReference3.Visible(e&&e.Reference3Caption!=null);e.Reference1Caption&&e.Reference2Caption?f.txtReference1.Caption("References:"):(f.txtReference1.Caption("Reference:"),f.txtReference1.BlankTip(""));f.txtAccountNumber.AllowBlank(!r.HasExportService);f.txtName.AllowBlank(!0);break;default:f.trAccountSortCode.hide();f.trAccountNumber.hide();f.trName.hide();f.trCardExpiry.hide();f.trReference.hide();f.trCashRegister.hide();window.alert("Unhandled Payment Type Category '"+s+"'.")}e;f.cboPaymentMethod.ReadOnly(o.readOnly);f.txtAccountSortCode.ReadOnly(o.readOnly);f.txtAccountNumber.ReadOnly(o.readOnly);f.txtName.ReadOnly(o.readOnly);f.cboCardExpiryMonth.ReadOnly(o.readOnly);f.cboCardExpiryYear.ReadOnly(o.readOnly);f.txtCardSecurityCode.ReadOnly(o.readOnly);f.txtReference1.ReadOnly(o.readOnly);f.txtReference2.ReadOnly(o.readOnly);f.txtReference3.ReadOnly(o.readOnly);f.cboCashRegister.ReadOnly(o.readOnly);i&&e&&f.cboPaymentMethod.Text()?k=window.setTimeout(function(){k=null;var i={bankingDetailsJson:pt()};b&&(i.AccountId=b);tt&&(i.TransactionDate=tt);n._SystemGetString("AccountPaymentDetails_GetValidationDetails",i,function(n){n?(n=JSON.parse(n),y=n.Message,o.readOnly||(f.txtAccountNumber.Text()&&f.txtAccountNumber.Text()==n.AccountNumberOriginal&&n.AccountNumberFormatted&&f.txtAccountNumber.Text(n.AccountNumberFormatted),f.txtAccountSortCode.Text()&&f.txtAccountSortCode.Text()==n.AccountSortCodeOriginal&&n.AccountSortCodeFormatted&&f.txtAccountSortCode.Text(n.AccountSortCodeFormatted))):y="";f.divWarning.html(t(y));y?f.trWarning.show():f.trWarning.hide();n.Warning?f.divWarning.css("color","darkred"):f.divWarning.css("color","green")},function(i){y=i;n.RegisterError("widget_ui.AccountOutgoingPaymentDetails: Failed to retrieve validation details: "+i);f.divWarning.html(t(y));y?f.trWarning.show():f.trWarning.hide()})},750):f.cboPaymentMethod.Text()&&(f.divWarning.html(t(y)),y?f.trWarning.show():f.trWarning.hide())}else y?f.divWarning.html(t(y)):(f.divWarning.css("color","darkred"),f.divWarning.text("Initialising, please wait...")),f.trWarning.show();u=[];b===undefined||o.readOnly||(u=[{caption:"Account ID",value:"[AccId]"},{caption:"Name",value:"[AccName]"},{caption:"External ID",value:"[ExtId]"},{caption:"Main Client ID",value:"[ClientId]"},{caption:"Last Name",value:"[LastName]"},{caption:"Account Type ID",value:"[ATId]"},{caption:"Bank Ref Code",value:"[ATCode]"},]);f.txtReference1.TagsListDefine(u);f.txtReference2.TagsListDefine(u);f.txtReference3.TagsListDefine(u)}function at(t,i){var r;i=$.extend({},{applyDefaultPaymentMethod:!1,applyDefaultCashRegister:!1,branchId:"",defaultValuesOnPaymentMethodChange:!1},i);b=t;d=!1;ct=i.defaultValuesOnPaymentMethodChange;y="";k&&(window.clearTimeout(k),k=null);c(!1);o.showCashRegister?f.cboCashRegister.RefreshFromStandardRange("CashRegisters"):f.cboCashRegister.VisibleRow(!1);r={accountId:b,branchId:i.branchId,paymentFlowDirection:"outgoing"};n._SystemGetString("AccountPaymentDetails_Initialise",r,function(n){if(n){if(n=JSON.parse(n),e=n,nt=n.PaymentMethodsList,v=nt,wt(g),i.applyDefaultPaymentMethod){f.cboPaymentMethod.Text(n.DefaultPaymentMethodId);if(o.onPaymentMethodChange)o.onPaymentMethodChange(ht,{})}i.applyDefaultCashRegister&&f.cboCashRegister.Text(n.DefaultCashRegisterId);d=!0;c(!0);i.defaultValuesOnPaymentMethodChange&&n.DefaultPaymentMethodId&&o.paymentEntry&&ot()}},function(t){y=t;n.RegisterError("widget_ui.AccountOutgoingPaymentDetails: Failed to retrieve initialisation details: "+t);c(!1)})}function kt(){f.cboPaymentMethod.Focus()}function dt(n){if(n===undefined)return o.visible;o.visible=n;c(!1)}function gt(n){if(n===undefined)return o.showCashRegister;o.showCashRegister=n;c(!1)}function ni(n){if(n===undefined)return!1;c(!1)}function ti(){return v&&f.cboPaymentMethod.ListIndex()!=-1?v[f.cboPaymentMethod.ListIndex()].HasFee:!1}function ii(){return v&&f.cboPaymentMethod.ListIndex()!=-1?v[f.cboPaymentMethod.ListIndex()].IsDirectCredit:!1}function ri(){return v&&f.cboPaymentMethod.ListIndex()!=-1?v[f.cboPaymentMethod.ListIndex()].IsDirectDebit:!1}function ui(n){if(n===undefined)return o.readOnly;n!=o.readOnly&&(o.readOnly=n,c())}function fi(n){if(n===undefined)return f.cboPaymentMethod.AllowBlank();f.cboPaymentMethod.AllowBlank(n)}function ei(n){if(n===undefined)return f.cboPaymentMethod.Text();n!=f.cboPaymentMethod.Text()&&(f.cboPaymentMethod.Text(n),c(!0))}function oi(n){if(n===undefined)return f.txtAccountSortCode.Text();n!=f.txtAccountSortCode.Text()&&(f.txtAccountSortCode.Text(n),c(!0))}function si(n){if(n===undefined)return f.txtAccountNumber.Text();n!=f.txtAccountNumber.Text()&&(f.txtAccountNumber.Text(n),c(!0))}function hi(n){if(n===undefined)return f.txtName.Text();n!=f.txtName.Text()&&(f.txtName.Text(n),c(!0))}function et(n){if(n===undefined)return f.cboCardExpiryMonth.ListIndex();f.cboCardExpiryMonth.ListIndex(n);c(!0)}function ci(n){if(n===undefined)return a(f.cboCardExpiryYear.Text());f.cboCardExpiryYear.Text(a(n));c(!0)}function li(n){if(n===undefined)return f.txtCardSecurityCode.Text();f.txtCardSecurityCode.Text(n);c(!0)}function ai(n){if(n===undefined)return f.cboCashRegister.Text();f.cboCashRegister.Text(n);c(!0)}function vi(n){if(n===undefined)return f.txtReference1.Text();n!=f.txtReference1.Text()&&(f.txtReference1.Text(n),c(!0))}function yi(n){if(n===undefined)return f.txtReference2.Text();n!=f.txtReference2.Text()&&(f.txtReference2.Text(n),c(!0))}function pi(n){if(n===undefined)return f.txtReference3.Text();n!=f.txtReference3.Text()&&(f.txtReference3.Text(n),c(!0))}function vt(n){if(n)try{var t=JSON.parse(n);f.cboPaymentMethod.Text(t.PaymentMethodId);f.txtAccountSortCode.Text(t.AccountSortCode);f.txtAccountNumber.Text(t.AccountNumber);f.txtName.Text(t.AccountName);et(t.CardExpiryMonthIndex);t.CardExpiryYear&&t.CardExpiryYear!=-1?f.cboCardExpiryYear.Text(t.CardExpiryYear):f.cboCardExpiryYear.Text("");f.txtCardSecurityCode.Text(t.CardSecurityCode);f.txtReference1.Text(t.Reference1);f.txtReference2.Text(t.Reference2);f.txtReference3.Text(t.Reference3);t.AccountId?b!=t.AccountId?at(t.AccountId,!1):c(!0):c(!0)}catch(i){console.warn("widget.UI.AccountOutgoingPaymentDetails: Error calling FromBankingDetailsJson: "+i)}}function ot(t,i){var r,u,e;if(!o.readOnly){if(d){if(!f.cboPaymentMethod.Text()){n.RegisterError("widget_ui.AccountOutgoingPaymentDetails: LoadAccountDetailsSmart failed since no Payment Method is entered.");i&&i("No Payment Method is entered.");return}}else{n.RegisterError("widget_ui.AccountOutgoingPaymentDetails: LoadAccountDetailsSmart failed since the control has not been initialised.");i&&i("Control has not been initialised.");return}(r="",u=null,f.cboPaymentMethod.ListIndex()!=-1&&(u=v[f.cboPaymentMethod.ListIndex()],r=u.PaymentTypeCategory),r.toUpperCase()!="CASH")&&(yt("Looking up payment details, please wait..."),e={accountId:b,paymentFlowDirection:"outgoing",paymentMethodId:f.cboPaymentMethod.Text(),resolveReference:o.resolveReference,paymentEntry:o.paymentEntry},n._SystemGetString("AccountPaymentDetails_LoadAccountDetailsSmart",e,function(n){n=JSON.parse(n);n.AccountId==b&&n.PaymentMethodId==f.cboPaymentMethod.Text()&&n.BankingDetailsJson&&vt(n.BankingDetailsJson);st()},function(t){n.RegisterError("widget_ui.AccountOutgoingPaymentDetails: Failed to load smart details: "+t);st()}))}}function pt(){var n={};return n.PaymentMethodId=f.cboPaymentMethod.Text(),n.AccountSortCode=f.txtAccountSortCode.Text(),n.AccountNumber=f.txtAccountNumber.Text(),n.AccountName=f.txtName.Text(),n.CardExpiryMonthIndex=et(),n.CardExpiryYear=f.cboCardExpiryYear.Text()?f.cboCardExpiryYear.Text(n.CardExpiryYear):-1,n.CardSecurityCode=f.txtCardSecurityCode.Text(),n.Reference1=f.txtReference1.Text(),n.Reference2=f.txtReference2.Text(),n.Reference3=f.txtReference3.Text(),JSON.stringify(n)}function wt(n){var i,t;if(n===undefined)return g;if(n||(n=""),g=n,v=[],nt)for(i=0;i<nt.length;i++){t=nt[i];switch(g.toUpperCase()){case"":v.push(t);break;case"DIRECTCREDIT":t.IsDirectCredit&&v.push(t);break;default:t.PaymentTypeCategory==g&&v.push(t)}}f.cboPaymentMethod.RefreshFromCollection(v,"PaymentMethodId","Description")}function wi(t){if(t===undefined)return tt;n.CompareDates(t,tt)!=0&&(tt=t,c(!0))}function bi(){f.txtName.WidthResizeFromParent();f.txtAccountNumber.WidthResizeFromParent()}var b,ct=!1,p,d=!1,o,g="",nt,v,e,tt=null,y="",k,f={trPaymentMethod:null,cboPaymentMethod:null,trAccountSortCode:null,txtAccountSortCode:null,trAccountNumber:null,txtAccountNumber:null,trName:null,txtName:null,trCardExpiry:null,cboCardExpiryMonth:null,cboCardExpiryYear:null,txtCardSecurityCode:null,trReference:null,divReferenceTagsList:null,txtReference1:null,txtReference2:null,txtReference3:null,trCashRegister:null,cboCashRegister:null,trWarning:null,divWarning:null},it,ut,l,rt,ht;if(AccountPaymentDetailsDefaults={allowBlank:!1,readOnly:!1,autoReadOnly:!0,visible:!0,paymentEntry:!1,historic:!1,resolveReference:!1,showCashRegister:!1,onPaymentMethodChange:null},o=$.extend({},AccountPaymentDetailsDefaults,u),typeof r=="string"?(it=r,r=$("#"+it)):it=$(r).attr("id"),ut=$(r),ut.length==0){console.warn("widget_ui.AccountOutgoingPaymentDetails: Element '"+it+"' not found.");return}p=$(ut[0]);switch(p.prop("tagName")){case"TBODY":break;default:console.warn("widget_ui.AccountOutgoingPaymentDetails: Element '"+it+"' must be a TBODY element.");return}l=h(!0);f.trPaymentMethod=$("<tr style='display:none'><th><label for='"+l+"'>Method:<\/label><\/th><td><input id='"+l+"'/><\/td>");p.append(f.trPaymentMethod);f.cboPaymentMethod=w($("input",f.trPaymentMethod),{allowBlank:o.allowBlank,maxLength:10,onChange:function(n,t){t.ChangeHandled=!0;c(!0);ct&&ot();var t={};if(o.onPaymentMethodChange)o.onPaymentMethodChange(ht,t)}});l+="X";f.trAccountSortCode=$("<tr style='display:none'><th><nobr><label for='"+l+"'>Sort Code:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+l+"'/><\/td>");p.append(f.trAccountSortCode);f.txtAccountSortCode=i($("input",f.trAccountSortCode),{allowBlank:!1,maxLength:10,width:"8em",onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});l+="X";f.trAccountNumber=$("<tr style='display:none'><th><nobr><label for='"+l+"'>Account No.:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+l+"'/><\/td>");p.append(f.trAccountNumber);f.txtAccountNumber=i($("input",f.trAccountNumber),{allowBlank:!1,maxLength:30,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});l+="X";f.trName=$("<tr style='display:none'><th><label for='"+l+"'>Name:<\/label><\/th><td><input id='"+l+"'/><\/td>");p.append(f.trName);f.txtName=i($("input",f.trName),{allowBlank:!0,maxLength:100,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});l+="X";f.trCardExpiry=$("<tr style='display:none'><th><nobr><label for='"+l+"'>Card Expiry:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+l+"'/> <input id='"+l+"2'/>  <input id='"+l+"3'/><\/td>");p.append(f.trCardExpiry);f.cboCardExpiryMonth=s($($("input",f.trCardExpiry)[0]),{allowBlank:!0,listCsv:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",limitToList:!1,maxLength:3,width:"4em",onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});f.cboCardExpiryMonth.Element().blur(function(){if(f.cboCardExpiryMonth.Text()){var n=a(f.cboCardExpiryMonth.Text());n>0?f.cboCardExpiryMonth.ListIndex(n-1):f.cboCardExpiryMonth.ListExists(f.cboCardExpiryMonth.Text())||f.cboCardExpiryMonth.Text("")}});f.cboCardExpiryYear=s($($("input",f.trCardExpiry)[1]),{allowBlank:!0,limitToList:!1,maxLength:4,width:"5em",onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});f.cboCardExpiryYear.Element().blur(function(){if(f.cboCardExpiryYear.Text()){var n=a(f.cboCardExpiryYear.Text());n<100&&(n+=2e3);n>9999&&(n=9999);f.cboCardExpiryYear.Text(n)}});var lt=[],ft=(new Date).getFullYear(),bt=ft+10;for(o.historic&&(ft-=10),rt=ft;rt<bt;rt++)lt.push(rt+"");return f.cboCardExpiryYear.ListFromArray(lt),f.txtCardSecurityCode=i($($("input",f.trCardExpiry)[2]),{allowBlank:!1,maxLength:10,width:"7em"}),l+="X",f.trReference=$("<tr style='display:none'><th><label for='"+l+"P'>Reference:<\/label><\/th><td><div id='"+l+"TL'><\/div><input id='"+l+"P'/> <input id='"+l+"C'/> <input id='"+l+"R'/><\/td>"),p.append(f.trReference),f.divReferenceTagsList=$("div",f.trReference),f.txtReference1=i($($("input",f.trReference)[0]),{allowBlank:!0,maxLength:10,tagsListElement:f.divReferenceTagsList,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}}),f.txtReference2=i($($("input",f.trReference)[1]),{allowBlank:!0,maxLength:10,tagsListElement:f.divReferenceTagsList,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}}),f.txtReference3=i($($("input",f.trReference)[2]),{allowBlank:!0,maxLength:10,tagsListElement:f.divReferenceTagsList,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}}),l+="X",f.trCashRegister=$("<tr style='display:none'><th><label for='"+l+"'>Cash&nbsp;Register:&nbsp;<\/label><\/th><td><input id='"+l+"'/><\/td>"),p.append(f.trCashRegister),f.cboCashRegister=w($("input",f.trCashRegister),{allowBlank:!0,maxLength:10,width:n.UI.FIELD_WIDTH_CODE_10}),l+="X",f.trWarning=$("<tr style='display:none'><th colspan='2'><div class='is-info-text info' style='color:darkred; margin-bottom:0 !important; margin-top:0 !important; width:100%'><\/div><\/th>"),p.append(f.trWarning),f.divWarning=$("div",f.trWarning),c(!1),ht={TypeName:"AccountOutgoingPaymentDetails",Focus:kt,Initialise:at,ReadOnly:ui,Visible:dt,LoadAccountDetailsSmart:ot,FromBankingDetailsJson:vt,ToBankingDetailsJson:pt,PaymentTypeCategoryFilter:wt,PaymentMethodId:ei,PaymentMethodAllowBlank:fi,AccountSortCode:oi,AccountNumber:si,AccountName:hi,CardExpiryMonthIndex:et,CardExpiryYear:ci,CardSecurityCode:li,CashRegisterId:ai,Reference1:vi,Reference2:yi,Reference3:pi,ShowCashRegister:gt,ShowChequeNumber:ni,TransactionDate:wi,SelectedPaymentMethodHasFee:ti,SelectedPaymentMethodIsDirectCredit:ii,SelectedPaymentMethodIsDirectDebit:ri,WidthResizeFromParent:bi}}function ru(r,u){function a(){e.visible?v.show():v.hide();p?(f.divWarning.html(t(p)),f.trWarning.show()):f.trWarning.hide();f.cboDeliveryType.VisibleRow(e.showDeliveryType);f.txtPropertyName.VisibleRow(e.showPropertyName);f.txtCity.VisibleRow(e.showCity);f.cboCountry.VisibleRow(e.showCountry);f.txtPostalId.VisibleRow(e.showPostalId);f.cboDeliveryType.ReadOnly(e.readOnly);f.txtPropertyName.ReadOnly(e.readOnly);f.txtStreetAddress.ReadOnly(e.readOnly);f.txtSuburb.ReadOnly(e.readOnly);f.txtCity.ReadOnly(e.readOnly);f.cboState.ReadOnly(e.readOnly);f.txtPostcode.ReadOnly(e.readOnly);f.cboCountry.ReadOnly(e.readOnly);f.txtPostalId.ReadOnly(e.readOnly);f.txtStreetAddress.AllowBlank(e.allowBlank);e.advancedCity?f.trCity.addClass("advanced"):f.trCity.removeClass("advanced");e.advancedPostalId?f.trPostalId.addClass("advanced"):f.trPostalId.removeClass("advanced");l||(l=it);f.cboCountry.Text()==l.Country&&f.cboState.ListFromCsvString(l.States);f.cboState.Caption(l.TerminologyState+":");f.txtPostcode.Caption(l.TerminologyPostcode+":");f.txtSuburb.VisibleRow(l.SupportsSuburb);f.cboState.VisibleRow(l.SupportsState);f.txtPostcode.VisibleRow(l.SupportsPostcode);l.PostalValidationAvailable&&!e.readOnly?f.cmdCheckPostalId.show():f.cmdCheckPostalId.hide();et()?(f.txtStreetAddress.Caption("Details:"),f.txtPropertyName.VisibleRow(!1)):f.txtStreetAddress.Caption("Street:")}function ot(){p="";n._SystemGetString("AddressDetails_Initialise",{},function(n){n&&(n=JSON.parse(n),d=n,f.cboCountry.ListFromCsvString(d.CountriesList),k(),f.cboCountry.BlankTip(d.DefaultCountry))},function(t){p=t;n.RegisterError("widget_ui.AddressDetails: Failed to retrieve initialisation details: "+t);a(!1)})}function k(n,t){t&&(t.ChangeHandled=!0);vt(f.cboCountry.Text()||f.cboCountry.BlankTip());y()}function st(){rt(!0,!0)}function ht(n,t){for(var i=0;i<t.ids.length;i++)switch(t.ids[i]){case"DeliveryType":f.cboDeliveryType.Text(o.DeliveryTypeText);break;case"PostalId":f.txtPostalId.Text(o.PostalId);break;case"Address":f.txtPropertyName.Text(o.PropertyName);f.txtStreetAddress.Text(o.StreetAddress);f.txtSuburb.Text(o.Suburb);f.txtCity.Text(o.City);f.cboState.Text(o.State);f.txtPostcode.Text(o.Postcode);f.cboCountry.Text(o.Country)}}function rt(t,i){p="";a();f.pulPromptUpdateList_Address.Hide();var r={AddressJson:ft(),ValidatePostalId:i};if(!f.txtPostalId.Text()&&!f.txtStreetAddress.Text()){t&&n.UI.MsgBoxAlert("You must enter either a Delivery/ Postal Id or Street Address/ Details.",{},function(){f.txtPostalId.Focus()});return}f.txtPostalId.VisibleRow(!0);n._SystemGetString("AddressDetails_ValidateAddress",r,function(n){b=null;ct(n,i,t)},function(t){p=t;n.RegisterError("widget_ui.AddressDetails: Failed to validate Postal Id: "+t);a(!1)})}function ct(t,i,r){var c,h,s,u;if(t){if(c=JSON.parse(t).UpdatedAddressJson,o=JSON.parse(c),!o.StreetAddress)return;h=[];e.showDeliveryType&&o.DeliveryTypeText&&o.DeliveryTypeText!=f.cboDeliveryType.Text()&&h.push({id:"DeliveryType",caption:"Delivery Type",value:o.DeliveryTypeText});o.PostalId!=f.txtPostalId.Text()&&h.push({id:"PostalId",caption:"Postal Id",value:o.PostalId});s="";e.showPropertyName&&f.txtPropertyName.Text()&&(s+=f.txtPropertyName.Text()+"\n");f.txtStreetAddress.Text()&&(s+=f.txtStreetAddress.Text()+"\n");f.txtSuburb.Text()&&(s+=f.txtSuburb.Text()+"\n");e.showCity&&f.txtCity.Text()&&(s+=f.txtCity.Text()+"\n");f.cboState.Text()&&(s+=f.cboState.Text()+"\n");f.txtPostcode.Text()&&(s+=f.txtPostcode.Text()+"\n");e.showCountry&&f.cboCountry.Text()&&(s+=f.cboCountry.Text()+"\n");u="";e.showPropertyName&&o.PropertyName&&(u+=o.PropertyName+"\n");o.StreetAddress&&(u+=o.StreetAddress+"\n");o.Suburb&&(u+=o.Suburb+"\n");e.showCity&&o.City&&(u+=o.City+"\n");o.State&&(u+=o.State+"\n");o.Postcode&&(u+=o.Postcode+"\n");e.showCountry&&o.Country&&(u+=o.Country+"\n");u&&s!=u&&h.push({id:"Address",caption:"Address",value:u});h.length==0?(f.pulPromptUpdateList_Address.Hide(),r&&(o.PostalId?n.UI.MsgBoxInfo("Delivery/ Postal Id matches the Address."):n.UI.MsgBoxAlert("No Delivery/ Postal Id was found for this Address."))):f.pulPromptUpdateList_Address.Show(f.txtStreetAddress,h)}}function lt(n,t){if(t&&(t.ChangeHandled=!0),a(),e.onDeliveryTypeChange)e.onDeliveryTypeChange(nt,{});y()}function y(n,t){if(t&&(t.ChangeHandled=!0),e.readOnly||!e.autoValidateAddress||!l||!l.PostalValidationAvailable){f.pulPromptUpdateList_Address.Hide();return}b&&window.clearTimeout(b);b=window.setTimeout(at,500)}function at(){rt(!1,!1)}function vt(t){var i="__CountryInfo_"+t,r="";l=t?tt[i]?tt[i]:null:it;l?ut():n._SystemGetString("AddressDetails_GetCountryInfo",{country:f.cboCountry.Text()},function(n){n&&n&&(n=JSON.parse(n),l=n,tt[i]=l,ut())},function(t){r=t;n.RegisterError("widget_ui.AddressDetails: Failed to retrieve country information: "+t);a()})}function ut(){if(a(),f.cboDeliveryType.ListFromCsvString(l.DeliveryTypes),e.onCountryInfoAvailable)e.onCountryInfoAvailable(nt,{countryInfo:l})}function yt(){e.readOnly||!f.txtStreetAddress.Text()?f.txtStreetAddress.Focus():e.showPropertyName?f.txtPropertyName.Focus():e.showCity&&f.txtCity.Focus()}function pt(n){if(n===undefined)return e.visible;e.visible=n;a(!1)}function wt(n){if(n===undefined)return e.showCity;e.showCity=n;a(!1)}function bt(n){if(n===undefined)return e.showCountry;e.showCountry=n;a(!1)}function kt(n){if(n===undefined)return e.showDeliveryType;e.showDeliveryType=n;a(!1)}function dt(n){if(n===undefined)return e.showPostalId;e.showPostalId=n;a(!1)}function gt(n){if(n===undefined)return e.showPropertyName;e.showPropertyName=n;a(!1)}function ni(n){if(n===undefined)return e.autoValidateAddress;e.autoValidateAddress=n;a(!1)}function ti(n){if(n===undefined)return e.advancedCity;e.advancedCity=n;a(!1)}function ii(n){if(n===undefined)return e.advancedPostalId;e.advancedPostalId=n;a(!1)}function ri(n){if(n===undefined)return e.readOnly;n!=e.readOnly&&(e.readOnly=n,a())}function ui(n){f.pulPromptUpdateList_Address.Hide();try{var t=JSON.parse(n);f.cboDeliveryType.Text(t.DeliveryTypeText);f.txtPropertyName.Text(t.PropertyName);f.txtStreetAddress.Text(t.StreetAddress);f.txtSuburb.Text(t.Suburb);f.txtCity.Text(t.City);f.cboState.Text(t.State);f.txtPostcode.Text(t.Postcode);f.cboCountry.Text(t.Country);f.txtPostalId.Text(t.PostalId);a();k()}catch(i){console.warn("widget.UI.AddressDetails: Error calling FromAddressDetailsJson: "+i)}}function ft(){var n={};return e.showDeliveryType&&(n.DeliveryTypeText=f.cboDeliveryType.Text()),e.showPropertyName&&(n.PropertyName=f.txtPropertyName.Text()),n.StreetAddress=f.txtStreetAddress.Text(),n.Suburb=f.txtSuburb.Text(),e.showCity&&(n.City=f.txtCity.Text()),n.State=f.cboState.Text(),n.Postcode=f.txtPostcode.Text(),e.showCountry&&(n.Country=f.cboCountry.Text()),e.showPostalId&&(n.PostalId=f.txtPostalId.Text()),JSON.stringify(n)}function fi(){f.cboDeliveryType.WidthResizeFromParent();f.txtPropertyName.WidthResizeFromParent();f.txtStreetAddress.WidthResizeFromParent();f.txtSuburb.WidthResizeFromParent();f.txtCity.WidthResizeFromParent();f.cboState.WidthResizeFromParent();f.txtPostcode.WidthResizeFromParent();f.cboCountry.WidthResizeFromParent();f.txtPostalId.WidthResizeFromParent()}function et(){var n=f.cboDeliveryType.Text().toUpperCase();return n.indexOf("BAG")!=-1||n.indexOf("BOX")!=-1?!0:!1}var it={Country:"",DeliveryTypes:"",States:"",SupportsPostcode:!0,SupportsState:!0,SupportsSuburb:!0,TerminologyPostcode:"Postcode",TerminologyState:"State",PostalValidationAvailable:!1},v,e,d,l,b,o,p="",f={trDeliveryType:null,cboDeliveryType:null,trPropertyName:null,txtPropertyName:null,trStreetAddress:null,txtStreetAddress:null,trSuburb:null,txtSuburb:null,trCity:null,txtCity:null,trState:null,cboState:null,trPostcode:null,txtPostcode:null,trCountry:null,cboCountry:null,trPostalId:null,txtPostalId:null,cmdCheckPostalId:null,trWarning:null,divWarning:null,pulPromptUpdateList_Address:null},w,g,c,nt;if(AddressDetailsDefaults={allowBlank:!0,readOnly:!1,autoReadOnly:!0,visible:!0,showCity:!0,showCountry:!0,showDeliveryType:!1,showInstructions:!1,showPostalId:!1,showPropertyName:!1,advancedCity:!1,advancedPostalId:!1,useAutoComplete:!0,autoValidateAddress:!1,onCountryInfoAvailable:null,onDeliveryTypeChange:null},e=$.extend({},AddressDetailsDefaults,u),typeof r=="string"?(w=r,r=$("#"+w)):w=$(r).attr("id"),g=$(r),g.length==0){console.warn("widget_ui.AddressDetails: Element '"+w+"' not found.");return}v=$(g[0]);switch(v.prop("tagName")){case"TBODY":break;default:console.warn("widget_ui.AddressDetails: Element '"+w+"' must be a TBODY element.");return}return c=h(!0),f.trDeliveryType=$("<tr style='display:none'><th><label for='"+c+"'>Delivery Type:<\/label><\/th><td><input id='"+c+"'/><\/td>"),v.append(f.trDeliveryType),f.cboDeliveryType=s($("input",f.trDeliveryType),{blankTip:"Unspecified",limitToList:!0,maxLength:20,onChange:lt}),c+="X",f.trPropertyName=$("<tr style='display:none'><th><label for='"+c+"'>Property&nbsp;Name:&nbsp;<\/label><\/th><td><input id='"+c+"'/><\/td>"),v.append(f.trPropertyName),f.txtPropertyName=i($("input",f.trPropertyName),{maxLength:50,onChange:y}),c+="X",f.trStreetAddress=$("<tr><th><label for='"+c+"'>Street:<\/label><\/th><td><input id='"+c+"'/><\/td>"),v.append(f.trStreetAddress),f.txtStreetAddress=i($("input",f.trStreetAddress),{maxLength:130,onChange:y}),c+="X",f.trSuburb=$("<tr><th><label for='"+c+"'>Suburb:<\/label><\/th><td><input id='"+c+"'/><\/td>"),v.append(f.trSuburb),f.txtSuburb=i($("input",f.trSuburb),{maxLength:50,onChange:y}),c+="X",f.trCity=$("<tr style='display:none'><th><label for='"+c+"'>City:<\/label><\/th><td><input id='"+c+"'/><\/td>"),v.append(f.trCity),f.txtCity=i($("input",f.trCity),{maxLength:50,onChange:y}),c+="X",f.trState=$("<tr><th><label for='"+c+"'>State:<\/label><\/th><td><input id='"+c+"'/><\/td>"),v.append(f.trState),f.cboState=s($("input",f.trState),{maxLength:50,onChange:y}),c+="X",f.trPostcode=$("<tr><th><label for='"+c+"'>Postcode:<\/label><\/th><td><input id='"+c+"'/><\/td>"),v.append(f.trPostcode),f.txtPostcode=i($("input",f.trPostcode),{maxLength:10,onChange:y}),c+="X",f.trCountry=$("<tr style='display:none'><th><label for='"+c+"'>Country:<\/label><\/th><td><input id='"+c+"'/><\/td>"),v.append(f.trCountry),f.cboCountry=s($("input",f.trCountry),{maxLength:50,onChange:k}),c+="X",f.trPostalId=$("<tr style='display:none'><th><label for='"+c+"'>Postal Id:<\/label><\/th><td><input id='"+c+"'/><button class='is-button small'>Check<\/button><\/td>"),v.append(f.trPostalId),f.txtPostalId=i($("input",f.trPostalId),{maxLength:20}),f.cmdCheckPostalId=$("button.is-button.small",f.trPostalId),f.cmdCheckPostalId.click(st),c+="X",f.trWarning=$("<tr style='display:none'><th colspan='2'><div class='is-info-text info' style='color:darkred; margin-bottom:0 !important; margin-top:0 !important; width:100%'><\/div><\/th>"),v.append(f.trWarning),f.divWarning=$("div",f.trWarning),f.pulPromptUpdateList_Address=n.UI.PromptUpdateList({onAccept:ht}),e.useAutoComplete&&n.UI.InitialiseAddressAutoComplete({streetAddress:f.txtStreetAddress,suburb:f.txtSuburb,city:f.txtCity,state:f.cboState,postcode:f.txtPostcode,country:f.cboCountry,onAfterAddressAutoComplete:function(){e.readOnly||k()}}),a(),ot(),nt={TypeName:"AddressDetails",Focus:yt,ReadOnly:ri,Visible:pt,FromAddressDetailsJson:ui,ToAddressDetailsJson:ft,ShowCity:wt,ShowCountry:bt,ShowDeliveryType:kt,ShowPostalId:dt,ShowPropertyName:gt,AdvancedCity:ti,AdvancedPostalId:ii,AutoValidateAddress:ni,IsDeliveryTypeBagOrBox:et,WidthResizeFromParent:fi}}function uu(t,i){function s(){var h,s,o,t,i;for(f.addClass("is-button-list"),f.removeClass("grid vertical"),r.style&&f.addClass(r.style.toLowerCase()),r.size&&f.addClass(r.size.toLowerCase()),f.children().remove(),h=$("<ul><\/ul>"),s=0;s<u.length;s++)if(o=u[s],o.visible){if(t=$("<li index='"+s+"'><\/li>"),i=o.caption||"",i&&i.toUpperCase().startsWith("<HTML>")?i=i.substring(6):(i=n.UI.HtmlEncode(i),t.attr("title",i)),o.icon)switch(r.size.toUpperCase()){case"LARGE":t.append("<a><img src='"+n.GetIconUrl(o.icon,32)+"'/>"+i+"<\/a>");break;default:t.append("<a><img src='"+n.GetIconUrl(o.icon,16)+"'/>"+i+"<\/a>")}else t.append("<a>"+i+"<\/a>");o.priority?(t.addClass("important"),t.css("order",o.PriorityIndex)):t.css("order",999);e==s&&t.addClass("selected");o._captionText=t.text();h.append(t)}f.append(h);r.readOnly?f.addClass("is-readonly"):f.removeClass("is-readonly");$("li",h).click(function(){if(!r.readOnly){var n=e;l($(this).attr("index"))}})}function v(n,t){var i,r;for(n=n.toUpperCase(),r=0;r<u.length;r++)if(u[r].id.toUpperCase()==n){i=u[r];break}if(i){if(t===undefined)return i.caption;i.caption!=t&&(i.caption=t,s())}}function y(n){var i,t;for(n=n.toUpperCase(),t=0;t<u.length;t++)if(u[t].id.toUpperCase()==n){i=u[t];break}return i?i._captionText||i.caption:""}function p(n,t){var i,r;for(n=n.toUpperCase(),r=0;r<u.length;r++)if(u[r].id.toUpperCase()==n){i=u[r];break}if(i){if(t===undefined)return i.visible;i.visible!=t&&(i.visible=t,s())}}function w(n){var t,i;if(u=n,n)for(t=0;t<n.length;t++)i=n[t],i.visible===undefined&&(i.visible=!0);s()}function b(){return f}function k(){f.focus()}function l(n,t){if(n===undefined)return e;if(n!=e&&(e=n,$("li",f).removeClass("selected"),e!=-1&&$("li[index='"+e+"']",f).addClass("selected"),!t&&r.onChange))r.onChange(a,{})}function d(n,t){var r,i;if(n===undefined)return e<0||e>u.length-1?"":u[e].id;if(r=-1,n)for(n=n.toUpperCase(),i=0;i<u.length;i++)if(u[i].id&&u[i].id.toUpperCase()==n){r=i;break}r!=e&&l(r,t)}function g(n){if(n===undefined)return r.visible;r.visible=n;r.visible?f.show():f.hide()}function nt(n){if(n===undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,s())}function tt(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,s())}function it(n){if(n===undefined)return r.style;n!=r.style&&(r.style=n,s())}function rt(n){if(!o&&(o=f.closest("tr"),o.length==0))return console.warn("ButtonList.VisibleRow: no parent row element found."),o=null,!1;if(n===undefined)return o.css("visibility").toUpperCase()=="HIDDEN";n?(o.css("display","table-row"),o.css("visibility","")):(o.css("display","none"),o.css("visibility","hidden"))}var u=[],f,o,r,e=-1,h,c,a;if(ButtonListDefaults={style:"grid",size:"large",readOnly:!1,autoReadOnly:!0,onChange:null},r=$.extend({},ButtonListDefaults,i),typeof t=="string"?(h=t,t=$("#"+h)):h=$(t).attr("id"),c=$(t),c.length==0){console.warn("widget_ui.ButtonList: Element '"+h+"' not found.");return}return f=$(c[0]),s(),a={TypeName:"ButtonList",AutoReadOnly:nt,ButtonCaption:v,ButtonVisible:p,ButtonsDefine:w,Element:b,Focus:k,GetButtonCaptionText:y,ReadOnly:tt,SelectedItemId:d,SelectedItemIndex:l,Style:it,Visible:g,VisibleRow:rt}}function ri(t,i){function e(){var o,s,t,e,i;for(u.addClass("is-button-strip"),u.children().remove(),o=$("<ul><\/ul>"),s=0;s<f.length;s++)t=f[s],t.visible&&(e=$("<li><\/li>"),e.attr("itemId",t.id),i=t.caption||"",i=i&&i.toUpperCase().startsWith("<HTML>")?i.substring(6):n.UI.HtmlEncode(i),t.icon?e.append("<a><img src='"+n.GetIconUrl(t.icon,16)+"'/>"+i+"<\/a>"):e.append("<a>"+i+"<\/a>"),t.tooltipText&&e.attr("title",t.tooltipText),t._captionText=e.text(),o.append(e));u.append(o);r.readOnly?u.addClass("is-readonly"):u.removeClass("is-readonly");$("li",o).click(function(){r.readOnly||v($(this).attr("itemId"))})}function c(n,t){var i,r;for(n=n.toUpperCase(),r=0;r<f.length;r++)if(f[r].id.toUpperCase()==n){i=f[r];break}if(i){if(t===undefined)return i.visible;i.visible!=t&&(i.visible=t,e())}}function l(n){var i,t;if(f=n,i={caption:"",checked:!1,enabled:!0,icon:"",id:"",itemType:"button",tooltipText:"",visible:!0},n)for(t=0;t<n.length;t++)n[t]=$.extend({},i,n[t]);e()}function a(){return u}function v(n){if(!r.readOnly){var t={id:n};if(r.onButtonClick)if(r.parentControl)r.onButtonClick(r.parentControl,t);else r.onButtonClick(h,t)}}function y(n){if(n===undefined)return r.visible;r.visible=n;r.visible?u.show():u.hide()}function p(n){if(n===undefined)return r.autoReadOnly;n!=r.autoReadOnly&&(r.autoReadOnly=n==!0,e())}function w(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,e())}var f=[],u,r,o,s,h;if(r=$.extend({},{readOnly:!1,autoReadOnly:!0,visible:!0,onButtonClick:null,parentControl:null},i),typeof t=="string"?(o=t,t=$("#"+o)):o=$(t).attr("id"),s=$(t),s.length==0){console.warn("widget_ui.ButtonStrip: Element '"+o+"' not found.");return}return u=$(s[0]),e(),h={TypeName:"ButtonStrip",AutoReadOnly:p,ButtonVisible:c,ButtonsDefine:l,Element:a,ReadOnly:w,Visible:y}}function di(n,t){return t.cssClass="is-radio-button",gi(n,t)}function gi(i,u){function y(){e.cssClass&&(f.addClass(e.cssClass),l&&l.addClass(e.cssClass));e.readOnly?(f.addClass("is-readonly"),f.attr("disabled","disabled")):(f.removeClass("is-readonly"),f.removeAttr("disabled"));e.autoReadOnly?f.attr("autoreadonly","true"):f.removeAttr("autoreadonly");g?(o.text(""),o.removeClass("is-block"),o.css({display:"none"}),f.removeClass("is-invalid")):(f.addClass("is-invalid"),v?(b?o.html(v):o.text(v),o.css({display:"inline-block"}),o.addClass("is-block")):(o.css({display:"none"}),o.removeClass("is-block")));e.visible?a.show():a.hide()}function it(n){a.addClass(n)}function rt(n){if(n===undefined)return l?l.text():"";l&&l.text(n)}function ut(){return f}function ft(){return a}function nt(){f.focus()}function et(){if(!e.readOnly){p(!0,"",!1);if(e.onChange)e.onChange(w,{})}}function ot(n){if(n===undefined)return e.readOnly;n!=e.readOnly&&(e.readOnly=n==!0,y())}function tt(n){if(n===undefined)try{return f.prop("checked")}catch(t){return!1}else n=n==!0||n=="True"||n=="true",f.prop("checked",n)}function st(n){if(n===undefined)return e.visible;e.visible=n;y()}function ht(n){if(!s&&(s=f.closest("tr"),s.length==0))return console.warn("widget_ui.Checkbox.VisibleRow: no parent row element found."),s=null,!1;if(n===undefined)return s.css("visibility").toUpperCase()=="HIDDEN";n?(s.css("display","table-row"),s.css("visibility","")):(s.css("display","none"),s.css("visibility","hidden"))}function ct(n){if(n===undefined)return e.allowBlank;n!=e.allowBlank&&(e.allowBlank=n==!0,y())}function lt(){var t="",n=!0;return e.allowBlank||tt()||(n=!1,t=e.blankValidationMessage),n?p(!0,"",!1):p(!1,t,!1),n}function p(n,t,i){g=n;v=t===undefined?"":t;b=i===undefined?!1:i;y()}var f,s,g=!0,l,e,o,v="",b=!1,a,c,k,w;if(CheckBoxDefaults={allowBlank:!0,blankValidationMessage:"You must check this box",caption:"",cssClass:"is-checkbox",readOnly:!1,visible:!0,captionWrap:!1,onChange:null},e=$.extend({},CheckBoxDefaults,u),typeof i=="string"?(c=i,i=$("#"+c)):(c=$(i).attr("id"),c||(c="chk"+h(!0),$(i).attr("id",c))),k=$(i),k.length==0){console.warn("widget_ui.CheckBox: Element '"+c+"' not found.");return}if(f=$(k[0]),(f.attr("type")+"").toUpperCase()!="CHECKBOX"&&(r&&(f.attr("type")+"").toUpperCase()=="RADIO"||console.warn("widget_ui.CheckBox: Element '"+c+"' does not have a type attribute of 'checkbox'.")),f.attr("is-created","y"),r||(e.captionWrap?f.wrap("<span class='is-checkbox caption-wrap' controlType='checkbox'/>"):f.wrap("<span style='white-space:nowrap' class='is-checkbox' controlType='checkbox'/>")),a=$(f.parent()),o=$("<label style='display:none' class='is-validation-tip'><\/label>"),a.append(o),r||(l=$("<label for='"+c+"'>"+t(e.caption)+"<\/label>").insertAfter(f)),o.click(function(){nt()}),y(),f.bind("click",function(){et()}),n.Options.enterMovesToNextField)f.on("keyup",function(n){n.keyCode==13&&d($(this))});return w={TypeName:"CheckBox",AddClass:it,AllowBlank:ct,Caption:rt,Element:ut,Focus:nt,ReadOnly:ot,Validate:lt,ValidationSet:p,Value:tt,Visible:st,VisibleRow:ht,WrapperElement:ft},f.prop("is-control",w),w}function fu(i,r){function y(){u.cssClass&&e.addClass(u.cssClass);e.addClass("is-no-select");u.allowBlank?(e.removeClass("is-mandatory"),s&&s.removeClass("is-mandatory")):(e.addClass("is-mandatory"),s&&s.addClass("is-mandatory"));f.attr("readonly","readonly");u.readOnly?e.addClass("is-readonly"):e.removeClass("is-readonly");u.autoReadOnly?f.attr("autoreadonly","true"):f.removeAttr("autoreadonly");u.width!="auto"&&e.css({width:u.width});u.visible?e.show():e.hide()}function b(){var i="",r=f.val(),n;for(h.children().remove(),l=JSON.parse(JSON.stringify(c)),n=0;n<l.length;n++)i+="<li class='is-selectable'>"+t(l[n])+"<\/li>";h.append(i);$("li",h).bind("click",function(){u.readOnly||(rt($(this).text()),g())});g();mListDirty=!1}function rt(t){for(var e,r=nt(f.val()),o=!1,u=[],i=0;i<r.length;i++)t.toUpperCase()==r[i].toUpperCase()?o=!0:u.push(r[i]);o||u.push(t);e=n.ArrayToCsvString(u);e!=f.val()&&wt(e,!0)}function g(){var r=$("li",h),i,t,u,n,e;for(r.removeClass("checked"),i=nt(f.val()),t=0;t<i.length;t++)for(u=i[t].toUpperCase(),n=0;n<l.length;n++)e=l[n].toUpperCase(),u==e&&$(r[n]).addClass("checked")}function ut(){return f.val()!=w}function ft(){var n={ChangeHandled:!1,TextOriginal:w};if(u.onChange)u.onChange(k,n);n.ChangeHandled&&(w=f.val())}function et(n){n!=u.allowBlank&&(u.allowBlank=n==!0,y())}function ot(n){if(n===undefined)return s?s.text():"";s&&s.text(n)}function st(){return f}function ht(){e.focus();window.setTimeout(function(){e.focus()},10)}function ct(n){c=n;b()}function tt(n){c=nt(n);b()}function lt(){return n.ArrayToCsvString(l)}function at(n){if(n===undefined)return u.readOnly;n!=u.readOnly&&(u.readOnly=n==!0,y())}function yt(n){if(n===undefined)return d;n!=d&&(d=n==!0,b())}function pt(n){if(n===undefined)return u.autoReadOnly;n!=u.autoReadOnly&&(u.autoReadOnly=n==!0,y())}function it(n){if(n===undefined)return vt(f);n!=f.val()&&(p+=1,f.val(n),p-=1,g());w=n}function wt(n,t){(n!=f.val()||t)&&(p+=1,f.val(n),p-=1,ft())}function bt(n){if(n===undefined)return u.visible;u.visible=n;y()}function kt(n){if(!o&&(o=f.closest("tr"),o.length==0))return console.warn("CheckList.VisibleRow: no parent row element found."),o=null,!1;if(n===undefined)return o.css("visibility").toUpperCase()=="HIDDEN";n?(o.css("display","table-row"),o.css("visibility","")):(o.css("display","none"),o.css("visibility","hidden"))}function dt(){}function gt(){window.alert("HeightResizeFromParent not implemented!");h&&h.hide();window.setTimeout(function(){var n;n=o?$("td,th",o).innerHeight():e.parent().innerHeight();e.css({height:n+0+"px",overflow:"auto"});u.visible&&h.show()},100)}function ni(n){u.onChange=n}function ti(){var n=!0;return u.allowBlank||it()||(n=!1),n}var f,o,p=0,s,c=[],l,h,u,d=!1,w="",e,v,a,k;if(ListBoxDefaults={allowBlank:!0,captionElement:"auto",cssClass:"is-checklist",listCsv:"",readOnly:!1,autoReadOnly:!0,visible:!0,width:"auto",onChange:null},u=$.extend({},ListBoxDefaults,r),typeof i=="string"?(v=i,i=$("#"+v)):v=$(i).attr("id"),a=$(i),a.length==0){console.warn("CheckList: Element '"+v+"' not found.");return}return f=$(a[0]),f.wrap("<span style='display:inline-block; padding:0; position:relative; margin:0' controlType='checklist' tabindex='0'/>"),e=$(f.parent()),a=$("label[for='"+v+"']"),s=a.length==0?null:$(a[0]),h=$("<ul><\/ul>"),e.append(h),y(),tt(u.listCsv),b(),k={TypeName:"CheckList",AutoReadOnly:pt,AllowBlank:et,Caption:ot,Changed:ut,Element:st,Focus:ht,HeightResizeFromParent:gt,ListFromArray:ct,ListFromCsvString:tt,ListToCsvString:lt,ReadOnly:at,Sorted:yt,Text:it,Validate:ti,Visible:bt,VisibleRow:kt,WidthResizeFromParent:dt,OnChange:ni,WrapperElement:function(){return e}},e.prop("is-control",k),k}function s(i,u){function g(){f.cssClass&&e.addClass(f.cssClass);f.allowBlank?(e.removeClass("is-mandatory"),s&&s.removeClass("is-mandatory")):(e.addClass("is-mandatory"),s&&s.addClass("is-mandatory"));e.attr("placeholder",f.blankTip);f.readOnly?(e.addClass("is-readonly"),e.attr("readonly","readonly")):(e.removeClass("is-readonly"),e.removeAttr("readonly"));f.autoReadOnly?e.attr("autoreadonly","true"):e.removeAttr("autoreadonly");f.allowDropdown||p.hide();e.attr("maxLength",f.maxLength==0?"":f.maxLength);e.attr("spellcheck","false");f.width!="auto"&&(e.css({width:f.width}),f.width&&f.width.endsWith("%")&&c.css({width:f.width}));f.visible?(c.show(),s&&s.show()):(s&&s.hide(),c.hide())}function bt(){var r,s=e.val(),t,i,u;if(l){ut();return}for(h.Clear(),r="<ul>",t=0;t<o.length;t++)if(f.onFormatItem){i=o[t];u={value:i,listIndex:t,displayValue:i,displayValueIsHtml:!0};f.onFormatItem(ct,u);i=u.displayValue;u.displayValueIsHtml||(i=n.UI.HtmlEncode(i));r+="<li class='is-selectable' style='min-height:20px' value='"+n.UI.HtmlEncode(o[t])+"'>"+i+"<\/li>"}else r+="<li class='is-selectable' style='min-height:20px'>"+n.UI.HtmlEncode(o[t])+"<\/li>";r+="<\/ul>";w=$(r);$("li",w).bind("click",function(){e.val($(this).attr("value")||$(this).text());f.usePicker||f.createdForGrid||et(!0);y(!0);f.usePicker&&(v(),SharedPickerPanel().Hide(!0))});f.usePicker||h.Append(w);tt=!1}function ut(){var i=e.val(),n;for(e.children().remove(),n=0;n<o.length;n++)e.append("<option>"+t(o[n])+"<\/option>");e.val(i)}function v(){var n=ot(e.val(),!1),t;$("li.is-sel",w).removeClass("is-sel");n>=0&&n<o.length&&(t=$($("li",w)[n]),t.addClass("is-sel"),f.createdForGrid||t.ScrollElementIntoView(!0))}function lt(){if(tt&&bt(),f.usePicker){var n=f.pickerCaption;!n&&s&&(n=s.text(),n&&(n="Select "+n,n.endsWith(":")&&(n=n.substr(0,n.length-1))));n||(n="Select Item");SharedPickerPanel().Toggle({closeFocusElement:ct,sourceButtonElement:p,caption:n,contentElement:w,onKeyDown:function(n){switch(n.keyCode){case 35:st(o.length-1);v();break;case 36:st(0);v();break;case 38:ht(-1);v();break;case 40:ht(1);v()}}})}else h.Show(),e.focus(),e.select();v()}function et(n){f.usePicker?SharedPickerPanel().Hide():(h.Hide(),n&&(e.focus(),e.select()))}function at(){return e.val()!=it}function y(n){l||f.limitToList&&!yt(e.val())&&e.val("");var t={ChangeHandled:!1,TextOriginal:it,ChangedFromPopup:n};if(f.onChange)f.onChange(ct,t);t.ChangeHandled&&(it=e.val())}function ni(n){if(n===undefined)return f.allowBlank;n!=f.allowBlank&&(f.allowBlank=n==!0,g())}function ti(n){if(n===undefined)return f.blankTip;f.blankTip=n;g()}function ii(n){if(n===undefined)return s?s.text():"";s&&s.text(n)}function ri(){return e}function ui(){e.focus();e.select()}function ot(n,t){if(t&&n.length==0)return-1;for(var i=0;i<o.length;i++)if(t){if(o[i].substr(0,n.length).toUpperCase()==n.toUpperCase())return i}else if(o[i]==n)return i;return-1}function st(n){if(n===undefined)return ot(e.val(),!1);n<0||n>o.length-1?pt(""):pt(o[n]);it=e.val()}function ht(n){var t=st()+n;t<0?t=0:t>o.length-1&&(t=o.length-1);wt(o[t],!1,!0)}function fi(n){n!=f.limitToList&&(f.limitToList=n==!0)}function yt(n,t){var i;if(t=t?!0:!1,n+="",t){for(n=n.toUpperCase(),i=0;i<o.length;i++)if(o[i].toUpperCase()==n)return!0}else for(i=0;i<o.length;i++)if(o[i]==n)return!0;return!1}function ei(n){o=n;tt=!0;l&&ut()}function oi(n){typeof n=="string"&&(n=JSON.parse(n));kt(n,"Description")}function kt(n,t){var r,i;if(o=[],tt=!0,n!=undefined&&t)for(r=0;r<n.length;r++)i=n[r][t],(i===null||i===undefined)&&(i=""),o.push(i);l&&ut()}function dt(n){o=nt(n);tt=!0;l&&ut()}function si(n){if(n===undefined)return f.readOnly;n!=f.readOnly&&(f.readOnly=n==!0,g())}function hi(n){if(n===undefined)return f.autoReadOnly;n!=f.autoReadOnly&&(f.autoReadOnly=n==!0,g())}function pt(n){if(n===undefined)return l?""+e.val():vt(e);n!=e.val()&&(rt+=1,e.val(n),rt-=1);it=n}function wt(n,t,i){(n!=e.val()||t)&&(rt+=1,e.val(n),rt-=1,y(i))}function ci(n){if(n===undefined)return f.visible;f.visible=n;g()}function li(n){if(!a&&(a=e.closest("tr"),a.length==0))return console.warn("ComboBox.VisibleRow: no parent row element found."),a=null,!1;if(n===undefined)return a.css("visibility").toUpperCase()=="HIDDEN";n?(a.css("display","table-row"),a.css("visibility","")):(a.css("display","none"),a.css("visibility","hidden"))}function gt(n){var r,t,i;c.hide();r=c.parent().innerWidth();c.show();t=f.width;i="";f.maxLength==0||f.maxLength>100||n?t="100%":(i=f.maxLength<=3?f.maxLength*.8+3+"em":f.maxLength*.8+"em",t="100%");c.css({width:t,maxWidth:i});e.css({width:t,maxWidth:i});f.visible||c.hide()}var b,k,ct;if(!r&&n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI&&!(u&&u.forceWidgetControl))return typeof i=="string"&&(i=$("#"+i)),i.attr("is-created","y"),u.widgetDocument=window.document,new window.parent.$UI.ComboBox(i,u);var p,h,e,a,rt=0,l,s,o=[],tt=!0,w,f,it="",c;if(ComboBoxDefaults={blankTip:"",captionElement:"auto",cssClass:"is-combobox",allowBlank:!0,allowDropdown:!0,limitToList:!1,listCsv:"",maxLength:0,readOnly:!1,autoReadOnly:!0,visible:!0,width:"auto",onChange:null,onFormatItem:null,usePicker:window.__alwaysUsePickerControls,pickerCaption:""},f=$.extend({},ComboBoxDefaults,u),typeof i=="string"?(b=i,i=$("#"+b)):b=$(i).attr("id"),k=$(i),k.length==0){console.warn("userinterface.ComboBox: Element '"+b+"' not found.");return}if(e=$(k[0]),l=e.prop("tagName")=="SELECT",l&&(r?(f.allowDropdown=!1,f.limitToList=!0):console.warn("userinterface.ComboBox: Element '"+b+"' is a SELECT element. This is only supported if widget.UI.DisableControlStyling has been set to true.")),e.attr("is-created","y"),r||e.wrap("<span style='display:inline-block; padding:0; position:relative; margin:0' controlType='combobox'/>"),c=$(e.parent()),p=$("<button type='button' tabindex='-1' class='is-combobox-button' style='position:absolute; right:0'/>"),f.usePicker&&p.addClass("is-picker"),c.append(p),h=new ft(c,{minWidthElement:e}),e.attr("autocomplete","off"),e.attr("spellcheck","false"),k=$("label[for='"+b+"']"),s=k.length==0?null:$(k[0]),f.width=="auto"&&f.maxLength!=0&&gt(),g(),dt(f.listCsv),l&&f.listCsv&&bt(),l?e.bind("change",function(){y(!0)}):(e.bind("blur",function(){!f.readOnly&&f.limitToList&&at()&&(yt(e.val())||e.val(""))}),e.bind("keydown",function(n){switch(n.keyCode){case 13:return h.Visible()&&et(!0),!1;case 27:return h.Visible()?(et(!1),!1):void 0;case 38:return h.Visible()&&(ht(-1),h.Visible()&&v()),!1;case 40:return h.Visible()?(ht(1),v()):f.readOnly||lt(),!1}}),e.bind("keyup",function(n){var r=0,t,i;switch(n.keyCode){case 46:f.limitToList||(r=-1);break;case 8:r=-1;break;default:if(n.keyCode<48)return}t=ot(e.val(),!1);h.Visible()&&v();t==-1&&f.limitToList&&n.keyCode==46?(wt("",!1,!1),y(!1)):t==-1&&(i=e[0].selectionStart+r,i<0&&(i=0),t=ot(e.val(),!0),t!=-1?((f.limitToList||n.keyCode!=46&&n.keyCode!=8)&&(e.val(o[t]),e[0].selectionStart=i,e[0].selectionEnd=1e3),y(!1)):f.limitToList?(wt("",!1,!1),y(!1)):at()&&y(!1))}),p.bind("click",function(){f.readOnly||(h.Visible()?et(!0):lt())})),n.Options.enterMovesToNextField&&!f.onEnterKey&&!f.multiLine)e.on("keyup",function(n){n.keyCode==13&&d($(this))});return ct={TypeName:"ComboBox",AllowBlank:ni,AutoReadOnly:hi,BlankTip:ti,Caption:ii,Changed:at,DropdownShow:lt,Element:ri,Focus:ui,LimitToList:fi,ListExists:yt,ListFromArray:ei,ListFromCodeDescriptionList:oi,ListFromCollection:kt,ListFromCsvString:dt,ListIndex:st,ReadOnly:si,Text:pt,Visible:ci,VisibleRow:li,WidthResizeFromParent:gt,WrapperElement:function(){return c}}}function eu(n){function e(n,r){var o,y,s,e,a,l,v;if(t||(t=$("<div class='column-container'><\/div>"),i.append(t)),o=$("<div class='column'><\/div>"),n.width&&o.css("width",n.width),n.maxWidth&&o.css("max-width",n.maxWidth),n.minWidth&&o.css("min-width",n.minWidth),f.push(o),t.append(o),f.length==1&&o.addClass("first"),r&&r.length!=0)for(y=100/r.length,s=0;s<r.length;s++){var u=r[s],h=u.element,c=u.headingElement,p=u.position;typeof h=="string"&&(h=$("#"+h));typeof c=="string"&&(c=$("#"+c));h.css("padding-top","none");e=$("<div class='panel'><\/div>");o.append(e);c&&(a=$("<div class='panel-heading'><\/div>"),e.append(a),a.append(c));l=$("<div class='panel-body'><\/div>");e.append(l);l.append(h);u.align&&l.addClass("align-"+u.align.toLowerCase());u.panelElement=e;s==0&&e.addClass("first");u.maxHeight&&e.css("max-height",u.maxHeight);u.visible==!1&&e.hide();s<r.length&&e.css("height",y+"%");u.zoomable&&(v=$("<div class='panel-zoom' title='Zoom'><\/div>"),e.append(v),function(n,t){t.click(function(){n.panelElement.hasClass("zoomed")?(n.panelElement.removeClass("zoomed zooming"),t.attr("title","Zoom"),n.maxHeight&&n.panelElement.css("max-height",n.maxHeight),window.setTimeout(function(){n.panelElement.removeClass("zooming")},500),n.onZoomOut&&n.onZoomOut()):(n.panelElement.addClass("zoomed zooming"),t.attr("title","Unzoom"),n.maxHeight&&n.panelElement.css("max-height",""),n.onZoomIn&&n.onZoomIn())})}(u,v))}}function o(n){t&&(t=null);typeof n=="string"&&(n=$("#"+n));r||(r=$("<div class='heading'><\/div>"),i.append(r));r.append(n)}var u,f=[],i,r,t;return typeof n=="string"&&(n=$("#"+n)),u=n,i=$("<div class='is-dashboard-container'><\/div>"),u.append(i),{TypeName:"DashboardLayout",AddColumn:e,AddHeading:o}}function v(t,i){function rt(){u.cssClass&&f.addClass(u.cssClass);u.allowBlank?(f.removeClass("is-mandatory"),a&&a.removeClass("is-mandatory")):(f.addClass("is-mandatory"),a&&a.addClass("is-mandatory"));u.readOnly?(f.addClass("is-readonly"),f.attr("readonly","readonly"),h.hide(),e&&(e.addClass("is-readonly"),e.attr("readonly","readonly"))):(f.removeClass("is-readonly"),f.removeAttr("readonly"),h.show(),h.css("display","inline-block"),e&&(e.removeClass("is-readonly"),e.removeAttr("readonly","readonly")));u.autoReadOnly?(f.attr("autoreadonly","true"),e&&e.attr("autoreadonly","true")):(f.removeAttr("autoreadonly"),e&&e.removeAttr("autoreadonly"));u.allowDropdown||h.hide();f.attr("maxLength",u.maxLength==0?"":u.maxLength);u.width!="auto"&&f.css({width:u.width});f.attr("spellcheck","false");u.showAge||u.showWeekDayName?y.show():y.hide();ht?(p.css({display:"none"}),f.removeClass("is-invalid")):(f.addClass("is-invalid"),nt?(ct?p.html(nt):p.text(nt),p.css({display:"inline-block"})):p.css({display:"none"}));u.visible?(s.show(),e&&e.show()):(s.hide(),e&&e.hide())}function dt(){if(!v){var n=$("<div><\/div>");v=new Calendar(n,{onChange:function(n,t){var i=t.CloseDropdown||t.CloseDropdown===undefined;v.Value()?ut(l(v.Value(),!1,!1,!1)):ut("");i&&bt(!0);yt()&&pt()}});g.Append(v.Element())}g.Show(310,!1);f.focus();f.select();o===null&&f[0].value&&ut(f[0].value);v.Value(o);v.GotoValue()}function bt(n){g.Hide();n&&(f.focus(),f.select())}function ut(n){u.readOnly||(o=n==""?null:lt(n,u.historic,!u.valueIsUtc));vt()}function vt(){if(st)f[0].valueAsDate=o;else{var t=l(o,!1,!0);f.val(t)}u.showAge&&o?y.text(n.GetAgeText(o)):u.showWeekDayName&&o?y.text(n.GetWeekDayNameFromDate(o)):y.text("")}function gt(n){n!=u.allowBlank&&(u.allowBlank=n==!0,rt())}function ni(n){if(n===undefined)return a?a.text():"";a&&a.text(n)}function yt(){return l(o)!=l(tt)}function pt(){var t={ChangeHandled:!1,ValueOriginal:tt};if(e&&(t.TimeValueOriginal=n.ParseTime(it,!0)),u.onChange)u.onChange(ot,t);t.ChangeHandled&&(tt=o,e&&(it=e.val()))}function ti(){return f}function ii(){f.focus();f.select()}function ri(n){if(n===undefined)return u.readOnly;n!=u.readOnly&&(u.readOnly=n==!0,rt())}function wt(t){var i,r;if(t===undefined)return i=o,i&&e&&(r=n.ParseTime(e.val(),!0),r?i.setUTCHours(r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),0):i.setUTCHours(0,0,0,0)),i;o=typeof t=="string"?at(t):t;vt();e&&(e.val(n.FormatTime(o,!0,!0)),o=lt(f.val()));tt=o}function ui(){return o?o.toISOString():""}function fi(n){if(n===undefined)return u.maxValue;u.maxValue=n}function ei(n){if(n===undefined)return u.minValue;u.minValue=n}function oi(n){if(n===undefined)return u.visible;u.visible=n;rt()}function si(n){if(!c&&(c=f.closest("tr"),c.length==0))return console.warn("ComboBox.VisibleRow: no parent row element found."),c=null,!1;if(n===undefined)return c.css("visibility").toUpperCase()=="HIDDEN";n?(c.css("display","table-row"),c.css("visibility","")):(c.css("display","none"),c.css("visibility","hidden"))}function kt(n){var i,t,r;s.hide();i=s.parent().innerWidth();s.show();t=u.width;r="";n&&(t="100%")}function hi(){return ht?!0:!1}function ci(){var n=!0,t;return!u.allowBlank&&!wt()?(et(!0,"",!1),!1):(typeof u.minValue=="string"&&(u.minValue=at(u.minValue)),typeof u.maxValue=="string"&&(u.maxValue=at(u.maxValue)),(u.minValue!=null||u.maxValue!=null)&&(t=wt(),n&&u.minValue!=null&&t<u.minValue&&(n=!1),n&&u.maxValue!=null&&t>u.maxValue&&(n=!1)),n?et(!0,"",!1):et(!1,"Valid range "+li(),!1),n)}function li(){var n="";return u.minValue!=null&&(n+=l(u.minValue)),u.maxValue!=null&&(n&&(n+=" "),n+="to "+l(u.maxValue)),n}function et(n,t,i){ht=n;nt=t===undefined?"":t;ct=i===undefined?!1:i;rt()}function ai(n){u.onChange=n}var b,k,ot;if(!r&&n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI)return typeof t=="string"&&(t=$("#"+t)),t.attr("is-created","y"),i.widgetDocument=window.document,new window.parent.$UI.DateBox(t,i);var h,v,y,g,f,c,e,w=!1,st=!1,ht=!0,a,u,p,nt="",ct=!1,o=null,tt=null,it="",s;if(DateBoxDefaults={captionElement:"auto",cssClass:"is-datebox",allowBlank:!0,allowDropdown:!0,allowTime:!1,historic:!1,valueIsUtc:!1,maxValue:null,minValue:null,readOnly:!1,autoReadOnly:!0,showWeekDayName:!1,showAge:!1,width:"auto",visible:!0,onChange:null},u=$.extend({},DateBoxDefaults,i),typeof t=="string"?(b=t,t=$("#"+b)):b=$(t).attr("id"),k=$(t),k.length==0){console.warn("widget_ui.DateBox: Element '"+b+"' not found.");return}if(f=$(k[0]),f[0].tagName!="INPUT"&&console.warn("widget_ui.DateBox: Element '"+b+"' must be an INPUT type Element."),f.attr("is-created","y"),r&&!u.allowDropdown||(r?f.wrap("<span style='' controlType='datebox'/>"):f.wrap("<span style='display:inline-block; padding:0; position:relative; margin:0' controlType='datebox'/>")),s=$(f.parent()),h=r?$("<button type='button' tabindex='-1' class='is-combobox-button'/>"):$("<button type='button' tabindex='-1' class='is-combobox-button' style='position:absolute; margin-left:-20px'/>"),u.usePicker&&h.addClass("is-picker"),s.append(h),u.allowTime&&(e=$("<input class='is-timebox' style='display:inline-block;width:6em;margin-left:4px;text-align:right' placeholder='Time'/>"),s.append(e)),p=$("<label style='display:none' class='is-validation-tip'><\/label>"),s.append(p),g=new ft(s,{minWidthElement:f,cssClass:"is-dropdown is-dropdown-calendar"}),y=$("<label class='is-combobox' style='display:none; position:relative; margin-top:-4px;'><\/label>"),y.insertAfter(h),f.attr("autocomplete","off"),f.attr("spellcheck","false"),k=$("label[for='"+b+"']"),a=k.length==0?null:$(k[0]),rt(),u.width=="auto"&&kt(),st?(f.blur(function(){w=!1}),f.focus(function(){w=!0})):(f.blur(function(){w=!1}),f.focus(function(){w=!0})),f.blur(function(){u.readOnly||(st?o=f[0].valueAsDate:ut(f.val()));yt()&&pt();tt=o;vt()}),h.bind("click",function(){u.readOnly||(g.Visible()?bt(!0):dt())}),e&&(e.focus(function(){w=!0;it=e.val()}),e.blur(function(){if(w=!1,!u.readOnly){var t=n.ParseTime(e.val(),!0);e.val(n.FormatTime(t,!0,!0));it!=e.val()&&pt();it=e.val()}})),n.Options.enterMovesToNextField){f.on("keyup",function(n){n.keyCode==13&&d($(this))});if(e)e.on("keyup",function(n){n.keyCode==13&&d($(this))})}return ot={TypeName:"DateBox",AllowBlank:gt,Caption:ni,Changed:yt,Element:ti,Focus:ii,MaxValue:fi,MinValue:ei,ReadOnly:ri,Value:wt,ValueAsISOString:ui,Visible:oi,VisibleRow:si,WidthResizeFromParent:kt,IsValid:hi,Validate:ci,ValidationSet:et,OnChange:ai},f.prop("is-control",ot),ot}function g(t,i){function h(){f.ListFromCsvString(i.list)}function a(n){var i,t;if(e.listOther&&n)for(i=e.listOther.split(","),n=n.toUpperCase(),t=0;t<i.length;t++)if(i[t].toUpperCase()==n)return!0;return!1}function c(){var t=f.Text();t?o==t||(a(t)?f.DescriptionUpdate(""):(f.DescriptionUpdate(""),n._SystemGetString("GetDateCycleDescription",{dateCycle:t,isFrequency:e.isFrequency},function(n){var u;if(n){var e=n.indexOf("|"),t=n,r="";e!=-1&&(r=t.substr(e+1),t=t.substr(0,e),t.toUpperCase()==r.toUpperCase()&&(t=""));f.DescriptionUpdate(t);r&&(f.Text(r),o=r)}else if(f.ListIndex()!=-1)f.DescriptionUpdate("");else if(i.listOther){var s=nt(i.listOther),h=!1,c=l().toUpperCase();for(u=0;u<s.length;u++)if(c==s[u].toUpperCase()){h=!0;break}h?f.DescriptionUpdate(""):f.DescriptionUpdate("Invalid",!1,!0)}else f.DescriptionUpdate("Invalid",!1,!0)},function(t){n.RegisterError("widget_ui.DateCycleComboBox: Failed to retrieve Date Cycle Description: "+t)}))):f.DescriptionUpdate("")}function v(n){e.list=n;h()}function y(n){e.listOther=n;h()}function l(n){if(n===undefined)return f.Text();n!=o&&(f.Text(n),c());o=n}if(!r&&n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI)return typeof t=="string"&&(t=$("#"+t)),t.attr("is-created","y"),i.widgetDocument=window.document,new window.parent.$UI.DateCycleComboBox(t,i);var f,e=i,o="",s=null;return i.showColumnHeadings=!1,i.showDescription==!1?i.showDescription=!1:i.showDecription=!0,i.maxLength=20,i.isFrequency=i.isFrequency?!0:!1,i.width===undefined&&(i.width="12em"),i.list===undefined&&(i.list=""),i.listOther===undefined&&(i.listOther=""),s=i.onChange,i.onChange=function(n,t){c();s?s(n,t):t&&(t.ChangeHandled=!0);o=f.Text()},f=n.UI.DBCombo(t,i),f.WidthResizeFromParent(),f.ListFromCsvString(""),u={TypeName:"DateCycleComboBox",ListFromCsvString:v,ListOtherFromCsvString:y,AllowBlank:f.AllowBlank,AutoReadOnly:f.AutoReadOnly,BlankTip:f.BlankTip,Caption:f.Caption,Element:f.Element,Focus:f.Focus,LimitToList:f.LimitToList,ReadOnly:f.ReadOnly,Text:l,Visible:f.Visible,VisibleRow:f.VisibleRow,WidthResizeFromParent:f.WidthResizeFromParent}}function w(u,f){function rt(){e.cssClass&&o.addClass(e.cssClass);e.allowBlank?(o.removeClass("is-mandatory"),g&&g.removeClass("is-mandatory")):(o.addClass("is-mandatory"),g&&g.addClass("is-mandatory"));r?e.blankTip&&o.attr("placeholder",e.blankTip):o.attr("placeholder",e.blankTip);si?(o.addClass("is-readonly"),o.attr("readonly","readonly"),o.addClass("fetchingdata"),k.addClass("fetchingdata")):e.readOnly?(o.addClass("is-readonly"),o.attr("readonly","readonly"),o.removeClass("fetchingdata"),k.removeClass("fetchingdata")):(o.removeClass("is-readonly"),o.removeAttr("readonly"),o.removeClass("fetchingdata"),k.removeClass("fetchingdata"));e.autoReadOnly?o.attr("autoreadonly","true"):o.removeAttr("autoreadonly");e.showDropdown?k.show():k.hide();s&&(e.showDescription?s.show():s.hide());o.attr("maxLength",e.maxLength==0?"":e.maxLength);o.css({width:e.width});o.attr("spellcheck","false");e.visible?w.show():w.hide()}function b(){var t,i;if(s&&e.showDecription)if(s.removeClass("is-invalid"),!bt()&&e.blankTipDescription)s.text(e.blankTipDescription);else switch(ht){case"Array":s.text(bi);ki&&s.addClass("is-invalid");break;case"Unbound":s.text(c);break;default:p?(t=bt(),t!=li&&(s.text(""),li="",ci="",t&&(ai&&(window.clearTimeout(ai),ai=null),window.setTimeout(function(){var i={standardRangeName:p,id:t};n._SystemGetString("GetStandardRangeRecordDescription",i,function(n){n&&(n=JSON.parse(n),bt()==t&&(li=t,ci=n.Description,s.text(ci),e.limitToList&&!n.Description&&(s.addClass("is-invalid"),s.text("!")),n.Id&&t!=n.Id&&(et+=1,o.val(n.Id),et-=1)))},function(t){n.RegisterError("widget_ui.DBCombo: Failed to retrieve Standard Range record description: "+t)})},500)))):(i=gt(o.val()),o.val()==""?s.text(""):i==-1||i>=ct.length?ct.length==0?s.text(""):(s.text("!"),s.addClass("is-invalid")):s.text(ct[i]))}}function vi(){v.Clear();a=[];ct=[];switch(ht){case"":break;case"Array":fr();break;case"Collection":p?sr():or();break;case"CodeDescriptionList":er();break;default:window.alert("widget.UI.DBCombo.UpdateList: Unsupported Data Source format")}h&&a.length>10&&(hi=$("<caption class='is-table-filter'><input type='search' placeholder='Type to filter list' style='width:100%' autocomplete='off' spellcheck='false'/><\/caption>"),$("tbody",h).before(hi),window.setInterval(function(){var n=$("input",hi);n.val()!=ii&&ar(n.val())},200));b();lt=!1}function fr(){var t,i;for(t="<table style='width:100%'>",t+="<tbody>",i=0;i<c.length;i++)a[i]=c[i],ct[i]="",t+="<tr class='is-selectable'>",t+=c[i]?"<td>"+n.UI.HtmlEncode(c[i])+"<\/td>":"<td>&nbsp;<\/td>",t+="<\/tr>";t+="<\/tbody>";t+="<\/table>";h=$(t);$("tbody > tr",h).bind("click",function(n){var t=$("tbody > tr",h).index(n.delegateTarget);t>=0&&t<a.length&&(o.val(a[t]),e.usePicker||ot(!0),st(!0),e.usePicker&&(tt(),SharedPickerPanel().Hide(!0)))});e.usePicker||v.Append(h)}function er(){var t,i;for(t="<table style='width:100%'>",e.showColumnHeadings&&fi&&(t+="<thead>",t+="<tr><th>"+n.UI.HtmlEncode(fi)+"<\/th><th>"+n.UI.HtmlEncode(di)+"<\/th><\/tr>",t+="<\/thead>"),t+="<tbody>",i=0;i<c.length;i++)a[i]=c[i].Code,ct[i]=c[i].Description,t+="<tr class='is-selectable'>",t+="<td>"+n.UI.HtmlEncode(c[i].Code)+"<\/td>",t+="<td>"+n.UI.HtmlEncode(c[i].Description)+"<\/td>",t+="<\/tr>";t+="<\/tbody>";t+="<\/table>";h=$(t);$("tbody > tr",h).bind("click",function(n){var t=$("tbody > tr",h).index(n.delegateTarget);t>=0&&t<a.length&&(o.val(a[t]),b(),e.usePicker||ot(!0),ot(!0),st(!0),e.usePicker&&(tt(),SharedPickerPanel().Hide(!0)))});e.usePicker||v.Append(h)}function or(){var f,u,y,d,k,r,w,i,s,p;for(f=kt.split(","),y=[f.length],i=0;i<f.length;i++)for(y[i]="",s=0;s<c.length;s++)if(d=c[s][f[i]],k="",k=typeof d=="boolean"?"Boolean":f[i]&&f[i].toUpperCase().indexOf("DATE")!=-1?"Date":"",k!=y[i])if(y[i]=="")y[i]=k;else{y[i]="";break}if(u="<table style='width:100%'>",e.showColumnHeadings&&f.length!=0){for(u+="<thead><tr>",i=0;i<f.length;i++){r=f[i];w="";r==ti&&r!="Value"?r="Code":r.endsWith("Resolved")?(r=r.substr(0,r.length-8),w="+"):r.endsWith("Full")?(r=r.substr(0,r.length-4),w="+"):r.endsWith("TypeText")?r=r.substr(0,r.length-4):r.startsWith("Master")&&r.endsWith("Id")&&(r="Master");switch(y[i]){case"Boolean":u+="<th align='center' style='width:1em'><nobr>"+n.UI.HtmlEncode(pt(r))+w+"<\/nobr><\/th>";break;case"Date":u+="<th align='right'>"+n.UI.HtmlEncode(pt(r))+w+"<\/th>";break;default:u+="<th>"+n.UI.HtmlEncode(pt(r))+w+"<\/th>"}}u+="<\/tr><\/thead>"}for(u+="<tbody>",i=0;i<c.length;i++){for(a[i]=c[i][ti],ct[i]=c[i][ei],u+="<tr class='is-selectable'>",s=0;s<f.length;s++)switch(y[s]){case"Boolean":u+=c[i][f[s]]?"<td align='center' class='is-symbol-tick' style='color:green'><\/td>":"<td align='center' class='is-symbol-cross' style='color:red'><\/td>";break;case"Date":c[i][f[s]]?(p=c[i][f[s]],u+=typeof p=="string"&&(p.indexOf(" ")!=-1||p.indexOf("M")!=-1||p.indexOf("/")!=-1)?"<td>"+t(p)+"<\/td>":"<td>"+l(p)+"<\/td>"):u+="<td>&nbsp;<\/td>";break;default:u+=c[i][f[s]]?"<td>"+n.UI.HtmlEncode(c[i][f[s]])+"<\/td>":"<td>&nbsp;<\/td>"}u+="<\/tr>"}u+="<\/tbody>";u+="<\/table>";h=$(u);$("tbody > tr",h).bind("click",function(n){var t=$("tbody > tr",h).index(n.delegateTarget);t>=0&&t<a.length&&(o.val(a[t]),b(),e.usePicker||ot(!0),st(!0),e.usePicker&&(tt(),SharedPickerPanel().Hide(!0)))});e.usePicker||v.Append(h)}function sr(){var n;h=$("<div style='min-height:120px; min-width:320px'><\/div>");var t=$("<input type='text' style='position:absolute !important; top:0; left:0; width:100%;border:1px solid transparent !important; border-bottom:1px solid rgba(0,0,0,0.2) !important'/>"),r=$("<button class='is-button dbcombo-search' style='min-width:0; width:22px; height:22px; margin:0; position:absolute; right:2px; top:0;'/>"),u=$("<div style='position:absolute; top:22px;left:0;right:0;bottom:0;overflow:auto'><\/div>");switch(p.toUpperCase()){case"CLIENTS":t.attr("placeholder","e.g. code, name, date of birth, email, phone");break;case"SECURITYSTMTS":t.attr("placeholder","e.g. code, name, serial number, registration");break;default:t.attr("placeholder","e.g. code, name")}h.append(t);h.append(r);h.append(u);y=new ui(u,{showColumnHeaders:!1,stickyHeader:!1,onAfterRowActivate:cr,onRowDrilldown:lr,onInitialiseRow:hr});y.AddColumnCode("Id",{caption:"Code"});y.AddColumnString("Name",{caption:"Description"});y.AddColumnString("Info",{caption:"Information",align:"right",colour:"gray"});y.Refresh();n=i(t,{onEnterKey:function(){gi(n.Text())}});n.Element().keydown(function(t){switch(t.which){case 27:return n.Text()?n.Text(""):ot(!0),!1;case 40:return it&&it.Results.length!=0&&(y.Focus(),y.ActiveDataRowIndex()==-1&&y.ActiveDataRowIndex(0)),!1}});y.Element().keydown(function(n){switch(n.which){case 13:y.ActiveDataRowIndex()!=-1&&y.PerformRowDrilldown()}});r.click(function(){n.Focus();gi(n.Text())});e.usePicker||v.Append(h)}function gi(t){if(t)y.Visible(!0);else{y.Visible(!1);return}var i={standardRangeName:p,query:t,sqlWhere:yt};n._SystemGetString("GetStandardRangeQuickSearchResults",i,function(n){var i,t;if(n){for(it=JSON.parse(n),i=!1,t=0;t<it.Results.length;t++)if(it.Results[t].Info){i=!0;break}y.ColumnVisible("Info",i);y.VirtualDataRefresh(it.Results);y.ActiveDataRowIndex(-1)}},function(t){n.RegisterError("widget_ui.DBCombo: Failed to retrieve Quick Search results for Standard Range: "+t)})}function hr(n){var t=it.Results[n.row.listIndex];n.row.cells.Id.value=t.Id;n.row.cells.Name.value=t.Name;n.row.cells.Info.value=t.Info}function cr(){if(it&&it.Results&&y.ActiveDataRowIndex()!=-1){var n=it.Results[y.ActiveDataRowIndex()];n&&o.val(n.Id);b();st(!0)}}function lr(){v.Hide();o.focus()}function ar(n){var u,t,v,s,f,e,a,o,r,i;if(ii=n,c&&h&&($("tbody > tr",h).removeClass("is-filtered-out"),ii)){if(u=ii.toUpperCase().split(" "),u.length>0)for(t=$("tbody > tr",h),i=0;i<t.length;i++){for(v=t[i],s=!0,f=0;f<u.length;f++){var l=u[f],y=!1,p=$("td",v);if(l&&l!=" ")for(e=0;e<p.length;e++)if(a=$(p[e]).text(),a&&a.toUpperCase().indexOf(l)!=-1){y=!0;break}if(!y){s=!1;break}}s||$(t[i]).addClass("is-filtered-out")}if(o=ni(),o>=0&&o<t.length&&$(t[o]).hasClass("is-filtered-out")){for(r=-1,i=0;i<t.length;i++)if(!$(t[i]).hasClass("is-filtered-out")){r=i;break}$("tr.is-sel",h).removeClass("is-sel");r>=0&&r<t.length&&$(t[r]).addClass("is-sel")}}}function tt(){var n=gt(o.val(),!1),t;$("tr.is-sel",h).removeClass("is-sel");n>=0&&n<a.length&&(t=$($("tbody > tr",h)[n]),t.addClass("is-sel"),t.ScrollElementIntoView(!0))}function yi(){if(lt&&vi(),e.usePicker){var n=e.pickerCaption;!n&&g&&(n=g.text(),n&&(n="Select "+n,n.endsWith(":")&&(n=n.substr(0,n.length-1))));n||(n="Select Item");SharedPickerPanel().Toggle({closeFocusElement:wi,sourceButtonElement:k,caption:n,contentElement:h,onKeyDown:function(n){switch(n.keyCode){case 35:ni(a.length-1);tt();break;case 36:ni(0);tt();break;case 38:ri(-1);tt();break;case 40:ri(1);tt()}}})}else p?(v.Show(0,!0),v.WidthResizeFromParent(800)):v.Show(),p?$("input",h).focus():(o.focus(),o.select());tt();oi=!0}function vr(){return oi}function ot(n){v.Hide();n&&(o.focus(),o.select());oi=!1}function nr(){return o.val()!=at}function yr(n,t,i){i||(i=!1);bi=n;ki=i;b()}function st(n){if(!et){et+=1;p||e.limitToList&&!tr(o.val())&&(o.val(""),s&&s.text(""));var t={ChangeHandled:!1,TextOriginal:at,ChangedFromPopup:n};if(e.onChange)e.onChange(wi,t);t.ChangeHandled&&(at=o.val());et-=1}}function pr(n){if(n===undefined)return e.allowBlank;n!=e.allowBlank&&(e.allowBlank=n==!0,rt())}function wr(n){if(n===undefined)return e.blankTip;e.blankTip=n;rt()}function br(n){if(n===undefined)return e.blankTipDescription;e.blankTipDescription=n;rt()}function kr(n){if(n===undefined)return g?g.text():"";g&&g.text(n)}function dr(){return o}function gr(){o.focus();o.select()}function nu(){return s?s.text():""}function gt(n,t){if(t&&n.length==0)return-1;for(var i=0;i<a.length;i++)if(t){if(a[i].substr(0,n.length).toUpperCase()==n.toUpperCase())return i}else if(a[i]==n)return i;return-1}function ni(n){if(n===undefined)return gt(o.val(),!1);n<0||n>a.length-1?bt(""):bt(a[n]);at=o.val()}function ri(n){var t=ni()+n;t<0?t=0:t>a.length-1&&(t=a.length-1);rr(a[t],!1,!0)}function tu(n){if(n===undefined)return e.limitToList;n!=e.limitToList&&(e.limitToList=n==!0)}function tr(n,t){var i;if(t=t?!0:!1,n+="",t){for(n=n.toUpperCase(),i=0;i<a.length;i++)if(a[i].toUpperCase()==n)return!0}else for(i=0;i<a.length;i++)if(a[i]==n)return!0;return!1}function iu(n){c=nt(n);ht="Array";lt=!0}function ru(n){if(n===undefined)return e.maxLength;e.maxLength=n;rt()}function uu(n){if(n===undefined)return e.readOnly;n!=e.readOnly&&(e.readOnly=n==!0,rt())}function fu(n){if(n===undefined)return e.autoReadOnly;n!=e.autoReadOnly&&(e.autoReadOnly=n==!0,rt())}function eu(n,t,i){n!==undefined&&(ht="CodeDescriptionList",c=n,t!==undefined&&(fi=t),i!==undefined&&(di=i),vi())}function ir(n,t,i,r){n!==undefined&&(ht="Collection",c=n,ti=t,ei=i,r?kt=r:(kt=t,i&&(kt+=","+i)),p="",vi())}function ou(t,i,r,u,f,o){var l,h,s;if(t){if(ht="Collection",c=null,ti="",ei="",kt="",p="",yt="",l=!1,t.startsWith("@")?(l=!0,t=t.substr(1)):e.forceDropdown&&(l=!0),!l){if(h=t.toUpperCase(),h.substr(0,8)=="ACCOUNTS"){p=t;yt=i;lt=!0;b();o&&o();return}if(h.substr(0,11)=="ACCOUNTAPPS"){p=t;yt=i;lt=!0;b();o&&o();return}if(h.substr(0,7)=="CLIENTS"){p=t;yt=i;lt=!0;b();o&&o();return}if(h.substr(0,13)=="SECURITYSTMTS"){p=t;yt=i;lt=!0;b();o&&o();return}}pi(!0);s={standardRangeName:t};i&&(s.sqlWhere=i);r&&(s.includeInactive=r);u&&(s.alwaysIncludeId=u);f&&(s.displayColumns=f);n._SystemGetString("GetStandardRange",s,function(n){var r,i,u,e,t;if(n){for(n=JSON.parse(n),r=[],i=0;i<n.Rows.length;i++){for(u={},e=n.Rows[i],t=0;t<n.Columns.length;t++)u[n.Columns[t].Name]=e[t];r.push(u)}ir(r,n.IdColumn,n.DescriptionColumn,f);pi(!1)}o&&o()},function(t){n.RegisterError("widget_ui.DBCombo: Failed to retrieve Standard Range: "+t);o&&o()})}}function su(){return p!=""}function hu(n,t){t||(t="");ht="Unbound";c=t;o.val(n);b();at=n}function pi(n){si=n;rt()}function cu(n){if(n===undefined)return e.showDescription;e.showDescription=n;rt()}function bt(n){if(n===undefined)return vt(o);n!=o.val()&&(et+=1,o.val(n),et-=1,b());at=n}function rr(n,t,i){(n!=o.val()||t)&&(et+=1,o.val(n),et-=1,st(i))}function ur(n){var t=e.width;e.showDescription?s.show():(w.css("width","100%"),s.hide());n||e.maxLength==0||e.maxLength>=50&&!e.showDescription?t="100%":t&&t!="auto"||e.maxLength&&(t=e.maxLength<=4?e.maxLength*.8+2+"em":e.maxLength*.8+"em");o.css({width:t});t!="100%"||e.showDescription?w.css("width",""):w.css("width","100%");s&&e.showDescription&&e.descriptionElement=="auto"&&(w.css("width","100%"),w.css("position","relative"),w.css("display","flex"),w.css("flex-direction","row"),w.css("white-space",""),o.css("flex-grow","0"),o.css("max-width",t),k.css("flex-grow","0"),s.css("flex-grow","1"),s.css("overflow","hidden"),s.css("position","relative"),s.css("height","22px"),s.css("line-height","22px"))}function lu(n){if(n===undefined)return e.visible;e.visible=n;rt()}function au(n){if(!ut&&(ut=o.closest("tr"),ut.length==0))return console.warn("widget_ui.DBCombo.VisibleRow: no parent row element found."),ut=null,!1;if(n===undefined)return ut.css("visibility").toUpperCase()=="HIDDEN";n?(ut.css("display","table-row"),ut.css("visibility","")):(ut.css("display","none"),ut.css("visibility","hidden"))}var dt,wt,wi;if(!r&&n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI&&!(f&&f.forceWidgetControl))return typeof u=="string"&&(u=$("#"+u)),u.attr("is-created","y"),f.widgetDocument=window.document,new window.parent.$UI.DBCombo(u,f);var bi="",ki=!1,k,fi="",di="",c,ht="",ti="",ei="",kt="",s,v,oi=!1,o,ut,si=!1,hi,ii="",et=0,g,a=[],ct=[],lt=!1,h,e,at="",w,it=null,y=null,p="",yt="",ci="",li="",ai=null;if(ComboBoxDefaults={blankTip:"",blankTipDescription:"",captionElement:"auto",cssClass:"is-combobox",descriptionElement:"auto",allowBlank:!0,limitToList:!1,maxLength:10,readOnly:!1,visible:!0,showColumnHeadings:!0,showDescription:!0,autoReadOnly:!0,showDropdown:!0,forceDropdown:!1,width:"auto",onChange:null,usePicker:!1,pickerCaption:""},e=$.extend({},ComboBoxDefaults,f),typeof u=="string"?(dt=u,u=$("#"+dt)):dt=$(u).attr("id"),wt=$(u),wt.length==0){console.warn("widget_ui.DBCombo: Element '"+dt+"' not found.");return}if(o=$(wt[0]),o.attr("is-created","y"),o.wrap("<span style='white-space:nowrap; display:flex; padding:0; margin:0; position:relative;' controlType='dbcombo'/>"),w=$(o.parent()),k=$("<button type='button' tabindex='-1' class='is-combobox-button' style='position:relative;left:1px;top:0'/>"),e.usePicker&&k.addClass("is-picker"),k.insertAfter(o),typeof e.descriptionElement=="string")switch(e.descriptionElement){case"":case"none":break;case"auto":s=$("<label class='is-combobox' style='display:none'><\/label>");s.insertAfter(k);break;default:console.warn("userinterface.DBCombo: options.descriptionElement must be a jQuery element or one of the following: '', 'none', 'auto'.")}else s=e.descriptionElement;if(v=e.showColumnHeadings?new ft(w,{}):new ft(w,{minWidthElement:o}),o.attr("autocomplete","off"),o.attr("spellcheck","false"),wt=$("label[for='"+dt+"']"),g=wt.length==0?null:$(wt[0]),e.width=="auto"&&e.maxLength!=0&&ur(),rt(),o.bind("keydown",function(n){switch(n.keyCode){case 13:v.Visible()&&ot(!0);break;case 27:v.Visible()&&ot(!1);break;case 38:v.Visible()&&(ri(-1),v.Visible()&&tt());break;case 40:v.Visible()?(ri(1),tt()):e.readOnly||yi()}p||b()}),o.bind("blur",function(){p&&b()}),o.bind("keyup",function(n){var r=0,t,i;switch(n.keyCode){case 46:e.limitToList||(r=-1);break;case 8:r=-1;break;default:if(n.keyCode<48)return}o.bind("blur",function(){e.readOnly||nr()&&st(!1)});p||(t=gt(o.val(),!1),v.Visible()&&tt(),t==-1&&e.limitToList&&n.keyCode==46?(rr("",!1,!1),st(!1)):t==-1&&(i=o[0].selectionStart+r,i<0&&(i=0),t=gt(o.val(),!0),t!=-1?(o.val(a[t]),o[0].selectionStart=i,o[0].selectionEnd=1e3,st(!1)):e.limitToList),b())}),k.bind("click",function(){e.readOnly||si||(v.Visible()?ot(!0):yi())}),n.Options.enterMovesToNextField)o.on("keyup",function(n){n.keyCode==13&&d($(this))});return wi={TypeName:"DBCombo",AllowBlank:pr,AutoReadOnly:fu,BlankTip:wr,BlankTipDescription:br,Caption:kr,Changed:nr,DescriptionUpdate:yr,DropdownShow:yi,DropdownShowing:vr,Element:dr,Focus:gr,GetDescription:nu,IsSpecialStandardRange:su,LimitToList:tu,ListExists:tr,ListFromCsvString:iu,ListIndex:ni,MaxLength:ru,ReadOnly:uu,RefreshFromCodeDescriptionList:eu,RefreshFromCollection:ir,RefreshFromStandardRange:ou,RefreshUnbound:hu,SetFetchingData:pi,ShowDescription:cu,Text:bt,Visible:lu,VisibleRow:au,WidthResizeFromParent:ur,WrapperElement:function(){return w}}}function ft(n,t){function l(n){i.append(n)}function a(){return f}function v(){i.children().remove()}function y(){return i}function p(n,t){var l,h,r,c,s;if(e=!0,l=!1,u.popupTip)h=0,r=0,i.css({left:h,top:r});else{var o=f.offset(),h=o.left,r=o.top+f.outerHeight(),a=0,v=!0;n||(n=200);r+=u.offsetTop;a=$(document).innerHeight()-r-4;a>=n?v=!0:o.top>=n?v=!1:(r=$(document).innerHeight()-n-16,r<0&&(r=0),i.css("min-height",n));v?i.css({bottom:"",left:h,top:r-window.pageYOffset+"px","max-height":a,height:""}):(l=!0,c=i.height()+2,s=o.top-c,s<0&&(c+=s,s=0),i.css({left:h,maxHeight:c,height:"100%",bottom:o.top,top:s-window.pageYOffset+"px"}));u.minWidthElement&&i.css({minWidth:u.minWidthElement.outerWidth()});t&&(l||i.css("bottom",0))}i.removeClass("active");i.show();window.setTimeout(function(){i.addClass("active")},10)}function w(){e&&(e=!1,i.hide())}function b(){return e}function k(){return u.closeOnClickOutside}function d(n){if(e){n?i.css("max-width",n+"px"):i.css("max-width","");var t=i.offset(),r=t.left;i.css("width",$("body").innerWidth()-r+"px")}}var f,i,u,e=!1,o,r,s,h,c;if(DropdownPanelDefaults={animate:!0,cssClass:"is-dropdown",offsetTop:0,minWidthElement:null,popupTip:!1,width:"auto",closeOnClickOutside:!0},u=$.extend({},DropdownPanelDefaults,t),typeof n=="string"?(s=n,n=$("#"+s)):s=$(n).attr("id"),h=$(n),h.length==0){console.warn("widget_ui.DropdownPanel: Attached Element '"+s+"' not found.");return}return f=$(h[0]),o=document,r=window,u.popupTip?(i=$("<div style='display:none; position:absolute; z-index:999999999999' class='"+u.cssClass+"' controlType='dropdownPanel'><\/div>"),f.append(i)):(i=$("<div style='display:none; position:fixed; z-index:999999999999' class='"+u.cssClass+"' controlType='dropdownPanel'><\/div>"),f.after(i)),c={TypeName:"DropdownPanel",Append:l,AttachedElement:a,Clear:v,Element:y,Hide:w,Show:p,Visible:b,WidthResizeFromParent:d,CloseOnClickOutside:k},r.__ISDropdownHandler||(r.__ISDropdownHandler=[],$(r).bind("resize scroll",function(){var n,t;if(!ot)for(n=0;n<r.__ISDropdownHandler.length;n++)t=r.__ISDropdownHandler[n],t!=undefined&&t.CloseOnClickOutside()&&t.Hide()}),$(o).bind("click",function(n){for(var t,i=0;i<r.__ISDropdownHandler.length;i++)t=r.__ISDropdownHandler[i],t!=undefined&&t.CloseOnClickOutside()&&(t.AttachedElement()[0]===n.target||t.AttachedElement().has(n.target).length==0&&t.Element().has(n.target).length==0&&t.Hide())}),$(document).bind("focusout focusin",function(){var t,n;switch(o.activeElement.tagName){case"BUTTON":case"INPUT":for(t=0;t<r.__ISDropdownHandler.length;t++)n=r.__ISDropdownHandler[t],n!=undefined&&n.AttachedElement().has(o.activeElement).length==0&&n.Element().has(o.activeElement).length==0&&n.Hide()}})),r.__ISDropdownHandler.push(c),c}function ou(t,i){function a(){var l,o,p,a,i,t,w,s,g,k,h,c,nt,e;if(r.style&&r.cssClass&&u.addClass(r.cssClass),r.style)for(l=$("table.is-form",u),i=0;i<l.length;i++)o=$(l[i]),p=$("col",o),p.length==0&&o.prepend("<colgroup><col style='width:"+r.captionWidth+"'/><col/><\/colgroup>"),$("th[colspan='2'] > label:first-child,th[colspan='3'] > label:first-child,th[colspan='4'] > label:first-child",o).addClass("is-label-heading");for(a=$("input,select,textarea",u),i=0;i<a.length;i++)if(t=$(a[i]),w=$("label[for='"+t.attr("id")+"']"),t.attr("is-created")!="y"){var y=(t.attr("field-type")+"").toUpperCase(),f=(t.attr("type")+"").toUpperCase(),d=t.prop("tagName").toUpperCase();if(d=="SELECT")t.addClass("is-combobox");else if(y=="CURRENCY")f=="NUMBER"?n.RegisterError("widget_ui.Form: Input '"+t.attr("id")+"' has a field-type of 'Currency' but cannot be handled since it also has a type attribute of 'number'. Remove this attribute if you wish to use Widget number handling."):(s=t.attr("blank-if-zero")=="true",r.style&&t.addClass("is-numberbox"),t.blur(function(){$(this).val(n.FormatCurrency(n.ParseCurrency($(this).val()),!1,s))}),t.focus(function(){$(this).val(n.ParseCurrency($(this).val()));$(this).select()}));else if(y=="INTEGER")f=="NUMBER"?n.RegisterError("widget_ui.Form: Input '"+t.attr("id")+"' has a field-type of 'Integer' but cannot be handled since it also has a type attribute of 'number'. Remove this attribute if you wish to use Widget number handling."):(s=t.attr("blank-if-zero")=="true",r.style&&t.addClass("is-numberbox"),t.blur(function(){$(this).val(n.FormatNumber(n.ParseNumber($(this).val(),0),0,!0,s))}),t.focus(function(){$(this).val(n.ParseNumber($(this).val(),0));$(this).select()}));else if(y=="DATE")f=="DATE"?n.RegisterError("widget_ui.Form: Input '"+t.attr("id")+"' has a field-type of 'Date' but cannot be handled since it also has a type attribute of 'date'. Remove this attribute if you wish to use Widget date handling."):(r.style&&t.addClass("is-datebox"),g=n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI?new window.parent.$UI.DateBox(t,{historic:t.attr("historic")=="true",widgetDocument:window.document,usePicker:window.__alwaysUsePickerControls}):new v(t,{historic:t.attr("historic")=="true"}),k=t.attr("placeholder"),k||t.attr("placeholder",n.Options.dateFormatTooltip));else if(f=="FILE")b(t);else if(f=="CHECKBOX")r.style&&(h=t.parent(),c="",h.attr("class")=="is-checkbox"&&(c=$("label",h).text(),$("label",h).remove(),t.unwrap(),t.attr("caption",c)),nt=n.UI.CheckBox(t,{caption:c}));else switch(t.prop("tagName")){case"SELECT":r.style&&t.addClass("is-combobox");break;default:r.style&&t.addClass("is-textbox");r.style&&t[0].outerHTML.indexOf("width:")==-1&&(r.textboxWidth?(t.css("width","100%"),t.css("max-width",r.textboxWidth)):(e=t.attr("maxlength"),e&&(e=parseInt(e),t.css("width","100%"),t.css("max-width",e*.8+"em"))))}t.attr("mandatory")&&(r.style&&t.addClass("is-mandatory"),r.style&&w.addClass("is-mandatory"))}}function y(n,t,i){s=n;f=typeof t=="string"?$("#"+t):t;f.addClass("is-button actions");n&&n.length>0?f.show():f.hide();e||(e=$("<div class='is-form-actions-menu' style='display:none'><\/div>"),$("body").append(e));f.unbind("click.actions");f.bind("click.actions",function(){w(e,s,i)})}function w(t,i,r){var u,f,y,p,b="",k,e,o,s,w,c,l,a,h,v;for(t.children().remove(),e=$("<div class='is-no-select' tabindex='-1'><\/div>"),t.append(e),o=$("<div class='caption'>Actions<\/div>"),s=$("<a><span class='is-symbol-close'><\/span><\/a>"),s.click(function(){t.off("click");t.hide()}),o.append(s),e.append(o),w=$("<div><\/div>"),e.append(w),e.css("border-color",gt),o.css("background-color",gt),c=$("<ul><\/ul>"),w.append(c),l=0;l<i.length;l++)u=i[l],u.enabled===undefined&&(u.enabled=!0),u.visible===undefined&&(u.visible=!0),a=u.visible,!a&&u.repeatInGroupId&&u.repeatInGroupId.toUpperCase()=="[BUTTONSOTHER]"&&u.contextPageId&&u.enabled&&(a=!0),a&&u.groupId.substr(0,1)!="["&&(u.groupId!=b&&(b=u.groupId,f=$("<li class='heading'><\/li>"),f.text(u.groupId),c.append(f),f.css("color",et)),f=$("<li class='action'><\/li>"),h=$("<button><\/button>"),f.append(h),u.enabled||(f.addClass("disabled"),h.attr("disabled","disabled")),u.icon&&(y=$("<img/>"),h.append(y),k=window.innerWidth>=640?n.GetIconUrl(u.icon,32):n.GetIconUrl(u.icon,16),y.attr("src",k)),p=$("<span><\/span>"),p.text(u.caption),h.append(p),c.append(f),u.enabled&&(u.handler?function(n){f.click(function(){t.hide();n.handler()})}(u):function(n){f.click(function(){t.hide();r(n.actionId,n.applicationShortcutUrl?n.applicationShortcutUrl:n.data)})}(u)));!1&&(v=$("<input type='text' placeholder='Type to filter list'/>"),o.append(v),v.bind("keyup",function(n){switch(n.keyCode){case 27:v.val("")}}));t.show();t.on("click",function(n){n.target===this&&s.trigger("click")});e.bind("keyup",function(n){n.keyCode==27&&(n.target.tagName=="INPUT"||s.trigger("click"))});e.focus()}function b(t){var a,i,c,h,u,r,e,f;if(window.FileReader){var o=t.attr("id"),l=t.attr("accept"),s=parseInt(t.attr("max-files"));if(s||(s=1),a=999999,i=$("label[for='"+o+"']"),i.length!=0){for(i=$("label[for='"+o+"']"),i.addClass("is-file-upload"),i.removeClass("is-label-heading"),c=i.text(),h=$("<input id='"+t.attr("id")+"' style='display:none'/>"),h.insertAfter(t),t.remove(),t=h,u=[],t[0].GetFiles=function(){return u},t[0].GetFileName=function(){return u[0].name},r=[],e=0;e<s;e++)f=$("<input type='file' id='"+o+"_"+e+"' style='display:none'/>"),f.attr("accept",l),f.change(function(){var n,i;for(u.length=0,n=0;n<r.length;n++)i=r[n],i.files.length!=0&&u.push(i.files[0]);t.trigger("change")}),f.insertAfter(i),r.push(f[0]);t.change(function(){var h,s,l,a,v,e,t,y,p;for(i.text(""),i.children().remove(),h=$("<h1><\/h1>"),h.click(function(n){n.preventDefault()}),h.html(c),i.append(h),t=0;t<u.length;t++){var f=u[t],w=!1,o="Document",b=f.name.lastIndexOf(".");if(b!=0)switch(f.name.substr(b+1).toUpperCase()){case"BMP":case"GIF":case"JPG":case"JPEG":case"PNG":o="Control_Image";w=!0;break;case"DOC":case"DOCX":o="DocumentType_Word";break;case"XLS":case"XLSX":o="DocumentType_Excel";break;case"PDF":o="DocumentType_PDF"}s=$("<div class='preview'><\/div>");l=$("<img src='"+n.GetIconUrl(o,64)+"' width='64'/>");l.attr("title",f.name);w&&function(n){var t=new FileReader;t.onloadend=function(){n[0].src=t.result};t.readAsDataURL(f)}(l);a=$("<label/>");v=$("<div><button class='is-button small'>Remove<\/button><\/div>"),function(n,t){$("button",v).click(function(){for(var n,i=0;i<r.length;i++)if(n=r[i],n.files.length>0&&n.files[0].name==t){n.value="";$(n).trigger("change");break}})}(t,f.name);a.text(f.name.length>25?f.name.substr(0,25)+"...":f.name);s.append(l);s.append(a);s.append(v);i.append(s)}for(e=null,t=0;t<r.length;t++)if(y=r[t],!y.value){e=$("<label class='addfile'><div><\/div>Add file<\/label>");e.attr("for",y.id);break}e||(p="",p=r.length==1?"Maximum of <b>1<\/b> file selected. Remove to choose a different file.":"Maximum of <b>"+r.length+"<\/b> files selected. Remove to add a different file.",e=$("<label><\/label>"),e.html(p));i.append(e)});t.trigger("change")}}}function k(){return u}function d(){bt=!0;p||(p=$("<div class='is-form-disabled' tabindex='-1' style='position:fixed; left:0; top:0; width:100%; height:100%; z-index:9999999; background-color:black; filter: alpha(opacity=75); opacity:0.75;'>XXXX<\/div>"),p.blur("",function(){bt&&p.focus()}),$("body").append(p));p.show();p.focus()}function g(){bt=!1;p.hide()}function nt(n,t){n&&h.text(n);t&&c.text(t)}function tt(n,t){var u,i,r;for(u in n)i=n[u],i&&i.TypeName&&i.ReadOnly&&(r=!0,i.AutoReadOnly&&!i.AutoReadOnly()&&(r=!1),r&&i.ReadOnly(t))}function it(n){if(n===undefined)return r.visible;r.visible=n;r.visible?(u.css("visibility","visible"),u.show()):u.hide()}var s,f,e,u,h,r,c,l,o;if(FormDefaults={cssClass:"is-widget-form",captionWidth:"9em",style:!0,textboxWidth:"",visible:!0},r=$.extend({},FormDefaults,i),typeof t=="string"?t=$("#"+t):l=$(t).attr("id"),o=$(t),o.length==0){n.RegisterError("widget_ui.Form: Element '"+l+"' not found.");return}return u=$(o[0]),h=$("header > div.header",u),c=$("header > div.summary",u),a(),r.visible?u.show():u.hide(),{TypeName:"Form",Element:k,ActionsDefine:y,FormDisable:d,FormEnable:g,FormReadOnly:tt,RefreshHeading:nt,Visible:it}}function ui(t,i){function fu(n){if(!n.attr("_original")){n.attr("_original","true");var i=n.attr("key")||n.attr("fieldId")||"Column"+ui,t={key:i,thElement:n,original:!0,align:n[0].style.textAlign,allowEdit:n.attr("allow-edit")=="true",caption:n.attr("caption"),drilldownGlyph:n.attr("drilldown-glyph"),selectable:n.attr("selectable")=="true",sortable:n.attr("sortable")=="true",summary:n.attr("summary"),type:n.attr("data-type")||"string",visible:n.attr("visible")!="false",width:n[0].style.width};t.caption||(t.caption=n.text());e.push(t)}}function ku(){var n,t;if(e)for(n=0;n<e.length;n++)t=e[n],t.thElement&&!t.original&&t.thElement.remove();e=[]}function hr(n){return n>=0&&n<e.length?e[n]:null}function yt(n){if(!n)return null;n=n.toUpperCase();for(var t=0;t<e.length;t++)if(n==e[t].key.toUpperCase())return e[t];return null}function du(n){if(!n)return null;n=n.toUpperCase();for(var t=0;t<e.length;t++)if(n==e[t].caption.toUpperCase())return e[t];return null}function eu(n){n=n.toUpperCase();for(var t=0;t<e.length;t++)if(n==e[t].key.toUpperCase())return t;return-1}function gu(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Boolean";i.width||(i.width="1em");e.push(i);it=!0}function nf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Currency";i.width||(i.width="4em");e.push(i);it=!0}function tf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Date";i.width||(i.width="4em");e.push(i);it=!0}function rf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="DateTime";i.width||(i.width="6em");e.push(i);it=!0}function uf(n,t){var i=$.extend({},GridColumnDefaults,t);n||(n="Drilldown");i.key=n;i.type="Drilldown";i.width="20px";i.allowDrilldown=!0;e.push(i);it=!0}function ff(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="HTML";e.push(i);it=!0}function ef(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Icon";i.width||(i.width="16px");e.push(i);it=!0}function sf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Integer";i.width||(i.width="4em");e.push(i);it=!0}function hf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="String";e.push(i);it=!0;i.collection?(i._collection={},i._collection.data=i.collection,i._collection.idColumn=i.idColumn,i._collection.displayColumns=i.columns):i.list&&ou(i)}function ou(t){var i,r;if(t._collection||(t._collection={}),i=t.list+"|"+t.idColumn+"|"+t.displayColumns,dt[i]){r=dt[i];t._collection.data=r.data;t._collection.idColumn=r.idColumn;t._collection.displayColumns=r.displayColumns;t._collection.loaded=!0;return}t._collection={};t._collection.loaded=!1;t._collection.data=[{"List not loaded":""}];t._collection.idColumn="List not loaded";n._SystemGetString("ResolveList",{list:t.list,columns:t.columns,idColumn:t.idColumn},function(n){var u,e,r,o,s,f;for(n=JSON.parse(n),u="",r=0;r<n.Columns.length;r++)n.Columns[r].Name==n.IdColumn||(u&&(u+=","),u+=n.Columns[r].Name);for(e=[],r=0;r<n.Rows.length;r++){for(o={},s=n.Rows[r],f=0;f<n.Columns.length;f++)o[n.Columns[f].Name]=s[f];e.push(o)}t._collection.data=e;t._collection.idColumn=n.IdColumn;t._collection.displayColumns=u;t._collection.loaded=!0;dt[i]={data:e,idColumn:n.IdColumn,displayColumns:u}},function(){n.RegisterError("widget_ui.Grid: Failed to resolve list: "+t.list)})}function cf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Code";e.push(i);it=!0}function lf(){return e.length}function af(n,t){var u,f,i,r;for(t=t?!0:!1,i=0;i<e.length;i++)e[i].visible=!1;if(u=[],n&&n.length!=0)for(i=0;i<n.length;i++)f=n[i],r=t?du(f):yt(f),r?(u.push(r),r.visible=!0):t?console.warn("widget.UI.Grid.SortColumnsByArray: Array contains invalid column caption '"+f+"'."):console.warn("widget.UI.Grid.SortColumnsByArray: Array contains invalid column key '"+f+"'.");for(i=0;i<e.length;i++)r=e[i],u.includes(r)||u.push(r);e=u}function vf(n,t){for(var c,o,f,u,h=n.toUpperCase().split(","),r=-1,i=0;i<e.length;i++){for(c=e[i],o=!1,u=0;u<h.length;u++)if(c.key.toUpperCase()==h[u]){o=!0;r==-1&&(r=i);break}if(!o||i==e.length-1){if(r!=-1||o&&i==e.length-1){for(ht||(ht=$("<tr><\/tr>"),$("thead",s).prepend(ht)),f=$("<th style='text-align:center'><\/th>"),f.text(t),f.attr("colspan",i-r),ht.append(f),e[r].thElementMerged=f,u=r;u<i;u++)e[u].merged=!0;o&&i==e.length-1&&(e[i].merged=!0,r!=-1&&f.attr("colspan",i-r+1))}r=-1}}it=!0}function vi(t){var si=0,bt=null,h,vi,gi,tr,p,w,hi,ci,er,ir,dt,l,rt,gt,li,k,ii,ui,u,st,lt,fi,rr,ai,at,ur,oi,i;if(t||!iu){if(iu=!0,r.docked?v.addClass("docked"):v.removeClass("docked"),r.stickyHeader?ct?v.addClass("is-sticky-header"):v.addClass("is-legacy-sticky-header"):(v.removeClass("is-sticky-header"),v.removeClass("is-legacy-sticky-header")),s.addClass(r.cssClass),r.style){s.addClass(r.style);switch(r.style.toUpperCase()){case"REPORT":break;default:console.warn("widget.UI.Grid: Invalid grid style '"+r.style+"'. Supported styles are: report")}}if(kt||(kt=$("<div class='is-grid-caption invalid'><span>xxxxx<\/span><\/div>"),v.append(kt)),kt.hide(),!ft){ft=$("<div class='is-grid-caption'><span><\/span><div class='close is-symbol-close'><\/div><\/div>");ki=$("span",ft);ki.text(wt);tu=$(".close",ft);v.append(ft);tu.on("click",function(n){ft.slideUp("fast");n.stopPropagation()});ft.on("click",ee)}if(ut||(ut=$("<div class='is-grid-buttons'><\/div>"),v.append(ut)),h=$("thead > tr",s),h.length>1&&(h=$(h[h.length-1])),h.length==0&&(vi=$("<thead><\/thead>"),h=$("<tr><\/tr>"),vi.append(h),s.append(vi)),(r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors)&&!di&&$("th.rowselector",h).length==0&&(gi=$("<th class='rowselector'><\/th>"),h.prepend(gi),r.allowMultiRowSelect&&(tr=$("<input type='checkbox'/>"),gi.append(tr),di=new n.UI.CheckBox(tr,{onChange:function(n){pu(n.Value(),!0)}}))),et=!1,d=!1,vt=!1,!g){g=$("<div style='display:none; position:absolute;' class='grid-cell-editor'><\/div>");g.off("focusout");g.on("focusout",function(){d&&window.setTimeout(function(){vt&&(!vt||g.dbcombo.DropdownShowing())||a(!1)},100)});ri.append(g);o={};p=$("<input/>");g.append(p);o.textbox=n.UI.TextBox(p,{onChange:function(){a(!1)}});o.textbox.Element().css({"background-color":"white",position:"absolute",left:0,top:0,right:0,bottom:0,width:"100%",height:"100%"});o.textbox.Element().on("keydown",function(n){switch(n.keyCode){case 9:return n.shiftKey?(a(!1),ti()):(a(!1),ni()),!1}});o.textbox.Element().on("keyup",function(n){switch(n.keyCode){case 13:return a(!1),!1;case 27:return a(!0),!1;case 38:return a(!1),wr(),!1;case 40:return a(!1),pr(!0),!1}});p=$("<input/>");g.append(p);o.listbox=n.UI.ComboBox(p,{forceWidgetControl:!0,createdForGrid:!0,width:"100%"});o.listbox.Element().css({"background-color":"white"});o.listbox.Element().on("keydown",function(n){switch(n.keyCode){case 9:return n.shiftKey?(a(!1),ti()):(a(!1),ni()),!1}});o.listbox.Element().on("keyup",function(n){switch(n.keyCode){case 13:return a(!1),!1;case 27:return a(!0),!1}});p=$("<input/>");g.append(p);o.dbcombo=n.UI.DBCombo(p,{forceWidgetControl:!0,createdForGrid:!0,showDescription:!1,width:"100%"});o.dbcombo.Element().css({"background-color":"white"});o.dbcombo.Element().on("keydown",function(n){switch(n.keyCode){case 9:return n.shiftKey?(a(!1),ti()):(a(!1),ni()),!1}});o.dbcombo.Element().on("keyup",function(n){switch(n.keyCode){case 13:return a(!1),!1;case 27:return a(!0),!1}});p=$("<input/>");g.append(p);o.numberbox=n.UI.NumberBox(p,{onChange:function(){a(!1)}});o.numberbox.Element().css({"background-color":"white"});o.numberbox.Element().on("keydown",function(n){switch(n.keyCode){case 9:return n.shiftKey?(a(!1),ti()):(a(!1),ni()),!1}});o.numberbox.Element().on("keyup",function(n){switch(n.keyCode){case 13:return a(!1),!1;case 27:return a(!0),!1;case 38:return a(!1),wr(),!1;case 40:return a(!1),pr(!0),!1}})}for(r.allowAddRows&&!r.readOnly?v.addClass("has-add-row"):v.removeClass("has-add-row"),u=0;u<e.length;u++)i=e[u],i.allowEdit&&(et=!0),i.thElement||(w=$("<th><\/th>"),w.attr("key",i.key),h.append(w),i.thElement=w,i.captionIcon?(w.html("<img src='"+n.GetIconUrl(i.captionIcon,16)+"' style='vertical-align:middle'/>"),i.caption&&$("img",w).attr("title",i.caption)):i.caption&&(i.caption.substr(0,6).toUpperCase()=="<HTML>"?w.html(i.caption.substr(6)):w.text(i.caption)),i.width&&w.css("width",i.width),w.addClass("is-grid-col-"+i.type.toLowerCase()),i.autoHideWidth!=0&&(mHasAutoHideColumns=!0),i.align&&w.css("text-align",i.align),h.append(w)),r.showColumnHeaders||h.hide(),ar(i,i.thElement,""),i.thElement.off("click"),i.thElement.removeClass("sortable selectable"),i.selectable&&(i.thElement.addClass("selectable"),function(n){n.thElement.click(function(){kr(n.key)})}(i)),i.sortable&&(i.thElement.addClass("sortable"),i.sorterElement||(i.sorterElement=$("<div class='sorter'><\/div>"),i.thElement.append(i.sorterElement),function(n){n.sorterElement.click(function(t){return dr(n.key),t.preventDefault(),!1})}(i)));if(ht)for(hi=$("thead > tr:last-child",s),ci=$("th.rowselector",hi),ci.length!=0&&(ci.attr("rowspan",2),$("th.rowselector",ht).length==0&&ht.prepend(ci)),u=0;u<e.length;u++)l=e[u],l.thElementMerged?(ht.append(l.thElementMerged),hi.append(l.thElement)):l.merged?hi.append(l.thElement):(l.thElement.attr("rowspan",2),ht.append(l.thElement));b=$("tbody",s);b.length==0&&(b=$("<tbody><\/tbody"),s.append(b))}for(er=$("thead > tr > th",s),er.removeClass("sorted sorted-desc selected"),r.sortByColumn&&(ir=$("thead > tr > th[key='"+r.sortByColumn+"']",s),ir.addClass("sorted"),r.sortByDesc&&ir.addClass("sorted-desc")),y=[],tt=null,b.children().remove(),dt=!1,u=0;u<e.length;u++)if(l=e[u],l.summary)switch(l.summary.toUpperCase()){case"":break;case"COUNT":case"CUSTOM":case"SUM":case"$SUM":dt=!0;break;default:window.alert("widget.UI.Grid: Invalid column summary type '"+l.summary+"'. Supported types are: count, sum, $sum, custom");console.warn("widget.UI.Grid: Invalid column summary type '"+l.summary+"'. Supported types are: count, sum, $sum, custom")}if(c){for(rt=[],gt=0,r.sortByColumn||r.groupByColumns&&r.groupByDesc?(r.groupByColumns?(li=r.groupByColumns,r.groupByDesc&&(li="-"+li),k=r.sortByColumn,r.sortByDesc&&(k="-"+k),f.sort(su([li,k]))):(k=r.sortByColumn,r.sortByDesc&&(k="-"+k),f.sort(su([k]))),nr=!0):nr&&(nr=!1,br(c,!0,{},!0)),ii=0,u=0;u<f.length;u++)if(st=f[u],st){if(r.groupByColumns&&(lt=st.cells[r.groupByColumns].sortValue||st.cells[r.groupByColumns].value,(lt===undefined||lt===null)&&(lt="(none)"),(bt===null||bt!=lt)&&(dt&&bt!=null&&(rt.push(cr(f,ii,u-1,r.groupByColumns)),ii=u),gt+=1,ui=$("<tr listIndex='-1' class='group-header'><\/tr>"),fi=$("<td><\/td>"),rr=e.length,(r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors)&&(rr+=1),fi.attr("colspan",rr),fi.text(lt),ai=$("<div group-index='"+gt+"'><\/div>"),r.groupingsCollapsed&&ai.addClass("collapsed"),fi.append(ai),function(n,t){n.click(function(){var n=t.attr("group-index");t.hasClass("collapsed")?(t.removeClass("collapsed"),$("tr[group-index='"+n+"']",b).removeClass("group-collapsed")):(t.addClass("collapsed"),$("tr[group-index='"+n+"']",b).addClass("group-collapsed"));nt&&wi()})}(ui,ai),st.hidden&&ui.addClass("hidden"),ui.append(fi),rt.push(ui),bt=lt)),at=$("<tr listIndex='"+st.listIndex+"' class='datarow'><\/tr>"),y.push(at),gt!=0&&(at.attr("group-index",gt),r.groupingsCollapsed&&at.addClass("group-collapsed")),lr(u,at),u==0&&!r.showColumnHeaders&&(ur=$("td,th",at),ur.length==e.length))for(oi=0;oi<e.length;oi++)i=e[oi],i.width&&$(ur[oi]).css("width",i.width);st.hidden&&(si+=1);rt.push(at)}dt&&bt!=null&&(rt.push(cr(f,ii,f.length-1,r.groupByColumns)),ii=u);dt&&rt.push(cr(f,0,f.length-1,""));b.append(rt);r.allowAddRows&&!r.readOnly&&(ot=$("<tr listIndex='-1' class='templaterow'><\/tr>"),lr(-1,ot),b.append(ot),ot.bind("click",function(n){if(d&&a(!1),bi(!0)){var t=yt($(n.target).attr("key")),i=-1;t&&(i=eu(t.key));pt(i)}else console.warn("Maximum new grid rows limit reached.")}));bf()}r.stickyHeader&&r.showColumnHeaders&&yf();r.showContextMenu&&fr($("*",v),function(n){var t=$(n.delegateTarget).closest("tr").attr("listIndex"),u,i;t!==undefined&&ei(t);try{if(u=$(this).attr("href"),u.toUpperCase().indexOf("APP://FORMSHOW?")>-1)return n.preventDefault(),!1}catch(n){}if(i={contextMenuEventArgs:n,row:{listIndex:t}},r.onContextMenuShow)r.onContextMenuShow(n,i);else pf(n,i);return n.preventDefault(),!1});r.selectedColumnKey&&kr(r.selectedColumnKey);si!=0&&r.showHiddenRowsPopup?(wt=si==1?"1 row is hidden":si+" rows are hidden",wt+=". Click to show.",ki.text(wt)):wt="";wt?ft.show():ft.hide();pi();yi(!1,!0);it=!1}function yf(){ct}function pf(n){ii||(ii=new of(s,{}));ii.OnAction(wf);var t=[];r.sortByColumn&&t.push({ItemId:"SortClear",Caption:"Clear Sorting",Icon:"Sort_Ascending|Clear"});t.push({ItemType:"SubMenu",Caption:"Export Grid"});t.push({ItemId:"Export_MSEXCELWORKBOOK",Caption:"MS Excel",Icon:"Application_Excel"});t.push({ItemId:"Export_CSV",Caption:"CSV",Icon:"Export_Csv"});t.push({ItemId:"Export_PDF",Caption:"PDF",Icon:"DocumentType_PDF"});t.push({ItemId:"Export_HTML",Caption:"HTML",Icon:"Control_Html"});ii.Define(t);t.length!=0&&ii.Show(n.clientX,n.clientY)}function wf(n){switch(n){case"Export_CSV":oi("CSV");break;case"Export_HTML":oi("HtmlTable");break;case"Export_MSEXCELWORKBOOK":oi("MSEXCELWORKBOOK");break;case"Export_PDF":oi("PDF");break;case"SortClear":dr("",!1)}}function bf(){s.off("click","a.is-drilldown, a.is-drilldown-button");s.on("click","a.is-drilldown, a.is-drilldown-button",function(n){var o=$(n.target).closest("tr.datarow"),s=$(n.target).closest("td"),t=o.attr("listIndex"),i=s.index(),u;(r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors)&&(i-=1);u=e[i].key;f&&t>=0&&t<f.length&&yr(t,u)});b.off("click","tr.datarow");b.on("click","tr.datarow",function(n){var f=$(n.target).closest("tr.datarow"),e=$(n.target).closest("td"),s=f.attr("listIndex"),o,i,t,u;if(!r.showRowSelectors||!n||!n.target||!$(n.target).closest("td").hasClass("rowselector")){for(d&&a(!1),o=e.hasClass("is-sel"),i=0;i<y.length;i++)if(y[i][0]==f[0]){w(i);break}t=yt(e.attr("key"));u=-1;t&&(u=eu(t.key));pt(u);et&&t&&o&&(t.allowEdit&&t.type.toUpperCase()!="BOOLEAN"?a(!1)&&gt():a(!1))}});if(!et){b.off("dblclick","tr.datarow");b.on("dblclick","tr.datarow",function(n){var i=$(n.target).closest("tr.datarow"),t=i.attr("listIndex");f&&t>=0&&t<f.length&&yr(t,"");r.onRowDrilldown&&window.getSelection&&window.getSelection().removeAllRanges()})}}function gt(){var t,i,e,n,o;if(!r.readOnly){if(d&&a(),t=hr(p),!t||!t.allowEdit)return!1;if(i=f[u],e=i.cells[rt],!i.readOnly&&!e.readOnly&&!e.notApplicable){i.newRow&&(i.newRow=!1);n={};switch(t.type.toUpperCase()){case"BOOLEAN":return;case"CURRENCY":n.type="numberbox";n.decimals=-1;break;case"DATE":n.type="datebox";n.historic=!1;break;case"INTEGER":n.type="numberbox";n.decimals=0;break;case"STRING":case"CODE":t.listCsv?(n.type="listbox",n.canLimitToList=!0,n.limitToList=t.limitToList?!0:!1,n.listCsv=t.listCsv,n.collection=null,n.standardRange=null):t.collection?(n.type="dbcombo",n.canLimitToList=!0,n.limitToList=t.limitToList?!0:!1,n.collection=t._collection,n.standardRange=null):t.list?(n.type="dbcombo",n.canLimitToList=t._collection.loaded,n.limitToList=t.limitToList?!0:!1,n.collection=t._collection):t.standardRange?(n.type="dbcombo",n.includeInactive=t.includeInactive?!0:!1,n.limitToList=t.limitToList?!0:!1,n.standardRange=t.standardRange,n.sqlWhere=t.sqlWhere,n.displayColumns=t.displayColumns):n.type="textbox";n.maxLength=t.maxLength?t.maxLength:0;break;default:window.alert("No default editor defined for column type '"+t.type+"'.")}if(r.onBeforeCellEdit){o={row:{listIndex:u},columnKey:rt,cancel:!1,editorInfo:n};r.onBeforeCellEdit(o);if(o.cancel)return!1}return d=!0,h=n,n.valueOriginal=e.value,yi(!0),!0}}}function a(n){if(!d)return!0;if(n)return d=!1,vt=!1,yi(),!0;d=!1;vt=!1;var t;switch(h.type.toUpperCase()){case"DATEBOX":t=lt(o.textbox.Text(),h.historic,!0);break;case"DBCOMBO":t=o.dbcombo.Text();h.canLimitToList&&(o.dbcombo.ListExists(t)||(t=""));break;case"LISTBOX":t=o.listbox.Text();break;case"NUMBERBOX":t=o.numberbox.Value();break;case"TEXTBOX":t=o.textbox.Text();break;default:window.alert("No editor handled for exiting edit mode for editorInfo type '"+h.type+"'.");t=undefined}return t===undefined?window.alert("cannot update!"):vr(u,rt,t,!0),yi(!1),!0}function yi(n,t){var e,c,r,f,i;if(u<0||u>y.length-1?(d=!1,vt=!1):et&&p!=-1&&u!=-1||(d=!1,vt=!1),d||(bt=null,g.hide()),!d){t||(e=ri.scrollTop(),s.focus(),ri.scrollTop(e));return}if(c=y[u],r=$("td[key='"+rt+"']",c),bt=r.length==1?r:null,bt){if(f=bt.position(),g.css({left:f.left+"px",top:f.top+"px",height:bt.outerHeight()+"px",width:bt.outerWidth()+"px"}),g.show(),n){o.dbcombo.Visible(!1);o.listbox.Visible(!1);o.numberbox.Visible(!1);o.textbox.Visible(!1);switch(h.type.toUpperCase()){case"DATEBOX":o.textbox.Visible(!0);typeof h.valueOriginal=="string"&&(h.valueOriginal=at(h.valueOriginal));h.valueOriginal||(h.valueOriginal=null);o.textbox.Text(l(h.valueOriginal,!1,!0));o.textbox.Element().css("text-align","right");o.textbox.Focus();break;case"DBCOMBO":o.dbcombo.Visible(!0);o.dbcombo.Element().css({height:g.innerHeight()+"px",backgroundColor:"white !important",border:"none",borderRadius:0});h.valueOriginal||(h.valueOriginal="");o.dbcombo.Text(h.valueOriginal);o.dbcombo.LimitToList(h.limitToList);h.standardRange?o.dbcombo.RefreshFromStandardRange(h.standardRange,h.sqlWhere,h.includeInactive,"",h.displayColumns):o.dbcombo.RefreshFromCollection(h.collection.data,h.collection.idColumn,h.collection.displayColumns);o.dbcombo.Focus();o.dbcombo.IsSpecialStandardRange()?vt=!0:window.setTimeout(function(){o.dbcombo.DropdownShow()},10);break;case"LISTBOX":o.listbox.Visible(!0);o.listbox.Element().css({height:g.innerHeight()+"px",backgroundColor:"white !important",border:"none",borderRadius:0});h.valueOriginal||(h.valueOriginal="");o.listbox.Text(h.valueOriginal);o.listbox.LimitToList(h.limitToList);o.listbox.ListFromCsvString(h.listCsv);o.listbox.Focus();window.setTimeout(function(){o.listbox.DropdownShow()},10);break;case"NUMBERBOX":o.numberbox.Visible(!0);h.valueOriginal||(h.valueOriginal=0);o.numberbox.Value(h.valueOriginal);o.numberbox.Focus();break;case"TEXTBOX":o.textbox.Visible(!0);o.textbox.MaxLength(h.maxLength);h.valueOriginal||(h.valueOriginal="");o.textbox.Text(h.valueOriginal);i=yt(rt);i&&i.align?o.textbox.Element().css("text-align",i.align):o.textbox.Element().css("text-align","left");o.textbox.Focus();break;default:window.alert("No editor defined for editorInfo type '"+h.type+"'.")}}}else s.focus(),g.hide()}function pi(){var i,r,e,s=!1,u,h,o,t,f;if(ut){for(ut.children().remove(),i=$("<ul><\/ul>"),ut.append(i),i.addClass("group"),u=null,h=!1,o=0;o<si.Actions().length;o++)if(t=si.Actions()[o],t.actionId)if(t.visible){if(s=!0,e=$("<li><button class='is-button'><\/button><\/li>"),i.append(e),r=$("button",e),u||(u=e),s=!0,t.caption&&r.text(t.caption),t.tooltipText&&r.attr("title",t.tooltipText),t.enabled||r.attr("disabled","disabled"),t.icon&&(f=n.GetIconUrl(t.icon,16),f&&(f=f.replace(/\\/g,"/"),r.css({backgroundImage:"url("+f+")"})),r.addClass("icon")),t.checked&&r.addClass("checked"),t.buttonStyle)r.addClass(t.buttonStyle);else switch(t.actionId.toUpperCase()){default:r.addClass("normal")}t.handler?function(n){r.click(function(){n.handler()})}(t):function(n){r.click(function(){df(n.actionId)})}(t)}else u&&(h=!0,u=null,i.addClass("group"),i=$("<ul><\/ul>"),i.addClass("group"),ut.append(i));else u&&(h=!0,u=null,i.addClass("group"),i=$("<ul><\/ul>"),i.addClass("group"),ut.append(i));s?ut.show():ut.hide()}}function kf(){return si}function df(n){if(r.onAction)r.onAction(n);else window.alert("widget.UI.Grid.ExecuteAction: No OnAction defined for this Grid object.")}function wi(){var e=v.offset(),o=v.outerWidth(),a=v.innerWidth(),h=v.outerHeight(),c=ri.scrollLeft(),t=v.scrollTop(),l=s.outerWidth(),i,r,n,u,f;if(nt)for(nt.css({width:l+"px"}),nt.css({"margin-left":-c+"px"}),bu.css("top",t+"px"),t!=ru&&k&&(ru=t,nt.hide(),window.setTimeout(function(){nt.fadeIn("fast")},500)),i=$("thead > tr > th",s),r=$("thead > tr > th",nt),n=0;n<i.length;n++)u=$(i[n]),f=$(r[n]),f.css("width",u.outerWidth()+"px");tr&&(tr.css({width:o+"px",top:h+e.top+"px"}),v.css({"margin-bottom":"36px"}))}function cr(t,i,u,f){var c=$("<tr class='footer'><\/tr>"),w,h,o,s,l,v,y,a,b,p;if((r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors)&&c.append("<td><\/td>"),f?c.addClass("is-row-footer"):c.addClass("is-row-footer-bold"),r.onFooterCellFormat)for(w=[],h=i;h<=u;h++)w.push(t[h].listIndex);for(h=0;h<e.length;h++)if(o=e[h],o.visible){if(s=$("<td><\/td>"),s.attr("key",o.key),ar(o,s,""),o.summary){switch(o.summary.toUpperCase()){case"COUNT":s.text(n.FormatNumber(u-i+1,0,!0));break;case"SUM":case"$SUM":for(l=0,v=i;v<=u;v++)y=t[v].cells[o.key],y&&y.value&&(l+=parseFloat(y.value));a=""+l;switch(o.type.toUpperCase()){case"CURRENCY":a=n.FormatCurrency(l,o.summary.substr(0,1)=="$");break;case"INTEGER":a=n.FormatCurrency(l,o.summary.substr(0,1)=="$");a=n.FormatNumber(l,0,!0)}s.text(a);break;default:s.html("&nbsp;")}if(r.onFooterCellFormat){b=s.text();p={key:o.key,listIndexes:w,cell:s,cellText:b,row:c};try{r.onFooterCellFormat(p)}catch(k){console.warn("widget.UI.Grid: Error calling onFooterCellFormat: "+k)}p.cellText!=b&&s.text(p.cellText)}}c.append(s)}return c}function su(n){return function(t,i){return n.map(function(n){var f=1,r,u;return(n[0]=="-"&&(f=-1,n=n.substring(1)),r=t.cells[n].sortValue||t.cells[n].value,u=i.cells[n].sortValue||i.cells[n].value,(r===undefined||r===null)&&(r=""),(u===undefined||u===null)&&(u=""),typeof r=="string"&&(r=r.toUpperCase()),typeof u=="string"&&(u=u.toUpperCase()),r>u)?f:r<u?-f:0}).reduce(function(n,t){return n?n:t},0)}}function lr(t,i,u){var l,v,d,g,y,c,h,o,p,b,nt,a,tt,k;for(u&&(i.children().remove(),i.removeClass("hidden inactive strike special1 expired selected row-selected invalid readonly new"),i.attr("style","")),l=t==-1?{}:f[t],(r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors)&&(v=$("<td class='rowselector is-no-select'><\/td>"),r.allowMultiRowSelect&&t!=-1&&(d=l.rowSelectorCheckBox&&l.rowSelectorCheckBox.Value(),g=$("<input type='checkbox'/>"),v.append(g),l.rowSelectorCheckBox=new n.UI.CheckBox(g,{onChange:function(){if(l.rowSelectorCheckBox.Value()?i.addClass("row-selected"):i.removeClass("row-selected"),r.onSelectedRowsChanged)r.onSelectedRowsChanged({})}}),l.rowSelectorCheckBox.Value(d),d&&i.addClass("row-selected")),r.rowNumbering&&t!=-1&&v.append("<span class='rownumber'>"+(t+1)+"<\/span>"),t==-1&&v.append("<span class='templaterow'><\/span>"),i.append(v)),l&&l.invalid&&i.addClass("invalid"),l&&(l.newRow==!0||l.newRow==!1)&&i.addClass("new"),y=0;y<e.length;y++)if(c=e[y],!0){if(h=$("<td><\/td>"),h.attr("key",c.key),ar(c,h,""),c.align&&h.css("text-align",c.align),c.colour&&h.css("color",c.colour),c.noLineBreak&&h.addClass("nobreak"),!r.showColumnHeaders)switch(c.type){case"Drilldown":c.width&&h.css("width",c.width)}if(o=t==-1?{value:null}:l.cells[c.key],o.notApplicable&&(o.value=null),p=!1,o.value==null){p=!0;switch(c.type.toUpperCase()){case"BOOLEAN":p=t==-1?!0:!c.allowEdit;break;case"DRILLDOWN":p=t==-1?!0:!1}}if(o)if(p)t==-1&&h.html("&nbsp;");else{h.addClass("is-grid-col-"+c.type.toLowerCase());switch(c.type.toUpperCase()){case"BOOLEAN":!c.allowEdit||r.readOnly||o.readOnly||o.notApplicable?o.value?h.addClass("is-grid-col-boolean-true is-symbol-tick"):(h.addClass("is-grid-col-boolean-false"),c.showCross&&h.addClass("is-symbol-cross")):(b=$("<input type='checkbox' class='is-grid-checkbox'/>"),b.prop("checked",o.value),function(n,t,i){t.click(function(){var r=b.closest("tr").attr("listIndex");w(r);pt(i);vr(r,n,t.prop("checked"));s.focus()})}(c.key,b,y),h.append(b));break;case"CURRENCY":o.value==null||o.value==0&&c.blankIfZero?h.text(""):typeof o.value=="string"?h.text(o.value):h.text(n.FormatCurrency(o.value));break;case"DATE":o.value&&h.text(n.FormatDateForGrid(o.value));break;case"DATETIME":o.value&&h.text(n.FormatDateForGrid(o.value,!0,c.longTime));break;case"DRILLDOWN":!o.value&&c.drilldownHideIfBlank||(h.html("<a class='is-drilldown-button'><\/a>"),c.drilldownGlyph?$("a",h).addClass(c.drilldownGlyph):c.icon&&(nt=$("a",h),a=n.GetIconUrl(c.icon,16),nt.addClass("icon"),nt.append("<img src='"+a+"' style='width:16px'/>")));break;case"HTML":o.value==null?h.text(""):h.html(o.value);break;case"ICON":o.value&&(a=o.value,a.indexOf("/")==-1&&(tt="",k=a.indexOf("|"),k!=-1&&(tt=a.substr(k+1),a=a.substr(0,k)),a=n.GetIconUrl(a,16,tt)),h.html("<img src='"+a+"' style='width:16px'/>"));break;case"INTEGER":o.value==null||o.value==0&&c.blankIfZero?h.text(""):h.text(n.FormatNumber(o.value,0,!0));break;default:c.truncate?(h.html("<div style='display:table;table-layout:fixed;width:100%'><div style='overflow-x:hidden;text-overflow:ellipsis;white-space:nowrap'>"+n.UI.HtmlEncode(o.value)+"<\/div><\/div>"),h.attr("title",o.value)):h.html(n.UI.HtmlEncode(o.value))}o.hyperlink&&h.wrapInner('<a href="'+o.hyperlink+'"><\/a>');o.backgroundColour&&h.css("background-color",o.backgroundColour);o.bold&&h.css({"font-weight":"bold"});o.colour&&h.css("color",o.colour);o.small&&h.addClass("small");o.strike&&h.addClass("strike");o.value&&o.value.eventId&&(h.text(""),function(t,i,r){n.GetString(o.value.eventId,r,function(n){t.text(n)},function(n){t.text("#ERR");console.warn("Error from grid callback: "+n)})}(h,o.value.eventId,o.value.params||{}))}else{window.alert("Invalid column key '"+c.key+"'");break}o.notApplicable&&h.addClass("notapplicable");(l.readOnly||o&&(o.readOnly||o.notApplicable))&&(h.addClass("readonly"),h.removeClass("editable"));c.allowDrilldown&&c.type!="Drilldown"&&h.wrapInner("<a class='is-drilldown'><\/a>");o.tooltipText&&h.attr("title",o.tooltipText);i.append(h)}l.cssClass&&i.addClass(l.cssClass);l.backgroundColour&&i.css({"background-color":l.backgroundColour});l.bold&&i.css({"font-weight":"bold"});l.colour&&i.css({color:l.colour});l.hidden&&i.addClass("hidden");l.inactive&&i.addClass("inactive");l.readOnly&&i.addClass("readonly");l.strike&&i.addClass("strike")}function ar(t,i){if(t.allowEdit?i.addClass("editable"):i.removeClass("editable"),!t.align)switch(t.type.toUpperCase()){case"BOOLEAN":case"ICON":i.css("text-align","center");break;case"CURRENCY":case"DATE":case"INTEGER":i.css("text-align","right");break;case"DATETIME":i.css({"text-align":"right","white-space":"nowrap"})}if(!t.width)switch(t.type.toUpperCase()){case"BOOLEAN":i.css("width","16px");break;case"CODE":i.css("width","8em");break;case"CURRENCY":i.css("width","8em");break;case"DATE":i.css("width","6em");break;case"INTEGER":i.css("width","4em")}if(t.type.toUpperCase()=="CODE"&&i.attr("data-type","code"),t.visible?i.css({display:"",visibility:""}):i.css({display:"none",visibility:"hidden"}),t.tooltipText&&i.prop("tagName")=="TH"){var r=$("label.is-tooltip",i);r.length==0&&(r=$("<label class='is-tooltip'>&nbsp;<\/label>"),i.append(r),r.click(function(){n.UI.MsgBoxInfo(t.tooltipText)}))}}function vr(n,t,i,u){if(r.onBeforeCellUpdate){var o=f[n],s=o.cells[t],e={row:{listIndex:o.listIndex},columnKey:t,oldValue:s.value,newValue:i,refreshRow:!1,cancel:!1};try{r.onBeforeCellUpdate(e)}catch(h){window.alert(h)}e.cancel||(s.value=i);(e.refreshRow||e.cancel||u)&&vu(o.listIndex);nt&&wi()}}function yr(n,t){if(r.onRowDrilldown){n===undefined&&(n=u);var i={row:{listIndex:n},columnKey:t};r.onRowDrilldown(i)}}function pt(n){var i,t;if(n===undefined)return p;n=parseInt(n);i=p;tt&&$("td",tt).removeClass("is-sel");n>=0&&n<e.length?(p=n,t=rt=hr(p),rt=t?t.key:"",r.allowCellSelect&&$("td[key='"+rt+"']",tt).addClass("is-sel")):(p=-1,rt="")}function w(n,t){var i,f;if(n===undefined)return u;if(n=parseInt(n),i=u,tt&&(tt.removeClass("is-sel"),$("td",tt).removeClass("is-sel"),tt=null),n>=0&&n<y.length?(u=n,tt=y[u],tt.addClass("is-sel"),tt.removeClass("hidden"),cu()):u=-1,p!=-1&&pt(p),st(),r.onAfterRowActivate&&u!=i&&!t){f={row:{listIndex:ei()}};r.onAfterRowActivate(f)}}function ei(n,t){if(n===undefined)return u==-1||!f||u>=f.length?-1:f[u].listIndex;u==-1;for(var i=0;i<f.length;i++)if(f[i].listIndex==n){w(i,t);break}}function gf(n){var i,t;if((u==-1||!n)&&c){for(i=-1,t=0;t<c.length;t--)if(!f[t].hidden){i=t;break}i!=-1&&w(i)}}function hu(n){var i,t;if((u==-1||!n)&&c){for(i=-1,t=c.length-1;t>=0;t--)if(!f[t].hidden){i=t;break}i!=-1&&w(i)}}function ne(){if(f&&u>0){var t=s.height(),i=s.scrollTop,n=u;n-=10;n<0&&(n=0);w(n);st(!0)}}function te(){if(f&&u<f.length-1){var t=s.height(),i=s.scrollTop,n=u;n+=10;n>f.length-1&&(n=f.length-1);w(n);st(!0)}}function ni(){var t,n;if(f&&p<e.length-1){for(t=p,n=p+1;n<e.length;n++)if(e[n].visible){t=n;break}pt(t)}}function pr(n){var i,t;if(n&&r.allowAddRows&&!r.readOnly&&f&&u==f.length-1&&bi(!0),f&&u<f.length-1){for(i=u,t=u+1;t<f.length;t++)if(f[t]!=null&&(gi||!f[t].hidden)){i=t;break}w(i);st(!0)}}function ti(){var t,n;if(f&&p>0){for(t=p,n=p-1;n>=0;n--)if(e[n].visible){t=n;break}pt(t)}}function wr(){var t,n;if(f&&u>0){for(t=u,n=u-1;n>=0;n--)if(f[n]!=null&&(gi||!f[n].hidden)){t=n;break}w(t);st(!0)}}function st(n,t){if(n===undefined&&(n=!1),r.visible){var i=tt;ot&&f&&u==f.length-1&&(i=ot);i&&(t||(t=0),r.stickyHeader&&nt&&(t=nt.outerHeight()),i.ScrollElementIntoView(n,n,{inViewAmount:t}))}}function bi(n){var t,u,i,e;if(hi>=r.maxNewRows)return!1;if(r.sortByColumn||r.groupByColumns)return window.alert("Sorted or grouped grid do not support adding new rows."),!1;if(hi+=1,r.onRowAdd){t=c.length;u={cancel:!1};r.onRowAdd(u);if(u.cancel)return!1;if(c.length<=t)return window.alert("Grid's onRowAdd handler did not add a new item to the collection this grid is bound to."),!1;if(c.length!=t+1)return window.alert("Grid's onRowAdd handler added multiple rows to the collection this grid is bound to. It should only add a single item."),!1;i=$("<tr listIndex='"+t+"' class='datarow'><\/tr>");y.push(i);ot?i.insertBefore(ot):b.append(i);e=lu(t);e.newRow=!0;f.push(e);yu(t,t);n&&hu(!1);(nt||tr)&&wi()}else return window.alert("Grid does not handle onRowAdd."),!1;return!0}function cu(){var t="",n;u>=0&&u<f.length&&(n=f[u],n.invalid&&n.invalidMessage&&(t=n.invalidMessage));t?(kt.text(t),kt.show()):kt.hide();ot?st(!1,ot.outerHeight()):st()}function lu(n){for(var i,r={},t=0;t<e.length;t++)r[e[t].key]={key:e[t].key,value:null,sortValue:null,readOnly:!1,notApplicable:!1,cssClass:null,colour:null,backgroundColour:null,bold:!1,small:!1,strike:!1,tooltipText:"",invalid:!1,invalidMessage:""};return i={listIndex:n,cells:r,bold:!1,inactive:!1,colour:null,backgroundColour:null,hidden:!1,readOnly:!1},i.AutoBind=function(n){ie(i,n)},i}function ie(n,t){var i,r;for(i in t)for(r in n.cells)i==r&&(n.cells[r].value=t[i])}function re(){return s}function oi(t){for(var i,u,l,a,s,y,o={columns:[],data:[]},r=0;r<e.length;r++)if(i=e[r],i.visible||i.alwaysExport)switch(i.type.toUpperCase()){case"DRILLDOWN":case"HTML":break;default:u=i.caption;i.exportColumnHeader&&(u=i.exportColumnHeader);u&&u.toUpperCase().startsWith("<HTML>")&&(u=i.key);o.columns.push({key:i.key,caption:u,dataType:i.type})}if(f)for(l=0;l<f.length;l++)if(a=[],s=f[l],s)for(o.data.push(a),r=0;r<o.columns.length;r++){var i=o.columns[r],h=s.cells[i.key].value,v=s.cells[i.key].valueExport;v!==undefined&&(h=v);i.dataType=="html"&&(h=c[s.listIndex][i.key]);h===undefined&&(h=null);a.push(h)}y={gridData:o,format:t};n._SystemDownloadFile("ExportGridData",y,function(){},function(t){n.RegisterError("widget_grid.ExportData: Failed to export grid data: "+t)})}function ue(n){if(n===undefined)return r.groupByColumns;r.groupByColumns=n}function fe(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,vi(!0))}function au(n){vi(n)}function ee(){$("tr.hidden",s).removeClass("hidden");ft.slideUp("fast");st();gi=!0;r.stickyHeader&&wi()}function br(n,t,i,o){var s,h,v;i||(i={});var l=i.retainSelectedRows==!0,y=u,a=[];if(l&&(a=gr(!1,!1)),n&&(c=n),f=[],e.length!=0){hi=0;r.onInitialiseRow||window.alert("widet.UI.Grid.VirtualDataRefresh: options.onInitialiseRow handler not specified.");try{for(s=0;s<c.length;s++)if(c[s]!=null){h=lu(s);v={row:h};f.push(h);r.onInitialiseRow(v)}}catch(p){window.alert("widget.UI.Grid.VirtualDataRefresh: "+p.message)}o||au(!0);t?(w(-2),w(y)):(w(-1),r.onAfterRowActivate&&r.onAfterRowActivate());l&&wu(a,!0)}}function vu(n,t){if(t===undefined)for(var i=0;i<f.length;i++)if(f[i].listIndex==n){t=i;break}yu(n,t);r.allowCellSelect&&pt(p)}function yu(n,t){var e={row:f[t]},i,u;r.onInitialiseRow(e);i=$("tr[listindex="+n+"]",b);u=i.hasClass("hidden");lr(t,i,!0);u||i.removeClass("hidden");cu()}function oe(t){var o,e,s,i;if(t<0||t>c.length-1)return console.warn("widget_ui.Grid.RemoveRowAndCollectionItem: listIndex is outside of the bounds of the virtual class."),!1;for((f[t].newRow==!0||f[t].newRow==!1)&&(hi-=1),t==u&&(tt=null),o=y[t],n.ArrayRemove(y,y[t]),o.remove(),n.ArrayRemove(f,f[t]),n.ArrayRemove(c,c[t]),i=0;i<y.length;i++)e=y[i],e.attr("listIndex",i),f[i].listIndex=i,r.rowNumbering&&(s=$("td.rowselector span.rownumber",e),s.text(i+1));return u!=-1&&t<=u&&(i=u,i<0&&(i=0),i>f.length-1&&(i=f.length-1),w(i)),!0}function se(){if(!(u<1)&&!(u>=c.length)){var n=$("tr[listIndex='"+u+"']",b),t=n.prev();t.before(n);n.attr("listIndex",u-1);t.attr("listIndex",u);n=y[u];t=y[u-1];y[u]=t;y[u-1]=n;n=c[u];t=c[u-1];c[u]=t;c[u-1]=n;n=f[u];t=f[u-1];f[u]=t;f[u-1]=n;n.listIndex=u-1;t.listIndex=u;w(u-1);pi()}}function he(){if(!(u<0)&&!(u>=c.length-1)){var n=$("tr[listIndex='"+u+"']",b),t=n.next();t.after(n);n.attr("listIndex",u+1);t.attr("listIndex",u);n=y[u];t=y[u+1];y[u]=t;y[u+1]=n;n=c[u];t=c[u+1];c[u]=t;c[u+1]=n;n=f[u];t=f[u+1];f[u]=t;f[u+1]=n;n.listIndex=u+1;t.listIndex=u;w(u+1);pi()}}function ce(){for(var n=0;n<e.length;n++)if(e[n].key.toUpperCase()==r.selectedColumnKey.toUpperCase())return e[n];return null}function kr(n){var t,i,u;if(n===undefined)return r.selectedColumnKey;t=r.selectedColumnKey;r.selectedColumnKey=n;$("th,td",s).removeClass("selected");nt&&$("th,td",nt).removeClass("selected");i=$("th[key='"+r.selectedColumnKey+"'],td[key='"+r.selectedColumnKey+"']",s);i.addClass("selected");nt&&(u=$("th[key='"+r.selectedColumnKey+"'],td[key='"+r.selectedColumnKey+"']",nt),u.addClass("selected"));r.onColumnSelect&&r.selectedColumnKey!=t&&r.onColumnSelect()}function le(n,t){var i=yt(n);i?(i.list=null,i.collection=null,i._collection=null,i.listCsv=t):console.warn("widget_ui.Grid.SetColumnListCsv: column '"+n+"' not found.")}function ae(n,t,i,r){var u=yt(n);u?(u.listCsv=null,u.list=null,u.collection=t,u.idColumn=i,u.columns=r,u._collection={},u._collection.data=u.collection,u._collection.idColumn=u.idColumn,u._collection.displayColumns=u.columns):console.warn("widget_ui.Grid.SetColumnCollection: column '"+n+"' not found.")}function ve(n,t,i,r){var u=yt(n);u?t==u.list||(u.list=t,i&&(u.isColumn=i),r&&(u.columns=r),ou(u)):console.warn("widget_ui.Grid.SetColumnList: column '"+n+"' not found.")}function dr(n,t,i){if(f){var u=ei();n?t===undefined&&n==r.sortByColumn?r.sortByDesc=!r.sortByDesc:(r.sortByColumn=n,r.sortByDesc=t):(r.sortByColumn="",r.sortByDesc=!1);r.sortByColumn&&r.sortByColumn==r.groupByColumns&&(r.groupByDesc=r.sortByDesc);vi(!1);ei(u,!0);!i&&r.onAfterColumnSort&&r.onAfterColumnSort()}}function ye(n,t){var r,i;for(n=n.toUpperCase(),r=0;r<e.length;r++)if(i=e[r],i.key.toUpperCase()==n){i.visible=t;i.thElement&&!t&&i.thElement.hide();break}}function pe(n){if(n===undefined)return r.visible;r.visible=n;r.visible?v.show():v.hide()}function we(){s.focus()}function pu(n,t){var u,i,e;if(r.allowMultiRowSelect){for(u=0;u<f.length;u++)i=f[u],i&&i.rowSelectorCheckBox&&(e=y[i.listIndex],t&&e.hasClass("is-filtered-out")||(i.rowSelectorCheckBox.Value(n),n?e.addClass("row-selected"):e.removeClass("row-selected")));if(di.Value(n),r.onAfterRowActivate&&r.onAfterRowActivate(),r.onSelectedRowsChanged)r.onSelectedRowsChanged({})}}function gr(n,t){var e=[],o,i;if(r.allowMultiRowSelect)for(o=0;o<f.length;o++)i=f[o],i&&i.rowSelectorCheckBox&&i.rowSelectorCheckBox.Value()&&(t&&i.expired||e.push(i.listIndex));return n&&e.length==0&&u>=0&&(t&&f[u].expired||e.push(u)),e}function wu(n,t){var r,i;if(t)for(r=0;r<f.length;r++)i=f[r],i&&i.rowSelectorCheckBox&&(i.rowSelectorCheckBox.Value(!1),y[i.listIndex].removeClass("row-selected"));for(r=0;r<n.length;r++)i=f[n[r]],i&&i.rowSelectorCheckBox&&(i.rowSelectorCheckBox.Value(!0),y[i.listIndex].addClass("row-selected"))}function be(n){var i,r,t,u,e;if(n===undefined&&(n=!1),i=[],c)for(r=gr(!1,!1),t=0;t<f.length;t++)u=f[t],(n&&r.length==0||r.indexOf(u.listIndex)!=-1)&&(e=c[u.listIndex],i.push(e));return i}function ke(n,t){var i=$.extend({},{descending:undefined,groupingsCollapsed:!1,virtualDataRefresh:!1},t);r.groupByColumns=n;r.sortByColumn=n;r.groupingsCollapsed=i.groupingsCollapsed;i.descending!=undefined&&(r.groupByDesc=i.descending,r.sortByDesc=i.descending);i.virtualDataRefresh&&br(c,!0)}function de(){var t=!0,n,i;if(f)for(n=0;n<f.length;n++)if(i=f[n],i.invalid){w(n);t=!1;break}return t}function ge(){s.css({width:"100%",height:"100%",overflow:"auto"})}function no(n,t){var r,i;for(n=n.toUpperCase(),r=0;r<e.length;r++)if(i=e[r],i.key.toUpperCase()==n){i.caption=t;i.thElement&&(i.caption.substr(0,6).toUpperCase()=="<HTML>"?i.thElement.html(i.caption.substr(6)):i.thElement.text(i.caption));break}}var si,u=-1,p=-1,rt,ut,ft,ki,tu,wt="",e=[],it=!0,y=[],bt,d=!1,vt=!1,g,o,et=!1,h,s,di,b,gi=!1,iu=!1,kt,ii,ht,hi=0,r,tt,nr=!1,tr,nt,bu,ru=0,ri,ot,c,f,v,ci,ir,ur,er,ui,li,uu,or,ai,fi,sr,nu;if(si=new rr,GridColumnDefaults={key:"",align:"",allowDrilldown:!1,blankIfZero:!1,caption:null,drilldownGlyph:null,readOnly:!1,selectable:!1,sortable:!1,style:"",summary:"",tooltipText:"",type:"string",visible:!0,width:"",thElement:null,original:!1,elementCreatedIndex:-1},GridDefaults={cssClass:"is-grid",groupByColumns:"",groupByDesc:!1,groupingsCollapsed:!1,selectedColumnKey:"",showColumnHeaders:!0,stickyHeader:null,docked:null,showRowSelectors:!1,rowNumbering:!1,allowAddRows:!1,allowCellSelect:!0,allowMultiRowSelect:!1,readOnly:!1,maxNewRows:100,sortByColumn:"",sortByDesc:!1,showContextMenu:!0,showHiddenRowsPopup:!0,visible:!0,onAction:null,onInitialiseRow:null,onAfterColumnSort:null,onAfterRowActivate:null,onBeforeCellEdit:null,onBeforeCellUpdate:null,onColumnSelect:null,onFooterCellFormat:null,onRowAdd:null,onRowDrilldown:null,onSelectedRowsChanged:null},r=$.extend({},GridDefaults,i),typeof t=="string"?(ci=t,t=$("#"+ci)):ci=$(t).attr("id"),ir=$(t),ir.length==0){n.RegisterError("widget_ui.Grid: Element '"+ci+"' not found.");return}for(s=$(ir[0]),s.prop("tagName")=="DIV"?(s.addClass("is-grid"),v=s,s=$("<table><thead class='is-no-select'><tr><\/tr><\/thead><tbody><\/tbody><\/table>"),r.width&&v.css("width",r.width),v.append(s)):(s.wrap("<div class='is-grid'><\/div>"),v=$(s.parent()),ur=s.css("float"),ur&&v.css("float",ur)),r.docked===null&&(r.docked=r.stickyHeader==!0?!0:!1),r.stickyHeader===null&&(r.stickyHeader=ct),s.attr("tabindex","-1"),s.wrap("<div class='is-grid'><\/div>"),ri=$(s.parent()),v.addClass("is-grid-container"),v.removeClass("is-grid"),er=$("thead > tr > th",s),ui=0;ui<er.length;ui++)if(li=$(er[ui]),uu=li.attr("colspan"),uu){if(or=li.attr("colspan-for"),or)for(ai=or.split(","),fi=0;fi<ai.length;fi++)sr=$("th[key='"+ai[fi]+"']",s),sr.length>0?fu($(sr[0])):window.alert("widget.UI.Grid: colspan-for '"+ai[fi]+"', child column not found")}else fu(li);return s.bind("keyup",function(n){if(!d)switch(n.keyCode){case 13:if(et)return gt(),!1}}),s.bind("keydown",function(n){var t,i,o;if(!d)switch(n.keyCode){case 9:if(r.allowCellSelect)return n.shiftKey?ti():ni(),!1;break;case 13:break;case 27:w(-1);pt(-1);break;case 32:if(et&&!r.readOnly&&u!=-1&&p!=-1&&(t=e[p],t.type=="Boolean"&&t.allowEdit))return i=$("td.is-sel > input.is-grid-checkbox",s),i.trigger("click"),!1;break;case 35:return f&&(w(f.length-1),st()),!1;case 36:return f&&(w(0),st()),!1;case 33:return ne(),!1;case 34:return te(),!1;case 37:return ti(),!1;case 38:return wr(),!1;case 39:return ni(),!1;case 40:return c&&u==c.length-1&&r.allowAddRows&&!r.readOnly?(o=f[u],o.newRow||bi(!0)):pr(),!1;case 46:if(et&&p==-1&&u!=-1){if(r.onAction)r.onAction("DeleteRow")}else switch(e[p].type){case"Currency":case"Integer":vr(u,rt,null,!0);break;default:gt();window.setTimeout(function(){a(!1)},10)}break;case 113:et&&gt();break;default:if(et)if(n.keyCode>=32&&n.keyCode<=111||n.keyCode==189)gt();else switch(n.keyCode){case 187:case 191:gt()}}}),e.length==0||vi(!0),nu={TypeName:"Grid",ClearColumns:ku,GetColumnByIndex:hr,GetColumnByKey:yt,AddColumnBoolean:gu,AddColumnCurrency:nf,AddColumnDate:tf,AddColumnDateTime:rf,AddColumnDrilldown:uf,AddColumnHtml:ff,AddColumnIcon:ef,AddColumnInteger:sf,AddColumnString:hf,AddColumnCode:cf,ColumnCount:lf,SortColumnsByArray:af,MergeColumnHeaders:vf,ActivateFirstDataRow:gf,ActivateLastDataRow:hu,ActiveDataRowIndex:w,ActiveDataRowListIndex:ei,AddRow:bi,GetSelectedRowIndexes:gr,SetSelectedRowIndexes:wu,SelectAllRows:pu,GetVirtualDataForSelectedRows:be,SetColumnCollection:ae,SetColumnList:ve,SetColumnListCsv:le,GroupByColumnsUpdate:ke,ColumnCaption:no,ColumnVisible:ye,Actions:kf,RowMoveUp:se,RowMoveDown:he,Editing:function(){return d},Element:re,ExportData:oi,Focus:we,GroupByColumns:ue,PerformRowDrilldown:yr,ReadOnly:fe,Refresh:au,RefreshButtons:pi,RefreshRow:vu,RemoveRowAndCollectionItem:oe,ResizeFromParent:ge,SelectedColumn:ce,SelectedColumnKey:kr,Sort:dr,Validate:de,VirtualDataRefresh:br,Visible:pe},v.prop("is-control",nu),nu}function su(t,i){function d(){tt||(tt=!0,e=$("#"+a),e.change(function(){e[0].GetFiles().length==0?(r.Text(""),p(),r.Focus(),l&&l(u,null)):(r.Visible(!1),s.show(),p(),l&&l(u,null))}))}function p(){d();var n=r.Text();f.allowNew&&(n.toUpperCase()=="[NEW FILE...]"||nt())?(r.Visible(!1),s.show(),$("label.addfile",s).trigger("click"),window.setTimeout(function(){e[0].GetFiles().length==0&&(r.Text(""),p(),r.Focus())},100)):(r.Visible(!0),s.hide());f.showPreview&&g()}function g(){var t,i;r.Text()!=o&&w&&b&&c&&(t=$("img",c),o=r.Text(),o&&!nt()&&o.toUpperCase()!="[NEW FILE...]"?(t.attr("src",""),c.show(),v[o]?t.attr("src",v[o]):(i={sourceType:w,sourceId:b,fileName:o,previewHeight:f.previewHeight},n._SystemGetString("DocumentManagerComboBox_GetPreview",i,function(n){o!=r.Text()||(t.attr("src",n),v[o]=n)},function(t){n.RegisterError("widget_ui.DocumentManagerComboBox: Failed to get preview details: "+t)}))):(t.attr("src",""),c.hide(),o=""))}function ut(n){if(n===undefined)return r.Text();n!=k&&(r.Text(n),g());k=n}function ft(t,i,u){var e,o;w=t;b=i;v={};e={fileTypes:"*"};it=$.extend({},e,u);r.ListFromCsvString("");o={sourceType:t,sourceId:i,fileTypes:it.fileTypes};n._SystemGetString("DocumentManagerComboBox_GetList",o,function(n){n=JSON.parse(n);f.allowNew&&n.unshift("[New file...]");r.ListFromArray(n);g()},function(t){n.RegisterError("widget_ui.DocumentManagerComboBox: Failed to refresh details: "+t)})}function et(){var n="",i="",t;n=e&&e.length!=0&&e[0].GetFiles&&f.allowNew&&e[0].GetFiles().length!=0?e[0].GetFileName():r.Text();t=n.lastIndexOf(".");t&&(i=n.substr(t+1).toUpperCase());switch(i){case"BMP":case"GIF":case"ICO":case"JPG":case"JPEG":case"PNG":return!0;default:return!1}}function nt(){return d(),e&&e.length!=0&&e[0].GetFiles?f.allowNew&&e[0].GetFiles().length!=0:!1}function ot(){return d(),e[0]}var r,e,a,tt=!1,s,f,v,c,o="",w,b,l=null,k="",it,rt,y;if(f=$.extend({},{allowNew:!0,fileTypes:"*",previewHeight:80,showPreview:!0},i),l=f.onChange,f.maxLength=255,f.limitToList=!1,f.width="100%",f.onChange=function(n,t){p();l?l(n,t):t&&(t.ChangeHandled=!0);k=r.Text()},r=n.UI.ComboBox(t,f),y=r.WrapperElement(),y.wrap("<div class='is-dm-combobox'><\/div>"),rt=$(y.parent()),f.showPreview&&(c=$("<div class='preview' style='min-height:"+f.previewHeight+"px;'><img style='height:"+f.previewHeight+"px'/><\/div>"),rt.append(c)),f.allowNew){a=h(!0);s=$("<div class='is-file-upload widget-control'><label for='"+a+"'><\/label><\/div>");e=$("<input type='file' id='"+a+"'/>");switch(f.fileTypes.toUpperCase()){case"[IMAGES]":e.attr("accept","image/*")}s.append(e);s.insertBefore(y)}return r.Visible(!0),c.hide(),s.hide(),u={TypeName:"DocumentManagerComboBox",GetFileData:ot,IsNewFile:nt,IsImageFile:et,Refresh:ft,AllowBlank:r.AllowBlank,AutoReadOnly:r.AutoReadOnly,BlankTip:r.BlankTip,Caption:r.Caption,Element:r.Element,Focus:r.Focus,ReadOnly:r.ReadOnly,Text:ut,Visible:r.Visible,VisibleRow:r.VisibleRow,WidthResizeFromParent:r.WidthResizeFromParent}}function hu(t,i){function l(){r.ListFromCsvString(i.list)}function a(){var t=r.Text();t?(f.attr("src",n.GetIconUrl(o.iconPrefix+t+i.iconSuffix,16)),f.show()):f.hide()}function v(n){o.list=n;l()}function y(n){o.listOther=n;l()}function p(n){if(n===undefined)return r.Text();n!=s&&(r.Text(n),a());s=n}var r,e,f,o=i,s="",h=null,c;return i.iconPrefix||(i.iconPrefix=""),i.iconSuffix||(i.iconSuffix=""),h=i.onChange,i.onChange=function(n,t){a();h?h(n,t):t&&(t.ChangeHandled=!0);s=r.Text()},i.onFormatItem=function(t,r){r.displayValue=r.displayValue?"<img style='width:16px; height:16px; overflow:hidden; display:inline-block; vertical-align:middle' src='"+n.GetIconUrl(i.iconPrefix+r.displayValue+i.iconSuffix,16)+"'/>&nbsp;"+r.displayValue:"<div style='border:1px solid rgba(0,0,0,0.1); width:16px; height:16px; overflow:hidden; display:inline-block; vertical-align:middle'><\/div>&nbsp;"+r.displayValue},r=n.UI.ComboBox(t,i),c=r.Element(),c.css("padding-left","22px"),e=$("<div style='width:16px; height:16px; position:absolute; top:3px; left:3px;'><img style='width:16px; height:16px; display:none;'/><\/div>"),e.insertBefore(c),f=$("img",e),u={TypeName:"IconComboBox",ListFromCsvString:v,ListOtherFromCsvString:y,AllowBlank:r.AllowBlank,AutoReadOnly:r.AutoReadOnly,BlankTip:r.BlankTip,Caption:r.Caption,Element:r.Element,Focus:r.Focus,ReadOnly:r.ReadOnly,Text:p,Visible:r.Visible,VisibleRow:r.VisibleRow,WidthResizeFromParent:r.WidthResizeFromParent}}function cu(t,i){function s(t,i,r,u){if(i===undefined&&(i=!1),t){if(f.SetFetchingData(!0),f.ShowDescription(!1),o.width||f.WidthResizeFromParent(),tt[t]){h(tt[t],t,i,r,u);return}n._SystemGetString("GetInformationList",{id:t},function(n){h(n,t,i,r,u)},function(t){n.RegisterError("widget_ui.InformationListComboBox: Failed to retrieve Information List: "+t);r&&r()})}else f.LimitToList(!1),f.ListFromCsvString(o.blankList),f.ShowDescription(!1),o.width||f.WidthResizeFromParent()}function h(n,t,i,r,u){var h,s;if(n){if(data=JSON.parse(n),data.ValuesAlt){for(h=[],s=0;s<data.Values.length;s++)h.push({Value:data.Values[s],Description:data.ValuesAlt[s]});f.RefreshFromCollection(h,"Value","Description","Value,Description");f.ShowDescription(!0)}else{for(h=[],s=0;s<data.Values.length;s++)h.push({Value:data.Values[s]});f.RefreshFromCollection(h,"Value","","Value");h.length==0&&o.blankList&&f.ListFromCsvString(o.blankList);f.ShowDescription(!1)}e=data;i&&f.AllowBlank(!e.Mandatory);f.LimitToList(e.LimitToList);f.MaxLength(e.MaxLength);f.WidthResizeFromParent(!0);u&&!f.Text()&&e.DefaultValue&&f.Text(e.DefaultValue)}r&&r();f.SetFetchingData(!1);f.WidthResizeFromParent(!1);tt[t]=n}function c(n,t,i){var r="",u;if(t){for(u=0;u<t.length;u++)r+=t[u]+"|";r=r.toUpperCase()}s(n,!1,function(){for(var n,c,t,h,o,u=[],s=0;s<e.Values.length;s++)if(n=e.Values[s],r?(c=n.toUpperCase(),c.substr(0,r.length)==r?(n=n.substr(r.length),t=n.indexOf("|"),t!=-1&&(n=n.substr(0,t))):n=null):(t=n.indexOf("|"),t!=-1&&(n=n.substr(0,t))),n){for(h=!1,o=0;o<u.length;o++)if(n.toUpperCase()==u[o].Value.toUpperCase()){h=!0;break}h||u.push({Value:n})}f.RefreshFromCollection(u,"Value","","Value");i&&i()},!1)}var f,e,o;return!r&&n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI?(typeof t=="string"&&(t=$("#"+t)),t.attr("is-created","y"),i.widgetDocument=window.document,new window.parent.$UI.InformationListComboBox(t,i)):(e=null,o=i,i.showColumnHeadings=!1,i.showDescription=!1,i.maxLength||(i.maxLength=50),i.blankList||(i.blankList=""),f=n.UI.DBCombo(t,i),u={TypeName:"InformationListComboBox",SetComboFromInformationList:s,SetComboFromSectionedInformationList:c,AllowBlank:f.AllowBlank,AutoReadOnly:f.AutoReadOnly,BlankTip:f.BlankTip,Caption:f.Caption,Focus:f.Focus,ReadOnly:f.ReadOnly,Text:f.Text,Visible:f.Visible,VisibleRow:f.VisibleRow,WidthResizeFromParent:f.WidthResizeFromParent})}function f(t,i){function l(){var o,t,n,i;u.cssClass&&f.addClass(u.cssClass);switch(u.width.toUpperCase()){case"AUTO":o=9999999999;t=-9999999999;u.maxValue!=null&&(o=u.maxValue);u.minValue!=null&&(t=u.minValue);o=rt(o,u.decimals,!1,!1);t=rt(t,u.decimals,!1,!1);n=o.length;t.length>n&&(n=t.length);n<2&&(n=2);u.percentage&&(n+=1);f.removeClass("date");f.css("max-width",n*.8+"em");f.css("width","100%");break;case"DATE":f.addClass("date");f.css("width","");break;default:f.removeClass("date");u.width&&f.css({"max-width":u.width,width:"100%"})}e&&(u.indentLevel?e.addClass("is-indent-"+u.indentLevel):(e.removeClass("is-indent-1"),e.removeClass("is-indent-2")));u.allowBlank?(f.removeClass("is-mandatory"),e&&e.removeClass("is-mandatory")):(f.addClass("is-mandatory"),e&&e.addClass("is-mandatory"));r?u.blankTip&&f.attr("placeholder",u.blankTip):f.attr("placeholder",u.blankTip);u.fontBold?(e&&e.css("font-weight","bold"),f.css("font-weight","bold")):(e&&e.css("font-weight",""),f.css("font-weight",""));u.readOnly?(f.addClass("is-readonly"),f.attr("readonly","readonly")):(f.removeClass("is-readonly"),f.removeAttr("readonly"));u.autoReadOnly?f.attr("autoreadonly","true"):f.removeAttr("autoreadonly");f.attr("maxLength",u.maxLength==0?"":u.maxLength);f.attr("spellcheck","false");it?(v.css({display:"none"}),f.removeClass("is-invalid")):(f.addClass("is-invalid"),w?(ft?v.html(w):v.text(w),v.css({display:"inline-block"})):v.css({display:"none"}));tt;i="";(u.maxValue!=null||u.minValue!=null)&&(i=pt(),i&&(i="Valid range "+i));f.attr("title",i);u.visible?c.show():c.hide()}function ht(text){u.readOnly||(text&&text.startsWith("=")&&(text=""+eval(text.substr(1))),text==""?(s=!0,o=0):(s=!1,o=a(text,u.decimals)));k()}function k(){var t,i;s?y&&!u.readOnly?f.val(""):f.val(""):y&&!u.readOnly?o==0?f.val("0"):tt||(t=u.decimals,t==-1&&(t=n.CurrencyDecimals()),f.val(rt(o,t,!1,!1))):u.blankIfZero&&o==0?f.val(""):tt||(i=rt(o,u.decimals,u.showSeparators,u.blankIfZero),u.percentage&&(i+="%"),f.val(i))}function wt(n){n!=u.allowBlank&&(u.allowBlank=n==!0,l())}function bt(n){if(n===undefined)return u.blankTip;u.blankTip=n;l()}function ct(){if(!nt){var n=$("<div><\/div>");c.append(n);nt=ri(n,{onButtonClick:u.onButtonClick,visible:!1,parentControl:g})}return nt}function kt(n){var t=ct();n||(n=[]);t.ButtonsDefine(n);nt.Visible(n.length!=0)}function dt(n){if(n===undefined)return e?e.text():"";e&&e.text(n)}function lt(){return!(o==ut&&s==et)}function gt(){var n={ChangeHandled:!1,ValueOriginal:ut};if(u.onChange)u.onChange(g,n);n.ChangeHandled&&(mTextOriginal=f.val());it||yt()}function ni(){return f}function ti(){f.focus();f.select()}function ii(n){if(n===undefined)return u.fontBold;n!=u.fontBold&&(u.fontBold=n==!0,l())}function ui(n){if(n===undefined)return u.readOnly;n!=u.readOnly&&(u.readOnly=n==!0,l())}function fi(n){if(n===undefined)return u.autoReadOnly;n!=u.autoReadOnly&&(u.autoReadOnly=n==!0,l())}function ot(t){if(t===undefined)return y&&ht(f.val()),o;t===null?u.allowBlank?(o=0,s=!0):o=0:(s=!1,t=u.decimals==-1?n.Round(t,n.CurrencyDecimals()):n.Round(t,u.decimals),o=t);ut=o;et=s;k()}function at(n){if(n===undefined)return s;n?(s=!0,o=0):s=!1;k()}function ei(n){if(n===undefined)return u.maxValue;u.maxValue=n}function oi(n){if(n===undefined)return u.minValue;u.minValue=n}function vt(n){var r,t,i;(n||u.width.toUpperCase()!="AUTO")&&(c.hide(),r=c.parent().innerWidth(),c.show(),t=u.width,i="",n?t="100%":(t=u.maxValue!=null&&u.minValue!=null?"6em":"6em",i=r+"px"),c.css({width:t,maxWidth:i}),f.css({width:t,maxWidth:i}))}function si(){return it?!0:!1}function yt(){var n=!0,t;return(u.minValue!=null||u.maxValue!=null)&&(t=ot(),u.blankIfZero&&u.allowBlank&&t==0||(n&&u.minValue!=null&&t<u.minValue&&(n=!1),n&&u.maxValue!=null&&t>u.maxValue&&(n=!1))),n?st(!0,"",!1):st(!1,"Valid range "+pt(),!1),n}function pt(){var n="";return u.minValue!=null&&(n+=u.minValue==0?"0":rt(u.minValue,u.decimals,!0,!1)),u.maxValue!=null?(n&&(n+=" "),n+="to "+rt(u.maxValue,u.decimals,!0,!1)):n&&(n+=" or above"),n}function st(n,t,i){it=n;w=t===undefined?"":t;ft=i===undefined?!1:i;l()}function hi(n){u.onChange=n}function ci(n){if(n===undefined)return u.visible;u.visible=n;l()}function li(n){if(!h&&(h=f.closest("tr"),h.length==0))return console.warn("widget_ui.TextBox.VisibleRow: no parent row element found."),h=null,!1;if(n===undefined)return h.css("visibility").toUpperCase()=="HIDDEN";n?(h.css("display","table-row"),h.css("visibility","")):(h.css("display","none"),h.css("visibility","hidden"))}var nt,f,h,y=!1,tt=!1,it=!0,e,u,v,w="",ft=!1,o=0,s=!0,ut=0,et=!0,c,b,p,g;if(NumberBoxDefaults={blankTip:"",captionElement:"auto",cssClass:"is-numberbox",allowBlank:!0,blankIfZero:!1,fontBold:!1,showSeparators:!0,indentLevel:0,decimals:-1,percentage:!1,maxValue:null,minValue:null,readOnly:!1,autoReadOnly:!0,visible:!0,width:"auto",onButtonClick:null,onChange:null},u=$.extend({},NumberBoxDefaults,i),typeof t=="string"?(b=t,t=$("#"+b)):b=$(t).attr("id"),p=$(t),p.length==0){console.warn("widget_ui.NumberBox: Element '"+b+"' not found.");return}if(f=$(p[0]),r||f.wrap("<span style='white-space:normal; display:inline; padding:0; margin:0;' controlType='numberbox'/>"),c=$(f.parent()),v=$("<label style='display:none' class='is-validation-tip'><\/label>"),c.append(v),p=$("label[for='"+b+"']"),e=p.length==0?null:$(p[0]),l(),u.width=="auto"&&vt(),tt?f.focus(function(){y=!0}):f.focus(function(){y=!0;u.readOnly||k();f.select()}),f.blur(function(){y=!1;u.readOnly||(ht(f.val()),lt()&&gt(),ut=ot(),et=at(),k())}),n.Options.enterMovesToNextField)f.on("keyup",function(n){n.keyCode==13&&d($(this))});return g={TypeName:"NumberBox",AllowBlank:wt,AutoReadOnly:fi,BlankTip:bt,Buttons:ct,ButtonsDefine:kt,Caption:dt,Changed:lt,Element:ni,Focus:ti,FontBold:ii,MaxValue:ei,MinValue:oi,ReadOnly:ui,Value:ot,ValueIsBlank:at,Visible:ci,VisibleRow:li,WidthResizeFromParent:vt,IsValid:si,Validate:yt,ValidationSet:st,OnChange:hi},f.prop("is-control",g),g}function lu(t,i){var e,r,f;if(n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI)return typeof t=="string"&&(t=$("#"+t)),t.attr("is-created","y"),i.widgetDocument=window.document,new window.parent.$UI.ParametersHost(t,i);if(e=i,typeof t=="string"?(r=t,t=$("#"+r)):r=$(t).attr("id"),f=$(t),f.length==0){console.warn("widget_ui.ParametersHost: Element '"+r+"' not found.");return}return mElement=$(f[0]),mElement.html("<div style='margin:4px; padding:4px; border:1px solid rgba(0,0,0,0.1); background-color:#ffffee; color:darkred; font-size:13px;'>Entry of parameters is only supported in finPOWER Connect Cloud.<\/div>"),u={TypeName:"ParametersHost",Focus:function(){},Initialise:function(){},Refresh:function(){},ResizeFromParent:function(){},RestoreParametersFromSnapshot:function(){},Visible:function(){},GetParameterValues:function(){return""},UpdateParameterValues:function(){}}}function au(i,r){function g(){s.addClass("is-preview-pane");l.border||s.css("border","none")}function tt(){return s}function it(n,t){a[n]=t}function rt(){a={}}function k(n){return a[n]!=undefined}function ut(n){k(n)&&delete a[n]}function w(){f="";var n=e[0].contentDocument;n.open();n.write("");n.close();v=!1}function ft(){return v}function et(){return c}function st(t,i,r){var u,f;if(i.GetCacheKey){if(!i.GetPreviewFetchParameters){window.alert("Grid.PreviewFromGridCollection: Collection does not provide a GetPreviewFetchParameters method.");return}}else{window.alert("Grid.PreviewFromGridCollection: Collection does not provide a GetCacheKey method.");return}if(u=t.ActiveDataRowListIndex(),u==-1){w();return}if(f=i.GetCacheKey(u),k(f)){lt(f,!1,{});return}w();setTimeout(function(){u==t.ActiveDataRowListIndex()&&(c=!0,o.attr("available",!1),n.GetString(r,i.GetPreviewFetchParameters(u),function(n){var r=n;it(f,r);f==i.GetCacheKey(t.ActiveDataRowListIndex())&&(y(r,!1,{}),v=!0);c=!1;o.attr("available",!0)},function(n){d(n);c=!1;o.attr("available",!0)}))},150)}function ht(){s.css({width:"100%",height:"100%",overflow:"visible",display:"block"});e.css({width:"100%",height:"100%",overflow:"auto"})}function y(t,i,r){var u=$.extend({},nt,r),s,a,h,p,y;if(v=!0,c=!1,o.attr("available",!0),f="",i||t&&t.toUpperCase().indexOf("<HTML")!=-1&&(i=!0,console.log("widget.UI.PreviewPane.SetContent: Complete HTML detected so 'htmlComplete=false' flag has been ignored")),s="",u.cssSummaryPage2){a="";window.$App&&$App.Version&&(a="?v="+$App.Version());h="";switch(n.GetHostingContext()){case"WebInternal":case"WebExternal":h=vi+"Content/SummaryPage2/";break;default:h=n.Options.templatesPath+"/"}s+="<link rel='stylesheet' type='text/css' href='"+h+"summarypage_2.css"+a+"'><\/link>";s+="<link rel='stylesheet' type='text/css' href='"+h+"summarypage_2_web.css"+a+"'><\/link>"}window.$App&&(t=$App.NormaliseHtmlPreview(t));l.smartBackgroundColour&&(t.indexOf("is-summarypage-blocks")==-1?e.css({"background-color":""}):e.css({"background-color":"#808080"}));p=e[0].contentWindow;i||(f+="<!doctype html>",f+="<html",u.summaryPage2Blocks&&(f+=" class='is-summarypage-2 is-summarypage-blocks'"),f+=">",f+="<head>",s||console.warn("No Resources!\n\no.cssSummaryPage2="+u.cssSummaryPage2),f+=s,f+="<\/head>",f+="<body style='margin:0;padding:0'",u.summaryPage2Blocks&&(f+=" class='is-summarypage-blocks'"),f+=">",u.formatAsSummaryPage2&&(f+="<div class='is-summarypage-2'>"));f+=t;i||(u.formatAsSummaryPage2&&(f+="<\/div>"),f+="<\/body>",f+="<\/html>");y=e[0].contentDocument;y.open();y.write(f);y.close();l.handleApplicationShortcuts&&window.parent.$Ash&&window.parent.$Ash.HandleIframe(e[0])}function d(n,i){var r="";r+="<div class='is-summarypage-2'>";r+="<div class='is-template-message'>";r+="<div class='is-template-message-error'>";r+=t(n);i&&(r+="<p>"+t(i)+"<\/p>");r+="<\/div>";r+="<\/div>";r+="<\/div>";y(r,!1)}function ct(n){var t,i="",r="";try{t=$.parseJSON(n.responseText);t.Message&&(i=t.Message);t.InternalMessage&&(r=t.InternalMessage)}catch(u){}d(i,r)}function lt(n,t,i){a[n]===undefined?y("Item '"+n+"' does not exist in the Content Cache.",!1,{}):y(a[n],t,i)}function at(){if(!c&&v&&f){var t=$UI.CommonDialog().ShowHtml("Preview",f,{forceWindowed:!0,popup:!1}),n=$UI.FindParentModal(s);n&&n.OnAction()&&t.OnAction(n.OnAction())}}function vt(n){if(n===undefined)return l.visible;l.visible=n;g()}function yt(n){if(!h&&(h=s.closest("tr"),h.length==0))return console.warn("widget_ui.PreviewPane.VisibleRow: no parent row element found."),h=null,!1;if(n===undefined)return h.css("visibility").toUpperCase()=="HIDDEN";n?(h.css("display","table-row"),h.css("visibility","")):(h.css("display","none"),h.css("visibility","hidden"))}var a={},f="",e,s,h,v=!1,c=!1,l,o,p,b,nt;if(PreviewPaneDefaults={handleApplicationShortcuts:!0,smartBackgroundColour:!0,collapsedCaption:"Preview row",border:!0},l=$.extend({},PreviewPaneDefaults,r),typeof i=="string"?(p=i,i=$("#"+p)):p=$(i).attr("id"),b=$(i),b.length==0){console.warn("widget_ui.PreviewPane: Parent element '"+p+"' not found.");return}return s=$(b[0]),o=$("<div class='collapsed-caption is-no-select' available='false'><\/div>"),o.html("<a>"+t(l.collapsedCaption)+"<\/a>"),s.append(o),$("a",o).click(function(){at()}),e=$("<iframe/>"),s.append(e),ot&&e.attr("scrolling","no"),g(),nt={cssSummaryPage2:!0,formatAsSummaryPage2:!1,summaryPage2Blocks:!1},u={TypeName:"PreviewPane",CacheClear:rt,CacheExists:k,CacheRemove:ut,Clear:w,Element:tt,Loaded:ft,Loading:et,PreviewFromGridCollection:st,ResizeFromParent:ht,SetContent:y,SetContentError:d,Visible:vt,VisibleRow:yt}}function vu(n){function e(n,e){var s,o,h,a,c,l;for(n.Element&&(n=n.Element()),i?i.children().remove():(i=$("<div class='is-prompt-update-list'><\/div>"),$(n).after(i)),i.append("<label>"+t(r.caption)+"<\/label>"),s=$("<ul><\/ul>"),i.append(s),o=0;o<e.length;o++)h=e[o],a=$("<li><b>"+t(h.caption)+"<\/b><div>"+t(h.value)+"<\/div><\/li>"),s.append(a);i.show();c=$("<button class='is-button small cross'>Cancel<\/button>");l=$("<button class='is-button small tick'>Accept<\/button>");i.append(c);i.append(l);c.click(function(){if(u(),r.onCancel)r.onCancel(f,{})});l.click(function(){var t,n,i;if(u(),r.onAccept){for(t=[],n=0;n<e.length;n++)i=e[n],i.id&&t.push(i.id);r.onAccept(f,{ids:t})}})}function u(){i&&i.hide()}var i,r,f;return PromptUpdateListDefaults={caption:"Update the following?",onAccept:null,onCancel:null},n===undefined&&(n={}),r=$.extend({},PromptUpdateListDefaults,n),f={TypeName:"PromptUpdateList",Hide:u,Show:e}}function c(t,i){function o(){r.isHtml?u.html(r.text):u.html(n.UI.HtmlEncode(r.text));u.removeClass();switch(r.style.toUpperCase()){case"HEADING":u.addClass("is-label-heading");break;case"HYPERLINK":u.addClass("is-label-hyperlink");break;case"INFORMATION":u.addClass("is-label-information");break;case"NORMAL":u.addClass("is-label-normal");break;case"PAGEHEADING":u.addClass("is-label-pageheading");break;case"WARNING":u.addClass("is-label-warning");break;default:console.warn("userinterface.Label: style '"+r.style+"' not supported.")}r.tooltipHtml||r.tooltipText?u.addClass("is-tooltip"):u.removeClass("is-tooltip");r.readOnly;r.visible?u.show():u.hide()}function a(n){if(n===undefined)return r.tooltipHtml;r.tooltipHtml=n;o()}function v(n){if(n===undefined)return r.tooltipText;r.tooltipText=n;o()}function y(n){if(n===undefined)return r.text;r.text=n;r.isHtml=!0;o()}function p(n){if(n===undefined)return r.text;r.text=n;r.isHtml=!1;o()}function w(){return u}function b(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,o())}function c(){e.Hide()}function l(){e.Clear();r.tooltipHtml?e.Append("<span>"+r.tooltipHtml+"<\/span>"):e.Append("<span>"+n.UI.HtmlEncode(r.tooltipText)+"<\/span>");e.Show()}function k(n){if(n===undefined)return r.visible;r.visible=n;o()}function d(n){if(!f&&(f=u.closest("tr"),f.length==0))return console.warn("widget_ui.VisibleRow: no parent row element found."),f=null,!1;if(n===undefined)return f.css("visibility").toUpperCase()=="HIDDEN";n?(f.css("display","table-row"),f.css("visibility","")):(f.css("display","none"),f.css("visibility","hidden"))}var e,u,f,r,s,h;if(LabelDefaults={style:"Heading",text:null,isHtml:!1,readOnly:!1,tooltipText:"",tooltipHtml:"",visible:!0},r=$.extend({},LabelDefaults,i),typeof t=="string"?(s=t,t=$("#"+s)):s=$(t).attr("id"),h=$(t),h.length==0){console.warn("widget_ui.Label: Element '"+s+"' not found.");return}return u=$(h[0]),r.text===null&&(r.text=u.text()),e=new ft(u,{cssClass:"is-tooltip"}),o(),u.bind("click",function(){(r.tooltipHtml||r.tooltipText)&&(e.Visible()?c():l())}),{TypeName:"Label",Element:w,Html:y,ReadOnly:b,Text:p,TooltipHtml:a,TooltipText:v,TooltipHide:c,TooltipShow:l,Visible:k,VisibleRow:d}}function yu(n,i){function y(){f.addClass("is-rangeslider");f.attr("min",r.minValue);f.attr("max",r.maxValue);f.attr("step",r.step);r.readOnly?(f.addClass("is-readonly"),f.attr("disabled","disabled")):(f.removeClass("is-readonly"),f.removeAttr("disabled"));r.autoReadOnly?f.attr("autoreadonly","true"):f.removeAttr("autoreadonly");r.visible?o.show():o.hide()}function ut(n){o.addClass(n)}function ft(n){if(n===undefined)return p?p.text():"";p&&p.text(n)}function et(){return f}function ot(){f.focus()}function k(){return 39}function d(){return o.width()}function st(n,t){t||(t=0);var i=d()-k(),r=nt()-b();n.css("left",i/r*(g()-b())+t+"px")}function ht(){if(!r.readOnly)if(r.onChange)r.onChange(it,{})}function ct(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,y())}function g(n){if(n===undefined)return v;v=n===null?0:n;f.val(v);rt=v}function nt(n){if(n===undefined)return r.maxValue;r.maxValue=n;y()}function b(n){if(n===undefined)return r.minValue;r.minValue=n;y()}function lt(n){if(n===undefined)return r.step;r.step=n;y()}function at(n){if(n===undefined)return r.visible;r.visible=n;y()}function vt(n){if(!c&&(c=f.closest("tr"),c.length==0))return console.warn("widget_ui.Checkbox.VisibleRow: no parent row element found."),c=null,!1;if(n===undefined)return c.css("visibility").toUpperCase()=="HIDDEN";n?(c.css("display","table-row"),c.css("visibility","")):(c.css("display","none"),c.css("visibility","hidden"))}function tt(n){var i,t,u;o.hide();i=o.parent().innerWidth();o.show();t=r.width;u="";t=n?"100%":r.width.toUpperCase()=="AUTO"?"100%":r.width;o.css({width:"100%","max-width":t});f.css({width:"100%","max-width":t})}var f,c,p,r,v=0,rt=0,o,s,w,it;if(RangeSliderDefaults={caption:"",step:10,minValue:0,maxValue:100,readOnly:!1,visible:!0,width:"auto",height:"auto",trackColour:"",trackHeight:"",thumbColour:"",thumbSize:"",thumbStyle:"",onChange:null},r=$.extend({},RangeSliderDefaults,i),typeof n=="string"?(s=n,n=$("#"+s)):(s=$(n).attr("id"),s||(s="rng"+h(!0),$(n).attr("id",s))),w=$(n),w.length==0){console.warn("widget_ui.RangeSlider: Element '"+s+"' not found.");return}if(f=$(w[0]),(f.attr("type")+"").toUpperCase()!="RANGE"&&console.warn("widget_ui.RangeSlider: Element '"+s+"' does not have a type attribute of 'range'."),f.attr("is-created","y"),f.wrap("<span class='is-rangeslider' controlType='rangeslider'/>"),o=$(f.parent()),p=$("<label for='"+s+"'>"+t(r.caption)+"<\/label>").insertAfter(f),r.trackColour||r.trackHeight||r.thumbColour||r.thumbSize||r.thumbStyle){var e="input#"+s+".is-rangeslider[type=range]",l=20,a=39,u="<style type='text/css'>";if(r.trackColour&&(u+=e+"::-webkit-slider-runnable-track { background-color:"+r.trackColour+"; }",u+=e+"::-moz-range-track { background-color:"+r.trackColour+"; }",u+=e+"::-ms-fill-lower { background-color:"+r.trackColour+"; }",u+=e+"::-ms-fill-upper { background-color:"+r.trackColour+"; }"),r.trackHeight&&(u+=e+"::-webkit-slider-runnable-track { height:"+r.trackHeight+"px; }",u+=e+"::-webkit-slider-runnable-track { margin-top:-12px; }",u+=e+"::-webkit-slider-thumb { margin-top:-"+(11-r.trackHeight/2)+"px; }",u+=e+"::-moz-range-track { height:"+r.trackHeight+"px; }",u+=e+"::-ms-fill-lower { height:"+r.trackHeight+"px; }",u+=e+"::-ms-fill-upper { height:"+r.trackHeight+"px; }"),r.thumbColour&&(u+=e+"::-webkit-slider-thumb { background-color:"+r.thumbColour+"; }",u+=e+"::-moz-range-thumb { background-color:"+r.thumbColour+"; }",u+=e+"::-ms-thumb { background-color:"+r.thumbColour+"; }"),r.thumbStyle)switch(r.thumbStyle.toUpperCase()){case"CIRCLE":a=l;r.thumbSize||(r.thumbSize=1);break;case"SQUARE":a=l;r.thumbSize||(r.thumbSize=1)}if(r.thumbSize){u+=e+" { height:"+l*r.thumbSize+"px; }";u+=e+"::-webkit-slider-thumb { height:"+l*r.thumbSize+"px; width:"+a*r.thumbSize+"px; }";u+=e+"::-moz-range-thumb { height:"+l*r.thumbSize+"px; width:"+a*r.thumbSize+"px; }";u+=e+"::-ms-thumb { height:"+l*r.thumbSize+"px; width:"+a*r.thumbSize+"px; }";switch(r.thumbStyle.toUpperCase()){case"CIRCLE":u+=e+"::-webkit-slider-thumb { border-radius:99px }";u+=e+"::-moz-range-thumb { border-radius:99px }";u+=e+"::-ms-thumb { border-radius:99px }";u+=e+"::-moz-range-thumb { height:"+l*r.thumbSize+"px; width:"+a*r.thumbSize+"px; }";u+=e+"::-ms-thumb { height:"+l*r.thumbSize+"px; width:"+a*r.thumbSize+"px; }"}}u+="<\/style>";o.append(u)}y();r.width!="auto"&&tt();f.on("change input",function(){v=f.val();ht()});return it={TypeName:"RangeSlider",AddClass:ut,Caption:ft,Element:et,Focus:ot,GetThumbWidth:k,GetWidth:d,MaxValue:nt,MinValue:b,PositionElementAtThumb:st,ReadOnly:ct,Step:lt,Value:g,Visible:at,VisibleRow:vt,WidthResizeFromParent:tt}}function pu(i,r){function p(){f.cssClass&&o.addClass(f.cssClass);switch(f.style.toUpperCase()){case"CUSTOM":o.show();break;case"NORMAL":o.show();break;case"WIZARD":o.hide();break;default:n.RegisterError("widget_ui.Tabs: Invalid style '"+f.style+"'. Must be either: Normal, Wizard, Custom")}tt()}function nt(){var s=0,r,n,i,o;for(l.children().remove(),r=0;r<u.length;r++)n=u[r],i=$("<li class='is-selectable'><\/li>"),l.append(i),n.element=i,n.cssClass&&i.addClass(n.cssClass),o="",o=n.symbol?"<div class='is-symbol is-symbol-"+n.symbol.toLowerCase()+"' title='"+t(n.caption)+"'><\/div>":t(n.caption),i.html(o),n.hidden&&(s+=1),function(n){i.click(function(){var t=it(n),i=n==e;y(n);i&&t.pageElement.removeClass("hold-animation");f.onSelectedTabChanged&&f.onSelectedTabChanged()})}(n.tabId);k()}function k(){for(var n,t=0;t<u.length;t++)n=u[t],n.visible?n.element.show():n.element.hide(),n.tabId==e?(s=t,n.element.addClass("selected"),n.pageElement&&n.pageElement.show()):(n.element.removeClass("selected"),n.pageElement&&n.pageElement.hide())}function tt(){for(var n,i=0,t=0;t<u.length;t++)n=u[t],f.visible&&n.visible?(n.element.show(),i+=1):(n.element.hide(),n.pageElement&&n.pageElement.hide());f.visible||o.hide()}function et(){return o}function ot(n){var f,r,i,t,o,e;if((!hi||n)&&s!=-1)for(f=$("input,select,textarea,div[tabindex=-1],span[tabindex=0]",u[s].pageElement),r=0;r<f.length;r++)if(i=$(f[r]),t=!0,t&&i.prop("disabled")&&(t=!1),t&&i.is("[readonly]")&&(i.hasClass("fetchingdata")||(t=!1)),t&&!i.is(":visible")&&(i.attr("type")=="checkbox"?(o=i.prop("id"),e=$("label[for='"+o+"']"),e.length!=1||e.is(":visible")||(t=!1)):t=!1),t){i.focus().select();break}}function it(n){return a(n)}function st(n){return u[n]}function a(n){n=n.toUpperCase();for(var t=0;t<u.length;t++)if(u[t].tabId.toUpperCase()==n)return u[t];return null}function ht(n){return n<0||n>=u.length?"":u[n].tabId}function ct(){return s<0||s>=u.length?null:u[s].pageElement}function lt(n){if(u=[],e="",s=-1,n)for(var t=0;t<n.length;t++)ut(n[t].tabId,n[t],!0);nt()}function y(n){if(n===undefined)return e;n!=e&&(e=n,s=-1,k())}function rt(t){if(t===undefined)return s;t<0||t>=u.length?(y(""),n.RegisterError("widget_ui.Tabs: SelectTabByIndex failed. Index must be between 0 and "+(u.length-1)+".")):y(u[t].tabId)}function at(n){var t,i;for(e=n,n=n.toUpperCase(),t=0;t<u.length;t++)i=u[t],i.visible=n==i.tabId.toUpperCase();tt();k()}function a(n){n=n.toUpperCase();for(var t=0;t<u.length;t++)if(u[t].tabId.toUpperCase()==n)return u[t];return null}function vt(n,t){var i=a(n);if(i==null&&console.warn("TabCaption: Cannot find tab '"+n+"'."),t==undefined)return i.caption;i.caption=t;i.element.text(t)}function yt(n,t){var i=a(n);if(i===null&&console.warn("TabTooltipText: Cannot find tab '"+n+"'."),t===undefined)return i.tooltipText;i.tooltipText=t;i.element.attr("title",t)}function pt(n,t){var i=a(n);if(i===null&&console.warn("TabVisible: Cannot find tab '"+n+"'."),t===undefined)return i.visible;i.visible=t;p()}function wt(n,t){var i=u[n];if(i===null&&console.warn("TabVisibleIndex: Cannot find tab "+n+"."),t===undefined)return i.visible;i.visible=t;p()}function bt(){for(var t=-1,n=0;n<u.length;n++)u[n].visible&&(t=n);return t}function kt(){return u.length}function ut(n,t,i){t=$.extend({},{caption:"",cssClass:null,pageElement:null,visible:!0},t);var r={tabId:n},o=$("<li><\/li>");return l.append(o),r.caption=t.caption||n,r.cssClass=t.cssClass,r.pageElement=t.pageElement,r.symbol=t.symbol,r.visible=t.visible,r.pageElement||(f.pagesParent?(r.pageElement=$("<div class='is-tab-page'><\/div>"),f.pagesParent.append(r.pageElement)):window.alert("Tabs cannot automatically create Page element since no pagesParent element was specified in the creation options for this Tabs control.")),u.push(r),e||(e=r.tabId,s=u.length-1),i||nt(),r}function dt(n,t){var r,i;if(n)return r=a(e),r?ii(r.pageElement,undefined,undefined,t):(window.alert("Tabs.Validate: No current tab."),!1);for(i=0;i<u.length;i++)if(u[i].visible&&!ii(u[i].pageElement,ft,i,t))return!1;return!0}function gt(n){if(n===undefined)return f.visible;f.visible=n;p()}var o,f,e="",s=-1,u,l,d,w,b,h,ft;if(TabDefaults={cssClass:"is-tabs",pagesParent:null,style:"normal",visible:!0,onSelectedTabChanged:null},f=$.extend({},TabDefaults,r),typeof i=="string"?i=$("#"+i):d=$(i).attr("id"),w=$(i),w.length==0){n.RegisterError("widget_ui.Tabs: Element '"+d+"' not found.");return}for(o=$(w[0]),f.pagesParent&&typeof f.pagesParent=="string"&&(f.pagesParent=$("#"+f.pagesParent)),$("ul,li",o).contents().filter(function(){return this.nodeType=Node.TEXT_NODE&&/\S/.test(this.nodeValue)==!1}).remove(),l=$("ul",o),l.length==0&&(l=$("<ul><\/ul>"),o.append(l)),u=[],b=$("li",l),h=0;h<b.length;h++){var v=$(b[h]),c={tabId:v.attr("tabId"),element:v,caption:v.text(),visible:!0,tooltipText:v.attr("tooltipText")},g=$("div#page"+c.tabId);g.length!=0&&(c.pageElement=g,c.pageElement.addClass("is-tab-page"));v.click(function(){var n=$(this).attr("tabId");n!=e&&(y(n),f.onSelectedTabChanged&&f.onSelectedTabChanged())});c.tabId||n.RegisterError("widget_ui.Tabs: Tab '"+c.caption+"' does not have a 'tabId' attribute to identify it.");c.pageElement||n.RegisterError("widget_ui.Tabs: Tab '"+c.tabId+"' does not have an associated page element (a div element with an id of 'page"+c.tabId+"').");u.push(c)}for(p(),h=0;h<u.length;h++)if(u[h].visible){rt(h);break}return ft={TypeName:"Tabs",Element:et,FocusFirst:ot,GetTabById:it,GetTabByIndex:st,GetTabIdByIndex:ht,GetSelectedPageElement:ct,Tabs:a,RefreshFromArray:lt,SelectedTabId:y,SelectedTabIndex:rt,ShowSingleTab:at,TabCount:kt,TabCaption:vt,TabTooltipText:yt,TabVisible:pt,TabVisibleIndex:wt,TabsAdd:ut,LastVisibleTabIndex:bt,Validate:dt,Visible:gt}}function i(t,i){function s(){u.cssClass&&f.addClass(u.cssClass);u.multiLine&&!u.autoExpand?f.css({minHeight:u.minHeight}):f.css({minHeight:""});u.allowBlank?(f.removeClass("is-mandatory"),l&&l.removeClass("is-mandatory")):(f.addClass("is-mandatory"),l&&l.addClass("is-mandatory"));f.attr("placeholder",u.blankTip);u.readOnly?(f.addClass("is-readonly"),f.attr("readonly","readonly")):(f.removeClass("is-readonly"),f.removeAttr("readonly"));u.autoReadOnly?f.attr("autoreadonly","true"):f.removeAttr("autoreadonly");u.hyperlinkContent?(f.addClass("is-hyperlink"),f.addClass("is-hyperlink")):f.removeClass("is-hyperlink");f.attr("maxLength",u.maxLength==0?"":u.maxLength);u.width!="auto"&&f.css({width:u.width});u.spellCheck?f.attr("spellcheck","true"):f.attr("spellcheck","false");u.multiLine&&u.rows&&(u.autoExpand?(it||(it=f[0].scrollHeight),at()):f.attr("rows",u.rows));u.actionsButtonVisible?(o.addClass("is-control-actions-button"),p.show()):(o.removeClass("is-control-actions-button"),p.hide());rt?(a.css({display:"none"}),f.removeClass("is-invalid")):(f.addClass("is-invalid"),b?(ft?a.html(b):a.text(b),a.css({display:"inline-block"})):a.css({display:"none"}));u.visible?o.show():o.hide()}function at(){if(!k&&u.multiLine&&u.autoExpand){f.css("height","1px");var t=f[0].scrollHeight,n=Math.ceil((t-it)/16);n<0&&(n=0);u.autoExpandMaxRows&&n+u.rows>u.autoExpandMaxRows&&(n=u.autoExpandMaxRows-u.rows);f.attr("rows",u.rows+n);f.css("height","unset")}}function gt(n){n!=u.allowBlank&&(u.allowBlank=n==!0,s())}function ni(n){if(n===undefined)return u.blankTip;u.blankTip=n;s()}function bt(){if(!v){var n=$("<div><\/div>");o.append(n);v=ri(n,{onButtonClick:u.onButtonClick,visible:!1,parentControl:nt})}return v}function ti(n){var t=bt();n||(n=[]);t.ButtonsDefine(n);v.Visible(n.length!=0)}function ii(n){if(n===undefined)return l?l.text():"";l&&l.text(n)}function kt(){return f.val()!=y}function yt(){var n={ChangeHandled:!1,TextOriginal:y};if(u.onChange)u.onChange(nt,n);n.ChangeHandled&&(y=f.val())}function ui(){return f}function fi(){return o}function dt(){f.focus();f.select()}function ei(n){if(n===undefined)return u.readOnly;n!=u.readOnly&&(u.readOnly=n==!0,s())}function oi(n){if(n===undefined)return u.readOnly;n!=u.maxLength&&(u.maxLength=n,s())}function si(n){if(n===undefined)return u.autoReadOnly;n!=u.autoReadOnly&&(u.autoReadOnly=n==!0,s())}function hi(n){if(n===undefined)return vt(f,!0);f.val(n);y=n;at()}function pt(n){var s,t,i,r,e;o.hide();s=o.parent().innerWidth();o.show();t=u.width;i="";u.maxLength==0||u.maxLength>100||n?t="100%":(i=u.maxLength*.8+"em",t="100%");o.css({width:t,maxWidth:i});f.css({width:t,maxWidth:i,"margin-right":0});u.widthButtonsInclusive&&v&&v.Visible()&&(r=v.Element().outerWidth(),e=f.css("width"),f.css("width","calc("+e+" - "+r+"px)"))}function ci(){u.multiLine?(o.css({width:"100%",height:"100%",overflow:"visible",display:"inline-block"}),f.css({width:"100%",height:"100%",overflow:"auto"})):pt()}function li(n){var t,i,s,r;if(tt=n,tt&&tt.length!=0){for(e?(e.attr("tleid")||e.attr("tleid",h(!0)),e.addClass("is-textbox-tagslist"),e.hide(),e.children().remove()):(e=$("<div class='is-textbox-tagslist' style='display:none' tleid='"+h(!0)+"'><\/div>"),o.prepend(e)),ut=e.parent(),f.attr("tleid",e.attr("tleid")),t=$("<ul><\/ul>"),i=0;i<n.length;i++)s=tt[i],r=$("<li tabindex='-1'><\/li>"),r.text(s.caption),r.attr("value",s.value),t.append(r);e.append(t);$("li",t).click(function(){var n=e.prop("tlt");n.focus();yi(n,$(this).attr("value"))});ut.focusin(function(){ai()});ut.focusout(function(){vi()})}else u.tagsListElement||(e=null)}function ai(){e&&!u.readOnly&&(e.stop(),e.slideDown("fast"))}function vi(){e&&(e.stop(),e.slideUp("fast"))}function yi(n,t){u.readOnly||pi(n,t)}function pi(n,t){var r=n[0],i=r.selectionStart,u=r.selectionEnd-i,f=n.val();n.val(f.substring(0,i)+t+f.substring(i+u));u?(r.selectionStart=i,r.selectionEnd=i+t.length):(r.selectionStart=i+t.length,r.selectionEnd=i+t.length);yt()}function wi(n){if(n===undefined)return u.visible;u.visible=n;s()}function bi(n){if(!c&&(c=f.closest("tr"),c.length==0))return console.warn("widget_ui.TextBox.VisibleRow: no parent row element found."),c=null,!1;if(n===undefined)return c.css("visibility").toUpperCase()=="HIDDEN";n?(c.css("display","table-row"),c.css("visibility","")):(c.css("display","none"),c.css("visibility","hidden"))}var p,it,v,f,c,wt=!1,rt=!0,l,u,tt=[],e,ut,y="",a,b="",ft=!1,o,g,w,et,ot,st,ht,ct,lt,nt;if(TextBoxDefaults={captionElement:"auto",cssClass:"is-textbox",allowBlank:!0,blankTip:"",maxLength:0,multiLine:!1,minHeight:"32px",spellCheck:!1,readOnly:!1,autoReadOnly:!0,visible:!0,width:"auto",widthButtonsInclusive:!0,rows:1,autoExpand:!1,autoExpandMaxRows:null,password:!1,onChange:null,onButtonClick:null,onEnterKey:null,changeWhileTyping:!1,hyperlinkContent:!1,onContentHyperlink:null,onFocus:null,tagsListElement:null,specialType:null,actionsButtonVisible:!1,onActionsButtonClick:null},u=$.extend({},TextBoxDefaults,i),typeof t=="string"?(g=t,t=$("#"+g)):g=$(t).attr("id"),w=$(t),w.length==0){console.warn("widget_ui.TextBox: Element '"+g+"' not found.");return}if(f=$(w[0]),u.blankTip||(u.blankTip=f.attr("placeholder")),u.multiLine?(et=f.attr("class"),ot=$("<textarea id='"+f.attr("id")+"' style='resize:none'><\/textarea>"),f.replaceWith(ot),f=ot,u.rows&&f.attr("rows",u.rows),et&&f.addClass(et)):u.password&&(st=$("<input type='password' id='"+f.attr("id")+"' autocomplete='off' value=''/>"),f.replaceWith(st),f=st),r||f.wrap("<span style='white-space:normal; display:inline; padding:0; margin:0;' controlType='textbox'/>"),o=$(f.parent()),p=$("<button class='is-control-actions-button'><\/button>"),o.append(p),p.click(function(){if(u.actionsButtonVisible)if(u.onActionsButtonClick)u.onActionsButtonClick(nt);else window.alert("onActionsButtonClick is not handled!")}),a=$("<label style='display:none' class='is-validation-tip'><\/label>"),o.append(a),w=$("label[for='"+g+"']"),l=w.length==0?null:$(w[0]),u.width=="auto"&&u.maxLength!=0&&pt(),f.blur(function(){kt()&&yt();y=f.val();wt=!1}),f.focus(function(){if(wt=!0,e&&e.prop("tlt",f),u.onFocus)u.onFocus(nt,{})}),u.changeWhileTyping){ht="keyup paste";ct=f.attr("type");ct&&ct.toLowerCase()=="search"&&(ht+=" input");f.on(ht,function(){yt();y!=f.val()&&console.warn("widget_ui.TextBox: changeWhileTyping is enabled but no onChange handler is setting e.changeHandled to true. Ignore if by design but this may mean code is called multiple times needlessly.")})}if(u.multiLine&&u.autoExpand)f.on("input",at);if(u.onEnterKey)f.on("keydown",function(n){n.keyCode==13&&u.onEnterKey()});if(u.onContentHyperlink)f.on("click",function(){u.readOnly&&u.hyperlinkContent&&u.onContentHyperlink&&u.onContentHyperlink()});if(a.click(function(){dt()}),n.Options.enterMovesToNextField&&!u.onEnterKey&&!u.multiLine)f.on("keyup",function(n){n.keyCode==13&&d($(this))});if(e=u.tagsListElement,u.specialType)switch(u.specialType.toUpperCase()){case"SEARCH":o.addClass("is-textbox-special-search");lt=$("<button class='search' title='Search'><\/button>");o.append(lt);lt.on("click",function(){f.focus();u.onEnterKey&&u.onEnterKey()})}return s(),nt={TypeName:"TextBox",AllowBlank:gt,AutoReadOnly:si,BlankTip:ni,Buttons:bt,ButtonsDefine:ti,Caption:ii,Changed:kt,Element:ui,Focus:dt,MaxLength:oi,ReadOnly:ei,ResizeFromParent:ci,TagsListDefine:li,Text:hi,Visible:wi,VisibleRow:bi,WrapperElement:fi,WidthResizeFromParent:pt,TextOriginal:function(){return y}}}function wu(n,t){function s(){r.removeClass("horizontal,vertical");r.addClass(i.layout);i.allowBlank?(r.removeClass("is-mandatory"),e&&e.removeClass("is-mandatory")):(r.addClass("is-mandatory"),e&&e.addClass("is-mandatory"));i.readOnly?(r.addClass("is-readonly"),r.attr("readonly","readonly")):(r.removeClass("is-readonly"),r.removeAttr("readonly"));i.autoReadOnly?r.attr("autoreadonly","true"):r.removeAttr("autoreadonly");b?(o.css({display:"none"}),r.removeClass("is-invalid")):(r.addClass("is-invalid"),l?(w?o.html(l):o.text(l),o.css({display:"inline-block"})):o.css({display:"none"}));i.visible?a.show():a.hide()}function k(){for(var f,e,t,n=0;n<u.length;n++)t=u[n],t.Element().remove();for(u=[],n=0;n<i.list.length;n++)f=i.list[n],e=$("<input type='checkbox'/>"),r.append(e),t=di(e,{caption:f.caption,onChange:function(n){var t,r;if(n.Value())h=n._TagValue;else if(i.allowBlank)h=null;else{n.Value(!0);return}for(y(!0,"",!1),t=0;t<u.length;t++)r=u[t],r!==n&&r.Value(!1);if(i.onChange)i.onChange(p,{})}}),t._TagValue=f.value,u.push(t)}function g(n){n!=i.allowBlank&&(i.allowBlank=n==!0,s())}function nt(n){if(n===undefined)return e?e.text():"";e&&e.text(n)}function tt(){return r}function d(){u.length!=0&&u[0].Focus()}function it(n){if(n===undefined)return i.readOnly;n!=i.readOnly&&(i.readOnly=n==!0,s())}function rt(n){if(n===undefined)return i.autoReadOnly;n!=i.autoReadOnly&&(i.autoReadOnly=n==!0,s())}function ut(n){var t,i;if(n===undefined)return h;for(h=n,t=0;t<u.length;t++)i=u[t],i.Value(i._TagValue==h);s()}function ft(n){if(n===undefined)return i.visible;i.visible=n;s()}function et(n){if(!f&&(f=r.closest("tr"),f.length==0))return console.warn("widget_ui.RadioButtonList.VisibleRow: no parent row element found."),f=null,!1;if(n===undefined)return f.css("visibility").toUpperCase()=="HIDDEN";n?(f.css("display","table-row"),f.css("visibility","")):(f.css("display","none"),f.css("visibility","hidden"))}function ot(){var t="",n=!0;return i.allowBlank||h!==null||(n=!1,t=i.blankValidationMessage),n?y(!0,"",!1):y(!1,t,!1),n}function y(n,t,i){b=n;l=t===undefined?"":t;w=i===undefined?!1:i;s()}var u=[],r,f,b=!0,e,i,h=null,o,l="",w=!1,a,v,c,p;if(RadioButtonListDefaults={captionElement:"auto",layout:"horizontal",allowBlank:!0,blankValidationMessage:"You must select a value",readOnly:!1,autoReadOnly:!0,visible:!0,list:[],onChange:null},i=$.extend({},RadioButtonListDefaults,t),typeof n=="string"?(v=n,n=$("#"+v)):v=$(n).attr("id"),c=$(n),c.length==0){console.warn("widget_ui.RadioButtonList: Element '"+v+"' not found.");return}return r=$(c[0]),r.wrap("<span style='padding:0; margin:0;' controlType='radiobuttonlist'/>"),a=$(r.parent()),o=$("<label style='display:none' class='is-validation-tip'><\/label>"),a.append(o),c=$("label[for='"+v+"']"),e=c.length==0?null:$(c[0]),o.click(function(){d()}),i.list&&i.list.length!=0&&k(),s(),p={TypeName:"RadioButtonList",AllowBlank:g,AutoReadOnly:rt,caption:nt,Element:tt,Focus:d,ReadOnly:it,Validate:ot,ValidationSet:y,Value:ut,Visible:ft,VisibleRow:et},a.prop("is-control",p),p}function bu(t){return n.Trim(t)}function ku(t){return n.LTrim(t)}function tr(t){return n.RTrim(t)}function du(i,r,u){var e,f;n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI?window.parent.$UI.MsgBoxAlert(i,r,u):(r=$.extend({},MsgBoxDefaults,r),r.title==null&&(r.title="Alert"),r.icon==null&&(r.icon="Warning"),r.captionOk==null&&(r.captionOk="OK"),r.focusActionId||(r.focusActionId="Ok"),r.width||(r.width="80%"),r.height||(r.height="80%"),i.length<100&&i.indexOf("\n")==-1?(r.maxWidth==null&&(r.maxWidth=320),r.maxHeight==null&&(r.maxHeight=240)):i.length<200&&i.indexOf("\n")==-1?(r.maxWidth==null&&(r.maxWidth=480),r.maxHeight==null&&(r.maxHeight=320)):i.length<500&&i.indexOf("\n")==-1?(r.maxWidth==null&&(r.maxWidth=520),r.maxHeight==null&&(r.maxHeight=480)):(r.maxWidth==null&&(r.maxWidth=800),r.maxHeight==null&&(r.maxHeight=800)),e=n.UI.Modal(r),e.Actions().Define([{groupId:"[buttons]",actionId:"Ok",caption:r.captionOk},]),e.OnAction(function(n){switch(n){case"Ok":e.Hide(!0);u&&u()}}),f="",f+="<div class='is-msgbox'>",r.icon!=null&&(f+="<img src='"+n.GetIconUrl(r.icon,32)+"'/>"),r.heading&&(f+="<h1>"+t(r.heading)+"<\/h1>"),f+=r.messageIsHtml?"<p>"+i+"<p>":"<p>"+t(i)+"<\/p>",f+="<\/div>",e.Show({content:f}))}function ir(i,r,u,f){var s,h,e;if(n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI)window.parent.$UI.MsgBoxConfirm(i,r,u,f);else{r=$.extend({},MsgBoxDefaults,r);r.title==null&&(r.title="Confirm");r.icon==null&&(r.icon="Help");r.captionOk==null&&(r.captionOk="OK");r.captionCancel==null&&(r.captionCancel="Cancel");r.focusActionId||(r.focusActionId="Ok");r.closeOnEscape==undefined&&(r.closeOnEscape=!0);r.width||(r.width="80%");r.height||(r.height="80%");i.length<100&&i.indexOf("\n")==-1?(r.maxWidth==null&&(r.maxWidth=320),r.maxHeight==null&&(r.maxHeight=240)):i.length<200&&i.indexOf("\n")==-1?(r.maxWidth==null&&(r.maxWidth=480),r.maxHeight==null&&(r.maxHeight=320)):i.length<500&&i.indexOf("\n")==-1?(r.maxWidth==null&&(r.maxWidth=520),r.maxHeight==null&&(r.maxHeight=480)):(r.maxWidth==null&&(r.maxWidth=800),r.maxHeight==null&&(r.maxHeight=800));var l=r.icon=="Trash"?"danger":"",o=n.UI.Modal(r),c=[{groupId:"[buttons]",actionId:"Ok",caption:r.captionOk,buttonStyle:l},{groupId:"[buttons]",actionId:"Cancel",caption:r.captionCancel},];if(r.additionalButtons)for(s=0;s<r.additionalButtons.length;s++)h=r.additionalButtons[s],h.groupId="[buttons]",c.unshift(h);o.Actions().Define(c);o.OnAction(function(n){switch(n){case"Cancel":o.Hide(!0);f&&f(n);break;default:o.Hide(!0);u&&u(n)}});e="";e+="<div class='is-msgbox'>";r.icon!=null&&(e+="<img src='"+n.GetIconUrl(r.icon,32)+"'/>");r.heading&&(e+="<h1>"+t(r.heading)+"<\/h1>");e+=r.messageIsHtml?"<p>"+i+"<p>":t(i);e+="<\/div>";o.Show({content:e})}}function gu(i,r,u,f,e){var l,p,a,c,o,w,s,v,b,h,y,k;if(u=$.extend({},MsgBoxDefaults,u),u.title===null&&(u.title="Confirmation Required"),u.icon===null&&(u.icon="Help"),u.captionOk===null&&(u.captionOk="OK"),u.captionCancel===null&&(u.captionCancel="Cancel"),!u.maxHeight){for(l=0,h=0;h<r.length;h++)for(p=r[h],a=(p+"").split("\n"),c=0;c<a.length;c++)l+=1,a[c].length>60&&(l+=Math.ceil(a[c].length/60));u.maxHeight=180+l*18;u.heading&&(u.maxHeight+=24)}for(u.height||(u.height="95%"),u.width||(u.width="95%"),u.maxWidth||(u.maxWidth=800),o=n.UI.Modal(u),w=[{groupId:"[buttons]",actionId:"Ok",caption:u.captionOk,enabled:!1},{groupId:"[buttons]",actionId:"Cancel",caption:u.captionCancel},],o.Actions().Define(w),o.OnAction(function(n){switch(n){case"Cancel":o.Hide(!0);e&&e();break;default:o.Hide(!0);f&&f()}}),s="",s+="<div class='is-msgbox'>",u.icon!=null&&(s+="<img src='"+n.GetIconUrl(u.icon,32)+"'/>"),u.heading&&(s+="<h1>"+t(u.heading)+"<\/h1>"),s+=u.messageIsHtml?"<p>"+i+"<p>":t(i),s+="<ul class='is-msgbox-confirm-list'>",s+="<\/ul>",s+="<\/div>",o.Show({content:s}),v=0,b=$("ul.is-msgbox-confirm-list",o.ContentElement()),h=0;h<r.length;h++)y=$("<li><input type='checkbox'/><\/li>"),b.append(y),k=n.UI.CheckBox($("input",y),{caption:r[h],captionWrap:!0,onChange:function(n){n.Value()?v+=1:v-=1;o.Actions().SetEnabled("OK",v==r.length);o.Refresh()}})}function nf(t,i,r,u){n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI?window.parent.$UI.MsgBoxConfirmDelete(t,i,r,u):(i=$.extend({},MsgBoxDefaults,i),i.title==null&&(i.title="Confirm"),i.heading==null&&(i.heading="Delete"),i.icon==null&&(i.icon="Trash"),i.captionOk==null&&(i.captionOk="Delete"),i.focusActionId="Cancel",ir(t,i,r,u))}function tf(t,i,r){i=$.extend({},MsgBoxDefaults,i);i.icon||(i.icon="Information");i.title||(i.title="Information");n.UI.MsgBoxAlert(t,i,r)}function rf(i,r,u,f){var s,e,v,l,o,h,a,y,c;if(n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI)window.parent.$UI.MsgBoxList(i,r,u,f);else{for(u=$.extend({},{closeOnEscape:!1,showClose:!1,width:480,height:"auto"},u),s=n.UI.Modal(u),s.Show({content:""}),s.ModalElement().css("display","block"),e="",v=!1,e+="<div id='divList' class='is-msgbox-list' tabindex='-1'>",i&&(e+="<label id='message'>"+t(i)+"<\/label>"),e+="<ul id='ulList'>",l=0;l<r.length;l++)o=$.extend({},{caption:"",details:"",enabled:!0,icon:"",disabledWarning:""},r[l]),h="",e+="<li key='"+o.key+"' index='"+l+"'",!v&&o.enabled?(v=!0,h+="is-sel "):o.enabled||(h+="disabled "),o.icon&&(h+="icon ",a=n.GetIconUrl(o.icon,32),a=a.replace(/\\/g,"/"),e+=" style=\"background-image:url('"+a+"')\""),h&&(e+=" class='"+h+"'"),e+=">",e+="<h1>"+t(o.caption)+"<\/h1>",o.details&&(e+="<div>"+t(o.details)+"<\/div>"),!o.enabled&&o.disabledWarning&&(e+="<div class='warning'>"+t(o.disabledWarning)+"<\/div>"),e+="<\/li>";e+="<\/ul>";e+="<\/div>";s.RenderView(e);y=s.GetElement("divList");c=s.GetElement("ulList");y.bind("keyup",function(n){var t=$("li.is-sel",c),i=parseInt(t.attr("index"));switch(n.keyCode){case 13:s.Close();try{if(t.hasClass("disabled"))return;f&&f(t.attr("key"))}catch(e){}return!1;case 27:return u.allowEscape&&s.Close(),!1;case 38:return i>0&&(t.removeClass("is-sel"),$($("li",c)[i-1]).addClass("is-sel")),!1;case 40:return i<r.length-1&&(t.removeClass("is-sel"),$($("li",c)[i+1]).addClass("is-sel")),!1}});$("li",c).click(function(){$("li",c).removeClass("is-sel");var n=$(this);n.addClass("is-sel");s.Close();try{if(n.hasClass("disabled"))return;f&&f(n.attr("key"))}catch(t){}});y.focus()}}function pt(t,i,r){return n.SplitWordsAtCapitals(t,i,r)}function nt(t){return n.ArrayFromCsvString(t)}function uf(n){return n.Element().closest("tr")}function ff(t,i,r){var u=$.extend({},{css:null,includeOtherCss:!0},i),f;if($("#_widget_style").remove(),$("#_widget_style_top").remove(),t===null||t===undefined){r&&r();return}f="";window.portal&&(f=portal.PortalId());n._SystemGetString("GetUIStyle",{style:t,includeOtherCss:u.includeOtherCss,portalId:f},function(n){var e,o,i,t,f,s;if(n="<div id='_widget_style'>"+n+"<\/div>",$("head").append(n),u.css&&(e="<style type='text/css'>"+u.css+"<\/style>",$("#_widget_style").append(e)),n.indexOf("@import")!=-1&&(o=/(?:@import)\s(?:url\()?\s?["\'](.*?)["\']\s?\)?(?:[^;]*);?/gi,i=n.match(o),i.length!=0)){for(t="",f=0;f<i.length;f++)t&&(t+="\n"),t+=i[f];s="<div id='_widget_style_top'><style type='text/css'>"+t+"<\/style><\/div>";$("head").prepend(s)}r&&r()},function(t){n.RegisterError("widget_ui.LoadStyle: Failed to retrieve Style information: "+t);r&&r()})}function h(n){return"xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var r=Math.random()*16|0,u=t=="x"?r:r&3|8,i=u.toString(16);return n&&(i=i.replace(/-/g,"")),i})}function ef(t,i,r){var u,f,v,h,w="",b,e,y,o,p,c,l,a,s;for(t.children().remove(),e=$("<div class='is-no-select showing' tabindex='-1'><\/div>"),t.append(e),y=$("<div class='caption'>Actions<\/div>"),o=$("<a><span class='is-symbol-close'><\/span><\/a>"),o.click(function(){t.off("click");t.hide()}),y.append(o),e.append(y),p=$("<div><\/div>"),e.append(p),c=$("<ul><\/ul>"),p.append(c),l=0;l<i.Actions().length;l++)u=i.Actions()[l],a=u.visible,!a&&u.repeatInGroupId&&u.repeatInGroupId.toUpperCase()=="[BUTTONSOTHER]"&&u.contextPageId&&u.enabled&&(a=!0),a&&u.groupId.substr(0,1)!="["&&(u.groupId!=w&&(w=u.groupId,f=$("<li class='heading'><\/li>"),f.text(u.groupId),c.append(f)),f=$("<li class='action'><\/li>"),u.system?f.addClass("system"):f.addClass("custom"),s=$("<button><\/button>"),f.append(s),u.enabled||(f.addClass("disabled"),s.attr("disabled","disabled")),u.icon&&(v=$("<img/>"),s.append(v),b=n.GetIconUrl(u.icon,16),v.attr("src",b)),h=$("<span><\/span>"),h.text(u.caption),h.attr("fincc_actionid",u.actionId),s.append(h),c.append(f),u.enabled&&(u.handler?function(n){f.click(function(){t.hide();n.handler()})}(u):function(n){f.click(function(){t.hide();r(n.actionId,n.applicationShortcutUrl?n.applicationShortcutUrl:n.data)})}(u)));t.show();t.on("click",function(n){n.target===this&&o.trigger("click")});e.bind("keyup",function(n){n.keyCode==27&&(n.target.tagName=="INPUT"||o.trigger("click"))});e.focus();window.setTimeout(function(){e.removeClass("showing")},50)}function rr(n){function u(){return t}function r(n){var r,u;for(t=n,r=0;r<t.length;r++)u=$.extend({},i,t[r]),t[r]=u}function f(n){var f,u,r;if(n&&n.Actions)for(f=0;f<n.Actions.length;f++){if(u=n.Actions[f],r=$.extend({},i,{}),r.actionId=u.ActionId,r.buttonCaption=u.ButtonCaption,r.caption=u.Caption,r.alwaysShowCaption=u.AlwaysShowCaption,r.context=u.ContextPageId?!0:!1,r.contextPageId=u.ContextPageId,r.groupId=u.GroupId,r.icon=u.Icon,r.repeatInGroupId=u.RepeatInGroupId,r.system=u.System,r.applicationShortcutUrl=u.ApplicationShortcutUrl,u.ParametersJson)if(r.applicationShortcutUrl)console.warn("$UI.ActionsCollection.AppendFromFormHeaderInfo: Action '"+r.actionId+"' defined both an Application Shortcut URL and JSON Parameters. JSON Parameters were ignored.");else try{r.data=JSON.parse(u.ParametersJson)}catch(e){window.alert("$UI.ActionsCollection.AppendFromFormHeaderInfo: Action '"+r.actionId+"'\n\nFailed to parse ParametersJson.\n\n"+e)}t.push(r)}}function e(n){var i,r;for(n=n.toUpperCase(),i=0;i<t.length;i++)if(r=t[i],r.actionId.toUpperCase()==n)return r;return null}function o(n){var i,r;for(n=n.toUpperCase(),r=0;r<t.length;r++)if(i=t[r],i.actionId&&i.actionId.toUpperCase()==n)return i.applicationShortcutUrl;return!1}function s(n){var i,r;for(n=n.toUpperCase(),r=0;r<t.length;r++)if(i=t[r],i.actionId&&i.actionId.toUpperCase()==n)return i.checked;return!1}function h(n,i){var r,u;for(n=n.toUpperCase(),i=i?!0:!1,u=0;u<t.length;u++)r=t[u],r.actionId&&r.actionId.toUpperCase()==n&&(r.checked=i)}function c(n,i,r){var u,f;for(n=n.toUpperCase(),f=0;f<t.length;f++)u=t[f],u.actionId&&u.actionId.toUpperCase()==n&&(u.enabled=i,r!=undefined&&(u.tooltipText=r))}function l(n){var i,r;for(n=n.toUpperCase(),r=0;r<t.length;r++)if(i=t[r],i.actionId&&i.actionId.toUpperCase()==n)return i.enabled;return!1}function a(n,i){var r,u;for(n=n.toUpperCase(),u=0;u<t.length;u++)r=t[u],r.actionId&&r.actionId.toUpperCase()==n&&(r.visible=i)}var t=[],i={buttonStyle:"",caption:"",alwaysShowCaption:!1,applicationShortcutUrl:"",data:null,checked:!1,context:!1,contextPageId:"",enabled:!0,icon:"",groupId:"",repeatInGroupId:"",system:!0,tooltipText:"",visible:!0};return n&&r(n),{TypeName:"ActionCollection",Actions:u,Define:r,AppendFromFormHeaderInfo:f,GetAction:e,GetApplicationShortcutUrl:o,GetEnabled:l,GetChecked:s,SetChecked:h,SetEnabled:c,SetVisible:a}}function of(t,i){function a(n){s=n;pi(s)}function v(n,t){var i,n;if(!h){if(h=!0,n!=undefined?r.css({left:n,top:t}):(i=c.offset(),r.css({left:i.left,top:i.top})),s&&y(r,u,s),u.forceOverlay){if(!f){f=$("<div class='is-modal-overlay top' style='background-color:rgba(0,0,0,0.2); position: fixed; left:0; right:0; top:0; bottom:0; min-width:100%; min-height:100%;' tabindex='-1'><\/div>");$("body").append(f);$("body").on("keydown.contextmenu",function(n){switch(n.keyCode){case 27:e()}})}f.mousedown(e)}r.removeClass("active");$("body").append(r);r.show();window.setTimeout(function(){r.addClass("active")},10);u.forceOverlay?f.focus():(o&&(window.clearInterval(o),o=null),document.activeElement&&document.activeElement.tagName=="IFRAME"&&(navigator.userAgent.toLowerCase().indexOf("firefox")>-1||(document.activeElement.blur(),r[0].focus(),o=window.setInterval(function(){document.activeElement&&document.activeElement.tagName=="IFRAME"&&e()},250))));var l=$(document).innerWidth(),v=r.offset(),a=r.innerWidth();v.left+a>l-4&&(n=l-a-4,r.css("left",n))}}function e(){r.remove();o&&(window.clearInterval(o),o=null);h&&(h=!1,r.hide());f&&($("body").off("keydown.contextmenu"),f.remove(),f=null);u.onClose&&u.onClose()}function y(){var f,n,t,i;r.children().remove();n=$("<div><\/div>");(u.caption||u.showCloseButton)&&(t=$("<div class='caption is-no-select'><\/div>"),t.text(u.caption),u.showCloseButton&&(i=$("<a><span class='is-symbol-close'><\/span><\/a>"),i.click(function(){u.onClose?u.onClose():e()}),t.append(i)),r.append(t),n.addClass("hascaption"));f=l(u,s,!1);n.append(f);r.append(n)}function l(t,i){for(var r,u,f,h,c,a,s=$("<ul class='is-no-select'><\/ul>"),o=0;o<i.length;o++)r=i[o],u=$("<li itemtype='"+r.ItemType+"'><\/li>"),f=$("<a><\/a>"),u.attr("itemid",r.ItemId),f.text(r.Caption),u.append(f),r.Icon&&(r.IconUrl=n.GetIconUrl(r.Icon)),r.IconUrl?(c="<img src='"+r.IconUrl+"' />",f.prepend(c)):r.IconClass&&(a="<div class='is-menu-item-glyph "+r.IconClass+"'><\/div>",f.prepend(a)),r.Visible||u.css("display","none"),u.attr("Enabled",""+r.Enabled),s.append(u),r.MenuItems&&r.MenuItems.length!=0?(h=l(t,r.MenuItems,!0),u.addClass("is-menu-sub"),u.append(h)):function(n){f.click(function(){if(n.Action||n.ItemId){if((n.Action||n.ItemId)&&n.Enabled)if(e(),t.onAction)t.onAction(n.Action||n.ItemId,n.ItemId);else window.alert("No onAction handler specified for this menu.")}else e()})}(r);return s}function p(n){if(n===undefined)return u.caption;u.caption=n}function w(n){u.onAction=n}function b(){r.focus()}var r,s=[],u,f=null,c,h=!1,o=null;MenuPopupDefaults={onAction:null,caption:"",autoClose:!0,showCaption:!1,showCloseButton:!1,onClose:null,forceOverlay:!0};u=$.extend({},MenuPopupDefaults,i);ot&&(u.forceOverlay=!0);c=t;r=$("<div style='display:none; position:fixed; min-width:200px; top:0; left:0;' class='is-popup-menu'><\/div>");r.on("contextmenu",function(){return!1});if(!u.forceOverlay)r.on("mousedownoutside focusoutside selectoutside keydownoutside",function(){e()});return{TypeName:"MenuPopup",Caption:p,Items:s,Define:a,Show:v,Hide:e,Focus:b,OnAction:w}}function sf(n){function wt(){return l}function ut(){ht();ct()}function ht(){if(f==o[o.length-1]){it>0&&(it-=1);var n=o.pop();o.length>0?o[o.length-1].NotifyChildClosed(n):f.ParentModal()&&f.ParentModal().NotifyChildClosed&&f.ParentModal().NotifyChildClosed(n)}else window.alert("userinterface.Modal.Close: Could not remove modal from stack since it is not the top-most item. Modals should always be closed last to first.")}function ct(){u&&(tt&&(b.detach(),b.hide(),tt.append(b),b=null,tt=null),r.remove(),r=null,u.remove(),u=null,$(window).unbind("resize.modal"+y),it<=0&&$("body").removeClass("is-has-modal"));i.onAfterClose&&i.onAfterClose()}function bt(){return a}function kt(n){if(n===undefined)return i.dialogResult;i.dialogResult=n}function dt(n){return $("#"+c+n)}function lt(n){rt?(rt=!1,u.fadeOut(100),n?(ht(),r.fadeOut(100,function(){ct()})):r.fadeOut(100)):n&&ut()}function at(n,t){if(1)if(i.onAction)i.onAction(n,t);else console.warn("widget.UI.Modal.ExecuteAction: No OnAction defined for this Modal object to handle action '"+n+"'.")}function gt(){for(var t=$("a, button, input, select, textarea",r),n=0;n<t.length;n++)e=$(t[n]),e.attr("disabled")||(e.attr("autoreadonly")==undefined||e.attr("autoreadonly")!="false")&&(e.attr("ISFormDisabled",!0),e.attr("disabled",!0))}function ni(){for(var t=$("a, button, input, select, textarea",r),n=0;n<t.length;n++)e=$(t[n]),e.attr("ISFormDisabled")&&(e.removeAttr("ISFormDisabled"),e.attr("disabled",!1))}function ti(n){if(i.onChildClosed)i.onChildClosed({child:n})}function ii(n){if(n===undefined)return i.onAction;i.onAction=n}function ri(n){i.onClose=n}function ui(n){i.onResize=n}function fi(n){if(n===undefined)return i.parentModal;i.parentModal=modal}function ei(n,t){var r,i,u,e,o;if(!window._portalInfo){window.alert("You cannot use Modal.LoadPortalPage when running from an HTML Widget rather than a Portal.");return}if(r=n,t){i="";for(u in t)i&&(i+="&"),i+=encodeURIComponent(u)+"="+encodeURIComponent(t[u]);i&&(r+="?"+i)}e="IFRAME_"+c;o=$("<iframe style='position:absolute; left:0; right:0; top:0; bottom:0; width:100%; height:100%; border:none;' border='no' name='"+e+"' id='"+e+"'><\/frame>");a.append(o);_portalInfo.hostingContext!="HtmlViewer"||_portalInfo.testingInExternalWebBrowser||f.Hide(!1);portal.Navigate(r,o,f);_portalInfo.hostingContext!="HtmlViewer"||_portalInfo.testingInExternalWebBrowser||f.Close()}function si(n,t){t===undefined&&(t=!0);t&&(n=n.replace(/ id=\"/g,' id="'+c),n=n.replace(/ id=\'/g," id='"+c),n=n.replace(/ for=\"/g,' for="'+c),n=n.replace(/ for=\'/g," for='"+c));a.html(n);(i.width=="auto"||i.height=="auto")&&ft()}function hi(n){var t=$.extend({},ModalShowDefaults,n),e;t.title&&(i.title=t.title);t.titleIcon&&(i.titleIcon=t.titleIcon);u?r.addClass("showing"):(oi+=1,y=oi,u=$("<div class='is-modal-overlay' style='display:none'><\/div>"),u.css("z-index",2+(y-1)*11),i.allowMinimise&&u.addClass("allows-minimise"),$("body").append(u),r=$("<div id='"+c+"' class='is-modal showing' style='display:none'><div class='is-modal-title-buttons'><div class='is-modal-minimise is-symbol-minimise-window' title='Temporarily minimise this form to view information underneath'><\/div><div class='is-modal-open-window is-symbol-open-window' title='Open in a new Web Browser Tab\n\nThis provides a URL that can be bookmarked in your browser or sent to someone'><\/div><div class='is-modal-close is-symbol-close' title='Close'><\/div><\/div><div class='is-form-actions-menu' style='display:none'><\/div><div class='is-modal-title-icon is-no-select'><\/div><div class='is-modal-title is-no-select'><\/div><div class='is-modal-header' style='display:none'><\/div><div class='is-modal-body'><\/div><div class='is-modal-footer' style='display:none'><ul class='is-modal-dialog-buttons main' style='display:none'><\/ul><ul class='is-modal-dialog-buttons other' style='display:none'><\/ul><\/div><\/div><\/div>"),$("body").append(r),r.css("z-index",10+(y-1)*11),g=$(".is-modal-minimise",r),nt=$(".is-modal-open-window",r),k=$(".is-modal-close",r),w=$(".is-modal-title-icon",r),p=$(".is-modal-title",r),d=$(".is-modal-header",r),a=$(".is-modal-body",r),v=$(".is-modal-footer",r),ot=$(".main",r),st=$(".other",r),et=$(".is-form-actions-menu",r),g.click(function(n){n.preventDefault();$UI.ModalMinimise(f,i.parentModal)}),nt.click(function(n){n.preventDefault();$App&&$App.RunAppShortcutInNewBrowserWindow(i.appShortcutUrl)}),k.click(function(n){n.preventDefault();i.onClose?i.onClose():lt(i.deleteOnClose)}),$(window).bind("resize.modal"+y,function(){ft();i.onResize&&i.onResize()}));t.content!=null?a.html(t.content):t.contentSourceElement&&(typeof t.contentSourceElement=="string"&&(t.contentSourceElement=$("#"+t.contentSourceElement)),b=t.contentSourceElement,tt=t.contentSourceElement.parent(),e=t.contentSourceElement.detach(),a.append(e),e.show());pt(i.title);i.allowMinimise?(g.show(),r.addClass("allows-minimise")):(g.hide(),r.removeClass("allows-minimise"));i.appShortcutUrl?nt.show():nt.hide();i.showClose?k.show():k.hide();ft();rt=!0;u.css({display:""});r.show();window.setTimeout(function(){r.removeClass("showing")},50);vt();it+=1;it==1&&$("body").addClass("is-has-modal");i.focusActionId&&window.setTimeout(function(){vi(i.focusActionId)},10)}function ci(){ef(et,l,at)}function ft(){var f=parseInt(i.minHeight),e=parseInt(i.minWidth),t,u,n;if(f||(f=460),e||(e=620),t=!1,(window.innerWidth<=640||window.innerHeight<=480)&&(t=!0),!t){r.removeClass("is-modal-full");u={width:i.width};i.height=="auto"||(u.height=i.height);r.css(u);n=i.width+"";n&&n.substr(n.length-1,1)=="%"&&(i.minWidth&&r.css({minWidth:i.minWidth}),i.maxWidth&&r.css({maxWidth:i.maxWidth}));n=i.height+"";n&&n.substr(n.length-1,1)=="%"&&(i.minHeight&&r.css({minHeight:i.minHeight}),i.maxHeight&&r.css({maxHeight:i.maxHeight}));var o=r.outerHeight(),s=r.outerWidth(),h=Math.max($(window).height()-o,0)/3,c=Math.max($(window).width()-s,0)/2;r.css({top:h,left:c});r.outerWidth()>=window.innerWidth-20?t=!0:r.outerHeight()>=window.innerHeight-20&&(t=!0)}r.removeClass("forced-windowed");t&&(i.forceWindowed?(r.css({top:8,left:8,bottom:8,right:8,width:"",height:"",minWidth:"",minHeight:""}),r.addClass("forced-windowed")):(r.addClass("is-modal-full"),r.css({top:0,left:0,width:"100%",height:"100%",minWidth:"",minHeight:""})))}function li(){return c}function ai(){return r}function vt(){var n=!1;u&&(yt("[buttons]",ot)>0&&(n=!0),yt("[buttonsOther]",st)>0&&(n=!0),n?v.show():v.hide())}function yt(n,t){var e=0,o=!1,i,r,u,f;for(t.children().remove(),f=0;f<l.Actions().length;f++)if(i=l.Actions()[f],(i.groupId.toUpperCase()==n.toUpperCase()||i.repeatInGroupId&&i.repeatInGroupId.toUpperCase()==n.toUpperCase())&&i.visible){if(e+=1,u=$("<li><button class='is-button'><\/button><\/li>"),t.append(u),r=$("button",u),r.attr("action-id",i.actionId),n=="[buttonsOther]"&&i.icon&&mIconResolver?(r.addClass("action-other"),iconUrl=iconUrl=GetIconUrl(i.icon,16),r.css("background-image","url("+iconUrl+")"),r.attr("title",i.tooltipText||i.caption)):(r.text(i.caption),r.attr("title",i.tooltipText)),i.enabled||r.attr("disabled","disabled"),i.buttonStyle)r.addClass(i.buttonStyle);else switch(i.actionId.toUpperCase()){case"ADD":r.addClass("positive");break;case"CANCEL":case"CLOSE":r.addClass("cancel");break;case"CUSTOMISE":r.addClass("customise");u.addClass("system");r.attr("title","Customise");break;case"DELETE":r.addClass("danger");break;case"FINISH":case"OK":case"SAVE":r.addClass("ok");break;case"REFRESH":r.addClass("refresh");u.addClass("system");r.attr("title","Refresh");break;default:r.addClass("normal")}i.enabled&&(i.handler?function(n){r.click(function(){n.handler()})}(i):function(n){r.click(function(){at(n.actionId,n.data?n.data:n.applicationShortcutUrl)})}(i))}if(n=="[buttonsOther]"){for(f=0;f<l.Actions().length;f++)if(i=l.Actions()[f],i.groupId.substr(0,1)!="["&&i.visible){o=!0;e+=1;break}o&&(u=$("<li class='system'><button class='is-button actions' title='Actions'><\/button><\/li>"),t.append(u),r=$("button",u),function(){r.click(function(){ci()})}())}return e>0?t.show():t.hide(),e}function vi(n){window.setTimeout(function(){var t=$("button[action-id='"+n+"']",r);t.focus()},10)}function pt(n){if(n===undefined)return i.title;n?(p.text(n),p.show()):(p.text(""),p.hide())}function yi(n){s||(n||(n=""),s=$("<div class='is-modal-overlay top is-wait-block' style='display:none'><div class='is-wait'><div class='is-wait1'><\/div><div class='is-wait2'><\/div><div class='is-wait3'><\/div><\/div><label>"+t(n)+"<\/label><\/div>"),r.append(s),s.show())}function pi(n){s&&($("label",s).text(n),s.show())}function wi(){s&&(s.remove(),s=null)}var l,et,k,a,ot,v,d,r,y,c,p,w,g,nt,i,st,u,b,tt,rt=!1,s,f;return ModalDefaults={formKey:"",formType:"",dialogResult:"Cancel",content:"",title:"",titleIcon:"",width:"50%",height:"50%",minWidth:620,minHeight:460,maxWidth:"",maxHeight:"",forceWindowed:!0,showClose:!0,deleteOnClose:!0,closeOnEscape:!1,actionCaption:"",onAction:null,onActionNotification:null,onChildClosed:null,onClose:null,onRefresh:null,onResize:null,onAfterClose:null,appShortcutUrl:"",parentModal:null,allowMinimise:!1},i=$.extend({},ModalDefaults,n),ModalShowDefaults={content:null,contentSourceElement:null,title:null},c="MODAL"+h(!0)+"ENDMODAL",l=new rr,f={TypeName:"Modal",Actions:wt,Close:ut,ContentElement:bt,DialogResult:kt,FormDisable:gt,FormEnable:ni,GetElement:dt,Hide:lt,LoadPortalPage:ei,ModalId:li,ModalElement:ai,ParentModal:fi,Refresh:vt,RenderView:si,Show:hi,Title:pt,NotifyChildClosed:ti,OnAction:ii,OnClose:ri,OnResize:ui,WaitShow:yi,WaitUpdate:pi,WaitHide:wi,CloseOnEscape:function(){return i.closeOnEscape},Tag:{}},o.push(f),f}function hf(t,i){function l(n,t){if(t&&(t.ChangeHandled=!0),a.onChange)if(t&&t.fieldUpdated)a.onChange(t.fieldUpdated);else a.onChange("")}function wt(n){var t=y.StdTrans[n.row.listIndex];n.row.cells.Description.value=t.ElementDescription;n.row.cells.Value.value=t.ValueBasis=="SetValue"?t.ValueCurrency:t.ValueDescription;t.ValueBasis=="SetValue"&&t.AllowChange&&t.Cycle=="Opening"||(n.row.cells.Value.readOnly=!0);n.row.cells.Description.readOnly=!0;t.Cycle!="Opening"&&(n.row.cells.Value.tooltipText=t.CycleDescription);n.row.cells.Description.bold=t.Cycle=="Opening"}function bt(){kt()}function kt(){r.gridStdTrans.ActiveDataRowListIndex()==-1?(r.gridStdTrans.Actions().SetEnabled("DeleteRow",!1),r.gridStdTrans.Actions().SetEnabled("RowMoveUp",!1),r.gridStdTrans.Actions().SetEnabled("RowMoveDown",!1)):(r.gridStdTrans.Actions().SetEnabled("DeleteRow",!0),r.gridStdTrans.Actions().SetEnabled("RowMoveUp",r.gridStdTrans.ActiveDataRowListIndex()>0),r.gridStdTrans.Actions().SetEnabled("RowMoveDown",r.gridStdTrans.ActiveDataRowListIndex()<y.StdTrans.length-1));r.gridStdTrans.RefreshButtons();r.gridStdTrans.Focus()}function dt(n){var t=y.StdTrans[n.row.listIndex],i;switch(n.columnKey){case"Value":t.ValueBasis=="SetValue"?t.ValueCurrency!=n.newValue&&(t.ValueCurrency=n.newValue,i=JSON.parse(t.Json),i.ValueCurrency=t.ValueCurrency,t.Json=JSON.stringify(i),l()):window.alert("todo:")}n.refreshRow=!0}function gt(n){it(n.row.listIndex)}function it(t){b=t;var r=t==-1?"{ AccountTypeId: '"+y.AccountTypeId+"' }":y.StdTrans[t].Json,i={EditJson:!0,StandardTransactionJson:r};a.stdTransWidgetId?n.UI.Forms.ShowHtmlWidgetModal(a.stdTransWidgetId,{startupParametersJson:JSON.stringify(i)},rt):n.UI.Forms.ShowHtmlWidgetModal("HtmlWidget:AccountStandardTransaction",{startupParametersJson:JSON.stringify(i)},rt)}function rt(n,t){var u=t,i;t=JSON.parse(t);switch(n){case"RecordUpdated":b==-1?(i={Added:!0},y.StdTrans.push(i)):i=y.StdTrans[b];i.Json=u;i.ElementDescription=t.ElementDescription;i.ValueCurrency=t.ValueCurrency;i.ValueDescription=t.ValueDescription;b==-1?(r.gridStdTrans.VirtualDataRefresh(y.StdTrans),r.gridStdTrans.ActivateLastDataRow()):r.gridStdTrans.RefreshRow(b);l()}}function ut(n,t){t&&(t.ChangeHandled=!0);r.cboInterestCycle.Text().toUpperCase()=="AT MATURITY"?r.dateInterestCycleDateFirst.ReadOnly(!1):r.dateInterestCycleDateFirst.ReadOnly(!0);n&&l()}function ft(n,t){if(t&&(t.ChangeHandled=!0),o.OptionAllowStartupInterest){if(r.cboStartupInterestType.ListIndex()==-1&&r.cboStartupInterestType.Text(y.StartupInterestTypeText),r.cboStartupInterestType.ListIndex()!=-1)switch(o.StartupInterestTypeList[r.cboStartupInterestType.ListIndex()].Code){case"FixedRate":r.cboStartupInterestPeriod.VisibleRow(!0);r.numStartupInterestRate.VisibleRow(!0);r.cboStartupInterestRateTable.VisibleRow(!1);r.numStartupInterestRatePremium.VisibleRow(!1);r.dateStartupInterestToDate.VisibleRow(!1);break;case"InterestFree":r.cboStartupInterestPeriod.VisibleRow(!0);r.numStartupInterestRate.VisibleRow(!1);r.cboStartupInterestRateTable.VisibleRow(!1);r.numStartupInterestRatePremium.VisibleRow(!1);r.dateStartupInterestToDate.VisibleRow(!1);break;case"NotApplicable":r.cboStartupInterestPeriod.VisibleRow(!1);r.dateStartupInterestToDate.VisibleRow(!1);r.numStartupInterestRate.VisibleRow(!1);r.cboStartupInterestRateTable.VisibleRow(!1);r.numStartupInterestRatePremium.VisibleRow(!1);r.dateStartupInterestToDate.VisibleRow(!1);break;case"RateTable":r.cboStartupInterestPeriod.VisibleRow(!0);r.numStartupInterestRate.VisibleRow(!1);r.cboStartupInterestRateTable.VisibleRow(!0);r.numStartupInterestRatePremium.VisibleRow(!0);break;default:console.warn("widget_ui.AccountFinancial: Unhandled Startup Interest Type '"+o.StartupInterestTypeList[r.cboStartupInterestType.ListIndex()].Code+"'")}n&&l(n,{fieldUpdated:"StartupInterestType"})}}function et(n,t){if(t&&(t.ChangeHandled=!0),r.cboInterestType.ListIndex()==-1&&r.cboInterestType.Text(y.InterestTypeText),r.cboInterestType.ListIndex()!=-1)switch(o.InterestTypeList[r.cboInterestType.ListIndex()].Code){case"FixedRate":r.numInterestRate.VisibleRow(o.OptionAllowInterest);r.cboInterestRateTable.VisibleRow(!1);r.numInterestRatePremium.VisibleRow(!1);break;case"FloatingRate":r.numInterestRate.VisibleRow(o.OptionAllowInterest);r.cboInterestRateTable.VisibleRow(!1);r.numInterestRatePremium.VisibleRow(!1);break;case"InterestFree":r.numInterestRate.VisibleRow(!1);r.cboInterestRateTable.VisibleRow(!1);r.numInterestRatePremium.VisibleRow(!1);break;case"NotApplicable":r.numInterestRate.VisibleRow(!1);r.cboInterestRateTable.VisibleRow(!1);r.numInterestRatePremium.VisibleRow(!1);break;case"RateTable":r.numInterestRate.VisibleRow(!1);r.cboInterestRateTable.VisibleRow(o.OptionAllowInterest);r.numInterestRatePremium.VisibleRow(o.OptionAllowInterest);break;default:console.warn("widget_ui.AccountFinancial: Unhandled Interest Type '"+o.InterestTypeList[r.cboInterestType.ListIndex()].Code+"'")}n&&l(n,{fieldUpdated:"InterestType"})}function ti(n,t){t&&(t.ChangeHandled=!0);r.cboInterestPaymentType.ListIndex()==-1&&r.cboInterestPaymentType.Text(y.InterestPaymentTypeText);n&&l()}function ot(n,t){if(t&&(t.ChangeHandled=!0),o.OptionAllowMinimumPayment){switch(o.MinimumPaymentBasisList[r.cboMinimumPaymentBasis.ListIndex()].Code){case"None":case"InterestAndFeesOnly":case"InterestOnly":r.numMinimumPaymentValue.VisibleRow(!1);r.numMinimumPaymentPercent.VisibleRow(!1);r.cboMinimumPaymentHoldToPeriod.VisibleRow(!1);break;case"Instalment":r.numMinimumPaymentValue.VisibleRow(!1);r.numMinimumPaymentPercent.VisibleRow(!1);r.cboMinimumPaymentHoldToPeriod.VisibleRow(o.OptionAllowMinimumPaymentHoldTo);break;case"OngoingSetValue":case"SetValue":r.numMinimumPaymentValue.VisibleRow(!0);r.numMinimumPaymentPercent.VisibleRow(!1);r.cboMinimumPaymentHoldToPeriod.VisibleRow(o.OptionAllowMinimumPaymentHoldTo);break;case"PercentOfBalance":r.numMinimumPaymentValue.VisibleRow(!1);r.numMinimumPaymentPercent.VisibleRow(!0);r.cboMinimumPaymentHoldToPeriod.VisibleRow(o.OptionAllowMinimumPaymentHoldTo);break;default:r.numMinimumPaymentValue.VisibleRow(!0);r.numMinimumPaymentPercent.VisibleRow(!0);r.cboMinimumPaymentHoldToPeriod.VisibleRow(o.OptionAllowMinimumPaymentHoldTo)}n&&l()}}function st(n,t){t&&(t.ChangeHandled=!0);(r.dateOpeningDate.Value()&&r.datePaymentFirstDate.ReadOnly()||!r.datePaymentFirstDate.Value())&&r.datePaymentFirstDate.Value(r.dateOpeningDate.Value());n&&l(n,{fieldUpdated:"OpeningDate"})}function ht(n,t){t&&(t.ChangeHandled=!0);r.cboMinimumPaymentHoldToPeriod.Text().toUpperCase()=="ON DATE"?r.dateMinimumPaymentHoldToDate.VisibleRow(!0):r.dateMinimumPaymentHoldToDate.VisibleRow(!1);n&&l()}function ct(n,t){t&&(t.ChangeHandled=!0);r.cboTermCycle.Text().toUpperCase()=="ON DATE"?r.dateTermCycleOnDate.VisibleRow(!0):r.dateTermCycleOnDate.VisibleRow(!1);n&&l()}function ii(n,t){t&&(t.ChangeHandled=!0);n&&l(n,{fieldUpdated:"PaymentCycle"})}function lt(n,t){t&&(t.ChangeHandled=!0);r.cboPaymentFirstDatePeriod.Text().toUpperCase()=="ON DATE"?r.datePaymentFirstDate.VisibleRow(!0):r.datePaymentFirstDate.VisibleRow(!1);n&&l()}function at(n,t){t&&(t.ChangeHandled=!0);r.numPaymentRegular.ValueIsBlank()?(r.numTermNumberOfPayments.ReadOnly(!1),r.cboTermCycle.ReadOnly(!1)):(r.numTermNumberOfPayments.ReadOnly(!0),r.cboTermCycle.ReadOnly(!0));n&&l()}function vt(n,t){(t&&(t.ChangeHandled=!0),o.OptionAllowStartupInterest)&&(r.cboStartupInterestPeriod.Text().toUpperCase()=="TO DATE"?r.cboStartupInterestType.ListIndex()!=-1&&o.StartupInterestTypeList[r.cboStartupInterestType.ListIndex()].Code!="NotApplicable"?r.dateStartupInterestToDate.VisibleRow(!0):r.dateStartupInterestToDate.VisibleRow(!1):r.dateStartupInterestToDate.VisibleRow(!1),n&&l())}function nt(){if(a.visible?k.show():k.hide(),y)switch(y.AccountClass){case"Deposit":r.lblTerm.Text("Term");r.cboTermCycle.VisibleRow(!o.TermOnCall);r.dateMaturityDate.VisibleRow(!1);r.numTermNumberOfPayments.VisibleRow(!1);r.lblMinimumPayments.VisibleRow(!1);r.lblPayments.VisibleRow(!1);r.cboPaymentCycle.VisibleRow(!1);r.cboPaymentFirstDatePeriod.VisibleRow(!1);r.datePaymentFirstDate.VisibleRow(!1);r.numPaymentRegular.VisibleRow(!1);r.numPaymentBalloon.VisibleRow(!1);r.lblResidualValue.VisibleRow(!1);r.numResidualValue.VisibleRow(!1);r.lblTaxCategory.VisibleRow(o.OptionAllowTaxCategory);r.cboTaxCategory.VisibleRow(o.OptionAllowTaxCategory);r.lblInterest.VisibleRow(!0);r.cboInterestCycle.VisibleRow(o.OptionAllowInterestCycle);r.cboInterestCycle.ReadOnly(!o.NewAccountWizard_InterestCycleUpdateable);r.dateInterestCycleDateFirst.VisibleRow(o.OptionAllowInterestCycle);r.dateInterestCycleDateFirst.ReadOnly(!o.NewAccountWizard_InterestCycleUpdateable);r.cboInterestPaymentType.VisibleRow(!0);r.lblStartupInterestRate.VisibleRow(!1);r.cboStartupInterestType.VisibleRow(!1);r.cboStartupInterestPeriod.VisibleRow(!1);r.numStartupInterestRate.VisibleRow(!1);r.numStartupInterestRatePremium.VisibleRow(!1);r.dateStartupInterestToDate.VisibleRow(!1);r.lblInterestRate.VisibleRow(o.OptionAllowInterest);r.cboInterestType.VisibleRow(o.OptionAllowInterest);r.cmdSchedule&&r.cmdSchedule.show();r.cmdResetFinancial&&r.cmdResetFinancial.show();break;case"Disbursement":r.lblTerm.Text("Opening date");r.cboTermCycle.VisibleRow(!1);r.dateMaturityDate.VisibleRow(!1);r.numTermNumberOfPayments.VisibleRow(!1);r.lblMinimumPayments.VisibleRow(!1);r.lblPayments.VisibleRow(!1);r.cboPaymentCycle.VisibleRow(!1);r.cboPaymentFirstDatePeriod.VisibleRow(!1);r.datePaymentFirstDate.VisibleRow(!1);r.numPaymentRegular.VisibleRow(!1);r.numPaymentBalloon.VisibleRow(!1);r.lblResidualValue.VisibleRow(!1);r.numResidualValue.VisibleRow(!1);r.lblTaxCategory.VisibleRow(!1);r.cboTaxCategory.VisibleRow(!1);r.cboInterestCycle.VisibleRow(!1);r.dateInterestCycleDateFirst.VisibleRow(!1);r.lblInterest.VisibleRow(!1);r.cboInterestPaymentType.VisibleRow(!1);r.dateInterestCycleDateFirst.VisibleRow(!1);r.lblStartupInterestRate.VisibleRow(!1);r.cboStartupInterestType.VisibleRow(!1);r.cboStartupInterestPeriod.VisibleRow(!1);r.numStartupInterestRate.VisibleRow(!1);r.numStartupInterestRatePremium.VisibleRow(!1);r.dateStartupInterestToDate.VisibleRow(!1);r.lblInterestRate.VisibleRow(!1);r.cboInterestType.VisibleRow(!1);r.cboInterestCycle.VisibleRow(!1);r.numInterestRate.VisibleRow(!1);r.numInterestRatePremium.VisibleRow(!1);r.dateInterestCycleDateFirst.VisibleRow(!1);r.lblOtherInterest.VisibleRow(!1);r.numOtherInterestRate.VisibleRow(!1);r.cmdSchedule&&r.cmdSchedule.hide();r.cmdResetFinancial&&r.cmdResetFinancial.hide();break;case"LoanFT":r.lblTerm.Text("Term");switch(o.TermEntryMethod){case"NumberOfPayments":r.cboTermCycle.VisibleRow(!1);r.numTermNumberOfPayments.VisibleRow(!0);break;case"Term":r.cboTermCycle.VisibleRow(!0);r.numTermNumberOfPayments.VisibleRow(!1)}r.dateTermCycleOnDate.VisibleRow(!1);r.dateMaturityDate.VisibleRow(!1);r.lblMinimumPayments.VisibleRow(!1);r.lblPayments.VisibleRow(!0);r.cboPaymentCycle.VisibleRow(!0);r.lblTaxCategory.VisibleRow(!1);r.cboTaxCategory.VisibleRow(!1);r.lblInterest.VisibleRow(o.OptionAllowInterestCycle);r.cboInterestCycle.VisibleRow(o.OptionAllowInterestCycle);r.cboInterestCycle.ReadOnly(!o.NewAccountWizard_InterestCycleUpdateable);r.dateInterestCycleDateFirst.VisibleRow(!1);r.cboInterestPaymentType.VisibleRow(!1);r.lblInterestRate.VisibleRow(o.OptionAllowInterest);r.cboInterestType.VisibleRow(o.OptionAllowInterest);r.cmdSchedule&&r.cmdSchedule.show();r.cmdResetFinancial&&r.cmdResetFinancial.show();break;case"LoanFR":r.lblTerm.Text("Term");switch(o.TermEntryMethod){case"NumberOfPayments":r.cboTermCycle.VisibleRow(!1);r.numTermNumberOfPayments.VisibleRow(!0);break;case"Term":r.cboTermCycle.VisibleRow(!0);r.numTermNumberOfPayments.VisibleRow(!1)}r.dateTermCycleOnDate.VisibleRow(!1);r.dateMaturityDate.VisibleRow(!1);r.lblMinimumPayments.VisibleRow(!1);r.lblPayments.VisibleRow(!0);r.cboPaymentCycle.VisibleRow(!0);r.lblTaxCategory.VisibleRow(!1);r.cboTaxCategory.VisibleRow(!1);r.lblInterest.VisibleRow(o.OptionAllowInterestCycle);r.cboInterestCycle.VisibleRow(o.OptionAllowInterestCycle);r.cboInterestCycle.ReadOnly(!o.NewAccountWizard_InterestCycleUpdateable);r.dateInterestCycleDateFirst.VisibleRow(!1);r.cboInterestPaymentType.VisibleRow(!1);r.lblInterestRate.VisibleRow(o.OptionAllowInterest);r.cboInterestType.VisibleRow(o.OptionAllowInterest);r.cmdSchedule&&r.cmdSchedule.show();r.cmdResetFinancial&&r.cmdResetFinancial.show();break;case"LoanRC":r.lblTerm.Text("Opening date");r.cboTermCycle.VisibleRow(!1);r.numTermNumberOfPayments.VisibleRow(!1);r.dateTermCycleOnDate.VisibleRow(!1);r.dateMaturityDate.VisibleRow(!0);r.lblMinimumPayments.VisibleRow(!0);r.lblPayments.VisibleRow(!1);r.cboPaymentCycle.VisibleRow(!1);r.cboPaymentFirstDatePeriod.VisibleRow(!1);r.datePaymentFirstDate.VisibleRow(!1);r.numPaymentRegular.VisibleRow(!1);r.numPaymentBalloon.VisibleRow(!1);r.lblResidualValue.VisibleRow(!1);r.numResidualValue.VisibleRow(!1);r.lblTaxCategory.VisibleRow(!1);r.cboTaxCategory.VisibleRow(!1);r.lblInterest.VisibleRow(o.OptionAllowInterestCycle);r.cboInterestCycle.VisibleRow(o.OptionAllowInterestCycle);r.cboInterestCycle.ReadOnly(!o.NewAccountWizard_InterestCycleUpdateable);r.dateInterestCycleDateFirst.VisibleRow(o.OptionAllowInterestCycle);r.dateInterestCycleDateFirst.ReadOnly(!o.NewAccountWizard_InterestCycleUpdateable);r.cboInterestPaymentType.VisibleRow(!1);r.lblInterestRate.VisibleRow(o.OptionAllowInterest);r.cboInterestType.VisibleRow(o.OptionAllowInterest);r.cmdSchedule&&r.cmdSchedule.show();r.cmdResetFinancial&&r.cmdResetFinancial.show();break;default:console.warn("widget_ui.AccountFinancial: AccountClass '"+y.AccountClass+"' not handled.")}}function ri(){r.dateOpeningDate.Focus()}function fi(n){if(n===undefined)return a.visible;a.visible=n;nt(!1)}function ei(n){if(n===undefined)return a.readOnly;n!=a.readOnly&&(a.readOnly=n,nt())}function oi(n){if(n===undefined)return a.stdTransWidgetId;a.stdTransWidgetId=n}function si(t){var i,u;try{i=JSON.parse(t)}catch(f){console.warn("widget.UI.AccountFinancial.FromAccountCalcJson: "+f)}i&&(y=i,i.Config?(o=i.Config,r.cboTermCycle.ListFromCsvString(o.TermList),r.cboTermCycle.LimitToList(o.TermLimitToList),r.cboPaymentCycle.ListFromCsvString(o.PaymentCycleList),r.cboPaymentCycle.LimitToList(o.PaymentCycleLimitToList),r.cboPaymentFirstDatePeriod.ListFromCsvString(o.PaymentFirstPeriodList),r.cboPaymentFirstDatePeriod.VisibleRow(o.OptionAllowFirstPaymentDate),r.datePaymentFirstDate.VisibleRow(o.OptionAllowFirstPaymentDate),r.numPaymentRegular.VisibleRow(o.OptionAllowRegularPayment),r.numPaymentBalloon.VisibleRow(o.OptionAllowBalloonPayment),r.lblResidualValue.VisibleRow(o.OptionAllowResidualValue),r.numResidualValue.VisibleRow(o.OptionAllowResidualValue),o.CreditLimitCount==0?(r.lblCreditLimit.VisibleRow(!1),r.numCreditLimit1.VisibleRow(!1),r.numCreditLimit2.VisibleRow(!1),r.numCreditLimit3.VisibleRow(!1)):o.CreditLimitCount==1?(r.lblCreditLimit.Text("Credit Limit"),r.lblCreditLimit.VisibleRow(!0),r.numCreditLimit1.VisibleRow(!0),r.numCreditLimit2.VisibleRow(!1),r.numCreditLimit3.VisibleRow(!1)):(r.lblCreditLimit.Text("Credit Limits"),r.lblCreditLimit.VisibleRow(!0),r.numCreditLimit1.VisibleRow(!0),r.numCreditLimit2.VisibleRow(o.CreditLimitCount>1),r.numCreditLimit3.VisibleRow(o.CreditLimitCount>2)),r.numCreditLimit1.Caption(o.CreditLimit1Description+":"),r.numCreditLimit2.Caption(o.CreditLimit2Description+":"),r.numCreditLimit3.Caption(o.CreditLimit3Description+":"),o.OptionAllowMinimumPayment?(r.lblMinimumPayments.VisibleRow(!0),r.cboMinimumPaymentBasis.VisibleRow(!0),r.cboMinimumPaymentBasis.ListFromCollection(o.MinimumPaymentBasisList,"Description"),r.cboMinimumPaymentHoldToPeriod.VisibleRow(o.OptionAllowMinimumPaymentHoldTo),r.cboMinimumPaymentHoldToPeriod.ListFromCsvString(o.MinimumPaymentHoldToList),r.cboMinimumPaymentHoldToPeriod.LimitToList(o.MinimumPaymentHoldToLimitToList)):(r.lblMinimumPayments.VisibleRow(!1),r.cboMinimumPaymentBasis.VisibleRow(!1),r.numMinimumPaymentValue.VisibleRow(!1),r.numMinimumPaymentPercent.VisibleRow(!1),r.cboMinimumPaymentHoldToPeriod.VisibleRow(!1)),o.OptionAllowTaxCategory&&r.cboTaxCategory.RefreshFromStandardRange("TaxCategories"),r.cboInterestCycle.ListFromCsvString(o.InterestCycleList),r.cboInterestCycle.LimitToList(o.InterestCycleLimitToList),r.cboInterestPaymentType.ListFromCollection(o.InterestPaymentTypeList,"Description"),o.OptionAllowStartupInterest?(r.lblStartupInterestRate.VisibleRow(!0),r.cboStartupInterestType.ListFromCollection(o.StartupInterestTypeList,"Description"),r.cboStartupInterestType.VisibleRow(!0),r.cboStartupInterestPeriod.ListFromCsvString(o.StartupInterestPeriodList),r.cboStartupInterestPeriod.LimitToList(o.StartupInterestPeriodLimitToList),r.cboStartupInterestRateTable.RefreshFromStandardRange("RateTables",o.StartupRateTableFilter),r.cboStartupInterestRateTable.BlankTip(o.StartupStandardRateTableId),r.cboStartupInterestRateTable.AllowBlank(o.StartupStandardRateTableId!="")):(r.lblStartupInterestRate.VisibleRow(!1),r.cboStartupInterestType.VisibleRow(!1),r.cboStartupInterestPeriod.VisibleRow(!1),r.numStartupInterestRate.VisibleRow(!1),r.cboStartupInterestRateTable.VisibleRow(!1),r.numStartupInterestRatePremium.VisibleRow(!1),r.dateStartupInterestToDate.VisibleRow(!1)),r.cboInterestType.ListFromCollection(o.InterestTypeList,"Description"),r.cboInterestRateTable.RefreshFromStandardRange("RateTables",o.RateTableFilter),r.cboInterestRateTable.BlankTip(o.StandardRateTableId),r.cboInterestRateTable.AllowBlank(o.StandardRateTableId!=""),r.lblOtherInterest.VisibleRow(o.OtherInterestShow),r.numOtherInterestRate.VisibleRow(o.OtherInterestShow)):(o={},console.warn("widget_ui.AccountFinancial: FromAccountCalcJson does not contain a Config object to enable configuration such as Term Entry Method")),r.dateOpeningDate.Value(i.OpeningDate),r.cboTermCycle.Text(i.TermCycle),ct(),r.dateTermCycleOnDate.Value(i.TermCycleOnDate),r.numTermNumberOfPayments.Value(i.TermNumberOfPayments),r.dateMaturityDate.Value(i.DateMaturity),r.cboMinimumPaymentBasis.Text(i.MinimumPaymentBasisText),ot(),r.numMinimumPaymentValue.Value(i.MinimumPaymentValue),r.numMinimumPaymentPercent.Value(i.MinimumPaymentPercent),r.cboMinimumPaymentHoldToPeriod.Text(i.MinimumPaymentHoldToPeriod),ht(),r.dateMinimumPaymentHoldToDate.Value(i.MinimumPaymentHoldToDate),r.cboPaymentCycle.Text(i.PaymentCycle),r.cboPaymentFirstDatePeriod.Text(i.PaymentFirstDatePeriod),lt(),r.datePaymentFirstDate.Value(i.PaymentFirstDate),st(),r.numPaymentRegular.BlankTip(n.FormatCurrency(i.PaymentRegular)),i.PaymentRegularOverride!=0?r.numPaymentRegular.Value(i.PaymentRegularOverride):r.numPaymentRegular.Value(null),at(),r.numPaymentBalloon.Value(i.PaymentBalloon),r.numResidualValue.Value(i.ResidualValue),r.numCreditLimit1.Value(i.CreditLimit1),r.numCreditLimit2.Value(i.CreditLimit2),r.numCreditLimit3.Value(i.CreditLimit3),r.cboTaxCategory.Text(i.TaxCategoryId),r.cboInterestCycle.Text(i.InterestCycle),ut(),r.dateInterestCycleDateFirst.Value(i.InterestCycleDateFirst),r.cboInterestPaymentType.Text(i.InterestPaymentTypeText),et(),r.cboStartupInterestType.Text(i.StartupInterestTypeText),ft(),r.cboStartupInterestPeriod.Text(i.StartupInterestPeriod),vt(),r.dateStartupInterestToDate.Value(i.StartupInterestToDate),r.numStartupInterestRate.Value(i.StartupInterestRate),r.cboStartupInterestRateTable.Text(i.StartupInterestRateTableId),r.numStartupInterestRatePremium.Value(i.StartupInterestRatePremium),r.cboInterestType.Text(i.InterestTypeText),r.numInterestRate.Value(i.InterestRate),r.cboInterestRateTable.Text(i.InterestRateTableId),r.numInterestRatePremium.Value(i.InterestRatePremium),r.numOtherInterestRate.Value(i.OtherInterestRate),nt(),a.showStdTrans&&(r.gridStdTrans.Editing()?u=window.setInterval(function(){r.gridStdTrans.Editing()||(window.clearInterval(u),u=null,r.gridStdTrans.VirtualDataRefresh(i.StdTrans,!0))},100):(r.gridStdTrans.VirtualDataRefresh(i.StdTrans,!0),b==-1?r.gridStdTrans.ActivateLastDataRow(!0):r.gridStdTrans.ActivateFirstDataRow(!0))))}function pt(){var n={};return y&&(n=JSON.parse(JSON.stringify(y)),n.FieldUpdated=""),n.OpeningDate=r.dateOpeningDate.Value(),n.TermCycle=r.cboTermCycle.Text(),n.TermCycleOnDate=r.dateTermCycleOnDate.Value(),n.TermNumberOfPayments=r.numTermNumberOfPayments.Value(),n.DateMaturity=r.dateMaturityDate.Value(),n.MinimumPaymentBasisText=r.cboMinimumPaymentBasis.Text(),n.MinimumPaymentValue=r.numMinimumPaymentValue.Value(),n.MinimumPaymentPercent=r.numMinimumPaymentPercent.Value(),n.MinimumPaymentHoldToPeriod=r.cboMinimumPaymentHoldToPeriod.Text(),n.MinimumPaymentHoldToDate=r.dateMinimumPaymentHoldToDate.Value(),n.PaymentCycle=r.cboPaymentCycle.Text(),n.PaymentFirstDatePeriod=r.cboPaymentFirstDatePeriod.Text(),n.PaymentFirstDate=r.datePaymentFirstDate.Value(),n.PaymentRegularOverride=r.numPaymentRegular.Value(),n.PaymentBalloon=r.numPaymentBalloon.Value(),n.ResidualValue=r.numResidualValue.Value(),n.CreditLimit1=r.numCreditLimit1.Value(),n.CreditLimit2=r.numCreditLimit2.Value(),n.CreditLimit3=r.numCreditLimit3.Value(),n.TaxCategoryId=r.cboTaxCategory.Text(),n.InterestCycle=r.cboInterestCycle.Text(),n.InterestCycleDateFirst=r.dateInterestCycleDateFirst.Value(),n.InterestPaymentTypeText=r.cboInterestPaymentType.Text(),n.StartupInterestTypeText=r.cboStartupInterestType.Text(),n.StartupInterestPeriod=r.cboStartupInterestPeriod.Text(),n.StartupInterestToDate=r.dateStartupInterestToDate.Value(),n.StartupInterestRate=r.numStartupInterestRate.Value(),n.StartupInterestRateTableId=r.cboStartupInterestRateTable.Text(),n.StartupInterestRatePremium=r.numStartupInterestRatePremium.Value(),n.InterestTypeText=r.cboInterestType.Text(),n.InterestRate=r.numInterestRate.Value(),n.InterestRateTableId=r.cboInterestRateTable.Text(),n.InterestRatePremium=r.numInterestRatePremium.Value(),n.OtherInterestRate=r.numOtherInterestRate.Value(),n.StdTrans=y.StdTrans,n}function hi(){return JSON.stringify(pt())}function ci(){var n=r.cboInterestPaymentType.Text().replace(" ","");return n=="Check"&&(n="Cheque"),n}function li(){return r.cboTermCycle.Text()}var o={},b,k,a,y,r={trMain:null,tdMain:null,tblStdTransactions:null,tblTermAndPayments:null,tblInterest:null,lblStdTransactions:null,gridStdTrans:null,lblTerm:null,dateOpeningDate:null,cboTermCycle:null,dateTermCycleOnDate:null,dateMaturityDate:null,numTermNumberOfPayments:null,lblMinimumPayments:null,cboMinimumPaymentBasis:null,numMinimumPaymentValue:null,numMinimumPaymentPercent:null,dateMinimumPaymentInstalmentEndDate:null,numMinimumPaymentInstalmentResidualValue:null,numMinimumPaymentDueDays:null,chkMinimumPaymentDueDaysOverride:null,cboMinimumPaymentHoldToPeriod:null,dateMinimumPaymentHoldToDate:null,lblPayments:null,cboPaymentCycle:null,cboPaymentFirstDatePeriod:null,datePaymentFirstDate:null,numPaymentRegular:null,numPaymentBalloon:null,lblResidualValue:null,numResidualValue:null,lblCreditLimit:null,numCreditLimit1:null,numCreditLimit2:null,numCreditLimit3:null,lblTaxCategory:null,cboTaxCategory:null,lblInterest:null,cboInterestCycle:null,dateInterestCycleDateFirst:null,cboInterestPaymentType:null,lblStartupInterest:null,cboStartupInterestType:null,cboStartupInterestPeriod:null,dateStartupInterestToDate:null,numStartupInterestRate:null,cboStartupInterestRateTable:null,numStartupInterestRatePremium:null,lblInterestRate:null,cboInterestType:null,numInterestRate:null,cboInterestRateTable:null,numInterestRatePremium:null,lblOtherInterest:null,numOtherInterestRate:null,cmdSchedule:null,cmdResetFinancial:null},d,tt,u,e,p;if(AccountFinancialDefaults={readOnly:!1,allowStdTransDrilldown:!0,allowStdTransReset:!0,allowReset:!0,allowSchedule:!0,autoReadOnly:!0,showStdTrans:!0,stdTransWidgetId:"",visible:!0,onAction:null,onChange:null},a=$.extend({},AccountFinancialDefaults,i),typeof t=="string"?(d=t,t=$("#"+d)):d=$(t).attr("id"),tt=$(t),tt.length==0){console.warn("widget_ui.AccountFinancial: Element '"+d+"' not found.");return}k=$(tt[0]);switch(k.prop("tagName")){case"TBODY":break;default:console.warn("widget_ui.AccountFinancial: Element '"+d+"' must be a TBODY element.");return}if(k.addClass("is-account-financial"),r.trMain=$("<tr><\/tr>"),k.append(r.trMain),r.tdMain=$("<td><\/td>"),r.trMain.append(r.tdMain),a.showStdTrans&&(r.tblStdTransactions=$("<div><\/div>"),r.tdMain.append(r.tblStdTransactions),r.tblStdTransactions.wrap("<div class='tblStdTransactions'><\/div>")),r.tblTermAndPayments=$("<table class='is-form'><\/table>"),r.tdMain.append(r.tblTermAndPayments),r.tblTermAndPayments.wrap("<div><\/div>"),r.tblTermAndPayments.append("<colgroup><col style='width:8em;'/><col/><\/colgroup>"),r.tblInterest=$("<table class='is-form'><\/table>"),r.tdMain.append(r.tblInterest),r.tblInterest.wrap("<div><\/div>"),r.tblInterest.append("<colgroup><col style='width:8em;'/><col/><\/colgroup>"),a.showStdTrans&&(e=h(!0),r.gridStdTrans=ui(r.tblStdTransactions,{showContextMenu:!1,showColumnHeaders:!1,stickyHeader:!0,docked:!0,width:"100%",onAction:function(n){switch(n){case"Add":it(-1);break;case"DeleteRow":y.StdTrans[r.gridStdTrans.ActiveDataRowListIndex()].Deleted=!0;yt("Removing Transaction, please wait...");l();break;case"RowMoveDown":r.gridStdTrans.RowMoveDown();l();break;case"RowMoveUp":r.gridStdTrans.RowMoveUp();l();break;default:if(a.onAction)a.onAction(n)}},onAfterRowActivate:bt,onBeforeCellUpdate:dt,onInitialiseRow:wt,onRowDrilldown:gt}),a.allowStdTransDrilldown&&r.gridStdTrans.AddColumnDrilldown("Drilldown"),r.gridStdTrans.AddColumnString("Description",{caption:"Description",allowEdit:!1,width:"60%"}),r.gridStdTrans.AddColumnCurrency("Value",{caption:"Value",allowEdit:!0,width:"40%"}),p=[],a.allowStdTransDrilldown&&(p.push({actionId:"Add",tooltipText:"Add Transaction",icon:"Add"}),p.push({actionId:"DeleteRow",tooltipText:"Delete row",icon:"Delete"}),p.push({}),p.push({actionId:"RowMoveUp",tooltipText:"Move current row up",icon:"Grid_Row_MoveUp"}),p.push({actionId:"RowMoveDown",tooltipText:"Move current row down",icon:"Grid_Row_MoveDown"})),a.allowStdTransReset&&(p.push({}),p.push({actionId:"StdTransReset",tooltipText:"Reset Transactions to Account Type defaults",icon:"Reset"})),r.gridStdTrans.Actions().Define(p)),e=h(!0),u=$("<tr><th colspan='2'><label>Term<\/label><\/th><\/tr>"),r.tblTermAndPayments.append(u),r.lblTerm=c($("label",u),{}),e+="X",u=$("<tr><th><label for='"+e+"'>Opening:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.dateOpeningDate=v($("input",u),{allowBlank:!1,onChange:st}),e+="X",u=$("<tr><th><label for='"+e+"'>Term:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.cboTermCycle=g($("input",u),{allowBlank:!1,isFrequency:!1,showDescription:!1,width:"10em",onChange:ct}),e+="X",u=$("<tr><th><label for='"+e+"'>On Date:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.dateTermCycleOnDate=v($("input",u),{allowBlank:!1,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>Maturity:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.dateMaturityDate=v($("input",u),{allowBlank:!0,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>No.&nbsp;Payments:&nbsp;<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.numTermNumberOfPayments=f($("input",u),{allowBlank:!0,decimals:0,minValue:0,maxValue:9999,onChange:l}),u=$("<tr><th colspan='2'><label>Minimum Payments<\/label><\/th><\/tr>"),r.tblTermAndPayments.append(u),r.lblMinimumPayments=c($("label",u),{}),e+="X",u=$("<tr><th><label for='"+e+"'>Basis:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.cboMinimumPaymentBasis=s($("input",u),{allowBlank:!1,width:"12em",onChange:ot}),e+="X",u=$("<tr><th><label for='"+e+"'>Value:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.numMinimumPaymentValue=f($("input",u),{allowBlank:!0,decimals:-1,minValue:0,maxValue:999999999,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>Percentage:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.numMinimumPaymentPercent=f($("input",u),{allowBlank:!1,decimals:4,minValue:0,maxValue:9999,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>Hold&nbsp;Period:&nbsp;<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.cboMinimumPaymentHoldToPeriod=g($("input",u),{allowBlank:!1,isFrequency:!0,showDescription:!1,width:"10em",onChange:ht}),e+="X",u=$("<tr><th><label for='"+e+"'>Hold To:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.dateMinimumPaymentHoldToDate=v($("input",u),{allowBlank:!1,onChange:l}),u=$("<tr><th colspan='2'><label>Payments<\/label><\/th><\/tr>"),r.tblTermAndPayments.append(u),r.lblPayments=c($("label",u),{}),e+="X",u=$("<tr><th><label for='"+e+"'>Payments:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.cboPaymentCycle=g($("input",u),{allowBlank:!1,isFrequency:!0,showDescription:!1,width:"10em",onChange:ii}),e+="X",u=$("<tr><th><label for='"+e+"'>First&nbsp;Period:&nbsp;<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.cboPaymentFirstDatePeriod=g($("input",u),{allowBlank:!1,isFrequency:!1,showDescription:!1,width:"10em",onChange:lt}),e+="X",u=$("<tr><th><label for='"+e+"'>First&nbsp;Date:&nbsp;<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.datePaymentFirstDate=v($("input",u),{allowBlank:!0,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>Payment:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.numPaymentRegular=f($("input",u),{allowBlank:!0,decimals:-1,minValue:0,maxValue:999999999,onChange:at}),e+="X",u=$("<tr><th><label for='"+e+"'>Balloon:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.numPaymentBalloon=f($("input",u),{allowBlank:!0,decimals:-1,minValue:0,maxValue:999999999,onChange:l}),u=$("<tr><th colspan='2'><label>Residual Value<\/label><\/th><\/tr>"),r.tblTermAndPayments.append(u),r.lblResidualValue=c($("label",u),{}),e+="X",u=$("<tr><th><label for='"+e+"'>Residual:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.numResidualValue=f($("input",u),{allowBlank:!0,decimals:-1,minValue:0,maxValue:999999999,onChange:l}),u=$("<tr><th colspan='2'><label>Credit Limit<\/label><\/th><\/tr>"),r.tblTermAndPayments.append(u),r.lblCreditLimit=c($("label",u),{}),e+="X",u=$("<tr><th><label for='"+e+"'>Credit Limit 1:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.numCreditLimit1=f($("input",u),{allowBlank:!0,decimals:-1,minValue:0,maxValue:999999999,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>Credit Limit 2:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.numCreditLimit2=f($("input",u),{allowBlank:!0,decimals:-1,minValue:0,maxValue:999999999,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>Credit Limit 3:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.numCreditLimit3=f($("input",u),{allowBlank:!0,decimals:-1,minValue:0,maxValue:999999999,onChange:l}),u=$("<tr><th colspan='2'><label>Tax Category<\/label><\/th><\/tr>"),r.tblTermAndPayments.append(u),r.lblTaxCategory=c($("label",u),{}),e+="X",u=$("<tr><th><label for='"+e+"'>Category:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblTermAndPayments.append(u),r.cboTaxCategory=w($("input",u),{allowBlank:!0,width:n.UI.FIELD_WIDTH_CODE_10,onChange:l}),e=h(!0),u=$("<tr><th colspan='2'><label>Interest<\/label><\/th><\/tr>"),r.tblInterest.append(u),r.lblInterest=c($("label",u),{}),e+="X",u=$("<tr><th><label for='"+e+"'>Cycle:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.cboInterestCycle=g($("input",u),{allowBlank:!1,isFrequency:!0,showDescription:!1,width:"10em",onChange:ut}),e+="X",u=$("<tr><th><label for='"+e+"'>First Date:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.dateInterestCycleDateFirst=v($("input",u),{allowBlank:!0,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>Pay Type:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.cboInterestPaymentType=s($("input",u),{allowBlank:!1,width:"10em",onChange:ti}),u=$("<tr><th colspan='2'><label>Startup Interest Rate<\/label><\/th><\/tr>"),r.tblInterest.append(u),r.lblStartupInterestRate=c($("label",u),{}),e+="X",u=$("<tr><th><label for='"+e+"'>Startup&nbsp;Type:&nbsp;<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.cboStartupInterestType=s($("input",u),{allowBlank:!1,width:"10em",onChange:ft}),e+="X",u=$("<tr><th><label for='"+e+"'>Period:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.cboStartupInterestPeriod=g($("input",u),{isFrequency:!1,allowBlank:!1,showDescription:!1,width:"10em",onChange:vt}),e+="X",u=$("<tr><th><label for='"+e+"'>To&nbsp;Date:&nbsp;<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.dateStartupInterestToDate=v($("input",u),{allowBlank:!1,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>Interest&nbsp;Rate:&nbsp;<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.numStartupInterestRate=f($("input",u),{allowBlank:!1,decimals:4,minValue:0,maxValue:9999,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>Rate Table:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.cboStartupInterestRateTable=w($("input",u),{allowBlank:!1,width:n.UI.FIELD_WIDTH_CODE_10,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>+ Premium:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.numStartupInterestRatePremium=f($("input",u),{allowBlank:!0,decimals:4,minValue:0,maxValue:9999,onChange:l}),u=$("<tr><th colspan='2'><label>Interest Rate<\/label><\/th><\/tr>"),r.tblInterest.append(u),r.lblInterestRate=c($("label",u),{}),e+="X",u=$("<tr><th><label for='"+e+"'>Interest&nbsp;Type:&nbsp;<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.cboInterestType=s($("input",u),{allowBlank:!1,width:"10em",onChange:et}),e+="X",u=$("<tr><th><label for='"+e+"'>Interest&nbsp;Rate:&nbsp;<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.numInterestRate=f($("input",u),{allowBlank:!1,decimals:4,minValue:0,maxValue:9999,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>Rate Table:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.cboInterestRateTable=w($("input",u),{allowBlank:!1,width:n.UI.FIELD_WIDTH_CODE_10,onChange:l}),e+="X",u=$("<tr><th><label for='"+e+"'>+ Premium:<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.numInterestRatePremium=f($("input",u),{allowBlank:!0,decimals:4,minValue:0,maxValue:9999,onChange:l}),u=$("<tr><th colspan='2'><label>Other Interest<\/label><\/th><\/tr>"),r.tblInterest.append(u),r.lblOtherInterest=c($("label",u),{}),e+="X",u=$("<tr><th><label for='"+e+"'>Other&nbsp;Rate:&nbsp;<\/label><\/th><td><input id='"+e+"'/><\/td><\/tr>"),r.tblInterest.append(u),r.numOtherInterestRate=f($("input",u),{allowBlank:!0,decimals:4,minValue:0,maxValue:9999,onChange:l}),a.allowSchedule||a.allowReset){if(u=$("<tr><th colspan='2' style='padding-top:8px'><\/th><\/tr>"),r.tblInterest.append(u),td=$("th",u),a.allowSchedule&&(r.cmdSchedule=$("<button class='is-button small' icon='Schedule'>Schedule<\/button>"),td.append(r.cmdSchedule),a.onAction))r.cmdSchedule.on("click",function(){a.onAction("ScheduleShow")});if(a.allowReset&&(r.cmdResetFinancial=$("<button class='is-button small' icon='Reset'>Reset Financial<\/button>"),td.append(r.cmdResetFinancial),a.onAction))r.cmdResetFinancial.on("click",function(){a.onAction("Reset")});ni($("*[icon]",td))}return nt(!1),{TypeName:"AccountFinancial",Focus:ri,ReadOnly:ei,StdTransWidgetId:oi,Visible:fi,FromAccountCalcJson:si,ToAccountCalc:pt,ToAccountCalcJson:hi,InterestPaymentType:ci,TermCycle:li}}var y=null,r=!1,wt=null,bt=!1,p,ht=!1,fi=!1,kt=[],ei=!1,ct=!0,dt={},tt={},oi=0,it=0,o=[],si="orange",et="navy",gt="navy",hi=!1,ot=!1,lt=n.ParseDate,ci=n.FormatCurrency,l=n.FormatDateInternal,at=function(n){return n?new Date(n):null},rt=n.FormatNumber,a=n.ParseNumber,li=function(n,t){var i=t?["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]:["January","February","March","April","May","June","July","August","September","October","November","December"];try{return i[n]}catch(r){return t?"Un":"Unknown"}},ai=function(n,t){var i=t?["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];try{return i[n]}catch(r){return t?"Un":"Unknown"}},vt=function(n,t){if(typeof t=="undefined"&&(t=!0),typeof n=="string"&&(n=$("#"+n)),n)try{var i=$(n).val();return t&&(i=tr(i)),i}catch(n){return""}else return""},vi="../",ur=!1,b,yi,k,nr,u;switch(n.GetHostingContext()){case"WebExternal":case"WebInternal":break;default:ur=!0;$("body").addClass("is-desktop")}if(n.GetHostingContext()=="WebInternal")try{b=window.parent.document.getElementById("themecolourtester");b&&(b=$(b),et=b.css("background-color"),gt=b.css("border-top-color"),si=b.css("border-left-color"),$("head").append("<style type='text/css'><\/style>"),yi=$("head").children(":last"),yi.html(".is-widget-content footer { border-top-color: "+et+" !important; }\n\n.is-modal .is-modal-title { background-color: "+et+" !important; color: white !important; }\n\n.is-modal .is-modal-close,.is-modal.is-modal-minimise,.is-modal.is-modal-open-window { color:rgba(255,255,255,0.6) !important; }\n\n.is-modal .is-modal-close:hover,.is-modal.is-modal-minimise:hover,.is-modal.is-modal-open-window:hover { color:rgba(255,255,255,1) !important; }\n\ndiv.help h1,div.help h2,div.help h3 {color:"+si+" !important; }\n\nbutton.is-button.checked {background-color:"+et+" !important; }\n\n"))}catch(cf){}if(n.GetHostingContext()=="WebInternal")try{vi=window.parent.$Runtime.WebRoot();hi=window.parent.$Runtime.IsMobileBrowser();ot=window.parent.$Runtime.IsPlatformIOS()}catch(cf){}switch(n.GetHostingContext()){}k=!1;navigator.appVersion.indexOf("MSIE")!=-1?k=!0:navigator.appVersion.indexOf("Trident/")!=-1&&(k=!0);k&&$("html").addClass("browser-ie");screen.width<=640&&(ei=!0);k&&(ct=!1);$(function(){ni($("*[icon]"));$(document.body).bind("keydown",function(n){if(n.keyCode==27&&o.length>0){var t=o[o.length-1];t.CloseOnEscape()&&t.Close()}})});Calendar=function(t,i){function s(n){var g,rt,at,vt,ft,yt,pt,st,wt,bt,kt,ht,ui,fi,ei,ct,dt,b,gt,ni,ti,ii,ri,i,lt,t,v;if(n){for(ot=!0,u.children().remove(),g=$("<div class='is-calendar-header'><\/div>"),it=$("<div class='dayname'><\/div>"),rt=$("<div><\/div>"),at=$("<div class='left month' title='Back a month'/>"),p=$("<select class='month'><\/select>"),t=0;t<12;t++)p.append("<option>"+li(t)+"<\/option>");for(vt=$("<div class='right month' title='Forward a month'/>"),rt.append(at),rt.append(p),rt.append(vt),ft=$("<div><\/div>"),yt=$("<div class='left day' title='Back a day'/>"),y=$("<select class='day'><\/select>"),t=1;t<32;t++)y.append("<option>"+t+"<\/option>");for(pt=$("<div class='right day' title='Forward a day'/>"),ft.append(yt),ft.append(y),ft.append(pt),st=$("<div><\/div>"),wt=$("<div class='left year' title='Back a year'/>"),w=$("<select class='year'><\/select>"),t=0;t<200;t++)w.append("<option>"+(1900+t)+"<\/option>");for(bt=$("<div class='right year' title='Forward a year'/>"),st.append(wt),st.append(w),st.append(bt),g.append(it),g.append(ft),g.append(rt),g.append(st),kt=$("<div class='is-calendar-body'><\/div>"),ht=$("<table style='width:100%'><thead><tr><\/tr><\/thead><tbody><\/tbody><\/table>"),kt.append(ht),ui=$(">thead>tr",ht),b=0;b<7;b++)fi=$("<th>"+ai(b).substr(0,3)+"<\/th>"),ui.append(fi);for(ei=$(">tbody",ht),ct=0;ct<6;ct++){for(dt=$("<tr><\/tr>"),b=0;b<7;b++)tt[b+ct*7]=$("<td><\/td>"),dt.append(tt[b+ct*7]);ei.append(dt)}y.bind("change",function(){e=parseInt(y.val());l();u.focus();u.select()});w.bind("change",function(){o=parseInt(w.val());l();u.focus();u.select()});p.bind("change",function(){f=p[0].selectedIndex;l();u.focus();u.select()});wt.bind("click",function(){o-=1;l()});at.bind("click",function(){f-=1;f<0&&(f=11,o-=1);l()});yt.bind("click",function(){e-=1;e<1&&(e=31);l()});vt.bind("click",function(){f+=1;f>11&&(f=0,o+=1);l()});bt.bind("click",function(){o+=1;l()});pt.bind("click",function(){e+=1;e>31&&(e=1);l()});$("td",ht).bind("click",function(n){if(!c.readOnly){var i=parseInt($(n.delegateTarget).attr("dateOffset")),t=new Date(a.getFullYear(),a.getMonth(),a.getDate()+i);(r===null||r.valueOf()!=t.valueOf())&&(r=t,s(!1),k())}});h=$("<div class='is-calendar-footer'><\/div>");gt=$("<button>Clear<\/button>");gt.on("click",function(){nt(null);s(!1);k()});ni=$("<button>Today<\/button>");ni.on("click",function(){var n=new Date;nt(new Date(n.getFullYear(),n.getMonth(),n.getDate()));s(!1);d();k()});ti=$("<button>+Week<\/button>");ti.on("click",function(){if(!r){var n=new Date;r=new Date(n.getFullYear(),n.getMonth(),n.getDate())}r=new Date(r.getFullYear(),r.getMonth(),r.getDate()+7);s(!1);d();u.focus();u.select();k(!1)});ii=$("<button>+Month<\/button>");ii.on("click",function(){if(!r){var n=new Date;r=new Date(n.getFullYear(),n.getMonth(),n.getDate())}r=new Date(r.getFullYear(),r.getMonth()+1,r.getDate());s(!1);d();u.focus();u.select();k(!1)});ri=$("<button class='ok'>Done<\/button>");ri.on("click",function(){nt(new Date(o,f,e));s(!1);k()});h.append(gt);h.append(ni);h.append(ti);h.append(ii);h.append(ri);u.append(g);u.append(kt);u.append(h)}for(it.text(ai(new Date(o,f,e).getDay())),w.val(o+""),p.val(li(f)),y.val(e),c.readOnly?h.hide():h.show(),a=new Date(o,f);a.getDay()!=0;)a.setDate(a.getDate()-1);for(i=new Date(a.valueOf()),lt=new Date,t=0;t<42;t++)v=tt[t],v.text(i.getDate()),v.attr("dateOffset",t),v.removeClass(),v.attr("title",null),c.readOnly||v.addClass("is-selectable"),i.getMonth()!=f&&v.addClass("notcurrent"),i.getFullYear()==lt.getFullYear()&&i.getMonth()==lt.getMonth()&&i.getDate()==lt.getDate()&&(v.addClass("today"),v.attr("title","Today")),r!=null&&i.getFullYear()==r.getFullYear()&&i.getMonth()==r.getMonth()&&i.getDate()==r.getDate()&&v.addClass("is-sel"),et[t]=i,i.setDate(i.getDate()+1);u.addClass("is-calendar");ut(y);ut(p);ut(w)}function ut(t){v||(v=$("<select style='position:fixed; left:-1000px; top:-1000px' tabindex='-1' />"),u.append(v));v.children().remove();v.append("<option>"+n.UI.HtmlEncode(t.val())+"<\/option>");t.after(v);v.attr("class",t.attr("class"));var i=v.width()+4;i&&t.css("width",i+"px")}function l(){r=new Date(o,f,e);s(!1)}function k(n){var t={ChangeHandled:!1,ValueOriginal:b,CloseDropdown:n};if(c.onChange)c.onChange(ft,t);t.ChangeHandled&&(b=r?new Date(r.valueOf()):null)}function st(){return r!=b}function ht(){return u}function ct(){u.focus();u.select()}function d(){if(r instanceof Date)o=r.getFullYear(),f=r.getMonth(),e=r.getDate();else{var n=new Date;o=n.getFullYear();f=n.getMonth();e=n.getDate()}s()}function at(n){if(n===undefined)return c.readOnly;n!=c.readOnly&&(c.readOnly=n==!0,s())}function nt(n){if(n===undefined)return r;n===null?(r=null,b=n):n instanceof Date?(r=n,b=n):console.warn("Attempted to set ISCalendar value to a value that is not a Date or null.");s();r!=null&&d()}var e=(new Date).getDate(),f=(new Date).getMonth(),o=(new Date).getFullYear(),a,et=new Array(42),u,tt=new Array(42),h,y,it,p,v,w,ot=!1,c,r,b,g,rt,ft;if(CalendarDefaults={width:"auto",readOnly:!1,autoReadOnly:!0,onChange:null},c=$.extend({},CalendarDefaults,i),r=lt("Now",!1,!1),b=new Date(r.valueOf()),typeof t=="string"?(g=t,t=$("#"+g)):g=$(t).attr("id"),rt=$(t),rt.length==0){console.warn("widget_ui.Calendar: Element '"+g+"' not found.");return}return u=$(rt[0]),u.attr("tabindex","-1"),u.addClass("is-no-select"),s(!0),ft={Changed:st,Element:ht,Focus:ct,GotoValue:d,ReadOnly:at,Value:nt}};nr={ShowAccountSchedule:function(t){return t=$.extend({},{scheduleJson:null},t),n.__requestForm("AccountSchedule",t),!0},ShowCompanyLookup:function(t,i,r){return t=$.extend({},{searchBy:"BusinessNumber",autoClose:!0,businessNumber:null,legalName:null,organisationNumber:null,organisationName:null},t),n.__requestForm("CompanyLookup",t,i,r),!0},ShowRangeLookupFromStandardRange:function(t,i,r,u,f){return r=$.extend({},{caption:"",rangeType:"Standard",sqlWhere:""},r),r.rangeName=t,r.value=i,n.__requestForm("RangeLookup",r,u,f),!0},ShowHtml:function(t,i,r){function f(n,t,i){var e=!1,f=!1,o=n.toUpperCase(),u,r;if(o.indexOf("<HTML")==-1)switch(i.popupStyle.toUpperCase()){case"":o.indexOf('<DIV CLASS="IS-SUMMARYPAGE-2"')!=-1||o.indexOf("IS-SUMMARYPAGE-BLOCKS")!=-1||(n="<div class='is-summarypage-2'>"+n+"<\/div>");break;case"NOTE":n="<div style='position:absolute;left:0;top:0;right:0;bottom:0;overflow:auto;-webkit-overflow-scrolling:touch;background-color:#FFF5A1'><div style='padding:8px'>"+n+"<\/div><\/div>"}else e=!0,f=!0;f=f||i.forceIFrame;f?(t.ContentElement().children().remove(),u=$("<iframe style='position:absolute;width:100%;height:100%;border:0'/>"),t.ContentElement().append(u),!0&&n.indexOf("is-summarypage-blocks")!=-1&&u.css({"background-color":"#808080"}),r=u[0].contentDocument,r.open(),e||(r.write("<!doctype html>"),r.write("<html>"),r.write("<head>"),r.write("<link rel='stylesheet' type='text/css' href='"+$Runtime.WebRoot()+"Content/SummaryPage2/summarypage_2.css'><\/link>"),r.write("<link rel='stylesheet' type='text/css' href='"+$Runtime.WebRoot()+"Content/SummaryPage2/summarypage_2_web.css'><\/link>"),r.write("<\/head>"),r.write("<body style='margin:0;padding:0'>")),r.write(n),e||(r.write("<\/body>"),r.write("<\/html>")),r.close(),window.$Ash?$Ash.HandleIframe(u[0]):window.alert("Show HTML cannot handle Application Shortcuts since no handler ($Ash) is available.")):(!0&&n.indexOf("is-summarypage-blocks")!=-1&&t.ContentElement().css("background-color","#808080"),t.ContentElement().html(n))}r=$.extend({},{height:"",width:"",maxWidth:"1024px",popupStyle:"",showWait:!1,title:"HTML Viewer"},r);r.height||(r.height="90%");r.width||(r.width="90%");var u=n.UI.Modal({formType:"HtmlViewer",width:r.width,maxWidth:r.maxWidth,minWidth:r.minWidth,height:r.height,maxHeight:r.maxHeight,minHeight:r.minHeight,title:t});return u.Show({content:""}),r.showWait?(u.ContentElement().children().remove(),u.ContentElement().append("<div class='is-wait-block'><div class='is-wait'><div class='is-wait1'><\/div><div class='is-wait2'><\/div><div class='is-wait3'><\/div><\/div><label>Please wait...<\/label><\/div>")):f(i,u,r),u.UpdateHtml=function(n){f(n,u,r)},u},ShowHtmlWidgetModal:function(t,i,r){return i=$.extend({},{id:t},i),n.GetHostingContext()=="WebInternal"?(i.__modal=n.__modal,n.__widget.__SetWidgetNotifyParentCallback(r)):__widgetNotifyParentCallback=r,i.closeCurrent&&n.Close(),n.__requestForm("HtmlWidget",i),!0}};MsgBoxDefaults={title:null,maxWidth:null,maxHeight:null,minWidth:null,minHeight:null,heading:null,icon:null,messageIsHtml:!1,captionOk:null,captionCancel:null};u={Block:yt,Unblock:st,ApplyIcons:ni,DisableControlStyling:ar,DDListFromArray:wi,DDListFromCollection:cr,DDListFromCsv:lr,DDListAdd:hr,HtmlEncode:t,ScrollToTop:gr,InitialiseAddressAutoComplete:vr,IsSmallMobileBrowser:dr,TableAddRowsFromCollection:nu,ValidateContainer:ii,Evaluate:bi,AccountFinancial:hf,AccountPaymentDetails:tu,AccountIncomingPaymentDetails:ki,AccountOutgoingPaymentDetails:iu,AddressDetails:ru,ButtonList:uu,ButtonStrip:ri,CheckBox:gi,CheckList:fu,ComboBox:s,DashboardLayout:eu,DateBox:v,DateCycleComboBox:g,DBCombo:w,DocumentManagerComboBox:su,DropdownPanel:ft,Form:ou,Grid:ui,IconComboBox:hu,InformationListComboBox:cu,Label:c,Modal:sf,NumberBox:f,ParametersHost:lu,PreviewPane:au,PromptUpdateList:vu,RadioButton:di,RadioButtonList:wu,RangeSlider:yu,Tabs:pu,TextBox:i,Forms:nr,ModalOpenCount:er,GetModalById:sr,MsgBoxAlert:du,MsgBoxConfirm:ir,MsgBoxConfirmList:gu,MsgBoxConfirmDelete:nf,MsgBoxInfo:tf,MsgBoxList:rf,GetControlRow:uf,LoadStyle:ff,StyleAsModal:or,FIELD_WIDTH_CODE_5:"6em",FIELD_WIDTH_CODE_10:"9em",FIELD_WIDTH_CODE_15:"12em",FIELD_WIDTH_CODE_20:"16em",Trim:bu,LTrim:ku,RTrim:tr,SplitWordsAtCapitals:pt,ArrayFromCsvString:nt,GetElement:ut};n.UI=u}(widget);console.log("  widget.UI (extension)"),function(n){n.fn.swapWith=function(t){var i=this,r=n(t),u=n("<div>");return i.before(u),r.before(i),u.after(r).remove(),i};var t=null;n.fn.ScrollElementIntoView=function(i,r,u){var f=n.extend({},{instant:!1,duration:null,step:null,inViewAmount:0},u),e;if(i==!0&&(f.instant=!0),f.complete&&window.alert("ScrollElementIntoView: o.complete not yet implemented!"),e=this,e.length!=1){console.warn("ScrollElementIntoView is designed only to work on a single element.");return}return t&&window.clearTimeout(t),t=setTimeout(function(){for(var i=e[0].offsetTop,o=e[0].offsetHeight,t=n(e[0].parentElement),r,u;t.length!=0;){if(t[0].tagName=="BODY")break;if(t[0].tagName=="DIV"&&t[0].scrollHeight>n(t[0]).height())break;t=n(t[0].parentElement)}t.length==1&&(r=t.height(),u=t[0].scrollTop,f.instant&&t.stop(!0,!0),i-f.inViewAmount<u?t.animate({scrollTop:i-f.inViewAmount},f):i+o+f.inViewAmount>u+r&&t.animate({scrollTop:i-r+o},f))},10),this}}($)