<!--


// Transfers the selected options from/to the specified listboxes
// @param src The listbox to transfer from.
// @param dest The listbox to transfer to.
function transferOptions(src, dest){

	for(var i = 0; i < src.length; i++){
		if(src.options[i].selected == true){
		
			var option = new Option(src.options[i].text, src.options[i].value, false, false);		
			
			dest.options[dest.length] = option;
			
			src.options[i] = null;
			i -= 1;
		
		}
	
	}
	
	bubbleSort(src);
	bubbleSort(dest);

}

// Sorts a listbox
function bubbleSort(listbox){

		var maxval;
		var maxindex;
		var i, j;

        // Step through the elements in the array starting with the
        // last element in the array.
        
        for(i = listbox.length - 1; i > -1; i--){

              // Set MaxVal to the element in the array and save the
              // index of this element as MaxIndex.
              maxval = listbox.options[i].text;
              maxindex = i;

              // Loop through the remaining elements to see if any is
              // larger than MaxVal. If it is then set this element
              // to be the new MaxVal.
              for(j = 1; j < i; j++){
              
				  if(listbox.options[j].text > maxval){
				     maxval = listbox.options[j];
				     maxindex = j;
				  }
              }

              // If the index of the largest element is not i, then
              // exchange this element with element i.
              if(maxindex < i){
              
				  var maxOption = new Option(listbox.options[i].text, listbox.options[i].value, false, false);
				  var iOption = new Option(maxval.text, maxval.value, false, false);
              
				  listbox.options[maxindex] = maxOption;
				  listbox.options[i] = iOption;
				  
			 }
         }

}

// Selects all options
function selectOptions(listbox){

	for(var i = 0; i < listbox.length; i++){
		listbox.options[i].selected = true;
	}

}

-->