var widget,__WidgetUI;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(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 ht(i){return n?n.FormatDate(i,!1,!1,!0):t(i,null,!0)}function ct(i){return n?n.FormatDate(i,!0,!1,!1):t(i,_config.dateFormat+" "+_config.timeFormat)}function lt(i){return n?n.FormatDate(i,!0,!1,!0):t(i,_config.dateFormat+" "+_config.timeFormat,!0)}function at(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 vt(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 yt(){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 pt(n,t){return(n&&typeof n=="string"&&(n=new Date(n)),!n||!n.getDay)?"":k(n.getDay(),t)}function wt(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 bt(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 kt(n){return!g(n)}function dt(){return window.devicePixelRatio>1.25}function gt(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 ni(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 ti(t){return n?n.ParseNumber(t,-1):nt(""+t,-1)}function ii(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 ri(){return n?n.ThemeContrastColourBackground():_config.themeContrastColourBackground}function ui(){return n?n.ThemeContrastColourForeground():_config.themeContrastColourForeground}function fi(){return n?n.ThemeMainColourBackground():_config.themeMainColourBackground}function ei(){return n?n.ThemeMainColourForeground():_config.themeMainColourForeground}function oi(n){return n.replace(/^\s+|\s+$/g,"")}function si(n){return n.replace(/^\s+/,"")}function tt(n){return n.replace(/\s+$/,"")}function hi(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 ci(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 li(){return"1.21"}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(ai){}return{ArrayAllowLookupById:it,ArrayRemove:rt,ArrayToCodeDescriptionList:ut,CompareDates:f,CurrencyDecimals:function(){return _config.currencyDecimals},CurrencySymbol:function(){return _config.currencySymbol},DateAddDays:ot,DayMonthYearOrder:function(){return _config.dayMonthYearOrder},FormatCurrency:st,FormatDate:c,FormatDateForGrid:at,FormatDateTime:ct,FormatTime:b,FormatUtcDate:ht,FormatUtcDateTime:lt,FormatNumber:vt,GetHostingContext:yt,GetAgeInYears:bt,GetAgeText:wt,GetWeekDayName:k,GetWeekDayNameFromDate:pt,IsColourDark:g,IsColourLight:kt,IsHighDpi:dt,ParseCurrency:ti,ParseDate:gt,ParseNumber:ii,ParseTime:ni,Round:p,RoundCurrency:ft,RoundCurrencyDown:i,RoundCurrencyUp:et,ThemeContrastColourBackground:ri,ThemeContrastColourForeground:ui,ThemeMainColourBackground:fi,ThemeMainColourForeground:ei,Trim:oi,LTrim:si,RTrim:tt,SplitWordsAtCapitals:hi,ArrayFromCsvString:ci,Version:li,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 widget_external.js (external functionality)");widget=window.__widgetGeneric,function(){function i(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)}var t=!0,n=new function(){var i,n;return GetWsError=function(n){var i="",t;typeof n=="string"?i=n:n&&n.responseText&&(i=n.responseText);t={};try{t=$.parseJSON(i)}catch(r){}return t.Code||(t.Code=""),t.Message||(t.Message="An unknown error occurred."),t.InternalMessage||(t.InternalMessage=""),t},i={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"},PostDirect=function(n,r,u,f){var h,e,o,s;if(h=!0,e=$.extend({},i,f),r||(r={}),u||(u={}),Object.keys(r).length!==0){o="";for(s in r)o&&(o+="&"),o+=s+"="+encodeURIComponent(r[s]);r&&(n+="&"+o)}$.ajax({method:"POST",url:n,contentType:e.contentType,data:JSON.stringify(u)}).fail(function(n,i,r){n.status==401&&(t=!1);e.fail(n,i,r)}).done(function(n,i,r){t=!0;e.done(n,i,r)}).always(function(){e.always&&e.always()})},n={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(t){var e="",o,i,r,h,c,s,u,f=0;for(t=n._utf8_encode(t);f<t.length;)o=t.charCodeAt(f++),i=t.charCodeAt(f++),r=t.charCodeAt(f++),h=o>>2,c=(o&3)<<4|i>>4,s=(i&15)<<2|r>>6,u=r&63,isNaN(i)?s=u=64:isNaN(r)&&(u=64),e=e+this._keyStr.charAt(h)+this._keyStr.charAt(c)+this._keyStr.charAt(s)+this._keyStr.charAt(u);return e},decode:function(t){var i="",o,s,h,c,f,u,e,r=0;for(t=t.replace(/[^A-Za-z0-9+/=]/g,"");r<t.length;)c=this._keyStr.indexOf(t.charAt(r++)),f=this._keyStr.indexOf(t.charAt(r++)),u=this._keyStr.indexOf(t.charAt(r++)),e=this._keyStr.indexOf(t.charAt(r++)),o=c<<2|f>>4,s=(f&15)<<4|u>>2,h=(u&3)<<6|e,i=i+String.fromCharCode(o),u!==64&&(i=i+String.fromCharCode(s)),e!==64&&(i=i+String.fromCharCode(h));return n._utf8_decode(i)},_utf8_encode:function(n){var i,r,t;for(n=n.replace(/rn/g,"n"),i="",r=0;r<n.length;r++)t=n.charCodeAt(r),t<128?i+=String.fromCharCode(t):t>127&&t<2048?(i+=String.fromCharCode(t>>6|192),i+=String.fromCharCode(t&63|128)):(i+=String.fromCharCode(t>>12|224),i+=String.fromCharCode(t>>6&63|128),i+=String.fromCharCode(t&63|128));return i},_utf8_decode:function(n){for(var r="",t=0,i=c1=c2=0;t<n.length;)i=n.charCodeAt(t),i<128?(r+=String.fromCharCode(i),t++):i>191&&i<224?(c2=n.charCodeAt(t+1),r+=String.fromCharCode((i&31)<<6|c2&63),t+=2):(c2=n.charCodeAt(t+1),c3=n.charCodeAt(t+2),r+=String.fromCharCode((i&15)<<12|(c2&63)<<6|c3&63),t+=3);return r}},{Base64Encode:function(t){return n.encode(t)},GetWsError:GetWsError,PostDirect:PostDirect}};widget.CanClose=function(){return window.frameElement?$(window.frameElement).attr("modalwidget")?!0:!0:!1};widget.Close=function(){if(window.frameElement){var t=$(window.frameElement,window.parent.document),i=t.prop("id"),n=window.parent.widget.UI.GetModalById(i.substring(7));n?n.Close():console.warn("Cannot find parent Modal to close.")}};widget.DownloadFile=function(t,i){var r,u,f;if(i||(i={}),r="_widgetAction=DownloadFile&eventId="+encodeURIComponent(t)+"&parameters="+JSON.stringify(i),window._portalInfo&&window._startupParametersJson&&(r+="&startupParametersJson="+window._startupParametersJson),r=n.Base64Encode(r),r=encodeURIComponent(r),u=_wsUrl,u+=u.indexOf("?")==-1?"?p="+r:"&p="+r,widget.IsApp_Android()||widget.IsApp_iOS()){u+="[download]";document.location.href=u;return}f=window.open(u)};widget.IsAuthenticated=function(){return window.portal?!0:!1};widget.UploadFiles=function(n,t,i,r,u){var f,o,s,e,h,c;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++)h=new FileReader,c=f[e],h.readAsDataURL(c),h.onload=function(i){return function(e){s+=1;o.push({name:i.name,data:e.target.result,tag:i.tag});s==f.length&&widget.UploadFilesInternal(n,t,o,r,u)}}(c);else widget.UploadFilesInternal(n,t,"",r,u)};widget.UploadFilesInternal=function(t,i,r,u,f){i.__fileDataJson=r;var e={_widgetAction:"UploadFiles",eventId:t,hostingContext:"WebExternal"};window._portalInfo&&window._startupParametersJson&&(e.startupParametersJson=window._startupParametersJson);n.PostDirect(_wsUrl,e,i,{done:function(n,t,i){switch(i.status){case 200:u&&u(""+n);break;default:f&&f(""+n)}},fail:function(t){var i=n.GetWsError(t);widget.RegisterError(i.Message,i.InternalMessage);f&&f(i.Message+"\n\n"+i.InternalMessage)},always:function(){}})};widget.ExecuteApplicationShortcutUrl=function(n){var t,u,f,o,e,s,i,r,h;if(!window.portal)return console.warn("widget.ExecuteApplicationShortcutUrl cannot function correctly since no portal object was found."),!1;t=(n+"").toUpperCase();t.startsWith("APP://")&&(t=t.substr(6));u=t;i=t.indexOf("?");i!=-1&&(u=t.substr(0,i));switch(u){case"DOCUMENTMANAGERFILE":for(f="document.pdf",o=n.split("&"),e=0;e<o.length;e++)if(s=o[e],i=s.toUpperCase().indexOf("FILENAME="),i!=-1){f=s.substr(i+9);break}r=window.open("","_blank");try{r.document.open();r.document.write("<p style='font-family:arial,helvetica'>Your document should be downloading now<\/p>");r.document.close()}catch(c){}h={url:n};page._SystemGetString("PortalExecuteApplicationShortcutUrl_DocumentManagerFile_GetDownloadUrl",h,function(n){var t=_portalInfo.portalRoot;if(t+=_portalInfo.portalProxied?"?"+f+"?p="+n:t.indexOf("?")==-1?f+"?p="+n:"&p="+n,widget.IsApp_Android()||widget.IsApp_iOS()){t+="[download]";document.location.href=t;return}r.document.location.href=t},function(n){window.alert(n)});break;default:return console.warn("widget.ExecuteApplicationShortcutUrl does not support '"+u+"' type Application Shortcuts for Portals and externally hosted Widgets."),!1}};widget.GetIconUrl=function(n,t,i,r){return t||(t=16),i||(i=""),r===undefined&&(r=!0),r&&window.devicePixelRatio>1.25&&(t*=2),_wsUrl+"&_widgetAction=GetIcon&icon="+n+"&size="+t+"&overlay="+i};widget.GetString=function(t,i,r,u){i||(i={});var f={_widgetAction:"GetString",eventId:t,hostingContext:"WebExternal"};window._portalInfo&&window._startupParametersJson&&(f.startupParametersJson=window._startupParametersJson);n.PostDirect(_wsUrl,f,i,{done:function(n,t,i){switch(i.status){case 200:r&&r(""+n);break;default:u&&u(""+n)}},fail:function(t){var i=n.GetWsError(t);widget.RegisterError(i.Message,i.InternalMessage);u&&u(i.Message+"\n\n"+i.InternalMessage)}})};widget.NotifyBusy=function(){return!1};widget.SystemGetString=function(t,i,r,u){i||(i={});n.PostDirect(_wsUrl,{_widgetAction:"SystemGetString",eventId:t,hostingContext:"WebExternal"},i,{done:function(n,t,i){switch(i.status){case 200:r&&r(""+n);break;default:u&&u(""+n)}},fail:function(t){var i=n.GetWsError(t);widget.RegisterError(i.Message,i.InternalMessage);u&&u(i.Message+"\n\n"+i.InternalMessage)}})};widget._SystemGetString=widget.SystemGetString;widget.SystemDownloadFile=function(n,t){t||(t={});var u={eventId:n,hostingContext:"WebInternal",target:"WebInternal",highDpi:!1,parameters:t},r=_wsUrl;r+=r.indexOf("?")==-1?"?_widgetAction=SystemDownloadFile":"&_widgetAction=SystemDownloadFile";i(r,{p:JSON.stringify(u)})};widget._SystemDownloadFile=widget.SystemDownloadFile;widget.RefreshParent=function(n,t){if(window.parent&&window.parent.widget){var i=window.parent.widget;i.__refreshParent(n,t)}};widget.RegisterError=function(n,t){console.warn("RegisterError: "+n+"\n\n"+t)}}();console.log("  widget (external functionality)");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 rr(n,t){if(ft){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 yi(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&&yi(n[t].MenuItems)}function dt(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 at(n){n||(n="");w||(w=$("<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(w));w.fadeIn("fast")}function et(){w&&(w.remove(),w=null)}function ur(){return tt}function fr(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 er(n){for(var i,t=0;t<o.length;t++)if(i=o[t],i.ModalId()==n)return i;return null}function or(n,t){var n=rt(n),i;n&&(i=$("<option><\/option>"),i.text(t),n.append(i))}function pi(n,t,i){var n=rt(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 sr(n,t,i,r){var n=rt(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 hr(n,t,i){t=""+t;pi(n,t.split(","),i)}function cr(n){if(n===undefined)return r;r=n==!0}function rt(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 yt||(yt=$("<div/>")),n+="",n=n.replace(/\n/g,"~br~"),n=yt.text(n).html(),t&&(n=n.replace(/ /g,"&nbsp;")),n.replace(/~br~/g,"<br/>")}function lr(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":ar(t);break;default:n.RegisterError("widget_ui.InitialiseAddressAutoComplete: service '"+t.service+"' is not a valid service.")}}function ar(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}ui?ot?wt.push(t):gt(t):(ui=!0,ot=!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(){gt(t)})}function gt(n){var i,r,t;if(ot)for(ot=!1,i=0;i<wt.length;i++)gt(wt[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=yr(n,e);break;case"New Zealand":i=pr(n,e,$(t).val());break;case"United Kingdom":i=wr(n,e);break;default:i=vr(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 vr(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 yr(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 pr(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 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"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 br(){return fi}function kr(n){if(n){n=rt(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 dr(n,t,i,r){var o,h,f,y,s,c,l,u,e,v,a;if(n=rt(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 ni(n,t,i,r){var c,p,e,u,t,l,o,a,h,s,v,f,y;for(l=!0,a=!1,c=$("input,select,textarea,div.is-grid-container,span[controlType='radiobuttonlist']",n),h=0;h<c.length;h++){if(s=!0,p=c[h],u=$(p),u.css("display")=="none")o=!1;else if(u.attr("readonly")=="readonly")o=!1;else for(o=!0,e=u;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(f=u?u.prop("is-control"):null,!o||f||u.attr("id")||(o=!1),o&&(s&&f&&f.Validate&&(s=f.Validate()),s&&u.hasClass("is-mandatory")&&(u.val()||(s=!1))),!s&&(l=!1,y=u.attr("id"),!y&&f&&f.Caption&&(y=f.Caption()),t&&t.SelectedTabIndex(i),a||(a=!0,f&&f.Focus?f.Focus():u.focus()),!r))break}return l}function wi(n,t){var l,r,a,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(l=0;l<g.length;l++){if(r=$(g[l]),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{a=r.attr("ng-bind-format")||"";switch(a.toLowerCase()){case"":case"string":break;case"currency":i=hi(i);break;case"currency$":i=hi(i,!0);break;case"date":i=y(i);break;default:console.warn("widget.UI.Evaluate: Unrecognised ns-bind-format '"+a+"'.")}}catch(e){console.warn("widget.UI.Evaluate: Failed to evaluate ns-bind-format '"+a+"' 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="",v=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:v=i.substr(c+4)),!h||s&&v||(h=!1),h)try{if(o=f(v),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),wi(d),r.append(k)}catch(e){console.warn("widget.UI.Evaluate: Failed to iterate array variable '"+v+"' 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 bi(r,u){function c(i){var u,r,s;if(k&&(i||!f.cboPaymentMethod.Text())&&(window.clearTimeout(k),k=null),o.visible?w.show():w.hide(),g||f.trPaymentMethod.hide(),y&&f.cboPaymentMethod.Text()||f.trWarning.hide(),g){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 vt(t,i){var r;i=$.extend({},{applyDefaultPaymentMethod:!1,applyDefaultCashRegister:!1,defaultValuesOnPaymentMethodChange:!1},i);b=t;g=!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);n._SystemGetString("AccountPaymentDetails_Initialise",{accountId:b,paymentFlowDirection:"incoming"},function(n){if(n){if(n=JSON.parse(n),e=n,nt=n.PaymentMethodsList,v=nt,wt(d),i.applyDefaultPaymentMethod){f.cboPaymentMethod.Text(n.DefaultPaymentMethodId);if(o.onPaymentMethodChange)o.onPaymentMethodChange(ht,{})}i.applyDefaultCashRegister&&f.cboCashRegister.Text(n.DefaultCashRegisterId);g=!0;c(!0);i.defaultValuesOnPaymentMethodChange&&n.DefaultPaymentMethodId&&o.paymentEntry&&st()}},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 ot(n){if(n===undefined)return f.cboCardExpiryMonth.ListIndex();f.cboCardExpiryMonth.ListIndex(n);c(!0)}function hi(n){if(n===undefined)return l(f.cboCardExpiryYear.Text());f.cboCardExpiryYear.Text(l(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 yt(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);ot(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?vt(t.AccountId,!1):c(!0):c(!0)}catch(i){console.warn("widget.UI.AccountIncomingPaymentDetails: Error calling FromBankingDetailsJson: "+i)}}function st(t,i){var r,u,e;if(!o.readOnly){if(g){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")&&(at("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&&yt(n.BankingDetailsJson);et()},function(t){n.RegisterError("widget_ui.AccountIncomingPaymentDetails: Failed to load smart details: "+t);et()}))}}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=ot(),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 d;if(n||(d=""),d=n,v=[],nt)for(i=0;i<nt.length;i++){t=nt[i];switch(d.toUpperCase()){case"":v.push(t);break;case"DIRECTCREDIT":t.IsDirectCredit&&v.push(t);break;default:t.PaymentTypeCategory==d&&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,w,g=!1,o,d="",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,a,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}w=$(ut[0]);switch(w.prop("tagName")){case"TBODY":break;default:console.warn("widget_ui.AccountIncomingPaymentDetails: Element '"+it+"' must be a TBODY element.");return}a=h(!0);f.trPaymentMethod=$("<tr style='display:none'><th><label for='"+a+"'>Method:<\/label><\/th><td><input id='"+a+"'/><\/td>");w.append(f.trPaymentMethod);f.cboPaymentMethod=p($("input",f.trPaymentMethod),{allowBlank:o.allowBlank,maxLength:10,onChange:function(n,t){t.ChangeHandled=!0;c(!0);ct&&st();var t={};if(o.onPaymentMethodChange)o.onPaymentMethodChange(ht,t)}});a+="X";f.trAccountSortCode=$("<tr style='display:none'><th><nobr><label for='"+a+"'>Sort Code:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+a+"'/><\/td>");w.append(f.trAccountSortCode);f.txtAccountSortCode=i($("input",f.trAccountSortCode),{allowBlank:!1,maxLength:10,width:"8em",onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});a+="X";f.trAccountNumber=$("<tr style='display:none'><th><nobr><label for='"+a+"'>Account No.:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+a+"'/><\/td>");w.append(f.trAccountNumber);f.txtAccountNumber=i($("input",f.trAccountNumber),{allowBlank:!1,maxLength:30,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});a+="X";f.trName=$("<tr style='display:none'><th><label for='"+a+"'>Name:<\/label><\/th><td><input id='"+a+"'/><\/td>");w.append(f.trName);f.txtName=i($("input",f.trName),{allowBlank:!0,maxLength:100,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});a+="X";f.trCardExpiry=$("<tr style='display:none'><th><nobr><label for='"+a+"'>Card Expiry:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+a+"'/> <input id='"+a+"2'/>  <input id='"+a+"3'/><\/td>");w.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=l(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=l(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"}),a+="X",f.trReference=$("<tr style='display:none'><th><label for='"+a+"P'>Reference:<\/label><\/th><td><div id='"+a+"TL'><\/div><input id='"+a+"P'/> <input id='"+a+"C'/> <input id='"+a+"R'/><\/td>"),w.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)}}),a+="X",f.trCashRegister=$("<tr style='display:none'><th><label for='"+a+"'>Cash&nbsp;Register:&nbsp;<\/label><\/th><td><input id='"+a+"'/><\/td>"),w.append(f.trCashRegister),f.cboCashRegister=p($("input",f.trCashRegister),{allowBlank:!0,maxLength:10,width:n.UI.FIELD_WIDTH_CODE_10}),a+="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>"),w.append(f.trWarning),f.divWarning=$("div",f.trWarning),c(!1),ht={TypeName:"AccountIncomingPaymentDetails",Focus:kt,Initialise:vt,ReadOnly:ri,Visible:dt,LoadAccountDetailsSmart:st,FromBankingDetailsJson:yt,ToBankingDetailsJson:pt,PaymentMethodId:fi,PaymentMethodAllowBlank:ui,PaymentTypeCategoryFilter:wt,AccountSortCode:ei,AccountNumber:oi,AccountName:si,CardExpiryMonthIndex:ot,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 gr(n,t){return console.warn("Use widget.UI.AccountIncomingPaymentDetails instead of widget.UI.AccountPaymentDetails."),bi(n,t)}function nu(r,u){function c(i){var s,r,h,u;if(k&&(i||!f.cboPaymentMethod.Text())&&(window.clearTimeout(k),k=null),o.visible?w.show():w.hide(),g||f.trPaymentMethod.hide(),y&&f.cboPaymentMethod.Text()||f.trWarning.hide(),g){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 vt(t,i){i=$.extend({},{applyDefaultPaymentMethod:!1,applyDefaultCashRegister:!1,defaultValuesOnPaymentMethodChange:!1},i);b=t;g=!1;ct=i.defaultValuesOnPaymentMethodChange;y="";k&&(window.clearTimeout(k),k=null);c(!1);o.showCashRegister?f.cboCashRegister.RefreshFromStandardRange("CashRegisters"):f.cboCashRegister.VisibleRow(!1);n._SystemGetString("AccountPaymentDetails_Initialise",{accountId:b,paymentFlowDirection:"outgoing"},function(n){if(n){if(n=JSON.parse(n),e=n,nt=n.PaymentMethodsList,v=nt,wt(d),i.applyDefaultPaymentMethod){f.cboPaymentMethod.Text(n.DefaultPaymentMethodId);if(o.onPaymentMethodChange)o.onPaymentMethodChange(ht,{})}i.applyDefaultCashRegister&&f.cboCashRegister.Text(n.DefaultCashRegisterId);g=!0;c(!0);i.defaultValuesOnPaymentMethodChange&&n.DefaultPaymentMethodId&&o.paymentEntry&&st()}},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 ot(n){if(n===undefined)return f.cboCardExpiryMonth.ListIndex();f.cboCardExpiryMonth.ListIndex(n);c(!0)}function ci(n){if(n===undefined)return l(f.cboCardExpiryYear.Text());f.cboCardExpiryYear.Text(l(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 yt(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);ot(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?vt(t.AccountId,!1):c(!0):c(!0)}catch(i){console.warn("widget.UI.AccountOutgoingPaymentDetails: Error calling FromBankingDetailsJson: "+i)}}function st(t,i){var r,u,e;if(!o.readOnly){if(g){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")&&(at("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&&yt(n.BankingDetailsJson);et()},function(t){n.RegisterError("widget_ui.AccountOutgoingPaymentDetails: Failed to load smart details: "+t);et()}))}}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=ot(),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 d;if(n||(d=""),d=n,v=[],nt)for(i=0;i<nt.length;i++){t=nt[i];switch(d.toUpperCase()){case"":v.push(t);break;case"DIRECTCREDIT":t.IsDirectCredit&&v.push(t);break;default:t.PaymentTypeCategory==d&&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,w,g=!1,o,d="",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,a,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}w=$(ut[0]);switch(w.prop("tagName")){case"TBODY":break;default:console.warn("widget_ui.AccountOutgoingPaymentDetails: Element '"+it+"' must be a TBODY element.");return}a=h(!0);f.trPaymentMethod=$("<tr style='display:none'><th><label for='"+a+"'>Method:<\/label><\/th><td><input id='"+a+"'/><\/td>");w.append(f.trPaymentMethod);f.cboPaymentMethod=p($("input",f.trPaymentMethod),{allowBlank:o.allowBlank,maxLength:10,onChange:function(n,t){t.ChangeHandled=!0;c(!0);ct&&st();var t={};if(o.onPaymentMethodChange)o.onPaymentMethodChange(ht,t)}});a+="X";f.trAccountSortCode=$("<tr style='display:none'><th><nobr><label for='"+a+"'>Sort Code:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+a+"'/><\/td>");w.append(f.trAccountSortCode);f.txtAccountSortCode=i($("input",f.trAccountSortCode),{allowBlank:!1,maxLength:10,width:"8em",onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});a+="X";f.trAccountNumber=$("<tr style='display:none'><th><nobr><label for='"+a+"'>Account No.:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+a+"'/><\/td>");w.append(f.trAccountNumber);f.txtAccountNumber=i($("input",f.trAccountNumber),{allowBlank:!1,maxLength:30,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});a+="X";f.trName=$("<tr style='display:none'><th><label for='"+a+"'>Name:<\/label><\/th><td><input id='"+a+"'/><\/td>");w.append(f.trName);f.txtName=i($("input",f.trName),{allowBlank:!0,maxLength:100,onChange:function(n,t){t.ChangeHandled=!0;c(!0)}});a+="X";f.trCardExpiry=$("<tr style='display:none'><th><nobr><label for='"+a+"'>Card Expiry:<\/label>&nbsp;<\/nobr><\/th><td><input id='"+a+"'/> <input id='"+a+"2'/>  <input id='"+a+"3'/><\/td>");w.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=l(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=l(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"}),a+="X",f.trReference=$("<tr style='display:none'><th><label for='"+a+"P'>Reference:<\/label><\/th><td><div id='"+a+"TL'><\/div><input id='"+a+"P'/> <input id='"+a+"C'/> <input id='"+a+"R'/><\/td>"),w.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)}}),a+="X",f.trCashRegister=$("<tr style='display:none'><th><label for='"+a+"'>Cash&nbsp;Register:&nbsp;<\/label><\/th><td><input id='"+a+"'/><\/td>"),w.append(f.trCashRegister),f.cboCashRegister=p($("input",f.trCashRegister),{allowBlank:!0,maxLength:10,width:n.UI.FIELD_WIDTH_CODE_10}),a+="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>"),w.append(f.trWarning),f.divWarning=$("div",f.trWarning),c(!1),ht={TypeName:"AccountOutgoingPaymentDetails",Focus:kt,Initialise:vt,ReadOnly:ui,Visible:dt,LoadAccountDetailsSmart:st,FromBankingDetailsJson:yt,ToBankingDetailsJson:pt,PaymentTypeCategoryFilter:wt,PaymentMethodId:ei,PaymentMethodAllowBlank:fi,AccountSortCode:oi,AccountNumber:si,AccountName:hi,CardExpiryMonthIndex:ot,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 tu(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(tt,{});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?nt[i]?nt[i]:null:it;l?ut():n._SystemGetString("AddressDetails_GetCountryInfo",{country:f.cboCountry.Text()},function(n){n&&n&&(n=JSON.parse(n),l=n,nt[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(tt,{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,tt;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(),tt={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 iu(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 ti(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 ki(n,t){return t.cssClass="is-radio-button",di(n,t)}function di(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 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 wt(){var r,s=e.val(),t,i,u;if(l){rt();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(ht,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||ft(!0);y(!0);f.usePicker&&(v(),SharedPickerPanel().Hide(!0))});f.usePicker||h.Append(w);nt=!1}function rt(){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=et(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 ct(){if(nt&&wt(),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:ht,sourceButtonElement:p,caption:n,contentElement:w,onKeyDown:function(n){switch(n.keyCode){case 35:ot(o.length-1);v();break;case 36:ot(0);v();break;case 38:st(-1);v();break;case 40:st(1);v()}}})}else h.Show(),e.focus(),e.select();v()}function ft(n){f.usePicker?SharedPickerPanel().Hide():(h.Hide(),n&&(e.focus(),e.select()))}function lt(){return e.val()!=tt}function y(n){l||f.limitToList&&!at(e.val())&&e.val("");var t={ChangeHandled:!1,TextOriginal:tt,ChangedFromPopup:n};if(f.onChange)f.onChange(ht,t);t.ChangeHandled&&(tt=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 et(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 ot(n){if(n===undefined)return et(e.val(),!1);n<0||n>o.length-1?yt(""):yt(o[n]);tt=e.val()}function st(n){var t=ot()+n;t<0?t=0:t>o.length-1&&(t=o.length-1);pt(o[t],!1,!0)}function fi(n){n!=f.limitToList&&(f.limitToList=n==!0)}function at(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;nt=!0;l&&rt()}function oi(n){typeof n=="string"&&(n=JSON.parse(n));bt(n,"Description")}function bt(n,t){var r,i;if(o=[],nt=!0,n!=undefined&&t)for(r=0;r<n.length;r++)i=n[r][t],(i===null||i===undefined)&&(i=""),o.push(i);l&&rt()}function dt(n){o=vt(n);nt=!0;l&&rt()}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 yt(n){if(n===undefined)return l?""+e.val():kt(e);n!=e.val()&&(it+=1,e.val(n),it-=1);tt=n}function pt(n,t,i){(n!=e.val()||t)&&(it+=1,e.val(n),it-=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,ht;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,it=0,l,s,o=[],nt=!0,w,f,tt="",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 ut(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&&wt(),l?e.bind("change",function(){y(!0)}):(e.bind("blur",function(){!f.readOnly&&f.limitToList&&lt()&&(at(e.val())||e.val(""))}),e.bind("keydown",function(n){switch(n.keyCode){case 13:return h.Visible()&&ft(!0),!1;case 27:return h.Visible()?(ft(!1),!1):void 0;case 38:return h.Visible()&&(st(-1),h.Visible()&&v()),!1;case 40:return h.Visible()?(st(1),v()):f.readOnly||ct(),!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=et(e.val(),!1);h.Visible()&&v();t==-1&&f.limitToList&&n.keyCode==46?(pt("",!1,!1),y(!1)):t==-1&&(i=e[0].selectionStart+r,i<0&&(i=0),t=et(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?(pt("",!1,!1),y(!1)):lt()&&y(!1))}),p.bind("click",function(){f.readOnly||(h.Visible()?ft(!0):ct())})),n.Options.enterMovesToNextField&&!f.onEnterKey&&!f.multiLine)e.on("keyup",function(n){n.keyCode==13&&d($(this))});return ht={TypeName:"ComboBox",AllowBlank:ni,AutoReadOnly:hi,BlankTip:ti,Caption:ii,Changed:lt,DropdownShow:ct,Element:ri,Focus:ui,LimitToList:fi,ListExists:at,ListFromArray:ei,ListFromCodeDescriptionList:oi,ListFromCollection:bt,ListFromCsvString:dt,ListIndex:ot,ReadOnly:si,Text:yt,Visible:ci,VisibleRow:li,WidthResizeFromParent:gt,WrapperElement:function(){return c}}}function ru(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 a(t,i){function rt(){u.cssClass&&f.addClass(u.cssClass);u.allowBlank?(f.removeClass("is-mandatory"),l&&l.removeClass("is-mandatory")):(f.addClass("is-mandatory"),l&&l.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?v.show():v.hide();st?(p.css({display:"none"}),f.removeClass("is-invalid")):(f.addClass("is-invalid"),nt?(ht?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(!a){var n=$("<div><\/div>");a=new Calendar(n,{onChange:function(n,t){var i=t.CloseDropdown||t.CloseDropdown===undefined;a.Value()?ft(y(a.Value(),!1,!1,!1)):ft("");i&&wt(!0);vt()&&yt()}});g.Append(a.Element())}g.Show(310,!1);f.focus();f.select();o===null&&f[0].value&&ft(f[0].value);a.Value(o);a.GotoValue()}function wt(n){g.Hide();n&&(f.focus(),f.select())}function ft(n){u.readOnly||(o=n==""?null:ct(n,u.historic,!u.valueIsUtc));at()}function at(){if(ot)f[0].valueAsDate=o;else{var t=y(o,!1,!0);f.val(t)}u.showAge&&o?v.text(n.GetAgeText(o)):u.showWeekDayName&&o?v.text(n.GetWeekDayNameFromDate(o)):v.text("")}function gt(n){n!=u.allowBlank&&(u.allowBlank=n==!0,rt())}function ni(n){if(n===undefined)return l?l.text():"";l&&l.text(n)}function vt(){return y(o)!=y(tt)}function yt(){var t={ChangeHandled:!1,ValueOriginal:tt};if(e&&(t.TimeValueOriginal=n.ParseTime(it,!0)),u.onChange)u.onChange(et,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 bt(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"?lt(t):t;at();e&&(e.val(n.FormatTime(o,!0,!0)),o=ct(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 st?!0:!1}function ci(){var n=!0,t;return typeof u.minValue=="string"&&(u.minValue=lt(u.minValue)),typeof u.maxValue=="string"&&(u.maxValue=lt(u.maxValue)),(u.minValue!=null||u.maxValue!=null)&&(t=bt(),n&&u.minValue!=null&&t<u.minValue&&(n=!1),n&&u.maxValue!=null&&t>u.maxValue&&(n=!1)),n?pt(!0,"",!1):pt(!1,"Valid range "+li(),!1),n}function li(){var n="";return u.minValue!=null&&(n+=y(u.minValue)),u.maxValue!=null&&(n&&(n+=" "),n+="to "+y(u.maxValue)),n}function pt(n,t,i){st=n;nt=t===undefined?"":t;ht=i===undefined?!1:i;rt()}function ai(n){u.onChange=n}var b,k,et;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,a,v,g,f,c,e,w=!1,ot=!1,st=!0,l,u,p,nt="",ht=!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 ut(s,{minWidthElement:f,cssClass:"is-dropdown is-dropdown-calendar"}),v=$("<label class='is-combobox' style='display:none; position:relative; margin-top:-4px;'><\/label>"),v.insertAfter(h),f.attr("autocomplete","off"),f.attr("spellcheck","false"),k=$("label[for='"+b+"']"),l=k.length==0?null:$(k[0]),rt(),u.width=="auto"&&kt(),ot?(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||(ot?o=f[0].valueAsDate:ft(f.val()));vt()&&yt();tt=o;at()}),h.bind("click",function(){u.readOnly||(g.Visible()?wt(!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()&&yt();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 et={TypeName:"DateBox",AllowBlank:gt,Caption:ni,Changed:vt,Element:ti,Focus:ii,MaxValue:fi,MinValue:ei,ReadOnly:ri,Value:bt,ValueAsISOString:ui,Visible:oi,VisibleRow:si,WidthResizeFromParent:kt,IsValid:hi,Validate:ci,ValidationSet:pt,OnChange:ai},f.prop("is-control",et),et}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=vt(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 p(t,u){function nt(){f.cssClass&&e.addClass(f.cssClass);f.allowBlank?(e.removeClass("is-mandatory"),b&&b.removeClass("is-mandatory")):(e.addClass("is-mandatory"),b&&b.addClass("is-mandatory"));r?f.blankTip&&e.attr("placeholder",f.blankTip):e.attr("placeholder",f.blankTip);fi?(e.addClass("is-readonly"),e.attr("readonly","readonly"),e.addClass("fetchingdata"),w.addClass("fetchingdata")):f.readOnly?(e.addClass("is-readonly"),e.attr("readonly","readonly"),e.removeClass("fetchingdata"),w.removeClass("fetchingdata")):(e.removeClass("is-readonly"),e.removeAttr("readonly"),e.removeClass("fetchingdata"),w.removeClass("fetchingdata"));f.autoReadOnly?e.attr("autoreadonly","true"):e.removeAttr("autoreadonly");f.showDropdown?w.show():w.hide();o&&(f.showDescription?o.show():o.hide());e.attr("maxLength",f.maxLength==0?"":f.maxLength);e.css({width:f.width});e.attr("spellcheck","false");f.visible?y.show():y.hide()}function p(){var t,i;if(o)if(o.removeClass("is-invalid"),!at()&&f.blankTipDescription)o.text(f.blankTipDescription);else switch(et){case"Array":o.text(yi);pi&&o.addClass("is-invalid");break;case"Unbound":o.text(c);break;default:v?(t=at(),t!=si&&(o.text(""),si="",oi="",t&&(hi&&(window.clearTimeout(hi),hi=null),window.setTimeout(function(){var i={standardRangeName:v,id:t};n._SystemGetString("GetStandardRangeRecordDescription",i,function(n){n&&(n=JSON.parse(n),at()==t&&(si=t,oi=n.Description,o.text(oi),f.limitToList&&!n.Description&&(o.addClass("is-invalid"),o.text("!")),n.Id&&t!=n.Id&&(it+=1,e.val(n.Id),it-=1)))},function(t){n.RegisterError("widget_ui.DBCombo: Failed to retrieve Standard Range record description: "+t)})},500)))):(i=wt(e.val()),e.val()==""?o.text(""):i==-1||i>=ot.length?ot.length==0?o.text(""):(o.text("!"),o.addClass("is-invalid")):o.text(ot[i]))}}function ci(){l.Clear();h=[];ot=[];switch(et){case"":break;case"Array":ir();break;case"Collection":v?fr():ur();break;case"CodeDescriptionList":rr();break;default:window.alert("widget.UI.DBCombo.UpdateList: Unsupported Data Source format")}s&&h.length>10&&(ei=$("<caption class='is-table-filter'><input type='search' placeholder='Type to filter list' style='width:100%' autocomplete='off' spellcheck='false'/><\/caption>"),$("tbody",s).before(ei),window.setInterval(function(){var n=$("input",ei);n.val()!=gt&&hr(n.val())},200));p();st=!1}function ir(){var t,i;for(t="<table style='width:100%'>",t+="<tbody>",i=0;i<c.length;i++)h[i]=c[i],ot[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>";s=$(t);$("tbody > tr",s).bind("click",function(n){var t=$("tbody > tr",s).index(n.delegateTarget);t>=0&&t<h.length&&(e.val(h[t]),f.usePicker||rt(!0),ft(!0),f.usePicker&&(k(),SharedPickerPanel().Hide(!0)))});f.usePicker||l.Append(s)}function rr(){var t,i;for(t="<table style='width:100%'>",f.showColumnHeadings&&ti&&(t+="<thead>",t+="<tr><th>"+n.UI.HtmlEncode(ti)+"<\/th><th>"+n.UI.HtmlEncode(wi)+"<\/th><\/tr>",t+="<\/thead>"),t+="<tbody>",i=0;i<c.length;i++)h[i]=c[i].Code,ot[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>";s=$(t);$("tbody > tr",s).bind("click",function(n){var t=$("tbody > tr",s).index(n.delegateTarget);t>=0&&t<h.length&&(e.val(h[t]),f.usePicker||rt(!0),rt(!0),ft(!0),f.usePicker&&(k(),SharedPickerPanel().Hide(!0)))});f.usePicker||l.Append(s)}function ur(){var u,r,a,w,y,i,v,t,o;for(u=yt.split(","),a=[u.length],t=0;t<u.length;t++)for(a[t]="",o=0;o<c.length;o++)if(w=c[o][u[t]],y="",y=typeof w=="boolean"?"Boolean":"",y!=a[t])if(a[t]=="")a[t]=y;else{a[t]="";break}if(r="<table style='width:100%'>",f.showColumnHeadings&&u.length!=0){for(r+="<thead><tr>",t=0;t<u.length;t++){i=u[t];v="";i==dt&&i!="Value"?i="Code":i.endsWith("Resolved")?(i=i.substr(0,i.length-8),v="+"):i.endsWith("Full")?(i=i.substr(0,i.length-4),v="+"):i.endsWith("TypeText")?i=i.substr(0,i.length-4):i.startsWith("Master")&&i.endsWith("Id")&&(i="Master");switch(a[t]){case"Boolean":r+="<th align='center' style='width:1em'><nobr>"+n.UI.HtmlEncode(ri(i))+v+"<\/nobr><\/th>";break;default:r+="<th>"+n.UI.HtmlEncode(ri(i))+v+"<\/th>"}}r+="<\/tr><\/thead>"}for(r+="<tbody>",t=0;t<c.length;t++){for(h[t]=c[t][dt],ot[t]=c[t][ui],r+="<tr class='is-selectable'>",o=0;o<u.length;o++)switch(a[o]){case"Boolean":r+=c[t][u[o]]?"<td align='center' class='is-symbol-tick' style='color:green'><\/td>":"<td align='center' class='is-symbol-cross' style='color:red'><\/td>";break;default:r+=c[t][u[o]]?"<td>"+n.UI.HtmlEncode(c[t][u[o]])+"<\/td>":"<td>&nbsp;<\/td>"}r+="<\/tr>"}r+="<\/tbody>";r+="<\/table>";s=$(r);$("tbody > tr",s).bind("click",function(n){var t=$("tbody > tr",s).index(n.delegateTarget);t>=0&&t<h.length&&(e.val(h[t]),p(),f.usePicker||rt(!0),ft(!0),f.usePicker&&(k(),SharedPickerPanel().Hide(!0)))});f.usePicker||l.Append(s)}function fr(){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'/>"),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(v.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(r);s.append(u);a=new ii(u,{showColumnHeaders:!1,stickyHeader:!1,onAfterRowActivate:or,onRowDrilldown:sr,onInitialiseRow:er});a.AddColumnCode("Id",{caption:"Code"});a.AddColumnString("Name",{caption:"Description"});a.AddColumnString("Info",{caption:"Information",align:"right",colour:"gray"});a.Refresh();n=i(t,{onEnterKey:function(){bi(n.Text())}});n.Element().keydown(function(t){switch(t.which){case 27:return n.Text()?n.Text(""):rt(!0),!1;case 40:return g&&g.Results.length!=0&&(a.Focus(),a.ActiveDataRowIndex()==-1&&a.ActiveDataRowIndex(0)),!1}});a.Element().keydown(function(n){switch(n.which){case 13:a.ActiveDataRowIndex()!=-1&&a.PerformRowDrilldown()}});r.click(function(){n.Focus();bi(n.Text())});f.usePicker||l.Append(s)}function bi(t){if(t)a.Visible(!0);else{a.Visible(!1);return}var i={standardRangeName:v,query:t,sqlWhere:ct};n._SystemGetString("GetStandardRangeQuickSearchResults",i,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}a.ColumnVisible("Info",i);a.VirtualDataRefresh(g.Results);a.ActiveDataRowIndex(-1)}},function(t){n.RegisterError("widget_ui.DBCombo: Failed to retrieve Quick Search results for Standard Range: "+t)})}function er(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 or(){if(g&&g.Results){var n=g.Results[a.ActiveDataRowIndex()];n&&e.val(n.Id);p();ft(!0)}}function sr(){l.Hide();e.focus()}function hr(n){var u,t,v,h,f,e,a,o,r,i;if(gt=n,c&&s&&($("tbody > tr",s).removeClass("is-filtered-out"),gt)){if(u=gt.toUpperCase().split(" "),u.length>0)for(t=$("tbody > tr",s),i=0;i<t.length;i++){for(v=t[i],h=!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){h=!1;break}}h||$(t[i]).addClass("is-filtered-out")}if(o=bt(),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",s).removeClass("is-sel");r>=0&&r<t.length&&$(t[r]).addClass("is-sel")}}}function k(){var n=wt(e.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 li(){if(st&&ci(),f.usePicker){var n=f.pickerCaption;!n&&b&&(n=b.text(),n&&(n="Select "+n,n.endsWith(":")&&(n=n.substr(0,n.length-1))));n||(n="Select Item");SharedPickerPanel().Toggle({closeFocusElement:vi,sourceButtonElement:w,caption:n,contentElement:s,onKeyDown:function(n){switch(n.keyCode){case 35:bt(h.length-1);k();break;case 36:bt(0);k();break;case 38:ni(-1);k();break;case 40:ni(1);k()}}})}else v?(l.Show(0,!0),l.WidthResizeFromParent(800)):l.Show(),v?$("input",s).focus():(e.focus(),e.select());k()}function rt(n){l.Hide();n&&(e.focus(),e.select())}function ki(){return e.val()!=ht}function cr(n,t,i){i||(i=!1);yi=n;pi=i;p()}function ft(n){if(!it){it+=1;v||f.limitToList&&!di(e.val())&&(e.val(""),o&&o.text(""));var t={ChangeHandled:!1,TextOriginal:ht,ChangedFromPopup:n};if(f.onChange)f.onChange(vi,t);t.ChangeHandled&&(ht=e.val());it-=1}}function lr(n){if(n===undefined)return f.allowBlank;n!=f.allowBlank&&(f.allowBlank=n==!0,nt())}function ar(n){if(n===undefined)return f.blankTip;f.blankTip=n;nt()}function vr(n){if(n===undefined)return f.blankTipDescription;f.blankTipDescription=n;nt()}function yr(n){if(n===undefined)return b?b.text():"";b&&b.text(n)}function pr(){return e}function wr(){e.focus();e.select()}function br(){return o?o.text():""}function wt(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 bt(n){if(n===undefined)return wt(e.val(),!1);n<0||n>h.length-1?at(""):at(h[n]);ht=e.val()}function ni(n){var t=bt()+n;t<0?t=0:t>h.length-1&&(t=h.length-1);nr(h[t],!1,!0)}function kr(n){if(n===undefined)return f.limitToList;n!=f.limitToList&&(f.limitToList=n==!0)}function di(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 dr(n){c=vt(n);et="Array";st=!0}function gr(n){if(n===undefined)return f.maxLength;f.maxLength=n;nt()}function nu(n){if(n===undefined)return f.readOnly;n!=f.readOnly&&(f.readOnly=n==!0,nt())}function tu(n){if(n===undefined)return f.autoReadOnly;n!=f.autoReadOnly&&(f.autoReadOnly=n==!0,nt())}function iu(n,t,i){n!==undefined&&(et="CodeDescriptionList",c=n,t!==undefined&&(ti=t),i!==undefined&&(wi=i),ci())}function gi(n,t,i,r){n!==undefined&&(et="Collection",c=n,dt=t,ui=i,r?yt=r:(yt=t,i&&(yt+=","+i)),v="",ci())}function ru(t,i,r,u,f,e){var h,s,o;if(t){if(et="Collection",c=null,dt="",ui="",yt="",v="",ct="",h=!1,t.startsWith("@")&&(h=!0,t=t.substr(1)),!h){if(s=t.toUpperCase(),s.substr(0,8)=="ACCOUNTS"){v=t;ct=i;st=!0;p();e&&e();return}if(s.substr(0,11)=="ACCOUNTAPPS"){v=t;ct=i;st=!0;p();e&&e();return}if(s.substr(0,7)=="CLIENTS"){v=t;ct=i;st=!0;p();e&&e();return}if(s.substr(0,13)=="SECURITYSTMTS"){v=t;ct=i;st=!0;p();e&&e();return}}ai(!0);o={standardRangeName:t};i&&(o.sqlWhere=i);r&&(o.includeInactive=r);u&&(o.alwaysIncludeId=u);f&&(o.displayColumns=f);n._SystemGetString("GetStandardRange",o,function(n){var r,i,u,o,t;if(n){for(n=JSON.parse(n),r=[],i=0;i<n.Rows.length;i++){for(u={},o=n.Rows[i],t=0;t<n.Columns.length;t++)u[n.Columns[t].Name]=o[t];r.push(u)}gi(r,n.IdColumn,n.DescriptionColumn,f);ai(!1)}e&&e()},function(t){n.RegisterError("widget_ui.DBCombo: Failed to retrieve Standard Range: "+t);e&&e()})}}function uu(n,t){t||(t="");et="Unbound";c=t;e.val(n);p();ht=n}function ai(n){fi=n;nt()}function fu(n){if(n===undefined)return f.showDescription;f.showDescription=n;nt()}function at(n){if(n===undefined)return kt(e);n!=e.val()&&(it+=1,e.val(n),it-=1,p());ht=n}function nr(n,t,i){(n!=e.val()||t)&&(it+=1,e.val(n),it-=1,ft(i))}function tr(n){var t=f.width;f.showDescription?o.show():(y.css("width","100%"),o.hide());n||f.maxLength==0||f.maxLength>=50&&!f.showDescription?t="100%":t&&t!="auto"||f.maxLength&&(t=f.maxLength<=4?f.maxLength*.8+2+"em":f.maxLength*.8+"em");e.css({width:t});t!="100%"||f.showDescription?y.css("width",""):y.css("width","100%");o&&f.showDescription&&f.descriptionElement=="auto"&&(y.css("width","100%"),y.css("position","relative"),y.css("display","flex"),y.css("flex-direction","row"),y.css("white-space",""),e.css("flex-grow","0"),e.css("max-width",t),w.css("flex-grow","0"),o.css("flex-grow","1"),o.css("overflow","hidden"),o.css("position","relative"),o.css("height","22px"),o.css("line-height","22px"))}function eu(n){if(n===undefined)return f.visible;f.visible=n;nt()}function ou(n){if(!tt&&(tt=e.closest("tr"),tt.length==0))return console.warn("widget_ui.DBCombo.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 pt,lt,vi;if(!r&&n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI&&!(u&&u.forceWidgetControl))return typeof t=="string"&&(t=$("#"+t)),t.attr("is-created","y"),u.widgetDocument=window.document,new window.parent.$UI.DBCombo(t,u);var yi="",pi=!1,w,ti="",wi="",c,et="",dt="",ui="",yt="",o,l,e,tt,fi=!1,ei,gt="",it=0,b,h=[],ot=[],st=!1,s,f,ht="",y,g=null,a=null,v="",ct="",oi="",si="",hi=null;if(ComboBoxDefaults={blankTip:"",blankDescription:"",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,width:"auto",onChange:null,usePicker:!1,pickerCaption:""},f=$.extend({},ComboBoxDefaults,u),typeof t=="string"?(pt=t,t=$("#"+pt)):pt=$(t).attr("id"),lt=$(t),lt.length==0){console.warn("widget_ui.DBCombo: Element '"+pt+"' not found.");return}if(e=$(lt[0]),e.attr("is-created","y"),e.wrap("<span style='white-space:nowrap; display:flex; padding:0; margin:0; position:relative;' controlType='dbcombo'/>"),y=$(e.parent()),w=$("<button type='button' tabindex='-1' class='is-combobox-button' style='position:relative;left:1px;top:0'/>"),f.usePicker&&w.addClass("is-picker"),w.insertAfter(e),typeof f.descriptionElement=="string")switch(f.descriptionElement){case"":case"none":break;case"auto":o=$("<label class='is-combobox' style='display:none'><\/label>");o.insertAfter(w);break;default:console.warn("userinterface.DBCombo: options.descriptionElement must be a jQuery element or one of the following: '', 'none', 'auto'.")}else o=f.descriptionElement;if(l=f.showColumnHeadings?new ut(y,{}):new ut(y,{minWidthElement:e}),e.attr("autocomplete","off"),e.attr("spellcheck","false"),lt=$("label[for='"+pt+"']"),b=lt.length==0?null:$(lt[0]),f.width=="auto"&&f.maxLength!=0&&tr(),nt(),e.bind("keydown",function(n){switch(n.keyCode){case 13:l.Visible()&&rt(!0);break;case 27:l.Visible()&&rt(!1);break;case 38:l.Visible()&&(ni(-1),l.Visible()&&k());break;case 40:l.Visible()?(ni(1),k()):f.readOnly||li()}v||p()}),e.bind("blur",function(){v&&p()}),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}e.bind("blur",function(){f.readOnly||ki()&&ft(!1)});v||(t=wt(e.val(),!1),l.Visible()&&k(),t==-1&&f.limitToList&&n.keyCode==46?(nr("",!1,!1),ft(!1)):t==-1&&(i=e[0].selectionStart+r,i<0&&(i=0),t=wt(e.val(),!0),t!=-1?(e.val(h[t]),e[0].selectionStart=i,e[0].selectionEnd=1e3,ft(!1)):f.limitToList),p())}),w.bind("click",function(){f.readOnly||fi||(l.Visible()?rt(!0):li())}),n.Options.enterMovesToNextField)e.on("keyup",function(n){n.keyCode==13&&d($(this))});return vi={TypeName:"DBCombo",AllowBlank:lr,AutoReadOnly:tu,BlankTip:ar,BlankTipDescription:vr,Caption:yr,Changed:ki,DescriptionUpdate:cr,DropdownShow:li,Element:pr,Focus:wr,GetDescription:br,LimitToList:kr,ListExists:di,ListFromCsvString:dr,ListIndex:bt,MaxLength:gr,ReadOnly:nu,RefreshFromCodeDescriptionList:iu,RefreshFromCollection:gi,RefreshFromStandardRange:ru,RefreshUnbound:uu,SetFetchingData:ai,ShowDescription:fu,Text:at,Visible:eu,VisibleRow:ou,WidthResizeFromParent:tr,WrapperElement:function(){return y}}}function ut(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(!ft)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 uu(t,i){function y(){var l,o,p,v,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(v=$("input,select,textarea",u),i=0;i<v.length;i++)if(t=$(v[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 a(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 p(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",bt),o.css("background-color",bt),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",ht)),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=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(){pt=!0;v||(v=$("<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>"),v.blur("",function(){pt&&v.focus()}),$("body").append(v));v.show();v.focus()}function g(){pt=!1;v.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),y(),r.visible?u.show():u.hide(),{TypeName:"Form",Element:k,ActionsDefine:p,FormDisable:d,FormEnable:g,FormReadOnly:tt,RefreshHeading:nt,Visible:it}}function ii(t,i){function iu(n){if(!n.attr("_original")){n.attr("_original","true");var i=n.attr("key")||n.attr("fieldId")||"Column"+ti,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 yu(){var n,t;if(e)for(n=0;n<e.length;n++)t=e[n],t.thElement&&!t.original&&t.thElement.remove();e=[]}function or(n){return n>=0&&n<e.length?e[n]:null}function ri(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 pu(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 ru(n){n=n.toUpperCase();for(var t=0;t<e.length;t++)if(n==e[t].key.toUpperCase())return t;return-1}function wu(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Boolean";i.width||(i.width="1em");e.push(i);it=!0}function bu(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Currency";i.width||(i.width="4em");e.push(i);it=!0}function ku(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Date";i.width||(i.width="4em");e.push(i);it=!0}function du(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="DateTime";i.width||(i.width="6em");e.push(i);it=!0}function gu(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 nf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="HTML";e.push(i);it=!0}function tf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Icon";i.width||(i.width="16px");e.push(i);it=!0}function rf(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Integer";i.width||(i.width="4em");e.push(i);it=!0}function uf(t,i){var r=$.extend({},GridColumnDefaults,i);r.key=t;r.type="String";e.push(r);it=!0;r.collection?(r._collection={},r._collection.data=r.collection,r._collection.idColumn=r.idColumn,r._collection.displayColumns=r.columns):r.list&&(r._collection={},r._collection.loaded=!1,r._collection.data=[{"List not loaded":""}],r._collection.idColumn="List not loaded",n._SystemGetString("ResolveList",{list:r.list,columns:r.columns,idColumn:r.idColumn},function(n){var i,f,t,e,o,u;for(n=JSON.parse(n),i="",t=0;t<n.Columns.length;t++)n.Columns[t].Name==n.IdColumn||(i&&(i+=","),i+=n.Columns[t].Name);for(f=[],t=0;t<n.Rows.length;t++){for(e={},o=n.Rows[t],u=0;u<n.Columns.length;u++)e[n.Columns[u].Name]=o[u];f.push(e)}r._collection.data=f;r._collection.idColumn=n.IdColumn;r._collection.displayColumns=i;r._collection.loaded=!0},function(){n.RegisterError("widget_ui.Grid: Failed to resolve list: "+r.list)}))}function ef(n,t){var i=$.extend({},GridColumnDefaults,t);i.key=n;i.type="Code";e.push(i);it=!0}function of(){return e.length}function sf(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?pu(f):ri(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 hf(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(at||(at=$("<tr><\/tr>"),$("thead",s).prepend(at)),f=$("<th style='text-align:center'><\/th>"),f.text(t),f.attr("colspan",i-r),at.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 ci(t){var ei=0,pt=null,h,ki,gi,nr,p,w,oi,si,fr,tr,bt,y,rt,gt,hi,k,ti,ii,u,ht,ct,ui,ir,ci,lt,ur,fi,i;if(t||!gr){if(gr=!0,r.docked?a.addClass("docked"):a.removeClass("docked"),r.stickyHeader?st?a.addClass("is-sticky-header"):a.addClass("is-legacy-sticky-header"):(a.removeClass("is-sticky-header"),a.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(wt||(wt=$("<div class='is-grid-caption invalid'><span>xxxxx<\/span><\/div>"),a.append(wt)),wt.hide(),!ft){ft=$("<div class='is-grid-caption'><span><\/span><div class='close is-symbol-close'><\/div><\/div>");wi=$("span",ft);wi.text(yt);dr=$(".close",ft);a.append(ft);dr.on("click",function(n){ft.slideUp("fast");n.stopPropagation()});ft.on("click",ie)}if(ut||(ut=$("<div class='is-grid-buttons'><\/div>"),a.append(ut)),h=$("thead > tr",s),h.length>1&&(h=$(h[h.length-1])),h.length==0&&(ki=$("<thead><\/thead>"),h=$("<tr><\/tr>"),ki.append(h),s.append(ki)),(r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors)&&!bi&&$("th.rowselector",h).length==0&&(gi=$("<th class='rowselector'><\/th>"),h.prepend(gi),r.allowMultiRowSelect&&(nr=$("<input type='checkbox'/>"),gi.append(nr),bi=new n.UI.CheckBox(nr,{onChange:function(n){lu(n.Value(),!0)}}))),et=!1,d=!1,!nt){nt=$("<div style='display:none; position:absolute;' class='grid-cell-editor'><\/div>");nt.focusout(function(){d&&window.setTimeout(function(){l(!1)},100)});ni.append(nt);o={};p=$("<input/>");nt.append(p);o.textbox=n.UI.TextBox(p,{onChange:function(){l(!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?(l(!1),dt()):(l(!1),kt()),!1}});o.textbox.Element().on("keyup",function(n){switch(n.keyCode){case 13:return l(!1),!1;case 27:return l(!0),!1;case 38:return l(!1),yr(),!1;case 40:return l(!1),vr(!0),!1}});p=$("<input/>");nt.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?(l(!1),dt()):(l(!1),kt()),!1}});o.listbox.Element().on("keyup",function(n){switch(n.keyCode){case 13:return l(!1),!1;case 27:return l(!0),!1}});p=$("<input/>");nt.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?(l(!1),dt()):(l(!1),kt()),!1}});o.dbcombo.Element().on("keyup",function(n){switch(n.keyCode){case 13:return l(!1),!1;case 27:return l(!0),!1}});p=$("<input/>");nt.append(p);o.numberbox=n.UI.NumberBox(p,{onChange:function(){l(!1)}});o.numberbox.Element().css({"background-color":"white"});o.numberbox.Element().on("keydown",function(n){switch(n.keyCode){case 9:return n.shiftKey?(l(!1),dt()):(l(!1),kt()),!1}});o.numberbox.Element().on("keyup",function(n){switch(n.keyCode){case 13:return l(!1),!1;case 27:return l(!0),!1;case 38:return l(!1),yr(),!1;case 40:return l(!1),vr(!0),!1}})}for(r.allowAddRows&&!r.readOnly?a.addClass("has-add-row"):a.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(),cr(i,i.thElement,""),i.thElement.off("click"),i.thElement.removeClass("sortable selectable"),i.selectable&&(i.thElement.addClass("selectable"),function(n){n.thElement.click(function(){wr(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 br(n.key),t.preventDefault(),!1})}(i)));if(at)for(oi=$("thead > tr:last-child",s),si=$("th.rowselector",oi),si.length!=0&&(si.attr("rowspan",2),$("th.rowselector",at).length==0&&at.prepend(si)),u=0;u<e.length;u++)y=e[u],y.thElementMerged?(at.append(y.thElementMerged),oi.append(y.thElement)):y.merged?oi.append(y.thElement):(y.thElement.attr("rowspan",2),at.append(y.thElement));b=$("tbody",s);b.length==0&&(b=$("<tbody><\/tbody"),s.append(b))}for(fr=$("thead > tr > th",s),fr.removeClass("sorted sorted-desc selected"),r.sortByColumn&&(tr=$("thead > tr > th[key='"+r.sortByColumn+"']",s),tr.addClass("sorted"),r.sortByDesc&&tr.addClass("sorted-desc")),v=[],tt=null,b.children().remove(),bt=!1,u=0;u<e.length;u++)if(y=e[u],y.summary)switch(y.summary.toUpperCase()){case"":break;case"COUNT":case"CUSTOM":case"SUM":case"$SUM":bt=!0;break;default:window.alert("widget.UI.Grid: Invalid column summary type '"+y.summary+"'. Supported types are: count, sum, $sum, custom");console.warn("widget.UI.Grid: Invalid column summary type '"+y.summary+"'. Supported types are: count, sum, $sum, custom")}if(c){for(rt=[],gt=0,r.sortByColumn||r.groupByColumns&&r.groupByDesc?(r.groupByColumns?(hi=r.groupByColumns,r.groupByDesc&&(hi="-"+hi),k=r.sortByColumn,r.sortByDesc&&(k="-"+k),f.sort(uu([hi,k]))):(k=r.sortByColumn,r.sortByDesc&&(k="-"+k),f.sort(uu([k]))),di=!0):di&&(di=!1,pr(c,!0,{},!0)),ti=0,u=0;u<f.length;u++)if(ht=f[u],ht){if(r.groupByColumns&&(ct=ht.cells[r.groupByColumns].sortValue||ht.cells[r.groupByColumns].value,(ct===undefined||ct===null)&&(ct="(none)"),(pt===null||pt!=ct)&&(bt&&pt!=null&&(rt.push(sr(f,ti,u-1,r.groupByColumns)),ti=u),gt+=1,ii=$("<tr listIndex='-1' class='group-header'><\/tr>"),ui=$("<td><\/td>"),ir=e.length,(r.rowNumbering||r.allowMultiRowSelect||r.showRowSelectors)&&(ir+=1),ui.attr("colspan",ir),ui.text(ct),ci=$("<div group-index='"+gt+"'><\/div>"),r.groupingsCollapsed&&ci.addClass("collapsed"),ui.append(ci),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"));g&&vi()})}(ii,ci),ht.hidden&&ii.addClass("hidden"),ii.append(ui),rt.push(ii),pt=ct)),lt=$("<tr listIndex='"+ht.listIndex+"' class='datarow'><\/tr>"),v.push(lt),gt!=0&&(lt.attr("group-index",gt),r.groupingsCollapsed&&lt.addClass("group-collapsed")),hr(u,lt),u==0&&!r.showColumnHeaders&&(ur=$("td,th",lt),ur.length==e.length))for(fi=0;fi<e.length;fi++)i=e[fi],i.width&&$(ur[fi]).css("width",i.width);ht.hidden&&(ei+=1);rt.push(lt)}bt&&pt!=null&&(rt.push(sr(f,ti,f.length-1,r.groupByColumns)),ti=u);bt&&rt.push(sr(f,0,f.length-1,""));b.append(rt);r.allowAddRows&&!r.readOnly&&(ot=$("<tr listIndex='-1' class='templaterow'><\/tr>"),hr(-1,ot),b.append(ot),ot.bind("click",function(n){if(d&&l(!1),pi(!0)){var t=ri($(n.target).attr("key")),i=-1;t&&(i=ru(t.key));vt(i)}else console.warn("Maximum new grid rows limit reached.")}));vf()}r.stickyHeader&&r.showColumnHeaders&&cf();r.showContextMenu&&rr($("*",a),function(n){var t=$(n.delegateTarget).closest("tr").attr("listIndex"),i;if(t!==undefined&&yi(t),i={contextMenuEventArgs:n,row:{listIndex:t}},r.onContextMenuShow)r.onContextMenuShow(n,i);else lf(n,i);return n.preventDefault(),!1});r.selectedColumnKey&&wr(r.selectedColumnKey);ei!=0&&r.showHiddenRowsPopup?(yt=ei==1?"1 row is hidden":ei+" rows are hidden",yt+=". Click to show.",wi.text(yt)):yt="";yt?ft.show():ft.hide();ai();li(!1,!0);it=!1}function cf(){st}function lf(n){gt||(gt=new ff(s,{}));gt.OnAction(af);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"});gt.Define(t);t.length!=0&&gt.Show(n.clientX,n.clientY)}function af(n){switch(n){case"Export_CSV":ui("CSV");break;case"Export_HTML":ui("HtmlTable");break;case"Export_MSEXCELWORKBOOK":ui("MSEXCELWORKBOOK");break;case"Export_PDF":ui("PDF");break;case"SortClear":br("",!1)}}function vf(){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&&ar(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&&l(!1),o=e.hasClass("is-sel"),i=0;i<v.length;i++)if(v[i][0]==f[0]){w(i);break}t=ri(e.attr("key"));u=-1;t&&(u=ru(t.key));vt(u);et&&t&&o&&(t.allowEdit&&t.type.toUpperCase()!="BOOLEAN"?l(!1)&&bt():l(!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&&ar(t,"");r.onRowDrilldown&&window.getSelection&&window.getSelection().removeAllRanges()})}}function bt(){var t,i,e,n,o;if(!r.readOnly){if(d&&l(),t=or(p),!t||!t.allowEdit)return!1;if(i=f[u],e=i.cells[rt],!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:u},columnKey:rt,cancel:!1,editorInfo:n};r.onBeforeCellEdit(o);if(o.cancel)return!1}return d=!0,h=n,n.valueOriginal=e.value,li(!0),!0}}}function l(n){if(!d)return!0;if(n)return d=!1,li(),!0;d=!1;var t;switch(h.type.toUpperCase()){case"DATEBOX":t=ct(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!"):lr(u,rt,t,!0),li(!1),!0}function li(n,t){var e,c,r,f,i;if(u<0||u>v.length-1?d=!1:et&&p!=-1&&u!=-1||(d=!1),d||(pt=null,nt.hide()),!d){t||(e=ni.scrollTop(),s.focus(),ni.scrollTop(e));return}if(c=v[u],r=$("td[key='"+rt+"']",c),pt=r.length==1?r:null,pt){if(f=pt.position(),nt.css({left:f.left+"px",top:f.top+"px",height:pt.outerHeight()+"px",width:pt.outerWidth()+"px"}),nt.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=lt(h.valueOriginal));h.valueOriginal||(h.valueOriginal=null);o.textbox.Text(y(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:nt.innerHeight()+"px",backgroundColor:"white !important",border:"none",borderRadius:0});h.valueOriginal||(h.valueOriginal="");o.dbcombo.Text(h.valueOriginal);o.dbcombo.LimitToList(h.limitToList);o.dbcombo.RefreshFromCollection(h.collection.data,h.collection.idColumn,h.collection.displayColumns);o.dbcombo.Focus();window.setTimeout(function(){o.dbcombo.DropdownShow()},10);break;case"LISTBOX":o.listbox.Visible(!0);o.listbox.Element().css({height:nt.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=ri(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(),nt.hide()}function ai(){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<fi.Actions().length;o++)if(t=fi.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(){pf(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 yf(){return fi}function pf(n){if(r.onAction)r.onAction(n);else window.alert("widget.UI.Grid.ExecuteAction: No OnAction defined for this Grid object.")}function vi(){var e=a.offset(),o=a.outerWidth(),v=a.innerWidth(),h=a.outerHeight(),c=ni.scrollLeft(),t=a.scrollTop(),l=s.outerWidth(),i,r,n,u,f;if(g)for(g.css({width:l+"px"}),g.css({"margin-left":-c+"px"}),vu.css("top",t+"px"),t!=nu&&k&&(nu=t,g.hide(),window.setTimeout(function(){g.fadeIn("fast")},500)),i=$("thead > tr > th",s),r=$("thead > tr > th",g),n=0;n<i.length;n++)u=$(i[n]),f=$(r[n]),f.css("width",u.outerWidth()+"px");gi&&(gi.css({width:o+"px",top:h+e.top+"px"}),a.css({"margin-bottom":"36px"}))}function sr(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),cr(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 uu(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(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),cr(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],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.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);vt(i);lr(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}(l.readOnly||o&&o.readOnly)&&(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 cr(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)}))}!t.original}function lr(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)&&hu(o.listIndex);g&&vi()}}function ar(n,t){if(r.onRowDrilldown){n===undefined&&(n=u);var i={row:{listIndex:n},columnKey:t};r.onRowDrilldown(i)}}function vt(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=or(p),rt=t?t.key:"",r.allowCellSelect&&$("td[key='"+rt+"']",tt).addClass("is-sel")):(p=-1,rt="")}function w(n,t){if(n===undefined)return u;n=parseInt(n);var i=u;tt&&(tt.removeClass("is-sel"),$("td",tt).removeClass("is-sel"),tt=null);n>=0&&n<v.length?(u=n,tt=v[u],tt.addClass("is-sel"),tt.removeClass("hidden"),eu()):u=-1;p!=-1&&vt(p);ht();r.onAfterRowActivate&&u!=i&&(t||r.onAfterRowActivate())}function yi(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 wf(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 fu(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 bf(){if(f&&u>0){var t=s.height(),i=s.scrollTop,n=u;n-=10;n<0&&(n=0);w(n);ht(!0)}}function kf(){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);ht(!0)}}function kt(){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}vt(t)}}function vr(n){var i,t;if(n&&r.allowAddRows&&!r.readOnly&&f&&u==f.length-1&&pi(!0),f&&u<f.length-1){for(i=u,t=u+1;t<f.length;t++)if(f[t]!=null&&(ki||!f[t].hidden)){i=t;break}w(i);ht(!0)}}function dt(){var t,n;if(f&&p>0){for(t=p,n=p-1;n>=0;n--)if(e[n].visible){t=n;break}vt(t)}}function yr(){var t,n;if(f&&u>0){for(t=u,n=u-1;n>=0;n--)if(f[n]!=null&&(ki||!f[n].hidden)){t=n;break}w(t);ht(!0)}}function ht(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&&g&&(t=g.outerHeight()),i.ScrollElementIntoView(n,n,{inViewAmount:t}))}}function pi(n){var t,u,i,e;if(ei>=r.maxNewRows)return!1;if(r.sortByColumn||r.groupByColumns)return window.alert("Sorted or grouped grid do not support adding new rows."),!1;if(ei+=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>");v.push(i);ot?i.insertBefore(ot):b.append(i);e=ou(t);e.newRow=!0;f.push(e);cu(t,t);n&&fu(!1);(g||gi)&&vi()}else return window.alert("Grid does not handle onRowAdd."),!1;return!0}function eu(){var t="",n;u>=0&&u<f.length&&(n=f[u],n.invalid&&n.invalidMessage&&(t=n.invalidMessage));t?(wt.text(t),wt.show()):wt.hide();ot?ht(!1,ot.outerHeight()):ht()}function ou(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,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){df(i,n)},i}function df(n,t){var i,r;for(i in t)for(r in n.cells)i==r&&(n.cells[r].value=t[i])}function gf(){return s}function ui(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 ne(n){if(n===undefined)return r.groupByColumns;r.groupByColumns=n}function te(n){if(n===undefined)return r.readOnly;n!=r.readOnly&&(r.readOnly=n==!0,ci(!0))}function su(n){ci(n)}function ie(){$("tr.hidden",s).removeClass("hidden");ft.slideUp("fast");ht();ki=!0;r.stickyHeader&&vi()}function pr(n,t,i,o){var l,s,h,a;if(n&&(c=n),f=[],e.length!=0){ei=0;l=u;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=ou(s);a={row:h};f.push(h);r.onInitialiseRow(a)}}catch(v){window.alert("widget.UI.Grid.VirtualDataRefresh: "+v.message)}o||su(!0);t?(w(-2),w(l)):(w(-1),r.onAfterRowActivate&&r.onAfterRowActivate())}}function hu(n,t){if(t===undefined)for(var i=0;i<f.length;i++)if(f[i].listIndex==n){t=i;break}cu(n,t);r.allowCellSelect&&vt(p)}function cu(n,t){var e={row:f[t]},i,u;r.onInitialiseRow(e);i=$("tr[listindex="+n+"]",b);u=i.hasClass("hidden");hr(t,i,!0);u||i.removeClass("hidden");eu()}function re(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)&&(ei-=1),t==u&&(tt=null),o=v[t],n.ArrayRemove(v,v[t]),o.remove(),n.ArrayRemove(f,f[t]),n.ArrayRemove(c,c[t]),i=0;i<v.length;i++)e=v[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 ue(){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=v[u];t=v[u-1];v[u]=t;v[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);ai()}}function fe(){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=v[u];t=v[u+1];v[u]=t;v[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);ai()}}function ee(){for(var n=0;n<e.length;n++)if(e[n].key.toUpperCase()==r.selectedColumnKey.toUpperCase())return e[n];return null}function wr(n){var t,i,u;if(n===undefined)return r.selectedColumnKey;t=r.selectedColumnKey;r.selectedColumnKey=n;$("th,td",s).removeClass("selected");g&&$("th,td",g).removeClass("selected");i=$("th[key='"+r.selectedColumnKey+"'],td[key='"+r.selectedColumnKey+"']",s);i.addClass("selected");g&&(u=$("th[key='"+r.selectedColumnKey+"'],td[key='"+r.selectedColumnKey+"']",g),u.addClass("selected"));r.onColumnSelect&&r.selectedColumnKey!=t&&r.onColumnSelect()}function br(n,t,i){if(f){var u=yi();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);ci(!1);yi(u,!0);!i&&r.onAfterColumnSort&&r.onAfterColumnSort()}}function oe(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 se(n){if(n===undefined)return r.visible;r.visible=n;r.visible?a.show():a.hide()}function he(){s.focus()}function lu(n,t){var u,i,e;if(r.allowMultiRowSelect){for(u=0;u<f.length;u++)i=f[u],i&&i.rowSelectorCheckBox&&(e=v[i.listIndex],t&&e.hasClass("is-filtered-out")||(i.rowSelectorCheckBox.Value(n),n?e.addClass("row-selected"):e.removeClass("row-selected")));if(bi.Value(n),r.onAfterRowActivate&&r.onAfterRowActivate(),r.onSelectedRowsChanged)r.onSelectedRowsChanged({})}}function au(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 ce(n,t){var r,i;if(t)for(r=0;r<f.length;r++)i=f[r],i&&i.rowSelectorCheckBox&&(i.rowSelectorCheckBox.Value(!1),v[i.listIndex].removeClass("row-selected"));for(r=0;r<n.length;r++)i=f[n[r]],i&&i.rowSelectorCheckBox&&(i.rowSelectorCheckBox.Value(!0),v[i.listIndex].addClass("row-selected"))}function le(n){var i,r,t,u,e;if(n===undefined&&(n=!1),i=[],c)for(r=au(!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 ae(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&&pr(c,!0)}function ve(){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}var fi,u=-1,p=-1,rt,ut,ft,wi,dr,yt="",e=[],it=!0,v=[],pt,d=!1,nt,o,et=!1,h,s,bi,b,ki=!1,gr=!1,wt,gt,at,ei=0,r,tt,di=!1,gi,g,vu,nu=0,ni,ot,c,f,a,oi,nr,ir,ur,ti,si,tu,fr,hi,ii,er,kr;if(fi=new tr,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"?(oi=t,t=$("#"+oi)):oi=$(t).attr("id"),nr=$(t),nr.length==0){n.RegisterError("widget_ui.Grid: Element '"+oi+"' not found.");return}for(s=$(nr[0]),s.prop("tagName")=="DIV"?(s.addClass("is-grid"),a=s,s=$("<table><thead class='is-no-select'><tr><\/tr><\/thead><tbody><\/tbody><\/table>"),r.width&&a.css("width",r.width),a.append(s)):(s.wrap("<div class='is-grid'><\/div>"),a=$(s.parent()),ir=s.css("float"),ir&&a.css("float",ir)),r.docked===null&&(r.docked=r.stickyHeader==!0?!0:!1),r.stickyHeader===null&&(r.stickyHeader=st),s.attr("tabindex","-1"),s.wrap("<div class='is-grid'><\/div>"),ni=$(s.parent()),a.addClass("is-grid-container"),a.removeClass("is-grid"),ur=$("thead > tr > th",s),ti=0;ti<ur.length;ti++)if(si=$(ur[ti]),tu=si.attr("colspan"),tu){if(fr=si.attr("colspan-for"),fr)for(hi=fr.split(","),ii=0;ii<hi.length;ii++)er=$("th[key='"+hi[ii]+"']",s),er.length>0?iu($(er[0])):window.alert("widget.UI.Grid: colspan-for '"+hi[ii]+"', child column not found")}else iu(si);return s.bind("keyup",function(n){if(!d)switch(n.keyCode){case 13:if(et)return bt(),!1}}),s.bind("keydown",function(n){var t,i,o;if(!d)switch(n.keyCode){case 9:if(r.allowCellSelect)return n.shiftKey?dt():kt(),!1;break;case 13:break;case 27:w(-1);vt(-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),ht()),!1;case 36:return f&&(w(0),ht()),!1;case 33:return bf(),!1;case 34:return kf(),!1;case 37:return dt(),!1;case 38:return yr(),!1;case 39:return kt(),!1;case 40:return c&&u==c.length-1&&r.allowAddRows&&!r.readOnly?(o=f[u],o.newRow||pi(!0)):vr(),!1;case 46:if(et&&p==-1&&u!=-1){if(r.onAction)r.onAction("DeleteRow")}else switch(e[p].type){case"Currency":case"Integer":lr(u,rt,null,!0);break;default:bt();window.setTimeout(function(){l(!1)},10)}break;case 113:et&&bt();break;default:if(et)if(n.keyCode>=32&&n.keyCode<=111||n.keyCode==189)bt();else switch(n.keyCode){case 187:case 191:bt()}}}),e.length==0||ci(!0),kr={TypeName:"Grid",ClearColumns:yu,GetColumnByIndex:or,GetColumnByKey:ri,AddColumnBoolean:wu,AddColumnCurrency:bu,AddColumnDate:ku,AddColumnDateTime:du,AddColumnDrilldown:gu,AddColumnHtml:nf,AddColumnIcon:tf,AddColumnInteger:rf,AddColumnString:uf,AddColumnCode:ef,ColumnCount:of,SortColumnsByArray:sf,MergeColumnHeaders:hf,ActivateFirstDataRow:wf,ActivateLastDataRow:fu,ActiveDataRowIndex:w,ActiveDataRowListIndex:yi,AddRow:pi,GetSelectedRowIndexes:au,SetSelectedRowIndexes:ce,SelectAllRows:lu,GetVirtualDataForSelectedRows:le,GroupByColumnsUpdate:ae,ColumnVisible:oe,Actions:yf,RowMoveUp:ue,RowMoveDown:fe,Editing:function(){return d},Element:gf,ExportData:ui,Focus:he,GroupByColumns:ne,PerformRowDrilldown:ar,ReadOnly:te,Refresh:su,RefreshButtons:ai,RefreshRow:hu,RemoveRowAndCollectionItem:re,SelectedColumn:ee,SelectedColumnKey:wr,Sort:br,Validate:ve,VirtualDataRefresh:pr,Visible:se},a.prop("is-control",kr),kr}function fu(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 eu(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 ou(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(),nt[t]){h(nt[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);nt[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 a(){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=it(o,u.decimals,!1,!1);t=it(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");rt?(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=l(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(it(o,t,!1,!1))):u.blankIfZero&&o==0?f.val(""):tt||(i=it(o,u.decimals,u.showSeparators,u.blankIfZero),u.percentage&&(i+="%"),f.val(i))}function wt(n){n!=u.allowBlank&&(u.allowBlank=n==!0,a())}function bt(n){if(n===undefined)return u.blankTip;u.blankTip=n;a()}function ct(){if(!nt){var n=$("<div><\/div>");c.append(n);nt=ti(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());rt||yt()}function ni(){return f}function ii(){f.focus();f.select()}function ri(n){if(n===undefined)return u.fontBold;n!=u.fontBold&&(u.fontBold=n==!0,a())}function ui(n){if(n===undefined)return u.readOnly;n!=u.readOnly&&(u.readOnly=n==!0,a())}function fi(n){if(n===undefined)return u.autoReadOnly;n!=u.autoReadOnly&&(u.autoReadOnly=n==!0,a())}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 rt?!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":it(u.minValue,u.decimals,!0,!1)),u.maxValue!=null&&(n&&(n+=" "),n+="to "+it(u.maxValue,u.decimals,!0,!1)),n}function st(n,t,i){rt=n;w=t===undefined?"":t;ft=i===undefined?!1:i;a()}function hi(n){u.onChange=n}function ci(n){if(n===undefined)return u.visible;u.visible=n;a()}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,rt=!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]),a(),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:ii,FontBold:ri,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 su(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 hu(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 et(){return v}function ot(){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 h=$.extend({},nt,r),u,a,s,p,y;if(v=!0,c=!1,o.attr("available",!0),f="",u="",h.cssSummaryPage2){a="";window.$App&&$App.Version&&(a="?v="+$App.Version());s="";switch(n.GetHostingContext()){case"WebInternal":case"WebExternal":s=ai+"Content/SummaryPage2/";break;default:s=n.Options.templatesPath+"/"}u+="<link rel='stylesheet' type='text/css' href='"+s+"summarypage_2.css"+a+"'><\/link>";u+="<link rel='stylesheet' type='text/css' href='"+s+"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>",f+="<head>",u||console.warn("No Resources!\n\no.cssSummaryPage2="+h.cssSummaryPage2),f+=u,f+="<\/head>",f+="<body style='margin:0;padding:0'>",h.formatAsSummaryPage2&&(f+="<div class='is-summarypage-2'>"));f+=t;i||(h.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),ft&&e.attr("scrolling","no"),g(),nt={cssSummaryPage2:!0,formatAsSummaryPage2:!1},u={TypeName:"PreviewPane",CacheClear:rt,CacheExists:k,CacheRemove:ut,Clear:w,Element:tt,Loaded:et,Loading:ot,PreviewFromGridCollection:st,ResizeFromParent:ht,SetContent:y,SetContentError:d,Visible:vt,VisibleRow:yt}}function cu(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 ut(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 lu(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 au(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((!si||n)&&s!=-1)for(f=$("input,select,textarea",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?ni(r.pageElement,undefined,undefined,t):(window.alert("Tabs.Validate: No current tab."),!1);for(i=0;i<u.length;i++)if(u[i].visible&&!ni(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 wt(){if(!v){var n=$("<div><\/div>");o.append(n);v=ti(n,{onButtonClick:u.onButtonClick,visible:!1,parentControl:nt})}return v}function ii(n){var t=wt();n||(n=[]);t.ButtonsDefine(n);v.Visible(n.length!=0)}function ri(n){if(n===undefined)return l?l.text():"";l&&l.text(n)}function bt(){return f.val()!=y}function vt(){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 kt(f,!0);f.val(n);y=n;at()}function yt(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"})):yt()}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);vt()}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,pt=!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&&yt(),f.blur(function(){bt()&&vt();y=f.val();pt=!1}),f.focus(function(){if(pt=!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(){vt();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:wt,ButtonsDefine:ii,Caption:ri,Changed:bt,Element:ui,Focus:dt,MaxLength:oi,ReadOnly:ei,ResizeFromParent:ci,TagsListDefine:li,Text:hi,Visible:wi,VisibleRow:bi,WrapperElement:fi,WidthResizeFromParent:yt,TextOriginal:function(){return y}}}function vu(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=ki(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 yu(t){return n.Trim(t)}function pu(t){return n.LTrim(t)}function nr(t){return n.RTrim(t)}function wu(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"),i.length<100&&i.indexOf("\n")==-1?(r.width||(r.width="50%"),r.height||(r.height="50%"),r.maxWidth==null&&(r.maxWidth=320),r.maxHeight==null&&(r.maxHeight=200)):i.length<200&&i.indexOf("\n")==-1?(r.width="60%",r.height="60%",r.maxWidth==null&&(r.maxWidth=480),r.maxHeight==null&&(r.maxHeight=320)):(r.width="80%",r.height="80%",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 bu(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.maxWidth==null&&(r.maxWidth=420);r.maxHeight==null&&(r.maxHeight=320);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 ku(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 du(t,i,r,u){n.GetHostingContext()=="WebInternal"&&window.parent&&window.parent.$UI?window.parent.$UI.MsgBoxConfirmDelete(t,i,r,u):window.confirm(t)?r&&r():u&&u()}function gu(t,i,r){i=$.extend({},MsgBoxDefaults,i);i.icon||(i.icon="Information");i.title||(i.title="Information");n.UI.MsgBoxAlert(t,i,r)}function nf(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 ri(t,i,r){return n.SplitWordsAtCapitals(t,i,r)}function vt(t){return n.ArrayFromCsvString(t)}function tf(n){return n.Element().closest("tr")}function rf(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 uf(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 tr(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 ff(t,i){function a(n){s=n;yi(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);ft&&(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 ef(n){function wt(){return l}function ut(){ht();ct()}function ht(){if(f==o[o.length-1]){tt>0&&(tt-=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&&(it&&(b.detach(),b.hide(),it.append(b),b=null,it=null),r.remove(),r=null,u.remove(),u=null,$(window).unbind("resize.modal"+y),tt<=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 oi(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"):(ei+=1,y=ei,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,it=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();tt+=1;tt==1&&$("body").addClass("is-has-modal");i.focusActionId&&window.setTimeout(function(){vi(i.focusActionId)},10)}function ci(){uf(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,it,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 tr,f={TypeName:"Modal",Actions:wt,Close:ut,ContentElement:bt,DialogResult:kt,FormDisable:gt,FormEnable:ni,GetElement:dt,Hide:lt,LoadPortalPage:oi,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 of(t,i){function l(n,t){if(t&&(t.ChangeHandled=!0),v.onChange)if(t&&t.fieldUpdated)v.onChange(t.fieldUpdated);else v.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 gt(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 ni(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};v.stdTransWidgetId?n.UI.Forms.ShowHtmlWidgetModal(v.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(!0);r.cboInterestRateTable.VisibleRow(!1);r.numInterestRatePremium.VisibleRow(!1);break;case"FloatingRate":r.numInterestRate.VisibleRow(!0);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(!0);r.numInterestRatePremium.VisibleRow(!0);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 ri(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 vt(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 yt(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(v.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.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.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.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.lblStartupInterestRate.VisibleRow(!1);r.cboStartupInterestType.VisibleRow(!1);r.cboStartupInterestPeriod.VisibleRow(!1);r.numStartupInterestRate.VisibleRow(!1);r.numStartupInterestRatePremium.VisibleRow(!1);r.dateStartupInterestToDate.VisibleRow(!1);r.cmdSchedule&&r.cmdSchedule.show();r.cmdResetFinancial&&r.cmdResetFinancial.show();break;default:console.warn("widget_ui.AccountFinancial: AccountClass '"+y.AccountClass+"' not handled.")}}function ui(){r.dateOpeningDate.Focus()}function fi(n){if(n===undefined)return v.visible;v.visible=n;nt(!1)}function ei(n){if(n===undefined)return v.readOnly;n!=v.readOnly&&(v.readOnly=n,nt())}function oi(n){if(n===undefined)return v.stdTransWidgetId;v.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),vt(),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),yt(),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(),v.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,v,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,w;if(AccountFinancialDefaults={readOnly:!1,allowStdTransDrilldown:!0,allowStdTransReset:!0,allowReset:!0,allowSchedule:!0,autoReadOnly:!0,showStdTrans:!0,stdTransWidgetId:"",visible:!0,onAction:null,onChange:null},v=$.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),v.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>"),v.showStdTrans&&(e=h(!0),r.gridStdTrans=ii(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;at("Removing Transaction, please wait...");l();break;case"RowMoveDown":r.gridStdTrans.RowMoveDown();l();break;case"RowMoveUp":r.gridStdTrans.RowMoveUp();l();break;default:if(v.onAction)v.onAction(n)}},onAfterRowActivate:bt,onBeforeCellUpdate:gt,onInitialiseRow:wt,onRowDrilldown:ni}),v.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%"}),w=[],v.allowStdTransDrilldown&&(w.push({actionId:"Add",tooltipText:"Add Transaction",icon:"Add"}),w.push({actionId:"DeleteRow",tooltipText:"Delete row",icon:"Delete"}),w.push({}),w.push({actionId:"RowMoveUp",tooltipText:"Move current row up",icon:"Grid_Row_MoveUp"}),w.push({actionId:"RowMoveDown",tooltipText:"Move current row down",icon:"Grid_Row_MoveDown"})),v.allowStdTransReset&&(w.push({}),w.push({actionId:"StdTransReset",tooltipText:"Reset Transactions to Account Type defaults",icon:"Reset"})),r.gridStdTrans.Actions().Define(w)),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=a($("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=a($("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=a($("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=a($("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:ri}),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=a($("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:vt}),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=p($("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=a($("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:yt}),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=a($("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=p($("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=p($("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}),v.allowSchedule||v.allowReset){if(u=$("<tr><th colspan='2' style='padding-top:8px'><\/th><\/tr>"),r.tblInterest.append(u),td=$("th",u),v.allowSchedule&&(r.cmdSchedule=$("<button class='is-button small' icon='Schedule'>Schedule<\/button>"),td.append(r.cmdSchedule),v.onAction))r.cmdSchedule.on("click",function(){v.onAction("ScheduleShow")});if(v.allowReset&&(r.cmdResetFinancial=$("<button class='is-button small' icon='Reset'>Reset Financial<\/button>"),td.append(r.cmdResetFinancial),v.onAction))r.cmdResetFinancial.on("click",function(){v.onAction("Reset")});dt($("*[icon]",td))}return nt(!1),{TypeName:"AccountFinancial",Focus:ui,ReadOnly:ei,StdTransWidgetId:oi,Visible:fi,FromAccountCalcJson:si,ToAccountCalc:pt,ToAccountCalcJson:hi,InterestPaymentType:ci,TermCycle:li}}var w=null,r=!1,yt=null,pt=!1,v,ot=!1,ui=!1,wt=[],fi=!1,st=!0,nt={},ei=0,tt=0,o=[],oi="orange",ht="navy",bt="navy",si=!1,ft=!1,ct=n.ParseDate,hi=n.FormatCurrency,y=n.FormatDateInternal,lt=function(n){return n?new Date(n):null},it=n.FormatNumber,l=n.ParseNumber,ci=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"}},li=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"}},kt=function(n,t){if(typeof t=="undefined"&&(t=!0),typeof n=="string"&&(n=$("#"+n)),n)try{var i=$(n).val();return t&&(i=nr(i)),i}catch(n){return""}else return""},ai="../",ir=!1,b,vi,k,gi,u;switch(n.GetHostingContext()){case"WebExternal":case"WebInternal":break;default:ir=!0;$("body").addClass("is-desktop")}if(n.GetHostingContext()=="WebInternal")try{b=window.parent.document.getElementById("themecolourtester");b&&(b=$(b),ht=b.css("background-color"),bt=b.css("border-top-color"),oi=b.css("border-left-color"),$("head").append("<style type='text/css'><\/style>"),vi=$("head").children(":last"),vi.html(".is-widget-content footer { border-top-color: "+ht+" !important; }\n\n.is-modal .is-modal-title { background-color: "+ht+" !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:"+oi+" !important; }\n\n"))}catch(sf){}if(n.GetHostingContext()=="WebInternal")try{ai=window.parent.$Runtime.WebRoot();si=window.parent.$Runtime.IsMobileBrowser();ft=window.parent.$Runtime.IsPlatformIOS()}catch(sf){}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&&(fi=!0);k&&(st=!1);$(function(){dt($("*[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>"+ci(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>"+li(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(li(new Date(o,f,e).getDay())),w.val(o+""),p.val(ci(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 lt(){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):(window.alert(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=ct("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:lt,GotoValue:d,ReadOnly:at,Value:nt}};gi={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:at,Unblock:et,ApplyIcons:dt,DisableControlStyling:cr,DDListFromArray:pi,DDListFromCollection:sr,DDListFromCsv:hr,DDListAdd:or,HtmlEncode:t,ScrollToTop:kr,InitialiseAddressAutoComplete:lr,IsSmallMobileBrowser:br,TableAddRowsFromCollection:dr,ValidateContainer:ni,Evaluate:wi,AccountFinancial:of,AccountPaymentDetails:gr,AccountIncomingPaymentDetails:bi,AccountOutgoingPaymentDetails:nu,AddressDetails:tu,ButtonList:iu,ButtonStrip:ti,CheckBox:di,ComboBox:s,DashboardLayout:ru,DateBox:a,DateCycleComboBox:g,DBCombo:p,DocumentManagerComboBox:fu,DropdownPanel:ut,Form:uu,Grid:ii,IconComboBox:eu,InformationListComboBox:ou,Label:c,Modal:ef,NumberBox:f,ParametersHost:su,PreviewPane:hu,PromptUpdateList:cu,RadioButton:ki,RadioButtonList:vu,RangeSlider:lu,Tabs:au,TextBox:i,Forms:gi,ModalOpenCount:ur,GetModalById:er,MsgBoxAlert:wu,MsgBoxConfirm:bu,MsgBoxConfirmList:ku,MsgBoxConfirmDelete:du,MsgBoxInfo:gu,MsgBoxList:nf,GetControlRow:tf,LoadStyle:rf,StyleAsModal:fr,FIELD_WIDTH_CODE_5:"6em",FIELD_WIDTH_CODE_10:"9em",FIELD_WIDTH_CODE_15:"12em",FIELD_WIDTH_CODE_20:"16em",Trim:yu,LTrim:pu,RTrim:nr,SplitWordsAtCapitals:ri,ArrayFromCsvString:vt,GetElement:rt};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}}($)