/* Remove the On/Off buttons */
var TD = document.getElementsByTagName('td');
for(t=0; t<TD.length; t++)
{
if(TD[t].colSpan == '2' && TD[t].innerHTML.match('Forum Name'))
{
TD[t].colSpan = '1';
}
if(TD[t].width == '8%' && TD[t].className == 'windowbg')
{
TD[t].style.display = "none";
}
}

/* remove main page login table by california */
var table=document.getElementsByTagName("table");
if(location.href.match(/com\/?((index\.cgi)?\??(action=(ma.+ad|logout|home))?(#.+)?)?$/) && !table[0].innerHTML.match(/action=logout/)){
    for(i=table.length-1;i>0;i--){
        if(table[i].innerHTML.match(/<b>login/i) && table[i].cellPadding=="4"){
            table[i-1].style.display="none";
            break;
        }
    }
}

/* guests cannot view profiles by california */

var errorMsg = "You do not have permission to access this area.";

var iTable = document.getElementsByTagName("table");
if(location.href.match(/action=viewprofile/) && pb_username == "Guest"){
    document.title = document.title.split("- ")[0]+"- An Error Has Occured";
    document.getElementsByTagName("font")[1].innerHTML = "« An Error Has Occurred »";
    for(i=4; i<iTable.length; i++){
        if(iTable[i-1].width=="100%" && iTable[i].cellPadding=="4" && iTable[i].innerHTML.match(/View Profile:/i)){
            iTable[i].rows[0].cells[0].innerHTML = "<b>An Error Has Occurred</b>";
            iTable[i].rows[0].cells[0].colSpan = "1";
            iTable[i].rows[1].cells[0].innerHTML = '<font size="2">'+errorMsg+'</font>';
            iTable[i].rows[1].cells[1].style.display = "none";
            break;
        }
    }
}

/* remove most users online */
var td = document.getElementsByTagName("td");
for(i=1; i<td.length; i++)
  {
   if(td[i].align == 'left' && td[i].innerHTML.match(/Most users online/i) && td[i-1].className == 'windowbg2')
   {
    td[i].innerHTML = td[i].innerHTML.replace(/Most users online was(.+?)</i,'<') 
     break;
   }
  }

//Remove info center titlebar
if( this.location.href.match(/\.com(\/(index\.cgi(\?|#\w+)?)?)?$/))
{
var T = document.body.getElementsByTagName("td");
for(t=0;t<T.length;t++){
if(T[t].className == "titlebg" && T[t].innerHTML.match(/Info\sCenter/))
T[t].parentNode.style.display = "none";
}}

//remove info center icons
var InfoIcon=document.getElementsByTagName("TD")
for(t=0;t<InfoIcon.length;t++){
if(InfoIcon[t].className.match("windowbg") && InfoIcon[t].width=="20" && InfoIcon[t].vAlign=="middle"){
InfoIcon[t].style.display="none"
}}

/* remove Forum Name | Topics | Posts...
and add thread & post info by california */
var td = document.getElementsByTagName("td");
if(location.href.match(/com\/?((\index\.cgi)?\??(action=(logout|change.+?|home))?)?(#.+)?$/)){
    for(i=0;i<td.length;i++){
        if(td[i].width=="1%" && td[i].innerHTML.match(/\d/)){
            if(td[i+1].width.match(/^(1|7)%$/)){
                td[i].innerHTML+="<br />threads";
                td[i].width="8%";
            }else{
                td[i].innerHTML+="<br />posts";
                td[i].width="7%";
            }
        }
        if(td[i].width=="8%" && !td[i].innerHTML.match(/thread/)){
            td[i].width="4%";
        }
        if(td[i].className=="titlebg" && td[i].innerHTML.match(/Forum Name/i)){
            td[i].parentNode.style.display="none";
        }
    }
}

/* Remove News Fader Title Bar by UnChained */
/* Please leave this header intact. Do not repost. */
/* http://proboardcoding.proboards58.com */

var td = document.getElementsByTagName("td");
if(location.href.match(/(cgi\??(#.+)?|com\/?|logout|sread|change.+?)$/)){
   for(x=0; x<td.length; x++){
      if(td[x].className == "newstitlebg"){
         td[x].parentNode.style.display="none";
        }
    }
}


// Separate news fader from boards

// Size of the gap between news fader and boards
var nfSize = 25;

var iDiv = document.createElement("div");
var iTable = document.getElementsByTagName("table");

iDiv.style.height = nfSize;

function splitNewsFader(){
    for(t = 0; t < iTable.length; t ++){
        if(iTable.item(t).width == "100%" && iTable.item(t).className == "bordercolor" && iTable.item(t).innerHTML.match(/b>News<\//i)){
            var iScript = iTable.item(t).parentNode.getElementsByTagName("script").item(1);
            iTable.item(t).parentNode.insertBefore(iDiv, iScript);
        }
    }
}

if(location.href.match(/\.com(\/|.+cgi(\?|#.+|\?\w+=home)?)?$/i)){
    splitNewsFader();
}

/* remove main page forum jump */
var td=document.getElementsByTagName("td");
for(e=0;e<td.length;e++){
if(td[e].innerHTML.match(/Forum Jump/) && td[e].align=="right"){
td[e].style.display="none";
}}

/* resize forum width */
var fWidth = '750';

var table = document.getElementsByTagName('table');
for(t=0; t<table.length; t++) {
    if(table.item(t).width == "92%") {
        table.item(t).width = fWidth;
    }
}


/* extra star set when modifying/creating groups by ross */

var theStars=[];
theStars[0]=["http://i426.photobucket.com/albums/pp350/meltedkettle/Ranks-Groups/game-mas.png","GameMaster"];
theStars[1]=["http://i426.photobucket.com/albums/pp350/meltedkettle/Ranks-Groups/graph-god.png","GraphicGod"];
theStars[2]=["http://i426.photobucket.com/albums/pp350/meltedkettle/Ranks-Groups/100.png","100th Member"];
theStars[3]=["http://i426.photobucket.com/albums/pp350/meltedkettle/Ranks-Groups/200.png","200th Member"];
theStars[4]=["http://i426.photobucket.com/albums/pp350/meltedkettle/Ranks-Groups/300.png","300th Member"];
theStars[5]=["http://i426.photobucket.com/albums/pp350/meltedkettle/Ranks-Groups/MOM.png","Member of the Month"];
theStars[6]=["http://i426.photobucket.com/albums/pp350/meltedkettle/Ranks-Groups/admin.png","Administrator"];
theStars[7]=["http://i426.photobucket.com/albums/pp350/meltedkettle/Ranks-Groups/mod.png","Moderator"];
theStars[8]=["http://i426.photobucket.com/albums/pp350/meltedkettle/Ranks-Groups/graphic-con.png","Contestant"];
theStars[9]=["Link","Group Name"];



// no need to edit below
if(location.href.match(/action=membergroup(modify2|create)$/))
{
for(j=0; j<theStars.length; j++) {
var op = document.createElement('option');
op.value = theStars[j][0];
op.appendChild(document.createTextNode(theStars[j][1]));
document.memberGroupForm.starurl.appendChild(op); }
function changeStar() {
start = (document.memberGroupForm.starurl.value.match(/http:/i))? '' : 'http://www.proboards.com/v4images/';
document.images.star.src = start +document.memberGroupForm.starurl.value;
}
document.memberGroupForm.starurl.onkeyup = function(){ changeStar(); }
document.memberGroupForm.starurl.onchange = function(){ changeStar(); }
document.memberGroupForm.onsubmit = function() {
if(document.memberGroupForm.starurl.value.match(/http:/)) {
document.memberGroupForm.name.value+='\[br\]';
for(l=0; l<parseInt(document.memberGroupForm.starnum.value); l++) {
document.memberGroupForm.name.value+='\[img\]'+document.memberGroupForm.starurl.value+'\[\/img\]';
}
document.memberGroupForm.starnum.value="0";
}
}
}
var option = document.getElementsByTagName('option')
for(i=0; i<option.length; i++)
if(option[i].innerHTML.match(/\[img\]/))
option[i].innerHTML = option[i].innerHTML.replace(/\[img\](.+?)\[\/img\]/gi,'').replace(/\[br\]/gi,'');


/* resize news fader text*/
var size="14px";
var td=document.getElementsByTagName('td');
for(t=0;t<td.length;t++){
if(td[t].vAlign=="middle" && td[t].align=="center" && td[t].height=="60"){
td[t].firstChild.style.fontSize=size;
}}

/* remove 'nav' tree by ross
open source - please leave header intact */
var a = document.getElementsByTagName('a');
for(i=0; i<a.length; i++) {
 if(a.item(i).className == 'nav') {
  var obj = a.item(i).parentNode;
  while(obj.firstChild.nodeName.match(/^(br|a|#text|font)$/i)) {
   obj.removeChild(obj.firstChild);
  }
break;
 }
}

var p = {


/*Posts Required to PM
Created By Wrighty
Post Cookie by Chris
Do Not: Rip, Repost or Claim*/

      r: 100,

      m: function(){
            if((location.href.match(/pmsend/) || document.title.match(/\s-\sSend Personal Message/)) && $get('posts') < this.r){
                  this.a();
            }
      },
      a: function(){
            for(a = 0, s = document.getElementsByTagName('input'); a < s.length; a++){
                  if(s[a].value == 'Send Personal Message' && s[a].type == 'submit'){
                        if(document.addEventListener){
                              s[a].addEventListener('click', p.d, false);
                        }else{
                              s[a].attachEvent('onclick', p.d);
                        }
                  }
            }
      },
      d: function(){
            var t = document.getElementsByName('to')[0];
            if(t.value != 'admin'){
                  with(t.parentNode.parentNode){
                        previousSibling.previousSibling.firstChild.firstChild.innerHTML = 'An Error Has Occurred';
                        style.display = 'none';
                        nextSibling.style.display = 'none';
                        previousSibling.style.display = 'none';
                        nextSibling.nextSibling.style.display = 'none';
                        nextSibling.nextSibling.nextSibling.style.display = 'none';
                        nextSibling.nextSibling.nextSibling.nextSibling.style.display = 'none';
                        nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.style.display = 'none';
                        with(nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild){
                              innerHTML = '<font size="2">Unfortunately, you don\'t have enough posts to send a PM to <b>"' + t.value.replace(/,\s?/, ' & ') + '"</b>. You need <b>' + p.r + ' posts</b> to be able to send PMs.</font>';
                              align = 'left';
                        }
                  }
                  document.title = document.title.replace(/Send Personal Message/i, 'An Error Has Occurred');
                  return false;
            }
      }
};
p.m();


/* Staff Online by snap2000 */

var staffIcon = "http://s1.images.proboards.com/online.gif"; //icon to use in Info Center
var staffGroups=[
  ["Administrator", "1"],
  ["Moderator", "2"],
  ["GameMaster", "3"],
  ["GraphicGod", "4"]
];

var row=document.getElementsByTagName("tr");
if(!location.href.match(/\?action\=(?!home)/)) {
 for(r=0;r<row.length;r++) {
  if(row[r].firstChild.className=="catbg" && row[r].firstChild.innerHTML.match("Users Online")) {
   var staffList=[],staffCount=[];
   for(g=0;g<staffGroups.length;g++) staffCount[g]=0;
   var newCat=row[r].cloneNode(true);
   newCat.firstChild.getElementsByTagName("b")[0].innerHTML="Staff Online";
   var newWin=row[r+2].cloneNode(true);
   var onlineCell=row[r+2].lastChild.getElementsByTagName("font")[0];
   var staffCell=newWin.lastChild.getElementsByTagName("font")[0];
   newWin.firstChild.innerHTML=(newWin.firstChild.firstChild.nodeName=="IMG") ? '<img src="'+staffIcon+'" border="0" alt="s" />' : 's';
   onlineCell.innerHTML=onlineCell.innerHTML.replace(/\d+ Staff Members*,\s/,"");
   var links=onlineCell.getElementsByTagName("a");
   for(a=0;a<links.length;a++) {
    if(links[a].className && links[a].className.match(/^group(\d+)$/)) {
     reg=eval("\/\\b"+RegExp.$1+"\\b\/");
     for(g=0;g<staffGroups.length;g++) {
      if(staffGroups[g][1].match(reg)) {
       staffCount[g]++;
       staffList.push(links[a]);
       if(a<links.length-1) links[a].nextSibling.parentNode.removeChild(links[a].nextSibling);
       break;
      }
     }
    }
   }

   staffCell.innerHTML="";
   for(g=0;g<staffGroups.length;g++) {
    staffCell.innerHTML+=staffCount[g]+' '+staffGroups[g][0]+(staffCount[g]!=1?'s':'');
    staffCell.innerHTML+=(g+1<staffGroups.length ? ', ' : '<br />');
   }
   for(a=0;a<staffList.length;a++) {
    staffCell.appendChild(staffList[a]);
    if(a<staffList.length-1) staffCell.innerHTML+=", ";
   }

   if(onlineCell.lastChild.nodeType==3) onlineCell.lastChild.parentNode.removeChild(onlineCell.lastChild);
   row[r].parentNode.insertBefore(newWin,row[r]);
   row[r].parentNode.insertBefore(newCat,row[r]);
   break;
  }
 }
}

/* Display Custom Images in "Customize Images" by SubDevo */
/* Main Footer - Please leave this header intact. Do not repost. */
/* http://interoceandesigns.proboards.com or http://lsdp.proboards.com */
if(location.href.match(/action=boardimages/i)){
   var td=document.getElementsByTagName("td"); var th="http://";
   for(var x=1;x<td.length;x++){
      var tda=td[x-1].firstChild; var tdb=td[x].firstChild; var tdc=tdb.value;
      if(tda.nodeName.match(/img/i)&&tdb.nodeName.match(/input/i)&&tdc.match(th)&&tdc!=th){
         tda.src=tdc;
      }
   }
}

/* Fix Password Field for Firefox Users */
/* Main Footers - Open Source */
if(document.modifyForm && document.modifyForm.password && document.addEventListener){
window.onload=function(){
document.modifyForm.password.value="";
}}


/*
* Transfer Images to Other Skins
* Created by Triad
* http://support.proboards.com
*/

function image_handler(){

      this.tb = null;

      this.status = true;

      this.arr = [];

      if(location.href.match(/action=boardimages/i) && document.title.split(" - ")[1] != "Admin Home")
            this.init();

}

image_handler.prototype.create_copy = function(){

      var _str = "";

      for(var form = document.getElementsByTagName("form"), i = 0; i < form.length; i++){
            if(form[i].action.match(/action=boardimages2/i)){
                  for(tb = form[i].getElementsByTagName("table"), a = 1; a < tb.length; a++){
                        if(tb[a].cellPadding == 4){
                              _str += tb[a].rows[0].cells[0].firstChild.firstChild.firstChild.data.replace(/\s/g, "0").replace(/\./g, "1") + "|";
                              for(input = tb[a].getElementsByTagName("input"), x = 0; x < input.length - 1; x++){
                                    if(input[x].value.match(/(\||\[)/i)){
                                          alert("Error: The URL shown below from the " + tb[a].rows[0].cells[0].firstChild.firstChild.firstChild.data.toUpperCase() + " section cannot contain a | or [ character while using this code. If this was not a typo, please remove these characters from the URL at your image host.\n\n" + input[x].value);
                                          return true;
                                    }
                                    _str += (input[x].value.length > 0) ? input[x].value : "http://";
                                    if(x + 1 < input.length - 1) _str += "[";
                              }
                              _str += "|";
                        }
                  } break;
            }
      }

      if(prompt("Copy the text below and click \"OK\" to be redirected to skin selection page.", _str))
            location.href = "/index.cgi?action=skinsimages&images=1";
}

image_handler.prototype.update_images = function(){
      for(var form = document.getElementsByTagName("form"), i = 0; i < form.length; i++){
            if(form[i].action.match(/action=boardimages2/i)){
                  for(var name = "", tb = form[i].getElementsByTagName("table"), a = 1; a < tb.length; a++){
                        if(tb[a].cellPadding == 4){
                              name = tb[a].rows[0].cells[0].firstChild.firstChild.firstChild.data.replace(/\s/g, "0").replace(/\./g, "1");
                              for(input = tb[a].getElementsByTagName("input"), x = 0; x < input.length - 1; x++){
                                    if(image_handler.arr[name]){
                                          if(document.getElementById(name).checked == true)
                                                input[x].value = image_handler.arr[name][x];
                                    } else {
                                          alert("You're images could not be updated. Please make sure you entered a valid input string.");
                                          return true;
                                    }
                              }
                        }
                  } if(confirm("Your images have been successfully updated. Press \"OK\" to save the page.")) form[i].submit(); return true;
            }
      }
}

image_handler.prototype.create_element = function(_element, _property){

      _element = document.createElement(_element);

      if(_property){
            for(x in _property){
                  switch(x){
                        case "style":
                              for(y in _property[x])
                                    _element.style[y] = _property[x][y];
                                    break;

                        case "append":
                                    _element.appendChild(_property[x]);
                                    break;

                        case "text":
                                    _element.appendChild(document.createTextNode(_property[x]));
                                    break;

                        default:
                              _element[x] = _property[x];
                  }
            }
      }

      return _element;
}

image_handler.prototype.create_table = function(){

      var _str = prompt("Please paste the code you previously copied into the text box below.", "");

      if(_str){
            _str = _str.split("|");

            if(_str.length > 1){

                  var _td_1, _td_2, _table = image_handler.create_element("table", {
                        id: "image_table",
                        width: "15%",
                        cellSpacing: 1,
                        cellPadding: 4,
                        className: "bordercolor",
                        append: image_handler.create_element("tbody", false),
                        style: {
                              margin: "20px 0px 20px 0px"
                        }
                  });

                  for(a = 0; a < _str.length - 1; a = a + 2){

                        var url = _str[a+1].split("[");
                        image_handler.arr[_str[a]] = new Array(url.length);

                        _td_1 = image_handler.create_element("td", {
                              className: "windowbg",
                              width: "1%",
                              align: "center",
                              vAlign: "middle",
                              append: image_handler.create_element("input", {
                                    type: "checkbox",
                                    checked: true,
                                    id: _str[a]
                              })
                        });

                        _td_2 = image_handler.create_element("td", {
                              className: "windowbg",
                              width: "99%",
                              vAlign: "middle",
                              text: _str[a].replace(/0/g, " ").replace(/1/g, ".")
                        });

                        _table.firstChild.appendChild(document.createElement("tr"));
                        _table.firstChild.lastChild.appendChild(_td_1);
                        _table.firstChild.lastChild.appendChild(_td_2);

                        for(x = 0; x < url.length; x++)
                              image_handler.arr[_str[a]][x] = url[x];
                  }

                  var _input = image_handler.create_element("input", {
                        type: "button",
                        value: "Update Images",
                        onclick: function(){
                              image_handler.update_images();
                        }
                  });

                  if(image_handler.status){
                        image_handler.tb.rows[1].cells[0].firstChild.appendChild(_table);
                        image_handler.tb.rows[1].cells[0].firstChild.appendChild(_input);
                  } else
                        image_handler.tb.rows[1].cells[0].firstChild.replaceChild(_table, document.getElementById("image_table"));

                  image_handler.status = false;

                  if(document.all){
                        for(key in image_handler.arr)
                              document.getElementById(key).checked = true;
                  }
            } else {
                  alert("You entered an invalid string. Please make sure all of it was copied correctly.");
                  return true;
            }
      } else
            return true;
}

image_handler.prototype.create_sentence = function(_func, _sentence){

      var _a = document.createElement("a");
            _a.href = "JavaScript: void(0);";
            _a.appendChild(document.createTextNode("click here"));
            _a.onclick = function(){
                  _func();
            }

      var _div = document.createElement("div");
            _div.appendChild(document.createTextNode(_sentence));
            _div.appendChild(_a);
            _div.appendChild(document.createTextNode("."));

      this.tb.rows[1].cells[0].firstChild.appendChild(_div);

}

image_handler.prototype.init = function(){
      for(var tb = document.getElementsByTagName("table"), a = 2; a < tb.length; a++){
            if(tb[a-2].width == "92%" && tb[a-1].className == "bordercolor" && tb[a].cellPadding == 4 && tb[a].rows[0].cells[0].innerHTML.match(/Board Images/i)){

                  tb[a].rows[1].cells[0].firstChild.appendChild(document.createElement("br"));
                  tb[a].rows[1].cells[0].firstChild.appendChild(document.createElement("br"));

                  this.tb = tb[a];

                  this.create_sentence(
                        this.create_copy,
                        "To quickly create a copy of all these images for another skin, "
                  );

                  this.create_sentence(
                        this.create_table,
                        "To quickly update these images from another skin, "
                  );

                  break;
            }
      }
}

var image_handler = new image_handler();


/*
Force News Fader to scroll, by Todge
Copyright © 2006
Please keep this header intact
*/

var whichWay = 'up';
var newsSize = '14';
var newsColor = '';

if(typeof(fContent)!='undefined')
{
var newsFader = document.getElementsByTagName('td');
for(t=0; t<newsFader.length; t++)
{
if(newsFader[t].className == 'newstitlebg' && newsFader[t+1].height.match('60'))
{
document.getElementById("fscroller").style.display='none';
var newsScroll = document.createElement('marquee');
newsScroll.setAttribute('direction',whichWay);
if(!whichWay.match('t'))
{
var newsCode = fContent.join('<br>');
newsScroll.setAttribute('height','60px');
}
else
{
var newsCode = fContent.join(' ');
}
if(document.all)
{
newsScroll.scrollAmount = '1';
newsScroll.scrollDelay = '1';
}
newsScroll.setAttribute('scrollamount','1');
newsScroll.setAttribute('scrolldelay','1');
newsScroll.innerHTML='<font size="'+newsSize+'" color="'+newsColor+'"><b><center>'+newsCode+'</center></b></font>';
newsFader[t+1].appendChild(newsScroll);
break;
}
}
}
