function SelectAll(selectItem) {
    var i;
    var j = 0;
    for (i = 0; i < selectItem.options.length; i++) {
         selectItem.options[j].selected = true;
         j++;
    }
}
		
function addItems(fromItem, toCtrl) {
    var i;
    var j;
    var itemexists;
    var nextitem;
		
    // step through all items in fromItem
    for (i = 0; i < fromItem.options.length; i++) {
         if (fromItem.options[i].selected) {
              // search toCtrl to see if duplicate
              j = 0;
              itemexists = false;
              while ((j < toCtrl.options.length) && (!(itemexists))) {
                   if (toCtrl.options[j].value == fromItem.options[i].value) {
                        itemexists = true;
                        alert(fromItem.options[i].value + " found!... Possibly a duplicate key in the arrays");
                   }
                   j++;
              }
              if (!(itemexists)) {
                   // add the item
                   nextitem = toCtrl.options.length;
                   toCtrl.options[nextitem] = new Option(fromItem.options[i].text);
                   toCtrl.options[nextitem].value = fromItem.options[i].value;
              }
         }
    }
}
		
		
		function removeItems(fromItem) {
		    var i = 0;
		    var j;
		    var k = 0;
		
		    while (i < (fromItem.options.length - k)) {
		         if (fromItem.options[i].selected) {
		              // remove the item
		              for (j = i; j < (fromItem.options.length - 1); j++) {
		                   fromItem.options[j].text = fromItem.options[j+1].text;
		                   fromItem.options[j].value = fromItem.options[j+1].value;
		                   fromItem.options[j].selected = fromItem.options[j+1].selected;
		              }
		               k++;
		         } else {
		              i++;
		         }
		    }
		    for (i = 0; i < k; i++) {
		         fromItem.options[fromItem.options.length - 1] = null;
		    }
		}