Chris@1115: var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5); Chris@1115: Chris@1464: function addOption(theSel, theText, theValue) { Chris@1115: var newOpt = new Option(theText, theValue); Chris@1115: var selLength = theSel.length; Chris@1115: theSel.options[selLength] = newOpt; Chris@1115: } Chris@1115: Chris@1464: function swapOptions(theSel, index1, index2) { Chris@1115: var text, value; Chris@1115: text = theSel.options[index1].text; Chris@1115: value = theSel.options[index1].value; Chris@1115: theSel.options[index1].text = theSel.options[index2].text; Chris@1115: theSel.options[index1].value = theSel.options[index2].value; Chris@1115: theSel.options[index2].text = text; Chris@1115: theSel.options[index2].value = value; Chris@1115: } Chris@1115: Chris@1464: function deleteOption(theSel, theIndex) { Chris@1115: var selLength = theSel.length; Chris@1464: if (selLength > 0) { Chris@1115: theSel.options[theIndex] = null; Chris@1115: } Chris@1115: } Chris@1115: Chris@1464: function moveOptions(theSelFrom, theSelTo) { Chris@1115: var selLength = theSelFrom.length; Chris@1115: var selectedText = new Array(); Chris@1115: var selectedValues = new Array(); Chris@1115: var selectedCount = 0; Chris@1115: var i; Chris@1464: for (i = selLength - 1; i >= 0; i--) { Chris@1464: if (theSelFrom.options[i].selected) { Chris@1115: selectedText[selectedCount] = theSelFrom.options[i].text; Chris@1115: selectedValues[selectedCount] = theSelFrom.options[i].value; Chris@1115: deleteOption(theSelFrom, i); Chris@1115: selectedCount++; Chris@1115: } Chris@1115: } Chris@1464: for (i = selectedCount - 1; i >= 0; i--) { Chris@1115: addOption(theSelTo, selectedText[i], selectedValues[i]); Chris@1115: } Chris@1464: if (NS4) history.go(0); Chris@1115: } Chris@1115: Chris@1115: function moveOptionUp(theSel) { Chris@1115: var index = theSel.selectedIndex; Chris@1115: if (index > 0) { Chris@1115: swapOptions(theSel, index-1, index); Chris@1115: theSel.selectedIndex = index-1; Chris@1115: } Chris@1115: } Chris@1115: Chris@1517: function moveOptionTop(theSel) { Chris@1517: var index = theSel.selectedIndex; Chris@1517: Chris@1517: if (index > 0) { Chris@1517: for (i=index; i>0; i--) { Chris@1517: swapOptions(theSel, i-1, i); Chris@1517: } Chris@1517: theSel.selectedIndex = 0; Chris@1517: } Chris@1517: } Chris@1517: Chris@1115: function moveOptionDown(theSel) { Chris@1115: var index = theSel.selectedIndex; Chris@1115: if (index < theSel.length - 1) { Chris@1115: swapOptions(theSel, index, index+1); Chris@1115: theSel.selectedIndex = index+1; Chris@1115: } Chris@1115: } Chris@1115: Chris@1517: function moveOptionBottom(theSel) { Chris@1517: var index = theSel.selectedIndex; Chris@1517: var indexTop = theSel.length - 1; Chris@1517: if (index < theSel.length - 1) { Chris@1517: for (i=index; i