﻿<?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="VideoURL" select="normalize-space(AjaxRequest/Params/VideoURL)"></xsl:variable>
        <xsl:variable name="Origin" select="AjaxRequest/Params/Origin"></xsl:variable>

        <xsl:choose>
            <xsl:when test="contains($VideoURL, 'dmcloud.net')">
                <xsl:choose>
                    <xsl:when test="$Origin = 'Action'">
                        <iframe frameborder="0" width="550" height="310" scrolling="no"
                                src="{$VideoURL}&amp;autoplay=1"></iframe>
                    </xsl:when>
                    <xsl:otherwise>
                        <iframe frameborder="0" width="250" height="200" scrolling="no"
                                src="{$VideoURL}&amp;autoplay=1"></iframe>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <object width="250" height="200">
                    <param name="movie" value="http://www.dailymotion.com/swf/video/{$VideoURL}&amp;autoplay=1"></param>
                    <param name="allowFullScreen" value="true"></param>
                    <param name="allowScriptAccess" value="always"></param>
                    <xsl:choose>
                        <xsl:when test="$Origin = 'Action'">
                            <embed src="http://www.dailymotion.com/swf/video/{$VideoURL}&amp;autoplay=1"
                                  type="application/x-shockwave-flash"
                                  width="490"
                                  height="350"
                                  allowfullscreen="true"></embed>
                        </xsl:when>
                        <xsl:otherwise>
                            <embed src="http://www.dailymotion.com/swf/video/{$VideoURL}&amp;autoplay=1"
                                   type="application/x-shockwave-flash"
                                   width="250"
                                   height="200"
                                   allowfullscreen="true"></embed>
                        </xsl:otherwise>
                    </xsl:choose>
                </object>
            </xsl:otherwise>            
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
