function CustomRadioGroup( groupName ) {
  this.toString = function() { return '[CustomRadioGroup]'; }

  this.name = groupName;
  this.items = new Array();
  this.hidden_input = null;

  this.append = function( customRadio ) {
    customRadio.registerListener( 'checked', this );
    this.items.push( customRadio );
  }

  this.handleEvent = function( eventType, eventSource ) {
    if ( eventType == 'checked' ) {
      var n_checked = 0;
      for( var i=0; i<this.items.length; i++ ) {
        if ( this.items[ i ] != eventSource ) {
          this.items[ i ].uncheck();
        } else {
          this.insertHiddenInput( eventSource.image, eventSource.value );
          eventSource.removeListener( this );
          n_checked++;
        }
      }

      if ( 0 == n_checked )
        this.removeHiddenInput();
    }
  }

  this.removeHiddenInput = function() {
    if ( isNull( this.hidden_input ) )
      return ;
    this.hidden_input.parentNode.removeChild( this.hidden_input );
    this.hidden_input = null;
  }

  this.insertHiddenInput = function( domNode, hiddenValue ) {
    if ( isNull( this.hidden_input ) ) {
      this.hidden_input = CustomForm.createHidden( this.name, hiddenValue );
      domNode.parentNode.insertBefore( this.hidden_input, domNode );
    } else {
      this.hidden_input.value = hiddenValue;
    }
  }
}
CustomRadioGroup.instances = new Array();

CustomRadioGroup.getInstance = function( groupName ) {
  var rv = null;
  for( var i=0; i<CustomRadioGroup.instances.length; i++ )
    if ( CustomRadioGroup.instances[ i ].name == groupName ) {
      rv = CustomRadioGroup.instances[ i ];
      break;
    }
  if ( isNull( rv ) ) {
    rv = new CustomRadioGroup( groupName );
    CustomRadioGroup.instances.push( rv );
  }
  return rv;
}