/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
/* This file is part of version 0.96beta2 released Fri, 20 Mar 2009 11:01:14 +0100 */
function InsertAnchor(c){this.editor=c;var a=c.config;var b=this;this.placeholderImg='<img class="IA_placeholder" src="'+Xinha.getPluginDir("InsertAnchor")+'/img/placeholder.gif" />';a.registerButton({id:"insert-anchor",tooltip:this._lc("Insert Anchor"),image:c.imgURL("insert-anchor.gif","InsertAnchor"),textMode:false,action:function(){b.show()}});a.addToolbarElement("insert-anchor","createlink",1)}InsertAnchor._pluginInfo={name:"InsertAnchor",origin:"version: 1.0, by Andre Rabold, MR Printware GmbH, http://www.mr-printware.de",version:"2.0",developer:"Udo Schmal",developer_url:"http://www.schaffrath-neuemedien.de",c_owner:"Udo Schmal",sponsor:"L.N.Schaffrath NeueMedien",sponsor_url:"http://www.schaffrath-neuemedien.de",license:"htmlArea"};InsertAnchor.prototype._lc=function(a){return Xinha._lc(a,"InsertAnchor")};InsertAnchor.prototype.onGenerate=function(){this.editor.addEditorStylesheet(Xinha.getPluginDir("InsertAnchor")+"/insert-anchor.css")};InsertAnchor.prototype.inwardHtml=function(a){a=a.replace(/(<a[^>]*class="anchor"[^>]*>)/g,"$1"+this.placeholderImg);return a};InsertAnchor.prototype.outwardHtml=function(a){a=a.replace(/(<img[^>]*class="?IA_placeholder"?[^>]*>)/ig,"");return a};InsertAnchor.prototype.onGenerateOnce=function(){this._prepareDialog()};InsertAnchor.prototype._prepareDialog=function(){var a=this;var b=this.editor;if(!this.html){Xinha._getback(Xinha.getPluginDir("InsertAnchor")+"/dialog.html",function(c){a.html=c;a._prepareDialog()});return}this.dialog=new Xinha.Dialog(b,this.html,"InsertAnchor",{width:400});this.dialog.getElementById("ok").onclick=function(){a.apply()};this.dialog.getElementById("cancel").onclick=function(){a.dialog.hide()};this.ready=true};InsertAnchor.prototype.show=function(){if(!this.ready){var b=this;window.setTimeout(function(){b.show()},100);return}var c=this.editor;this.selectedHTML=c.getSelectedHTML();var d=c.getSelection();var a=c.createRange(d);this.a=c.activeElement(d);if(!(this.a!=null&&this.a.tagName.toLowerCase()=="a")){this.a=c._getFirstAncestor(d,"a")}if(this.a!=null&&this.a.tagName.toLowerCase()=="a"){inputs={name:this.a.id}}else{inputs={name:""}}this.dialog.show(inputs);this.dialog.getElementById("name").focus()};InsertAnchor.prototype.apply=function(){var g=this.editor;var c=this.dialog.hide();var d=c.name;var i=this.a;var k=this;if(d==""||d==null){if(i){var b=k.outwardHtml(i.innerHTML);i.parentNode.removeChild(i);g.insertHTML(b)}return}try{var j=g._doc;if(!i){i=j.createElement("a");i.id=d;i.name=d;i.title=d;i.className="anchor";i.innerHTML=k.placeholderImg;var f=g.getSelectedHTML();if(f){i.innerHTML+=f}if(Xinha.is_ie){range.pasteHTML(i.outerHTML)}else{g.insertNodeAtSelection(i)}}else{i.id=d;i.name=d;i.title=d;i.className="anchor"}}catch(h){}};