<a name=<% $class %>></a>
<table width="578" cellpadding="2" cellspacing="0" border="0">
<tr valign="middle">
    <td class="darkHeader" width=100><span class=whiteTextTab>&nbsp;<% uc $caption %></span>&nbsp;&nbsp;&nbsp;&nbsp;</td>
    <td align="right" class="darkHeader" width=190><span class="body"><%$lang->maketext('Sort By')%>:</span> <& '/widgets/profile/select.mc',
                         value => $sort_by_val,
			 useTable => 0,
                         indent => 70,
                         width  => 100,
                         options => $sort_by->{$class},
                         name => $class . '_sort_by',
			 js => qq{onChange="location.href='} . $r->uri . "?${class}_sort_by=' + " . qq{escape(this.options[this.selectedIndex].value)"},
			 &></td>
    <td align="right" width=288>&nbsp;
% if ($link1) {
<a href="<% $link1 %>"><img src="/media/images/<% $lang_key . '/' . lc ($lab1) %>_dgreen.gif" border=0 hspace=2></a>
% } if ($link2) {
<a href="<% $link2 %>"><img src="/media/images/<% $lang_key . '/' . lc($lab2) %>_dgreen.gif" border=0 hspace=2></a>
% }
    </td>
</tr>
</table><br />
<div id="desk">
<%args>
$class => 'story'
$caption => ''
$sort_by_val => undef
$others => {}
</%args>
<%init>;
$caption ||= $pl_names->{$class};
my ($link1, $link2, $lab1, $lab2);
if ($class eq 'story') {
    ($link1, $lab1) = ('#media', $pl_names->{media}) if $others->{media};
    ($link2, $lab2) = ('#formatting', $pl_names->{formatting})
      if $others->{formatting};
} elsif ($class eq 'media') {
    ($link1, $lab1) = ('#story', $pl_names->{story}) if $others->{story};
    ($link2, $lab2) = ('#formatting', $pl_names->{formatting})
      if $others->{formatting};
} else {
    ($link1, $lab1) = ('#story', $pl_names->{story}) if $others->{story};
    ($link2, $lab2) = ('#media', $pl_names->{media}) if $others->{media};

}

$sort_by_val = get_pref('Default Asset Sort') unless defined $sort_by_val;
</%init>
<%once>;
my $sort_by = { story      => [ [ cover_date => 'Cover Date' ],
                                [ priority => 'Priority' ],
			        [ name => 'Title' ],
                                [ category_name => 'Category' ],
                                [ site_id => 'Site' ],
                                [ element => 'Story Type' ],
                                [ id => 'ID' ],
                              ],
                media      => [ [ cover_date => 'Cover Date' ],
			        [ priority => 'Priority' ],
                                [ name => 'Title' ],
                                [ category_name => 'Category' ],
                                [ site_id => 'Site' ],
                                [ element => 'Media Type' ],
                                [ id => 'ID' ],
                              ],
                formatting => [ [ deploy_date => 'Cover Date' ],
				[ priority => 'Priority' ],
				[ file_name => 'File Name' ],
                                [ category_name => 'Category' ],
                                [ site_id => 'Site' ],
                                [ element => 'Asset Type' ],
                                [ id => 'ID' ],
                              ]
              };
my $pl_names = { story => get_class_info('story')->get_plural_name,
                 media => get_class_info('media')->get_plural_name,
                 formatting => 'templates' #get_class_info('formatting')->get_plural_name
               };
</%once>
