Formidable.Classes.CheckBox = Formidable.Classes.RdtBaseClass.extend({
	isParentObj: function() {
		return this.config.bParentObj == true;
	},
	getParentObj: function() {
		if(!this.isParentObj()) {
			return this.oForm.o(this.config.parentid);
		} else {
			return this;
		}
	},
	checkAll: function() {
		var oParent = this.getParentObj();
		for(var k in oParent.config.checkboxes) {
			this.oForm.o(oParent.config.checkboxes[k]).domNode().checked = true;
		}
	},
	checkNone: function() {
		var oParent = this.getParentObj();
		for(var k in oParent.config.checkboxes) {
			this.oForm.o(oParent.config.checkboxes[k]).domNode().checked = false;
		}
	},
	checkItem: function(sValue) {
		if(this.isParentObj()) {
			for(var k in this.config.checkboxes) {
				var oItem = this.oForm.o(this.config.checkboxes[k]);
				if(oItem.domNode().value == sValue) {
					oItem.domNode().checked = true;
					break;
				}
			}
		}
	},
	unCheckItem: function(sValue) {
		if(this.isParentObj()) {
			for(var k in this.config.checkboxes) {
				var oItem = this.oForm.o(this.config.checkboxes[k]);
				if(oItem.domNode().value == sValue) {
					oItem.domNode().checked = false;
					break;
				}
			}
		}
	},
	getValue: function() {
		if(this.isParentObj()) {

			var aValues = [];

			console.log(this.config.checkboxes);
			for(var k in this.config.checkboxes) {
				//console.log("parent:value:" + this.oForm.o(this.config.checkboxes[k]).getValue());
				sValue = this.oForm.o(this.config.checkboxes[k]).getValue();
				if(sValue != null) {
					aValues[aValues.length] = sValue;
				}
			}
			return aValues;
		} else {
			return $F(this.domNode());
		}
	},
	getMajixThrowerIdentity: function(sObjectId) {
		var oParent = this.getParentObj();

		for(var k in oParent.config.checkboxes) {
			var oItem = this.oForm.o(oParent.config.checkboxes[k]);
			if(oItem.domNode().id == sObjectId) {
				return oItem.domNode().value;
				break;
			}
		}
	}
});