function HTMLCheckbox(sys, formID, code, posX, posY, width, height, description, value, valueCheck, valueUnCheck) {
  this.create(sys, formID, code, posX, posY, width, height, description, '');
  this.style = 1;
  this.nodesc = false;
  this.tabable = true;
  this.value = value;
  this.valueCheck = valueCheck;
  this.valueUnCheck = valueUnCheck;
  this.inputname = 'WFRInput'+this.code;
}

HTMLCheckbox.inherits(HTMLElementBase);

HTMLCheckbox.prototype.name = 'HTMLCheckBox';
HTMLCheckbox.prototype.tabable = true;
HTMLCheckbox.prototype.zindex = 1;

HTMLCheckbox.prototype.setWidth = function(width) {
  width = parseInt(width);
  this.width = width;
  this.div.style.width = width;
  this.table.style.width = width;
}

HTMLCheckbox.prototype.setHeight = function(height) {
  height = parseInt(height);
  this.height = height;
  this.div.style.height = height;
  this.table.style.height = height;
}

HTMLCheckbox.prototype.setDescription = function(description) {
  this.description = description;
  if (this.label) this.label.innerHTML = description.replace(/\s/g, '&nbsp;');
}

HTMLCheckbox.prototype.setColor = function(color) {
  this.color= color;
  if (this.label) this.label.style.color = color;
}

HTMLCheckbox.prototype.setBGColor = function(color) {
  this.bgColor= color;
  if (this.content) this.content.style.backgroundColor = color;
  if (this.label) this.label.style.backgroundColor = color;
}

HTMLCheckbox.prototype.setFont = function(f) {
  this.font = f;
  if (this.label) this.label.style.fontFamily = f;
}

HTMLCheckbox.prototype.setSize = function(s) {
  this.size = s;
  if (this.label) this.label.style.fontSize = s;
}

HTMLCheckbox.prototype.setEnabled = function(v) {
  this.enabled = v;
  this.updateImage();
}

HTMLCheckbox.prototype.setReadOnly = function(v) {
  this.readonly = v;
  this.updateImage();
}

HTMLCheckbox.prototype.getValue = function() {
  return this.hidden.getValue();
}

HTMLCheckbox.prototype.updateImage = function() {
  var activation = '';
  if (!this.enabled)
    activation = '_des';

  if (this.valueCheck == this.value) {
    this.img.src = skin+'check'+activation+'.gif';
    this.status = 1;
  } else if (this.valueUnCheck == this.value) {
    this.img.src = skin+'uncheck'+activation+'.gif';
    this.status = 0;
  } else {
    this.img.src = skin+'unknowcheck'+activation+'.gif';
    this.status = 2;
  }

  if (this.readonly || !this.enabled) {
    this.onkeydown = null;
    this.removeEvent(this.input, 'click');
    this.removeEvent(this.labelCell, 'click');
    this.labelCell.style.cursor = '';
  } else {
    this.attachEvent(this.input, 'click', this.click);
    this.attachEvent(this.labelCell, 'click', this.click);
    this.onkeydown = this.keyPressedAction;
    this.labelCell.style.cursor = 'pointer';
  }

  if (!this.enabled) {
    this.label.style.color = '#999999';
  } else {
    if (this.color)
      this.label.style.color = this.color;
    else
      this.label.style.color = '';
  }
}

HTMLCheckbox.prototype.designComponent = function(doc) {
  preload(skin+'check.gif');
  preload(skin+'check_des.gif');
  preload(skin+'uncheck.gif');
  preload(skin+'uncheck_des.gif');
  preload(skin+'unknowcheck.gif');
  preload(skin+'unknowcheck_des.gif');

  // Criação dos objetos
  this.hidden = new HTMLHidden(this.sys, this.formID, this.code, this.value);
  this.hidden.inputname = this.inputname;
  this.hidden.design(doc);

  this.input = document.createElement("a");
  this.input.href = 'javascript:;';

  this.img = document.createElement("img");
  this.img.border = '0';

  this.input.appendChild(this.img);

  this.label = getLabel(this.description);

  // Cria a tabela
  this.table = document.createElement("table");
  this.table.onmousedown = function() { return false; };
  this.table.onselectstart = function() { return false; };
  this.table.style.cursor = 'pointer';

  var tbody = document.createElement("tbody");

  this.table.setAttribute('border', 0);
  this.table.setAttribute('cellSpacing', 0);
  this.table.setAttribute('cellPadding', 0);
  this.table.setAttribute('height', '100%');

  // Cria a linha e suas colunas
  var row = document.createElement("tr");

  var col1 = document.createElement("td");
  col1.appendChild(this.input);
  col1.setAttribute('align', 'center');
  col1.setAttribute('valign', 'middle');
  row.appendChild(col1);

  var col2 = document.createElement("td");
  col2.style.width = "3";
  row.appendChild(col2);

  var col3 = document.createElement("td");
  col3.style.cursor = 'pointer';
  this.labelCell = col3;
  col3.onmousedown = function() { return false; };
  col3.onselectstart = function() { return false; };

  col3.appendChild(this.label);
  row.appendChild(col3);

  // Vincula a linha à tabela
  tbody.appendChild(row);
  this.table.appendChild(tbody);

  // Vincula a tabela ao documento
  this.context.appendChild(this.table);
}

HTMLCheckbox.prototype.afterInit = function() {
this.updateImage();
}

HTMLCheckbox.prototype.keyPressedAction = function(evt) {
  var key = getKey(evt);
  var r = true;
  if (key == 32) {
    this.click();
    r = false;
  }
    
  
  if (!r) {
    if (evt.preventDefault) {
      evt.preventDefault();
      evt.stopPropagation();
    } else {
      evt.keyCode = 0;
      evt.returnValue = false;
    }
    return false;
  } else
    return true;  
    
}

HTMLCheckbox.prototype.getChecked = function(e) {
  return this.status == 1;
}

HTMLCheckbox.prototype.click = function(e) {
  this.input.focus();
  var checked = (this.valueCheck == this.value);
  if (checked)
    this.setValue(this.valueUnCheck);
  else
    this.setValue(this.valueCheck);
  this.clickAction(e);
}

HTMLCheckbox.prototype.setValue = function(value) {
	value = normalizeRuleParam(value);
  var temp = this.value;

  this.value = value;
  this.hidden.setValue(this.value);
  this.updateImage();

  if (temp != value)
    this.changeAction(window.event);
}

HTMLCheckbox.prototype.setHint = function(hint) {
	this.callMethod(HTMLElementBase, "setHint", [hint]);
	
	if (this.table) {
	  this.table.hint = hint;
    this.table.alt = hint;
    this.table.title = hint;
	}
}

HTMLCheckbox.prototype.flush = function() {
  if (this.label) {
    if (this.label.onmousedown) this.label.onmousedown = null;
    if (this.label.onselectstart) this.label.onselectstart = null;
    this.label = null;
  }
  if (this.labelCell) {
    if (this.labelCell.onmousedown) this.labelCell.onmousedown = null;
    if (this.labelCell.onselectstart) this.labelCell.onselectstart = null;
    this.labelCell = null;
  }
  this.img = null;
  this.hidden = null;
  this.table = null;
	this.callMethod(HTMLElementBase, "flush");
}