CKEDITOR.dialog.add("anchor",function(e){var d=function(b){this._.selectedElement=b;var a=b.data("cke-saved-name");this.setValueOf("info","txtName",a||"")};function f(b,a){return b.createFakeElement(a,"cke_anchor","anchor")}return{title:e.lang.anchor.title,minWidth:300,minHeight:60,onOk:function(){var a=this;var p=CKEDITOR.tools.trim(a.getValueOf("info","txtName")),o={id:p,name:p,"data-cke-saved-name":p};if(a._.selectedElement){if(a._.selectedElement.data("cke-realelement")){var n=f(e,e.document.createElement("a",{attributes:o}));n.replace(a._.selectedElement)}else{a._.selectedElement.setAttributes(o)}}else{var m=e.getSelection(),l=m&&m.getRanges()[0];if(l.collapsed){if(CKEDITOR.plugins.link.synAnchorSelector){o["class"]="cke_anchor_empty"}if(CKEDITOR.plugins.link.emptyAnchorFix){o.contenteditable="false";o["data-cke-editable"]=1}var c=e.document.createElement("a",{attributes:o});if(CKEDITOR.plugins.link.fakeAnchor){c=f(e,c)}l.insertNode(c)}else{if(CKEDITOR.env.ie&&CKEDITOR.env.version<9){o["class"]="cke_anchor"}var b=new CKEDITOR.style({element:"a",attributes:o});b.type=CKEDITOR.STYLE_INLINE;b.apply(e.document)}}},onHide:function(){delete this._.selectedElement},onShow:function(){var a=this;var j=e.getSelection(),i=j.getSelectedElement(),c;if(i){if(CKEDITOR.plugins.link.fakeAnchor){var b=CKEDITOR.plugins.link.tryRestoreFakeAnchor(e,i);b&&d.call(a,b);a._.selectedElement=i}else{if(i.is("a")&&i.hasAttribute("name")){d.call(a,i)}}}else{c=CKEDITOR.plugins.link.getSelectedLink(e);if(c){d.call(a,c);j.selectElement(c)}}a.getContentElement("info","txtName").focus()},contents:[{id:"info",label:e.lang.anchor.title,accessKey:"I",elements:[{type:"text",id:"txtName",label:e.lang.anchor.name,required:true,validate:function(){if(!this.getValue()){alert(e.lang.anchor.errorName);return false}return true}}]}]}});