1function add() {
2	doMove("allusers", "groupusers", true, true);
3}
4
5function addall() {
6	doMove("allusers", "groupusers", false, true);
7}
8
9function remove() {
10	doMove("groupusers", "allusers", true, false);
11}
12
13function removeall() {
14	doMove("groupusers", "allusers", false, false);
15}
16
17function doMove(fromselect, toselect, needsselected, setselected) {
18	var allusers = document.getElementById(fromselect);
19	var grpusers = document.getElementById(toselect);
20	for (var i = allusers.options.length - 1; i >= 0; i--) {
21		if ((needsselected && allusers.options[i].selected) || !needsselected) {
22			var userInput = document.getElementById("users."+allusers.options[i].value);
23			if (setselected) {
24				userInput.name = 'users[]';
25			} else {
26				userInput.name = null;
27			}
28			allusers.options[i].selected = false;
29			grpusers.add(allusers.options[i], null);
30		}
31	}
32}