/****************************************
Auto Script Hosting Tool by Mwr247, for BigBoards
http://bigboardsresources.com/
****************************************/


/*
Whisper Code v2
Created by Zelnen
Updated by iFusion
*/

var whisper_zelnen = {
 init_post: function(){
var the_cell = document.getElementsByName('tagcount')[0].parentNode
if(the_cell.tagName.toLowerCase() != "td") return false;

var whisper_input = document.createElement('SPAN');
whisper_input.innerHTML = "<input class='codebuttons' name='whisper' onclick='whisper_zelnen.setup_whisp(); return false;' value='Whisper' type='submit' />&nbsp;";
the_cell.insertBefore(whisper_input,the_cell.getElementsByTagName('INPUT')[3]);
},
setup_whisp : function(){
  var uName = prompt("Please type in the member's name you would like to see the whisper.","")
document.forms['REPLIER'].Post.value += "[whisper=" + uName + "] [/whisper]"
  return false;
},
check_st : function(){
 var iDiv = document.getElementsByTagName('DiV');
 for(i=0;i<iDiv.length;i++){
  if(iDiv[i].className != 'postcolor' || iDiv[i].innerHTML.match(/\[whisper/i) == null) continue;

   var iUser = document.getElementById('userlinks').getElementsByTagName('A')[0].innerHTML;
   var myReg = new RegExp( "\\[whisper\\=(.*?)\\](.*)\\[\\/whisper\\]" , "i" );
var myTest = myReg.exec(iDiv[i].innerHTML);
   if(myTest[1] == iUser){
iDiv[i].innerHTML = iDiv[i].innerHTML.replace(/\[whisper=(.*?)\]/i,"<b>Whisper:</b>&nbsp;<i>").replace(/\[\/whisper\]/gi,"</i>")
   } else {
     iDiv[i].innerHTML = iDiv[i].innerHTML.replace(/\[whisper=(.*?)\](.*)\[\/whisper\]/i," ")
   }   }  }
}

if(location.href.match(/act=post\&code=/i) != null){
 whisper_zelnen.init_post();
} else if(location.href.match(/showtopic=\d/i) != null){
whisper_zelnen.check_st();
}