function CGroupedChecklistBoxes(id){
	try{
		
		
		var borderStyle = '0px solid Red';
		
		this.HEIGHT = 0;
		this.CONTAINER = document.getElementById(id);
		this.CONTAINER.style.border = borderStyle;
		
		/**
		 * If checkbox is nested inside a tabbed form then initially hide it
		 */
		var p = this.CONTAINER.parentNode;
		while(p.parentNode!=null)
		{
			if(p.className=='tabbedForm')
			{
				this.CONTAINER.style.display = 'none';
				break;
			}
			p = p.parentNode;
		}
		
		this.CONTAINER.style.width = '550px';
		this.CONTAINER.GROUPEDCHECKLISTBOX = this;
		this.FIELDSETS = new Array();	

		
		var html = this.CONTAINER.innerHTML;
		this.CONTAINER.innerHTML = '';
		

		var div1 = document.createElement('DIV');
		div1.className = 'menu';		
		this.CONTAINER.appendChild(div1);
		
		
		var div2 = document.createElement('DIV');
		div2.className = 'list';
		div2.innerHTML = html; 


		var ul = document.createElement('UL');
		div1.appendChild(ul);


		
		/**
		 * Create the Menu
		 */
		var legends = div2.getElementsByTagName('LEGEND');
		for(var i=0;i<legends.length;i++)
		{
			var li = document.createElement('LI');

			/**
			 * Create the menu list item with onmouseover event showing the 
			 * relevant page (fieldset)
			 */
			legends[i].style.display = 'none';
			li.PARENTOBJECT = this;	
			li.FIELDSET = legends[i].parentNode;
			li.FIELDSET.LI = li;
			this.FIELDSETS.push(li.FIELDSET);		
			li.FIELDSET.style.position = 'absolute';
			li.FIELDSET.style.visibility = 'hidden';

			li.appendChild(document.createTextNode(legends[i].innerHTML));
			ul.appendChild(li);
			li.onmouseover = function()
			{
				for(var i=0;i<this.PARENTOBJECT.FIELDSETS.length;i++)
				{
					this.PARENTOBJECT.FIELDSETS[i].style.visibility ='hidden';
					this.PARENTOBJECT.FIELDSETS[i].LI.className = '';
				}
				this.FIELDSET.getElementsByTagName('DIV')[0].style.height = (li.FIELDSET.parentNode.offsetHeight-50)+'px';
				this.FIELDSET.style.visibility = 'visible';
				
				
				var ieAdjustLeft = 3;
				var ieAdjustTop = 1;
				var ieAdjustHeight = 0;
				if(document.all)
				{
					ieAdjustLeft = 3;
					ieAdjustTop = 0;
					ieAdjustHeight = 0;
					this.FIELDSET.style.width = '385px';//(this.FIELDSET.parentNode.offsetWidth-30)+'px';
				}
				this.PARENTOBJECT.MASK.style.display = 'block';
				this.PARENTOBJECT.MASK.style.left = (this.offsetWidth+getAbsoluteLeft(this)-5+ieAdjustLeft)+'px';
				this.PARENTOBJECT.MASK.style.top = (getAbsoluteTop(this)+1+ieAdjustTop)+'px';
				this.PARENTOBJECT.MASK.style.height = (this.offsetHeight-3+ieAdjustHeight)+'px';
				
				this.className = 'hover';
			}
			if(i==0)
			{
				var firstLI = li;
			}
		}

		this.CONTAINER.appendChild(div2);

		/**
		 * Cycle through the cells containing checkboxes and assign events to 
		 * mouse actions
		 */
		var tds = div2.getElementsByTagName('TD');
		for(var i=0;i<tds.length;i++)
		{
			tds[i].INPUT = tds[i].getElementsByTagName('INPUT')[0];
			tds[i].INPUT.style.display = 'none';
			tds[i].style.cursor = 'pointer';
			tds[i].onmouseover = function(){
				if(this.START_CLASS==null)
				{
					this.START_CLASS = this.className;
					this.CURRENT_CLASS = this.className;
				}
				this.className = this.CURRENT_CLASS+'_over';
			}
			tds[i].onmouseout = function(){
				if(!this.INPUT.checked){
					this.className = this.CLASS_NAME;
				}
			}
			tds[i].onclick = function(){
				if(this.INPUT.checked){
					this.INPUT.checked=false;
					this.className = this.START_CLASS;
					this.CURRENT_CLASS = this.className;
				}
				else{
					this.INPUT.checked=true;
					this.className = 'selected';
					this.CURRENT_CLASS = this.className;
				}
			}
		}
		
		/**
		 * Create a small masking div to hide the border between
		 * the menu item and the checkbox panel
		 */		
		this.MASK = document.createElement('DIV');
		this.MASK.style.backgroundColor = 'White';
		this.MASK.style.border = '0px solid red';
		this.MASK.style.display = 'none';
		this.MASK.style.height = '5px';
		this.MASK.style.width = '5px';
		this.MASK.style.position = 'absolute';
		
		document.body.appendChild(this.MASK);
		

		var startDisplay = this.CONTAINER.style.display;
		if(startDisplay=='none')
		{
			this.CONTAINER.style.display = 'block';
		}
		
		if(document.all)
		{
			this.HEIGHT = 310;
		}
		else
		{
			this.HEIGHT = ul.offsetHeight;
		}
		
		
		this.CONTAINER.style.height = (this.HEIGHT+50)+'px';
		div2.style.height = (this.HEIGHT+70)+'px';
		
		if(document.all)
		{
			div2.style.marginLeft = '-1px';
			div2.style.position = 'absolute';
			this.CONTAINER.style.width = '560px';
		}
		
		
		firstLI.onmouseover();
		
		this.CONTAINER.style.display = startDisplay;
		
	}catch(e){
		alert(e);
	}
}