ASPxClientCheckBox = _aspxCreateClass(ASPxClientEdit, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.stateInput = null;
  this.valueChecked = true;
  this.valueUnchecked = false;
  this.sizingConfig.allowSetWidth = false;
  this.sizingConfig.allowSetHeight = false;
  this.CheckedChanged = new ASPxClientEvent();
 },
 Initialize: function() {
  ASPxClientEdit.prototype.Initialize.call(this);
  this.previousChecked = this.GetInputElement().checked;
 },
 FindInputElement: function() {
  var element = this.GetMainElement();
  if(_aspxIsExistsElement(element) && element.tagName != "INPUT")
   element = this.GetChild("_I");
  return element;
 },
 GetStateInput: function() {
  if(!_aspxIsExistsElement(this.stateInput))
   this.stateInput = this.GetChild("_S");
  return this.stateInput;
 },
 RaiseValueChangedEvent: function() {
  var processOnServer = ASPxClientEdit.prototype.RaiseValueChangedEvent.call(this);
  processOnServer = this.RaiseCheckedChanged(processOnServer);
  return processOnServer;
 }, 
 OnClick: function() {
  var value = this.previousChecked ? this.valueUnchecked : this.valueChecked;  
  this.SetValue(value);
  this.OnValueChanged();
  this.SetInputElementFocusForWebKits(); 
 },  
 SetInputElementFocusForWebKits: function() {
  this.SetFocus();
 },  
 GetValue: function() {
  var value;
  switch(this.GetStateInput().value) {
   case "N":
    return null;
   case "C":
    value = this.valueChecked; break;
   case "U":
    value = this.valueUnchecked; break;       
  }
  if(value === "" && this.convertEmptyStringToNull)
   value = null;     
  return value;
 },  
 SetValue: function(value) {
  var stateInput = this.GetStateInput();  
  if(value == null)
   stateInput.value = "N";
  else
   stateInput.value = value == this.valueChecked ? "C" : "U";  
  this.GetInputElement().checked = this.previousChecked = value == this.valueChecked;
  this.OnValueSet();
 },
 OnValueSet: function() {
 },
 RaiseCheckedChanged: function(processOnServer) {
  if(!this.CheckedChanged.IsEmpty()) {
   var args = new ASPxClientProcessingModeEventArgs(processOnServer);
   this.CheckedChanged.FireEvent(this, args);
   processOnServer = args.processOnServer;
  }
  return processOnServer;
 },
 GetChecked: function() {
  return this.GetValue() == this.valueChecked;
 },
 SetChecked: function(isChecked) {
  this.SetValue(isChecked ? this.valueChecked : this.valueUnchecked);
 },
 GetText: function() {
  var labelElement = _aspxGetChildByTagName(this.GetMainElement(), "LABEL", 0);
  return (labelElement != null) ? labelElement.innerHTML : "";
 },
 SetText: function(text) {
  var labelElement = _aspxGetChildByTagName(this.GetMainElement(), "LABEL", 0);
  if(labelElement != null) 
   _aspxSetInnerHtml(labelElement, text);
 },
 ChangeEnabledAttributes: function(enabled){
  this.ChangeInputEnabledAttributes(this.GetInputElement(), _aspxChangeAttributesMethod(enabled));
  this.GetInputElement().disabled = !enabled;
 },
 ChangeEnabledStateItems: function(enabled){
  aspxGetStateController().SetElementEnabled(this.GetMainElement(), enabled);
 },
 ChangeInputEnabledAttributes: function(element, method){
  method(element, "onclick");
 }
});
ASPxClientCheckBox.Cast = ASPxClientControl.Cast;
ASPxClientRadioButton = _aspxCreateClass(ASPxClientCheckBox, {
 constructor: function(name) {
  this.constructor.prototype.constructor.call(this, name);
  this.isASPxClientRadioButton = true;
 },
 OnValueSet: function() {
  if(this.GetInputElement().checked)
   this.UncheckOtherGroupMemebers(true );
 },
 OnClick: function() {
  if(!this.previousChecked) {
   this.UncheckOtherGroupMemebers();
   ASPxClientCheckBox.prototype.OnClick.call(this);
  } else
   this.SetInputElementFocusForWebKits(); 
 },
 UncheckOtherGroupMemebers: function(suppressEvents) {
  var members = this.GetGroupMembers();
  for(var i = 0; i < members.length; i++) {
   var radioButton = members[i];
   if(radioButton != this && radioButton.GetValue()){
    radioButton.SetValue(false);
    if(!suppressEvents)
     radioButton.RaiseValueChangedEvent();
   }
  }
 },
 OnReadonlyClick: function() {
  if(!this.previousChecked) {   
   var members = this.GetGroupMembers();   
   for(var i = 0; i < members.length; i++) {
    var radioButton = members[i];
    radioButton.SetValue(radioButton.GetValue());
   }
  }
 }, 
 GetGroupName: function() {
  var inputElement = this.GetInputElement();
  if (!_aspxIsExistsElement(inputElement))
   return null;
  var name = inputElement.name;
  if(!name.length)
   name = "";
  return name;
 },
 GetGroupMembers: function() {
  var result = [ ];
  var groupName = this.GetGroupName();
  if(groupName.length > 0) {
   aspxGetControlCollection().ForEachControl(function(control) {
    if(ASPxIdent.IsASPxClientRadioButton(control)) {
     var controlGroupName = control.GetGroupName();
     if (controlGroupName != null && controlGroupName == groupName)
      result.push(control);
    }
   });
  } else {
   result.push(this);
  }
  return result;  
 },
 GetChecked: function() {
  return this.GetValue() == true;
 },
 SetChecked: function(isChecked) {
  this.SetValue(isChecked);
 }
});
ASPxClientRadioButton.Cast = ASPxClientControl.Cast;
ASPxIdent.IsASPxClientRadioButton = function(obj) {
 return _aspxIsExists(obj.isASPxClientRadioButton) && obj.isASPxClientRadioButton;
};
function aspxChkOnClick(name) {
 var edit = aspxGetControlCollection().Get(name);
 if(_aspxIsExists(edit))
  edit.OnClick();
}
function aspxERBOnReadonlyClick(name) {
 var rb = aspxGetControlCollection().Get(name);
 if(_aspxIsExists(rb))
  rb.OnReadonlyClick();
}
