package Edynn;







BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    # set the version for version checking
    $VERSION     = 0.01;

    
    # inherit stuff from Exporter.
    @ISA         = qw(Exporter);

    # Export these functions
    @EXPORT      = qw(&FileList &ListPages &ImageList &ImagePager);
}

sub FileList {
	ImageList();
}

sub ImageList {
	my (@files, $file);
	open $file, "image.index" or die "Can't open image.index, $!";
	@files = <$file>;
	close $file;
	map chomp, @files;

	reverse @files;
}

sub ImagePager {
	my @files = ImageList();
	new Pager({items => \@files, per_page => 12, page => shift || 1});
}

sub ListPages {
	my ($pager, $fmt) = @_;
	my $pages = $pager->pages;
	my $count = 0;
	my @return = ();

	
	while ($count++ < $pages) {
		if ($count == $pager->{this_page}) {
			push(@return, sprintf($fmt, $count));
		} else {
			push (@return, "<a href=\"index.html?page=$count\">".
			sprintf($fmt, $count) . "</a>");
		}
	}

	return join(' ', @return);
}


1;
