;tinyMCEPopup.requireLangPack();(function($){var path=tinyMCEPopup.getParam('shop_path');$(function(){window.setTimeout(function(){$('#mediaservice_url').observe({type:'constant',delay:500,callback:onMediaServiceUrlChange});renderMediaServiceIntro();onMediaServiceUrlChange()},1)});var renderMediaServiceIntro=function(){var services=tinymce.plugins.MediaService.getServiceList(),service,html='<ul style="margin:0;padding:0;">';for(var i=0;i<services.length;i++){service=services[i];html+='<li style="margin:0 0 0 18px;padding:0;">'+$.htmlEncode(service.getDescription())+'</li>'};html+='</ul>';$('#mediaservice_intro_servicelist').html(html)},onMediaServiceUrlChange=function(){var url=$('#mediaservice_url').val(),service=tinymce.plugins.MediaService.getServiceByUrl(url),embed=false;if(service){service.setUrl(url);var embed=service.getEmbedHtml()};if(embed){$('#mediaservice_preview').html(embed).show();$('#mediaservice_intro').hide()}else{$('#mediaservice_intro').show();$('#mediaservice_preview').hide()}}})(jQuery);tinyMCEPopup.onInit.add(function(){var ed=tinyMCEPopup.editor,placeholder=ed.selection.getNode();if(placeholder!==null&&/^mceItemMediaService_(.*?):(.*?)$/.test(placeholder.title)){var serviceName=RegExp.$1,serializedData=RegExp.$2,service=tinymce.plugins.MediaService.services[serviceName];service.unserializeData($.htmlDecode(serializedData));$('#mediaservice_url').val(service.getVideoUrl())}})
function insertMediaService(){tinyMCEPopup.restoreSelection();var ed=tinyMCEPopup.editor,url=$('#mediaservice_url').val(),service=tinymce.plugins.MediaService.getServiceByUrl(url);if(!service){tinyMCEPopup.alert(ed.getLang('mediaservice_dlg.invalid_url'));return};service.setUrl(url);var placeholder=ed.selection.getNode();if(placeholder!==null&&/mceItemMediaService mceItemMediaService_/.test(ed.dom.getAttrib(placeholder,'class'))){service.updatePlaceholderNode(placeholder);ed.execCommand('mceRepaint')}else ed.execCommand('mceInsertContent',false,service.getPlaceholderHtml(tinyMCEPopup.getWindowArg("plugin_url")));tinyMCEPopup.close()}