﻿<?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="AddExercise.xslt"/>

    <xsl:output method="xml" omit-xml-declaration="yes" indent ="no"/>

    <xsl:template match="/">
        <xsl:call-template name="Program_Exercise">
            <xsl:with-param name="ItemID" select="Exercises/Exercise/PortalItemID"></xsl:with-param>
            <xsl:with-param name="ExerciseID" select="Exercises/Exercise/ExerciseID"></xsl:with-param>
            <xsl:with-param name="ExerciseName" select="Exercises/Exercise/ExerciseName"></xsl:with-param>
            <xsl:with-param name="Description" select="Exercises/Exercise/Description"></xsl:with-param>
            <xsl:with-param name="ThumbnailURL" select="Exercises/Exercise/ThumbnailURL"></xsl:with-param>
            <xsl:with-param name="PublishRowInnerContentOnly">
                <xsl:choose>
                    <xsl:when test="Exercises/Mode = 'UpdateExercise'">
                        <xsl:number value="1"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:number value ="0"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="Program_Exercise">
        <xsl:param name="ItemID" select="'N/A'"></xsl:param>
        <xsl:param name="ExerciseID" select="'N/A'"></xsl:param>
        <xsl:param name="ExerciseName" select="'N/A'"></xsl:param>
        <xsl:param name="Description" select="'N/A'"></xsl:param>
        <xsl:param name="TypeID" select="'N/A'"></xsl:param>
        <xsl:param name="CustomType" select="'N/A'"></xsl:param>
        <xsl:param name="ImageURL" select="'N/A'"></xsl:param>
        <xsl:param name="ThumbnailURL" select="'N/A'"></xsl:param>
        <xsl:param name="VideoURL" select="'N/A'"></xsl:param>
        <xsl:param name="Sets" select="'N/A'"></xsl:param>
        <xsl:param name="Reps" select="'N/A'"></xsl:param>
        <xsl:param name="Levels" select="'N/A'"></xsl:param>
        <xsl:param name="Time" select="'N/A'"></xsl:param>
        <xsl:param name="Distance" select="'N/A'"></xsl:param>
        <xsl:param name="Weight" select="'N/A'"></xsl:param>
        <xsl:param name="Calories" select="'N/A'"></xsl:param>
        <xsl:param name="Active" select="'N/A'"></xsl:param>
        <xsl:param name="Public" select="'N/A'"></xsl:param>
        <xsl:param name="Published" select="'N/A'"></xsl:param>
        <xsl:param name="PublishRowInnerContentOnly">
            <xsl:number value ="0"/>
        </xsl:param>

        <xsl:choose>
            <xsl:when test="$PublishRowInnerContentOnly = 1">
                <xsl:call-template name="Program_Exercise_BodyContent">
                    <xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
                    <xsl:with-param name="ExerciseID" select="$ExerciseID"></xsl:with-param>
                    <xsl:with-param name="ExerciseName" select="$ExerciseName"></xsl:with-param>
                    <xsl:with-param name="Description" select="$Description"></xsl:with-param>
                    <xsl:with-param name="TypeID" select="$TypeID"></xsl:with-param>
                    <xsl:with-param name="CustomType" select="$CustomType"></xsl:with-param>
                    <xsl:with-param name="ImageURL" select="$ImageURL"></xsl:with-param>
                    <xsl:with-param name="ThumbnailURL" select="$ThumbnailURL"></xsl:with-param>
                    <xsl:with-param name="VideoURL" select="$VideoURL"></xsl:with-param>
                    <xsl:with-param name="Sets" select="$Sets"></xsl:with-param>
                    <xsl:with-param name="Reps" select="$Reps"></xsl:with-param>
                    <xsl:with-param name="Levels" select="$Levels"></xsl:with-param>
                    <xsl:with-param name="Time" select="$Time"></xsl:with-param>
                    <xsl:with-param name="Distance" select="$Distance"></xsl:with-param>
                    <xsl:with-param name="Weight" select="$Weight"></xsl:with-param>
                    <xsl:with-param name="Calories" select="$Calories"></xsl:with-param>
                    <xsl:with-param name="Active" select="$Active"></xsl:with-param>
                    <xsl:with-param name="Public" select="$Public"></xsl:with-param>
                    <xsl:with-param name="Published" select="$Published"></xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <tr id="tr_{$ItemID}_{$ExerciseID}">
                    <xsl:call-template name="Program_Exercise_BodyContent">
                        <xsl:with-param name="ItemID" select="$ItemID"></xsl:with-param>
                        <xsl:with-param name="ExerciseID" select="$ExerciseID"></xsl:with-param>
                        <xsl:with-param name="ExerciseName" select="$ExerciseName"></xsl:with-param>
                        <xsl:with-param name="Description" select="$Description"></xsl:with-param>
                        <xsl:with-param name="TypeID" select="$TypeID"></xsl:with-param>
                        <xsl:with-param name="CustomType" select="$CustomType"></xsl:with-param>
                        <xsl:with-param name="ImageURL" select="$ImageURL"></xsl:with-param>
                        <xsl:with-param name="ThumbnailURL" select="$ThumbnailURL"></xsl:with-param>
                        <xsl:with-param name="VideoURL" select="$VideoURL"></xsl:with-param>
                        <xsl:with-param name="Sets" select="$Sets"></xsl:with-param>
                        <xsl:with-param name="Reps" select="$Reps"></xsl:with-param>
                        <xsl:with-param name="Levels" select="$Levels"></xsl:with-param>
                        <xsl:with-param name="Time" select="$Time"></xsl:with-param>
                        <xsl:with-param name="Distance" select="$Distance"></xsl:with-param>
                        <xsl:with-param name="Weight" select="$Weight"></xsl:with-param>
                        <xsl:with-param name="Calories" select="$Calories"></xsl:with-param>
                        <xsl:with-param name="Active" select="$Active"></xsl:with-param>
                        <xsl:with-param name="Public" select="$Public"></xsl:with-param>
                        <xsl:with-param name="Published" select="$Published"></xsl:with-param>
                    </xsl:call-template>
                </tr>
                <tr id="tr_{$ItemID}_{$ExerciseID}_Operations">
                    <td colspan="6">
                        <div id="div_{$ItemID}_{$ExerciseID}_Operations" style="display:none;">
                        </div>
                    </td>
                </tr>
            </xsl:otherwise>
        </xsl:choose>
        
    </xsl:template>

    <xsl:template name="Program_Exercise_BodyContent">
        <xsl:param name="ItemID" select="'N/A'"></xsl:param>
        <xsl:param name="ExerciseID" select="'N/A'"></xsl:param>
        <xsl:param name="ExerciseName" select="'N/A'"></xsl:param>
        <xsl:param name="Description" select="'N/A'"></xsl:param>
        <xsl:param name="Type" select="'N/A'"></xsl:param>
        <xsl:param name="CustomType" select="'N/A'"></xsl:param>
        <xsl:param name="ImageURL" select="'N/A'"></xsl:param>
        <xsl:param name="ThumbnailURL" select="'N/A'"></xsl:param>
        <xsl:param name="VideoURL" select="'N/A'"></xsl:param>
        <xsl:param name="Sets" select="'N/A'"></xsl:param>
        <xsl:param name="Reps" select="'N/A'"></xsl:param>
        <xsl:param name="Levels" select="'N/A'"></xsl:param>
        <xsl:param name="Time" select="'N/A'"></xsl:param>
        <xsl:param name="Distance" select="'N/A'"></xsl:param>
        <xsl:param name="Weight" select="'N/A'"></xsl:param>
        <xsl:param name="Calories" select="'N/A'"></xsl:param>
        <xsl:param name="Active" select="'N/A'"></xsl:param>
        <xsl:param name="Public" select="'N/A'"></xsl:param>
        <xsl:param name="Published" select="'N/A'"></xsl:param>

        <td width="5%" style="vertical-align:middle;padding-top:5px;padding-bottom:5px; padding-left:5px;">
            <span class="link" style="padding-left:5px;"
                  onClick="return workoutTracker_DeleteExercise('{$ExerciseID}','{$ItemID}','tr_{$ItemID}_{$ExerciseID}','tr_{$ItemID}_{$ExerciseID}_Operations');">[X]</span>
        </td>
        <td width="10%" style="padding-top:5px;padding-bottom:5px;padding-left:5px;vertical-align:middle;">
            <xsl:if test ="$ThumbnailURL != ''"><img src="{$ThumbnailURL}" width="60px" ></img>
            </xsl:if>
        </td>
        <td width="60%" style="vertical-align:middle;padding-top:5px;padding-bottom:5px;padding-left:5px;">
            <div id="div_ExerciseName">
                <span class="labelSize11">
                    <xsl:value-of select="$ExerciseName"/>
                </span>
            </div>
            <div id="div_ExerciseDescription">
                <span>
                    <xsl:value-of select="$Description"/>
                </span>
            </div>
        </td>
        <td style="padding-top:5px;padding-bottom:5px;padding-left:5px;"></td>
        <td style="padding-top:5px;padding-bottom:5px;padding-left:5px;"></td>
        <td style="vertical-align:middle;" >
            <input type="button" class="button" value="Edit" 
                   onClick="return workoutTracker_DisplayUpdateexercise('div_{$ItemID}_{$ExerciseID}_Operations','{$ItemID}','{$ExerciseID}');"></input>
        </td>
        
    </xsl:template>

</xsl:stylesheet>
