function CompactInput( nodeId, caption, noSelectionText )
{
	this.caption = caption;
	this.noSelectionText = noSelectionText;

	this.close = function close()
	{
		this.inputsNode.style.display = "none";
	}
	
	this.open = function open()
	{
		this.inputsNode.style.display = "block";
	}
	
	this.toggle = function toggle()
	{
		if( this.inputsNode.style.display != "none" )
		{
			this.setToggleButtonCaption( "Vælg" );
		
			this.inputsNode.style.display = "none";
		}
		else
		{
			this.setToggleButtonCaption( "Luk" );
			
			this.inputsNode.style.display = "block";
		}
	}
	
	this.reset = function reset()
	{
		var inputs = this.inputsNode.getElementsByTagName( "input" );
				
		for( var i = 0 ; i < inputs.length ; i++ )
		{
			if( inputs[i].getAttribute( "type" ) == "checkbox" )
			{
				inputs[i].checked = false;
			}
		}
		
		this.updateSelectedValues();
	}
	
	this.updateSelectedValues = function updateSelectedValues()
	{
		var inputs = this.inputsNode.getElementsByTagName( "input" );
		var labels = this.inputsNode.getElementsByTagName( "label" );
		
		this.selectedValues = new Array();
		
		for( var i = 0 ; i < inputs.length ; i++ )
		{
			if( inputs[i].getAttribute( "type" ) == "checkbox" )
			{
				if( !this.inputActionsAdded )
				{
					// Changed 2008-03-08
					//appendNodeAttribute( inputs[i], "onchange", this.id + ".updateSelectedValues();" );
					inputs[i].setAttribute( "onclick", this.id + ".updateSelectedValues();" );

					// For IE
					eval( "inputs[i].onclick = function() { " + this.id + ".updateSelectedValues(); }" );
				}

				if( inputs[i].checked )
				{
					var id = inputs[i].getAttribute( "id" );
				
					if( id )
					{
						for( var l = 0 ; l < labels.length ; l++ )
						{
							var forNode;
						
							if( forNode = labels[l].getAttributeNode( "for" ) )
							{
								if( forNode.value == id )
								{
									this.selectedValues.push( labels[l].firstChild.data );
								}
							}
						}
					}
				}
			}
		}

		this.inputActionsAdded = true;
		
		while( this.selectionStringNode.childNodes.length > 0 )
		{
			this.selectionStringNode.removeChild( this.selectionStringNode.lastChild );
		}
		
		if( this.selectedValues.length > 0 )
		{
			this.selectionStringNode.setAttribute( classAttributeName, "selectedValuesLabel" );
			this.selectionStringNode.appendChild( document.createTextNode( this.selectedValues.join( ", " ) ) );
		}
		else
		{
			this.selectionStringNode.setAttribute( classAttributeName, "selectedValuesLabel noSelection" );
			this.selectionStringNode.appendChild( document.createTextNode( this.noSelectionText ) );
		}
	}
	
	this.setToggleButtonCaption = function setToggleButtonCaption( caption )
	{	
		if( this.toggleButton.hasChildNodes() )
		{
			this.toggleButton.firstChild.data = caption;
		}
		else
		{
			this.toggleButton.appendChild( document.createTextNode( caption ) );
		}
	}
	
	this.buildControls = function buildControls()
	{
		var div = document.createElement( "div" );
		
		{
			var a = document.createElement( "a" );
			
			a.setAttribute( "onclick", this.id + ".toggle()" );
			a.setAttribute( classAttributeName, "toggleButton" );

			// For IE
			eval( "a.onclick = function() { " + this.id + ".toggle(); }" );
			
			div.appendChild( a );
			
			this.toggleButton = a;
			
			this.setToggleButtonCaption( "Vælg" );
		}
		
		{
			var a = document.createElement( "a" );
			
			a.setAttribute( "onclick", this.id + ".reset()" );
			a.setAttribute( classAttributeName, "resetButton" );

			// For IE
			eval( "a.onclick = function() { " + this.id + ".reset(); }" );
			
			a.appendChild( document.createTextNode( "Nulstil" ) );
			
			div.appendChild( a );
		}

		{
			var strong = document.createElement( "strong" );
			
			strong.appendChild( document.createTextNode( this.caption + ":" ) );
			strong.setAttribute( classAttributeName, "inputGroupLabel" );
			
			//strong.setAttribute( "style", "display: block; float: left; width: 120px;" );
			
			div.appendChild( strong );
		}

		{
			var p = document.createElement( "p" );
	
			p.setAttribute( classAttributeName, "selectedValuesLabel" );
			
			this.selectionStringNode = p;
						
			div.appendChild( p );
		}
		
		this.rootNode.insertBefore( div, this.inputsNode );
	}
	
	if( document.getElementById )
	{
		this.inputActionsAdded = false;
	
		this.id = nodeId;
		
		this.rootNode = document.getElementById( nodeId );
		
		if( this.rootNode )
		{			
			for( var i = 0 ; i < this.rootNode.childNodes.length ; i++ )
			{
				if( this.rootNode.childNodes[i].nodeType == 1 )
				{
					this.inputsNode = this.rootNode.childNodes[i];
					
					this.inputsNode.style.display = "none";
					
					this.buildControls();

					this.updateSelectedValues();
					
					return;
				}
			}
		}
	}
}