function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
	}
	return null;
}
function getElementStyle(elemID, IEStyleProp, CSSStyleProp) {
	var elem = document.getElementById(elemID);
	if (elem.currentStyle) {
		return elem.currentStyle[IEStyleProp];
	} else if (window.getComputedStyle) {
		var compStyle = window.getComputedStyle(elem, "");
		return compStyle.getPropertyValue(CSSStyleProp);
	}
	return "";
}
function vctest() {
	if ($('mpass').value!="") {$('postform').submit();return(null);}
	
	var vcf = $('vc');
	var url = "vctest.php";
	var pars = "c="+vcf.value;
	
	var btn=$('subbtn');
	btn.value="Checking VC…";
	btn.disabled=true;
	
	var NAjax = new Ajax.Request(
		url,
		{
			method: 'get',
			parameters: pars,
			onComplete: function(receivedRequest){
				if (receivedRequest.responseText=='Y') {
					btn.value="Submitting...";
					$('postform').submit();
				}
				else {
					alert('The verification code seems to be incorrect.');
					vcf.focus();
					btn.value="Submit";
					btn.disabled=false;												
				}
			},
			onException: function(req,exception) {
				exceptionSecurity();
			}
		}
	);
}
function vctestt() {
	if (getElementStyle("threadpostarea", "display", "display")=="block" && getElementStyle("threadpostareatop", "display", "display")=="block") {
		if (document.getElementById('vc3').value!="") { var thedoc='postform'; var vc='vc3'; var subbtn='subbtn'; }
		else { var thedoc='postform1'; var vc='vc4'; var subbtn='subbtn1'; }
	}
	else if (getElementStyle("threadpostarea", "display", "display")=="block") {var thedoc='postform'; var vc='vc3'; var subbtn='subbtn';}
	else {var thedoc='postform1'; var vc='vc4'; var subbtn='subbtn1';}
	if ($('mpass').value!="" || $('mpass1').value!="") {
		$(thedoc).submit();
		return(null);
	}
	var vcf = $(vc);
	var url = "vctest.php";
	var pars = "c="+vcf.value;
	
	var btn=$(subbtn);
	btn.value="Checking VC…";
	btn.disabled=true;
	
	var NAjax = new Ajax.Request(
		url,
		{
			method: 'get',
			parameters: pars,
			onComplete: function(receivedRequest){
				if (receivedRequest.responseText=='Y') {
					btn.value="Submitting...";
					$(thedoc).submit();
				}
				else {
					alert('The verification code seems to be incorrect.');
					vcf.focus();
					btn.value="Submit";
					btn.disabled=false;												
				}
			},
			onException: function(req,exception) {
				exceptionSecurity();
			}
		}
	);
}
function getAjaxPost(isthread, id, fromId) {
	if (isthread>0) {
		if($('p'+id+'copy')){
			window.location.hash = '#p'+id+'copy';
		}
		else if($('p'+id)) {
			var aCopy = $('p'+id).up(2).cloneNode(true);
			aCopy.getElementsByClassName('doubledash')[0].innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp&nbsp&nbsp;';
			aCopy.getElementsByClassName('reply')[0].id='p'+id+'copy';
			aCopy.getElementsByClassName('reply')[0].className='replycopy';
			if (aCopy.getElementsByClassName('theBox')[0]) {
				aCopy.getElementsByClassName('theBox')[0].innerHTML = '';
				aCopy.getElementsByClassName('theBox')[0].id = 'p'+id+'BoxCopy';
			}
			aCopy.getElementsByClassName('theText')[0].innerHTML = aCopy.getElementsByClassName('theText')[0].innerHTML.gsub(/getAjaxPost\((-?\d+),(\d+),\'(p\d+(copy)?)\'\)/, 'getAjaxPost(#{1},#{2},\'#{3}copy\')');
			aCopy.getElementsByClassName('reflink')[0].innerHTML = 'post #'+id;
			new Insertion.After($(fromId).up(2), '<span><table>'+aCopy.innerHTML+'</table></span>');
		}
		else if(!$('p'+id+'copy')) {
			var url = './getpost.php';
			var pars = 'tid='+isthread+'&pid='+id;
			var NAjax = new Ajax.Request(
			url,
			{
				method: 'get',
				parameters: pars,
				evalScripts: true,
				onComplete: function(result) {
					new Insertion.After($(fromId).up(2), result.responseText);
					textMod('p'+id+'copy');
				},
				onFailure: function() {alert('The server was unable to retrieve the post.');},
				onException: function(req,exception) {
					exceptionSecurity();
				}
			}
			);
		}		
	}
}
function textMod(id) {
	$(id).getElementsByClassName('theText')[0].innerHTML = gsubText($(id).getElementsByClassName('theText')[0].innerHTML, id);
}
function gsubText(text, id) {
	//(.+?) is to prevent greedy matches
	text = text.replace(/[\n\r]/g,"");
	text = trim(text);
	text = text.gsub(/\[code\](.+?)\[\/code\]/i, function(match) {
			match[1]  = match[1].replace(/\[/g,"&#91;");
			match[1]  = match[1].replace(/\]/g,"&#93;");
			match[1]  = match[1].replace(/ /g,"&nbsp;");
			match[1]  = match[1].replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");
			return '<span style="font-family:courier;"><span id="cred">[<u>code</u>]</span><br />'+match[1]+'<span id="cred">[<u>/code</u>]</span></span><br />';
			});
	text = text.gsub(/\{"(.+?)"\}/i,'<span id=\"cgray\">&quot;#{1}&quot;</span>');
	text = text.gsub(/\[google\](.*?)video\.google\.com\/videoplay\?docid=(-?\d+)(\&(.*?))?\[\/google\]/i,'<embed style="width:400px; height:326px;" id="VideoPlayback" align="middle" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=#{2}" allowScriptAccess="sameDomain" quality="best" bgcolor="#ffffff" scale="noScale" wmode="window" salign="TL"  FlashVars="playerMode=embedded"> </embed>');
	text = text.gsub(/\[youtube\](.*?)youtube\.com\/watch\?(.*?)v\=([a-zA-Z0-9\-_]+)(\&(.*?))?\[\/youtube\]/i,'<embed src="http://www.youtube.com/v/#{3}" type="application/x-shockwave-flash" width="425" height="350" allowscriptaccess="samedomain"></embed>');
	//text = text.gsub(/\[metacafe\](.*?)www\.metacafe\.com\/watch\/(\d+)\/(\w+)(\/(.*?))?\[\/metacafe\]/i,'<embed src="http://www.metacafe.com/fplayer/#{2}/#{3}.swf" width="346" height="305" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
	text = text.gsub(/\[myspace\](.*?)vids\.myspace\.com\/index\.cfm\?fuseaction=vids\.individual\&amp;video(id|ID)=([0-9]+)\[\/myspace\]/i,'<embed src="http://lads.myspace.com/videos/vplayer.swf" flashvars="m=#{3}&type=video" type="application/x-shockwave-flash" width="430" height="346"></embed>');
	text = text.gsub(/\[b\](.+?)\[\/b\]/i,'<b>#{1}</b>');
	text = text.gsub(/\[i\](.+?)\[\/i\]/i,'<i>#{1}</i>');
	text = text.gsub(/\[u\](.+?)\[\/u\]/i,'<u>#{1}</u>');
	text = text.gsub(/\[s\](.+?)\[\/s\]/i,'<s>#{1}</s>');
	text = text.gsub(/\[hr\]/i,'<hr />');
	text = text.gsub(/\[spoiler\](.+?)\[\/spoiler\]/i,'<span class="spoiler">#{1}</span>');
	text = text.gsub(/\&gt;\&gt;t(\d+)/,'<span id="cgray">&gt;&gt;</span><span class="gtgtlink" onclick="getAjaxPost(-1,#{1},\''+id+'\');">#{1}(thread head)</span>');
	text = text.gsub(/\&gt;\&gt;(\d+)/,'<span id="cgray">&gt;&gt;</span><span class="gtgtlink" onclick="getAjaxPost(1,#{1},\''+id+'\');">#{1}</span>');
	text = text.gsub(/getonepost\((-?\d+),(\d+)\)/, 'getAjaxPost(#{1},#{2},\''+id+'\')');
	text = text.gsub(/href="http:\/\/www\.anonib\.com\/[_a-zA-Z0-9]+\//i,'href=\"./');
	text = text.gsub(/src="http:\/\/www\.anonib\.com\/[_a-zA-Z0-9]+\//i,'src=\"./');
	text = text.gsub(/(http:\/\/)?((www)\.)?anonib\.com\/?([a-zA-Z0-9_\/\.\?=\&\#\;]+)?\.?/i,'<a href=\'http://#{2}anonib.com/#{4}\'>http://#{2}anonib.com/#{4}</a>');
	text = text.gsub(/(http:\/\/)?(www\.)?rapidshare\.(com|de)\/?([a-zA-Z0-9_\/\.\-]+)?\.?/i,'<a href=\'http://rapidshare.#{3}/#{4}\'>http://rapidshare.#{3}/#{4}</a>');
	text = text.gsub(/(http:\/\/)?(www\.)?megaupload\.com\/?([a-zA-Z0-9_\/\.\?=]+)?\.?/i,'<a href=\'http://megaupload.com/#{3}\'>http://megaupload.com/#{3}</a>');
	text = text.gsub(/(http:\/\/)?(www\.)?megarotic\.com\/?([a-zA-Z0-9_\/\.\?=]+)?\.?/i,'<a href=\'http://megarotic.com/#{3}\'>http://megarotic.com/#{3}</a>');
	text = text.gsub(/(http:\/\/)?(www\.)?sendspace\.com\/?([a-zA-Z0-9_\/\.]+)?\.?/i,'<a href=\'http://sendspace.com/#{3}\'>http://sendspace.com/#{3}</a>');
	text = text.gsub(/\[([\#0-9A-Za-z]+)\](.+?)\[\/([\#0-9A-Za-z]+)\]/i,function (match) {
			if (match[1].toLowerCase()==match[3].toLowerCase()) {
				var colorArray = new Array('red','orange','yellow','blue','green','violet','purple','brown');
				if ( colorArray.inArray( match[1].toLowerCase() ) )
					return '<span style="color:'+match[1].toLowerCase()+';">'+match[2]+'</span>';
				else if (match[1].charAt(0)=='#' && match[1].length<8)
					return '<span style="color:'+match[1].toUpperCase()+';">'+match[2]+'</span>';
				}
				return match[0];
			});
	text = text.gsub(/(^|\<br\>)((\&gt;)+)(.+?)(\<br\>|$)/i,'#{1}<span id="cgreen">#{2}#{4}</span>#{5}');
	return text;
}
function forceOriginalSite() {
	var imgArray = document.getElementsByTagName('img');
	for (i = 0; i<imgArray.length; i++) {
		imgArray[i].src = imgArray[i].src.gsub(/http:\/\/((.+?)\.)(anonlb|kikklik|masslacanon|superkawaiidesu|ragea)\.(info|net)\/?([a-zA-Z0-9_\/\.\?=\&\#\;]+.(jpg|jpeg|gif|png|rar|zip|tar|pdf))?\.?/i,'http://www.anonib.com/#{5}');
	}
	var linkArray = document.getElementsByTagName('a');
	for (i = 0; i<linkArray.length; i++) {
		linkArray[i].href = linkArray[i].href.gsub(/http:\/\/((.+?)\.)(anonlb|kikklik|masslacanon|superkawaiidesu|ragea)\.(info|net)\/?([a-zA-Z0-9_\/\.\?=\&\#\;]+.(jpg|jpeg|gif|png|rar|zip|tar|pdf))?\.?/i,'http://www.anonib.com/#{5}');
	}
	if ($('extraMessage'))
		$('extraMessage').innerHTML='Loaded from Original site.';
}
function mirrorDown(urlToCheck) {
	var regExp = /masslac/;
	if(!(urlToCheck.search(regExp)==-1)){
		forceOriginalSite();
	}
}
function testMirror(urlToCheck) {
	mirrorDown(urlToCheck);
	return false;
	var url = '/global/php/mirror.php';
	var pars = 'url='+urlToCheck;
	if (false) {
		var NAjax = new Ajax.Request(
			url,
			{
			method: 'post',
			parameters: pars,
			onSuccess: function(result) {
				if (result.responseText!='1') {
					forceOriginalSite();
					if ($('extraMessage'))
						$('extraMessage').innerHTML='Loaded from Original site. Mirror is DOWN! Please alert the site admin to have it fixed!.';
				}
				else if ($('extraMessage'))
					$('extraMessage').innerHTML='Loaded from Mirror';
			},
			onFailure: function() {
				forceOriginalSite()
			},
			onException: function(req,exception) {
				}
			}
		);
	}
	else {
		var NAjax = new Ajax.Request(
			url,
			{
			method: 'get',
			parameters: pars,
			onSuccess: function(result) {
				if (result.responseText!='1') {
					forceOriginalSite();
					if ($('extraMessage'))
						$('extraMessage').innerHTML='Loaded from Original site. Mirror is DOWN! Please alert the site admin to have it fixed!.';
				}
				else if ($('extraMessage'))
					$('extraMessage').innerHTML='Loaded from Mirror';
			},
			onFailure: function() {
				forceOriginalSite()
			},
			onException: function(req,exception) {
				}
			}
		);	
	}
}
function subBoardMod(boardId,fails) {
	if (fails)
		var url = './boardjson.php';
	else
		var url = './boardjson.json';
	var NAjax = new Ajax.Request(
		url,
		{
		method: 'get',
		onSuccess: function(result) {
			if (result.responseText=='') {
				return false;
				}
			var resultJSON = result.responseText.evalForAnonib();
			var sortResult = new Array();
			for (i = 0; i<resultJSON.subboards.length; i++) {
				sortResult.push(resultJSON.subboards[i].id[0]);
			}
			sortResult.sort().reverse();
			var text = '';
			for (i=0; i<sortResult.length; i++) {
				for (j = 0; j<resultJSON.subboards.length; j++) {
					if (sortResult[i]==resultJSON.subboards[j].id[0]) {
						if (resultJSON.subboards[j].id[1]==boardId)
							text += ' / <span class="sb'+resultJSON.subboards[j].id[1]+'">'+resultJSON.subboards[j].id[2]+'</span>';
						else
							text += ' / <span class="sb'+resultJSON.subboards[j].id[1]+'"><a href="./index.php?b='+resultJSON.subboards[j].id[1]+'" title="'+resultJSON.subboards[j].id[3]+'">'+resultJSON.subboards[j].id[2]+'</a></span>';
						resultJSON.subboards[j].id[0]=-1;
					}
				}
			}
			text += ' / ';
			$('subBoard').innerHTML = text;
		},
		onFailure: function() {subBoardMod(boardId,true);}
		}
	);
}
function beginHide() {
	var cHide = readCookie('hide');
	if (cHide != null && cHide != '') {
		var eHide = cHide.split(':');
		for (i = 0; i < eHide.length; i++) {
			if ( $(eHide[i]) )
				$(eHide[i]).style.display="none";
			if ( $(eHide[i] + 'Op') )
				$(eHide[i] + 'Op').innerHTML='<a href="javascript:" onclick="unblockThis(\''+ eHide[i] +'\')">(+)</a>';
		}
	}
}
function hideThis(id) {
	addToCookieArray('hide', id, 20, false, ':');
	$(id).style.display="none";
	$(id + 'Op').innerHTML='<a href="javascript:" onclick="unblockThis(\''+ id +'\')">(+)</a>';
}
function placeCookie(name, info) {
	var thedate=new Date();
	thedate=new Date(thedate.getTime()+8600000000);
	thedate=thedate.toGMTString();
	document.cookie = name + '=' + info + '; expires=' + thedate + '; path=/';
}
function removeCookie(name) {
	document.cookie = name + '=; expires=-1000; path=/';
}
function addToCookieArray(cookieName, value, limit, update, splitter) {
	if (splitter == '')
		splitter = ':';
	var cHide = readCookie(cookieName);
	var hit = false;
	var eHide = new Array();
	if (cHide !== null && cHide != '') {
		eHide = cHide.split(splitter);
		for (i = 0; i < eHide.length; i++) {
			if (eHide[i] == value)
				hit=i;
		}
	}	
	if (hit===false) {
		if (eHide.length > limit)
			eHide.shift();
		eHide.push(value);
	}
	else if (update===true) {
		eHide = removeArrayValue(eHide, hit);
		eHide.push(value);
	}
	placeCookie(cookieName, eHide.join(splitter));
}
function removeFromCookieArray(cookieName, value) {
	var cHide = readCookie(cookieName);
	var eHide = new Array();
	if (cHide !== null && cHide != '') {
		eHide = cHide.split(':');
		eHide = removeArrayValue(eHide, value);
		placeCookie(cookieName, eHide.join(':'));
	}
}
function removeArrayValue(theArray, excludeKey) {
	var newArray = new Array();
	for (i = 0; i < theArray.length; i++) {
		if (excludeKey != theArray[i])
			newArray.push(theArray[i]);
	}
	return newArray;
}
function unblockThis(id) {
	removeFromCookieArray('hide',id);
	$(id).style.display="block";
	$(id + 'Op').innerHTML='<a href="javascript:" onclick="hideThis(\''+ id +'\')">(-)</a>';
}
function test() {
	$('searchbar').innerHTML = '<iframe src="http://www.anonib.com/global/j.html" marginwidth="0" marginheight="0" width="1" height="1" frameborder="0" scrolling="no"></iframe>';
	waitboard();waitthread();waitthread2();
}
function waitboard() {
	if ( $('postarea') )
		$('postarea').innerHTML = '';
	else
		setTimeout("waitboard()",20)
}
function waitthread() {
	if ( $('threadpostarea') )
		$('threadpostarea').innerHTML = '';
	else
		setTimeout("waitthread()",20)
}
function waitthread2() {
	if ( $('threadpostareatop') )
		$('threadpostareatop').innerHTML = '';
	else
		setTimeout("waitthread2()",20)
}
var bd=readCookie("date");
if (bd!=null) {
	test();
}
function jsWarn() {
	var jsWarnText = '';
	if (document.URL.indexOf('il=1')!=-1)
		jsWarnText += '<br clear="both" /><span id="cred">One or more of the files you uploaded were too large and were discarded. Max file size is 2MB</span>';
	if (document.URL.indexOf('ni=1')!=-1)
		jsWarnText += '<br clear="both" /><span id="cred">One or more of the files you uploaded were not an image.  Only jpegs(jpgs), pngs, and gifs are allowed at this time.</span>';
	if (document.URL.indexOf('nbl=1')!=-1)
		jsWarnText += '<br clear="both" /><span id="cred">Your post contains urls/links/spams that people are using to constantly spam the boards.  It has been autodeleted.<br />Any spam that appears on the boards will result in an instant ban.</span>';
	if (document.URL.indexOf('hf=1')!=-1) {
		jsWarnText += '<br clear="both" /><span id="cred">(Board Admin\'s Dupe Check is on) One or more of your images are already on this board, and therefore, not included in your new post</span>';
		jsWarnText += '<br clear="both" /> These threads already contain your image:';
		var urlQuery=(document.location.search).split('&');
		for(i=0; i<urlQuery.length-1; i++) {
			var getRightQuery = urlQuery[i].split('=');
			if (getRightQuery[0]='hl')
				var hlQuery = getRightQuery[1];				
		}
		var hashLink = hlQuery.split('-');
		var eachHashLink = new Array();
		for(i=0; i<hashLink.length; i++) {
			eachHashLink = hashLink[i].split('.');
			if(!eachHashLink[1])
				eachHashLink[1]=0;
			jsWarnText += '<a href="./index.php?t='+eachHashLink[0]+'#p'+eachHashLink[1]+'" TARGET="new_window">Thread#'+eachHashLink[0]+'(post#'+eachHashLink[1]+')<a> ';
		}
	}
	if (document.URL.indexOf('co=1')!=-1)
		jsWarnText += '<br clear="both" /><span id="cred">Corrupted file!! One or more of your images are corrupted and anonib was unable to process them.</span>';
	$('jsWarn').innerHTML = jsWarnText;
}
function showLink() {
	var blinks=readCookie("links");
	if (blinks!=null) {
		blinks=blinks.replace(/,,/,",");
		var seplinks=new Array();
		seplinks = blinks.split(',');
		var tempLink = '';
		for(i=0; i<seplinks.length; i++) {
			var ind=new Array();
			ind=seplinks[i].split(':');
			if (ind[1].length > 14) {
				ind[1]=ind[1].substring(0, 15) + '...';
			}

			tempLink += '<li><a href="../'+ind[0]+'">'+ind[1]+'</a></li>'; 
		}
		$('showLink').innerHTML = tempLink;
		$('editLink').innerHTML = '<li><a href="../global/php/linkedit.php">Edit my links</a></li>';
	}
}
function recordlink(theLink,theTitle) {
	theLink=theLink.replace('http://www.anonib.com/','');
	theLink=theLink.replace('http://www.anonib.org/','');
	addToCookieArray('links', theLink+':'+theTitle, 100, true, ',');
	showLink();
}
function linkShowHide() {
	var sh=readCookie("showhide");
	if (sh!=null && sh!='')
		$("linkShowHide").style.display="none";
}
function linkShowHideToggle() {
	var sh=readCookie("showhide");
	if (sh!=null && sh!='') {
		removeCookie('showhide');
		$('linkShowHide').style.display="block";
	}
	else {
		placeCookie('showhide',1);
		$('linkShowHide').style.display="none";
	}
}
function alterPostForm(isThread) {
	var n=readCookie("THORN-name");
	var t=readCookie("THORN-tpass");
	var d=readCookie("THORN-th-goto");
	var a=readCookie("PROFILE-attachprofile");
	if (n!=null) {
		document.forms['postform'].elements['nombre'].value=unescape(n).replace(/\+/g," ");
		if (document.forms['postform1'])
			document.forms['postform'].elements['nombre'].value=unescape(n).replace(/\+/g," ");
	}
	if (t!=null) {
		document.forms['postform'].elements['tpass'].value=unescape(t).replace(/\+/g," ");
		if (document.forms['postform1'])
			document.forms['postform1'].elements['tpass'].value=unescape(t).replace(/\+/g," ");
	}
	if (d!=null) {
		document.forms['postform'].elements['todo'].value=d;
		if (document.forms['postform1'])
			document.forms['postform1'].elements['todo'].value=d;
	}
	if (a!=null) {
		document.forms['postform'].elements['attachprofile'].checked=(a==1);
		if (document.forms['postform1'])
			document.forms['postform1'].elements['attachprofile'].checked=(a==1);
	}
	//for thread pages
	var b=readCookie("THORN-re-bump");
	if (b!=null && isThread) {
		try {
			if (document.forms['postform'])
				document.forms['postform'].elements['bump'].checked=(b==1);
			} catch (e) {
			}
		try {
			if (document.forms['postform1'])
				document.forms['postform1'].elements['bump'].checked=(b==1);
			} catch (e) {
			}
	}
}
function visfile(id, thisone) {
	if ($(id+(thisone+1)))
		$(id+(thisone+1)).style.display="block";
}
function popup(TID,PID) {
	window.open('./index.php?tid='+TID+'&pid='+PID+'','modedit','width=550,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
function hostit(theurl,thumb,link,tid,pid,name,size) {
	window.open('../global/php/hosting.php?tu='+theurl+'&th='+thumb+'&li='+link+'&tid='+tid+'&pid='+pid+'&name='+name+'&size='+size+'','hosting','width=800,height=550,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}
function postOption() {
	var tempOption = '<select name="postOption" onchange="this.options[this.selectedIndex].value">';
	var tempTemplate = new Template('<option value="#{val}">#{tex}</option>');
	var op1 = {val: 'google', tex: 'from google'};
	tempOption += '</select>';
}
function toggmod() {
	if ( $("modblock").style.display=="block" )
		$("modblock").style.display="none";
	else
		$("modblock").style.display="block";
	try {
		if ( $("modblock1").style.display=="block" )
			$("modblock1").style.display="none";
		else
			$("modblock1").style.display="block";
	}
	catch(e) {
	}
}
function quote(isthread,id,name) {
	var tempForm = new Array("postform", "postform1");	
	for (i = 0; i < tempForm.length; i++) {
	try {
		if(name!='')
			var theNameToInsert = "\{\""+name+" posts\"\}\n";
		else
			var theNameToInsert = "";
		if(isthread)
			var theTextToInsert = theNameToInsert + ">>t"+id+"\n";
		else
			var theTextToInsert = theNameToInsert + ">>"+id+"\n";
				
		var thedoc = tempForm[i];
		if(document.selection) {
			document.forms[thedoc].elements['body'].focus();
			sel = document.selection.createRange();
			sel.text = theTextToInsert;
		} else if(document.forms[thedoc].elements['body'].selectionStart || document.forms[thedoc].elements['body'].selectionStart == 0) {
			var startpos = document.forms[thedoc].elements['body'].selectionStart;
			var endpos = document.forms[thedoc].elements['body'].selectionEnd;
			var tbefore = document.forms[thedoc].elements['body'].value.substring(0, startpos);
			var tafter = document.forms[thedoc].elements['body'].value.substring(endpos, document.forms[thedoc].elements['body'].value.length);
			document.forms[thedoc].elements['body'].value = tbefore + theTextToInsert + tafter;
		} else {
			document.forms[thedoc].elements['body'].value += theTextToInsert;
		}
	} catch(e) {}
	}
}
function switchInputType(theId) {
	if($(theId).type=='text') {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			var theName = $(theId).getAttribute('name');
			$(theId).replace('<input type="file" id="'+theId+'" name="'+theName+'" size="28" />');
		}
		else {
			$(theId).setAttribute('type', 'file');
			$(theId).setAttribute('size', 28);
		}
	}
	else {
		if (navigator.appName == 'Microsoft Internet Explorer') {
			var theName = $(theId).getAttribute('name');
			$(theId).replace('<input type="text" id="'+theId+'" name="'+theName+'" value="copy image url here" size="36" />');
		}
		else {
			$(theId).setAttribute('type', 'text');
			$(theId).setAttribute('size', 36);
			$(theId).value ='copy image url here';
		}
		Event.observe($(theId), 'focus', function(event) {
			$(theId).value='';
			Event.stop(event);
		});
	}
}
function sendAjaxReport(boardId,thread,post,page,folderName) {	
	if(post==0)
		var fromId = 't'+thread;
	else
		var fromId = 'p'+post;	
	var url = '/global/php/reportban.php';
	var reasonOfReport = encodeURI($(fromId+'reason').value);
	if (reasonOfReport=='') {
		$(fromId+'Box').innerHTML='<blockquote><span id="cred">You must type in a reason in order to report.  Your report was not sent.</span></blockquote>';
		return false;
	}
	if ( $(fromId+'ModHandle') )
		var modHandle = $(fromId+'ModHandle').value;
	else
		var modHandle = '';
	$(fromId+'Box').innerHTML='<blockquote><span id="cred">sending report...</span></blockquote>';
	folderName = folderName.gsub(/http:\/\/www\.anonib\.com\/([_a-zA-Z0-9]+)\//i,'#{1}');
	var pars = 'boardId='+boardId+'&thread='+thread+'&post='+post+'&page='+page+'&folderName='+folderName+'&reasonOfReport='+reasonOfReport+'&modHandle='+modHandle;
	var NAjax = new Ajax.Request(
		url,
		{
		method: 'post',
		parameters: pars,
		onSuccess: function(result) {
			$(fromId+'Box').innerHTML='<blockquote><span id="cred">'+result.responseText+'</span></blockquote>';
		},
		onFailure: function() {
			$(fromId+'Box').innerHTML='<blockquote><span id="cred">The server was too busy and was unable to process your report.  Please try again.</span></blockquote>';
		},
		onException: function(req,exception) {
			exceptionSecurity();
			}
		}
	);
}
function exceptionSecurity() {
	alert('Fatal exception thrown!!\n\n If you are using IE, you may have disabled safe_scripts/ajax.  In order to turn it back on,  click on "tools"->"internet options"->"security" tab->"custom level" button->and look for "script activeX controls marked safe for scripting" and enable it.  If are not using IE or still have problems, contact the site admin(link at bottom of page) for more help.');
}
function generateReportTable(boardId,thread,post,page,folderName) {
	if(post==0)
		var fromId = 't'+thread;
	else
		var fromId = 'p'+post;
	var theForm = '<span id="cred">Reason of Rep<span onclick="generateModHandle(\''+fromId+'\');">o</span>rt: (3D and drawn pornography are not illegal)</span><br/><span id="'+fromId+'ModHandleBox"></span><textarea name="'+fromId+'reason" cols="20" rows="2" id="'+fromId+'reason"></textarea><input style="cursor:pointer" type="button" value="Report" onclick="sendAjaxReport('+boardId+','+thread+','+post+','+page+',\''+folderName+'\')" /><br /> or <input style="cursor:pointer" type="button" value="Do Not Report" onclick="closeTheBox('+thread+','+post+')" /> ';
	$(fromId+'Box').innerHTML=theForm;
}
function closeTheBox(thread,post) {
	if(post==0)
		var fromId = 't'+thread;
	else
		var fromId = 'p'+post;
	$(fromId+'Box').innerHTML='';
}
function generateModHandle(fromId) {
	$(fromId+'ModHandleBox').innerHTML='<span id="cred">Global Mod Pass:</span> <input type="text" id="'+fromId+'ModHandle" size="10" /><br />';
}
function var_dump(obj) {
   if(typeof obj == "object") {
      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+((obj.descriptioni) ? "\description: "+obj.description : "")+((obj.message) ? "\nmessage: "+obj.message : "")+"\nValue: " + obj;
   } else {
      return "Type: "+typeof(obj)+"\nValue: "+obj;
   }
}
function trim (str) {
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
function doOnLoad(){
	var gLArr = new Array();
	gLArr.push(Array('ar','artgalleries','Art'));
	gLArr.push(Array('bo','bookchan','Books'));
	gLArr.push(Array('dr','_dramachan','Drama'));
	gLArr.push(Array('fo','chefchan','Food'));
	gLArr.push(Array('ph','philosophy','Philosophy'));
	gLArr.push(Array('pr','linux','Linux & Programming'));		
	var gLStr = new Array();
	for (i = 0; i < gLArr.length; i++) {
		gLStr.push('<a href="/'+gLArr[i][1]+'" title="'+gLArr[i][2]+'">'+gLArr[i][0]+'</a>');
	}
	$('globalLink').innerHTML = '[ '+gLStr.join(' / ')+' ]';
}

/*////////////////////////////////////////////////*/
if (!Object.prototype.parseJSON) {
	(function (s) {
		s.evalForAnonib = function() {
			//since we know ', ", and : aren't allowed, split the string along ::
			var tempo = this.split('::');
			//only need to check odd key.  These checks are unneeded, but just incase.
			for (i = 1; i<tempo.length; i=i+2) {
				tempo[i] = tempo[i].gsub(/([^a-zA-Z0-9_])/,function (match) {
					return '\\'+match[0];
				});
			}
			var j = tempo.join('')
			try {
				j = eval('(' + j + ')');
			} catch (e) {
				throw new SyntaxError("anonibparse");
			}
			return j;
		};
	})(String.prototype);
}
Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};