function pcolor(id)
{
var col = id.style.backgroundColor;
if (col == 'rgb(255, 255, 0)') { checkcurrency('/b',100); }
document.getElementById('pcolor').value = col;
var cells = id.parentNode.getElementsByTagName('div');
for (var i = 0; i < cells.length; i++){ cells[i].className = 'nosel'; }
id.className = 'sel';
document.getElementById('title').style.color = col;
}

_cids = new Array();
_cids[0] = 'a';
function checkcurrency(id,amt)
{
var noadd = 0;
document.write(id); return;
/*
if (id.indexOf('/') != -1) { amt = amt.replace('/',''); noadd = 1; }
var debug = document.getElementById('cdebug');
amt = parseInt(amt);
var obj = document.getElementById('currency');
var cur = obj.innerHTML;
cur = parseInt(cur);
var incid = 0;
if (noadd == 0)
{
_cids = _cids.join(',');
if (_cids.indexOf(','+id) != -1) { _cids = _cids.replace(','+id,''); amt = -amt; incid = 1; }
_cids = _cids.split(',');
if (incid == 0) { _cids[_cids.length] = id; }
}
cur -= amt;
obj.innerHTML = cur;
if (cur < 0) { obj.style.cssText += 'color: #ff7777;'; } else { obj.style.cssText = obj.style.cssText.replace('color: #ff7777;',''); }
*/
}

function textadd(x)
{
document.getElementById('quickreply').value += x;
document.getElementById('quickreply').scrollTop = document.getElementById('quickreply').scrollHeight;
}

function switch_icon(src)
{
src = src.replace('http://gtx0.com/images/icons/','');
var imgs = '128-9e8731c6a29285327501eec0510d821eb048b8f8.jpg,128-119811_37441_32_hat_witch_icon.png,128-1555229146799153847.png,128-bat5sy.png,128-devil.png,128-DVD_Ghost-159309.jpg,128-ghost.png,128-Gravestone_032x032_32.png,128-jack.png,128-Sad%20Pumpkin.png,128-sally.gif,128-Skeleton.png,128-zombie_driver_-_slaughter_dlc_trailer_hd-357840-1271228846.jpeg,128-spider.png,128-windows-logo.jpg';
imgs = imgs.split(',');

for (var i = 0; i < imgs.length; i++)
{
if (imgs[i] == src) { src = imgs[(i+1)]; break; }
}
if (src == undefined) { src = imgs[0]; }
document.getElementById('whisper_img').src = 'images/icons/'+src;
}

function checkchar(id)
{
var max = 1000;
var len = id.value.length;
if (len > max) { id.value = id.value.substring(0,max); document.getElementById('charlength').innerHTML = max; }
len = (max-len); if (len == -1) { len = 0; }
document.getElementById('charlength').innerHTML = len;
}


function newel(type,id,into)
{
var newdiv = document.createElement(type);
newdiv.id = id;
into = document.getElementById(into);
into.appendChild(newdiv);
return newdiv;
}

function kill(id)
{
document.getElementById(id).innerHTML = '';
}

function d2h(dec)
{
var hex = new Array( "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
var tens = Math.floor(dec / 16);
var ones = dec % 16;
tens = hex[tens];
ones = hex[ones];
tens += ones;
return tens;
} 
function h2d(h) {return parseInt(h,16);} 

function turnon(sel,from)
{
sel = parseInt(sel);
var cells = document.getElementById(from).getElementsByTagName('a');

for (var i = 0; i < cells.length; i++)
{
if (i == sel) { cells[i].className = 'on'; cells[i].blur(); } 
else { cells[i].className = 'off'; }
}
}

function showonly(from,id)
{
var fromid = from;

var newclass = '';

if (from.indexOf('_') != -1)
{
from = from.replace('_','');
var newclass = 'text-align: center;';
}

from = document.getElementById(from).getElementsByTagName('div');
id = document.getElementById(id);

for (var i = 0; i < from.length; i++)
{
if (from[i].className != 'skip' && from[i].parentNode.id == fromid)
{
from[i].style.cssText = 'display: none;';
}
}
if (id.length != 0)
{
id.style.cssText = newclass;
}
}

function showtube(link,num)
{
var area = document.getElementById('yt'+num);
area.innerHTML = '<input type="button" onclick="hidetube(\''+link+'\',\''+num+'\');" value="Hide Youtube" /><br /><object width="640" height="385"><param name="movie" value="'+link+'&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+link+'&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>';
}

function hidetube(link,num)
{
var area = document.getElementById('yt'+num);
area.innerHTML = '<span style="padding: 5px; border: 1px dotted #aaaaaa;"><input type="button" onclick="showtube(\''+link+'\',\''+num+'\');" value="Show Youtube" /></span>';
}

function show(id)
{
var val = document.getElementById(id).style.cssText;
document.getElementById(id).style.cssText = val.replace('display: none;','');
}

function hide(id)
{
document.getElementById(id).style.visibility = 'hidden';
} 

function toggle(id)
{
var s = document.getElementById(id).style.cssText;
if (s.indexOf('display: none;') == -1) { document.getElementById(id).style.cssText += 'display: none;'; }
else { document.getElementById(id).style.cssText = document.getElementById(id).style.cssText.replace('display: none;',''); }
}

function editmode()
{
var vreplies = document.getElementById('vreplies').value;

if (vreplies.length == 0 || vreplies == 0)
{
vreplies = 1;
}

for (i = 0; i <= vreplies; i++)
{
if (document.getElementById('edit'+i).style.cssText == '')
{
document.getElementById('edit'+i).style.cssText = 'display: none;';
}
else
{
document.getElementById('edit'+i).style.cssText = '';
}
}
}

function unhide(id)
{
document.getElementById(id).style.cssText = '';
}

function hidesel(id)
{
if (id != 'body')
{
document.getElementById(id).innerHTML = '';
}
else
{
document.getElementsByTagName('body')[0].background = '';
}
}

function dopt(id,type)
{
var olds = '';
var news = '';
if (type == '1')
{
var box = document.getElementById(id)
box.style.cssText = 'background-color: #0000BB';
box.onclick = function(){dopt(this.id,'2');eval(document.getElementById(this.id+'script').value);};
olds = document.getElementById(id+'script').value;
news = document.getElementById(id+'aux').value;
document.getElementById(id+'script').value = news;
document.getElementById(id+'aux').value = olds;
box.onmouseover = function(){this.style.cssText = 'background-color: #000044';};
box.onmouseout = function(){this.style.cssText = 'background-color: #0000BB';};
setCookie(id,'1','10');
}
else
{
var box = document.getElementById(id)
box.style.cssText = '';
box.onclick = function(){dopt(this.id,'1');eval(document.getElementById(this.id+'script').value);};
olds = document.getElementById(id+'script').value;
news = document.getElementById(id+'aux').value;
document.getElementById(id+'script').value = news;
document.getElementById(id+'aux').value = olds;
box.onmouseover = function(){this.style.cssText = 'background-color: #0000BB';};
box.onmouseout = function(){this.style.cssText = '';};
setCookie(id,'','-1');
}
}

function dropbox(sel,type)
{

if (type == '1')
{
document.getElementById(sel).onclick = function(){dropbox(this.id,'2');};
document.getElementById(sel).onmouseout = function(){};
document.getElementById(sel).style.cssText = 'background-color: #000099;';
sel = sel.replace('top','');
document.getElementById(sel+'img').src = 'images/arrowup.png';
document.getElementById('menu'+sel).style.cssText = '';
}
else
{
document.getElementById(sel).onclick = function(){dropbox(this.id,'1');};
document.getElementById(sel).onmouseout = function(){this.style.cssText = 'background-color: #000077;';};
sel = sel.replace('top','');
document.getElementById(sel+'img').src = 'images/arrow.png';
document.getElementById('menu'+sel).style.cssText = 'display: none;';
}
}

function menubox(sel,box,id)
{
if (id == '1')
{
document.getElementById(sel).style.cssText = 'background-color: #000099;';
document.getElementById(box).style.cssText = '';
if (box == 'menusers' && document.getElementById('menusers').innerHTML.length == 0)
{
ajax('ajax/views','','','menusers');
}
}
else
{
document.getElementById(sel).style.cssText = '';
document.getElementById(box).style.cssText = 'display:none;';
}
}

function dogames()
{
var heitop = document.getElementById('topnav').offsetTop + document.getElementById('topnav').offsetHeight;
var heilow = document.getElementById('lowql').offsetTop - document.getElementById('lowql').offsetHeight + heitop;

document.getElementById('else').style.cssText = 'margin-top: '+heitop+'px;';

document.getElementById('lowql').style.cssText = 'position: absolute; top: '+heitop+'px;';

document.getElementById('low0').className = 'info';
document.getElementById('low1').className = 'box';
document.getElementById('low2').className = 'box';
document.getElementById('low3').className = 'box';
document.getElementById('low4').className = 'box';
document.getElementById('low5').className = 'box';

document.getElementById('ql').style.cssText = 'position: absolute; top: '+heilow+'px;';

document.getElementById('top0').className = 'barinfo';
document.getElementById('top1').className = 'barbox';
document.getElementById('top2').className = 'barbox';
document.getElementById('top3').className = 'barbox';
document.getElementById('top4').className = 'barbox';
document.getElementById('top5').className = 'barbox';

}

function highlight(id)
{

var hsty = 'position: absolute;';

if (id == 'left')
{
hsty += 'top: 0px; left: 0px; width: 140px; height: 70px;';
}
else
{
hsty += 'top: 0px; left: 141px; width: 82px; height: 70px;';
}

if (id == 'none')
{
hsty = 'display: none';
}

document.getElementById('highlight').style.cssText = hsty;

}

function showapic(pic)
{

if (pic.length == 0 || pic == '')
{
document.getElementById('apic').innerHTML = '';
}
else
{
document.getElementById('apic').innerHTML = '<img src="'+pic+'" alt="" style="height: 100%; width: 100%;" />';
}

}


function showvid(vid)
{
vid = vid.split("=");
vid = vid[1];
vid = vid.split("&");
vid = vid[0];

if (vid.length == 0 || vid == '')
{
document.getElementById('vid').innerHTML = '';
}
else
{
document.getElementById('vid').innerHTML = '<img src="http://i3.ytimg.com/vi/'+vid+'/default.jpg" alt="" style="height: 100%; width: 100%;" />';
}

}


function edtit(id)
{
var title = document.getElementById('title'+id).innerHTML;
var nit = '<input size="100" id="etitle" value="'+title+'" style="background-color: #222222; color: #ffaa00; border: 2px solid #555555;"><input type="hidden" id="etid" value="'+id+'"><br /><input type="button" onclick="edtitdo(\'\')" value=" Submit Title ">';
nit += '<input type="button" onclick="edtitdo(\'stick\')" value="Sticky" />';
nit += '<input type="button" onclick="edtitdo(\'ban\')" value="Ban" />';
nit += '<input type="button" onclick="edtitdo(\'lock\')" value="Lock" />';
document.getElementById('espan'+id).innerHTML = nit;
}


function edtitdo(mode)
{
var title = document.getElementById('etitle').value;
var etid = document.getElementById('etid').value;
var query = '1&title='+title+'&tid='+etid+'&mode='+mode;
ajax('mod/edtit','',query,'espan'+etid);
}

function previmg()
{
var loc = document.getElementById('location').style.cssText;
var images = document.getElementById('imgs').innerHTML;
var caps = document.getElementById('caps').innerHTML;

document.write(loc+' '+images+' '+caps);
}

function cc()
{
document.getElementById('javano').setAttribute('style','display:none');
document.getElementById('javayes').setAttribute('style','');
}

function showfold(id)
{

var docs = document.getElementsByTagName('span');
for (var i = 0; i < docs.length; i++)
{
if (docs[i].getAttribute('class') == 'docs')
{
docs[i].setAttribute('style','display:none');
}
}

var fold = document.getElementById('fold'+id);
fold.setAttribute('style','');
}

function qlhide()
{
header = document.getElementById('header');
ql = document.getElementById('ql');
body = document.getElementsByTagName('body')[0];

if (ql.getAttribute('style') == null || ql.getAttribute('style') == '')
{
ql.setAttribute('style','display:none');
header.setAttribute('style','position:fixed; top: 0;');
body.setAttribute('marginheight','140');
}
else
{
ql.setAttribute('style','');
header.setAttribute('style','');
body.setAttribute('marginheight','0');
}

}

function showpic(loc,id,name)
{
var truid = id;
id = document.getElementById('givepic'+id);
id.style.cssText = '';
id.innerHTML = '<img src="'+loc+'" style="border: 1px solid #ffffff;" ondblclick="hidepic(\''+loc+'\',\''+truid+'\');" title="'+name+'" id="tpic'+id+'">';
}

function hidepic(loc,id)
{
var truid = id;
id = document.getElementById('givepic'+id);
var title = document.getElementById('tpic'+id).title;
id.style.cssText = 'display: inline-block;';
id.innerHTML = '{<a href="javascript:showpic(\''+loc+'\',\''+truid+'\',\''+title+'\');">'+title+'</a>}';
}

function checkpass()
{

// get info

var user = document.getElementById('user').value;
var pass = document.getElementById('pass').value;

var hidden = '<input type="hidden" name="user" value="'+user+'"><input type="hidden" name="pass" value="'+pass+'">';

var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
{

if(xmlhttp.readyState == 4 && xmlhttp.responseText.length != 0)
  {
document.getElementById('userpass').innerHTML = hidden+xmlhttp.responseText;
document.getElementById('quickreply').focus();
  }

}

var url = 'ajax/checkpass.php?user='+user+'&pass='+pass;

xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}



function changeuser(blur)
{

document.getElementById('userpass').innerHTML = '<table width=100% bgcolor=#000060 cellpadding=6><tr><td><font face=arial size=2>&nbsp;&nbsp;&nbsp;<b>Your Name or Nickname</b></td></tr><tr><td> <input size=50 name="user" id="user"></td></tr></table><p><table width=100% cellpadding=6 bgcolor=#000060><tr><td><tr><td bgcolor=><font face=arial size=2>&nbsp;&nbsp;&nbsp;<b>Password (optional)</b></td></tr><tr><td><input size=50 name="pass" type="password" id="pass" onkeyup="checkpass();"></td></tr></table>';
if (blur.length != 0)
{
document.getElementById('user').focus()
}

}

function xjax(sel,from,where,goto)
{
ajax('ajax/xjax','',sel+','+from+','+where,goto);
}

function ajax(file,type,query,goto)
{
var plus = 0;

if (goto.indexOf('++') != -1)
{
plus = 1;
goto = goto.replace('++','');
}

query = encodeURI(query);

if (goto == 'faces')
{

if (type == 1)
{
document.getElementById('faces').setAttribute('width','15%');
document.getElementById('main').setAttribute('width','85%');
}
else
{
document.getElementById('faces').setAttribute('width','0%');
document.getElementById('main').setAttribute('width','100%');
}

}

var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
{

if(xmlhttp.readyState < 4 && plus == 0)
  {

if (goto == 'posts')
{
document.getElementById(goto).innerHTML='Loading Posts...';
}
else
{
document.getElementById(goto).innerHTML='Loading...';
}
  
}

if(xmlhttp.readyState==4 && goto.length != 0)
  {
if (plus == 0) { document.getElementById(goto).innerHTML=xmlhttp.responseText; }
else { document.getElementById(goto).innerHTML += xmlhttp.responseText; }
  }

}

var url = file+".php?type="+type+"&query="+query;

xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function post()
{

document.getElementById('send').setAttribute('onclick','');
document.getElementById('send').setAttribute('style','background:#000000; color:#ffffff; border: 0px;');
document.getElementById('send').value = 'Sending...';

var myform = document.getElementById('reply');
var url = '';

for (var i = 0; i < (myform.length - 1); i++)
{
if (i == 0)
{
url += '?';
}
else
{
url += '&';
}

if (myform[i].getAttribute('name') == 'message')
{
myform[i].value = escape(myform[i].value);
}

url += myform[i].getAttribute('name')+'='+myform[i].value;
}

var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange=function()
{

if(xmlhttp.readyState==4)
{

for (var i = 0; i < (myform.length - 1); i++)
{

if (myform[i].getAttribute('name') == 'tid')
{
var tid = myform[i].value;
}

if (myform[i].getAttribute('name') != 'tid')
{
myform[i].value = '';
}
}

document.getElementById('lookhere').focus();

ajax('view/fetch_posts','',tid,'posts');

changeuser('blur');

document.getElementById('send').value = ' Post Message ';
document.getElementById('send').setAttribute('style','');
document.getElementById('send').setAttribute('onclick','post();');

}

}

url = 'inc/newreply.php'+url;

xmlhttp.open("GET",url,true);
xmlhttp.send(null);

}

function resizebox(id)
{
var box = document.getElementById("quickreply");
var rows = parseInt(box.getAttribute('rows'));
var cols = parseInt(box.getAttribute('cols'));

switch (id)
{
case '1':
cols+=3;
break;

case '2':
cols-=3;
break;

case '3':
rows-=1;
break;

case '4':
rows+=1;
break;

case '5':
rows = 10;
cols = 50;
break;

}


box.setAttribute('rows', rows);
box.setAttribute('cols', cols);
}

document.getElementById('cat'+query).setAttribute('bgColor', '#444444');
document.getElementById('cat'+query).getElementsByTagname("table")[0].setAttribute('cellspacing', '0');

function infopop(url) {
a = "info/" + url;
	newwindow=window.open(a,"name","height=500,width=600,scrollbars=yes");
	if (window.focus) {newwindow.focus()}
}

function popitup(url) {
a = "mod/" + url;
	newwindow=window.open(a,"name","height=800,width=800,scrollbars=yes");
	if (window.focus) {newwindow.focus()}
	return false;
}

function editpop(url) {
a = "edit.php?reply=" + url;
	newwindow=window.open(a,"name","height=550,width=900");
	if (window.focus) {newwindow.focus()}
	return false;
}

function shatpop(url) {
a = "shatter.php?reply=" + url;
	newwindow=window.open(a,"name","height=650,width=600");
	if (window.focus) {newwindow.focus()}
	return false;
}

function makered(id) {

if (document.getElementById('test'+id).bgColor == '#501616')
{
document.getElementById('test'+id).bgColor = '#222222';
}
else
{
document.getElementById('test'+id).bgColor = '#501616';
}
}

function alldel(end)
{

// find starting point

for (i = end; i > 0; i--)
{
if (document.getElementById('test'+i).getAttribute('bgColor') == '#501616')
{
start = i;
break;
}
}

var inputs = document.getElementById('tagall').getElementsByTagName('input');

for (i = start; i < end; i++)
{

if (inputs[i].getAttribute('type') == 'checkbox')
{

inputs[i].checked = true;

}
}

for (i = (start+1); i < end; i++)
{
makered(i);
}

makered(end);

}

function viewred(i)
{

var row = document.getElementById('test'+i);
if (row.getAttribute('class') == row.getAttribute('bgColor'))
{
row.setAttribute('bgColor','#501616');
}
else
{
row.setAttribute('bgColor',row.getAttribute('class'));
}

}

function qpop(qid) {
a = "inc/qvote.php?qid=" + qid;
	newwindow=window.open(a,"name","height=1,width=600");
	if (window.focus) {newwindow.focus()}
	return false;
}

function qadd() {
a = "addquote.php";
	newwindow=window.open(a,"name","height=550,width=600");
	if (window.focus) {newwindow.focus()}
	return false;
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+';'+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())+';';
}

function killCookie(c_name)
{
setCookie(c_name,'','0');
}
