// ۞// text{ encoding:utf-8; bom:no; linebreaks:unix; tabs:4; } // ۞//

/*
	Socoder's Javascript, so I don't have to keep sending it every damn page.
	Not sure why I didn't do this before, to be honest!
*/

 
var mTimer;
var eTimer;
var pollTimer;
var jbit;
jbit=0;
var flaunch;
flaunch=0;
 
 function openfold(part) {
document.getElementById(part).style.display='';
}
function closefold(part) {
document.getElementById(part).style.display='none';
}


function opentab(part,id) {
var n;
var sh;
var id2;
var def;
def='none';
 if (id==0) {def='';}
	for (n=1;n<15;n++) {
		sh=def;
		if (n==id) {sh='';}
		if (document.getElementById(part+n)) {document.getElementById(part+n).style.display=sh;}
	}
}


var newwindow;
function popup(url,post,comment)
{
	newwindow=window.open(url+'?post='+post+'&comment='+comment,'Nominate Post','height=100,width=320,resizable=yes,scrollbars=yes,toolbar=no,status=yes,directories=no,location=no,menubar=no');
	if (window.focus) {newwindow.focus()}
}
 
function addtag(e,b) {
	InsertText(e, b);
}

function TodoSomething(a,b,c) {
	var sendto="TodoSomething.php";
		if (document.getElementById) {
			var todothis = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
		}
		if (todothis) {
			todothis.onreadystatechange = function()	{
				if (todothis.readyState == 4 && todothis.status == 200) {
					todohere = document.getElementById("TodoList_"+a.toString());
					todohere.innerHTML = todothis.responseText.replace(/\\\'/g,"'");
					}
				}
			var poststr = "postid="+a.toString()+"&value="+b.toString()+"&set="+c.toString();
			todothis.open("POST", sendto, true);
			todothis.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			todothis.setRequestHeader("Content-length", poststr.length.toString());
			todothis.setRequestHeader("Connection", "close");
			todothis.send(poststr);
		}	
}

function TodoSomethingNew(a) {
	var sendto = "TodoSomething.php";
	var TodoForm = document.getElementById("TodoEntry_"+a.toString());
	var sendthis = encodeURI(TodoForm.addme.value);
	
		if (document.getElementById) {
			var todothis = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
		}
		if (todothis) {
			todothis.onreadystatechange = function()	{
				if (todothis.readyState == 4 && todothis.status == 200) {
					todohere = document.getElementById("TodoList_"+a.toString());
					todohere.innerHTML = todothis.responseText.replace(/\\\'/g,"'");
					}
				}
			var poststr = "postid="+a.toString()+"&addme="+sendthis;
			todothis.open("POST", sendto, true);
			todothis.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			todothis.setRequestHeader("Content-length", poststr.length.toString());
			todothis.setRequestHeader("Connection", "close");
			todothis.send(poststr);
		}	
}
 
 
function PreviewBBCode(e) {
	var textarea = GetParentFormTextarea(e);
	var getdata="justformat.php";
	var BBCode = textarea.value;
			BBCode = BBCode.replace(/%/g,"*pc*");
			BBCode = BBCode.replace(/&/g,"*am*");
			BBCode = BBCode.replace(/\+/g,"*pl*");
			BBCode = BBCode.replace(/\n/g,"*BR*");
	
		if (document.getElementById) {
			var w = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
		}
		if (w) {
			w.onreadystatechange = function()	{
				if (w.readyState == 4 && w.status == 200) {
					el = document.getElementById("BBPreview");
					el.innerHTML = w.responseText.replace(/\\\'/g,"'");
					}
				}
			var poststr = "in=" +  escape(encodeURI(BBCode));
			w.open("POST", getdata, true);
			w.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			w.setRequestHeader("Content-length", poststr.length.toString());
			w.setRequestHeader("Connection", "close");
			w.send(poststr);
		}
				
}
 
function JNKGets(putdata,getdata,putinto) {
	var d = new Date();
	var time = d.getTime();
 
			if (document.getElementById) {
				var pb = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
				}
			if (pb) {
				pb.onreadystatechange = function()	{
					if ((pb.readyState == 4 || pb.readyState == 0)) {
						el = document.getElementById(putinto);
						el.innerHTML = pb.responseText;
						}
					}
					
				pb.open("GET", getdata+"?"+putdata+"&time="+time, true);
				pb.send(null);
				}
	}
	
