﻿<?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="WorkoutItemID" select="AjaxRequest/Exercise/WorkoutItemID"></xsl:variable>
        <xsl:variable name="ExerciseID" select="AjaxRequest/Exercise/ExerciseID"></xsl:variable>
        <xsl:variable name="ThumbnailURL" select="AjaxRequest/Exercise/ThumbnailURL"></xsl:variable>
        <xsl:variable name="ExerciseName" select="AjaxRequest/Exercise/ExerciseName"></xsl:variable>
        <xsl:variable name="Description" select="AjaxRequest/Exercise/Description"></xsl:variable>
        <xsl:variable name="LevelYN" select="AjaxRequest/Exercise/LevelYN"></xsl:variable>
        <xsl:variable name="SetsYN" select="AjaxRequest/Exercise/SetsYN"></xsl:variable>
        <xsl:variable name="RepsYN" select="AjaxRequest/Exercise/RepsYN"></xsl:variable>
        <xsl:variable name="TimeYN" select="AjaxRequest/Exercise/TimeYN"></xsl:variable>
        <xsl:variable name="DistanceYN" select="AjaxRequest/Exercise/DistanceYN"></xsl:variable>
        <xsl:variable name="WeightYN" select="AjaxRequest/Exercise/WeightYN"></xsl:variable>
        <xsl:variable name="CaloriesYN" select="AjaxRequest/Exercise/CaloriesYN"></xsl:variable>
        <xsl:variable name="RepsNum" select="AjaxRequest/Exercise/Sets/RepsNum"></xsl:variable>
        <xsl:variable name="LevelNum" select="AjaxRequest/Exercise/Sets/LevelNum"></xsl:variable>
        <xsl:variable name="TimeAct" select="AjaxRequest/Exercise/Sets/TimeAct"></xsl:variable>
        <xsl:variable name="TimeMeasueValue" select="AjaxRequest/Exercise/Sets/TimeMeasueValue"></xsl:variable>
        <xsl:variable name="WeightMeasureValue" select="AjaxRequest/Exercise/Sets/WeightMeasureValue"></xsl:variable>
        <xsl:variable name="DistanceMeasureValue" select="AjaxRequest/Exercise/Sets/DistanceMeasureValue"></xsl:variable>
        <xsl:variable name="WeightAct" select="AjaxRequest/Exercise/Sets/WeightAct"></xsl:variable>
        <xsl:variable name="DistanceAct" select="AjaxRequest/Exercise/Sets/DistanceAct"></xsl:variable>
        <xsl:variable name="CaloriesAct" select="AjaxRequest/Exercise/Sets/CaloriesAct"></xsl:variable>
        <xsl:variable name="Exercise" select="AjaxRequest/Exercise"></xsl:variable>
        <xsl:variable name="TimeActValue" select="AjaxRequest/Exercise/Sets/TimeActValue"></xsl:variable>
        <xsl:variable name="WeightActValue" select="AjaxRequest/Exercise/Sets/WeightActValue"></xsl:variable>
        <xsl:variable name="DistanceActValue" select="AjaxRequest/Exercise/Sets/DistanceActValue"></xsl:variable>
        <xsl:variable name="CaloriesActValue" select="AjaxRequest/Exercise/Sets/CaloriesActValue"></xsl:variable>
        <xsl:variable name ="TemplatePathURL" select ="normalize-space(AjaxRequest/TemplateURL)"/>
        <xsl:variable name="SetsCount" select="count(AjaxRequest/Exercise/Sets)"></xsl:variable>
        <xsl:variable name="SetsCompleteCount" select="count(AjaxRequest/Exercise/Sets[StatusID = 4])"></xsl:variable>
        <xsl:variable name="SetItemID" select="AjaxRequest/Params/ItemID"></xsl:variable>
        <xsl:variable name="SetProgramExerciseID" select="AjaxRequest/Params/ProgramExerciseID"></xsl:variable>
        <xsl:variable name="ItemID" select="AjaxRequest/Exercise/ItemID"></xsl:variable>
        <xsl:variable name="ImageURL" select="AjaxRequest/Exercise/ImageURL"></xsl:variable>
        <xsl:variable name="VideoURL" select="AjaxRequest/Exercise/VideoURL"></xsl:variable>
        <xsl:variable name="VideoKeyValue" select="AjaxRequest/VideoKeyValue"></xsl:variable>
        <xsl:variable name="HostName" select="AjaxRequest/HostName"></xsl:variable>
        <xsl:variable name ="TemplateUrl" select ="normalize-space(AjaxRequest/TemplateURL)"></xsl:variable>
        <xsl:variable name="VimeoThumbnailURL" select="AjaxRequest/ThumbnailURL"></xsl:variable>
        <xsl:variable name="WorkoutStatusID" select="AjaxRequest/Exercise/WorkoutStatusID"></xsl:variable>
    
      
        <div id="div_ItemWorkoutExerciseDetail" style="margin-left:10px;">
            <xsl:choose>
                <xsl:when test ="$SetsCount = $SetsCompleteCount">
                    <input id="workoutSetsCompleteCount" type="hidden" value="1"></input>
                </xsl:when>
                <xsl:otherwise>
                    <input id="workoutSetsCompleteCount" type="hidden" value="-99"></input>
                </xsl:otherwise>
            </xsl:choose>
            <table class="tableMaster" width="100%">
                <tr>
                    <td width="10%">
                       
                        <xsl:choose>
                            <xsl:when test ="$VideoURL != '' and $VideoKeyValue != ''">
                                <xsl:choose>
                                    <xsl:when test ="contains($VideoURL, 'youtube')">
                                        <div id="divWorkOutYouTubeVideoContainer" style="margin-bottom:15px; margin-right:5px;">
                                            <div>
                                                <img src="http://img.youtube.com/vi/{$VideoKeyValue}/1.jpg" class="link"
                                                   title="Play Video" onClick="workout_LoadYouTubeVideo('{$VideoKeyValue}','divWorkOutYouTubeVideoContainer','Workout');"></img>
                                            </div>
                                            <div style="margin-top:-30px;">
                                                <img class="link" title ="Play Video"
                                                     onClick="workout_LoadYouTubeVideo('{$VideoKeyValue}','divWorkOutYouTubeVideoContainer','Workout');"
                                                     src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>
                                            </div>
                                        </div>
                                    </xsl:when>
                                    <xsl:when test ="contains($VideoURL, 'vimeo')">
                                        <div id="divWorkOutYouTubeVideoContainer" style="margin-bottom:15px; margin-right:5px;">
                                            <div>
                                                <img src="{$VimeoThumbnailURL}" class="link" width="120" height="90"
                                                   title="Play Video"
                                                   onClick="LoadVimeoVideo('{$VideoKeyValue}','divWorkOutYouTubeVideoContainer','Workout');"></img>
                                            </div>
                                            <div style="margin-top:-30px;">
                                                <img class="link" title ="Play Video"
                                                     onClick="LoadVimeoVideo('{$VideoKeyValue}','divWorkOutYouTubeVideoContainer','Workout');"
                                                     src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>
                                            </div>
                                        </div>
                                    </xsl:when>                                   
                                        <xsl:when test="contains($VideoURL, 'dailymotion')">
                                            <div id="divWorkOutYouTubeVideoContainer" style="margin-bottom:15px; margin-right:5px;">
                                                <div>
                                                    <img src="http://www.dailymotion.com/thumbnail/video/{$VideoKeyValue}" class="link" width="120" height="90"
                                                       title="Play Video" onClick="LoadDailyMotionVideo('{$VideoKeyValue}','divWorkOutYouTubeVideoContainer','Workout');"></img>
                                                </div>
                                                <div style="margin-top:-30px;">
                                                    <img class="link" title ="Play Video"
                                                         onClick="LoadDailyMotionVideo('{$VideoKeyValue}','divWorkOutYouTubeVideoContainer','Workout');"
                                                         src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>
                                                </div>
                                            </div>
                                        </xsl:when>
                                        <xsl:when test="contains($VideoURL, 'dmcloud.net')">
                                            <div id="divWorkOutYouTubeVideoContainer" style="margin-bottom:15px; margin-right:5px;">
                                                <div>
                                                    <img src="http://static.dmcloud.net/{$VimeoThumbnailURL}/jpeg_thumbnail_medium-1308342384.jpeg" class="link" width="120" height="90"
                                                       title="Play Video" onClick="LoadDailyMotionVideo('{$VideoURL}','divWorkOutYouTubeVideoContainer','Workout');"></img>
                                                </div>
                                                <div style="margin-top:-30px;">
                                                    <img class="link" title ="Play Video"
                                                         onClick="LoadDailyMotionVideo('{$VideoURL}','divWorkOutYouTubeVideoContainer','Workout');"
                                                         src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>
                                                </div>
                                            </div>
                                        </xsl:when>                                                                                                                                        
                                </xsl:choose>
                            </xsl:when>
                            <xsl:when test ="$ThumbnailURL != ''">
                                <img src="{$ThumbnailURL}" style="margin-bottom:15px; margin-right:5px;display:none;"
                                     onload='setWidthAndHeightImage(this,"100");'></img>
                            </xsl:when>
                            <xsl:when test ="$ImageURL != ''">
                                <img src="{$ImageURL}" style="margin-bottom:15px; margin-right:5px;display:none;"
                                    onload='setWidthAndHeightImage(this,"100");'></img>
                            </xsl:when>
                            <xsl:otherwise>
                                <div id="divWorkoutVideoContainer" style="display:block;">
                                </div>                           
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                    <td width="90%">
                        <div>
                            <span class="labelHeader">
                                <xsl:value-of select="$ExerciseName"/>
                            </span>
                        </div>
                        <div>
                            <span>
                                <xsl:value-of select="$Description"/>
                            </span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <xsl:for-each select="AjaxRequest/Exercise/Sets">
                        
                          
                            <xsl:choose>
                                <xsl:when test ="StatusID = 4">
                                    <div id="div_{ItemID}_Sets_Completed" style="display:block;">
                                        <table class="tableMaster" width="100%">
                                            <tr>
                                                <td width="10%">
                                                    <span style="margin-right:10px;" class="labelGraySize11">
                                                        <xsl:value-of select="position()"/>
                                                    </span>
                                                </td>
                                                <td width="90%">
                                                    <span>
                                                        <input id="chk_{ItemID}_Sets" type="checkbox"
                                                               checked="true" DISABLED="disabled"></input>
                                                    </span>
                                                    <xsl:if test="$RepsYN = 1">
                                                        <span class="labelGraySize11" style="margin-right:10px;">
                                                            <xsl:value-of select ="RepsNum"></xsl:value-of>&#xa0;Reps
                                                        </span>
                                                    </xsl:if>
                                                    <xsl:if test="$LevelYN = 1">
                                                        <span class="labelGraySize11" style="margin-right:5px;">
                                                            <xsl:value-of select ="LevelNum"></xsl:value-of>&#xa0;Level
                                                        </span>
                                                    </xsl:if>
                                                    <xsl:if test="$TimeYN = 1">
                                                        <span class="labelGraySize11" style="margin-right:10px;">
                                                            <xsl:value-of select ="TimeActValue"></xsl:value-of>&#xa0;<xsl:value-of select="$TimeMeasueValue"/>
                                                        </span>
                                                    </xsl:if>
                                                    <xsl:if test="$DistanceYN = 1">
                                                        <span class="labelGraySize11" style="margin-right:10px;">
                                                            <xsl:value-of select ="DistanceActValue"></xsl:value-of>&#xa0;<xsl:value-of select="$DistanceMeasureValue"/>
                                                        </span>
                                                    </xsl:if>
                                                    <xsl:if test="$WeightYN = 1">
                                                        <span class="labelGraySize11" style="margin-right:10px;">
                                                            <xsl:value-of select ="WeightActValue"></xsl:value-of>&#xa0;<xsl:value-of select="$WeightMeasureValue"/>
                                                        </span>
                                                    </xsl:if>
                                                    <xsl:if test="$CaloriesYN = 1">
                                                        <span class="labelGraySize11" style="margin-right:10px;">
                                                            <xsl:value-of select ="CaloriesActValue"></xsl:value-of>&#xa0;Cals
                                                        </span>
                                                    </xsl:if>
                                                    <xsl:choose>
                                                        <xsl:when test="position() = $SetsCount">
                                                            <span class="link" id="span_{ItemID}_DeleteSet"
                                                                 onClick="return workoutTracker_deleteWorkoutExerciseSet('{ItemID}','{SeqNum}','Workout',-99);" style="display:inline;">
                                                                <img src="{$TemplatePathURL}Web/Icons/Delete%203/32%20Bit%20Alpha%20png/Delete%203%2016%20n%20p.png"
                                                                    class="onMouseOver"></img>
                                                                <input type="hidden" name="hiddenDeleteExerciseSet" seqNumer="{SeqNum}"></input>
                                                            </span>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <span class="link" id="span_{ItemID}_DeleteSet"
                                                             onClick="return workoutTracker_deleteWorkoutExerciseSet('{ItemID}','{SeqNum}','Workout',-99);" style="display:none;">
                                                                <img src="{$TemplatePathURL}Web/Icons/Delete%203/32%20Bit%20Alpha%20png/Delete%203%2016%20n%20p.png"
                                                                    class="onMouseOver"></img>
                                                                <input type="hidden" name="hiddenDeleteExerciseSet" seqNumer="{SeqNum}"></input>
                                                            </span>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </xsl:when>
                                <xsl:otherwise>
                                    <div id="div_{ItemID}_Sets" style="display:block;">
                                        <table class="tableMaster" width="100%">
                                            <tr>
                                                <td width="10%">
                                                    <span style="margin-right:10px;" class="labelHeader">
                                                        <xsl:value-of select="position()"/>
                                                    </span>
                                                </td>
                                                <td width="90%">
                                                    <span>
                                                      <xsl:choose>
                                                        <xsl:when test="$WorkoutStatusID = 1">
                                                          <input id="chk_{ItemID}_Sets" type="checkbox"
                                                              onClick="workoutTracker_MarkCompleteWorkoutExreciseSet('chk_{ItemID}_Sets','div_{ItemID}_Sets','{ItemID}','{SeqNum}','Workout',-99);
                                                                        workoutTracker_RefreshWorkoutHeader('{$WorkoutItemID}','RefreshWorkoutHeader','div_{$WorkoutItemID}_WorkoutDetail');"></input>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                          <input id="chk_{ItemID}_Sets" type="checkbox"
                                                              onClick="workoutTracker_MarkCompleteWorkoutExreciseSet('chk_{ItemID}_Sets','div_{ItemID}_Sets','{ItemID}','{SeqNum}','Workout',-99);"></input>
                                                        </xsl:otherwise>
                                                      </xsl:choose>
                                                       
                                                    </span>
                                                    <xsl:if test="$RepsYN = 1">
                                                        <input id="txt_{ItemID}_Reps" type="text" value="{RepsNum}" style="width:35px;text-align:center;"
                                                               onBlur="return workoutTracker_UpdateWorkoutItemSetData('{ItemID}','txt_{ItemID}_Reps','RepsNum');"></input>
                                                        <span class="labelFormFields" style="margin-right:10px;">
                                                            Reps
                                                        </span>
                                                    </xsl:if>
                                                    <xsl:if test="$LevelYN = 1">
                                                        <span class="labelFormFields" style="margin-right:5px;">
                                                            Level
                                                        </span>
                                                        <input id="txt_{ItemID}_Levels" type="text" value="{LevelNum}" style="width:35px;text-align:center;margin-right:5px;"
                                                                onBlur="return workoutTracker_UpdateWorkoutItemSetData('{ItemID}','txt_{ItemID}_Levels','LevelNum');"></input>
                                                    </xsl:if>
                                                    <xsl:if test="$TimeYN = 1">
                                                        <input id="txt_{ItemID}_Time" type="text" value="{TimeActValue}" style="width:35px;text-align:center;"
                                                               onBlur="return workoutTracker_UpdateWorkoutItemSetData('{ItemID}','txt_{ItemID}_Time','TimeAct');"></input>
                                                        <span class="labelFormFields" style="margin-right:10px;">
                                                            <xsl:value-of select="$TimeMeasueValue"/>
                                                        </span>
                                                    </xsl:if>
                                                    <xsl:if test="$DistanceYN = 1">
                                                        <input id="txt_{ItemID}_Distance" type="text" value="{DistanceActValue}" style="width:35px;text-align:center;"
                                                               onBlur="return workoutTracker_UpdateWorkoutItemSetData('{ItemID}','txt_{ItemID}_Distance','DistanceAct');"></input>
                                                        <span class="labelFormFields" style="margin-right:10px;">
                                                            <xsl:value-of select="$DistanceMeasureValue"/>
                                                        </span>
                                                    </xsl:if>
                                                    <xsl:if test="$WeightYN = 1">
                                                        <input id="txt_{ItemID}_Weight" type="text" value="{WeightActValue}" style="width:35px;text-align:center;"
                                                               onBlur="return workoutTracker_UpdateWorkoutItemSetData('{ItemID}','txt_{ItemID}_Weight','WeightAct');"></input>
                                                        <span class="labelFormFields" style="margin-right:10px;">
                                                            <xsl:value-of select="$WeightMeasureValue"/>
                                                        </span>
                                                    </xsl:if>
                                                    <xsl:if test="$CaloriesYN = 1">
                                                        <input id="txt_{ItemID}_Calories" type="text" value="{CaloriesActValue}" style="width:35px;text-align:center;"
                                                               onBlur="return workoutTracker_UpdateWorkoutItemSetData('{ItemID}','txt_{ItemID}_Calories','CaloriesAct');"></input>
                                                        <span class="labelFormFields" style="margin-right:10px;">
                                                            Cals
                                                        </span>
                                                    </xsl:if>

                                                    <xsl:choose>
                                                        <xsl:when test="position() = $SetsCount">
                                                            <span class="link" id="span_{ItemID}_DeleteSet"
                                                                 onClick="return workoutTracker_deleteWorkoutExerciseSet('{ItemID}','{SeqNum}','Workout',-99);" style="display:inline;">
                                                                <img src="{$TemplatePathURL}Web/Icons/Delete%203/32%20Bit%20Alpha%20png/Delete%203%2016%20n%20p.png"
                                                                    class="onMouseOver"></img>
                                                                <input type="hidden" name="hiddenDeleteExerciseSet" seqNumer="{SeqNum}"></input>
                                                            </span>
                                                        </xsl:when>
                                                        <xsl:otherwise>
                                                            <span class="link" id="span_{ItemID}_DeleteSet"
                                                             onClick="return workoutTracker_deleteWorkoutExerciseSet('{ItemID}','{SeqNum}','Workout',-99);" style="display:none;">
                                                                <img src="{$TemplatePathURL}Web/Icons/Delete%203/32%20Bit%20Alpha%20png/Delete%203%2016%20n%20p.png"
                                                                    class="onMouseOver"></img>
                                                                <input type="hidden" name="hiddenDeleteExerciseSet" seqNumer="{SeqNum}"></input>
                                                            </span>
                                                        </xsl:otherwise>
                                                    </xsl:choose>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:for-each>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <!--<xsl:choose>
                            <xsl:when test ="$SetProgramExerciseID &gt; 0">-->
                        <span class="labelGraySize10" style="margin-bottom:15px;cursor:pointer;"
                      onClick="workout_AddAdditionSetforWorkout({$WorkoutItemID},{$ExerciseID},{AjaxRequest/Exercise/Sets/SeqNum},'Workout',-99);">Add Additional Set</span>
                        <!--</xsl:when>
                            <xsl:otherwise>
                                <span class="link" style="margin-bottom:15px;"
                              onClick="workout_AddAdditionSetforWorkout({$SetItemID},{$ExerciseID});">Add Additional Set</span>
                            </xsl:otherwise>
                        </xsl:choose>-->
                    </td>
                </tr>
                <tr>
                    <td colspan="3" class="notesReply" style="width:100%; background-color: rgb(236, 239, 248); border: 1px dashed #D9D9D9; 
                             font-family: Calibri, Verdana, Arial;	font-size: 10pt; vertical-align: top;">
                        <xsl:value-of select="AjaxRequest/NotesHTML" disable-output-escaping="yes"/>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>
</xsl:stylesheet>
