function CustomCheckbox( form_input ) {
  this.toString = function() { return '[CustomCheckbox]'; }

  CustomCheckbox.CHECKED     = 1;
  CustomCheckbox.DISABLED    = 2;

  this.name = form_input.name;
  this.value = form_input.value;
  this.hidden_input = null;

  this.disable = function() {
    this.image.className = 'customCheckboxDisabled';
    this.image.status = CustomCheckbox.DISABLED;

    this.__removeHiddenInput();
  }
  this.check = function() {
    if ( this.image.status & CustomCheckbox.DISABLED )
      return ;

    this.image.className = 'customCheckboxChecked';
    this.image.status = CustomCheckbox.CHECKED;

    this.__insertHiddenInput();
  }
  this.uncheck = function() {
    if ( this.image.status & CustomCheckbox.DISABLED )
      return ;

    this.image.className = 'customCheckboxUnchecked';
    this.image.status = 0;

    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() {
    if ( !isNull( this.hidden_input ) )
      return ;
    this.hidden_input = CustomForm.createHidden( this.name, this.value );
    this.image.parentNode.insertBefore( this.hidden_input, this.image );
  }

  this.onImageClick = function( e ) {
    var eventTarget = DOMEvent.getTarget( e );
    DOMEvent.preventDefault( e );

    if ( eventTarget.status & CustomCheckbox.DISABLED )
      return ;

    if ( eventTarget.status & CustomCheckbox.CHECKED ) {
      this.uncheck();
    } else {
      this.check();
    }
  }

  this.image = document.createElement( 'img' );
  this.image.src = 'spacer.gif';

  form_input.parentNode.replaceChild( this.image, form_input );

  this.uncheck();
  if ( form_input.disabled )
    this.disable();
  else if ( form_input.checked )
    this.check();

  addListener( this.image, 'click', Delegate.create( this, 'onImageClick' ) );
}