﻿<?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="ImageURL" select="AjaxRequest/AttachedItemDetail/ImageURL"></xsl:variable>
        <xsl:variable name="Title" select="AjaxRequest/AttachedItemDetail/Title"></xsl:variable>
        <xsl:variable name="Summary" select="AjaxRequest/AttachedItemDetail/Summary"></xsl:variable>
        <xsl:variable name="AttachedItemID" select="AjaxRequest/AttachedItemDetail/AttachedItemID"></xsl:variable>
        <xsl:variable name="HostName" select="AjaxRequest/HostName"></xsl:variable>
        <xsl:variable name="ItemTypeID" select="AjaxRequest/AttachedItemDetail/ItemTypeID"></xsl:variable>
        <xsl:variable name="PromoteKey" select="AjaxRequest/AttachedItemDetail/PromoteKey"></xsl:variable>
        <xsl:variable name="ContentType" select="AjaxRequest/AttachedItemDetail/ContentType"></xsl:variable>
        <xsl:variable name="VideoURL" select="AjaxRequest/AttachedItemDetail/URL"></xsl:variable>
        <xsl:variable name="VideoKeyValue" select="AjaxRequest/VideoKeyValue"></xsl:variable>
        <xsl:variable name="TemplatePathURL" select="AjaxRequest/TemplateURL"></xsl:variable>
        <xsl:variable name="VimeoThumbnailURL" select="AjaxRequest/VimeoThumbnailURL"></xsl:variable>


        <div id="Action_AttachedItem">
            <table class="tableMaster">
                <tr>
                    <td width="10%">
                        <xsl:choose>
                            <xsl:when test="$ItemTypeID = 22">
                                <a href="http://{$HostName}/Publication.aspx?ID={normalize-space($AttachedItemID)}" target="_blank">
                                    <img src ="{$ImageURL}" onload='setWidthAndHeightImage(this,"80");'
										 style="margin-right:5px;margin-top:3px;width:30px;height:30px;"></img>
                                </a>
                            </xsl:when>
                            <xsl:when test="$ItemTypeID = 19">
                                <xsl:choose>
                                    <xsl:when test="$ContentType = 'Video'">
                                        <xsl:choose>
                                            <xsl:when test="contains($VideoURL,'youtube')">
                                                <div id="divVideoContainer">
                                                    <!--<a href="http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}" target="_blank">-->
                                                        <div>
                                                            <img src="http://img.youtube.com/vi/{$VideoKeyValue}/1.jpg" class="link" style="width:30px;height:30px;"
                                                              title="Play Video" onClick="workout_LoadYouTubeVideo('{$VideoKeyValue}','divVideoContainer','Action');"></img>
                                                        </div>
                                                        <div style="margin-top:-30px;">

                                                            <img class="link" title ="Play Video"
                                                                 onClick="workout_LoadYouTubeVideo('{$VideoKeyValue}','divVideoContainer','Action');"
                                                                 src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>

                                                        </div>
                                                    <!--</a>-->
                                                </div>
                                            </xsl:when>
                                            <xsl:when test ="contains($VideoURL, 'vimeo')">
                                                <div id="divWorkOutYouTubeVideoContainer" style="margin-bottom:15px; margin-right:5px;">
                                                    <div id="divVideoContainer">
                                                        <!--<a href="http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}" target="_blank">-->
                                                            <div>
                                                                <!--<img src="{$VimeoThumbnailURL}" class="link" width="120" height="90"
                                                                   title="Play Video"
                                                                   onClick="LoadVimeoVideo('{$VideoKeyValue}','divVideoContainer','Action');"></img>-->
                                                                <img src="{$VimeoThumbnailURL}" class="link" width="120" height="90"
                                                                   title="Play Video"
                                                                   onClick="OpenSpecifiedURL('http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}');"></img>
                                                            </div>
                                                            <div style="margin-top:-30px;">

                                                                <!--<img class="link" title ="Play Video"
                                                                     onClick="LoadVimeoVideo('{$VideoKeyValue}','divVideoContainer','Action');"
                                                                     src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>-->

                                                                <img class="link" title ="Play Video"
                                                                   onClick="OpenSpecifiedURL('http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}');"
                                                                     src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>

                                                            </div>
                                                        <!--</a>-->
                                                    </div>
                                                </div>
                                            </xsl:when>
                                            <xsl:when test="contains($VideoURL, 'dailymotion')">
                                                <div id="divWorkOutYouTubeVideoContainer" style="margin-bottom:15px; margin-right:5px;">
                                                    <div id="divVideoContainer">
                                                        <!--<a href="http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}" target="_blank">-->
                                                            <div>
                                                                <!--<img src="http://www.dailymotion.com/thumbnail/video/{$VideoKeyValue}" class="link" width="120" height="90"
                                                                   title="Play Video" onClick="LoadDailyMotionVideo('{$VideoKeyValue}','divVideoContainer','Action');"></img>-->
                                                                <img src="http://www.dailymotion.com/thumbnail/video/{$VideoKeyValue}" class="link" width="120" height="90"
                                                                   title="Play Video" onClick="OpenSpecifiedURL('http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}');"></img>
                                                            </div>
                                                            <div style="margin-top:-30px;">
                                                                <!--<img class="link" title ="Play Video"
                                                                     onClick="LoadDailyMotionVideo('{$VideoKeyValue}','divVideoContainer','Action');"
                                                                     src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>-->
                                                                <img class="link" title ="Play Video"
                                                                    onClick="OpenSpecifiedURL('http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}');"
                                                                    src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>
                                                            </div>
                                                        <!--</a>-->
                                                    </div>
                                                </div>
                                            </xsl:when>
                                            <xsl:when test="contains($VideoURL, 'dmcloud.net')">
                                                <div id="divWorkOutYouTubeVideoContainer" style="margin-bottom:15px; margin-right:5px;">
                                                    <div id="divVideoContainer">
                                                        <!--<a href="http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}" target="_blank">-->
                                                            <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}','divVideoContainer','Action');"></img>-->

                                                                <img src="http://static.dmcloud.net/{$VimeoThumbnailURL}/jpeg_thumbnail_medium-1308342384.jpeg" class="link" width="120" height="90"
                                                                  title="Play Video" onClick="OpenSpecifiedURL('http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}');"></img>
                                                            </div>
                                                            <div style="margin-top:-30px;">
                                                                <!--<img class="link" title ="Play Video"
                                                                     onClick="LoadDailyMotionVideo('{$VideoURL}','divVideoContainer','Action');"
                                                                     src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>-->
                                                                <img class="link" title ="Play Video"
                                                                    onClick="OpenSpecifiedURL('http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}');"
                                                                    src="{$TemplatePathURL}/Web/Images/Play_Icon.png" width="30" height="30"></img>
                                                            </div>
                                                        <!--</a>-->
                                                    </div>
                                                </div>
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <!--<xsl:value-of select ="$VideoURL"/>-->
                                                <div id="divWorkoutVideoContainer" style="display:block;">
                                                </div>
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <a href="http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}" target="_blank">
                                            <img src ="{$ImageURL}" onload='setWidthAndHeightImage(this,"80");' style="margin-right:5px;margin-top:3px;"></img>
                                        </a>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:when>
                            <xsl:when test="$ItemTypeID = 23">
                                <a href="http://{$HostName}/{$PromoteKey}" target="_blank">
                                    <img src ="{$ImageURL}" onload='setWidthAndHeightImage(this,"80");' style="margin-right:5px;margin-top:3px;"></img>
                                </a>
                            </xsl:when>
                        </xsl:choose>
                    </td>
                    <td>
                        <div id="div_AttachedItemTitle">
                            <xsl:choose>
                                <xsl:when test="$ItemTypeID = 22">
                                    <a href="http://{$HostName}/Publication.aspx?ID={normalize-space($AttachedItemID)}"
                                            class="link" target="_blank">
                                        <xsl:value-of select="$Title"/>
                                    </a>
                                </xsl:when>
                                <xsl:when test="$ItemTypeID = 19">
                                    <a href="http://{$HostName}/Content.aspx?ID={normalize-space($AttachedItemID)}"
                                            class="link" target="_blank">
                                        <xsl:value-of select="$Title"/>
                                    </a>
                                </xsl:when>
                                <xsl:when test="$ItemTypeID = 23">
                                    <a href="http://{$HostName}/{$PromoteKey}"
                                            class="link" target="_blank">
                                        <xsl:value-of select="$Title"/>
                                    </a>
                                </xsl:when>
                            </xsl:choose>
                        </div>
                        <div id="div_AttachedItemSummary">
                            <span class="label">
                                <xsl:value-of select="$Summary"/>
                            </span>
                        </div>
                    </td>
                </tr>
            </table>
        </div>

    </xsl:template>
</xsl:stylesheet>
