var Attacklab=Attacklab||{};Attacklab.wmdBase=function(){var i=top.Attacklab;var c=top.document;var p=top.RegExp;var o=top.navigator;i.Util={};i.Position={};i.Command={};i.Global={};var h=i.Util;var k=i.Position;var n=i.Command;var q=i.Global;q.isIE=/msie/.test(o.userAgent.toLowerCase());q.isIE_5or6=/msie 6/.test(o.userAgent.toLowerCase())||/msie 5/.test(o.userAgent.toLowerCase());q.isIE_7plus=q.isIE&&!q.isIE_5or6;q.isOpera=/opera/.test(o.userAgent.toLowerCase());q.isKonqueror=/konqueror/.test(o.userAgent.toLowerCase());var g="<p style='margin-top: 0px'><b>Enter the image URL.</b></p><p>You can also add a title, which will be displayed as a tool tip.</p><p>Example:<br />http://wmd-editor.com/images/cloud1.jpg   \"Optional title\"</p>";var j="<p style='margin-top: 0px'><b>Enter the web address.</b></p><p>You can also use the name of the page for inter-page links.</p><p>Example:<br /><ul><li>http://foo.com/bar</li><li>my-page</li></ul></p>";var l="";var a="";var r="/Views/Shared/Images/";var m=500;var b=100;var e="http://wmd-editor.com/";var d="WMD website";var f="_blank";i.PanelCollection=function(){this.buttonBar=c.getElementById("wmd-button-bar");this.preview=c.getElementById("wmd-preview");this.output=c.getElementById("wmd-output");this.input=c.getElementById("wmd-input")};i.panels=undefined;i.ieCachedRange=null;i.ieRetardedClick=false;h.isVisible=function(s){if(window.getComputedStyle){return window.getComputedStyle(s,null).getPropertyValue("display")!=="none"}else{if(s.currentStyle){return s.currentStyle.display!=="none"}}};h.addEvent=function(t,u,s){if(t!=null&&t.attachEvent){t.attachEvent("on"+u,s)}else{if(t!=null){t.addEventListener(u,s,false)}}};h.removeEvent=function(t,u,s){if(t.detachEvent){t.detachEvent("on"+u,s)}else{t.removeEventListener(u,s,false)}};h.fixEolChars=function(s){s=s.replace(/\r\n/g,"\n");s=s.replace(/\r/g,"\n");return s};h.extendRegExp=function(v,s,t){if(s===null||s===undefined){s=""}if(t===null||t===undefined){t=""}var u=v.toString();var w;u=u.replace(/\/([gim]*)$/,"");w=p.$1;u=u.replace(/(^\/|\/$)/g,"");u=s+u+t;return new p(u,w)};h.createImage=function(u){var s=r+u;var t=c.createElement("img");t.className="wmd-button";t.src=s;return t};h.prompt=function(y,z,B){var A;var x;var w;if(z===undefined){z=""}var t=function(C){var D=(C.charCode||C.keyCode);if(D===27){v(true)}};var v=function(D){h.removeEvent(c.body,"keydown",t);var C=w.value;if(D){C=null}else{C=C.replace("http://http://","http://");C=C.replace("http://https://","https://");C=C.replace("http://ftp://","ftp://");if(C.indexOf("http://")===-1&&C.indexOf("ftp://")===-1&&C.indexOf("https://")===-1){}}A.parentNode.removeChild(A);x.parentNode.removeChild(x);B(C);return false};var s=function(){x=c.createElement("div");x.className="wmd-prompt-background";style=x.style;style.position="absolute";style.top="0";style.zIndex="1000";if(q.isKonqueror){style.backgroundColor="transparent"}else{if(q.isIE){style.filter="alpha(opacity=50)"}else{style.opacity="0.5"}}var C=k.getPageSize();style.height=C[1]+"px";if(q.isIE){style.left=c.documentElement.scrollLeft;style.width=c.documentElement.clientWidth}else{style.left="0";style.width="100%"}c.body.appendChild(x)};var u=function(){A=c.createElement("div");A.className="wmd-prompt-dialog";A.style.padding="10px;";A.style.position="fixed";A.style.width="400px";A.style.zIndex="1001";var F=c.createElement("div");F.innerHTML=y;F.style.padding="5px";A.appendChild(F);var D=c.createElement("form");D.onsubmit=function(){return v(false)};style=D.style;style.padding="0";style.margin="0";style.cssFloat="left";style.width="100%";style.textAlign="center";style.position="relative";A.appendChild(D);w=c.createElement("input");w.type="text";w.value=z;style=w.style;style.display="block";style.width="80%";style.marginLeft=style.marginRight="auto";D.appendChild(w);var C=c.createElement("input");C.type="button";C.onclick=function(){return v(false)};C.value="OK";style=C.style;style.margin="10px";style.display="inline";style.width="7em";var E=c.createElement("input");E.type="button";E.onclick=function(){return v(true)};E.value="Cancel";style=E.style;style.margin="10px";style.display="inline";style.width="7em";if(/mac/.test(o.platform.toLowerCase())){D.appendChild(E);D.appendChild(C)}else{D.appendChild(C);D.appendChild(E)}h.addEvent(c.body,"keydown",t);A.style.top="50%";A.style.left="50%";A.style.display="block";if(q.isIE_5or6){A.style.position="absolute";A.style.top=c.documentElement.scrollTop+200+"px";A.style.left="50%"}c.body.appendChild(A);A.style.marginTop=-(k.getHeight(A)/2)+"px";A.style.marginLeft=-(k.getWidth(A)/2)+"px"};s();top.setTimeout(function(){u();var D=z.length;if(w.selectionStart!==undefined){w.selectionStart=0;w.selectionEnd=D}else{if(w.createTextRange){var C=w.createTextRange();C.collapse(false);C.moveStart("character",-D);C.moveEnd("character",D);C.select()}}w.focus()},0)};k.getTop=function(t,u){var s=t.offsetTop;if(!u){while(t=t.offsetParent){s+=t.offsetTop}}return s};k.getHeight=function(s){return s.offsetHeight||s.scrollHeight};k.getWidth=function(s){return s.offsetWidth||s.scrollWidth};k.getPageSize=function(){var x,u;var w,v;if(self.innerHeight&&self.scrollMaxY){x=c.body.scrollWidth;u=self.innerHeight+self.scrollMaxY}else{if(c.body.scrollHeight>c.body.offsetHeight){x=c.body.scrollWidth;u=c.body.scrollHeight}else{x=c.body.offsetWidth;u=c.body.offsetHeight}}if(self.innerHeight){w=self.innerWidth;v=self.innerHeight}else{if(c.documentElement&&c.documentElement.clientHeight){w=c.documentElement.clientWidth;v=c.documentElement.clientHeight}else{if(c.body){w=c.body.clientWidth;v=c.body.clientHeight}}}var t=Math.max(x,w);var s=Math.max(u,v);return[t,s,w,v]};i.inputPoller=function(B,y){var v=this;var w=i.panels.input;var A;var z;var x;var u;this.tick=function(){if(!h.isVisible(w)){return}if(w.selectionStart||w.selectionStart===0){var C=w.selectionStart;var D=w.selectionEnd;if(C!=A||D!=z){A=C;z=D;if(x!=w.value){x=w.value;return true}}}return false};var t=function(){if(!h.isVisible(w)){return}if(v.tick()){B()}};var s=function(){u=top.setInterval(t,y)};this.destroy=function(){top.clearInterval(u)};s()};i.undoManager=function(H){var y=this;var u=[];var C=0;var s="none";var F;var G;var t;var v;var D=function(J,I){if(s!=J){s=J;if(!I){w()}}if(!q.isIE||s!="moving"){t=top.setTimeout(x,1)}else{v=null}};var x=function(){v=new i.TextareaState();G.tick();t=undefined};this.setCommandMode=function(){s="command";w();t=top.setTimeout(x,0)};this.canUndo=function(){return C>1};this.canRedo=function(){if(u[C+1]){return true}return false};this.undo=function(){if(y.canUndo()){if(F){F.restore();F=null}else{u[C]=new i.TextareaState();u[--C].restore();if(H){H()}}}s="none";i.panels.input.focus();x()};this.redo=function(){if(y.canRedo()){u[++C].restore();if(H){H()}}s="none";i.panels.input.focus();x()};var w=function(){var I=v||new i.TextareaState();if(!I){return false}if(s=="moving"){if(!F){F=I}return}if(F){if(u[C-1].text!=F.text){u[C++]=F}F=null}u[C++]=I;u[C+1]=null;if(H){H()}};var B=function(K){var I=false;if(K.ctrlKey||K.metaKey){var J=K.charCode||K.keyCode;var L=String.fromCharCode(J);switch(L){case"y":y.redo();I=true;break;case"z":if(!K.shiftKey){y.undo()}else{y.redo()}I=true;break}}if(I){if(K.preventDefault){K.preventDefault()}if(top.event){top.event.returnValue=false}return}};var A=function(J){if(!J.ctrlKey&&!J.metaKey){var I=J.keyCode;if((I>=33&&I<=40)||(I>=63232&&I<=63235)){D("moving")}else{if(I==8||I==46||I==127){D("deleting")}else{if(I==13){D("newlines")}else{if(I==27){D("escape")}else{if((I<16||I>20)&&I!=91){D("typing")}}}}}}};var E=function(){h.addEvent(i.panels.input,"keypress",function(J){if((J.ctrlKey||J.metaKey)&&(J.keyCode==89||J.keyCode==90)){J.preventDefault()}});var I=function(){if(q.isIE||(v&&v.text!=i.panels.input.value)){if(t==undefined){s="paste";w();x()}}};G=new i.inputPoller(I,b);h.addEvent(i.panels.input,"keydown",B);h.addEvent(i.panels.input,"keydown",A);h.addEvent(i.panels.input,"mousedown",function(){D("moving")});i.panels.input.onpaste=I;i.panels.input.ondrop=I};var z=function(){E();x();w()};this.destroy=function(){if(G){G.destroy()}};z()};i.editor=function(D){if(!D){D=function(){}}var F=i.panels.input;var E=0;var A=this;var t;var x;var H;var s;var u;var z=function(K){F.focus();if(K.textOp){if(u){u.setCommandMode()}var I=new i.TextareaState();if(!I){return}var L=I.getChunks();var J=function(){F.focus();if(L){I.setChunks(L)}I.restore();D()};var M=K.textOp(L,J);if(!M){J()}}if(K.execute){K.execute(A)}};var y=function(){if(u){G(document.getElementById("wmd-undo-button"),u.canUndo());G(document.getElementById("wmd-redo-button"),u.canRedo())}};var G=function(L,J){var M="0px";var I="-20px";var K="-40px";if(J){L.style.backgroundPosition=L.XShift+" "+M;L.onmouseover=function(){this.style.backgroundPosition=this.XShift+" "+K};L.onmouseout=function(){this.style.backgroundPosition=this.XShift+" "+M};if(q.isIE){L.onmousedown=function(){i.ieRetardedClick=true;i.ieCachedRange=document.selection.createRange()}}if(!L.isHelp){L.onclick=function(){if(this.onmouseout){this.onmouseout()}z(this);return false}}}else{L.style.backgroundPosition=L.XShift+" "+I;L.onmouseover=L.onmouseout=L.onclick=function(){}}};var B=function(){var Y=document.getElementById("wmd-button-bar");var ab="0px";var N="-20px";var Z="-40px";var aa=document.createElement("ul");aa.id="wmd-button-row";aa=Y.appendChild(aa);var K=document.createElement("li");K.className="wmd-button";K.id="wmd-bold-button";K.title="Strong <strong> Ctrl+B";K.XShift="0px";K.textOp=n.doBold;G(K,true);aa.appendChild(K);var P=document.createElement("li");P.className="wmd-button";P.id="wmd-italic-button";P.title="Emphasis <em> Ctrl+I";P.XShift="-20px";P.textOp=n.doItalic;G(P,true);aa.appendChild(P);var R=document.createElement("li");R.className="wmd-spacer";R.id="wmd-spacer1";aa.appendChild(R);var X=document.createElement("li");X.className="wmd-button";X.id="wmd-link-button";X.title="Hyperlink <a> Ctrl+L";X.XShift="-40px";X.textOp=function(af,ae){return n.doLinkOrImage(af,ae,false)};G(X,true);aa.appendChild(X);var I=document.createElement("li");I.className="wmd-button";I.id="wmd-quote-button";I.title="Blockquote <blockquote> Ctrl+Q";I.XShift="-60px";I.textOp=n.doBlockquote;G(I,true);aa.appendChild(I);var T=document.createElement("li");T.className="wmd-button";T.id="wmd-code-button";T.title="Code Sample <pre><code> Ctrl+K";T.XShift="-80px";T.textOp=n.doCode;G(T,true);aa.appendChild(T);var L=document.createElement("li");L.className="wmd-button";L.id="wmd-image-button";L.title="Image <img> Ctrl+G";L.XShift="-100px";L.textOp=function(af,ae){return n.doLinkOrImage(af,ae,true)};G(L,true);aa.appendChild(L);var V=document.createElement("li");V.className="wmd-spacer";V.id="wmd-spacer2";aa.appendChild(V);var ad=document.createElement("li");ad.className="wmd-button";ad.id="wmd-olist-button";ad.title="Numbered List <ol> Ctrl+O";ad.XShift="-120px";ad.textOp=function(af,ae){n.doList(af,ae,true)};G(ad,true);aa.appendChild(ad);var M=document.createElement("li");M.className="wmd-button";M.id="wmd-ulist-button";M.title="Bulleted List <ul> Ctrl+U";M.XShift="-140px";M.textOp=function(af,ae){n.doList(af,ae,false)};G(M,true);aa.appendChild(M);var U=document.createElement("li");U.className="wmd-button";U.id="wmd-heading-button";U.title="Heading <h1>/<h2> Ctrl+H";U.XShift="-160px";U.textOp=n.doHeading;G(U,true);aa.appendChild(U);var O=document.createElement("li");O.className="wmd-button";O.id="wmd-hr-button";O.title="Horizontal Rule <hr> Ctrl+R";O.XShift="-180px";O.textOp=n.doHorizontalRule;G(O,true);aa.appendChild(O);var Q=document.createElement("li");Q.className="wmd-spacer";Q.id="wmd-spacer3";aa.appendChild(Q);var J=document.createElement("li");J.className="wmd-button";J.id="wmd-undo-button";J.title="Undo - Ctrl+Z";J.XShift="-200px";J.execute=function(ae){ae.undo()};G(J,true);aa.appendChild(J);var ac=document.createElement("li");ac.className="wmd-button";ac.id="wmd-redo-button";ac.title="Redo - Ctrl+Y";if(/win/.test(o.platform.toLowerCase())){ac.title="Redo - Ctrl+Y"}else{ac.title="Redo - Ctrl+Shift+Z"}ac.XShift="-220px";ac.execute=function(ae){ae.redo()};G(ac,true);aa.appendChild(ac);var S=document.createElement("li");S.className="wmd-button";S.id="wmd-help-button";S.XShift="-240px";S.isHelp=true;var W=document.createElement("a");W.href=e;W.target=f;W.title=d;S.appendChild(W);G(S,true);aa.appendChild(S);y()};var v=function(){if(/\?noundo/.test(c.location.href)){i.nativeUndo=true}if(!i.nativeUndo){u=new i.undoManager(function(){D();y()})}B();var I="keydown";if(q.isOpera){I="keypress"}h.addEvent(F,I,function(K){if(K.ctrlKey||K.metaKey){var L=K.charCode||K.keyCode;var M=String.fromCharCode(L).toLowerCase();switch(M){case"b":z(document.getElementById("wmd-bold-button"));break;case"i":z(document.getElementById("wmd-italic-button"));break;case"l":z(document.getElementById("wmd-link-button"));break;case"q":z(document.getElementById("wmd-quote-button"));break;case"k":z(document.getElementById("wmd-code-button"));break;case"g":z(document.getElementById("wmd-image-button"));break;case"o":z(document.getElementById("wmd-olist-button"));break;case"u":z(document.getElementById("wmd-ulist-button"));break;case"h":z(document.getElementById("wmd-heading-button"));break;case"r":z(document.getElementById("wmd-hr-button"));break;case"y":z(document.getElementById("wmd-redo-button"));break;case"z":if(K.shiftKey){z(document.getElementById("wmd-redo-button"))}else{z(document.getElementById("wmd-undo-button"))}break;default:return}if(K.preventDefault){K.preventDefault()}if(top.event){top.event.returnValue=false}}});h.addEvent(F,"keyup",function(K){if(K.shiftKey&&!K.ctrlKey&&!K.metaKey){var L=K.charCode||K.keyCode;if(L===13){fakeButton={};fakeButton.textOp=n.doAutoindent;z(fakeButton)}}});if(q.isIE){h.addEvent(F,"keydown",function(K){var L=K.keyCode;if(L===27){return false}})}if(F.form){var J=F.form.onsubmit;F.form.onsubmit=function(){if(J){return J.apply(this,arguments)}}}};var C=function(){if(i.showdown){var J=new i.showdown.converter()}var K=F.value;var I=function(){F.value=K};if(!/markdown/.test(i.wmd_env.output.toLowerCase())){if(J){F.value=J.makeHtml(K);top.setTimeout(I,0)}}return true};this.undo=function(){if(u){u.undo()}};this.redo=function(){if(u){u.redo()}};var w=function(){v()};this.destroy=function(){if(u){u.destroy()}if(H.parentNode){H.parentNode.removeChild(H)}if(F){F.style.marginTop=""}top.clearInterval(s)};w()};i.TextareaState=function(){var s=this;var t=i.panels.input;this.init=function(){if(!h.isVisible(t)){return}this.setInputAreaSelectionStartEnd();this.scrollTop=t.scrollTop;if(!this.text&&t.selectionStart||t.selectionStart===0){this.text=t.value}};this.setInputAreaSelection=function(){if(!h.isVisible(t)){return}if(t.selectionStart!==undefined&&!q.isOpera){t.focus();t.selectionStart=s.start;t.selectionEnd=s.end;t.scrollTop=s.scrollTop}else{if(c.selection){if(c.activeElement&&c.activeElement!==t){return}t.focus();var u=t.createTextRange();u.moveStart("character",-t.value.length);u.moveEnd("character",-t.value.length);u.moveEnd("character",s.end);u.moveStart("character",s.start);u.select()}}};this.setInputAreaSelectionStartEnd=function(){if(t.selectionStart||t.selectionStart===0){s.start=t.selectionStart;s.end=t.selectionEnd}else{if(c.selection){s.text=h.fixEolChars(t.value);var u;if(i.ieRetardedClick&&i.ieCachedRange){u=i.ieCachedRange;i.ieRetardedClick=false}else{u=c.selection.createRange()}var x=h.fixEolChars(u.text);var v="\x07";var y=v+x+v;u.text=y;var z=h.fixEolChars(t.value);u.moveStart("character",-y.length);u.text=x;s.start=z.indexOf(v);s.end=z.lastIndexOf(v)-v.length;var w=s.text.length-h.fixEolChars(t.value).length;if(w){u.moveStart("character",-x.length);while(w--){x+="\n";s.end+=1}u.text=x}this.setInputAreaSelection()}}};this.restore=function(){if(s.text!=undefined&&s.text!=t.value){t.value=s.text}this.setInputAreaSelection();t.scrollTop=s.scrollTop};this.getChunks=function(){var u=new i.Chunks();u.before=h.fixEolChars(s.text.substring(0,s.start));u.startTag="";u.selection=h.fixEolChars(s.text.substring(s.start,s.end));u.endTag="";u.after=h.fixEolChars(s.text.substring(s.end));u.scrollTop=s.scrollTop;return u};this.setChunks=function(u){u.before=u.before+u.startTag;u.after=u.endTag+u.after;if(q.isOpera){u.before=u.before.replace(/\n/g,"\r\n");u.selection=u.selection.replace(/\n/g,"\r\n");u.after=u.after.replace(/\n/g,"\r\n")}this.start=u.before.length;this.end=u.before.length+u.selection.length;this.text=u.before+u.selection+u.after;this.scrollTop=u.scrollTop};this.init()};i.Chunks=function(){};i.Chunks.prototype.findTags=function(s,v){var t=this;var u;if(s){u=h.extendRegExp(s,"","$");this.before=this.before.replace(u,function(w){t.startTag=t.startTag+w;return""});u=h.extendRegExp(s,"^","");this.selection=this.selection.replace(u,function(w){t.startTag=t.startTag+w;return""})}if(v){u=h.extendRegExp(v,"","$");this.selection=this.selection.replace(u,function(w){t.endTag=w+t.endTag;return""});u=h.extendRegExp(v,"^","");this.after=this.after.replace(u,function(w){t.endTag=w+t.endTag;return""})}};i.Chunks.prototype.trimWhitespace=function(s){this.selection=this.selection.replace(/^(\s*)/,"");if(!s){this.before+=p.$1}this.selection=this.selection.replace(/(\s*)$/,"");if(!s){this.after=p.$1+this.after}};i.Chunks.prototype.skipLines=function(w,t,v){if(w===undefined){w=1}if(t===undefined){t=1}w++;t++;var s;var u;this.selection=this.selection.replace(/(^\n*)/,"");this.startTag=this.startTag+p.$1;this.selection=this.selection.replace(/(\n*$)/,"");this.endTag=this.endTag+p.$1;this.startTag=this.startTag.replace(/(^\n*)/,"");this.before=this.before+p.$1;this.endTag=this.endTag.replace(/(\n*$)/,"");this.after=this.after+p.$1;if(this.before){s=u="";while(w--){s+="\\n?";u+="\n"}if(v){s="\\n*"}this.before=this.before.replace(new p(s+"$",""),u)}if(this.after){s=u="";while(t--){s+="\\n?";u+="\n"}if(v){s="\\n*"}this.after=this.after.replace(new p(s,""),u)}};n.prefixes="(?:\\s{4,}|\\s*>|\\s*-\\s+|\\s*\\d+\\.|=|\\+|-|_|\\*|#|\\s*\\[[^\n]]+\\]:)";n.unwrap=function(t){var s=new p("([^\\n])\\n(?!(\\n|"+n.prefixes+"))","g");t.selection=t.selection.replace(s,"$1 $2")};n.wrap=function(u,s){n.unwrap(u);var t=new p("(.{1,"+s+"})( +|$\\n?)","gm");u.selection=u.selection.replace(t,function(v,w){if(new p("^"+n.prefixes,"").test(v)){return v}return w+"\n"});u.selection=u.selection.replace(/\s+$/,"")};n.doBold=function(t,s){return n.doBorI(t,s,2,"strong text")};n.doItalic=function(t,s){return n.doBorI(t,s,1,"emphasized text")};n.doBorI=function(z,v,u,w){z.trimWhitespace();z.selection=z.selection.replace(/\n{2,}/g,"\n");z.before.search(/(\**$)/);var x=p.$1;z.after.search(/(^\**)/);var A=p.$1;var t=Math.min(x.length,A.length);if((t>=u)&&(t!=2||u!=1)){z.before=z.before.replace(p("[*]{"+u+"}$",""),"");z.after=z.after.replace(p("^[*]{"+u+"}",""),"")}else{if(!z.selection&&A){z.after=z.after.replace(/^([*_]*)/,"");z.before=z.before.replace(/(\s?)$/,"");var s=p.$1;z.before=z.before+A+s}else{if(!z.selection&&!A){z.selection=w}var y=u<=1?"*":"**";z.before=z.before+y;z.after=y+z.after}}return};n.stripLinkDefs=function(t,s){t=t.replace(/^[ ]{0,3}\[(\d+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|$)/gm,function(y,x,w,u,v){s[x]=y.replace(/\s*$/,"");if(u){s[x]=y.replace(/["(](.+?)[")]$/,"");return u+v}return""});return t};n.addLinkDef=function(A,w){var z=0;var s={};A.before=n.stripLinkDefs(A.before,s);A.selection=n.stripLinkDefs(A.selection,s);A.after=n.stripLinkDefs(A.after,s);var u="";var x=/(\[(?:\[[^\]]*\]|[^\[\]])*\][ ]?(?:\n[ ]*)?\[)(\d+)(\])/g;var t=function(B){z++;B=B.replace(/^[ ]{0,3}\[(\d+)\]:/,"  ["+z+"]:");u+="\n"+B};var v=function(E,C,B,D){if(s[B]){t(s[B]);return C+z+D}return E};A.before=A.before.replace(x,v);if(w){t(w)}else{A.selection=A.selection.replace(x,v)}var y=z;A.after=A.after.replace(x,v);if(A.after){A.after=A.after.replace(/\n*$/,"")}if(!A.after){A.selection=A.selection.replace(/\n*$/,"")}A.after+="\n\n"+u;return y};n.doLinkOrImage=function(v,u,t){v.trimWhitespace();v.findTags(/\s*!?\[/,/\][ ]?(?:\n[ ]*)?(\[.*?\])?/);if(v.endTag.length>1){v.startTag=v.startTag.replace(/!?\[/,"");v.endTag="";n.addLinkDef(v,null)}else{if(/\n\n/.test(v.selection)){n.addLinkDef(v,null);return}var s=function(w){if(w!==null){var z=window.location.protocol+"//"+window.location.hostname;if(w.toString().length>z.length&&w.toString().substring(0,z.length)==z){w=w.toString().substring(z.length,w.length)}if(w.toString().substring(0,4)!="http"&&w.toString().substring(0,1)!="/"){w="/"+w}v.startTag=v.endTag="";var x=" [999]: "+w;var y=n.addLinkDef(v,x);v.startTag=t?"![":"[";v.endTag="]["+y+"]";if(!v.selection){if(t){v.selection="alt text"}else{v.selection="link text"}}}u()};if(t){h.prompt(g,l,s)}else{h.prompt(j,a,s)}return true}};h.makeAPI=function(){i.wmd={};i.wmd.editor=i.editor;i.wmd.previewManager=i.previewManager};h.startEditor=function(){if(i.wmd_env.autostart===false){h.makeAPI();return}var t;var s;var u=function(){i.panels=new i.PanelCollection();s=new i.previewManager();var v=s.refresh;t=new i.editor(v);s.refresh(true)};h.addEvent(top,"load",u)};i.previewManager=function(){var C=this;var I;var J;var F;var x;var u;var B;var E=3000;var s="delayed";var y=function(L,K){h.addEvent(L,"input",K);L.onpaste=K;L.ondrop=K;h.addEvent(L,"keypress",K);h.addEvent(L,"keydown",K);J=new i.inputPoller(K,m)};var H=function(){var K=0;if(top.innerHeight){K=top.pageYOffset}else{if(c.documentElement&&c.documentElement.scrollTop){K=c.documentElement.scrollTop}else{if(c.body){K=c.body.scrollTop}}}return K};var v=function(){if(!i.panels.preview&&!i.panels.output){return}var M=i.panels.input.value;if(M&&M==u){return}else{u=M}var L=new Date().getTime();if(!I&&i.showdown){I=new i.showdown.converter()}if(I){M=I.makeHtml(M)}var K=new Date().getTime();x=K-L;z(M);B=M};var A=function(){if(F){top.clearTimeout(F);F=undefined}if(s!=="manual"){var K=0;if(s==="delayed"){K=x}if(K>E){K=E}F=top.setTimeout(v,K)}};var G=function(K){if(K.scrollHeight<=K.clientHeight){return 1}return K.scrollTop/(K.scrollHeight-K.clientHeight)};var t=function(){if(i.panels.preview){i.panels.preview.scrollTop=(i.panels.preview.scrollHeight-i.panels.preview.clientHeight)*G(i.panels.preview)}if(i.panels.output){i.panels.output.scrollTop=(i.panels.output.scrollHeight-i.panels.output.clientHeight)*G(i.panels.output)}};this.refresh=function(K){if(K){u="";v()}else{A()}};this.processingTime=function(){return x};this.output=function(){return B};this.setUpdateMode=function(K){s=K;C.refresh()};var w=true;var z=function(N){var L=k.getTop(i.panels.input)-H();if(i.panels.output){if(i.panels.output.value!==undefined){i.panels.output.value=N;i.panels.output.readOnly=true}else{var M=N.replace(/&/g,"&amp;");M=M.replace(/</g,"&lt;");i.panels.output.innerHTML="<pre><code>"+M+"</code></pre>"}}if(i.panels.preview){i.panels.preview.innerHTML=N}t();if(w){w=false;return}var K=k.getTop(i.panels.input)-H();if(q.isIE){top.setTimeout(function(){top.scrollBy(0,K-L)},0)}else{top.scrollBy(0,K-L)}};var D=function(){if(i.panels.input==null){return}y(i.panels.input,A);v();if(i.panels.preview){i.panels.preview.scrollTop=0}if(i.panels.output){i.panels.output.scrollTop=0}};this.destroy=function(){if(J){J.destroy()}};D()};n.doAutoindent=function(t,s){t.before=t.before.replace(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]*\n$/,"\n\n");t.before=t.before.replace(/(\n|^)[ ]{0,3}>[ \t]*\n$/,"\n\n");t.before=t.before.replace(/(\n|^)[ \t]+\n$/,"\n\n");if(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]+.*\n$/.test(t.before)){if(n.doList){n.doList(t)}}if(/(\n|^)[ ]{0,3}>[ \t]+.*\n$/.test(t.before)){if(n.doBlockquote){n.doBlockquote(t)}}if(/(\n|^)(\t|[ ]{4,}).*\n$/.test(t.before)){if(n.doCode){n.doCode(t)}}};n.doBlockquote=function(u,t){u.selection=u.selection.replace(/^(\n*)([^\r]+?)(\n*)$/,function(y,w,v,x){u.before+=w;u.after=x+u.after;return v});u.before=u.before.replace(/(>[ \t]*)$/,function(w,v){u.selection=v+u.selection;return""});u.selection=u.selection.replace(/^(\s|>)+$/,"");u.selection=u.selection||"Blockquote";if(u.before){u.before=u.before.replace(/\n?$/,"\n")}if(u.after){u.after=u.after.replace(/^\n?/,"\n")}u.before=u.before.replace(/(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*$)/,function(v){u.startTag=v;return""});u.after=u.after.replace(/^(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*)/,function(v){u.endTag=v;return""});var s=function(v){var w=v?"> ":"";if(u.startTag){u.startTag=u.startTag.replace(/\n((>|\s)*)\n$/,function(y,x){return"\n"+x.replace(/^[ ]{0,3}>?[ \t]*$/gm,w)+"\n"})}if(u.endTag){u.endTag=u.endTag.replace(/^\n((>|\s)*)\n/,function(y,x){return"\n"+x.replace(/^[ ]{0,3}>?[ \t]*$/gm,w)+"\n"})}};if(/^(?![ ]{0,3}>)/m.test(u.selection)){n.wrap(u,i.wmd_env.lineLength-2);u.selection=u.selection.replace(/^/gm,"> ");s(true);u.skipLines()}else{u.selection=u.selection.replace(/^[ ]{0,3}> ?/gm,"");n.unwrap(u);s(false);if(!/^(\n|^)[ ]{0,3}>/.test(u.selection)&&u.startTag){u.startTag=u.startTag.replace(/\n{0,2}$/,"\n\n")}if(!/(\n|^)[ ]{0,3}>.*$/.test(u.selection)&&u.endTag){u.endTag=u.endTag.replace(/^\n{0,2}/,"\n\n")}}if(!/\n/.test(u.selection)){u.selection=u.selection.replace(/^(> *)/,function(w,v){u.startTag+=v;return""})}};n.doCode=function(w,u){var s=/\S[ ]*$/.test(w.before);var x=/^[ ]*\S/.test(w.after);if((!x&&!s)||/\n/.test(w.selection)){w.before=w.before.replace(/[ ]{4}$/,function(y){w.selection=y+w.selection;return""});var v=1;var t=1;if(/\n(\t|[ ]{4,}).*\n$/.test(w.before)){v=0}if(/^\n(\t|[ ]{4,})/.test(w.after)){t=0}w.skipLines(v,t);if(!w.selection){w.startTag="    ";w.selection="enter code here"}else{if(/^[ ]{0,3}\S/m.test(w.selection)){w.selection=w.selection.replace(/^/gm,"    ")}else{w.selection=w.selection.replace(/^[ ]{4}/gm,"")}}}else{w.trimWhitespace();w.findTags(/`/,/`/);if(!w.startTag&&!w.endTag){w.startTag=w.endTag="`";if(!w.selection){w.selection="enter code here"}}else{if(w.endTag&&!w.startTag){w.before+=w.endTag;w.endTag=""}else{w.startTag=w.endTag=""}}}};n.doList=function(w,x,t){var A=/(\n|^)(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*$/;var E=/^\n*(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*/;var v="-";var C=1;var z=function(){var G;if(t){G=" "+C+". ";C++}else{G=" "+v+" "}return G};var y=function(G){if(t===undefined){t=/^\s*\d/.test(G)}G=G.replace(/^[ ]{0,3}([*+-]|\d+[.])\s/gm,function(H){return z()});return G};w.findTags(/(\n|^)*[ ]{0,3}([*+-]|\d+[.])\s+/,null);if(w.before&&!/\n$/.test(w.before)&&!/^\n/.test(w.startTag)){w.before+=w.startTag;w.startTag=""}if(w.startTag){var B=/\d+[.]/.test(w.startTag);w.startTag="";w.selection=w.selection.replace(/\n[ ]{4}/g,"\n");n.unwrap(w);w.skipLines();if(B){w.after=w.after.replace(E,y)}if(t==B){return}}var F=1;w.before=w.before.replace(A,function(G){if(/^\s*([*+-])/.test(G)){v=p.$1}F=/[^\n]\n\n[^\n]/.test(G)?1:0;return y(G)});if(!w.selection){w.selection="List item"}var s=z();var u=1;w.after=w.after.replace(E,function(G){u=/[^\n]\n\n[^\n]/.test(G)?1:0;return y(G)});w.trimWhitespace(true);w.skipLines(F,u,true);w.startTag=s;var D=s.replace(/./g," ");n.wrap(w,i.wmd_env.lineLength-D.length);w.selection=w.selection.replace(/\n/g,"\n"+D)};n.doHeading=function(w,u){w.selection=w.selection.replace(/\s+/g," ");w.selection=w.selection.replace(/(^\s+|\s+$)/g,"");if(!w.selection){w.startTag="## ";w.selection="Heading";w.endTag=" ##";return}var t=0;w.findTags(/#+[ ]*/,/[ ]*#+/);if(/#+/.test(w.startTag)){t=p.lastMatch.length}w.startTag=w.endTag="";w.findTags(null,/\s?(-+|=+)/);if(/=+/.test(w.endTag)){t=1}if(/-+/.test(w.endTag)){t=2}w.startTag=w.endTag="";w.skipLines(1,1);var s=t==0?2:t-1;if(s>0){var v=s>=2?"-":"=";var x=w.selection.length;if(x>i.wmd_env.lineLength){x=i.wmd_env.lineLength}w.endTag="\n";while(x--){w.endTag+=v}}};n.doHorizontalRule=function(t,s){t.startTag="----------\n";t.selection="";t.skipLines(2,1,true)}};function initializeWmd(){Attacklab.wmd_env={};Attacklab.account_options={};Attacklab.wmd_defaults={version:1,output:"Markdown",lineLength:40,delayLoad:false};if(!Attacklab.wmd){Attacklab.wmd=function(){Attacklab.loadEnv=function(){var b=function(d){if(!d){return}for(var c in d){Attacklab.wmd_env[c]=d[c]}};b(Attacklab.wmd_defaults);b(Attacklab.account_options);b(top.wmd_options);Attacklab.full=true;var a="bold italic link blockquote code image ol ul heading hr";Attacklab.wmd_env.buttons=Attacklab.wmd_env.buttons||a};Attacklab.loadEnv()};Attacklab.wmd();Attacklab.wmdBase();Attacklab.Util.startEditor()}};