!function(){var a={};tinymce.create("tinymce.plugins.wpEditImage",{url:"",editor:{},init:function(b,c){var d=this;d.url=c,d.editor=b,d._createButtons(),b.addCommand("WP_EditImage",d._editImage),b.onInit.add(function(a){a.dom.events.add(a.getBody(),"mousedown",function(b){var c;"IMG"==b.target.nodeName&&(c=a.dom.getParent(b.target,"div.mceTemp"))&&(tinymce.isGecko?a.selection.select(c):tinymce.isWebKit&&a.dom.events.prevent(b))}),a.dom.events.add(a.getBody(),"keydown",function(b){var c,d,e,f;return 13==b.keyCode&&(c=a.selection.getNode(),d=a.dom.getParent(c,"dl.wp-caption"),d&&(e=a.dom.getParent(d,"div.mceTemp")),e)?(a.dom.events.cancel(b),f=a.dom.create("p",{},""),a.dom.insertAfter(f,e),a.selection.setCursorLocation(f,0),!1):void 0}),"ontouchstart"in window&&a.dom.events.add(a.getBody(),"touchstart",function(a){d._showButtons(a)})}),b.onMouseUp.add(function(b,c){if(!tinymce.isWebKit&&!tinymce.isOpera){if(a.x&&(c.clientX!=a.x||c.clientY!=a.y)){var d=b.selection.getNode();"IMG"==d.nodeName&&window.setTimeout(function(){var c,e=b.dom.getParent(d,"dl.wp-caption");(d.width!=a.img_w||d.height!=a.img_h)&&(d.className=d.className.replace(/size-[^ "']+/,"")),e&&(c=b.dom.getAttrib(d,"width")||d.width,c=parseInt(c,10),b.dom.setStyle(e,"width",10+c),b.execCommand("mceRepaint"))},100)}a={}}}),b.onMouseDown.add(function(a,b){d._showButtons(b)}),b.onBeforeSetContent.add(function(a,b){b.content=a.wpSetImgCaption(b.content)}),b.onPostProcess.add(function(a,b){b.get&&(b.content=a.wpGetImgCaption(b.content))}),b.wpSetImgCaption=function(a){return d._do_shcode(a)},b.wpGetImgCaption=function(a){return d._get_shcode(a)},b.onBeforeExecCommand.add(function(a,b){var c,d;if("mceInsertContent"==b){if(c=a.dom.getParent(a.selection.getNode(),"div.mceTemp"),!c)return;d=a.dom.create("p"),a.dom.insertAfter(d,c),a.selection.setCursorLocation(d,0)}})},_do_shcode:function(a){return a.replace(/(?:
)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g,function(a,b,c){var d,e,f,g,h,i,j=tinymce.trim;return d=b.match(/id=['"]([^'"]*)['"] ?/),d&&(b=b.replace(d[0],"")),e=b.match(/align=['"]([^'"]*)['"] ?/),e&&(b=b.replace(e[0],"")),f=b.match(/width=['"]([0-9]*)['"] ?/),f&&(b=b.replace(f[0],"")),c=j(c),i=c.match(/((?:]+>)? [\s\S]*<\/p>)?[\s\S]*/gi," $1]+>(?:<\/a>)?)([\s\S]*)/i),i&&i[2]?(g=j(i[2]),i=j(i[1])):(g=j(b).replace(/caption=['"]/,"").replace(/['"]$/,""),i=c),d=d&&d[1]?d[1]:"",e=e&&e[1]?e[1]:"alignnone",f=f&&f[1]?f[1]:"",f&&g?(h="mceTemp","aligncenter"==e&&(h+=" mceIEcenter"),f=parseInt(f,10)+10,'
]+)>\s*
"),'[caption id="'+e+'" align="'+f+'" width="'+g+'"]'+c+" "+d+"[/caption]"):c});return 0!==c.indexOf("[caption")&&(c=b.replace(/[\s\S]*?((?:]+>)?]+>(?:<\/a>)?)(