home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Plugins / tinymce-advanced / mce / media / jscripts / media.js < prev   
Encoding:
Text File  |  2008-02-20  |  17.5 KB  |  595 lines

  1. var oldWidth, oldHeight;
  2. var url = tinyMCE.getParam("media_external_list_url");
  3. if (url != null) {
  4.     // Fix relative
  5.     if (url.charAt(0) != '/' && url.indexOf('://') == -1)
  6.         url = tinyMCE.documentBasePath + "/" + url;
  7.  
  8.     document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></sc'+'ript>');
  9. }
  10.  
  11. function init() {
  12.     var pl = "", f, val;
  13.     var type = "flash", fe, i;
  14.  
  15.     tinyMCEPopup.resizeToInnerSize();
  16.     f = document.forms[0]
  17.  
  18.     fe = tinyMCE.selectedInstance.getFocusElement();
  19.     if (/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(tinyMCE.getAttrib(fe, 'class'))) {
  20.         pl = "x={" + fe.title + "};";
  21.  
  22.         switch (tinyMCE.getAttrib(fe, 'class')) {
  23.             case 'mceItemFlash':
  24.                 type = 'flash';
  25.                 break;
  26.  
  27.             case 'mceItemShockWave':
  28.                 type = 'shockwave';
  29.                 break;
  30.  
  31.             case 'mceItemWindowsMedia':
  32.                 type = 'wmp';
  33.                 break;
  34.  
  35.             case 'mceItemQuickTime':
  36.                 type = 'qt';
  37.                 break;
  38.  
  39.             case 'mceItemRealMedia':
  40.                 type = 'rmp';
  41.                 break;
  42.         }
  43.  
  44.         document.forms[0].insert.value = tinyMCE.getLang('lang_update', 'Insert', true); 
  45.     }
  46.  
  47.     document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media');
  48.     document.getElementById('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','qt_qtsrc','media','media');
  49.     document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
  50.  
  51.     var html = getMediaListHTML('filebrowser','src','media','media');
  52.     if (html == "")
  53.         document.getElementById("linklistrow").style.display = 'none';
  54.     else
  55.         document.getElementById("linklistcontainer").innerHTML = html;
  56.  
  57.     // Resize some elements
  58.     if (isVisible('filebrowsercontainer'))
  59.         document.getElementById('src').style.width = '230px';
  60.  
  61.     // Setup form
  62.     if (pl != "") {
  63.         pl = eval(pl);
  64.  
  65.         switch (type) {
  66.             case "flash":
  67.                 setBool(pl, 'flash', 'play');
  68.                 setBool(pl, 'flash', 'loop');
  69.                 setBool(pl, 'flash', 'menu');
  70.                 setBool(pl, 'flash', 'swliveconnect');
  71.                 setStr(pl, 'flash', 'quality');
  72.                 setStr(pl, 'flash', 'scale');
  73.                 setStr(pl, 'flash', 'salign');
  74.                 setStr(pl, 'flash', 'wmode');
  75.                 setStr(pl, 'flash', 'base');
  76.                 setStr(pl, 'flash', 'flashvars');
  77.             break;
  78.  
  79.             case "qt":
  80.                 setBool(pl, 'qt', 'loop');
  81.                 setBool(pl, 'qt', 'autoplay');
  82.                 setBool(pl, 'qt', 'cache');
  83.                 setBool(pl, 'qt', 'controller');
  84.                 setBool(pl, 'qt', 'correction');
  85.                 setBool(pl, 'qt', 'enablejavascript');
  86.                 setBool(pl, 'qt', 'kioskmode');
  87.                 setBool(pl, 'qt', 'autohref');
  88.                 setBool(pl, 'qt', 'playeveryframe');
  89.                 setBool(pl, 'qt', 'tarsetcache');
  90.                 setStr(pl, 'qt', 'scale');
  91.                 setStr(pl, 'qt', 'starttime');
  92.                 setStr(pl, 'qt', 'endtime');
  93.                 setStr(pl, 'qt', 'tarset');
  94.                 setStr(pl, 'qt', 'qtsrcchokespeed');
  95.                 setStr(pl, 'qt', 'volume');
  96.                 setStr(pl, 'qt', 'qtsrc');
  97.             break;
  98.  
  99.             case "shockwave":
  100.                 setBool(pl, 'shockwave', 'sound');
  101.                 setBool(pl, 'shockwave', 'progress');
  102.                 setBool(pl, 'shockwave', 'autostart');
  103.                 setBool(pl, 'shockwave', 'swliveconnect');
  104.                 setStr(pl, 'shockwave', 'swvolume');
  105.                 setStr(pl, 'shockwave', 'swstretchstyle');
  106.                 setStr(pl, 'shockwave', 'swstretchhalign');
  107.                 setStr(pl, 'shockwave', 'swstretchvalign');
  108.             break;
  109.  
  110.             case "wmp":
  111.                 setBool(pl, 'wmp', 'autostart');
  112.                 setBool(pl, 'wmp', 'enabled');
  113.                 setBool(pl, 'wmp', 'enablecontextmenu');
  114.                 setBool(pl, 'wmp', 'fullscreen');
  115.                 setBool(pl, 'wmp', 'invokeurls');
  116.                 setBool(pl, 'wmp', 'mute');
  117.                 setBool(pl, 'wmp', 'stretchtofit');
  118.                 setBool(pl, 'wmp', 'windowlessvideo');
  119.                 setStr(pl, 'wmp', 'balance');
  120.                 setStr(pl, 'wmp', 'baseurl');
  121.                 setStr(pl, 'wmp', 'captioningid');
  122.                 setStr(pl, 'wmp', 'currentmarker');
  123.                 setStr(pl, 'wmp', 'currentposition');
  124.                 setStr(pl, 'wmp', 'defaultframe');
  125.                 setStr(pl, 'wmp', 'playcount');
  126.                 setStr(pl, 'wmp', 'rate');
  127.                 setStr(pl, 'wmp', 'uimode');
  128.                 setStr(pl, 'wmp', 'volume');
  129.             break;
  130.  
  131.             case "rmp":
  132.                 setBool(pl, 'rmp', 'autostart');
  133.                 setBool(pl, 'rmp', 'loop');
  134.                 setBool(pl, 'rmp', 'autogotourl');
  135.                 setBool(pl, 'rmp', 'center');
  136.                 setBool(pl, 'rmp', 'imagestatus');
  137.                 setBool(pl, 'rmp', 'maintainaspect');
  138.                 setBool(pl, 'rmp', 'nojava');
  139.                 setBool(pl, 'rmp', 'prefetch');
  140.                 setBool(pl, 'rmp', 'shuffle');
  141.                 setStr(pl, 'rmp', 'console');
  142.                 setStr(pl, 'rmp', 'controls');
  143.                 setStr(pl, 'rmp', 'numloop');
  144.                 setStr(pl, 'rmp', 'scriptcallbacks');
  145.             break;
  146.         }
  147.  
  148.         setStr(pl, null, 'src');
  149.         setStr(pl, null, 'id');
  150.         setStr(pl, null, 'name');
  151.         setStr(pl, null, 'vspace');
  152.         setStr(pl, null, 'hspace');
  153.         setStr(pl, null, 'bgcolor');
  154.         setStr(pl, null, 'align');
  155.         setStr(pl, null, 'width');
  156.         setStr(pl, null, 'height');
  157.  
  158.         if ((val = tinyMCE.getAttrib(fe, "width")) != "")
  159.             pl.width = f.width.value = val;
  160.  
  161.         if ((val = tinyMCE.getAttrib(fe, "height")) != "")
  162.             pl.height = f.height.value = val;
  163.  
  164.         oldWidth = pl.width ? parseInt(pl.width) : 0;
  165.         oldHeight = pl.height ? parseInt(pl.height) : 0;
  166.     } else
  167.         oldWidth = oldHeight = 0;
  168.  
  169.     selectByValue(f, 'media_type', type);
  170.     changedType(type);
  171.     updateColor('bgcolor_pick', 'bgcolor');
  172.  
  173.     TinyMCE_EditableSelects.init();
  174.     generatePreview();
  175. }
  176.  
  177. function insertMedia() {
  178.     var fe, f = document.forms[0], h;
  179.  
  180.     if (!AutoValidator.validate(f)) {
  181.         alert(tinyMCE.getLang('lang_invalid_data'));
  182.         return false;
  183.     }
  184.  
  185.     f.width.value = f.width.value == "" ? 100 : f.width.value;
  186.     f.height.value = f.height.value == "" ? 100 : f.height.value;
  187.  
  188.     fe = tinyMCE.selectedInstance.getFocusElement();
  189.     if (fe != null && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(tinyMCE.getAttrib(fe, 'class'))) {
  190.         switch (f.media_type.options[f.media_type.selectedIndex].value) {
  191.             case "flash":
  192.                 fe.className = "mceItemFlash";
  193.                 break;
  194.  
  195.             case "shockwave":
  196.                 fe.className = "mceItemShockWave";
  197.                 break;
  198.  
  199.             case "qt":
  200.                 fe.className = "mceItemQuickTime";
  201.                 break;
  202.  
  203.             case "wmp":
  204.                 fe.className = "mceItemWindowsMedia";
  205.                 break;
  206.  
  207.             case "rmp":
  208.                 fe.className = "mceItemRealMedia";
  209.                 break;
  210.         }
  211.  
  212.         if (fe.width != f.width.value || fe.height != f.height.height)
  213.             tinyMCE.selectedInstance.repaint();
  214.  
  215.         fe.title = serializeParameters();
  216.         fe.width = f.width.value;
  217.         fe.height = f.height.value;
  218.         fe.style.width = f.width.value + (f.width.value.indexOf('%') == -1 ? 'px' : '');
  219.         fe.style.height = f.height.value + (f.height.value.indexOf('%') == -1 ? 'px' : '');
  220.         fe.align = f.align.options[f.align.selectedIndex].value;
  221.     } else {
  222.         h = '<img src="' + tinyMCE.getParam("theme_href") + '/images/spacer.gif"' ;
  223.  
  224.         switch (f.media_type.options[f.media_type.selectedIndex].value) {
  225.             case "flash":
  226.                 h += ' class="mceItemFlash"';
  227.                 break;
  228.  
  229.             case "shockwave":
  230.                 h += ' class="mceItemShockWave"';
  231.                 break;
  232.  
  233.             case "qt":
  234.                 h += ' class="mceItemQuickTime"';
  235.                 break;
  236.  
  237.             case "wmp":
  238.                 h += ' class="mceItemWindowsMedia"';
  239.                 break;
  240.  
  241.             case "rmp":
  242.                 h += ' class="mceItemRealMedia"';
  243.                 break;
  244.         }
  245.  
  246.         h += ' title="' + serializeParameters() + '"';
  247.         h += ' width="' + f.width.value + '"';
  248.         h += ' height="' + f.height.value + '"';
  249.         h += ' align="' + f.align.options[f.align.selectedIndex].value + '"';
  250.  
  251.         h += ' />';
  252.  
  253.         tinyMCE.selectedInstance.execCommand('mceInsertContent', false, h);
  254.     }
  255.  
  256.     tinyMCEPopup.close();
  257. }
  258.  
  259. function getMediaListHTML() {
  260.     if (typeof(tinyMCEMediaList) != "undefined" && tinyMCEMediaList.length > 0) {
  261.         var html = "";
  262.  
  263.         html += '<select id="linklist" name="linklist" style="width: 250px" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="this.form.src.value=this.options[this.selectedIndex].value;">';
  264.         html += '<option value="">---</option>';
  265.  
  266.         for (var i=0; i<tinyMCEMediaList.length; i++)
  267.             html += '<option value="' + tinyMCEMediaList[i][1] + '">' + tinyMCEMediaList[i][0] + '</option>';
  268.  
  269.         html += '</select>';
  270.  
  271.         return html;
  272.     }
  273.  
  274.     return "";
  275. }
  276.  
  277. function getType(v) {
  278.     var fo, i, c, el, x, f = document.forms[0];
  279.  
  280.     fo = tinyMCE.getParam("media_types", "flash=swf;shockwave=dcr;qt=mov,qt,mpg,mp3,mp4,mpeg;shockwave=dcr;wmp=avi,wmv,wm,asf,asx,wmx,wvx;rmp=rm,ra,ram").split(';');
  281.  
  282.     // YouTube
  283.     if (v.indexOf('http://www.youtube.com/watch?v=') == 0 || v.indexOf('http://youtube.com/watch?v=') == 0) {
  284.         f.width.value = '425';
  285.         f.height.value = '350';
  286.  
  287.         v = v.replace('http://youtube.com/watch?v=', '');
  288.         v = v.replace('http://www.youtube.com/watch?v=', '');
  289.  
  290.         f.src.value = 'http://www.youtube.com/v/' + v;
  291.         return 'flash';
  292.     }
  293.  
  294.     // Google video
  295.     if (v.indexOf('http://video.google.com/videoplay?docid=') == 0) {
  296.         f.width.value = '425';
  297.         f.height.value = '326';
  298.         f.src.value = 'http://video.google.com/googleplayer.swf?docId=' + v.substring('http://video.google.com/videoplay?docid='.length) + '&hl=en';
  299.         return 'flash';
  300.     }
  301.  
  302.     for (i=0; i<fo.length; i++) {
  303.         c = fo[i].split('=');
  304.  
  305.         el = c[1].split(',');
  306.         for (x=0; x<el.length; x++)
  307.         if (v.indexOf('.' + el[x]) != -1)
  308.             return c[0];
  309.     }
  310.  
  311.     return null;
  312. }
  313.  
  314. function switchType(v) {
  315.     var t = getType(v), d = document, f = d.forms[0];
  316.  
  317.     if (!t)
  318.         return;
  319.  
  320.     selectByValue(d.forms[0], 'media_type', t);
  321.     changedType(t);
  322.  
  323.     // Update qtsrc also
  324.     if (t == 'qt' && f.src.value.toLowerCase().indexOf('rtsp://') != -1) {
  325.         alert(tinyMCE.getLang("lang_media_qt_stream_warn"));
  326.  
  327.         if (f.qt_qtsrc.value == '')
  328.             f.qt_qtsrc.value = f.src.value;
  329.     }
  330. }
  331.  
  332. function changedType(t) {
  333.     var d = document;
  334.  
  335.     d.getElementById('flash_options').style.display = 'none';
  336.     d.getElementById('qt_options').style.display = 'none';
  337.     d.getElementById('shockwave_options').style.display = 'none';
  338.     d.getElementById('wmp_options').style.display = 'none';
  339.     d.getElementById('rmp_options').style.display = 'none';
  340.     d.getElementById(t + '_options').style.display = 'block';
  341. }
  342.  
  343. function serializeParameters() {
  344.     var d = document, f = d.forms[0], s = '';
  345.  
  346.     switch (f.media_type.options[f.media_type.selectedIndex].value) {
  347.         case "flash":
  348.             s += getBool('flash', 'play', true);
  349.             s += getBool('flash', 'loop', true);
  350.             s += getBool('flash', 'menu', true);
  351.             s += getBool('flash', 'swliveconnect', false);
  352.             s += getStr('flash', 'quality');
  353.             s += getStr('flash', 'scale');
  354.             s += getStr('flash', 'salign');
  355.             s += getStr('flash', 'wmode');
  356.             s += getStr('flash', 'base');
  357.             s += getStr('flash', 'flashvars');
  358.         break;
  359.  
  360.         case "qt":
  361.             s += getBool('qt', 'loop', false);
  362.             s += getBool('qt', 'autoplay', true);
  363.             s += getBool('qt', 'cache', false);
  364.             s += getBool('qt', 'controller', true);
  365.             s += getBool('qt', 'correction', false, 'none', 'full');
  366.             s += getBool('qt', 'enablejavascript', false);
  367.             s += getBool('qt', 'kioskmode', false);
  368.             s += getBool('qt', 'autohref', false);
  369.             s += getBool('qt', 'playeveryframe', false);
  370.             s += getBool('qt', 'targetcache', false);
  371.             s += getStr('qt', 'scale');
  372.             s += getStr('qt', 'starttime');
  373.             s += getStr('qt', 'endtime');
  374.             s += getStr('qt', 'target');
  375.             s += getStr('qt', 'qtsrcchokespeed');
  376.             s += getStr('qt', 'volume');
  377.             s += getStr('qt', 'qtsrc');
  378.         break;
  379.  
  380.         case "shockwave":
  381.             s += getBool('shockwave', 'sound');
  382.             s += getBool('shockwave', 'progress');
  383.             s += getBool('shockwave', 'autostart');
  384.             s += getBool('shockwave', 'swliveconnect');
  385.             s += getStr('shockwave', 'swvolume');
  386.             s += getStr('shockwave', 'swstretchstyle');
  387.             s += getStr('shockwave', 'swstretchhalign');
  388.             s += getStr('shockwave', 'swstretchvalign');
  389.         break;
  390.  
  391.         case "wmp":
  392.             s += getBool('wmp', 'autostart', true);
  393.             s += getBool('wmp', 'enabled', false);
  394.             s += getBool('wmp', 'enablecontextmenu', true);
  395.             s += getBool('wmp', 'fullscreen', false);
  396.             s += getBool('wmp', 'invokeurls', true);
  397.             s += getBool('wmp', 'mute', false);
  398.             s += getBool('wmp', 'stretchtofit', false);
  399.             s += getBool('wmp', 'windowlessvideo', false);
  400.             s += getStr('wmp', 'balance');
  401.             s += getStr('wmp', 'baseurl');
  402.             s += getStr('wmp', 'captioningid');
  403.             s += getStr('wmp', 'currentmarker');
  404.             s += getStr('wmp', 'currentposition');
  405.             s += getStr('wmp', 'defaultframe');
  406.             s += getStr('wmp', 'playcount');
  407.             s += getStr('wmp', 'rate');
  408.             s += getStr('wmp', 'uimode');
  409.             s += getStr('wmp', 'volume');
  410.         break;
  411.  
  412.         case "rmp":
  413.             s += getBool('rmp', 'autostart', false);
  414.             s += getBool('rmp', 'loop', false);
  415.             s += getBool('rmp', 'autogotourl', true);
  416.             s += getBool('rmp', 'center', false);
  417.             s += getBool('rmp', 'imagestatus', true);
  418.             s += getBool('rmp', 'maintainaspect', false);
  419.             s += getBool('rmp', 'nojava', false);
  420.             s += getBool('rmp', 'prefetch', false);
  421.             s += getBool('rmp', 'shuffle', false);
  422.             s += getStr('rmp', 'console');
  423.             s += getStr('rmp', 'controls');
  424.             s += getStr('rmp', 'numloop');
  425.             s += getStr('rmp', 'scriptcallbacks');
  426.         break;
  427.     }
  428.  
  429.     s += getStr(null, 'id');
  430.     s += getStr(null, 'name');
  431.     s += getStr(null, 'src');
  432.     s += getStr(null, 'align');
  433.     s += getStr(null, 'bgcolor');
  434.     s += getInt(null, 'vspace');
  435.     s += getInt(null, 'hspace');
  436.     s += getStr(null, 'width');
  437.     s += getStr(null, 'height');
  438.  
  439.     s = s.length > 0 ? s.substring(0, s.length - 1) : s;
  440.  
  441.     return s;
  442. }
  443.  
  444. function setBool(pl, p, n) {
  445.     if (typeof(pl[n]) == "undefined")
  446.         return;
  447.  
  448.     document.forms[0].elements[p + "_" + n].checked = pl[n];
  449. }
  450.  
  451. function setStr(pl, p, n) {
  452.     var f = document.forms[0], e = f.elements[(p != null ? p + "_" : '') + n];
  453.  
  454.     if (typeof(pl[n]) == "undefined")
  455.         return;
  456.  
  457.     if (e.type == "text")
  458.         e.value = pl[n];
  459.     else
  460.         selectByValue(f, (p != null ? p + "_" : '') + n, pl[n]);
  461. }
  462.  
  463. function getBool(p, n, d, tv, fv) {
  464.     var v = document.forms[0].elements[p + "_" + n].checked;
  465.  
  466.     tv = typeof(tv) == 'undefined' ? 'true' : "'" + jsEncode(tv) + "'";
  467.     fv = typeof(fv) == 'undefined' ? 'false' : "'" + jsEncode(fv) + "'";
  468.  
  469.     return (v == d) ? '' : n + (v ? ':' + tv + ',' : ':' + fv + ',');
  470. }
  471.  
  472. function getStr(p, n, d) {
  473.     var e = document.forms[0].elements[(p != null ? p + "_" : "") + n];
  474.     var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value;
  475.  
  476.     return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',");
  477. }
  478.  
  479. function getInt(p, n, d) {
  480.     var e = document.forms[0].elements[(p != null ? p + "_" : "") + n];
  481.     var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value;
  482.  
  483.     return ((n == d || v == '') ? '' : n + ":" + v.replace(/[^0-9]+/g, '') + ",");
  484. }
  485.  
  486. function jsEncode(s) {
  487.     s = s.replace(new RegExp('\\\\', 'g'), '\\\\');
  488.     s = s.replace(new RegExp('"', 'g'), '\\"');
  489.     s = s.replace(new RegExp("'", 'g'), "\\'");
  490.  
  491.     return s;
  492. }
  493.  
  494. function generatePreview(c) {
  495.     var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh;
  496.  
  497.     p.innerHTML = '<!-- x --->';
  498.  
  499.     nw = parseInt(f.width.value);
  500.     nh = parseInt(f.height.value);
  501.  
  502.     if (f.width.value != "" && f.height.value != "") {
  503.         if (f.constrain.checked) {
  504.             if (c == 'width' && oldWidth != 0) {
  505.                 wp = nw / oldWidth;
  506.                 nh = Math.round(wp * nh);
  507.                 f.height.value = nh;
  508.             } else if (c == 'height' && oldHeight != 0) {
  509.                 hp = nh / oldHeight;
  510.                 nw = Math.round(hp * nw);
  511.                 f.width.value = nw;
  512.             }
  513.         }
  514.     }
  515.  
  516.     if (f.width.value != "")
  517.         oldWidth = nw;
  518.  
  519.     if (f.height.value != "")
  520.         oldHeight = nh;
  521.  
  522.     // After constrain
  523.     pl = serializeParameters();
  524.  
  525.     switch (f.media_type.options[f.media_type.selectedIndex].value) {
  526.         case "flash":
  527.             cls = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
  528.             codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';
  529.             type = 'application/x-shockwave-flash';
  530.             break;
  531.  
  532.         case "shockwave":
  533.             cls = 'clsid:166B1BCA-3F9C-11CF-8075-444553540000';
  534.             codebase = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0';
  535.             type = 'application/x-director';
  536.             break;
  537.  
  538.         case "qt":
  539.             cls = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';
  540.             codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0';
  541.             type = 'video/quicktime';
  542.             break;
  543.  
  544.         case "wmp":
  545.             cls = tinyMCE.getParam('media_wmp6_compatible') ? 'clsid:05589FA1-C356-11CE-BF01-00AA0055595A' : 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6';
  546.             codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';
  547.             type = 'application/x-mplayer2';
  548.             break;
  549.  
  550.         case "rmp":
  551.             cls = 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA';
  552.             codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';
  553.             type = 'audio/x-pn-realaudio-plugin';
  554.             break;
  555.     }
  556.  
  557.     if (pl == '') {
  558.         p.innerHTML = '';
  559.         return;
  560.     }
  561.  
  562.     pl = eval('x={' + pl + '};');
  563.  
  564.     if (!pl.src) {
  565.         p.innerHTML = '';
  566.         return;
  567.     }
  568.  
  569.     pl.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], pl.src);
  570.     pl.width = !pl.width ? 100 : pl.width;
  571.     pl.height = !pl.height ? 100 : pl.height;
  572.     pl.id = !pl.id ? 'obj' : pl.id;
  573.     pl.name = !pl.name ? 'eobj' : pl.name;
  574.     pl.align = !pl.align ? '' : pl.align;
  575.  
  576.     h += '<object classid="clsid:' + cls + '" codebase="' + codebase + '" width="' + pl.width + '" height="' + pl.height + '" id="' + pl.id + '" name="' + pl.name + '" align="' + pl.align + '">';
  577.  
  578.     for (n in pl) {
  579.         h += '<param name="' + n + '" value="' + pl[n] + '">';
  580.  
  581.         // Add extra url parameter if it's an absolute URL
  582.         if (n == 'src' && pl[n].indexOf('://') != -1)
  583.             h += '<param name="url" value="' + pl[n] + '" />';
  584.     }
  585.  
  586.     h += '<embed type="' + type + '" ';
  587.  
  588.     for (n in pl)
  589.         h += n + '="' + pl[n] + '" ';
  590.  
  591.     h += '></embed></object>';
  592.  
  593.     p.innerHTML = "<!-- x --->" + h;
  594. }
  595.