CKEDITOR.plugins.add("vblink",{init:function(B){var C="vblink";B.addCommand("link",new CKEDITOR.dialogCommand("link"));B.addCommand("anchor",new CKEDITOR.dialogCommand("anchor"));B.addCommand("unlink",new CKEDITOR.unlinkCommand());B.ui.addButton("Link",{label:B.lang.link.toolbar,command:"link"});B.ui.addButton("Unlink",{label:B.lang.unlink,command:"unlink"});B.ui.addButton("Anchor",{label:B.lang.anchor.toolbar,command:"anchor"});CKEDITOR.dialog.add("link",B.config.vbPluginPath+"vblink/dialogs/link.js");CKEDITOR.dialog.add("anchor",B.config.vbPluginPath+"vblink/dialogs/anchor.js");var A=B.lang.dir=="rtl"?"right":"left";B.addCss("img.cke_anchor{background-image: url("+CKEDITOR.getUrl(B.config.vbPluginPath+"vblink/images/anchor.gif")+");background-position: center center;background-repeat: no-repeat;border: 1px solid #a9a9a9;width: 18px !important;height: 18px !important;}\na.cke_anchor{background-image: url("+CKEDITOR.getUrl(B.config.vbPluginPath+"vblink/images/anchor.gif")+");background-position: "+A+" center;background-repeat: no-repeat;border: 1px solid #a9a9a9;padding-"+A+": 18px;}");B.on("selectionChange",function(D){var F=B.getCommand("unlink"),E=D.data.path.lastElement&&D.data.path.lastElement.getAscendant("a",true);if(E&&E.getName()=="a"&&E.getAttribute("href")){F.setState(CKEDITOR.TRISTATE_OFF)}else{F.setState(CKEDITOR.TRISTATE_DISABLED)}});B.on("doubleclick",function(D){var E=CKEDITOR.plugins.vblink.getSelectedLink(B)||D.data.element;if(!E.isReadOnly()){if(E.is("a")){D.data.dialog=(E.getAttribute("name")&&!E.getAttribute("href"))?"anchor":"link"}else{if(E.is("img")&&E.data("cke-real-element-type")=="anchor"){D.data.dialog="anchor"}}}});if(B.addMenuItems){B.addMenuItems({anchor:{label:B.lang.anchor.menu,command:"anchor",group:"anchor"},link:{label:B.lang.link.menu,command:"link",group:"link",order:1},unlink:{label:B.lang.unlink,command:"unlink",group:"link",order:5}})}if(B.contextMenu){B.contextMenu.addListener(function(E,F){if(!E||E.isReadOnly()){return null}var D=(E.is("img")&&E.data("cke-real-element-type")=="anchor");if(!D){if(!(E=CKEDITOR.plugins.vblink.getSelectedLink(B))){return null}D=(E.getAttribute("name")&&!E.getAttribute("href"))}return D?{anchor:CKEDITOR.TRISTATE_OFF}:{link:CKEDITOR.TRISTATE_OFF,unlink:CKEDITOR.TRISTATE_OFF}})}},afterInit:function(B){var A=B.dataProcessor,C=A&&A.dataFilter;if(C){C.addRules({elements:{a:function(E){var D=E.attributes;if(D.name&&!D.href){return B.createFakeParserElement(E,"cke_anchor","anchor")}}}})}},requires:["fakeobjects"]});CKEDITOR.plugins.vblink={getSelectedLink:function(D){try{var C=D.getSelection();if(C.getType()==CKEDITOR.SELECTION_ELEMENT){var F=C.getSelectedElement();if(F.is("a")){return F}}var B=C.getRanges(true)[0];B.shrink(CKEDITOR.SHRINK_TEXT);var A=B.getCommonAncestor();return A.getAscendant("a",true)}catch(E){return null}}};CKEDITOR.unlinkCommand=function(){};CKEDITOR.unlinkCommand.prototype={exec:function(F){var E=F.getSelection(),D=E.createBookmarks(),A=E.getRanges(),G,C;for(var B=0;B<A.length;B++){G=A[B].getCommonAncestor(true);C=G.getAscendant("a",true);if(!C){continue}A[B].selectNodeContents(C)}E.selectRanges(A);F.document.$.execCommand("unlink",false,null);E.selectBookmarks(D)},startDisabled:true};CKEDITOR.tools.extend(CKEDITOR.config,{linkShowAdvancedTab:true,linkShowTargetTab:true});