<html>
<head>
<title><& crumbs, $path &></title>
<link rel="stylesheet" type="text/css" href="<% $base |h %>/gallery/main.css" 
 title="main">
<link rel="top" href="<% $base |h %>/">
<link rel="parent" href="./">
% if ($file ne $files[0]) {
<link rel="first" href="<% $files[0] |h %>">
% }
% if ($file ne $files[-1]) {
<link rel="last" href="<% $files[-1] |h %>">
% }
% if ($prev) {
<link rel="prev" href="<% $prev |h %>">
% }
% if ($next) {
<link rel="next" href="<% $next |h %>">
% }
% if ($m->comp('config')->{search_dbi_args}) {
<link rel="search" href="<% $base |h %>/gallery/search.html">
% }
% if ($link) {
<link rel="prefetch" href="<% $name |h %>">
% }
</head>
<body bgcolor="#ffffff">
<p>
<div align="center">
<table width="<% $w %>" border="0" cellpadding="0" cellspacing="0">
 <tr bgcolor="#ffffcc">
  <td align="left">
   <font style="font-weight: bold"><& crumbs, $path, 1 &></font>
  </td>
  <td align="right"><font style="font-weight: bold">
    &nbsp;&nbsp;&nbsp;[<a href="<% $name |h %>.info.html"
	onClick="window.open('<% $name |h %>.info.html','Info','width=345,height=345,scrollbars,resizable');return false">info</a>]
  </font></td>
 </tr>
 <tr>
  <td colspan="2" align="center">\
% if ($link) {
<a href="<% $name |h %>">\
% }
<img width="<% $w %>" height="<% $h %>" border="0" src="<% $file |h %>">\
% if ($link) {
</a>\
% }
</td>
 </tr>
% if (length($comment)) {
 <tr>
  <td colspan="2" bgcolor="#ffffcc" align="center">
   <% $comment %>
  </td>
 </tr>
% }
</table>
</div>
</body>
</html>
<%init>
    my ($base, $path, $comment, $w, $h, $file, $dir, @files, $prev, $next, 
	$match, $link, $name);

    ($path) = @_;

    $base = dirname(dirname($m->current_comp->dir_path));

    $dir = $ENV{DOCUMENT_ROOT} . dirname($path);
    $name = basename($path);

    $comment = $m->comp('comment', $path);
    ($file, $w, $h) = $m->comp('view', $path);

    ## get files in dir
    chdir($dir) || die "couldn't cd to '$path': $!";

    opendir(DIR, '.');
    @files = map { "$_.html" } sort grep(/\.(jpg|png|gif)$/, readdir(DIR));
    closedir(DIR);

    $match = "$name.html";
    for (0..$#files) {
	next unless $files[$_] eq $match;
	$next = $files[$_+1] if $_ < $#files;
	$prev = $files[$_-1] if $_ > 0;
	last;
    }

    $link = ($name ne $file);
</%init>
