
function ProcessSubscriptionSelections()
{
   var origString; 
   var foundOne = false; 
   var availLength = document.forms['form2'].elements['Available[]'].options.length;
   origString = document.form2.origavaillist.value;
   for (i=0;i<availLength;i++) {
   	myindex = origString.indexOf(document.forms['form2'].elements['Available[]'].options[i].text);
   	if (myindex == -1) {
		foundOne = true;
		document.forms['form2'].elements['Available[]'].options[i].selected = true;
	}
/*	else 
		if (myindex + document.forms['form2'].elements['Available[]'].options[i].length == availLength) {
		}
		else {
			myindex = origString.indexOf(document.forms['form2'].elements['Available[]'].options[i].text + '|');
			if (myindex == -1) {
				foundOne = true;
				document.forms['form2'].elements['Available[]'].options[i].selected = true;
			}
		}
*/		
   }
   var assignLength = document.forms['form2'].elements['Assigned[]'].options.length;
   origString = document.form2.origassignedlist.value;
   for (i=0;i<assignLength;i++) {
   	myindex = origString.indexOf(document.forms['form2'].elements['Assigned[]'].options[i].text);
   	if (myindex == -1) {
        foundOne = true;
        document.forms['form2'].elements['Assigned[]'].options[i].selected = true;
      }
/*	else
		if (myindex + document.forms['form2'].elements['Assigned[]'].options[i].length == availLength) {
		}
		else {
			myindex = origString.indexOf(document.forms['form2'].elements['Assigned[]'].options[i].text + '|');
			if (myindex == -1) {
				foundOne = true;
				document.forms['form2'].elements['Assigned[]'].options[i].selected = true;
			}
		}
*/		
   }
   return foundOne;
}

//This function moves available/assigned privileges from one list to the other when one
//of the "move" buttons is clicked. (Assign or Deassign).
function AssignSubscriptionVal(Source,Target)
{
   //save the initial length of the available items list
   //as we remove items from this list (selected items) we 
   //will need to decrement the length
	var AvailLength = Source.options.length;
	var i = 0;
	while (i < AvailLength) {
      //if the available item is selected 
		if (Source.options[i].selected) {
	      //create new Option item to insert into Assigned list
   		  var optionName = new Option(Source.options[i].text, Source.options[i].value, false,false);
	      var length = Target.options.length;
	      //insert Available Item into Assigned List
	      Target.options[length] = optionName;
         //now remove Available item which was just assigned from available list
         Source.options[i] = null;
         //if there are any items left then
         //decrement number of items in Available List
         if (AvailLength > 0) AvailLength--;
		}
      else {
      	i++;
      }
	}
return false;
}
