<%!
	import se.datadosen.util.*;
	// Make links to sibling directories that contain an index.html file
	void slideSiblingLinks() {
		File[] dirs = outputDirectory.getParentFile().listFiles(new FileFilter() {
			public boolean accept(File f) {
				return f.isDirectory() && new File(f, "index.html").exists();
			}
		});
		for (int i=0; i<dirs.length; i++) {
			out.println("\t\t\t\t<td class=\"tabspace\"></td>");
			String name = dirs[i].getName();
			out.println("\t\t\t\t<td valign=\"middle\" class=\"tab" + (name.equals(title) ? " activetab" : "") + "\">" +
			"<a href=\"../../" + name + "/index.html\">" + name + "</a></td>");
		}
	}

	void thumbLinks() {
		if (nThumbs == void) nThumbs = 5;	// Default
		int curr = imageNum-1;
		int start = 0;
		if (nThumbs < totalImages) {
			start = curr-nThumbs/2;
			if (start < 0) start = 0;
			else if (start+nThumbs >= totalImages) start = totalImages-nThumbs;
		}
		for (int i=start; (i<start+nThumbs) && (i<totalImages); i++) {
			Map vars = (Map)fileVariables.get(files[i]);
			out.print("\t\t\t\t<tr><td>");
			out.print("<a href=\"" + vars.get("currentPage") + "\">" +
			 "<img border=0 src=\"" + vars.get("thumbPath") + "\" alt=\"\"></a>");
			out.println("</td></tr>");
		}

	}
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
	<TITLE>$title</TITLE>
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=$textEncoding">
	<link href="$stylePath" rel="stylesheet" type="text/css">
</HEAD>

<BODY style="margin: 0">

<TABLE WIDTH=660 BORDER=0 CELLPADDING=0 CELLSPACING=0>
	<TR>
		<TD COLSPAN=4 id="toparea"></TD>
	</TR>
	<TR>
		<TD COLSPAN=4 align="right" id="tabarea">
			<table BORDER=0 CELLPADDING=0 CELLSPACING=0>
				<tr>
<%= slideSiblingLinks() %>
					<td class="tabmargin"></td>
				</TR>
			</TABLE>
		</TD>
  </TR>
	<TR>
		<TD id="leftarea"></TD>
		<TD id="navarea">
			<TABLE BORDER=0>
<%= thumbLinks() %>
			</TABLE>
		</TD>
		<TD id="imagearea">
			<CENTER>
			
			<!-- Image, maybe with link to original -->
			<ja:if exists=originalPath>
				<a href="$originalPath">
					<img src="$imagePath" width="$imageWidth" height="$imageHeight" border=0 alt="$label">
				</a>
			</ja:if>
			<ja:else>
				<img src="$imagePath" width="$imageWidth" height="$imageHeight" alt="$label">
			</ja:else>

			<!-- Always display comment below image (if exists) -->
			<ja:if exists="comment">
				<br>
				<div class="comment">$comment</div>
			</ja:if>
			</CENTER>
			
		</TD>
		<TD id="rightarea">
		</TD>
	</TR>
	<TR>
		<TD COLSPAN=4 id="bottomarea"></TD>
	</TR>
</TABLE>
<ja:include page="footer.inc" />
</BODY>
</HTML>