<%
  import se.datadosen.util.*;

  String sOutput    		= "";
  String jsPlugins   		= "";
  String jsFoldState 		= "";
  String sInformationPanel	= "";
  String sActivitiesPanel	= "";
  SmartResourceBundle texts	= null;

%><ja:if test="$useFolderView"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"></ja:if><ja:else><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></ja:else>
<html>
<head>
<!-- saved from url=(0013)about:internet -->
	<meta http-equiv="content-type" content="text/html; charset=$textEncoding" />
	<meta name="description" content="Album generated with $generator and the XP skin v2.2. More skins available at http://jrepository.engblom.org.">
	<title>$label</title>
	<link href="$stylePath" rel="stylesheet">
	<ja:if exists="nextPage"><link rel="next" href="$nextPage"></ja:if>
	<ja:if exists="previousPage"><link rel="prev" href="$previousPage"></ja:if>
	<link rel="index" href="../$indexPage">
<%
sOutput = "";
// If we are using plug-ins - include their CSS-files
if (Plugins != null && Plugins != void) {
	String[] arrPlugins = Plugins.split("#");
	for (int i = 0; i < arrPlugins.length; i++) {
		// Read localized strings for plug-in
		texts = getResources(arrPlugins[i]);
		
		File fCSS = new File(resDirectory, arrPlugins[i] + "/styles.css");
		if (fCSS.exists())
			sOutput += "	<link href=\"" + resPath + "/" + arrPlugins[i] + "/styles.css\" rel=\"stylesheet\">";
		File fHead = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/head.htt");
		if (fHead.exists())
			sOutput += engine.processTemplate(IO.readTextFile(fHead));
		fHead = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/headSlide.htt");
		if (fHead.exists())
			sOutput += engine.processTemplate(IO.readTextFile(fHead));
	}
}
%><%=sOutput%>
	<ja:if exists="nextPage"><link rel="prefetch" href="$nextPage"></ja:if>
<script language="javascript" src="$resPath/x.js"></script>
<script language="JavaScript">
function saveCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000))
		var expires = "; expires="+date.toGMTString()
	}
	else expires = ""
	document.cookie = name+"="+value+expires+"; path=/"
}
function readCookie(name) {
	var nameEQ = name + "="
	var ca = document.cookie.split(';')
	for(var i=0;i<ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length)
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
	}
	return '';
}
function setSlideShowCookie() {
	saveCookie('slideShow', 'true');
}

<ja:if test="$useFolderView">
function toggleNode(index) {
	var sItem    = '|' + index + '|';
	var sFolders = readCookie('Folders');
	var lStart   = sFolders.indexOf(sItem);
	if (lStart == -1) {
		sFolders += sItem;
		document.images['img' + index].src = '$resPath/TreeMinus.gif';
		document.getElementById('folder' + index + 'c').style.display = 'block';
	} else {
	    sFolders = sFolders.substring(0, lStart) + sFolders.substring(lStart + sItem.length, sFolders.length);
		document.images['img' + index].src = '$resPath/TreePlus.gif';
		document.getElementById('folder' + index + 'c').style.display = 'none';
	}
	saveCookie('Folders', sFolders);
}
</ja:if>

function moveOn() {
<%
se.datadosen.util.Replacer r = new se.datadosen.util.Replacer();
r.add("\'","\\\'");
if (nextPage != void) 
	out.print("	document.location.href = '" + r.replace(nextPage) + "';");
%>
}
function stopSlideShow() {
	try {
		clearTimeout(timeout);
	} catch(e) {
	}
	saveCookie('slideShow', '', -1);
}

var timeout = null;
function toggleVisibility(div) {
	try {
		var elem = xGetElementById(div);
		if (!elem) 
			return;
			
		if (elem.style.overflow == '' || elem.style.overflow == 'visible') {
			saveCookie(div + 'Overflow', 'hidden', 1000);
		} else {
			saveCookie(div + 'Overflow', 'visible', 1000);
		}
		setFoldState();
	} catch (ex) {}
}

function setFoldState() {
	try {
		switch (readCookie('divImageActivityOverflow')) {
			case '': return;
			case 'hidden':
				xHeight('divImageActivity', 32);
				xGetElementById('divImageActivity').style.overflow = 'hidden';
				xGetElementById('tdImageActivity').setAttribute("class", "ImagePaneHeaderClosed");
				xGetElementById('tdImageActivity').setAttribute("className", "ImagePaneHeaderClosed");
				break;
			case 'visible':
				xGetElementById('divImageActivity').style.height = '';
				xGetElementById('divImageActivity').style.overflow = 'visible';
				xGetElementById('tdImageActivity').setAttribute("class", "ImagePaneHeader");
				xGetElementById('tdImageActivity').setAttribute("className", "ImagePaneHeader");
				break;
		}
		switch (readCookie('divInfoActivityOverflow')) {
			case '': return;
			case 'hidden':
				xHeight('divInfoActivity', 23);
				xGetElementById('divInfoActivity').style.overflow = 'hidden';
				xGetElementById('tdInfoActivity').setAttribute("class", "InfoPaneHeaderClosed");
				xGetElementById('tdInfoActivity').setAttribute("className", "InfoPaneHeaderClosed");
				break;
			case 'visible':
				xGetElementById('divInfoActivity').style.height = '';
				xGetElementById('divInfoActivity').style.overflow = 'visible';
				xGetElementById('tdInfoActivity').setAttribute("class", "InfoPaneHeader");
				xGetElementById('tdInfoActivity').setAttribute("className", "InfoPaneHeader");
				break;
		}
		
		pluginFoldState();
	} catch (ex) {}
}

function initPage() {
	if (readCookie('slideShow') == 'true') {
	<ja:if exists="nextPage">
		timeout = setTimeout('moveOn()', 4000);
	</ja:if>
	<ja:else>
		saveCookie('slideShow', '', -1);
	</ja:else>

	}
	setFoldState();
	resizeHandler();
<ja:if test="$useFolderView">	
	try {
		var sFolders = readCookie('Folders');
		if (sFolders.length > 0)
			sFolders = sFolders.substring(1,sFolders.length - 1);
		var arrFolders = sFolders.split('||');
		for (var i = 0; i < arrFolders.length; i++) {
			try {
				document.images['img' + arrFolders[i]].src = '$resPath/TreeMinus.gif';
				document.getElementById('folder' + arrFolders[i] + 'c').style.display = 'block';
			} catch (ex) {}
		}
		if (readCookie('ShowFolders') == 'true')
		    xLeft('divFolders', 0);
	} catch (e) {}
</ja:if>
<%
sOutput = "";
// If we are using plug-ins - include their onLoad js-files
if (Plugins != null && Plugins != void) {
	String[] arrPlugins = Plugins.split("#");
	for (int i = 0; i < arrPlugins.length; i++) {
		texts = getResources(arrPlugins[i]);
		sOutput += getOnLoadJavascript(arrPlugins[i], false);
	}
	if (sOutput != "") {
		sOutput = "try {\n" + sOutput + "} catch (ex) {}\n";
	}
}
%><%=sOutput%>
}
function resizeHandler() {
<ja:if test="$useFolderView">	
    try {
		xHeight('divTree', xClientHeight()-25);
	} catch (e) {}
</ja:if>
	xHeight('divActivity', parseInt(xClientHeight(),10) + parseInt(xScrollTop(),10));
}
window.onresize = resizeHandler
window.onscroll = resizeHandler
</script>
</head>
<body onload="initPage();" ID="slide">
<ja:if test="<%=!printing.equals("none")%>"><ja:include page="printing.inc" /></ja:if>
<% sOutput = ""; %>
<ja:if exists="Plugins">
<%
String[] arrPlugins = Plugins.split("#");
for (int i = 0; i < arrPlugins.length; i++) {
	// Read localized strings for plug-in
	texts = getResources(arrPlugins[i]);

	// Panel common to index and slide pages
	File plg = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/panel.htt");
	if (plg.exists()) {
		sOutput += renderPanel("Panel" + i.toString(), getText("panelTitle"), engine.processTemplate(IO.readTextFile(plg))) + "<br/>";
		jsFoldState += renderFoldState("Panel" + i.toString());
	}
	// Panel exclusive to slide page
	plg = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/panelSlide.htt");
	if (plg.exists()) {
		sOutput += renderPanel("PanelSlide" + i.toString(), getText("panelSlideTitle"), engine.processTemplate(IO.readTextFile(plg))) + "<br/>";
		jsFoldState += renderFoldState("PanelSlide" + i.toString());
	}
	// Common javascript file
	plg = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/javascript.js");
	if (plg.exists())
		jsPlugins += IO.readTextFile(plg);
	// Javascript file exclusive to slide page
	plg = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/javascriptSlide.js");
	if (plg.exists())
		jsPlugins += IO.readTextFile(plg);

	// Get reference to plugin directory
	File pluginDir = new File(skinDirectory, "plugins/" + arrPlugins[i]);
	
	// Evaluate all templates starting with "slide_"
	File[] templates = getSlideTemplates(pluginDir);
	for (int j = 0; j < templates.length; j++) {
		String sName = templates[j].getName();
		File newFile = new File(outputDirectory, engine.getSlideDirectory() + "/" + IO.baseName(currentFile.getName()) + "_" + sName.substring(6, sName.length() - 4) + engine.getPageExtension());
		engine.processTemplateFile(templates[j], newFile);
	}

	// Adding to activities panel
	plg = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/panelActivities.htt");
	if (plg.exists())
		sActivitiesPanel += renderPanelRow(engine.processTemplate(IO.readTextFile(plg)), "Image");
	plg = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/panelActivitiesSlide.htt");
	if (plg.exists())
		sActivitiesPanel += renderPanelRow(engine.processTemplate(IO.readTextFile(plg)), "Image");

	// Adding to information panel
	plg = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/panelInformation.htt");
	if (plg.exists())
		sInformationPanel += renderPanelRow(engine.processTemplate(IO.readTextFile(plg)), "Info");
	plg = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/panelInformationSlide.htt");
	if (plg.exists())
		sInformationPanel += renderPanelRow(engine.processTemplate(IO.readTextFile(plg)), "Info");
}
%>
</ja:if>
<div id="divActivity">
<div id="divImageActivity">
<table border="0" cellspacing="0" cellpadding="0" width="185">
<tr>
	<td colspan="3" width="185" class="ImagePaneHeader" id="tdImageActivity" onclick="toggleVisibility('divImageActivity'); return false;">$text.imageActivities<img src="$resPath/1x1.gif" border="0" alt="" width="1" height="21" style="visibility: hidden;" /></td>
</tr>
<tr>
	<td width="1" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="ImagePaneRow"><a href="../$indexPage" class="ImagePaneRow"><img src="$resPath/FolderUp.gif" border="0" align="absmiddle" style="margin-right: 5px;"/>$text.backToIndexPage</a></td>
	<td width="1" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
<ja:if exists="nextPage">
<script language="JavaScript">
if (readCookie('slideShow') == 'true') {
	document.write("<tr>" +
	"	<td width=\"1\" class=\"ImagePaneFrame\"><img src=\"$resPath/1x1.gif\" width=\"1\" height=\"1\"/></td>" +
	"	<td width=\"183\" class=\"ImagePaneRow\"><a onclick=\"stopSlideShow(); document.location.reload(false); return false;\" href=\"#\" class=\"ImagePaneRow\"><img src=\"$resPath/Slideshow.gif\" border=\"0\" align=\"absmiddle\" style=\"margin-right: 5px;\"/>$text.stopSlideshow</a></td>" +
	"	<td width=\"1\" class=\"ImagePaneFrame\"><img src=\"$resPath/1x1.gif\" width=\"1\" height=\"1\"/></td>" +
	"</tr>");
} else {
	document.write("<tr>" +
	"	<td width=\"1\" class=\"ImagePaneFrame\"><img src=\"$resPath/1x1.gif\" width=\"1\" height=\"1\"/></td>" +
	"	<td width=\"183\" class=\"ImagePaneRow\"><a onclick=\"setSlideShowCookie();\" href=\"$nextPage\" class=\"ImagePaneRow\"><img src=\"$resPath/Slideshow.gif\" border=\"0\" align=\"absmiddle\" style=\"margin-right: 5px;\"/>$text.startSlideshow</a></td>" +
	"	<td width=\"1\" class=\"ImagePaneFrame\"><img src=\"$resPath/1x1.gif\" width=\"1\" height=\"1\"/></td>" +
	"</tr>");
}
</script>
</ja:if>
<ja:if test="<%=!printing.equals("none")%>">
<tr>
	<td width="1" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="ImagePaneRow">
	
	<a onclick="stopSlideShow();" href="javascript:submitOrderForm()" class="ImagePaneRow"><img src="$resPath/OrderPrints.gif" border="0" align="absmiddle" style="margin-right: 5px;"/>$text.orderPrints</a>
	
	</td>
	<td width="1" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="nextPage">
<tr>
	<td width="1" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="ImagePaneRow"><a onclick="stopSlideShow();" href="$nextPage" class="ImagePaneRow"><img src="$resPath/Forward.gif" border="0" align="absmiddle" style="margin-right: 5px;"/>$text.nextImage</a></td>
	<td width="1" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="previousPage">
<tr>
	<td width="1" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="ImagePaneRow"><a onclick="stopSlideShow();" href="$previousPage" class="ImagePaneRow"><img src="$resPath/Back.gif" border="0" align="absmiddle" style="margin-right: 5px;"/>$text.previousImage</a></td>
	<td width="1" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if test="$useFolderView">
<tr>
	<td width="1" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="ImagePaneRow"><a onclick="saveCookie('ShowFolders', 'true'); xLeft('divFolders',0); return false;" href="#" class="ImagePaneRow"><img src="$resPath/IconFolderOpen.gif" border="0" align="absmiddle" style="margin-right: 5px;"/>$text.folders</a></td>
	<td width="1" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<%=sActivitiesPanel%>
<tr>
	<td width="185" colspan="3" class="ImagePaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</table>
</div>
<div id="divInfoActivity">
<table border="0" cellspacing="0" cellpadding="0" width="185" ID="Table1">
<tr>
	<td colspan="3" width="185" class="InfoPaneHeader" id="tdInfoActivity" onclick="toggleVisibility('divInfoActivity'); return false;">$text.information</td>
</tr>
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow"><strong>$fileName</strong></td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
<ja:if exists="formatName">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$formatName</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="originalWidth">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.resolution: $originalWidth&times;$originalHeight</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.fileSize: $fileSize $text.bytes</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.date: <ja:if exists="originalDate">$originalDate</ja:if><ja:else>$fileDate</ja:else></td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
<ja:if exists="flash">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.flash: $flash</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="focalLength">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.focalLength: $focalLength</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="exposureTime">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.exposureTime: $exposureTime</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="aperture">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.aperture: $aperture</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="focusDistance">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.focusDistance: $focusDistance</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="meteringMode">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.meteringMode: $meteringMode</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="cameraMake">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.camera: $cameraMake</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="cameraModel">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.model: $cameraModel</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<ja:if exists="sensorType">
<tr>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
	<td width="183" class="InfoPaneRow">$text.sensorType: $sensorType</td>
	<td width="1" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</ja:if>
<%=sInformationPanel%>
<tr>
	<td width="185" colspan="3" class="InfoPaneFrame"><img src="$resPath/1x1.gif" width="1" height="1"/></td>
</tr>
</table>
</div>
<%=sOutput%>
<script language="javascript">
<%=jsPlugins%>
function pluginFoldState() {
<%=jsFoldState%>
}
</script>
<div id="divJAlbum">
Powered by <a href="$generatorUrl" target="_blank"><img src="$resPath/JAlbum.gif" border="0" alt="JAlbum" align="absmiddle"/></a>&nbsp;JAlbum
</div>
</div>
<div id="divMainSlideHeader">$fileName ($imageNum $text.of $totalImages)</div>
<div id="divMain" align="center">
<%
boolean	bReplaced = false;
sOutput = "";
// If we are using plug-ins - include their CSS-files and evaluate any head.htt files found
if (Plugins != null && Plugins != void) {
	String[] arrPlugins = Plugins.split("#");
	for (int i = 0; i < arrPlugins.length; i++) {
		// Read localized strings for plug-in
		texts = getResources(arrPlugins[i]);

		File fReplacement = new File(skinDirectory, "plugins/" + arrPlugins[i] + "/slideReplacement.htt");
		if (fReplacement.exists()) {
			bReplaced = true;
			sOutput += engine.processTemplate(IO.readTextFile(fReplacement));
		}
	}
}
%><%=sOutput%>
<ja:if test="<%=!bReplaced%>">
<ja:if exists="originalPath">
<a href="$originalPath" target="_blank"><img src="$imagePath" width="$imageWidth" height="$imageHeight" border="0"/></a>
</ja:if>
<ja:else>
<img src="$imagePath" width="$imageWidth" height="$imageHeight">
</ja:else>
</ja:if>
<!-- Always display comment below image (if exists) -->
<ja:if exists="comment">
<br>
$comment
</ja:if>
<ja:else>
<br>
<ja:include page="<%= new File(imageDirectory, label+".txt") %>" />
</ja:else>
</div>
<ja:if test="$useFolderView"><ja:include page="Tree.htt"/></ja:if>
</body>
</html>
