#use zw;
sub yahooUnifiedHandler
{
   $html = shift;
   $tableCount = shift;

   my $done;
   my $count;
   @rValue = ();

#   print "-------------- yahooUnifiedHandler ---------------\n";

   if ($tableCount =~ /^$/)
   {
      $tableCount = 28;
   }

   $done = 0;
   $count = $tableCount;
   while( !$done )
   {
      print "iteration .. count: $count..\n";
      $storyBlock = zUtil::getNthItemNew( $count, $html, "<table", "</table>" );
      #print "story block: $storyBlock\n";
      #exit;
      $storyBlock =~ s/<a href=".*?add.my.yahoo.*?".*?>//g;
      if( $storyBlock =~ /<a\ href="(.*?)"
                           (><img\ src="(.*?)"\ .*?><\/a>.*?)?
                           .*?class=topstory>(.*?)<\/a>
                           .*?<div\ class=.*?timedate>
                           (.*?)<\/div>
                           # .*?(<font\ size=-1>)?
                           (.*?) # (<\/font>)?.*?
                           <br\ clear=all>
                           /ixs )
      {
#         print "story block: $storyBlock\n";
#         print "=================================================\n";
#         exit;
         $done = 1;
      }
      else
      {
#         print "b";
         $count++;
         if( $count > 50 )
         {
            $done = 1;
         }
      }
   }

#   print  "html($html)\n";
#   print  "storyBlock($storyBlock)\n";
#   print  "table=$tableCount\n";
#   exit();

   # Our performance sucks pretty bad.  Let's try and help things out a bit.
   $storyBlock =~ s/(.*)More Stories.*/$1/s;
#   print STDERR "Processing story block...\n";
#   print  "storyBlock($storyBlock)\n";
#   exit;

   while (
      $storyBlock =~ /
      <a\ href="(.*?)"
      (><img\ src="(.*?)"\ .*?><\/a>.*?)?
      .*?class=(topstory|reg)>(.*?)<\/a>
      .*?<div\s*?class=.*?timedate>.*?
      (.*?)<\/div>
      (.*?)<br\ clear=all>
      /gixs
   )
   {
      $image = $3;
      $url = $1;
      $headline = $5;
      $date = $6;
      $blurb = $7;
      if ($image =~ /^$/)
      {
         $image = "clear.gif";
      }
#      print STDERR "url=($url)\n";
#      print STDERR "img=($image)\n";
#      print STDERR "hdl=($headline)\n";
#      print STDERR "dte=($date)\n";
#      print STDERR "blb=($blurb)\n";
#      exit;
      push @rValue,
      {
         'url' => $url,
         'headline' => $headline,
         'date' => $date,
         'blurb' => $blurb,
         'image' => $image
      };
   }

#   print "exiting yahooUnifiedHandler\n";
   return @rValue;
}

1;

# vi: set ts=3 sw=3 nowrap expandtab:
