﻿<?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:output method="xml" indent="yes"/>

	<xsl:template match="/">
		<xsl:variable name="Tabs" select="/AjaxRequest/Settings/BusinessPlan/Tabs/."></xsl:variable>
		<xsl:variable name="LoggedInUserID" select="/AjaxRequest/LoggedInUserID"></xsl:variable>
		<xsl:variable name="MasterPortalItemID" select="/AjaxRequest/Params/MasterPortalItemID"></xsl:variable>
		<xsl:variable name="YearList" select="/AjaxRequest/YearList"></xsl:variable>
		<xsl:variable name="CurrentYear" select="/AjaxRequest/CurrentYear"></xsl:variable>
		<xsl:variable name="SelectedYear" select="AjaxRequest/SelectedYear"></xsl:variable>
		<xsl:variable name="IsActiveGoalPage" select="AjaxRequest/Params/IsActiveGoalPage"></xsl:variable>
		<xsl:variable name="userID" select="AjaxRequest/Params/userID"/>
		<xsl:variable name="ClassifiedGoals" select="AjaxRequest/ClassifiedGoals"></xsl:variable>
		<xsl:variable name="PortalItemID">
			<xsl:choose>
				<xsl:when test="/AjaxRequest/Params/PortalItemID[text()]">
					<xsl:value-of select="/AjaxRequest/Params/PortalItemID"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$MasterPortalItemID"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="displayYearStyle">
			<xsl:choose>
				<xsl:when test="$IsActiveGoalPage = 1">
					<xsl:text>display:none;</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>display:inline-block;</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<div class="business_top">
			<!--<div class="container business_top">-->
			<style type="text/css">
				.goalOperationBackground{background:#fff;}
			</style>
			<div class="col-md-12 col-xs-12 col-sm-12" style="margin:20px 0;float:left;">
				<ul class="nav nav-pills nav-justified txtcolor BusinessPlanningTab">
					<li style="padding-right: 14px;">
						<select class="form-control" style="height: 47px;margin-right: 10px;{$displayYearStyle}" id="ddlBusinessPlanningYear"
							   onchange="$('#btnBusinessPlanningTab_1').click();">
							<xsl:for-each select="$YearList/Year">
								<xsl:choose>
									<xsl:when test="$SelectedYear=Value">
										<option selected="" value="01/01/{Value}">
											<xsl:value-of select="Value"/>
										</option>
									</xsl:when>
									<xsl:otherwise>
										<option value="01/01/{Value}">
											<xsl:value-of select="Value"/>
										</option>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:for-each>
						</select>
					</li>
					<xsl:variable name="TabList">
						<xsl:choose>
							<xsl:when test="$IsActiveGoalPage = 1">
								<xsl:copy-of select="$Tabs/Tab[ActiveOnGoal !=0  or not(ActiveOnGoal)]"></xsl:copy-of>
							</xsl:when>
							<xsl:otherwise>
								<xsl:copy-of select="$Tabs/Tab[
											 (
												ConditionalDisplay = 1 
												and 
												(
													($ClassifiedGoals/Item/Classification = 'Business Plan' and Classification = 'BusinessPlanning')
													or 
													($ClassifiedGoals/Item/Classification = Classification)
												)
											 )
											 or ConditionalDisplay = 0
											 or not(ConditionalDisplay)]"></xsl:copy-of>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:variable>
					<!--$Tabs/Tab[ActiveOnGoal !=0  or not(ActiveOnGoal)]-->
					<xsl:for-each select="msxsl:node-set($TabList)/child::node()">
						<xsl:variable name="TabClass">
							<xsl:choose>
								<xsl:when test="position() = 1">
									<xsl:text>active</xsl:text>
								</xsl:when>
							</xsl:choose>
						</xsl:variable>
						<xsl:variable name="CurrentClassification">
							<xsl:choose>
								<xsl:when test="Classification = 'BusinessPlanning'">
									<xsl:text>Business Plan</xsl:text>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="Classification"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>
						<xsl:variable name="varCheckKeyDate">
							<xsl:choose>
								<xsl:when test="not(CheckKeyDate)">
									<xsl:text>null</xsl:text>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="CheckKeyDate"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>

						<xsl:variable name="varAllowGoalAddition">
							<xsl:choose>
								<xsl:when test="not(AllowGoalAddition)">
									<xsl:text>null</xsl:text>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="AllowGoalAddition"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:variable>

						<!--<xsl:if test="(ConditionalDisplay = 1 and $ClassifiedGoals/Item[Classification = $CurrentClassification])
								or ConditionalDisplay = 0
								or not(ConditionalDisplay)">-->
						<li class="{$TabClass} BusinessPlanningTab_Li_{position()}" onClick="activeTab('BusinessPlanningTab li', 'active','BusinessPlanningTab_Li_{position()}');">
							<a id="btnBusinessPlanningTab_{position()}" position="{position()}" class="btnBusinessPlanningTab_{Key}" href="javascript:void(0)"
							onClick="LoadBusinessPlanTab_3_0('{Key}', '{Classification}',{$MasterPortalItemID},{$PortalItemID},{$userID},'divBusinessPlanDashboardOpertaions',0,{$varCheckKeyDate},{$varAllowGoalAddition});">
								<xsl:value-of select="Label"/>
							</a>
							<input type="hidden" id="hfdBussinessPlanNavigation_{position()}"
								onClick="LoadBusinessPlanTab_3_0('{Key}', '{Classification}',{$MasterPortalItemID},{$PortalItemID},{$userID},'divBusinessPlanDashboardOpertaions',1,{$varCheckKeyDate},{$varAllowGoalAddition});"></input>
						</li>
						<xsl:if test="position() = 1">
							<script>
								LoadBusinessPlanTab_3_0('<xsl:value-of select="Key"></xsl:value-of>', '<xsl:value-of select="Classification"></xsl:value-of>'
								, <xsl:value-of select="$MasterPortalItemID"></xsl:value-of>, <xsl:value-of select="$PortalItemID"></xsl:value-of>
								, <xsl:value-of select="$userID"/>, 'divBusinessPlanDashboardOpertaions',0,<xsl:value-of select="$varCheckKeyDate"/>,
								<xsl:value-of select="$varAllowGoalAddition"/>);
							</script>
						</xsl:if>
						<!--</xsl:if>-->
					</xsl:for-each>
				</ul>
			</div>
			<div id="divBusinessPlanDashboardOpertaions">

			</div>
		</div>
	</xsl:template>
</xsl:stylesheet>
