//Ext.override(Ext.form.RadioGroup, {
// 
//    afterRender: function() {
//        var group = this;
//        this.items.each(function(field) {
//            // Listen for 'check' event on each child item
//            field.on("check", function(self, checked) {
//             
//              // if checkbox is checked, then fire 'change' event on RadioGroup container
//              if(checked)
//                // Note, oldValue (third parameter in 'change' event listener) is not passed, 
//                // because is not easy to get it
//                group.fireEvent('change', group, self.getRawValue());
//               
//            });
//        });
//       
//        Ext.form.RadioGroup.superclass.afterRender.call(this)
//    }
//
//}); 



Ext.override(Ext.form.CheckboxGroup, {
  getNames: function() {
    var n = [];

    this.items.each(function(item) {
      if (item.getValue()) {
        n.push(item.getName());
      }
    });

    return n;
  },

  getValues: function() {
    var v = [];

    this.items.each(function(item) {
      if (item.getValue()) {
        v.push(item.getRawValue());
      }
    });

    return v;
  },

  setValues: function(v) {
    var r = new RegExp('(' + v.join('|') + ')');

    this.items.each(function(item) {
      item.setValue(r.test(item.getRawValue()));
    });
  }
});

Ext.override(Ext.form.RadioGroup, {
  getName: function() {
    return this.items.first().getName();
  },

  getValue: function() {
    var v;
	if(typeof this.items.each == "function")
	{
		this.items.each(function(item) {
		  v = item.getRawValue();
		  return !item.getValue();
		});	
	}else{
		return this.value;
	}


    return v;
  },

  setValue: function(v) {
    this.items.each(function(item) {
      item.setValue(item.getRawValue() == v);
    });
  }
});





Ext.override(Ext.form.ComboBox, {
  getName: function() {
    return this.items.first().getName();
  },

  getDataValue: function() {
    var v;
	var TextLable =	this.getValue();
	for(i=0; i<2; i++)
   {
		oItem	=	this.store.data.items[i]
		if(typeof oItem == "object")
		{
			if(oItem.data.lable==TextLable)
			{
				return oItem.data.value ;  
			}
   		}
	}
	return TextLable;
  }
});

Ext.apply(Ext.form.VTypes, {
    password : function(val, field) {
        if (field.initialPassField) {
            var pwd = Ext.getCmp(field.initialPassField);
            return (val == pwd.getValue());
        }
        return true;
    },
    passwordText : 'Passwords diferentes'
});





