var m_vCheckbox = new Array();


function Checkbox(sFormName, sName, sUncheckedImage, sCheckedImage, bStartValue, doDisable, bValue) {
	this.sFormName = sFormName;
	this.sName = sName;
	this.sUncheckedImage	= "icons.unchecked.gif";
	this.sCheckedImage		= "icons.checked.gif";
	this.sDisabledImageA	= "icons.disabled.unchecked.gif";
	this.sDisabledImageB	= "icons.disabled.checked.gif";
	this.checked			= false;
	this.bValue				= bValue;
	this.disabled = (doDisable==true);
	if (bStartValue != "false")
		this.check(bStartValue);
	else
		this.uncheck();

	m_vCheckbox[m_vCheckbox.length] = this;
}
function toggleAll() {
	if(m_vCheckbox[0].checked) {
		for(var i = 1; i<m_vCheckbox.length; i++) {
			m_vCheckbox[i].check();
		}
	} else {
		for(var i = 1; i<m_vCheckbox.length; i++) {
			m_vCheckbox[i].uncheck();
		}
	}
}
Checkbox.prototype.disable = function() {
	this.disabled=true;
	if(this.checked) {
		document.images[this.sName + "Image"].src = this.sDisabledImageB;
	} else {
		document.images[this.sName + "Image"].src = this.sDisabledImageA;
	}
}
Checkbox.prototype.enable = function() {
	this.disabled=false;
	if(this.checked) {
		document.images[this.sName + "Image"].src = this.sCheckedImage;
	} else {
		document.images[this.sName + "Image"].src = this.sUncheckedImage;
	}
}
Checkbox.prototype.check = function() {
	if(this.disabled) {
		document.images[this.sName + "Image"].src = this.sDisabledImageB;
	} else {
		document.images[this.sName + "Image"].src = this.sCheckedImage;
	}
	eval("document.forms['" + this.sFormName + "']['" + this.sName + "Value'].value = '" + this.bValue + "';");
	this.checked = true;
}
Checkbox.prototype.toggleValue = function() {
	if(this.disabled) {
		return false;
	}
	if(this.checked)
		this.uncheck();
	else
		this.check();
	return true;
}
Checkbox.prototype.uncheck = function() {
	if(this.disabled) {
		document.images[this.sName + "Image"].src = this.sDisabledImageA;
	} else {
		document.images[this.sName + "Image"].src = this.sUncheckedImage;
	}
	eval("document.forms['" + this.sFormName + "']['" + this.sName + "Value'].value = '0';");
	this.checked = false;
}
