ko.components.register('ko-radio', {
    viewModel: function (params) {
        var self = this;
        self.list = params.list;
        self.className = params.className;
        self.name = params.name;
        self.inputValue = params.val;
        self.value = ko.observable();
        self.value.subscribe(function (newValue) {
            if (!_h.isNullOrEmpty(newValue)) {
                var item = _h.getEnumItemByText(params.list, newValue);
                if (item.value !== self.inputValue())
                    self.inputValue(item.value);
            }
        })
        self.init = function (model) {
            var item = _h.getEnumItem(model.list, model.val());
            if (item)
                self.value(item.enText);
        }        
        self.onClick = function (item) {
            self.value(item.enText);
        }
        self.init(params);
    },
    template: ' <!-- ko foreach: list -->  \n' +
        '            <div data-bind="attr: {\'class\': $parent.className }">\n' +
        '                <input type="radio" data-bind="checked: $parent.value, attr:{value: enText, name: $parent.name}">\n' +
        '                <label data-bind="click: $parent.onClick, text: text"></label>\n' +
        '            </div>\n' +
        '            <!-- /ko -->'

});