function Category()
{
	var D;
	var D0;
	var D1;
	var D2;
	var D3;
	var D4;
	var D5;
	var D6;
	
	var P0 = '';						// Text
	var P1 = 0;							// Top
	var P2 = 0;							// Left
	var P3 = 100;						// Width
	var P4 = 100;						// Height
	var P5 = false;						// Selected
	var P6 = null;						// ItemContainer
	var P7 = null;						// Tag
	var P8 = null;						// Contents control





	var T0;
	var T1;
	var T2;
	var T3;
	var T4;
	var T5;
	
	var container;

	// Events
	var clickEvent;
	
	clickEvent = new Event('Click', null);
	
	this.Subscribe = function(type, fn, obj, override)
	{
		if (type == clickEvent.type)
		{
			clickEvent.subscribe(fn, obj, override);
		}
	}
	
	D = this;

	this.BackgroundColor = '#FFFFFF';
	
	this.SelectionBackgroundColor = '#EBEEFF';

	this.BorderColor = '#FFFFFF';
	//this.BorderColor = 'transparent';
	this.SelectionBorderColor = '#FFFFFF';

	this.Font = 'normal 8pt Verdana';

	this.GridLineColor = '#D4D4D4';

	this.PreferredRowHeight = 22;
	
	this.Rows = new Array();

	this.Parent = null;

	this.Initialize = function()
	{
		D0 = document.createElement('div');
		D0.style.position = 'relative';
		D0.style.left = P2;
		D0.style.top = P1;
		D0.style.width = P3;
		//D0.style.height = P4;
		//D0.style.backgroundColor = 'red';
		D0.style.overflow = 'hidden';
		D0.style.borderWidth = 1;
		D0.style.borderStyle = 'solid';
		D0.style.borderColor = D.BorderColor;
		D0.className = 'divElement';
		
			var r;
			var c0;
			var c1;
			var c2;

			T0 = document.createElement('table');
			T0.style.position = 'relative';
			//T0.style.height = '100%';
			T0.style.width = '100%';
			T0.cellSpacing = 0;
			T0.cellPadding = 0;

			// Caption row
			r = T0.insertRow(-1);
			c0 = r.insertCell(-1);
			c0.style.height = D.PreferredRowHeight;

				D3 = document.createElement('div');
				D3.style.position = 'relative';
				//D3.style.font = D.CaptionFont;
				D3.style.backgroundColor = D.BackgroundColor;
				//D3.style.color = D.CaptionForegroundColor;
				D3.style.width = '100%';
				D3.style.height = D.PreferredRowHeight;
				D3.style.overflow = 'hidden';
				D3.style.lineHeight = c0.style.height;
				D3.style.textAlign = 'center';
				
					var x;

					x = new Label();
					x.Color = '#999999';
					//x.Position = 'relative';
					x.Position = 'absolute';
					x.Top = 0;
					//x.Left = 1;
					x.Left = 18;
					x.Height = D.PreferredRowHeight;
					//x.Width = '100%';
					x.Width = P3 - 2 * 18;
					x.Parent = D3;
					x.Cursor = 'hand';
					x.Font = D.Font;
					x.SetProperty('Text', P0);
					x.Subscribe('Click', LabelClicked, x, true);
					x.Initialize();
				
				//D3.innerHTML = P0;
				
			c0.appendChild(D3);

		D0.appendChild(T0);

		D.Parent.appendChild(D0);
	}
	
	var LabelClicked = function(type, arguments, object)
	{
		//D.SetProperty('Selected', ! D.GetProperty('Selected'));

		clickEvent.fire();
	}
	
	this.ShowItemContainer = function()
	{
		var c;
		var r;
		var c1;
		var r1;
		
		if (T0.rows.length == 1)
		{
			r = T0.insertRow(-1);
			c = r.insertCell(-1);

				T1 = document.createElement('table');
				T1.style.position = 'relative';
				T1.style.width = '100%';
				T1.style.height = '100%';
				T1.cellSpacing = 0;
				T1.cellPadding = 0;

				r1 = T1.insertRow(-1);
				
				c1 = r1.insertCell(-1);
				
				P6 = c1;
				
				P8 = null;

			c.appendChild(T1);
		}
	}
	
	this.HideItemContainer = function()
	{
		var c;
		var r;
		var c1;
		var r1;
		
		if (T0.rows.length > 1)
		{
			T0.deleteRow(1);
			
			P6 = null;
			
			P8 = null;
		}
	}

	this.GetProperty = function(property)
	{
		if (property == 'Text')
		{
			return P0;
		}
		else if (property == 'Selected')
		{
			return P5;
		}
		else if (property == 'ItemContainer')
		{
			return P6;
		}
		else if (property == 'Tag')
		{
			return P7;
		}
		else if (property == 'Contents')
		{
			return P8;
		}
		else
		{
			return null;
		}
	}

	this.SetProperty = function(property, value)
	{
		if (property == 'Text')
		{
			P0 = value;
			
			if (D3)
			{
				D3.innerHTML = P0;
			}
		}
		else if (property == 'Top')
		{
			P1 = value;
			
			if (D0)
			{
				D0.style.top = P1;
			}
		}
		else if (property == 'Left')
		{
			P2 = value;
			
			if (D0)
			{
				D0.style.left = P2;
			}
		}
		else if (property == 'Width')
		{
			P3 = value;
			
			if (D0)
			{
				D0.style.width = P3;
			}
		}
		else if (property == 'Height')
		{
			P4 = value;
			
			if (D0)
			{
				D0.style.height = P4;
			}
		}
		else if (property == 'Selected')
		{
			P5 = value;

			if (D0)
			{
				if (P5)
				{
					D3.style.backgroundColor = D.SelectionBackgroundColor;
					
					//ShowItemContainer();
				}
				else
				{
					D3.style.backgroundColor = D.BackgroundColor;
					
					//HideItemContainer();
				}
			}
		}
		else if (property == 'Tag')
		{
			P7 = value;
		}
		else if (property == 'Contents')
		{
			P8 = value;
		}
	}
}
