﻿<?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" omit-xml-declaration ="yes"/>

    <xsl:template match="/">
        <xsl:variable name="TemplateURL" select="normalize-space(AjaxRequest/TemplateURL)"/>
        <xsl:variable name="HostName" select="normalize-space(AjaxRequest/HostName)"/>
        <xsl:variable name="BrandVideoURL" select="normalize-space(AjaxRequest/Params/VideoURL)"/>
        <xsl:variable name="VideoKeyValue" select="normalize-space(AjaxRequest/VideoKeyValue)"/>
        <xsl:choose>
            <xsl:when test="$BrandVideoURL != ''">
                <div style="margin-top:10px;" align="center">
                    <xsl:choose>
                        <xsl:when test="contains($BrandVideoURL,'youtube') or contains($BrandVideoURL,'youtu.be')">
                            <div id="divVideoContainer">
                                <object width="391"
                                            height="220">
                                    <param name="movie" value="http://www.youtube.com/v/{$VideoKeyValue}?autoplay=1&amp;version=3&amp;autohide=1&amp;showinfo=0"></param>
                                    <param name="allowFullScreen" value="true"></param>
                                    <param name="allowScriptAccess" value="always"></param>
                                    <embed src="http://www.youtube.com/v/{$VideoKeyValue}?autoplay=1&amp;version=3&amp;autohide=1&amp;showinfo=0"
                                            type="application/x-shockwave-flash"
                                            allowfullscreen="true"
                                            allowscriptaccess="always"
                                            width="391"
                                            height="220"
                                                                >
                                    </embed>
                                </object>
                            </div>
                        </xsl:when>
                        <xsl:when test ="contains($BrandVideoURL,'vimeo')">
                            <div id="divVideoContainer">
                                <iframe src="http://player.vimeo.com/video/{$VideoKeyValue}?autoplay=1&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1"
                                                  width="391"
                                                   height="220"
                                                   frameborder="0">
                                </iframe>
                            </div>
                        </xsl:when>
                        <xsl:when test="contains($BrandVideoURL,'dailymotion')">
                            <object width="391" height="220">
                                <param name="movie" value="http://www.dailymotion.com/swf/video/{$VideoKeyValue}&amp;autoplay=1"></param>
                                <param name="allowFullScreen" value="true"></param>
                                <param name="allowScriptAccess" value="always"></param>
                                <embed src="http://www.dailymotion.com/swf/video/{$VideoKeyValue}&amp;autoplay=1"
                                       type="application/x-shockwave-flash"
                                       width="391"
                                       height="220"
                                       allowfullscreen="true"></embed>
                            </object>
                        </xsl:when>
                        <xsl:when test="contains($BrandVideoURL,'dmcloud.net')">
                            <iframe frameborder="0" width="391" height="220"
                                            src="{$BrandVideoURL}&amp;autoplay=1"></iframe>
                        </xsl:when>
                        <xsl:otherwise>
                            <div id="divWorkoutVideoContainer" style="display:block;">
                            </div>
                            <script type='text/javascript'>
                                LoadAudioFiles('divVideoContainer','<xsl:value-of select ="$BrandVideoURL"/>');
                            </script>
                        </xsl:otherwise>
                    </xsl:choose>
                </div>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
