<%-- 
  ExhibitPlus V1.4a 25.10.2005. Author: Mark Fyvie. Official site: http://exhibitplus.fyvie.net

  ****************************************************************************************************************
  Please take note: If you plan to modify this skin, including modifications which may affect the resulting HTML:
   
  The output from this skin has been authored as XHTML 1.0 - this is a very strict DOCTYPE.
   
  Ensure that you do *NOT* use depreciated HTML elements, and that any modifications you make conform to XHTML 1.0
  If you have modified the skin, please check your generated pages at validator.w3.org to ensure compliance!
  **************************************************************************************************************** --%>
<%
	if (slideShowDelay == void) slideShowDelay = 4;
	if (slideShowContinuous == void) slideShowContinuous = false;
  	if (iconSet == void) iconSet = "default";
	if (keyboardShortcuts == void) keyboardShortcuts = true;

	if (resSubPath != void) resPath = resPath + "/" + resSubPath;

	buttonSet = (iconSet.equalsIgnoreCase("default") ? album.get("BUTTON_SET") : iconSet);
	originalPage2 = "orig2_"+fName+engine.getPageExtension();

	import java.util.*;
  	import se.datadosen.util.*;

	// We save the label variable to fName, because we may change the label value using various config files
	fName = label;
	// Now check to see if the user wants to use a different label for their photo by checking for an entry in titles.properties, or a text file named with the same name as the filename

      // If meta.properties exists in the image directory and contains
      // a description of the folder, display it with the variable descript.
      File propsFile = new File(imageDirectory, "titles.properties");
      if (propsFile.exists()) {
        Map props = IO.readMapFile(propsFile);
        String newTitle = props.get(fileName);
        if (newTitle != null && newTitle.length() >0) label = newTitle;
	} 

	// If a text file with the same name as an image exists, use the contents of this for the image comment and/or label instead
  	File cFile = new File(imageDirectory, fName+".txt");
  	if (cFile.exists()) {
  	  Map captions = IO.readMapFile(cFile);
  	  String text = (String)captions.get("comment");
  	  if (text != null && text.length()> 0) comment = text;
  	  String text = (String)captions.get("title");
  	  if (text != null && text.length()> 0) label = text;
  	}
		
// Allow variables to be overridden on a per folder basis (see below)
%>
<ja:include page = "variables.inc"></ja:include>
<%
//Double check and initalise user variables if they are not present (e.g. running from command line, or if some problem with onload.bsh) 
if (fullScreenButtons == void) fullScreenButtons = true;
if (jumpDirectFullscreen == void) jumpDirectFullscreen = false;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$language">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=$textEncoding" />
<meta name="Keywords" content="photo album,gallery,photo gallery,digital,photo,gallery,online,exhibitplus_v_onepointfour" />
<title>${label}</title>
<link href="${resPath}/basestyle.css" rel="stylesheet" />
<link href="${resPath}/$style" rel="stylesheet" />
<!-- Include styles.inc from root image directory if present -->
<ja:include page="$rootPath/styles.inc"></ja:include>
<ja:if test="<%=keyboardShortcuts%>">
	<script type="text/javascript">
	<!--
	var nextPageUrl = "<% if (imageNum == totalImages ) ( (slideShowContinuous) ? out.print("orig_$firstPage") : out.print("#") ); else  out.print("orig_$nextPage");%>";
	var prevPageUrl = "<% if (imageNum == 1 ) ( (slideShowContinuous) ? out.print("orig_$lastPage") : out.print("#") ); else out.print("orig_$previousPage");%>";
	var indexPageUrl = "$closeupPath";
	var firstPageUrl = "orig_$firstPage";
	var lastPageUrl = "orig_$lastPage";
 	var zoomPageUrl = "<%="orig2_"+fName+engine.getPageExtension()%>";
	var isSlideShow = true;
	-->
	</script>
	<script type="text/javascript" src="${resPath}/keyboard.js">
	</script>
	<script type="text/javascript" src="${resPath}/navslideorig.js">
	</script>
<%= out.print("</" + "head>") %>
<body onload="initPage();initKeyboard();">
</ja:if>
<ja:else>
<%= out.print("</" + "head>") %>
<body onload="initPage();">
</ja:else>

<script type="text/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('orig_slideShow', 'true');
}
 
function moveOn() {
<%
if (nextPage != void || slideShowContinuous) {
	out.print("	document.location.href = \"");
	if (imageNum == totalImages )  out.print("orig_$firstPage"); else  out.print("orig_$nextPage");	
	out.print("#theSlide" + "\";");
}
%>
}
function stopSlideShow() {
	try {
		clearTimeout(timeout);
	} catch(e) {
	}
	saveCookie('orig_slideShow', '', -1);
}
 
var timeout = null;
function initPage() {
	if (readCookie('orig_slideShow') == 'true') {
	<ja:if test="<%=!(imageNum == totalImages) || slideShowContinuous %>">
		document.getElementById('navButtons').style.visibility="hidden";
		timeout = setTimeout('moveOn()', <%=slideShowDelay * 1000%>);
	</ja:if>
	<ja:else>
		saveCookie('orig_slideShow', '', -1);
		document.getElementById('navButtons').style.visibility="visible";
	</ja:else>
	}
}
-->
</script>

<div id="navButtons" style="position: absolute; left: 0; bottom: 0; visibility: hidden">
<ja:if test="${fullScreenButtons}">
<script type="text/javascript">
	<!--
	if (readCookie('orig_slideShow') != 'true') {
		document.getElementById('navButtons').style.visibility="visible";
	}
	-->
</script>
<!-- First button -->
<ja:if exists="previousPage">
        <a href="orig_$firstPage"><img src="${resPath}/${buttonSet}/first.gif" alt="$text.firstPage" title="$text.firstPage" /></a>
</ja:if>
<ja:else>
	<img src="${resPath}/${buttonSet}/first_disabled.gif" alt="$text.atFirstPage" title="$text.atFirstPage" />
</ja:else>
 
<!-- Previous button -->
<ja:if exists="previousPage">
	<a href="orig_$previousPage"><img src="${resPath}/${buttonSet}/previous.gif" alt="$text.previousPage" title="$text.previousPage" /></a>
</ja:if>
<ja:else>
	<img src="${resPath}/${buttonSet}/previous_disabled.gif" alt="$text.atFirstPage" title="$text.atFirstPage" />
</ja:else>
 
<!-- Index button -->
<a href="<ja:if test="${jumpDirectFullscreen}">../$indexPage</ja:if><ja:else>$closeupPath</ja:else>"><img src="${resPath}/${buttonSet}/index.gif" alt="$text.goBack" title="$text.goBack" /></a>
 
<!-- Next button -->
<ja:if exists="nextPage">
	<a href="orig_$nextPage"><img src="${resPath}/${buttonSet}/next.gif" alt="$text.nextPage" title="$text.nextPage" /></a>
</ja:if>
<ja:else>
	<img src="${resPath}/${buttonSet}/next_disabled.gif" alt="$text.atLastPage" title="$text.atLastPage" />
</ja:else>
 
<!-- Last button -->
<ja:if exists="nextPage">
        <a href="orig_$lastPage"><img src="${resPath}/${buttonSet}/last.gif" alt="$text.lastPage" title="$text.lastPage" /></a>
</ja:if>
<ja:else>
	<img src="${resPath}/${buttonSet}/last_disabled.gif" alt="$text.atLastPage" title="$text.atLastPage" />
</ja:else>

<!-- Zoom button -->
<a href="${originalPage2}"><img src="${resPath}/${buttonSet}/zoom.gif" alt="$text.zoom" title="$text.zoom" /></a>
 
<!-- Slide show button -->
<ja:if test="<%=!(imageNum == totalImages) || slideShowContinuous %>">
	<script type="text/javascript">
	<!--
	if (readCookie('orig_slideShow') == 'true') {
		document.write("	<a onclick=\"stopSlideShow(); document.location.reload(false); return false;\" href=\"#\"><img src=\"${resPath}/${buttonSet}/slideshowstop.gif\" alt=\"$text.stopSlideShow\" title=\"$text.stopSlideShow\" /></" + "a>");
	} else {
		document.write("	<a onclick=\"setSlideShowCookie();\" href=\"<% if (imageNum == totalImages )  out.print("orig_$firstPage"); else  out.print("orig_$nextPage");%>\"><img src=\"${resPath}/${buttonSet}/slideshowstart.gif\" alt=\"$text.startSlideShow\" title=\"$text.startSlideShow\" /></" + "a>");
	}
	-->
	</script>
</ja:if>
</ja:if>
</div>

<div> 
<a href="<ja:if test="${jumpDirectFullscreen}">../$indexPage</ja:if><ja:else>$closeupPath</ja:else>"><img src="$originalPath" width="100%" alt="" /></a>
</div>
</body>
</html>

<%
	String originalPage2 = originalPath;	// Default if no extra template page
	File template = new File(skinDirectory, "originalslide2.htt");
	if (template.exists()) {
		originalPage2 = "orig2_"+fName+engine.getPageExtension();
		engine.processTemplateFile(template, new File(outputDirectory,"slides/"+originalPage2));
	}
%>
