!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;ic&&(b=c)}return b}function e(a,b){1!=a.nodeType||a.hasChildNodes()?g.setStart(a,d(a,b)):g.setStartBefore(a)}function f(a,b){1!=a.nodeType||a.hasChildNodes()?g.setEnd(a,d(a,b)):g.setEndAfter(a)}var g,j,k,l,m,n,o,p,q,r;if("A"!=a.selection.getNode().tagName){if(g=a.selection.getRng(!0).cloneRange(),g.startOffset<5){if(p=g.endContainer.previousSibling,!p){if(!g.endContainer.firstChild||!g.endContainer.firstChild.nextSibling)return;p=g.endContainer.firstChild.nextSibling}if(q=p.length,e(p,q),f(p,q),g.endOffset<5)return;j=g.endOffset,l=p}else{if(l=g.endContainer,3!=l.nodeType&&l.firstChild){for(;3!=l.nodeType&&l.firstChild;)l=l.firstChild;3==l.nodeType&&(e(l,0),f(l,l.nodeValue.length))}j=1==g.endOffset?2:g.endOffset-1-b}k=j;do e(l,j>=2?j-2:0),f(l,j>=1?j-1:0),j-=1,r=g.toString();while(" "!=r&&""!==r&&160!=r.charCodeAt(0)&&j-2>=0&&r!=c);i(g.toString(),c)?(e(l,j),f(l,k),j+=1):0===g.startOffset?(e(l,0),f(l,k)):(e(l,j),f(l,k)),n=g.toString(),"."==n.charAt(n.length-1)&&f(l,k-1),n=g.toString(),o=n.match(h),o&&("www."==o[1]?o[1]="http://www.":/@$/.test(o[1])&&!/^mailto:/.test(o[1])&&(o[1]="mailto:"+o[1]),m=a.selection.getBookmark(),a.selection.setRng(g),a.execCommand("createlink",!1,o[1]+o[2]),a.settings.default_link_target&&a.dom.setAttrib(a.selection.getNode(),"target",a.settings.default_link_target),a.selection.moveToBookmark(m),a.nodeChanged())}}var g,h=/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+\-]+@)(.+)$/i;if(b.settings.autolink_pattern&&(h=b.settings.autolink_pattern),b.on("keydown",function(a){if(13==a.keyCode)return e(b)}),a.ie)return void b.on("focus",function(){if(!g){g=!0;try{b.execCommand("AutoUrlDetect",!1,!0)}catch(a){}}});b.on("keypress",function(a){if(41==a.keyCode)return c(b)}),b.on("keyup",function(a){if(32==a.keyCode)return d(b)});var i=function(a,b){return a==b||" "===a||160==a.charCodeAt(0)}}),function(){}}),d("0")()}();