// GetPickList returns the value from a single selection SELECT list
function GetPickList(thelist){	
	
  var PickList='';
  for (var i=0; i < thelist.length; i++) {
    if (thelist.options[i].selected) {
      PickList = thelist.options[i].value;
      return PickList;
    }
  }
  return PickList;
}

// GetPickList returns the value from a single selection SELECT list
function GetPickListText(thelist){
  var PickList='';
  for (var i=0; i < thelist.length; i++) {
    if (thelist.options[i].selected) {
      PickList = thelist.options[i].text;
      return PickList;
    }
  }
  return PickList;
}

// Check to see if the default item is selected
function ItemSelected(thelist){
  for (var i=0; i < thelist.length; i++) {
    if (thelist.options[i].selected)
      return i;
  }
  return -1;
}
// Sets specific value in list
function setPickList(thelist, thevalue) {
  for (var i=0; i < thelist.length; i++) {
    if (thelist.options[i].value == thevalue) {
      thelist.options[i].selected = true;
      break;
    }
  }
}
// Returns comma delimited list of values from a MULTI-Select box kent 1/26/2001
function GetPickListMulti(thelist){
	var picklist = "";
	for (var i=0; i < thelist.length; i++) {
		if (thelist.options[i].selected) {
			// determine if we need to start separating with commas 
			if(picklist > ""){
				picklist += ",";
			}
			picklist += String(thelist.options[i].value);
		}
	}
	return picklist;
}
// Returns comma delimited list of text from a MULTI-Select box kent 1/26/2001
function GetPickListTextMulti(thelist){
	var picklist = "";
	for (var i=0; i < thelist.length; i++) {
		if (thelist.options[i].selected) {
			// determine if we need to start separating with commas 
			if(picklist > ""){
				picklist += ",";
			}
			picklist += String(thelist.options[i].text);
		}
	}
	return picklist;
}

// Removes all selected options from a MULTI-Select box kent 1/26/2001
function RemovePickListMulti(thelist){
	var picklist = "";
	for (var i=0; i < thelist.length; i++) {
		if (thelist.options[i].selected) {
			thelist.options[i] = null;
			// recursively call itself until all are found and removed
			RemovePickListMulti(thelist);
		}
	}
}
// Moves options FROM a multi Select box to another kent 1/26/2001
function MovePickListMulti(fromlist,tolist){
	// create comma delim lists
	tempindex = GetPickListMulti(fromlist);
	temptext = GetPickListTextMulti(fromlist);

	// now remove the options from the fromlist
	temp = RemovePickListMulti(fromlist);

	// create arrays, loop thru and add to the tolist 
	var arrayindex = tempindex.split(",");
	var arraytext = temptext.split(",");
	var startat = tolist.length;
	for (var i=0; i < arrayindex.length; i++) {
		// we don't want to move empty indexes 
		if(arrayindex[i] > ""){
			var newoption = startat + i;
			tolist.options[newoption] = new Option (arraytext[i], arrayindex[i]);
		}
	}
}

// Returns comma delimited list of ALL values from a MULTI-Select box kent 1/26/2001
function GetPickListMultiAll(thelist){
	var picklist = "";
	for (var i=0; i < thelist.length; i++) {
		if(picklist > ""){
			picklist += ",";
		}
		// we don't want to return empty indexes 
		if(thelist.options[i].value > ""){
			picklist += String(thelist.options[i].value);
		}
	}
	return picklist;
}

// Returns comma delimited list of ALL text from a MULTI-Select box kent 1/26/2001
function GetPickListTextMultiAll(thelist){
	var picklist = "";
	for (var i=0; i < thelist.length; i++) {
		if(picklist > ""){
			picklist += ",";
		}
		// we don't want to return empty indexes 
		if(thelist.options[i].value > ""){
			picklist += String(thelist.options[i].text);
		}
	}
	return picklist;
}

