Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink=function(n){Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink.initializeBase(this,[n]);this._emptySrc=window.location.href.replace(/(http[s]*\:\/\/)[^\u0000]*/i,"$1")};Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink.prototype={callMethod:function(){var t=this._designPanel,i=t._getSelection(),r=t._createRange(i),n=Sys.Extended.UI.HtmlEditor.getSelParent(t);for(n.nodeType==3&&(n=n.parentNode);n&&Sys.Extended.UI.HtmlEditor.isStyleTag(n.tagName)&&n.tagName.toUpperCase()!="A";)n=n.parentNode;if(n&&n.tagName.toUpperCase()=="A")this._edit=!0,this._editLink(n);else if(this._edit=!1,!this._createLink())return!1;return Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink.callBaseMethod(this,"callMethod")?!0:!1},opened:function(n){this._preparePopup(n)},ok:function(n){var t=n.popupMediator.getField("target"),i;if(t!=null&&(this._obj.target=t.value),i=n.popupMediator.getField("url"),i!=null&&(this._obj.href=i.value),/^javascript:/.test(this._obj.href)){this._obj.target=null;try{this._obj.removeAttribute("target")}catch(r){}}else t=n.popupMediator.getField("target"),t!=null&&(this._obj.target=t.value);this._edit?this._edit_callback(!0):this._create_callback(!0)},cancel:function(){this._edit?this._edit_callback(!1):this._create_callback(!1)},_createLink:function(){var n=this._designPanel,h=Sys.Extended.UI.HtmlEditor.isIE?"":Sys.Extended.UI.HtmlEditor.Trim(n.getSelectedHTML()),f=n._getSelection(),i=n._createRange(f),e,c,r,l,a,u,s,o,t,v,y;if(this._txt=null,n.isControl()&&Sys.Extended.UI.HtmlEditor.getSelParent(n).tagName&&(Sys.Extended.UI.HtmlEditor.getSelParent(n).tagName.toUpperCase()=="EMBED"||Sys.Extended.UI.HtmlEditor.getSelParent(n).tagName.toUpperCase()=="IMG")||!n.isControl()&&(Sys.Extended.UI.HtmlEditor.isIE&&i.text.length>0||!Sys.Extended.UI.HtmlEditor.isIE&&h.length>0)||(n._saveContent(),e=n._doc.createElement("span"),e.innerHTML="new link",e.id=Sys.Extended.UI.HtmlEditor.smartClassName,c=!0,Sys.Extended.UI.HtmlEditor.isIE&&n.isControl()?(r=i.item(0),l=n._doc.createElement("span"),r.parentNode.insertBefore(l,r),this._txt=e.firstChild,r.parentNode.insertBefore(this._txt,r),a=n._doc.createElement("span"),r.parentNode.insertBefore(a,r),r.parentNode.removeChild(r),n.setSelectionAfterOperation([l,a],!1),c=!1):(n.insertHTML(Sys.Extended.UI.HtmlEditor.getHTML(e,!0)),u=n._doc.getElementById(Sys.Extended.UI.HtmlEditor.smartClassName),this._txt=u.firstChild,u.parentNode.insertBefore(u.firstChild,u),u.parentNode.removeChild(u)),Sys.Extended.UI.HtmlEditor.isIE?c&&i.select():(i=n._createRange(),i.setStart(this._txt,0),i.setEnd(this._txt,(""+this._txt.data+"").length),n._removeAllRanges(f),n._selectRange(f,i)),h=Sys.Extended.UI.HtmlEditor.isIE?"":Sys.Extended.UI.HtmlEditor.Trim(n.getSelectedHTML()),f=n._getSelection(),i=n._createRange(f)),n.isControl()&&Sys.Extended.UI.HtmlEditor.getSelParent(n).tagName.toUpperCase()=="IMG"||!n.isControl()&&(Sys.Extended.UI.HtmlEditor.isIE&&i.text.length>0||!Sys.Extended.UI.HtmlEditor.isIE&&h.length>0)){for(n._saveContent(),this._obj={target:"default",href:this._emptySrc,title:""},s=n._doc.getElementsByTagName("A"),o=[],t=0;t0&&this._obj.target=="default"&&(this._obj.target=this.get_relatedPopup().get_defaultTarget());i=n.popupMediator.getField("target");i!=null&&(i.value=this._obj.target&&this._obj.target.length>0&&this._obj.target.substr(0,1)=="_"?this._obj.target.toLowerCase():"_self");t=n.popupMediator.getField("url");t!=null&&(t.value=this._edit?Sys.Extended.UI.HtmlEditor.getRealAttribute(this._obj,"href"):this._obj.href,t.value.length==0&&(t.value=this._emptySrc),t.value=t.value.replace(/\"/g,'"'),setTimeout(function(){Sys.Extended.UI.HtmlEditor.setSelectionRange(t,0,t.value.length)},0))},_edit_callback:function(n){var t=this._designPanel;try{n?(this._obj.title.length==0&&(this._obj.title=null,this._obj.removeAttribute("title")),t.onContentChanged()):t._undo(!1)}catch(i){}return!0},okCheck:function(n){var i=n.popupMediator.getField("url"),t;return i!=null?(t=i.value,t==""||t.length>=3&&t.substr(t.length-3,3)=="://")?(n.alert(this.get_message("EmptyURL")),n.setTimeout(function(){try{i.focus()}catch(n){}},0),!1):!0:!1},_create_callback:function(n){var t=this._designPanel,u,s,f,h,e,o,i,r;try{if(n){for(u=t._doc.getElementsByTagName("A"),s=0,f=0;f0&&(e.title=this._obj.title))}this._txt&&(this._txt.data=this._obj.href);u.length>0&&(i=u[s],r=t._doc.createElement("span"),r.innerHTML=" ",i.nextSibling!=null?i.parentNode.insertBefore(r,i.nextSibling):i.parentNode.appendChild(r),setTimeout(function(){Sys.Extended.UI.HtmlEditor._setCursor(r,t);setTimeout(function(){i.parentNode.removeChild(r)},0)},0));setTimeout(function(){t._editPanel.updateToolbar();t.onContentChanged()},0)}else t._undo(!1),t.__stack.pop(),this._txt&&(t._undo(!1),t.__stack.pop());t.focusEditor()}catch(c){}return!0}};Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink",Sys.Extended.UI.HtmlEditor.ToolbarButtons.OkCancelPopupButton);