function quote(a){if(document.selection)document.post.com.focus(),document.selection.createRange().text=">>"+a+"\n";else if(document.post.com.selectionStart||"0"==document.post.com.selectionStart){var b=document.post.com.selectionEnd;document.post.com.value=document.post.com.value.substring(0,document.post.com.selectionStart)+">>"+a+"\n"+document.post.com.value.substring(b,document.post.com.value.length)}else document.post.com.value+=">>"+a+"\n"}
function replyhl(a){for(var a=document.getElementById("p"+a),b=document.querySelectorAll(".highlight"),c=0;c<b.length;c++)b[c].className&&(b[c].className=b[c].className.replace(/ highlight$/,""));a.className+=" highlight"}function repquote(a){""==document.post.com.value&&quote(a)}function reppop(a){var b=(new Date).getTime();window.open(a,b,"toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=660,height=192");return!1}
function recaptcha_load(){document.getElementById("recaptcha_div")&&Recaptcha.create("6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc","recaptcha_div",{theme:"clean"})}
function toggleMobilePostForm(a,b){elem=document.getElementById("mpostform");postForm=document.getElementById("postForm");elem.className.match("hidden")?(elem.className=elem.className.replace("hidden","shown"),postForm.className=postForm.className.replace(" hideMobile",""),elem.innerHTML="Close Post Form"):(elem.className=elem.className.replace("shown","hidden"),postForm.className+=" hideMobile",elem.innerHTML=a?"Start a Thread":"Reply to Thread");b&&window.scroll(0,0)}
function init(){if("undefined"!=typeof style_group&&style_group)var a=readCookie(style_group),a=a?a:getPreferredStyleSheet();switch(a){case "Yotsuba B":setActiveStyleSheet("Yotsuba B New");break;case "Yotsuba":setActiveStyleSheet("Yotsuba New");break;case "Burichan":setActiveStyleSheet("Burichan New");break;case "Futaba":setActiveStyleSheet("Futaba New");break;default:setActiveStyleSheet(a)}location.href.match(/boards\.4chan\.org\/(\w+)/);a=location.href.split(/#/);if(a[1]){if(a[1].match(/^p([0-9]+)$/)){var b=
a[1].replace("p","");replyhl(b)}a[1].match(/^q([0-9]+)$/)&&(b=a[1].replace("q",""),repquote(b),replyhl(b))}if("undefined"!=typeof jsMath&&"undefined"!=typeof jsMath.Easy.onload&&!jsMath.Easy.loaded)jsMath.Easy.onload();if(window.location.href.match("/res/")){elem=document.querySelectorAll(".postNum a");len=elem.length;for(a=0;a<len;a++)elem[a].onclick=function(){link=this.getAttribute("href").match("#p");if(!link)return!0;link=this.getAttribute("href").match(/#p([0-9]+)/)[1];replyhl(link)}}if(navigator.userAgent&&
navigator.userAgent.match(/iP(hone|ad|od)/i)){links=document.querySelectorAll(".spoiler");len=links.length;for(a=0;a<len;a++)links[a].onclick=function(){this.setAttribute("style",this.getAttribute("style").match("fff")?"color: #000!important;":"color: #fff!important;")}}initExtra()}function uninit(){var a=getActiveStyleSheet();a&&createCookie(style_group,a,365,".4chan.org")}
function setActiveStyleSheet(a){console.log("trying to set to "+a);for(var b,c,d="",e=0;b=document.getElementsByTagName("link")[e];e++)"switch"==b.getAttribute("title")&&(c=b),-1!=b.getAttribute("rel").indexOf("style")&&b.getAttribute("title")&&b.getAttribute("title")==a&&(d=b.href);c.setAttribute("href",d)}
function getActiveStyleSheet(){var a,b,c;for(a=0;b=document.getElementsByTagName("link")[a];a++)if("switch"==b.getAttribute("title"))c=b;else if(-1!=b.getAttribute("rel").indexOf("style")&&b.getAttribute("title")&&b.href==c.href)return b.getAttribute("title");return null}function getPreferredStyleSheet(){return"ws_style"==style_group?"Yotsuba B New":"Yotsuba New"}
function createCookie(a,b,c,d){if(c){var e=new Date;e.setTime(e.getTime()+864E5*c);c="; expires="+e.toGMTString()}else c="";document.cookie=a+"="+b+c+"; path=/"+(d?"; domain="+d:"")}function readCookie(a){for(var a=a+"=",b=document.cookie.split(";"),c=0;c<b.length;c++){for(var d=b[c];" "==d.charAt(0);)d=d.substring(1,d.length);if(0==d.indexOf(a))return d.substring(a.length,d.length)}return null}window.onload=init;window.onunload=uninit;