%# Logicians have but ill defined
%# As rational the human kind.
%# Logic, they say, belongs to man,
%# But let them prove it if they can.
%# 		-- Oliver Goldsmith

</form><form action="index.html" method="Post">
<input type="hidden" name="CF" value="<% $CF %>">
<input type="hidden" name="Value" value="<% $Value %>">
<input type="hidden" name="Begin" value="<% $Begin %>">
<input type="hidden" name="Queue" value="<% $Queue %>">
<table width="100%" border="0" cellspacing="3" cellpadding="0" class="poptable" bgcolor="#89D5ED" class="fixed"><COL width=100%>
  <tr> 
    <td><nobr><&|/l&>Field Content:</&> <% $Item->Name %></nobr></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="3" cellpadding="0">
  <tr> 
    <td> 
      <table border="0" cellpadding="0" align="center" cellspacing="0" width="95%">
	<tr> 
	    <td colspan=2>
	    <& /Edit/Elements/Button, Name => "Action-ValueAdd", Image => "funcAdd", Text => "Add", Disabled => $disabled &>
	    <& /Edit/Elements/Button, Name => "Action-ValueSave", Image => "funcSave", Text => "Save", Disabled => $noitem &>
	    <& /Edit/Elements/Button, Name => "Action-ValueDelete", Image => "funcDelete", Text => "Delete", Disabled => $noitem &>
	    </td>
	</tr>
        <tr> 
          <td  width="50"><nobr><&|/l&>Option Name</&>&nbsp;</nobr></td>
          <td > 
            <input type="text" name="ValueName" value="<% $SubItem->Name %>" style="width:280px" <% $noitem %>>
          </td>
        </tr>
        <tr> 
          <td  width="50"><nobr><&|/l&>Option Description</&>&nbsp;</nobr></td>
          <td > 
            <input type="text" name="ValueDescription" value="<% $SubItem->Description %>" style="width:280" <% $noitem %>>
          </td>
        </tr>
        <tr> 
          <td  colspan=2 align="left">
	  <& /Edit/Elements/Button, Name => "Action-ValueUp", Image => "funcUp", Text => "Move up", Disabled => $novalue &>
	  <& /Edit/Elements/Button, Name => "Action-ValueDown", Image => "funcDown", Text => "Move down", Disabled => $novalue &>
	  <& /Edit/Elements/Button, Name => "Action-ValueUpMost", Image => "funcUpMost", Text => "Move to first", Disabled => $novalue &>
	  <& /Edit/Elements/Button, Name => "Action-ValueDownMost", Image => "funcDownMost", Text => "Move to last", Disabled => $novalue &>
          </td>
        </tr>
      </table>
      <div align="center">
        <select name="select" size="19" style="height:350; width:333px" <% $disabled %>
% $m->print('onclick="location.href=this.options[this.selectedIndex].tag"') unless $novalue or (!$RT::IsMSIE);
	>
% if (@SubHash) {
%     while (my ($v, $descr) = splice(@SubHash, 0, 2)) {
	  <option value="<% $v %>"><% $descr %></option>
%     }
% } else {
%     foreach my $v (@$SubList) { 
          <option 
	  onclick="location.href='index.html?Queue=<% $Queue %>&Begin=<% $Begin %>&CF=<% $CF %>&Value=<% $v->id %>'"
	  tag="index.html?Queue=<% $Queue %>&Begin=<% $Begin %>&CF=<% $CF %>&Value=<% $v->id %>" <% ($Value == $v->id) ? 'selected' : '' %> value="<% $v->id %>"
	  ><% $v->Name %>
%     if (length $v->Description) {
(<% $v->Description %>)
%     }
	  </option>
%     }
% }
        </select>
      </div>
    </td>
  </tr>
</table>
<%INIT>
my $disabled = (
    ($Item->Id and $Item->Type =~ /Select(?!External)/) ? '' : 'disabled'
);
my $values = $disabled ? $RT::Nothing : $Item->Values;
my $novalue = ( ($disabled or !$values or !$values->Count) ? 'disabled' : '' );
my @SubHash;
my $SubList = $values->ItemsArrayRef || [];
my $SubItem = (grep { $_->id == $Value } @$SubList)[0] || $RT::Nothing;
my $noitem = ( ($disabled or $novalue or ($SubItem == $RT::Nothing)) ? 'disabled' : '' );

if ($Item->Type =~ /^(?:Select|Entry)External$/ and my $ext_id = $Item->Description) {
    @SubHash = eval { $session{CurrentUser}->UserObj->field_values($Item->Description) };
}
</%INIT>
<%ARGS>
$CF => 0
$Item => $RT::Nothing
$Value => 0
$Begin => 0
$Queue => 0
$Action => ''
$ARGS => {}
</%ARGS>
