﻿<?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="/">
        <div id="div_UpdateExerciseList" >
            <table id="div_UpdateExerciseList_Content" cellpadding="0" cellspacing="0">
                <tbody id="div_UpdateExerciseList_Content_Body">
                    <xsl:call-template name="AddNewExercise">
                        <xsl:with-param name="PortalItemID" select="Exercises/ItemID"></xsl:with-param>
                        <xsl:with-param name="Origin" select="Exercises/Origin"></xsl:with-param>
                        <xsl:with-param name="ProgramID" select="Exercises/ProgramID"></xsl:with-param>
                        <xsl:with-param name="WorkoutID" select="Exercises/WorkoutID"></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="TypeID" select="Exercises/Exercise/TypeID"></xsl:with-param>
                        <xsl:with-param name="CustomType" select="Exercises/Exercise/CustomType"></xsl:with-param>
                        <xsl:with-param name="ThumbnailURL" select="Exercises/Exercise/ThumbnailURL"></xsl:with-param>
                        <xsl:with-param name="ImageURL" select="Exercises/Exercise/ImageURL"></xsl:with-param>
                        <xsl:with-param name="VideoURL" select="Exercises/Exercise/VideoURL"></xsl:with-param>
                        <xsl:with-param name="LevelYN" select="Exercises/Exercise/LevelYN"></xsl:with-param>
                        <xsl:with-param name="SetsYN" select="Exercises/Exercise/SetsYN"></xsl:with-param>
                        <xsl:with-param name="RepsYN" select="Exercises/Exercise/RepsYN"></xsl:with-param>
                        <xsl:with-param name="TimeYN" select="Exercises/Exercise/TimeYN"></xsl:with-param>
                        <xsl:with-param name="DistanceYN" select="Exercises/Exercise/DistanceYN"></xsl:with-param>
                        <xsl:with-param name="WeightYN" select="Exercises/Exercise/WeightYN"></xsl:with-param>
                        <xsl:with-param name="CaloriesYN" select="Exercises/Exercise/CaloriesYN"></xsl:with-param>
                        <xsl:with-param name="IsActive" select="Exercises/Exercise/IsActive"></xsl:with-param>
                        <xsl:with-param name="IsPublic" select="Exercises/Exercise/IsPublic"></xsl:with-param>
                        <xsl:with-param name="IsPublished" select="Exercises/Exercise/IsPublished"></xsl:with-param>
                        <xsl:with-param name="FitnessExerciseTypes" select="Exercises/FitnessExerciseTypes/."></xsl:with-param>
                    </xsl:call-template>
                </tbody>
            </table>
        </div>
    </xsl:template>

    <xsl:template name="AddNewExercise">
        <xsl:param name="PortalItemID" select="'N/A'"></xsl:param>
        <xsl:param name="Origin" select="'N/A'"></xsl:param>
        <xsl:param name="ProgramID" select="'N/A'"></xsl:param>
        <xsl:param name="WorkoutID" select="'N/A'"></xsl:param>
        <xsl:param name="FitnessExerciseTypes" select="'N/A'"></xsl:param>
        <xsl:param name="ExerciseID">
            <xsl:number value="-99"/>
        </xsl:param>
        <xsl:param name="ExerciseName"></xsl:param>
        <xsl:param name="Description"></xsl:param>
        <xsl:param name="TypeID">
            <xsl:number value ="-99"/>
        </xsl:param>
        <xsl:param name="CustomType"></xsl:param>
        <xsl:param name="ThumbnailURL"></xsl:param>
        <xsl:param name="ImageURL"></xsl:param>
        <xsl:param name="VideoURL"></xsl:param>
        <xsl:param name="LevelYN">
            <xsl:number value="1"/>
        </xsl:param>
        <xsl:param name="SetsYN">
            <xsl:number value="1"/>
        </xsl:param>
        <xsl:param name="RepsYN">
            <xsl:number value="1"/>
        </xsl:param>
        <xsl:param name="TimeYN">
            <xsl:number value="1"/>
        </xsl:param>
        <xsl:param name="DistanceYN">
            <xsl:number value="1"/>
        </xsl:param>
        <xsl:param name="WeightYN">
            <xsl:number value="1"/>
        </xsl:param>
        <xsl:param name="CaloriesYN">
            <xsl:number value="1"/>
        </xsl:param>
        <xsl:param name="IsActive">
            <xsl:number value="1"/>
        </xsl:param>
        <xsl:param name="IsPublic">
            <xsl:number value="1"/>
        </xsl:param>
        <xsl:param name="IsPublished">
            <xsl:number value="1"/>
        </xsl:param>

        <div id="div_{$PortalItemID}_{$ExerciseID}_AddNewUpdateExercise">
                <input id="txtAddNewPortalItemID" type="hidden" value="{$PortalItemID}"/>
            <table class="tableMaster" id="div_ClientPortal_AddNewExercise">
                <tr>
                    <td width="25%">
                        <span class="labelFormFields" style="font-size: 9pt;">Name</span>
                    </td>
                    <td width="75%">
                        <input id="txt_{$PortalItemID}_{$ExerciseID}_ExerciseName" type="text"  value="{$ExerciseName}" class="text"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields" style="font-size: 9pt;">Description</span>
                    </td>
                    <td>                        
                        <textarea id="txt_{$PortalItemID}_{$ExerciseID}_txtDescription"  type="text"  style="width: 340px;height:150px;"  class="wideText">
                            <xsl:value-of select="normalize-space($Description)"/>
                        </textarea>
                    </td>                    
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields" style="font-size: 9pt;">Type</span>
                    </td>
                    <td>
                        <select id="txt_{$PortalItemID}_{$ExerciseID}_ddlType" name="Type" class="smallDropdown">
                            <option value="-1" selected="selected">
                                Select
                            </option>
                            <xsl:for-each select="$FitnessExerciseTypes/FitnessExerciseType">

                                <xsl:choose>
                                    <xsl:when test="FitnessExerciseTypeID = $TypeID">
                                        <option value="{FitnessExerciseTypeID}" selected="selected">
                                            <xsl:value-of select="FitnessExerciseType"/>
                                        </option>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <option value="{FitnessExerciseTypeID}">
                                            <xsl:value-of select="FitnessExerciseType"/>
                                        </option>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:for-each>
                        </select>
                        <input id="txt_{$PortalItemID}_{$ExerciseID}_txtCustomType" type="text" value="{$CustomType}" class="text" style="width:237px;"></input>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields" style="font-size: 9pt;">Thumbnail URL</span>
                    </td>
                    <td>
                        <input id="txt_{$PortalItemID}_{$ExerciseID}_thumbnailURL" type="text" value="{$ThumbnailURL}" class="text"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields" style="font-size: 9pt;">Image URL</span>
                    </td>
                    <td>
                        <input id="txt_{$PortalItemID}_{$ExerciseID}_imageURL" value="{$ImageURL}" type="text" class="text"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields" style="font-size: 9pt;">Video URL</span>
                    </td>
                    <td>
                        <input id="txt_{$PortalItemID}_{$ExerciseID}_videoURL" type="text" value="{$VideoURL}" class="text"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields" style="font-size: 9pt;">Measures</span>
                    </td>
                    <td>
                        <xsl:choose>
                            <xsl:when test="$SetsYN = 1 ">
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkSets" value="{$SetsYN}" class="taskFilter" checked="checked"/>
                                <span class="taskFilter">Sets</span>
                            </xsl:when>
                            <xsl:otherwise>
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkSets" value="{$SetsYN}" class="taskFilter"/>
                                <span class="taskFilter">Sets</span>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:choose>
                            <xsl:when test="$RepsYN = 1 ">
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkReps" value="{$RepsYN}" class="taskFilter" checked="checked"/>
                                <span class="taskFilter">Reps</span>
                            </xsl:when>
                            <xsl:otherwise>
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkReps" value="{$RepsYN}" class="taskFilter"/>
                                <span class="taskFilter">Reps</span>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:choose>
                            <xsl:when test="$LevelYN = 1">
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkLevel" value="{$LevelYN}" class="taskFilter" checked="checked"/>
                                <span class="taskFilter">Levels</span>
                            </xsl:when>
                            <xsl:otherwise>
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkLevel" value="{$LevelYN}" class="taskFilter"/>
                                <span class="taskFilter">Levels</span>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:choose>
                            <xsl:when test="$TimeYN = 1">
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkTime" value="{$TimeYN}" class="taskFilter" checked="checked"/>
                                <span class="taskFilter">Time</span>
                            </xsl:when>
                            <xsl:otherwise>
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkTime" value="{$TimeYN}" class="taskFilter"/>
                                <span class="taskFilter">Time</span>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:choose>
                            <xsl:when test="$DistanceYN = 1">
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkDistance" value="{$DistanceYN}" class="taskFilter" checked="checked"/>
                                <span class="taskFilter">Dist</span>
                            </xsl:when>
                            <xsl:otherwise>
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkDistance" value="{$DistanceYN}" class="taskFilter"/>
                                <span class="taskFilter">Dist</span>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:choose>
                            <xsl:when test="$WeightYN = 1">
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkWeight" value="{$WeightYN}" class="taskFilter" checked="checked"/>
                                <span class="taskFilter">Weight</span>
                            </xsl:when>
                            <xsl:otherwise>
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkWeight" value="{$WeightYN}" class="taskFilter"/>
                                <span class="taskFilter">Weight</span>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:choose>
                            <xsl:when test="$CaloriesYN = 1">
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkCalories" value="{$CaloriesYN}" class="taskFilter" checked="checked"/>
                                <span class="taskFilter">Cals</span>
                            </xsl:when>
                            <xsl:otherwise>
                                <input type="checkbox" id="txt_{$PortalItemID}_{$ExerciseID}_chkCalories" value="{$CaloriesYN}" class="taskFilter"/>
                                <span class="taskFilter">Cals</span>
                            </xsl:otherwise>
                        </xsl:choose>
                    </td>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields" style="font-size: 9pt;">Active</span>
                    </td>
                    <xsl:choose>
                        <xsl:when test="$IsActive = 1">
                            <td>
                                <select id="txt_{$PortalItemID}_{$ExerciseID}_ddlActive" name="Type" class="smallDropdown">                                   
                                    <option value="1" selected="selected">
                                        <xsl:text>Yes</xsl:text>
                                    </option>
                                    <option value="0">
                                        <xsl:text>No</xsl:text>
                                    </option>
                                </select>
                            </td>
                        </xsl:when>
                        <xsl:when test="$IsActive = 0">
                            <td>
                                <select id="txt_{$PortalItemID}_{$ExerciseID}_ddlActive" name="Type" class="smallDropdown">                                   
                                    <option value="1" >
                                        <xsl:text>Yes</xsl:text>
                                    </option>
                                    <option value="0" selected="selected">
                                        <xsl:text>No</xsl:text>
                                    </option>
                                </select>
                            </td>
                        </xsl:when>
                        <xsl:otherwise>
                            <td>
                                <select id="txt_{$PortalItemID}_{$ExerciseID}_ddlActive" name="Type" class="smallDropdown">                                  
                                    <option value="1" selected="selected">
                                        <xsl:text>Yes</xsl:text>
                                    </option>
                                    <option value="0">
                                        <xsl:text>No</xsl:text>
                                    </option>
                                </select>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields" style="font-size: 9pt;">Public</span>
                    </td>
                    <xsl:choose>
                        <xsl:when test="$IsPublic = 1">
                            <td>
                                <select id="txt_{$PortalItemID}_{$ExerciseID}_ddlPublic" name="Type" class="smallDropdown">                                   
                                    <option value="1" selected="selected">
                                        <xsl:text>Yes</xsl:text>
                                    </option>
                                    <option value="0">
                                        <xsl:text>No</xsl:text>
                                    </option>
                                </select>
                            </td>
                        </xsl:when>
                        <xsl:when test="$IsPublic = 0">
                            <td>
                                <select id="txt_{$PortalItemID}_{$ExerciseID}_ddlPublic" name="Type" class="smallDropdown">                                   
                                    <option value="1" >
                                        <xsl:text>Yes</xsl:text>
                                    </option>
                                    <option value="0" selected="selected">
                                        <xsl:text>No</xsl:text>
                                    </option>
                                </select>
                            </td>
                        </xsl:when>
                        <xsl:otherwise>
                            <td>
                                <select id="txt_{$PortalItemID}_{$ExerciseID}_ddlPublic" name="Type" class="smallDropdown">                                   
                                    <option value="1" >
                                        <xsl:text>Yes</xsl:text>
                                    </option>
                                    <option value="0" selected="selected">
                                        <xsl:text>No</xsl:text>
                                    </option>
                                </select>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>
                </tr>
                <tr>
                    <td>
                        <span class="labelFormFields" style="font-size: 9pt;">Published</span>
                    </td>
                    <xsl:choose>
                        <xsl:when test="$IsPublished = 1">
                            <td>
                                <select id="txt_{$PortalItemID}_{$ExerciseID}_ddlPublished" name="Type" class="smallDropdown">                                   
                                    <option value="1" selected="selected">
                                        <xsl:text>Yes</xsl:text>
                                    </option>
                                    <option value="0">
                                        <xsl:text>No</xsl:text>
                                    </option>
                                </select>
                            </td>
                        </xsl:when>
                        <xsl:when test ="$IsPublished = 0">
                            <td>
                                <select id="txt_{$PortalItemID}_{$ExerciseID}_ddlPublished" name="Type" class="smallDropdown">                                    
                                    <option value="1" >
                                        <xsl:text>Yes</xsl:text>
                                    </option>
                                    <option value="0" selected="selected">
                                        <xsl:text>No</xsl:text>
                                    </option>
                                </select>
                            </td>
                        </xsl:when>
                        <xsl:otherwise>
                            <td>
                                <select id="txt_{$PortalItemID}_{$ExerciseID}_ddlPublished" name="Type" class="smallDropdown">                                   
                                    <option value="1" >
                                        <xsl:text>Yes</xsl:text>
                                    </option>
                                    <option value="0" selected="selected">
                                        <xsl:text>No</xsl:text>
                                    </option>
                                </select>
                            </td>
                        </xsl:otherwise>
                    </xsl:choose>
                </tr>

                <xsl:choose>
                    <xsl:when test="$ExerciseID > 0">
                        <tr>
                            <td colspan="2">
                                <input type="button" class="button" value="Update" style="margin-left:10px;margin-top:10px;"
                               onClick="return workoutTracker_UpdateExercise('{normalize-space($PortalItemID)}','{$ExerciseID}',
                                            'txt_{$PortalItemID}_{$ExerciseID}_ExerciseName', 'txt_{$PortalItemID}_{$ExerciseID}_txtDescription',
                                            'txt_{$PortalItemID}_{$ExerciseID}_ddlType','txt_{$PortalItemID}_{$ExerciseID}_txtCustomType',
                                            'txt_{$PortalItemID}_{$ExerciseID}_thumbnailURL','txt_{$PortalItemID}_{$ExerciseID}_imageURL',
                                            'txt_{$PortalItemID}_{$ExerciseID}_videoURL','txt_{$PortalItemID}_{$ExerciseID}_chkLevel',
                                            'txt_{$PortalItemID}_{$ExerciseID}_chkSets','txt_{$PortalItemID}_{$ExerciseID}_chkReps',
                                            'txt_{$PortalItemID}_{$ExerciseID}_chkTime','txt_{$PortalItemID}_{$ExerciseID}_chkDistance',
                                            'txt_{$PortalItemID}_{$ExerciseID}_chkWeight','txt_{$PortalItemID}_{$ExerciseID}_chkCalories',
                                            'txt_{$PortalItemID}_{$ExerciseID}_ddlActive','txt_{$PortalItemID}_{$ExerciseID}_ddlPublic',
                                            'txt_{$PortalItemID}_{$ExerciseID}_ddlPublished','div_{$PortalItemID}_{$ExerciseID}_Operations');"></input>
                           
                                <input type="button" class="button" value="Cancel" style="margin-left:10px;margin-top:10px;"
                                       onClick="workoutTracker_CloseUpdateExerciseBox('div_{$PortalItemID}_{$ExerciseID}_Operations');"></input>
                            </td>
                        </tr>
                    </xsl:when>
                    <xsl:otherwise>
                        <tr>
                            <td colspan="2">
                                <input type="button" class="button" value="Submit" style="margin-left:10px;margin-top:10px;"
                             onClick="return workoutTracker_AddExercise('{normalize-space($PortalItemID)}','txt_{$PortalItemID}_{$ExerciseID}_ExerciseName',
                                            'txt_{$PortalItemID}_{$ExerciseID}_txtDescription',
                                            'txt_{$PortalItemID}_{$ExerciseID}_ddlType','txt_{$PortalItemID}_{$ExerciseID}_txtCustomType',
                                            'txt_{$PortalItemID}_{$ExerciseID}_thumbnailURL','txt_{$PortalItemID}_{$ExerciseID}_imageURL',
                                            'txt_{$PortalItemID}_{$ExerciseID}_videoURL','txt_{$PortalItemID}_{$ExerciseID}_chkLevel',
                                            'txt_{$PortalItemID}_{$ExerciseID}_chkSets','txt_{$PortalItemID}_{$ExerciseID}_chkReps',
                                            'txt_{$PortalItemID}_{$ExerciseID}_chkTime','txt_{$PortalItemID}_{$ExerciseID}_chkDistance',
                                            'txt_{$PortalItemID}_{$ExerciseID}_chkWeight','txt_{$PortalItemID}_{$ExerciseID}_chkCalories',
                                            'txt_{$PortalItemID}_{$ExerciseID}_ddlActive','txt_{$PortalItemID}_{$ExerciseID}_ddlPublic',
                                            'txt_{$PortalItemID}_{$ExerciseID}_ddlPublished','div_ExerciseList_{$PortalItemID}_Add','{$ProgramID}','{$Origin}','{$WorkoutID}');"></input>
                                <xsl:choose>
                                    <xsl:when test ="$Origin = 'DisplayAddExcercise'">
                                        <input type="button" class="button" value="Cancel" style="margin-left:10px;margin-top:10px;"
                                      onClick="workoutTracker_CloseUpdateExerciseBox('divInsertProgramExcerciseLink');"></input>
                                    </xsl:when>
                                    <xsl:when test="$Origin = 'DisplayAddExcerciseToWorkout'">
                                        <input type="button" class="button" value="Cancel" style="margin-left:10px;margin-top:10px;"
                                     onClick="workoutTracker_CloseUpdateExerciseBox('div_Exercise_Operations');"></input>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <input type="button" class="button" value="Cancel" style="margin-left:10px;margin-top:10px;"
                                       onClick="workoutTracker_CloseAddNewExerciseBox('div_ExerciseList_{$PortalItemID}_Add_Operations', 
                               'div_ExerciseList_{$PortalItemID}_Add_Control');"></input>
                                    </xsl:otherwise>
                                </xsl:choose>
                                
                            </td>
                        </tr>
                    </xsl:otherwise>
                </xsl:choose>
            </table>
        </div>
    </xsl:template>
</xsl:stylesheet>
