function addSrcToDestList(slist,dlist) {
	destList = dlist;
	srcList = slist;
	var len = destList.length;
	
	var count;
	var CatId;
	var MyIndex;
	var numChildren;
	var chosenCategory;
	
	for(var i = 0; i < srcList.length; i++)
	{
		var found = false;
		
		for(count = 0; count < len; count++)
		{
			if (destList.options[count] != null)
			{
				if (srcList.options[i].text == destList.options[count].text)
				{
					found = true;
					break;
				}	
			}
		}
		
		
		if (found != true && i == srcList.selectedIndex)
		{
			// Adding to the other listbox.
			destList.options[len] = new Option(srcList.options[i].text);
			destList.options[len].value = srcList.options[i].value;
			
			// Deleting from the current list box.
			srcList.options[i] = null;
			
			len++;
		}
	}
}

function addFromWindow(slist,xlist,dlist)
{
	destList = dlist;
	srcList = slist;
	srcDesc = xlist;
	var len = destList.length;
	
	var count;
	var CatId;
	var MyIndex;
	var numChildren;
	var chosenCategory;
	
	var found = false;
		
	for(count = 0; count < len; count++)
	{
		if (destList.options[count] != null)
		{
			if (srcList.value == destList.options[count].value)
			{
				found = true;
				break;
			}	
		}
	}
	
	if (found != true)
	{
		// Adding to the other listbox.
		destList.options[len] = new Option(srcDesc.value);
		//alert("OK");
		destList.options[len].value = srcList.value;
		len++;
	}
}


function deleteFromDestList(dlist) {
	var destList  = dlist;
	var len = destList.options.length;
	for(var i = (len-1); i >= 0; i--) {
		if ((destList.options[i] != null) && (destList.options[i].selected == true) && (destList.options[i].value != 'sil')) {
			destList.options[i] = null;
		}
	}
}





function compareText (option1, option2) {
  return option1.text < option2.text ? -1 :
    option1.text > option2.text ? 1 : 0;
}
function compareValue (option1, option2) {
  return option1.value < option2.value ? -1 :
    option1.value > option2.value ? 1 : 0;
}
function compareTextAsFloat (option1, option2) {
  var value1 = parseFloat(option1.text);
  var value2 = parseFloat(option2.text);
  return value1 < value2 ? -1 :
    value1 > value2 ? 1 : 0;
}
function compareValueAsFloat (option1, option2) {
  var value1 = parseFloat(option1.value);
  var value2 = parseFloat(option2.value);
  return value1 < value2 ? -1 :
    value1 > value2 ? 1 : 0;
}
function sortSelect (select, compareFunction) {
  if (!compareFunction)
    compareFunction = compareText;
  var options = new Array (select.options.length);
  for (var i = 0; i < options.length; i++)
    options[i] = 
      new Option (
        select.options[i].text,
        select.options[i].value,
        select.options[i].defaultSelected,
        select.options[i].selected
      );
  options.sort(compareFunction);
  select.options.length = 0;
  for (var i = 0; i < options.length; i++)
    select.options[i] = options[i];
}
