function editorReady(a){$.get("/questions/ticks",function(b){$("#post-editor-hidden").append("<input type='hidden' name='bullet' value='"+b+"' />")});if($("#show-editor-button").length==0){initPostEditor(a)}}function initPostEditor(b){setupFormValidation("#post-form",null,function(c){setConfirmUnload(null);c.submit()});var a=$("#wmd-input");a.not(".processed").TextAreaResizer();a.typeWatch({highlight:false,wait:5000,captureLength:5,callback:styleCode});a.rules("add",{required:true,minlength:15});if($("#title").length>0){$("#title").rules("add",{required:true,minlength:15})}Attacklab.wmdBase();Attacklab.Util.startEditor();if(b){a.keypress(heartbeat.start)}a.keypress(initNavPrevention);initPostLoginValidation()}function initPostLoginValidation(){if($("#openid_identifier").length==0){return}$.validator.addMethod("alturl",function(a){return/((^https?:\/\/)?.{2,}\.\w{2,4}\/?|^$)/.test(a)},"Enter a valid URL.");$("#openid_identifier").rules("add",{alturl:true});if($("#display-name").length==0){return}$.validator.addMethod("validUserName",function(b,a){return this.optional(a)||/^[\w\-\s\d'\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/.test(b)},"Can only contain A-Z, 0-9, spaces, and hyphens.");$.validator.addMethod("oidalt",function(a){return(a.length>2)||($("#openid_identifier").val().length>0)},function(){return"<br>"+($("#name_req_err").text()?$("#name_req_err").text():"Required if you're not using an OpenID")});$("#display-name").rules("add",{validUserName:true,oidalt:true,minlength:2,maxlength:30});$("#email").rules("add",{email:true,oidalt:true});$("#home-page").rules("add",{alturl:true})}function initNavPrevention(a){if(a.which=="undefined"){return}$("#wmd-input").unbind("keypress",initNavPrevention);setConfirmUnload("You have started writing or editing a post.")}(function(a){a.fn.typeWatch=function(d){var b=a.extend({wait:750,callback:function(){},highlight:true,captureLength:2},d);function c(h,g){var f=a(h.el).val();if((f.length>b.captureLength&&f.toUpperCase()!=h.text)||(g&&f.length>b.captureLength)){h.text=f.toUpperCase();h.cb(f)}}function e(g){if(g.type.toUpperCase()=="TEXT"||g.nodeName.toUpperCase()=="TEXTAREA"){var h={timer:null,text:a(g).val().toUpperCase(),cb:b.callback,el:g,wait:b.wait};if(b.highlight){a(g).focus(function(){this.select()})}var f=function(i){var l=h.wait;var k=false;if(i.keyCode==13&&this.type.toUpperCase()=="TEXT"){l=1;k=true}var j=function(){c(h,k)};clearTimeout(h.timer);h.timer=setTimeout(j,l)};a(g).keydown(f)}}return this.each(function(f){e(this)})}})(jQuery);(function(c){var h,i;var d=0;var a=32;var e;c.fn.TextAreaResizer=function(){return this.each(function(){h=c(this).addClass("processed"),i=null;c(this).parent().append(c('<div class="grippie"></div>').bind("mousedown",{el:this},b));var k=c("div.grippie",c(this).parent())[0];k.style.marginRight=(k.offsetWidth-c(this)[0].offsetWidth)+"px"})};function b(k){h=c(k.data.el);h.blur();d=j(k).y;i=h.height()-d;h.css("opacity",0.25);c(document).mousemove(g).mouseup(f);return false}function g(m){var k=j(m).y;var l=i+k;if(d>=(k)){l-=5}d=k;l=Math.max(a,l);h.height(l+"px");if(l<a){f(m)}return false}function f(k){c(document).unbind("mousemove",g).unbind("mouseup",f);h.css("opacity",1);h.focus();h=null;i=null;d=0}function j(k){return{x:k.clientX+document.documentElement.scrollLeft,y:k.clientY+document.documentElement.scrollTop}}})(jQuery);var heartbeat=function(){var c=1000*60;var b;var d=0;var a=false;return{start:function(e){if(e.which=="undefined"){return}if(d++>0){return}$("#wmd-input").unbind("keypress",heartbeat.start);b=location.href.match(/\/questions\/(\d+)/i)[1];setTimeout(heartbeat.ping,c)},ping:function(){var e="";$("div.answer").each(function(){e+=this.id.substring("answer-".length)+" "});$.post("/posts/"+b+"/new-activity-heartbeat",{answerIds:e},heartbeat.result,"json")},result:function(f){var e=true;if(f&&!a){if(f.NoPosting){var g="This question has been "+f.Msg+" - no more answers will be accepted.";notify.show(g);a=true;disableSubmitButton("#post-form");setConfirmUnload(null);e=false}else{if(f.Result){var g=f.Count+" new answer"+(f.Count==1?" has":"s have")+" been posted - ";g+='<a onclick="heartbeat.update()">load new answers.</a>';notify.show(g);a=true}}}if(e){setTimeout(heartbeat.ping,c)}},update:function(){var e=[];$.get("/questions/"+b,function(h){var k=$(h);k.find("div.answer").each(function(){var l=this.id.substring("answer-".length);if($("#answer-"+l).length==0){e.push(this.id)}});if(e.length>0){var g="#"+e.join(",#");var j=k.find(g);var f=$("div.answer:last");if(f.length==0){f=$("#answers-header")}j.hide();f.after(j);j.fadeIn("slow");var i=$("div.answer").length;$("#subheader h2").text(i+" Answer"+(i>1?"s":""));vote.init(b);comments.init()}notify.close();a=false},"html")}}}();