	function compareOptionValues(a, b){ 
	  // Radix 10: for numeric values
	  // Radix 36: for alphanumeric values
	  var sA = parseInt( a.value, 36 );  
	  var sB = parseInt( b.value, 36 );  
	  return sA - sB;
	}
	// Compare two options within a list by TEXT
	function compareOptionText(a, b){ 
	  // Radix 10: for numeric values
	  // Radix 36: for alphanumeric values
	  var sA = parseInt( a.text, 36 );
	  var sB = parseInt( b.text, 36 );
	  return sA - sB;
	}
	// Dual list move function
	
	function moveDualList( srcList, destList, moveAll, removeItem ) {
	  // Do nothing if nothing is selected
	  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )){
	    return;
	  }
	  newDestList = new Array( destList.options.length );
	  var len = 0;
	  var optionPresent = false
	  for( len = 0; len < destList.options.length; len++ ) {
	    if ( destList.options[ len ] != null ){
	      newDestList[len] = new Option( destList.options[len].text, destList.options[len].value, destList.options[len].defaultSelected); 
	      newDestList[len].style.color = destList.options[len].style.color;
	    }
	  }
    for( var i = 0; i < srcList.options.length; i++ ){
      if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ){
				// Statements to perform if option is selected
				// Incorporate into new list only if they aren't already present in the srcList
				optionPresent = false
				// Check to see if the value in in the present list already
				for (destLen = 0 ; destLen < destList.options.length; destLen++){
					if ( destList.options[ destLen ].value == srcList.options[i].value ){
						optionPresent = true
					}
				}
				if(!optionPresent){
					if(!removeItem){
						newDestList[len] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected); 
						newDestList[len].style.color = srcList.options[i].style.color;
					}
				}
				len++;
      }
    }
	  // Sort out the new destination list
	  newDestList.sort( compareOptionValues );   // BY VALUES
	  //newDestList.sort( compareOptionText );   // BY TEXT
	  // Populate the destination with the items from the new array
	  for ( var j = 0; j < newDestList.length; j++ ) {
	    if ( newDestList[ j ] != null ){
	      destList.options[ j ] = newDestList[ j ];
	    }
	  }
	  // Erase source list selected elements
	  if(removeItem){
	  	var optionPresent2 = false
	    for( var i = srcList.options.length - 1; i >= 0; i-- ) {
	      if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ){
	      	// New bit
	      	for (destLen = 0 ; destLen < destList.options.length; destLen++){
						if ( destList.options[ destLen ].value == srcList.options[i].value ){
							optionPresent2 = true
						}
					}
	      	if(optionPresent2){
		      	srcList.options[i] = null;
		      }
		      optionPresent2 = false
	      }
	    }
	  }
	}
	
	function moveUpList(listField) {
	   if ( listField.length == -1) {  // If the list is empty
	      alert("There are no values which can be moved!");
	   } else {
	      var selected = listField.selectedIndex;
	      if (selected == -1) {
	         alert("You must select an entry to be moved!");
	      } else {  // Something is selected 
	         if ( listField.length == 0 ) {  // If there's only one in the list
	            alert("There is only one entry!\nThe one entry will remain in place.");
	         } else {  // There's more than one in the list, rearrange the list order
	            if ( selected == 0 ) {
	               alert("The first entry in the list cannot be moved up.");
	            } else {
	               // Get the text/value of the one directly above the hightlighted entry as
	               // well as the highlighted entry; then flip them
	               var moveText1 = listField[selected-1].text;
	               var moveText2 = listField[selected].text;
	               var moveValue1 = listField[selected-1].value;
	               var moveValue2 = listField[selected].value;
	               listField[selected].text = moveText1;
	               listField[selected].value = moveValue1;
	               listField[selected-1].text = moveText2;
	               listField[selected-1].value = moveValue2;
	               listField.selectedIndex = selected-1; // Select the one that was selected before
	            }  // Ends the check for selecting one which can be moved
	         }  // Ends the check for there only being one in the list to begin with
	      }  // Ends the check for there being something selected
	   }  // Ends the check for there being none in the list
	}
		
	function moveDownList(listField) {
	   if ( listField.length == -1) {  // If the list is empty
	      alert("There are no values which can be moved!");
	   } else {
	      var selected = listField.selectedIndex;
	      if (selected == -1) {
	         alert("You must select an entry to be moved!");
	      } else {  // Something is selected 
	         if ( listField.length == 0 ) {  // If there's only one in the list
	            alert("There is only one entry!\nThe one entry will remain in place.");
	         } else {  // There's more than one in the list, rearrange the list order
	            if ( selected == listField.length-1 ) {
	               alert("The last entry in the list cannot be moved down.");
	            } else {
	               // Get the text/value of the one directly below the hightlighted entry as
	               // well as the highlighted entry; then flip them
	               var moveText1 = listField[selected+1].text;
	               var moveText2 = listField[selected].text;
	               var moveValue1 = listField[selected+1].value;
	               var moveValue2 = listField[selected].value;
	               listField[selected].text = moveText1;
	               listField[selected].value = moveValue1;
	               listField[selected+1].text = moveText2;
	               listField[selected+1].value = moveValue2;
	               listField.selectedIndex = selected+1; // Select the one that was selected before
	            }  // Ends the check for selecting one which can be moved
	         }  // Ends the check for there only being one in the list to begin with
	      }  // Ends the check for there being something selected
	   }  // Ends the check for there being none in the list
	}
 
 
 
 //added by WN for alphabetical page ordering
    function ListOrder(listField,type) {
	   if ( listField.length == -1) {  // If the list is empty
	      alert("There are no values which can be moved!");
	   } else {
	         if ( listField.length == 0 ) {  // If there's only one in the list
	            alert("There is only one entry!\nThe one entry will remain in place.");
	         } else {  // There's more than one in the list, rearrange the list order
                    //add these 3 lines to the script!!
                    for( len = 0; len < listField.options.length; len++ ) {
                       if ( type == 'alpha' ){
                         listField.options[len] = AlphabeticalArray[len];
                       } else {
                         listField.options[len] = PageOrderArray[len];
                       }
                    }
                 }
           }
        }

