ko.extenders.validateFloat=function(a,c){a.isValid=ko.observable();a.isInRange=ko.observable(!0);var b=function(b){var d="number"==typeof b&&!isNaN(b)&&isFinite(b);a.isValid(d);a.isInRange(!0);d&&(0<=b&&(100>b&&c.allowPercentageOf&&!a.percentageLock)&&(d=ko.utils.unwrapObservable(c.allowPercentageOf),a.percentageLock=!0,isNaN(d)||(b=Math.roundTo(b*d/100,Culture.currentCulture().currencyDecimalDigits))),a()!=b&&a(b));a.percentageLock=!1};b(a());a.subscribe(b);return a};
ko.extenders.validateStringLength=function(a,c){function b(b){null==b&&(b="");c.min<=b.length&&b.length<=c.max?a.isValid(!0):a.isValid(!1)}a.isValid=ko.observable(!0);c.validateOnInitiate&&b(a());a.subscribe(b);return a};
ko.extenders.validateEmail=function(a,c){function b(b){-1!=String(b).search(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)?255>b.length?a.isValid(!0):a.isValid(!1):a.isValid(!1)}a.isValid=ko.observable(!0);c.validateOnInitiate&&b(a());a.subscribe(b);return a};
ko.extenders.validateInterestRate=function(a){a.isValid=ko.observable();var c=function(b){var c="number"==typeof b&&!isNaN(b)&&isFinite(b);a.isValid(c);c&&0<b?a()!=b&&a(b):a(ApplicationSettings.defaultInterestRate);a.percentageLock=!1};c(a());a.subscribe(c);return a};
ko.extenders.onlyValidateInterestRate=function(a){a.isValid=ko.observable();var c=function(b){var c="number"==typeof b&&!isNaN(b)&&isFinite(b);a.isValid(c);c&&0<b?a()!=b&&a(b):a.isValid(!1);a.percentageLock=!1};c(a());a.subscribe(c);return a};ko.extenders.validateTaxMode=function(a){a.isValid=ko.observable();var c=function(b){var c="number"==typeof b&&!isNaN(b)&&isFinite(b);a.isValid(c);c&&0<b?a()!=b&&a(b):a(ApplicationSettings.valueAddedTaxRate);a.percentageLock=!1};c(a());a.subscribe(c);return a};
