<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp   "&#160;">
<!ENTITY copy   "&#169;">
]>
<!--

-->
<xsl:stylesheet version="3.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:ou="http://omniupdate.com/XSL/Variables"
	xmlns:fn="http://omniupdate.com/XSL/Functions"
	xmlns:ouc="http://omniupdate.com/XSL/Variables"
	xmlns="http://www.w3.org/1999/xhtml"
	exclude-result-prefixes="xsl xs ou fn ouc"
	expand-text="yes">

	<!-- Header Gallery -->

	<xsl:template name="header-gallery">
		<xsl:comment> SLIDESHOW SCRIPT </xsl:comment>

		<input type="hidden" name="ctl00$ContentBody$RotationImage" id="ctl00_ContentBody_RotationImage" />

		<div id="ctl00_ContentBody_cb_slideshow_data">
			<xsl:choose>
				<xsl:when test="ou:multiedit-field('header-type') = 'gallery'">
					<xsl:apply-templates select="ou:multiedit-field('header-gallery')" mode="header-gallery" />
				</xsl:when>
				<xsl:when test="ou:multiedit-field('header-type') = 'section' and ou:multiedit-props-field('header-type') = 'gallery'">
					<xsl:choose>
						<xsl:when test="string-length(ou:multiedit-props-field('header-gallery')) eq 0">
							<xsl:call-template name="temp-head-gallery" />
						</xsl:when>
						<xsl:otherwise>
							<xsl:apply-templates select="ou:multiedit-props-field('header-gallery')" mode="header-gallery" />
						</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<xsl:otherwise />
			</xsl:choose>
		</div>
	</xsl:template>
	
	<!-- 07/28/2016	-	Support for migrated images. Intended for temp use. (cls) -->
	<xsl:template name="temp-head-gallery">
		<xsl:variable name="asset" select="ou:pcf-param('header-gallery', doc($props-path))"/>	
		<xsl:if test="not($asset/@asset_id!='') and doc($props-path)/descendant::ouc:div[@label='temp-gallery']/descendant::img">
			<xsl:variable name="props-doc" select="doc($props-path)" />
			<div id="artimg">
				<img src="{$props-doc/ouc:div[@label='temp-gallery']/descendant::img[1]/@src}" alt="{$props-doc/ouc:div[@label='temp-gallery']/descendant::img[1]/@alt}" title="{$props-doc/ouc:div[@label='temp-gallery']/descendant::img[1]/@title}">
					<xsl:attribute name="style" select="'width:100%;'" />
				</img>
			</div>
			<div id="vt_col2_nav">
				<div id="vt_col2_nav_left">
					<a href="{ou:pcf-param('vt-asset-left')}">
						<img class="cleardecoration" src="/_resources/images/GlassArrows-LeftSingle.jpg" alt="left arrow"/>
					</a>
				</div>
				<!-- 07/22/2016	- if at least 2, show thumbs -->
				<xsl:if test="$props-doc/descendant::ouc:div[@label='temp-gallery']/descendant::img[2]">
					<div id="vt_col2_nav_thumbs">
						<xsl:for-each select="$props-doc/descendant::ouc:div[@label='temp-gallery']/descendant::img">
							<a href="#" class="toggleopacity" onmouseover="javascript:ChangePic('{@src}','{@title}','artimg', this);return false;" onfocus="javascript:ChangePic('{@url}','{@title}','artimg', this);return false;">
								<img width="45" height="45" style="margin: 1px 5px 0px 0px;" src="{@src}" alt="{@alt}" title="{@title}"/>
							</a>
						</xsl:for-each>
					</div>
				</xsl:if>
				<div id="vt_col2_nav_right">
					<a href="{ou:pcf-param('vt-asset-right')}">
						<img class="cleardecoration" src="/_resources/images/GlassArrows-RightSingle.jpg" alt="Next" title="Next"/>
					</a>
				</div>
			</div>
		</xsl:if>
	
	</xsl:template>

	<xsl:template match="gallery" mode="header-gallery">
		<script type="text/javascript">
			var imgtitlelist = new Array(<xsl:apply-templates select="images/image" mode="slide-title" />);
		</script>
		<script type="text/javascript">
			var imgsrclist = new Array(<xsl:apply-templates select="images/image" mode="slide-url" />);
		</script>
	</xsl:template>

	<xsl:template match="image" mode="slide-title">'{title}'<xsl:if test="position() != last()">,</xsl:if></xsl:template>
	<xsl:template match="image" mode="slide-url">'{@url}'<xsl:if test="position() != last()">,</xsl:if></xsl:template>

	<!-- Standard Galleries -->

	<xsl:template match="gallery">
		<xsl:param name="gallery-type" select="ou:pcf-param('gallery-type')" />

		<xsl:choose>
			<xsl:when test="$gallery-type = 'pretty-photo'">
				<ul class="thumbnails">
					<xsl:apply-templates select="images/image" mode="pretty-photo">
						<xsl:with-param name="gallery-id" select="@asset_id" />
					</xsl:apply-templates>
				</ul>
			</xsl:when>
			
			<xsl:when test="$gallery-type = 'timeline'">
				<script language="javascript" type="text/javascript">
					// do not make width or height greater than 500
					var max_width = 500;
					var max_height = 500;
				</script>
				<style>
					.gallery_body {{ width:710px; text-align:center; }}
					.gallery_thumbs {{ margin:0px 50px 10px 50px; }}
					.listbox_position {{ position:absolute; top:-50px; }}
				</style>
				<div class="gallery_body">
					<div class="gallery_thumbs">
						<xsl:for-each select="images/image">
							<a href='' class='toggleopacity' style='margin-right:5px'><img width='50' height='50' src='{thumbnail/@url}' alt='{title}' onclick='javascript:GetGalleryItem({position() - 1}, this);event.returnValue = false; return false;'></img></a>
						</xsl:for-each>
					</div>
					<div class="clear"></div>
					<div id="vt_col2_nav_left">
						<input type="image" src="/_resources/images/GlassArrows-LeftSingle.jpg" alt="Previous" title="Previous" onclick="javascript:GetGalleryItem('','prev', this);event.returnValue = false; return false;"/>
					</div>
					<div id="vt_col2_nav_right" style="vertical-align:top"> <!-- style over-ride -->
						<input  type="image" src="/_resources/images/GlassArrows-RightSingle.jpg" alt="Next" title="Next" onclick="javascript:GetGalleryItem('','next', this);event.returnValue = false; return false;"/>
					</div>
					<div id="gallery_img">
						<img src='{images/image[1]/@url}' alt='{images/image[1]/title}'></img>
					</div>
					<div class="clear"></div>
					<br />	
					<div id="gallery_caption" style="text-align:left">  <!-- style over-ride -->
						<xsl:if test="images/image[1]/title">
							<strong><xsl:value-of select="images/image[1]/title" /></strong>:
						</xsl:if>
						<xsl:value-of select="images/image[1]/caption" disable-output-escaping="yes" />
					</div>
				</div>
				
				<select size="4" name="ctl00$ContentBody$ListBox1" id="ctl00_ContentBody_ListBox1" class="listbox_position" style="height:0px;width:0px;">
					<xsl:for-each select="images/image">
						<option value="{@url}">
							<xsl:if test="position() = 1">
								<xsl:attribute name="selected">selected</xsl:attribute>
							</xsl:if>
							<xsl:value-of select="@url" />
						</option>
					</xsl:for-each>
				</select>
				
				<select size="4" name="ctl00$ContentBody$ListBox2" id="ctl00_ContentBody_ListBox2" class="listbox_position" style="height:0px;width:0px;">
					<xsl:for-each select="images/image">
						<option value="{description}">
							<xsl:if test="position() = 1">
								<xsl:attribute name="selected">selected</xsl:attribute>
							</xsl:if>
							<xsl:if test="title">
								<xsl:text>&lt;strong&gt;</xsl:text><xsl:value-of select="title" /><xsl:text>&lt;/strong&gt;:&nbsp;</xsl:text>
							</xsl:if>
							<xsl:value-of select="caption" />
						</option>
					</xsl:for-each>
				</select>
			</xsl:when>
			<xsl:otherwise>

				<div class="flex-nav-container">
					<div class="flexslider">
						<div class="slides">
						
							
							<xsl:apply-templates select="images/image" mode="flex-slider" />
								
					
						</div>
					</div>
				</div>

			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>

	<xsl:template match="image" mode="flex-slider">
		
		<div data-thumb="{@url}">
			<xsl:choose>
				<xsl:when test="link != ''">
					<a href="{link}">
						<img src="{@url}" alt="{title}" title="{title}" />
					</a>
				</xsl:when>
				<xsl:otherwise>
					<img src="{@url}" alt="{title}" title="{title}" />
				</xsl:otherwise>
			</xsl:choose>
			<xsl:if test="title != '' or description != ''">
				<p class="flex-caption">
					<xsl:choose>

						<xsl:when test="link != ''">
							<a href="{link}">
								<xsl:value-of select="title" />
								<xsl:if test="description != ''">
									- <xsl:value-of select="description" />
								</xsl:if>
							</a>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="title" />
							<xsl:if test="description != ''">
								- <xsl:value-of select="description" />
							</xsl:if>
						</xsl:otherwise>
					</xsl:choose>
					<xsl:comment> slide </xsl:comment>
				</p>
			</xsl:if>

		</div>
	</xsl:template>

	<xsl:template match="image" mode="pretty-photo">
		<xsl:param name="gallery-id" />

		<li>
			<a href="{@url}" rel="prettyPhoto[{$gallery-id}]" title="{title}"  class="thumbnail">
				<img src="{thumbnail/@url}" alt="{description}" style="height:{thumbnail/height}px; width:{thumbnail/width}px;"/>
			</a>
		</li>
	</xsl:template>

	<xsl:template match="gallery" mode="virtual-tour">
		<xsl:param name="button-right"/>
		<xsl:param name="button-left"/>

		<div id="artimg">
			<img src="{images/image[1]/@url}" alt="{images/image[1]/description}" title="{images/image[1]/title}">
				<xsl:attribute name="style" select="'width:100%;'" />
			</img>
		</div>
		<div id="vt_col2_nav">
			<div id="vt_col2_nav_left">
				<a href="{$button-left}">
					<img class="cleardecoration" src="/_resources/images/GlassArrows-LeftSingle.jpg" alt="left arrow"/>
				</a>
			</div>
			<!-- 07/22/2016	- if at least 2, show thumbs -->
			<xsl:if test="images//image[2]">
				<div id="vt_col2_nav_thumbs">
					<xsl:apply-templates select="images//image" mode="virtual-tour"/>
				</div>
			</xsl:if>			
			<div id="vt_col2_nav_right">
				<a href="{$button-right}">
					<img class="cleardecoration" src="/_resources/images/GlassArrows-RightSingle.jpg" alt="Next" title="Next"/>
				</a>
			</div>
		</div>
	</xsl:template>

	<xsl:template match="image" mode="virtual-tour">
		<a href="#" class="toggleopacity" onmouseover="javascript:ChangePic('{@url}','title','artimg', this);return false;" onfocus="javascript:ChangePic('{@url}','title','artimg', this);return false;">
			<img width="45" height="45" style="margin: 1px 5px 0px 0px;" src="{@url}" alt="{description}" title="{title}"/>
		</a>
	</xsl:template>

	<xsl:template match="gallery" mode="update-gallery">
		<div id="news_working_tabs"></div>
		<input type="hidden" name="ctl00$ContentBody$RotationImage" id="ctl00_ContentBody_RotationImage" />
		<input type="hidden" name="ctl00$ContentBody$RunSlideShow" id="ctl00_ContentBody_RunSlideShow" value="1" />

		<div id="gallery">

			<div id="image"></div>

			<div id="caption_ribbon">
				<div id="caption"></div>
			</div>
			<div id="credit"></div>

			<div id="gallery_wrapper">
				<div id="ctl00_ContentBody_cb_thumbs_news_and_working">

					<xsl:apply-templates select="images/image" mode="update-thumbnails" />

					<div id="slideEnd"></div>

					<script type="text/javascript">
						var imgtitlelist = new Array(<xsl:apply-templates select="images/image" mode="array-title" />);
					</script>
					<script type="text/javascript">
						var imgsrclist = new Array(<xsl:apply-templates select="images/image" mode="array-url" />);
					</script>
					<script type="text/javascript">
						var imgcaplist = new Array(<xsl:apply-templates select="images/image" mode="array-caption" />);
					</script>
					<script type="text/javascript">
						var imgcredlist = new Array(<xsl:apply-templates select="images/image" mode="array-description" />);
					</script>
				</div>
			</div>
		</div>
	</xsl:template>
	
	<xsl:variable name="apos">'</xsl:variable>
	<xsl:variable name="rsq">&#8217;</xsl:variable>

	<xsl:template match="image" mode="array-title">'{replace(title,$apos,$rsq)}'<xsl:if test="position() != last()">,</xsl:if></xsl:template>
	<xsl:template match="image" mode="array-url">'{@url}'<xsl:if test="position() != last()">,</xsl:if></xsl:template>
	<xsl:template match="image" mode="array-caption">'{replace(caption,$apos,$rsq)}'<xsl:if test="position() != last()">,</xsl:if></xsl:template>
	<xsl:template match="image" mode="array-description">'{replace(description,$apos,$rsq)}'<xsl:if test="position() != last()">,</xsl:if></xsl:template>

	<xsl:template match="image" mode="update-thumbnails">
		<a href="{link}" class="toggleopacity">
			<img width="75" height="50" class="thumb_spacers" onclick="getSlideShowThumbImage('{@url}', this);return false;" src="{@url}" alt="{title}" title="{title}" />
		</a>
	</xsl:template>

</xsl:stylesheet>
