ko.bindingHandlers.floatValue={init:function(a,c,b){$(a).bind("change",function(){var d=b().floatFormat,f=c(),e=$(a).val(),e=Number.parseFloatWithFormat(e,d);switch(d){default:case FloatFormats.Currency:e=Math.roundTo(e,Culture.currentCulture().currencyDecimalDigits);case FloatFormats.Percentage:e=Math.roundTo(e,Culture.currentCulture().numberDecimalDigits)}e.format(d)!=ko.utils.unwrapObservable(f)&&(isNaN(e)||f(0),f(e))});Culture.currentCulture.subscribe(function(){var d=ko.utils.unwrapObservable(c());
if(!isNaN(d)){var f=b().floatFormat;$(a).val(d.format(f))}})},update:function(a,c,b){c=ko.utils.unwrapObservable(c());isNaN(c)||(b=b().floatFormat,$(a).val(c.format(b)))}};
ko.bindingHandlers.slider={setOptions:function(a,c,b){ko.utils.unwrapObservable(c.value);!0==c.reverse?($(a).attr(Constants.Min,-1*ko.utils.unwrapObservable(c.max)),$(a).attr(Constants.Max,-1*ko.utils.unwrapObservable(c.min))):($(a).attr(Constants.Min,ko.utils.unwrapObservable(c.min)),$(a).attr(Constants.Max,ko.utils.unwrapObservable(c.max)));$(a).attr(Constants.Step,ko.utils.unwrapObservable(c.step?c.step:100));b&&(!0==c.reverse?$(a).val(-1*ko.utils.unwrapObservable(c.value)):$(a).val(ko.utils.unwrapObservable(c.value)))},
setVisibility:function(a,c){var b=$(a).next("div.ui-slider");c?b.show():b.hide()},init:function(a,c){var b=ko.utils.unwrapObservable(c()),d=ko.utils.unwrapObservable(b.visible);ko.bindingHandlers.slider.setOptions(a,b,d);$(a).slider();ko.bindingHandlers.slider.setVisibility(a,d);$(a).bind("change",function(){var b=ko.utils.unwrapObservable(c()),d=!0==b.reverse?-1*parseFloat($(a).val()):parseFloat($(a).val());d!=ko.utils.unwrapObservable(b.value)&&ko.utils.unwrapObservable(b.visible)&&b.value(d)})},
update:function(a,c){var b=ko.utils.unwrapObservable(c()),d=ko.utils.unwrapObservable(b.visible);ko.bindingHandlers.slider.setOptions(a,b,d);$(a).next("div.ui-slider");ko.bindingHandlers.slider.setVisibility(a,d);$(a).slider("refresh");$(a).change()}};
ko.bindingHandlers.radioButtons={getRadioButtons:function(a){return $('input[type="radio"]',a)},setValue:function(a,c){for(var b=0;b<a.length;b++)$(a[b]).prop("checked",$(a[b]).val()==c),Log($(a[b]).val()==c);a.checkboxradio("refresh")},getValue:function(a){for(var c=0;c<a.length;c++)if($(a[c]).prop("checked"))return $(a[c]).val()},init:function(a,c){var b=ko.bindingHandlers.radioButtons.getRadioButtons(a);b.bind("change",function(){var a=ko.bindingHandlers.radioButtons.getValue(b),f=c();a!=ko.utils.unwrapObservable(c())&&
f(a)})},update:function(a,c){var b=ko.bindingHandlers.radioButtons.getRadioButtons(a),d=ko.utils.unwrapObservable(c());ko.bindingHandlers.radioButtons.setValue(b,d)}};ko.bindingHandlers.floatText={update:function(a,c,b){c=ko.utils.unwrapObservable(c());isNaN(c)||(b=b().floatFormat,$(a).text(c.format(b)))}};ko.bindingHandlers.textDateValue={update:function(a,c){var b=ko.utils.unwrapObservable(c()),b=""!=b?moment(b,Constants.LongDataFormat).toDate():"";$(a).val(String.format("{0:d}",b))}};
ko.bindingHandlers.dateText={update:function(a,c){var b=ko.utils.unwrapObservable(c()).toDate();$(a).text(String.format("{0:d}",b))}};ko.bindingHandlers.atomDateText={update:function(a,c){var b=ko.utils.unwrapObservable(c()),b=moment(b,Constants.ServiceDataFormat).toDate();$(a).text(String.format("{0:d} {0:T}",b))}};
ko.bindingHandlers.selectMenuOptions={init:function(a,c,b,d){"undefined"!==typeof ko.bindingHandlers.options.init&&ko.bindingHandlers.options.init(a,c,b,d)},update:function(a,c,b,d){"undefined"!==typeof ko.bindingHandlers.options.update&&ko.bindingHandlers.options.update(a,c,b,d);$(a).selectmenu("refresh")}};ko.bindingHandlers.selectMenuEnabled={update:function(a,c){ko.utils.unwrapObservable(c())?$(a).selectmenu("enable"):$(a).selectmenu("disable")}};
ko.bindingHandlers.toggleSwitch={init:function(a,c){Log("Toggle switch binding: init");var b=c();b.labels||(b.labels=[1,0]);b.values||(b.values=["",""]);var d=$("option",a),f=$("span.ui-slider-label",$(a).parent());if(2!=b.labels.length||2!=b.values.length||2!=d.length||2!=f.length)Log("Toggle switch binding: parameters invalid");else{for(var e=0;2>e;e++)ko.applyBindingsToNode(d[e],{text:b.labels[e],value:b.values[e]}),ko.applyBindingsToNode(f[e],{text:b.labels[e]});ko.isObservable(b.value)?($(a).val(b.value()).change(),
$(a).change(function(){b.value($(a).val())}),b.value.subscribe(function(b){$(a).val()!=b&&$(a).val(b).change()})):$(a).val(b.value).change()}}};ko.bindingHandlers.readOnly={update:function(a,c){c()?a.setAttribute("readOnly",!0):a.removeAttribute("readOnly")}};ko.bindingHandlers.buttonText={update:function(a,c){var b=c();$("span.ui-btn-text",a).text(b)}};
ko.bindingHandlers.pageParameters={update:function(a,c){var b=c();$(a).bind("click",function(){PageParameters.clear();for(var a in b)PageParameters[a]=b[a]})}};ko.bindingHandlers.selectAll={init:function(a){$(a).bind("click",function(){a.setSelectionRange(0,9999)});$(a).bind("mouseup",function(a){a.preventDefault()})}};
ko.bindingHandlers.image={update:function(a,c){var b=c(),d="Images/"+document.getScreenDensity()+"/";$(a).error(function(){$(this).unbind("error").attr("src",d+b.error)}).attr("src",d+b.src)}};ko.bindingHandlers.urlImage={update:function(a,c){var b=c(),d="Images/"+document.getScreenDensity()+"/";""==b.src?(b.src=d+b.error,$(a).addClass("SmallImage")):$(a).removeClass("SmallImage");$(a).error(function(){$(this).unbind("error").attr("src",d+b.error);$(a).addClass("SmallImage")}).attr("src",b.src)}};
ko.bindingHandlers.listViewFilterText={update:function(a,c){var b=ko.utils.unwrapObservable(c());$(a).parent().find("form input").attr("placeholder",b)}};
ko.bindingHandlers.liPanel={init:function(a,c){$(a).click(function(){var b=c();ko.utils.unwrapObservable(b.enabled)&&($(a).parent().find("span.ui-icon-arrow-d").removeClass("ui-icon-arrow-d").addClass("ui-icon-arrow-r"),$(a).find("span.ui-icon").removeClass("ui-icon-arrow-r").addClass("ui-icon-arrow-d"),$(a).after($(b.tpl).removeClass("ui-screen-hidden").attr("data-filtertext",$(a).find("span").text())))})}};
ko.bindingHandlers.validation={update:function(a,c){var b=c();!0==b.Invalid?($(a).parent().addClass("Invalid"),$(a).parent().removeClass("NotInRange")):($(a).parent().removeClass("Invalid"),!0==b.NotInRange?$(a).parent().addClass("NotInRange"):$(a).parent().removeClass("NotInRange"));!0==b.Result?$(a).parent().addClass("Result"):$(a).parent().removeClass("Result");!0==b.disable?$(a).parent().addClass("disable"):$(a).parent().removeClass("disable")}};
ko.bindingHandlers.page={init:function(a,c){var b=c();$(a).click(function(){$.mobile.changePage(b)})}};
