<!--
/*
Create new item at the end of the list.

*/
function addLstItem(aText, aValue, aList, aIndex) {
  var newOption = document.createElement("OPTION");
  aList.options[aList.length] = newOption

	if ((aIndex == null) || (aIndex >= aList.length)) {
  	aIndex = aList.length-1
  } else {
  	for (var i = aList.Length-1; i > aIndex; i--) {
    	aList.options[i] = aList.options[i-1]
    }
  }
  aList.options[aIndex].text = aText
  aList.options[aIndex].value = aValue
}

/*
Remove item from the list.

*/
function removeLstItem(aList, aIndex) {
  var lstLength = aList.length
  if (aIndex < lstLength) {
  	aList.options[aIndex] = null
  }
}

/*
Move selected items from source list to destination list.

*/
function moveLstSel2Lst(aSrcList, aDestList) {
  var destLength = aDestList.length

   // Add selected items to destination list
  for (var ind = 0; ind < aSrcList.length; ind++) {
  	if (aSrcList.options[ind].selected)
    	addLstItem(aSrcList.options[ind].text, aSrcList.options[ind].value, aDestList);
  }

   // Remove selected items from list
	var ind2 = aSrcList.length-1
  while (ind2 >= 0) {
  	if (aSrcList.options[ind2].selected) removeLstItem(aSrcList, ind2);
  		ind2--
 	}
}

/*
Select all items.

*/
function selectAllLstItems(aList) {
	for (var ind = 0; ind < aList.length; ind++) {
  	aList.options[ind].selected = true;
  }
}

/*
Force the selection of an item, removing the selection of all others.
*/
function forceSingleSelection(aList, aIndex) {
	// If selected item is the one that forces single selection, unselect all the others
  if (aList.selectedIndex == aIndex) {
		for (ind = 0; ind < aList.length; ind++) {
			if (ind != aIndex) aList.options[ind].selected = false;
		}
	}
}

/*
Force the selection of all items, if the index parameter is the current selected one.
*/
function forceAllSelection(aList, aIndex) {
	// If selected item is the one that forces all selection, select all the others
  if (aList.selectedIndex == aIndex) {
		for (ind = 0; ind < aList.length; ind++) {
			if (ind != aIndex) aList.options[ind].selected = true;
		}
	}
}

function getRadioValue(aList) {
	for (var ind = 0; ind < aList.length; ind++) {
		if (aList[ind].checked) {
			return aList[ind].value;
		}
  }
  
  return -1;
}

function setRadioValue(aList, aValue) {
  for (var ind = 0; ind < aList.length; ind++) {
    if (aList[ind].value == aValue) {
      aList[ind].checked = true;
    }
  }
}
//-->