/* 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 */
CreateLink.prototype.show=function(c){if(!this.dialog){this.prepareDialog()}var d=this.editor;this.a=c;if(!c&&this.editor.selectionEmpty(this.editor.getSelection())){alert(this._lc("You need to select some text before creating a link"));return false}var b={f_href:"",f_title:"",f_target:"",f_other_target:""};if(c&&c.tagName.toLowerCase()=="a"){b.f_href=this.editor.fixRelativeLinks(c.getAttribute("href"));b.f_title=c.title;if(c.target){if(!/_self|_top_|_blank/.test(c.target)){b.f_target="_other";b.f_other_target=c.target}else{b.f_target=c.target;b.f_other_target=""}}}this.dialog.show(b)};CreateLink.prototype.apply=function(){var m=this.dialog.hide();var l=this.a;var h=this.editor;var k={href:"",target:"",title:""};if(m.f_href){k.href=m.f_href;k.title=m.f_title;if(m.f_target.value){if(m.f_target.value=="other"){k.target=m.f_other_target}else{k.target=m.f_target.value}}}if(m.f_target.value){if(m.f_target.value!="_other"){k.target=m.f_target.value}else{k.target=m.f_other_target}}if(l&&l.tagName.toLowerCase()=="a"){if(!k.href){if(confirm(this._lc("Are you sure you wish to remove this link?"))){var c=l.parentNode;while(l.hasChildNodes()){c.insertBefore(l.removeChild(l.childNodes[0]),l)}c.removeChild(l);h.updateToolbar();return}}else{for(var f in k){l.setAttribute(f,k[f])}if(Xinha.is_ie){if(/mailto:([^?<>]*)(\?[^<]*)?$/i.test(l.innerHTML)){l.innerHTML=RegExp.$1}}}}else{if(!k.href){return true}var g=Xinha.uniq("http://www.example.com/Link");h._doc.execCommand("createlink",false,g);var b=h._doc.getElementsByTagName("a");for(var f=0;f<b.length;f++){var e=b[f];if(e.href==g){if(!l){l=e}for(var d in k){e.setAttribute(d,k[d])}}}}h.selectNodeContents(l);h.updateToolbar()};CreateLink.prototype._getSelectedAnchor=function(){var d=this.editor.getSelection();var c=this.editor.createRange(d);var b=this.editor.activeElement(d);if(b!=null&&b.tagName.toLowerCase()=="a"){return b}else{b=this.editor._getFirstAncestor(d,"a");if(b!=null){return b}}return null};