function CTabbedForm(id){
	try{
		
		var maxHeight = 0;
		
		var borderStyle = '0px solid Red';
		
		this.HEIGHT = 0;
		this.WIDTH = 750;
		this.CONTAINER = document.getElementById(id);
		this.CONTAINER.style.border = borderStyle;
		this.CONTAINER.style.display = 'block';
		this.CONTAINER.style.width = this.WIDTH+'px';
		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 = new Array();
		var childNodes = div2.getElementsByTagName('FORM')[0].childNodes;
		for(var i in childNodes)
		{
			try{
				//alert(childNodes[i].nodeName);
				if(childNodes[i].nodeName.toLowerCase()=='fieldset')
				{					
					legends.push(childNodes[i].getElementsByTagName('LEGEND')[0]);
				}
			}catch(e){
				
			}
		}
		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 = '';
					
					//HACK!!Show any tabbedCheckboxLists
					var divs = this.PARENTOBJECT.FIELDSETS[i].getElementsByTagName('DIV');
					for(var j in divs)
					{
						if(divs[j].className=='groupedCheckboxes')
						{
							divs[j].style.display = 'none';
							try{
								divs[j].GROUPEDCHECKLISTBOX.MASK.style.display = 'none';
							}catch(e){
								
							}
						}
					}
				}
				try{
					this.FIELDSET.getElementsByTagName('DIV')[0].style.height = (li.FIELDSET.parentNode.offsetHeight-50)+'px';
				}catch(e){}
				this.FIELDSET.style.visibility = 'visible';
				//HACK!!Show any tabbedCheckboxLists
				var divs = this.FIELDSET.getElementsByTagName('DIV');
				for(var i in divs)
				{
					if(divs[i].className=='groupedCheckboxes')
					{
						divs[i].style.display = 'block';
						divs[i].GROUPEDCHECKLISTBOX.MASK.style.display = 'block';
					}
				}
				
				if(this.FIELDSET.offsetHeight>this.PARENTOBJECT.HEIGHT)
				{
					this.PARENTOBJECT.CONTAINER.style.height = this.FIELDSET.offsetHeight+'px';
				}
				else
				{
					this.PARENTOBJECT.CONTAINER.style.height = this.PARENTOBJECT.HEIGHT+'px';
				}
				
				var ieAdjustLeft = 0;
				var ieAdjustTop = 0;
				var ieAdjustHeight = 0;
				if(document.all)
				{
					ieAdjustLeft = 3;
					ieAdjustTop = 0;
					ieAdjustHeight = 0;
					this.FIELDSET.style.width = (this.FIELDSET.parentNode.offsetWidth-30)+'px';
				}
				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);
		
		/**
		 * 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.height = '5px';
		this.MASK.style.width = '5px';
		this.MASK.style.position = 'absolute';
		document.body.appendChild(this.MASK);
		

		if(document.all)
		{
			this.HEIGHT = 310;
		}
		else
		{
			this.HEIGHT = ul.offsetHeight;
		}
		
		
		/**
		 * Recalibrate ground level
		 */
		/*
		for(var i in this.FIELDSETS)
		{
			if(this.FIELDSETS[i].offsetWidth+div1.offsetWidth>this.CONTAINER.offsetWidth)
			{
				this.WIDTH = this.FIELDSETS[i].offsetWidth+div1.offsetWidth;
				this.CONTAINER.style.width = this.WIDTH+200+'px'; 
			}
		}
		*/
		for(var i in this.FIELDSETS)
		{
			this.FIELDSETS[i].style.width = this.WIDTH - div1.offsetWidth-30+'px';
		}
		
		this.CONTAINER.style.height = (this.HEIGHT+50)+'px';
		div2.style.height = (this.HEIGHT+70)+'px';
		
		this.CONTAINER.style.width = this.WIDTH+'px';
		
		if(document.all)
		{
			div2.style.marginLeft = '-1px';
			div2.style.position = 'absolute';
		}
		
		
		firstLI.onmouseover();
		
		var submit = document.createElement('INPUT');
		submit.name = this.CONTAINER.getElementsByTagName('FORM')[0].name+'_submit';
		submit.type = 'submit';
		submit.className = 'submit';
		submit.style.marginLeft = div1.offsetWidth+div2.offsetWidth-320+'px';
		
		submit.style.marginTop = '-50px';
		submit.style.position = 'absolute';
		submit.value = 'Save Changes';
		this.CONTAINER.getElementsByTagName('FORM')[0].insertBefore(submit,this.CONTAINER.getElementsByTagName('FORM')[0].firstChild);
	}catch(e){
		//alert(e);
	}
}