(function(){function h(a){var b=[];for(a=a.firstChild;a;a=a.nextSibling)a.$instanceof(zul.wgt.Radio)?b.push(a):a.$instanceof(zul.wgt.Radiogroup)||(b=b.concat(h(a)));return b}function k(a,b,c){for(a=a.firstChild;a;a=a.nextSibling)if(a.$instanceof(zul.wgt.Radio)){if(b.value++==c)return a}else if(!a.$instanceof(zul.wgt.Radiogroup)){var d=k(a,b,c);if(null!=d)return d}}function l(a,b){for(a=a.firstChild;a;a=a.nextSibling)if(a.$instanceof(zul.wgt.Radio)){if(a.isSelected())return b.value;++b.value}else if(!a.$instanceof(zul.wgt.Radiogroup)){var c=
l(a,b);if(0<=c)return c}return-1}function f(a,b){for(b=b.parent;null!=b;b=b.parent)if(b.$instanceof(zul.wgt.Radiogroup))return b==a}zul.wgt.Radiogroup=zk.$extends(zul.Widget,{_orient:"horizontal",_jsel:-1,$init:function(){this.$supers("$init",arguments);this._externs=[]},$define:{orient:function(){this.rerender()},name:function(a){for(var b=this.getItems(),c=b.length;c--;)b[c].setName(a)}},getItemAtIndex:function(a){if(0<=a)a:{var b={value:0},c=k(this,b,a);if(!c)for(var d=this._externs,e=0,g=d.length;e<
g;++e)if(!f(this,d[e])&&b.value++==a){a=d[e];break a}a=c}else a=null;return a},getItemCount:function(){return this.getItems().length},getItems:function(){var a=h(this);a.$addAll(this._externs);return a},getSelectedIndex:function(){return this._jsel},setSelectedIndex:function(a){0>a&&(a=-1);this._jsel!=a&&(0>a?getSelectedItem().setSelected(!1):getItemAtIndex(a).setSelected(!0))},getSelectedItem:function(){return 0<=this._jsel?this.getItemAtIndex(this._jsel):null},setSelectedItem:function(a){null==
a?this.setSelectedIndex(-1):a.$instanceof(zul.wgt.Radio)&&a.setSelected(!0)},appendItem:function(a,b){var c=new zul.wgt.Radio;c.setLabel(a);c.setValue(b);this.appendChild(c);return c},removeItemAt:function(a){if((a=this.getItemAtIndex(a))&&!this._rmExtern(a)){var b=a.parent;b&&b.removeChild(a)}return a},_fixSelectedIndex:function(){a:{var a={value:0};var b=l(this,a);if(0>b)for(var c=this._externs,d=0,e=c.length,g;d<e;++d)if(!f(this,g=c[d])){if(g.isSelected()){a=a.value;break a}++a.value}a=b}this._jsel=
a},_fixOnAdd:function(a){0<=this._jsel&&a.isSelected()?a.setSelected(!1):this._fixSelectedIndex()},_fixOnRemove:function(a){a.isSelected()?this._jsel=-1:0<this._jsel&&this._fixSelectedIndex()},_addExtern:function(a){this._externs.push(a);f(this,a)||this._fixOnAdd(a)},_rmExtern:function(a){if(this._externs.$remove(a))return f(this,a)||this._fixOnRemove(a),!0}})})();
