<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />

  <telerik:RadEditor ID="RadEditor1" runat="server" onClientPasteHtml="onClientPasteHtml ">
    <MediaManager ViewPaths="~/Images" UploadPaths="~/Images" MaxUploadFileSize="10000000" SearchPatterns="*.mov"/>
  </telerik:RadEditor>
  <script type="text/javascript">
  fixMediaManagerHtml = function(args) 
{ 
    var div = document.createElement("DIV"); 
    Telerik.Web.UI.Editor.Utils.setElementInnerHtml(div, args.get_value()); 
    var obj = div.firstChild; 
    if (obj.tagName.toLowerCase() != "object") 
        return; 
 
    var embed = document.createElement("EMBED"); 
    embed.setAttribute("type", "movie/quicktime"); 
    embed.setAttribute("pluginspage", "http://www.apple.com/quicktime/download/"); 
 
    for (var i=0; i<obj.attributes.length; i++) 
    { 
        var node = obj.attributes[i] 
        if (node.name.toLowerCase() != "classid" && node.name.toLowerCase() != "type") 
            embed.setAttribute(node.name, node.value); 
    } 
 
    getExtension = function(filePath) 
    { 
        var match = filePath.match(/\.(\w+)$/); 
        return match ? match[1].toLowerCase() : null; 
    } 
 
    var node = obj.firstChild; 
    while (node != null) 
    { 
        if (node.nodeType == 1 && node.tagName.toLowerCase() == "param") 
        { 
            if (node.getAttribute("name") != "FileName") 
                embed.setAttribute(node.getAttribute("name"), node.getAttribute("value")); 
            else if (getExtension(node.getAttribute("value")) != "mov") 
                return; 
            else 
                embed.setAttribute("src", node.getAttribute("value")); 
        } 
        node = node.nextSibling; 
    } 
 
    div.innerHTML = ""; 
    div.appendChild(embed); 
    args.set_value(div.innerHTML); 
} 
 
onClientPasteHtml = function(editor, args) 
{ 
    if (args.get_commandName() == "MediaManager") 
    {
        fixMediaManagerHtml(args); 
    }
}
  </script>
    </form>
</body>
</html>
