			function MCComboItem_ToString()
			{
				var s = '[ ' + this.Label;
				if( this.SubItems != null )
				{
					s += ', ';
					for(var i=0 ; i<this.SubItems.length ; i++ )
					{
						s += this.SubItems[i];
					}
				}
				s += ']';
				return s;
				
			}
			
			function MCComboItem( label, value, description, subItems )
			{
				this.Label = label;
				this.Value = value;
				this.Description = description;
				this.SubItems = subItems;
				this.toString = MCComboItem_ToString;
			}

			function MCAddOption( combo, label, value, isSelected )
			{
				var oOption = document.createElement('OPTION');
				combo.appendChild( oOption );
				oOption.innerHTML = label;
				oOption.value = value;
				if( isSelected != null )
				{
					oOption.selected = true;
				}
			}

		
			function MCClearCombo( combo, fillWithEmptyOption )
			{
				var size = combo.options.length;
				for( var i=0 ; i<size ; i++ )
				{
					combo.removeChild( combo.options[0] );
				}

				if( fillWithEmptyOption && combo.getAttribute( 'MCEmptyOption' ) != null )
				{
					MCAddOption( combo, combo.getAttribute( 'MCEmptyOption' ) );
				}
				
			}
			function MCFillCombo( combo, data, initialValue )
			{
				var selectedIndex = -1;

				if( combo.getAttribute( 'MCDefaultOption' ) != null)
				{
					MCAddOption( combo, combo.getAttribute( 'MCDefaultOption' ) );
				}
				for(var i=0 ; i<data.length ; i++ )
				{
					var isSelected = ( initialValue == data[i].Value );
					MCAddOption( combo, data[i].Label, data[i].Value, isSelected );
					if( isSelected )
					{
						selectedIndex = i;
					}
				}
				if( selectedIndex == -1 )
				{
					combo.selectedIndex = 0;
				}
				else
				{
					if( initialValue != null ) combo.value = initialValue;
				}
				
				return selectedIndex;
			}
			
		
			
			
			function MCStart( baseComboId, varBaseData, actionFunction, initValues )
			{
				var baseCombo = document.getElementById( baseComboId );
				baseCombo.setAttribute( 'MCData', varBaseData );
				baseCombo.setAttribute( 'MCAction', actionFunction );

				var initialValue, combo;
				var i=0;
				var comboId = baseComboId;
				var data = eval( varBaseData );
				do
				{
					combo = document.getElementById( comboId );
					//Set the attributes on the combo
					if( combo.addEventListener != null )
						combo.addEventListener( 'change', MCChangeCombo, false);
					else
						combo.onchange = MCChangeCombo;
					combo.setAttribute( 'MCRefBaseId', baseCombo.id );
					
					//Clear the combo
					MCClearCombo( combo, false );

					//Fill the combo
					if( initValues != null )
					{
						initialValue = initValues[i];
					}
					var selectedIndex = MCFillCombo( combo, data, initialValue );

					//Prepare the variables for the sub combo
					if( selectedIndex != -1 )
					{
						MCShowDescription( combo, data[selectedIndex].Description );
						comboId = combo.getAttribute( 'MCSub' );
						i++;
						data = data[selectedIndex].SubItems;
					}
					else
					{
						data = null;
					}
					
				} while( data != null );
				
				var comboId = combo.getAttribute( 'MCSub' );
				while( comboId != null )
				{
					//Set the empty options on all sub combos
					var combo = document.getElementById( comboId );
					MCClearCombo( combo, true );
					comboId = combo.getAttribute( 'MCSub' );
					
					//Set the attributes on the combo
					if( combo.addEventListener != null )
						combo.addEventListener( 'change', MCChangeCombo, false);
					else
						combo.onchange = MCChangeCombo;
					combo.setAttribute( 'MCRefBaseId', baseCombo.id );

				}
			}
			
			//Returns -1 if the default option is selected
			function MCGetSelectedIndex( combo )
			{
				if( combo.getAttribute( 'MCDefaultOption' ) == null )
				{
					return combo.selectedIndex;
				}
				else
				{
					if( combo.selectedIndex == 0 ) return -1;
					return combo.selectedIndex - 1;
				}
			}
			
			function MCShowDescription( combo, desc )
			{
				var elem = document.getElementById( combo.getAttribute( 'MCDesc' ) );
				if( elem == null ) return;
				elem.innerHTML = desc == null ? '' : desc;
			}
			
			
			function MCEmptySubCombos( combo )
			{
				var comboId = combo.getAttribute( 'MCSub' );
				while( comboId != null )
				{
					combo = document.getElementById( comboId );
					MCClearCombo( combo, true );
					MCShowDescription( combo, null );
					comboId = combo.getAttribute( 'MCSub' );
				}
			}
			
			function MCChangeCombo( e )
			{
				var changedCombo;

				if( e == null )
				{
					changedCombo = window.event.srcElement;
				}
				else
				{
					changedCombo = e.target;
				}
				var baseCombo = document.getElementById( changedCombo.getAttribute( 'MCRefBaseId' ) );

				//Selected Default option, clear sub combos and the descriptions
				if( MCGetSelectedIndex( changedCombo ) == -1 )
				{
					MCShowDescription( changedCombo, null );
					MCEmptySubCombos( changedCombo );
					return;
				}

				//Find the data for the changed combo
				var data = eval( baseCombo.getAttribute( 'MCData' ) );
				var combo = baseCombo;
				while( combo != changedCombo )
				{
					var selectedIndex = MCGetSelectedIndex( combo );
					data = data[ selectedIndex ].SubItems;
					combo = document.getElementById( combo.getAttribute( 'MCSub' ) );
				}

				//Selected the default option				
				var selectedIndex = MCGetSelectedIndex( changedCombo );
				if( selectedIndex == -1 )
				{
					MCShowDescription( changedCombo, null );
					MCEmptySubCombos( combo );
					return;
				}
				
				//Show the description
				var description = data[ selectedIndex ].Description;
				MCShowDescription( changedCombo, description );

				//Process the sub combo
				if( changedCombo.getAttribute( 'MCSub' ) == null )
				{
					//Last combo, execute action
					eval( baseCombo.getAttribute( 'MCAction' ) + '( "' + changedCombo.value + '" );' );
				}
				else
				{
					combo = document.getElementById( changedCombo.getAttribute( 'MCSub' ) );
					data = data[ selectedIndex ].SubItems;

					//Fill the combo
					MCClearCombo( combo, false );
					MCFillCombo( combo, data, null );

					//Set the empty options on all sub combos
					MCEmptySubCombos( combo );
				}				
				
			}
