﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
	<xsl:import href="../../GenericTemplates/StringReplace.xslt"/>
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="MasterPortalItemID" select="AjaxRequest/Params/MasterPortalItemID"></xsl:variable>
		<xsl:variable name="GoalItemID" select="AjaxRequest/Params/GoalItemID"></xsl:variable>
		<xsl:variable name="UserID" select="AjaxRequest/Params/UserID"></xsl:variable>
		<xsl:variable name="GoalList" select="AjaxRequest/Items/Item"></xsl:variable>
		<xsl:variable name ="HostName" select ="normalize-space(AjaxRequest/HostName)"></xsl:variable>
		<xsl:variable name="IsSecureConnection" select="AjaxRequest/IsSecureConnection"></xsl:variable>
		<xsl:variable name="LoggedInUserID" select="AjaxRequest/LoggedInUserID"></xsl:variable>
		<xsl:variable name="divID" select="AjaxRequest/Params/divID"></xsl:variable>
		<xsl:variable name="PortalItemID">
			<xsl:choose>
				<xsl:when test="AjaxRequest/Params/PortalItemID=''">
					<xsl:text>-99</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="AjaxRequest/Params/PortalItemID"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="PortalID">
			<xsl:choose>
				<xsl:when test="$PortalItemID=-99">
					<xsl:value-of select="$MasterPortalItemID"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$PortalItemID"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="Protocol">
			<xsl:choose>
				<xsl:when test="$IsSecureConnection = 1">
					<xsl:text>https://</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>http://</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="countGoalList">
			<xsl:value-of select="count($GoalList)"> </xsl:value-of>
		</xsl:variable>
		<xsl:variable name="styleNextArrow">
			<xsl:choose>
				<xsl:when test="$countGoalList &lt; 6">
					<xsl:text>display:none</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>display:inline-block</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<div>
			<div id="accordion2" class="accordion" >
				<div id="collapseTwo"  class="collapse in" style="margin:20px auto 0px auto;text-align:center;float:none;">

					<input type="hidden" value="1" id="hfdQuickPageNumber"/>
					<input type="hidden" value="{$countGoalList}" id="hfdTotalPageNumber"/>
					<div class="col-md-1 col-sm-1 col-xs-6 contain divhide" style="float:left;text-align:left;">
						<xsl:if test="$countGoalList &gt; 5">
							<i id="iconPrevPage" class="glyphicon glyphicon-menu-left arow onMouseOver" style="font-size: 43px;top:75px; left:10px;display:none;" onClick="getQuickPageStart('Prev')"></i>
						</xsl:if>
					</div>
					<div class="col-md-12 arowshow">
						<div class="col-md-6 col-sm-6 col-xs-6 contain midd">
							<xsl:if test="$countGoalList &gt; 5">
								<i id="iconPrevPageMob" class="glyphicon glyphicon-menu-left arow onMouseOver tpL" style="font-size: 43px;top:75px; left:45px;display:none;" onClick="getQuickPageStart('Prev')"></i>
							</xsl:if>
						</div>
						<div class="col-md-6 col-sm-6 col-xs-6 contain midr">
							<xsl:if test="$countGoalList &gt; 5">
								<i id="iconNextPageMob" class="glyphicon tpR glyphicon-menu-right arow onMouseOver {$styleNextArrow}" style="font-size: 43px;top:75px; left:30px;"  onClick="getQuickPageStart('Next')"></i>
							</xsl:if>
						</div>
					</div>
					<xsl:for-each select="$GoalList[position() &lt; 6]">
						<xsl:variable name="SelectedClass">
							<xsl:choose>
								<xsl:when test="position()=1">
									<xsl:text>selectedQuickGoal</xsl:text>
								</xsl:when>
								<xsl:otherwise>
									<xsl:text></xsl:text>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>

						<xsl:variable name="EscapedItem">
							<xsl:call-template name="replaceCharsInString">
								<xsl:with-param name="stringIn" select="Item"></xsl:with-param>
								<xsl:with-param name="charsIn">
									<xsl:text>'</xsl:text>
								</xsl:with-param>
								<xsl:with-param name="charsOut">
									<xsl:text>\'</xsl:text>
								</xsl:with-param>
							</xsl:call-template>
						</xsl:variable>

						<xsl:if test="position()=1">

							<script>
								<xsl:text>loadGoal_3_0('</xsl:text>
								<xsl:value-of select="ItemID"/>
								<xsl:text>','divMainGoal','</xsl:text>
								<xsl:value-of select="$EscapedItem"/>
								<xsl:text>','</xsl:text>
								<xsl:value-of select="ImageURL"/>
								<xsl:text>','</xsl:text>
								<xsl:value-of select="SuccessKey"/>
								<xsl:text>','-99','</xsl:text>
								<xsl:value-of select="$PortalID"/>
								<xsl:text>','</xsl:text>
								<xsl:value-of select="$LoggedInUserID"/>
								<xsl:text>','QuickStart');</xsl:text>

							</script>
						</xsl:if>

						<xsl:variable name="FormattedImageURL">
							<xsl:choose>
								<xsl:when test="$IsSecureConnection = 1 and ImageURL !=''">
									<xsl:call-template name="replaceCharsInString">
										<xsl:with-param name="stringIn" select="ImageURL"></xsl:with-param>
										<xsl:with-param name="charsIn">
											<xsl:text>http://</xsl:text>
										</xsl:with-param>
										<xsl:with-param name="charsOut">
											<xsl:text>https://</xsl:text>
										</xsl:with-param>
									</xsl:call-template>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="ImageURL"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>

						<div data-toggle="collapse" href="#collapseTwo" id="divQuickGoal_{ItemID}" position="{position()}" class="col-md-2 col-sm-2 col-xs-6 contain QuickPageClass {$SelectedClass} onMouseOver"
							 onClick="loadGoal_3_0('{ItemID}','divMainGoal','{$EscapedItem}','{ImageURL}','{SuccessKey}','-99','{$PortalID}','{$LoggedInUserID}','QuickStart');getSelectedQuickGoal('divQuickGoal_{ItemID}');ChangeText('btnShowHideProgram');">
							<!--	<img src="{ImageURL}" class="img-responsive"/>-->
							<img src="{$FormattedImageURL}" class="img-responsive"></img>
							<h6 class="text-center">
								<xsl:value-of select="Item"/>
							</h6>
						</div>

					</xsl:for-each>
					<xsl:for-each select="$GoalList[position() &gt; 5]">

						<xsl:variable name="EscapedItem">
							<xsl:call-template name="replaceCharsInString">
								<xsl:with-param name="stringIn" select="Item"></xsl:with-param>
								<xsl:with-param name="charsIn">
									<xsl:text>'</xsl:text>
								</xsl:with-param>
								<xsl:with-param name="charsOut">
									<xsl:text>\'</xsl:text>
								</xsl:with-param>
							</xsl:call-template>
						</xsl:variable>

						<xsl:variable name="FormattedImageURL">
							<xsl:choose>
								<xsl:when test="$IsSecureConnection = 1 and ImageURL !=''">
									<xsl:call-template name="replaceCharsInString">
										<xsl:with-param name="stringIn" select="ImageURL"></xsl:with-param>
										<xsl:with-param name="charsIn">
											<xsl:text>http://</xsl:text>
										</xsl:with-param>
										<xsl:with-param name="charsOut">
											<xsl:text>https://</xsl:text>
										</xsl:with-param>
									</xsl:call-template>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="ImageURL"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>

						<div data-toggle="collapse" href="#collapseTwo" id="divQuickGoal_{ItemID}"  position="{position()+5}" class="col-md-2 col-sm-2 col-xs-6 contain QuickPageClass  onMouseOver" style="display:none;"
								 onClick="loadGoal_3_0('{ItemID}','divMainGoal','{$EscapedItem}','{ImageURL}','{SuccessKey}','-99','{$PortalID}','{$LoggedInUserID}','QuickStart');getSelectedQuickGoal('divQuickGoal_{ItemID}');ChangeText('btnShowHideProgram');">
							<!--<img src="{ImageURL}" class="img-responsive" />-->
							<img src="{$FormattedImageURL}" class="img-responsive"></img>
							<h6 class="text-center">
								<xsl:value-of select="Item"/>

							</h6>
						</div>
					</xsl:for-each>

					<div class="col-md-1 col-sm-1 col-xs-6 contain divhide arR" style="float:right;width:5%;right:4%;">
						<xsl:if test="$countGoalList &gt; 5">
							<i id="iconNextPage" class="glyphicon glyphicon-menu-right arow onMouseOver {$styleNextArrow}" style="font-size: 43px;top:75px; left:30px;"  onClick="getQuickPageStart('Next')"></i>
						</xsl:if>
					</div>
				</div>
				<div class="widcomplete">
					<input type="button" id="btnShowHideProgram" onClick="ChangeText('btnShowHideProgram');"
						   class="SeeMore2 btn btn-info" data-toggle="collapse" href="#collapseTwo" value="Hide My Programs"></input>
				</div>
			</div>
			<div id="divMainGoal">
			</div>
		</div>
	</xsl:template>
</xsl:stylesheet>
