function CheckList(listID)
{
	//Properties
	this.options = new Array();
	this.id = listID;
	
	//Methods
	this.Clear = function()
	{
		this.options = new Array();
	}
	
	this.Update = function()
	{
		var fieldset = document.getElementById(this.id);
		var name = fieldset.getAttribute("name");
		
		var script = fieldset.getAttribute("OnCheckClick");
		
		var i;
		for (i = 0; i < this.options.length; i++)
		{
			var container = document.getElementById(this.id+"_option"+i);
			var checkbox = document.getElementById(this.id+"_option"+i+"check")
			var label = document.getElementById(this.id+"_option"+i+"label")
			if (container==null)
			{
				container = document.createElement("div");
				container.id = this.id+"_option"+i;
				fieldset.appendChild(container);
				
				checkbox = document.createElement("input");
				checkbox.type = "checkbox";
				checkbox.id = container.id+"check";
				checkbox.name = name;
				if (script!=null) eval ("checkbox.onclick=function(){"+script+"};");
				container.appendChild(checkbox);
				
				label = document.createElement("label");
				label.htmlFor = checkbox.id;
				label.id = container.id+"label";
				container.appendChild(label);
			}
			if (this.options[i].highlight) container.className="CheckListHighlight";
			else container.className="";
			checkbox.value = this.options[i].value;
			checkbox.checked = this.options[i].selected;
			label.innerHTML = this.options[i].text;
		}
		
		var removeOpt;
		while ((removeOpt = document.getElementById(this.id+"_option"+i))!=null)
		{
			fieldset.removeChild(removeOpt);
			i++;
		}
	}
	
	//Initilise
	this.cotr = function()
	{
		var fieldset = document.getElementById(this.id);
		for (var i = 0; i < fieldset.childNodes.length; i++)
			if (fieldset.childNodes[i].tagName && fieldset.childNodes[i].tagName.toUpperCase()=="DIV")
			{
				var forid = fieldset.childNodes[i].id;
				var checkbox = document.getElementById(forid+"check");
				var label = document.getElementById(forid+"label");
				
				var opt = new CheckListOption(label.innerHTML, checkbox.value);
				opt.selected = checkbox.checked;
				opt.sourceDiv = fieldset.childNodes[i];
				opt.sourceCheck = checkbox;
				opt.sourceLabel = label;
				
				this.options[this.options.length] = opt;
			}
	}
	this.cotr();
}

//Checklist option object
function CheckListOption(opttext, optvalue)
{
	this.value = typeof(optvalue)=="undefined"?opttext:optvalue;
	this.text = opttext;
	this.selected = false;
	this.sourceDiv = null;
	this.sourceLabel = null;
	this.sourceCheck = null;
	this.highlight = false;
}