(function(){function p(){dialog.onok=function(){$G("preview").innerHTML="";var a;a=$G("videoWidth");var b=$G("videoHeight"),d=$G("videoUrl").value,e;e=$G("videoFloat").children;for(var c,g=0,f;f=e[g++];)if("focus"==f.className){c=f.getAttribute("name");break}e=c;if(d){b:{c=[a,b];for(g=0;f=c[g++];){var h=f.value;if(!/(0|^[1-9]\d*$)/.test(h)&&h){f.value="";f.focus();c=!1;break b}}c=!0}c?(k(d)?editor.execCommand("insertvideo",{url:m(d),width:a.value,height:b.value,align:e},n?"upload":null):(e=d.substr(d.lastIndexOf(".")+1),"ogv"==e&&(e="ogg"),"mp4"==e&&(e="mp4"),editor.execCommand("insertHtml",'\x3cp class\x3d"espcms_video_read_content" style\x3d"text-align: center;"\x3e\x3cvideo class\x3d"edui-faked-video" controls\x3d"" preload\x3d"none" width\x3d"'+a.value+'" height\x3d"'+b.value+'" src\x3d"'+d+'" data-setup\x3d"{}"\x3e\x3csource src\x3d"'+d+'" type\x3d"video/'+e+'" /\x3e\u60a8\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u89c6\u9891\u64ad\u653e\u6807\u7b7e\uff0c\u8bf7\u5347\u7ea7\u6d4f\u89c8\u5668\x3c/video\x3e\x3c/p\x3e')),a=void 0):a=!1}else a=!1;return a};dialog.oncancel=function(){$G("preview").innerHTML=""}}function m(a){return a?k(a)?a=utils.trim(a).replace(/v\.youku\.com\/v_show\/id_([\w\-=]+)\.html/i,"player.youku.com/player.php/sid/$1/v.swf").replace(/(www\.)?youtube\.com\/watch\?v=([\w\-]+)/i,"www.youtube.com/v/$2").replace(/youtu.be\/(\w+)$/i,"www.youtube.com/v/$1").replace(/v\.ku6\.com\/.+\/([\w\.]+)\.html.*$/i,"player.ku6.com/refer/$1/v.swf").replace(/www\.56\.com\/u\d+\/v_([\w\-]+)\.html/i,"player.56.com/v_$1.swf").replace(/www.56.com\/w\d+\/play_album\-aid\-\d+_vid\-([^.]+)\.html/i,"player.56.com/v_$1.swf").replace(/v\.pps\.tv\/play_([\w]+)\.html.*$/i,"player.pps.tv/player/sid/$1/v.swf").replace(/www\.letv\.com\/ptv\/vplay\/([\d]+)\.html.*$/i,"i7.imgs.letv.com/player/swfPlayer.swf?id\x3d$1\x26autoplay\x3d0").replace(/www\.tudou\.com\/programs\/view\/([\w\-]+)\/?/i,"www.tudou.com/v/$1").replace(/v\.qq\.com\/cover\/[\w]+\/[\w]+\/([\w]+)\.html/i,"static.video.qq.com/TPout.swf?vid\x3d$1").replace(/v\.qq\.com\/.+[\?\&]vid=([^&]+).*$/i,"static.video.qq.com/TPout.swf?vid\x3d$1").replace(/my\.tv\.sohu\.com\/[\w]+\/[\d]+\/([\d]+)\.shtml.*$/i,"share.vrs.sohu.com/my/v.swf\x26id\x3d$1"):a:""}function k(a){var b=!1;if(0<a.indexOf("youku.com")||0<a.indexOf("youtube")||0<a.indexOf("ku6.com")||0<a.indexOf("56.com")||0<a.indexOf("pps.tv")||0<a.indexOf("letv.com")||0<a.indexOf("tudou.com")||0<a.indexOf("qq.com")||0<a.indexOf("sohu.com"))b=!0;return b}function q(a){var b=$G(a).children;a=0;for(var d;d=b[a++];)domUtils.on(d,"click",function(){for(var a=0,c;c=b[a++];)c.className="",c.removeAttribute&&c.removeAttribute("class");this.className="focus"})}function r(a){browser.ie?a.onpropertychange=function(){l(this.value)}:a.addEventListener("input",function(){l(this.value)},!1)}function l(a){if(!a)return!1;var b=m(a);k(a)?$G("preview").innerHTML='\x3cdiv class\x3d"previewMsg"\x3e\x3cspan\x3e'+lang.urlError+'\x3c/span\x3e\x3c/div\x3e\x3cvideo class\x3d"previewVideo" src\x3d"'+b+'" width\x3d"420" height\x3d"280"\x3c/video\x3e':$G("preview").innerHTML='\x3cvideo autoplay\x3d"autoplay" src\x3d"'+b+'" class\x3d"edui-faked-video" width\x3d"420" height\x3d"280"\x3e\x3c/video\x3e'}var n=!1;window.onload=function(){$focus($G("videoUrl"));for(var a=["videoFloat"],b=0,d;d=a[b++];){var e=$G(d),c={none:lang["default"],left:lang.floatLeft,right:lang.floatRight,center:lang.block},g;for(g in c){var f=document.createElement("div");f.setAttribute("name",g);"none"==g&&(f.className="focus");f.style.cssText="background:url(images/"+g+"_focus.jpg);";f.setAttribute("title",c[g]);e.appendChild(f)}q(d)}r($G("videoUrl"));p();var b=editor.selection.getRange().getClosedNode(),h;if(b&&b.className){d="edui-faked-video"==b.className;a=-1!=b.className.indexOf("edui-upload-video");if(d||a)for($G("videoUrl").value=h=b.getAttribute("_url"),$G("videoWidth").value=b.getAttribute("width")?b.getAttribute("width"):"100%",$G("videoHeight").value=b.getAttribute("height")?b.getAttribute("height"):"560",d=domUtils.getComputedStyle(b,"float"),b="center"===domUtils.getComputedStyle(b.parentNode,"text-align")?"center":d,d=$G("videoFloat").children,e=0;c=d[e++];)c.getAttribute("name")==b?"focus"!=c.className&&(c.className="focus"):"focus"==c.className&&(c.className="");a&&(n=!0)}l(h)}})();