// JavaScript Document
function selector(count) { };
selector.prototype = {
	selections: {},
	cnt: 0,
	setValue: function (cnt, value)
	{
		//document.getElementById('test2').innerHTML = "set " + value;	
		document.cookie = this.selections[cnt]['cookie'] + "=" + escape(value);
	},
	getValue: function (cnt) {
					name = this.selections[cnt]['cookie'];
			var dc = document.cookie;
  			var prefix = name + "=";
  			var begin = dc.indexOf("; " + prefix);
  			if (begin == -1) {
    			begin = dc.indexOf(prefix);
    		if (begin != 0) return null;
  			} else
   				begin += 2;
  			var end = document.cookie.indexOf(";", begin);
  			if (end == -1)
    			end = dc.length;
  			return unescape(dc.substring(begin + prefix.length, end));
	},
	addSelection: function (objName, cookie)
	{
		this.selections[this.cnt] = {};
		this.selections[this.cnt]['name'] = objName;
		this.selections[this.cnt]['cookie'] = cookie;
		if (this.getValue(this.cnt) != null) {
			if (this.getValue(this.cnt) == "true") {
				document.getElementById(objName).checked = true;
			}
			else
			{
				document.getElementById(objName).checked = false;
			}
		}
		//this.selections[this.cnt]['value'] = value;
		var cntm = this.cnt;
		var field = document.getElementById(objName)
		var sheild = this;
		field.onclick = function () { sheild.setValue(cntm, document.getElementById(objName).checked) }
		this.cnt++;
		return (this.cnt - 1);
	},
	selectionStatus: function (cnt) {

	}
}
