function lbControl(id)
{
	var lbObject=document.getElementById(id);
	this.add=add;
	this.clear=clear;
	this.getSeleced=getSelected; 
	this.getValue=getValue; 	
	this.removeSelected=removeSelected;
	this.removeByValue=removeByValue;	
	this.removeByText=removeByText;	
	this.setSelected=setSelected;
	this.setSelectedByValue=setSelectedByValue;	
	this.setSelectedByText=setSelectedByText;	
	this.getAllTextComaSeparated=getAllTextComaSeparated;
	
	function add(text,value) // TODO: sorted?
	{
	  var newOpt;
	  newOpt = document.createElement("OPTION");
	  newOpt.text=text;
	  newOpt.value = value;
	  try
	  {
		lbObject.add(newOpt,null);
	  } catch(ex)
		{
			lbObject.add(newOpt,0);
		}
	}
	
	function clear()
	{
		while (lbObject.options.length!=0)
			lbObject.remove(0);	
	}
	
	function getSelected()
	{
		if(lbObject.selectedIndex<0) return null;
		return lbObject.options[selectedIndex];	
	}
	
	function getValue()
	{
		if(lbObject.selectedIndex<0) return null;
		return lbObject.value;	
	}	
	
	function removeSelected()
	{
		lbObject.remove(lbObject.selectedIndex);
	}
	
	function removeSelectedByValue()
	{
		for(i=0; i<lbObject.options.length; i++)
		{
			if(lbObject.options[i].value==value)
			{
				lbObject.options.splice(i);
				return;
			}
		}			
	}
	
	function removeByValue()
	{
		for(i=0; i<lbObject.options.length; i++)
		{
			if(lbObject.options[i].value==value)
			{
				lbObject.options.splice(i);
				return;
			}				
		}			
	}	
	
	function removeByText()
	{
		for(i=0; i<lbObject.options.length; i++)
		{
			if(lbObject.options[i].text==text)
			{
				lbObject.options.splice(i);
				return;
			}				
		}			
	}	
	
	function setSelected(index)
	{
		lbObject.selectedIndex=index;
	}
	
	function setSelectedByValue()
	{
		for(i=0; i<lbObject.options.length; i++)
		{
			if(lbObject.options[i].value==value)
			{
				lbObject.selectedIndex=i;
				return;
			}
		}			
	}	
	
	function setSelectedByText()
	{
		for(i=0; i<lbObject.options.length; i++)
		{
			if(lbObject.options[i].text==text)
			{
				lbObject.selectedIndex=i;
				return;
			}
		}			
	}
	
	function getAllValueComaSeparated()
	{
		var values="";
		for(i=0; i<lbObject.options.length; i++)
		{
			values+=lbObject.options[i].value + ";"
		}			
		return values;
	}

	function getAllTextComaSeparated()
	{
		var texts="";
		for(i=0; i<lbObject.options.length; i++)
		{
			texts+=lbObject.options[i].text + ";"
		}			
		return texts;
	}
	
}

