/* directional marquee */
var moveReg = /\[move=(.+?)\](.+?)\[\/move\]/gi;
if(location.href.match(/action=(display|gotopost|(pm)?(calendar)?view|(user)?recent|search2)/)) {
var td = document.getElementsByTagName('td');
for(i=0; i<td.length; i++) {
if(td.item(i).colSpan == '3' && td.item(i).innerHTML.match(moveReg)) {
td.item(i).innerHTML = td.item(i).innerHTML.replace(/<!-- google_ad_section_(start|end) -->/gi,'').replace(moveReg,'<marquee direction="$1">$2</marquee>');
}
}
}

//No right click on images
// Modified to only effect guests

if(pb_username == 'Guest') {
function iCapImg(evt){
var evt = (evt)? evt : ((window.event)? event : null);
if(evt){
var elem = (evt.target)? evt.target : ((evt.srcElement)? evt.srcElement : null);
if(elem){
if(elem.nodeName.toLowerCase() == "img"){
if(evt.cancelBubble){
evt.cancelBubble = true;
}
alert("Sorry! You must ask permission from the artist first!");
return false;
}
}
}
}

document.oncontextmenu = iCapImg;
}

/* remove last edit */
var font=document.getElementsByTagName("font");
if(location.href.match(/on=(displ|search2|(user)?rece)/)){
    for(i=0;i<font.length;i++){
        if(font[i].innerHTML.match(/Last\sEdit:/i) && font[i].parentNode.align=="left"){
            font[i].style.display="none";
        }
    }
}

/* remove embedded quotes by california */
if(document.postForm){
    var msg=document.postForm.message;
    if(msg.value.match(/\[quote\s*.*\s*(\[quote.*\[\/quote\])\s*.*\s*\[\/quote\]/i)){
        msg.value=msg.value.replace(RegExp.$1,'');
    }
}

/* Remove "Sub-Boards|Topics|Posts" Row */
if(location.href.match(/\?board=\w+(&page=\d+)?(&moderationmode=\d)?$/)) {
 var td = document.getElementsByTagName('td');
 for(i=0; i<td.length; i++) {
   if(td.item(i).colSpan == '2' && td.item(i).className == 'titlebg') {
    td.item(i).parentNode.style.display = 'none';
    break;
  }
 }
}

/* Put Message in Last Post for Forums without Posts */
var td=document.getElementsByTagName("td");
if(location.href.match(/com\/?((index\.cgi)?\??(action=(ma.+ad|logout|home))?(#.+)?)?$/) || !location.href.match(/action/)){
    for(i=0;i<td.length;i++){
        if(td[i].width=="24%" && td[i].innerHTML.match(/^<font size=\"?1\"?>\s?<\/font>$/i)){
            td[i].innerHTML='Please Login or Register to view the posts in this forum.';
        }
    }
}

/* Remove Moderator: and names from Board display */
var i = document.getElementsByTagName('i');
for (m=0;m<i.length;m++) {
if (i[m].innerHTML.match(/Moderators?:/))
i[m].style.display='none';
}

/* remove quick reply title - ross */
if(!document.postForm && location.href.match(/ion=(display|goto)/)) {
var f = document.forms;
for(i=0; i<f.length; i++) {
if(f[i].message) {
f[i].parentNode.parentNode.parentNode.previousSibling.style.display = 'none';
}
}
}

/* remove topic icon cell and option by california */
var td=document.getElementsByTagName("td");
if(location.href.match(/board=/)){
    for(i=1;i<td.length-1;i++){
        if(document.postForm){
            if(td[i].width=="30%" && td

[i].innerHTML.match(/sage icon/i)){
                td[i].parentNode.style.display="none";
                continue;
            }
        }else if(td[i].width=="5%" && td

[i+1].width.match(/^4(3|8)%$/)){
            td[i].style.display="none";
        }
    }
}

var onoff = document.getElementsByTagName('TD')
for(t=0;t<onoff.length;t++){
if(onoff[t].width=="8%"){
onoff[t].style.display="none"}}
var onoff2= document.getElementsByTagName('TD')
for(t=0;t<onoff2.length;t++){
if(onoff2[t].innerHTML.match("Forum Name") && onoff2[t].className=="titlebg")
{onoff2[t].colSpan='1'}}

/* Avatar Uploader by hey */

var fontColor = 'titlebg';
var typeWidth = '25';

if(location.href.match(/action=modifyprofile/i)){
var num = (document.modifyForm.user.value == pb_username)? 6 : 5;
var prsinfo = document.modifyForm.avatarurl.parentNode.parentNode.parentNode.parentNode;
var cells = prsinfo.insertRow(prsinfo.rows.length-num);
var title = cells.insertCell(0); var uploader = cells.insertCell(1); var description = cells.insertCell(2);
title.innerHTML ='<font size="2">Avatar Uploader:</font>';
uploader.innerHTML ='<iframe src="http://imageshack.us/iframe.php?txtcolor='+fontColor+'&type=blank&size='+typeWidth+'" scrolling="no" allowtransparency="true" frameborder="0" width="280" height="70">Update your browser for ImageShack.us!</iframe>';
description.innerHTML ='<font size="1">If you don\'t have an avatar uploaded onto the internet yet, you may upload one here.</font>';
}

/* preview with quick reply - by ross */
var mes = document.getElementsByName('message');
if(location.href.match(/ion=display/) && mes[0]) {
var qrForm = mes[0].parentNode;
var preview = '<input name="nextaction" type="hidden" value="post">';
preview += '<input type="submit" accesskey="p" value="Preview" onclick="qrForm.nextaction.value=\'preview\'; return true;" /> ';
qrForm.removeChild(qrForm.lastChild)
qrForm.innerHTML += preview;
}
function spellChecker( textObject ) {
this.popUpUrl = '/speller/spellchecker.html'; 
this.popUpName = 'spellchecker'; 
this.popUpProps = "menu=no,width=440,height=350,top=70,left=120,resizable=yes,status=yes"; 
this.spellCheckScript = '/speller/server-scripts/spellchecker.pl'; 
this.replWordFlag = "R"; 
this.ignrWordFlag = "I"; 
this.replAllFlag = "RA"; 
this.ignrAllFlag = "IA"; 
this.fromReplAll = "~RA"; 
this.fromIgnrAll = "~IA"; 
this.wordFlags = new Array(); 
this.currentTextIndex = 0; 
this.currentWordIndex = 0; 
this.spellCheckerWin = null; 
this.controlWin = null; 
this.wordWin = null; 
this.textArea = textObject; 
this.textInputs = arguments; 
this._spellcheck = _spellcheck; 
this._getSuggestions = _getSuggestions; 
this._setAsIgnored = _setAsIgnored; 
this._getTotalReplaced = _getTotalReplaced; 
this._setWordText = _setWordText; 
this._getFormInputs = _getFormInputs; 
this.openChecker = openChecker; this.startCheck = startCheck; 
this.checkTextBoxes = checkTextBoxes; 
this.checkTextAreas = checkTextAreas; 
this.spellCheckAll = spellCheckAll; 
this.ignoreWord = ignoreWord; 
this.ignoreAll = ignoreAll; 
this.replaceWord = replaceWord; 
this.replaceAll = replaceAll; 
this.terminateSpell = terminateSpell; 
this.undo = undo; 
window.speller = this;
}
function checkTextBoxes() {
this.textInputs = this._getFormInputs( "^text$" ); 
this.openChecker();
}
function checkTextAreas() { 
this.textInputs = this._getFormInputs( "^textarea$" ); 
this.openChecker();
}
function spellCheckAll() {
this.textInputs = this._getFormInputs( "^text(area)?$" );
this.openChecker();
}
function openChecker() { 
this.spellCheckerWin = window.open( this.popUpUrl, this.popUpName, this.popUpProps ); 
if( !this.spellCheckerWin.opener ) { 
this.spellCheckerWin.opener = window; 
}
}
function startCheck( wordWindowObj, controlWindowObj ) { 
this.wordWin = wordWindowObj; 
this.controlWin = controlWindowObj; 
this.wordWin.resetForm(); 
this.controlWin.resetForm(); 
this.currentTextIndex = 0; 
this.currentWordIndex = 0; 
this.wordFlags = new Array( this.wordWin.textInputs.length ); 
for( var i=0; i<this.wordFlags.length; i++ ) { 
this.wordFlags[i] = [];
} 
this._spellcheck();
return true;
}
function ignoreWord() { 
var wi = this.currentWordIndex; 
var ti = this.currentTextIndex; 
if( !this.wordWin ) { 
alert( 'Error: Word frame not available.' ); 
return false; 
} 
if( !this.wordWin.getTextVal( ti, wi )) { 
alert( 'Error: "Not in dictionary" text is missing.' ); 
return false; 
} 
if( this._setAsIgnored( ti, wi, this.ignrWordFlag )) {
this.currentWordIndex++; 
this._spellcheck(); 
}
}
function ignoreAll() { 
var wi = this.currentWordIndex; 
var ti = this.currentTextIndex; if( !this.wordWin ) { 
alert( 'Error: Word frame not available.' ); 
return false; 
}
var s_word_to_repl = this.wordWin.getTextVal( ti, wi );
if( !s_word_to_repl ) { 
alert( 'Error: "Not in dictionary" text is missing' ); 
return false; 
}
this._setAsIgnored( ti, wi, this.ignrAllFlag ); 
for( var i = ti; i < this.wordWin.textInputs.length; i++ ) {
for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) {
if(( i == ti && j > wi ) || i > ti ) {
if(( this.wordWin.getTextVal( i, j ) == s_word_to_repl ) && ( !this.wordFlags[i][j] )) { 
this._setAsIgnored( i, j, this.fromIgnrAll ); } 
} } } 
this.currentWordIndex++; 
this._spellcheck();}function replaceWord() { 
var wi = this.currentWordIndex; var ti = this.currentTextIndex; if( !this.wordWin ) { 
alert( 'Error: Word frame not available.' ); 
return false; } 
if( !this.wordWin.getTextVal( ti, wi )) { 
alert( 'Error: "Not in dictionary" text is missing' ); 
return false; } if( !this.controlWin.replacementText ) { 
return; } var txt = this.controlWin.replacementText; 
if( txt.value ) { var newspell = new String( txt.value ); 
if( this._setWordText( ti, wi, newspell, this.replWordFlag )) { 
this.currentWordIndex++; this._spellcheck(); 
} 
}}function replaceAll() { 
var ti = this.currentTextIndex; 
var wi = this.currentWordIndex; if( !this.wordWin ) { 
alert( 'Error: Word frame not available.' ); return false; } 
var s_word_to_repl = this.wordWin.getTextVal( ti, wi ); if( !s_word_to_repl ) { 
alert( 'Error: "Not in dictionary" text is missing' );
return false; 
}
var txt = this.controlWin.replacementText;
if( !txt.value ) return; 
var newspell = new String( txt.value ); this._setWordText( ti, wi, newspell, this.replAllFlag );
for( var i = ti; i < this.wordWin.textInputs.length; i++ ) { 
for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { 
if(( i == ti && j > wi ) || i > ti ) { 
if(( this.wordWin.getTextVal( i, j ) == s_word_to_repl ) && ( !this.wordFlags[i][j] )) { 
this._setWordText( i, j, newspell, this.fromReplAll ); 
} 
} 
} 
} 
this.currentWordIndex++; 
this._spellcheck();}function terminateSpell() { 
var msg = "Spell check complete:\n\n"; 
var numrepl = this._getTotalReplaced(); if( numrepl == 0 ) { 
if( !this.wordWin ) { 
msg = ""; 
} else { 
if( this.wordWin.totalMisspellings() ) { 
msg += "No words changed."; 
} else { 
msg += "No misspellings found."; 
} 
} } else if( numrepl == 1 ) { 
msg += "One word changed."; 
} else { 
msg += numrepl + " words changed."; 
} 
if( msg ) { 
msg += "\n"; alert( msg ); 
} 
if( numrepl > 0 ) { 
for( var i = 0; i < this.textInputs.length; i++ ) { 
if( this.wordWin ) { 
if( this.wordWin.textInputs[i] ) { 
this.textInputs[i].value = this.wordWin.textInputs[i]; 
} 
} 
} 
} 
this.spellCheckerWin.close(); 
return true;
}function undo() { 
var ti = this.currentTextIndex; 
var wi = this.currentWordIndex; 
if( this.wordWin.totalPreviousWords( ti, wi ) > 0 ) { 
this.wordWin.removeFocus( ti, wi ); do { 
if( this.currentWordIndex == 0 && this.currentTextIndex > 0 ) { 
this.currentTextIndex--; 
this.currentWordIndex = this.wordWin.totalWords( this.currentTextIndex )-1; 
if( this.currentWordIndex < 0 ) this.currentWordIndex = 0; 
} else { if( this.currentWordIndex > 0 ) { 
this.currentWordIndex--; 
} 
} 
} while ( 
this.wordWin.totalWords( this.currentTextIndex ) == 0 || this.wordFlags[this.currentTextIndex][this.currentWordIndex] == this.fromIgnrAll || this.wordFlags[this.currentTextIndex][this.currentWordIndex] == this.fromReplAll ); 
var text_idx = this.currentTextIndex; 
var idx = this.currentWordIndex; 
var preReplSpell = this.wordWin.originalSpellings[text_idx][idx]; 
if( this.wordWin.totalPreviousWords( text_idx, idx ) == 0 ) { 
this.controlWin.disableUndo(); } 
switch( this.wordFlags[text_idx][idx] ) { 
case this.replAllFlag : 
for( var i = text_idx; i < this.wordWin.textInputs.length; i++ ) { 
for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) {
if(( i == text_idx && j >= idx ) || i > text_idx ) { 
var origSpell = this.wordWin.originalSpellings[i][j]; 
if( origSpell == preReplSpell ) { 
this._setWordText ( i, j, origSpell, undefined ); 
} 
} 
} 
} 
break; 
case this.ignrAllFlag : 
for( var i = text_idx; i < this.wordWin.textInputs.length; i++ ) { 
for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { 
if(( i == text_idx && j >= idx ) || i > text_idx ) { 
var origSpell = this.wordWin.originalSpellings[i][j]; 
if( origSpell == preReplSpell ) { 
this.wordFlags[i][j] = undefined; 
} 
} 
} 
} 
break; 
case this.replWordFlag : 
this._setWordText ( text_idx, idx, preReplSpell, undefined ); 
break; } 
this.wordFlags[text_idx][idx] = undefined; 
this._spellcheck(); }}function _spellcheck() { 
var ww = this.wordWin; 
if( this.currentWordIndex == ww.totalWords( this.currentTextIndex) ) { 
this.currentTextIndex++; 
this.currentWordIndex = 0; 
if( this.currentTextIndex < this.wordWin.textInputs.length ) { 
this._spellcheck(); 
return; 
} else { 
this.terminateSpell(); 
return; 
} 
} 
if( this.currentWordIndex > 0 ) { 
this.controlWin.enableUndo(); 
} 
if( this.wordFlags[this.currentTextIndex][this.currentWordIndex] ) { 
this.currentWordIndex++; 
this._spellcheck();
} else { 
var evalText = ww.getTextVal( this.currentTextIndex, this.currentWordIndex ); 
if( evalText ) { 
this.controlWin.evaluatedText.value = evalText; 
ww.setFocus( this.currentTextIndex, this.currentWordIndex ); 
this._getSuggestions( this.currentTextIndex, this.currentWordIndex ); 
} 
}
}function _getSuggestions( text_num, word_num ) { 
this.controlWin.clearSuggestions(); 
var a_suggests = this.wordWin.suggestions[text_num][word_num]; 
if( a_suggests ) { 
for( var ii = 0; ii < a_suggests.length; ii++ ) { 
this.controlWin.addSuggestion( a_suggests[ii] ); 
} 
} 
this.controlWin.selectDefaultSuggestion();
}
function _setAsIgnored( text_num, word_num, flag ) { 
this.wordWin.removeFocus( text_num, word_num ); 
this.wordFlags[text_num][word_num] = flag; 
return true;
}
function _getTotalReplaced() { 
var i_replaced = 0; 
for( var i = 0; i < this.wordFlags.length; i++ ) { 
for( var j = 0; j < this.wordFlags[i].length; j++ ) { 
if(( this.wordFlags[i][j] == this.replWordFlag ) || ( this.wordFlags[i][j] == this.replAllFlag ) || ( this.wordFlags[i][j] == this.fromReplAll )) { 
i_replaced++; } } } 
return i_replaced;
}
function _setWordText( text_num, word_num, newText, flag ) { 
this.wordWin.setText( text_num, word_num, newText ); 
this.wordFlags[text_num][word_num] = flag; 
return true;
}
function _getFormInputs( inputPattern ) { 
var inputs = new Array(); 
for( var i = 0; i < document.forms.length; i++ ) { 
for( var j = 0; j < document.forms[i].elements.length; j++ ) { 
if( document.forms[i].elements[j].type.match( inputPattern )) { 
inputs[inputs.length] = document.forms[i].elements[j]; 
} 
} 
} 
return inputs;
}
function openSpellCheck(){ 
if(document.postForm)
var speller = new spellChecker(document.postForm.subject,document.postForm.message);
else
var speller = new spellChecker(document.getElementsByName('message')[0]); 
speller.openChecker();
}

/* spell check with quick reply */
var mes = document.getElementsByName('message');
if(mes[0] && !document.postForm) {
var qrForm = mes[0].parentNode;
var pre = document.createElement('font');
pre.innerHTML = '<input type="button" value="Spell Check" onclick="openSpellCheck();">';
qrForm.insertBefore(pre, qrForm.lastChild.previousSibling)
}

// Change announcement seperater bar class by ANDYSPUD
// http://ngdesign.proboards52.com
var announce=document.getElementsByTagName("TD")
for(t=0;t<announce.length;t++){
if(announce[t].height=="5"&&announce[t].className=="catbg"){announce[t].className="catbg"}
}

// Font Fix / Font Scaling - CCWorld
var fonts = document.getElementsByTagName("font");
for (i=0; i<fonts.length; i++){
if (fonts.item(i).size.match(/\d/)){
fonts.item(i).className = "fontFix" + fonts.item(i).size.replace("+", "Plus").replace("-", "Minus");}}


// UBBC Buttons Above Quick Reply by Mithras
// Do not repost without permission

// Buttons - [Image Location, Opening Tag, Closing Tag] -- Do not edit unless you want to add buttons, or change the default ones.
var buttons = [
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/bold.png','[b]','[/b]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/italic.png','[i]','[/i]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/underline.png','[u]','[/u]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/strike.png','[s]','[/s]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/glow.png','[glow=red,2,300]','[/glow]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/shadow.png','[shadow=red,left,300','[/shadow]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/move.png','[move]','[/move]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/pre.png','[pre]','[/pre]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/left.png','[left]','[/left]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/center.png','[center]','[/center]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/right.png','[center]','[/center]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/hr.png','[hr]',''],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/size.png','[size=2]','[/size]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/face.png','[font=Verdana]','[/font]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/color.png','[color=red]','[/color]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/youtube.png','[youtube]','[/youtube]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/blockquote.png','[blockquote]','[/blockquote]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/url.png','[url]','[/url]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/img.png','[img]','[/img]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/e-mail.png','[email]','[/email]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/table.png','[table][tr][td]','[/td][/tr][/table]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/tr.png','[tr]','[/tr]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/td.png','[td]','[/td]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/sup.png','[sup]','[/sup]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/sub.png','[sub]','[/sub]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/tele.png','[tt]','[/tt]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/code.png','[code]','[/code]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/quote.png','[quote]','[/quote]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/list.png','[list]\n[*]','\n[*]\n[*]\n[/list]'],
['http://i426.photobucket.com/albums/pp350/meltedkettle/Skins/Halloween/post_icon/spoiler.png','[spoiler]','[/spoiler]'] // Note: no comma after the last line.
];


function ubbc(open, end){
// This function was created by Peter, but is open source. The first section has been changed.
var tAreas = document.getElementsByTagName('textarea');
for(i=0; i<tAreas.length; i++) {
if(tAreas[i].rows == 5 && tAreas[i].cols == 100) {
var tArea = tAreas[0];
}
}

var isIE = (document.all)? true : false;
var open = (open)? open : "";
var end = (end)? end : "";

if(isIE){
tArea.focus();
var curSelect = document.selection.createRange();
if(arguments[2]){
curSelect.text = open + arguments[2] + "]" + curSelect.text + end;
} else {
curSelect.text = open + curSelect.text + end;
}
} else if(!isIE && typeof tArea.selectionStart != "undefined"){
var selStart = tArea.value.substr(0, tArea.selectionStart);
var selEnd = tArea.value.substr(tArea.selectionEnd, tArea.value.length);
var curSelection = tArea.value.replace(selStart, '').replace(selEnd, '');
if(arguments[2]){
tArea.value = selStart + open + arguments[2] + "]" + curSelection + end + selEnd;
} else {
tArea.value = selStart + open + curSelection + end + selEnd;
}
} else {
tArea.value += (arguments[2])? open + arguments[2] + "]" + end : open + end;
}
}

if(location.href.match(/thread=/)) {
var tds = document.getElementsByTagName('TD')
for(a=0; a<tds.length; a++) {
if(tds[a].width=='100%' && tds[a+1].align=='right') {
var b = a
}
}
var quickReply = tds[b].innerHTML;
var buttonHTML = '';

for(i=0; i<buttons.length; i++) {
buttonHTML += '<a href="javascript:ubbc(\'' + buttons[i][1] + '\',\'' + buttons[i][2] + '\')"><img src="' + buttons[i][0] + '" border="0" /></a>';
if(i==13) { buttonHTML += '<br />'; }
}

buttonHTML += '<br/>';

tds[b].innerHTML = buttonHTML + '' + quickReply;
}



// Profile Drop-Down Addons [Open Source]
// http://support.proboards.com

var load = document.createElement('script');
if(location.href.match(/n=(disp|search2|(user)?rece|pmvi|goto|(calendar)?view|(view|modify)pro)/)){
        load.type = 'text/javascript';
        load.src = 'http://pb.proscripts.co.uk/dregond/mpAddOpt.js';
        document.body.appendChild(load);
}


/*
Smileys with quick reply - global footers

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.
*/

// Base url for the smileys folder
var sBaseImg = "http://i426.photobucket.com/albums/pp350/meltedkettle/Smilies/";

// List of smileys - [SMILEY FILE, CODE, TITLE]
var iSmileys = [
    ["victory.gif", ":)", "Smiley"],
    ["wink.gif", ";)", "Wink"],
    ["lmao.gif", ":D", "Cheesy"],
    ["biggrin.gif", ";D", "Grin"],
    ["mad.gif", ">:(", "Angry"],
    ["sad.gif", ":(", "Sad"],
    ["shocked.gif", ":o", "Shocked"],
    ["cool.gif", "8-)", "Cool"],
    ["dntknw.gif", "???","Huh"],
    ["mda.gif", "::)", "Roll Eyes"],
    ["tongue.gif", ":P", "Tongue"],
    ["blush.gif", ":-[", "Embarassed"],
    ["diablo.gif", ":-X", "Lips Sealed"],
    ["angel.gif", ":-/", "Undecided"],
    ["kiss.gif", ":-*", "Kiss"],
    ["cry.gif", ":'(", "Cry"]
];

var iTable = document.getElementsByTagName("table");

function addSmiley(smiley){
    var isIE = (document.all)? true : false;
    var mArea = document.getElementById("qrform").message;
    if(isIE){
        mArea.focus();
        var iCurSelect = document.selection.createRange();
        iCurSelect.text = smiley + iCurSelect.text
    } else if(!isIE){
        var selStart = mArea.value.substr(0, mArea.selectionStart);
        var selEnd = mArea.value.substr(mArea.selectionEnd, mArea.value.length);
        var curSelection = mArea.value.replace(selStart, '').replace(selEnd, '');
        mArea.value = selStart + smiley + curSelection + selEnd;
    } else {
        mArea.value += smiley;
    }
    mArea.focus();
}

for(t = 0; t < iTable.length; t ++){
    var iBR = document.createElement("br");
    if(iTable.item(t).cellPadding == "4" && iTable.item(t).cellSpacing == "1" && iTable.item(t).rows.item(0).innerHTML.match(/>Quick Reply</)){
        var iMCell = iTable.item(t).rows.item(1).cells.item(0);
        iTable.item(t).getElementsByTagName("form").item(0).id = "qrform";
        iMCell.insertBefore(iBR, iMCell.firstChild);
        iSmileys.reverse();
        for(s = 0; s < iSmileys.length; s ++){
            var sLink = document.createElement("a");
            var sImg = document.createElement("img");

            sImg.border = "0";
            sImg.src = sBaseImg + iSmileys[s][0];
            sImg.title = iSmileys[s][2];
            sLink.href = "javascript: addSmiley(\" " + iSmileys[s][1] + "\")";
            sLink.appendChild(sImg);

            iMCell.insertBefore(sLink, iMCell.firstChild);
            iMCell.insertBefore(document.createTextNode(" "), iMCell.firstChild);
        }
    }
}

/* Show a subset of selected users that are offline (random) in the Info Center 
== thanks to CrAzY_J for core code
== thanks to Rosss for the core Users Online function*/

// set basic parameters
var MinAdd = 17; // minimum selected users offline to add, e.g. 3 +/- 1 (random)
var Aggr = 0.75; // aggressiveness factor, e.g. add additional 0.75*(Actual Users Online), [ 0 to x ] 

// add selected users
var OnlineUsers = [
['millieboyer', 'Millie Boyer', 'group'],
['daron', 'Daron Onell', 'group'],
['doctorvanhelsing', 'Dr. VonHelsing', 'group'],
['edwardcullen', 'Edward Cullen', 'group'],
['jacob', 'Jacob Black', 'group'],
['lucaswyler', 'Lucas Wyler', 'group'],
['marysue', 'Mary Sue Pecklebottom', 'group'],
['mariecrabtree', 'Marie Crabtree', 'group'],
['testaccount', 'Spookie', 'group'],
['gob', 'Renesmee Cullen', 'group'],
['jasmin1279', 'Jasmin1279', 'group'],
['27mspotter', '27mspotter', 'group'],
['briana', 'briana', 'group'],
['gingerm', 'gingerm', 'group'],
['irishdragon6', 'irishdragon6', 'group'],
['ladyoricon', 'ladyoricon', 'group'],
['monkeypail', 'MonkeyPail', 'group'] // no comma for last entry
];

// do not edit below this line

if( MinAdd < 0 ) { MinAdd = 0;}
if( Aggr < 0 ) { Aggr = 0; }

// calculate number of selected users offline to add (based on the number of actual users online) 
var userct = get_users_online(1);
MinAdd = Math.round( MinAdd + Aggr*userct );

var users = get_users_online(0);

// determine indices and number of selected users offline
var ay = [];
var Len = 0;
for( var z = 0 ; z < OnlineUsers.length ; z ++ )
{
if( 0 > users.search( OnlineUsers[z][0] ))
{
ay[Len] = z;
Len = Len + 1;
}
}

// randomize indices of selected users offline 
for( var z = 0 ; z < Len ; z ++ )
{
j = Math.floor(Math.random()*Len);
h = ay[z];
ay[z] = ay[j];
ay[j] = h;
}

// determine the number of selected users offline to add ( random +/- 1 )
MinAdd = MinAdd + Math.floor(Math.random()*3) -1;
if( Len < MinAdd ) { MinAdd = Len; }
if( MinAdd < 0 ) { MinAdd = 0; }
Len = MinAdd;

var TD = document.body.getElementsByTagName('td');

if( this.location.href.match(/\.com(\/(index\.cgi(#\w+|\?(action=home)?)?)?)?$/))
{
for( var t = TD.length-1 ; t > 0 ; t -- )
{
if( TD[t].vAlign == 'top' && TD[t].align == 'left' && TD[t].firstChild.firstChild && new RegExp('\\d+\\sMembers?').test(TD[t].firstChild.firstChild.data))
{
for( var z = 0 ; z < Len ; z ++ )
{
az = ay[z];
var A = document.createElement('a');
A.href = '/index.cgi?action=viewprofile&user='+OnlineUsers[az][0];
A.className = OnlineUsers[az][2];
A.appendChild( document.createTextNode( OnlineUsers[az][1] ));
if( 0 < ( userct + z ) ) {
TD[t].firstChild.appendChild( document.createTextNode(', ') );
}
TD[t].firstChild.appendChild( A );
}
var setReg = /(\d+) Member(s)?/i;
var toAdd = Len;
var cur = (TD[t].innerHTML.match(setReg)?RegExp.$1:0);
var n = toAdd+parseInt(cur);
TD[t].innerHTML = TD[t].innerHTML.replace(setReg,n+" Member"+(n==1?"":"s"));
break;
}
}
}

if( this.location.href.match(/on=(displ|search2|viewpr|pmv|(user)?rece|cal\w+iew)/))
{
for( var t = 0 ; t < TD.length ; t ++ )
{
if( TD[t].width == '20%' && TD[t].vAlign == 'top' && TD[t].className != 'catbg' && TD[t].getElementsByTagName('a') )
{
var Inp = TD[t].getElementsByTagName('a');
kill:
for( var z = 0 ; z < Inp.length ; z ++ )
{
for( var o = 0 ; o < Len ; o ++ )
{
az = ay[o];
if( new RegExp(OnlineUsers[az][0]).test(Inp[z].href) )
{
TD[t].innerHTML = TD[t].innerHTML.replace(/\sis\soffline/,' is <b>online</b>');
break;
break kill;
}
}
}
}
}
}

function get_users_online(zz) {
var users = "";
var userct = 0;
var td = document.getElementsByTagName('td'); 
if(location.href.match(/\.com\/?index.cgi\??(&?action=home)?(#\w+)?$/)) {
for(i=td.length-1; i>0; i--) {
if(td.item(i).vAlign == 'top' && td.item(i).align == 'left' && td.item(i).innerHTML.match(/\d+ Members?,/)) {
var a = td.item(i).getElementsByTagName('a');
for(n=0; n<a.length; n++) {
if(a.item(n).href.match(/user=/)) {
if(users != "") {
users += ", ";
} 
users += a.item(n).href.split(/user=/)[1];
userct = userct + 1;
}
}
break;
}
}
}
if( zz < 1) { return users; }
return userct;
}






