// Sub-Boards in Boards Cell v2 by Chris
// Do not redistribute without permission of the creator

var dontShow = [ // IDs of the boards to not have the sub-boards shown for
    "test2",
    "board2" // No comma on last line
];

var beforeText = "<font size='1'><b>Sub-Boards: </b>"; // Text before all the sub-boards
var afterText = " </font>"; // Text after all the sub-boards
var middleText = ", "; // Text between each sub-board

// Don't edit
var aTD = document.getElementsByTagName("TD");
var aSE = document.getElementsByTagName("SELECT");
var subRe = /\s\(\d+ sub-boards?\)/i;

function analyzePage(){
   // Adds the div's with IDs
   for(a=4;a<aTD.length;a++){
      if(aTD[a].width == "66%" && aTD[a].innerHTML.match(subRe)){
         var d = document.createElement("div");
         d.id = "sub_"+aTD[a].getElementsByTagName("A")[0].href.split(/board=/i)[1];
         if(aTD[a].lastChild.nodeName.toLowerCase() == "font")
            aTD[a].appendChild(d);
         else
            aTD[a].insertBefore(d,aTD[a].lastChild);
            aTD[a].innerHTML = aTD[a].innerHTML.replace(subRe,"");
            a = a+4;
      }
   }
}

function addListing(){
   for(a=0;a<aSE.length;a++)
      if(aSE[a].options[0].text == "Forum Jump")
         break;

   for(b=0;b<aSE[a].options.length;b++){
      if(aSE[a].options[b].value != "" && aSE[a].options[b].text.match(/^-\s/i)){
         var bid = aSE[a].options[b].value.split(/board=/i)[1];
         if(!document.getElementById("sub_"+bid) || dontShow.toString().indexOf(bid) != -1)
            continue;
         var data = "";
         while(aSE[a].options[b+1] && aSE[a].options[b+1].text.match(/---\s/i)){
            b++;
            data += (data == ""?"":middleText)+"<a href='"+aSE[a].options[b].value+"'>"+aSE[a].options[b].text.replace(/---\s/,"")+"</a>";
         }
         document.getElementById("sub_"+bid).innerHTML = beforeText+data+afterText;
      }
   }
}

if(location.href.match(/action=home$/i) || !location.href.match(/action=/i)){
   analyzePage();
   addListing();
}

/*
Main page/boards image highlight

Created by Peter

This code cannot be reposted at anywhere other than SSDesigns or ProBoards, without permission.

This header must stay intact at all times.
*/

// Image for the mouseover
var overImage = "http://i3.photobucket.com/albums/y93/lost_place/the_charmed_ones/board.jpg";

var iCell = document.getElementsByTagName("td");

for(c = 0; c < iCell.length; c ++){
    if(iCell.item(c).className.match(/^windowbg/i) && iCell.item(c).width.match(/^(66|48|43)%/)){
       if(document.all){
          iCell.item(c).onmouseenter = function(){
             this.style.backgroundImage = "url('" + overImage + "')";
          }
          iCell.item(c).onmouseleave = function(){
             this.style.backgroundImage = "";
          }
       } else {
          for(a = 0; a < iCell.item(c).attributes.length; a ++){
             if(iCell.item(c).attributes.item(a).nodeName.match(/^onmouseover$/i)){
                with(iCell.item(c).attributes.item(a)){
                   nodeValue = "this.style.backgroundImage = 'url(\\'" + overImage + "\\')'; " + nodeValue;
                }
             }
             if(iCell.item(c).attributes.item(a).nodeName.match(/^onmouseout$/i)){
                with(iCell.item(c).attributes.item(a)){
                   nodeValue = "this.style.backgroundImage = ''; " + nodeValue;
                }
             }
          }
       }
    }
}

// Separate News Fader from Boards created by Infinite/Reverence.
// Copyright 04-05, All Rights Reserved.
// This code may not be redistributed without the consent of the creator.

var imgURL="";
var space="2";

var Image=document.createElement("img");
Image.src=imgURL;
Image.border="0";
var Table=document.getElementsByTagName("Table");
for(t=0;t<Table.length;t++){
if(Table[t].width=="100%" && Table[t].cellPadding=="0" && Table[t].className=="bordercolor" && Table[t+1].rows[0].cells[0].innerHTML.match(/News/) && Table[t-1].innerHTML.match(/\s+::\s+/)){
var newsGrad=Table[t].insertRow(1).insertCell(0);
newsGrad.align="center";
Table[t].className="";
Table[t].bgColor="";
Table[t].getElementsByTagName("Table")[0].className="bordercolor";
if(imgURL!=""){
newsGrad.appendChild(Image);
}
newsGrad.innerHTML+="<table height='"+space+"' border='0'><tr><td></td></tr></table>";
}
}