function add (ele) {
	
	if (ele.form.unsuball.checked) {
		undoUnsubAll (ele.form.unsuball);
	}
	removeFromList (ele.name, ele.form.sub);
	removeFromList (ele.name, ele.form.unsub);
	if (ele.value == "sub") {
		addToList (ele.name, ele.form.sub);
	} else { // ele.value == "unsub"
		addToList (ele.name, ele.form.unsub);
	} // end if
} // end add

function doUnsubAll (ele) {
	
	if (ele.checked) {
		var i, eles;
		eles = ele.form.elements;
		for (i = 0; i < eles.length; ++i) {
			if (eles[i].type == "radio" && eles[i].value == "unsub") {
				eles[i].checked = true;
				eles[i].blur ();
				add (eles[i]);
			}
		}
		addToList ("-1", ele.form.unsub);
		ele.checked = true;
		ele.blur ();
	} else { // unsuball is now unchecked
		removeFromList ("-1", ele.form.unsub);
	}
}

function undoUnsubAll (ele) {
	
	removeFromList ("-1", ele.form.unsub);
	ele.checked = false;
	ele.blur ();
}

function addToList (val, lst) {
	
	if (lst.value == "" || lst.value == null) {
		lst.value = "" + val;
	} else {
		lst.value = val + ", " + lst.value;
	} // end if
} // end addToSubList

function removeFromList (val, lst) {
	
	var i
	if ((i = lst.value.indexOf (val + ",",0)) >= 0) { // val is in list
		if (i == 0) { // remove from front of list
			if (lst.value.indexOf (" ") < 1) { // only one item in sub list
				lst.value = "";
			} else {
				lst.value = lst.value.substring (lst.value.indexOf (" ", 0) + 1, lst.value.length);
			} // end if
		} else if (i > lst.value.lastIndexOf (" ")) { // remove from back of list
			lst.value = lst.value.substring (0, lst.value.lastIndexOf (","));
		} else { // remove from within list
			lst.value = lst.value.substring (0, i) + lst.value.substring (lst.value.indexOf (" ", i) + 1, lst.value.length);
		} // end if
	}
} // end removeFromSubList

