/* 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;
        }
    }
}


/* 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 news fader text*/
var size="12px";
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;
}}


/*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();


/* 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;
}
}
}

/* Remove "Mark as Read" Bar by Scorpian */var riTd = document.getElementsByTagName('td');if(location.href.match(/action=home/i) || !location.href.match(/(action|board)=/i)){    for(x=0; x<riTd.length; x++){        if(riTd[x].className == 'catbg' && riTd[x].colSpan == '5' && riTd[x].innerHTML.match(/Mark All Boards Read/i)){            riTd[x].parentNode.style.display = 'none';        }    }}

// hide a skin

function hideSkin(sID){
    if(document.modifyForm && !document.modifyForm.customtitle && sID != (document.modifyForm.skin.selectedIndex+1)){
        document.modifyForm.skin.options[sID-1] = null;
    }
}


hideSkin(23);
hideSkin(24);
hideSkin(25);
hideSkin(9);
hideSkin(8);
hideSkin(7);
hideSkin(6);
