#-*-Perl-*-

#Tack on the names of the subroutines to the list of functions
$hof{"fika"} = 0;

#Out of Fika 
#not date based
#does not appear to be having any updates since jan 23, 2001
#using that date as last strip
#first strip will be 220 comics before
#strip 0442 is missing but html page points to 443
#strip 0443 is missing html page 
sub fika  {
    my $time = shift;
    my @ltime = gmtime($time);
    my $daysago = (time - $time)/(3600*24);
    $daysago =~ s/\..*$//;
    my $dayssincelast = (time - mkgmtime(0,0,0,23,0,101))/(3600*24);
    $dayssincelast =~ s/\..*$//;
    my $totalcomics = 220;
    
    my $comicnum = ($dayssincelast - $daysago)%$totalcomics;

    my $stripnum = 329+$comicnum;
    my $archive = "before/";
    if ($comicnum <115) {
    } elsif ($comicnum < 216) {
      $stripnum = 557+$comicnum-115;
      $archive = "then/";
    } elsif ($comicnum < 217) {  
      $stripnum = 802+$comicnum-216;
      $archive = "then/";
    } else {
      $stripnum = 858+$comicnum-217;
      $archive = "now/";
    }  
    my $page = "$archive"."0".$stripnum.".html";
    
    my $rec = {
	'title' => "Out Of Fika",
	'author' => "Chris Muse",
	'main' => "http://www.modernhair.net/fika/index.html",
	'archives' => "http://www.modernhair.net/fika/archys.html",
	'base' => "http://www.modernhair.net/fika/",
	'page' => $page,
    'size' => [720,267],
    };

    $rec->{'func'} = sub {
 	 my $text = shift;
     my @relurls = ();
     if ($stripnum  == 442) {$stripnum = 443};
  	  #repeatedly match and replace.  
          while (1) {
           if ($text =~ s/src="(strips\/.*?$stripnum\w?\.((:?jpg)|(:?gif)|(:?png)))"//i) {
              push(@relurls,$archive.$1);
              $rec->{'type'} = $2;
            } else {
              last;
            }
          }
      return reverse @relurls;
    };

    return $rec;
}

1;
