function hideFlash(){flashObj=null,flashContainer.innerHTML=""}function addOkListener(){dialog.onok=function(){if(imageUrls.length){var e=editor.getOpt("imageUrlPrefix"),t=domUtils.getElementsByTagName(editor.document,"img");editor.fireEvent("saveScene");for(var a,n=0;a=t[n++];){var i=a.getAttribute("word_img");if(i)for(var r,o=0;r=imageUrls[o++];)if(i.indexOf(r.original.replace(" ",""))!=-1){a.src=e+r.url,a.setAttribute("_src",e+r.url),a.setAttribute("title",r.title),domUtils.removeAttributes(a,["word_img","style","width","height"]),editor.fireEvent("selectionchange");break}}editor.fireEvent("saveScene"),hideFlash()}},dialog.oncancel=function(){hideFlash()}}function addUploadListener(){g("upload").onclick=function(){flashObj.upload(),this.style.display="none"}}function showLocalPath(e){var t=editor.selection.getRange().getClosedNode(),a=editor.execCommand("wordimage");if(1==a.length||t&&"IMG"==t.tagName)return void(g(e).value=a[0]);var n=a[0],i=n.lastIndexOf("/")||0,r=n.lastIndexOf("\\")||0,o=i>r?"/":"\\";n=n.substring(0,n.lastIndexOf(o)+1),g(e).value=n}function createFlashUploader(e,t){var a=utils.extend({},lang.flashI18n);for(var n in a)n in{lang:1,uploadingTF:1,imageTF:1,textEncoding:1}||!a[n]||(a[n]=encodeURIComponent(editor.options.langPath+editor.options.lang+"/images/"+a[n]));e=utils.extend(e,a,!1);var i={createOptions:{id:"flash",url:e.flashUrl,width:e.width,height:e.height,errorMessage:lang.flashError,wmode:browser.safari?"transparent":"window",ver:"10.0.0",vars:e,container:e.container}};i=extendProperty(t,i),flashObj=new baidu.flash.imageUploader(i),flashContainer=$G(e.container)}function extendProperty(e,t){for(var a in e)t[a]||(t[a]=e[a]);return t}function getPasteData(e){return baidu.g("msg").innerHTML=lang.copySuccess+"</br>",setTimeout(function(){baidu.g("msg").innerHTML=""},5e3),baidu.g(e).value}function createCopyButton(e,t){baidu.swf.create({id:"copyFlash",url:"fClipboard_ueditor.swf",width:"58",height:"25",errorMessage:"",bgColor:"#CBCBCB",wmode:"transparent",ver:"10.0.0",vars:{tid:t}},e);var a=baidu.swf.getMovie("copyFlash"),n=setInterval(function(){a&&a.flashInit&&(clearInterval(n),a.setHandCursor(!0),a.setContentFuncName("getPasteData"))},500)}var wordImage={},g=baidu.g,flashObj,flashContainer;wordImage.init=function(e,t){showLocalPath("localPath"),createFlashUploader(e,t),addUploadListener(),addOkListener()},createCopyButton("clipboard","localPath");