Thematic Child Theme - Post Footer Modification

For this site, I use 'Murkymatic' which is a child theme of 'Thematic'. I wanted to amend the footer on each post to allow me to link posts which are in a series. I add a custom field to posts in a series, and I want to pick that up, and automatically link the posts.

I've now done this, following a little help from a commenter which told me something relatively easy that I just didn't know - the resulting code is shown below and is currently in my functions.php file. I've also added social bookmarking links.

function childtheme_article_footer($footer) {      $extra_stuff='';

     global $id, $post;      $series = get_post_meta($post->ID, 'Series', true);      $pstlink = get_permalink();      $psttitle = get_the_title();      $pstbody = get_the_excerpt();      if($series) :           $args = array(                'numberposts' => -1,                'meta_key' => 'Series',                'meta_value' => $series,           );           $series_posts = get_posts($args);           if($series_posts) :                $class = preg_replace("/[^a-z0-9\\040\\.\\-\\_\\\\]/i", "", $series);                $class = strtolower(str_replace(array(' ', ' '), '-', $class));                if (is_single()) {                     $extra_stuff = '<div class="series series-' . $class . '"><h4 class="series-title">' . __('Articles in this series') . '</h4><ul>';                     foreach($series_posts as $serial) :                          if($serial->ID == $post->ID)                               $extra_stuff = $extra_stuff . '<li class="current-post">' . $serial->post_title . '</li>';                          else                          $extra_stuff = $extra_stuff . '<li><a href="' . get_permalink($serial->ID) . '" class="postID_' . $serial->ID . '" title="' . str_replace('"', '"', $serial->post_title) . '">' . str_replace('"', '"', $serial->post_title) . '</a></li>';                     endforeach;                     $extra_stuff = $extra_stuff . '</ul></div>';                } else {                $extra_stuff = $extra_stuff . '<div class="series series-' . $class . '">';                $extra_stuff = $extra_stuff . '<h4 class="series-title"><a href="' . $pstlink . '">' . $psttitle . '</a>';                $extra_stuff = $extra_stuff . ' is part of a series' . '</h4></div>';           }           endif;      endif;

     $extra_stuff_post = '<div class="socialnetwork"><ul>';      $extra_stuff_post = $extra_stuff_post . '<li>Send to: <a class="twitterlink" href="http://twitter.com/home?status=Currently reading ' . $pstlink . '" title="Click to send ' . $psttitle . ' to Twitter!" target="_blank">Twitter</a></li>';      $extra_stuff_post = $extra_stuff_post . '<li><a class="deliciouslink" href="http://del.icio.us/post?url=' . $pstlink . '&title=' . $psttitle . '" title="Click to bookmark ' . $psttitle . ' on del.icio.us!" target="_blank">del.icio.us</a></li>';      $extra_stuff_post = $extra_stuff_post . '<li><a class="digglink" href="http://digg.com/submit?phase=2&url=' . $pstlink . '&title='. $psttitle . '&bodytext=' . $pstbody . '" title="Click to bookmark ' . $psttitle . ' on Digg!" target="_blank">Digg</a></li>';      $rss_url = get_bloginfo('rss2_url');      $extra_stuff_post = $extra_stuff_post . '<li>Use the: <a class="rsslink" href="' . $rss_url . '" title="Click to Subscribe to the Feed" rel="alternate" type="application/rss+xml" target="_blank">RSS Feed</a></li>';      $extra_stuff_post = $extra_stuff_post . '</ul></div>';

     $footer = $extra_stuff . $footer . $extra_stuff_post;      return $footer; }

add_action('thematic_postfooter','childtheme_article_footer');

Where I want to include a post in a series, I add a custom field imaginatively called 'Series' and give that series a name. Any post sharing that series name is included.

What I now want to do is to modify the function above to show a restricted listing of the series, e.g. First in Series, Previous in Series, Next in Series, Last in Series.... except, perhaps, for the first post in the series which would show the entire sequence. I'm not quite sure of how to do this neatly, the best I can think of is to do two passes through the list of post IDs to find the relevant IDs. I'd appreciate any input.