// the function below EXPECTS the dodosPicklist jQuery plugin
function selectManyPicklist(id) {
	// (OPTIONAL) adjust the width of the select box to the bigger of the two
	$("select[name='"+id+"_SELECTED']").selectAdjustWidth("select[name='"+id+"_AVAILABLE']");
	
	$("select[name='"+id+"_SELECTED']").multiSelect("select[name='"+id+"_AVAILABLE']", {
		trigger: "div#"+id+"_SWAP_BUTTON input[name='remove']",
		triggerAll: "div#"+id+"_SWAP_BUTTON input[name='removeAll']",
		afterMove: function() {updateHidden("select[name='"+id+"_SELECTED']", "#"+id+"_HIDDEN");}
	});
	
	$("select[name='"+id+"_AVAILABLE']").multiSelect("select[name='"+id+"_SELECTED']", {
		trigger: "div#"+id+"_SWAP_BUTTON input[name='add']",
		triggerAll: "div#"+id+"_SWAP_BUTTON input[name='addAll']",
		afterMove: function() {updateHidden("select[name='"+id+"_SELECTED']", "#"+id+"_HIDDEN");}
	});
}
function updateHidden(selectedList, hiddenId) {
	var selectedOptions = selectedList+ " option";
	var arrValues = new Array($(selectedOptions).length);
	$(selectedOptions).each(function(i,option) {
		arrValues[i] = $(this).val();
	});
	$(hiddenId).val(arrValues.join());
}
